@ampath/esm-patient-registration-app 9.2.0-next.17 → 9.2.0-next.19
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/2498.js +2 -0
- package/dist/2498.js.map +1 -0
- package/dist/2523.js +1 -0
- package/dist/2523.js.map +1 -0
- package/dist/5239.js +1 -1
- package/dist/5239.js.map +1 -1
- package/dist/6276.js +1 -1
- package/dist/6276.js.map +1 -1
- package/dist/6583.js +1 -0
- package/dist/6583.js.map +1 -0
- package/dist/7821.js +1 -1
- package/dist/7821.js.map +1 -1
- package/dist/8414.js +1 -1
- package/dist/8414.js.map +1 -1
- package/dist/8434.js +1 -1
- package/dist/8434.js.map +1 -1
- package/dist/9853.js +1 -0
- package/dist/9853.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 +109 -109
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/patient-registration/client-registry/client-registry-search.component.tsx +164 -68
- package/src/patient-registration/client-registry/client-registry-search.scss +26 -0
- package/src/patient-registration/client-registry/existing-client/client-dependants-comparison/client-dependants-comparison.component.tsx +26 -0
- package/src/patient-registration/client-registry/existing-client/client-dependants-comparison/dependant-comparison-rows.component.tsx +153 -0
- package/src/patient-registration/client-registry/existing-client/client-details-comparison/client-details-comparison.component.tsx +181 -0
- package/src/patient-registration/client-registry/existing-client/client-details-comparison/comparison-table-row.component.tsx +42 -0
- package/src/patient-registration/client-registry/existing-client/client-registry-verification-tag.component.tsx +54 -0
- package/src/patient-registration/client-registry/existing-client/existing-client-tab.component.tsx +85 -0
- package/src/patient-registration/client-registry/existing-client/existing-client.resource.ts +78 -0
- package/src/patient-registration/client-registry/existing-client/mapper-utils.ts +419 -0
- package/src/patient-registration/client-registry/existing-client/types/index.ts +185 -0
- package/src/patient-registration/client-registry/hie-client-adapter.ts +56 -0
- package/src/patient-registration/client-registry/new-client/client-dependants/list/client-depandants.component.tsx +55 -0
- package/src/patient-registration/client-registry/new-client/client-details/client-details.tsx +42 -0
- package/src/patient-registration/client-registry/new-client/new-client-tab.component.tsx +30 -0
- package/src/patient-registration/client-registry/types/index.ts +210 -0
- package/src/patient-registration/custom-patient-registration.scss +6 -0
- package/src/patient-registration/patient-registration.component.tsx +24 -12
- package/src/widgets/client-registry-verification.modal.tsx +13 -0
- package/dist/4395.js +0 -1
- package/dist/4395.js.map +0 -1
- package/dist/6996.js +0 -1
- package/dist/6996.js.map +0 -1
- package/dist/8882.js +0 -1
- package/dist/8882.js.map +0 -1
- package/dist/9933.js +0 -2
- package/dist/9933.js.map +0 -1
- /package/dist/{9933.js.LICENSE.txt → 2498.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { TableRow, TableCell, Checkbox } from '@carbon/react';
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
|
+
import { type ComparisonTableRowProps } from '../types';
|
|
4
|
+
|
|
5
|
+
const ComparisonTableRow: React.FC<ComparisonTableRowProps> = ({
|
|
6
|
+
field,
|
|
7
|
+
label,
|
|
8
|
+
amrsValue,
|
|
9
|
+
hieValue,
|
|
10
|
+
onChange,
|
|
11
|
+
allChecked,
|
|
12
|
+
}) => {
|
|
13
|
+
const [checked, setChecked] = useState(false);
|
|
14
|
+
const randomString = Math.random().toString(10).substring(2, 6).toUpperCase();
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
onChange?.(allChecked, field, hieValue, true);
|
|
17
|
+
setChecked(allChecked);
|
|
18
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
+
}, [allChecked]);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<TableRow>
|
|
23
|
+
<TableCell>
|
|
24
|
+
<p style={{ color: amrsValue!.trim().toUpperCase() == hieValue!.trim().toUpperCase() ? '' : 'red' }}>{label}</p>
|
|
25
|
+
</TableCell>
|
|
26
|
+
<TableCell>{amrsValue}</TableCell>
|
|
27
|
+
<TableCell>{hieValue}</TableCell>
|
|
28
|
+
<TableCell>
|
|
29
|
+
<Checkbox
|
|
30
|
+
id={`cbox-${randomString}`}
|
|
31
|
+
onChange={(e) => {
|
|
32
|
+
onChange(e.target.checked, field, hieValue, false);
|
|
33
|
+
setChecked(e.target.checked);
|
|
34
|
+
}}
|
|
35
|
+
checked={checked}
|
|
36
|
+
/>
|
|
37
|
+
</TableCell>
|
|
38
|
+
</TableRow>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default ComparisonTableRow;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Button } from '@carbon/react';
|
|
3
|
+
import { age, usePatient } from '@openmrs/esm-framework';
|
|
4
|
+
import { Formik } from 'formik';
|
|
5
|
+
import ClientRegistryLookupSection from '../client-registry-search.component';
|
|
6
|
+
|
|
7
|
+
const ClientRegistryVerificationTag = () => {
|
|
8
|
+
const { patient } = usePatient();
|
|
9
|
+
const [showCrBtn, setShowCrBtn] = useState(false);
|
|
10
|
+
const [showVerifyModal, setShowVerifyModal] = useState(false);
|
|
11
|
+
const [isClientVerified, setIsClientVerified] = useState(false);
|
|
12
|
+
const initialFormValues = {};
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (patient && patient.birthDate) {
|
|
16
|
+
const ageArr = age(patient.birthDate).split(' ');
|
|
17
|
+
if (ageArr.includes('yrs')) {
|
|
18
|
+
const yrs = Number(ageArr[0]);
|
|
19
|
+
setShowCrBtn(yrs > 17);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}, [patient]);
|
|
23
|
+
|
|
24
|
+
const openVerifyModal = () => {
|
|
25
|
+
setShowVerifyModal(true);
|
|
26
|
+
};
|
|
27
|
+
const closeVerifyModal = () => {
|
|
28
|
+
setShowVerifyModal(false);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return showCrBtn ? (
|
|
32
|
+
<>
|
|
33
|
+
<Button kind="ghost" style={{ backgroundColor: 'purple', color: 'white' }} onClick={openVerifyModal}>
|
|
34
|
+
Verify CR
|
|
35
|
+
</Button>
|
|
36
|
+
{showVerifyModal ? (
|
|
37
|
+
<Formik enableReinitialize initialValues={initialFormValues} onSubmit={null}>
|
|
38
|
+
<ClientRegistryLookupSection
|
|
39
|
+
onClientVerified={() => setIsClientVerified(true)}
|
|
40
|
+
onModalClose={closeVerifyModal}
|
|
41
|
+
open={showVerifyModal}
|
|
42
|
+
isNewClient={false}
|
|
43
|
+
/>
|
|
44
|
+
</Formik>
|
|
45
|
+
) : (
|
|
46
|
+
<></>
|
|
47
|
+
)}
|
|
48
|
+
</>
|
|
49
|
+
) : (
|
|
50
|
+
<></>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default ClientRegistryVerificationTag;
|
package/src/patient-registration/client-registry/existing-client/existing-client-tab.component.tsx
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { Tabs, TabList, Tab, TabPanels, TabPanel, InlineLoading } from '@carbon/react';
|
|
3
|
+
import { type HieClient } from '../types';
|
|
4
|
+
import ClientDetailsComparison from './client-details-comparison/client-details-comparison.component';
|
|
5
|
+
import { type CustomRelationship, type AmrsClient } from './types';
|
|
6
|
+
import ClientDependantsComparison from './client-dependants-comparison/client-dependants-comparison.component';
|
|
7
|
+
import { showSnackbar, usePatient } from '@openmrs/esm-framework';
|
|
8
|
+
import { fetchAmrsPatientData, getRelationships } from './existing-client.resource';
|
|
9
|
+
|
|
10
|
+
interface ExistingClientTabProps {
|
|
11
|
+
hieClient: HieClient;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const ExistingClientTab: React.FC<ExistingClientTabProps> = ({ hieClient }) => {
|
|
15
|
+
const [amrsClient, setAmrsClient] = useState<AmrsClient>();
|
|
16
|
+
const [loading, setLoading] = useState<boolean>(false);
|
|
17
|
+
const { patientUuid } = usePatient();
|
|
18
|
+
const [relationships, setRelationships] = useState<Array<CustomRelationship>>([]);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (patientUuid) {
|
|
22
|
+
handleAmrsPersonDetails();
|
|
23
|
+
handleFetchPatientRelationships();
|
|
24
|
+
}
|
|
25
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
|
+
}, [patientUuid]);
|
|
27
|
+
|
|
28
|
+
const handleFetchPatientRelationships = async () => {
|
|
29
|
+
const resp = await getRelationships(patientUuid);
|
|
30
|
+
if (resp) {
|
|
31
|
+
setRelationships(resp);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const handleAmrsPersonDetails = async () => {
|
|
36
|
+
try {
|
|
37
|
+
setLoading(true);
|
|
38
|
+
const response = await fetchAmrsPatientData(patientUuid);
|
|
39
|
+
if (response) {
|
|
40
|
+
setAmrsClient(response.data);
|
|
41
|
+
}
|
|
42
|
+
showSnackbar({
|
|
43
|
+
kind: 'success',
|
|
44
|
+
title: 'AMRS person data fetched successfully.',
|
|
45
|
+
});
|
|
46
|
+
} catch (er) {
|
|
47
|
+
showSnackbar({
|
|
48
|
+
kind: 'error',
|
|
49
|
+
title: 'Error fetching AMRS person data.',
|
|
50
|
+
subtitle: JSON.stringify(er),
|
|
51
|
+
});
|
|
52
|
+
} finally {
|
|
53
|
+
setLoading(false);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return loading ? (
|
|
58
|
+
<InlineLoading description="Fetching existing client details..." />
|
|
59
|
+
) : (
|
|
60
|
+
<Tabs>
|
|
61
|
+
<TabList contained>
|
|
62
|
+
<Tab>Patient</Tab>
|
|
63
|
+
<Tab>Dependants</Tab>
|
|
64
|
+
</TabList>
|
|
65
|
+
<TabPanels>
|
|
66
|
+
<TabPanel>
|
|
67
|
+
{hieClient && <ClientDetailsComparison hieClient={hieClient} amrsClient={amrsClient} fromDependant={false} />}
|
|
68
|
+
</TabPanel>
|
|
69
|
+
<TabPanel>
|
|
70
|
+
{hieClient && hieClient.dependants ? (
|
|
71
|
+
<ClientDependantsComparison
|
|
72
|
+
hieDependants={hieClient.dependants}
|
|
73
|
+
amrsClient={amrsClient}
|
|
74
|
+
patientRelationships={relationships}
|
|
75
|
+
/>
|
|
76
|
+
) : (
|
|
77
|
+
<div>Dependants not found.</div>
|
|
78
|
+
)}
|
|
79
|
+
</TabPanel>
|
|
80
|
+
</TabPanels>
|
|
81
|
+
</Tabs>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default ExistingClientTab;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
2
|
+
import { type AmrsClient } from './types';
|
|
3
|
+
import { mapAmrsPatientRelationship } from './mapper-utils';
|
|
4
|
+
|
|
5
|
+
export async function fetchAmrsPatientData(patientUuid: string) {
|
|
6
|
+
return await openmrsFetch<AmrsClient>(`${restBaseUrl}/patient/${patientUuid}?v=full`, {
|
|
7
|
+
method: 'GET',
|
|
8
|
+
}).catch((err) => {
|
|
9
|
+
console.error(err);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function updateAmrsPersonIdentifiers(
|
|
14
|
+
patientUuid: string,
|
|
15
|
+
identifierUuid: string,
|
|
16
|
+
payload: unknown,
|
|
17
|
+
fromDependant = false,
|
|
18
|
+
) {
|
|
19
|
+
const resource = fromDependant ? 'person' : 'patient';
|
|
20
|
+
return await openmrsFetch(`${restBaseUrl}/${resource}/${patientUuid}/identifier/${identifierUuid}`, {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
headers: {
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
},
|
|
25
|
+
body: payload,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export async function fetchAmrsPersonData(personUuid: string) {
|
|
30
|
+
return await openmrsFetch(`${restBaseUrl}/person/${personUuid}?v=full`, {
|
|
31
|
+
method: 'GET',
|
|
32
|
+
}).catch((err) => {
|
|
33
|
+
console.error(err);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function updatePerson(patientUuid: string, payload: unknown) {
|
|
38
|
+
return await openmrsFetch<AmrsClient>(`${restBaseUrl}/person/${patientUuid}`, {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
headers: {
|
|
41
|
+
'Content-Type': 'application/json',
|
|
42
|
+
},
|
|
43
|
+
body: payload,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function createPerson(payload: unknown) {
|
|
48
|
+
return await openmrsFetch<AmrsClient>(`${restBaseUrl}/person`, {
|
|
49
|
+
method: 'POST',
|
|
50
|
+
headers: {
|
|
51
|
+
'Content-Type': 'application/json',
|
|
52
|
+
},
|
|
53
|
+
body: payload,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export async function createRelationship(payload: unknown) {
|
|
58
|
+
return await openmrsFetch(`${restBaseUrl}/relationship`, {
|
|
59
|
+
method: 'POST',
|
|
60
|
+
headers: {
|
|
61
|
+
'Content-Type': 'application/json',
|
|
62
|
+
},
|
|
63
|
+
body: payload,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export async function getRelationships(patientUuid: string) {
|
|
68
|
+
const response = await openmrsFetch(`${restBaseUrl}/relationship?person=${patientUuid}&v=full`, {
|
|
69
|
+
method: 'GET',
|
|
70
|
+
headers: {
|
|
71
|
+
'Content-Type': 'application/json',
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
if (response && response.data) {
|
|
75
|
+
return mapAmrsPatientRelationship(patientUuid, response.data.results);
|
|
76
|
+
}
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import { HieAttributeType, type HieClient, HieIdentificationType } from '../types';
|
|
3
|
+
import {
|
|
4
|
+
type AmrsClient,
|
|
5
|
+
type CustomRelationship,
|
|
6
|
+
IdentifierTypesUuids,
|
|
7
|
+
PersonAttributeTypeUuids,
|
|
8
|
+
RelationshipTypeUuids,
|
|
9
|
+
} from './types';
|
|
10
|
+
|
|
11
|
+
export const nameFields = ['givenName', 'middleName', 'familyName'];
|
|
12
|
+
|
|
13
|
+
export const addressFields = [
|
|
14
|
+
'country',
|
|
15
|
+
'countyDistrict',
|
|
16
|
+
'address2',
|
|
17
|
+
'address7',
|
|
18
|
+
'cityVillage',
|
|
19
|
+
'longitude',
|
|
20
|
+
'latitude',
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export const personSyncFields = [...nameFields, 'gender', 'birthdate', ...addressFields];
|
|
24
|
+
|
|
25
|
+
export const identifiersSyncFields = () => Object.keys(HieIdentificationType);
|
|
26
|
+
|
|
27
|
+
export const attributesSyncFields = () => Object.keys(HieAttributeType);
|
|
28
|
+
|
|
29
|
+
export const getIdentifierUuid = (identifier: string) => {
|
|
30
|
+
let val = '';
|
|
31
|
+
switch (identifier) {
|
|
32
|
+
case HieIdentificationType.AlienID:
|
|
33
|
+
val = IdentifierTypesUuids.ALIEN_ID_UUID;
|
|
34
|
+
break;
|
|
35
|
+
case HieIdentificationType.HouseholdNumber:
|
|
36
|
+
val = IdentifierTypesUuids.HOUSE_HOLD_NUMBER_UUID;
|
|
37
|
+
break;
|
|
38
|
+
case HieIdentificationType.MandateNumber:
|
|
39
|
+
val = IdentifierTypesUuids.MANDATE_NUMBER_UUID;
|
|
40
|
+
break;
|
|
41
|
+
case HieIdentificationType.Cr:
|
|
42
|
+
val = IdentifierTypesUuids.CLIENT_REGISTRY_NO_UUID;
|
|
43
|
+
break;
|
|
44
|
+
case HieIdentificationType.NationalID:
|
|
45
|
+
val = IdentifierTypesUuids.NATIONAL_ID_UUID;
|
|
46
|
+
break;
|
|
47
|
+
case HieIdentificationType.RefugeeID:
|
|
48
|
+
val = IdentifierTypesUuids.REFUGEE_ID_UUID;
|
|
49
|
+
break;
|
|
50
|
+
case HieIdentificationType.SHANumber:
|
|
51
|
+
val = IdentifierTypesUuids.SHA_UUID;
|
|
52
|
+
break;
|
|
53
|
+
case HieIdentificationType.TemporaryDependantID:
|
|
54
|
+
val = IdentifierTypesUuids.TEMPORARY_DEPENDANT_ID_UUID;
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
val = '';
|
|
58
|
+
}
|
|
59
|
+
return val;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const getAttributeUuid = (attribute: string) => {
|
|
63
|
+
let val = '';
|
|
64
|
+
switch (attribute) {
|
|
65
|
+
case HieAttributeType.Citizenship:
|
|
66
|
+
val = PersonAttributeTypeUuids.CITIZENSHIP_UUID;
|
|
67
|
+
break;
|
|
68
|
+
case HieAttributeType.CivilStatus:
|
|
69
|
+
val = PersonAttributeTypeUuids.CIVIL_STATUS_UUID;
|
|
70
|
+
break;
|
|
71
|
+
case HieAttributeType.Email:
|
|
72
|
+
val = PersonAttributeTypeUuids.CONTACT_EMAIL_ADDRESS_UUID;
|
|
73
|
+
break;
|
|
74
|
+
case HieAttributeType.KRAPin:
|
|
75
|
+
val = PersonAttributeTypeUuids.KRA_PIN_UUID;
|
|
76
|
+
break;
|
|
77
|
+
case HieAttributeType.Phone:
|
|
78
|
+
val = PersonAttributeTypeUuids.CONTACT_PHONE_NUMBER_UUID;
|
|
79
|
+
break;
|
|
80
|
+
case HieAttributeType.PlaceOfBirth:
|
|
81
|
+
val = PersonAttributeTypeUuids.PLACE_OF_BIRTH_UUID;
|
|
82
|
+
break;
|
|
83
|
+
case HieAttributeType.Cr:
|
|
84
|
+
val = PersonAttributeTypeUuids.CLIENT_REGISTRY_ID_UUID;
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
val = '';
|
|
88
|
+
}
|
|
89
|
+
return val;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const getAmrsRelationshipTypeUuid = (relationshipType: string) => {
|
|
93
|
+
let relationShipTypeUuid = '';
|
|
94
|
+
switch (relationshipType) {
|
|
95
|
+
case 'Spouse':
|
|
96
|
+
relationShipTypeUuid = RelationshipTypeUuids.SPOUSE_UUID;
|
|
97
|
+
break;
|
|
98
|
+
case 'Child':
|
|
99
|
+
relationShipTypeUuid = RelationshipTypeUuids.PARENT_CHILD_UUID;
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
relationShipTypeUuid = RelationshipTypeUuids.OTHER_NON_CODED_UUID;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return relationShipTypeUuid;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const patientObjFields = [...personSyncFields, ...identifiersSyncFields()];
|
|
109
|
+
|
|
110
|
+
const sanitizeValue = (value: unknown) => {
|
|
111
|
+
if (value === null || value === undefined) {
|
|
112
|
+
return '';
|
|
113
|
+
}
|
|
114
|
+
return value;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const mapFieldValue = (field: string, hieData: HieClient, amrsPerson: AmrsClient): Array<string> => {
|
|
118
|
+
let arr = [];
|
|
119
|
+
switch (field) {
|
|
120
|
+
case 'givenName':
|
|
121
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredName?.givenName), sanitizeValue(hieData?.first_name)];
|
|
122
|
+
break;
|
|
123
|
+
case 'middleName':
|
|
124
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredName?.middleName), sanitizeValue(hieData?.middle_name)];
|
|
125
|
+
break;
|
|
126
|
+
case 'familyName':
|
|
127
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredName?.familyName), sanitizeValue(hieData?.last_name)];
|
|
128
|
+
break;
|
|
129
|
+
case 'gender':
|
|
130
|
+
arr = [sanitizeValue(amrsPerson?.person?.gender), sanitizeValue(hieData?.gender)];
|
|
131
|
+
break;
|
|
132
|
+
case 'birthdate':
|
|
133
|
+
arr = [
|
|
134
|
+
dayjs(sanitizeValue(amrsPerson?.person?.birthdate) + '', 'YYYY-MM-DD', true).isValid()
|
|
135
|
+
? dayjs(sanitizeValue(amrsPerson?.person?.birthdate) + '').format('YYYY-MM-DD')
|
|
136
|
+
: sanitizeValue(amrsPerson?.person?.birthdate),
|
|
137
|
+
sanitizeValue(hieData?.date_of_birth),
|
|
138
|
+
];
|
|
139
|
+
break;
|
|
140
|
+
case 'country':
|
|
141
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredAddress?.country), sanitizeValue(hieData?.country)];
|
|
142
|
+
break;
|
|
143
|
+
case 'countyDistrict':
|
|
144
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredAddress?.countyDistrict), sanitizeValue(hieData?.county)];
|
|
145
|
+
break;
|
|
146
|
+
case 'address2':
|
|
147
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredAddress?.address2), sanitizeValue(hieData?.sub_county)];
|
|
148
|
+
break;
|
|
149
|
+
case 'address7':
|
|
150
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredAddress?.address7), sanitizeValue(hieData?.ward)];
|
|
151
|
+
break;
|
|
152
|
+
case 'cityVillage':
|
|
153
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredAddress?.cityVillage), sanitizeValue(hieData?.village_estate)];
|
|
154
|
+
break;
|
|
155
|
+
case 'longitude':
|
|
156
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredAddress?.longitude), sanitizeValue(hieData?.longitude)];
|
|
157
|
+
break;
|
|
158
|
+
case 'latitude':
|
|
159
|
+
arr = [sanitizeValue(amrsPerson?.person?.preferredAddress?.latitude), sanitizeValue(hieData?.latitude)];
|
|
160
|
+
break;
|
|
161
|
+
case 'NationalID':
|
|
162
|
+
arr = [
|
|
163
|
+
sanitizeValue(
|
|
164
|
+
amrsPerson?.person?.identifiers?.find(
|
|
165
|
+
(v) => v.identifierType.uuid === getIdentifierUuid(HieIdentificationType.NationalID),
|
|
166
|
+
)?.identifier,
|
|
167
|
+
),
|
|
168
|
+
sanitizeValue(
|
|
169
|
+
hieData?.other_identifications.find((v) => v.identification_type === HieIdentificationType.NationalID)
|
|
170
|
+
?.identification_number,
|
|
171
|
+
),
|
|
172
|
+
];
|
|
173
|
+
break;
|
|
174
|
+
case 'SHANumber':
|
|
175
|
+
arr = [
|
|
176
|
+
sanitizeValue(
|
|
177
|
+
amrsPerson?.person?.identifiers?.find(
|
|
178
|
+
(v) => v.identifierType.uuid === getIdentifierUuid(HieIdentificationType.SHANumber),
|
|
179
|
+
)?.identifier,
|
|
180
|
+
),
|
|
181
|
+
sanitizeValue(
|
|
182
|
+
hieData?.other_identifications.find((v) => v.identification_type === HieIdentificationType.SHANumber)
|
|
183
|
+
?.identification_number,
|
|
184
|
+
),
|
|
185
|
+
];
|
|
186
|
+
break;
|
|
187
|
+
case 'HouseholdNumber':
|
|
188
|
+
arr = [
|
|
189
|
+
sanitizeValue(
|
|
190
|
+
amrsPerson?.person?.identifiers?.find(
|
|
191
|
+
(v) => v.identifierType.uuid === getIdentifierUuid(HieIdentificationType.HouseholdNumber),
|
|
192
|
+
)?.identifier,
|
|
193
|
+
),
|
|
194
|
+
sanitizeValue(
|
|
195
|
+
hieData?.other_identifications?.find((v) => v.identification_type === HieIdentificationType.HouseholdNumber)
|
|
196
|
+
?.identification_number,
|
|
197
|
+
),
|
|
198
|
+
];
|
|
199
|
+
break;
|
|
200
|
+
case 'RefugeeID':
|
|
201
|
+
arr = [
|
|
202
|
+
sanitizeValue(
|
|
203
|
+
amrsPerson?.person?.identifiers?.find(
|
|
204
|
+
(v) => v.identifierType.uuid === getIdentifierUuid(HieIdentificationType.RefugeeID),
|
|
205
|
+
)?.identifier,
|
|
206
|
+
),
|
|
207
|
+
sanitizeValue(
|
|
208
|
+
hieData?.other_identifications.find((v) => v.identification_type === HieIdentificationType.RefugeeID)
|
|
209
|
+
?.identification_number,
|
|
210
|
+
),
|
|
211
|
+
];
|
|
212
|
+
break;
|
|
213
|
+
case 'AlienID':
|
|
214
|
+
arr = [
|
|
215
|
+
sanitizeValue(
|
|
216
|
+
amrsPerson?.person?.identifiers?.find(
|
|
217
|
+
(v) => v.identifierType.uuid === getIdentifierUuid(HieIdentificationType.AlienID),
|
|
218
|
+
)?.identifier,
|
|
219
|
+
),
|
|
220
|
+
sanitizeValue(
|
|
221
|
+
hieData?.other_identifications.find((v) => v.identification_type === HieIdentificationType.AlienID)
|
|
222
|
+
?.identification_number,
|
|
223
|
+
),
|
|
224
|
+
];
|
|
225
|
+
break;
|
|
226
|
+
case 'MandateNumber':
|
|
227
|
+
arr = [
|
|
228
|
+
sanitizeValue(
|
|
229
|
+
amrsPerson?.person?.identifiers?.find(
|
|
230
|
+
(v) => v.identifierType.uuid === getIdentifierUuid(HieIdentificationType.MandateNumber),
|
|
231
|
+
)?.identifier,
|
|
232
|
+
),
|
|
233
|
+
sanitizeValue(
|
|
234
|
+
hieData?.other_identifications.find((v) => v.identification_type === HieIdentificationType.MandateNumber)
|
|
235
|
+
?.identification_number,
|
|
236
|
+
),
|
|
237
|
+
];
|
|
238
|
+
break;
|
|
239
|
+
case 'Cr':
|
|
240
|
+
arr = [
|
|
241
|
+
sanitizeValue(
|
|
242
|
+
amrsPerson?.person?.identifiers?.find(
|
|
243
|
+
(v) => v.identifierType.uuid === getIdentifierUuid(HieIdentificationType.Cr),
|
|
244
|
+
)?.identifier,
|
|
245
|
+
),
|
|
246
|
+
sanitizeValue(
|
|
247
|
+
hieData?.other_identifications.find((v) => v.identification_type === HieIdentificationType.Cr)
|
|
248
|
+
?.identification_number,
|
|
249
|
+
),
|
|
250
|
+
];
|
|
251
|
+
break;
|
|
252
|
+
case 'TemporaryDependantID':
|
|
253
|
+
arr = [
|
|
254
|
+
sanitizeValue(
|
|
255
|
+
amrsPerson?.person?.identifiers?.find(
|
|
256
|
+
(v) => v.identifierType.uuid === getIdentifierUuid(HieIdentificationType.TemporaryDependantID),
|
|
257
|
+
)?.identifier,
|
|
258
|
+
),
|
|
259
|
+
sanitizeValue(
|
|
260
|
+
hieData?.other_identifications.find(
|
|
261
|
+
(v) => v.identification_type === HieIdentificationType.TemporaryDependantID,
|
|
262
|
+
)?.identification_number,
|
|
263
|
+
),
|
|
264
|
+
];
|
|
265
|
+
break;
|
|
266
|
+
case 'PlaceOfBirth':
|
|
267
|
+
arr = [
|
|
268
|
+
sanitizeValue(
|
|
269
|
+
amrsPerson?.person?.attributes.find(
|
|
270
|
+
(v) => v.attributeType.uuid === getAttributeUuid(HieAttributeType.PlaceOfBirth),
|
|
271
|
+
)?.value,
|
|
272
|
+
),
|
|
273
|
+
sanitizeValue(hieData?.place_of_birth),
|
|
274
|
+
];
|
|
275
|
+
break;
|
|
276
|
+
case 'CivilStatus':
|
|
277
|
+
arr = [
|
|
278
|
+
sanitizeValue(
|
|
279
|
+
amrsPerson?.person?.attributes.find(
|
|
280
|
+
(v) => v.attributeType.uuid === getAttributeUuid(HieAttributeType.CivilStatus),
|
|
281
|
+
)?.value,
|
|
282
|
+
),
|
|
283
|
+
sanitizeValue(hieData?.civil_status),
|
|
284
|
+
];
|
|
285
|
+
break;
|
|
286
|
+
case 'Email':
|
|
287
|
+
arr = [
|
|
288
|
+
sanitizeValue(
|
|
289
|
+
amrsPerson?.person?.attributes.find((v) => v.attributeType.uuid === getAttributeUuid(HieAttributeType.Email))
|
|
290
|
+
?.value,
|
|
291
|
+
),
|
|
292
|
+
sanitizeValue(hieData?.email),
|
|
293
|
+
];
|
|
294
|
+
break;
|
|
295
|
+
case 'Phone':
|
|
296
|
+
arr = [
|
|
297
|
+
sanitizeValue(
|
|
298
|
+
amrsPerson?.person?.attributes.find((v) => v.attributeType.uuid === getAttributeUuid(HieAttributeType.Phone))
|
|
299
|
+
?.value,
|
|
300
|
+
),
|
|
301
|
+
sanitizeValue(hieData?.phone),
|
|
302
|
+
];
|
|
303
|
+
break;
|
|
304
|
+
case 'KRAPin':
|
|
305
|
+
arr = [
|
|
306
|
+
sanitizeValue(
|
|
307
|
+
amrsPerson?.person?.attributes.find((v) => v.attributeType.uuid === getAttributeUuid(HieAttributeType.KRAPin))
|
|
308
|
+
?.value,
|
|
309
|
+
),
|
|
310
|
+
sanitizeValue(hieData?.kra_pin),
|
|
311
|
+
];
|
|
312
|
+
break;
|
|
313
|
+
case 'Citizenship':
|
|
314
|
+
arr = [
|
|
315
|
+
sanitizeValue(
|
|
316
|
+
amrsPerson?.person?.attributes.find(
|
|
317
|
+
(v) => v.attributeType.uuid === getAttributeUuid(HieAttributeType.Citizenship),
|
|
318
|
+
)?.value,
|
|
319
|
+
),
|
|
320
|
+
sanitizeValue(hieData?.citizenship),
|
|
321
|
+
];
|
|
322
|
+
break;
|
|
323
|
+
default:
|
|
324
|
+
arr = ['', ''];
|
|
325
|
+
}
|
|
326
|
+
return arr;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
export function getPatientRelationshipPayload(amrsPerson: AmrsClient, relationshipType: string, dependantUuid: string) {
|
|
330
|
+
const startDate = dayjs().format('YYYY-MM-DDTHH:mm:ss.SSSZZ');
|
|
331
|
+
const patientRelationshipPayload = {
|
|
332
|
+
personA: amrsPerson.person.uuid,
|
|
333
|
+
relationshipType: getAmrsRelationshipTypeUuid(relationshipType),
|
|
334
|
+
personB: dependantUuid,
|
|
335
|
+
startDate: startDate,
|
|
336
|
+
};
|
|
337
|
+
return patientRelationshipPayload;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export function mapAmrsPatientRelationship(uuid: string, relationships: Array<any>) {
|
|
341
|
+
const relationshipsArr: Array<CustomRelationship> = [];
|
|
342
|
+
if (relationships) {
|
|
343
|
+
for (const relationship of relationships) {
|
|
344
|
+
if (uuid === relationship?.personA?.uuid) {
|
|
345
|
+
const relation = {
|
|
346
|
+
uuid: relationship?.uuid,
|
|
347
|
+
display: relationship?.personB?.display,
|
|
348
|
+
relative: relationship?.personB?.display,
|
|
349
|
+
relatedPersonUuid: relationship?.personB?.uuid,
|
|
350
|
+
relationshipType: relationship?.relationshipType?.bIsToA,
|
|
351
|
+
relationshipTypeUuId: relationship?.relationshipType?.uuid,
|
|
352
|
+
relationshipTypeName: relationship?.relationshipType?.display,
|
|
353
|
+
relatedPerson: relationship?.personB,
|
|
354
|
+
};
|
|
355
|
+
relationshipsArr.push(relation);
|
|
356
|
+
} else {
|
|
357
|
+
const relation = {
|
|
358
|
+
uuid: relationship?.uuid,
|
|
359
|
+
display: relationship?.personA?.display,
|
|
360
|
+
relative: relationship?.personA?.display,
|
|
361
|
+
relatedPersonUuid: relationship?.personA?.uuid,
|
|
362
|
+
relationshipType: relationship?.relationshipType?.aIsToB,
|
|
363
|
+
relatedPerson: relationship?.personA,
|
|
364
|
+
relationshipTypeUuId: relationship?.relationshipType?.uuid,
|
|
365
|
+
relationshipTypeName: relationship?.relationshipType?.display,
|
|
366
|
+
};
|
|
367
|
+
relationshipsArr.push(relation);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return relationshipsArr;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export function getPatientAttributes(hieClient: HieClient) {
|
|
375
|
+
const attributes = [];
|
|
376
|
+
if (hieClient.place_of_birth.length > 0) {
|
|
377
|
+
attributes.push({
|
|
378
|
+
value: hieClient.place_of_birth,
|
|
379
|
+
attributeType: getAttributeUuid(HieAttributeType.PlaceOfBirth),
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
if (hieClient.phone.length > 0) {
|
|
383
|
+
attributes.push({
|
|
384
|
+
value: hieClient.phone,
|
|
385
|
+
attributeType: getAttributeUuid(HieAttributeType.Phone),
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
if (hieClient.email.length > 0) {
|
|
389
|
+
attributes.push({
|
|
390
|
+
value: hieClient.email,
|
|
391
|
+
attributeType: getAttributeUuid(HieAttributeType.Email),
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
if (hieClient.kra_pin.length > 0) {
|
|
395
|
+
attributes.push({
|
|
396
|
+
value: hieClient.kra_pin,
|
|
397
|
+
attributeType: getAttributeUuid(HieAttributeType.KRAPin),
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
if (hieClient.civil_status.length > 0) {
|
|
401
|
+
attributes.push({
|
|
402
|
+
value: this.getAmrsConceptUuidFromField(hieClient.civil_status),
|
|
403
|
+
attributeType: getAttributeUuid(HieAttributeType.CivilStatus),
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
if (hieClient.id) {
|
|
407
|
+
attributes.push({
|
|
408
|
+
value: hieClient.id,
|
|
409
|
+
attributeType: getAttributeUuid(HieAttributeType.Cr),
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
if (hieClient.citizenship) {
|
|
413
|
+
attributes.push({
|
|
414
|
+
value: hieClient.citizenship,
|
|
415
|
+
attributeType: getAttributeUuid(HieAttributeType.Citizenship),
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
return attributes;
|
|
419
|
+
}
|