@ampath/esm-dha-workflow-app 4.0.0-next.13 → 4.0.0-next.14
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/306.js +1 -0
- package/dist/306.js.map +1 -0
- package/dist/860.js +1 -1
- package/dist/860.js.map +1 -1
- package/dist/91.js +1 -1
- package/dist/91.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-home-app.js.buildmanifest.json +30 -30
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/left-panel/left-panel.component.tsx +0 -2
- package/src/registry/mock-client.ts +627 -0
- package/src/registry/modal/otp-verification-modal/otp-verification-modal.tsx +13 -11
- package/src/registry/modal/send-to-triage/send-to-triage.modal.scss +7 -0
- package/src/registry/modal/send-to-triage/send-to-triage.modal.tsx +97 -72
- package/src/registry/registry.component.scss +12 -1
- package/src/registry/registry.component.tsx +168 -104
- package/src/registry/types/index.ts +59 -1
- package/src/registry/utils/error-handler.ts +33 -0
- package/src/registry/utils/format-dependant-display-data.ts +8 -0
- package/src/registry/utils/hie-client-adapter.ts +309 -0
- package/src/resources/hie-amrs-automatic-registration.service.ts +16 -0
- package/src/resources/identifier-types.ts +27 -0
- package/src/resources/patient-resource.ts +60 -0
- package/src/shared/constants/civil-status.ts +29 -0
- package/src/shared/constants/person-attributes.ts +33 -0
- package/dist/16.js +0 -1
- package/dist/16.js.map +0 -1
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { IdentifierTypesUuids } from '../../resources/identifier-types';
|
|
2
|
+
import { CivilStatusUids } from '../../shared/constants/civil-status';
|
|
3
|
+
import { PersonAttributeTypeUuids } from '../../shared/constants/person-attributes';
|
|
4
|
+
import {
|
|
5
|
+
type AlternateContact,
|
|
6
|
+
type CreatePersonDto,
|
|
7
|
+
type HieClient,
|
|
8
|
+
type HieIdentifications,
|
|
9
|
+
HieIdentificationType,
|
|
10
|
+
} from '../types';
|
|
11
|
+
|
|
12
|
+
const clientDatailsFields = [
|
|
13
|
+
'id',
|
|
14
|
+
'other_identifications',
|
|
15
|
+
'first_name',
|
|
16
|
+
'middle_name',
|
|
17
|
+
'last_name',
|
|
18
|
+
'gender',
|
|
19
|
+
'date_of_birth',
|
|
20
|
+
'is_alive',
|
|
21
|
+
'deceased_datetime',
|
|
22
|
+
'phone',
|
|
23
|
+
'email',
|
|
24
|
+
'civil_status',
|
|
25
|
+
'place_of_birth',
|
|
26
|
+
'citizenship',
|
|
27
|
+
'country',
|
|
28
|
+
'county',
|
|
29
|
+
'sub_county',
|
|
30
|
+
'ward',
|
|
31
|
+
'village_estate',
|
|
32
|
+
'longitude',
|
|
33
|
+
'latitude',
|
|
34
|
+
'identification_type',
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const nameFields = ['first_name', 'middle_name', 'last_name'];
|
|
38
|
+
const otherPersonFields = ['gender', 'date_of_birth', 'is_alive', 'deceased_datetime'];
|
|
39
|
+
const attributeFields = ['phone', 'email', 'civil_status', 'place_of_birth', 'citizenship'];
|
|
40
|
+
const addressFields = ['country', 'county', 'sub_county', 'ward', 'village_estate', 'longitude', 'latitude'];
|
|
41
|
+
const otherFields = ['gender', 'date_of_birth'];
|
|
42
|
+
const identifierFields = [
|
|
43
|
+
HieIdentificationType.Cr,
|
|
44
|
+
HieIdentificationType.SHANumber,
|
|
45
|
+
HieIdentificationType.HouseholdNumber,
|
|
46
|
+
HieIdentificationType.RefugeeID,
|
|
47
|
+
HieIdentificationType.MandateNumber,
|
|
48
|
+
HieIdentificationType.AlienID,
|
|
49
|
+
HieIdentificationType.NationalID,
|
|
50
|
+
HieIdentificationType.TemporaryDependantID,
|
|
51
|
+
];
|
|
52
|
+
const hieAmrsSyncFields = [
|
|
53
|
+
...identifierFields,
|
|
54
|
+
...nameFields,
|
|
55
|
+
...otherPersonFields,
|
|
56
|
+
...attributeFields,
|
|
57
|
+
...addressFields,
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
export function generateHieClientDetails(hieClient: HieClient) {
|
|
61
|
+
let data = {};
|
|
62
|
+
Object.keys(hieClient)
|
|
63
|
+
.filter((key) => {
|
|
64
|
+
return clientDatailsFields.includes(key);
|
|
65
|
+
})
|
|
66
|
+
.forEach((key) => {
|
|
67
|
+
if (key === 'other_identifications') {
|
|
68
|
+
const otherIds = generateOtherIdentifications(hieClient[key]);
|
|
69
|
+
data = {
|
|
70
|
+
...data,
|
|
71
|
+
...otherIds,
|
|
72
|
+
};
|
|
73
|
+
} else if (key === 'identification_type') {
|
|
74
|
+
data[hieClient['identification_type']] = hieClient.identification_number;
|
|
75
|
+
} else {
|
|
76
|
+
const value = hieClient[key];
|
|
77
|
+
data[key] = value;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return data;
|
|
81
|
+
}
|
|
82
|
+
function generateOtherIdentifications(hieIdentifications: HieIdentifications[]) {
|
|
83
|
+
const other = {};
|
|
84
|
+
hieIdentifications.forEach((id) => {
|
|
85
|
+
other[id.identification_type] = id.identification_number;
|
|
86
|
+
});
|
|
87
|
+
return other;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function generateAmrsPersonPayload(hieClient: HieClient): CreatePersonDto {
|
|
91
|
+
const createPersonPayload: CreatePersonDto = {};
|
|
92
|
+
const namesAttribute = {};
|
|
93
|
+
const addresses = {};
|
|
94
|
+
let attributes = [];
|
|
95
|
+
hieAmrsSyncFields.forEach((d) => {
|
|
96
|
+
if (d === 'first_name') {
|
|
97
|
+
namesAttribute['givenName'] = hieClient.first_name;
|
|
98
|
+
}
|
|
99
|
+
if (d === 'middle_name') {
|
|
100
|
+
namesAttribute['middleName'] = hieClient.middle_name;
|
|
101
|
+
}
|
|
102
|
+
if (d === 'last_name') {
|
|
103
|
+
namesAttribute['familyName'] = hieClient.last_name;
|
|
104
|
+
}
|
|
105
|
+
if (d === 'gender') {
|
|
106
|
+
createPersonPayload['gender'] = hieClient.gender === 'Male' ? 'M' : 'F';
|
|
107
|
+
}
|
|
108
|
+
if (d === 'date_of_birth') {
|
|
109
|
+
createPersonPayload['birthdate'] = hieClient.date_of_birth;
|
|
110
|
+
createPersonPayload['birthdateEstimated'] = false;
|
|
111
|
+
}
|
|
112
|
+
if (d === 'is_alive') {
|
|
113
|
+
createPersonPayload['dead'] = hieClient.is_alive === 0 ? true : false;
|
|
114
|
+
}
|
|
115
|
+
if (d === 'deceased_datetime') {
|
|
116
|
+
if (hieClient.deceased_datetime.length > 0) {
|
|
117
|
+
createPersonPayload['deathDate'] = hieClient.deceased_datetime;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (d === 'country' && hieClient.country.length > 0) {
|
|
121
|
+
addresses['country'] = hieClient.country;
|
|
122
|
+
addresses['address1'] = hieClient.country;
|
|
123
|
+
}
|
|
124
|
+
if (d === 'place_of_birth' && hieClient.place_of_birth.length > 0) {
|
|
125
|
+
addresses['address10'] = hieClient.place_of_birth;
|
|
126
|
+
}
|
|
127
|
+
if (d === 'county' && hieClient.county.length > 0) {
|
|
128
|
+
addresses['countyDistrict'] = hieClient.county;
|
|
129
|
+
}
|
|
130
|
+
if (d === 'sub_county' && hieClient.sub_county.length > 0) {
|
|
131
|
+
addresses['address2'] = hieClient.sub_county;
|
|
132
|
+
addresses['stateProvince'] = hieClient.sub_county;
|
|
133
|
+
}
|
|
134
|
+
if (d === 'ward' && hieClient.sub_county.length > 0) {
|
|
135
|
+
addresses['address7'] = hieClient.sub_county;
|
|
136
|
+
addresses['address4'] = hieClient.sub_county;
|
|
137
|
+
}
|
|
138
|
+
if (d === 'village_estate' && hieClient.village_estate.length > 0) {
|
|
139
|
+
addresses['cityVillage'] = hieClient.village_estate;
|
|
140
|
+
}
|
|
141
|
+
if (d === 'longitude' && hieClient.longitude.length > 0) {
|
|
142
|
+
addresses['longitude'] = hieClient.longitude;
|
|
143
|
+
}
|
|
144
|
+
if (d === 'latitude' && hieClient.latitude.length > 0) {
|
|
145
|
+
addresses['latitude'] = hieClient.latitude;
|
|
146
|
+
}
|
|
147
|
+
if (d === 'place_of_birth' && hieClient.place_of_birth.length > 0) {
|
|
148
|
+
attributes.push({
|
|
149
|
+
value: hieClient.place_of_birth,
|
|
150
|
+
attributeType: PersonAttributeTypeUuids.PLACE_OF_BIRTH_UUID,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
if (d === 'phone' && hieClient.phone.length > 0) {
|
|
154
|
+
attributes.push({
|
|
155
|
+
value: hieClient.phone,
|
|
156
|
+
attributeType: PersonAttributeTypeUuids.CONTACT_PHONE_NUMBER_UUID,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
if (d === 'email' && hieClient.email.length > 0) {
|
|
160
|
+
attributes.push({
|
|
161
|
+
value: hieClient.email,
|
|
162
|
+
attributeType: PersonAttributeTypeUuids.CONTACT_EMAIL_ADDRESS_UUID,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (d === 'civil_status' && hieClient.civil_status.length > 0) {
|
|
166
|
+
attributes.push({
|
|
167
|
+
value: getAmrsConceptUuidFromField(hieClient.civil_status),
|
|
168
|
+
attributeType: PersonAttributeTypeUuids.CIVIL_STATUS_UUID,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
if (d === 'id' && hieClient.id) {
|
|
172
|
+
attributes.push({
|
|
173
|
+
value: hieClient.id,
|
|
174
|
+
attributeType: PersonAttributeTypeUuids.CLIENT_REGISTRY_ID_UUID,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
if (d === 'citizenship' && hieClient.citizenship) {
|
|
178
|
+
attributes.push({
|
|
179
|
+
value: hieClient.citizenship,
|
|
180
|
+
attributeType: PersonAttributeTypeUuids.CITIZENSHIP_UUID,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
// Add next of kin details
|
|
185
|
+
const nextOfKinAndAlternativeAttributes = generateNextOfKinAndAlternateContactDetails(hieClient.alternative_contacts);
|
|
186
|
+
attributes = [...attributes, ...nextOfKinAndAlternativeAttributes];
|
|
187
|
+
if (Object.keys(namesAttribute).length > 0) {
|
|
188
|
+
createPersonPayload['names'] = [namesAttribute];
|
|
189
|
+
}
|
|
190
|
+
if (Object.keys(addresses).length > 0) {
|
|
191
|
+
createPersonPayload['addresses'] = [addresses];
|
|
192
|
+
}
|
|
193
|
+
if (attributes.length > 0) {
|
|
194
|
+
createPersonPayload['attributes'] = attributes;
|
|
195
|
+
}
|
|
196
|
+
return createPersonPayload;
|
|
197
|
+
}
|
|
198
|
+
function generateNextOfKinAndAlternateContactDetails(alternativeContacts: AlternateContact[]) {
|
|
199
|
+
const attributes = [];
|
|
200
|
+
const alterNativeClientContact = alternativeContacts.find((a) => {
|
|
201
|
+
return a.relationship === 'Alternative Phone Number';
|
|
202
|
+
});
|
|
203
|
+
const nextOfKinContact = alternativeContacts.find((a) => {
|
|
204
|
+
return a.remarks === 'Next Of Kin';
|
|
205
|
+
});
|
|
206
|
+
if (alterNativeClientContact) {
|
|
207
|
+
if (alterNativeClientContact.contact_type === 'Phone') {
|
|
208
|
+
attributes.push({
|
|
209
|
+
value: alterNativeClientContact.contact_id,
|
|
210
|
+
attributeType: PersonAttributeTypeUuids.ALTERNATIVE_CONTACT_PHONE_NUMBER_UUID,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (nextOfKinContact) {
|
|
215
|
+
if (nextOfKinContact.contact_type === 'Phone') {
|
|
216
|
+
attributes.push({
|
|
217
|
+
value: nextOfKinContact.contact_id,
|
|
218
|
+
attributeType: PersonAttributeTypeUuids.NEXT_OF_KIN_CONTACT_PHONE_NUMBER_UUID,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
attributes.push({
|
|
222
|
+
value: nextOfKinContact.relationship,
|
|
223
|
+
attributeType: PersonAttributeTypeUuids.NEXT_OF_KIN_RELATIONSHIP_UUID,
|
|
224
|
+
});
|
|
225
|
+
attributes.push({
|
|
226
|
+
value: nextOfKinContact.contact_name,
|
|
227
|
+
attributeType: PersonAttributeTypeUuids.NEXT_OF_KIN_NAME_UUID,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
return attributes;
|
|
231
|
+
}
|
|
232
|
+
function getAmrsConceptUuidFromField(fieldName: string): string {
|
|
233
|
+
let conceptUuid = '';
|
|
234
|
+
switch (fieldName) {
|
|
235
|
+
case 'Divorced':
|
|
236
|
+
conceptUuid = CivilStatusUids.DIVORCED_UUID;
|
|
237
|
+
break;
|
|
238
|
+
case 'Married':
|
|
239
|
+
conceptUuid = CivilStatusUids.MARRIED_UUID;
|
|
240
|
+
break;
|
|
241
|
+
case 'Single':
|
|
242
|
+
conceptUuid = CivilStatusUids.SINGLE_UUID;
|
|
243
|
+
break;
|
|
244
|
+
default:
|
|
245
|
+
conceptUuid = CivilStatusUids.NOT_APPLICABLE_UUID;
|
|
246
|
+
}
|
|
247
|
+
return conceptUuid;
|
|
248
|
+
}
|
|
249
|
+
export function generateAmrsCreatePatientIdentifiersPayload(hieClient: HieClient, identifierLocation: string) {
|
|
250
|
+
const identifiers = [];
|
|
251
|
+
// add CR number
|
|
252
|
+
identifiers.push({
|
|
253
|
+
identifierType: getAmrsIdentifierTypeUuid(HieIdentificationType.Cr),
|
|
254
|
+
identifier: hieClient.id,
|
|
255
|
+
location: identifierLocation,
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// add main identifier
|
|
259
|
+
identifiers.push({
|
|
260
|
+
identifierType: getAmrsIdentifierTypeUuid(hieClient.identification_type),
|
|
261
|
+
identifier: hieClient.identification_number,
|
|
262
|
+
location: identifierLocation,
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// add other idenfications
|
|
266
|
+
hieClient.other_identifications.forEach((id) => {
|
|
267
|
+
identifiers.push({
|
|
268
|
+
identifierType: getAmrsIdentifierTypeUuid(id.identification_type),
|
|
269
|
+
identifier: id.identification_number,
|
|
270
|
+
location: identifierLocation,
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
return identifiers;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export function getAmrsIdentifierTypeUuid(hieIdentifierName: string) {
|
|
278
|
+
let idTypeUuid;
|
|
279
|
+
switch (hieIdentifierName) {
|
|
280
|
+
case HieIdentificationType.NationalID:
|
|
281
|
+
idTypeUuid = IdentifierTypesUuids.NATIONAL_ID_UUID;
|
|
282
|
+
break;
|
|
283
|
+
case HieIdentificationType.HouseholdNumber:
|
|
284
|
+
idTypeUuid = IdentifierTypesUuids.HOUSE_HOLD_NUMBER_UUID;
|
|
285
|
+
break;
|
|
286
|
+
case HieIdentificationType.AlienID:
|
|
287
|
+
idTypeUuid = IdentifierTypesUuids.ALIEN_ID_UUID;
|
|
288
|
+
break;
|
|
289
|
+
case HieIdentificationType.SHANumber:
|
|
290
|
+
idTypeUuid = IdentifierTypesUuids.SHA_UUID;
|
|
291
|
+
break;
|
|
292
|
+
case HieIdentificationType.MandateNumber:
|
|
293
|
+
idTypeUuid = IdentifierTypesUuids.MANDATE_NUMBER_UUID;
|
|
294
|
+
break;
|
|
295
|
+
case HieIdentificationType.RefugeeID:
|
|
296
|
+
idTypeUuid = IdentifierTypesUuids.REFUGEE_ID_UUID;
|
|
297
|
+
break;
|
|
298
|
+
case HieIdentificationType.Cr:
|
|
299
|
+
idTypeUuid = IdentifierTypesUuids.CLIENT_REGISTRY_NO_UUID;
|
|
300
|
+
break;
|
|
301
|
+
case HieIdentificationType.BirthCertificate:
|
|
302
|
+
idTypeUuid = IdentifierTypesUuids.BIRTH_CERTIFICATE_NUMBER_UUID;
|
|
303
|
+
break;
|
|
304
|
+
case HieIdentificationType.TemporaryDependantID:
|
|
305
|
+
idTypeUuid = IdentifierTypesUuids.TEMPORARY_DEPENDANT_ID_UUID;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
return idTypeUuid;
|
|
309
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Patient } from '@openmrs/esm-framework';
|
|
2
|
+
import { type HieClient } from '../registry/types';
|
|
3
|
+
import { generateAmrsPersonPayload } from '../registry/utils/hie-client-adapter';
|
|
4
|
+
import { createPatient, generatePatientIdentifiers } from './patient-resource';
|
|
5
|
+
|
|
6
|
+
export async function registerHieClientInAmrs(client: HieClient, identifierLocation: string): Promise<Patient> {
|
|
7
|
+
const createPersonPayload = generateAmrsPersonPayload(client);
|
|
8
|
+
const identifiers = await generatePatientIdentifiers(identifierLocation, client);
|
|
9
|
+
const resp = await createPatient({
|
|
10
|
+
person: createPersonPayload,
|
|
11
|
+
identifiers: identifiers,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const res = await resp.json();
|
|
15
|
+
return res;
|
|
16
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const HOUSE_HOLD_NUMBER_UUID = 'bb74b20e-dcee-4f59-bdf1-2dffc3abf106';
|
|
2
|
+
const SHA_UUID = 'cf5362b2-8049-4442-b3c6-36f870e320cb';
|
|
3
|
+
const CLIENT_REGISTRY_NO_UUID = 'e88dc246-3614-4ee3-8141-1f2a83054e72';
|
|
4
|
+
const NATIONAL_ID_UUID = '58a47054-1359-11df-a1f1-0026b9348838';
|
|
5
|
+
const PROVIDER_NATIONAL_ID_UUID = '4550df92-c684-4597-8ab8-d6b10eabdcfb';
|
|
6
|
+
const REFUGEE_ID_UUID = '465e81af-8d69-47e9-9127-53a94adc75fb';
|
|
7
|
+
const MANDATE_NUMBER_UUID = 'aae2d097-20ba-43ca-9b71-fd8296068f39';
|
|
8
|
+
const ALIEN_ID_UUID = '12f5b147-3403-4a73-913d-7ded9ffec094';
|
|
9
|
+
const TEMPORARY_DEPENDANT_ID_UUID = 'a3d34214-93e8-4faf-bf4d-0272eee079eb';
|
|
10
|
+
const AMRS_UNIVERSAL_ID_UUID = '58a4732e-1359-11df-a1f1-0026b9348838';
|
|
11
|
+
const UPI_NUMBER_UUID = 'cba702b9-4664-4b43-83f1-9ab473cbd64d';
|
|
12
|
+
const BIRTH_CERTIFICATE_NUMBER_UUID = '7924e13b-131a-4da8-8efa-e294184a1b0d';
|
|
13
|
+
|
|
14
|
+
export const IdentifierTypesUuids = {
|
|
15
|
+
HOUSE_HOLD_NUMBER_UUID,
|
|
16
|
+
SHA_UUID,
|
|
17
|
+
CLIENT_REGISTRY_NO_UUID,
|
|
18
|
+
NATIONAL_ID_UUID,
|
|
19
|
+
PROVIDER_NATIONAL_ID_UUID,
|
|
20
|
+
REFUGEE_ID_UUID,
|
|
21
|
+
MANDATE_NUMBER_UUID,
|
|
22
|
+
ALIEN_ID_UUID,
|
|
23
|
+
TEMPORARY_DEPENDANT_ID_UUID,
|
|
24
|
+
AMRS_UNIVERSAL_ID_UUID,
|
|
25
|
+
UPI_NUMBER_UUID,
|
|
26
|
+
BIRTH_CERTIFICATE_NUMBER_UUID,
|
|
27
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
2
|
+
import { type HieClient, type CreatePatientDto, HieIdentificationType } from '../registry/types';
|
|
3
|
+
import { IdentifierTypesUuids } from './identifier-types';
|
|
4
|
+
import { getAmrsIdentifierTypeUuid } from '../registry/utils/hie-client-adapter';
|
|
5
|
+
|
|
6
|
+
export async function createPatient(payload: CreatePatientDto) {
|
|
7
|
+
return await openmrsFetch(`${restBaseUrl}/patient`, {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
headers: {
|
|
10
|
+
'Content-Type': 'application/json',
|
|
11
|
+
},
|
|
12
|
+
body: payload,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const generatePatientIdentifiers = async (identifierLocation: string, client: HieClient) => {
|
|
17
|
+
const amrsUniverSalId = await generateAmrsUniversalIdentifier();
|
|
18
|
+
const identifiers = generateAmrsCreatePatientIdentifiersPayload(client, identifierLocation);
|
|
19
|
+
identifiers.push({
|
|
20
|
+
identifierType: IdentifierTypesUuids.AMRS_UNIVERSAL_ID_UUID,
|
|
21
|
+
identifier: amrsUniverSalId,
|
|
22
|
+
location: identifierLocation,
|
|
23
|
+
preferred: true,
|
|
24
|
+
});
|
|
25
|
+
return identifiers;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function generateAmrsCreatePatientIdentifiersPayload(hieClient: HieClient, identifierLocation: string) {
|
|
29
|
+
const identifiers = [];
|
|
30
|
+
// add CR number
|
|
31
|
+
identifiers.push({
|
|
32
|
+
identifierType: getAmrsIdentifierTypeUuid(HieIdentificationType.Cr),
|
|
33
|
+
identifier: hieClient.id,
|
|
34
|
+
location: identifierLocation,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// add main identifier
|
|
38
|
+
identifiers.push({
|
|
39
|
+
identifierType: getAmrsIdentifierTypeUuid(hieClient.identification_type),
|
|
40
|
+
identifier: hieClient.identification_number,
|
|
41
|
+
location: identifierLocation,
|
|
42
|
+
});
|
|
43
|
+
return identifiers;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function generateAmrsUniversalIdentifier() {
|
|
47
|
+
const abortController = new AbortController();
|
|
48
|
+
const resp = await openmrsFetch(`https://staging.ampath.or.ke/amrs-id-generator/generateidentifier`, {
|
|
49
|
+
headers: {
|
|
50
|
+
'Content-Type': 'application/json',
|
|
51
|
+
},
|
|
52
|
+
method: 'POST',
|
|
53
|
+
body: {
|
|
54
|
+
user: 1,
|
|
55
|
+
},
|
|
56
|
+
signal: abortController.signal,
|
|
57
|
+
});
|
|
58
|
+
const data = await resp.json();
|
|
59
|
+
return data['identifier'] ?? '';
|
|
60
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const SEPARATED_UUID = 'a899aba0-1350-11df-a1f1-0026b9348838';
|
|
2
|
+
const NEVER_MARRIED_UUID = 'a899ac7c-1350-11df-a1f1-0026b9348838';
|
|
3
|
+
const DIVORCED_UUID = 'a899ad58-1350-11df-a1f1-0026b9348838';
|
|
4
|
+
const WIDOWED_UUID = 'a899ae34-1350-11df-a1f1-0026b9348838';
|
|
5
|
+
const MARRIED_UUID = 'a8aa76b0-1350-11df-a1f1-0026b9348838';
|
|
6
|
+
const LIVING_WITH_PARTNER_UUID = 'a899af10-1350-11df-a1f1-0026b9348838';
|
|
7
|
+
const FRIEND_UUID = 'a8aaf07c-1350-11df-a1f1-0026b9348838';
|
|
8
|
+
const NOT_APPLICABLE_UUID = 'a89ad3a4-1350-11df-a1f1-0026b9348838';
|
|
9
|
+
const POLYGAMOUS_UUID = 'a8b03712-1350-11df-a1f1-0026b9348838';
|
|
10
|
+
const PARTNER_UUID = 'a89ebd3e-1350-11df-a1f1-0026b9348838';
|
|
11
|
+
const CASUAL_SEX_PARTNER_UUID = '7831f002-331d-4f07-bf91-6bb65cd31050';
|
|
12
|
+
const OTHER_UUID = 'a8aaf3e2-1350-11df-a1f1-0026b9348838';
|
|
13
|
+
const SINGLE_UUID = 'a899ac7c-1350-11df-a1f1-0026b9348838';
|
|
14
|
+
|
|
15
|
+
export const CivilStatusUids = {
|
|
16
|
+
SEPARATED_UUID,
|
|
17
|
+
NEVER_MARRIED_UUID,
|
|
18
|
+
DIVORCED_UUID,
|
|
19
|
+
WIDOWED_UUID,
|
|
20
|
+
MARRIED_UUID,
|
|
21
|
+
LIVING_WITH_PARTNER_UUID,
|
|
22
|
+
FRIEND_UUID,
|
|
23
|
+
NOT_APPLICABLE_UUID,
|
|
24
|
+
POLYGAMOUS_UUID,
|
|
25
|
+
PARTNER_UUID,
|
|
26
|
+
CASUAL_SEX_PARTNER_UUID,
|
|
27
|
+
SINGLE_UUID,
|
|
28
|
+
OTHER_UUID,
|
|
29
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const CONTACT_PHONE_NUMBER_UUID = '72a759a8-1359-11df-a1f1-0026b9348838';
|
|
2
|
+
const CITIZENSHIP_UUID = '8d871afc-c2cc-11de-8d13-0010c6dffd0f';
|
|
3
|
+
const CONTACT_EMAIL_ADDRESS_UUID = '2f65dbcb-3e58-45a3-8be7-fd1dc9aa0faa';
|
|
4
|
+
const ALTERNATIVE_CONTACT_PHONE_NUMBER_UUID = 'c725f524-c14a-4468-ac19-4a0e6661c930';
|
|
5
|
+
const KRA_PIN_UUID = 'ae683747-b3fc-4e5c-bad3-c3be743b248f';
|
|
6
|
+
const CIVIL_STATUS_UUID = '8d871f2a-c2cc-11de-8d13-0010c6dffd0f';
|
|
7
|
+
const CLIENT_REGISTRY_ID_UUID = 'e068e02b-faac-4baf-bd58-fe6e0c29a81f';
|
|
8
|
+
const PLACE_OF_BIRTH_UUID = '8d8718c2-c2cc-11de-8d13-0010c6dffd0f';
|
|
9
|
+
const EMAIL_UUID = '2f65dbcb-3e58-45a3-8be7-fd1dc9aa0faa';
|
|
10
|
+
const HIGHEST_LEVEL_OF_EDUCATION_UUID = '352b0d51-63c6-47d0-a295-156bebee4fd5';
|
|
11
|
+
const RELIGION_UUID = '4ae16101-cfba-4c08-9c9c-d848e6f609aa';
|
|
12
|
+
const OCCUPATION_UUID = '9e86409f-9c20-42d0-aeb3-f29a4ca0a7a0';
|
|
13
|
+
const NEXT_OF_KIN_CONTACT_PHONE_NUMBER_UUID = 'a657a4f1-9c0f-444b-a1fd-445bb91dd12d';
|
|
14
|
+
const NEXT_OF_KIN_NAME_UUID = '72a75bec-1359-11df-a1f1-0026b9348838';
|
|
15
|
+
const NEXT_OF_KIN_RELATIONSHIP_UUID = '5730994e-c267-426b-87b6-c152b606973d';
|
|
16
|
+
|
|
17
|
+
export const PersonAttributeTypeUuids = {
|
|
18
|
+
CONTACT_PHONE_NUMBER_UUID,
|
|
19
|
+
CITIZENSHIP_UUID,
|
|
20
|
+
CONTACT_EMAIL_ADDRESS_UUID,
|
|
21
|
+
ALTERNATIVE_CONTACT_PHONE_NUMBER_UUID,
|
|
22
|
+
KRA_PIN_UUID,
|
|
23
|
+
CIVIL_STATUS_UUID,
|
|
24
|
+
CLIENT_REGISTRY_ID_UUID,
|
|
25
|
+
PLACE_OF_BIRTH_UUID,
|
|
26
|
+
EMAIL_UUID,
|
|
27
|
+
HIGHEST_LEVEL_OF_EDUCATION_UUID,
|
|
28
|
+
RELIGION_UUID,
|
|
29
|
+
OCCUPATION_UUID,
|
|
30
|
+
NEXT_OF_KIN_CONTACT_PHONE_NUMBER_UUID,
|
|
31
|
+
NEXT_OF_KIN_NAME_UUID,
|
|
32
|
+
NEXT_OF_KIN_RELATIONSHIP_UUID,
|
|
33
|
+
};
|
package/dist/16.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(globalThis.webpackChunk_ampath_esm_dha_workflow_app=globalThis.webpackChunk_ampath_esm_dha_workflow_app||[]).push([[16],{3754:(e,t,n)=>{n.d(t,{A:()=>l});var r=n(72996),a=n.n(r),o=n(70159),i=n.n(o)()(a());i.push([e.id,".-esm-dha-workflow__send-to-triage-modal__formSection___8euyX{display:flex;flex-direction:column;width:100%;row-gap:5px}.-esm-dha-workflow__send-to-triage-modal__formRow___Hf27O{display:flex;flex-direction:row;width:100%;column-gap:5px}.-esm-dha-workflow__send-to-triage-modal__formControl___Gmnpd{display:flex;flex-direction:column;width:40%;row-gap:5px}.-esm-dha-workflow__send-to-triage-modal__actionSection___Dlgbe{display:flex;flex-direction:row;column-gap:5px;margin-top:15px}","",{version:3,sources:["webpack://./src/registry/modal/send-to-triage/send-to-triage.modal.scss"],names:[],mappings:"AAAA,8DACI,YAAA,CACA,qBAAA,CACA,UAAA,CACA,WAAA,CAEJ,0DACG,YAAA,CACA,kBAAA,CACA,UAAA,CACA,cAAA,CAEH,8DACG,YAAA,CACA,qBAAA,CACA,SAAA,CACA,WAAA,CAEH,gEACI,YAAA,CACA,kBAAA,CACA,cAAA,CACA,eAAA",sourcesContent:[".formSection{\n display: flex;\n flex-direction: column;\n width: 100%;\n row-gap: 5px;\n}\n.formRow{\n display: flex;\n flex-direction: row;\n width: 100%;\n column-gap: 5px;\n}\n.formControl{\n display: flex;\n flex-direction: column;\n width: 40%;\n row-gap: 5px;\n}\n.actionSection{\n display: flex;\n flex-direction: row;\n column-gap: 5px;\n margin-top: 15px;\n}"],sourceRoot:""}]),i.locals={formSection:"-esm-dha-workflow__send-to-triage-modal__formSection___8euyX",formRow:"-esm-dha-workflow__send-to-triage-modal__formRow___Hf27O",formControl:"-esm-dha-workflow__send-to-triage-modal__formControl___Gmnpd",actionSection:"-esm-dha-workflow__send-to-triage-modal__actionSection___Dlgbe"};const l=i},6842:(e,t,n)=>{n.d(t,{A:()=>l});var r=n(72996),a=n.n(r),o=n(70159),i=n.n(o)()(a());i.push([e.id,".-esm-dha-workflow__registry-component__registryLayout___PF4WP{display:flex;flex-direction:row;width:100%;row-gap:10px;padding:2% 2%}.-esm-dha-workflow__registry-component__mainContent___qOmrp{display:flex;flex-direction:column;width:100%}.-esm-dha-workflow__registry-component__registryHeader___YIQ62{display:flex;flex-direction:column;row-gap:10px;width:100%}.-esm-dha-workflow__registry-component__registryContent___W1b-9{display:flex;flex-direction:column;width:100%}.-esm-dha-workflow__registry-component__formRow___qlwjG{display:flex;flex-direction:row;width:100%;column-gap:5px;margin-top:10px}.-esm-dha-workflow__registry-component__formControl___R5c2A{width:30%}.-esm-dha-workflow__registry-component__hieData___jx5gt{margin-top:15px;display:flex;flex-direction:column;width:50%;row-gap:10px}.-esm-dha-workflow__registry-component__btnContainer___aXZfC{padding:5px 5px}.-esm-dha-workflow__registry-component__selectionHeader___-zRam{display:flex;flex-direction:column;width:100%;row-gap:5px}.-esm-dha-workflow__registry-component__patientSelect___wgPYw{display:flex;flex-direction:row;width:100%;column-gap:5px}.-esm-dha-workflow__registry-component__patientSelectRadio___3aGYW{width:70%}.-esm-dha-workflow__registry-component__patientConfirmSelection___Py9-y{display:flex;flex-direction:row;width:30%;column-gap:5px}.-esm-dha-workflow__registry-component__formBtn___ok0W6{display:flex;flex-direction:row;column-gap:5px}.-esm-dha-workflow__registry-component__registrySearchBtn___jHA2M{height:30px}","",{version:3,sources:["webpack://./src/registry/registry.component.scss"],names:[],mappings:"AAAA,+DACI,YAAA,CACA,kBAAA,CACA,UAAA,CACA,YAAA,CACA,aAAA,CAEJ,4DACE,YAAA,CACA,qBAAA,CACA,UAAA,CAEF,+DACI,YAAA,CACA,qBAAA,CACA,YAAA,CACA,UAAA,CAEJ,gEACI,YAAA,CACA,qBAAA,CACA,UAAA,CAEJ,wDACI,YAAA,CACA,kBAAA,CACA,UAAA,CACA,cAAA,CACA,eAAA,CAEJ,4DACI,SAAA,CAEJ,wDACI,eAAA,CACA,YAAA,CACA,qBAAA,CACA,SAAA,CACA,YAAA,CAEJ,6DACI,eAAA,CAEJ,gEACI,YAAA,CACA,qBAAA,CACA,UAAA,CACA,WAAA,CAEJ,8DACI,YAAA,CACA,kBAAA,CACA,UAAA,CACA,cAAA,CAEJ,mEACI,SAAA,CAEJ,wEACI,YAAA,CACA,kBAAA,CACA,SAAA,CACA,cAAA,CAEJ,wDACI,YAAA,CACA,kBAAA,CACA,cAAA,CAEJ,kEACI,WAAA",sourcesContent:[".registryLayout{\n display: flex;\n flex-direction: row;\n width: 100%;\n row-gap: 10px;\n padding: 2% 2%;\n}\n.mainContent{\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n.registryHeader{\n display: flex;\n flex-direction: column;\n row-gap: 10px;\n width: 100%;\n}\n.registryContent{\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n.formRow{\n display: flex;\n flex-direction: row;\n width: 100%;\n column-gap: 5px;\n margin-top: 10px;\n}\n.formControl{\n width: 30%;\n}\n.hieData{\n margin-top: 15px;\n display: flex;\n flex-direction: column;\n width: 50%;\n row-gap: 10px;\n}\n.btnContainer{\n padding: 5px 5px;\n}\n.selectionHeader{\n display: flex;\n flex-direction: column;\n width: 100%;\n row-gap: 5px;\n}\n.patientSelect{\n display: flex;\n flex-direction: row;\n width: 100%;\n column-gap: 5px;\n}\n.patientSelectRadio{\n width: 70%;\n}\n.patientConfirmSelection{\n display: flex;\n flex-direction: row;\n width: 30%;\n column-gap: 5px;\n}\n.formBtn{\n display: flex;\n flex-direction: row;\n column-gap: 5px;\n}\n.registrySearchBtn{\n height: 30px;\n}"],sourceRoot:""}]),i.locals={registryLayout:"-esm-dha-workflow__registry-component__registryLayout___PF4WP",mainContent:"-esm-dha-workflow__registry-component__mainContent___qOmrp",registryHeader:"-esm-dha-workflow__registry-component__registryHeader___YIQ62",registryContent:"-esm-dha-workflow__registry-component__registryContent___W1b-9",formRow:"-esm-dha-workflow__registry-component__formRow___qlwjG",formControl:"-esm-dha-workflow__registry-component__formControl___R5c2A",hieData:"-esm-dha-workflow__registry-component__hieData___jx5gt",btnContainer:"-esm-dha-workflow__registry-component__btnContainer___aXZfC",selectionHeader:"-esm-dha-workflow__registry-component__selectionHeader___-zRam",patientSelect:"-esm-dha-workflow__registry-component__patientSelect___wgPYw",patientSelectRadio:"-esm-dha-workflow__registry-component__patientSelectRadio___3aGYW",patientConfirmSelection:"-esm-dha-workflow__registry-component__patientConfirmSelection___Py9-y",formBtn:"-esm-dha-workflow__registry-component__formBtn___ok0W6",registrySearchBtn:"-esm-dha-workflow__registry-component__registrySearchBtn___jHA2M"};const l=i},10540:e=>{e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},41113:e=>{e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}},55056:(e,t,n)=>{e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},70159:e=>{e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=e(t);return t[2]?"@media ".concat(t[2]," {").concat(n,"}"):n})).join("")},t.i=function(e,n,r){"string"==typeof e&&(e=[[null,e,""]]);var a={};if(r)for(var o=0;o<this.length;o++){var i=this[o][0];null!=i&&(a[i]=!0)}for(var l=0;l<e.length;l++){var c=[].concat(e[l]);r&&a[c[0]]||(n&&(c[2]?c[2]="".concat(n," and ").concat(c[2]):c[2]=n),t.push(c))}},t}},72996:e=>{function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}e.exports=function(e){var n,r,a=(r=4,function(e){if(Array.isArray(e))return e}(n=e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=n){var r,a,o=[],i=!0,l=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);i=!0);}catch(e){l=!0,a=e}finally{try{i||null==n.return||n.return()}finally{if(l)throw a}}return o}}(n,r)||function(e,n){if(e){if("string"==typeof e)return t(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}(n,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=a[1],i=a[3];if(!i)return o;if("function"==typeof btoa){var l=btoa(unescape(encodeURIComponent(JSON.stringify(i)))),c="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(l),s="/*# ".concat(c," */"),u=i.sources.map((function(e){return"/*# sourceURL=".concat(i.sourceRoot||"").concat(e," */")}));return[o].concat(u).concat([s]).join("\n")}return[o].join("\n")}},77659:e=>{var t={};e.exports=function(e,n){var r=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},78016:(e,t,n)=>{n.r(t),n.d(t,{default:()=>he});var r=n(69200),a=n(16072),o=n.n(a),i=n(85072),l=n.n(i),c=n(97825),s=n.n(c),u=n(77659),d=n.n(u),m=n(55056),f=n.n(m),p=n(10540),A=n.n(p),y=n(41113),h=n.n(y),_=n(6842),w={};w.styleTagTransform=h(),w.setAttributes=f(),w.insert=d().bind(null,"head"),w.domAPI=s(),w.insertStyleElement=A(),l()(_.A,w);const g=_.A&&_.A.locals?_.A.locals:void 0;var v=["National ID","Alien ID","Passport","Mandate Number","Refugee ID"],b="https://staging.ampath.or.ke/hie";function C(e,t,n,r,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void n(e)}l.done?t(c):Promise.resolve(c).then(r,a)}function E(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){C(o,r,a,i,l,"next",e)}function l(e){C(o,r,a,i,l,"throw",e)}i(void 0)}))}}function x(e,t){var n,r,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=l(0),i.throw=l(1),i.return=l(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(c){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&l[0]?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[2&l[0],a.value]),l[0]){case 0:case 1:a=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!a||l[1]>a[0]&&l[1]<a[3])){o.label=l[1];break}if(6===l[0]&&o.label<a[1]){o.label=a[1],a=l;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(l);break}a[2]&&o.ops.pop(),o.trys.pop();continue}l=t.call(e,o)}catch(e){l=[6,e],r=0}finally{n=a=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,c])}}}function S(e,t){return E((function(){var n,r;return x(this,(function(a){switch(a.label){case 0:return[4,fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})];case 1:return(n=a.sent()).ok?[3,3]:[4,n.text()];case 2:throw r=a.sent(),new Error("Request failed with ".concat(n.status,": ").concat(r));case 3:return[2,n.json()]}}))}))()}function k(e){return E((function(){var t,n;return x(this,(function(r){return t="".concat(b,"/client/search"),n={identificationNumber:e.identificationNumber,identificationType:e.identificationType,locationUuid:e.locationUuid},[2,S(t,n)]}))}))()}var T=n(25987),N=n(84497),P={};P.styleTagTransform=h(),P.setAttributes=f(),P.insert=d().bind(null,"head"),P.domAPI=s(),P.insertStyleElement=A(),l()(N.A,P);const I=N.A&&N.A.locals?N.A.locals:void 0;var O=function(e){for(var t=e.split(""),n=0;n<e.length;n++)n%2==0&&(t[n]="*");return t.join("")},F=function(e){for(var t=e.split(""),n=0;n<e.length;n++)0!=n&&n!==e.length-1&&(t[n]="*");return t.join("")};function R(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function j(e,t,n,r,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void n(e)}l.done?t(c):Promise.resolve(c).then(r,a)}function D(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){j(o,r,a,i,l,"next",e)}function l(e){j(o,r,a,i,l,"throw",e)}i(void 0)}))}}function B(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o=[],i=!0,l=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);i=!0);}catch(e){l=!0,a=e}finally{try{i||null==n.return||n.return()}finally{if(l)throw a}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return R(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?R(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function H(e,t){var n,r,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=l(0),i.throw=l(1),i.return=l(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(c){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&l[0]?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[2&l[0],a.value]),l[0]){case 0:case 1:a=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!a||l[1]>a[0]&&l[1]<a[3])){o.label=l[1];break}if(6===l[0]&&o.label<a[1]){o.label=a[1],a=l;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(l);break}a[2]&&o.ops.pop(),o.trys.pop();continue}l=t.call(e,o)}catch(e){l=[6,e],r=0}finally{n=a=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,c])}}}const Y=function(e){var t=e.requestCustomOtpDto,n=e.phoneNumber,i=e.open,l=e.onModalClose,c=B((0,a.useState)(""),2),s=c[0],u=c[1],d=B((0,a.useState)("DRAFT"),2),m=d[0],f=d[1],p=B((0,a.useState)(!1),2),A=p[0],y=p[1],h=B((0,a.useState)(""),2),_=h[0],w=h[1],g=function(e,t,n){(0,T.showSnackbar)({kind:e,title:t,subtitle:n})};return o().createElement(o().Fragment,null,o().createElement(r.aFV,{open:i,size:"md",onSecondarySubmit:l,onRequestClose:l,onRequestSubmit:function(){window.open("https://afyayangu.go.ke/","_blank")},primaryButtonText:"Register on Afya Yangu",secondaryButtonText:"Cancel"},o().createElement(r.cwr,null,o().createElement("div",{className:I.modalVerificationLayout},o().createElement("div",{className:I.sectionHeader},o().createElement("h4",{className:I.sectionTitle},"One Time Password (OTP)"),o().createElement("h6",null,"Enter one time password to proceed")),o().createElement("div",{className:I.sectionContent},o().createElement("div",{className:I.contentHeader},"DRAFT"===m?o().createElement(o().Fragment,null,o().createElement("h6",null,"Send Code to Phone ",O(n))):o().createElement(o().Fragment,null),"OTP_SENT"===m?o().createElement(o().Fragment,null,o().createElement(r.ksK,{id:"otp-input",labelText:"Enter OTP",value:s,onChange:function(e){return u(e.target.value)},placeholder:"Enter the code sent to your phone"})):o().createElement(o().Fragment,null),"OTP_VERIFIED"===m?o().createElement(o().Fragment,null,o().createElement("h6",null,"OTP Verification Successfull!")):o().createElement(o().Fragment,null))),o().createElement("div",{className:I.sectionAction},"DRAFT"===m?o().createElement(o().Fragment,null,o().createElement(r.$nd,{kind:"primary",onClick:function(){return D((function(){var e,n,r;return H(this,(function(a){switch(a.label){case 0:if(!t.identificationNumber)return g("error","Invalid Identification Value","Please enter a valid ID value"),[2];y(!0),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,(o=t,E((function(){var e,t;return x(this,(function(n){return e="".concat(b,"/client/send-custom-otp"),t={identificationNumber:o.identificationNumber,identificationType:o.identificationType,locationUuid:o.locationUuid},[2,S(e,t)]}))}))())];case 2:return e=a.sent(),w(e.sessionId),f("OTP_SENT"),g("success","OTP sent successfully","A code was sent to ".concat(e.maskedPhone)),[3,5];case 3:return n=a.sent(),r=n.message||"Failed to send OTP",g("error","Error sending OTP",r),[3,5];case 4:return y(!1),[7];case 5:return[2]}var o}))}))()}},A?o().createElement(r.OuH,{description:"Sending OTP..."}):"Send OTP")):o().createElement(o().Fragment,null),"OTP_SENT"===m?o().createElement(o().Fragment,null,o().createElement(r.$nd,{kind:"primary",onClick:function(){return D((function(){var e,n;return H(this,(function(r){switch(r.label){case 0:if(!s.trim())return g("error","Please enter the OTP code",""),[2];y(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,(a={sessionId:_,otp:s,locationUuid:t.locationUuid},E((function(){var e,t;return x(this,(function(n){return e="".concat(b,"/client/validate-custom-otp"),t={sessionId:a.sessionId,otp:a.otp,locationUuid:a.locationUuid},[2,S(e,t)]}))}))())];case 2:return r.sent(),f("OTP_VERIFIED"),(0,T.showSnackbar)({kind:"success",title:"OTP Verified",subtitle:"You can now fetch data from Client Registry."}),[3,5];case 3:return e=r.sent(),n=e.message||"OTP verification failed",(0,T.showSnackbar)({kind:"error",title:"OTP Verification Failed",subtitle:n}),[3,5];case 4:return y(!1),[7];case 5:return[2]}var a}))}))()}},A?o().createElement(r.OuH,{description:"Verifying OTP..."}):"Verify")):o().createElement(o().Fragment,null),"OTP_VERIFIED"===m?o().createElement(o().Fragment,null,o().createElement(r.$nd,{kind:"primary",onClick:l},"Continue")):o().createElement(o().Fragment,null))))))};var U=n(86575),q={};q.styleTagTransform=h(),q.setAttributes=f(),q.insert=d().bind(null,"head"),q.domAPI=s(),q.insertStyleElement=A(),l()(U.A,q);const L=U.A&&U.A.locals?U.A.locals:void 0;function M(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var V=["id","other_identifications","first_name","middle_name","last_name","gender","date_of_birth","is_alive","deceased_datetime","phone","email","civil_status","place_of_birth","citizenship","country","county","sub_county","ward","village_estate","longitude","latitude","identification_type"];const J=function(e){var t=e.client,n=(0,a.useMemo)((function(){return e=t,n={},Object.keys(e).filter((function(e){return V.includes(e)})).forEach((function(t){if("other_identifications"===t){var r=(o=e[t],i={},o.forEach((function(e){i[e.identification_type]=e.identification_number})),i);n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){M(e,t,n[t])}))}return e}({},n,r)}else if("identification_type"===t)n[e.identification_type]=e.identification_number;else{var a=e[t];n[t]=a}var o,i})),n;var e,n}),[t]);return t&&n?o().createElement(o().Fragment,null,o().createElement(r.XIK,null,o().createElement(r.ndF,null,o().createElement(r.Hjg,null,o().createElement(r.A0N,null,"Field"),o().createElement(r.A0N,null,"Value"))),o().createElement(r.BFY,null,Object.keys(n).map((function(e){return o().createElement(r.Hjg,null,o().createElement(r.nA6,null,e),o().createElement(r.nA6,null,n[e]))}))))):o().createElement(o().Fragment,null,o().createElement("h4",null,"No patient Data to Display"))},W=function(){return o().createElement(o().Fragment,null,o().createElement(r.zWQ,{defaultSelected:"sha",legendText:"Patient",onChange:function(e){},name:"payment-options-radio-group"},o().createElement(r.aaP,{id:"sha",labelText:"Social Health Authority",value:"sha"}),o().createElement(r.aaP,{id:"insurance",labelText:"Other Insurance",value:"other"}),o().createElement(r.aaP,{id:"cash",labelText:"Cash",value:"cash"})))},G=function(e){var t=e.client,n=e.open,a=e.onModalClose,i=(e.onSubmit,e.onSendClientToTriage);return t?o().createElement(o().Fragment,null,o().createElement(r.aFV,{open:n,size:"md",onSecondarySubmit:a,onRequestClose:a,onRequestSubmit:function(){window.open("https://afyayangu.go.ke/","_blank")},primaryButtonText:"Register on Afya Yangu",secondaryButtonText:"Cancel"},o().createElement(r.cwr,null,o().createElement("div",{className:L.clientDetailsLayout},o().createElement("div",{className:L.sectionHeader},o().createElement("h4",{className:L.sectionTitle},"Patient/Payment Details")),o().createElement("div",{className:L.sectionContent},o().createElement(r.tUM,null,o().createElement(r.wbY,{contained:!0},o().createElement(r.ozo,null,"Patient Details"),o().createElement(r.ozo,null,"Payment Details")),o().createElement(r.T2N,null,o().createElement(r.KpK,null,o().createElement(J,{client:t})),o().createElement(r.KpK,null,o().createElement(W,null))))),o().createElement("div",{className:L.actionSection},o().createElement("div",{className:L.btnContainer},o().createElement(r.$nd,{kind:"primary"},"Book Appointment")),o().createElement("div",{className:L.btnContainer},o().createElement(r.$nd,{kind:"secondary"},"Walk In Orders")),o().createElement("div",{className:L.btnContainer},o().createElement(r.$nd,{kind:"tertiary",onClick:function(){return i(t.id)}},"Send To Triage"))))))):o().createElement(o().Fragment,null,"No Client data")};function $(e,t,n,r,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void n(e)}l.done?t(c):Promise.resolve(c).then(r,a)}function z(e){return(t=function(){var t,n,r,a;return function(e,t){var n,r,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=l(0),i.throw=l(1),i.return=l(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(c){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&l[0]?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[2&l[0],a.value]),l[0]){case 0:case 1:a=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!a||l[1]>a[0]&&l[1]<a[3])){o.label=l[1];break}if(6===l[0]&&o.label<a[1]){o.label=a[1],a=l;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(l);break}a[2]&&o.ops.pop(),o.trys.pop();continue}l=t.call(e,o)}catch(e){l=[6,e],r=0}finally{n=a=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,c])}}}(this,(function(o){switch(o.label){case 0:return t="".concat(T.restBaseUrl,"/patient"),n=new URLSearchParams({q:e,v:"full",includeDead:"true",limit:"10",totalCount:"true"}).toString(),[4,(0,T.openmrsFetch)("".concat(t,"?").concat(n))];case 1:return(r=o.sent()).ok?[3,3]:[4,r.text()];case 2:throw a=o.sent(),new Error("Request failed with ".concat(r.status,": ").concat(a));case 3:return[2,r.json()]}}))},function(){var e=this,n=arguments;return new Promise((function(r,a){var o=t.apply(e,n);function i(e){$(o,r,a,i,l,"next",e)}function l(e){$(o,r,a,i,l,"throw",e)}i(void 0)}))})();var t}var K=n(3754),X={};X.styleTagTransform=h(),X.setAttributes=f(),X.insert=d().bind(null,"head"),X.domAPI=s(),X.insertStyleElement=A(),l()(K.A,X);const Q=K.A&&K.A.locals?K.A.locals:void 0;function Z(e,t,n,r,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void n(e)}l.done?t(c):Promise.resolve(c).then(r,a)}function ee(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Z(o,r,a,i,l,"next",e)}function l(e){Z(o,r,a,i,l,"throw",e)}i(void 0)}))}}function te(e,t){var n,r,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=l(0),i.throw=l(1),i.return=l(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(c){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&l[0]?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[2&l[0],a.value]),l[0]){case 0:case 1:a=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!a||l[1]>a[0]&&l[1]<a[3])){o.label=l[1];break}if(6===l[0]&&o.label<a[1]){o.label=a[1],a=l;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(l);break}a[2]&&o.ops.pop(),o.trys.pop();continue}l=t.call(e,o)}catch(e){l=[6,e],r=0}finally{n=a=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,c])}}}function ne(e){return ee((function(){var t,n,r,a;return te(this,(function(o){switch(o.label){case 0:return t="".concat(T.restBaseUrl,"/queue"),n=new URLSearchParams({v:"custom:(uuid,display,name,description,service:(uuid,display),allowedPriorities:(uuid,display),allowedStatuses:(uuid,display),location:(uuid,display))",location:e}).toString(),[4,(0,T.openmrsFetch)("".concat(t,"?").concat(n))];case 1:return(r=o.sent()).ok?[3,3]:[4,r.text()];case 2:throw a=o.sent(),new Error("Request failed with ".concat(r.status,": ").concat(a));case 3:return[2,r.json()]}}))}))()}function re(e,t,n,r,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void n(e)}l.done?t(c):Promise.resolve(c).then(r,a)}function ae(e){return(t=function(){var t,n,r;return function(e,t){var n,r,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=l(0),i.throw=l(1),i.return=l(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(c){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&l[0]?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[2&l[0],a.value]),l[0]){case 0:case 1:a=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!a||l[1]>a[0]&&l[1]<a[3])){o.label=l[1];break}if(6===l[0]&&o.label<a[1]){o.label=a[1],a=l;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(l);break}a[2]&&o.ops.pop(),o.trys.pop();continue}l=t.call(e,o)}catch(e){l=[6,e],r=0}finally{n=a=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,c])}}}(this,(function(a){switch(a.label){case 0:return t="".concat(T.restBaseUrl,"/visit"),[4,(0,T.openmrsFetch)(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)})];case 1:return(n=a.sent()).ok?[3,3]:[4,n.text()];case 2:throw r=a.sent(),new Error("Request failed with ".concat(n.status,": ").concat(r));case 3:return[2,n.json()]}}))},function(){var e=this,n=arguments;return new Promise((function(r,a){var o=t.apply(e,n);function i(e){re(o,r,a,i,l,"next",e)}function l(e){re(o,r,a,i,l,"throw",e)}i(void 0)}))})();var t}function oe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ie(e,t,n,r,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void n(e)}l.done?t(c):Promise.resolve(c).then(r,a)}function le(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){ie(o,r,a,i,l,"next",e)}function l(e){ie(o,r,a,i,l,"throw",e)}i(void 0)}))}}function ce(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o=[],i=!0,l=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);i=!0);}catch(e){l=!0,a=e}finally{try{i||null==n.return||n.return()}finally{if(l)throw a}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return oe(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?oe(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function se(e,t){var n,r,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=l(0),i.throw=l(1),i.return=l(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(c){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&l[0]?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[2&l[0],a.value]),l[0]){case 0:case 1:a=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!a||l[1]>a[0]&&l[1]<a[3])){o.label=l[1];break}if(6===l[0]&&o.label<a[1]){o.label=a[1],a=l;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(l);break}a[2]&&o.ops.pop(),o.trys.pop();continue}l=t.call(e,o)}catch(e){l=[6,e],r=0}finally{n=a=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,c])}}}const ue=function(e){var t=e.patients,n=e.open,i=e.onModalClose,l=(e.onSubmit,ce((0,a.useState)(),2)),c=l[0],s=l[1],u=ce((0,a.useState)(),2),d=u[0],m=u[1],f=ce((0,a.useState)(),2),p=f[0],A=f[1],y=ce((0,a.useState)(),2),h=y[0],_=y[1],w=ce((0,a.useState)(""),2),g=w[0],v=w[1],b=ce((0,a.useState)(!1),2),C=b[0],E=b[1],x=(0,T.useVisitTypes)(),S=(0,T.useSession)().sessionLocation.uuid;if((0,a.useEffect)((function(){k()}),[t]),!t)return o().createElement(o().Fragment,null,"No Client data");var k=function(){return le((function(){var e;return se(this,(function(t){switch(t.label){case 0:return[4,ne(S)];case 1:return(e=t.sent())&&e.results&&A(e.results),[2]}}))}))()},N=function(e){return e.location?e.patient?!!e.visitType||(I("error","Please select a visit",""),!1):(I("error","Please select a patient",""),!1):(I("error","Missing location in create visits",""),!1)},P=function(){var e;return{visitType:d,location:S,startDatetime:null,stopDatetime:null,patient:null!==(e=null==c?void 0:c.uuid)&&void 0!==e?e:""}},I=function(e,t,n){(0,T.showSnackbar)({kind:e,title:t,subtitle:n})};return o().createElement(o().Fragment,null,o().createElement(r.aFV,{open:n,size:"md",onSecondarySubmit:function(){return i({success:!1})},onRequestClose:function(){return i({success:!1})},onRequestSubmit:function(){window.open("https://afyayangu.go.ke/","_blank")},primaryButtonText:"Register on Afya Yangu",secondaryButtonText:"Cancel"},o().createElement(r.cwr,null,o().createElement("div",{className:Q.clientDetailsLayout},o().createElement("div",{className:Q.sectionHeader},o().createElement("h4",{className:Q.sectionTitle},"Send To Triage")),o().createElement("div",{className:Q.sectionContent},o().createElement("div",{className:Q.patientSelect},o().createElement(r.XIK,null,o().createElement(r.ndF,null,o().createElement(r.Hjg,null,o().createElement(r.A0N,null,"No"),o().createElement(r.A0N,null,"Name"),o().createElement(r.A0N,null,"DOB"),o().createElement(r.A0N,null,"Select Patient"))),o().createElement(r.BFY,null,t.map((function(e,t){return o().createElement(r.Hjg,{key:e.uuid},o().createElement(r.nA6,null,t+1),o().createElement(r.nA6,null,e.person.preferredName.display),o().createElement(r.nA6,null,e.person.birthdate),o().createElement(r.nA6,null,o().createElement(r.Sc0,{id:e.uuid,labelText:"",onChange:function(){s(e)}})))}))))),o().createElement("div",{className:Q.formSection},o().createElement("div",{className:Q.formRow},o().createElement("div",{className:Q.formControl},o().createElement(r.l6P,{id:"visit-type",labelText:"Select a Visit Type",onChange:function(e){var t=e.target.value;m(t)}},o().createElement(r.ebT,{value:"",text:"Select"}),";",x&&x.map((function(e){return o().createElement(r.ebT,{value:e.uuid,text:e.display})})))),o().createElement("div",{className:Q.formControl},o().createElement(r.l6P,{id:"service",labelText:"Select a Service",onChange:function(e){var t=e.target.value;_(t)}},o().createElement(r.ebT,{value:"",text:"Select"}),";",p&&p.map((function(e){return o().createElement(r.ebT,{value:e.uuid,text:e.display})}))))),o().createElement("div",{className:Q.formRow},o().createElement("div",{className:Q.formControl},o().createElement(r.l6P,{id:"priority",labelText:"Select Priority",onChange:function(e){return t=e.target.value,void v(t);var t}},o().createElement(r.ebT,{value:"",text:"Select"}),";",o().createElement(r.ebT,{value:"bbd99c12-67e9-4381-8b4c-1f231e86f8e2",text:"NORMAL"}),";",o().createElement(r.ebT,{value:"8e86ff12-ec83-41e8-a534-bb410739d880",text:"EMERGENCY"}),";"))))),o().createElement("div",{className:Q.actionSection},o().createElement("div",{className:Q.btnContainer},o().createElement(r.$nd,{kind:"primary",onClick:function(){return le((function(){var e,t;return se(this,(function(n){switch(n.label){case 0:E(!0),n.label=1;case 1:return n.trys.push([1,5,6,7]),[4,le((function(){var e,t;return se(this,(function(n){switch(n.label){case 0:return e=P(),N(e)?[4,ae(e)]:[2,!1];case 1:if(t=n.sent())return I("success","Visit has been created succesfully",""),[2,t];throw I("error","Error creating patient visit",""),new Error("Error creating patient visit")}}))}))()];case 2:return(e=n.sent())?(r=e.uuid,t={visit:{uuid:r},queueEntry:{status:{uuid:"89d01aa5-0ab0-4626-934b-37766b4cd779"},priority:{uuid:g},queue:{uuid:h},patient:{uuid:c.uuid},startedAt:(new Date).toISOString(),sortWeight:0}},[4,(a=t,ee((function(){var e,t,n;return te(this,(function(r){switch(r.label){case 0:return e="".concat(T.restBaseUrl,"/visit-queue-entry"),[4,(0,T.openmrsFetch)(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(a)})];case 1:return(t=r.sent()).ok?[3,3]:[4,t.text()];case 2:throw n=r.sent(),new Error("Request failed with ".concat(t.status,": ").concat(n));case 3:return[2,t.json()]}}))}))())]):[3,4];case 3:n.sent()&&(I("success","Patient has succesfully been moved to the Triage queue",""),i({success:!0})),n.label=4;case 4:return[3,7];case 5:return n.sent(),I("error","Error creating visit",""),[3,7];case 6:return E(!1),[7];case 7:return[2]}var r,a}))}))()}},C?o().createElement(r.OuH,{description:"Sending To Triage..."}):"Send To Triage")))))))};var de=n(27114);function me(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function fe(e,t,n,r,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void n(e)}l.done?t(c):Promise.resolve(c).then(r,a)}function pe(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){fe(o,r,a,i,l,"next",e)}function l(e){fe(o,r,a,i,l,"throw",e)}i(void 0)}))}}function Ae(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o=[],i=!0,l=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);i=!0);}catch(e){l=!0,a=e}finally{try{i||null==n.return||n.return()}finally{if(l)throw a}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return me(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?me(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ye(e,t){var n,r,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=l(0),i.throw=l(1),i.return=l(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(c){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&l[0]?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[2&l[0],a.value]),l[0]){case 0:case 1:a=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,r=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==l[0]&&2!==l[0])){o=0;continue}if(3===l[0]&&(!a||l[1]>a[0]&&l[1]<a[3])){o.label=l[1];break}if(6===l[0]&&o.label<a[1]){o.label=a[1],a=l;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(l);break}a[2]&&o.ops.pop(),o.trys.pop();continue}l=t.call(e,o)}catch(e){l=[6,e],r=0}finally{n=a=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,c])}}}const he=function(){var e=Ae((0,a.useState)("National ID"),2),t=e[0],n=e[1],i=Ae((0,a.useState)(""),2),l=i[0],c=i[1],s=Ae((0,a.useState)(!1),2),u=s[0],d=s[1],m=Ae((0,a.useState)(),2),f=m[0],p=m[1],A=Ae((0,a.useState)(),2),y=A[0],h=A[1],_=Ae((0,a.useState)("principal"),2),w=_[0],b=_[1],C=Ae((0,a.useState)(!1),2),E=C[0],x=C[1],S=Ae((0,a.useState)(!1),2),N=S[0],P=S[1],I=Ae((0,a.useState)(!1),2),R=I[0],j=I[1],D=Ae((0,a.useState)(),2),B=D[0],H=D[1],U=(0,T.useSession)().sessionLocation.uuid,q=(0,de.useNavigate)(),L=function(e,t,n){(0,T.showSnackbar)({kind:e,title:t,subtitle:n})},M=function(){P(!1)};return o().createElement(o().Fragment,null,o().createElement("div",{className:g.registryLayout},o().createElement("div",{className:g.mainContent},o().createElement("div",{className:g.registryHeader},o().createElement("h4",null,"Client Registry"),o().createElement("p",null,"Please enter identification number to begin")),o().createElement("div",{className:g.registryContent},o().createElement("div",{className:g.formRow},o().createElement("div",{className:g.formControl},o().createElement(r.msM,{id:"identifier-type-dropdown",label:"Identifier Type",titleText:"Select Identifier Type",items:v,selectedItem:t,onChange:function(e){var t=e.selectedItem;return n(t)}})),o().createElement("div",{className:g.formControl},o().createElement(r.ksK,{id:"identifier-value",labelText:"".concat(t," Value"),value:l,onChange:function(e){return c(e.target.value)},placeholder:"Enter ".concat(t.toLowerCase()," value")}))),o().createElement("div",{className:g.formRow},o().createElement("div",{className:g.formControl},o().createElement("div",{className:g.formBtn},o().createElement(r.$nd,{className:g.registrySearchBtn,kind:"primary",onClick:function(){return pe((function(){var e,n,r,a,o,i;return ye(this,(function(c){switch(c.label){case 0:d(!0),c.label=1;case 1:return c.trys.push([1,3,4,5]),function(e){return e.identificationNumber?e.identificationType?!!e.locationUuid||(L("error","No default location selected",""),!1):(L("error","Please enter a valid identification type",""),!1):(L("error","Please enter a valid identification number",""),!1)}(e={identificationNumber:l,identificationType:t,locationUuid:U})?(H(e),[4,k(e)]):[2,!1];case 2:if(n=c.sent(),0===(r=Array.isArray(n)?n:[]).length)throw new Error("No matching patient found in Client Registry.");return a=r[0],p(a),L("success","Client Data Loaded","Patient fetched successfully"),[3,5];case 3:return o=c.sent(),i=o.message||"Failed to fetch client data",L("error","Fetch Failed",i),[3,5];case 4:return d(!1),[7];case 5:return[2]}}))}))()},disabled:u},u?o().createElement(r.OuH,{description:"Searching..."}):"Search"),o().createElement(r.$nd,{className:g.registrySearchBtn,kind:"secondary",onClick:function(){window.location.href="".concat(window.spaBase,"/patient-registration")},disabled:u},"Emergency Registration")))),f?o().createElement("div",{className:g.formRow},o().createElement("div",{className:g.hieData},o().createElement("div",{className:g.selectionHeader},o().createElement("h5",null,"Please select one patient and request patient to share the OTP sent")),o().createElement("div",{className:g.patientSelect},o().createElement("div",{className:g.patientSelectRadio},o().createElement(r.zWQ,{defaultSelected:"principal",legendText:"Patient",onChange:function(e){b(e)},name:"radio-button-default-group"},o().createElement(r.aaP,{id:"principal",labelText:"Principal",value:"principal"}),o().createElement(r.aaP,{id:"dependants",labelText:"Dependants",value:"dependants"}))),o().createElement("div",{className:g.patientConfirmSelection},o().createElement("div",{className:g.btnContainer},o().createElement(r.$nd,{kind:"primary",onClick:function(){x(!0)}}," ","Confirm")),o().createElement("div",{className:g.btnContainer},o().createElement(r.$nd,{kind:"secondary"},"Cancel")))),"principal"===w?o().createElement(o().Fragment,null,o().createElement(r.XIK,null,o().createElement(r.ndF,null,o().createElement(r.Hjg,null,o().createElement(r.A0N,null,"Name"),o().createElement(r.A0N,null,"CR"),o().createElement(r.A0N,null,"Phone No"),o().createElement(r.A0N,null,"ID No"))),o().createElement(r.BFY,null,o().createElement(r.Hjg,null,o().createElement(r.nA6,null,f.first_name," ",F(f.middle_name)," ",F(f.last_name)),o().createElement(r.nA6,null,O(f.id)),o().createElement(r.nA6,null,O(f.phone)),o().createElement(r.nA6,null,O(f.identification_number)))))):o().createElement(o().Fragment,null),"dependants"===w?o().createElement(o().Fragment,null,o().createElement(r.XIK,null,o().createElement(r.ndF,null,o().createElement(r.Hjg,null,o().createElement(r.A0N,null,"Name"),o().createElement(r.A0N,null,"CR"),o().createElement(r.A0N,null,"Relationship"))),o().createElement(r.BFY,null,f.dependants.map((function(e){var t=e.result[0],n=e.relationship;return o().createElement(o().Fragment,null,o().createElement(r.Hjg,null,o().createElement(r.nA6,null,t.first_name," ",F(t.middle_name)," ",F(t.last_name)),o().createElement(r.nA6,null,O(t.id)),o().createElement(r.nA6,null,n)))}))))):o().createElement(o().Fragment,null),E?o().createElement(Y,{requestCustomOtpDto:B,phoneNumber:f.phone,open:E,onModalClose:function(){x(!1),P(!0)}}):o().createElement(o().Fragment,null),f&&N?o().createElement(o().Fragment,null,o().createElement(G,{client:f,open:N,onModalClose:M,onSubmit:function(){},onSendClientToTriage:function(e){return pe((function(){var t;return ye(this,(function(n){switch(n.label){case 0:return M(),[4,z(e)];case 1:return(t=n.sent()).totalCount>0&&(h(t.results),j(!0)),[2]}}))}))()}})," "):o().createElement(o().Fragment,null),f&&R?o().createElement(o().Fragment,null,o().createElement(ue,{patients:y,open:R,onModalClose:function(e){j(!1),e&&e.success&&q("/triage")},onSubmit:function(){}})):o().createElement(o().Fragment,null))):o().createElement(o().Fragment,null)))))}},84497:(e,t,n)=>{n.d(t,{A:()=>l});var r=n(72996),a=n.n(r),o=n(70159),i=n.n(o)()(a());i.push([e.id,".-esm-dha-workflow__otp-verification-modal__modalVerificationLayout___MST8n{display:flex;flex-direction:column;row-gap:10px;width:100%}.-esm-dha-workflow__otp-verification-modal__sectionHeader___g62oo{display:flex;flex-direction:column;column-gap:5px;margin-top:5px;margin-bottom:5px}","",{version:3,sources:["webpack://./src/registry/modal/otp-verification-modal/otp-verification-modal.scss"],names:[],mappings:"AAAA,4EACE,YAAA,CACA,qBAAA,CACA,YAAA,CACA,UAAA,CAEF,kEACE,YAAA,CACA,qBAAA,CACA,cAAA,CACA,cAAA,CACA,iBAAA",sourcesContent:[".modalVerificationLayout {\n display: flex;\n flex-direction: column;\n row-gap: 10px;\n width: 100%;\n}\n.sectionHeader{\n display: flex;\n flex-direction: column;\n column-gap: 5px;\n margin-top: 5px;\n margin-bottom: 5px;\n}"],sourceRoot:""}]),i.locals={modalVerificationLayout:"-esm-dha-workflow__otp-verification-modal__modalVerificationLayout___MST8n",sectionHeader:"-esm-dha-workflow__otp-verification-modal__sectionHeader___g62oo"};const l=i},85072:e=>{var t=[];function n(e){for(var n=-1,r=0;r<t.length;r++)if(t[r].identifier===e){n=r;break}return n}function r(e,r){for(var o={},i=[],l=0;l<e.length;l++){var c=e[l],s=r.base?c[0]+r.base:c[0],u=o[s]||0,d="".concat(s," ").concat(u);o[s]=u+1;var m=n(d),f={css:c[1],media:c[2],sourceMap:c[3],supports:c[4],layer:c[5]};if(-1!==m)t[m].references++,t[m].updater(f);else{var p=a(f,r);r.byIndex=l,t.splice(l,0,{identifier:d,updater:p,references:1})}i.push(d)}return i}function a(e,t){var n=t.domAPI(t);return n.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;n.update(e=t)}else n.remove()}}e.exports=function(e,a){var o=r(e=e||[],a=a||{});return function(e){e=e||[];for(var i=0;i<o.length;i++){var l=n(o[i]);t[l].references--}for(var c=r(e,a),s=0;s<o.length;s++){var u=n(o[s]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}o=c}}},86575:(e,t,n)=>{n.d(t,{A:()=>l});var r=n(72996),a=n.n(r),o=n(70159),i=n.n(o)()(a());i.push([e.id,".-esm-dha-workflow__client-details-modal__clientDetailsLayout___r5WF\\+{display:flex;flex-direction:column;width:100%;row-gap:5px}.-esm-dha-workflow__client-details-modal__sectionHeader___lH-gL{display:flex;flex-direction:column;row-gap:5px;margin-top:5px;margin-bottom:10px}.-esm-dha-workflow__client-details-modal__sectionContent___QDFT7{display:flex;flex-direction:column;row-gap:5px}.-esm-dha-workflow__client-details-modal__actionSection___okVDp{display:flex;flex-direction:row;width:100%;column-gap:5px}.-esm-dha-workflow__client-details-modal__btnContainer___ETNEk{margin-top:2px;margin-bottom:2px}","",{version:3,sources:["webpack://./src/registry/modal/client-details-modal/client-details-modal.scss"],names:[],mappings:"AAAA,uEACI,YAAA,CACA,qBAAA,CACA,UAAA,CACA,WAAA,CAEJ,gEACI,YAAA,CACA,qBAAA,CACA,WAAA,CACA,cAAA,CACA,kBAAA,CAEJ,iEACI,YAAA,CACA,qBAAA,CACA,WAAA,CAEJ,gEACI,YAAA,CACA,kBAAA,CACA,UAAA,CACA,cAAA,CAEJ,+DACI,cAAA,CACA,iBAAA",sourcesContent:[".clientDetailsLayout{\n display: flex;\n flex-direction: column;\n width: 100%;\n row-gap: 5px;\n}\n.sectionHeader{\n display: flex;\n flex-direction: column;\n row-gap: 5px;\n margin-top: 5px;\n margin-bottom: 10px;\n}\n.sectionContent{\n display: flex;\n flex-direction: column;\n row-gap: 5px;\n}\n.actionSection{\n display: flex;\n flex-direction: row;\n width: 100%;\n column-gap: 5px;\n}\n.btnContainer{\n margin-top: 2px;\n margin-bottom: 2px;\n}"],sourceRoot:""}]),i.locals={clientDetailsLayout:"-esm-dha-workflow__client-details-modal__clientDetailsLayout___r5WF+",sectionHeader:"-esm-dha-workflow__client-details-modal__sectionHeader___lH-gL",sectionContent:"-esm-dha-workflow__client-details-modal__sectionContent___QDFT7",actionSection:"-esm-dha-workflow__client-details-modal__actionSection___okVDp",btnContainer:"-esm-dha-workflow__client-details-modal__btnContainer___ETNEk"};const l=i},97825:e=>{e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var a=void 0!==n.layer;a&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,a&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var o=n.sourceMap;o&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),t.styleTagTransform(r,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}}}]);
|