@kenyaemr/esm-patient-registration-app 6.0.1-pre.1.0.6 → 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 (44) hide show
  1. package/dist/130.js +1 -1
  2. package/dist/130.js.map +1 -1
  3. package/dist/271.js +1 -1
  4. package/dist/330.js +1 -1
  5. package/dist/336.js +2 -0
  6. package/dist/336.js.LICENSE.txt +14 -0
  7. package/dist/336.js.map +1 -0
  8. package/dist/537.js +1 -1
  9. package/dist/537.js.map +1 -1
  10. package/dist/574.js +1 -1
  11. package/dist/59.js +1 -1
  12. package/dist/644.js +1 -1
  13. package/dist/735.js +1 -1
  14. package/dist/889.js +1 -0
  15. package/dist/889.js.map +1 -0
  16. package/dist/kenyaemr-esm-patient-registration-app.js +1 -1
  17. package/dist/kenyaemr-esm-patient-registration-app.js.buildmanifest.json +247 -253
  18. package/dist/main.js +1 -1
  19. package/dist/main.js.LICENSE.txt +0 -15
  20. package/dist/main.js.map +1 -1
  21. package/dist/routes.json +1 -1
  22. package/package.json +2 -2
  23. package/src/config-schema.ts +5 -0
  24. package/src/patient-registration/field/custom-field.component.tsx +6 -0
  25. package/src/patient-registration/field/dob/dob.component.tsx +17 -14
  26. package/src/patient-registration/field/dob/dob.test.tsx +1 -0
  27. package/src/patient-registration/field/field.test.tsx +1 -0
  28. package/src/patient-registration/field/person-attributes/custom-person-attribute-field.component.tsx +56 -0
  29. package/src/patient-registration/field/person-attributes/person-attribute-field.component.tsx +21 -7
  30. package/src/patient-registration/form-manager.ts +0 -1
  31. package/src/patient-registration/patient-registration.test.tsx +1 -1
  32. package/src/patient-registration/section/demographics/demographics-section.test.tsx +1 -0
  33. package/src/patient-registration/section/patient-relationships/relationships-section.component.tsx +5 -1
  34. package/src/patient-verification/assets/verification-assets.ts +1 -1
  35. package/src/patient-verification/patient-verification.component.tsx +17 -10
  36. package/src/patient-verification/patient-verification.scss +0 -4
  37. package/translations/en.json +4 -2
  38. package/translations/zh.json +1 -1
  39. package/translations/zh_CN.json +1 -1
  40. package/dist/762.js +0 -2
  41. package/dist/762.js.LICENSE.txt +0 -29
  42. package/dist/762.js.map +0 -1
  43. package/dist/816.js +0 -1
  44. package/dist/816.js.map +0 -1
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":"cancelPatientEditModal","name":"cancel-patient-edit-modal","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},{"component":"deleteIdentifierConfirmationModal","name":"delete-identifier-confirmation-modal","online":true,"offline":true},{"component":"emptyClientRegistryModal","name":"empty-client-registry-modal","online":true,"offline":true},{"component":"confirmClientRegistryModal","name":"confirm-client-registry-modal","online":true,"offline":true}],"version":"6.0.1-local.0"}
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":"cancelPatientEditModal","name":"cancel-patient-edit-modal","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},{"component":"deleteIdentifierConfirmationModal","name":"delete-identifier-confirmation-modal","online":true,"offline":true},{"component":"emptyClientRegistryModal","name":"empty-client-registry-modal","online":true,"offline":true},{"component":"confirmClientRegistryModal","name":"confirm-client-registry-modal","online":true,"offline":true}],"version":"6.0.1-pre.1.0.6"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenyaemr/esm-patient-registration-app",
3
- "version": "6.0.1-pre.1.0.6",
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 (
@@ -189,7 +189,6 @@ export class FormManager {
189
189
  );
190
190
  } else {
191
191
  const encounterToSave: Encounter = {
192
- encounterDatetime: new Date(),
193
192
  patient: savePatientResponse.data.uuid,
194
193
  encounterType: config.registrationObs.encounterTypeUuid,
195
194
  location: currentLocation,
@@ -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
 
@@ -177,7 +177,11 @@ export const RelationshipsSection = () => {
177
177
  uuid: type.uuid,
178
178
  direction: 'bIsToA',
179
179
  };
180
- aIsToB.display === bIsToA.display ? tmp.push(aIsToB) : tmp.push(aIsToB, bIsToA);
180
+ aIsToB.display === bIsToA.display
181
+ ? tmp.push(aIsToB)
182
+ : bIsToA.display === 'Patient'
183
+ ? tmp.push(aIsToB, { display: `Patient (${aIsToB.display})`, uuid: type.uuid, direction: 'bIsToA' })
184
+ : tmp.push(aIsToB, bIsToA);
181
185
  });
182
186
  setDisplayRelationshipTypes(tmp);
183
187
  }
@@ -7,5 +7,5 @@ export const countries = [
7
7
  export const verificationIdentifierTypes = [
8
8
  { name: 'National ID', value: 'national-id' },
9
9
  { name: 'Passport', value: 'passport' },
10
- { name: 'Birth certificate number', value: 'birth-certificate-number' },
10
+ { name: 'Birth certificate number', value: 'birth-certificate' },
11
11
  ];
@@ -1,6 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
- import { Tile, ComboBox, Layer, Button, Search, InlineLoading } from '@carbon/react';
3
+ import { Tile, ComboBox, Layer, Button, Search, InlineLoading, InlineNotification } from '@carbon/react';
4
4
  import styles from './patient-verification.scss';
5
5
  import { countries, verificationIdentifierTypes } from './assets/verification-assets';
6
6
  import { searchClientRegistry, useGlobalProperties } from './patient-verification-hook';
@@ -48,13 +48,6 @@ const PatientVerification: React.FC<PatientVerificationProps> = ({ props }) => {
48
48
  }
49
49
  };
50
50
 
51
- if (error) {
52
- return (
53
- <Tile className={styles.errorWrapper}>
54
- <p>Error occurred while reaching the client registry, please proceed with registration and try again later</p>
55
- </Tile>
56
- );
57
- }
58
51
  return (
59
52
  <div id={'patientVerification'}>
60
53
  <h3 className={styles.productiveHeading02} style={{ color: '#161616' }}>
@@ -64,6 +57,20 @@ const PatientVerification: React.FC<PatientVerificationProps> = ({ props }) => {
64
57
  <Layer>
65
58
  {isLoading && <InlineLoading status="active" iconDescription="Loading" description="Loading data..." />}
66
59
  </Layer>
60
+ {error && (
61
+ <InlineNotification
62
+ className={styles.errorWrapper}
63
+ aria-label="closes notification"
64
+ kind="error"
65
+ lowContrast
66
+ statusIconDescription="notification"
67
+ subtitle={t(
68
+ 'clientRegistryErrorSubtitle',
69
+ 'Please proceed with registration contact system admin and try again later',
70
+ )}
71
+ title={t('clientRegistryError', 'Error occurred while reaching the client registry')}
72
+ />
73
+ )}
67
74
  <Tile className={styles.verificationWrapper}>
68
75
  <Layer>
69
76
  <ComboBox
@@ -75,7 +82,7 @@ const PatientVerification: React.FC<PatientVerificationProps> = ({ props }) => {
75
82
  titleText={t('selectCountry', 'Select country')}
76
83
  initialSelectedItem={countries[0]}
77
84
  onChange={({ selectedItem }) =>
78
- setVerificationCriteria({ ...verificationCriteria, countryCode: selectedItem.initials })
85
+ setVerificationCriteria({ ...verificationCriteria, countryCode: selectedItem?.initials })
79
86
  }
80
87
  />
81
88
  </Layer>
@@ -88,7 +95,7 @@ const PatientVerification: React.FC<PatientVerificationProps> = ({ props }) => {
88
95
  label="Select identifier type"
89
96
  titleText={t('selectIdentifierType', 'Select identifier type')}
90
97
  onChange={({ selectedItem }) =>
91
- setVerificationCriteria({ ...verificationCriteria, identifierType: selectedItem.value })
98
+ setVerificationCriteria({ ...verificationCriteria, identifierType: selectedItem?.value })
92
99
  }
93
100
  />
94
101
  </Layer>
@@ -21,9 +21,5 @@
21
21
  }
22
22
 
23
23
  .errorWrapper {
24
- color: colors.$red-50;
25
24
  margin: 0 0 1rem 0;
26
- display: flex;
27
- justify-content: center;
28
- align-items: center;
29
25
  }
@@ -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",
@@ -45,7 +45,7 @@
45
45
  "givenNameLabelText": "名字",
46
46
  "givenNameRequired": "名字是必填项",
47
47
  "identifierValueRequired": "ID标识是必填项",
48
- "idFieldLabelText": "ID标识",
48
+ "idFieldLabelText": "ID",
49
49
  "IDInstructions": "选择您想为该患者添加的ID标识:",
50
50
  "incompleteForm": "表单未填完",
51
51
  "invalidEmail": "需要提供一个有效的电子邮件地址",
@@ -45,7 +45,7 @@
45
45
  "givenNameLabelText": "名字",
46
46
  "givenNameRequired": "名字是必填项",
47
47
  "identifierValueRequired": "ID标识是必填项",
48
- "idFieldLabelText": "ID标识",
48
+ "idFieldLabelText": "ID",
49
49
  "IDInstructions": "选择您想为该患者添加的ID标识:",
50
50
  "incompleteForm": "表单未填完",
51
51
  "invalidEmail": "需要提供一个有效的电子邮件地址",