@kenyaemr/esm-patient-registration-app 6.0.2 → 7.0.0

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.
Files changed (34) hide show
  1. package/dist/130.js +1 -1
  2. package/dist/130.js.map +1 -1
  3. package/dist/330.js +1 -1
  4. package/dist/336.js +2 -0
  5. package/dist/336.js.LICENSE.txt +14 -0
  6. package/dist/336.js.map +1 -0
  7. package/dist/537.js +1 -1
  8. package/dist/537.js.map +1 -1
  9. package/dist/574.js +1 -1
  10. package/dist/59.js +1 -1
  11. package/dist/735.js +1 -1
  12. package/dist/889.js +1 -0
  13. package/dist/889.js.map +1 -0
  14. package/dist/kenyaemr-esm-patient-registration-app.js +1 -1
  15. package/dist/kenyaemr-esm-patient-registration-app.js.buildmanifest.json +66 -66
  16. package/dist/main.js +1 -1
  17. package/dist/main.js.LICENSE.txt +0 -15
  18. package/dist/main.js.map +1 -1
  19. package/package.json +2 -2
  20. package/src/config-schema.ts +5 -0
  21. package/src/patient-registration/field/custom-field.component.tsx +6 -0
  22. package/src/patient-registration/field/dob/dob.component.tsx +17 -14
  23. package/src/patient-registration/field/dob/dob.test.tsx +1 -0
  24. package/src/patient-registration/field/field.test.tsx +1 -0
  25. package/src/patient-registration/field/person-attributes/custom-person-attribute-field.component.tsx +56 -0
  26. package/src/patient-registration/field/person-attributes/person-attribute-field.component.tsx +21 -7
  27. package/src/patient-registration/patient-registration.test.tsx +1 -1
  28. package/src/patient-registration/section/demographics/demographics-section.test.tsx +1 -0
  29. package/translations/en.json +4 -2
  30. package/dist/762.js +0 -2
  31. package/dist/762.js.LICENSE.txt +0 -29
  32. package/dist/762.js.map +0 -1
  33. package/dist/816.js +0 -1
  34. package/dist/816.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenyaemr/esm-patient-registration-app",
3
- "version": "6.0.2",
3
+ "version": "7.0.0",
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",
@@ -18,7 +18,7 @@
18
18
  "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
19
19
  "coverage": "yarn test --coverage",
20
20
  "typescript": "tsc",
21
- "extract-translations": "i18next 'src/**/*.component.tsx' 'src/index.ts'"
21
+ "extract-translations": "i18next 'src/**/*.component.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
22
22
  },
23
23
  "browserslist": [
24
24
  "extends browserslist-config-openmrs"
@@ -19,6 +19,11 @@ export interface FieldDefinition {
19
19
  };
20
20
  answerConceptSetUuid?: string;
21
21
  customConceptAnswers?: Array<CustomConceptAnswer>;
22
+ showWhenExpression?: {
23
+ field: string;
24
+ value: string;
25
+ };
26
+ renderType?: string;
22
27
  }
23
28
  export interface CustomConceptAnswer {
24
29
  uuid: string;
@@ -4,6 +4,7 @@ import { type RegistrationConfig } from '../../config-schema';
4
4
  import { AddressField } from './address/custom-address-field.component';
5
5
  import { ObsField } from './obs/obs-field.component';
6
6
  import { PersonAttributeField } from './person-attributes/person-attribute-field.component';
7
+ import { useField } from 'formik';
7
8
 
8
9
  export interface CustomFieldProps {
9
10
  name: string;
@@ -13,6 +14,11 @@ export function CustomField({ name }: CustomFieldProps) {
13
14
  const config = useConfig() as RegistrationConfig;
14
15
  const fieldDefinition = config.fieldDefinitions.filter((def) => def.id == name)[0];
15
16
 
17
+ const [{ value }] = useField(`attributes.${fieldDefinition.showWhenExpression?.field}`);
18
+ if (fieldDefinition.showWhenExpression && value !== fieldDefinition.showWhenExpression.value) {
19
+ return null;
20
+ }
21
+
16
22
  if (fieldDefinition.type === 'person attribute') {
17
23
  return <PersonAttributeField fieldDefinition={fieldDefinition} />;
18
24
  } else if (fieldDefinition.type === 'obs') {
@@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
4
4
  import { useField } from 'formik';
5
5
  import { generateFormatting } from '../../date-util';
6
6
  import { PatientRegistrationContext } from '../../patient-registration-context';
7
- import { useConfig } from '@openmrs/esm-framework';
7
+ import { OpenmrsDatePicker, useConfig } from '@openmrs/esm-framework';
8
8
  import { type RegistrationConfig } from '../../../config-schema';
9
9
  import styles from '../field.scss';
10
10
 
@@ -46,8 +46,8 @@ export const DobField: React.FC = () => {
46
46
  );
47
47
 
48
48
  const onDateChange = useCallback(
49
- (birthdate: Date[]) => {
50
- setFieldValue('birthdate', birthdate[0]);
49
+ (birthdate: Date) => {
50
+ setFieldValue('birthdate', birthdate);
51
51
  },
52
52
  [setFieldValue],
53
53
  );
@@ -101,17 +101,20 @@ export const DobField: React.FC = () => {
101
101
  <Layer>
102
102
  {!dobUnknown ? (
103
103
  <div className={styles.dobField}>
104
- <DatePicker dateFormat={dateFormat} datePickerType="single" onChange={onDateChange} maxDate={format(today)}>
105
- <DatePickerInput
106
- id="birthdate"
107
- {...birthdate}
108
- placeholder={placeHolder}
109
- labelText={t('dateOfBirthLabelText', 'Date of Birth')}
110
- invalid={!!(birthdateMeta.touched && birthdateMeta.error)}
111
- invalidText={birthdateMeta.error && t(birthdateMeta.error)}
112
- value={format(birthdate.value)}
113
- />
114
- </DatePicker>
104
+ <OpenmrsDatePicker
105
+ id="birthdate"
106
+ {...birthdate}
107
+ dateFormat={dateFormat}
108
+ onChange={onDateChange}
109
+ maxDate={today}
110
+ labelText={t('dateOfBirthLabelText', 'Date of Birth')}
111
+ invalid={!!(birthdateMeta.touched && birthdateMeta.error)}
112
+ invalidText={birthdateMeta.error && t(birthdateMeta.error)}
113
+ value={birthdate.value}
114
+ carbonOptions={{
115
+ placeholder: placeHolder,
116
+ }}
117
+ />
115
118
  </div>
116
119
  ) : (
117
120
  <div className={styles.grid}>
@@ -19,6 +19,7 @@ jest.mock('@openmrs/esm-framework', () => {
19
19
  },
20
20
  },
21
21
  })),
22
+ getLocale: jest.fn().mockReturnValue('en'),
22
23
  };
23
24
  });
24
25
 
@@ -10,6 +10,7 @@ import { PatientRegistrationContext } from '../patient-registration-context';
10
10
  jest.mock('@openmrs/esm-framework', () => ({
11
11
  ...jest.requireActual('@openmrs/esm-framework'),
12
12
  useConfig: jest.fn(),
13
+ getLocale: jest.fn().mockReturnValue('en'),
13
14
  }));
14
15
 
15
16
  const predefinedAddressTemplate = {
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import { Field } from 'formik';
3
+ import { Layer, Select, SelectItem } from '@carbon/react';
4
+ import { type PersonAttributeTypeResponse } from '../../patient-registration.types';
5
+ import { useTranslation } from 'react-i18next';
6
+ import styles from './../field.scss';
7
+ import classNames from 'classnames';
8
+
9
+ type CustomPersonAttributeFieldProps = {
10
+ id: string;
11
+ personAttributeType: PersonAttributeTypeResponse;
12
+ answerConceptSetUuid: string;
13
+ label?: string;
14
+ customConceptAnswers: Array<{ uuid: string; label?: string }>;
15
+ required: boolean;
16
+ };
17
+
18
+ const CustomPersonAttributeField: React.FC<CustomPersonAttributeFieldProps> = ({
19
+ personAttributeType,
20
+ required,
21
+ id,
22
+ label,
23
+ customConceptAnswers,
24
+ }) => {
25
+ const { t } = useTranslation();
26
+ const fieldName = `attributes.${personAttributeType.uuid}`;
27
+
28
+ return (
29
+ <div className={classNames(styles.customField, styles.halfWidthInDesktopView)}>
30
+ <Layer>
31
+ <Field name={fieldName}>
32
+ {({ field, form: { touched, errors }, meta }) => {
33
+ return (
34
+ <>
35
+ <Select
36
+ id={id}
37
+ name={`person-attribute-${personAttributeType.uuid}`}
38
+ labelText={label ?? personAttributeType?.display}
39
+ invalid={errors[fieldName] && touched[fieldName]}
40
+ required={required}
41
+ {...field}>
42
+ <SelectItem value={''} text={t('selectAnOption', 'Select an option')} />
43
+ {customConceptAnswers.map((answer) => (
44
+ <SelectItem key={answer.uuid} value={answer.uuid} text={answer.uuid} />
45
+ ))}
46
+ </Select>
47
+ </>
48
+ );
49
+ }}
50
+ </Field>
51
+ </Layer>
52
+ </div>
53
+ );
54
+ };
55
+
56
+ export default CustomPersonAttributeField;
@@ -6,6 +6,7 @@ import { usePersonAttributeType } from './person-attributes.resource';
6
6
  import { TextPersonAttributeField } from './text-person-attribute-field.component';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import styles from '../field.scss';
9
+ import CustomPersonAttributeField from './custom-person-attribute-field.component';
9
10
 
10
11
  export interface PersonAttributeFieldProps {
11
12
  fieldDefinition: FieldDefinition;
@@ -22,13 +23,26 @@ export function PersonAttributeField({ fieldDefinition }: PersonAttributeFieldPr
22
23
  switch (personAttributeType.format) {
23
24
  case 'java.lang.String':
24
25
  return (
25
- <TextPersonAttributeField
26
- personAttributeType={personAttributeType}
27
- validationRegex={fieldDefinition.validation?.matches ?? ''}
28
- label={fieldDefinition.label}
29
- required={fieldDefinition.validation?.required ?? false}
30
- id={fieldDefinition?.id}
31
- />
26
+ <>
27
+ {fieldDefinition.renderType === 'select' ? (
28
+ <CustomPersonAttributeField
29
+ personAttributeType={personAttributeType}
30
+ answerConceptSetUuid={fieldDefinition.answerConceptSetUuid}
31
+ label={fieldDefinition.label}
32
+ id={fieldDefinition?.id}
33
+ customConceptAnswers={fieldDefinition.customConceptAnswers ?? []}
34
+ required={fieldDefinition.validation?.required ?? false}
35
+ />
36
+ ) : (
37
+ <TextPersonAttributeField
38
+ personAttributeType={personAttributeType}
39
+ validationRegex={fieldDefinition.validation?.matches ?? ''}
40
+ label={fieldDefinition.label}
41
+ required={fieldDefinition.validation?.required ?? false}
42
+ id={fieldDefinition?.id}
43
+ />
44
+ )}
45
+ </>
32
46
  );
33
47
  case 'org.openmrs.Concept':
34
48
  return (
@@ -405,7 +405,7 @@ describe('Updating an existing patient record', () => {
405
405
  expect(givenNameInput.value).toBe('John');
406
406
  expect(familyNameInput.value).toBe('Wilson');
407
407
  expect(middleNameInput.value).toBeFalsy();
408
- expect(dateOfBirthInput.value).toBe('4/4/1972');
408
+ expect(dateOfBirthInput.value).toBe('04/04/1972');
409
409
  expect(genderInput.value).toBe('male');
410
410
 
411
411
  // do some edits
@@ -15,6 +15,7 @@ jest.mock('@openmrs/esm-framework', () => {
15
15
  useConfig: jest.fn().mockImplementation(() => ({
16
16
  fieldConfigurations: { dateOfBirth: { useEstimatedDateOfBirth: { enabled: true, dayOfMonth: 0, month: 0 } } },
17
17
  })),
18
+ getLocale: jest.fn().mockReturnValue('en'),
18
19
  };
19
20
  });
20
21
 
@@ -10,6 +10,8 @@
10
10
  "cancel": "Cancel",
11
11
  "causeOfDeathInputLabel": "Cause of Death",
12
12
  "clientRegistryEmpty": "Create & Post Patient",
13
+ "clientRegistryError": "Error occurred while reaching the client registry",
14
+ "clientRegistryErrorSubtitle": "Please proceed with registration contact system admin and try again later",
13
15
  "clientVerificationWithClientRegistry": "Client verification with client registry",
14
16
  "closeOverlay": "Close overlay",
15
17
  "codedPersonAttributeAnswerSetEmpty": "The coded person attribute field '{{codedPersonAttributeFieldId}}' has been defined with an answer concept set UUID '{{answerConceptSetUuid}}' that does not have any concept answers.",
@@ -65,7 +67,7 @@
65
67
  "negativeYears": "Negative years",
66
68
  "no": "No",
67
69
  "numberInNameDubious": "Number in name is dubious",
68
- "NUPI": "",
70
+ "nupi": "NUPI",
69
71
  "obsFieldUnknownDatatype": "Concept for obs field '{{fieldDefinitionId}}' has unknown datatype '{{datatypeName}}'",
70
72
  "optional": "optional",
71
73
  "other": "Other",
@@ -97,7 +99,7 @@
97
99
  "selectCountry": "Select country",
98
100
  "selectIdentifierType": "Select identifier type",
99
101
  "sexFieldLabelText": "Sex",
100
- "SHA Number": "",
102
+ "shaNumber": "SHA Number",
101
103
  "source": "Source",
102
104
  "stroke": "Stroke",
103
105
  "submitting": "Submitting",