@kenyaemr/esm-patient-registration-app 5.2.1 → 5.2.3

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 (111) hide show
  1. package/dist/102.js +1 -0
  2. package/dist/102.js.map +1 -0
  3. package/dist/130.js +1 -1
  4. package/dist/130.js.map +1 -1
  5. package/dist/271.js +1 -0
  6. package/dist/319.js +1 -1
  7. package/dist/431.js +2 -0
  8. package/dist/431.js.map +1 -0
  9. package/dist/460.js +1 -1
  10. package/dist/537.js +1 -1
  11. package/dist/537.js.map +1 -1
  12. package/dist/574.js +1 -1
  13. package/dist/644.js +1 -0
  14. package/dist/757.js +1 -1
  15. package/dist/784.js +1 -1
  16. package/dist/788.js +1 -1
  17. package/dist/807.js +1 -1
  18. package/dist/833.js +1 -1
  19. package/dist/kenyaemr-esm-patient-registration-app.js +1 -1
  20. package/dist/kenyaemr-esm-patient-registration-app.js.buildmanifest.json +91 -47
  21. package/dist/kenyaemr-esm-patient-registration-app.js.map +1 -1
  22. package/dist/main.js +1 -1
  23. package/dist/main.js.map +1 -1
  24. package/dist/routes.json +1 -1
  25. package/dist.tar.gz +0 -0
  26. package/package.json +3 -2
  27. package/src/add-patient-link.test.tsx +9 -7
  28. package/src/config-schema.ts +31 -38
  29. package/src/constants.ts +1 -1
  30. package/src/offline.resources.ts +1 -1
  31. package/src/offline.ts +2 -2
  32. package/src/patient-registration/before-save-prompt.tsx +2 -1
  33. package/src/patient-registration/field/__mocks__/field.resource.ts +1 -1
  34. package/src/patient-registration/field/address/address-field.component.tsx +5 -4
  35. package/src/patient-registration/field/address/address-hierarchy.resource.tsx +2 -2
  36. package/src/patient-registration/field/address/address-search.component.tsx +1 -14
  37. package/src/patient-registration/field/address/custom-address-field.component.tsx +1 -1
  38. package/src/patient-registration/field/address/tests/address-hierarchy.test.tsx +3 -3
  39. package/src/patient-registration/field/address/tests/address-search-component.test.tsx +14 -7
  40. package/src/patient-registration/field/custom-field.component.tsx +1 -1
  41. package/src/patient-registration/field/dob/dob.component.tsx +2 -2
  42. package/src/patient-registration/field/dob/dob.test.tsx +0 -3
  43. package/src/patient-registration/field/field.component.tsx +4 -1
  44. package/src/patient-registration/field/field.resource.ts +2 -2
  45. package/src/patient-registration/field/field.test.tsx +98 -95
  46. package/src/patient-registration/field/gender/gender-field.component.tsx +4 -4
  47. package/src/patient-registration/field/gender/gender-field.test.tsx +7 -14
  48. package/src/patient-registration/field/id/id-field.component.tsx +6 -6
  49. package/src/patient-registration/field/id/id-field.test.tsx +9 -7
  50. package/src/patient-registration/field/id/identifier-selection-overlay.component.tsx +1 -1
  51. package/src/patient-registration/field/name/name-field.component.tsx +1 -1
  52. package/src/patient-registration/field/obs/obs-field.component.tsx +35 -33
  53. package/src/patient-registration/field/obs/obs-field.test.tsx +106 -28
  54. package/src/patient-registration/field/person-attributes/coded-attributes.component.tsx +1 -1
  55. package/src/patient-registration/field/person-attributes/coded-person-attribute-field.component.tsx +67 -24
  56. package/src/patient-registration/field/person-attributes/coded-person-attribute-field.test.tsx +54 -30
  57. package/src/patient-registration/field/person-attributes/person-attribute-field.component.tsx +4 -3
  58. package/src/patient-registration/field/person-attributes/person-attribute-field.test.tsx +1 -1
  59. package/src/patient-registration/field/person-attributes/{person-attributes.resource.tsx → person-attributes.resource.ts} +2 -2
  60. package/src/patient-registration/field/person-attributes/text-person-attribute-field.component.tsx +1 -1
  61. package/src/patient-registration/field/phone/phone-field.component.tsx +16 -0
  62. package/src/patient-registration/form-manager.test.ts +1 -1
  63. package/src/patient-registration/form-manager.ts +14 -22
  64. package/src/patient-registration/input/basic-input/select/select-input.test.tsx +3 -3
  65. package/src/patient-registration/input/custom-input/autosuggest/autosuggest.component.tsx +5 -5
  66. package/src/patient-registration/input/custom-input/autosuggest/autosuggest.test.tsx +70 -58
  67. package/src/patient-registration/input/custom-input/identifier/identifier-input.component.tsx +1 -1
  68. package/src/patient-registration/input/custom-input/identifier/identifier-input.test.tsx +2 -5
  69. package/src/patient-registration/input/custom-input/identifier/utils.ts +1 -1
  70. package/src/patient-registration/input/dummy-data/dummy-data-input.component.tsx +1 -1
  71. package/src/patient-registration/input/dummy-data/dummy-data-input.test.tsx +6 -6
  72. package/src/patient-registration/patient-registration-context.ts +3 -4
  73. package/src/patient-registration/patient-registration-hooks.ts +12 -12
  74. package/src/patient-registration/patient-registration-utils.ts +7 -7
  75. package/src/patient-registration/patient-registration.component.tsx +7 -7
  76. package/src/patient-registration/{patient-registration.resource.tsx → patient-registration.resource.ts} +1 -1
  77. package/src/patient-registration/patient-registration.test.tsx +270 -251
  78. package/src/patient-registration/{patient-registration.types.tsx → patient-registration.types.ts} +11 -3
  79. package/src/patient-registration/section/death-info/death-info-section.test.tsx +33 -45
  80. package/src/patient-registration/section/demographics/demographics-section.test.tsx +1 -2
  81. package/src/patient-registration/section/generic-section.component.tsx +1 -1
  82. package/src/patient-registration/section/patient-relationships/relationships-section.component.tsx +3 -3
  83. package/src/patient-registration/section/patient-relationships/relationships-section.test.tsx +17 -5
  84. package/src/patient-registration/section/patient-relationships/relationships.resource.tsx +3 -3
  85. package/src/patient-registration/section/section-wrapper.component.tsx +1 -1
  86. package/src/patient-registration/section/section.component.tsx +1 -1
  87. package/src/patient-registration/validation/patient-registration-validation.test.tsx +140 -126
  88. package/src/patient-registration/validation/patient-registration-validation.tsx +54 -46
  89. package/src/widgets/cancel-patient-edit.test.tsx +7 -4
  90. package/src/widgets/delete-identifier-confirmation-modal.test.tsx +7 -4
  91. package/src/widgets/display-photo.test.tsx +1 -1
  92. package/src/widgets/edit-patient-details-button.test.tsx +12 -7
  93. package/translations/am.json +4 -2
  94. package/translations/ar.json +4 -2
  95. package/translations/en.json +4 -2
  96. package/translations/es.json +4 -2
  97. package/translations/fr.json +4 -2
  98. package/translations/he.json +4 -2
  99. package/translations/km.json +4 -2
  100. package/translations/zh.json +89 -0
  101. package/translations/zh_CN.json +89 -0
  102. package/tsconfig.json +1 -1
  103. package/__mocks__/autogenerationoptions.mock.ts +0 -34
  104. package/dist/388.js +0 -2
  105. package/dist/388.js.map +0 -1
  106. package/dist/598.js +0 -1
  107. package/dist/598.js.map +0 -1
  108. package/src/patient-registration/field/__mocks__/identifier-types.mock.ts +0 -76
  109. package/src/patient-registration/field/__mocks__/identifiers.mock.ts +0 -27
  110. package/src/patient-registration/field/address/tests/mocks.ts +0 -98
  111. /package/dist/{388.js.LICENSE.txt → 431.js.LICENSE.txt} +0 -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":"cancelPatientEditModal","name":"cancel-patient-edit-modal","online":true,"offline":true},{"component":"patientPhoto","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":"5.2.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":"patientPhoto","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":"5.2.3"}
package/dist.tar.gz ADDED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenyaemr/esm-patient-registration-app",
3
- "version": "5.2.1",
3
+ "version": "5.2.3",
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",
@@ -38,10 +38,11 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@carbon/react": "^1.12.0",
41
+ "core-js-pure": "^3.34.0",
41
42
  "formik": "^2.1.5",
42
43
  "geopattern": "^1.2.3",
43
44
  "lodash-es": "^4.17.15",
44
- "react-avatar": "^4.0.0",
45
+ "react-avatar": "^5.0.3",
45
46
  "uuid": "^8.3.2",
46
47
  "yup": "^0.29.1"
47
48
  },
@@ -1,18 +1,20 @@
1
1
  import React from 'react';
2
- import { render, fireEvent } from '@testing-library/react';
3
- import * as esmFramework from '@openmrs/esm-framework';
2
+ import userEvent from '@testing-library/user-event';
3
+ import { render } from '@testing-library/react';
4
+ import { navigate } from '@openmrs/esm-framework';
4
5
  import Root from './add-patient-link';
5
6
 
7
+ const mockedNavigate = navigate as jest.Mock;
8
+
6
9
  describe('Add patient link component', () => {
7
- it('renders an "Add Patient" button and triggers navigation on click', () => {
8
- const navigateMock = jest.fn();
9
- jest.spyOn(esmFramework, 'navigate').mockImplementation(navigateMock);
10
+ it('renders an "Add Patient" button and triggers navigation on click', async () => {
11
+ const user = userEvent.setup();
10
12
 
11
13
  const { getByRole } = render(<Root />);
12
14
  const addButton = getByRole('button', { name: /add patient/i });
13
15
 
14
- fireEvent.click(addButton);
16
+ await user.click(addButton);
15
17
 
16
- expect(navigateMock).toHaveBeenCalledWith({ to: '${openmrsSpaBase}/patient-registration' });
18
+ expect(mockedNavigate).toHaveBeenCalledWith({ to: '${openmrsSpaBase}/patient-registration' });
17
19
  });
18
20
  });
@@ -11,14 +11,14 @@ export interface FieldDefinition {
11
11
  type: string;
12
12
  label?: string;
13
13
  uuid: string;
14
- placeholder: string;
14
+ placeholder?: string;
15
15
  showHeading: boolean;
16
- validation: {
16
+ validation?: {
17
17
  required: boolean;
18
18
  matches?: string;
19
19
  };
20
20
  answerConceptSetUuid?: string;
21
- customConceptAnswers: Array<CustomConceptAnswer>;
21
+ customConceptAnswers?: Array<CustomConceptAnswer>;
22
22
  }
23
23
  export interface CustomConceptAnswer {
24
24
  uuid: string;
@@ -27,7 +27,6 @@ export interface CustomConceptAnswer {
27
27
  export interface Gender {
28
28
  label?: string;
29
29
  value: string;
30
- id: string;
31
30
  }
32
31
 
33
32
  export interface RegistrationConfig {
@@ -59,6 +58,9 @@ export interface RegistrationConfig {
59
58
  month: number;
60
59
  };
61
60
  };
61
+ phone: {
62
+ personAttributeUuid: string;
63
+ };
62
64
  };
63
65
  links: {
64
66
  submitButton: string;
@@ -85,7 +87,8 @@ export const builtInSections: Array<SectionDefinition> = [
85
87
  { id: 'relationships', name: 'Relationships', fields: [] },
86
88
  ];
87
89
 
88
- export const builtInFields = ['name', 'gender', 'dob', 'address', 'id', 'phone & email'] as const;
90
+ // These fields are handled specially in field.component.tsx
91
+ export const builtInFields = ['name', 'gender', 'dob', 'id', 'address', 'phone'] as const;
89
92
 
90
93
  export const esmPatientRegistrationSchema = {
91
94
  sections: {
@@ -133,7 +136,7 @@ export const esmPatientRegistrationSchema = {
133
136
  type: {
134
137
  _type: Type.String,
135
138
  _description: "How this field's data will be stored—a person attribute or an obs.",
136
- // _validators: [validators.oneOf(['person attribute', 'obs'])],
139
+ _validators: [validators.oneOf(['person attribute', 'obs'])],
137
140
  },
138
141
  uuid: {
139
142
  _type: Type.UUID,
@@ -182,20 +185,12 @@ export const esmPatientRegistrationSchema = {
182
185
  },
183
186
  },
184
187
  _default: [],
185
- _description: 'For coded questions only. Provide ability to add custom concept answers.',
188
+ _description:
189
+ 'For coded questions only (obs or person attrbute). A list of custom concept answers. Overrides answers that come from the obs concept or from `answerSetConceptUuid`.',
186
190
  },
187
191
  },
188
- _default: [
189
- {
190
- id: 'phone',
191
- type: 'person attribute',
192
- uuid: '14d4f066-15f5-102d-96e4-000c29c2a5d7',
193
- showHeading: false,
194
- validation: {
195
- matches: '',
196
- },
197
- },
198
- ],
192
+ // Do not add fields here. If you want to add a field in code, add it to built-in fields above.
193
+ _default: [],
199
194
  _description:
200
195
  'Definitions for custom fields that can be used in sectionDefinitions. Can also be used to override built-in fields.',
201
196
  },
@@ -233,42 +228,33 @@ export const esmPatientRegistrationSchema = {
233
228
  _elements: {
234
229
  value: {
235
230
  _type: Type.String,
236
- _description: 'The value for sex option',
231
+ _description:
232
+ 'Value that will be sent to the server. Limited to FHIR-supported values for Administrative Gender',
233
+ _validators: [validators.oneOf(['male', 'female', 'other', 'unknown'])],
237
234
  },
238
235
  label: {
239
236
  _type: Type.String,
240
237
  _default: null,
241
- _description: 'The label displayed for sex option.',
242
- },
243
- id: {
244
- _type: Type.String,
245
- _default: null,
246
- _description: 'The id for sex option.',
238
+ _description:
239
+ 'The label displayed for the sex option, if it should be different from the value (the value will be translated; the English "translation" is upper-case).',
247
240
  },
248
241
  },
249
242
  _default: [
250
243
  {
251
- id: 'male',
252
- value: 'Male',
253
- label: 'Male',
244
+ value: 'male',
254
245
  },
255
246
  {
256
- id: 'female',
257
- value: 'Female',
258
- label: 'Female',
247
+ value: 'female',
259
248
  },
260
249
  {
261
- id: 'other',
262
- value: 'Other',
263
- label: 'Other',
250
+ value: 'other',
264
251
  },
265
252
  {
266
- id: 'unknown',
267
- value: 'Unknown',
268
- label: 'Unknown',
253
+ value: 'unknown',
269
254
  },
270
255
  ],
271
- _description: 'Provide ability to configure sex options.',
256
+ _description:
257
+ 'The options for sex selection during patient registration. This is Administrative Gender as it is called by FHIR (Possible options are limited to those defined in FHIR Administrative Gender, see https://hl7.org/fhir/R4/valueset-administrative-gender.html).',
272
258
  },
273
259
  address: {
274
260
  useAddressHierarchy: {
@@ -320,6 +306,13 @@ export const esmPatientRegistrationSchema = {
320
306
  },
321
307
  },
322
308
  },
309
+ phone: {
310
+ personAttributeUuid: {
311
+ _type: Type.UUID,
312
+ _default: '14d4f066-15f5-102d-96e4-000c29c2a5d7',
313
+ _description: 'The UUID of the phone number person attribute type',
314
+ },
315
+ },
323
316
  },
324
317
  links: {
325
318
  submitButton: {
package/src/constants.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { omrsOfflineCachingStrategyHttpHeaderName, OmrsOfflineHttpHeaders } from '@openmrs/esm-framework';
1
+ import { omrsOfflineCachingStrategyHttpHeaderName, type OmrsOfflineHttpHeaders } from '@openmrs/esm-framework';
2
2
 
3
3
  export const personRelationshipRepresentation =
4
4
  'custom:(display,uuid,' +
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import find from 'lodash-es/find';
3
3
  import camelCase from 'lodash-es/camelCase';
4
4
  import escapeRegExp from 'lodash-es/escapeRegExp';
5
- import { getConfig, messageOmrsServiceWorker, openmrsFetch, Session } from '@openmrs/esm-framework';
5
+ import { getConfig, messageOmrsServiceWorker, openmrsFetch, type Session } from '@openmrs/esm-framework';
6
6
  import type {
7
7
  PatientIdentifierType,
8
8
  FetchedPatientIdentifierType,
package/src/offline.ts CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  navigate,
5
5
  setupDynamicOfflineDataHandler,
6
6
  setupOfflineSync,
7
- SyncProcessOptions,
7
+ type SyncProcessOptions,
8
8
  } from '@openmrs/esm-framework';
9
9
  import { patientRegistration, personRelationshipRepresentation } from './constants';
10
10
  import {
@@ -15,7 +15,7 @@ import {
15
15
  fetchPatientIdentifierTypesWithSources,
16
16
  } from './offline.resources';
17
17
  import { FormManager } from './patient-registration/form-manager';
18
- import { PatientRegistration } from './patient-registration/patient-registration.types';
18
+ import { type PatientRegistration } from './patient-registration/patient-registration.types';
19
19
 
20
20
  export function setupOffline() {
21
21
  setupOfflineSync(patientRegistration, [], syncPatientRegistration, {
@@ -1,4 +1,5 @@
1
- import React, { useCallback, useEffect, useRef, useState } from 'react';
1
+ import type React from 'react';
2
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
3
  import { showModal, navigate } from '@openmrs/esm-framework';
3
4
  import { useTranslation } from 'react-i18next';
4
5
 
@@ -1,4 +1,4 @@
1
- import { ConceptResponse } from '../../patient-registration.types';
1
+ import { type ConceptResponse } from '../../patient-registration.types';
2
2
 
3
3
  export const useConcept = jest.fn(function mockUseConceptImplementation(uuid: string): {
4
4
  data: ConceptResponse;
@@ -2,13 +2,13 @@ import React, { useEffect, useState, useContext, useMemo } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import { ResourcesContext } from '../../../offline.resources';
4
4
  import { SkeletonText, InlineNotification } from '@carbon/react';
5
- import styles from '../field.scss';
6
5
  import { Input } from '../../input/basic-input/input/input.component';
7
- import { useConfig } from '@openmrs/esm-framework';
8
- import AddressSearchComponent from './address-search.component';
6
+ import { useConfig, useConnectivity } from '@openmrs/esm-framework';
9
7
  import { PatientRegistrationContext } from '../../patient-registration-context';
10
8
  import { useOrderedAddressHierarchyLevels } from './address-hierarchy.resource';
11
9
  import AddressHierarchyLevels from './address-hierarchy-levels.component';
10
+ import AddressSearchComponent from './address-search.component';
11
+ import styles from '../field.scss';
12
12
 
13
13
  function parseString(xmlDockAsString: string) {
14
14
  const parser = new DOMParser();
@@ -38,6 +38,7 @@ export const AddressComponent: React.FC = () => {
38
38
 
39
39
  const { t } = useTranslation();
40
40
  const config = useConfig();
41
+ const isOnline = useConnectivity();
41
42
  const {
42
43
  fieldConfigurations: {
43
44
  address: {
@@ -77,7 +78,7 @@ export const AddressComponent: React.FC = () => {
77
78
  );
78
79
  }
79
80
 
80
- if (!addressHierarchyEnabled) {
81
+ if (!addressHierarchyEnabled || !isOnline) {
81
82
  return (
82
83
  <AddressComponentContainer>
83
84
  {addressLayout.map((attributes, index) => (
@@ -1,7 +1,7 @@
1
- import { type FetchResponse, openmrsFetch } from '@openmrs/esm-framework';
2
- import { useField } from 'formik';
3
1
  import { useCallback, useContext, useEffect, useMemo } from 'react';
2
+ import { useField } from 'formik';
4
3
  import useSWRImmutable from 'swr/immutable';
4
+ import { type FetchResponse, openmrsFetch } from '@openmrs/esm-framework';
5
5
  import { PatientRegistrationContext } from '../../patient-registration-context';
6
6
 
7
7
  interface AddressFields {
@@ -66,26 +66,13 @@ const AddressSearchComponent: React.FC<AddressSearchComponentProps> = ({ address
66
66
  labelText={t('searchAddress', 'Search address')}
67
67
  placeholder={t('searchAddress', 'Search address')}
68
68
  ref={searchBox}
69
- helperText={
70
- searchString
71
- ? isLoading
72
- ? t('loadingResults', 'Loading results')
73
- : error
74
- ? error.message
75
- : addresses?.length === 0
76
- ? t('noResultsFound', 'No results found')
77
- : null
78
- : null
79
- }
80
69
  value={searchString}
81
70
  />
82
71
  {addressOptions.length > 0 && (
83
72
  /* Since the input has a marginBottom of 1rem */
84
73
  <ul className={styles.suggestions}>
85
74
  {addressOptions.map((address, index) => (
86
- <li //eslint-disable-line jsx-a11y/no-noninteractive-element-interactions
87
- key={index}
88
- onClick={(e) => handleChange(address)}>
75
+ <li key={index} onClick={(e) => handleChange(address)}>
89
76
  {address}
90
77
  </li>
91
78
  ))}
@@ -4,7 +4,7 @@ import { Field } from 'formik';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { Input } from '../../input/basic-input/input/input.component';
6
6
  import styles from '../field.scss';
7
- import { FieldDefinition } from '../../../config-schema';
7
+ import { type FieldDefinition } from '../../../config-schema';
8
8
 
9
9
  export interface AddressFieldProps {
10
10
  fieldDefinition: FieldDefinition;
@@ -2,11 +2,11 @@ import React from 'react';
2
2
  import { cleanup, render, screen } from '@testing-library/react';
3
3
  import { AddressComponent } from '../address-field.component';
4
4
  import { Formik, Form } from 'formik';
5
- import { Resources, ResourcesContext } from '../../../../offline.resources';
5
+ import { type Resources, ResourcesContext } from '../../../../offline.resources';
6
6
  import { PatientRegistrationContext } from '../../../patient-registration-context';
7
7
  import { useConfig } from '@openmrs/esm-framework';
8
8
  import { useOrderedAddressHierarchyLevels } from '../address-hierarchy.resource';
9
- import { mockedAddressTemplate, mockedOrderedFields } from './mocks';
9
+ import { mockedAddressTemplate, mockedOrderedFields } from '__mocks__';
10
10
 
11
11
  // Mocking the AddressSearchComponent
12
12
  jest.mock('../address-search.component', () => jest.fn(() => <div data-testid="address-search-bar" />));
@@ -31,7 +31,7 @@ jest.mock('../address-hierarchy.resource', () => ({
31
31
 
32
32
  async function renderAddressHierarchy(addressTemplate = mockedAddressTemplate) {
33
33
  await render(
34
- <ResourcesContext.Provider value={{ addressTemplate } as Resources}>
34
+ <ResourcesContext.Provider value={{ addressTemplate } as unknown as Resources}>
35
35
  <Formik initialValues={{}} onSubmit={null}>
36
36
  <Form>
37
37
  <PatientRegistrationContext.Provider value={{ setFieldValue: jest.fn() } as any}>
@@ -1,13 +1,13 @@
1
1
  import React from 'react';
2
- import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
2
+ import userEvent from '@testing-library/user-event';
3
+ import { render, screen } from '@testing-library/react';
3
4
  import { Formik, Form, useFormikContext } from 'formik';
4
- import { Resources, ResourcesContext } from '../../../../offline.resources';
5
+ import { type Resources, ResourcesContext } from '../../../../offline.resources';
5
6
  import { PatientRegistrationContext } from '../../../patient-registration-context';
6
7
  import { useConfig } from '@openmrs/esm-framework';
7
8
  import { useAddressHierarchy, useOrderedAddressHierarchyLevels } from '../address-hierarchy.resource';
8
- import { mockedAddressTemplate, mockedAddressOptions, mockedOrderedFields } from './mocks';
9
+ import { mockedAddressTemplate, mockedAddressOptions, mockedOrderedFields } from '__mocks__';
9
10
  import AddressSearchComponent from '../address-search.component';
10
- import userEvent from '@testing-library/user-event';
11
11
 
12
12
  useAddressHierarchy;
13
13
  jest.mock('@openmrs/esm-framework', () => ({
@@ -60,7 +60,6 @@ const setFieldValue = jest.fn();
60
60
 
61
61
  describe('Testing address search bar', () => {
62
62
  beforeEach(() => {
63
- cleanup();
64
63
  (useConfig as jest.Mock).mockImplementation(() => ({
65
64
  fieldConfigurations: {
66
65
  address: {
@@ -88,23 +87,31 @@ describe('Testing address search bar', () => {
88
87
  error: null,
89
88
  isLoading: false,
90
89
  }));
90
+
91
91
  renderAddressHierarchy();
92
+
92
93
  const searchbox = screen.getByRole('searchbox');
93
94
  expect(searchbox).toBeInTheDocument();
95
+
94
96
  const ul = screen.queryByRole('list');
95
97
  expect(ul).not.toBeInTheDocument();
96
98
  });
97
99
 
98
100
  it("should render only the results for the search term matched address' parents", async () => {
101
+ const user = userEvent.setup();
102
+
99
103
  (useAddressHierarchy as jest.Mock).mockImplementation(() => ({
100
104
  addresses: mockedAddressOptions,
101
105
  error: null,
102
106
  isLoading: false,
103
107
  }));
108
+
104
109
  renderAddressHierarchy();
110
+
105
111
  const searchString = 'nea';
106
112
  const separator = ' > ';
107
113
  const options: Set<string> = new Set();
114
+
108
115
  mockedAddressOptions.forEach((address) => {
109
116
  const values = address.split(separator);
110
117
  values.forEach((val, index) => {
@@ -118,10 +125,10 @@ describe('Testing address search bar', () => {
118
125
  addressOptions.forEach(async (address) => {
119
126
  const optionElement = screen.getByText(address);
120
127
  expect(optionElement).toBeInTheDocument();
121
- fireEvent.click(optionElement);
128
+ await user.click(optionElement);
122
129
  const values = address.split(separator);
123
130
  allFields.map(({ name }, index) => {
124
- waitFor(() => expect(setFieldValue).toBeCalledWith(`address.${name}`, values?.[index]));
131
+ expect(setFieldValue).toHaveBeenCalledWith(`address.${name}`, values?.[index]);
125
132
  });
126
133
  });
127
134
  });
@@ -1,6 +1,6 @@
1
1
  import { useConfig } from '@openmrs/esm-framework';
2
2
  import React from 'react';
3
- import { RegistrationConfig } from '../../config-schema';
3
+ 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';
@@ -1,11 +1,11 @@
1
- import React, { ChangeEvent, useCallback, useContext } from 'react';
1
+ import React, { type ChangeEvent, useCallback, useContext } from 'react';
2
2
  import { ContentSwitcher, DatePicker, DatePickerInput, Layer, Switch, TextInput } from '@carbon/react';
3
3
  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
7
  import { useConfig } from '@openmrs/esm-framework';
8
- import { RegistrationConfig } from '../../../config-schema';
8
+ import { type RegistrationConfig } from '../../../config-schema';
9
9
  import styles from '../field.scss';
10
10
 
11
11
  const calcBirthdate = (yearDelta, monthDelta, dateOfBirth) => {
@@ -2,8 +2,6 @@ import React from 'react';
2
2
  import { Formik, Form } from 'formik';
3
3
  import { render, screen } from '@testing-library/react';
4
4
  import userEvent from '@testing-library/user-event';
5
- import '@testing-library/jest-dom/extend-expect';
6
- import '@testing-library/jest-dom';
7
5
  import { DobField } from './dob.component';
8
6
  import { PatientRegistrationContext } from '../../patient-registration-context';
9
7
  import { initialFormValues } from '../../patient-registration.component';
@@ -62,7 +60,6 @@ function renderDob() {
62
60
  identifierTypes: [],
63
61
  values: formValues,
64
62
  validationSchema: null,
65
- setValidationSchema: (value) => {},
66
63
  inEditMode: false,
67
64
  setFieldValue: () => {},
68
65
  setCapturePhotoProps: (value) => {},
@@ -4,9 +4,10 @@ import { GenderField } from './gender/gender-field.component';
4
4
  import { Identifiers } from './id/id-field.component';
5
5
  import { DobField } from './dob/dob.component';
6
6
  import { reportError, useConfig } from '@openmrs/esm-framework';
7
- import { builtInFields, RegistrationConfig } from '../../config-schema';
7
+ import { builtInFields, type RegistrationConfig } from '../../config-schema';
8
8
  import { CustomField } from './custom-field.component';
9
9
  import { AddressComponent } from './address/address-field.component';
10
+ import { PhoneField } from './phone/phone-field.component';
10
11
 
11
12
  export interface FieldProps {
12
13
  name: string;
@@ -38,6 +39,8 @@ export function Field({ name }: FieldProps) {
38
39
  return <AddressComponent />;
39
40
  case 'id':
40
41
  return <Identifiers />;
42
+ case 'phone':
43
+ return <PhoneField />;
41
44
  default:
42
45
  return <CustomField name={name} />;
43
46
  }
@@ -1,6 +1,6 @@
1
- import { FetchResponse, openmrsFetch, showSnackbar } from '@openmrs/esm-framework';
1
+ import { type FetchResponse, openmrsFetch, showSnackbar } from '@openmrs/esm-framework';
2
2
  import useSWRImmutable from 'swr/immutable';
3
- import { ConceptAnswers, ConceptResponse } from '../patient-registration.types';
3
+ import { type ConceptAnswers, type ConceptResponse } from '../patient-registration.types';
4
4
 
5
5
  export function useConcept(conceptUuid: string): { data: ConceptResponse; isLoading: boolean } {
6
6
  const shouldFetch = typeof conceptUuid === 'string' && conceptUuid !== '';