@kenyaemr/esm-patient-registration-app 8.0.3-pre.140 → 8.0.3-pre.146
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/.turbo/turbo-build.log +10 -10
- package/dist/574.js +1 -1
- package/dist/610.js +1 -1
- package/dist/610.js.map +1 -1
- package/dist/kenyaemr-esm-patient-registration-app.js.buildmanifest.json +9 -9
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/client-registry/hie-client-registry/dependants/dependants.component.tsx +5 -7
- package/src/client-registry/hie-client-registry/hie-client-registry.component.tsx +38 -8
- package/src/client-registry/hie-client-registry/hie-resource.ts +26 -21
- package/src/client-registry/hie-client-registry/hie-types.ts +102 -0
- package/src/client-registry/hie-client-registry/modal/confirm-hie.modal.tsx +6 -4
- package/src/client-registry/hie-client-registry/modal/hie-patient-detail-preview.component.tsx +15 -11
- package/src/config-schema.ts +1 -1
- package/translations/en.json +3 -0
package/dist/routes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.24.0"},"pages":[{"component":"root","route":"patient-registration","online":true,"offline":true},{"component":"editPatient","routeRegex":"patient\\/([a-zA-Z0-9\\-]+)\\/edit","online":true,"offline":true}],"extensions":[{"component":"addPatientLink","name":"add-patient-action","slot":"top-nav-actions-slot","online":true,"offline":true},{"component":"patientPhotoExtension","name":"patient-photo-widget","slot":"patient-photo-slot","online":true,"offline":true},{"component":"editPatientDetailsButton","name":"edit-patient-details-button","slot":"patient-actions-slot","online":true,"offline":true},{"component":"editPatientDetailsButton","name":"edit-patient-details-button","slot":"patient-search-actions-slot","online":true,"offline":true}],"modals":[{"name":"cancel-patient-edit-modal","component":"cancelPatientEditModal"},{"name":"delete-identifier-confirmation-modal","component":"deleteIdentifierConfirmationModal"},{"component":"emptyClientRegistryModal","name":"empty-client-registry-modal"},{"component":"confirmClientRegistryModal","name":"confirm-client-registry-modal"},{"component":"hieConfirmationModal","name":"hie-confirmation-modal"}],"version":"8.0.3-pre.
|
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.24.0"},"pages":[{"component":"root","route":"patient-registration","online":true,"offline":true},{"component":"editPatient","routeRegex":"patient\\/([a-zA-Z0-9\\-]+)\\/edit","online":true,"offline":true}],"extensions":[{"component":"addPatientLink","name":"add-patient-action","slot":"top-nav-actions-slot","online":true,"offline":true},{"component":"patientPhotoExtension","name":"patient-photo-widget","slot":"patient-photo-slot","online":true,"offline":true},{"component":"editPatientDetailsButton","name":"edit-patient-details-button","slot":"patient-actions-slot","online":true,"offline":true},{"component":"editPatientDetailsButton","name":"edit-patient-details-button","slot":"patient-search-actions-slot","online":true,"offline":true}],"modals":[{"name":"cancel-patient-edit-modal","component":"cancelPatientEditModal"},{"name":"delete-identifier-confirmation-modal","component":"deleteIdentifierConfirmationModal"},{"component":"emptyClientRegistryModal","name":"empty-client-registry-modal"},{"component":"confirmClientRegistryModal","name":"confirm-client-registry-modal"},{"component":"hieConfirmationModal","name":"hie-confirmation-modal"}],"version":"8.0.3-pre.146"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kenyaemr/esm-patient-registration-app",
|
|
3
|
-
"version": "8.0.3-pre.
|
|
3
|
+
"version": "8.0.3-pre.146",
|
|
4
4
|
"description": "Patient registration microfrontend for the OpenMRS SPA",
|
|
5
5
|
"browser": "dist/kenyaemr-esm-patient-registration-app.js",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -14,15 +14,13 @@ const DependentInfo: React.FC<{ dependents: any[] }> = ({ dependents }) => {
|
|
|
14
14
|
const name = dependent?.name?.text;
|
|
15
15
|
const relationship =
|
|
16
16
|
dependent?.relationship?.[0]?.coding?.[0]?.display || t('unknownRelationship', 'Unknown');
|
|
17
|
+
|
|
17
18
|
const nationalID = dependent?.extension?.find(
|
|
18
|
-
(ext) =>
|
|
19
|
-
ext.url === 'http://cr.tiberbu.app/fhir/StructureDefinition/dependants-id-number' &&
|
|
20
|
-
ext.valueIdentifier?.type?.coding?.[0]?.code === 'national-id',
|
|
19
|
+
(ext) => ext?.valueIdentifier?.type?.coding?.some((coding) => coding.code === 'national-id'),
|
|
21
20
|
)?.valueIdentifier?.value;
|
|
21
|
+
|
|
22
22
|
const birthCertificate = dependent?.extension?.find(
|
|
23
|
-
(ext) =>
|
|
24
|
-
ext.url === 'http://cr.tiberbu.app/fhir/StructureDefinition/dependants-id-number' &&
|
|
25
|
-
ext.valueIdentifier?.type?.coding?.[0]?.code === 'birth-certificate-number',
|
|
23
|
+
(ext) => ext?.valueIdentifier?.type?.coding?.some((coding) => coding.code === 'birth-certificate'),
|
|
26
24
|
)?.valueIdentifier?.value;
|
|
27
25
|
|
|
28
26
|
const primaryIdentifier = nationalID || birthCertificate;
|
|
@@ -34,7 +32,7 @@ const DependentInfo: React.FC<{ dependents: any[] }> = ({ dependents }) => {
|
|
|
34
32
|
<div key={index} className={styles.dependentInfo}>
|
|
35
33
|
<PatientInfo label={t('name', 'Name')} value={name} />
|
|
36
34
|
<PatientInfo label={t('relationship', 'Relationship')} value={relationship} />
|
|
37
|
-
<PatientInfo label={identifierLabel} value={primaryIdentifier} />
|
|
35
|
+
{primaryIdentifier && <PatientInfo label={identifierLabel} value={primaryIdentifier} />}
|
|
38
36
|
</div>
|
|
39
37
|
);
|
|
40
38
|
})}
|
|
@@ -11,7 +11,7 @@ import { type RegistrationConfig } from '../../config-schema';
|
|
|
11
11
|
import { useForm, Controller, type SubmitHandler } from 'react-hook-form';
|
|
12
12
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
13
13
|
import { fetchPatientFromHIE, mapHIEPatientToFormValues } from './hie-resource';
|
|
14
|
-
import { type HIEPatient } from './hie-types';
|
|
14
|
+
import { type HIEPatientResponse, type HIEPatient, type ErrorResponse } from './hie-types';
|
|
15
15
|
|
|
16
16
|
type HIEClientRegistryProps = {
|
|
17
17
|
props: FormikProps<FormValues>;
|
|
@@ -39,26 +39,56 @@ const HIEClientRegistry: React.FC<HIEClientRegistryProps> = ({ setInitialFormVal
|
|
|
39
39
|
hieClientRegistry: { identifierTypes },
|
|
40
40
|
} = useConfig<RegistrationConfig>();
|
|
41
41
|
|
|
42
|
+
const isHIEPatientResponse = (
|
|
43
|
+
response: HIEPatientResponse | ErrorResponse | undefined,
|
|
44
|
+
): response is HIEPatientResponse => {
|
|
45
|
+
return response?.resourceType === 'Bundle' && 'total' in response;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const isOperationOutcome = (response: HIEPatientResponse | ErrorResponse | undefined): response is ErrorResponse => {
|
|
49
|
+
return response?.resourceType === 'OperationOutcome' && 'issue' in response;
|
|
50
|
+
};
|
|
51
|
+
|
|
42
52
|
const onSubmit: SubmitHandler<HIEFormValues> = async (data: HIEFormValues, event: React.BaseSyntheticEvent) => {
|
|
43
53
|
try {
|
|
44
54
|
const hieClientRegistry = await fetchPatientFromHIE(data.identifierType, data.identifierValue);
|
|
45
55
|
|
|
46
|
-
if (hieClientRegistry
|
|
56
|
+
if (isHIEPatientResponse(hieClientRegistry)) {
|
|
57
|
+
if (hieClientRegistry.total === 0) {
|
|
58
|
+
const dispose = showModal('empty-client-registry-modal', {
|
|
59
|
+
onConfirm: () => dispose(),
|
|
60
|
+
close: () => dispose(),
|
|
61
|
+
title: t('clientRegistryEmpty', 'Create & Post Patient'),
|
|
62
|
+
message: t(
|
|
63
|
+
'patientNotFound',
|
|
64
|
+
`No patient found with the provided ${data?.identifierType}. Proceed to register.`,
|
|
65
|
+
),
|
|
66
|
+
});
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
47
70
|
const dispose = showModal('hie-confirmation-modal', {
|
|
48
71
|
patient: hieClientRegistry,
|
|
49
72
|
closeModal: () => dispose(),
|
|
50
73
|
onUseValues: () =>
|
|
51
|
-
setInitialFormValues(
|
|
74
|
+
setInitialFormValues(
|
|
75
|
+
mapHIEPatientToFormValues(hieClientRegistry as unknown as HIEPatientResponse, props.values),
|
|
76
|
+
),
|
|
52
77
|
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (hieClientRegistry && hieClientRegistry.resourceType === 'OperationOutcome') {
|
|
56
|
-
const issueMessage = hieClientRegistry?.['issue']?.map((issue) => issue.diagnostics).join(', ');
|
|
78
|
+
} else if (isOperationOutcome(hieClientRegistry)) {
|
|
79
|
+
const issueMessage = hieClientRegistry?.issue?.map((issue) => issue.diagnostics).join(', ');
|
|
57
80
|
const dispose = showModal('empty-client-registry-modal', {
|
|
58
81
|
onConfirm: () => dispose(),
|
|
59
82
|
close: () => dispose(),
|
|
60
83
|
title: t('clientRegistryEmpty', 'Create & Post Patient'),
|
|
61
|
-
message: issueMessage,
|
|
84
|
+
message: issueMessage || t('errorOccurred', ' There was an error processing the request. Try again later'),
|
|
85
|
+
});
|
|
86
|
+
} else {
|
|
87
|
+
showSnackbar({
|
|
88
|
+
title: t('unexpectedResponse', 'Unexpected Response'),
|
|
89
|
+
subtitle: t('contactAdmin', 'Please contact the administrator.'),
|
|
90
|
+
kind: 'error',
|
|
91
|
+
isLowContrast: true,
|
|
62
92
|
});
|
|
63
93
|
}
|
|
64
94
|
} catch (error) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import capitalize from 'lodash-es/capitalize';
|
|
2
2
|
import { type PatientIdentifierValue, type FormValues } from '../../patient-registration/patient-registration.types';
|
|
3
|
-
import { type MapperConfig, type HIEPatient, type ErrorResponse } from './hie-types';
|
|
3
|
+
import { type MapperConfig, type HIEPatient, type ErrorResponse, type HIEPatientResponse } from './hie-types';
|
|
4
4
|
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
5
5
|
import { v4 } from 'uuid';
|
|
6
6
|
import { z } from 'zod';
|
|
@@ -13,7 +13,6 @@ class HealthInformationExchangeClient<T> {
|
|
|
13
13
|
async fetchResource(resourceType: string, params: Record<string, string>): Promise<T> {
|
|
14
14
|
const [identifierType, identifierValue] = Object.entries(params)[0];
|
|
15
15
|
const url = `${restBaseUrl}/kenyaemr/getSHAPatient/${identifierValue}/${identifierType}`;
|
|
16
|
-
|
|
17
16
|
const response = await openmrsFetch(url);
|
|
18
17
|
return response.json();
|
|
19
18
|
}
|
|
@@ -35,19 +34,19 @@ class Mapper<T, U> {
|
|
|
35
34
|
/**
|
|
36
35
|
* Maps HIEPatient objects to FormValues objects.
|
|
37
36
|
*/
|
|
38
|
-
class PatientMapper extends Mapper<
|
|
39
|
-
mapHIEPatientToFormValues(hiePatient:
|
|
37
|
+
class PatientMapper extends Mapper<HIEPatientResponse, FormValues> {
|
|
38
|
+
mapHIEPatientToFormValues(hiePatient: HIEPatientResponse, currentFormValues: FormValues): FormValues {
|
|
40
39
|
const { familyName, givenName, middleName } = getPatientName(hiePatient);
|
|
41
|
-
const telecom = hiePatient.telecom || [];
|
|
40
|
+
const telecom = hiePatient?.entry[0]?.resource.telecom || [];
|
|
42
41
|
|
|
43
42
|
const telecomAttributes = this.mapTelecomToAttributes(telecom);
|
|
44
43
|
const updatedIdentifiers = this.mapIdentifiers(hiePatient, currentFormValues);
|
|
45
|
-
const extensionAddressEntries = this.mapExtensionsToAddress(hiePatient.extension);
|
|
44
|
+
const extensionAddressEntries = this.mapExtensionsToAddress(hiePatient?.entry[0]?.resource.extension);
|
|
46
45
|
|
|
47
46
|
return {
|
|
48
|
-
isDead: hiePatient
|
|
49
|
-
gender: hiePatient.gender || '',
|
|
50
|
-
birthdate: hiePatient
|
|
47
|
+
isDead: hiePatient?.entry[0]?.resource?.active || false,
|
|
48
|
+
gender: hiePatient?.entry[0]?.resource.gender || '',
|
|
49
|
+
birthdate: hiePatient?.entry[0]?.resource?.birthDate || '',
|
|
51
50
|
givenName,
|
|
52
51
|
familyName,
|
|
53
52
|
telephoneNumber: telecom.find((t) => t.system === 'phone')?.value || '',
|
|
@@ -73,7 +72,7 @@ class PatientMapper extends Mapper<HIEPatient, FormValues> {
|
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
private mapIdentifiers(
|
|
76
|
-
hiePatient:
|
|
75
|
+
hiePatient: HIEPatientResponse,
|
|
77
76
|
currentFormValues: FormValues,
|
|
78
77
|
): Record<string, PatientIdentifierValue> {
|
|
79
78
|
const updatedIdentifiers: Record<string, PatientIdentifierValue> = { ...currentFormValues.identifiers };
|
|
@@ -81,11 +80,11 @@ class PatientMapper extends Mapper<HIEPatient, FormValues> {
|
|
|
81
80
|
// See https://github.com/palladiumkenya/openmrs-module-kenyaemr/blob/1e1d281eaba8041c45318e60ca0730449b8e4197/api/src/main/distro/metadata/identifierTypes.xml#L33
|
|
82
81
|
updatedIdentifiers.socialHealthAuthorityIdentificationNumber = {
|
|
83
82
|
...currentFormValues.identifiers['socialHealthAuthorityIdentificationNumber'],
|
|
84
|
-
identifierValue: hiePatient
|
|
83
|
+
identifierValue: hiePatient?.entry[0]?.resource?.id,
|
|
85
84
|
};
|
|
86
85
|
|
|
87
86
|
// Map fhir.Patient.Identifier to identifiers
|
|
88
|
-
hiePatient.identifier?.forEach((identifier: fhir.Identifier) => {
|
|
87
|
+
hiePatient.entry[0]?.resource.identifier?.forEach((identifier: fhir.Identifier) => {
|
|
89
88
|
const identifierType = identifier.type?.coding?.[0]?.code;
|
|
90
89
|
const mappedIdentifierType = this.convertToCamelCase(identifierType);
|
|
91
90
|
const identifierValue = identifier.value;
|
|
@@ -148,18 +147,21 @@ const mapperConfig: MapperConfig = {
|
|
|
148
147
|
};
|
|
149
148
|
|
|
150
149
|
// Create instances
|
|
151
|
-
const hieApiClient = new HealthInformationExchangeClient<
|
|
150
|
+
const hieApiClient = new HealthInformationExchangeClient<HIEPatientResponse | ErrorResponse>();
|
|
152
151
|
const patientMapper = new PatientMapper(mapperConfig);
|
|
153
152
|
|
|
154
153
|
// Exported functions
|
|
155
154
|
export const fetchPatientFromHIE = async (
|
|
156
155
|
identifierType: string,
|
|
157
156
|
identifierValue: string,
|
|
158
|
-
): Promise<
|
|
159
|
-
return hieApiClient.fetchResource('
|
|
157
|
+
): Promise<HIEPatientResponse | ErrorResponse> => {
|
|
158
|
+
return hieApiClient.fetchResource('Bundle', { [identifierType]: identifierValue });
|
|
160
159
|
};
|
|
161
160
|
|
|
162
|
-
export const mapHIEPatientToFormValues = (
|
|
161
|
+
export const mapHIEPatientToFormValues = (
|
|
162
|
+
hiePatient: HIEPatientResponse,
|
|
163
|
+
currentFormValues: FormValues,
|
|
164
|
+
): FormValues => {
|
|
163
165
|
return patientMapper.mapHIEPatientToFormValues(hiePatient, currentFormValues);
|
|
164
166
|
};
|
|
165
167
|
|
|
@@ -169,7 +171,7 @@ export const mapHIEPatientToFormValues = (hiePatient: HIEPatient, currentFormVal
|
|
|
169
171
|
* @returns {string} - The masked data
|
|
170
172
|
*/
|
|
171
173
|
export const maskData = (data: string): string => {
|
|
172
|
-
const maskedData = data.slice(0, 2) + '*'.repeat(data.length - 2);
|
|
174
|
+
const maskedData = data.slice(0, 2) + '*'.repeat(Math.max(0, data.length - 2));
|
|
173
175
|
return maskedData;
|
|
174
176
|
};
|
|
175
177
|
|
|
@@ -178,10 +180,13 @@ export const maskData = (data: string): string => {
|
|
|
178
180
|
* @param patient {fhir.Patient} - The FHIR Patient resource
|
|
179
181
|
* @returns {object} - The patient name
|
|
180
182
|
*/
|
|
181
|
-
export const getPatientName = (patient:
|
|
182
|
-
const familyName = patient?.name[0]?.
|
|
183
|
-
const
|
|
184
|
-
|
|
183
|
+
export const getPatientName = (patient: HIEPatientResponse) => {
|
|
184
|
+
const familyName = patient?.entry?.[0]?.resource?.name?.[0]?.family ?? ''; // Safely access the family name
|
|
185
|
+
const givenNames = patient?.entry?.[0]?.resource?.name?.[0]?.given ?? []; // Safely access the given names array
|
|
186
|
+
|
|
187
|
+
const givenName = givenNames?.[0] ?? ''; // The first item is the given name (first name)
|
|
188
|
+
const middleName = givenNames.slice(1).join(' ').trim(); // Combine all other given names as middle name(s)
|
|
189
|
+
|
|
185
190
|
return { familyName, givenName, middleName };
|
|
186
191
|
};
|
|
187
192
|
|
|
@@ -5,6 +5,108 @@ export type HIEPatient = fhir.Patient & {
|
|
|
5
5
|
}>;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
+
export interface HIEPatientResponse {
|
|
9
|
+
resourceType: string;
|
|
10
|
+
id: string;
|
|
11
|
+
total: number;
|
|
12
|
+
meta: Metadata;
|
|
13
|
+
link: Link[];
|
|
14
|
+
entry: Entry[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface Metadata {
|
|
18
|
+
lastUpdated: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface Link {
|
|
22
|
+
relation: string;
|
|
23
|
+
url: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface Entry {
|
|
27
|
+
resource: Resource;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface Resource {
|
|
31
|
+
id: string;
|
|
32
|
+
extension: Extension[];
|
|
33
|
+
identifier: Identifier[];
|
|
34
|
+
active: boolean;
|
|
35
|
+
name: Name[];
|
|
36
|
+
telecom: Telecom[];
|
|
37
|
+
birthDate: string;
|
|
38
|
+
address: Address[];
|
|
39
|
+
gender: string;
|
|
40
|
+
maritalStatus: MaritalStatus;
|
|
41
|
+
contact: Contact[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface Extension {
|
|
45
|
+
url: string;
|
|
46
|
+
valueString: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface Identifier {
|
|
50
|
+
type: CodingType;
|
|
51
|
+
value: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface CodingType {
|
|
55
|
+
coding: Coding[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface Coding {
|
|
59
|
+
system?: string;
|
|
60
|
+
code: string;
|
|
61
|
+
display: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface Name {
|
|
65
|
+
text: string;
|
|
66
|
+
family: string;
|
|
67
|
+
given: string[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface Telecom {
|
|
71
|
+
system: string;
|
|
72
|
+
value?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface Address {
|
|
76
|
+
extension: AddressExtension[];
|
|
77
|
+
city: string;
|
|
78
|
+
country: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
interface AddressExtension {
|
|
82
|
+
url: string;
|
|
83
|
+
valueString: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface MaritalStatus {
|
|
87
|
+
coding: Coding[];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface Contact {
|
|
91
|
+
id: string;
|
|
92
|
+
extension: ContactExtension[];
|
|
93
|
+
relationship: Relationship[];
|
|
94
|
+
name: Name;
|
|
95
|
+
telecom: Telecom[];
|
|
96
|
+
address: Address;
|
|
97
|
+
gender: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
interface ContactExtension {
|
|
101
|
+
url: string;
|
|
102
|
+
valueIdentifier?: Identifier;
|
|
103
|
+
valueString?: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface Relationship {
|
|
107
|
+
coding: Coding[];
|
|
108
|
+
}
|
|
109
|
+
|
|
8
110
|
export type APIClientConfig = {
|
|
9
111
|
baseUrl: string;
|
|
10
112
|
credentials: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Button, ModalBody, ModalFooter, ModalHeader } from '@carbon/react';
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import { type HIEPatient } from '../hie-types';
|
|
4
|
+
import { type HIEPatientResponse, type HIEPatient } from '../hie-types';
|
|
5
5
|
import styles from './confirm-hie.scss';
|
|
6
6
|
import { authorizationFormSchema, generateOTP, getPatientName, persistOTP, sendOtp, verifyOtp } from '../hie-resource';
|
|
7
7
|
import HIEPatientDetailPreview from './hie-patient-detail-preview.component';
|
|
@@ -14,7 +14,7 @@ import { showSnackbar } from '@openmrs/esm-framework';
|
|
|
14
14
|
|
|
15
15
|
interface HIEConfirmationModalProps {
|
|
16
16
|
closeModal: () => void;
|
|
17
|
-
patient:
|
|
17
|
+
patient: HIEPatientResponse;
|
|
18
18
|
onUseValues: () => void;
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -22,9 +22,11 @@ const HIEConfirmationModal: React.FC<HIEConfirmationModalProps> = ({ closeModal,
|
|
|
22
22
|
const { t } = useTranslation();
|
|
23
23
|
const [mode, setMode] = useState<'authorization' | 'preview'>('preview');
|
|
24
24
|
const [status, setStatus] = useState<'loadingOtp' | 'otpSendSuccessfull' | 'otpFetchError'>();
|
|
25
|
-
const phoneNumber = patient?.telecom?.find((num) => num.
|
|
25
|
+
const phoneNumber = patient?.entry[0]?.resource.telecom?.find((num) => num.system === 'phone')?.value;
|
|
26
26
|
const getidentifier = (code: string) =>
|
|
27
|
-
patient?.identifier?.find(
|
|
27
|
+
patient?.entry[0]?.resource.identifier?.find(
|
|
28
|
+
(identifier) => identifier?.type?.coding?.some((coding) => coding?.code === code),
|
|
29
|
+
);
|
|
28
30
|
const patientId = patient?.id ?? getidentifier('SHA-number')?.value;
|
|
29
31
|
const form = useForm<z.infer<typeof authorizationFormSchema>>({
|
|
30
32
|
defaultValues: {
|
package/src/client-registry/hie-client-registry/modal/hie-patient-detail-preview.component.tsx
CHANGED
|
@@ -7,16 +7,19 @@ import DependentInfo from '../dependants/dependants.component';
|
|
|
7
7
|
import { getPatientName, maskData } from '../hie-resource';
|
|
8
8
|
import PatientInfo from '../patient-info/patient-info.component';
|
|
9
9
|
import styles from './confirm-hie.scss';
|
|
10
|
+
import { type HIEPatientResponse } from '../hie-types';
|
|
10
11
|
|
|
11
12
|
type HIEPatientDetailPreviewProps = {
|
|
12
|
-
patient:
|
|
13
|
+
patient: HIEPatientResponse;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
const HIEPatientDetailPreview: React.FC<HIEPatientDetailPreviewProps> = ({ patient }) => {
|
|
16
17
|
const { familyName, givenName, middleName } = getPatientName(patient);
|
|
17
18
|
const { t } = useTranslation();
|
|
18
19
|
const getidentifier = (code: string) =>
|
|
19
|
-
patient?.identifier?.find(
|
|
20
|
+
patient?.entry[0]?.resource.identifier?.find(
|
|
21
|
+
(identifier) => identifier?.type?.coding?.some((coding) => coding?.code === code),
|
|
22
|
+
);
|
|
20
23
|
|
|
21
24
|
return (
|
|
22
25
|
<>
|
|
@@ -27,7 +30,7 @@ const HIEPatientDetailPreview: React.FC<HIEPatientDetailPreviewProps> = ({ patie
|
|
|
27
30
|
state={{ patientName: `${maskData(givenName)} . ${maskData(middleName)} . ${maskData(familyName)}` }}
|
|
28
31
|
/>
|
|
29
32
|
<div className={styles.patientInfoContainer}>
|
|
30
|
-
<PatientInfo label={t('healthID', 'HealthID')} value={getidentifier('
|
|
33
|
+
<PatientInfo label={t('healthID', 'HealthID')} value={getidentifier('sha-number')?.value} />
|
|
31
34
|
<PatientInfo
|
|
32
35
|
label={t('patientName', 'Patient name')}
|
|
33
36
|
customValue={
|
|
@@ -41,21 +44,22 @@ const HIEPatientDetailPreview: React.FC<HIEPatientDetailPreviewProps> = ({ patie
|
|
|
41
44
|
}
|
|
42
45
|
/>
|
|
43
46
|
|
|
44
|
-
<PatientInfo label={t('age', 'Age')} value={age(patient?.birthDate)} />
|
|
45
|
-
<PatientInfo
|
|
46
|
-
|
|
47
|
+
<PatientInfo label={t('age', 'Age')} value={age(patient?.entry[0]?.resource.birthDate)} />
|
|
48
|
+
<PatientInfo
|
|
49
|
+
label={t('dateOfBirth', 'Date of birth')}
|
|
50
|
+
value={formatDate(new Date(patient?.entry[0]?.resource?.birthDate))}
|
|
51
|
+
/>
|
|
52
|
+
<PatientInfo label={t('gender', 'Gender')} value={capitalize(patient?.entry[0]?.resource.gender)} />
|
|
47
53
|
<PatientInfo
|
|
48
54
|
label={t('maritalStatus', 'Marital status')}
|
|
49
|
-
value={patient?.maritalStatus?.coding?.map((m) => m.code).join('')}
|
|
55
|
+
value={patient?.entry[0]?.resource.maritalStatus?.coding?.map((m) => m.code).join('')}
|
|
50
56
|
/>
|
|
51
57
|
|
|
52
|
-
{
|
|
53
|
-
<PatientInfo label={t('dependents', 'Dependents')} value="--" />
|
|
54
|
-
)}
|
|
58
|
+
{!patient?.entry[0]?.resource.contact && <PatientInfo label={t('dependents', 'Dependents')} value="--" />}
|
|
55
59
|
</div>
|
|
56
60
|
</div>
|
|
57
61
|
|
|
58
|
-
<DependentInfo dependents={patient?.contact} />
|
|
62
|
+
<DependentInfo dependents={patient?.entry[0]?.resource.contact} />
|
|
59
63
|
|
|
60
64
|
<div>
|
|
61
65
|
<Accordion>
|
package/src/config-schema.ts
CHANGED
|
@@ -416,7 +416,7 @@ export const esmPatientRegistrationSchema = {
|
|
|
416
416
|
},
|
|
417
417
|
},
|
|
418
418
|
_default: [
|
|
419
|
-
{ identifierType: 'National ID', identifierValue: '
|
|
419
|
+
{ identifierType: 'National ID', identifierValue: 'National ID' },
|
|
420
420
|
{ identifierType: 'Passport Number', identifierValue: 'passport-number' },
|
|
421
421
|
{ identifierType: 'Birth Certificate Number', identifierValue: 'birth-certificate-number' },
|
|
422
422
|
{ identifierType: 'Alien ID Number', identifierValue: 'alien-id-number' },
|
package/translations/en.json
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"confirmDiscardChangesBody": "Your unsaved changes will be lost if you proceed to discard the form",
|
|
25
25
|
"confirmDiscardChangesTitle": "Are you sure you want to discard these changes?",
|
|
26
26
|
"confirmIdentifierDeletionText": "Are you sure you want to remove this identifier?",
|
|
27
|
+
"contactAdmin": "Please contact the administrator.",
|
|
27
28
|
"contactSection": "Contact Details",
|
|
28
29
|
"continue": "Continue",
|
|
29
30
|
"createNewPatient": "Create new patient",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"errorFetchingCodedCausesOfDeath": "Error fetching coded causes of death",
|
|
60
61
|
"errorFetchingOrderedFields": "Error occured fetching ordered fields for address hierarchy",
|
|
61
62
|
"errorFetchingPatient": "Error fetching patient",
|
|
63
|
+
"errorOccurred": " There was an error processing the request. Try again later",
|
|
62
64
|
"estimatedAgeInMonthsLabelText": "Estimated age in months",
|
|
63
65
|
"estimatedAgeInYearsLabelText": "Estimated age in years",
|
|
64
66
|
"familyNameLabelText": "Family Name",
|
|
@@ -145,6 +147,7 @@
|
|
|
145
147
|
"timeFormat": "Time Format",
|
|
146
148
|
"timeOfDeathInputLabel": "Time of death (hh:mm)",
|
|
147
149
|
"unableToFetch": "Unable to fetch person attribute type - {{personattributetype}}",
|
|
150
|
+
"unexpectedResponse": "Unexpected Response",
|
|
148
151
|
"unknown": "Unknown",
|
|
149
152
|
"unknownPatientAttributeType": "Patient attribute type has unknown format {{personAttributeTypeFormat}}",
|
|
150
153
|
"unknownRelationship": "Unknown",
|