@openmrs/esm-form-engine-lib 2.1.0-pre.1362

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 (272) hide show
  1. package/.editorconfig +12 -0
  2. package/.eslintignore +2 -0
  3. package/.eslintrc +58 -0
  4. package/.husky/pre-commit +6 -0
  5. package/.husky/pre-push +6 -0
  6. package/.prettierignore +4 -0
  7. package/LICENSE.txt +401 -0
  8. package/README.md +136 -0
  9. package/__mocks__/concepts.mock.json +140 -0
  10. package/__mocks__/forms/afe-forms/component_art.json +38 -0
  11. package/__mocks__/forms/afe-forms/component_preclinic-review.json +38 -0
  12. package/__mocks__/forms/afe-forms/demo_hts-form.json +62 -0
  13. package/__mocks__/forms/afe-forms/form-component.json +38 -0
  14. package/__mocks__/forms/afe-forms/mini-form.json +31 -0
  15. package/__mocks__/forms/afe-forms/nested-form1.json +38 -0
  16. package/__mocks__/forms/afe-forms/nested-form2.json +38 -0
  17. package/__mocks__/forms/afe-forms/test-orders.json +72 -0
  18. package/__mocks__/forms/afe-forms/test-schema-transformer-form.json +88 -0
  19. package/__mocks__/forms/rfe-forms/age-validation-form.json +58 -0
  20. package/__mocks__/forms/rfe-forms/bmi-test-form.json +69 -0
  21. package/__mocks__/forms/rfe-forms/bsa-test-form.json +69 -0
  22. package/__mocks__/forms/rfe-forms/component_art.json +1705 -0
  23. package/__mocks__/forms/rfe-forms/component_preclinic-review.json +480 -0
  24. package/__mocks__/forms/rfe-forms/conditional-answered-form.json +97 -0
  25. package/__mocks__/forms/rfe-forms/conditional-required-form.json +281 -0
  26. package/__mocks__/forms/rfe-forms/demo_hts-form.json +346 -0
  27. package/__mocks__/forms/rfe-forms/edd-test-form.json +88 -0
  28. package/__mocks__/forms/rfe-forms/external_data_source_form.json +43 -0
  29. package/__mocks__/forms/rfe-forms/filter-answer-options-test-form.json +87 -0
  30. package/__mocks__/forms/rfe-forms/form-component.json +43 -0
  31. package/__mocks__/forms/rfe-forms/forms-loader.test.schema.ts +209 -0
  32. package/__mocks__/forms/rfe-forms/historical-expressions-form.json +170 -0
  33. package/__mocks__/forms/rfe-forms/labour_and_delivery_test_form.json +374 -0
  34. package/__mocks__/forms/rfe-forms/mini-form.json +29 -0
  35. package/__mocks__/forms/rfe-forms/mockHistoricalvisitsEncounter.json +89 -0
  36. package/__mocks__/forms/rfe-forms/months-on-art-form.json +90 -0
  37. package/__mocks__/forms/rfe-forms/multi-select-form.json +86 -0
  38. package/__mocks__/forms/rfe-forms/nested-form1.json +43 -0
  39. package/__mocks__/forms/rfe-forms/nested-form2.json +43 -0
  40. package/__mocks__/forms/rfe-forms/next-visit-test-form.json +78 -0
  41. package/__mocks__/forms/rfe-forms/obs-group-test_form.json +137 -0
  42. package/__mocks__/forms/rfe-forms/obs-list-data.ts +37 -0
  43. package/__mocks__/forms/rfe-forms/post-submission-test-form.json +116 -0
  44. package/__mocks__/forms/rfe-forms/reference-by-mapping-form.json +54 -0
  45. package/__mocks__/forms/rfe-forms/required-form.json +50 -0
  46. package/__mocks__/forms/rfe-forms/sample_fields.json +36 -0
  47. package/__mocks__/forms/rfe-forms/test-enrolment-form.json +241 -0
  48. package/__mocks__/forms/rfe-forms/treatment-end-date-test-form.json +121 -0
  49. package/__mocks__/forms/rfe-forms/viral-load-status-form.json +75 -0
  50. package/__mocks__/forms/rfe-forms/zscore-bmi-for-age-form.json +79 -0
  51. package/__mocks__/forms/rfe-forms/zscore-height-for-age-form.json +79 -0
  52. package/__mocks__/forms/rfe-forms/zscore-weight-height-form.json +77 -0
  53. package/__mocks__/packages/hiv/forms/hts_poc/1.0.json +8 -0
  54. package/__mocks__/packages/hiv/forms/hts_poc/1.1.json +91 -0
  55. package/__mocks__/packages/test-forms-registry.ts +12 -0
  56. package/__mocks__/patient.mock.ts +173 -0
  57. package/__mocks__/react-i18next.js +49 -0
  58. package/__mocks__/react-markdown.tsx +5 -0
  59. package/__mocks__/session.mock.ts +117 -0
  60. package/__mocks__/single-spa-react.js +11 -0
  61. package/__mocks__/use-initial-values/encounter.mock.json +963 -0
  62. package/__mocks__/use-initial-values/patient.mock.json +73 -0
  63. package/__mocks__/visit.mock.ts +19 -0
  64. package/dist/openmrs-esm-form-engine-lib.js +1 -0
  65. package/jest.config.js +30 -0
  66. package/package.json +104 -0
  67. package/prettier.config.js +8 -0
  68. package/readme/form-engine.jpeg +0 -0
  69. package/src/adapters/control-adapter.ts +29 -0
  70. package/src/adapters/encounter-datetime-adapter.ts +38 -0
  71. package/src/adapters/encounter-location-adapter.ts +39 -0
  72. package/src/adapters/encounter-provider-adapter.ts +48 -0
  73. package/src/adapters/encounter-role-adapter.ts +54 -0
  74. package/src/adapters/inline-date-adapter.ts +58 -0
  75. package/src/adapters/obs-adapter.ts +280 -0
  76. package/src/adapters/obs-comment-adapter.ts +60 -0
  77. package/src/adapters/orders-adapter.ts +75 -0
  78. package/src/adapters/patient-identifier-adapter.ts +40 -0
  79. package/src/adapters/program-state-adapter.ts +52 -0
  80. package/src/api/index.ts +178 -0
  81. package/src/components/error/error-modal.component.tsx +37 -0
  82. package/src/components/error/error.scss +4 -0
  83. package/src/components/extension/extension-parcel.component.tsx +32 -0
  84. package/src/components/field-label/field-label.component.tsx +32 -0
  85. package/src/components/field-label/field-label.scss +11 -0
  86. package/src/components/group/obs-group.component.tsx +29 -0
  87. package/src/components/group/obs-group.scss +12 -0
  88. package/src/components/inputs/content-switcher/content-switcher.component.tsx +71 -0
  89. package/src/components/inputs/content-switcher/content-switcher.scss +55 -0
  90. package/src/components/inputs/date/date.component.tsx +149 -0
  91. package/src/components/inputs/date/date.scss +36 -0
  92. package/src/components/inputs/file/camera/camera.component.tsx +34 -0
  93. package/src/components/inputs/file/camera/camera.scss +3 -0
  94. package/src/components/inputs/file/file.component.tsx +159 -0
  95. package/src/components/inputs/file/file.scss +101 -0
  96. package/src/components/inputs/fixed-value/fixed-value.component.tsx +19 -0
  97. package/src/components/inputs/markdown/markdown-wrapper.component.tsx +14 -0
  98. package/src/components/inputs/markdown/markdown.component.tsx +8 -0
  99. package/src/components/inputs/multi-select/multi-select.component.tsx +151 -0
  100. package/src/components/inputs/multi-select/multi-select.scss +25 -0
  101. package/src/components/inputs/multi-select/multi-select.test.tsx +90 -0
  102. package/src/components/inputs/number/number.component.tsx +69 -0
  103. package/src/components/inputs/number/number.scss +15 -0
  104. package/src/components/inputs/radio/radio.component.tsx +79 -0
  105. package/src/components/inputs/radio/radio.scss +36 -0
  106. package/src/components/inputs/select/dropdown.component.tsx +73 -0
  107. package/src/components/inputs/select/dropdown.scss +11 -0
  108. package/src/components/inputs/select/dropdown.test.tsx +120 -0
  109. package/src/components/inputs/text/text.component.tsx +65 -0
  110. package/src/components/inputs/text/text.scss +15 -0
  111. package/src/components/inputs/text/text.test.tsx +104 -0
  112. package/src/components/inputs/text-area/text-area.component.tsx +63 -0
  113. package/src/components/inputs/text-area/text-area.scss +11 -0
  114. package/src/components/inputs/toggle/toggle.component.tsx +66 -0
  115. package/src/components/inputs/toggle/toggle.scss +12 -0
  116. package/src/components/inputs/tooltip/tooltip.component.tsx +23 -0
  117. package/src/components/inputs/tooltip/tooltip.scss +8 -0
  118. package/src/components/inputs/ui-select-extended/ui-select-extended.component.tsx +187 -0
  119. package/src/components/inputs/ui-select-extended/ui-select-extended.scss +15 -0
  120. package/src/components/inputs/ui-select-extended/ui-select-extended.test.tsx +211 -0
  121. package/src/components/inputs/unspecified/unspecified.component.tsx +74 -0
  122. package/src/components/inputs/unspecified/unspecified.scss +7 -0
  123. package/src/components/inputs/unspecified/unspecified.test.tsx +95 -0
  124. package/src/components/inputs/workspace-launcher/workspace-launcher.component.tsx +35 -0
  125. package/src/components/inputs/workspace-launcher/workspace-launcher.scss +15 -0
  126. package/src/components/label/label.component.tsx +20 -0
  127. package/src/components/label/label.scss +11 -0
  128. package/src/components/loaders/loader.component.tsx +16 -0
  129. package/src/components/loaders/loader.scss +20 -0
  130. package/src/components/patient-banner/patient-banner.component.tsx +20 -0
  131. package/src/components/patient-banner/patient-banner.scss +12 -0
  132. package/src/components/previous-value-review/previous-value-review.component.tsx +49 -0
  133. package/src/components/previous-value-review/previous-value-review.scss +36 -0
  134. package/src/components/processor-factory/form-processor-factory.component.tsx +127 -0
  135. package/src/components/renderer/custom-hooks-renderer.component.tsx +30 -0
  136. package/src/components/renderer/field/fieldLogic.ts +214 -0
  137. package/src/components/renderer/field/form-field-renderer.component.tsx +281 -0
  138. package/src/components/renderer/field/form-field-renderer.scss +5 -0
  139. package/src/components/renderer/form/form-renderer.component.tsx +89 -0
  140. package/src/components/renderer/form/state.ts +54 -0
  141. package/src/components/renderer/page/page.renderer.component.tsx +50 -0
  142. package/src/components/renderer/page/page.renderer.scss +36 -0
  143. package/src/components/renderer/section/section-renderer.component.tsx +21 -0
  144. package/src/components/renderer/section/section-renderer.scss +19 -0
  145. package/src/components/repeat/helpers.test.ts +29 -0
  146. package/src/components/repeat/helpers.ts +68 -0
  147. package/src/components/repeat/repeat-controls.component.tsx +38 -0
  148. package/src/components/repeat/repeat-controls.scss +7 -0
  149. package/src/components/repeat/repeat.component.tsx +201 -0
  150. package/src/components/repeat/repeat.scss +30 -0
  151. package/src/components/repeat/repeat.test.ts +29 -0
  152. package/src/components/sidebar/sidebar.component.tsx +134 -0
  153. package/src/components/sidebar/sidebar.scss +121 -0
  154. package/src/components/value/value.component.tsx +27 -0
  155. package/src/components/value/value.scss +17 -0
  156. package/src/components/value/view/field-value-view.component.tsx +33 -0
  157. package/src/components/value/view/field-value-view.scss +31 -0
  158. package/src/constants.ts +12 -0
  159. package/src/datasources/concept-data-source.ts +42 -0
  160. package/src/datasources/data-source.ts +23 -0
  161. package/src/datasources/encounter-role-datasource.ts +15 -0
  162. package/src/datasources/historical-data-source.ts +11 -0
  163. package/src/datasources/location-data-source.ts +27 -0
  164. package/src/datasources/provider-datasource.ts +15 -0
  165. package/src/datasources/select-concept-answers-datasource.ts +15 -0
  166. package/src/declarations.d.ts +4 -0
  167. package/src/external-function-context.tsx +8 -0
  168. package/src/form-context.tsx +42 -0
  169. package/src/form-engine.component.tsx +178 -0
  170. package/src/form-engine.scss +140 -0
  171. package/src/form-engine.test.tsx +817 -0
  172. package/src/globals.ts +1 -0
  173. package/src/hooks/useClobData.tsx +21 -0
  174. package/src/hooks/useConcepts.tsx +55 -0
  175. package/src/hooks/useDatasourceDependentValue.ts +16 -0
  176. package/src/hooks/useEncounter.tsx +32 -0
  177. package/src/hooks/useEncounterRole.tsx +15 -0
  178. package/src/hooks/useEvaluateFormFieldExpressions.ts +138 -0
  179. package/src/hooks/useFieldValidationResults.ts +18 -0
  180. package/src/hooks/useFormCollapse.tsx +36 -0
  181. package/src/hooks/useFormFieldValidators.ts +22 -0
  182. package/src/hooks/useFormFieldValueAdapters.ts +24 -0
  183. package/src/hooks/useFormFields.ts +37 -0
  184. package/src/hooks/useFormFieldsMeta.ts +48 -0
  185. package/src/hooks/useFormJson.test.tsx +173 -0
  186. package/src/hooks/useFormJson.tsx +237 -0
  187. package/src/hooks/useFormStateHelpers.ts +50 -0
  188. package/src/hooks/useFormsConfig.tsx +27 -0
  189. package/src/hooks/useInitialValues.ts +38 -0
  190. package/src/hooks/usePatientData.tsx +32 -0
  191. package/src/hooks/usePatientPrograms.ts +32 -0
  192. package/src/hooks/usePostSubmissionActions.test.tsx +42 -0
  193. package/src/hooks/usePostSubmissionActions.ts +31 -0
  194. package/src/hooks/useProcessorDependencies.ts +30 -0
  195. package/src/hooks/useRestMaxResultsCount.ts +5 -0
  196. package/src/hooks/useSystemSetting.ts +36 -0
  197. package/src/hooks/useWorkspaceLayout.ts +29 -0
  198. package/src/index.ts +12 -0
  199. package/src/lifecycle.ts +33 -0
  200. package/src/post-submission-actions/program-enrollment-action.ts +138 -0
  201. package/src/processors/encounter/encounter-form-processor.ts +337 -0
  202. package/src/processors/encounter/encounter-processor-helper.ts +320 -0
  203. package/src/processors/form-processor.ts +41 -0
  204. package/src/provider/form-factory-helper.ts +100 -0
  205. package/src/provider/form-factory-provider.tsx +169 -0
  206. package/src/provider/form-provider.tsx +37 -0
  207. package/src/registry/inbuilt-components/InbuiltPostSubmissionActions.ts +9 -0
  208. package/src/registry/inbuilt-components/control-templates.ts +57 -0
  209. package/src/registry/inbuilt-components/inbuiltControls.ts +99 -0
  210. package/src/registry/inbuilt-components/inbuiltDataSources.ts +41 -0
  211. package/src/registry/inbuilt-components/inbuiltFieldValueAdapters.ts +64 -0
  212. package/src/registry/inbuilt-components/inbuiltTransformers.ts +10 -0
  213. package/src/registry/inbuilt-components/inbuiltValidators.ts +33 -0
  214. package/src/registry/inbuilt-components/template-component-map.ts +28 -0
  215. package/src/registry/registry.test.ts +20 -0
  216. package/src/registry/registry.ts +261 -0
  217. package/src/routes.json +1 -0
  218. package/src/setupI18n.ts +16 -0
  219. package/src/setupTests.ts +5 -0
  220. package/src/transformers/default-schema-transformer.test.ts +155 -0
  221. package/src/transformers/default-schema-transformer.ts +239 -0
  222. package/src/types/domain.ts +129 -0
  223. package/src/types/index.ts +130 -0
  224. package/src/types/schema.ts +238 -0
  225. package/src/typings.d.ts +9 -0
  226. package/src/utils/boolean-utils.ts +25 -0
  227. package/src/utils/common-expression-helpers.ts +503 -0
  228. package/src/utils/common-utils.test.ts +136 -0
  229. package/src/utils/common-utils.ts +55 -0
  230. package/src/utils/error-utils.ts +37 -0
  231. package/src/utils/expression-parser.test.ts +308 -0
  232. package/src/utils/expression-parser.ts +158 -0
  233. package/src/utils/expression-runner.test.ts +387 -0
  234. package/src/utils/expression-runner.ts +219 -0
  235. package/src/utils/form-helper.test.ts +482 -0
  236. package/src/utils/form-helper.ts +210 -0
  237. package/src/utils/form-page-utils.ts +13 -0
  238. package/src/utils/forms-loader.test.ts +323 -0
  239. package/src/utils/forms-loader.ts +306 -0
  240. package/src/utils/post-submission-action-helper.ts +71 -0
  241. package/src/utils/test-utils.ts +54 -0
  242. package/src/utils/zscore-service.ts +59 -0
  243. package/src/validators/conditional-answered-validator.test.ts +61 -0
  244. package/src/validators/conditional-answered-validator.ts +17 -0
  245. package/src/validators/date-validator.test.ts +46 -0
  246. package/src/validators/date-validator.ts +19 -0
  247. package/src/validators/default-value-validator.test.ts +90 -0
  248. package/src/validators/default-value-validator.ts +36 -0
  249. package/src/validators/form-validator.test.ts +188 -0
  250. package/src/validators/form-validator.ts +95 -0
  251. package/src/validators/js-expression-validator.test.ts +118 -0
  252. package/src/validators/js-expression-validator.ts +44 -0
  253. package/src/validators/schema.ts +34 -0
  254. package/src/zscore/bfa_boys_5_above.json +2522 -0
  255. package/src/zscore/bfa_girls_5_above.json +2522 -0
  256. package/src/zscore/hfa_boys_5_above.json +2186 -0
  257. package/src/zscore/hfa_boys_below5.json +22286 -0
  258. package/src/zscore/hfa_girls_5_above.json +2186 -0
  259. package/src/zscore/hfa_girls_below5.json +22286 -0
  260. package/src/zscore/wfl_boys_below5.json +7814 -0
  261. package/src/zscore/wfl_girls_below5.json +7814 -0
  262. package/src/zscore-tests/bmi-age.test.tsx +88 -0
  263. package/src/zscore-tests/height-age.test.tsx +96 -0
  264. package/src/zscore-tests/weight-height.test.tsx +87 -0
  265. package/tools/i18next-parser.config.js +93 -0
  266. package/translations/en.json +47 -0
  267. package/translations/es.json +38 -0
  268. package/translations/fr.json +38 -0
  269. package/translations/km.json +38 -0
  270. package/tsconfig.json +19 -0
  271. package/turbo.json +15 -0
  272. package/webpack.config.js +1 -0
@@ -0,0 +1,91 @@
1
+ {
2
+ "name": "Test HTS POC",
3
+ "pages": [
4
+ {
5
+ "label": "Screening",
6
+ "sections": [
7
+ {
8
+ "label": "Testing history",
9
+ "isExpanded": "true",
10
+ "questions": [
11
+ {
12
+ "label": "When was the HIV test conducted?",
13
+ "type": "obs",
14
+ "questionOptions": {
15
+ "rendering": "date",
16
+ "concept": "164400AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
17
+ "weeksList": ""
18
+ },
19
+ "required": "true",
20
+ "unspecified": "true",
21
+ "hide": {
22
+ "hideWhenExpression": "false"
23
+ },
24
+ "validators": [
25
+ {
26
+ "type": "date",
27
+ "allowFutureDates": "false"
28
+ },
29
+ {
30
+ "type": "js_expression",
31
+ "failsWhenExpression": "myValue < '1/1/1980' || myValue > today()"
32
+ }
33
+ ],
34
+ "behaviours": [
35
+ {
36
+ "intent": "HTS_RETROSPECTIVE",
37
+ "required": "true",
38
+ "unspecified": "true",
39
+ "hide": {
40
+ "hideWhenExpression": "false"
41
+ },
42
+ "validators": [
43
+ {
44
+ "type": "date",
45
+ "allowFutureDates": "false"
46
+ },
47
+ {
48
+ "type": "js_expression",
49
+ "failsWhenExpression": "myValue < '1/1/1980' || myValue > today()"
50
+ }
51
+ ]
52
+ },
53
+ {
54
+ "intent": "HTS_HIVTEST",
55
+ "required": "true"
56
+ },
57
+ {
58
+ "intent": "",
59
+ "required": "false",
60
+ "hide": {
61
+ "hideWhenExpression": "hivTestConducted !== 'cf82933b-3f3f-45e7-a5ab-5d31aaee3da3'"
62
+ },
63
+ "validators": [
64
+ {
65
+ "type": "date",
66
+ "allowFutureDates": "false"
67
+ },
68
+ {
69
+ "type": "js_expression",
70
+ "failsWhenExpression": "myValue < '1/1/1980' || myValue > today()"
71
+ }
72
+ ]
73
+ }
74
+ ],
75
+ "id": "dateTestPerformed"
76
+ }
77
+ ]
78
+ }
79
+ ]
80
+ }
81
+ ],
82
+ "availableIntents": [
83
+ "HTS_RETROSPECTIVE",
84
+ "HTS_HIVTEST",
85
+ "*"
86
+ ],
87
+ "processor": "EncounterFormProcessor",
88
+ "uuid": "da24c540-cc83-43bc-978f-c1ef180a497f",
89
+ "referencedForms": [],
90
+ "encounterType": "79c1f50f-f77d-42e2-ad2a-d29304dde2fe"
91
+ }
@@ -0,0 +1,12 @@
1
+ import hiv_retro_v_1_0 from './hiv/forms/hts_poc/1.0.json';
2
+ import hiv_retro_v_1_1 from './hiv/forms/hts_poc/1.1.json';
3
+
4
+ export default {
5
+ hiv: {
6
+ hts_poc: {
7
+ '1.0': hiv_retro_v_1_0,
8
+ '1.1': hiv_retro_v_1_1,
9
+ },
10
+ },
11
+ covid: {},
12
+ };
@@ -0,0 +1,173 @@
1
+ export const mockPatient = {
2
+ resourceType: 'Patient',
3
+ id: '8673ee4f-e2ab-4077-ba55-4980f408773e',
4
+ extension: [
5
+ {
6
+ url: 'http://fhir-es.transcendinsights.com/stu3/StructureDefinition/resource-date-created',
7
+ valueDateTime: '2017-01-18T09:42:40+00:00',
8
+ },
9
+ {
10
+ url: 'https://purl.org/elab/fhir/StructureDefinition/Creator-crew-version1',
11
+ valueString: 'daemon',
12
+ },
13
+ ],
14
+ identifier: [
15
+ {
16
+ id: '1f0ad7a1-430f-4397-b571-59ea654a52db',
17
+ use: 'secondary',
18
+ system: 'Old Identification Number',
19
+ value: '100732HE',
20
+ },
21
+ {
22
+ id: '1f0ad7a1-430f-4397-b571-59ea654a52db',
23
+ use: 'usual',
24
+ system: 'OpenMRS ID',
25
+ value: '100GEJ',
26
+ },
27
+ ],
28
+ active: true,
29
+ name: [
30
+ {
31
+ id: 'efdb246f-4142-4c12-a27a-9be60b9592e9',
32
+ use: 'usual',
33
+ family: 'Wilson',
34
+ given: ['John'],
35
+ },
36
+ ],
37
+ gender: 'male',
38
+ birthDate: '1972-04-04',
39
+ deceasedBoolean: false,
40
+ address: [
41
+ {
42
+ id: '0c244eae-85c8-4cc9-b168-96b51f864e77',
43
+ use: 'home',
44
+ line: ['Address10351'],
45
+ city: 'City0351',
46
+ state: 'State0351tested',
47
+ postalCode: '60351',
48
+ country: 'Country0351',
49
+ },
50
+ ],
51
+ telecom: [
52
+ {
53
+ system: 'Mobile',
54
+ value: '+25467388299499',
55
+ },
56
+ ],
57
+ };
58
+
59
+ export const mockPatientAge4 = {
60
+ resourceType: 'Patient',
61
+ id: '8673ee4f-e2ab-4077-ba55-4980f408773e',
62
+ extension: [
63
+ {
64
+ url: 'http://fhir-es.transcendinsights.com/stu3/StructureDefinition/resource-date-created',
65
+ valueDateTime: '2017-01-18T09:42:40+00:00',
66
+ },
67
+ {
68
+ url: 'https://purl.org/elab/fhir/StructureDefinition/Creator-crew-version1',
69
+ valueString: 'daemon',
70
+ },
71
+ ],
72
+ identifier: [
73
+ {
74
+ id: '1f0ad7a1-430f-4397-b571-59ea654a52db',
75
+ use: 'secondary',
76
+ system: 'Old Identification Number',
77
+ value: '100732HE',
78
+ },
79
+ {
80
+ id: '1f0ad7a1-430f-4397-b571-59ea654a52db',
81
+ use: 'usual',
82
+ system: 'OpenMRS ID',
83
+ value: '100GEJ',
84
+ },
85
+ ],
86
+ active: true,
87
+ name: [
88
+ {
89
+ id: 'efdb246f-4142-4c12-a27a-9be60b9592e9',
90
+ use: 'usual',
91
+ family: 'Wilson',
92
+ given: ['John'],
93
+ },
94
+ ],
95
+ gender: 'male',
96
+ birthDate: '2020-01-01',
97
+ deceasedBoolean: false,
98
+ address: [
99
+ {
100
+ id: '0c244eae-85c8-4cc9-b168-96b51f864e77',
101
+ use: 'home',
102
+ line: ['Address10351'],
103
+ city: 'City0351',
104
+ state: 'State0351tested',
105
+ postalCode: '60351',
106
+ country: 'Country0351',
107
+ },
108
+ ],
109
+ telecom: [
110
+ {
111
+ system: 'Mobile',
112
+ value: '+25467388299499',
113
+ },
114
+ ],
115
+ };
116
+
117
+ export const mockPatientAge8 = {
118
+ resourceType: 'Patient',
119
+ id: 'e13a8696-dc58-4b8c-ae40-2a1e7dd843e7',
120
+ extension: [
121
+ {
122
+ url: 'http://fhir-es.transcendinsights.com/stu3/StructureDefinition/resource-date-created',
123
+ valueDateTime: '2017-01-18T09:42:40+00:00',
124
+ },
125
+ {
126
+ url: 'https://purl.org/elab/fhir/StructureDefinition/Creator-crew-version1',
127
+ valueString: 'daemon',
128
+ },
129
+ ],
130
+ identifier: [
131
+ {
132
+ id: '1f0ad7a1-430f-4397-b571-59ea654a52db',
133
+ use: 'secondary',
134
+ system: 'Old Identification Number',
135
+ value: '100732HE',
136
+ },
137
+ {
138
+ id: '1f0ad7a1-430f-4397-b571-59ea654a52db',
139
+ use: 'usual',
140
+ system: 'OpenMRS ID',
141
+ value: '100GEJ',
142
+ },
143
+ ],
144
+ active: true,
145
+ name: [
146
+ {
147
+ id: 'efdb246f-4142-4c12-a27a-9be60b9592e9',
148
+ use: 'usual',
149
+ family: 'Wilson',
150
+ given: ['John'],
151
+ },
152
+ ],
153
+ gender: 'male',
154
+ birthDate: '2016-04-04',
155
+ deceasedBoolean: false,
156
+ address: [
157
+ {
158
+ id: '0c244eae-85c8-4cc9-b168-96b51f864e77',
159
+ use: 'home',
160
+ line: ['Address10351'],
161
+ city: 'City0351',
162
+ state: 'State0351tested',
163
+ postalCode: '60351',
164
+ country: 'Country0351',
165
+ },
166
+ ],
167
+ telecom: [
168
+ {
169
+ system: 'Mobile',
170
+ value: '+25467388299499',
171
+ },
172
+ ],
173
+ };
@@ -0,0 +1,49 @@
1
+ const React = require('react');
2
+ const reactI18next = require('react-i18next');
3
+
4
+ const hasChildren = (node) => node && (node.children || (node.props && node.props.children));
5
+
6
+ const getChildren = (node) => (node && node.children ? node.children : node.props && node.props.children);
7
+
8
+ const renderNodes = (reactNodes) => {
9
+ if (typeof reactNodes === 'string') {
10
+ return reactNodes;
11
+ }
12
+
13
+ return Object.keys(reactNodes).map((key, i) => {
14
+ const child = reactNodes[key];
15
+ const isElement = React.isValidElement(child);
16
+
17
+ if (typeof child === 'string') {
18
+ return child;
19
+ }
20
+ if (hasChildren(child)) {
21
+ const inner = renderNodes(getChildren(child));
22
+ return React.cloneElement(child, { ...child.props, key: i }, inner);
23
+ }
24
+ if (typeof child === 'object' && !isElement) {
25
+ return Object.keys(child).reduce((str, childKey) => `${str}${child[childKey]}`, '');
26
+ }
27
+
28
+ return child;
29
+ });
30
+ };
31
+
32
+ const useMock = [(k) => k, {}];
33
+ useMock.t = (key, defaultValue) => defaultValue || key;
34
+ useMock.i18n = {};
35
+
36
+ module.exports = {
37
+ // this mock makes sure any components using the translate HoC receive the t function as a prop
38
+ Trans: ({ children }) => renderNodes(children),
39
+ Translation: ({ children }) => children((k) => k, { i18n: {} }),
40
+ useTranslation: () => useMock,
41
+
42
+ // mock if needed
43
+ I18nextProvider: jest.fn().mockImplementation(({ children }) => children),
44
+ initReactI18next: reactI18next.initReactI18next,
45
+ setDefaults: reactI18next.setDefaults,
46
+ getDefaults: reactI18next.getDefaults,
47
+ setI18n: reactI18next.setI18n,
48
+ getI18n: reactI18next.getI18n,
49
+ };
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+
3
+ export default function({ children }) {
4
+ return <>{children}</>;
5
+ }
@@ -0,0 +1,117 @@
1
+ export const mockSessionDataResponse = {
2
+ data: {
3
+ authenticated: true,
4
+ locale: 'en_GB',
5
+ currentProvider: {
6
+ uuid: 'b1a8b05e-3542-4037-bbd3-998ee9c4057z',
7
+ display: 'Test User',
8
+ person: {
9
+ uuid: 'ddd5fa89-48a6-432e-abb8-0d11b4be7e4f',
10
+ display: 'Test User',
11
+ },
12
+ identifier: 'UNKNOWN',
13
+ attributes: [],
14
+ },
15
+ sessionLocation: {
16
+ uuid: 'b1a8b05e-3542-4037-bbd3-998ee9c40574',
17
+ display: 'Inpatient Ward',
18
+ name: 'Inpatient Ward',
19
+ description: null,
20
+ address1: null,
21
+ address2: null,
22
+ cityVillage: null,
23
+ stateProvince: null,
24
+ country: null,
25
+ postalCode: null,
26
+ latitude: null,
27
+ longitude: null,
28
+ countyDistrict: null,
29
+ address3: null,
30
+ address4: null,
31
+ address5: null,
32
+ address6: null,
33
+ tags: [
34
+ {
35
+ uuid: '8d4626ca-7abd-42ad-be48-56767bbcf272',
36
+ display: 'Transfer Location',
37
+ },
38
+ {
39
+ uuid: 'b8bbf83e-645f-451f-8efe-a0db56f09676',
40
+ display: 'Login Location',
41
+ },
42
+ {
43
+ uuid: '1c783dca-fd54-4ea8-a0fc-2875374e9cb6',
44
+ display: 'Admission Location',
45
+ },
46
+ ],
47
+ parentLocation: {
48
+ uuid: 'aff27d58-a15c-49a6-9beb-d30dcfc0c66e',
49
+ display: 'Amani Hospital',
50
+ },
51
+ childLocations: [],
52
+ retired: false,
53
+ attributes: [],
54
+ address7: null,
55
+ address8: null,
56
+ address9: null,
57
+ address10: null,
58
+ address11: null,
59
+ address12: null,
60
+ address13: null,
61
+ address14: null,
62
+ address15: null,
63
+ links: [],
64
+ },
65
+ user: {
66
+ uuid: '45ce6c2e-dd5a-11e6-9d9c-0242ac150002',
67
+ display: 'admin',
68
+ username: '',
69
+ systemId: 'admin',
70
+ userProperties: {
71
+ loginAttempts: '0',
72
+ },
73
+ person: {
74
+ uuid: '0775e6b7-f439-40e5-87a3-2bd11f3b9ee5',
75
+ display: 'Test User',
76
+ },
77
+ privileges: [
78
+ {
79
+ uuid: '62431c71-5244-11ea-a771-0242ac160002',
80
+ display: 'Manage Appointment Services',
81
+ links: [],
82
+ },
83
+ {
84
+ uuid: '6206682c-5244-11ea-a771-0242ac160002',
85
+ display: 'Manage Appointments',
86
+ links: [],
87
+ },
88
+ {
89
+ uuid: '6280ff58-5244-11ea-a771-0242ac160002',
90
+ display: 'Manage Appointment Specialities',
91
+ links: [],
92
+ },
93
+ ],
94
+ roles: [
95
+ {
96
+ uuid: '8d94f852-c2cc-11de-8d13-0010c6dffd0f',
97
+ display: 'System Developer',
98
+ links: [],
99
+ },
100
+ {
101
+ uuid: '62c195c5-5244-11ea-a771-0242ac160002',
102
+ display: 'Bahmni Role',
103
+ links: [],
104
+ },
105
+ {
106
+ uuid: '8d94f280-c2cc-11de-8d13-0010c6dffd0f',
107
+ display: 'Provider',
108
+ links: [],
109
+ },
110
+ ],
111
+ retired: false,
112
+ locale: 'en_GB',
113
+ allowedLocales: ['en_GB'],
114
+ },
115
+ sessionId: 'D4F7D4D4-6A6D-4D4D-8D4D-4D4D4D4D4D4D',
116
+ },
117
+ };
@@ -0,0 +1,11 @@
1
+ // In __mocks__/single-spa-react.js
2
+ //import context from "../src/view-components/widget/testHelpers";
3
+ const React = require("react");
4
+ //const context = require("../src/view-components/widget/testHelpers");
5
+
6
+ const SingleSpaContext = React.createContext({ mountParcel: () => jest.fn() });
7
+
8
+ //constexport default mock;
9
+ module.exports = {
10
+ SingleSpaContext: SingleSpaContext
11
+ };