@kenyaemr/esm-patient-registration-app 4.3.0 → 4.4.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 (36) hide show
  1. package/dist/574.js +1 -1
  2. package/dist/68.js +1 -1
  3. package/dist/68.js.map +1 -1
  4. package/dist/822.js +1 -1
  5. package/dist/822.js.map +1 -1
  6. package/dist/main.js +1 -1
  7. package/dist/main.js.map +1 -1
  8. package/dist/openmrs-esm-patient-registration-app.js.buildmanifest.json +12 -12
  9. package/package.json +2 -2
  10. package/src/index.ts +0 -18
  11. package/src/offline.resources.ts +8 -1
  12. package/src/patient-registration/field/address/address-field.component.tsx +0 -1
  13. package/src/patient-registration/field/person-attributes/coded-person-attribute-field.component.tsx +13 -11
  14. package/src/patient-registration/form-manager.ts +27 -10
  15. package/src/patient-registration/input/basic-input/input/input.test.tsx +47 -10
  16. package/src/patient-registration/input/basic-input/select/select-input.test.tsx +16 -3
  17. package/src/patient-registration/input/custom-input/autosuggest/autosuggest.test.tsx +25 -14
  18. package/src/patient-registration/patient-registration-hooks.ts +21 -75
  19. package/src/patient-registration/patient-registration-types.tsx +2 -8
  20. package/src/patient-registration/patient-registration.component.tsx +3 -26
  21. package/src/patient-registration/section/section-wrapper.component.tsx +1 -1
  22. package/src/root.component.tsx +1 -5
  23. package/translations/en.json +0 -15
  24. package/src/patient-registration/input/custom-input/estimated-age/estimated-age-input.component.tsx +0 -32
  25. package/src/patient-registration/input/custom-input/estimated-age/estimated-age-input.test.tsx +0 -36
  26. package/src/patient-registration/input/custom-input/unidentified-patient/unidentified-patient-input.component.tsx +0 -24
  27. package/src/patient-registration/input/custom-input/unidentified-patient/unidentified-patient-input.test.tsx +0 -39
  28. package/src/patient-verification/assets/counties.json +0 -236
  29. package/src/patient-verification/assets/verification-assets.ts +0 -11
  30. package/src/patient-verification/patient-verification-hook.tsx +0 -156
  31. package/src/patient-verification/patient-verification-utils.ts +0 -173
  32. package/src/patient-verification/patient-verification.component.tsx +0 -118
  33. package/src/patient-verification/patient-verification.scss +0 -30
  34. package/src/patient-verification/verification-modal/confirm-prompt.component.tsx +0 -69
  35. package/src/patient-verification/verification-modal/empty-prompt.component.tsx +0 -35
  36. package/src/patient-verification/verification-types.ts +0 -50
@@ -1,173 +0,0 @@
1
- import { showModal } from '@openmrs/esm-framework';
2
- import { FormikProps } from 'formik';
3
- import { FormValues } from '../patient-registration/patient-registration-types';
4
- import { ClientRegistryPatient, RegistryPatient } from './verification-types';
5
- import counties from './assets/counties.json';
6
-
7
- export function handleClientRegistryResponse(
8
- clientResponse: ClientRegistryPatient,
9
- props: FormikProps<FormValues>,
10
- searchTerm: string,
11
- ) {
12
- if (clientResponse?.clientExists === false) {
13
- const nupiIdentifiers = {
14
- ['nationalId']: {
15
- initialValue: searchTerm,
16
- identifierUuid: undefined,
17
- selectedSource: { uuid: '', name: '' },
18
- preferred: false,
19
- required: false,
20
- identifierTypeUuid: '49af6cdc-7968-4abb-bf46-de10d7f4859f',
21
- identifierName: 'National ID',
22
- identifierValue: searchTerm,
23
- },
24
- };
25
- const dispose = showModal('empty-client-registry-modal', {
26
- onConfirm: () => {
27
- props.setValues({ ...props.values, identifiers: { ...props.values.identifiers, ...nupiIdentifiers } });
28
- dispose();
29
- },
30
- close: () => dispose(),
31
- });
32
- }
33
-
34
- if (clientResponse?.clientExists) {
35
- const {
36
- client: {
37
- middleName,
38
- lastName,
39
- firstName,
40
- contact,
41
- country,
42
- countyOfBirth,
43
- residence,
44
- identifications,
45
- gender,
46
- dateOfBirth,
47
- isAlive,
48
- clientNumber,
49
- educationLevel,
50
- occupation,
51
- maritalStatus,
52
- },
53
- } = clientResponse;
54
-
55
- const nupiIdentifiers = {
56
- ['nationalId']: {
57
- initialValue: identifications !== undefined && identifications[0]?.identificationNumber,
58
- identifierUuid: undefined,
59
- selectedSource: { uuid: '', name: '' },
60
- preferred: false,
61
- required: false,
62
- identifierTypeUuid: '49af6cdc-7968-4abb-bf46-de10d7f4859f',
63
- identifierName: 'National ID',
64
- identifierValue: identifications !== undefined && identifications[0]?.identificationNumber,
65
- },
66
-
67
- ['nationalUniquePatientIdentifier']: {
68
- identifierTypeUuid: 'f85081e2-b4be-4e48-b3a4-7994b69bb101',
69
- identifierName: 'National Unique patient identifier',
70
- identifierValue: clientNumber,
71
- initialValue: clientNumber,
72
- identifierUuid: undefined,
73
- selectedSource: { uuid: '', name: '' },
74
- preferred: false,
75
- required: false,
76
- },
77
- };
78
-
79
- const dispose = showModal('confirm-client-registry-modal', {
80
- onConfirm: () => {
81
- props.setValues({
82
- ...props.values,
83
- familyName: lastName,
84
- middleName: middleName,
85
- givenName: firstName,
86
- gender: gender === 'male' ? 'Male' : 'Female',
87
- birthdate: new Date(dateOfBirth),
88
- isDead: !isAlive,
89
- attributes: {
90
- 'b2c38640-2603-4629-aebd-3b54f33f1e3a': contact?.primaryPhone,
91
- '94614350-84c8-41e0-ac29-86bc107069be': contact?.secondaryPhone,
92
- 'b8d0b331-1d2d-4a9a-b741-1816f498bdb6': contact?.emailAddress ?? '',
93
- },
94
- address: {
95
- address1: residence?.address,
96
- address2: '',
97
- address4: residence?.ward,
98
- cityVillage: residence?.village,
99
- stateProvince: residence?.subCounty,
100
- countyDistrict: counties.find((county) => county.code === parseInt(residence?.county))?.name,
101
- country: 'Kenya',
102
- postalCode: residence?.address,
103
- },
104
- identifiers: { ...props.values.identifiers, ...nupiIdentifiers },
105
- obs: {
106
- '1054AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA':
107
- props.values.concepts.find((concept) => concept.display?.toLowerCase() === maritalStatus?.toLowerCase())
108
- ?.uuid ?? '',
109
- '1712AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA':
110
- props.values.concepts.find((concept) => concept.display?.toLowerCase() === educationLevel?.toLowerCase())
111
- ?.uuid ?? '',
112
- '1542AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA':
113
- props.values.concepts.find((concept) => concept.display?.toLowerCase() === occupation?.toLowerCase())
114
- ?.uuid ?? '',
115
- },
116
- });
117
- dispose();
118
- },
119
- close: () => dispose(),
120
- patient: clientResponse.client,
121
- });
122
- }
123
- }
124
-
125
- export function generateNUPIPayload(formValues: FormValues): RegistryPatient {
126
- const educationLevel = formValues.concepts.find(
127
- (concept) => concept.uuid === formValues.obs['1712AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'],
128
- );
129
- const occupation = formValues.concepts.find(
130
- (concept) => concept.uuid === formValues.obs['1542AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'],
131
- );
132
- const maritalStatus = formValues.concepts.find(
133
- (concept) => concept.uuid === formValues.obs['1054AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'],
134
- );
135
-
136
- let createRegistryPatient: RegistryPatient = {
137
- firstName: formValues?.givenName,
138
- middleName: formValues?.middleName,
139
- lastName: formValues?.familyName,
140
- gender: formValues?.gender === 'Male' ? 'male' : 'female',
141
- dateOfBirth: new Date(formValues.birthdate).toISOString(),
142
- isAlive: !formValues.isDead,
143
- residence: {
144
- county: `0${counties.find((county) => county.name.includes(formValues.address['countyDistrict']))?.code}`,
145
- subCounty: formValues.address['stateProvince']?.toLocaleLowerCase(),
146
- ward: formValues.address['address4']?.toLocaleLowerCase(),
147
- village: formValues.address['cityVillage'],
148
- landmark: formValues.address['address2'],
149
- address: formValues.address['postalCode'],
150
- },
151
- nextOfKins: [],
152
- contact: {
153
- primaryPhone: formValues.attributes['b2c38640-2603-4629-aebd-3b54f33f1e3a'],
154
- secondaryPhone: formValues.attributes['94614350-84c8-41e0-ac29-86bc107069be'],
155
- emailAddress: formValues.attributes['b8d0b331-1d2d-4a9a-b741-1816f498bdb6'],
156
- },
157
- country: 'KE',
158
- countyOfBirth: `0${counties.find((county) => county.name.includes(formValues.address['countyDistrict']))?.code}`,
159
- educationLevel: educationLevel?.display?.toLowerCase() ?? '',
160
- religion: '',
161
- occupation: occupation?.display?.toLowerCase() ?? '',
162
- maritalStatus: maritalStatus?.display?.toLowerCase() ?? '',
163
- originFacilityKmflCode: '',
164
- nascopCCCNumber: '',
165
- identifications: [
166
- {
167
- identificationType: 'national-id',
168
- identificationNumber: formValues.identifiers['nationalId']?.identifierValue,
169
- },
170
- ],
171
- };
172
- return createRegistryPatient;
173
- }
@@ -1,118 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import { Tile, ComboBox, Layer, Button, Search, InlineLoading, InlineNotification } from '@carbon/react';
4
- import styles from './patient-verification.scss';
5
- import { countries, verificationIdentifierTypes } from './assets/verification-assets';
6
- import { searchClientRegistry, useGlobalProperties } from './patient-verification-hook';
7
- import { showToast } from '@openmrs/esm-framework';
8
- import { handleClientRegistryResponse } from './patient-verification-utils';
9
- import { FormValues } from '../patient-registration/patient-registration-types';
10
- import { FormikProps } from 'formik';
11
-
12
- interface PatientVerificationProps {
13
- props: FormikProps<FormValues>;
14
- }
15
-
16
- const PatientVerification: React.FC<PatientVerificationProps> = ({ props }) => {
17
- const { t } = useTranslation();
18
- const { data, isLoading, error } = useGlobalProperties();
19
- const [verificationCriteria, setVerificationCriteria] = useState({
20
- searchTerm: '',
21
- identifierType: '',
22
- });
23
- const [isLoadingSearch, setIsLoadingSearch] = useState(false);
24
-
25
- const handleSearch = async () => {
26
- setIsLoadingSearch(true);
27
- try {
28
- const clientRegistryResponse = await searchClientRegistry(
29
- verificationCriteria.identifierType,
30
- verificationCriteria.searchTerm,
31
- props.values.token,
32
- );
33
- setIsLoadingSearch(false);
34
- handleClientRegistryResponse(clientRegistryResponse, props, verificationCriteria.searchTerm);
35
- } catch (error) {
36
- showToast({
37
- title: 'Client registry error',
38
- description: `Please reload the registration page and re-try again, if the issue persist contact system administrator`,
39
- millis: 10000,
40
- kind: 'error',
41
- critical: true,
42
- });
43
- setIsLoadingSearch(false);
44
- }
45
- };
46
-
47
- if (isLoading) {
48
- <InlineLoading status="active" iconDescription="Loading" description="Loading data..." />;
49
- }
50
-
51
- if (error) {
52
- return (
53
- <InlineNotification
54
- lowContrast
55
- hideCloseButton
56
- title="Client registry network error"
57
- subtitle="Could not connect to client registry, please proceed with registration and try again later"
58
- style={{ marginBottom: '0.5rem' }}
59
- />
60
- );
61
- }
62
- return (
63
- <div id={'patientVerification'}>
64
- <h3 className={styles.productiveHeading02} style={{ color: '#161616' }}>
65
- {t('clientVerificationWithClientRegistry', 'Client verification with client registry')}
66
- </h3>
67
- <div style={{ margin: '1rem 0 1rem' }}>
68
- <Layer>
69
- {isLoading && <InlineLoading status="active" iconDescription="Loading" description="Loading data..." />}
70
- </Layer>
71
- <Tile className={styles.verificationWrapper}>
72
- <Layer>
73
- <ComboBox
74
- ariaLabel={t('selectCountry', 'Select country')}
75
- id="selectCountry"
76
- items={countries}
77
- itemToString={(item) => item?.name ?? ''}
78
- label="Combo box menu options"
79
- titleText={t('selectCountry', 'Select country')}
80
- initialSelectedItem={countries[0]}
81
- />
82
- </Layer>
83
- <Layer>
84
- <ComboBox
85
- ariaLabel={t('selectIdentifierType', 'Select identifier type')}
86
- id="selectIdentifierType"
87
- items={verificationIdentifierTypes}
88
- itemToString={(item) => item?.name ?? ''}
89
- label="Combo box menu options"
90
- titleText={t('selectIdentifierType', 'Select identifier type')}
91
- onChange={({ selectedItem }) =>
92
- setVerificationCriteria({ ...verificationCriteria, identifierType: selectedItem.value })
93
- }
94
- />
95
- </Layer>
96
- <Layer>
97
- <Search
98
- id="search-1"
99
- autoFocus
100
- placeHolderText="Search"
101
- disabled={!verificationCriteria.identifierType}
102
- onChange={(event) => setVerificationCriteria({ ...verificationCriteria, searchTerm: event.target.value })}
103
- />
104
- </Layer>
105
- {!isLoadingSearch ? (
106
- <Button disabled={!verificationCriteria.identifierType && !isLoading} size="md" onClick={handleSearch}>
107
- {t('validate', 'Validate')}
108
- </Button>
109
- ) : (
110
- <InlineLoading status="active" iconDescription="Loading" description="Searching client registry" />
111
- )}
112
- </Tile>
113
- </div>
114
- </div>
115
- );
116
- };
117
-
118
- export default PatientVerification;
@@ -1,30 +0,0 @@
1
- @use '@carbon/colors';
2
- @import '../patient-registration/patient-registration.scss';
3
-
4
- /* Desktop */
5
- :global(.omrs-breakpoint-gt-tablet) {
6
- .verificationWrapper {
7
- display: grid;
8
- grid-template-columns: 1fr 1fr 1fr 1fr;
9
- column-gap: 0.325rem;
10
- align-items: flex-end;
11
- }
12
- }
13
-
14
- /* Tablet */
15
- :global(.omrs-breakpoint-lt-desktop) {
16
- .verificationWrapper {
17
- row-gap: 0.5rem;
18
- display: flex;
19
- flex-direction: column;
20
-
21
- }
22
- }
23
-
24
- .errorWrapper {
25
- color: colors.$red-50;
26
- margin: 0 0 1rem 0;
27
- display: flex;
28
- justify-content: center;
29
- align-items: center;
30
- }
@@ -1,69 +0,0 @@
1
- import React from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import { Button } from '@carbon/react';
4
- import { age, ExtensionSlot, formatDate } from '@openmrs/esm-framework';
5
- import capitalize from 'lodash-es/capitalize';
6
-
7
- const PatientInfo: React.FC<{ label: string; value: string }> = ({ label, value }) => {
8
- return (
9
- <div style={{ display: 'grid', gridTemplateColumns: '0.25fr 0.75fr', margin: '0.25rem' }}>
10
- <span style={{ minWidth: '5rem', fontWeight: 'bold' }}>{label}</span>
11
- <span>{value}</span>
12
- </div>
13
- );
14
- };
15
-
16
- interface ConfirmPromptProps {
17
- onConfirm: void;
18
- close: void;
19
- patient: any;
20
- }
21
-
22
- const ConfirmPrompt: React.FC<ConfirmPromptProps> = ({ close, onConfirm, patient }) => {
23
- const { t } = useTranslation();
24
- return (
25
- <>
26
- <div className="cds--modal-header">
27
- <h3 className="cds--modal-header__heading">
28
- {t('clientRegistryEmpty', `Patient ${patient?.firstName} ${patient?.lastName} found`)}
29
- </h3>
30
- </div>
31
- <div className="cds--modal-content">
32
- <p>
33
- {t(
34
- 'patientDetailsFound',
35
- 'Patient information found in the registry, do you want to use the information to continue with registration?',
36
- )}
37
- </p>
38
- <div style={{ display: 'flex', margin: '1rem' }}>
39
- <ExtensionSlot
40
- style={{ display: 'flex', alignItems: 'center' }}
41
- extensionSlotName="patient-photo-slot"
42
- state={{ patientName: `${patient?.firstName} ${patient?.lastName}` }}
43
- />
44
- <div style={{ width: '100%', marginLeft: '0.625rem' }}>
45
- <PatientInfo
46
- label={t('patientName', 'Patient name')}
47
- value={`${patient?.firstName} ${patient?.lastName}`}
48
- />
49
- <PatientInfo
50
- label={t('nationalId', 'National ID')}
51
- value={patient?.identifications[0]?.identificationNumber}
52
- />
53
- <PatientInfo label={t('age', 'Age')} value={age(patient?.dateOfBirth)} />
54
- <PatientInfo label={t('dateOfBirth', 'Date of birth')} value={formatDate(new Date(patient?.dateOfBirth))} />
55
- <PatientInfo label={t('gender', 'Gender')} value={capitalize(patient?.gender)} />
56
- </div>
57
- </div>
58
- </div>
59
- <div className="cds--modal-footer">
60
- <Button kind="secondary" onClick={close}>
61
- {t('cancel', 'Cancel')}
62
- </Button>
63
- <Button onClick={onConfirm}>{t('useValues', 'Use values')}</Button>
64
- </div>
65
- </>
66
- );
67
- };
68
-
69
- export default ConfirmPrompt;
@@ -1,35 +0,0 @@
1
- import React from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import { Button } from '@carbon/react';
4
-
5
- interface EmptyPromptProps {
6
- onConfirm: void;
7
- close: void;
8
- }
9
-
10
- const EmptyPrompt: React.FC<EmptyPromptProps> = ({ close, onConfirm }) => {
11
- const { t } = useTranslation();
12
- return (
13
- <>
14
- <div className="cds--modal-header">
15
- <h3 className="cds--modal-header__heading">{t('clientRegistryEmpty', 'Create & Post Patient')}</h3>
16
- </div>
17
- <div className="cds--modal-content">
18
- <p>
19
- {t(
20
- 'patientNotFound',
21
- 'The patient records could not be found in Client registry, do you want to continue to create and post patient to registry',
22
- )}
23
- </p>
24
- </div>
25
- <div className="cds--modal-footer">
26
- <Button kind="secondary" onClick={close}>
27
- {t('cancel', 'Cancel')}
28
- </Button>
29
- <Button onClick={onConfirm}>{t('continue', 'Continue to registration')}</Button>
30
- </div>
31
- </>
32
- );
33
- };
34
-
35
- export default EmptyPrompt;
@@ -1,50 +0,0 @@
1
- export interface ClientIdentification {
2
- identificationType: string;
3
- identificationNumber: string;
4
- }
5
-
6
- interface ClientContact {
7
- primaryPhone: string;
8
- secondaryPhone?: string;
9
- emailAddress?: string;
10
- }
11
-
12
- export interface ClientRegistryPatient {
13
- clientExists: boolean;
14
- client?: RegistryPatient;
15
- }
16
-
17
- export interface RegistryPatient {
18
- clientNumber?: string;
19
- firstName: string;
20
- middleName: string;
21
- lastName: string;
22
- dateOfBirth: string;
23
- maritalStatus?: string;
24
- gender: string;
25
- occupation?: string;
26
- religion?: string;
27
- educationLevel?: string;
28
- country: string;
29
- countyOfBirth?: string;
30
- isAlive: boolean;
31
- originFacilityKmflCode?: string;
32
- isOnART?: string;
33
- nascopCCCNumber?: string;
34
- residence: {
35
- county: string;
36
- subCounty: string;
37
- ward: string;
38
- village: string;
39
- landmark: string;
40
- address: string;
41
- };
42
- identifications: Array<ClientIdentification>;
43
- contact: ClientContact;
44
- nextOfKins: Array<{
45
- name: string;
46
- relationship: string;
47
- residence: string;
48
- contact: ClientContact;
49
- }>;
50
- }