@kenyaemr/esm-patient-registration-app 7.0.3-pre.89 → 8.0.1-pre.95
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 +15 -14
- package/dist/130.js +1 -1
- package/dist/130.js.map +1 -1
- package/dist/271.js +1 -1
- package/dist/319.js +1 -1
- package/dist/460.js +1 -1
- package/dist/564.js +1 -0
- package/dist/564.js.map +1 -0
- package/dist/623.js +1 -0
- package/dist/623.js.map +1 -0
- package/dist/644.js +1 -1
- package/dist/757.js +1 -1
- package/dist/788.js +1 -1
- package/dist/807.js +1 -1
- package/dist/831.js +2 -0
- package/dist/831.js.map +1 -0
- package/dist/833.js +1 -1
- package/dist/kenyaemr-esm-patient-registration-app.js +1 -1
- package/dist/kenyaemr-esm-patient-registration-app.js.buildmanifest.json +99 -99
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +2 -2
- package/src/add-patient-link.test.tsx +5 -9
- package/src/config-schema.ts +2 -0
- package/src/nav-link.test.tsx +3 -3
- package/src/patient-registration/field/address/address-field.component.tsx +2 -2
- package/src/patient-registration/field/address/address-hierarchy-levels.component.tsx +16 -18
- package/src/patient-registration/field/address/address-search.scss +5 -5
- package/src/patient-registration/field/address/tests/address-hierarchy.test.tsx +165 -95
- package/src/patient-registration/field/address/tests/address-search-component.test.tsx +18 -17
- package/src/patient-registration/field/dob/dob.component.tsx +3 -6
- package/src/patient-registration/field/dob/dob.test.tsx +69 -53
- package/src/patient-registration/field/field.scss +30 -25
- package/src/patient-registration/field/field.test.tsx +50 -52
- package/src/patient-registration/field/gender/gender-field.component.tsx +2 -2
- package/src/patient-registration/field/gender/gender-field.test.tsx +45 -27
- package/src/patient-registration/field/id/id-field.component.tsx +11 -12
- package/src/patient-registration/field/id/id-field.test.tsx +64 -49
- package/src/patient-registration/field/id/identifier-selection.scss +12 -8
- package/src/patient-registration/field/name/name-field.component.tsx +1 -1
- package/src/patient-registration/field/obs/obs-field.component.tsx +7 -12
- package/src/patient-registration/field/obs/obs-field.test.tsx +98 -62
- package/src/patient-registration/field/person-attributes/coded-person-attribute-field.test.tsx +9 -6
- package/src/patient-registration/field/person-attributes/person-attribute-field.test.tsx +49 -51
- package/src/patient-registration/field/person-attributes/text-person-attribute-field.test.tsx +2 -0
- package/src/patient-registration/input/basic-input/select/select-input.test.tsx +1 -1
- package/src/patient-registration/input/custom-input/autosuggest/autosuggest.scss +5 -5
- package/src/patient-registration/input/custom-input/autosuggest/autosuggest.test.tsx +75 -33
- package/src/patient-registration/input/custom-input/identifier/identifier-input.component.tsx +3 -1
- package/src/patient-registration/input/custom-input/identifier/identifier-input.test.tsx +9 -12
- package/src/patient-registration/input/dummy-data/dummy-data-input.test.tsx +2 -11
- package/src/patient-registration/input/input.scss +12 -12
- package/src/patient-registration/patient-registration-context.ts +6 -6
- package/src/patient-registration/patient-registration-utils.ts +4 -5
- package/src/patient-registration/patient-registration.component.tsx +4 -14
- package/src/patient-registration/patient-registration.resource.test.tsx +0 -4
- package/src/patient-registration/patient-registration.scss +11 -25
- package/src/patient-registration/patient-registration.test.tsx +75 -85
- package/src/patient-registration/patient-registration.types.ts +18 -18
- package/src/patient-registration/section/death-info/death-info-section.test.tsx +1 -10
- package/src/patient-registration/section/demographics/demographics-section.test.tsx +32 -29
- package/src/patient-registration/section/patient-relationships/relationships-section.test.tsx +16 -6
- package/src/patient-registration/section/patient-relationships/relationships.scss +4 -4
- package/src/patient-registration/section/section-wrapper.component.tsx +1 -1
- package/src/patient-registration/section/section.scss +16 -1
- package/src/patient-registration/ui-components/overlay/overlay.scss +8 -8
- package/src/patient-registration/validation/patient-registration-validation.test.tsx +35 -10
- package/src/patient-verification/patient-verification-utils.ts +0 -1
- package/src/widgets/cancel-patient-edit.test.tsx +0 -4
- package/src/widgets/delete-identifier-confirmation.scss +8 -8
- package/src/widgets/delete-identifier-confirmation.test.tsx +0 -4
- package/src/widgets/edit-patient-details-button.test.tsx +2 -8
- package/translations/am.json +4 -0
- package/translations/ar.json +4 -0
- package/translations/es.json +4 -0
- package/translations/fr.json +4 -0
- package/translations/he.json +4 -0
- package/translations/km.json +4 -0
- package/translations/zh.json +4 -0
- package/translations/zh_CN.json +4 -0
- package/dist/220.js +0 -2
- package/dist/220.js.map +0 -1
- package/dist/453.js +0 -1
- package/dist/453.js.map +0 -1
- package/dist/975.js +0 -1
- package/dist/975.js.map +0 -1
- package/src/root.test.tsx +0 -32
- /package/dist/{220.js.LICENSE.txt → 831.js.LICENSE.txt} +0 -0
|
@@ -1,68 +1,91 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
3
|
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import { Form, Formik } from 'formik';
|
|
5
|
+
import { getDefaultsFromConfigSchema, useConfig } from '@openmrs/esm-framework';
|
|
4
6
|
import { Identifiers } from './id-field.component';
|
|
7
|
+
import { mockOpenmrsId, mockIdentifierTypes, mockPatient, mockSession } from '__mocks__';
|
|
8
|
+
import { type RegistrationConfig, esmPatientRegistrationSchema } from '../../../config-schema';
|
|
5
9
|
import { type Resources, ResourcesContext } from '../../../offline.resources';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
import { PatientRegistrationContext, type PatientRegistrationContextProps } from '../../patient-registration-context';
|
|
11
|
+
|
|
12
|
+
const mockUseConfig = jest.mocked(useConfig<RegistrationConfig>);
|
|
13
|
+
|
|
14
|
+
const mockResourcesContextValue = {
|
|
15
|
+
addressTemplate: null,
|
|
16
|
+
currentSession: mockSession.data,
|
|
17
|
+
identifierTypes: [],
|
|
18
|
+
relationshipTypes: [],
|
|
19
|
+
} as Resources;
|
|
20
|
+
|
|
21
|
+
const mockInitialFormValues = {
|
|
22
|
+
additionalFamilyName: '',
|
|
23
|
+
additionalGivenName: '',
|
|
24
|
+
additionalMiddleName: '',
|
|
25
|
+
addNameInLocalLanguage: false,
|
|
26
|
+
address: {},
|
|
27
|
+
birthdate: null,
|
|
28
|
+
birthdateEstimated: false,
|
|
29
|
+
deathCause: '',
|
|
30
|
+
deathDate: '',
|
|
31
|
+
familyName: 'Doe',
|
|
32
|
+
gender: 'male',
|
|
33
|
+
givenName: 'John',
|
|
34
|
+
identifiers: mockOpenmrsId,
|
|
35
|
+
isDead: false,
|
|
36
|
+
middleName: 'Test',
|
|
37
|
+
monthsEstimated: 0,
|
|
38
|
+
patientUuid: mockPatient.uuid,
|
|
39
|
+
relationships: [],
|
|
40
|
+
telephoneNumber: '',
|
|
41
|
+
yearsEstimated: 0,
|
|
42
|
+
};
|
|
9
43
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
44
|
+
const mockContextValues: PatientRegistrationContextProps = {
|
|
45
|
+
currentPhoto: null,
|
|
46
|
+
inEditMode: false,
|
|
47
|
+
identifierTypes: [],
|
|
48
|
+
initialFormValues: mockInitialFormValues,
|
|
49
|
+
isOffline: false,
|
|
50
|
+
setCapturePhotoProps: jest.fn(),
|
|
51
|
+
setFieldValue: jest.fn(),
|
|
52
|
+
setInitialFormValues: jest.fn(),
|
|
53
|
+
validationSchema: null,
|
|
54
|
+
values: mockInitialFormValues,
|
|
55
|
+
};
|
|
16
56
|
|
|
17
57
|
describe('Identifiers', () => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
relationshipTypes: [],
|
|
26
|
-
identifierTypes: [...mockedIdentifierTypes],
|
|
27
|
-
} as Resources;
|
|
58
|
+
beforeEach(() => {
|
|
59
|
+
mockUseConfig.mockReturnValue({
|
|
60
|
+
...getDefaultsFromConfigSchema(esmPatientRegistrationSchema),
|
|
61
|
+
defaultPatientIdentifierTypes: ['OpenMRS ID'],
|
|
62
|
+
});
|
|
63
|
+
});
|
|
28
64
|
|
|
29
65
|
it('should render loading skeleton when identifier types are loading', () => {
|
|
30
66
|
render(
|
|
31
|
-
<ResourcesContext.Provider value={
|
|
67
|
+
<ResourcesContext.Provider value={mockResourcesContextValue}>
|
|
32
68
|
<Formik initialValues={{}} onSubmit={null}>
|
|
33
69
|
<Form>
|
|
34
|
-
<PatientRegistrationContext.Provider
|
|
35
|
-
value={{
|
|
36
|
-
setFieldValue: jest.fn(),
|
|
37
|
-
initialFormValues: { identifiers: { ...mockedIdentifierTypes[0] } },
|
|
38
|
-
setInitialFormValues: jest.fn(),
|
|
39
|
-
values: {
|
|
40
|
-
identifiers: { openmrsID },
|
|
41
|
-
},
|
|
42
|
-
}}>
|
|
70
|
+
<PatientRegistrationContext.Provider value={mockContextValues}>
|
|
43
71
|
<Identifiers />
|
|
44
72
|
</PatientRegistrationContext.Provider>
|
|
45
73
|
</Form>
|
|
46
74
|
</Formik>
|
|
47
75
|
</ResourcesContext.Provider>,
|
|
48
76
|
);
|
|
49
|
-
|
|
77
|
+
|
|
78
|
+
expect(screen.getByRole('progressbar')).toBeInTheDocument();
|
|
50
79
|
});
|
|
51
80
|
|
|
52
81
|
it('should render identifier inputs when identifier types are loaded', () => {
|
|
82
|
+
mockResourcesContextValue.identifierTypes = mockIdentifierTypes;
|
|
83
|
+
|
|
53
84
|
render(
|
|
54
85
|
<ResourcesContext.Provider value={mockResourcesContextValue}>
|
|
55
86
|
<Formik initialValues={{}} onSubmit={null}>
|
|
56
87
|
<Form>
|
|
57
|
-
<PatientRegistrationContext.Provider
|
|
58
|
-
value={{
|
|
59
|
-
setFieldValue: jest.fn(),
|
|
60
|
-
initialFormValues: { identifiers: { ...mockedIdentifierTypes[0] } },
|
|
61
|
-
setInitialFormValues: jest.fn(),
|
|
62
|
-
values: {
|
|
63
|
-
identifiers: { openmrsID },
|
|
64
|
-
},
|
|
65
|
-
}}>
|
|
88
|
+
<PatientRegistrationContext.Provider value={mockContextValues}>
|
|
66
89
|
<Identifiers />
|
|
67
90
|
</PatientRegistrationContext.Provider>
|
|
68
91
|
</Form>
|
|
@@ -78,20 +101,12 @@ describe('Identifiers', () => {
|
|
|
78
101
|
|
|
79
102
|
it('should open identifier selection overlay when "Configure" button is clicked', async () => {
|
|
80
103
|
const user = userEvent.setup();
|
|
81
|
-
|
|
104
|
+
mockResourcesContextValue.identifierTypes = mockIdentifierTypes;
|
|
82
105
|
render(
|
|
83
106
|
<ResourcesContext.Provider value={mockResourcesContextValue}>
|
|
84
107
|
<Formik initialValues={{}} onSubmit={null}>
|
|
85
108
|
<Form>
|
|
86
|
-
<PatientRegistrationContext.Provider
|
|
87
|
-
value={{
|
|
88
|
-
setFieldValue: jest.fn(),
|
|
89
|
-
initialFormValues: { identifiers: { ...mockedIdentifierTypes[0] } },
|
|
90
|
-
setInitialFormValues: jest.fn(),
|
|
91
|
-
values: {
|
|
92
|
-
identifiers: { openmrsID },
|
|
93
|
-
},
|
|
94
|
-
}}>
|
|
109
|
+
<PatientRegistrationContext.Provider value={mockContextValues}>
|
|
95
110
|
<Identifiers />
|
|
96
111
|
</PatientRegistrationContext.Provider>
|
|
97
112
|
</Form>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
@use '@carbon/
|
|
2
|
-
@
|
|
1
|
+
@use '@carbon/layout';
|
|
2
|
+
@use '@openmrs/esm-styleguide/src/vars' as *;
|
|
3
3
|
|
|
4
4
|
.button {
|
|
5
|
-
height:
|
|
5
|
+
height: layout.$spacing-10;
|
|
6
6
|
display: flex;
|
|
7
7
|
align-content: flex-start;
|
|
8
8
|
align-items: baseline;
|
|
@@ -10,28 +10,32 @@
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
.tablet {
|
|
13
|
-
padding:
|
|
13
|
+
padding: layout.$spacing-06 layout.$spacing-05;
|
|
14
14
|
background-color: $ui-02;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
.desktop {
|
|
18
|
-
padding:
|
|
18
|
+
padding: 0;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
.radioGroup {
|
|
22
22
|
background-color: $ui-01;
|
|
23
|
-
padding:
|
|
23
|
+
padding: layout.$spacing-05;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
.radioButton {
|
|
27
27
|
margin: 0 !important;
|
|
28
28
|
label {
|
|
29
|
-
height:
|
|
29
|
+
height: layout.$spacing-07;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
.space05 {
|
|
34
|
+
margin: layout.$spacing-05 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
33
37
|
:global(.omrs-breakpoint-lt-desktop) {
|
|
34
38
|
.radioButton label {
|
|
35
|
-
height:
|
|
39
|
+
height: layout.$spacing-09 !important;
|
|
36
40
|
}
|
|
37
41
|
}
|
|
@@ -5,8 +5,8 @@ import { useField } from 'formik';
|
|
|
5
5
|
import { ExtensionSlot, useConfig } from '@openmrs/esm-framework';
|
|
6
6
|
import { Input } from '../../input/basic-input/input/input.component';
|
|
7
7
|
import { PatientRegistrationContext } from '../../patient-registration-context';
|
|
8
|
-
import styles from '../field.scss';
|
|
9
8
|
import { type RegistrationConfig } from '../../../config-schema';
|
|
9
|
+
import styles from '../field.scss';
|
|
10
10
|
|
|
11
11
|
export const unidentifiedPatientAttributeTypeUuid = '8b56eac7-5c76-4b9c-8c6f-1deab8d3fc47';
|
|
12
12
|
const containsNoNumbers = /^([^0-9]*)$/;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useContext, useMemo } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { Field } from 'formik';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { InlineNotification, Layer, Select, SelectItem } from '@carbon/react';
|
|
6
|
-
import { OpenmrsDatePicker,
|
|
6
|
+
import { OpenmrsDatePicker, useConfig } from '@openmrs/esm-framework';
|
|
7
7
|
import { type ConceptResponse } from '../../patient-registration.types';
|
|
8
8
|
import { type FieldDefinition, type RegistrationConfig } from '../../../config-schema';
|
|
9
9
|
import { Input } from '../../input/basic-input/input/input.component';
|
|
10
10
|
import { useConcept, useConceptAnswers } from '../field.resource';
|
|
11
|
-
import styles from './../field.scss';
|
|
12
11
|
import { PatientRegistrationContext } from '../../patient-registration-context';
|
|
13
|
-
import
|
|
12
|
+
import styles from './../field.scss';
|
|
14
13
|
|
|
15
14
|
export interface ObsFieldProps {
|
|
16
15
|
fieldDefinition: FieldDefinition;
|
|
@@ -19,7 +18,6 @@ export interface ObsFieldProps {
|
|
|
19
18
|
export function ObsField({ fieldDefinition }: ObsFieldProps) {
|
|
20
19
|
const { t } = useTranslation();
|
|
21
20
|
const { data: concept, isLoading } = useConcept(fieldDefinition.uuid);
|
|
22
|
-
|
|
23
21
|
const config = useConfig<RegistrationConfig>();
|
|
24
22
|
|
|
25
23
|
if (!config.registrationObs.encounterTypeUuid) {
|
|
@@ -170,9 +168,8 @@ function DateObsField({ concept, label, required, placeholder }: DateObsFieldPro
|
|
|
170
168
|
const fieldName = `obs.${concept.uuid}`;
|
|
171
169
|
const { setFieldValue } = useContext(PatientRegistrationContext);
|
|
172
170
|
|
|
173
|
-
const onDateChange = (
|
|
174
|
-
|
|
175
|
-
setFieldValue(fieldName, refinedDate);
|
|
171
|
+
const onDateChange = (date: Date) => {
|
|
172
|
+
setFieldValue(fieldName, date);
|
|
176
173
|
};
|
|
177
174
|
|
|
178
175
|
return (
|
|
@@ -186,14 +183,12 @@ function DateObsField({ concept, label, required, placeholder }: DateObsFieldPro
|
|
|
186
183
|
id={fieldName}
|
|
187
184
|
{...field}
|
|
188
185
|
isRequired={required}
|
|
189
|
-
onChange={
|
|
186
|
+
onChange={onDateChange}
|
|
190
187
|
labelText={label ?? concept.display}
|
|
191
188
|
isInvalid={errors[fieldName] && touched[fieldName]}
|
|
189
|
+
invalidText={t(meta.error)}
|
|
192
190
|
value={field.value}
|
|
193
191
|
/>
|
|
194
|
-
{errors[fieldName] && touched[fieldName] && (
|
|
195
|
-
<div className={styles.radioFieldError}>{meta.error && t(meta.error)}</div>
|
|
196
|
-
)}
|
|
197
192
|
</>
|
|
198
193
|
);
|
|
199
194
|
}}
|
|
@@ -1,39 +1,36 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
import { getDefaultsFromConfigSchema, OpenmrsDatePicker, useConfig } from '@openmrs/esm-framework';
|
|
6
|
+
import { esmPatientRegistrationSchema, type FieldDefinition, type RegistrationConfig } from '../../../config-schema';
|
|
6
7
|
import { useConcept, useConceptAnswers } from '../field.resource';
|
|
7
8
|
import { ObsField } from './obs-field.component';
|
|
8
|
-
import { PatientRegistrationContext } from '../../patient-registration-context';
|
|
9
|
-
import
|
|
9
|
+
import { PatientRegistrationContext, type PatientRegistrationContextProps } from '../../patient-registration-context';
|
|
10
|
+
import { mockOpenmrsId, mockPatient } from '__mocks__';
|
|
10
11
|
|
|
11
|
-
const
|
|
12
|
+
const mockOpenmrsDatePicker = jest.mocked(OpenmrsDatePicker);
|
|
13
|
+
const mockUseConcept = jest.mocked(useConcept);
|
|
14
|
+
const mockUseConceptAnswers = jest.mocked(useConceptAnswers);
|
|
15
|
+
const mockUseConfig = jest.mocked(useConfig<RegistrationConfig>);
|
|
12
16
|
|
|
13
|
-
jest.mock('../field.resource');
|
|
17
|
+
jest.mock('../field.resource');
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
30
|
-
}),
|
|
31
|
-
};
|
|
19
|
+
mockOpenmrsDatePicker.mockImplementation(({ id, labelText, value, onChange }) => {
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<label htmlFor={id}>{labelText}</label>
|
|
23
|
+
<input
|
|
24
|
+
id={id}
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
value={value ? dayjs(value).format('DD/MM/YYYY') : ''}
|
|
27
|
+
onChange={(evt) => {
|
|
28
|
+
onChange(dayjs(evt.target.value).toDate());
|
|
29
|
+
}}
|
|
30
|
+
/>
|
|
31
|
+
</>
|
|
32
|
+
);
|
|
32
33
|
});
|
|
33
|
-
|
|
34
|
-
const mockedUseConcept = useConcept as jest.Mock;
|
|
35
|
-
const mockedUseConceptAnswers = useConceptAnswers as jest.Mock;
|
|
36
|
-
|
|
37
34
|
const useConceptMockImpl = (uuid: string) => {
|
|
38
35
|
let data;
|
|
39
36
|
if (uuid == 'weight-uuid') {
|
|
@@ -122,7 +119,7 @@ jest.mock('formik', () => ({
|
|
|
122
119
|
const textFieldDef: FieldDefinition = {
|
|
123
120
|
id: 'chief-complaint',
|
|
124
121
|
type: 'obs',
|
|
125
|
-
label: '',
|
|
122
|
+
label: 'Chief complaint',
|
|
126
123
|
placeholder: '',
|
|
127
124
|
showHeading: false,
|
|
128
125
|
uuid: 'chief-complaint-uuid',
|
|
@@ -137,7 +134,7 @@ const textFieldDef: FieldDefinition = {
|
|
|
137
134
|
const numberFieldDef: FieldDefinition = {
|
|
138
135
|
id: 'weight',
|
|
139
136
|
type: 'obs',
|
|
140
|
-
label: '',
|
|
137
|
+
label: 'Weight',
|
|
141
138
|
placeholder: '',
|
|
142
139
|
showHeading: false,
|
|
143
140
|
uuid: 'weight-uuid',
|
|
@@ -152,7 +149,7 @@ const numberFieldDef: FieldDefinition = {
|
|
|
152
149
|
const dateFieldDef: FieldDefinition = {
|
|
153
150
|
id: 'vac_date',
|
|
154
151
|
type: 'obs',
|
|
155
|
-
label: '',
|
|
152
|
+
label: 'Vaccination date',
|
|
156
153
|
placeholder: '',
|
|
157
154
|
showHeading: false,
|
|
158
155
|
uuid: 'vaccination-date-uuid',
|
|
@@ -167,7 +164,7 @@ const dateFieldDef: FieldDefinition = {
|
|
|
167
164
|
const codedFieldDef: FieldDefinition = {
|
|
168
165
|
id: 'nationality',
|
|
169
166
|
type: 'obs',
|
|
170
|
-
label: '',
|
|
167
|
+
label: 'Nationality',
|
|
171
168
|
placeholder: '',
|
|
172
169
|
showHeading: false,
|
|
173
170
|
uuid: 'nationality-uuid',
|
|
@@ -179,41 +176,82 @@ const codedFieldDef: FieldDefinition = {
|
|
|
179
176
|
customConceptAnswers: [],
|
|
180
177
|
};
|
|
181
178
|
|
|
179
|
+
const mockInitialFormValues = {
|
|
180
|
+
additionalFamilyName: '',
|
|
181
|
+
additionalGivenName: '',
|
|
182
|
+
additionalMiddleName: '',
|
|
183
|
+
addNameInLocalLanguage: false,
|
|
184
|
+
address: {},
|
|
185
|
+
birthdate: null,
|
|
186
|
+
birthdateEstimated: false,
|
|
187
|
+
deathCause: '',
|
|
188
|
+
deathDate: '',
|
|
189
|
+
familyName: 'Doe',
|
|
190
|
+
gender: 'male',
|
|
191
|
+
givenName: 'John',
|
|
192
|
+
identifiers: mockOpenmrsId,
|
|
193
|
+
isDead: false,
|
|
194
|
+
middleName: 'Test',
|
|
195
|
+
monthsEstimated: 0,
|
|
196
|
+
patientUuid: mockPatient.uuid,
|
|
197
|
+
relationships: [],
|
|
198
|
+
telephoneNumber: '',
|
|
199
|
+
yearsEstimated: 0,
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const initialContextValues: PatientRegistrationContextProps = {
|
|
203
|
+
currentPhoto: null,
|
|
204
|
+
inEditMode: false,
|
|
205
|
+
identifierTypes: [],
|
|
206
|
+
initialFormValues: mockInitialFormValues,
|
|
207
|
+
isOffline: false,
|
|
208
|
+
setCapturePhotoProps: jest.fn(),
|
|
209
|
+
setFieldValue: jest.fn(),
|
|
210
|
+
setInitialFormValues: jest.fn(),
|
|
211
|
+
validationSchema: null,
|
|
212
|
+
values: mockInitialFormValues,
|
|
213
|
+
};
|
|
214
|
+
|
|
182
215
|
describe('ObsField', () => {
|
|
183
216
|
beforeEach(() => {
|
|
184
|
-
mockUseConfig.mockReturnValue({
|
|
185
|
-
|
|
186
|
-
|
|
217
|
+
mockUseConfig.mockReturnValue({
|
|
218
|
+
...getDefaultsFromConfigSchema(esmPatientRegistrationSchema),
|
|
219
|
+
registrationObs: { encounterTypeUuid: 'reg-enc-uuid' },
|
|
220
|
+
} as RegistrationConfig);
|
|
221
|
+
mockUseConcept.mockImplementation(useConceptMockImpl);
|
|
222
|
+
mockUseConceptAnswers.mockImplementation(useConceptAnswersMockImpl);
|
|
187
223
|
});
|
|
188
224
|
|
|
189
225
|
it("logs an error and doesn't render if no registration encounter type is provided", () => {
|
|
190
|
-
mockUseConfig.mockReturnValue({
|
|
226
|
+
mockUseConfig.mockReturnValue({
|
|
227
|
+
...getDefaultsFromConfigSchema(esmPatientRegistrationSchema),
|
|
228
|
+
registrationObs: { encounterTypeUuid: null },
|
|
229
|
+
} as RegistrationConfig);
|
|
230
|
+
|
|
191
231
|
console.error = jest.fn();
|
|
192
232
|
render(<ObsField fieldDefinition={textFieldDef} />);
|
|
193
233
|
expect(console.error).toHaveBeenCalledWith(
|
|
194
234
|
expect.stringMatching(/no registration encounter type has been configured/i),
|
|
195
235
|
);
|
|
196
|
-
expect(screen.queryByRole('textbox')).
|
|
236
|
+
expect(screen.queryByRole('textbox')).not.toBeInTheDocument();
|
|
197
237
|
});
|
|
198
238
|
|
|
199
239
|
it('renders a text box for text concept', () => {
|
|
200
240
|
render(<ObsField fieldDefinition={textFieldDef} />);
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
expect(screen.getByRole('textbox')).toBeInTheDocument();
|
|
241
|
+
|
|
242
|
+
expect(screen.getByRole('textbox', { name: 'Chief complaint (optional)' })).toBeInTheDocument();
|
|
204
243
|
});
|
|
205
244
|
|
|
206
245
|
it('renders a number box for number concept', () => {
|
|
207
246
|
render(<ObsField fieldDefinition={numberFieldDef} />);
|
|
208
|
-
|
|
209
|
-
expect(screen.getByRole('spinbutton')).toBeInTheDocument();
|
|
247
|
+
|
|
248
|
+
expect(screen.getByRole('spinbutton', { name: 'Weight (optional)' })).toBeInTheDocument();
|
|
210
249
|
});
|
|
211
250
|
|
|
212
|
-
// TODO
|
|
213
|
-
|
|
214
|
-
it.skip('renders a datepicker for date concept', async () => {
|
|
251
|
+
// TODO: Fix this test
|
|
252
|
+
xit('renders a datepicker for date concept', async () => {
|
|
215
253
|
render(
|
|
216
|
-
<PatientRegistrationContext.Provider value={
|
|
254
|
+
<PatientRegistrationContext.Provider value={initialContextValues}>
|
|
217
255
|
<ObsField fieldDefinition={dateFieldDef} />
|
|
218
256
|
</PatientRegistrationContext.Provider>,
|
|
219
257
|
);
|
|
@@ -227,25 +265,23 @@ describe('ObsField', () => {
|
|
|
227
265
|
|
|
228
266
|
it('renders a select for a coded concept', () => {
|
|
229
267
|
render(<ObsField fieldDefinition={codedFieldDef} />);
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
expect(
|
|
233
|
-
expect(
|
|
268
|
+
|
|
269
|
+
expect(screen.getByRole('combobox', { name: 'Nationality' })).toBeInTheDocument();
|
|
270
|
+
expect(screen.getByRole('option', { name: 'USA' })).toBeInTheDocument();
|
|
271
|
+
expect(screen.getByRole('option', { name: 'Mexico' })).toBeInTheDocument();
|
|
234
272
|
});
|
|
235
273
|
|
|
236
274
|
it('select uses answerConcept for answers when it is provided', async () => {
|
|
237
|
-
const user = userEvent.setup();
|
|
238
|
-
|
|
239
275
|
render(<ObsField fieldDefinition={{ ...codedFieldDef, answerConceptSetUuid: 'other-countries-uuid' }} />);
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
expect(
|
|
243
|
-
|
|
276
|
+
|
|
277
|
+
expect(screen.getByRole('combobox', { name: 'Nationality' })).toBeInTheDocument();
|
|
278
|
+
expect(screen.getByRole('option', { name: 'Kenya' })).toBeInTheDocument();
|
|
279
|
+
expect(screen.getByRole('option', { name: 'Uganda' })).toBeInTheDocument();
|
|
280
|
+
expect(screen.queryByRole('option', { name: 'USA' })).not.toBeInTheDocument();
|
|
281
|
+
expect(screen.queryByRole('option', { name: 'Mexico' })).not.toBeInTheDocument();
|
|
244
282
|
});
|
|
245
283
|
|
|
246
284
|
it('select uses customConceptAnswers for answers when provided', async () => {
|
|
247
|
-
const user = userEvent.setup();
|
|
248
|
-
|
|
249
285
|
render(
|
|
250
286
|
<ObsField
|
|
251
287
|
fieldDefinition={{
|
|
@@ -259,9 +295,9 @@ describe('ObsField', () => {
|
|
|
259
295
|
}}
|
|
260
296
|
/>,
|
|
261
297
|
);
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
expect(
|
|
265
|
-
|
|
298
|
+
|
|
299
|
+
expect(screen.getByRole('combobox', { name: 'Nationality' })).toBeInTheDocument();
|
|
300
|
+
expect(screen.getByRole('option', { name: 'Mozambique' })).toBeInTheDocument();
|
|
301
|
+
expect(screen.queryByRole('option', { name: 'Uganda' })).not.toBeInTheDocument();
|
|
266
302
|
});
|
|
267
303
|
});
|
package/src/patient-registration/field/person-attributes/coded-person-attribute-field.test.tsx
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Form, Formik } from 'formik';
|
|
2
3
|
import { render, screen } from '@testing-library/react';
|
|
3
4
|
import { useConceptAnswers } from '../field.resource';
|
|
4
5
|
import { CodedPersonAttributeField } from './coded-person-attribute-field.component';
|
|
5
|
-
import { Form, Formik } from 'formik';
|
|
6
6
|
|
|
7
7
|
jest.mock('formik', () => ({
|
|
8
8
|
...jest.requireActual('formik'),
|
|
9
9
|
}));
|
|
10
10
|
|
|
11
|
-
jest.mock('../field.resource');
|
|
11
|
+
jest.mock('../field.resource');
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const mockUseConceptAnswers = jest.mocked(useConceptAnswers);
|
|
14
14
|
|
|
15
15
|
describe('CodedPersonAttributeField', () => {
|
|
16
16
|
const conceptAnswers = [
|
|
@@ -27,8 +27,7 @@ describe('CodedPersonAttributeField', () => {
|
|
|
27
27
|
const answerConceptSetUuid = '6682d17f-0777-45e4-a39b-93f77eb3531c';
|
|
28
28
|
|
|
29
29
|
beforeEach(() => {
|
|
30
|
-
|
|
31
|
-
mockedUseConceptAnswers.mockReturnValue({
|
|
30
|
+
mockUseConceptAnswers.mockReturnValue({
|
|
32
31
|
data: conceptAnswers,
|
|
33
32
|
isLoading: false,
|
|
34
33
|
});
|
|
@@ -45,6 +44,7 @@ describe('CodedPersonAttributeField', () => {
|
|
|
45
44
|
answerConceptSetUuid={null}
|
|
46
45
|
label={personAttributeType.display}
|
|
47
46
|
customConceptAnswers={[]}
|
|
47
|
+
required={false}
|
|
48
48
|
/>
|
|
49
49
|
</Form>
|
|
50
50
|
</Formik>,
|
|
@@ -53,7 +53,7 @@ describe('CodedPersonAttributeField', () => {
|
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
it('shows error if the concept answer set does not have any concept answers', () => {
|
|
56
|
-
|
|
56
|
+
mockUseConceptAnswers.mockReturnValue({
|
|
57
57
|
data: [],
|
|
58
58
|
isLoading: false,
|
|
59
59
|
});
|
|
@@ -67,6 +67,7 @@ describe('CodedPersonAttributeField', () => {
|
|
|
67
67
|
answerConceptSetUuid={answerConceptSetUuid}
|
|
68
68
|
label={personAttributeType.display}
|
|
69
69
|
customConceptAnswers={[]}
|
|
70
|
+
required={false}
|
|
70
71
|
/>
|
|
71
72
|
</Form>
|
|
72
73
|
</Formik>,
|
|
@@ -84,6 +85,7 @@ describe('CodedPersonAttributeField', () => {
|
|
|
84
85
|
answerConceptSetUuid={answerConceptSetUuid}
|
|
85
86
|
label={personAttributeType.display}
|
|
86
87
|
customConceptAnswers={[]}
|
|
88
|
+
required={false}
|
|
87
89
|
/>
|
|
88
90
|
</Form>
|
|
89
91
|
</Formik>,
|
|
@@ -113,6 +115,7 @@ describe('CodedPersonAttributeField', () => {
|
|
|
113
115
|
label: 'Special Option B',
|
|
114
116
|
},
|
|
115
117
|
]}
|
|
118
|
+
required={false}
|
|
116
119
|
/>
|
|
117
120
|
</Form>
|
|
118
121
|
</Formik>,
|