@olaboot/esm-form-engine-lib 4.1.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.
- package/LICENSE.txt +401 -0
- package/README.md +202 -0
- package/dist/adapters/control-adapter.d.ts +3 -0
- package/dist/adapters/control-adapter.d.ts.map +1 -0
- package/dist/adapters/control-adapter.js +17 -0
- package/dist/adapters/encounter-datetime-adapter.d.ts +3 -0
- package/dist/adapters/encounter-datetime-adapter.d.ts.map +1 -0
- package/dist/adapters/encounter-datetime-adapter.js +26 -0
- package/dist/adapters/encounter-diagnosis-adapter.d.ts +10 -0
- package/dist/adapters/encounter-diagnosis-adapter.d.ts.map +1 -0
- package/dist/adapters/encounter-diagnosis-adapter.js +89 -0
- package/dist/adapters/encounter-diagnosis-adapter.test.js +217 -0
- package/dist/adapters/encounter-location-adapter.d.ts +3 -0
- package/dist/adapters/encounter-location-adapter.d.ts.map +1 -0
- package/dist/adapters/encounter-location-adapter.js +25 -0
- package/dist/adapters/encounter-provider-adapter.d.ts +3 -0
- package/dist/adapters/encounter-provider-adapter.d.ts.map +1 -0
- package/dist/adapters/encounter-provider-adapter.js +34 -0
- package/dist/adapters/encounter-role-adapter.d.ts +3 -0
- package/dist/adapters/encounter-role-adapter.d.ts.map +1 -0
- package/dist/adapters/encounter-role-adapter.js +40 -0
- package/dist/adapters/inline-date-adapter.d.ts +3 -0
- package/dist/adapters/inline-date-adapter.d.ts.map +1 -0
- package/dist/adapters/inline-date-adapter.js +56 -0
- package/dist/adapters/obs-adapter.d.ts +29 -0
- package/dist/adapters/obs-adapter.d.ts.map +1 -0
- package/dist/adapters/obs-adapter.js +284 -0
- package/dist/adapters/obs-adapter.test.js +1443 -0
- package/dist/adapters/obs-comment-adapter.d.ts +4 -0
- package/dist/adapters/obs-comment-adapter.d.ts.map +1 -0
- package/dist/adapters/obs-comment-adapter.js +52 -0
- package/dist/adapters/orders-adapter.d.ts +4 -0
- package/dist/adapters/orders-adapter.d.ts.map +1 -0
- package/dist/adapters/orders-adapter.js +64 -0
- package/dist/adapters/patient-identifier-adapter.d.ts +3 -0
- package/dist/adapters/patient-identifier-adapter.d.ts.map +1 -0
- package/dist/adapters/patient-identifier-adapter.js +40 -0
- package/dist/adapters/person-attribute-adapter.d.ts +3 -0
- package/dist/adapters/person-attribute-adapter.d.ts.map +1 -0
- package/dist/adapters/person-attribute-adapter.js +39 -0
- package/dist/adapters/person-attribute-adapter.test.js +146 -0
- package/dist/adapters/program-state-adapter.d.ts +3 -0
- package/dist/adapters/program-state-adapter.d.ts.map +1 -0
- package/dist/adapters/program-state-adapter.js +41 -0
- package/dist/adapters/program-state-adapter.test.js +411 -0
- package/dist/api/index.d.ts +27 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +170 -0
- package/dist/components/error/error-modal.component.d.ts +7 -0
- package/dist/components/error/error-modal.component.d.ts.map +1 -0
- package/dist/components/error/error-modal.component.js +31 -0
- package/dist/components/error/error.scss +4 -0
- package/dist/components/extension/extension-parcel.component.d.ts +5 -0
- package/dist/components/extension/extension-parcel.component.d.ts.map +1 -0
- package/dist/components/extension/extension-parcel.component.js +35 -0
- package/dist/components/field-label/field-label.component.d.ts +12 -0
- package/dist/components/field-label/field-label.component.d.ts.map +1 -0
- package/dist/components/field-label/field-label.component.js +33 -0
- package/dist/components/field-label/field-label.scss +15 -0
- package/dist/components/group/obs-group.component.d.ts +5 -0
- package/dist/components/group/obs-group.component.d.ts.map +1 -0
- package/dist/components/group/obs-group.component.js +48 -0
- package/dist/components/group/obs-group.scss +16 -0
- package/dist/components/inputs/content-switcher/content-switcher.component.d.ts +5 -0
- package/dist/components/inputs/content-switcher/content-switcher.component.d.ts.map +1 -0
- package/dist/components/inputs/content-switcher/content-switcher.component.js +70 -0
- package/dist/components/inputs/content-switcher/content-switcher.scss +55 -0
- package/dist/components/inputs/date/date.component.d.ts +5 -0
- package/dist/components/inputs/date/date.component.d.ts.map +1 -0
- package/dist/components/inputs/date/date.component.js +125 -0
- package/dist/components/inputs/date/date.scss +37 -0
- package/dist/components/inputs/date/date.test.js +85 -0
- package/dist/components/inputs/file/file-thumbnail.component.d.ts +10 -0
- package/dist/components/inputs/file/file-thumbnail.component.d.ts.map +1 -0
- package/dist/components/inputs/file/file-thumbnail.component.js +51 -0
- package/dist/components/inputs/file/file-thumbnail.scss +42 -0
- package/dist/components/inputs/file/file.component.d.ts +5 -0
- package/dist/components/inputs/file/file.component.d.ts.map +1 -0
- package/dist/components/inputs/file/file.component.js +90 -0
- package/dist/components/inputs/file/file.scss +21 -0
- package/dist/components/inputs/fixed-value/fixed-value.component.d.ts +5 -0
- package/dist/components/inputs/fixed-value/fixed-value.component.d.ts.map +1 -0
- package/dist/components/inputs/fixed-value/fixed-value.component.js +14 -0
- package/dist/components/inputs/markdown/markdown-wrapper.component.d.ts +6 -0
- package/dist/components/inputs/markdown/markdown-wrapper.component.d.ts.map +1 -0
- package/dist/components/inputs/markdown/markdown-wrapper.component.js +20 -0
- package/dist/components/inputs/markdown/markdown.component.d.ts +5 -0
- package/dist/components/inputs/markdown/markdown.component.d.ts.map +1 -0
- package/dist/components/inputs/markdown/markdown.component.js +26 -0
- package/dist/components/inputs/multi-select/multi-select.component.d.ts +5 -0
- package/dist/components/inputs/multi-select/multi-select.component.d.ts.map +1 -0
- package/dist/components/inputs/multi-select/multi-select.component.js +134 -0
- package/dist/components/inputs/multi-select/multi-select.scss +25 -0
- package/dist/components/inputs/multi-select/multi-select.test.js +106 -0
- package/dist/components/inputs/number/number.component.d.ts +5 -0
- package/dist/components/inputs/number/number.component.d.ts.map +1 -0
- package/dist/components/inputs/number/number.component.js +77 -0
- package/dist/components/inputs/number/number.scss +15 -0
- package/dist/components/inputs/number/number.test.js +98 -0
- package/dist/components/inputs/radio/radio.component.d.ts +5 -0
- package/dist/components/inputs/radio/radio.component.d.ts.map +1 -0
- package/dist/components/inputs/radio/radio.component.js +69 -0
- package/dist/components/inputs/radio/radio.scss +36 -0
- package/dist/components/inputs/radio/radio.test.js +190 -0
- package/dist/components/inputs/select/dropdown.component.d.ts +5 -0
- package/dist/components/inputs/select/dropdown.component.d.ts.map +1 -0
- package/dist/components/inputs/select/dropdown.component.js +82 -0
- package/dist/components/inputs/select/dropdown.scss +11 -0
- package/dist/components/inputs/select/dropdown.test.js +157 -0
- package/dist/components/inputs/text/text.component.d.ts +5 -0
- package/dist/components/inputs/text/text.component.d.ts.map +1 -0
- package/dist/components/inputs/text/text.component.js +62 -0
- package/dist/components/inputs/text/text.scss +15 -0
- package/dist/components/inputs/text/text.test.js +184 -0
- package/dist/components/inputs/text-area/text-area.component.d.ts +5 -0
- package/dist/components/inputs/text-area/text-area.component.d.ts.map +1 -0
- package/dist/components/inputs/text-area/text-area.component.js +60 -0
- package/dist/components/inputs/text-area/text-area.scss +11 -0
- package/dist/components/inputs/toggle/toggle.component.d.ts +5 -0
- package/dist/components/inputs/toggle/toggle.component.d.ts.map +1 -0
- package/dist/components/inputs/toggle/toggle.component.js +57 -0
- package/dist/components/inputs/toggle/toggle.scss +12 -0
- package/dist/components/inputs/ui-select-extended/ui-select-extended.component.d.ts +5 -0
- package/dist/components/inputs/ui-select-extended/ui-select-extended.component.d.ts.map +1 -0
- package/dist/components/inputs/ui-select-extended/ui-select-extended.component.js +203 -0
- package/dist/components/inputs/ui-select-extended/ui-select-extended.scss +19 -0
- package/dist/components/inputs/ui-select-extended/ui-select-extended.test.js +250 -0
- package/dist/components/inputs/unspecified/unspecified.component.d.ts +11 -0
- package/dist/components/inputs/unspecified/unspecified.component.d.ts.map +1 -0
- package/dist/components/inputs/unspecified/unspecified.component.js +65 -0
- package/dist/components/inputs/unspecified/unspecified.scss +7 -0
- package/dist/components/inputs/unspecified/unspecified.test.js +152 -0
- package/dist/components/inputs/workspace-launcher/workspace-launcher.component.d.ts +5 -0
- package/dist/components/inputs/workspace-launcher/workspace-launcher.component.d.ts.map +1 -0
- package/dist/components/inputs/workspace-launcher/workspace-launcher.component.js +64 -0
- package/dist/components/inputs/workspace-launcher/workspace-launcher.scss +21 -0
- package/dist/components/inputs/workspace-launcher/workspace-launcher.test.js +174 -0
- package/dist/components/label/label.component.d.ts +8 -0
- package/dist/components/label/label.component.d.ts.map +1 -0
- package/dist/components/label/label.component.js +15 -0
- package/dist/components/label/label.scss +15 -0
- package/dist/components/loaders/loader.component.d.ts +4 -0
- package/dist/components/loaders/loader.component.d.ts.map +1 -0
- package/dist/components/loaders/loader.component.js +14 -0
- package/dist/components/loaders/loader.scss +20 -0
- package/dist/components/patient-banner/patient-banner.component.d.ts +7 -0
- package/dist/components/patient-banner/patient-banner.component.d.ts.map +1 -0
- package/dist/components/patient-banner/patient-banner.component.js +16 -0
- package/dist/components/patient-banner/patient-banner.scss +12 -0
- package/dist/components/previous-value-review/previous-value-review.component.d.ts +12 -0
- package/dist/components/previous-value-review/previous-value-review.component.d.ts.map +1 -0
- package/dist/components/previous-value-review/previous-value-review.component.js +29 -0
- package/dist/components/previous-value-review/previous-value-review.scss +36 -0
- package/dist/components/processor-factory/form-processor-factory.component.d.ts +10 -0
- package/dist/components/processor-factory/form-processor-factory.component.d.ts.map +1 -0
- package/dist/components/processor-factory/form-processor-factory.component.js +114 -0
- package/dist/components/renderer/custom-hooks-renderer.component.d.ts +13 -0
- package/dist/components/renderer/custom-hooks-renderer.component.d.ts.map +1 -0
- package/dist/components/renderer/custom-hooks-renderer.component.js +13 -0
- package/dist/components/renderer/field/fieldLogic.d.ts +16 -0
- package/dist/components/renderer/field/fieldLogic.d.ts.map +1 -0
- package/dist/components/renderer/field/fieldLogic.js +238 -0
- package/dist/components/renderer/field/fieldLogic.test.js +140 -0
- package/dist/components/renderer/field/fieldRenderUtils.d.ts +9 -0
- package/dist/components/renderer/field/fieldRenderUtils.d.ts.map +1 -0
- package/dist/components/renderer/field/fieldRenderUtils.js +8 -0
- package/dist/components/renderer/field/fieldRenderUtils.test.js +51 -0
- package/dist/components/renderer/field/form-field-renderer.component.d.ts +19 -0
- package/dist/components/renderer/field/form-field-renderer.component.d.ts.map +1 -0
- package/dist/components/renderer/field/form-field-renderer.component.js +214 -0
- package/dist/components/renderer/field/form-field-renderer.scss +5 -0
- package/dist/components/renderer/form/form-renderer.component.d.ts +10 -0
- package/dist/components/renderer/form/form-renderer.component.d.ts.map +1 -0
- package/dist/components/renderer/form/form-renderer.component.js +102 -0
- package/dist/components/renderer/form/state.d.ts +41 -0
- package/dist/components/renderer/form/state.d.ts.map +1 -0
- package/dist/components/renderer/form/state.js +69 -0
- package/dist/components/renderer/page/page.renderer.component.d.ts +9 -0
- package/dist/components/renderer/page/page.renderer.component.d.ts.map +1 -0
- package/dist/components/renderer/page/page.renderer.component.js +85 -0
- package/dist/components/renderer/page/page.renderer.scss +74 -0
- package/dist/components/renderer/section/section-renderer.component.d.ts +6 -0
- package/dist/components/renderer/section/section-renderer.component.d.ts.map +1 -0
- package/dist/components/renderer/section/section-renderer.component.js +20 -0
- package/dist/components/renderer/section/section-renderer.scss +19 -0
- package/dist/components/repeat/helpers.d.ts +6 -0
- package/dist/components/repeat/helpers.d.ts.map +1 -0
- package/dist/components/repeat/helpers.js +64 -0
- package/dist/components/repeat/helpers.test.js +25 -0
- package/dist/components/repeat/repeat-controls.component.d.ts +12 -0
- package/dist/components/repeat/repeat-controls.component.d.ts.map +1 -0
- package/dist/components/repeat/repeat-controls.component.js +22 -0
- package/dist/components/repeat/repeat-controls.scss +7 -0
- package/dist/components/repeat/repeat.component.d.ts +5 -0
- package/dist/components/repeat/repeat.component.d.ts.map +1 -0
- package/dist/components/repeat/repeat.component.js +185 -0
- package/dist/components/repeat/repeat.scss +30 -0
- package/dist/components/repeat/repeat.test.js +25 -0
- package/dist/components/sidebar/page-observer.d.ts +20 -0
- package/dist/components/sidebar/page-observer.d.ts.map +1 -0
- package/dist/components/sidebar/page-observer.js +60 -0
- package/dist/components/sidebar/sidebar.component.d.ts +14 -0
- package/dist/components/sidebar/sidebar.component.d.ts.map +1 -0
- package/dist/components/sidebar/sidebar.component.js +77 -0
- package/dist/components/sidebar/sidebar.scss +114 -0
- package/dist/components/sidebar/useCurrentActivePage.d.ts +34 -0
- package/dist/components/sidebar/useCurrentActivePage.d.ts.map +1 -0
- package/dist/components/sidebar/useCurrentActivePage.js +114 -0
- package/dist/components/sidebar/useCurrentActivePage.test.js +208 -0
- package/dist/components/sidebar/usePageObserver.d.ts +11 -0
- package/dist/components/sidebar/usePageObserver.d.ts.map +1 -0
- package/dist/components/sidebar/usePageObserver.js +42 -0
- package/dist/components/value/value.component.d.ts +6 -0
- package/dist/components/value/value.component.d.ts.map +1 -0
- package/dist/components/value/value.component.js +24 -0
- package/dist/components/value/value.scss +17 -0
- package/dist/components/value/view/field-value-view.component.d.ts +10 -0
- package/dist/components/value/view/field-value-view.component.d.ts.map +1 -0
- package/dist/components/value/view/field-value-view.component.js +29 -0
- package/dist/components/value/view/field-value-view.scss +31 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +13 -0
- package/dist/datasources/concept-data-source.d.ts +6 -0
- package/dist/datasources/concept-data-source.d.ts.map +1 -0
- package/dist/datasources/concept-data-source.js +35 -0
- package/dist/datasources/data-source.d.ts +10 -0
- package/dist/datasources/data-source.d.ts.map +1 -0
- package/dist/datasources/data-source.js +41 -0
- package/dist/datasources/encounter-role-datasource.d.ts +6 -0
- package/dist/datasources/encounter-role-datasource.d.ts.map +1 -0
- package/dist/datasources/encounter-role-datasource.js +13 -0
- package/dist/datasources/historical-data-source.d.ts +6 -0
- package/dist/datasources/historical-data-source.d.ts.map +1 -0
- package/dist/datasources/historical-data-source.js +24 -0
- package/dist/datasources/location-data-source.d.ts +6 -0
- package/dist/datasources/location-data-source.d.ts.map +1 -0
- package/dist/datasources/location-data-source.js +24 -0
- package/dist/datasources/provider-datasource.d.ts +6 -0
- package/dist/datasources/provider-datasource.d.ts.map +1 -0
- package/dist/datasources/provider-datasource.js +13 -0
- package/dist/datasources/select-concept-answers-datasource.d.ts +9 -0
- package/dist/datasources/select-concept-answers-datasource.d.ts.map +1 -0
- package/dist/datasources/select-concept-answers-datasource.js +19 -0
- package/dist/declarations.d.js +0 -0
- package/dist/external-function-context.d.ts +7 -0
- package/dist/external-function-context.d.ts.map +1 -0
- package/dist/external-function-context.js +2 -0
- package/dist/form-engine.component.d.ts +23 -0
- package/dist/form-engine.component.d.ts.map +1 -0
- package/dist/form-engine.component.js +174 -0
- package/dist/form-engine.scss +148 -0
- package/dist/form-engine.test.js +1253 -0
- package/dist/globals.d.ts +3 -0
- package/dist/globals.d.ts.map +1 -0
- package/dist/globals.js +2 -0
- package/dist/hooks/useConcepts.d.ts +23 -0
- package/dist/hooks/useConcepts.d.ts.map +1 -0
- package/dist/hooks/useConcepts.js +31 -0
- package/dist/hooks/useDataSourceDependentValue.d.ts +4 -0
- package/dist/hooks/useDataSourceDependentValue.d.ts.map +1 -0
- package/dist/hooks/useDataSourceDependentValue.js +14 -0
- package/dist/hooks/useEncounter.d.ts +7 -0
- package/dist/hooks/useEncounter.d.ts.map +1 -0
- package/dist/hooks/useEncounter.js +38 -0
- package/dist/hooks/useEncounterRole.d.ts +7 -0
- package/dist/hooks/useEncounterRole.d.ts.map +1 -0
- package/dist/hooks/useEncounterRole.js +18 -0
- package/dist/hooks/useEvaluateFormFieldExpressions.d.ts +7 -0
- package/dist/hooks/useEvaluateFormFieldExpressions.d.ts.map +1 -0
- package/dist/hooks/useEvaluateFormFieldExpressions.js +112 -0
- package/dist/hooks/useExternalFormAction.d.ts +43 -0
- package/dist/hooks/useExternalFormAction.d.ts.map +1 -0
- package/dist/hooks/useExternalFormAction.js +71 -0
- package/dist/hooks/useFormCollapse.d.ts +6 -0
- package/dist/hooks/useFormCollapse.d.ts.map +1 -0
- package/dist/hooks/useFormCollapse.js +35 -0
- package/dist/hooks/useFormFieldValidators.d.ts +3 -0
- package/dist/hooks/useFormFieldValidators.d.ts.map +1 -0
- package/dist/hooks/useFormFieldValidators.js +20 -0
- package/dist/hooks/useFormFieldValueAdapters.d.ts +3 -0
- package/dist/hooks/useFormFieldValueAdapters.d.ts.map +1 -0
- package/dist/hooks/useFormFieldValueAdapters.js +21 -0
- package/dist/hooks/useFormFields.d.ts +6 -0
- package/dist/hooks/useFormFields.d.ts.map +1 -0
- package/dist/hooks/useFormFields.js +62 -0
- package/dist/hooks/useFormFieldsMeta.d.ts +4 -0
- package/dist/hooks/useFormFieldsMeta.d.ts.map +1 -0
- package/dist/hooks/useFormFieldsMeta.js +42 -0
- package/dist/hooks/useFormJson.d.ts +19 -0
- package/dist/hooks/useFormJson.d.ts.map +1 -0
- package/dist/hooks/useFormJson.js +198 -0
- package/dist/hooks/useFormJson.test.js +194 -0
- package/dist/hooks/useFormStateHelpers.d.ts +15 -0
- package/dist/hooks/useFormStateHelpers.d.ts.map +1 -0
- package/dist/hooks/useFormStateHelpers.js +83 -0
- package/dist/hooks/useFormWorkspaceSize.d.ts +7 -0
- package/dist/hooks/useFormWorkspaceSize.d.ts.map +1 -0
- package/dist/hooks/useFormWorkspaceSize.js +46 -0
- package/dist/hooks/useFormWorkspaceSize.test.js +141 -0
- package/dist/hooks/useInitialValues.d.ts +9 -0
- package/dist/hooks/useInitialValues.d.ts.map +1 -0
- package/dist/hooks/useInitialValues.js +29 -0
- package/dist/hooks/useInitialValues.test.js +78 -0
- package/dist/hooks/usePatientData.d.ts +6 -0
- package/dist/hooks/usePatientData.d.ts.map +1 -0
- package/dist/hooks/usePatientData.js +30 -0
- package/dist/hooks/usePatientPrograms.d.ts +7 -0
- package/dist/hooks/usePatientPrograms.d.ts.map +1 -0
- package/dist/hooks/usePatientPrograms.js +22 -0
- package/dist/hooks/usePostSubmissionActions.d.ts +13 -0
- package/dist/hooks/usePostSubmissionActions.d.ts.map +1 -0
- package/dist/hooks/usePostSubmissionActions.js +23 -0
- package/dist/hooks/usePostSubmissionActions.test.js +55 -0
- package/dist/hooks/useProcessorDependencies.d.ts +8 -0
- package/dist/hooks/useProcessorDependencies.d.ts.map +1 -0
- package/dist/hooks/useProcessorDependencies.js +33 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/lifecycle.d.ts +11 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +25 -0
- package/dist/post-submission-actions/mark-patient-deceased-action.d.ts +4 -0
- package/dist/post-submission-actions/mark-patient-deceased-action.d.ts.map +1 -0
- package/dist/post-submission-actions/mark-patient-deceased-action.js +53 -0
- package/dist/post-submission-actions/program-enrollment-action.d.ts +4 -0
- package/dist/post-submission-actions/program-enrollment-action.d.ts.map +1 -0
- package/dist/post-submission-actions/program-enrollment-action.js +105 -0
- package/dist/processors/encounter/encounter-form-processor.d.ts +26 -0
- package/dist/processors/encounter/encounter-form-processor.d.ts.map +1 -0
- package/dist/processors/encounter/encounter-form-processor.js +376 -0
- package/dist/processors/encounter/encounter-form-processor.test.js +207 -0
- package/dist/processors/encounter/encounter-processor-helper.d.ts +19 -0
- package/dist/processors/encounter/encounter-processor-helper.d.ts.map +1 -0
- package/dist/processors/encounter/encounter-processor-helper.js +293 -0
- package/dist/processors/form-processor.d.ts +25 -0
- package/dist/processors/form-processor.d.ts.map +1 -0
- package/dist/processors/form-processor.js +26 -0
- package/dist/provider/form-factory-helper.d.ts +8 -0
- package/dist/provider/form-factory-helper.d.ts.map +1 -0
- package/dist/provider/form-factory-helper.js +73 -0
- package/dist/provider/form-factory-provider.d.ts +48 -0
- package/dist/provider/form-factory-provider.d.ts.map +1 -0
- package/dist/provider/form-factory-provider.js +136 -0
- package/dist/provider/form-provider.d.ts +26 -0
- package/dist/provider/form-provider.d.ts.map +1 -0
- package/dist/provider/form-provider.js +17 -0
- package/dist/registry/inbuilt-components/InbuiltPostSubmissionActions.d.ts +4 -0
- package/dist/registry/inbuilt-components/InbuiltPostSubmissionActions.d.ts.map +1 -0
- package/dist/registry/inbuilt-components/InbuiltPostSubmissionActions.js +10 -0
- package/dist/registry/inbuilt-components/control-templates.d.ts +4 -0
- package/dist/registry/inbuilt-components/control-templates.d.ts.map +1 -0
- package/dist/registry/inbuilt-components/control-templates.js +54 -0
- package/dist/registry/inbuilt-components/inbuiltControls.d.ts +7 -0
- package/dist/registry/inbuilt-components/inbuiltControls.d.ts.map +1 -0
- package/dist/registry/inbuilt-components/inbuiltControls.js +94 -0
- package/dist/registry/inbuilt-components/inbuiltDataSources.d.ts +8 -0
- package/dist/registry/inbuilt-components/inbuiltDataSources.d.ts.map +1 -0
- package/dist/registry/inbuilt-components/inbuiltDataSources.js +36 -0
- package/dist/registry/inbuilt-components/inbuiltFieldValueAdapters.d.ts +4 -0
- package/dist/registry/inbuilt-components/inbuiltFieldValueAdapters.d.ts.map +1 -0
- package/dist/registry/inbuilt-components/inbuiltFieldValueAdapters.js +71 -0
- package/dist/registry/inbuilt-components/inbuiltTransformers.d.ts +4 -0
- package/dist/registry/inbuilt-components/inbuiltTransformers.d.ts.map +1 -0
- package/dist/registry/inbuilt-components/inbuiltTransformers.js +7 -0
- package/dist/registry/inbuilt-components/inbuiltValidators.d.ts +7 -0
- package/dist/registry/inbuilt-components/inbuiltValidators.d.ts.map +1 -0
- package/dist/registry/inbuilt-components/inbuiltValidators.js +29 -0
- package/dist/registry/inbuilt-components/template-component-map.d.ts +5 -0
- package/dist/registry/inbuilt-components/template-component-map.d.ts.map +1 -0
- package/dist/registry/inbuilt-components/template-component-map.js +27 -0
- package/dist/registry/registry.d.ts +61 -0
- package/dist/registry/registry.d.ts.map +1 -0
- package/dist/registry/registry.js +184 -0
- package/dist/registry/registry.test.js +17 -0
- package/dist/setup-tests.js +30 -0
- package/dist/transformers/default-schema-transformer.d.ts +4 -0
- package/dist/transformers/default-schema-transformer.d.ts.map +1 -0
- package/dist/transformers/default-schema-transformer.js +308 -0
- package/dist/transformers/default-schema-transformer.test.js +319 -0
- package/dist/types/domain.d.ts +219 -0
- package/dist/types/domain.d.ts.map +1 -0
- package/dist/types/domain.js +1 -0
- package/dist/types/index.d.ts +126 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/schema.d.ts +243 -0
- package/dist/types/schema.d.ts.map +1 -0
- package/dist/types/schema.js +1 -0
- package/dist/typings.d.js +1 -0
- package/dist/utils/boolean-utils.d.ts +13 -0
- package/dist/utils/boolean-utils.d.ts.map +1 -0
- package/dist/utils/boolean-utils.js +22 -0
- package/dist/utils/common-expression-helpers.d.ts +261 -0
- package/dist/utils/common-expression-helpers.d.ts.map +1 -0
- package/dist/utils/common-expression-helpers.js +538 -0
- package/dist/utils/common-expression-helpers.test.js +461 -0
- package/dist/utils/common-utils.d.ts +51 -0
- package/dist/utils/common-utils.d.ts.map +1 -0
- package/dist/utils/common-utils.js +102 -0
- package/dist/utils/common-utils.test.js +134 -0
- package/dist/utils/error-utils.d.ts +11 -0
- package/dist/utils/error-utils.d.ts.map +1 -0
- package/dist/utils/error-utils.js +34 -0
- package/dist/utils/expression-runner.d.ts +25 -0
- package/dist/utils/expression-runner.d.ts.map +1 -0
- package/dist/utils/expression-runner.js +104 -0
- package/dist/utils/expression-runner.test.js +362 -0
- package/dist/utils/form-helper.d.ts +37 -0
- package/dist/utils/form-helper.d.ts.map +1 -0
- package/dist/utils/form-helper.js +239 -0
- package/dist/utils/form-helper.test.js +638 -0
- package/dist/utils/form-page-utils.d.ts +3 -0
- package/dist/utils/form-page-utils.d.ts.map +1 -0
- package/dist/utils/form-page-utils.js +10 -0
- package/dist/utils/forms-loader.d.ts +45 -0
- package/dist/utils/forms-loader.d.ts.map +1 -0
- package/dist/utils/forms-loader.js +246 -0
- package/dist/utils/forms-loader.test.js +333 -0
- package/dist/utils/post-submission-action-helper.d.ts +2 -0
- package/dist/utils/post-submission-action-helper.d.ts.map +1 -0
- package/dist/utils/post-submission-action-helper.js +57 -0
- package/dist/utils/test-utils.js +66 -0
- package/dist/utils/zscore-service.d.ts +6 -0
- package/dist/utils/zscore-service.d.ts.map +1 -0
- package/dist/utils/zscore-service.js +54 -0
- package/dist/validators/conditional-answered-validator.d.ts +3 -0
- package/dist/validators/conditional-answered-validator.d.ts.map +1 -0
- package/dist/validators/conditional-answered-validator.js +18 -0
- package/dist/validators/conditional-answered-validator.test.js +63 -0
- package/dist/validators/date-validator.d.ts +3 -0
- package/dist/validators/date-validator.d.ts.map +1 -0
- package/dist/validators/date-validator.js +21 -0
- package/dist/validators/date-validator.test.js +53 -0
- package/dist/validators/default-value-validator.d.ts +3 -0
- package/dist/validators/default-value-validator.d.ts.map +1 -0
- package/dist/validators/default-value-validator.js +46 -0
- package/dist/validators/default-value-validator.test.js +95 -0
- package/dist/validators/form-validator.d.ts +9 -0
- package/dist/validators/form-validator.d.ts.map +1 -0
- package/dist/validators/form-validator.js +82 -0
- package/dist/validators/form-validator.test.js +158 -0
- package/dist/validators/js-expression-validator.d.ts +3 -0
- package/dist/validators/js-expression-validator.d.ts.map +1 -0
- package/dist/validators/js-expression-validator.js +25 -0
- package/dist/validators/js-expression-validator.test.js +115 -0
- package/dist/validators/schema.d.ts +1 -0
- package/dist/validators/schema.d.ts.map +1 -0
- package/dist/validators/schema.js +32 -0
- package/dist/zscore/bfa_boys_5_above.json +2522 -0
- package/dist/zscore/bfa_girls_5_above.json +2522 -0
- package/dist/zscore/hfa_boys_5_above.json +2186 -0
- package/dist/zscore/hfa_boys_below5.json +22286 -0
- package/dist/zscore/hfa_girls_5_above.json +2186 -0
- package/dist/zscore/hfa_girls_below5.json +22286 -0
- package/dist/zscore/wfl_boys_below5.json +7814 -0
- package/dist/zscore/wfl_girls_below5.json +7814 -0
- package/dist/zscore-tests/bmi-age.test.js +84 -0
- package/dist/zscore-tests/height-age.test.js +88 -0
- package/dist/zscore-tests/weight-height.test.js +82 -0
- package/package.json +105 -0
- package/src/adapters/control-adapter.ts +29 -0
- package/src/adapters/encounter-datetime-adapter.ts +38 -0
- package/src/adapters/encounter-diagnosis-adapter.ts +121 -0
- package/src/adapters/encounter-location-adapter.ts +39 -0
- package/src/adapters/encounter-provider-adapter.ts +48 -0
- package/src/adapters/encounter-role-adapter.ts +54 -0
- package/src/adapters/inline-date-adapter.ts +59 -0
- package/src/adapters/obs-adapter.ts +349 -0
- package/src/adapters/obs-comment-adapter.ts +61 -0
- package/src/adapters/orders-adapter.ts +82 -0
- package/src/adapters/patient-identifier-adapter.ts +46 -0
- package/src/adapters/person-attribute-adapter.ts +45 -0
- package/src/adapters/program-state-adapter.ts +57 -0
- package/src/api/index.ts +224 -0
- package/src/components/error/error-modal.component.tsx +37 -0
- package/src/components/error/error.scss +4 -0
- package/src/components/extension/extension-parcel.component.tsx +32 -0
- package/src/components/field-label/field-label.component.tsx +55 -0
- package/src/components/field-label/field-label.scss +15 -0
- package/src/components/group/obs-group.component.tsx +59 -0
- package/src/components/group/obs-group.scss +16 -0
- package/src/components/inputs/content-switcher/content-switcher.component.tsx +81 -0
- package/src/components/inputs/content-switcher/content-switcher.scss +55 -0
- package/src/components/inputs/date/date.component.tsx +141 -0
- package/src/components/inputs/date/date.scss +37 -0
- package/src/components/inputs/file/file-thumbnail.component.tsx +55 -0
- package/src/components/inputs/file/file-thumbnail.scss +42 -0
- package/src/components/inputs/file/file.component.tsx +98 -0
- package/src/components/inputs/file/file.scss +21 -0
- package/src/components/inputs/fixed-value/fixed-value.component.tsx +19 -0
- package/src/components/inputs/markdown/markdown-wrapper.component.tsx +14 -0
- package/src/components/inputs/markdown/markdown.component.tsx +24 -0
- package/src/components/inputs/multi-select/multi-select.component.tsx +152 -0
- package/src/components/inputs/multi-select/multi-select.scss +25 -0
- package/src/components/inputs/number/number.component.tsx +85 -0
- package/src/components/inputs/number/number.scss +15 -0
- package/src/components/inputs/radio/radio.component.tsx +81 -0
- package/src/components/inputs/radio/radio.scss +36 -0
- package/src/components/inputs/select/dropdown.component.tsx +86 -0
- package/src/components/inputs/select/dropdown.scss +11 -0
- package/src/components/inputs/text/text.component.tsx +67 -0
- package/src/components/inputs/text/text.scss +15 -0
- package/src/components/inputs/text-area/text-area.component.tsx +63 -0
- package/src/components/inputs/text-area/text-area.scss +11 -0
- package/src/components/inputs/toggle/toggle.component.tsx +66 -0
- package/src/components/inputs/toggle/toggle.scss +12 -0
- package/src/components/inputs/ui-select-extended/ui-select-extended.component.tsx +208 -0
- package/src/components/inputs/ui-select-extended/ui-select-extended.scss +19 -0
- package/src/components/inputs/unspecified/unspecified.component.tsx +84 -0
- package/src/components/inputs/unspecified/unspecified.scss +7 -0
- package/src/components/inputs/workspace-launcher/workspace-launcher.component.tsx +80 -0
- package/src/components/inputs/workspace-launcher/workspace-launcher.scss +21 -0
- package/src/components/label/label.component.tsx +20 -0
- package/src/components/label/label.scss +15 -0
- package/src/components/loaders/loader.component.tsx +16 -0
- package/src/components/loaders/loader.scss +20 -0
- package/src/components/patient-banner/patient-banner.component.tsx +20 -0
- package/src/components/patient-banner/patient-banner.scss +12 -0
- package/src/components/previous-value-review/previous-value-review.component.tsx +49 -0
- package/src/components/previous-value-review/previous-value-review.scss +36 -0
- package/src/components/processor-factory/form-processor-factory.component.tsx +128 -0
- package/src/components/renderer/custom-hooks-renderer.component.tsx +30 -0
- package/src/components/renderer/field/fieldLogic.ts +314 -0
- package/src/components/renderer/field/fieldRenderUtils.ts +16 -0
- package/src/components/renderer/field/form-field-renderer.component.tsx +291 -0
- package/src/components/renderer/field/form-field-renderer.scss +5 -0
- package/src/components/renderer/form/form-renderer.component.tsx +123 -0
- package/src/components/renderer/form/state.ts +59 -0
- package/src/components/renderer/page/page.renderer.component.tsx +120 -0
- package/src/components/renderer/page/page.renderer.scss +74 -0
- package/src/components/renderer/section/section-renderer.component.tsx +25 -0
- package/src/components/renderer/section/section-renderer.scss +19 -0
- package/src/components/repeat/helpers.ts +77 -0
- package/src/components/repeat/repeat-controls.component.tsx +38 -0
- package/src/components/repeat/repeat-controls.scss +7 -0
- package/src/components/repeat/repeat.component.tsx +206 -0
- package/src/components/repeat/repeat.scss +30 -0
- package/src/components/sidebar/page-observer.ts +58 -0
- package/src/components/sidebar/sidebar.component.tsx +121 -0
- package/src/components/sidebar/sidebar.scss +114 -0
- package/src/components/sidebar/useCurrentActivePage.ts +137 -0
- package/src/components/sidebar/usePageObserver.ts +45 -0
- package/src/components/value/value.component.tsx +30 -0
- package/src/components/value/value.scss +17 -0
- package/src/components/value/view/field-value-view.component.tsx +36 -0
- package/src/components/value/view/field-value-view.scss +31 -0
- package/src/constants.ts +14 -0
- package/src/datasources/concept-data-source.ts +42 -0
- package/src/datasources/data-source.ts +34 -0
- package/src/datasources/encounter-role-datasource.ts +15 -0
- package/src/datasources/historical-data-source.ts +11 -0
- package/src/datasources/location-data-source.ts +27 -0
- package/src/datasources/provider-datasource.ts +15 -0
- package/src/datasources/select-concept-answers-datasource.ts +25 -0
- package/src/declarations.d.ts +2 -0
- package/src/external-function-context.tsx +8 -0
- package/src/form-engine.component.tsx +222 -0
- package/src/form-engine.scss +148 -0
- package/src/globals.ts +2 -0
- package/src/hooks/useConcepts.ts +58 -0
- package/src/hooks/useDataSourceDependentValue.ts +16 -0
- package/src/hooks/useEncounter.ts +40 -0
- package/src/hooks/useEncounterRole.ts +15 -0
- package/src/hooks/useEvaluateFormFieldExpressions.ts +152 -0
- package/src/hooks/useExternalFormAction.ts +94 -0
- package/src/hooks/useFormCollapse.ts +36 -0
- package/src/hooks/useFormFieldValidators.ts +22 -0
- package/src/hooks/useFormFieldValueAdapters.ts +23 -0
- package/src/hooks/useFormFields.ts +65 -0
- package/src/hooks/useFormFieldsMeta.ts +48 -0
- package/src/hooks/useFormJson.ts +257 -0
- package/src/hooks/useFormStateHelpers.ts +72 -0
- package/src/hooks/useFormWorkspaceSize.ts +52 -0
- package/src/hooks/useInitialValues.ts +39 -0
- package/src/hooks/usePatientData.ts +32 -0
- package/src/hooks/usePatientPrograms.ts +38 -0
- package/src/hooks/usePostSubmissionActions.ts +31 -0
- package/src/hooks/useProcessorDependencies.ts +42 -0
- package/src/index.ts +11 -0
- package/src/lifecycle.ts +32 -0
- package/src/post-submission-actions/mark-patient-deceased-action.ts +68 -0
- package/src/post-submission-actions/program-enrollment-action.ts +137 -0
- package/src/processors/encounter/encounter-form-processor.ts +445 -0
- package/src/processors/encounter/encounter-processor-helper.ts +387 -0
- package/src/processors/form-processor.ts +40 -0
- package/src/provider/form-factory-helper.ts +106 -0
- package/src/provider/form-factory-provider.tsx +211 -0
- package/src/provider/form-provider.tsx +39 -0
- package/src/registry/inbuilt-components/InbuiltPostSubmissionActions.ts +13 -0
- package/src/registry/inbuilt-components/control-templates.ts +57 -0
- package/src/registry/inbuilt-components/inbuiltControls.ts +99 -0
- package/src/registry/inbuilt-components/inbuiltDataSources.ts +41 -0
- package/src/registry/inbuilt-components/inbuiltFieldValueAdapters.ts +74 -0
- package/src/registry/inbuilt-components/inbuiltTransformers.ts +10 -0
- package/src/registry/inbuilt-components/inbuiltValidators.ts +33 -0
- package/src/registry/inbuilt-components/template-component-map.ts +28 -0
- package/src/registry/registry.ts +290 -0
- package/src/transformers/default-schema-transformer.ts +340 -0
- package/src/types/domain.ts +237 -0
- package/src/types/index.ts +153 -0
- package/src/types/schema.ts +259 -0
- package/src/typings.d.ts +9 -0
- package/src/utils/boolean-utils.ts +25 -0
- package/src/utils/common-expression-helpers.ts +636 -0
- package/src/utils/common-utils.ts +108 -0
- package/src/utils/error-utils.ts +37 -0
- package/src/utils/expression-runner.ts +172 -0
- package/src/utils/form-helper.ts +283 -0
- package/src/utils/form-page-utils.ts +13 -0
- package/src/utils/forms-loader.ts +306 -0
- package/src/utils/post-submission-action-helper.ts +71 -0
- package/src/utils/zscore-service.ts +59 -0
- package/src/validators/conditional-answered-validator.ts +17 -0
- package/src/validators/date-validator.ts +19 -0
- package/src/validators/default-value-validator.ts +36 -0
- package/src/validators/form-validator.ts +95 -0
- package/src/validators/js-expression-validator.ts +44 -0
- package/src/validators/schema.ts +34 -0
- package/src/zscore/bfa_boys_5_above.json +2522 -0
- package/src/zscore/bfa_girls_5_above.json +2522 -0
- package/src/zscore/hfa_boys_5_above.json +2186 -0
- package/src/zscore/hfa_boys_below5.json +22286 -0
- package/src/zscore/hfa_girls_5_above.json +2186 -0
- package/src/zscore/hfa_girls_below5.json +22286 -0
- package/src/zscore/wfl_boys_below5.json +7814 -0
- package/src/zscore/wfl_girls_below5.json +7814 -0
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import { ProgramStateAdapter } from "./program-state-adapter.js";
|
|
2
|
+
const formContext = {
|
|
3
|
+
methods: null,
|
|
4
|
+
workspaceLayout: 'maximized',
|
|
5
|
+
isSubmitting: false,
|
|
6
|
+
patient: {
|
|
7
|
+
id: '833db896-c1f0-11eb-8529-0242ac130003'
|
|
8
|
+
},
|
|
9
|
+
formJson: null,
|
|
10
|
+
visit: null,
|
|
11
|
+
sessionMode: 'enter',
|
|
12
|
+
sessionDate: new Date(),
|
|
13
|
+
location: {
|
|
14
|
+
uuid: '41e6e516-c1f0-11eb-8529-0242ac130003'
|
|
15
|
+
},
|
|
16
|
+
currentProvider: null,
|
|
17
|
+
layoutType: 'small-desktop',
|
|
18
|
+
domainObjectValue: {
|
|
19
|
+
uuid: '873455da-3ec4-453c-b565-7c1fe35426be',
|
|
20
|
+
obs: []
|
|
21
|
+
},
|
|
22
|
+
previousDomainObjectValue: null,
|
|
23
|
+
processor: null,
|
|
24
|
+
formFields: [],
|
|
25
|
+
formFieldAdapters: null,
|
|
26
|
+
formFieldValidators: null,
|
|
27
|
+
customDependencies: {
|
|
28
|
+
patientPrograms: []
|
|
29
|
+
},
|
|
30
|
+
deletedFields: [],
|
|
31
|
+
getFormField: jest.fn(),
|
|
32
|
+
addFormField: jest.fn(),
|
|
33
|
+
updateFormField: jest.fn(),
|
|
34
|
+
removeFormField: ()=>{},
|
|
35
|
+
addInvalidField: jest.fn(),
|
|
36
|
+
removeInvalidField: jest.fn(),
|
|
37
|
+
setInvalidFields: jest.fn(),
|
|
38
|
+
setForm: jest.fn(),
|
|
39
|
+
setDeletedFields: jest.fn()
|
|
40
|
+
};
|
|
41
|
+
const field = {
|
|
42
|
+
label: 'HIV Enrollment Initial State',
|
|
43
|
+
type: 'programState',
|
|
44
|
+
required: false,
|
|
45
|
+
id: 'hivEnrollmentInitialState',
|
|
46
|
+
questionOptions: {
|
|
47
|
+
rendering: 'select',
|
|
48
|
+
answers: [
|
|
49
|
+
{
|
|
50
|
+
value: '7293cb90-c93f-4386-b32f-e8cfc633dc3e',
|
|
51
|
+
label: 'Example Option 1'
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
value: 'c26a8cc7-fb07-4b2f-bdb0-730db9ce0020',
|
|
55
|
+
label: 'Example Option 2'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
value: '29a513f0-2810-4356-98f5-42b12f7013a5',
|
|
59
|
+
label: 'Example Option 3'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
value: '7c0a5653-313f-4564-b9cf-d59adf1173dc',
|
|
63
|
+
label: 'On Antiretrovirals Treatment'
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
programUuid: '64f950e6-1b07-4ac0-8e7e-f3e148f3463f',
|
|
67
|
+
workflowUuid: '70921392-4e3e-5465-978d-45b68b7def5f'
|
|
68
|
+
},
|
|
69
|
+
meta: {
|
|
70
|
+
submission: {}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const patientPrograms = [
|
|
74
|
+
{
|
|
75
|
+
uuid: 'c0dd89a7-62d5-40ed-850a-d3b1709ea7f2',
|
|
76
|
+
display: 'HIV Care and Treatment',
|
|
77
|
+
program: {
|
|
78
|
+
uuid: '64f950e6-1b07-4ac0-8e7e-f3e148f3463f',
|
|
79
|
+
name: 'HIV Care and Treatment',
|
|
80
|
+
allWorkflows: [
|
|
81
|
+
{
|
|
82
|
+
uuid: '70921392-4e3e-5465-978d-45b68b7def5f',
|
|
83
|
+
concept: {
|
|
84
|
+
uuid: '7dc379f6-1725-11ed-861d-0242ac120002',
|
|
85
|
+
display: 'HIV treatment status',
|
|
86
|
+
links: [
|
|
87
|
+
{
|
|
88
|
+
rel: 'self',
|
|
89
|
+
uri: 'http://dev3.openmrs.org/openmrs/ws/rest/v1/concept/7dc379f6-1725-11ed-861d-0242ac120002',
|
|
90
|
+
resourceAlias: 'concept'
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
description: null,
|
|
95
|
+
retired: false,
|
|
96
|
+
states: [
|
|
97
|
+
{
|
|
98
|
+
uuid: '7293cb90-c93f-4386-b32f-e8cfc633dc3e',
|
|
99
|
+
description: null,
|
|
100
|
+
retired: false,
|
|
101
|
+
concept: {
|
|
102
|
+
uuid: 'acc6f157-c9a5-4690-b814-e653cbf80b4c',
|
|
103
|
+
display: 'Example Option 1',
|
|
104
|
+
name: {
|
|
105
|
+
display: 'Example Option 1',
|
|
106
|
+
uuid: '51d0d6c4-0361-479e-aec4-b40ee82fb23c',
|
|
107
|
+
name: 'Example Option 1',
|
|
108
|
+
locale: 'en',
|
|
109
|
+
localePreferred: true,
|
|
110
|
+
conceptNameType: 'FULLY_SPECIFIED',
|
|
111
|
+
links: [],
|
|
112
|
+
resourceVersion: '1.9'
|
|
113
|
+
},
|
|
114
|
+
datatype: {
|
|
115
|
+
uuid: '8d4a4c94-c2cc-11de-8d13-0010c6dffd0f',
|
|
116
|
+
display: 'N/A',
|
|
117
|
+
links: []
|
|
118
|
+
},
|
|
119
|
+
conceptClass: {
|
|
120
|
+
uuid: '8d492774-c2cc-11de-8d13-0010c6dffd0f',
|
|
121
|
+
display: 'Misc',
|
|
122
|
+
links: []
|
|
123
|
+
},
|
|
124
|
+
set: false,
|
|
125
|
+
version: null,
|
|
126
|
+
retired: false,
|
|
127
|
+
names: [
|
|
128
|
+
{
|
|
129
|
+
uuid: '51d0d6c4-0361-479e-aec4-b40ee82fb23c',
|
|
130
|
+
display: 'Example Option 1',
|
|
131
|
+
links: []
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
descriptions: [],
|
|
135
|
+
mappings: [],
|
|
136
|
+
answers: [],
|
|
137
|
+
setMembers: [],
|
|
138
|
+
attributes: [],
|
|
139
|
+
links: [],
|
|
140
|
+
resourceVersion: '2.0'
|
|
141
|
+
},
|
|
142
|
+
links: [
|
|
143
|
+
{
|
|
144
|
+
rel: 'self',
|
|
145
|
+
uri: 'http://dev3.openmrs.org/openmrs/ws/rest/v1/workflow/70921392-4e3e-5465-978d-45b68b7def5f/state/7293cb90-c93f-4386-b32f-e8cfc633dc3e',
|
|
146
|
+
resourceAlias: 'state'
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
rel: 'full',
|
|
150
|
+
uri: 'http://dev3.openmrs.org/openmrs/ws/rest/v1/workflow/70921392-4e3e-5465-978d-45b68b7def5f/state/7293cb90-c93f-4386-b32f-e8cfc633dc3e?v=full',
|
|
151
|
+
resourceAlias: 'state'
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
resourceVersion: '1.8'
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
uuid: 'c26a8cc7-fb07-4b2f-bdb0-730db9ce0020',
|
|
158
|
+
description: null,
|
|
159
|
+
retired: false,
|
|
160
|
+
concept: {
|
|
161
|
+
uuid: '4f2f8cd9-e57c-4bcd-822f-0dfabb684bc1',
|
|
162
|
+
display: 'Example Option 2',
|
|
163
|
+
name: {
|
|
164
|
+
display: 'Example Option 2',
|
|
165
|
+
uuid: 'd0934337-68bd-47ff-83f7-075c8d15f31c',
|
|
166
|
+
name: 'Example Option 2',
|
|
167
|
+
locale: 'en',
|
|
168
|
+
localePreferred: true,
|
|
169
|
+
conceptNameType: 'FULLY_SPECIFIED',
|
|
170
|
+
links: [],
|
|
171
|
+
resourceVersion: '1.9'
|
|
172
|
+
},
|
|
173
|
+
datatype: {
|
|
174
|
+
uuid: '8d4a4c94-c2cc-11de-8d13-0010c6dffd0f',
|
|
175
|
+
display: 'N/A',
|
|
176
|
+
links: []
|
|
177
|
+
},
|
|
178
|
+
conceptClass: {
|
|
179
|
+
uuid: '8d492774-c2cc-11de-8d13-0010c6dffd0f',
|
|
180
|
+
display: 'Misc',
|
|
181
|
+
links: []
|
|
182
|
+
},
|
|
183
|
+
set: false,
|
|
184
|
+
version: null,
|
|
185
|
+
retired: false,
|
|
186
|
+
names: [
|
|
187
|
+
{
|
|
188
|
+
uuid: 'd0934337-68bd-47ff-83f7-075c8d15f31c',
|
|
189
|
+
display: 'Example Option 2',
|
|
190
|
+
links: []
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
descriptions: [],
|
|
194
|
+
mappings: [],
|
|
195
|
+
answers: [],
|
|
196
|
+
setMembers: [],
|
|
197
|
+
attributes: [],
|
|
198
|
+
links: [],
|
|
199
|
+
resourceVersion: '2.0'
|
|
200
|
+
},
|
|
201
|
+
links: [],
|
|
202
|
+
resourceVersion: '1.8'
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
uuid: '7c0a5653-313f-4564-b9cf-d59adf1173dc',
|
|
206
|
+
description: null,
|
|
207
|
+
retired: false,
|
|
208
|
+
concept: {
|
|
209
|
+
uuid: '7dc37bb8-1725-11ed-861d-0242ac120002',
|
|
210
|
+
display: 'On Antiretrovirals Treatment',
|
|
211
|
+
name: {
|
|
212
|
+
display: 'On Antiretrovirals Treatment',
|
|
213
|
+
uuid: 'c90ed5f3-4c4d-303b-b8bd-d6b5d21c0f81',
|
|
214
|
+
name: 'On Antiretrovirals Treatment',
|
|
215
|
+
locale: 'en',
|
|
216
|
+
localePreferred: true,
|
|
217
|
+
conceptNameType: 'FULLY_SPECIFIED',
|
|
218
|
+
links: [],
|
|
219
|
+
resourceVersion: '1.9'
|
|
220
|
+
},
|
|
221
|
+
datatype: {
|
|
222
|
+
uuid: '8d4a4c94-c2cc-11de-8d13-0010c6dffd0f',
|
|
223
|
+
display: 'N/A',
|
|
224
|
+
links: []
|
|
225
|
+
},
|
|
226
|
+
conceptClass: {
|
|
227
|
+
uuid: '8d492774-c2cc-11de-8d13-0010c6dffd0f',
|
|
228
|
+
display: 'Misc',
|
|
229
|
+
links: []
|
|
230
|
+
},
|
|
231
|
+
set: false,
|
|
232
|
+
version: null,
|
|
233
|
+
retired: false,
|
|
234
|
+
names: [
|
|
235
|
+
{
|
|
236
|
+
uuid: 'c90ed5f3-4c4d-303b-b8bd-d6b5d21c0f81',
|
|
237
|
+
display: 'On Antiretrovirals Treatment',
|
|
238
|
+
links: []
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
uuid: '3d61609a-30e1-3dd1-83a0-21310b06c388',
|
|
242
|
+
display: 'On Antiretrovirals',
|
|
243
|
+
links: []
|
|
244
|
+
}
|
|
245
|
+
],
|
|
246
|
+
descriptions: [
|
|
247
|
+
{
|
|
248
|
+
uuid: '07fc6455-9ffa-4848-a4bc-e58ffb91503a',
|
|
249
|
+
display: 'On Antiretrovirals Treatment program workflow state',
|
|
250
|
+
links: []
|
|
251
|
+
}
|
|
252
|
+
],
|
|
253
|
+
mappings: [
|
|
254
|
+
{
|
|
255
|
+
uuid: 'fffc1802-f832-49ef-bfaa-0ffe4bc7db0f',
|
|
256
|
+
display: 'SNOMED MVP: OATT',
|
|
257
|
+
links: []
|
|
258
|
+
}
|
|
259
|
+
],
|
|
260
|
+
answers: [],
|
|
261
|
+
setMembers: [],
|
|
262
|
+
attributes: [],
|
|
263
|
+
links: [],
|
|
264
|
+
resourceVersion: '2.0'
|
|
265
|
+
},
|
|
266
|
+
links: [],
|
|
267
|
+
resourceVersion: '1.8'
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
uuid: '29a513f0-2810-4356-98f5-42b12f7013a5',
|
|
271
|
+
description: null,
|
|
272
|
+
retired: false,
|
|
273
|
+
concept: {
|
|
274
|
+
uuid: 'e1ad9977-c106-4116-9f23-45258b7e306b',
|
|
275
|
+
display: 'Example Option 3',
|
|
276
|
+
name: {
|
|
277
|
+
display: 'Example Option 3',
|
|
278
|
+
uuid: '988af00b-6243-4fc2-9d81-718bc9bbe743',
|
|
279
|
+
name: 'Example Option 3',
|
|
280
|
+
locale: 'en',
|
|
281
|
+
localePreferred: true,
|
|
282
|
+
conceptNameType: 'FULLY_SPECIFIED',
|
|
283
|
+
links: [],
|
|
284
|
+
resourceVersion: '1.9'
|
|
285
|
+
},
|
|
286
|
+
datatype: {
|
|
287
|
+
uuid: '8d4a4c94-c2cc-11de-8d13-0010c6dffd0f',
|
|
288
|
+
display: 'N/A',
|
|
289
|
+
links: []
|
|
290
|
+
},
|
|
291
|
+
conceptClass: {
|
|
292
|
+
uuid: '8d492774-c2cc-11de-8d13-0010c6dffd0f',
|
|
293
|
+
display: 'Misc',
|
|
294
|
+
links: []
|
|
295
|
+
},
|
|
296
|
+
set: false,
|
|
297
|
+
version: null,
|
|
298
|
+
retired: false,
|
|
299
|
+
names: [
|
|
300
|
+
{
|
|
301
|
+
uuid: '988af00b-6243-4fc2-9d81-718bc9bbe743',
|
|
302
|
+
display: 'Example Option 3',
|
|
303
|
+
links: [
|
|
304
|
+
{
|
|
305
|
+
rel: 'self',
|
|
306
|
+
uri: 'http://dev3.openmrs.org/openmrs/ws/rest/v1/concept/e1ad9977-c106-4116-9f23-45258b7e306b/name/988af00b-6243-4fc2-9d81-718bc9bbe743',
|
|
307
|
+
resourceAlias: 'name'
|
|
308
|
+
}
|
|
309
|
+
]
|
|
310
|
+
}
|
|
311
|
+
],
|
|
312
|
+
descriptions: [],
|
|
313
|
+
mappings: [],
|
|
314
|
+
answers: [],
|
|
315
|
+
setMembers: [],
|
|
316
|
+
attributes: [],
|
|
317
|
+
links: [],
|
|
318
|
+
resourceVersion: '2.0'
|
|
319
|
+
},
|
|
320
|
+
links: [],
|
|
321
|
+
resourceVersion: '1.8'
|
|
322
|
+
}
|
|
323
|
+
],
|
|
324
|
+
links: [],
|
|
325
|
+
resourceVersion: '1.8'
|
|
326
|
+
}
|
|
327
|
+
]
|
|
328
|
+
},
|
|
329
|
+
dateEnrolled: '2024-09-23T09:31:51.000+0000',
|
|
330
|
+
dateCompleted: null,
|
|
331
|
+
location: null,
|
|
332
|
+
states: [
|
|
333
|
+
{
|
|
334
|
+
startDate: '2024-09-23T00:00:00.000+0000',
|
|
335
|
+
endDate: null,
|
|
336
|
+
state: {
|
|
337
|
+
uuid: '7293cb90-c93f-4386-b32f-e8cfc633dc3e',
|
|
338
|
+
name: null,
|
|
339
|
+
retired: false,
|
|
340
|
+
concept: {
|
|
341
|
+
uuid: 'acc6f157-c9a5-4690-b814-e653cbf80b4c'
|
|
342
|
+
},
|
|
343
|
+
programWorkflow: {
|
|
344
|
+
uuid: '70921392-4e3e-5465-978d-45b68b7def5f'
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
]
|
|
349
|
+
}
|
|
350
|
+
];
|
|
351
|
+
describe('ProgramStateAdapter', ()=>{
|
|
352
|
+
// new submission (enter mode)
|
|
353
|
+
it('should handle submission for a program state', ()=>{
|
|
354
|
+
const value = '7293cb90-c93f-4386-b32f-e8cfc633dc3e';
|
|
355
|
+
ProgramStateAdapter.transformFieldValue(field, value, formContext);
|
|
356
|
+
expect(field.meta.submission.newValue).toEqual({
|
|
357
|
+
state: value,
|
|
358
|
+
startDate: expect.any(String)
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
it('should return null if the new value is the same as the previous value', ()=>{
|
|
362
|
+
field.meta.initialValue = {
|
|
363
|
+
omrsObject: {
|
|
364
|
+
uuid: '7293cb90-c93f-4386-b32f-e8cfc633dc3e'
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
const value = '7293cb90-c93f-4386-b32f-e8cfc633dc3e';
|
|
368
|
+
const result = ProgramStateAdapter.transformFieldValue(field, value, formContext);
|
|
369
|
+
expect(result).toBeNull();
|
|
370
|
+
expect(field.meta.submission.newValue).toBeNull();
|
|
371
|
+
});
|
|
372
|
+
it('should return null if the new value is empty or null', ()=>{
|
|
373
|
+
const value = null;
|
|
374
|
+
const result = ProgramStateAdapter.transformFieldValue(field, value, formContext);
|
|
375
|
+
expect(result).toBeNull();
|
|
376
|
+
expect(field.meta.submission.newValue).toBeNull();
|
|
377
|
+
});
|
|
378
|
+
it('should get initial value for the program state', async ()=>{
|
|
379
|
+
formContext.customDependencies.patientPrograms.push(...patientPrograms);
|
|
380
|
+
const program = await ProgramStateAdapter.getInitialValue(field, null, formContext);
|
|
381
|
+
expect(program).toEqual('7293cb90-c93f-4386-b32f-e8cfc633dc3e');
|
|
382
|
+
});
|
|
383
|
+
it('should return null if no active state is found for the patient program', async ()=>{
|
|
384
|
+
formContext.customDependencies.patientPrograms = [
|
|
385
|
+
{
|
|
386
|
+
...patientPrograms[0],
|
|
387
|
+
states: []
|
|
388
|
+
}
|
|
389
|
+
];
|
|
390
|
+
const p = await ProgramStateAdapter.getInitialValue(field, null, formContext);
|
|
391
|
+
expect(p).toBeNull();
|
|
392
|
+
});
|
|
393
|
+
it('should return null if no patient program matches the programUuid', async ()=>{
|
|
394
|
+
const fieldWithDifferentProgramUuid = {
|
|
395
|
+
...field,
|
|
396
|
+
questionOptions: {
|
|
397
|
+
...field.questionOptions,
|
|
398
|
+
programUuid: 'non-existing-uuid'
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
const program = await ProgramStateAdapter.getInitialValue(fieldWithDifferentProgramUuid, null, formContext);
|
|
402
|
+
expect(program).toBeNull();
|
|
403
|
+
});
|
|
404
|
+
it('should return null for getPreviousValue', async ()=>{
|
|
405
|
+
const previousValue = await ProgramStateAdapter.getPreviousValue(field, null, formContext);
|
|
406
|
+
expect(previousValue).toBeNull();
|
|
407
|
+
});
|
|
408
|
+
it('should execute tearDown without issues', ()=>{
|
|
409
|
+
expect(()=>ProgramStateAdapter.tearDown()).not.toThrow();
|
|
410
|
+
});
|
|
411
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { TFunction } from 'i18next';
|
|
2
|
+
import type { AttachmentFieldValue, FHIRObsResource, OpenmrsForm, PatientDeathPayload, PatientIdentifier, PatientProgramPayload, PersonAttribute } from '../types';
|
|
3
|
+
export declare function saveEncounter(abortController: AbortController, payload: any, encounterUuid?: string): Promise<import("@openmrs/esm-framework").FetchResponse<any>>;
|
|
4
|
+
export declare function createAttachment(patientUuid: string, encounterUUID: string, attachment: AttachmentFieldValue): Promise<import("@openmrs/esm-framework").FetchResponse<any>>;
|
|
5
|
+
export declare function getConcept(conceptUuid: string, v: string): Promise<any>;
|
|
6
|
+
export declare function getLocationsByTag(tag: string): Promise<any>;
|
|
7
|
+
export declare function getAllLocations(): Promise<any>;
|
|
8
|
+
export declare function getPreviousEncounter(patientUuid: string, encounterType: string): Promise<any>;
|
|
9
|
+
export declare function getLatestObs(patientUuid: string, conceptUuid: string, encounterTypeUuid?: string): Promise<FHIRObsResource>;
|
|
10
|
+
/**
|
|
11
|
+
* Fetches an OpenMRS form using either its name or UUID.
|
|
12
|
+
* @param {string} nameOrUUID - The form's name or UUID.
|
|
13
|
+
* @returns {Promise<OpenmrsForm | null>} - A Promise that resolves to the fetched OpenMRS form or null if not found.
|
|
14
|
+
*/
|
|
15
|
+
export declare function fetchOpenMRSForm(nameOrUUID: string): Promise<OpenmrsForm | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Fetches ClobData for a given OpenMRS form.
|
|
18
|
+
* @param {OpenmrsForm} form - The OpenMRS form object.
|
|
19
|
+
* @returns {Promise<any | null>} - A Promise that resolves to the fetched ClobData or null if not found.
|
|
20
|
+
*/
|
|
21
|
+
export declare function fetchClobData(form: OpenmrsForm): Promise<any | null>;
|
|
22
|
+
export declare function getPatientEnrolledPrograms(patientUuid: string): Promise<any>;
|
|
23
|
+
export declare function saveProgramEnrollment(payload: PatientProgramPayload, abortController: AbortController): Promise<import("@openmrs/esm-framework").FetchResponse<any>>;
|
|
24
|
+
export declare function savePatientIdentifier(patientIdentifier: PatientIdentifier, patientUuid: string): Promise<import("@openmrs/esm-framework").FetchResponse<any>>;
|
|
25
|
+
export declare function savePersonAttribute(personAttribute: PersonAttribute, patientUuid: string): Promise<import("@openmrs/esm-framework").FetchResponse<any>>;
|
|
26
|
+
export declare function markPatientAsDeceased(t: TFunction, patientUUID: string, payload: PatientDeathPayload, abortController: AbortController): Promise<import("@openmrs/esm-framework").FetchResponse<any>>;
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EAChB,MAAM,UAAU,CAAC;AAGlB,wBAAgB,aAAa,CAAC,eAAe,EAAE,eAAe,EAAE,OAAO,KAAA,EAAE,aAAa,CAAC,EAAE,MAAM,gEAa9F;AAED,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,gEAoBlH;AAED,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,gBAExD;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,gBAE5C;AAED,wBAAgB,eAAe,iBAE9B;AAED,wBAAsB,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,gBASpF;AAED,wBAAsB,YAAY,CAChC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,iBAAiB,CAAC,EAAE,MAAM,GACzB,OAAO,CAAC,eAAe,CAAC,CAQ1B;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAqBtF;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,CAc1E;AAGD,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,gBAS7D;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,eAAe,gEAarG;AAED,wBAAgB,qBAAqB,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,gEAgB9F;AAED,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gEAgBxF;AAED,wBAAgB,qBAAqB,CACnC,CAAC,EAAE,SAAS,EACZ,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,mBAAmB,EAC5B,eAAe,EAAE,eAAe,gEAmBjC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { attachmentUrl, fhirBaseUrl, openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
|
|
2
|
+
import { encounterRepresentation } from "../constants.js";
|
|
3
|
+
import { isUuid } from "../utils/boolean-utils.js";
|
|
4
|
+
export function saveEncounter(abortController, payload, encounterUuid) {
|
|
5
|
+
const url = encounterUuid ? `${restBaseUrl}/encounter/${encounterUuid}?v=${encounterRepresentation}` : `${restBaseUrl}/encounter?v=${encounterRepresentation}`;
|
|
6
|
+
return openmrsFetch(url, {
|
|
7
|
+
headers: {
|
|
8
|
+
'Content-Type': 'application/json'
|
|
9
|
+
},
|
|
10
|
+
method: 'POST',
|
|
11
|
+
body: payload,
|
|
12
|
+
signal: abortController.signal
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export async function createAttachment(patientUuid, encounterUUID, attachment) {
|
|
16
|
+
const formData = new FormData();
|
|
17
|
+
formData.append('fileCaption', attachment.fileDescription);
|
|
18
|
+
formData.append('patient', patientUuid);
|
|
19
|
+
if (attachment.file) {
|
|
20
|
+
formData.append('file', attachment.file, attachment.fileName);
|
|
21
|
+
} else {
|
|
22
|
+
formData.append('file', new File([
|
|
23
|
+
''
|
|
24
|
+
], attachment.fileName), attachment.fileName);
|
|
25
|
+
formData.append('base64Content', attachment.base64Content);
|
|
26
|
+
}
|
|
27
|
+
formData.append('encounter', encounterUUID);
|
|
28
|
+
formData.append('formFieldNamespace', attachment.formFieldNamespace);
|
|
29
|
+
formData.append('formFieldPath', attachment.formFieldPath);
|
|
30
|
+
return openmrsFetch(`${attachmentUrl}`, {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
body: formData
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export function getConcept(conceptUuid, v) {
|
|
36
|
+
return openmrsFetch(`${restBaseUrl}/concept/${conceptUuid}?v=${v}`).then(({ data })=>data.results);
|
|
37
|
+
}
|
|
38
|
+
export function getLocationsByTag(tag) {
|
|
39
|
+
return openmrsFetch(`${restBaseUrl}/location?tag=${tag}&v=custom:(uuid,display)`).then(({ data })=>data.results);
|
|
40
|
+
}
|
|
41
|
+
export function getAllLocations() {
|
|
42
|
+
return openmrsFetch(`${restBaseUrl}/location?v=custom:(uuid,display)`).then(({ data })=>data.results);
|
|
43
|
+
}
|
|
44
|
+
export async function getPreviousEncounter(patientUuid, encounterType) {
|
|
45
|
+
const query = `patient=${patientUuid}&_sort=-date&_count=1&type=${encounterType}`;
|
|
46
|
+
let response = await openmrsFetch(`${fhirBaseUrl}/Encounter?${query}`);
|
|
47
|
+
if (response?.data?.entry?.length) {
|
|
48
|
+
const latestEncounter = response.data.entry[0].resource.id;
|
|
49
|
+
response = await openmrsFetch(`${restBaseUrl}/encounter/${latestEncounter}?v=${encounterRepresentation}`);
|
|
50
|
+
return response.data;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
export async function getLatestObs(patientUuid, conceptUuid, encounterTypeUuid) {
|
|
55
|
+
let params = `patient=${patientUuid}&code=${conceptUuid}${encounterTypeUuid ? `&encounter.type=${encounterTypeUuid}` : ''}`;
|
|
56
|
+
// the latest obs
|
|
57
|
+
params += '&_sort=-date&_count=1';
|
|
58
|
+
const { data } = await openmrsFetch(`${fhirBaseUrl}/Observation?${params}`);
|
|
59
|
+
return data.entry?.length ? data.entry[0].resource : null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Fetches an OpenMRS form using either its name or UUID.
|
|
63
|
+
* @param {string} nameOrUUID - The form's name or UUID.
|
|
64
|
+
* @returns {Promise<OpenmrsForm | null>} - A Promise that resolves to the fetched OpenMRS form or null if not found.
|
|
65
|
+
*/ export async function fetchOpenMRSForm(nameOrUUID) {
|
|
66
|
+
if (!nameOrUUID) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const { url, isUUID } = isUuid(nameOrUUID) ? {
|
|
70
|
+
url: `${restBaseUrl}/form/${nameOrUUID}?v=full`,
|
|
71
|
+
isUUID: true
|
|
72
|
+
} : {
|
|
73
|
+
url: `${restBaseUrl}/form?q=${nameOrUUID}&v=full`,
|
|
74
|
+
isUUID: false
|
|
75
|
+
};
|
|
76
|
+
const { data: openmrsFormResponse } = await openmrsFetch(url);
|
|
77
|
+
if (isUUID) {
|
|
78
|
+
return openmrsFormResponse;
|
|
79
|
+
}
|
|
80
|
+
if (openmrsFormResponse.results?.length) {
|
|
81
|
+
const form = openmrsFormResponse.results.find((form)=>form.retired === false);
|
|
82
|
+
if (form) {
|
|
83
|
+
return form;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
throw new Error(`Form with ID "${nameOrUUID}" was not found`);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Fetches ClobData for a given OpenMRS form.
|
|
90
|
+
* @param {OpenmrsForm} form - The OpenMRS form object.
|
|
91
|
+
* @returns {Promise<any | null>} - A Promise that resolves to the fetched ClobData or null if not found.
|
|
92
|
+
*/ export async function fetchClobData(form) {
|
|
93
|
+
if (!form) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
const jsonSchemaResource = form.resources?.find(({ name })=>name === 'JSON schema');
|
|
97
|
+
if (!jsonSchemaResource) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const clobDataUrl = `${restBaseUrl}/clobdata/${jsonSchemaResource.valueReference}`;
|
|
101
|
+
const { data: clobDataResponse } = await openmrsFetch(clobDataUrl);
|
|
102
|
+
return clobDataResponse;
|
|
103
|
+
}
|
|
104
|
+
// Program Enrollment
|
|
105
|
+
export function getPatientEnrolledPrograms(patientUuid) {
|
|
106
|
+
return openmrsFetch(`${restBaseUrl}/programenrollment?patient=${patientUuid}&v=custom:(uuid,display,program:(uuid,name,allWorkflows),dateEnrolled,dateCompleted,location:(uuid,display),states:(state:(uuid,name,concept:(uuid),programWorkflow:(uuid)))`).then(({ data })=>{
|
|
107
|
+
if (data) {
|
|
108
|
+
return data;
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
export function saveProgramEnrollment(payload, abortController) {
|
|
114
|
+
if (!payload) {
|
|
115
|
+
throw new Error('Program enrollment cannot be created because no payload is supplied');
|
|
116
|
+
}
|
|
117
|
+
const url = payload.uuid ? `${restBaseUrl}/programenrollment/${payload.uuid}` : `${restBaseUrl}/programenrollment`;
|
|
118
|
+
return openmrsFetch(url, {
|
|
119
|
+
method: 'POST',
|
|
120
|
+
headers: {
|
|
121
|
+
'Content-Type': 'application/json'
|
|
122
|
+
},
|
|
123
|
+
body: payload,
|
|
124
|
+
signal: abortController.signal
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
export function savePatientIdentifier(patientIdentifier, patientUuid) {
|
|
128
|
+
let url;
|
|
129
|
+
if (patientIdentifier.uuid) {
|
|
130
|
+
url = `${restBaseUrl}/patient/${patientUuid}/identifier/${patientIdentifier.uuid}`;
|
|
131
|
+
} else {
|
|
132
|
+
url = `${restBaseUrl}/patient/${patientUuid}/identifier`;
|
|
133
|
+
}
|
|
134
|
+
return openmrsFetch(url, {
|
|
135
|
+
headers: {
|
|
136
|
+
'Content-Type': 'application/json'
|
|
137
|
+
},
|
|
138
|
+
method: 'POST',
|
|
139
|
+
body: JSON.stringify(patientIdentifier)
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
export function savePersonAttribute(personAttribute, patientUuid) {
|
|
143
|
+
let url;
|
|
144
|
+
if (personAttribute.uuid) {
|
|
145
|
+
url = `${restBaseUrl}/person/${patientUuid}/attribute/${personAttribute.uuid}`;
|
|
146
|
+
} else {
|
|
147
|
+
url = `${restBaseUrl}/person/${patientUuid}/attribute`;
|
|
148
|
+
}
|
|
149
|
+
return openmrsFetch(url, {
|
|
150
|
+
headers: {
|
|
151
|
+
'Content-Type': 'application/json'
|
|
152
|
+
},
|
|
153
|
+
method: 'POST',
|
|
154
|
+
body: personAttribute
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
export function markPatientAsDeceased(t, patientUUID, payload, abortController) {
|
|
158
|
+
if (!payload) {
|
|
159
|
+
throw new Error(t('patientCannotBeMarkedAsDeceasedBecauseNoPayloadSupplied', 'Patient cannot be marked as deceased because no payload is supplied'));
|
|
160
|
+
}
|
|
161
|
+
const url = `${restBaseUrl}/person/${patientUUID}`;
|
|
162
|
+
return openmrsFetch(url, {
|
|
163
|
+
method: 'POST',
|
|
164
|
+
headers: {
|
|
165
|
+
'Content-Type': 'application/json'
|
|
166
|
+
},
|
|
167
|
+
body: payload,
|
|
168
|
+
signal: abortController.signal
|
|
169
|
+
});
|
|
170
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-modal.component.d.ts","sourceRoot":"","sources":["../../../src/components/error/error-modal.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,MAAM,EAAE,gBAAgB,EAAE,CAAA;CAAE,CA2BxD,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { InlineNotification } from "@carbon/react";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { fieldRequiredErrCode, fieldOutOfBoundErrCode } from "../../validators/form-validator.js";
|
|
5
|
+
import styles from "./error.scss";
|
|
6
|
+
const ErrorModal = ({ errors })=>{
|
|
7
|
+
const { t } = useTranslation();
|
|
8
|
+
const errorMessage = useMemo(()=>{
|
|
9
|
+
const errorMessages = {};
|
|
10
|
+
errors.forEach((error)=>{
|
|
11
|
+
if (error?.errCode === fieldRequiredErrCode && !errorMessages[fieldRequiredErrCode]) {
|
|
12
|
+
errorMessages[fieldRequiredErrCode] = t('nullMandatoryField', 'Please fill the required fields');
|
|
13
|
+
} else if (error?.errCode === fieldOutOfBoundErrCode && !errorMessages[fieldOutOfBoundErrCode]) {
|
|
14
|
+
errorMessages[fieldOutOfBoundErrCode] = t('valuesOutOfBound', 'Some of the values are out of bounds');
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return Object.values(errorMessages).join(', ');
|
|
18
|
+
}, [
|
|
19
|
+
errors,
|
|
20
|
+
t
|
|
21
|
+
]);
|
|
22
|
+
return /*#__PURE__*/ React.createElement(InlineNotification, {
|
|
23
|
+
role: "alert",
|
|
24
|
+
className: styles.inlineErrorMessage,
|
|
25
|
+
kind: "error",
|
|
26
|
+
lowContrast: true,
|
|
27
|
+
title: t('fieldErrorDescriptionTitle', 'Validation Errors'),
|
|
28
|
+
subtitle: errorMessage
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
export default ErrorModal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-parcel.component.d.ts","sourceRoot":"","sources":["../../../src/components/extension/extension-parcel.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAGlD,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGvD,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAuBlD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|