@ampath/esm-patient-registration-app 9.2.0-next.15 → 9.2.0-next.17
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.
- package/dist/4300.js +1 -1
- package/dist/4395.js +1 -0
- package/dist/4395.js.map +1 -0
- package/dist/5239.js +1 -1
- package/dist/5239.js.LICENSE.txt +10 -0
- package/dist/5239.js.map +1 -1
- package/dist/6276.js +1 -1
- package/dist/6687.js +1 -0
- package/dist/6687.js.map +1 -0
- package/dist/6996.js +1 -0
- package/dist/6996.js.map +1 -0
- package/dist/7125.js +2 -0
- package/dist/7125.js.map +1 -0
- package/dist/7821.js +1 -0
- package/dist/7821.js.map +1 -0
- package/dist/8414.js +1 -0
- package/dist/8414.js.map +1 -0
- package/dist/8434.js +1 -1
- package/dist/8882.js +1 -0
- package/dist/8882.js.map +1 -0
- package/dist/9898.js +1 -0
- package/dist/9898.js.map +1 -0
- package/dist/9933.js +2 -0
- package/dist/{2615.js.LICENSE.txt → 9933.js.LICENSE.txt} +9 -0
- package/dist/9933.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-patient-registration-app.js +1 -1
- package/dist/openmrs-esm-patient-registration-app.js.buildmanifest.json +226 -150
- package/dist/openmrs-esm-patient-registration-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/index.ts +9 -0
- package/src/patient-registration/client-registry/client-registry.resource.ts +1 -1
- package/src/patient-registration/client-registry-search/client-registry-dependant-details.component.tsx +237 -0
- package/src/patient-registration/client-registry-search/client-registry-details.component.tsx +111 -0
- package/src/patient-registration/client-registry-search/client-registry-patient-details.component.tsx +234 -0
- package/src/patient-registration/client-registry-search/client-registry-search.component.tsx +234 -0
- package/src/patient-registration/client-registry-search/client-registry-verification-tag.component.tsx +78 -0
- package/src/patient-registration/client-registry-search/client-registry.resource.ts +135 -0
- package/src/patient-registration/client-registry-search/client-registry.types.ts +243 -0
- package/src/patient-registration/client-registry-search/map-client-registry-to-form-utils.ts +590 -0
- package/src/patient-registration/field/field.component.tsx +3 -0
- package/src/patient-registration/field/id/id-field.component.tsx +1 -1
- package/src/patient-registration/field/id/id-field.test.tsx +1 -1
- package/src/patient-registration/form-manager.test.ts +1 -0
- package/src/patient-registration/patient-registration.component.tsx +0 -1
- package/src/patient-registration/patient-registration.resource.ts +1 -1
- package/src/patient-registration/patient-registration.scss +4 -0
- package/src/routes.json +12 -1
- package/src/widgets/client-registry-verification.modal.tsx +27 -0
- package/translations/en.json +4 -0
- package/dist/2450.js +0 -1
- package/dist/2450.js.map +0 -1
- package/dist/2615.js +0 -2
- package/dist/2615.js.map +0 -1
- package/dist/320.js +0 -2
- package/dist/320.js.LICENSE.txt +0 -8
- package/dist/320.js.map +0 -1
- package/dist/3474.js +0 -2
- package/dist/3474.js.LICENSE.txt +0 -8
- package/dist/3474.js.map +0 -1
- package/dist/7071.js +0 -1
- package/dist/7071.js.map +0 -1
- package/dist/729.js +0 -2
- package/dist/729.js.map +0 -1
- /package/dist/{729.js.LICENSE.txt → 7125.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import {
|
|
3
|
+
type AmrsPerson,
|
|
4
|
+
type ClientRegistryBody,
|
|
5
|
+
type CustomRelationship,
|
|
6
|
+
HieAttributeType,
|
|
7
|
+
HieIdentificationType,
|
|
8
|
+
IdentifierTypesUuids,
|
|
9
|
+
PersonAttributeTypeUuids,
|
|
10
|
+
RelationshipTypeUuids,
|
|
11
|
+
} from './client-registry.types';
|
|
12
|
+
import { string } from 'yup/lib/locale';
|
|
13
|
+
import { forEach } from 'lodash-es';
|
|
14
|
+
|
|
15
|
+
interface PatientData {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface Dependant {
|
|
20
|
+
relationship: string;
|
|
21
|
+
result: Array<{
|
|
22
|
+
first_name: string;
|
|
23
|
+
middle_name: string;
|
|
24
|
+
last_name: string;
|
|
25
|
+
gender: string;
|
|
26
|
+
date_of_birth: string;
|
|
27
|
+
identification_number: string;
|
|
28
|
+
identification_type: string;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface AlternativeContact {
|
|
33
|
+
contact_type: string;
|
|
34
|
+
contact_id: string;
|
|
35
|
+
contact_name: string;
|
|
36
|
+
relationship: string;
|
|
37
|
+
remarks: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const fieldMapping: Record<string, string | { path: string; transform?: (value: any) => any }> = {
|
|
41
|
+
givenName: 'first_name',
|
|
42
|
+
familyName: 'last_name',
|
|
43
|
+
middleName: 'middle_name',
|
|
44
|
+
birthdate: 'date_of_birth',
|
|
45
|
+
phone: 'phone',
|
|
46
|
+
email: 'email',
|
|
47
|
+
identificationNumber: 'identification_number',
|
|
48
|
+
identificationType: 'identification_type',
|
|
49
|
+
county: 'county',
|
|
50
|
+
subCounty: 'sub_county',
|
|
51
|
+
ward: 'ward',
|
|
52
|
+
village: 'village_estate',
|
|
53
|
+
postalAddress: 'postal_address',
|
|
54
|
+
address: 'address',
|
|
55
|
+
gender: {
|
|
56
|
+
path: 'gender',
|
|
57
|
+
transform: (value) => {
|
|
58
|
+
if (!value) return '';
|
|
59
|
+
const genderMap: Record<string, string> = {
|
|
60
|
+
male: 'male',
|
|
61
|
+
m: 'male',
|
|
62
|
+
female: 'female',
|
|
63
|
+
f: 'female',
|
|
64
|
+
other: 'other',
|
|
65
|
+
unknown: 'unknown',
|
|
66
|
+
};
|
|
67
|
+
return genderMap[value.toLowerCase()] || value.toLowerCase();
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
'academicOccupation.highestLevelEducation': {
|
|
71
|
+
path: 'employment_type',
|
|
72
|
+
transform: (value) => value || '',
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
// Occupation field - also using employment_type (you might want to separate these)
|
|
76
|
+
'academicOccupation.occupation': {
|
|
77
|
+
path: 'employment_type',
|
|
78
|
+
transform: (value) => value || '',
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
// Civil status/marital status
|
|
82
|
+
civilStatus: {
|
|
83
|
+
path: 'civil_status',
|
|
84
|
+
transform: (value) => value || '',
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
function mapNextOfKin(patient: PatientData, setFieldValue: (field: string, value: any) => void) {
|
|
89
|
+
const alternativeContacts: AlternativeContact[] = patient.alternative_contacts || [];
|
|
90
|
+
|
|
91
|
+
const spouseContact = alternativeContacts.find((contact) => contact.relationship.toLowerCase() === 'spouse');
|
|
92
|
+
|
|
93
|
+
const nextOfKinContact =
|
|
94
|
+
spouseContact ||
|
|
95
|
+
alternativeContacts.find(
|
|
96
|
+
(contact) =>
|
|
97
|
+
contact.remarks.toLowerCase().includes('next of kin') ||
|
|
98
|
+
contact.relationship.toLowerCase().includes('next of kin'),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
if (nextOfKinContact) {
|
|
102
|
+
setFieldValue('nextOfKin.nextOfKinName', nextOfKinContact.contact_name);
|
|
103
|
+
setFieldValue('nextOfKin.nextOfKinRelationship', nextOfKinContact.relationship);
|
|
104
|
+
setFieldValue('nextOfKin.nextOfKinPhoneNumber', nextOfKinContact.contact_id);
|
|
105
|
+
setFieldValue('nextOfKin.nextOfKinResidence', patient.village_estate || patient.county || '');
|
|
106
|
+
} else {
|
|
107
|
+
setFieldValue('nextOfKin.nextOfKinName', '');
|
|
108
|
+
setFieldValue('nextOfKin.nextOfKinRelationship', '');
|
|
109
|
+
setFieldValue('nextOfKin.nextOfKinPhoneNumber', '');
|
|
110
|
+
setFieldValue('nextOfKin.nextOfKinResidence', '');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function mapRelationships(patient: PatientData, setFieldValue: (field: string, value: any) => void) {
|
|
115
|
+
const dependants: Dependant[] = patient.dependants || [];
|
|
116
|
+
const relationships: any[] = [];
|
|
117
|
+
|
|
118
|
+
dependants.forEach((dependant, index) => {
|
|
119
|
+
if (dependant.result && dependant.result.length > 0) {
|
|
120
|
+
const person = dependant.result[0];
|
|
121
|
+
relationships.push({
|
|
122
|
+
relationshipType: dependant.relationship, // "Child"
|
|
123
|
+
relatedPersonName: `${person.first_name} ${person.middle_name || ''} ${person.last_name}`.trim(),
|
|
124
|
+
relatedPersonUuid: '',
|
|
125
|
+
relationshipTypeUuid: '',
|
|
126
|
+
relativeName: `${person.first_name} ${person.middle_name || ''} ${person.last_name}`.trim(),
|
|
127
|
+
relativePhone: '',
|
|
128
|
+
relationship: dependant.relationship,
|
|
129
|
+
birthdate: person.date_of_birth,
|
|
130
|
+
gender: person.gender,
|
|
131
|
+
identifier: person.identification_number,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
setFieldValue('relationships', relationships);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function mapAddresses(patient: PatientData, setFieldValue: (field: string, value: any) => void) {
|
|
140
|
+
// county
|
|
141
|
+
if (patient['county']) {
|
|
142
|
+
setFieldValue('address.countyDistrict', patient['county']);
|
|
143
|
+
}
|
|
144
|
+
//subcounty
|
|
145
|
+
if (patient['sub_county']) {
|
|
146
|
+
setFieldValue('address.stateProvince', patient['sub_county']);
|
|
147
|
+
}
|
|
148
|
+
if (patient['ward']) {
|
|
149
|
+
//ward
|
|
150
|
+
setFieldValue('address.address4', patient['ward']);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function mapContactDetails(patient: PatientData, setFieldValue: (field: string, value: any) => void) {
|
|
155
|
+
if (patient['email']) {
|
|
156
|
+
setFieldValue('attributes.2f65dbcb-3e58-45a3-8be7-fd1dc9aa0faa', patient['email']);
|
|
157
|
+
}
|
|
158
|
+
if (patient['phone']) {
|
|
159
|
+
setFieldValue('attributes.72a759a8-1359-11df-a1f1-0026b9348838', patient['phone']);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function applyClientRegistryMapping(patient: PatientData, setFieldValue: (field: string, value: any) => void) {
|
|
164
|
+
Object.entries(fieldMapping).forEach(([formField, mapping]) => {
|
|
165
|
+
let crField: string;
|
|
166
|
+
let transformFn: (value: any) => any = (v) => v;
|
|
167
|
+
|
|
168
|
+
if (typeof mapping === 'string') {
|
|
169
|
+
crField = mapping;
|
|
170
|
+
} else {
|
|
171
|
+
crField = mapping.path;
|
|
172
|
+
transformFn = mapping.transform || transformFn;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (crField && patient[crField] !== undefined && patient[crField] !== null && patient[crField] !== '') {
|
|
176
|
+
const value = transformFn(patient[crField]);
|
|
177
|
+
setFieldValue(formField, value);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
mapNextOfKin(patient, setFieldValue);
|
|
182
|
+
mapRelationships(patient, setFieldValue);
|
|
183
|
+
mapAddresses(patient, setFieldValue);
|
|
184
|
+
mapContactDetails(patient, setFieldValue);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export const nameFields = ['givenName', 'middleName', 'familyName'];
|
|
188
|
+
|
|
189
|
+
export const addressFields = [
|
|
190
|
+
'country',
|
|
191
|
+
'countyDistrict',
|
|
192
|
+
'address2',
|
|
193
|
+
'address7',
|
|
194
|
+
'cityVillage',
|
|
195
|
+
'longitude',
|
|
196
|
+
'latitude',
|
|
197
|
+
];
|
|
198
|
+
|
|
199
|
+
export const personSyncFields = [...nameFields, 'gender', 'birthdate', ...addressFields];
|
|
200
|
+
|
|
201
|
+
export const identifiersSyncFields = () => Object.keys(HieIdentificationType);
|
|
202
|
+
|
|
203
|
+
export const attributesSyncFields = () => Object.keys(HieAttributeType);
|
|
204
|
+
|
|
205
|
+
export const getIdentifierUuid = (identifier: string) => {
|
|
206
|
+
let val = '';
|
|
207
|
+
switch (identifier) {
|
|
208
|
+
case HieIdentificationType.AlienID:
|
|
209
|
+
val = IdentifierTypesUuids.ALIEN_ID_UUID;
|
|
210
|
+
break;
|
|
211
|
+
case HieIdentificationType.HouseholdNumber:
|
|
212
|
+
val = IdentifierTypesUuids.HOUSE_HOLD_NUMBER_UUID;
|
|
213
|
+
break;
|
|
214
|
+
case HieIdentificationType.MandateNumber:
|
|
215
|
+
val = IdentifierTypesUuids.MANDATE_NUMBER_UUID;
|
|
216
|
+
break;
|
|
217
|
+
case HieIdentificationType.Cr:
|
|
218
|
+
val = IdentifierTypesUuids.CLIENT_REGISTRY_NO_UUID;
|
|
219
|
+
break;
|
|
220
|
+
case HieIdentificationType.NationalID:
|
|
221
|
+
val = IdentifierTypesUuids.NATIONAL_ID_UUID;
|
|
222
|
+
break;
|
|
223
|
+
case HieIdentificationType.RefugeeID:
|
|
224
|
+
val = IdentifierTypesUuids.REFUGEE_ID_UUID;
|
|
225
|
+
break;
|
|
226
|
+
case HieIdentificationType.SHANumber:
|
|
227
|
+
val = IdentifierTypesUuids.SHA_UUID;
|
|
228
|
+
break;
|
|
229
|
+
case HieIdentificationType.TemporaryDependantID:
|
|
230
|
+
val = IdentifierTypesUuids.TEMPORARY_DEPENDANT_ID_UUID;
|
|
231
|
+
break;
|
|
232
|
+
default:
|
|
233
|
+
val = '';
|
|
234
|
+
}
|
|
235
|
+
return val;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export const getAttributeUuid = (attribute: string) => {
|
|
239
|
+
let val = '';
|
|
240
|
+
switch (attribute) {
|
|
241
|
+
case HieAttributeType.Citizenship:
|
|
242
|
+
val = PersonAttributeTypeUuids.CITIZENSHIP_UUID;
|
|
243
|
+
break;
|
|
244
|
+
case HieAttributeType.CivilStatus:
|
|
245
|
+
val = PersonAttributeTypeUuids.CIVIL_STATUS_UUID;
|
|
246
|
+
break;
|
|
247
|
+
case HieAttributeType.Email:
|
|
248
|
+
val = PersonAttributeTypeUuids.CONTACT_EMAIL_ADDRESS_UUID;
|
|
249
|
+
break;
|
|
250
|
+
case HieAttributeType.KRAPin:
|
|
251
|
+
val = PersonAttributeTypeUuids.KRA_PIN_UUID;
|
|
252
|
+
break;
|
|
253
|
+
case HieAttributeType.Phone:
|
|
254
|
+
val = PersonAttributeTypeUuids.CONTACT_PHONE_NUMBER_UUID;
|
|
255
|
+
break;
|
|
256
|
+
case HieAttributeType.PlaceOfBirth:
|
|
257
|
+
val = PersonAttributeTypeUuids.PLACE_OF_BIRTH_UUID;
|
|
258
|
+
break;
|
|
259
|
+
case HieAttributeType.Cr:
|
|
260
|
+
val = PersonAttributeTypeUuids.CLIENT_REGISTRY_ID_UUID;
|
|
261
|
+
break;
|
|
262
|
+
default:
|
|
263
|
+
val = '';
|
|
264
|
+
}
|
|
265
|
+
return val;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
export const getAmrsRelationshipTypeUuid = (relationshipType: string) => {
|
|
269
|
+
let relationShipTypeUuid = '';
|
|
270
|
+
switch (relationshipType) {
|
|
271
|
+
case 'Spouse':
|
|
272
|
+
relationShipTypeUuid = RelationshipTypeUuids.SPOUSE_UUID;
|
|
273
|
+
break;
|
|
274
|
+
case 'Child':
|
|
275
|
+
relationShipTypeUuid = RelationshipTypeUuids.PARENT_CHILD_UUID;
|
|
276
|
+
break;
|
|
277
|
+
default:
|
|
278
|
+
relationShipTypeUuid = RelationshipTypeUuids.OTHER_NON_CODED_UUID;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return relationShipTypeUuid;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
export const patientObjFields = [...personSyncFields, ...identifiersSyncFields()];
|
|
285
|
+
|
|
286
|
+
const sanitizeValue = (value: unknown) => {
|
|
287
|
+
if (value === null || value === undefined) {
|
|
288
|
+
return '';
|
|
289
|
+
}
|
|
290
|
+
return value;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export const mapFieldValue = (field: string, hieData: ClientRegistryBody, amrsPerson: AmrsPerson): Array<string> => {
|
|
294
|
+
let arr = [];
|
|
295
|
+
switch (field) {
|
|
296
|
+
case 'givenName':
|
|
297
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredName?.givenName), sanitizeValue(hieData?.first_name)];
|
|
298
|
+
break;
|
|
299
|
+
case 'middleName':
|
|
300
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredName?.middleName), sanitizeValue(hieData?.middle_name)];
|
|
301
|
+
break;
|
|
302
|
+
case 'familyName':
|
|
303
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredName?.familyName), sanitizeValue(hieData?.last_name)];
|
|
304
|
+
break;
|
|
305
|
+
case 'gender':
|
|
306
|
+
arr = [sanitizeValue(amrsPerson?.person?.gender), sanitizeValue(hieData?.gender)];
|
|
307
|
+
break;
|
|
308
|
+
case 'birthdate':
|
|
309
|
+
arr = [sanitizeValue(amrsPerson?.person?.birthdate), sanitizeValue(hieData?.date_of_birth)];
|
|
310
|
+
break;
|
|
311
|
+
case 'country':
|
|
312
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredAddress?.country), sanitizeValue(hieData?.country)];
|
|
313
|
+
break;
|
|
314
|
+
case 'countyDistrict':
|
|
315
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredAddress?.countyDistrict), sanitizeValue(hieData?.county)];
|
|
316
|
+
break;
|
|
317
|
+
case 'address2':
|
|
318
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredAddress?.address2), sanitizeValue(hieData?.sub_county)];
|
|
319
|
+
break;
|
|
320
|
+
case 'address7':
|
|
321
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredAddress?.address7), sanitizeValue(hieData?.ward)];
|
|
322
|
+
break;
|
|
323
|
+
case 'cityVillage':
|
|
324
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredAddress?.cityVillage), sanitizeValue(hieData?.village_estate)];
|
|
325
|
+
break;
|
|
326
|
+
case 'longitude':
|
|
327
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredAddress?.longitude), sanitizeValue(hieData?.longitude)];
|
|
328
|
+
break;
|
|
329
|
+
case 'latitude':
|
|
330
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredAddress?.latitude), sanitizeValue(hieData?.latitude)];
|
|
331
|
+
break;
|
|
332
|
+
case 'NationalID':
|
|
333
|
+
arr = [
|
|
334
|
+
sanitizeValue(
|
|
335
|
+
amrsPerson?.person?.identifiers?.find(
|
|
336
|
+
(v) => v.identifierType.uuid === getIdentifierUuid(HieIdentificationType.NationalID),
|
|
337
|
+
)?.identifier,
|
|
338
|
+
),
|
|
339
|
+
sanitizeValue(
|
|
340
|
+
hieData?.other_identifications.find((v) => v.identification_type === HieIdentificationType.NationalID)
|
|
341
|
+
?.identification_number,
|
|
342
|
+
),
|
|
343
|
+
];
|
|
344
|
+
break;
|
|
345
|
+
case 'SHANumber':
|
|
346
|
+
arr = [
|
|
347
|
+
sanitizeValue(
|
|
348
|
+
amrsPerson?.person?.identifiers?.find(
|
|
349
|
+
(v) => v.identifierType.uuid === getIdentifierUuid(HieIdentificationType.SHANumber),
|
|
350
|
+
)?.identifier,
|
|
351
|
+
),
|
|
352
|
+
sanitizeValue(
|
|
353
|
+
hieData?.other_identifications.find((v) => v.identification_type === HieIdentificationType.SHANumber)
|
|
354
|
+
?.identification_number,
|
|
355
|
+
),
|
|
356
|
+
];
|
|
357
|
+
break;
|
|
358
|
+
case 'HouseholdNumber':
|
|
359
|
+
arr = [
|
|
360
|
+
sanitizeValue(
|
|
361
|
+
amrsPerson?.person?.identifiers?.find(
|
|
362
|
+
(v) => v.identifierType.uuid === getIdentifierUuid(HieIdentificationType.HouseholdNumber),
|
|
363
|
+
)?.identifier,
|
|
364
|
+
),
|
|
365
|
+
sanitizeValue(
|
|
366
|
+
hieData?.other_identifications?.find((v) => v.identification_type === HieIdentificationType.HouseholdNumber)
|
|
367
|
+
?.identification_number,
|
|
368
|
+
),
|
|
369
|
+
];
|
|
370
|
+
break;
|
|
371
|
+
case 'RefugeeID':
|
|
372
|
+
arr = [
|
|
373
|
+
sanitizeValue(
|
|
374
|
+
amrsPerson?.person?.identifiers?.find(
|
|
375
|
+
(v) => v.identifierType.uuid === getIdentifierUuid(HieIdentificationType.RefugeeID),
|
|
376
|
+
)?.identifier,
|
|
377
|
+
),
|
|
378
|
+
sanitizeValue(
|
|
379
|
+
hieData?.other_identifications.find((v) => v.identification_type === HieIdentificationType.RefugeeID)
|
|
380
|
+
?.identification_number,
|
|
381
|
+
),
|
|
382
|
+
];
|
|
383
|
+
break;
|
|
384
|
+
case 'AlienID':
|
|
385
|
+
arr = [
|
|
386
|
+
sanitizeValue(
|
|
387
|
+
amrsPerson?.person?.identifiers?.find(
|
|
388
|
+
(v) => v.identifierType.uuid === getIdentifierUuid(HieIdentificationType.AlienID),
|
|
389
|
+
)?.identifier,
|
|
390
|
+
),
|
|
391
|
+
sanitizeValue(
|
|
392
|
+
hieData?.other_identifications.find((v) => v.identification_type === HieIdentificationType.AlienID)
|
|
393
|
+
?.identification_number,
|
|
394
|
+
),
|
|
395
|
+
];
|
|
396
|
+
break;
|
|
397
|
+
case 'MandateNumber':
|
|
398
|
+
arr = [
|
|
399
|
+
sanitizeValue(
|
|
400
|
+
amrsPerson?.person?.identifiers?.find(
|
|
401
|
+
(v) => v.identifierType.uuid === getIdentifierUuid(HieIdentificationType.MandateNumber),
|
|
402
|
+
)?.identifier,
|
|
403
|
+
),
|
|
404
|
+
sanitizeValue(
|
|
405
|
+
hieData?.other_identifications.find((v) => v.identification_type === HieIdentificationType.MandateNumber)
|
|
406
|
+
?.identification_number,
|
|
407
|
+
),
|
|
408
|
+
];
|
|
409
|
+
break;
|
|
410
|
+
case 'Cr':
|
|
411
|
+
arr = [
|
|
412
|
+
sanitizeValue(
|
|
413
|
+
amrsPerson?.person?.identifiers?.find(
|
|
414
|
+
(v) => v.identifierType.uuid === getIdentifierUuid(HieIdentificationType.Cr),
|
|
415
|
+
)?.identifier,
|
|
416
|
+
),
|
|
417
|
+
sanitizeValue(
|
|
418
|
+
hieData?.other_identifications.find((v) => v.identification_type === HieIdentificationType.Cr)
|
|
419
|
+
?.identification_number,
|
|
420
|
+
),
|
|
421
|
+
];
|
|
422
|
+
break;
|
|
423
|
+
case 'TemporaryDependantID':
|
|
424
|
+
arr = [
|
|
425
|
+
sanitizeValue(
|
|
426
|
+
amrsPerson?.person?.identifiers?.find(
|
|
427
|
+
(v) => v.identifierType.uuid === getIdentifierUuid(HieIdentificationType.TemporaryDependantID),
|
|
428
|
+
)?.identifier,
|
|
429
|
+
),
|
|
430
|
+
sanitizeValue(
|
|
431
|
+
hieData?.other_identifications.find(
|
|
432
|
+
(v) => v.identification_type === HieIdentificationType.TemporaryDependantID,
|
|
433
|
+
)?.identification_number,
|
|
434
|
+
),
|
|
435
|
+
];
|
|
436
|
+
break;
|
|
437
|
+
case 'PlaceOfBirth':
|
|
438
|
+
arr = [
|
|
439
|
+
sanitizeValue(
|
|
440
|
+
amrsPerson?.person?.attributes.find(
|
|
441
|
+
(v) => v.attributeType.uuid === getAttributeUuid(HieAttributeType.PlaceOfBirth),
|
|
442
|
+
)?.value,
|
|
443
|
+
),
|
|
444
|
+
sanitizeValue(hieData?.place_of_birth),
|
|
445
|
+
];
|
|
446
|
+
break;
|
|
447
|
+
case 'CivilStatus':
|
|
448
|
+
arr = [
|
|
449
|
+
sanitizeValue(
|
|
450
|
+
amrsPerson?.person?.attributes.find(
|
|
451
|
+
(v) => v.attributeType.uuid === getAttributeUuid(HieAttributeType.CivilStatus),
|
|
452
|
+
)?.value,
|
|
453
|
+
),
|
|
454
|
+
sanitizeValue(hieData?.civil_status),
|
|
455
|
+
];
|
|
456
|
+
break;
|
|
457
|
+
case 'Email':
|
|
458
|
+
arr = [
|
|
459
|
+
sanitizeValue(
|
|
460
|
+
amrsPerson?.person?.attributes.find((v) => v.attributeType.uuid === getAttributeUuid(HieAttributeType.Email))
|
|
461
|
+
?.value,
|
|
462
|
+
),
|
|
463
|
+
sanitizeValue(hieData?.email),
|
|
464
|
+
];
|
|
465
|
+
break;
|
|
466
|
+
case 'Phone':
|
|
467
|
+
arr = [
|
|
468
|
+
sanitizeValue(
|
|
469
|
+
amrsPerson?.person?.attributes.find((v) => v.attributeType.uuid === getAttributeUuid(HieAttributeType.Phone))
|
|
470
|
+
?.value,
|
|
471
|
+
),
|
|
472
|
+
sanitizeValue(hieData?.phone),
|
|
473
|
+
];
|
|
474
|
+
break;
|
|
475
|
+
case 'KRAPin':
|
|
476
|
+
arr = [
|
|
477
|
+
sanitizeValue(
|
|
478
|
+
amrsPerson?.person?.attributes.find((v) => v.attributeType.uuid === getAttributeUuid(HieAttributeType.KRAPin))
|
|
479
|
+
?.value,
|
|
480
|
+
),
|
|
481
|
+
sanitizeValue(hieData?.kra_pin),
|
|
482
|
+
];
|
|
483
|
+
break;
|
|
484
|
+
case 'Citizenship':
|
|
485
|
+
arr = [
|
|
486
|
+
sanitizeValue(
|
|
487
|
+
amrsPerson?.person?.attributes.find(
|
|
488
|
+
(v) => v.attributeType.uuid === getAttributeUuid(HieAttributeType.Citizenship),
|
|
489
|
+
)?.value,
|
|
490
|
+
),
|
|
491
|
+
sanitizeValue(hieData?.citizenship),
|
|
492
|
+
];
|
|
493
|
+
break;
|
|
494
|
+
default:
|
|
495
|
+
arr = ['', ''];
|
|
496
|
+
}
|
|
497
|
+
return arr;
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
export function getPatientRelationshipPayload(amrsPerson: AmrsPerson, relationshipType: string, dependantUuid: string) {
|
|
501
|
+
const startDate = dayjs().format('YYYY-MM-DDTHH:mm:ss.SSSZZ');
|
|
502
|
+
const patientRelationshipPayload = {
|
|
503
|
+
personA: amrsPerson.person.uuid,
|
|
504
|
+
relationshipType: getAmrsRelationshipTypeUuid(relationshipType),
|
|
505
|
+
personB: dependantUuid,
|
|
506
|
+
startDate: startDate,
|
|
507
|
+
};
|
|
508
|
+
return patientRelationshipPayload;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
export function mapAmrsPatientRelationship(uuid: string, relationships: Array<any>) {
|
|
512
|
+
const relationshipsArr: Array<CustomRelationship> = [];
|
|
513
|
+
if (relationships) {
|
|
514
|
+
for (const relationship of relationships) {
|
|
515
|
+
if (uuid === relationship?.personA?.uuid) {
|
|
516
|
+
const relation = {
|
|
517
|
+
uuid: relationship?.uuid,
|
|
518
|
+
display: relationship?.personB?.display,
|
|
519
|
+
relative: relationship?.personB?.display,
|
|
520
|
+
relatedPersonUuid: relationship?.personB?.uuid,
|
|
521
|
+
relationshipType: relationship?.relationshipType?.bIsToA,
|
|
522
|
+
relationshipTypeUuId: relationship?.relationshipType?.uuid,
|
|
523
|
+
relationshipTypeName: relationship?.relationshipType?.display,
|
|
524
|
+
relatedPerson: relationship?.personB,
|
|
525
|
+
};
|
|
526
|
+
relationshipsArr.push(relation);
|
|
527
|
+
} else {
|
|
528
|
+
const relation = {
|
|
529
|
+
uuid: relationship?.uuid,
|
|
530
|
+
display: relationship?.personA?.display,
|
|
531
|
+
relative: relationship?.personA?.display,
|
|
532
|
+
relatedPersonUuid: relationship?.personA?.uuid,
|
|
533
|
+
relationshipType: relationship?.relationshipType?.aIsToB,
|
|
534
|
+
relatedPerson: relationship?.personA,
|
|
535
|
+
relationshipTypeUuId: relationship?.relationshipType?.uuid,
|
|
536
|
+
relationshipTypeName: relationship?.relationshipType?.display,
|
|
537
|
+
};
|
|
538
|
+
relationshipsArr.push(relation);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return relationshipsArr;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
export function getPatientAttributes(hieClient: ClientRegistryBody) {
|
|
546
|
+
const attributes = [];
|
|
547
|
+
if (hieClient.place_of_birth.length > 0) {
|
|
548
|
+
attributes.push({
|
|
549
|
+
value: hieClient.place_of_birth,
|
|
550
|
+
attributeType: getAttributeUuid(HieAttributeType.PlaceOfBirth),
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
if (hieClient.phone.length > 0) {
|
|
554
|
+
attributes.push({
|
|
555
|
+
value: hieClient.phone,
|
|
556
|
+
attributeType: getAttributeUuid(HieAttributeType.Phone),
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
if (hieClient.email.length > 0) {
|
|
560
|
+
attributes.push({
|
|
561
|
+
value: hieClient.email,
|
|
562
|
+
attributeType: getAttributeUuid(HieAttributeType.Email),
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
if (hieClient.kra_pin.length > 0) {
|
|
566
|
+
attributes.push({
|
|
567
|
+
value: hieClient.kra_pin,
|
|
568
|
+
attributeType: getAttributeUuid(HieAttributeType.KRAPin),
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
if (hieClient.civil_status.length > 0) {
|
|
572
|
+
attributes.push({
|
|
573
|
+
value: this.getAmrsConceptUuidFromField(hieClient.civil_status),
|
|
574
|
+
attributeType: getAttributeUuid(HieAttributeType.CivilStatus),
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
if (hieClient.id) {
|
|
578
|
+
attributes.push({
|
|
579
|
+
value: hieClient.id,
|
|
580
|
+
attributeType: getAttributeUuid(HieAttributeType.Cr),
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
if (hieClient.citizenship) {
|
|
584
|
+
attributes.push({
|
|
585
|
+
value: hieClient.citizenship,
|
|
586
|
+
attributeType: getAttributeUuid(HieAttributeType.Citizenship),
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
return attributes;
|
|
590
|
+
}
|
|
@@ -10,6 +10,7 @@ import { GenderField } from './gender/gender-field.component';
|
|
|
10
10
|
import { Identifiers } from './id/id-field.component';
|
|
11
11
|
import { NameField } from './name/name-field.component';
|
|
12
12
|
import { PhoneField } from './phone/phone-field.component';
|
|
13
|
+
import ClientRegistryLookupSection from '../client-registry-search/client-registry-search.component';
|
|
13
14
|
|
|
14
15
|
export interface FieldProps {
|
|
15
16
|
name: string;
|
|
@@ -47,6 +48,8 @@ export function Field({ name }: FieldProps) {
|
|
|
47
48
|
return <Identifiers />;
|
|
48
49
|
case 'phone':
|
|
49
50
|
return <PhoneField />;
|
|
51
|
+
case 'clientRegistrySearch':
|
|
52
|
+
return <ClientRegistryLookupSection />;
|
|
50
53
|
default:
|
|
51
54
|
return <CustomField name={name} />;
|
|
52
55
|
}
|
|
@@ -30,7 +30,7 @@ export function setIdentifierSource(
|
|
|
30
30
|
selectedSource: identifierSource,
|
|
31
31
|
autoGeneration,
|
|
32
32
|
identifierValue:
|
|
33
|
-
(autoGeneration && !manualEntryEnabled) || (
|
|
33
|
+
(autoGeneration && !manualEntryEnabled) || (autoGeneration && manualEntryEnabled)
|
|
34
34
|
? 'auto-generated'
|
|
35
35
|
: identifierValue !== 'auto-generated'
|
|
36
36
|
? identifierValue
|
|
@@ -138,7 +138,7 @@ describe('setIdentifierSource', () => {
|
|
|
138
138
|
|
|
139
139
|
it('should return the identifier value when manual entry enabled', () => {
|
|
140
140
|
const identifierSource = {
|
|
141
|
-
autoGenerationOption: { automaticGenerationEnabled:
|
|
141
|
+
autoGenerationOption: { automaticGenerationEnabled: false, manualEntryEnabled: true },
|
|
142
142
|
} as IdentifierSource;
|
|
143
143
|
const { identifierValue } = setIdentifierSource(identifierSource, '10001V', '');
|
|
144
144
|
expect(identifierValue).toBe('10001V');
|
|
@@ -82,6 +82,7 @@ describe('FormManager', () => {
|
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
it('should not generate identifiers if manual entry enabled and identifier value given', async () => {
|
|
85
|
+
// to correct after amrs manual entry corrected
|
|
85
86
|
formValues.identifiers.foo.autoGeneration = true;
|
|
86
87
|
formValues.identifiers.foo.selectedSource.autoGenerationOption.manualEntryEnabled = true;
|
|
87
88
|
await FormManager.savePatientIdentifiers(true, undefined, formValues.identifiers, {}, 'Nyc');
|
|
@@ -41,7 +41,6 @@ export const PatientRegistration: React.FC<PatientRegistrationProps> = ({ savePa
|
|
|
41
41
|
const { search } = useLocation();
|
|
42
42
|
const { isLoading: isLoadingPatientToEdit, patient: patientToEdit } = usePatient(uuidOfPatientToEdit);
|
|
43
43
|
const config = useConfig<RegistrationConfig>();
|
|
44
|
-
|
|
45
44
|
const [initialFormValues, setInitialFormValues] = useInitialFormValues(
|
|
46
45
|
isLoadingPatientToEdit,
|
|
47
46
|
patientToEdit,
|
|
@@ -60,7 +60,7 @@ export function generateIdentifier(source: string) {
|
|
|
60
60
|
|
|
61
61
|
export async function generateAmrsUniversalIdentifier() {
|
|
62
62
|
const abortController = new AbortController();
|
|
63
|
-
const resp = await openmrsFetch(`https://
|
|
63
|
+
const resp = await openmrsFetch(`https://staging.ampath.or.ke/amrs-id-generator/generateidentifier`, {
|
|
64
64
|
headers: {
|
|
65
65
|
'Content-Type': 'application/json',
|
|
66
66
|
},
|
package/src/routes.json
CHANGED
|
@@ -46,6 +46,13 @@
|
|
|
46
46
|
"slot": "patient-search-actions-slot",
|
|
47
47
|
"online": true,
|
|
48
48
|
"offline": true
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"component": "clientRegistryVerificationTag",
|
|
52
|
+
"name": "client-registry-verification-tag",
|
|
53
|
+
"slot": "patient-banner-tags-slot",
|
|
54
|
+
"online": true,
|
|
55
|
+
"offline": true
|
|
49
56
|
}
|
|
50
57
|
],
|
|
51
58
|
"modals": [
|
|
@@ -56,6 +63,10 @@
|
|
|
56
63
|
{
|
|
57
64
|
"name": "delete-identifier-confirmation-modal",
|
|
58
65
|
"component": "deleteIdentifierConfirmationModal"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name": "client-registry-verification-modal",
|
|
69
|
+
"component": "clientRegistryVerificationModal"
|
|
59
70
|
}
|
|
60
71
|
]
|
|
61
|
-
}
|
|
72
|
+
}
|