@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,141 @@
|
|
|
1
|
+
import { act } from "react";
|
|
2
|
+
import { renderHook } from "@testing-library/react";
|
|
3
|
+
import { useFormWorkspaceSize } from "./useFormWorkspaceSize.js";
|
|
4
|
+
// Mock the pxToRem utility
|
|
5
|
+
jest.mock('../utils/common-utils', ()=>({
|
|
6
|
+
pxToRem: (px)=>px / 16
|
|
7
|
+
}));
|
|
8
|
+
describe('useFormWorkspaceSize', ()=>{
|
|
9
|
+
let ref;
|
|
10
|
+
let parentElement;
|
|
11
|
+
let resizeCallback;
|
|
12
|
+
let originalResizeObserver;
|
|
13
|
+
beforeEach(()=>{
|
|
14
|
+
// Create DOM elements
|
|
15
|
+
parentElement = document.createElement('div');
|
|
16
|
+
const element = document.createElement('div');
|
|
17
|
+
parentElement.appendChild(element);
|
|
18
|
+
// ref
|
|
19
|
+
ref = {
|
|
20
|
+
current: element
|
|
21
|
+
};
|
|
22
|
+
// Mock offsetWidth getter
|
|
23
|
+
Object.defineProperty(parentElement, 'offsetWidth', {
|
|
24
|
+
configurable: true,
|
|
25
|
+
value: 400
|
|
26
|
+
});
|
|
27
|
+
// Store original ResizeObserver
|
|
28
|
+
originalResizeObserver = global.ResizeObserver;
|
|
29
|
+
resizeCallback = null;
|
|
30
|
+
// Store the ResizeObserver callback
|
|
31
|
+
global.ResizeObserver = class MockResizeObserver {
|
|
32
|
+
observe() {}
|
|
33
|
+
unobserve() {}
|
|
34
|
+
disconnect() {}
|
|
35
|
+
constructor(callback){
|
|
36
|
+
resizeCallback = callback;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
afterEach(()=>{
|
|
41
|
+
// Restore original ResizeObserver
|
|
42
|
+
global.ResizeObserver = originalResizeObserver;
|
|
43
|
+
resizeCallback = null;
|
|
44
|
+
});
|
|
45
|
+
const setParentWidth = (width)=>{
|
|
46
|
+
Object.defineProperty(parentElement, 'offsetWidth', {
|
|
47
|
+
configurable: true,
|
|
48
|
+
value: width
|
|
49
|
+
});
|
|
50
|
+
// Trigger resize callback
|
|
51
|
+
act(()=>{
|
|
52
|
+
if (resizeCallback) {
|
|
53
|
+
const entry = {
|
|
54
|
+
target: parentElement,
|
|
55
|
+
borderBoxSize: [
|
|
56
|
+
{
|
|
57
|
+
blockSize: 0,
|
|
58
|
+
inlineSize: width
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
contentBoxSize: [
|
|
62
|
+
{
|
|
63
|
+
blockSize: 0,
|
|
64
|
+
inlineSize: width
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
contentRect: {
|
|
68
|
+
width,
|
|
69
|
+
height: 0,
|
|
70
|
+
x: 0,
|
|
71
|
+
y: 0,
|
|
72
|
+
top: 0,
|
|
73
|
+
right: width,
|
|
74
|
+
bottom: 0,
|
|
75
|
+
left: 0,
|
|
76
|
+
toJSON: ()=>({})
|
|
77
|
+
},
|
|
78
|
+
devicePixelContentBoxSize: [
|
|
79
|
+
{
|
|
80
|
+
blockSize: 0,
|
|
81
|
+
inlineSize: width
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
};
|
|
85
|
+
resizeCallback([
|
|
86
|
+
entry
|
|
87
|
+
], {});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
it('should return "narrow" for width <= 26.25rem (420px)', ()=>{
|
|
92
|
+
setParentWidth(420);
|
|
93
|
+
const { result } = renderHook(()=>useFormWorkspaceSize(ref));
|
|
94
|
+
expect(result.current).toBe('narrow');
|
|
95
|
+
});
|
|
96
|
+
it('should return "wider" for width <= 32.25rem (516px)', ()=>{
|
|
97
|
+
setParentWidth(516);
|
|
98
|
+
const { result } = renderHook(()=>useFormWorkspaceSize(ref));
|
|
99
|
+
expect(result.current).toBe('wider');
|
|
100
|
+
});
|
|
101
|
+
it('should return "extra-wide" for width <= 48.25rem (772px)', ()=>{
|
|
102
|
+
setParentWidth(772);
|
|
103
|
+
const { result } = renderHook(()=>useFormWorkspaceSize(ref));
|
|
104
|
+
expect(result.current).toBe('extra-wide');
|
|
105
|
+
});
|
|
106
|
+
it('should return "ultra-wide" for width > 48.25rem (772px)', ()=>{
|
|
107
|
+
setParentWidth(1000);
|
|
108
|
+
const { result } = renderHook(()=>useFormWorkspaceSize(ref));
|
|
109
|
+
expect(result.current).toBe('ultra-wide');
|
|
110
|
+
});
|
|
111
|
+
it('should handle null ref', ()=>{
|
|
112
|
+
const nullRef = {
|
|
113
|
+
current: null
|
|
114
|
+
};
|
|
115
|
+
const { result } = renderHook(()=>useFormWorkspaceSize(nullRef));
|
|
116
|
+
expect(result.current).toBe('narrow');
|
|
117
|
+
});
|
|
118
|
+
it('should update size when container width changes', ()=>{
|
|
119
|
+
const { result } = renderHook(()=>useFormWorkspaceSize(ref));
|
|
120
|
+
// Start with narrow
|
|
121
|
+
act(()=>{
|
|
122
|
+
setParentWidth(400);
|
|
123
|
+
});
|
|
124
|
+
expect(result.current).toBe('narrow');
|
|
125
|
+
// Change to wider
|
|
126
|
+
act(()=>{
|
|
127
|
+
setParentWidth(516);
|
|
128
|
+
});
|
|
129
|
+
expect(result.current).toBe('wider');
|
|
130
|
+
// Change to extra-wide
|
|
131
|
+
act(()=>{
|
|
132
|
+
setParentWidth(772);
|
|
133
|
+
});
|
|
134
|
+
expect(result.current).toBe('extra-wide');
|
|
135
|
+
// Change to ultra-wide
|
|
136
|
+
act(()=>{
|
|
137
|
+
setParentWidth(1000);
|
|
138
|
+
});
|
|
139
|
+
expect(result.current).toBe('ultra-wide');
|
|
140
|
+
});
|
|
141
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type FormProcessorContextProps } from '../types';
|
|
2
|
+
import { type FormProcessor } from '../processors/form-processor';
|
|
3
|
+
declare const useInitialValues: (formProcessor: FormProcessor, isLoadingContextDependencies: boolean, context: FormProcessorContextProps) => {
|
|
4
|
+
isLoadingInitialValues: boolean;
|
|
5
|
+
initialValues: {};
|
|
6
|
+
error: any;
|
|
7
|
+
};
|
|
8
|
+
export default useInitialValues;
|
|
9
|
+
//# sourceMappingURL=useInitialValues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInitialValues.d.ts","sourceRoot":"","sources":["../../src/hooks/useInitialValues.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,QAAA,MAAM,gBAAgB,GACpB,eAAe,aAAa,EAC5B,8BAA8B,OAAO,EACrC,SAAS,yBAAyB;;;;CA6BnC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
const useInitialValues = (formProcessor, isLoadingContextDependencies, context)=>{
|
|
3
|
+
const [isLoadingInitialValues, setIsLoadingInitialValues] = useState(true);
|
|
4
|
+
const [initialValues, setInitialValues] = useState({});
|
|
5
|
+
const [error, setError] = useState(null);
|
|
6
|
+
useEffect(()=>{
|
|
7
|
+
if (formProcessor && !isLoadingContextDependencies && context.formFields?.length && Object.keys(context.formFieldAdapters).length && !Object.keys(initialValues).length) {
|
|
8
|
+
formProcessor.getInitialValues(context).then((values)=>{
|
|
9
|
+
setInitialValues(values);
|
|
10
|
+
setIsLoadingInitialValues(false);
|
|
11
|
+
}).catch((error)=>{
|
|
12
|
+
console.error(error);
|
|
13
|
+
setError(error);
|
|
14
|
+
setIsLoadingInitialValues(false);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}, [
|
|
18
|
+
formProcessor,
|
|
19
|
+
isLoadingContextDependencies,
|
|
20
|
+
context,
|
|
21
|
+
initialValues
|
|
22
|
+
]);
|
|
23
|
+
return {
|
|
24
|
+
isLoadingInitialValues,
|
|
25
|
+
initialValues,
|
|
26
|
+
error
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export default useInitialValues;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { act, renderHook, waitFor } from "@testing-library/react";
|
|
2
|
+
import useInitialValues from "./useInitialValues.js";
|
|
3
|
+
export const mockFormFields = [
|
|
4
|
+
{
|
|
5
|
+
label: 'First Name',
|
|
6
|
+
type: 'text',
|
|
7
|
+
id: 'firstName',
|
|
8
|
+
questionOptions: {
|
|
9
|
+
rendering: 'text'
|
|
10
|
+
},
|
|
11
|
+
value: '',
|
|
12
|
+
isRequired: true,
|
|
13
|
+
validators: [
|
|
14
|
+
{
|
|
15
|
+
required: true
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: 'Date of Birth',
|
|
21
|
+
type: 'date',
|
|
22
|
+
questionOptions: {
|
|
23
|
+
rendering: 'date'
|
|
24
|
+
},
|
|
25
|
+
datePickerFormat: 'both',
|
|
26
|
+
id: 'dob',
|
|
27
|
+
value: null,
|
|
28
|
+
isRequired: true,
|
|
29
|
+
validators: [
|
|
30
|
+
{
|
|
31
|
+
required: true
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
describe('useInitialValues', ()=>{
|
|
37
|
+
let formProcessor;
|
|
38
|
+
let context;
|
|
39
|
+
beforeEach(()=>{
|
|
40
|
+
formProcessor = {
|
|
41
|
+
getInitialValues: jest.fn()
|
|
42
|
+
};
|
|
43
|
+
context = {
|
|
44
|
+
formFields: mockFormFields,
|
|
45
|
+
formFieldAdapters: {
|
|
46
|
+
adapter1: {},
|
|
47
|
+
adapter2: {}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
it('should not call getInitialValues if context dependencies are not loaded', ()=>{
|
|
52
|
+
const { result } = renderHook(()=>useInitialValues(formProcessor, true, context));
|
|
53
|
+
expect(result.current.isLoadingInitialValues).toBe(true);
|
|
54
|
+
expect(formProcessor.getInitialValues).not.toHaveBeenCalled();
|
|
55
|
+
});
|
|
56
|
+
it('should set error if getInitialValues rejects', async ()=>{
|
|
57
|
+
const mockConsole = jest.spyOn(console, 'error').mockImplementation(()=>{});
|
|
58
|
+
const mockError = new Error('Failed to fetch initial values');
|
|
59
|
+
formProcessor.getInitialValues.mockRejectedValue(mockError);
|
|
60
|
+
const { result } = await act(()=>renderHook(()=>useInitialValues(formProcessor, false, context)));
|
|
61
|
+
expect(result.current.error).toEqual(mockError);
|
|
62
|
+
expect(result.current.isLoadingInitialValues).toBe(false);
|
|
63
|
+
mockConsole.mockRestore();
|
|
64
|
+
});
|
|
65
|
+
it('should set initial values when dependencies are loaded', async ()=>{
|
|
66
|
+
const mockInitialValues = {
|
|
67
|
+
firstName: 'John Doe',
|
|
68
|
+
dob: '1992-10-10'
|
|
69
|
+
};
|
|
70
|
+
formProcessor.getInitialValues.mockResolvedValue(mockInitialValues);
|
|
71
|
+
const { result } = renderHook(()=>useInitialValues(formProcessor, false, context));
|
|
72
|
+
await waitFor(()=>expect(result.current.isLoadingInitialValues).toBe(false));
|
|
73
|
+
expect(formProcessor.getInitialValues).toHaveBeenCalledWith(context);
|
|
74
|
+
expect(result.current.initialValues).toEqual(mockInitialValues);
|
|
75
|
+
expect(result.current.isLoadingInitialValues).toBe(false);
|
|
76
|
+
expect(result.current.error).toBe(null);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePatientData.d.ts","sourceRoot":"","sources":["../../src/hooks/usePatientData.ts"],"names":[],"mappings":"AAuBA,eAAO,MAAM,cAAc,GAAI,gBAAW;;;;CAQzC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { usePatient } from "@openmrs/esm-framework";
|
|
2
|
+
function calculateAge(birthDate) {
|
|
3
|
+
const today = new Date();
|
|
4
|
+
const yearsDiff = today.getFullYear() - birthDate.getFullYear();
|
|
5
|
+
if (today.getMonth() < birthDate.getMonth() || today.getMonth() === birthDate.getMonth() && today.getDate() < birthDate.getDate()) {
|
|
6
|
+
// subtract one year if the current date is before the birth date this year
|
|
7
|
+
return yearsDiff - 1;
|
|
8
|
+
} else {
|
|
9
|
+
return yearsDiff;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const patientGenderMap = {
|
|
13
|
+
female: 'F',
|
|
14
|
+
male: 'M',
|
|
15
|
+
other: 'O',
|
|
16
|
+
unknown: 'U'
|
|
17
|
+
};
|
|
18
|
+
export const usePatientData = (patientUuid)=>{
|
|
19
|
+
const { patient, isLoading: isLoadingPatient, error: patientError } = usePatient(patientUuid);
|
|
20
|
+
if (patient && !isLoadingPatient) {
|
|
21
|
+
// This is for backward compatibility with the Angular form engine
|
|
22
|
+
patient['age'] = calculateAge(new Date(patient?.birthDate));
|
|
23
|
+
patient['sex'] = patientGenderMap[patient.gender] ?? 'U';
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
patient,
|
|
27
|
+
isLoadingPatient,
|
|
28
|
+
patientError
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FormSchema } from '../types';
|
|
2
|
+
export declare const usePatientPrograms: (patientUuid: string, formJson: FormSchema) => {
|
|
3
|
+
patientPrograms: import("../types").PatientProgram[];
|
|
4
|
+
errorFetchingPatientPrograms: Error;
|
|
5
|
+
isLoadingPatientPrograms: boolean;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=usePatientPrograms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePatientPrograms.d.ts","sourceRoot":"","sources":["../../src/hooks/usePatientPrograms.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAyB,MAAM,UAAU,CAAC;AAyBlE,eAAO,MAAM,kBAAkB,GAAI,aAAa,MAAM,EAAE,UAAU,UAAU;;;;CAU3E,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import useSWR from "swr";
|
|
2
|
+
import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
|
|
3
|
+
const useActiveProgramEnrollments = (patientUuid)=>{
|
|
4
|
+
const customRepresentation = `custom:(uuid,display,program:(uuid,name,allWorkflows),dateEnrolled,dateCompleted,location:(uuid,display),states:(startDate,endDate,state:(uuid,name,retired,concept:(uuid),programWorkflow:(uuid)))`;
|
|
5
|
+
const apiUrl = `${restBaseUrl}/programenrollment?patient=${patientUuid}&v=${customRepresentation}`;
|
|
6
|
+
const { data, error, isLoading } = useSWR(patientUuid ? apiUrl : null, openmrsFetch);
|
|
7
|
+
const sortedEnrollments = data?.data?.results.length > 0 ? data?.data.results.sort((a, b)=>b.dateEnrolled > a.dateEnrolled ? 1 : -1) : null;
|
|
8
|
+
const activePrograms = sortedEnrollments?.filter((enrollment)=>!enrollment.dateCompleted);
|
|
9
|
+
return {
|
|
10
|
+
activePrograms,
|
|
11
|
+
error,
|
|
12
|
+
isLoading
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export const usePatientPrograms = (patientUuid, formJson)=>{
|
|
16
|
+
const { activePrograms, error, isLoading } = useActiveProgramEnrollments(formJson.meta?.programs?.hasProgramFields ? patientUuid : null);
|
|
17
|
+
return {
|
|
18
|
+
patientPrograms: activePrograms,
|
|
19
|
+
errorFetchingPatientPrograms: error,
|
|
20
|
+
isLoadingPatientPrograms: isLoading
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type PostSubmissionAction } from '../types';
|
|
2
|
+
export interface PostSubmissionActionMeta {
|
|
3
|
+
postAction: PostSubmissionAction;
|
|
4
|
+
actionId: string;
|
|
5
|
+
config: Record<string, any>;
|
|
6
|
+
enabled?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function usePostSubmissionActions(actionRefs: Array<{
|
|
9
|
+
actionId: string;
|
|
10
|
+
enabled?: string;
|
|
11
|
+
config?: Record<string, any>;
|
|
12
|
+
}>): Array<PostSubmissionActionMeta>;
|
|
13
|
+
//# sourceMappingURL=usePostSubmissionActions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePostSubmissionActions.d.ts","sourceRoot":"","sources":["../../src/hooks/usePostSubmissionActions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,oBAAoB,CAAC;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,KAAK,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,CAAC,GACtF,KAAK,CAAC,wBAAwB,CAAC,CAiBjC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { getRegisteredPostSubmissionAction } from "../registry/registry.js";
|
|
3
|
+
export function usePostSubmissionActions(actionRefs) {
|
|
4
|
+
const [actions, setActions] = useState([]);
|
|
5
|
+
useEffect(()=>{
|
|
6
|
+
const actionArray = [];
|
|
7
|
+
if (actionRefs?.length) {
|
|
8
|
+
actionRefs.map((ref)=>{
|
|
9
|
+
const actionId = typeof ref === 'string' ? ref : ref.actionId;
|
|
10
|
+
getRegisteredPostSubmissionAction(actionId)?.then((action)=>actionArray.push({
|
|
11
|
+
postAction: action,
|
|
12
|
+
config: ref.config,
|
|
13
|
+
actionId: actionId,
|
|
14
|
+
enabled: ref.enabled
|
|
15
|
+
}));
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
setActions(actionArray);
|
|
19
|
+
}, [
|
|
20
|
+
actionRefs
|
|
21
|
+
]);
|
|
22
|
+
return actions;
|
|
23
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { renderHook, act } from "@testing-library/react";
|
|
2
|
+
import { usePostSubmissionActions } from "./usePostSubmissionActions.js";
|
|
3
|
+
// Mock the getRegisteredPostSubmissionAction function
|
|
4
|
+
jest.mock('../registry/registry', ()=>({
|
|
5
|
+
getRegisteredPostSubmissionAction: jest.fn()
|
|
6
|
+
}));
|
|
7
|
+
describe('usePostSubmissionActions', ()=>{
|
|
8
|
+
// Mock the actual post-submission action function
|
|
9
|
+
const mockPostAction = jest.fn();
|
|
10
|
+
// Sample action references
|
|
11
|
+
const actionRefs = [
|
|
12
|
+
{
|
|
13
|
+
actionId: 'action1',
|
|
14
|
+
config: {
|
|
15
|
+
param1: 'value1'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
actionId: 'action2',
|
|
20
|
+
config: {
|
|
21
|
+
param2: 'value2'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
// Set up the mock implementation for getRegisteredPostSubmissionAction
|
|
26
|
+
beforeEach(()=>{
|
|
27
|
+
jest.requireMock('../registry/registry').getRegisteredPostSubmissionAction.mockImplementation((actionId)=>{
|
|
28
|
+
if (actionId === 'action1') {
|
|
29
|
+
return Promise.resolve(mockPostAction);
|
|
30
|
+
}
|
|
31
|
+
return Promise.resolve(null);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
it('should fetch post-submission actions and return them', async ()=>{
|
|
35
|
+
const { result } = renderHook(()=>usePostSubmissionActions(actionRefs));
|
|
36
|
+
// Wait for the effect to complete
|
|
37
|
+
await act(async ()=>{});
|
|
38
|
+
expect(result.current).toEqual([
|
|
39
|
+
{
|
|
40
|
+
postAction: mockPostAction,
|
|
41
|
+
config: {
|
|
42
|
+
param1: 'value1'
|
|
43
|
+
},
|
|
44
|
+
actionId: 'action1'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
postAction: null,
|
|
48
|
+
config: {
|
|
49
|
+
param2: 'value2'
|
|
50
|
+
},
|
|
51
|
+
actionId: 'action2'
|
|
52
|
+
}
|
|
53
|
+
]);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type FormProcessorContextProps } from '../types';
|
|
2
|
+
import { type FormProcessor } from '../processors/form-processor';
|
|
3
|
+
declare const useProcessorDependencies: (formProcessor: FormProcessor, context: Partial<FormProcessorContextProps>, setContext: (context: FormProcessorContextProps) => void) => {
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
error: string;
|
|
6
|
+
};
|
|
7
|
+
export default useProcessorDependencies;
|
|
8
|
+
//# sourceMappingURL=useProcessorDependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useProcessorDependencies.d.ts","sourceRoot":"","sources":["../../src/hooks/useProcessorDependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGlE,QAAA,MAAM,wBAAwB,GAC5B,eAAe,aAAa,EAC5B,SAAS,OAAO,CAAC,yBAAyB,CAAC,EAC3C,YAAY,CAAC,OAAO,EAAE,yBAAyB,KAAK,IAAI;;;CA+BzD,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { reportError } from "../utils/error-utils.js";
|
|
3
|
+
const useProcessorDependencies = (formProcessor, context, setContext)=>{
|
|
4
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
5
|
+
const [error, setError] = useState('');
|
|
6
|
+
const { loadDependencies } = formProcessor;
|
|
7
|
+
useEffect(()=>{
|
|
8
|
+
let ignore = false;
|
|
9
|
+
if (loadDependencies) {
|
|
10
|
+
setIsLoading(true);
|
|
11
|
+
loadDependencies(context, setContext).then(()=>{
|
|
12
|
+
if (!ignore) {
|
|
13
|
+
setIsLoading(false);
|
|
14
|
+
}
|
|
15
|
+
}).catch((error)=>{
|
|
16
|
+
if (!ignore) {
|
|
17
|
+
setError(error);
|
|
18
|
+
reportError(error, 'Encountered error while loading dependencies');
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return ()=>{
|
|
23
|
+
ignore = true;
|
|
24
|
+
};
|
|
25
|
+
}, [
|
|
26
|
+
loadDependencies
|
|
27
|
+
]);
|
|
28
|
+
return {
|
|
29
|
+
isLoading,
|
|
30
|
+
error
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export default useProcessorDependencies;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './utils/forms-loader';
|
|
3
|
+
export * from './registry/registry';
|
|
4
|
+
export * from './constants';
|
|
5
|
+
export * from './utils/boolean-utils';
|
|
6
|
+
export * from './validators/form-validator';
|
|
7
|
+
export * from './utils/form-helper';
|
|
8
|
+
export * from './components/value/view/field-value-view.component';
|
|
9
|
+
export * from './components/previous-value-review/previous-value-review.component';
|
|
10
|
+
export * from './hooks/useFormJson';
|
|
11
|
+
export { default as FormEngine } from './form-engine.component';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oDAAoD,CAAC;AACnE,cAAc,oEAAoE,CAAC;AACnF,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./types/index.js";
|
|
2
|
+
export * from "./utils/forms-loader.js";
|
|
3
|
+
export * from "./registry/registry.js";
|
|
4
|
+
export * from "./constants.js";
|
|
5
|
+
export * from "./utils/boolean-utils.js";
|
|
6
|
+
export * from "./validators/form-validator.js";
|
|
7
|
+
export * from "./utils/form-helper.js";
|
|
8
|
+
export * from "./components/value/view/field-value-view.component.js";
|
|
9
|
+
export * from "./components/previous-value-review/previous-value-review.component.js";
|
|
10
|
+
export * from "./hooks/useFormJson.js";
|
|
11
|
+
export { default as FormEngine } from "./form-engine.component.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type FormFieldValueAdapter } from './types';
|
|
2
|
+
export declare function registerFormFieldAdaptersForCleanUp(formFieldAdaptersMap: Record<string, FormFieldValueAdapter>): void;
|
|
3
|
+
/**
|
|
4
|
+
* Invoked on mounting the "FormEngine" component
|
|
5
|
+
*/
|
|
6
|
+
export declare function init(): void;
|
|
7
|
+
/**
|
|
8
|
+
* Invoked on unmounting the "FormEngine" component
|
|
9
|
+
*/
|
|
10
|
+
export declare function teardown(): void;
|
|
11
|
+
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAIrD,wBAAgB,mCAAmC,CAAC,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,QAM9G;AACD;;GAEG;AACH,wBAAgB,IAAI,SACnB;AAED;;GAEG;AACH,wBAAgB,QAAQ,SAUvB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { pageObserver } from "./components/sidebar/page-observer.js";
|
|
2
|
+
const formFieldAdapters = new Set();
|
|
3
|
+
export function registerFormFieldAdaptersForCleanUp(formFieldAdaptersMap) {
|
|
4
|
+
if (formFieldAdaptersMap) {
|
|
5
|
+
Object.values(formFieldAdaptersMap).forEach((adapter)=>{
|
|
6
|
+
formFieldAdapters.add(adapter);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Invoked on mounting the "FormEngine" component
|
|
12
|
+
*/ export function init() {}
|
|
13
|
+
/**
|
|
14
|
+
* Invoked on unmounting the "FormEngine" component
|
|
15
|
+
*/ export function teardown() {
|
|
16
|
+
formFieldAdapters.forEach((adapter)=>{
|
|
17
|
+
try {
|
|
18
|
+
adapter.tearDown();
|
|
19
|
+
} catch (error) {
|
|
20
|
+
// pass
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
formFieldAdapters.clear();
|
|
24
|
+
pageObserver.clear();
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mark-patient-deceased-action.d.ts","sourceRoot":"","sources":["../../src/post-submission-actions/mark-patient-deceased-action.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAuB,MAAM,UAAU,CAAC;AAG1E,eAAO,MAAM,2BAA2B,EAAE,oBA0DzC,CAAC;AAEF,eAAe,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import { showSnackbar, translateFrom } from "@openmrs/esm-framework";
|
|
3
|
+
import { markPatientAsDeceased } from "../api/index.js";
|
|
4
|
+
import { extractErrorMessagesFromResponse } from "../utils/error-utils.js";
|
|
5
|
+
import { formEngineAppName } from "../globals.js";
|
|
6
|
+
export const MarkPatientAsDeceasedAction = {
|
|
7
|
+
applyAction: async function({ patient, encounters, sessionMode }, config) {
|
|
8
|
+
const t = translateFrom.bind(null, formEngineAppName);
|
|
9
|
+
const encounter = encounters[0];
|
|
10
|
+
if (sessionMode === 'view') {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (patient._deceasedBoolean || patient.deceasedDateTime) {
|
|
14
|
+
throw new Error(t('patientIsAlreadyMarkedAsDeceased', 'Patient is already marked as deceased'));
|
|
15
|
+
}
|
|
16
|
+
const causeOfDeathQuestionId = config.causeOfDeathQuestionId;
|
|
17
|
+
const dateOfDeathQuestionId = config.dateOfDeathQuestionId;
|
|
18
|
+
if (!causeOfDeathQuestionId) {
|
|
19
|
+
throw new Error(t('causeOfDeathQuestionIdIsNotConfigured', 'Cause of death question ID is not configured'));
|
|
20
|
+
}
|
|
21
|
+
if (!dateOfDeathQuestionId) {
|
|
22
|
+
throw new Error(t('dateOfDeathQuestionIdIsNotConfigured', 'Date of death question ID is not configured'));
|
|
23
|
+
}
|
|
24
|
+
const causeOfDeath = encounter.obs?.find((item)=>{
|
|
25
|
+
return item.formFieldPath.includes(causeOfDeathQuestionId);
|
|
26
|
+
})?.value.uuid;
|
|
27
|
+
const dateOfDeath = encounter.obs?.find((item)=>item.formFieldPath.includes(dateOfDeathQuestionId))?.value;
|
|
28
|
+
if (!causeOfDeath) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const deathPayload = {
|
|
32
|
+
dead: true,
|
|
33
|
+
causeOfDeath,
|
|
34
|
+
deathDate: dateOfDeath ?? dayjs().format()
|
|
35
|
+
};
|
|
36
|
+
const abortController = new AbortController();
|
|
37
|
+
markPatientAsDeceased(t, patient.id, deathPayload, abortController).then((response)=>{
|
|
38
|
+
showSnackbar({
|
|
39
|
+
kind: 'success',
|
|
40
|
+
title: t('successfullyMarkedAsDeceased', 'The patient has successfully been marked as deceased'),
|
|
41
|
+
isLowContrast: true
|
|
42
|
+
});
|
|
43
|
+
}, (err)=>{
|
|
44
|
+
showSnackbar({
|
|
45
|
+
title: t('errorMarkingAsDeceased', 'Error marking patient as deceased'),
|
|
46
|
+
subtitle: extractErrorMessagesFromResponse(err).join(', '),
|
|
47
|
+
kind: 'error',
|
|
48
|
+
isLowContrast: false
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
export default MarkPatientAsDeceasedAction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program-enrollment-action.d.ts","sourceRoot":"","sources":["../../src/post-submission-actions/program-enrollment-action.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,oBAAoB,EAA8B,MAAM,UAAU,CAAC;AAKjF,eAAO,MAAM,iCAAiC,EAAE,oBAuG/C,CAAC;AAyBF,eAAe,iCAAiC,CAAC"}
|