@olaboot/esm-patient-registration-app 9.2.1 → 10.0.2
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.
- package/dist/1339.js +1 -0
- package/dist/1339.js.map +1 -0
- package/dist/1480.js +1 -0
- package/dist/1480.js.map +1 -0
- package/dist/1646.js +1 -0
- package/dist/1646.js.map +1 -0
- package/dist/1789.js +1 -0
- package/dist/1789.js.map +1 -0
- package/dist/1869.js +1 -0
- package/dist/1869.js.map +1 -0
- package/dist/1877.js +1 -0
- package/dist/1877.js.map +1 -0
- package/dist/2317.js +1 -0
- package/dist/2317.js.map +1 -0
- package/dist/2416.js +1 -0
- package/dist/2416.js.map +1 -0
- package/dist/2747.js +1 -0
- package/dist/2747.js.map +1 -0
- package/dist/282.js +1 -0
- package/dist/282.js.map +1 -0
- package/dist/2881.js +1 -0
- package/dist/2881.js.map +1 -0
- package/dist/3378.js +1 -0
- package/dist/3378.js.map +1 -0
- package/dist/3720.js +1 -0
- package/dist/3720.js.map +1 -0
- package/dist/3906.js +1 -0
- package/dist/3906.js.map +1 -0
- package/dist/3963.js +1 -0
- package/dist/3963.js.map +1 -0
- package/dist/3989.js +1 -0
- package/dist/3989.js.map +1 -0
- package/dist/4106.js +1 -0
- package/dist/4106.js.map +1 -0
- package/dist/4111.js +1 -0
- package/dist/4111.js.map +1 -0
- package/dist/434.js +1 -0
- package/dist/434.js.map +1 -0
- package/dist/4348.js +1 -0
- package/dist/4348.js.map +1 -0
- package/dist/4383.js +1 -0
- package/dist/4383.js.map +1 -0
- package/dist/4658.js +1 -0
- package/dist/4658.js.map +1 -0
- package/dist/466.js +1 -0
- package/dist/466.js.map +1 -0
- package/dist/4928.js +1 -0
- package/dist/4928.js.map +1 -0
- package/dist/5117.js +1 -0
- package/dist/5117.js.map +1 -0
- package/dist/5132.js +1 -0
- package/dist/5132.js.map +1 -0
- package/dist/5145.js +1 -0
- package/dist/5145.js.map +1 -0
- package/dist/5208.js +43 -0
- package/dist/5208.js.map +1 -0
- package/dist/527.js +1 -0
- package/dist/527.js.map +1 -0
- package/dist/5280.js +1 -0
- package/dist/5280.js.map +1 -0
- package/dist/5338.js +6 -0
- package/dist/5338.js.map +1 -0
- package/dist/5503.js +1 -0
- package/dist/5503.js.map +1 -0
- package/dist/555.js +1 -0
- package/dist/555.js.map +1 -0
- package/dist/556.js +1 -0
- package/dist/556.js.map +1 -0
- package/dist/5644.js +1 -0
- package/dist/5644.js.map +1 -0
- package/dist/5697.js +1 -0
- package/dist/{4024.js.map → 5697.js.map} +1 -1
- package/dist/5940.js +1 -0
- package/dist/5940.js.map +1 -0
- package/dist/6047.js +1 -0
- package/dist/6047.js.map +1 -0
- package/dist/6371.js +1 -0
- package/dist/6371.js.map +1 -0
- package/dist/6377.js +1 -0
- package/dist/6377.js.map +1 -0
- package/dist/6388.js +1 -0
- package/dist/6388.js.map +1 -0
- package/dist/6444.js +1 -0
- package/dist/6444.js.map +1 -0
- package/dist/6508.js +1 -0
- package/dist/6508.js.map +1 -0
- package/dist/6724.js +1 -0
- package/dist/6724.js.map +1 -0
- package/dist/689.js +1 -0
- package/dist/689.js.map +1 -0
- package/dist/6904.js +1 -0
- package/dist/6904.js.map +1 -0
- package/dist/7045.js +1 -0
- package/dist/7045.js.map +1 -0
- package/dist/7175.js +1 -0
- package/dist/7175.js.map +1 -0
- package/dist/7182.js +1 -0
- package/dist/7182.js.map +1 -0
- package/dist/7649.js +1 -0
- package/dist/7649.js.map +1 -0
- package/dist/7742.js +1 -0
- package/dist/7742.js.map +1 -0
- package/dist/7912.js +1 -0
- package/dist/7912.js.map +1 -0
- package/dist/8358.js +1 -0
- package/dist/8358.js.map +1 -0
- package/dist/8359.js +1 -0
- package/dist/8359.js.map +1 -0
- package/dist/8695.js +1 -0
- package/dist/8695.js.map +1 -0
- package/dist/903.js +1 -0
- package/dist/903.js.map +1 -0
- package/dist/9061.js +1 -0
- package/dist/9061.js.map +1 -0
- package/dist/9072.js +1 -0
- package/dist/9072.js.map +1 -0
- package/dist/9397.js +1 -0
- package/dist/9397.js.map +1 -0
- package/dist/9712.js +1 -0
- package/dist/9712.js.map +1 -0
- package/dist/9771.js +1 -0
- package/dist/9771.js.map +1 -0
- package/dist/9806.js +1 -0
- package/dist/9806.js.map +1 -0
- package/dist/9816.js +1 -0
- package/dist/9816.js.map +1 -0
- package/dist/main.js +7 -6
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-patient-registration-app.js +6 -0
- package/dist/{olaboot-esm-patient-registration-app.js.buildmanifest.json → openmrs-esm-patient-registration-app.js.buildmanifest.json} +540 -455
- package/dist/openmrs-esm-patient-registration-app.js.map +1 -0
- package/dist/routes.json +1 -1
- package/package.json +8 -9
- package/src/add-patient-link.extension.tsx +3 -2
- package/src/add-patient-link.test.tsx +2 -1
- package/src/config-schema.ts +507 -507
- package/src/constants.ts +1 -1
- package/src/index.ts +2 -24
- package/src/nav-link.test.tsx +1 -0
- package/src/offline.resources.ts +97 -31
- package/src/patient-registration/before-save-prompt.test.tsx +199 -0
- package/src/patient-registration/field/__mocks__/field.resource.ts +8 -7
- package/src/patient-registration/field/address/address-field.component.tsx +183 -186
- package/src/patient-registration/field/address/address-hierarchy-levels.component.tsx +6 -1
- package/src/patient-registration/field/address/address-hierarchy.test.tsx +289 -296
- package/src/patient-registration/field/address/address-search.component.tsx +20 -8
- package/src/patient-registration/field/address/address-search.scss +19 -2
- package/src/patient-registration/field/address/address-search.test.tsx +333 -141
- package/src/patient-registration/field/address/custom-address-field.component.tsx +1 -1
- package/src/patient-registration/field/cause-of-death/cause-of-death.component.tsx +1 -1
- package/src/patient-registration/field/cause-of-death/cause-of-death.test.tsx +251 -0
- package/src/patient-registration/field/custom-field.component.tsx +1 -1
- package/src/patient-registration/field/date-and-time-of-death/date-and-time-of-death.component.tsx +1 -1
- package/src/patient-registration/field/date-and-time-of-death/date-and-time-of-death.test.tsx +144 -0
- package/src/patient-registration/field/dob/dob.component.tsx +2 -2
- package/src/patient-registration/field/dob/dob.test.tsx +370 -54
- package/src/patient-registration/field/field.component.tsx +1 -1
- package/src/patient-registration/field/field.resource.ts +2 -2
- package/src/patient-registration/field/field.test.tsx +333 -330
- package/src/patient-registration/field/gender/gender-field.test.tsx +240 -54
- package/src/patient-registration/field/id/id-field.component.tsx +146 -144
- package/src/patient-registration/field/id/id-field.test.tsx +177 -121
- package/src/patient-registration/field/id/identifier-selection-overlay.component.tsx +200 -200
- package/src/patient-registration/field/id/identifier-selection-overlay.test.tsx +346 -0
- package/src/patient-registration/field/name/name-field.component.tsx +2 -2
- package/src/patient-registration/field/name/name-field.test.tsx +282 -0
- package/src/patient-registration/field/obs/obs-field.test.tsx +294 -118
- package/src/patient-registration/field/person-attributes/coded-person-attribute-field.test.tsx +172 -108
- package/src/patient-registration/field/person-attributes/location-person-attribute-field.component.tsx +3 -3
- package/src/patient-registration/field/person-attributes/location-person-attribute-field.resource.tsx +2 -5
- package/src/patient-registration/field/person-attributes/person-attribute-field.component.tsx +2 -2
- package/src/patient-registration/field/person-attributes/person-attribute-field.test.tsx +249 -131
- package/src/patient-registration/field/person-attributes/person-attributes.resource.ts +1 -1
- package/src/patient-registration/field/person-attributes/text-person-attribute-field.test.tsx +98 -70
- package/src/patient-registration/field/phone/phone-field.test.tsx +100 -0
- package/src/patient-registration/form-manager.test.ts +6 -5
- package/src/patient-registration/form-manager.ts +5 -2
- package/src/patient-registration/input/basic-input/input/input.component.tsx +3 -121
- package/src/patient-registration/input/basic-input/input/input.test.tsx +151 -51
- package/src/patient-registration/input/basic-input/select/select-input.test.tsx +113 -33
- package/src/patient-registration/input/combo-input/combo-input.component.tsx +60 -24
- package/src/patient-registration/input/custom-input/autosuggest/autosuggest.component.tsx +10 -101
- package/src/patient-registration/input/custom-input/autosuggest/autosuggest.test.tsx +144 -108
- package/src/patient-registration/input/custom-input/identifier/identifier-input.test.tsx +241 -177
- package/src/patient-registration/input/custom-input/identifier/utils.test.ts +47 -8
- package/src/patient-registration/input/dummy-data/dummy-data-input.component.tsx +12 -12
- package/src/patient-registration/input/dummy-data/dummy-data-input.test.tsx +52 -20
- package/src/patient-registration/input/input.scss +1 -2
- package/src/patient-registration/patient-registration-context.ts +5 -3
- package/src/patient-registration/patient-registration-hooks.ts +4 -12
- package/src/patient-registration/patient-registration-utils.test.ts +2 -1
- package/src/patient-registration/patient-registration-utils.ts +2 -98
- package/src/patient-registration/patient-registration.component.tsx +50 -46
- package/src/patient-registration/patient-registration.resource.test.tsx +4 -7
- package/src/patient-registration/patient-registration.resource.ts +1 -4
- package/src/patient-registration/patient-registration.scss +16 -3
- package/src/patient-registration/patient-registration.test.tsx +614 -580
- package/src/patient-registration/patient-registration.types.ts +17 -28
- package/src/patient-registration/section/death-info/death-info-section.test.tsx +130 -34
- package/src/patient-registration/section/demographics/demographics-section.test.tsx +122 -68
- package/src/patient-registration/section/patient-relationships/relationships-section.component.tsx +15 -15
- package/src/patient-registration/section/patient-relationships/relationships-section.test.tsx +278 -84
- package/src/patient-registration/section/section-wrapper.component.tsx +1 -1
- package/src/patient-registration/ui-components/overlay/overlay.test.tsx +104 -0
- package/src/patient-registration/validation/patient-registration-validation.test.ts +2 -1
- package/src/patient-registration/validation/patient-registration-validation.ts +9 -3
- package/src/root.component.tsx +2 -5
- package/src/widgets/cancel-patient-edit.test.tsx +48 -11
- package/src/widgets/delete-identifier-confirmation.test.tsx +77 -24
- package/src/widgets/edit-patient-details-button.component.tsx +14 -18
- package/src/widgets/edit-patient-details-button.scss +2 -2
- package/src/widgets/edit-patient-details-button.test.tsx +11 -13
- package/translations/am.json +9 -4
- package/translations/ar.json +9 -4
- package/translations/ar_SY.json +9 -4
- package/translations/bn.json +9 -4
- package/translations/cs.json +9 -4
- package/translations/de.json +120 -115
- package/translations/en.json +10 -4
- package/translations/en_US.json +9 -4
- package/translations/es.json +9 -4
- package/translations/es_MX.json +9 -4
- package/translations/fr.json +9 -4
- package/translations/he.json +9 -4
- package/translations/hi.json +9 -4
- package/translations/hi_IN.json +9 -4
- package/translations/id.json +9 -4
- package/translations/it.json +9 -4
- package/translations/ka.json +9 -4
- package/translations/km.json +9 -4
- package/translations/ku.json +9 -4
- package/translations/ky.json +9 -4
- package/translations/lg.json +9 -4
- package/translations/ne.json +9 -4
- package/translations/pl.json +9 -4
- package/translations/pt.json +9 -4
- package/translations/pt_BR.json +10 -5
- package/translations/qu.json +9 -4
- package/translations/ro_RO.json +9 -4
- package/translations/ru_RU.json +9 -4
- package/translations/si.json +9 -4
- package/translations/sq.json +9 -4
- package/translations/sw.json +9 -4
- package/translations/sw_KE.json +9 -4
- package/translations/tr.json +9 -4
- package/translations/tr_TR.json +9 -4
- package/translations/uk.json +9 -4
- package/translations/uz.json +9 -4
- package/translations/uz@Latn.json +9 -4
- package/translations/uz_UZ.json +9 -4
- package/translations/vi.json +9 -4
- package/translations/zh.json +50 -45
- package/translations/zh_CN.json +9 -4
- package/translations/zh_TW.json +9 -4
- package/vitest.config.ts +4 -0
- package/dist/126.js +0 -1
- package/dist/15.js +0 -1
- package/dist/1564.js +0 -1
- package/dist/1567.js +0 -1
- package/dist/1845.js +0 -1
- package/dist/1953.js +0 -1
- package/dist/200.js +0 -1
- package/dist/200.js.map +0 -1
- package/dist/215.js +0 -1
- package/dist/2178.js +0 -1
- package/dist/250.js +0 -1
- package/dist/250.js.map +0 -1
- package/dist/2523.js +0 -1
- package/dist/2523.js.map +0 -1
- package/dist/2566.js +0 -1
- package/dist/2586.js +0 -1
- package/dist/2586.js.map +0 -1
- package/dist/2716.js +0 -1
- package/dist/2716.js.map +0 -1
- package/dist/2759.js +0 -1
- package/dist/2821.js +0 -6
- package/dist/2821.js.map +0 -1
- package/dist/3089.js +0 -1
- package/dist/3089.js.map +0 -1
- package/dist/3230.js +0 -1
- package/dist/3441.js +0 -1
- package/dist/3565.js +0 -1
- package/dist/3571.js +0 -1
- package/dist/3571.js.map +0 -1
- package/dist/3746.js +0 -1
- package/dist/3925.js +0 -1
- package/dist/3946.js +0 -1
- package/dist/4024.js +0 -1
- package/dist/4744.js +0 -1
- package/dist/4744.js.map +0 -1
- package/dist/4809.js +0 -1
- package/dist/4894.js +0 -1
- package/dist/4970.js +0 -1
- package/dist/4970.js.map +0 -1
- package/dist/5130.js +0 -1
- package/dist/5187.js +0 -1
- package/dist/5491.js +0 -1
- package/dist/5491.js.map +0 -1
- package/dist/5595.js +0 -1
- package/dist/5961.js +0 -1
- package/dist/6133.js +0 -1
- package/dist/634.js +0 -1
- package/dist/634.js.map +0 -1
- package/dist/6456.js +0 -1
- package/dist/6466.js +0 -1
- package/dist/6613.js +0 -1
- package/dist/6783.js +0 -1
- package/dist/7073.js +0 -38
- package/dist/7073.js.map +0 -1
- package/dist/7154.js +0 -1
- package/dist/7154.js.map +0 -1
- package/dist/7348.js +0 -1
- package/dist/7439.js +0 -1
- package/dist/7439.js.map +0 -1
- package/dist/7543.js +0 -1
- package/dist/7607.js +0 -1
- package/dist/772.js +0 -1
- package/dist/7984.js +0 -1
- package/dist/7984.js.map +0 -1
- package/dist/8538.js +0 -1
- package/dist/8538.js.map +0 -1
- package/dist/8599.js +0 -1
- package/dist/8727.js +0 -1
- package/dist/8847.js +0 -1
- package/dist/9015.js +0 -1
- package/dist/906.js +0 -1
- package/dist/9065.js +0 -1
- package/dist/9182.js +0 -1
- package/dist/9339.js +0 -1
- package/dist/9453.js +0 -1
- package/dist/9833.js +0 -1
- package/dist/9833.js.map +0 -1
- package/dist/9856.js +0 -1
- package/dist/9856.js.map +0 -1
- package/dist/9920.js +0 -1
- package/dist/9938.js +0 -1
- package/dist/9943.js +0 -1
- package/dist/9943.js.map +0 -1
- package/dist/olaboot-esm-patient-registration-app.js +0 -5
- package/dist/olaboot-esm-patient-registration-app.js.map +0 -1
- package/jest.config.js +0 -3
- package/src/resource.ts +0 -12
|
@@ -1,330 +1,333 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { type
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { vi, describe, it, expect, test, beforeEach } from 'vitest';
|
|
3
|
+
import { Form, Formik } from 'formik';
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
import { getDefaultsFromConfigSchema, useConfig } from '@openmrs/esm-framework';
|
|
6
|
+
import { Field } from './field.component';
|
|
7
|
+
import { esmPatientRegistrationSchema, type RegistrationConfig } from '../../config-schema';
|
|
8
|
+
import { type Resources } from '../../offline.resources';
|
|
9
|
+
import type { AddressTemplate, FormValues } from '../patient-registration.types';
|
|
10
|
+
import { PatientRegistrationContextProvider } from '../patient-registration-context';
|
|
11
|
+
import { ResourcesContextProvider } from '../../resources-context';
|
|
12
|
+
import { renderWithContext } from 'tools';
|
|
13
|
+
|
|
14
|
+
const mockUseConfig = vi.mocked(useConfig<RegistrationConfig>);
|
|
15
|
+
|
|
16
|
+
const predefinedAddressTemplate = {
|
|
17
|
+
uuid: 'test-address-template-uuid',
|
|
18
|
+
property: 'layout.address.format',
|
|
19
|
+
description: 'Test Address Template',
|
|
20
|
+
display:
|
|
21
|
+
'Layout - Address Format = <org.openmrs.layout.address.AddressTemplate>\n <nameMappings class="properties">\n <property name="postalCode" value="Location.postalCode"/>\n <property name="address2" value="Location.address2"/>\n <property name="address1" value="Location.address1"/>\n <property name="country" value="Location.country"/>\n <property name="stateProvince" value="Location.stateProvince"/>\n <property name="cityVillage" value="Location.cityVillage"/>\n </nameMappings>\n <sizeMappings class="properties">\n <property name="postalCode" value="10"/>\n <property name="address2" value="40"/>\n <property name="address1" value="40"/>\n <property name="country" value="10"/>\n <property name="stateProvince" value="10"/>\n <property name="cityVillage" value="10"/>\n </sizeMappings>\n <lineByLineFormat>\n <string>address1</string>\n <string>address2</string>\n <string>cityVillage stateProvince country postalCode</string>\n </lineByLineFormat>\n </org.openmrs.layout.address.AddressTemplate>',
|
|
22
|
+
value:
|
|
23
|
+
'<org.openmrs.layout.address.AddressTemplate>\r\n <nameMappings class="properties">\r\n <property name="postalCode" value="Location.postalCode"/>\r\n <property name="address2" value="Location.address2"/>\r\n <property name="address1" value="Location.address1"/>\r\n <property name="country" value="Location.country"/>\r\n <property name="stateProvince" value="Location.stateProvince"/>\r\n <property name="cityVillage" value="Location.cityVillage"/>\r\n </nameMappings>\r\n <sizeMappings class="properties">\r\n <property name="postalCode" value="4"/>\r\n <property name="address1" value="40"/>\r\n <property name="address2" value="40"/>\r\n <property name="country" value="10"/>\r\n <property name="stateProvince" value="10"/>\r\n <property name="cityVillage" value="10"/>\r\n <asset name="cityVillage" value="10"/>\r\n </sizeMappings>\r\n <lineByLineFormat>\r\n <string>address1 address2</string>\r\n <string>cityVillage stateProvince postalCode</string>\r\n <string>country</string>\r\n </lineByLineFormat>\r\n <elementDefaults class="properties">\r\n <property name="country" value=""/>\r\n </elementDefaults>\r\n <elementRegex class="properties">\r\n <property name="address1" value="[a-zA-Z]+$"/>\r\n </elementRegex>\r\n <elementRegexFormats class="properties">\r\n <property name="address1" value="Countries can only be letters"/>\r\n </elementRegexFormats>\r\n </org.openmrs.layout.address.AddressTemplate>',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const mockIdentifierTypes = [
|
|
27
|
+
{
|
|
28
|
+
fieldName: 'openMrsId',
|
|
29
|
+
format: '',
|
|
30
|
+
identifierSources: [
|
|
31
|
+
{
|
|
32
|
+
uuid: '8549f706-7e85-4c1d-9424-217d50a2988b',
|
|
33
|
+
name: 'Generator for OpenMRS ID',
|
|
34
|
+
description: 'Generator for OpenMRS ID',
|
|
35
|
+
baseCharacterSet: '0123456789ACDEFGHJKLMNPRTUVWXY',
|
|
36
|
+
prefix: '',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
isPrimary: true,
|
|
40
|
+
name: 'OpenMRS ID',
|
|
41
|
+
required: true,
|
|
42
|
+
uniquenessBehavior: 'UNIQUE' as const,
|
|
43
|
+
uuid: '05a29f94-c0ed-11e2-94be-8c13b969e334',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
fieldName: 'idCard',
|
|
47
|
+
format: '',
|
|
48
|
+
identifierSources: [],
|
|
49
|
+
isPrimary: false,
|
|
50
|
+
name: 'ID Card',
|
|
51
|
+
required: false,
|
|
52
|
+
uniquenessBehavior: 'UNIQUE' as const,
|
|
53
|
+
uuid: 'b4143563-16cd-4439-b288-f83d61670fc8',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
fieldName: 'legacyId',
|
|
57
|
+
format: '',
|
|
58
|
+
identifierSources: [],
|
|
59
|
+
isPrimary: false,
|
|
60
|
+
name: 'Legacy ID',
|
|
61
|
+
required: false,
|
|
62
|
+
uniquenessBehavior: null,
|
|
63
|
+
uuid: '22348099-3873-459e-a32e-d93b17eda533',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
fieldName: 'oldIdentificationNumber',
|
|
67
|
+
format: '',
|
|
68
|
+
identifierSources: [],
|
|
69
|
+
isPrimary: false,
|
|
70
|
+
name: 'Old Identification Number',
|
|
71
|
+
required: false,
|
|
72
|
+
uniquenessBehavior: null,
|
|
73
|
+
uuid: '8d79403a-c2cc-11de-8d13-0010c6dffd0f',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
fieldName: 'openMrsIdentificationNumber',
|
|
77
|
+
format: '',
|
|
78
|
+
identifierSources: [],
|
|
79
|
+
isPrimary: false,
|
|
80
|
+
name: 'OpenMRS Identification Number',
|
|
81
|
+
required: false,
|
|
82
|
+
uniquenessBehavior: null,
|
|
83
|
+
uuid: '8d793bee-c2cc-11de-8d13-0010c6dffd0f',
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
const mockResourcesContextValue: Resources = {
|
|
88
|
+
addressTemplate: predefinedAddressTemplate as unknown as AddressTemplate,
|
|
89
|
+
currentSession: {
|
|
90
|
+
authenticated: true,
|
|
91
|
+
sessionId: 'JSESSION',
|
|
92
|
+
currentProvider: { uuid: 'provider-uuid', identifier: 'PRO-123' },
|
|
93
|
+
},
|
|
94
|
+
relationshipTypes: { results: [] },
|
|
95
|
+
identifierTypes: [...mockIdentifierTypes],
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const initialContextValues = {
|
|
99
|
+
currentPhoto: 'data:image/png;base64,1234567890',
|
|
100
|
+
identifierTypes: [],
|
|
101
|
+
inEditMode: false,
|
|
102
|
+
initialFormValues: {} as FormValues,
|
|
103
|
+
isOffline: false,
|
|
104
|
+
setCapturePhotoProps: vi.fn(),
|
|
105
|
+
setFieldValue: vi.fn(),
|
|
106
|
+
setFieldTouched: vi.fn(),
|
|
107
|
+
setInitialFormValues: vi.fn(),
|
|
108
|
+
validationSchema: null,
|
|
109
|
+
values: {} as FormValues,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
describe('Field', () => {
|
|
113
|
+
beforeEach(() => {
|
|
114
|
+
mockUseConfig.mockReturnValue({
|
|
115
|
+
...getDefaultsFromConfigSchema(esmPatientRegistrationSchema),
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('should render NameField component when name prop is "name"', () => {
|
|
120
|
+
mockUseConfig.mockReturnValue({
|
|
121
|
+
...getDefaultsFromConfigSchema(esmPatientRegistrationSchema),
|
|
122
|
+
fieldConfigurations: {
|
|
123
|
+
name: {
|
|
124
|
+
allowUnidentifiedPatients: true,
|
|
125
|
+
displayMiddleName: true,
|
|
126
|
+
defaultUnknownGivenName: 'UNKNOWN',
|
|
127
|
+
defaultUnknownFamilyName: 'UNKNOWN',
|
|
128
|
+
},
|
|
129
|
+
} as RegistrationConfig['fieldConfigurations'],
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
renderWithContext(
|
|
133
|
+
<Formik initialValues={{}} onSubmit={vi.fn()}>
|
|
134
|
+
<Form>
|
|
135
|
+
<PatientRegistrationContextProvider value={initialContextValues}>
|
|
136
|
+
<Field name="name" />
|
|
137
|
+
</PatientRegistrationContextProvider>
|
|
138
|
+
</Form>
|
|
139
|
+
</Formik>,
|
|
140
|
+
ResourcesContextProvider,
|
|
141
|
+
mockResourcesContextValue,
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
expect(screen.getByText('Full Name')).toBeInTheDocument();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('should render GenderField component when name prop is "gender"', () => {
|
|
148
|
+
mockUseConfig.mockReturnValue({
|
|
149
|
+
...getDefaultsFromConfigSchema(esmPatientRegistrationSchema),
|
|
150
|
+
fieldConfigurations: {
|
|
151
|
+
gender: [
|
|
152
|
+
{
|
|
153
|
+
value: 'Male',
|
|
154
|
+
label: 'Male',
|
|
155
|
+
id: 'male',
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
} as unknown as RegistrationConfig['fieldConfigurations'],
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
renderWithContext(
|
|
162
|
+
<Formik initialValues={{}} onSubmit={vi.fn()}>
|
|
163
|
+
<Form>
|
|
164
|
+
<PatientRegistrationContextProvider value={initialContextValues}>
|
|
165
|
+
<Field name="gender" />
|
|
166
|
+
</PatientRegistrationContextProvider>
|
|
167
|
+
</Form>
|
|
168
|
+
</Formik>,
|
|
169
|
+
ResourcesContextProvider,
|
|
170
|
+
mockResourcesContextValue,
|
|
171
|
+
);
|
|
172
|
+
expect(screen.getByLabelText('Male')).toBeInTheDocument();
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('should render DobField component when name prop is "dob"', () => {
|
|
176
|
+
renderWithContext(
|
|
177
|
+
<Formik initialValues={{}} onSubmit={vi.fn()}>
|
|
178
|
+
<Form>
|
|
179
|
+
<PatientRegistrationContextProvider value={initialContextValues}>
|
|
180
|
+
<Field name="dob" />
|
|
181
|
+
</PatientRegistrationContextProvider>
|
|
182
|
+
</Form>
|
|
183
|
+
</Formik>,
|
|
184
|
+
ResourcesContextProvider,
|
|
185
|
+
mockResourcesContextValue,
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
expect(screen.getByText('Birth')).toBeInTheDocument();
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// TODO: Re-enable after migrating the in-test `vi.mock` of `address-hierarchy.resource`
|
|
192
|
+
// to a top-level mock with `mockReturnValue` set. The current setup leaves
|
|
193
|
+
// `useOrderedAddressHierarchyLevels` returning undefined and the component crashes.
|
|
194
|
+
it.skip('should render AddressComponent component when name prop is "address"', () => {
|
|
195
|
+
vi.mock('./address/address-hierarchy.resource', async () => ({
|
|
196
|
+
...((await vi.importActual('./address/address-hierarchy.resource')) as object),
|
|
197
|
+
useOrderedAddressHierarchyLevels: vi.fn(),
|
|
198
|
+
}));
|
|
199
|
+
|
|
200
|
+
mockUseConfig.mockReturnValue({
|
|
201
|
+
...getDefaultsFromConfigSchema(esmPatientRegistrationSchema),
|
|
202
|
+
fieldConfigurations: {
|
|
203
|
+
address: {
|
|
204
|
+
useAddressHierarchy: {
|
|
205
|
+
enabled: false,
|
|
206
|
+
useQuickSearch: false,
|
|
207
|
+
searchAddressByLevel: false,
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
} as RegistrationConfig['fieldConfigurations'],
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
renderWithContext(
|
|
214
|
+
<Formik initialValues={{}} onSubmit={vi.fn()}>
|
|
215
|
+
<Form>
|
|
216
|
+
<PatientRegistrationContextProvider value={initialContextValues}>
|
|
217
|
+
<Field name="address" />
|
|
218
|
+
</PatientRegistrationContextProvider>
|
|
219
|
+
</Form>
|
|
220
|
+
</Formik>,
|
|
221
|
+
ResourcesContextProvider,
|
|
222
|
+
mockResourcesContextValue,
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
expect(screen.getByText('Address')).toBeInTheDocument();
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('should render Identifiers component when name prop is "id"', () => {
|
|
229
|
+
mockUseConfig.mockReturnValue({
|
|
230
|
+
...getDefaultsFromConfigSchema(esmPatientRegistrationSchema),
|
|
231
|
+
defaultPatientIdentifierTypes: ['OpenMRS ID'],
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
const openmrsID = {
|
|
235
|
+
name: 'OpenMRS ID',
|
|
236
|
+
fieldName: 'openMrsId',
|
|
237
|
+
required: true,
|
|
238
|
+
uuid: '05a29f94-c0ed-11e2-94be-8c13b969e334',
|
|
239
|
+
format: null,
|
|
240
|
+
isPrimary: true,
|
|
241
|
+
identifierSources: [
|
|
242
|
+
{
|
|
243
|
+
uuid: '691eed12-c0f1-11e2-94be-8c13b969e334',
|
|
244
|
+
name: 'Generator 1 for OpenMRS ID',
|
|
245
|
+
autoGenerationOption: {
|
|
246
|
+
manualEntryEnabled: false,
|
|
247
|
+
automaticGenerationEnabled: true,
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
uuid: '01af8526-cea4-4175-aa90-340acb411771',
|
|
252
|
+
name: 'Generator 2 for OpenMRS ID',
|
|
253
|
+
autoGenerationOption: {
|
|
254
|
+
manualEntryEnabled: true,
|
|
255
|
+
automaticGenerationEnabled: true,
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
identifierUuid: 'openmrs-identifier-uuid',
|
|
260
|
+
identifierTypeUuid: 'openmrs-id-identifier-type-uuid',
|
|
261
|
+
initialValue: '12345',
|
|
262
|
+
identifierValue: '12345',
|
|
263
|
+
identifierName: 'OpenMRS ID',
|
|
264
|
+
preferred: true,
|
|
265
|
+
selectedSource: {
|
|
266
|
+
uuid: 'openmrs-id-selected-source-uuid',
|
|
267
|
+
name: 'Generator 1 for OpenMRS ID',
|
|
268
|
+
autoGenerationOption: {
|
|
269
|
+
manualEntryEnabled: false,
|
|
270
|
+
automaticGenerationEnabled: true,
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
autoGenerationSource: null,
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
const updatedContextValues = {
|
|
277
|
+
currentPhoto: 'data:image/png;base64,1234567890',
|
|
278
|
+
identifierTypes: [],
|
|
279
|
+
inEditMode: false,
|
|
280
|
+
initialFormValues: { identifiers: { openmrsID } } as unknown as FormValues,
|
|
281
|
+
isOffline: false,
|
|
282
|
+
setCapturePhotoProps: vi.fn(),
|
|
283
|
+
setFieldValue: vi.fn(),
|
|
284
|
+
setInitialFormValues: vi.fn(),
|
|
285
|
+
validationSchema: null,
|
|
286
|
+
values: { identifiers: { openmrsID } } as unknown as FormValues,
|
|
287
|
+
setFieldTouched: vi.fn(),
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
renderWithContext(
|
|
291
|
+
<Formik initialValues={{}} onSubmit={vi.fn()}>
|
|
292
|
+
<Form>
|
|
293
|
+
<PatientRegistrationContextProvider value={updatedContextValues}>
|
|
294
|
+
<Field name="id" />
|
|
295
|
+
</PatientRegistrationContextProvider>
|
|
296
|
+
</Form>
|
|
297
|
+
</Formik>,
|
|
298
|
+
ResourcesContextProvider,
|
|
299
|
+
mockResourcesContextValue,
|
|
300
|
+
);
|
|
301
|
+
expect(screen.getByText('Identifiers')).toBeInTheDocument();
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it('should return null and report an error for an invalid field name', () => {
|
|
305
|
+
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
306
|
+
|
|
307
|
+
mockUseConfig.mockReturnValue({
|
|
308
|
+
...getDefaultsFromConfigSchema(esmPatientRegistrationSchema),
|
|
309
|
+
fieldDefinitions: [{ id: 'weight' }] as RegistrationConfig['fieldDefinitions'],
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
let error = null;
|
|
313
|
+
|
|
314
|
+
try {
|
|
315
|
+
renderWithContext(
|
|
316
|
+
<Formik initialValues={{}} onSubmit={vi.fn()}>
|
|
317
|
+
<Form>
|
|
318
|
+
<Field name="invalidField" />
|
|
319
|
+
</Form>
|
|
320
|
+
</Formik>,
|
|
321
|
+
ResourcesContextProvider,
|
|
322
|
+
mockResourcesContextValue,
|
|
323
|
+
);
|
|
324
|
+
} catch (err) {
|
|
325
|
+
error = err;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
expect(error).toMatch(/Invalid field name 'invalidField'. Valid options are /);
|
|
329
|
+
expect(screen.queryByTestId('invalid-field')).not.toBeInTheDocument();
|
|
330
|
+
|
|
331
|
+
consoleError.mockRestore();
|
|
332
|
+
});
|
|
333
|
+
});
|