@kenyaemr/esm-patient-registration-app 8.1.1-pre.124 → 8.1.2-pre.152

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/.turbo/turbo-build.log +21 -23
  2. package/dist/108.js +1 -1
  3. package/dist/130.js +1 -1
  4. package/dist/130.js.map +1 -1
  5. package/dist/173.js +2 -0
  6. package/dist/{895.js.LICENSE.txt → 173.js.LICENSE.txt} +25 -0
  7. package/dist/173.js.map +1 -0
  8. package/dist/236.js +1 -0
  9. package/dist/240.js +1 -0
  10. package/dist/261.js +1 -0
  11. package/dist/271.js +1 -1
  12. package/dist/272.js +1 -0
  13. package/dist/319.js +1 -1
  14. package/dist/336.js +1 -0
  15. package/dist/371.js +1 -0
  16. package/dist/371.js.map +1 -0
  17. package/dist/378.js +1 -0
  18. package/dist/460.js +1 -1
  19. package/dist/501.js +1 -1
  20. package/dist/501.js.map +1 -1
  21. package/dist/539.js +1 -0
  22. package/dist/566.js +1 -0
  23. package/dist/574.js +1 -1
  24. package/dist/623.js +1 -0
  25. package/dist/623.js.map +1 -0
  26. package/dist/644.js +1 -1
  27. package/dist/652.js +1 -0
  28. package/dist/657.js +1 -0
  29. package/dist/657.js.map +1 -0
  30. package/dist/673.js +1 -0
  31. package/dist/705.js +1 -0
  32. package/dist/711.js +1 -0
  33. package/dist/727.js +1 -0
  34. package/dist/737.js +1 -0
  35. package/dist/744.js +1 -0
  36. package/dist/757.js +1 -1
  37. package/dist/759.js +1 -0
  38. package/dist/759.js.map +1 -0
  39. package/dist/76.js +1 -1
  40. package/dist/788.js +1 -1
  41. package/dist/807.js +1 -1
  42. package/dist/833.js +1 -1
  43. package/dist/899.js +1 -0
  44. package/dist/kenyaemr-esm-patient-registration-app.js +1 -1
  45. package/dist/kenyaemr-esm-patient-registration-app.js.buildmanifest.json +445 -93
  46. package/dist/kenyaemr-esm-patient-registration-app.js.map +1 -1
  47. package/dist/main.js +1 -1
  48. package/dist/main.js.LICENSE.txt +25 -0
  49. package/dist/main.js.map +1 -1
  50. package/dist/routes.json +1 -1
  51. package/package-lock.json +6400 -0
  52. package/package.json +4 -4
  53. package/src/client-registry/hie-client-registry/dependants/dependants.component.tsx +46 -0
  54. package/src/client-registry/hie-client-registry/hie-client-registry.component.tsx +38 -8
  55. package/src/client-registry/hie-client-registry/hie-resource.ts +126 -21
  56. package/src/client-registry/hie-client-registry/hie-types.ts +102 -0
  57. package/src/client-registry/hie-client-registry/modal/confirm-hie.modal.tsx +78 -62
  58. package/src/client-registry/hie-client-registry/modal/confirm-hie.scss +55 -3
  59. package/src/client-registry/hie-client-registry/modal/hie-otp-verification-form.component.tsx +88 -0
  60. package/src/client-registry/hie-client-registry/modal/hie-patient-detail-preview.component.tsx +77 -0
  61. package/src/client-registry/hie-client-registry/patient-info/patient-info.component.tsx +17 -0
  62. package/src/config-schema.ts +30 -2
  63. package/src/patient-registration/field/address/address-search.component.tsx +5 -2
  64. package/src/patient-registration/field/date-and-time-of-death/date-and-time-of-death.component.tsx +1 -1
  65. package/src/patient-registration/field/dob/dob.component.tsx +1 -1
  66. package/src/patient-registration/field/field.scss +4 -4
  67. package/src/patient-registration/field/gender/gender-field.component.tsx +6 -2
  68. package/src/patient-registration/field/id/identifier-selection-overlay.component.tsx +3 -3
  69. package/src/patient-registration/field/name/name-field.component.tsx +2 -2
  70. package/src/patient-registration/field/obs/obs-field.component.tsx +9 -5
  71. package/src/patient-registration/field/person-attributes/coded-person-attribute-field.component.tsx +4 -3
  72. package/src/patient-registration/field/person-attributes/coded-person-attribute-field.test.tsx +22 -11
  73. package/src/patient-registration/field/person-attributes/custom-person-attribute-field.component.tsx +76 -27
  74. package/src/patient-registration/field/person-attributes/location-person-attribute-field.component.tsx +1 -1
  75. package/src/patient-registration/field/person-attributes/person-attribute-field.test.tsx +12 -4
  76. package/src/patient-registration/field/person-attributes/useUpdateIdentifierRequirement.tsx +83 -0
  77. package/src/patient-registration/form-manager.test.ts +4 -1
  78. package/src/patient-registration/form-manager.ts +0 -1
  79. package/src/patient-registration/input/custom-input/autosuggest/autosuggest.test.tsx +52 -62
  80. package/src/patient-registration/mpi/mpi-patient.resource.ts +21 -0
  81. package/src/patient-registration/patient-registration-hooks.ts +90 -25
  82. package/src/patient-registration/patient-registration-utils.test.ts +33 -0
  83. package/src/patient-registration/patient-registration-utils.ts +63 -13
  84. package/src/patient-registration/patient-registration.component.tsx +17 -2
  85. package/src/patient-registration/patient-registration.test.tsx +442 -56
  86. package/src/patient-registration/section/demographics/demographics-section.component.tsx +3 -3
  87. package/src/patient-registration/section/patient-relationships/relationships-section.component.tsx +1 -1
  88. package/src/patient-registration/section/patient-relationships/relationships.resource.tsx +28 -28
  89. package/src/widgets/cancel-patient-edit.modal.tsx +2 -0
  90. package/src/widgets/cancel-patient-edit.scss +29 -0
  91. package/src/widgets/delete-identifier-confirmation.modal.tsx +2 -0
  92. package/src/widgets/delete-identifier-confirmation.scss +29 -0
  93. package/translations/am.json +1 -0
  94. package/translations/ar.json +6 -4
  95. package/translations/de.json +118 -0
  96. package/translations/en.json +17 -0
  97. package/translations/es.json +2 -0
  98. package/translations/fr.json +1 -0
  99. package/translations/he.json +1 -0
  100. package/translations/hi.json +118 -0
  101. package/translations/hi_IN.json +118 -0
  102. package/translations/id.json +118 -0
  103. package/translations/it.json +118 -0
  104. package/translations/km.json +1 -0
  105. package/translations/ne.json +118 -0
  106. package/translations/pt.json +118 -0
  107. package/translations/pt_BR.json +118 -0
  108. package/translations/qu.json +118 -0
  109. package/translations/si.json +118 -0
  110. package/translations/sw.json +118 -0
  111. package/translations/sw_KE.json +118 -0
  112. package/translations/tr.json +118 -0
  113. package/translations/tr_TR.json +118 -0
  114. package/translations/uk.json +118 -0
  115. package/translations/vi.json +118 -0
  116. package/translations/zh.json +3 -1
  117. package/translations/zh_CN.json +2 -0
  118. package/dist/10.js +0 -1
  119. package/dist/10.js.map +0 -1
  120. package/dist/250.js +0 -1
  121. package/dist/250.js.map +0 -1
  122. package/dist/662.js +0 -1
  123. package/dist/662.js.map +0 -1
  124. package/dist/753.js +0 -1
  125. package/dist/753.js.map +0 -1
  126. package/dist/895.js +0 -2
  127. package/dist/895.js.map +0 -1
@@ -0,0 +1,33 @@
1
+ import { filterOutUndefinedPatientIdentifiers } from './patient-registration-utils';
2
+
3
+ describe('filterOutUndefinedPatientIdentifiers', () => {
4
+ const getIdentifiers = (autoGeneration = true, manualEntryEnabled = false) => ({
5
+ OpenMRSId: {
6
+ autoGeneration: autoGeneration,
7
+ identifierName: 'OpenMRS ID',
8
+ identifierTypeUuid: '05a29f94-c0ed-11e2-94be-8c13b969e334',
9
+ identifierValue: undefined,
10
+ initialValue: '100GEJ',
11
+ preferred: true,
12
+ required: true,
13
+ selectedSource: {
14
+ uuid: '01af8526-cea4-4175-aa90-340acb411771',
15
+ name: 'Generator for OpenMRS ID',
16
+ autoGenerationOption: {
17
+ manualEntryEnabled: manualEntryEnabled,
18
+ automaticGenerationEnabled: autoGeneration,
19
+ },
20
+ },
21
+ },
22
+ });
23
+
24
+ it('should fitler out undefined identifiers', () => {
25
+ const filteredIdentifiers = filterOutUndefinedPatientIdentifiers(getIdentifiers());
26
+ expect(filteredIdentifiers.OpenMRSId).not.toBeDefined();
27
+ });
28
+
29
+ it('should retain auto-generated identifiers with manual entry', () => {
30
+ const filteredIdentifiers = filterOutUndefinedPatientIdentifiers(getIdentifiers(true, true));
31
+ expect(filteredIdentifiers.OpenMRSId).toBeDefined();
32
+ });
33
+ });
@@ -1,6 +1,6 @@
1
1
  import * as Yup from 'yup';
2
2
  import camelCase from 'lodash-es/camelCase';
3
- import { parseDate } from '@openmrs/esm-framework';
3
+ import { openmrsFetch, restBaseUrl, parseDate } from '@openmrs/esm-framework';
4
4
  import {
5
5
  type AddressValidationSchemaType,
6
6
  type Encounter,
@@ -110,15 +110,14 @@ export function getFormValuesFromFhirPatient(patient: fhir.Patient) {
110
110
  const result = {} as FormValues;
111
111
  const patientName = patient.name[0];
112
112
  const additionalPatientName = patient.name[1];
113
-
114
113
  result.patientUuid = patient.id;
115
- result.givenName = patientName?.given[0];
116
- result.middleName = patientName?.given[1];
114
+ result.givenName = patientName?.given?.[0];
115
+ result.middleName = patientName?.given?.[1];
117
116
  result.familyName = patientName?.family;
118
117
  result.addNameInLocalLanguage = !!additionalPatientName ? true : undefined;
119
- result.additionalGivenName = additionalPatientName?.given[0];
120
- result.additionalMiddleName = additionalPatientName?.given[1];
121
- result.additionalFamilyName = additionalPatientName?.family;
118
+ result.additionalGivenName = additionalPatientName?.given?.[0] ?? undefined;
119
+ result.additionalMiddleName = additionalPatientName?.given?.[1] ?? undefined;
120
+ result.additionalFamilyName = additionalPatientName?.family ?? undefined;
122
121
 
123
122
  result.gender = patient.gender;
124
123
  result.birthdate = patient.birthDate ? parseDate(patient.birthDate) : undefined;
@@ -192,18 +191,69 @@ export function getPatientIdentifiersFromFhirPatient(patient: fhir.Patient): Arr
192
191
  });
193
192
  }
194
193
 
195
- export function getPhonePersonAttributeValueFromFhirPatient(patient: fhir.Patient) {
194
+ export async function getIdentifierFieldValuesFromFhirPatient(
195
+ patient: fhir.Patient,
196
+ identifierConfig,
197
+ ): Promise<{ [identifierFieldName: string]: PatientIdentifierValue }> {
198
+ const identifiers: FormValues['identifiers'] = {};
199
+ const promises: Promise<void>[] = [];
200
+
201
+ for (const identifier of patient.identifier) {
202
+ for (const config of identifierConfig) {
203
+ if (config.fhirIdentifierSystem !== identifier.system) {
204
+ continue;
205
+ }
206
+
207
+ const url = `${restBaseUrl}/patientidentifiertype/${config.openmrsIdentifierTypeUuid}`;
208
+
209
+ promises.push(
210
+ openmrsFetch(url)
211
+ .then((response) => {
212
+ if (!response.data?.name) {
213
+ return;
214
+ }
215
+ identifiers[response.data.name] = {
216
+ identifierUuid: null,
217
+ preferred: false,
218
+ initialValue: identifier.value,
219
+ identifierValue: identifier.value,
220
+ identifierTypeUuid: config.identifierTypeUuid,
221
+ identifierName: response.data.name,
222
+ required: false,
223
+ selectedSource: null,
224
+ autoGeneration: false,
225
+ };
226
+ })
227
+ .catch((error) => {
228
+ console.error(`Error fetching identifier type for ${config.identifierTypeUuid}:`, error);
229
+ }),
230
+ );
231
+ }
232
+ }
233
+ await Promise.all(promises);
234
+ return identifiers;
235
+ }
236
+
237
+ export function getPhonePersonAttributeValueFromFhirPatient(patient: fhir.Patient, phoneUuid) {
196
238
  const result = {};
197
- if (patient.telecom) {
198
- result['phone'] = patient.telecom[0].value;
239
+
240
+ if (patient.telecom && Array.isArray(patient.telecom)) {
241
+ const phoneEntry = patient.telecom.find((entry) => entry.system === 'phone');
242
+ if (phoneEntry) {
243
+ result[phoneUuid] = phoneEntry.value;
244
+ }
199
245
  }
246
+
200
247
  return result;
201
248
  }
202
249
 
203
- export const filterOutUndefinedPatientIdentifiers = (patientIdentifiers) =>
250
+ type IdentifierMap = { [identifierFieldName: string]: PatientIdentifierValue };
251
+ export const filterOutUndefinedPatientIdentifiers = (patientIdentifiers: IdentifierMap): IdentifierMap =>
204
252
  Object.fromEntries(
205
- Object.entries<PatientIdentifierValue>(patientIdentifiers).filter(
206
- ([key, value]) => value.identifierValue !== undefined,
253
+ Object.entries(patientIdentifiers).filter(
254
+ ([key, value]) =>
255
+ (value.autoGeneration && value.selectedSource.autoGenerationOption.manualEntryEnabled) ||
256
+ value.identifierValue !== undefined,
207
257
  ),
208
258
  );
209
259
 
@@ -9,6 +9,7 @@ import {
9
9
  createErrorHandler,
10
10
  interpolateUrl,
11
11
  showSnackbar,
12
+ useAppContext,
12
13
  useConfig,
13
14
  usePatient,
14
15
  usePatientPhoto,
@@ -20,7 +21,12 @@ import { PatientRegistrationContext } from './patient-registration-context';
20
21
  import { type SavePatientForm, SavePatientTransactionManager } from './form-manager';
21
22
  import { DummyDataInput } from './input/dummy-data/dummy-data-input.component';
22
23
  import { cancelRegistration, filterOutUndefinedPatientIdentifiers, scrollIntoView } from './patient-registration-utils';
23
- import { useInitialAddressFieldValues, useInitialFormValues, usePatientUuidMap } from './patient-registration-hooks';
24
+ import {
25
+ useInitialAddressFieldValues,
26
+ useMpiInitialFormValues,
27
+ useInitialFormValuesLocal,
28
+ usePatientUuidMap,
29
+ } from './patient-registration-hooks';
24
30
  import { ResourcesContext } from '../offline.resources';
25
31
  import { builtInSections, type RegistrationConfig, type SectionDefinition } from '../config-schema';
26
32
  import { SectionWrapper } from './section/section-wrapper.component';
@@ -44,10 +50,12 @@ export const PatientRegistration: React.FC<PatientRegistrationProps> = ({ savePa
44
50
  const config = useConfig() as RegistrationConfig;
45
51
  const [target, setTarget] = useState<undefined | string>();
46
52
  const { patientUuid: uuidOfPatientToEdit } = useParams();
53
+ const sourcePatientId = new URLSearchParams(search).get('sourceRecord');
47
54
  const { isLoading: isLoadingPatientToEdit, patient: patientToEdit } = usePatient(uuidOfPatientToEdit);
48
55
  const { t } = useTranslation();
49
56
  const [capturePhotoProps, setCapturePhotoProps] = useState<CapturePhotoProps | null>(null);
50
- const [initialFormValues, setInitialFormValues] = useInitialFormValues(uuidOfPatientToEdit);
57
+ const [initialFormValues, setInitialFormValues] = useInitialFormValuesLocal(uuidOfPatientToEdit);
58
+ const [initialMPIFormValues, setInitialMPIFormValues] = useMpiInitialFormValues(sourcePatientId);
51
59
  const [initialAddressFieldValues] = useInitialAddressFieldValues(uuidOfPatientToEdit);
52
60
  const [patientUuidMap] = usePatientUuidMap(uuidOfPatientToEdit);
53
61
  const location = currentSession?.sessionLocation?.uuid;
@@ -61,6 +69,13 @@ export const PatientRegistration: React.FC<PatientRegistrationProps> = ({ savePa
61
69
  inEditMode ? initialFormValues.identifiers['nationalUniquePatientIdentifier']?.identifierValue : false,
62
70
  );
63
71
 
72
+ useEffect(() => {
73
+ if (initialMPIFormValues) {
74
+ setInitialFormValues(initialMPIFormValues);
75
+ }
76
+ // eslint-disable-next-line react-hooks/exhaustive-deps
77
+ }, [initialMPIFormValues, setInitialMPIFormValues]);
78
+
64
79
  useEffect(() => {
65
80
  exportedInitialFormValuesForTesting = initialFormValues;
66
81
  }, [initialFormValues]);