@ampath/esm-patient-registration-app 6.0.1-pre.7 → 6.0.1-pre.70
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 +23 -24
- package/dist/132.js +1 -0
- package/dist/197.js +1 -0
- package/dist/236.js +1 -0
- package/dist/{735.js.map → 236.js.map} +1 -1
- package/dist/300.js +1 -0
- package/dist/335.js +1 -0
- package/dist/372.js +1 -0
- package/dist/372.js.map +1 -0
- package/dist/41.js +2 -0
- package/dist/41.js.map +1 -0
- package/dist/449.js +1 -0
- package/dist/449.js.map +1 -0
- package/dist/464.js +1 -0
- package/dist/464.js.map +1 -0
- package/dist/495.js +1 -0
- package/dist/495.js.map +1 -0
- package/dist/55.js +1 -0
- package/dist/56.js +1 -0
- package/dist/56.js.map +1 -0
- package/dist/621.js +1 -1
- package/dist/621.js.map +1 -1
- package/dist/629.js +2 -0
- package/dist/629.js.LICENSE.txt +24 -0
- package/dist/629.js.map +1 -0
- package/dist/652.js +1 -0
- package/dist/661.js +1 -0
- package/dist/757.js +1 -1
- package/dist/757.js.map +1 -0
- package/dist/828.js +1 -0
- package/dist/828.js.map +1 -0
- package/dist/830.js +1 -0
- package/dist/830.js.map +1 -0
- package/dist/831.js +2 -0
- package/dist/831.js.map +1 -0
- package/dist/876.js +2 -0
- package/dist/876.js.map +1 -0
- package/dist/879.js +1 -1
- package/dist/913.js +2 -0
- package/dist/{591.js.LICENSE.txt → 913.js.LICENSE.txt} +23 -3
- package/dist/913.js.map +1 -0
- package/dist/927.js +1 -0
- package/dist/927.js.map +1 -0
- package/dist/99.js +1 -0
- package/dist/ampath-esm-patient-registration-app.js +1 -1
- package/dist/ampath-esm-patient-registration-app.js.buildmanifest.json +236 -191
- package/dist/ampath-esm-patient-registration-app.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.LICENSE.txt +0 -32
- package/dist/main.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +6 -9
- package/src/config-schema.ts +19 -10
- package/src/index.ts +11 -4
- package/src/offline.resources.ts +13 -18
- package/src/offline.ts +6 -4
- package/src/patient-photo.extension.tsx +9 -0
- package/src/patient-registration/field/address/custom-address-field.component.tsx +1 -0
- package/src/patient-registration/field/custom-field.component.tsx +6 -0
- package/src/patient-registration/field/dob/dob.component.tsx +17 -14
- package/src/patient-registration/field/field.resource.ts +3 -3
- package/src/patient-registration/field/person-attributes/coded-person-attribute-field.component.tsx +4 -0
- package/src/patient-registration/field/person-attributes/custom-person-attribute-field.component.tsx +56 -0
- package/src/patient-registration/field/person-attributes/person-attribute-field.component.tsx +22 -7
- package/src/patient-registration/field/person-attributes/person-attributes.resource.ts +2 -2
- package/src/patient-registration/field/phone/phone-field.component.tsx +1 -0
- package/src/patient-registration/form-manager.ts +13 -6
- package/src/patient-registration/patient-registration-hooks.ts +91 -9
- package/src/patient-registration/patient-registration.component.tsx +55 -13
- package/src/patient-registration/{patient-registration.resource.test.tsx → patient-registration.resource.testt.tsx} +3 -3
- package/src/patient-registration/patient-registration.resource.ts +15 -75
- package/src/patient-registration/patient-registration.scss +0 -8
- package/src/patient-registration/patient-registration.types.ts +7 -1
- package/src/patient-registration/section/patient-relationships/relationships-section.component.tsx +5 -1
- package/src/patient-registration/section/patient-relationships/relationships.resource.tsx +2 -2
- package/src/patient-verification/assets/counties.json +236 -0
- package/src/patient-verification/assets/verification-assets.ts +11 -0
- package/src/patient-verification/patient-verification-hook.tsx +176 -0
- package/src/patient-verification/patient-verification-utils.ts +179 -0
- package/src/patient-verification/patient-verification.component.tsx +124 -0
- package/src/patient-verification/patient-verification.scss +25 -0
- package/src/patient-verification/verification-modal/confirm-prompt.component.tsx +72 -0
- package/src/patient-verification/verification-modal/empty-prompt.component.tsx +35 -0
- package/src/patient-verification/verification-types.ts +50 -0
- package/src/routes.json +12 -3
- package/translations/am.json +26 -12
- package/translations/ar.json +26 -12
- package/translations/en.json +19 -5
- package/translations/es.json +10 -0
- package/translations/fr.json +6 -0
- package/translations/he.json +18 -0
- package/translations/km.json +18 -0
- package/translations/zh.json +30 -22
- package/translations/zh_CN.json +30 -22
- package/dist/130.js +0 -2
- package/dist/130.js.map +0 -1
- package/dist/152.js +0 -1
- package/dist/152.js.map +0 -1
- package/dist/249.js +0 -2
- package/dist/249.js.LICENSE.txt +0 -46
- package/dist/249.js.map +0 -1
- package/dist/255.js +0 -2
- package/dist/255.js.map +0 -1
- package/dist/271.js +0 -1
- package/dist/303.js +0 -1
- package/dist/303.js.map +0 -1
- package/dist/319.js +0 -1
- package/dist/365.js +0 -1
- package/dist/365.js.map +0 -1
- package/dist/460.js +0 -1
- package/dist/525.js +0 -1
- package/dist/525.js.map +0 -1
- package/dist/537.js +0 -1
- package/dist/537.js.map +0 -1
- package/dist/574.js +0 -1
- package/dist/591.js +0 -2
- package/dist/591.js.map +0 -1
- package/dist/644.js +0 -1
- package/dist/729.js +0 -1
- package/dist/729.js.map +0 -1
- package/dist/735.js +0 -1
- package/dist/784.js +0 -2
- package/dist/784.js.map +0 -1
- package/dist/788.js +0 -1
- package/dist/807.js +0 -1
- package/dist/833.js +0 -1
- package/dist/879.js.map +0 -1
- package/src/patient-registration/field/address/tests/address-hierarchy.test.tsx +0 -214
- package/src/patient-registration/field/address/tests/address-search-component.test.tsx +0 -135
- package/src/patient-registration/field/dob/dob.test.tsx +0 -75
- package/src/patient-registration/field/field.test.tsx +0 -294
- package/src/patient-registration/field/id/id-field.test.tsx +0 -107
- package/src/patient-registration/field/person-attributes/coded-attributes.component.tsx +0 -60
- package/src/patient-registration/field/person-attributes/coded-person-attribute-field.test.tsx +0 -127
- package/src/patient-registration/field/person-attributes/person-attribute-field.test.tsx +0 -187
- package/src/patient-registration/field/person-attributes/text-person-attribute-field.test.tsx +0 -88
- package/src/patient-registration/form-manager.test.ts +0 -67
- package/src/patient-registration/input/basic-input/select/select-input.test.tsx +0 -49
- package/src/patient-registration/input/custom-input/autosuggest/autosuggest.test.tsx +0 -132
- package/src/patient-registration/input/custom-input/identifier/identifier-input.test.tsx +0 -107
- package/src/patient-registration/patient-registration.test.tsx +0 -471
- package/src/patient-registration/section/death-info/death-info-section.test.tsx +0 -64
- package/src/patient-registration/section/demographics/demographics-section.test.tsx +0 -83
- package/src/patient-registration/section/patient-relationships/relationships-section.test.tsx +0 -100
- package/src/patient-verification/client-registry-constants.ts +0 -13
- package/src/patient-verification/client-registry.component.tsx +0 -66
- package/src/patient-verification/client-registry.scss +0 -1
- package/src/patient-verification/utils.tsx +0 -56
- package/src/patient-verification/verification-modal.scss +0 -20
- package/src/patient-verification/verification.component.tsx +0 -48
- package/src/root.test.tsx +0 -32
- package/src/widgets/cancel-patient-edit.test.tsx +0 -27
- package/src/widgets/display-photo.component.tsx +0 -30
- package/src/widgets/display-photo.test.tsx +0 -37
- package/src/widgets/edit-patient-details-button.test.tsx +0 -41
- /package/dist/{784.js.LICENSE.txt → 41.js.LICENSE.txt} +0 -0
- /package/dist/{130.js.LICENSE.txt → 831.js.LICENSE.txt} +0 -0
- /package/dist/{255.js.LICENSE.txt → 876.js.LICENSE.txt} +0 -0
- /package/src/patient-registration/input/custom-input/identifier/{utils.test.ts → utils.testt.ts} +0 -0
- /package/src/widgets/{delete-identifier-confirmation-modal.test.tsx → delete-identifier-confirmation-modal.testt.tsx} +0 -0
package/src/patient-registration/section/patient-relationships/relationships-section.test.tsx
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Form, Formik } from 'formik';
|
|
3
|
-
import { render, screen } from '@testing-library/react';
|
|
4
|
-
import { PatientRegistrationContext } from '../../patient-registration-context';
|
|
5
|
-
import { type Resources, ResourcesContext } from '../../../offline.resources';
|
|
6
|
-
import { RelationshipsSection } from './relationships-section.component';
|
|
7
|
-
|
|
8
|
-
jest.mock('../../patient-registration.resource', () => ({
|
|
9
|
-
fetchPerson: jest.fn().mockResolvedValue({
|
|
10
|
-
data: {
|
|
11
|
-
results: [
|
|
12
|
-
{ uuid: '42ae5ce0-d64b-11ea-9064-5adc43bbdd24', display: 'Person 1' },
|
|
13
|
-
{ uuid: '691eed12-c0f1-11e2-94be-8c13b969e334', display: 'Person 2' },
|
|
14
|
-
],
|
|
15
|
-
},
|
|
16
|
-
}),
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
let mockResourcesContextValue = {
|
|
20
|
-
addressTemplate: null,
|
|
21
|
-
currentSession: {
|
|
22
|
-
authenticated: true,
|
|
23
|
-
sessionId: 'JSESSION',
|
|
24
|
-
currentProvider: { uuid: '45ce6c2e-dd5a-11e6-9d9c-0242ac150002', identifier: 'PRO-123' },
|
|
25
|
-
},
|
|
26
|
-
identifierTypes: [],
|
|
27
|
-
relationshipTypes: null,
|
|
28
|
-
} as Resources;
|
|
29
|
-
|
|
30
|
-
describe('RelationshipsSection', () => {
|
|
31
|
-
it('renders a loader when relationshipTypes are not available', () => {
|
|
32
|
-
render(
|
|
33
|
-
<ResourcesContext.Provider value={mockResourcesContextValue}>
|
|
34
|
-
<Formik initialValues={{}} onSubmit={null}>
|
|
35
|
-
<Form>
|
|
36
|
-
<RelationshipsSection />
|
|
37
|
-
</Form>
|
|
38
|
-
</Formik>
|
|
39
|
-
</ResourcesContext.Provider>,
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
expect(screen.getByLabelText(/loading relationships section/i)).toBeInTheDocument();
|
|
43
|
-
expect(screen.getByRole('progressbar')).toBeInTheDocument();
|
|
44
|
-
expect(screen.queryByText(/add relationship/i)).not.toBeInTheDocument();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('renders relationships when relationshipTypes are available', () => {
|
|
48
|
-
const relationshipTypes = {
|
|
49
|
-
results: [
|
|
50
|
-
{
|
|
51
|
-
displayAIsToB: 'Mother',
|
|
52
|
-
aIsToB: 'Mother',
|
|
53
|
-
bIsToA: 'Child',
|
|
54
|
-
displayBIsToA: 'Child',
|
|
55
|
-
uuid: '42ae5ce0-d64b-11ea-9064-5adc43bbdd34',
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
displayAIsToB: 'Father',
|
|
59
|
-
aIsToB: 'Father',
|
|
60
|
-
bIsToA: 'Child',
|
|
61
|
-
displayBIsToA: 'Child',
|
|
62
|
-
uuid: '52ae5ce0-d64b-11ea-9064-5adc43bbdd24',
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
};
|
|
66
|
-
mockResourcesContextValue = {
|
|
67
|
-
...mockResourcesContextValue,
|
|
68
|
-
relationshipTypes: relationshipTypes,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
render(
|
|
72
|
-
<ResourcesContext.Provider value={mockResourcesContextValue}>
|
|
73
|
-
<Formik
|
|
74
|
-
initialValues={{
|
|
75
|
-
relationships: [{ action: 'ADD', relatedPersonUuid: '11524ae7-3ef6-4ab6-aff6-804ffc58704a' }],
|
|
76
|
-
}}
|
|
77
|
-
onSubmit={null}>
|
|
78
|
-
<Form>
|
|
79
|
-
<PatientRegistrationContext.Provider
|
|
80
|
-
value={{
|
|
81
|
-
setFieldValue: jest.fn(),
|
|
82
|
-
setInitialFormValues: jest.fn(),
|
|
83
|
-
}}>
|
|
84
|
-
<RelationshipsSection />
|
|
85
|
-
</PatientRegistrationContext.Provider>
|
|
86
|
-
</Form>
|
|
87
|
-
</Formik>
|
|
88
|
-
</ResourcesContext.Provider>,
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
expect(screen.getByLabelText(/relationships section/i)).toBeInTheDocument();
|
|
92
|
-
expect(screen.getByRole('heading', { name: /relationship/i })).toBeInTheDocument();
|
|
93
|
-
expect(screen.getByRole('button', { name: /delete/i })).toBeInTheDocument();
|
|
94
|
-
expect(screen.getByRole('button', { name: /add relationship/i })).toBeInTheDocument();
|
|
95
|
-
expect(screen.getByRole('searchbox', { name: /full name/i })).toBeInTheDocument();
|
|
96
|
-
expect(screen.getByRole('option', { name: /mother/i })).toBeInTheDocument();
|
|
97
|
-
expect(screen.getByRole('option', { name: /father/i })).toBeInTheDocument();
|
|
98
|
-
expect(screen.getAllByRole('option', { name: /child/i }).length).toEqual(2);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const countries = [
|
|
2
|
-
{ text: 'Kenya', id: 'KE' },
|
|
3
|
-
{ text: 'Uganda', id: 'UG' },
|
|
4
|
-
{ text: 'Tanzania', id: 'TZ' },
|
|
5
|
-
];
|
|
6
|
-
|
|
7
|
-
export const identifierTypes = [
|
|
8
|
-
{ text: 'National ID number', id: '58a47054-1359-11df-a1f1-0026b9348838' },
|
|
9
|
-
{ text: 'Passport number', id: 'ced014a1-068a-4a13-b6b3-17412f754af2' },
|
|
10
|
-
{ text: 'Birth Certificate Entry Number', id: '7924e13b-131a-4da8-8efa-e294184a1b0d' },
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
export const defaultSelectedCountry = 'KE';
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type FormValues } from '../patient-registration/patient-registration.types';
|
|
3
|
-
import {} from '@carbon/react';
|
|
4
|
-
import { Dropdown, TextInput, Button, InlineLoading } from '@carbon/react';
|
|
5
|
-
import styles from './client-registry.scss';
|
|
6
|
-
import { useTranslation } from 'react-i18next';
|
|
7
|
-
import { useClientRegistryForm } from './utils';
|
|
8
|
-
import { countries, identifierTypes } from './client-registry-constants';
|
|
9
|
-
|
|
10
|
-
type ClientRegistryProps = {
|
|
11
|
-
setInitialFormValues: (initialValues) => void;
|
|
12
|
-
initialFormValues: FormValues;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const ClientRegistry: React.FC<ClientRegistryProps> = ({ setInitialFormValues, initialFormValues }) => {
|
|
16
|
-
const { t } = useTranslation();
|
|
17
|
-
const { handleClientRegistryDataSubmit, handleOnChange, clientRegistryData } = useClientRegistryForm(
|
|
18
|
-
setInitialFormValues,
|
|
19
|
-
initialFormValues,
|
|
20
|
-
);
|
|
21
|
-
return (
|
|
22
|
-
<div className={styles.patientVerification}>
|
|
23
|
-
<h3 className={styles.productiveHeading02} style={{ color: '#161616' }}>
|
|
24
|
-
{t('patientVerification', 'Patient Verification')}
|
|
25
|
-
</h3>
|
|
26
|
-
<Dropdown
|
|
27
|
-
id="default"
|
|
28
|
-
titleText="Country"
|
|
29
|
-
label="Select country"
|
|
30
|
-
items={countries}
|
|
31
|
-
onChange={({ selectedItem }) => handleOnChange(selectedItem?.id, 'country')}
|
|
32
|
-
initialSelectedItem={countries[0]}
|
|
33
|
-
itemToString={(item) => (item ? item.text : '')}
|
|
34
|
-
/>
|
|
35
|
-
<Dropdown
|
|
36
|
-
id="default"
|
|
37
|
-
titleText="Verification ID Type"
|
|
38
|
-
label="Select verification ID Type"
|
|
39
|
-
items={identifierTypes}
|
|
40
|
-
onChange={({ selectedItem }) => handleOnChange(selectedItem?.id, 'identifierType')}
|
|
41
|
-
itemToString={(item) => (item ? item.text : '')}
|
|
42
|
-
/>
|
|
43
|
-
<TextInput
|
|
44
|
-
disabled={clientRegistryData.identifierType === ''}
|
|
45
|
-
onChange={(e) => handleOnChange(e.target.value, 'patientIdentifier')}
|
|
46
|
-
id="patientIdentifier"
|
|
47
|
-
type="text"
|
|
48
|
-
labelText="Patient identifier"
|
|
49
|
-
placeholder="Enter patient identifier"
|
|
50
|
-
/>
|
|
51
|
-
{clientRegistryData.isSubmitting ? (
|
|
52
|
-
<InlineLoading
|
|
53
|
-
description={`${t('searchRegistry', 'Searching registry')} ...`}
|
|
54
|
-
iconDescription="searching registry ..."
|
|
55
|
-
status="active"
|
|
56
|
-
/>
|
|
57
|
-
) : (
|
|
58
|
-
<Button
|
|
59
|
-
disabled={clientRegistryData.isSubmitting || clientRegistryData.patientIdentifier === ''}
|
|
60
|
-
onClick={() => handleClientRegistryDataSubmit()}>
|
|
61
|
-
{t('searchRegistry', 'Search Registry')}
|
|
62
|
-
</Button>
|
|
63
|
-
)}
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import '../patient-registration/patient-registration.scss';
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { showModal } from '@openmrs/esm-framework';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { fetchPatientRecordFromClientRegistry } from '../patient-registration/patient-registration.resource';
|
|
4
|
-
import { defaultSelectedCountry } from './client-registry-constants';
|
|
5
|
-
|
|
6
|
-
export const handleSetFormValueFromClientRegistry = (clientData, setInitialFormValues, initialFormValues) => {
|
|
7
|
-
setInitialFormValues({
|
|
8
|
-
...initialFormValues,
|
|
9
|
-
familyName: clientData.lastName,
|
|
10
|
-
givenName: clientData.firstName,
|
|
11
|
-
middleName: clientData.middleName,
|
|
12
|
-
gender: clientData.gender,
|
|
13
|
-
birthdate: clientData.dateOfBirth,
|
|
14
|
-
address: {
|
|
15
|
-
address2: clientData.subCounty,
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const useClientRegistryForm = (setInitialFormValues, initialFormValues) => {
|
|
21
|
-
const [clientRegistryData, setClientRegistryData] = useState<{
|
|
22
|
-
country: string;
|
|
23
|
-
identifierType: string;
|
|
24
|
-
patientIdentifier: string;
|
|
25
|
-
isSubmitting: boolean;
|
|
26
|
-
}>({ country: defaultSelectedCountry, identifierType: '', patientIdentifier: '', isSubmitting: false });
|
|
27
|
-
|
|
28
|
-
const handleOnChange = (data, key: 'country' | 'identifierType' | 'patientIdentifier') => {
|
|
29
|
-
setClientRegistryData({ ...clientRegistryData, [key]: data });
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const handleClientRegistryDataSubmit = () => {
|
|
33
|
-
setClientRegistryData({ ...clientRegistryData, isSubmitting: true });
|
|
34
|
-
fetchPatientRecordFromClientRegistry(
|
|
35
|
-
clientRegistryData.patientIdentifier,
|
|
36
|
-
clientRegistryData.identifierType,
|
|
37
|
-
clientRegistryData.country,
|
|
38
|
-
).then((res) => {
|
|
39
|
-
setClientRegistryData({ ...clientRegistryData, isSubmitting: false });
|
|
40
|
-
if (res.clientExists) {
|
|
41
|
-
const clientData = res.client;
|
|
42
|
-
const closeModal = showModal('client-registry-modal', {
|
|
43
|
-
clientData,
|
|
44
|
-
closeModal: () => {
|
|
45
|
-
closeModal();
|
|
46
|
-
handleSetFormValueFromClientRegistry(clientData, setInitialFormValues, initialFormValues);
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
} else {
|
|
50
|
-
const clientData = res.client;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return { handleClientRegistryDataSubmit, handleOnChange, clientRegistryData };
|
|
56
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
@use '@carbon/type';
|
|
2
|
-
@use '@carbon/colors';
|
|
3
|
-
|
|
4
|
-
.cardContainer {
|
|
5
|
-
display: grid;
|
|
6
|
-
grid-template-columns: 0.5fr 1fr;
|
|
7
|
-
column-gap: 0.25rem;
|
|
8
|
-
margin: 0.5rem 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.label {
|
|
12
|
-
@include type.type-style('body-compact-02');
|
|
13
|
-
color: colors.$cool-gray-100;
|
|
14
|
-
font-weight: bold;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.value {
|
|
18
|
-
@include type.type-style('legal-01');
|
|
19
|
-
color: colors.$cool-gray-80;
|
|
20
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ModalHeader, ModalBody, ModalFooter, Button } from '@carbon/react';
|
|
3
|
-
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import styles from './verification-modal.scss';
|
|
5
|
-
|
|
6
|
-
type VerificationModalProps = { clientData; closeModal };
|
|
7
|
-
|
|
8
|
-
const VerificationModal: React.FC<VerificationModalProps> = ({ clientData, closeModal }) => {
|
|
9
|
-
const { t } = useTranslation();
|
|
10
|
-
return (
|
|
11
|
-
<div>
|
|
12
|
-
<ModalHeader closeModal={closeModal} title={t('clientRegistry', 'Client registry')} />
|
|
13
|
-
<ModalBody>
|
|
14
|
-
<p>{t('clientRegistry', 'Client registry')}</p>
|
|
15
|
-
<Card label="Name" value={`${clientData.firstName} ${clientData.middleName} ${clientData.lastName}`} />
|
|
16
|
-
<Card
|
|
17
|
-
label="Identification Type"
|
|
18
|
-
value={clientData.identifications.map((id) => id.identificationType).join(' ')}
|
|
19
|
-
/>
|
|
20
|
-
<Card
|
|
21
|
-
label="Identication Number"
|
|
22
|
-
value={clientData.identifications.map((id) => id.identificationNumber).join(' ')}
|
|
23
|
-
/>
|
|
24
|
-
<Card label="Date of Birth" value={clientData.dateOfBirth} />
|
|
25
|
-
<Card label={t('gender', 'Gender')} value={clientData.gender} />
|
|
26
|
-
</ModalBody>
|
|
27
|
-
<ModalFooter>
|
|
28
|
-
<Button kind="secondary" onClick={() => {}}>
|
|
29
|
-
{t('contactSupport', 'Contact supportt')}
|
|
30
|
-
</Button>
|
|
31
|
-
<Button kind="danger" onClick={closeModal}>
|
|
32
|
-
{t('continue', 'Continue')}
|
|
33
|
-
</Button>
|
|
34
|
-
</ModalFooter>
|
|
35
|
-
</div>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export default VerificationModal;
|
|
40
|
-
|
|
41
|
-
export const Card: React.FC<{ label: string; value: string }> = ({ label, value }) => {
|
|
42
|
-
return (
|
|
43
|
-
<div className={styles.cardContainer}>
|
|
44
|
-
<span>{label}</span>
|
|
45
|
-
<span>{value}</span>
|
|
46
|
-
</div>
|
|
47
|
-
);
|
|
48
|
-
};
|
package/src/root.test.tsx
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { createRoot } from 'react-dom/client';
|
|
3
|
-
import Root from './root.component';
|
|
4
|
-
|
|
5
|
-
window['getOpenmrsSpaBase'] = jest.fn().mockImplementation(() => '/');
|
|
6
|
-
|
|
7
|
-
jest.mock('@openmrs/esm-framework', () => {
|
|
8
|
-
const originalModule = jest.requireActual('@openmrs/esm-framework');
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
...originalModule,
|
|
12
|
-
validator: jest.fn(),
|
|
13
|
-
};
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
describe('root component', () => {
|
|
17
|
-
it('renders without crashing', () => {
|
|
18
|
-
const div = document.createElement('div');
|
|
19
|
-
const root = createRoot(div);
|
|
20
|
-
|
|
21
|
-
root.render(
|
|
22
|
-
<Root
|
|
23
|
-
savePatientForm={jest.fn()}
|
|
24
|
-
addressTemplate={{ results: [] }}
|
|
25
|
-
currentSession={{} as any}
|
|
26
|
-
relationshipTypes={{ results: [] }}
|
|
27
|
-
identifierTypes={[]}
|
|
28
|
-
isOffline={false}
|
|
29
|
-
/>,
|
|
30
|
-
);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import userEvent from '@testing-library/user-event';
|
|
3
|
-
import { screen, render } from '@testing-library/react';
|
|
4
|
-
import CancelPatientEdit from './cancel-patient-edit.component';
|
|
5
|
-
|
|
6
|
-
describe('CancelPatientEdit component', () => {
|
|
7
|
-
const mockClose = jest.fn();
|
|
8
|
-
const mockOnConfirm = jest.fn();
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
jest.clearAllMocks();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('renders the modal and triggers close and onConfirm functions', async () => {
|
|
15
|
-
const user = userEvent.setup();
|
|
16
|
-
|
|
17
|
-
render(<CancelPatientEdit close={mockClose} onConfirm={mockOnConfirm} />);
|
|
18
|
-
|
|
19
|
-
const cancelButton = screen.getByRole('button', { name: /Cancel/i });
|
|
20
|
-
await user.click(cancelButton);
|
|
21
|
-
expect(mockClose).toHaveBeenCalledTimes(1);
|
|
22
|
-
|
|
23
|
-
const discardButton = screen.getByRole('button', { name: /discard/i });
|
|
24
|
-
await user.click(discardButton);
|
|
25
|
-
expect(mockOnConfirm).toHaveBeenCalledTimes(1);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Avatar from 'react-avatar';
|
|
3
|
-
import GeoPattern from 'geopattern';
|
|
4
|
-
import { usePatientPhoto } from '../patient-registration/patient-registration.resource';
|
|
5
|
-
|
|
6
|
-
interface DisplayPatientPhotoProps {
|
|
7
|
-
patientName: string;
|
|
8
|
-
patientUuid: string;
|
|
9
|
-
size?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default function DisplayPatientPhoto({ patientUuid, patientName, size }: DisplayPatientPhotoProps) {
|
|
13
|
-
const { data: photo } = usePatientPhoto(patientUuid);
|
|
14
|
-
const patternUrl: string = GeoPattern.generate(patientUuid).toDataUri();
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<Avatar
|
|
18
|
-
alt={`${patientName ? `${patientName}'s avatar` : 'Patient avatar'}`}
|
|
19
|
-
color="rgba(0,0,0,0)"
|
|
20
|
-
name={patientName}
|
|
21
|
-
src={photo?.imageSrc}
|
|
22
|
-
size={size === 'small' ? '48' : '80'}
|
|
23
|
-
textSizeRatio={size === 'small' ? 1 : 2}
|
|
24
|
-
style={{
|
|
25
|
-
backgroundImage: `url(${patternUrl})`,
|
|
26
|
-
backgroundRepeat: 'round',
|
|
27
|
-
}}
|
|
28
|
-
/>
|
|
29
|
-
);
|
|
30
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { mockPatient } from '__mocks__';
|
|
4
|
-
import DisplayPatientPhoto from './display-photo.component';
|
|
5
|
-
|
|
6
|
-
jest.mock('../patient-registration/patient-registration.resource', () => ({
|
|
7
|
-
usePatientPhoto: jest.fn().mockReturnValue({ data: { imageSrc: 'test-image-src' } }),
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
jest.mock('geopattern', () => ({
|
|
11
|
-
generate: jest.fn().mockReturnValue({
|
|
12
|
-
toDataUri: jest.fn().mockReturnValue('https://example.com'),
|
|
13
|
-
}),
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
const patientUuid = mockPatient.uuid;
|
|
17
|
-
const patientName = mockPatient.name;
|
|
18
|
-
|
|
19
|
-
describe('DisplayPatientPhoto Component', () => {
|
|
20
|
-
it('should render the component with the patient photo and size should not be small', () => {
|
|
21
|
-
render(<DisplayPatientPhoto patientUuid={patientUuid} patientName={patientName} />);
|
|
22
|
-
|
|
23
|
-
const avatarImage = screen.getByTitle(`${patientName}`);
|
|
24
|
-
|
|
25
|
-
expect(avatarImage).toBeInTheDocument();
|
|
26
|
-
expect(avatarImage).toHaveAttribute('style', expect.stringContaining('width: 80px; height: 80px'));
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should render the component with the patient photo and size should be small i.e. 48px', () => {
|
|
30
|
-
render(<DisplayPatientPhoto patientUuid={patientUuid} patientName={patientName} size="small" />);
|
|
31
|
-
|
|
32
|
-
const avatarImage = screen.getByTitle(`${patientName}`);
|
|
33
|
-
|
|
34
|
-
expect(avatarImage).toBeInTheDocument();
|
|
35
|
-
expect(avatarImage).toHaveAttribute('style', expect.stringContaining('width: 48px; height: 48px'));
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import userEvent from '@testing-library/user-event';
|
|
3
|
-
import { render, screen } from '@testing-library/react';
|
|
4
|
-
import { navigate } from '@openmrs/esm-framework';
|
|
5
|
-
import { mockPatient } from '__mocks__';
|
|
6
|
-
import EditPatientDetailsButton from './edit-patient-details-button.component';
|
|
7
|
-
|
|
8
|
-
describe('EditPatientDetailsButton', () => {
|
|
9
|
-
const patientUuid = mockPatient.uuid;
|
|
10
|
-
|
|
11
|
-
it('should navigate to the edit page when clicked', async () => {
|
|
12
|
-
const user = userEvent.setup();
|
|
13
|
-
const mockNavigate = navigate as jest.Mock;
|
|
14
|
-
|
|
15
|
-
jest.mock('@openmrs/esm-framework', () => {
|
|
16
|
-
const originalModule = jest.requireActual('@openmrs/esm-framework');
|
|
17
|
-
return {
|
|
18
|
-
...originalModule,
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
render(<EditPatientDetailsButton patientUuid={patientUuid} />);
|
|
23
|
-
|
|
24
|
-
const button = screen.getByRole('menuitem');
|
|
25
|
-
await user.click(button);
|
|
26
|
-
|
|
27
|
-
expect(mockNavigate).toHaveBeenCalledWith({ to: expect.stringContaining(`/patient/${patientUuid}/edit`) });
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('should call the onTransition function when provided', async () => {
|
|
31
|
-
const user = userEvent.setup();
|
|
32
|
-
|
|
33
|
-
const onTransitionMock = jest.fn();
|
|
34
|
-
render(<EditPatientDetailsButton patientUuid={patientUuid} onTransition={onTransitionMock} />);
|
|
35
|
-
|
|
36
|
-
const button = screen.getByRole('menuitem');
|
|
37
|
-
await user.click(button);
|
|
38
|
-
|
|
39
|
-
expect(onTransitionMock).toHaveBeenCalled();
|
|
40
|
-
});
|
|
41
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/patient-registration/input/custom-input/identifier/{utils.test.ts → utils.testt.ts}
RENAMED
|
File without changes
|