@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,538 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
import dayjs from "dayjs";
|
|
15
|
+
import customParseFormat from "dayjs/plugin/customParseFormat";
|
|
16
|
+
dayjs.extend(customParseFormat);
|
|
17
|
+
import findIndex from "lodash/findIndex";
|
|
18
|
+
import filter from "lodash/filter";
|
|
19
|
+
import first from "lodash/first";
|
|
20
|
+
import forEach from "lodash/forEach";
|
|
21
|
+
import last from "lodash/last";
|
|
22
|
+
import { isEmpty as isValueEmpty } from "../validators/form-validator.js";
|
|
23
|
+
import * as apiFunctions from "../api/index.js";
|
|
24
|
+
import { getZRefByGenderAndAge } from "./zscore-service.js";
|
|
25
|
+
import { formatDate, parseDate } from "@openmrs/esm-framework";
|
|
26
|
+
export class CommonExpressionHelpers {
|
|
27
|
+
constructor(node, patient, allFields, allFieldValues){
|
|
28
|
+
_define_property(this, "node", null);
|
|
29
|
+
_define_property(this, "patient", null);
|
|
30
|
+
_define_property(this, "allFields", []);
|
|
31
|
+
_define_property(this, "allFieldValues", {});
|
|
32
|
+
_define_property(this, "api", apiFunctions);
|
|
33
|
+
_define_property(this, "isEmpty", isValueEmpty);
|
|
34
|
+
_define_property(this, "dayjs", dayjs);
|
|
35
|
+
/**
|
|
36
|
+
* Shared helper for Z-score calculations. Finds the standard deviation (SD) value
|
|
37
|
+
* by comparing a measurement against WHO growth reference data.
|
|
38
|
+
* @param refSectionObject - Reference data object with SD columns (e.g., '-3SD', '-2SD', etc.)
|
|
39
|
+
* @param measurementValue - The patient's measurement to compare against reference values
|
|
40
|
+
* @returns The SD score as a string (e.g., '-2', '0', '1') or null if no reference data
|
|
41
|
+
*/ _define_property(this, "calculateZScoreFromRef", (refSectionObject, measurementValue)=>{
|
|
42
|
+
if (!refSectionObject) {
|
|
43
|
+
console.warn('Z-score calculation: No reference data object provided');
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const refObjectKeys = Object.keys(refSectionObject);
|
|
47
|
+
const refObjectValues = refObjectKeys.map((key)=>refSectionObject[key]);
|
|
48
|
+
const minimumValue = refObjectValues[1];
|
|
49
|
+
const minReferencePoint = [];
|
|
50
|
+
if (measurementValue < minimumValue) {
|
|
51
|
+
minReferencePoint.push(minimumValue);
|
|
52
|
+
} else {
|
|
53
|
+
forEach(refObjectValues, (value)=>{
|
|
54
|
+
if (value <= measurementValue) {
|
|
55
|
+
minReferencePoint.push(value);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const lastReferenceValue = last(minReferencePoint);
|
|
60
|
+
const lastValueIndex = findIndex(refObjectValues, (o)=>o === lastReferenceValue);
|
|
61
|
+
const SDValue = refObjectKeys[lastValueIndex];
|
|
62
|
+
let formattedSDValue = SDValue?.replace('SD', '');
|
|
63
|
+
if (formattedSDValue?.includes('neg')) {
|
|
64
|
+
formattedSDValue = '-' + formattedSDValue.substring(0, 1);
|
|
65
|
+
}
|
|
66
|
+
if (formattedSDValue === 'S' || formattedSDValue === 'L' || formattedSDValue === 'M' || formattedSDValue === '-5') {
|
|
67
|
+
formattedSDValue = '-4';
|
|
68
|
+
}
|
|
69
|
+
return formattedSDValue ?? null;
|
|
70
|
+
});
|
|
71
|
+
/**
|
|
72
|
+
* Returns the current date and time.
|
|
73
|
+
* @returns A new Date object representing the current moment
|
|
74
|
+
*/ _define_property(this, "today", ()=>{
|
|
75
|
+
return new Date();
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* Checks if a collection contains a specific value.
|
|
79
|
+
* @param collection - The array to search in
|
|
80
|
+
* @param value - The value to search for
|
|
81
|
+
* @returns true if the collection contains the value, false otherwise
|
|
82
|
+
*/ _define_property(this, "includes", (collection, value)=>{
|
|
83
|
+
return collection?.includes(value);
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* Checks if the left date is before the right date.
|
|
87
|
+
* @param left - The date to check
|
|
88
|
+
* @param right - The date to compare against (can be a Date object or string)
|
|
89
|
+
* @param format - Optional format string for parsing right date (defaults to 'YYYY-MM-DD')
|
|
90
|
+
* @returns true if left is before right
|
|
91
|
+
*/ _define_property(this, "isDateBefore", (left, right, format)=>{
|
|
92
|
+
const otherDate = right instanceof Date ? right : format ? dayjs(right, format, true).toDate() : dayjs(right, 'YYYY-MM-DD', true).toDate();
|
|
93
|
+
return left?.getTime() < otherDate.getTime();
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* Checks if selectedDate is on or after baseDate plus a duration offset.
|
|
97
|
+
* @param selectedDate - The date to check
|
|
98
|
+
* @param baseDate - The base date to add the duration to
|
|
99
|
+
* @param duration - The number of time units to add to baseDate
|
|
100
|
+
* @param timePeriod - The time unit: 'days', 'weeks', 'months', or 'years'
|
|
101
|
+
* @returns true if selectedDate >= (baseDate + duration)
|
|
102
|
+
*/ _define_property(this, "isDateAfter", (selectedDate, baseDate, duration, timePeriod)=>{
|
|
103
|
+
const parsedBaseDate = dayjs(baseDate);
|
|
104
|
+
let calculatedDate;
|
|
105
|
+
switch(timePeriod){
|
|
106
|
+
case 'months':
|
|
107
|
+
calculatedDate = parsedBaseDate.add(duration, 'month').toDate();
|
|
108
|
+
break;
|
|
109
|
+
case 'weeks':
|
|
110
|
+
calculatedDate = parsedBaseDate.add(duration, 'week').toDate();
|
|
111
|
+
break;
|
|
112
|
+
case 'days':
|
|
113
|
+
calculatedDate = parsedBaseDate.add(duration, 'day').toDate();
|
|
114
|
+
break;
|
|
115
|
+
case 'years':
|
|
116
|
+
calculatedDate = parsedBaseDate.add(duration, 'year').toDate();
|
|
117
|
+
break;
|
|
118
|
+
default:
|
|
119
|
+
calculatedDate = new Date(0);
|
|
120
|
+
}
|
|
121
|
+
return selectedDate.getTime() >= calculatedDate.getTime();
|
|
122
|
+
});
|
|
123
|
+
/**
|
|
124
|
+
* Adds weeks to a date without mutating the original.
|
|
125
|
+
* @param date - The starting date
|
|
126
|
+
* @param weeks - Number of weeks to add
|
|
127
|
+
* @returns A new Date object with the weeks added
|
|
128
|
+
*/ _define_property(this, "addWeeksToDate", (date, weeks)=>{
|
|
129
|
+
return dayjs(date).add(weeks, 'week').toDate();
|
|
130
|
+
});
|
|
131
|
+
/**
|
|
132
|
+
* Adds days to a date without mutating the original.
|
|
133
|
+
* @param date - The starting date
|
|
134
|
+
* @param days - Number of days to add
|
|
135
|
+
* @returns A new Date object with the days added
|
|
136
|
+
*/ _define_property(this, "addDaysToDate", (date, days)=>{
|
|
137
|
+
return dayjs(date).add(days, 'day').toDate();
|
|
138
|
+
});
|
|
139
|
+
/**
|
|
140
|
+
* Simple date comparison - checks if left date is strictly after right date.
|
|
141
|
+
* Mirrors the API of isDateBefore for consistency.
|
|
142
|
+
* @param left - The date to check
|
|
143
|
+
* @param right - The date to compare against (string or Date)
|
|
144
|
+
* @param format - Optional format string for parsing right date (defaults to 'YYYY-MM-DD')
|
|
145
|
+
* @returns true if left is after right
|
|
146
|
+
*/ _define_property(this, "isDateAfterSimple", (left, right, format)=>{
|
|
147
|
+
const otherDate = right instanceof Date ? right : format ? dayjs(right, format, true).toDate() : dayjs(right, 'YYYY-MM-DD', true).toDate();
|
|
148
|
+
return left?.getTime() > otherDate.getTime();
|
|
149
|
+
});
|
|
150
|
+
/**
|
|
151
|
+
* Retrieves the current value of another form field and registers a dependency.
|
|
152
|
+
* When the referenced field changes, expressions using this helper will be re-evaluated.
|
|
153
|
+
* @param questionId - The ID of the field to get the value from
|
|
154
|
+
* @returns The field's current value, or null if not found/set
|
|
155
|
+
*/ _define_property(this, "useFieldValue", (questionId)=>{
|
|
156
|
+
const targetField = this.allFields.find((field)=>field.id === questionId);
|
|
157
|
+
if (targetField) {
|
|
158
|
+
registerDependency(this.node, targetField);
|
|
159
|
+
}
|
|
160
|
+
return this.allFieldValues[questionId] ?? null;
|
|
161
|
+
});
|
|
162
|
+
/**
|
|
163
|
+
* Tests if a value does NOT match a regular expression pattern.
|
|
164
|
+
* Returns true for empty/null/undefined values (treated as non-matching).
|
|
165
|
+
* @param regexString - The regular expression pattern to test against
|
|
166
|
+
* @param val - The value to test
|
|
167
|
+
* @returns true if the value does not match the pattern or is empty/null/undefined
|
|
168
|
+
*/ _define_property(this, "doesNotMatchExpression", (regexString, val)=>{
|
|
169
|
+
if (!val || [
|
|
170
|
+
'undefined',
|
|
171
|
+
'null',
|
|
172
|
+
''
|
|
173
|
+
].includes(val.toString())) {
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
const pattern = new RegExp(regexString);
|
|
177
|
+
return !pattern.test(val);
|
|
178
|
+
});
|
|
179
|
+
/**
|
|
180
|
+
* Calculates Body Mass Index (BMI) from height and weight.
|
|
181
|
+
* Formula: weight (kg) / height (m)²
|
|
182
|
+
* @param height - Height in centimeters
|
|
183
|
+
* @param weight - Weight in kilograms
|
|
184
|
+
* @returns BMI rounded to 1 decimal place, or null if inputs are missing
|
|
185
|
+
*/ _define_property(this, "calcBMI", (height, weight)=>{
|
|
186
|
+
if (!height || !weight) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
const heightInMeters = height / 100;
|
|
190
|
+
const bmi = (weight / (heightInMeters * heightInMeters)).toFixed(1);
|
|
191
|
+
return parseFloat(bmi);
|
|
192
|
+
});
|
|
193
|
+
/**
|
|
194
|
+
* Calculates the Expected Date of Delivery (EDD) from the last menstrual period.
|
|
195
|
+
* Uses Naegele's rule: LMP + 280 days (40 weeks).
|
|
196
|
+
* @param lmp - Last menstrual period date
|
|
197
|
+
* @returns Expected delivery date, or null if lmp is not provided
|
|
198
|
+
*/ _define_property(this, "calcEDD", (lmp)=>{
|
|
199
|
+
if (!lmp) {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
return new Date(lmp.getTime() + 280 * 24 * 60 * 60 * 1000);
|
|
203
|
+
});
|
|
204
|
+
/**
|
|
205
|
+
* Calculates the number of complete months a patient has been on ART.
|
|
206
|
+
* @param artStartDate - The date when ART treatment started
|
|
207
|
+
* @returns Number of months on ART, 0 if less than 30 days, or null if no start date
|
|
208
|
+
* @throws Error if artStartDate is not a valid Date object
|
|
209
|
+
*/ _define_property(this, "calcMonthsOnART", (artStartDate)=>{
|
|
210
|
+
if (artStartDate == null) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
if (!(artStartDate instanceof Date)) {
|
|
214
|
+
throw new Error('DateFormatException: value passed is not a valid date');
|
|
215
|
+
}
|
|
216
|
+
const today = new Date();
|
|
217
|
+
const artInDays = Math.round((today.getTime() - artStartDate.getTime()) / 86400000);
|
|
218
|
+
if (artInDays < 30) {
|
|
219
|
+
return 0;
|
|
220
|
+
}
|
|
221
|
+
return dayjs(today).diff(artStartDate, 'month');
|
|
222
|
+
});
|
|
223
|
+
/**
|
|
224
|
+
* Determines viral load suppression status based on the viral load count.
|
|
225
|
+
*
|
|
226
|
+
* WARNING: This function returns hardcoded concept UUIDs that are specific to certain
|
|
227
|
+
* OpenMRS implementations. These UUIDs may not exist or may differ in your system.
|
|
228
|
+
* Consider using form-level configuration or concept mappings instead.
|
|
229
|
+
*
|
|
230
|
+
* @param viralLoadCount - The viral load count (copies/mL)
|
|
231
|
+
* @returns Concept UUID based on suppression threshold (>50 copies/mL), or null if no count
|
|
232
|
+
* @deprecated Consider implementing viral load status logic in form expressions with
|
|
233
|
+
* configurable concept UUIDs instead of using this hardcoded helper.
|
|
234
|
+
*/ _define_property(this, "calcViralLoadStatus", (viralLoadCount)=>{
|
|
235
|
+
let resultViralLoadStatus;
|
|
236
|
+
if (viralLoadCount) {
|
|
237
|
+
if (viralLoadCount > 50) {
|
|
238
|
+
resultViralLoadStatus = 'a6768be6-c08e-464d-8f53-5f4229508e54';
|
|
239
|
+
} else {
|
|
240
|
+
resultViralLoadStatus = '5d5e42cc-acc4-4069-b3a8-7163e0db5d96';
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return resultViralLoadStatus ?? null;
|
|
244
|
+
});
|
|
245
|
+
/**
|
|
246
|
+
* Calculates the next clinic visit date based on ARV dispensing duration.
|
|
247
|
+
* @param followupDate - The current follow-up/encounter date
|
|
248
|
+
* @param arvDispensedInDays - Number of days of ARV medication dispensed
|
|
249
|
+
* @returns The next visit date (followupDate + arvDispensedInDays), or null if inputs are missing
|
|
250
|
+
*/ _define_property(this, "calcNextVisitDate", (followupDate, arvDispensedInDays)=>{
|
|
251
|
+
if (followupDate && arvDispensedInDays) {
|
|
252
|
+
return new Date(followupDate.getTime() + arvDispensedInDays * 24 * 60 * 60 * 1000);
|
|
253
|
+
}
|
|
254
|
+
return null;
|
|
255
|
+
});
|
|
256
|
+
/**
|
|
257
|
+
* Calculates the treatment end date for patients on ART.
|
|
258
|
+
* Adds a 30-day grace period plus the ARV dispensing duration.
|
|
259
|
+
*
|
|
260
|
+
* WARNING: This function checks against a hardcoded concept UUID (160429AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)
|
|
261
|
+
* for 'Currently in Treatment' status. This UUID may not exist or may differ in your system.
|
|
262
|
+
* Consider implementing this logic in form expressions with configurable concept references instead.
|
|
263
|
+
*
|
|
264
|
+
* @param followupDate - The current follow-up/encounter date
|
|
265
|
+
* @param arvDispensedInDays - Number of days of ARV medication dispensed
|
|
266
|
+
* @param patientStatus - The patient's treatment status UUID (must match hardcoded UUID)
|
|
267
|
+
* @returns Treatment end date (followupDate + 30 + arvDispensedInDays), or null if conditions not met
|
|
268
|
+
* @deprecated Consider implementing treatment end date logic in form expressions with
|
|
269
|
+
* configurable concept UUIDs instead of using this hardcoded helper.
|
|
270
|
+
*/ _define_property(this, "calcTreatmentEndDate", (followupDate, arvDispensedInDays, patientStatus)=>{
|
|
271
|
+
if (!followupDate || !arvDispensedInDays || patientStatus !== '160429AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA') {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
const extraDaysAdded = 30 + arvDispensedInDays;
|
|
275
|
+
return new Date(followupDate.getTime() + extraDaysAdded * 24 * 60 * 60 * 1000);
|
|
276
|
+
});
|
|
277
|
+
/**
|
|
278
|
+
* Calculates the patient's age in years based on a reference date.
|
|
279
|
+
* Note: Uses year-only calculation (ignores month/day), so a patient born in December 1990
|
|
280
|
+
* will be considered 31 years old on January 1, 2021.
|
|
281
|
+
* @param dateValue - The reference date to calculate age at (defaults to today if not provided)
|
|
282
|
+
* @returns Age in years (year difference only, not precise age)
|
|
283
|
+
*/ _define_property(this, "calcAgeBasedOnDate", (dateValue)=>{
|
|
284
|
+
const targetYear = dateValue ? new Date(dateValue).getFullYear() : new Date().getFullYear();
|
|
285
|
+
const birthYear = new Date(this.patient.birthDate).getFullYear();
|
|
286
|
+
return targetYear - birthYear;
|
|
287
|
+
});
|
|
288
|
+
/**
|
|
289
|
+
* Calculates Body Surface Area (BSA) using the Mosteller formula.
|
|
290
|
+
* Formula: √((height × weight) / 3600)
|
|
291
|
+
* @param height - Height in centimeters
|
|
292
|
+
* @param weight - Weight in kilograms
|
|
293
|
+
* @returns BSA in m² rounded to 2 decimal places, or null if inputs are missing
|
|
294
|
+
*/ _define_property(this, "calcBSA", (height, weight)=>{
|
|
295
|
+
if (!height || !weight) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
return parseFloat(Math.sqrt(height * weight / 3600).toFixed(2));
|
|
299
|
+
});
|
|
300
|
+
/**
|
|
301
|
+
* Checks if an array contains ALL of the specified members.
|
|
302
|
+
* @param array - The array to search in
|
|
303
|
+
* @param members - A single value or array of values that must all be present
|
|
304
|
+
* @returns true if array contains all members, false otherwise.
|
|
305
|
+
* Returns true for empty members array. Returns false for null/non-array input.
|
|
306
|
+
*/ _define_property(this, "arrayContains", (array, members)=>{
|
|
307
|
+
if (!array || !Array.isArray(array)) {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
if (array.length === 0) {
|
|
311
|
+
return members === undefined || members === null || Array.isArray(members) && members.length === 0;
|
|
312
|
+
}
|
|
313
|
+
if (!Array.isArray(members)) {
|
|
314
|
+
members = [
|
|
315
|
+
members
|
|
316
|
+
];
|
|
317
|
+
}
|
|
318
|
+
if (members.length === 0) {
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
for (let val of members){
|
|
322
|
+
if (array.indexOf(val) === -1) {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return true;
|
|
327
|
+
});
|
|
328
|
+
/**
|
|
329
|
+
* Checks if an array contains ANY of the specified members.
|
|
330
|
+
* @param array - The array to search in
|
|
331
|
+
* @param members - An array of values where at least one must be present
|
|
332
|
+
* @returns true if array contains at least one member, false otherwise.
|
|
333
|
+
* Returns true for empty members array. Returns false for null/non-array input.
|
|
334
|
+
*/ _define_property(this, "arrayContainsAny", (array, members)=>{
|
|
335
|
+
if (!array || !Array.isArray(array)) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
if (array.length === 0) {
|
|
339
|
+
return members === undefined || members === null || Array.isArray(members) && members.length === 0;
|
|
340
|
+
}
|
|
341
|
+
if (!Array.isArray(members)) {
|
|
342
|
+
members = [
|
|
343
|
+
members
|
|
344
|
+
];
|
|
345
|
+
}
|
|
346
|
+
if (members.length === 0) {
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
for (let val of members){
|
|
350
|
+
if (array.indexOf(val) !== -1) {
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return false;
|
|
355
|
+
});
|
|
356
|
+
/**
|
|
357
|
+
* Parses a date string into a Date object using OpenMRS framework parsing.
|
|
358
|
+
* @param dateString - The date string to parse
|
|
359
|
+
* @returns A Date object
|
|
360
|
+
*/ _define_property(this, "parseDate", (dateString)=>{
|
|
361
|
+
return parseDate(dateString);
|
|
362
|
+
});
|
|
363
|
+
/**
|
|
364
|
+
* Formats a date value into a string.
|
|
365
|
+
* @param value - The date to format (Date object or value that can be converted to Date)
|
|
366
|
+
* @param format - Optional dayjs format string (e.g., 'YYYY-MM-DD', 'DD/MM/YYYY').
|
|
367
|
+
* If not provided, uses OpenMRS default locale format.
|
|
368
|
+
* @returns Formatted date string
|
|
369
|
+
* @throws Error if the value cannot be converted to a valid date
|
|
370
|
+
*/ _define_property(this, "formatDate", (value, format)=>{
|
|
371
|
+
if (!(value instanceof Date)) {
|
|
372
|
+
value = new Date(value);
|
|
373
|
+
if (isNaN(value.getTime())) {
|
|
374
|
+
throw new Error('DateFormatException: value passed is not a valid date');
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (format) {
|
|
378
|
+
return dayjs(value).format(format);
|
|
379
|
+
}
|
|
380
|
+
return formatDate(value);
|
|
381
|
+
});
|
|
382
|
+
/**
|
|
383
|
+
* Extracts values for a specific key from an array of objects (typically repeating group data).
|
|
384
|
+
* @param key - The property key to extract from each object
|
|
385
|
+
* @param array - Array of objects to extract values from
|
|
386
|
+
* @returns Array of values for the specified key
|
|
387
|
+
*/ _define_property(this, "extractRepeatingGroupValues", (key, array)=>{
|
|
388
|
+
const values = array.map(function(item) {
|
|
389
|
+
return item[key];
|
|
390
|
+
});
|
|
391
|
+
return values;
|
|
392
|
+
});
|
|
393
|
+
/**
|
|
394
|
+
* Calculates the gravida (total number of pregnancies) based on term pregnancies and abortions/miscarriages.
|
|
395
|
+
* @param parityTerm - The number of term pregnancies (can be number or numeric string)
|
|
396
|
+
* @param parityAbortion - The number of abortions including miscarriages (can be number or numeric string)
|
|
397
|
+
* @returns The total number of pregnancies (gravida)
|
|
398
|
+
* @throws Error if either input is not a valid number
|
|
399
|
+
*/ _define_property(this, "calcGravida", (parityTerm, parityAbortion)=>{
|
|
400
|
+
const term = typeof parityTerm === 'number' ? parityTerm : parseInt(parityTerm, 10);
|
|
401
|
+
const abortion = typeof parityAbortion === 'number' ? parityAbortion : parseInt(parityAbortion, 10);
|
|
402
|
+
if (!Number.isInteger(term) || !Number.isInteger(abortion)) {
|
|
403
|
+
throw new Error('Both inputs must be valid numbers.');
|
|
404
|
+
}
|
|
405
|
+
return term + abortion;
|
|
406
|
+
});
|
|
407
|
+
/**
|
|
408
|
+
* Calculates the Weight-for-Height Z-score for pediatric patients using WHO growth standards.
|
|
409
|
+
* Used to assess acute malnutrition (wasting).
|
|
410
|
+
* @param height - Patient's height/length in centimeters (valid range: 45-110 cm)
|
|
411
|
+
* @param weight - Patient's weight in kilograms
|
|
412
|
+
* @returns Z-score as a string (e.g., '-2', '0', '1'), '-4' if out of range, or null if inputs missing
|
|
413
|
+
*/ _define_property(this, "calcWeightForHeightZscore", (height, weight)=>{
|
|
414
|
+
if (!height || !weight) {
|
|
415
|
+
return null;
|
|
416
|
+
}
|
|
417
|
+
const birthDate = new Date(this.patient.birthDate);
|
|
418
|
+
const weightForHeightRef = getZRefByGenderAndAge(this.patient.sex, birthDate, new Date()).weightForHeightRef;
|
|
419
|
+
const formattedHeight = height.toFixed(1);
|
|
420
|
+
const standardHeightMin = 45;
|
|
421
|
+
const standardMaxHeight = 110;
|
|
422
|
+
if (parseFloat(formattedHeight) < standardHeightMin || parseFloat(formattedHeight) > standardMaxHeight) {
|
|
423
|
+
return '-4';
|
|
424
|
+
}
|
|
425
|
+
const refSection = filter(weightForHeightRef, (refObject)=>{
|
|
426
|
+
return parseFloat(refObject['Length']).toFixed(1) === formattedHeight;
|
|
427
|
+
});
|
|
428
|
+
const refSectionObject = first(refSection);
|
|
429
|
+
return this.calculateZScoreFromRef(refSectionObject, weight);
|
|
430
|
+
});
|
|
431
|
+
/**
|
|
432
|
+
* Calculates the BMI-for-Age Z-score for pediatric patients using WHO growth standards.
|
|
433
|
+
* Used to assess both undernutrition and overweight/obesity.
|
|
434
|
+
* @param height - Patient's height in centimeters
|
|
435
|
+
* @param weight - Patient's weight in kilograms
|
|
436
|
+
* @returns Z-score as a string (e.g., '-2', '0', '1'), or null if inputs missing
|
|
437
|
+
*/ _define_property(this, "calcBMIForAgeZscore", (height, weight)=>{
|
|
438
|
+
if (!height || !weight) {
|
|
439
|
+
return null;
|
|
440
|
+
}
|
|
441
|
+
const birthDate = new Date(this.patient.birthDate);
|
|
442
|
+
const bmiForAgeRef = getZRefByGenderAndAge(this.patient.sex, birthDate, new Date()).bmiForAgeRef;
|
|
443
|
+
const heightInMeters = height / 100;
|
|
444
|
+
const bmi = parseFloat((weight / (heightInMeters * heightInMeters)).toFixed(1));
|
|
445
|
+
const refSectionObject = first(bmiForAgeRef);
|
|
446
|
+
return this.calculateZScoreFromRef(refSectionObject, bmi);
|
|
447
|
+
});
|
|
448
|
+
/**
|
|
449
|
+
* Calculates the Height-for-Age Z-score for pediatric patients using WHO growth standards.
|
|
450
|
+
* Used to assess chronic malnutrition (stunting).
|
|
451
|
+
* @param height - Patient's height/length in centimeters
|
|
452
|
+
* @param _weight - Unused parameter kept for backward compatibility
|
|
453
|
+
* @returns Z-score as a string (e.g., '-2', '0', '1'), or null if height is missing
|
|
454
|
+
*/ _define_property(this, "calcHeightForAgeZscore", (height, _weight)=>{
|
|
455
|
+
if (!height) {
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
const birthDate = new Date(this.patient.birthDate);
|
|
459
|
+
const heightForAgeRef = getZRefByGenderAndAge(this.patient.sex, birthDate, new Date()).heightForAgeRef;
|
|
460
|
+
const refSectionObject = first(heightForAgeRef);
|
|
461
|
+
return this.calculateZScoreFromRef(refSectionObject, height);
|
|
462
|
+
});
|
|
463
|
+
/**
|
|
464
|
+
* Calculates the time difference between an observation date and today.
|
|
465
|
+
* @param obsDate - The observation/reference date to compare against today
|
|
466
|
+
* @param timeFrame - The unit of time: 'd' (days), 'w' (weeks), 'm' (months), or 'y' (years)
|
|
467
|
+
* @returns The absolute time difference as a number, or 0 if obsDate is not provided
|
|
468
|
+
*/ _define_property(this, "calcTimeDifference", (obsDate, timeFrame)=>{
|
|
469
|
+
if (!obsDate) {
|
|
470
|
+
return 0;
|
|
471
|
+
}
|
|
472
|
+
const endDate = dayjs();
|
|
473
|
+
switch(timeFrame){
|
|
474
|
+
case 'd':
|
|
475
|
+
return Math.abs(Math.round(endDate.diff(obsDate, 'day', true)));
|
|
476
|
+
case 'w':
|
|
477
|
+
return Math.abs(Math.round(endDate.diff(obsDate, 'week', true)));
|
|
478
|
+
case 'm':
|
|
479
|
+
return Math.abs(Math.round(endDate.diff(obsDate, 'month', true)));
|
|
480
|
+
case 'y':
|
|
481
|
+
return Math.abs(Math.round(endDate.diff(obsDate, 'year', true)));
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
/**
|
|
485
|
+
* Resolves a Promise and returns its value. Used to await async operations in form expressions.
|
|
486
|
+
* @param lazy - A Promise to resolve
|
|
487
|
+
* @returns A Promise that resolves to the value of the input Promise
|
|
488
|
+
*/ _define_property(this, "resolve", (lazy)=>{
|
|
489
|
+
return Promise.resolve(lazy);
|
|
490
|
+
});
|
|
491
|
+
this.allFields = allFields;
|
|
492
|
+
this.allFieldValues = allFieldValues;
|
|
493
|
+
this.node = node;
|
|
494
|
+
this.patient = patient;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Simple hash function to generate a unique identifier for a string.
|
|
499
|
+
* @param str - The string to hash.
|
|
500
|
+
* @returns A unique identifier for the string.
|
|
501
|
+
*/ export function simpleHash(str) {
|
|
502
|
+
let hash = 0;
|
|
503
|
+
for(let i = 0; i < str.length; i++){
|
|
504
|
+
const char = str.charCodeAt(i);
|
|
505
|
+
hash = (hash << 5) - hash + char;
|
|
506
|
+
hash |= 0;
|
|
507
|
+
}
|
|
508
|
+
return hash;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Registers a dependency relationship between a form node and a field.
|
|
512
|
+
* When the determinant field's value changes, the dependent node will be re-evaluated.
|
|
513
|
+
* @param node - The dependent node (page, section, or field) that depends on the determinant
|
|
514
|
+
* @param determinant - The field that the node depends on
|
|
515
|
+
*/ export function registerDependency(node, determinant) {
|
|
516
|
+
if (!node || !determinant) {
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
switch(node.type){
|
|
520
|
+
case 'page':
|
|
521
|
+
if (!determinant.pageDependents) {
|
|
522
|
+
determinant.pageDependents = new Set();
|
|
523
|
+
}
|
|
524
|
+
determinant.pageDependents.add(node.value.label);
|
|
525
|
+
break;
|
|
526
|
+
case 'section':
|
|
527
|
+
if (!determinant.sectionDependents) {
|
|
528
|
+
determinant.sectionDependents = new Set();
|
|
529
|
+
}
|
|
530
|
+
determinant.sectionDependents.add(node.value.label);
|
|
531
|
+
break;
|
|
532
|
+
default:
|
|
533
|
+
if (!determinant.fieldDependents) {
|
|
534
|
+
determinant.fieldDependents = new Set();
|
|
535
|
+
}
|
|
536
|
+
determinant.fieldDependents.add(node.value['id']);
|
|
537
|
+
}
|
|
538
|
+
}
|