@ampath/esm-patient-registration-app 6.0.1-pre.6

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 (176) hide show
  1. package/.turbo/turbo-build.log +41 -0
  2. package/README.md +7 -0
  3. package/dist/130.js +2 -0
  4. package/dist/130.js.LICENSE.txt +3 -0
  5. package/dist/130.js.map +1 -0
  6. package/dist/152.js +1 -0
  7. package/dist/152.js.map +1 -0
  8. package/dist/249.js +2 -0
  9. package/dist/249.js.LICENSE.txt +46 -0
  10. package/dist/249.js.map +1 -0
  11. package/dist/255.js +2 -0
  12. package/dist/255.js.LICENSE.txt +9 -0
  13. package/dist/255.js.map +1 -0
  14. package/dist/271.js +1 -0
  15. package/dist/303.js +1 -0
  16. package/dist/303.js.map +1 -0
  17. package/dist/319.js +1 -0
  18. package/dist/365.js +1 -0
  19. package/dist/365.js.map +1 -0
  20. package/dist/460.js +1 -0
  21. package/dist/525.js +1 -0
  22. package/dist/525.js.map +1 -0
  23. package/dist/537.js +1 -0
  24. package/dist/537.js.map +1 -0
  25. package/dist/574.js +1 -0
  26. package/dist/591.js +2 -0
  27. package/dist/591.js.LICENSE.txt +32 -0
  28. package/dist/591.js.map +1 -0
  29. package/dist/621.js +1 -0
  30. package/dist/621.js.map +1 -0
  31. package/dist/644.js +1 -0
  32. package/dist/729.js +1 -0
  33. package/dist/729.js.map +1 -0
  34. package/dist/735.js +1 -0
  35. package/dist/735.js.map +1 -0
  36. package/dist/757.js +1 -0
  37. package/dist/784.js +2 -0
  38. package/dist/784.js.LICENSE.txt +9 -0
  39. package/dist/784.js.map +1 -0
  40. package/dist/788.js +1 -0
  41. package/dist/807.js +1 -0
  42. package/dist/833.js +1 -0
  43. package/dist/879.js +1 -0
  44. package/dist/879.js.map +1 -0
  45. package/dist/ampath-esm-patient-registration-app.js +1 -0
  46. package/dist/ampath-esm-patient-registration-app.js.buildmanifest.json +649 -0
  47. package/dist/ampath-esm-patient-registration-app.js.map +1 -0
  48. package/dist/main.js +2 -0
  49. package/dist/main.js.LICENSE.txt +56 -0
  50. package/dist/main.js.map +1 -0
  51. package/dist/routes.json +1 -0
  52. package/docs/images/patient-registration-hierarchy.png +0 -0
  53. package/jest.config.js +3 -0
  54. package/package.json +61 -0
  55. package/src/add-patient-link.scss +3 -0
  56. package/src/add-patient-link.test.tsx +20 -0
  57. package/src/add-patient-link.tsx +21 -0
  58. package/src/config-schema.ts +410 -0
  59. package/src/constants.ts +14 -0
  60. package/src/declarations.d.ts +6 -0
  61. package/src/index.ts +71 -0
  62. package/src/nav-link.test.tsx +13 -0
  63. package/src/nav-link.tsx +10 -0
  64. package/src/offline.resources.ts +155 -0
  65. package/src/offline.ts +91 -0
  66. package/src/patient-registration/before-save-prompt.tsx +73 -0
  67. package/src/patient-registration/date-util.ts +52 -0
  68. package/src/patient-registration/field/__mocks__/field.resource.ts +60 -0
  69. package/src/patient-registration/field/address/address-field.component.tsx +153 -0
  70. package/src/patient-registration/field/address/address-hierarchy-levels.component.tsx +73 -0
  71. package/src/patient-registration/field/address/address-hierarchy.resource.tsx +157 -0
  72. package/src/patient-registration/field/address/address-search.component.tsx +85 -0
  73. package/src/patient-registration/field/address/address-search.scss +53 -0
  74. package/src/patient-registration/field/address/custom-address-field.component.tsx +31 -0
  75. package/src/patient-registration/field/address/tests/address-hierarchy.test.tsx +214 -0
  76. package/src/patient-registration/field/address/tests/address-search-component.test.tsx +135 -0
  77. package/src/patient-registration/field/custom-field.component.tsx +25 -0
  78. package/src/patient-registration/field/dob/dob.component.tsx +159 -0
  79. package/src/patient-registration/field/dob/dob.test.tsx +75 -0
  80. package/src/patient-registration/field/field.component.tsx +47 -0
  81. package/src/patient-registration/field/field.resource.ts +35 -0
  82. package/src/patient-registration/field/field.scss +127 -0
  83. package/src/patient-registration/field/field.test.tsx +294 -0
  84. package/src/patient-registration/field/gender/gender-field.component.tsx +49 -0
  85. package/src/patient-registration/field/gender/gender-field.test.tsx +59 -0
  86. package/src/patient-registration/field/id/id-field.component.tsx +144 -0
  87. package/src/patient-registration/field/id/id-field.test.tsx +107 -0
  88. package/src/patient-registration/field/id/identifier-selection-overlay.component.tsx +198 -0
  89. package/src/patient-registration/field/id/identifier-selection.scss +37 -0
  90. package/src/patient-registration/field/name/name-field.component.tsx +142 -0
  91. package/src/patient-registration/field/obs/obs-field.component.tsx +204 -0
  92. package/src/patient-registration/field/obs/obs-field.test.tsx +205 -0
  93. package/src/patient-registration/field/person-attributes/coded-attributes.component.tsx +60 -0
  94. package/src/patient-registration/field/person-attributes/coded-person-attribute-field.component.tsx +116 -0
  95. package/src/patient-registration/field/person-attributes/coded-person-attribute-field.test.tsx +127 -0
  96. package/src/patient-registration/field/person-attributes/person-attribute-field.component.tsx +88 -0
  97. package/src/patient-registration/field/person-attributes/person-attribute-field.test.tsx +187 -0
  98. package/src/patient-registration/field/person-attributes/person-attributes.resource.ts +20 -0
  99. package/src/patient-registration/field/person-attributes/text-person-attribute-field.component.tsx +58 -0
  100. package/src/patient-registration/field/person-attributes/text-person-attribute-field.test.tsx +88 -0
  101. package/src/patient-registration/field/phone/phone-field.component.tsx +16 -0
  102. package/src/patient-registration/form-manager.test.ts +67 -0
  103. package/src/patient-registration/form-manager.ts +414 -0
  104. package/src/patient-registration/input/basic-input/input/input.component.tsx +179 -0
  105. package/src/patient-registration/input/basic-input/input/input.test.tsx +72 -0
  106. package/src/patient-registration/input/basic-input/select/select-input.component.tsx +32 -0
  107. package/src/patient-registration/input/basic-input/select/select-input.test.tsx +49 -0
  108. package/src/patient-registration/input/combo-input/combo-input.component.tsx +128 -0
  109. package/src/patient-registration/input/combo-input/selection-tick.component.tsx +20 -0
  110. package/src/patient-registration/input/custom-input/autosuggest/autosuggest.component.tsx +187 -0
  111. package/src/patient-registration/input/custom-input/autosuggest/autosuggest.scss +62 -0
  112. package/src/patient-registration/input/custom-input/autosuggest/autosuggest.test.tsx +132 -0
  113. package/src/patient-registration/input/custom-input/identifier/identifier-input.component.tsx +156 -0
  114. package/src/patient-registration/input/custom-input/identifier/identifier-input.test.tsx +107 -0
  115. package/src/patient-registration/input/custom-input/identifier/utils.test.ts +81 -0
  116. package/src/patient-registration/input/custom-input/identifier/utils.ts +19 -0
  117. package/src/patient-registration/input/dummy-data/dummy-data-input.component.tsx +53 -0
  118. package/src/patient-registration/input/dummy-data/dummy-data-input.test.tsx +43 -0
  119. package/src/patient-registration/input/input.scss +118 -0
  120. package/src/patient-registration/patient-registration-context.ts +24 -0
  121. package/src/patient-registration/patient-registration-hooks.ts +287 -0
  122. package/src/patient-registration/patient-registration-utils.ts +216 -0
  123. package/src/patient-registration/patient-registration.component.tsx +240 -0
  124. package/src/patient-registration/patient-registration.resource.test.tsx +26 -0
  125. package/src/patient-registration/patient-registration.resource.ts +250 -0
  126. package/src/patient-registration/patient-registration.scss +122 -0
  127. package/src/patient-registration/patient-registration.test.tsx +471 -0
  128. package/src/patient-registration/patient-registration.types.ts +318 -0
  129. package/src/patient-registration/section/death-info/death-info-section.component.tsx +31 -0
  130. package/src/patient-registration/section/death-info/death-info-section.test.tsx +64 -0
  131. package/src/patient-registration/section/demographics/demographics-section.component.tsx +30 -0
  132. package/src/patient-registration/section/demographics/demographics-section.test.tsx +83 -0
  133. package/src/patient-registration/section/generic-section.component.tsx +17 -0
  134. package/src/patient-registration/section/patient-relationships/relationships-section.component.tsx +235 -0
  135. package/src/patient-registration/section/patient-relationships/relationships-section.test.tsx +100 -0
  136. package/src/patient-registration/section/patient-relationships/relationships.resource.tsx +78 -0
  137. package/src/patient-registration/section/patient-relationships/relationships.scss +35 -0
  138. package/src/patient-registration/section/section-wrapper.component.tsx +40 -0
  139. package/src/patient-registration/section/section.component.tsx +23 -0
  140. package/src/patient-registration/section/section.scss +1 -0
  141. package/src/patient-registration/ui-components/overlay/overlay.component.tsx +51 -0
  142. package/src/patient-registration/ui-components/overlay/overlay.scss +63 -0
  143. package/src/patient-registration/validation/patient-registration-validation.test.tsx +157 -0
  144. package/src/patient-registration/validation/patient-registration-validation.tsx +60 -0
  145. package/src/patient-verification/client-registry-constants.ts +13 -0
  146. package/src/patient-verification/client-registry.component.tsx +66 -0
  147. package/src/patient-verification/client-registry.scss +1 -0
  148. package/src/patient-verification/utils.tsx +56 -0
  149. package/src/patient-verification/verification-modal.scss +20 -0
  150. package/src/patient-verification/verification.component.tsx +48 -0
  151. package/src/resource.ts +12 -0
  152. package/src/root.component.tsx +63 -0
  153. package/src/root.scss +7 -0
  154. package/src/root.test.tsx +32 -0
  155. package/src/routes.json +66 -0
  156. package/src/widgets/cancel-patient-edit.component.tsx +37 -0
  157. package/src/widgets/cancel-patient-edit.test.tsx +27 -0
  158. package/src/widgets/delete-identifier-confirmation-modal.test.tsx +34 -0
  159. package/src/widgets/delete-identifier-confirmation-modal.tsx +41 -0
  160. package/src/widgets/delete-identifier-modal.scss +34 -0
  161. package/src/widgets/display-photo.component.tsx +30 -0
  162. package/src/widgets/display-photo.test.tsx +37 -0
  163. package/src/widgets/edit-patient-details-button.component.tsx +34 -0
  164. package/src/widgets/edit-patient-details-button.scss +3 -0
  165. package/src/widgets/edit-patient-details-button.test.tsx +41 -0
  166. package/translations/am.json +97 -0
  167. package/translations/ar.json +97 -0
  168. package/translations/en.json +103 -0
  169. package/translations/es.json +97 -0
  170. package/translations/fr.json +97 -0
  171. package/translations/he.json +97 -0
  172. package/translations/km.json +97 -0
  173. package/translations/zh.json +89 -0
  174. package/translations/zh_CN.json +89 -0
  175. package/tsconfig.json +5 -0
  176. package/webpack.config.js +1 -0
@@ -0,0 +1,159 @@
1
+ import React, { type ChangeEvent, useCallback, useContext } from 'react';
2
+ import { ContentSwitcher, DatePicker, DatePickerInput, Layer, Switch, TextInput } from '@carbon/react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { useField } from 'formik';
5
+ import { generateFormatting } from '../../date-util';
6
+ import { PatientRegistrationContext } from '../../patient-registration-context';
7
+ import { useConfig } from '@openmrs/esm-framework';
8
+ import { type RegistrationConfig } from '../../../config-schema';
9
+ import styles from '../field.scss';
10
+
11
+ const calcBirthdate = (yearDelta, monthDelta, dateOfBirth) => {
12
+ const { enabled, month, dayOfMonth } = dateOfBirth.useEstimatedDateOfBirth;
13
+ const startDate = new Date();
14
+ const resultMonth = new Date(startDate.getFullYear() - yearDelta, startDate.getMonth() - monthDelta, 1);
15
+ const daysInResultMonth = new Date(resultMonth.getFullYear(), resultMonth.getMonth() + 1, 0).getDate();
16
+ const resultDate = new Date(
17
+ resultMonth.getFullYear(),
18
+ resultMonth.getMonth(),
19
+ Math.min(startDate.getDate(), daysInResultMonth),
20
+ );
21
+ return enabled ? new Date(resultDate.getFullYear(), month, dayOfMonth) : resultDate;
22
+ };
23
+
24
+ export const DobField: React.FC = () => {
25
+ const { t } = useTranslation();
26
+ const {
27
+ fieldConfigurations: { dateOfBirth },
28
+ } = useConfig<RegistrationConfig>();
29
+ const allowEstimatedBirthDate = dateOfBirth?.allowEstimatedDateOfBirth;
30
+ const [{ value: dobUnknown }] = useField('birthdateEstimated');
31
+ const [birthdate, birthdateMeta] = useField('birthdate');
32
+ const [yearsEstimated, yearsEstimateMeta] = useField('yearsEstimated');
33
+ const [monthsEstimated, monthsEstimateMeta] = useField('monthsEstimated');
34
+ const { setFieldValue } = useContext(PatientRegistrationContext);
35
+ const { format, placeHolder, dateFormat } = generateFormatting(['d', 'm', 'Y'], '/');
36
+ const today = new Date();
37
+
38
+ const onToggle = useCallback(
39
+ (e: { name?: string | number }) => {
40
+ setFieldValue('birthdateEstimated', e.name === 'unknown');
41
+ setFieldValue('birthdate', '');
42
+ setFieldValue('yearsEstimated', 0);
43
+ setFieldValue('monthsEstimated', '');
44
+ },
45
+ [setFieldValue],
46
+ );
47
+
48
+ const onDateChange = useCallback(
49
+ (birthdate: Date[]) => {
50
+ setFieldValue('birthdate', birthdate[0]);
51
+ },
52
+ [setFieldValue],
53
+ );
54
+
55
+ const onEstimatedYearsChange = useCallback(
56
+ (ev: ChangeEvent<HTMLInputElement>) => {
57
+ const years = +ev.target.value;
58
+
59
+ if (!isNaN(years) && years < 140 && years >= 0) {
60
+ setFieldValue('yearsEstimated', years);
61
+ setFieldValue('birthdate', calcBirthdate(years, monthsEstimateMeta.value, dateOfBirth));
62
+ }
63
+ },
64
+ [setFieldValue, dateOfBirth, monthsEstimateMeta.value],
65
+ );
66
+
67
+ const onEstimatedMonthsChange = useCallback(
68
+ (ev: ChangeEvent<HTMLInputElement>) => {
69
+ const months = +ev.target.value;
70
+
71
+ if (!isNaN(months)) {
72
+ setFieldValue('monthsEstimated', months);
73
+ setFieldValue('birthdate', calcBirthdate(yearsEstimateMeta.value, months, dateOfBirth));
74
+ }
75
+ },
76
+ [setFieldValue, dateOfBirth, yearsEstimateMeta.value],
77
+ );
78
+
79
+ const updateBirthdate = useCallback(() => {
80
+ const months = +monthsEstimateMeta.value % 12;
81
+ const years = +yearsEstimateMeta.value + Math.floor(monthsEstimateMeta.value / 12);
82
+ setFieldValue('yearsEstimated', years);
83
+ setFieldValue('monthsEstimated', months > 0 ? months : '');
84
+ setFieldValue('birthdate', calcBirthdate(years, months, dateOfBirth));
85
+ }, [setFieldValue, monthsEstimateMeta, yearsEstimateMeta, dateOfBirth]);
86
+
87
+ return (
88
+ <div className={styles.halfWidthInDesktopView}>
89
+ <h4 className={styles.productiveHeading02Light}>{t('birthFieldLabelText', 'Birth')}</h4>
90
+ {(allowEstimatedBirthDate || dobUnknown) && (
91
+ <div className={styles.dobField}>
92
+ <div className={styles.dobContentSwitcherLabel}>
93
+ <span className={styles.label01}>{t('dobToggleLabelText', 'Date of Birth Known?')}</span>
94
+ </div>
95
+ <ContentSwitcher onChange={onToggle} selectedIndex={dobUnknown ? 1 : 0}>
96
+ <Switch name="known" text={t('yes', 'Yes')} />
97
+ <Switch name="unknown" text={t('no', 'No')} />
98
+ </ContentSwitcher>
99
+ </div>
100
+ )}
101
+ <Layer>
102
+ {!dobUnknown ? (
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>
115
+ </div>
116
+ ) : (
117
+ <div className={styles.grid}>
118
+ <div className={styles.dobField}>
119
+ <Layer>
120
+ <TextInput
121
+ id="yearsEstimated"
122
+ type="number"
123
+ name={yearsEstimated.name}
124
+ onChange={onEstimatedYearsChange}
125
+ labelText={t('estimatedAgeInYearsLabelText', 'Estimated age in years')}
126
+ invalid={!!(yearsEstimateMeta.touched && yearsEstimateMeta.error)}
127
+ invalidText={yearsEstimateMeta.error && t(yearsEstimateMeta.error)}
128
+ value={yearsEstimated.value}
129
+ min={0}
130
+ required
131
+ {...yearsEstimated}
132
+ onBlur={updateBirthdate}
133
+ />
134
+ </Layer>
135
+ </div>
136
+ <div className={styles.dobField}>
137
+ <Layer>
138
+ <TextInput
139
+ id="monthsEstimated"
140
+ type="number"
141
+ name={monthsEstimated.name}
142
+ onChange={onEstimatedMonthsChange}
143
+ labelText={t('estimatedAgeInMonthsLabelText', 'Estimated age in months')}
144
+ invalid={!!(monthsEstimateMeta.touched && monthsEstimateMeta.error)}
145
+ invalidText={monthsEstimateMeta.error && t(monthsEstimateMeta.error)}
146
+ value={monthsEstimated.value}
147
+ min={0}
148
+ {...monthsEstimated}
149
+ required={!yearsEstimateMeta.value}
150
+ onBlur={updateBirthdate}
151
+ />
152
+ </Layer>
153
+ </div>
154
+ </div>
155
+ )}
156
+ </Layer>
157
+ </div>
158
+ );
159
+ };
@@ -0,0 +1,75 @@
1
+ import React from 'react';
2
+ import { Formik, Form } from 'formik';
3
+ import { render, screen } from '@testing-library/react';
4
+ import userEvent from '@testing-library/user-event';
5
+ import { DobField } from './dob.component';
6
+ import { PatientRegistrationContext } from '../../patient-registration-context';
7
+ import { initialFormValues } from '../../patient-registration.component';
8
+ import { type FormValues } from '../../patient-registration.types';
9
+
10
+ jest.mock('@openmrs/esm-framework', () => {
11
+ const originalModule = jest.requireActual('@openmrs/esm-framework');
12
+ return {
13
+ ...originalModule,
14
+ useConfig: jest.fn().mockImplementation(() => ({
15
+ fieldConfigurations: {
16
+ dateOfBirth: {
17
+ allowEstimatedDateOfBirth: true,
18
+ useEstimatedDateOfBirth: { enabled: true, dayOfMonth: 0, month: 0 },
19
+ },
20
+ },
21
+ })),
22
+ };
23
+ });
24
+
25
+ describe('Dob', () => {
26
+ it('renders the fields in the birth section of the registration form', async () => {
27
+ renderDob();
28
+
29
+ expect(screen.getByRole('heading', { name: /birth/i })).toBeInTheDocument();
30
+ expect(screen.getByText(/date of birth known?/i)).toBeInTheDocument();
31
+ expect(screen.getByRole('tab', { name: /no/i })).toBeInTheDocument();
32
+ expect(screen.getByRole('tab', { name: /yes/i })).toBeInTheDocument();
33
+ expect(screen.getByRole('tab', { name: /yes/i })).toHaveAttribute('aria-selected', 'true');
34
+ expect(screen.getByRole('tab', { name: /no/i })).toHaveAttribute('aria-selected', 'false');
35
+ expect(screen.getByRole('textbox', { name: /date of birth/i })).toBeInTheDocument();
36
+ });
37
+
38
+ it('typing in the date picker input sets the date of birth', async () => {
39
+ const user = userEvent.setup();
40
+
41
+ renderDob();
42
+
43
+ const dateInput = screen.getByRole('textbox', { name: /date of birth/i });
44
+ expect(dateInput).toBeInTheDocument();
45
+
46
+ await user.type(dateInput, '10/10/2022');
47
+
48
+ expect(screen.getByPlaceholderText('dd/mm/YYYY')).toHaveValue('10/10/2022');
49
+ });
50
+ });
51
+
52
+ function renderDob() {
53
+ let formValues: FormValues = initialFormValues;
54
+
55
+ render(
56
+ <Formik initialValues={{ birthdate: '' }} onSubmit={() => {}}>
57
+ <Form>
58
+ <PatientRegistrationContext.Provider
59
+ value={{
60
+ identifierTypes: [],
61
+ values: formValues,
62
+ validationSchema: null,
63
+ inEditMode: false,
64
+ setFieldValue: () => {},
65
+ setCapturePhotoProps: (value) => {},
66
+ currentPhoto: '',
67
+ isOffline: false,
68
+ initialFormValues: formValues,
69
+ }}>
70
+ <DobField />
71
+ </PatientRegistrationContext.Provider>
72
+ </Form>
73
+ </Formik>,
74
+ );
75
+ }
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import { NameField } from './name/name-field.component';
3
+ import { GenderField } from './gender/gender-field.component';
4
+ import { Identifiers } from './id/id-field.component';
5
+ import { DobField } from './dob/dob.component';
6
+ import { reportError, useConfig } from '@openmrs/esm-framework';
7
+ import { builtInFields, type RegistrationConfig } from '../../config-schema';
8
+ import { CustomField } from './custom-field.component';
9
+ import { AddressComponent } from './address/address-field.component';
10
+ import { PhoneField } from './phone/phone-field.component';
11
+
12
+ export interface FieldProps {
13
+ name: string;
14
+ }
15
+
16
+ export function Field({ name }: FieldProps) {
17
+ const config = useConfig() as RegistrationConfig;
18
+ if (
19
+ !(builtInFields as ReadonlyArray<string>).includes(name) &&
20
+ !config.fieldDefinitions.some((def) => def.id == name)
21
+ ) {
22
+ reportError(
23
+ `Invalid field name '${name}'. Valid options are '${config.fieldDefinitions
24
+ .map((def) => def.id)
25
+ .concat(builtInFields)
26
+ .join("', '")}'.`,
27
+ );
28
+ return null;
29
+ }
30
+
31
+ switch (name) {
32
+ case 'name':
33
+ return <NameField />;
34
+ case 'gender':
35
+ return <GenderField />;
36
+ case 'dob':
37
+ return <DobField />;
38
+ case 'address':
39
+ return <AddressComponent />;
40
+ case 'id':
41
+ return <Identifiers />;
42
+ case 'phone':
43
+ return <PhoneField />;
44
+ default:
45
+ return <CustomField name={name} />;
46
+ }
47
+ }
@@ -0,0 +1,35 @@
1
+ import { type FetchResponse, openmrsFetch, showSnackbar } from '@openmrs/esm-framework';
2
+ import useSWRImmutable from 'swr/immutable';
3
+ import { type ConceptAnswers, type ConceptResponse } from '../patient-registration.types';
4
+
5
+ export function useConcept(conceptUuid: string): { data: ConceptResponse; isLoading: boolean } {
6
+ const shouldFetch = typeof conceptUuid === 'string' && conceptUuid !== '';
7
+ const { data, error, isLoading } = useSWRImmutable<FetchResponse<ConceptResponse>, Error>(
8
+ shouldFetch ? `/ws/rest/v1/concept/${conceptUuid}` : null,
9
+ openmrsFetch,
10
+ );
11
+ if (error) {
12
+ showSnackbar({
13
+ title: error.name,
14
+ subtitle: error.message,
15
+ kind: 'error',
16
+ });
17
+ }
18
+ return { data: data?.data, isLoading };
19
+ }
20
+
21
+ export function useConceptAnswers(conceptUuid: string): { data: Array<ConceptAnswers>; isLoading: boolean } {
22
+ const shouldFetch = typeof conceptUuid === 'string' && conceptUuid !== '';
23
+ const { data, error, isLoading } = useSWRImmutable<FetchResponse<ConceptResponse>, Error>(
24
+ shouldFetch ? `/ws/rest/v1/concept/${conceptUuid}` : null,
25
+ openmrsFetch,
26
+ );
27
+ if (error) {
28
+ showSnackbar({
29
+ title: error.name,
30
+ subtitle: error.message,
31
+ kind: 'error',
32
+ });
33
+ }
34
+ return { data: data?.data?.answers, isLoading };
35
+ }
@@ -0,0 +1,127 @@
1
+ @use '@carbon/styles/scss/spacing';
2
+ @use '@carbon/styles/scss/type';
3
+ @import '~@openmrs/esm-styleguide/src/vars';
4
+
5
+ .productiveHeading02 {
6
+ @include type.type-style('heading-compact-02');
7
+ margin-bottom: 1rem;
8
+ }
9
+
10
+ .productiveHeading02Light {
11
+ @include type.type-style('heading-compact-02');
12
+ margin-bottom: 1rem;
13
+ color: #525252;
14
+ }
15
+
16
+ .label01 {
17
+ @include type.type-style('label-01');
18
+ }
19
+
20
+ .grid {
21
+ display: grid;
22
+ grid-template-columns: 1fr 1fr;
23
+ column-gap: spacing.$spacing-05;
24
+ }
25
+
26
+ .halfWidthInDesktopView {
27
+ width: calc(50% - spacing.$spacing-05);
28
+ }
29
+
30
+ .patientPhoto {
31
+ display: flex;
32
+ justify-content: center;
33
+ }
34
+
35
+ .nameField {
36
+ grid-row: 1;
37
+ grid-column: 1;
38
+ }
39
+
40
+ .nameField > :global(.cds--content-switcher) {
41
+ display: grid;
42
+ grid-template-columns: 1fr 1fr;
43
+ width: max-content;
44
+ justify-content: flex-start;
45
+ }
46
+
47
+ .contentSwitcher {
48
+ margin-bottom: 1rem;
49
+ }
50
+
51
+ .dobField > :global(.cds--content-switcher) {
52
+ display: grid;
53
+ grid-template-columns: 1fr 1fr;
54
+ width: max-content;
55
+ justify-content: flex-start;
56
+ }
57
+
58
+ .photoExtension {
59
+ margin-bottom: 1rem;
60
+ grid-row: 1;
61
+ grid-column: 2;
62
+ justify-self: center;
63
+ }
64
+
65
+ .sexField,
66
+ .dobField {
67
+ margin-bottom: spacing.$spacing-05;
68
+ }
69
+
70
+ .dobContentSwitcherLabel {
71
+ margin-bottom: spacing.$spacing-03;
72
+ }
73
+
74
+ .identifierLabelText {
75
+ display: flex;
76
+ align-items: center;
77
+ }
78
+
79
+ .setIDNumberButton {
80
+ margin-bottom: spacing.$spacing-05;
81
+ }
82
+
83
+ .setIDNumberButton > svg {
84
+ margin-left: spacing.$spacing-03;
85
+ }
86
+
87
+ .customField {
88
+ margin-bottom: spacing.$spacing-05;
89
+ }
90
+
91
+ .attributeField {
92
+ margin-bottom: spacing.$spacing-05;
93
+ }
94
+
95
+ :global(.omrs-breakpoint-lt-desktop) {
96
+ .grid {
97
+ grid-template-columns: 1fr;
98
+ grid-template-rows: auto auto;
99
+ }
100
+ .nameField {
101
+ grid-row: 2;
102
+ grid-column: 1;
103
+ }
104
+ .photoExtension {
105
+ grid-column: 1;
106
+ grid-row: 1;
107
+ justify-self: start;
108
+ }
109
+ .radioButton label {
110
+ height: spacing.$spacing-09 !important;
111
+ }
112
+ .halfWidthInDesktopView {
113
+ width: 100%;
114
+ }
115
+ }
116
+
117
+ .radioFieldError {
118
+ color: #da1e28;
119
+ display: block;
120
+ font-weight: 400;
121
+ max-height: 12.5rem;
122
+ overflow: visible;
123
+ font-size: 0.75rem;
124
+ letter-spacing: 0.32px;
125
+ line-height: 1.34;
126
+ margin: 0.25rem 0 0;
127
+ }