@ampath/esm-patient-registration-app 9.2.0-next.19 → 9.2.0-next.21
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/1453.js +1 -0
- package/dist/1453.js.map +1 -0
- package/dist/4300.js +1 -1
- package/dist/5365.js +2 -0
- package/dist/5365.js.map +1 -0
- package/dist/6168.js +1 -0
- package/dist/6168.js.map +1 -0
- package/dist/6583.js +1 -1
- package/dist/7821.js +1 -1
- package/dist/8487.js +1 -0
- package/dist/8487.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/openmrs-esm-patient-registration-app.js +1 -1
- package/dist/openmrs-esm-patient-registration-app.js.buildmanifest.json +101 -101
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/patient-registration/client-registry/client-registry-search.component.tsx +5 -53
- package/src/patient-registration/client-registry/client-registry.resource.ts +8 -29
- package/src/patient-registration/client-registry/constants/civil-status.ts +29 -0
- package/src/patient-registration/client-registry/constants/person-attribute-types.ts +21 -0
- package/src/patient-registration/client-registry/hie-client-adapter.ts +327 -1
- package/src/patient-registration/client-registry/mock-client.ts +627 -0
- package/src/patient-registration/client-registry/new-client/new-client-registration/new-client-registration.scss +25 -0
- package/src/patient-registration/client-registry/new-client/new-client-registration/new-client-registration.tsx +276 -0
- package/src/patient-registration/client-registry/new-client/new-client-tab.component.tsx +6 -4
- package/src/patient-registration/client-registry/new-client/registration-form-data.ts +251 -0
- package/src/patient-registration/client-registry/types/index.ts +320 -6
- package/src/patient-registration/client-registry-search/client-registry-dependant-details.component.tsx +1 -1
- package/src/patient-registration/client-registry-search/client-registry-details.component.tsx +1 -1
- package/src/patient-registration/client-registry-search/client-registry-patient-details.component.tsx +1 -1
- package/src/patient-registration/client-registry-search/client-registry-search.component.tsx +1 -1
- package/src/patient-registration/client-registry-search/client-registry-verification-tag.component.tsx +1 -1
- package/src/patient-registration/client-registry-search/client-registry.resource.ts +16 -3
- package/src/patient-registration/client-registry-search/map-client-registry-to-form-utils.ts +1 -1
- package/translations/en.json +1 -0
- package/dist/2523.js +0 -1
- package/dist/2523.js.map +0 -1
- package/dist/5239.js +0 -2
- package/dist/5239.js.map +0 -1
- package/dist/9853.js +0 -1
- package/dist/9853.js.map +0 -1
- package/dist/9898.js +0 -1
- package/dist/9898.js.map +0 -1
- package/src/patient-registration/client-registry-search/client-registry.types.ts +0 -243
- /package/dist/{5239.js.LICENSE.txt → 5365.js.LICENSE.txt} +0 -0
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createPerson, createRelationship } from '../client-registry-search/client-registry.resource';
|
|
2
|
+
import {
|
|
3
|
+
type AlternateContact,
|
|
4
|
+
type CreateRelationshipDto,
|
|
5
|
+
HieClientDependant,
|
|
6
|
+
type HieDependant,
|
|
7
|
+
HieIdentificationType,
|
|
8
|
+
IdentifierTypesUuids,
|
|
9
|
+
PersonAttributeTypeUuids,
|
|
10
|
+
RelationshipTypeUuids,
|
|
11
|
+
} from '../client-registry/types';
|
|
12
|
+
import { CivilStatusUids } from './constants/civil-status';
|
|
13
|
+
import { type HieIdentifications, type HieClient, type CreatePersonDto } from './types';
|
|
2
14
|
|
|
3
15
|
const clientDatailsFields = [
|
|
4
16
|
'id',
|
|
@@ -25,6 +37,29 @@ const clientDatailsFields = [
|
|
|
25
37
|
'identification_type',
|
|
26
38
|
];
|
|
27
39
|
|
|
40
|
+
const nameFields = ['first_name', 'middle_name', 'last_name'];
|
|
41
|
+
const otherPersonFields = ['gender', 'date_of_birth', 'is_alive', 'deceased_datetime'];
|
|
42
|
+
const attributeFields = ['phone', 'email', 'civil_status', 'place_of_birth', 'citizenship'];
|
|
43
|
+
const addressFields = ['country', 'county', 'sub_county', 'ward', 'village_estate', 'longitude', 'latitude'];
|
|
44
|
+
const otherFields = ['gender', 'date_of_birth'];
|
|
45
|
+
const identifierFields = [
|
|
46
|
+
HieIdentificationType.Cr,
|
|
47
|
+
HieIdentificationType.SHANumber,
|
|
48
|
+
HieIdentificationType.HouseholdNumber,
|
|
49
|
+
HieIdentificationType.RefugeeID,
|
|
50
|
+
HieIdentificationType.MandateNumber,
|
|
51
|
+
HieIdentificationType.AlienID,
|
|
52
|
+
HieIdentificationType.NationalID,
|
|
53
|
+
HieIdentificationType.TemporaryDependantID,
|
|
54
|
+
];
|
|
55
|
+
const hieAmrsSyncFields = [
|
|
56
|
+
...identifierFields,
|
|
57
|
+
...nameFields,
|
|
58
|
+
...otherPersonFields,
|
|
59
|
+
...attributeFields,
|
|
60
|
+
...addressFields,
|
|
61
|
+
];
|
|
62
|
+
|
|
28
63
|
export function generateHieClientDetails(hieClient: HieClient) {
|
|
29
64
|
let data = {};
|
|
30
65
|
Object.keys(hieClient)
|
|
@@ -54,3 +89,294 @@ function generateOtherIdentifications(hieIdentifications: HieIdentifications[])
|
|
|
54
89
|
});
|
|
55
90
|
return other;
|
|
56
91
|
}
|
|
92
|
+
|
|
93
|
+
export function generateAmrsPersonPayload(hieClient: HieClient): CreatePersonDto {
|
|
94
|
+
const createPersonPayload: CreatePersonDto = {};
|
|
95
|
+
const namesAttribute = {};
|
|
96
|
+
const addresses = {};
|
|
97
|
+
let attributes = [];
|
|
98
|
+
hieAmrsSyncFields.forEach((d) => {
|
|
99
|
+
if (d === 'first_name') {
|
|
100
|
+
namesAttribute['givenName'] = hieClient.first_name;
|
|
101
|
+
}
|
|
102
|
+
if (d === 'middle_name') {
|
|
103
|
+
namesAttribute['middleName'] = hieClient.middle_name;
|
|
104
|
+
}
|
|
105
|
+
if (d === 'last_name') {
|
|
106
|
+
namesAttribute['familyName'] = hieClient.last_name;
|
|
107
|
+
}
|
|
108
|
+
if (d === 'gender') {
|
|
109
|
+
createPersonPayload['gender'] = hieClient.gender === 'Male' ? 'M' : 'F';
|
|
110
|
+
}
|
|
111
|
+
if (d === 'date_of_birth') {
|
|
112
|
+
createPersonPayload['birthdate'] = hieClient.date_of_birth;
|
|
113
|
+
createPersonPayload['birthdateEstimated'] = false;
|
|
114
|
+
}
|
|
115
|
+
if (d === 'is_alive') {
|
|
116
|
+
createPersonPayload['dead'] = hieClient.is_alive === 0 ? true : false;
|
|
117
|
+
}
|
|
118
|
+
if (d === 'deceased_datetime') {
|
|
119
|
+
if (hieClient.deceased_datetime.length > 0) {
|
|
120
|
+
createPersonPayload['deathDate'] = hieClient.deceased_datetime;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (d === 'country' && hieClient.country.length > 0) {
|
|
124
|
+
addresses['country'] = hieClient.country;
|
|
125
|
+
addresses['address1'] = hieClient.country;
|
|
126
|
+
}
|
|
127
|
+
if (d === 'place_of_birth' && hieClient.place_of_birth.length > 0) {
|
|
128
|
+
addresses['address10'] = hieClient.place_of_birth;
|
|
129
|
+
}
|
|
130
|
+
if (d === 'county' && hieClient.county.length > 0) {
|
|
131
|
+
addresses['countyDistrict'] = hieClient.county;
|
|
132
|
+
}
|
|
133
|
+
if (d === 'sub_county' && hieClient.sub_county.length > 0) {
|
|
134
|
+
addresses['address2'] = hieClient.sub_county;
|
|
135
|
+
addresses['stateProvince'] = hieClient.sub_county;
|
|
136
|
+
}
|
|
137
|
+
if (d === 'ward' && hieClient.sub_county.length > 0) {
|
|
138
|
+
addresses['address7'] = hieClient.sub_county;
|
|
139
|
+
addresses['address4'] = hieClient.sub_county;
|
|
140
|
+
}
|
|
141
|
+
if (d === 'village_estate' && hieClient.village_estate.length > 0) {
|
|
142
|
+
addresses['cityVillage'] = hieClient.village_estate;
|
|
143
|
+
}
|
|
144
|
+
if (d === 'longitude' && hieClient.longitude.length > 0) {
|
|
145
|
+
addresses['longitude'] = hieClient.longitude;
|
|
146
|
+
}
|
|
147
|
+
if (d === 'latitude' && hieClient.latitude.length > 0) {
|
|
148
|
+
addresses['latitude'] = hieClient.latitude;
|
|
149
|
+
}
|
|
150
|
+
if (d === 'place_of_birth' && hieClient.place_of_birth.length > 0) {
|
|
151
|
+
attributes.push({
|
|
152
|
+
value: hieClient.place_of_birth,
|
|
153
|
+
attributeType: PersonAttributeTypeUuids.PLACE_OF_BIRTH_UUID,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (d === 'phone' && hieClient.phone.length > 0) {
|
|
157
|
+
attributes.push({
|
|
158
|
+
value: hieClient.phone,
|
|
159
|
+
attributeType: PersonAttributeTypeUuids.CONTACT_PHONE_NUMBER_UUID,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
if (d === 'email' && hieClient.email.length > 0) {
|
|
163
|
+
attributes.push({
|
|
164
|
+
value: hieClient.email,
|
|
165
|
+
attributeType: PersonAttributeTypeUuids.CONTACT_EMAIL_ADDRESS_UUID,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
if (d === 'civil_status' && hieClient.civil_status.length > 0) {
|
|
169
|
+
attributes.push({
|
|
170
|
+
value: getAmrsConceptUuidFromField(hieClient.civil_status),
|
|
171
|
+
attributeType: PersonAttributeTypeUuids.CIVIL_STATUS_UUID,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
if (d === 'id' && hieClient.id) {
|
|
175
|
+
attributes.push({
|
|
176
|
+
value: hieClient.id,
|
|
177
|
+
attributeType: PersonAttributeTypeUuids.CLIENT_REGISTRY_ID_UUID,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
if (d === 'citizenship' && hieClient.citizenship) {
|
|
181
|
+
attributes.push({
|
|
182
|
+
value: hieClient.citizenship,
|
|
183
|
+
attributeType: PersonAttributeTypeUuids.CITIZENSHIP_UUID,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
// Add next of kin details
|
|
188
|
+
const nextOfKinAndAlternativeAttributes = generateNextOfKinAndAlternateContactDetails(hieClient.alternative_contacts);
|
|
189
|
+
attributes = [...attributes, ...nextOfKinAndAlternativeAttributes];
|
|
190
|
+
if (Object.keys(namesAttribute).length > 0) {
|
|
191
|
+
createPersonPayload['names'] = [namesAttribute];
|
|
192
|
+
}
|
|
193
|
+
if (Object.keys(addresses).length > 0) {
|
|
194
|
+
createPersonPayload['addresses'] = [addresses];
|
|
195
|
+
}
|
|
196
|
+
if (attributes.length > 0) {
|
|
197
|
+
createPersonPayload['attributes'] = attributes;
|
|
198
|
+
}
|
|
199
|
+
return createPersonPayload;
|
|
200
|
+
}
|
|
201
|
+
function generateNextOfKinAndAlternateContactDetails(alternativeContacts: AlternateContact[]) {
|
|
202
|
+
const attributes = [];
|
|
203
|
+
const alterNativeClientContact = alternativeContacts.find((a) => {
|
|
204
|
+
return a.relationship === 'Alternative Phone Number';
|
|
205
|
+
});
|
|
206
|
+
const nextOfKinContact = alternativeContacts.find((a) => {
|
|
207
|
+
return a.remarks === 'Next Of Kin';
|
|
208
|
+
});
|
|
209
|
+
if (alterNativeClientContact) {
|
|
210
|
+
if (alterNativeClientContact.contact_type === 'Phone') {
|
|
211
|
+
attributes.push({
|
|
212
|
+
value: alterNativeClientContact.contact_id,
|
|
213
|
+
attributeType: PersonAttributeTypeUuids.ALTERNATIVE_CONTACT_PHONE_NUMBER_UUID,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (nextOfKinContact) {
|
|
218
|
+
if (nextOfKinContact.contact_type === 'Phone') {
|
|
219
|
+
attributes.push({
|
|
220
|
+
value: nextOfKinContact.contact_id,
|
|
221
|
+
attributeType: PersonAttributeTypeUuids.NEXT_OF_KIN_CONTACT_PHONE_NUMBER_UUID,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
attributes.push({
|
|
225
|
+
value: nextOfKinContact.relationship,
|
|
226
|
+
attributeType: PersonAttributeTypeUuids.NEXT_OF_KIN_RELATIONSHIP_UUID,
|
|
227
|
+
});
|
|
228
|
+
attributes.push({
|
|
229
|
+
value: nextOfKinContact.contact_name,
|
|
230
|
+
attributeType: PersonAttributeTypeUuids.NEXT_OF_KIN_NAME_UUID,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return attributes;
|
|
234
|
+
}
|
|
235
|
+
function getAmrsConceptUuidFromField(fieldName: string): string {
|
|
236
|
+
let conceptUuid = '';
|
|
237
|
+
switch (fieldName) {
|
|
238
|
+
case 'Divorced':
|
|
239
|
+
conceptUuid = CivilStatusUids.DIVORCED_UUID;
|
|
240
|
+
break;
|
|
241
|
+
case 'Married':
|
|
242
|
+
conceptUuid = CivilStatusUids.MARRIED_UUID;
|
|
243
|
+
break;
|
|
244
|
+
case 'Single':
|
|
245
|
+
conceptUuid = CivilStatusUids.SINGLE_UUID;
|
|
246
|
+
break;
|
|
247
|
+
default:
|
|
248
|
+
conceptUuid = CivilStatusUids.NOT_APPLICABLE_UUID;
|
|
249
|
+
}
|
|
250
|
+
return conceptUuid;
|
|
251
|
+
}
|
|
252
|
+
export function generateAmrsCreatePatientIdentifiersPayload(hieClient: HieClient, identifierLocation: string) {
|
|
253
|
+
const identifiers = [];
|
|
254
|
+
// add CR number
|
|
255
|
+
identifiers.push({
|
|
256
|
+
identifierType: getAmrsIdentifierTypeUuid(HieIdentificationType.Cr),
|
|
257
|
+
identifier: hieClient.id,
|
|
258
|
+
location: identifierLocation,
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
// add main identifier
|
|
262
|
+
identifiers.push({
|
|
263
|
+
identifierType: getAmrsIdentifierTypeUuid(hieClient.identification_type),
|
|
264
|
+
identifier: hieClient.identification_number,
|
|
265
|
+
location: identifierLocation,
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
// add other idenfications
|
|
269
|
+
hieClient.other_identifications.forEach((id) => {
|
|
270
|
+
identifiers.push({
|
|
271
|
+
identifierType: getAmrsIdentifierTypeUuid(id.identification_type),
|
|
272
|
+
identifier: id.identification_number,
|
|
273
|
+
location: identifierLocation,
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
return identifiers;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function getAmrsIdentifierTypeUuid(hieIdentifierName: string) {
|
|
281
|
+
let idTypeUuid;
|
|
282
|
+
switch (hieIdentifierName) {
|
|
283
|
+
case HieIdentificationType.NationalID:
|
|
284
|
+
idTypeUuid = IdentifierTypesUuids.NATIONAL_ID_UUID;
|
|
285
|
+
break;
|
|
286
|
+
case HieIdentificationType.HouseholdNumber:
|
|
287
|
+
idTypeUuid = IdentifierTypesUuids.HOUSE_HOLD_NUMBER_UUID;
|
|
288
|
+
break;
|
|
289
|
+
case HieIdentificationType.AlienID:
|
|
290
|
+
idTypeUuid = IdentifierTypesUuids.ALIEN_ID_UUID;
|
|
291
|
+
break;
|
|
292
|
+
case HieIdentificationType.SHANumber:
|
|
293
|
+
idTypeUuid = IdentifierTypesUuids.SHA_UUID;
|
|
294
|
+
break;
|
|
295
|
+
case HieIdentificationType.MandateNumber:
|
|
296
|
+
idTypeUuid = IdentifierTypesUuids.MANDATE_NUMBER_UUID;
|
|
297
|
+
break;
|
|
298
|
+
case HieIdentificationType.RefugeeID:
|
|
299
|
+
idTypeUuid = IdentifierTypesUuids.REFUGEE_ID_UUID;
|
|
300
|
+
break;
|
|
301
|
+
case HieIdentificationType.Cr:
|
|
302
|
+
idTypeUuid = IdentifierTypesUuids.CLIENT_REGISTRY_NO_UUID;
|
|
303
|
+
break;
|
|
304
|
+
case HieIdentificationType.TemporaryDependantID:
|
|
305
|
+
idTypeUuid = IdentifierTypesUuids.TEMPORARY_DEPENDANT_ID_UUID;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
return idTypeUuid;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export async function createPatientDependantRelationsips(patientUuid: string, hieClientDependants: HieDependant[]) {
|
|
312
|
+
for (const dependant of hieClientDependants) {
|
|
313
|
+
await createPatientDependantRelationsip(patientUuid, dependant);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
async function createPatientDependantRelationsip(patientUuid: string, hieDependant: HieDependant) {
|
|
318
|
+
const resp = await createDependant(hieDependant);
|
|
319
|
+
const res = (await resp.json()) as any;
|
|
320
|
+
const dependantPersonUuid = res.uuid;
|
|
321
|
+
return createDependantRelationship(hieDependant, patientUuid, dependantPersonUuid);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function createDependant(hieDependant: HieDependant) {
|
|
325
|
+
const depentantPersonPayload = createDependantPersonPayload(hieDependant);
|
|
326
|
+
return createDependantPerson(depentantPersonPayload);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function createDependantPersonPayload(hieDependant: HieDependant) {
|
|
330
|
+
const createPersonPayload: CreatePersonDto = generateAmrsPersonPayload(hieDependant.result[0]);
|
|
331
|
+
return createPersonPayload;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function createDependantPerson(createPersonPayload: CreatePersonDto) {
|
|
335
|
+
return createPerson(createPersonPayload);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function createDependantRelationship(hieDependant: HieDependant, patientUuid: string, dependantPersonUuid: string) {
|
|
339
|
+
const relationshipPayload = generateRelationshipPayload(hieDependant, patientUuid, dependantPersonUuid);
|
|
340
|
+
return createDepandantRelationship(relationshipPayload);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function generateRelationshipPayload(hieDependant: HieDependant, patientUuid: string, dependantPersonUuid: string) {
|
|
344
|
+
const payload = getPatientRelationshipPayload(hieDependant.relationship, patientUuid, dependantPersonUuid);
|
|
345
|
+
|
|
346
|
+
return payload;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function createDepandantRelationship(relationshipPayload: CreateRelationshipDto) {
|
|
350
|
+
return createRelationship(relationshipPayload);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export function getPatientRelationshipPayload(
|
|
354
|
+
relationship: string,
|
|
355
|
+
personAuuid: string,
|
|
356
|
+
personBuUuid: string,
|
|
357
|
+
): CreateRelationshipDto {
|
|
358
|
+
const startDate = new Date().toISOString();
|
|
359
|
+
const patientRelationshipPayload = {
|
|
360
|
+
personA: personAuuid,
|
|
361
|
+
relationshipType: getAmrsRelationshipTypeUuid(relationship),
|
|
362
|
+
personB: personBuUuid,
|
|
363
|
+
startDate: startDate,
|
|
364
|
+
};
|
|
365
|
+
return patientRelationshipPayload;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function getAmrsRelationshipTypeUuid(relationshipType: string) {
|
|
369
|
+
let relationShipTypeUuid = '';
|
|
370
|
+
switch (relationshipType) {
|
|
371
|
+
case 'Spouse':
|
|
372
|
+
relationShipTypeUuid = RelationshipTypeUuids.SPOUSE_UUID;
|
|
373
|
+
break;
|
|
374
|
+
case 'Child':
|
|
375
|
+
relationShipTypeUuid = RelationshipTypeUuids.PARENT_CHILD_UUID;
|
|
376
|
+
break;
|
|
377
|
+
default:
|
|
378
|
+
relationShipTypeUuid = RelationshipTypeUuids.OTHER_NON_CODED_UUID;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return relationShipTypeUuid;
|
|
382
|
+
}
|