@openmrs/esm-form-engine-lib 4.0.1-pre.2260 → 4.0.1-pre.2263
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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-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 +24 -0
- package/dist/adapters/obs-adapter.d.ts.map +1 -0
- package/dist/adapters/obs-adapter.js +259 -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/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/api/index.d.ts +26 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +155 -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 +67 -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/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/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/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/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/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-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/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/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 +49 -0
- package/dist/components/inputs/workspace-launcher/workspace-launcher.scss +15 -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/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/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/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/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/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/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/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/useInitialValues.d.ts +9 -0
- package/dist/hooks/useInitialValues.d.ts.map +1 -0
- package/dist/hooks/useInitialValues.js +29 -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/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/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 +355 -0
- package/dist/processors/encounter/encounter-processor-helper.d.ts +17 -0
- package/dist/processors/encounter/encounter-processor-helper.d.ts.map +1 -0
- package/dist/processors/encounter/encounter-processor-helper.js +285 -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 +66 -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/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/types/domain.d.ts +214 -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 +242 -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 +260 -0
- package/dist/utils/common-expression-helpers.d.ts.map +1 -0
- package/dist/utils/common-expression-helpers.js +537 -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/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/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-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/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/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/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/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/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/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/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/package.json +10 -2
- package/.editorconfig +0 -12
- package/.eslintignore +0 -2
- package/.eslintrc +0 -59
- package/.husky/pre-commit +0 -6
- package/.husky/pre-push +0 -6
- package/.prettierignore +0 -4
- package/.swcrc +0 -20
- package/__mocks__/concepts.mock.json +0 -140
- package/__mocks__/forms/afe-forms/component-art.json +0 -38
- package/__mocks__/forms/afe-forms/component-preclinic-review.json +0 -38
- package/__mocks__/forms/afe-forms/demo-hts-form.json +0 -62
- package/__mocks__/forms/afe-forms/form-component.json +0 -38
- package/__mocks__/forms/afe-forms/index.ts +0 -9
- package/__mocks__/forms/afe-forms/mini-form.json +0 -31
- package/__mocks__/forms/afe-forms/nested-form1.json +0 -38
- package/__mocks__/forms/afe-forms/nested-form2.json +0 -38
- package/__mocks__/forms/afe-forms/test-orders.json +0 -72
- package/__mocks__/forms/afe-forms/test-schema-transformer-form.json +0 -88
- package/__mocks__/forms/index.ts +0 -19
- package/__mocks__/forms/rfe-forms/age-validation-form.json +0 -58
- package/__mocks__/forms/rfe-forms/bmi-test-form.json +0 -69
- package/__mocks__/forms/rfe-forms/bsa-test-form.json +0 -69
- package/__mocks__/forms/rfe-forms/component-art.json +0 -1705
- package/__mocks__/forms/rfe-forms/component-preclinic-review.json +0 -480
- package/__mocks__/forms/rfe-forms/conditional-answered-form.json +0 -97
- package/__mocks__/forms/rfe-forms/conditional-required-form.json +0 -280
- package/__mocks__/forms/rfe-forms/default-values-form.json +0 -91
- package/__mocks__/forms/rfe-forms/demo-hts-form.json +0 -346
- package/__mocks__/forms/rfe-forms/diagnosis-test-form.json +0 -60
- package/__mocks__/forms/rfe-forms/edd-test-form.json +0 -88
- package/__mocks__/forms/rfe-forms/expression-visit-object-test.json +0 -29
- package/__mocks__/forms/rfe-forms/external-data-source-form.json +0 -42
- package/__mocks__/forms/rfe-forms/filter-answer-options-test-form.json +0 -87
- package/__mocks__/forms/rfe-forms/form-component.json +0 -43
- package/__mocks__/forms/rfe-forms/forms-loader.test.schema.ts +0 -209
- package/__mocks__/forms/rfe-forms/hide-pages-and-sections-form.json +0 -93
- package/__mocks__/forms/rfe-forms/historical-expressions-form.json +0 -170
- package/__mocks__/forms/rfe-forms/index.ts +0 -51
- package/__mocks__/forms/rfe-forms/js-expression-validation-form.json +0 -54
- package/__mocks__/forms/rfe-forms/labour-and-delivery-test-form.json +0 -371
- package/__mocks__/forms/rfe-forms/mini-form.json +0 -29
- package/__mocks__/forms/rfe-forms/mock-historical-visits-encounter.json +0 -129
- package/__mocks__/forms/rfe-forms/mock-save-encounter.json +0 -18
- package/__mocks__/forms/rfe-forms/months-on-art-form.json +0 -90
- package/__mocks__/forms/rfe-forms/multi-select-form.json +0 -106
- package/__mocks__/forms/rfe-forms/nested-form1.json +0 -43
- package/__mocks__/forms/rfe-forms/nested-form2.json +0 -43
- package/__mocks__/forms/rfe-forms/next-visit-test-form.json +0 -78
- package/__mocks__/forms/rfe-forms/obs-group-test-form.json +0 -201
- package/__mocks__/forms/rfe-forms/obs-list-data.ts +0 -37
- package/__mocks__/forms/rfe-forms/post-submission-test-form.json +0 -116
- package/__mocks__/forms/rfe-forms/radio-button-form.json +0 -198
- package/__mocks__/forms/rfe-forms/read-only-validation-form.json +0 -63
- package/__mocks__/forms/rfe-forms/reference-by-mapping-form.json +0 -54
- package/__mocks__/forms/rfe-forms/required-form.json +0 -50
- package/__mocks__/forms/rfe-forms/sample-fields.json +0 -36
- package/__mocks__/forms/rfe-forms/sample-ui-select-ext.json +0 -47
- package/__mocks__/forms/rfe-forms/sample-unspecified-form.json +0 -39
- package/__mocks__/forms/rfe-forms/test-enrolment-form.json +0 -241
- package/__mocks__/forms/rfe-forms/treatment-end-date-test-form.json +0 -121
- package/__mocks__/forms/rfe-forms/viral-load-status-form.json +0 -75
- package/__mocks__/forms/rfe-forms/zscore-bmi-for-age-form.json +0 -79
- package/__mocks__/forms/rfe-forms/zscore-height-for-age-form.json +0 -79
- package/__mocks__/forms/rfe-forms/zscore-weight-height-form.json +0 -77
- package/__mocks__/index.ts +0 -85
- package/__mocks__/packages/hiv/forms/hts_poc/1.0.json +0 -8
- package/__mocks__/packages/hiv/forms/hts_poc/1.1.json +0 -96
- package/__mocks__/packages/test-forms-registry.ts +0 -12
- package/__mocks__/patient.mock.ts +0 -173
- package/__mocks__/react-i18next.js +0 -49
- package/__mocks__/react-markdown.tsx +0 -5
- package/__mocks__/session.mock.ts +0 -123
- package/__mocks__/single-spa-react.js +0 -6
- package/__mocks__/use-initial-values/encounter.mock.json +0 -963
- package/__mocks__/use-initial-values/patient.mock.json +0 -73
- package/__mocks__/visit.mock.ts +0 -19
- package/jest.config.js +0 -31
- package/prettier.config.js +0 -8
- package/src/adapters/encounter-diagnosis-adapter.test.ts +0 -232
- package/src/adapters/obs-adapter.test.ts +0 -1374
- package/src/adapters/program-state-adapter.test.ts +0 -417
- package/src/components/inputs/date/date.test.tsx +0 -87
- package/src/components/inputs/multi-select/multi-select.test.tsx +0 -95
- package/src/components/inputs/number/number.test.tsx +0 -109
- package/src/components/inputs/radio/radio.test.tsx +0 -196
- package/src/components/inputs/select/dropdown.test.tsx +0 -161
- package/src/components/inputs/text/text.test.tsx +0 -194
- package/src/components/inputs/ui-select-extended/ui-select-extended.test.tsx +0 -284
- package/src/components/inputs/unspecified/unspecified.test.tsx +0 -165
- package/src/components/inputs/workspace-launcher/workspace-launcher.test.tsx +0 -197
- package/src/components/renderer/field/fieldLogic.test.ts +0 -145
- package/src/components/renderer/field/fieldRenderUtils.test.ts +0 -69
- package/src/components/repeat/helpers.test.ts +0 -29
- package/src/components/repeat/repeat.test.ts +0 -29
- package/src/components/sidebar/useCurrentActivePage.test.ts +0 -221
- package/src/form-engine.test.tsx +0 -1292
- package/src/hooks/useFormJson.test.tsx +0 -197
- package/src/hooks/useFormWorkspaceSize.test.ts +0 -138
- package/src/hooks/useInitialValues.test.ts +0 -77
- package/src/hooks/usePostSubmissionActions.test.tsx +0 -40
- package/src/processors/encounter/encounter-form-processor.test.ts +0 -225
- package/src/registry/registry.test.ts +0 -20
- package/src/setup-tests.ts +0 -35
- package/src/transformers/default-schema-transformer.test.ts +0 -338
- package/src/utils/common-expression-helpers.test.ts +0 -479
- package/src/utils/common-utils.test.ts +0 -167
- package/src/utils/expression-runner.test.ts +0 -363
- package/src/utils/form-helper.test.ts +0 -664
- package/src/utils/forms-loader.test.ts +0 -341
- package/src/utils/test-utils.ts +0 -59
- package/src/validators/conditional-answered-validator.test.ts +0 -61
- package/src/validators/date-validator.test.ts +0 -46
- package/src/validators/default-value-validator.test.ts +0 -90
- package/src/validators/form-validator.test.ts +0 -188
- package/src/validators/js-expression-validator.test.ts +0 -118
- package/src/zscore-tests/bmi-age.test.tsx +0 -83
- package/src/zscore-tests/height-age.test.tsx +0 -91
- package/src/zscore-tests/weight-height.test.tsx +0 -82
- package/tools/i18next-parser.config.js +0 -93
- package/tools/update-openmrs-deps.mjs +0 -42
- package/tsconfig.build.json +0 -11
- package/tsconfig.json +0 -29
- package/turbo.json +0 -15
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/control-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkD,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtG,eAAO,MAAM,cAAc,EAAE,qBAwB5B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const ControlAdapter = {
|
|
2
|
+
getDisplayValue: (field, value)=>{
|
|
3
|
+
return value;
|
|
4
|
+
},
|
|
5
|
+
transformFieldValue: function(field, value, context) {
|
|
6
|
+
return null;
|
|
7
|
+
},
|
|
8
|
+
getInitialValue: function(field, sourceObject, context) {
|
|
9
|
+
return null;
|
|
10
|
+
},
|
|
11
|
+
getPreviousValue: function(field, sourceObject, context) {
|
|
12
|
+
return null;
|
|
13
|
+
},
|
|
14
|
+
tearDown: function() {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encounter-datetime-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/encounter-datetime-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,qBAAqB,EAE3B,MAAM,UAAU,CAAC;AAGlB,eAAO,MAAM,wBAAwB,EAAE,qBA2BtC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { formatDate } from "@openmrs/esm-framework";
|
|
2
|
+
import { gracefullySetSubmission } from "../utils/common-utils.js";
|
|
3
|
+
export const EncounterDatetimeAdapter = {
|
|
4
|
+
transformFieldValue: function(field, value, context) {
|
|
5
|
+
gracefullySetSubmission(field, value, null);
|
|
6
|
+
},
|
|
7
|
+
getInitialValue: function(field, sourceObject, context) {
|
|
8
|
+
return sourceObject?.encounterDatetime ? new Date(sourceObject.encounterDatetime) : context.sessionDate;
|
|
9
|
+
},
|
|
10
|
+
getPreviousValue: function(field, sourceObject, context) {
|
|
11
|
+
if (sourceObject?.encounterDatetime) {
|
|
12
|
+
const date = new Date(sourceObject.encounterDatetime);
|
|
13
|
+
return {
|
|
14
|
+
value: date,
|
|
15
|
+
display: this.getDisplayValue(field, date)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
},
|
|
20
|
+
getDisplayValue: function(field, value) {
|
|
21
|
+
return formatDate(value);
|
|
22
|
+
},
|
|
23
|
+
tearDown: function() {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type OpenmrsResource } from '@openmrs/esm-framework';
|
|
2
|
+
import { type FormFieldValueAdapter } from '../types';
|
|
3
|
+
export declare let assignedDiagnosesIds: string[];
|
|
4
|
+
export declare const EncounterDiagnosisAdapter: FormFieldValueAdapter;
|
|
5
|
+
export declare function hasPreviousDiagnosisValueChanged(previousDiagnosis: OpenmrsResource, newValue: string): boolean;
|
|
6
|
+
export declare function voidDiagnosis(diagnosis: OpenmrsResource): {
|
|
7
|
+
uuid: string;
|
|
8
|
+
voided: boolean;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=encounter-diagnosis-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encounter-diagnosis-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/encounter-diagnosis-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAEL,KAAK,qBAAqB,EAI3B,MAAM,UAAU,CAAC;AAMlB,eAAO,IAAI,oBAAoB,EAAE,MAAM,EAAO,CAAC;AAE/C,eAAO,MAAM,yBAAyB,EAAE,qBAyDvC,CAAC;AAuCF,wBAAgB,gCAAgC,CAAC,iBAAiB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,WAKpG;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,eAAe;;;EAEvD"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { gracefullySetSubmission } from "../utils/common-utils.js";
|
|
2
|
+
import { isEmpty } from "../validators/form-validator.js";
|
|
3
|
+
import { isTrue } from "../utils/boolean-utils.js";
|
|
4
|
+
export let assignedDiagnosesIds = [];
|
|
5
|
+
export const EncounterDiagnosisAdapter = {
|
|
6
|
+
transformFieldValue: function(field, value, context) {
|
|
7
|
+
if (field.meta.initialValue?.omrsObject && isEmpty(value)) {
|
|
8
|
+
return gracefullySetSubmission(field, undefined, voidDiagnosis(field.meta.initialValue.omrsObject));
|
|
9
|
+
}
|
|
10
|
+
if (!isEmpty(value)) {
|
|
11
|
+
const previousDiagnosis = field.meta.initialValue?.omrsObject;
|
|
12
|
+
if (hasPreviousDiagnosisValueChanged(previousDiagnosis, value)) {
|
|
13
|
+
return gracefullySetSubmission(field, editDiagnosis(value, field, previousDiagnosis, context.patient.id), undefined);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const newValue = constructNewDiagnosis(value, field, context.patient.id);
|
|
17
|
+
gracefullySetSubmission(field, newValue, null);
|
|
18
|
+
return newValue;
|
|
19
|
+
},
|
|
20
|
+
getInitialValue: function(field, sourceObject, context) {
|
|
21
|
+
const encounter = sourceObject ?? context.domainObjectValue;
|
|
22
|
+
const matchedDiagnosis = encounter.diagnoses.find((diagnosis)=>diagnosis.formFieldPath === `rfe-forms-${field.id}`);
|
|
23
|
+
if (matchedDiagnosis) {
|
|
24
|
+
field.meta = {
|
|
25
|
+
...field.meta || {},
|
|
26
|
+
initialValue: {
|
|
27
|
+
omrsObject: matchedDiagnosis,
|
|
28
|
+
refinedValue: matchedDiagnosis.diagnosis?.coded.uuid
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
if (!assignedDiagnosesIds.includes(matchedDiagnosis.diagnosis?.coded?.uuid)) {
|
|
32
|
+
assignedDiagnosesIds.push(matchedDiagnosis.diagnosis?.coded?.uuid);
|
|
33
|
+
}
|
|
34
|
+
return matchedDiagnosis.diagnosis?.coded.uuid;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
},
|
|
38
|
+
getPreviousValue: function(field, sourceObject, context) {
|
|
39
|
+
return null;
|
|
40
|
+
},
|
|
41
|
+
getDisplayValue: (field, value)=>{
|
|
42
|
+
return field.questionOptions.answers?.find((option)=>option.concept == value)?.label || value;
|
|
43
|
+
},
|
|
44
|
+
tearDown: function() {
|
|
45
|
+
assignedDiagnosesIds = [];
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const constructNewDiagnosis = (value, field, patientUuid)=>{
|
|
49
|
+
if (!value) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
patient: patientUuid,
|
|
54
|
+
condition: null,
|
|
55
|
+
diagnosis: {
|
|
56
|
+
coded: value
|
|
57
|
+
},
|
|
58
|
+
certainty: isTrue(field.questionOptions?.diagnosis?.isConfirmed) ? 'CONFIRMED' : 'PROVISIONAL',
|
|
59
|
+
rank: field.questionOptions.diagnosis?.rank ?? 1,
|
|
60
|
+
formFieldPath: `rfe-forms-${field.id}`,
|
|
61
|
+
formFieldNamespace: 'rfe-forms'
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
function editDiagnosis(newEncounterDiagnosis, field, previousDiagnosis, patientUuid) {
|
|
65
|
+
return {
|
|
66
|
+
patient: patientUuid,
|
|
67
|
+
condition: null,
|
|
68
|
+
diagnosis: {
|
|
69
|
+
coded: newEncounterDiagnosis
|
|
70
|
+
},
|
|
71
|
+
certainty: isTrue(field.questionOptions?.diagnosis?.isConfirmed) ? 'CONFIRMED' : 'PROVISIONAL',
|
|
72
|
+
rank: field.questionOptions.diagnosis?.rank ?? 1,
|
|
73
|
+
formFieldPath: `rfe-forms-${field.id}`,
|
|
74
|
+
formFieldNamespace: 'rfe-forms',
|
|
75
|
+
uuid: previousDiagnosis.uuid
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export function hasPreviousDiagnosisValueChanged(previousDiagnosis, newValue) {
|
|
79
|
+
if (isEmpty(previousDiagnosis)) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
return previousDiagnosis.value !== newValue;
|
|
83
|
+
}
|
|
84
|
+
export function voidDiagnosis(diagnosis) {
|
|
85
|
+
return {
|
|
86
|
+
uuid: diagnosis.uuid,
|
|
87
|
+
voided: true
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encounter-location-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/encounter-location-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,qBAAqB,EAE3B,MAAM,UAAU,CAAC;AAGlB,eAAO,MAAM,wBAAwB,EAAE,qBA4BtC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { gracefullySetSubmission } from "../utils/common-utils.js";
|
|
2
|
+
export const EncounterLocationAdapter = {
|
|
3
|
+
transformFieldValue: function(field, value, context) {
|
|
4
|
+
gracefullySetSubmission(field, value, null);
|
|
5
|
+
},
|
|
6
|
+
getInitialValue: function(field, sourceObject, context) {
|
|
7
|
+
if (sourceObject && sourceObject['location']?.uuid) {
|
|
8
|
+
return sourceObject['location'].uuid;
|
|
9
|
+
}
|
|
10
|
+
return context.location.uuid;
|
|
11
|
+
},
|
|
12
|
+
getPreviousValue: function(field, sourceObject, context) {
|
|
13
|
+
const encounter = sourceObject ?? context.previousDomainObjectValue;
|
|
14
|
+
return {
|
|
15
|
+
value: encounter?.location?.uuid,
|
|
16
|
+
display: encounter?.location?.name
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
getDisplayValue: function(field, value) {
|
|
20
|
+
return value;
|
|
21
|
+
},
|
|
22
|
+
tearDown: function() {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encounter-provider-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/encounter-provider-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,qBAAqB,EAE3B,MAAM,UAAU,CAAC;AAGlB,eAAO,MAAM,wBAAwB,EAAE,qBA6BtC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { gracefullySetSubmission } from "../utils/common-utils.js";
|
|
2
|
+
export const EncounterProviderAdapter = {
|
|
3
|
+
transformFieldValue: function(field, value, context) {
|
|
4
|
+
gracefullySetSubmission(field, value, null);
|
|
5
|
+
},
|
|
6
|
+
getInitialValue: function(field, sourceObject, context) {
|
|
7
|
+
const encounter = sourceObject ?? context.previousDomainObjectValue;
|
|
8
|
+
return getLatestProvider(encounter)?.uuid;
|
|
9
|
+
},
|
|
10
|
+
getPreviousValue: function(field, sourceObject, context) {
|
|
11
|
+
const encounter = sourceObject ?? context.previousDomainObjectValue;
|
|
12
|
+
const provider = getLatestProvider(encounter);
|
|
13
|
+
return {
|
|
14
|
+
value: provider?.uuid,
|
|
15
|
+
display: provider?.name
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
getDisplayValue: function(field, value) {
|
|
19
|
+
if (value?.display) {
|
|
20
|
+
return value.display;
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
},
|
|
24
|
+
tearDown: function() {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
function getLatestProvider(encounter) {
|
|
29
|
+
if (encounter && encounter['encounterProviders']?.length) {
|
|
30
|
+
const lastProviderIndex = encounter['encounterProviders'].length - 1;
|
|
31
|
+
return encounter['encounterProviders'][lastProviderIndex].provider;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encounter-role-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/encounter-role-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,qBAAqB,EAE3B,MAAM,UAAU,CAAC;AAGlB,eAAO,MAAM,oBAAoB,EAAE,qBAmClC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { gracefullySetSubmission } from "../utils/common-utils.js";
|
|
2
|
+
export const EncounterRoleAdapter = {
|
|
3
|
+
transformFieldValue: function(field, value, context) {
|
|
4
|
+
gracefullySetSubmission(field, value, null);
|
|
5
|
+
},
|
|
6
|
+
getInitialValue: function(field, sourceObject, context) {
|
|
7
|
+
const encounter = sourceObject ?? context.domainObjectValue;
|
|
8
|
+
if (encounter) {
|
|
9
|
+
return getLatestEncounterRole(encounter)?.uuid;
|
|
10
|
+
}
|
|
11
|
+
return context.customDependencies.defaultEncounterRole.uuid;
|
|
12
|
+
},
|
|
13
|
+
getPreviousValue: function(field, sourceObject, context) {
|
|
14
|
+
const encounter = sourceObject ?? context.previousDomainObjectValue;
|
|
15
|
+
if (encounter) {
|
|
16
|
+
const role = getLatestEncounterRole(encounter);
|
|
17
|
+
return {
|
|
18
|
+
value: role?.uuid,
|
|
19
|
+
display: role?.name
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
},
|
|
24
|
+
getDisplayValue: function(field, value) {
|
|
25
|
+
if (value?.display) {
|
|
26
|
+
return value.display;
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
},
|
|
30
|
+
tearDown: function() {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
function getLatestEncounterRole(encounter) {
|
|
35
|
+
if (encounter && encounter['encounterProviders']?.length) {
|
|
36
|
+
const lastProviderIndex = encounter['encounterProviders'].length - 1;
|
|
37
|
+
return encounter['encounterProviders'][lastProviderIndex].encounterRole;
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-date-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/inline-date-adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAkB,KAAK,qBAAqB,EAAkC,MAAM,UAAU,CAAC;AAItG,eAAO,MAAM,iBAAiB,EAAE,qBAkD/B,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { formatDate, parseDate, toOmrsIsoString } from "@openmrs/esm-framework";
|
|
2
|
+
import { isNewSubmissionEffective } from "./obs-comment-adapter.js";
|
|
3
|
+
import { isEmpty } from "../validators/form-validator.js";
|
|
4
|
+
import { hasSubmission } from "../utils/common-utils.js";
|
|
5
|
+
import { editObs } from "./obs-adapter.js";
|
|
6
|
+
export const InlineDateAdapter = {
|
|
7
|
+
transformFieldValue: function(field, value, context) {
|
|
8
|
+
const targetField = context.getFormField(field.meta.targetField);
|
|
9
|
+
const targetFieldCurrentValue = context.methods.getValues(targetField.id);
|
|
10
|
+
const dateString = value instanceof Date ? toOmrsIsoString(value) : value;
|
|
11
|
+
if (targetField.meta.submission?.newValue) {
|
|
12
|
+
if (isEmpty(dateString) && !isNewSubmissionEffective(targetField, targetFieldCurrentValue)) {
|
|
13
|
+
// clear submission
|
|
14
|
+
targetField.meta.submission.newValue = null;
|
|
15
|
+
} else {
|
|
16
|
+
targetField.meta.submission.newValue.obsDatetime = dateString;
|
|
17
|
+
}
|
|
18
|
+
} else if (!hasSubmission(targetField) && targetField.meta.initialValue?.omrsObject) {
|
|
19
|
+
if (isEmpty(value) && isEmpty(targetField.meta.initialValue.omrsObject?.obsDatetime)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
// generate submission
|
|
23
|
+
const newSubmission = editObs(targetField, targetFieldCurrentValue);
|
|
24
|
+
targetField.meta.submission = {
|
|
25
|
+
newValue: {
|
|
26
|
+
...newSubmission,
|
|
27
|
+
obsDatetime: dateString
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
getInitialValue: function(field, sourceObject, context) {
|
|
33
|
+
const encounter = sourceObject ?? context.domainObjectValue;
|
|
34
|
+
if (encounter) {
|
|
35
|
+
const targetFieldId = field.id.split('_inline_date')[0];
|
|
36
|
+
const targetField = context.formFields.find((field)=>field.id === targetFieldId);
|
|
37
|
+
const targetFieldInitialObs = targetField?.meta.initialValue?.omrsObject;
|
|
38
|
+
if (targetFieldInitialObs?.obsDatetime) {
|
|
39
|
+
return parseDate(targetFieldInitialObs.obsDatetime);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
},
|
|
44
|
+
getPreviousValue: function(field, sourceObject, context) {
|
|
45
|
+
return null;
|
|
46
|
+
},
|
|
47
|
+
getDisplayValue: function(field, value) {
|
|
48
|
+
if (value) {
|
|
49
|
+
return formatDate(value);
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
},
|
|
53
|
+
tearDown: function() {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type OpenmrsObs, type FormField, type FormFieldValueAdapter } from '../types';
|
|
2
|
+
export declare let assignedObsIds: string[];
|
|
3
|
+
export declare const ObsAdapter: FormFieldValueAdapter;
|
|
4
|
+
export declare function constructObs(field: FormField, value: any): Partial<OpenmrsObs>;
|
|
5
|
+
export declare function voidObs(obs: OpenmrsObs): {
|
|
6
|
+
uuid: string;
|
|
7
|
+
voided: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function editObs(field: FormField, newValue: any): {
|
|
10
|
+
uuid: string;
|
|
11
|
+
value: any;
|
|
12
|
+
formFieldNamespace: string;
|
|
13
|
+
formFieldPath: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function hasPreviousObsValueChanged(field: FormField, newValue: any): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves a list of observations from a given `obsList` that correspond to the specified field.
|
|
18
|
+
*
|
|
19
|
+
* Notes:
|
|
20
|
+
* If the query by field-path returns an empty list, the function falls back to querying
|
|
21
|
+
* by concept and uses `claimedObsIds` to exclude already assigned observations.
|
|
22
|
+
*/
|
|
23
|
+
export declare function findObsByFormField(obsList: Array<OpenmrsObs>, claimedObsIds: string[], field: FormField): OpenmrsObs[];
|
|
24
|
+
//# sourceMappingURL=obs-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obs-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/obs-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,SAAS,EAGd,KAAK,qBAAqB,EAC3B,MAAM,UAAU,CAAC;AAclB,eAAO,IAAI,cAAc,EAAE,MAAM,EAAO,CAAC;AAEzC,eAAO,MAAM,UAAU,EAAE,qBAyExB,CAAC;AAkDF,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAgB9E;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,UAAU;;;EAEtC;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG;;;;;EAWtD;AAkBD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,WAkBzE;AA+CD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,EAC1B,aAAa,EAAE,MAAM,EAAE,EACvB,KAAK,EAAE,SAAS,GACf,UAAU,EAAE,CAmBd"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import { ConceptTrue, codedTypes } from "../constants.js";
|
|
3
|
+
import { hasRendering, gracefullySetSubmission, clearSubmission, flattenObsList, parseToLocalDateTime, formatDateAsDisplayString } from "../utils/common-utils.js";
|
|
4
|
+
import { isEmpty } from "../validators/form-validator.js";
|
|
5
|
+
import { attachmentUrl, getAttachmentByUuid } from "@openmrs/esm-framework";
|
|
6
|
+
// Temporarily holds observations that have already been bound with matching fields
|
|
7
|
+
export let assignedObsIds = [];
|
|
8
|
+
export const ObsAdapter = {
|
|
9
|
+
async getInitialValue (field, sourceObject, context) {
|
|
10
|
+
const encounter = sourceObject ?? context.domainObjectValue;
|
|
11
|
+
const matchingObs = findObsByFormField(flattenObsList(encounter.obs), assignedObsIds, field);
|
|
12
|
+
if (hasRendering(field, 'file') && matchingObs?.length) {
|
|
13
|
+
return resolveAttachmentsFromObs(field, matchingObs);
|
|
14
|
+
}
|
|
15
|
+
return extractFieldValue(field, matchingObs, true);
|
|
16
|
+
},
|
|
17
|
+
async getPreviousValue (field, sourceObject, context) {
|
|
18
|
+
const encounter = sourceObject ?? context.previousDomainObjectValue;
|
|
19
|
+
if (encounter) {
|
|
20
|
+
const value = extractFieldValue(field, findObsByFormField(flattenObsList(encounter.obs), assignedObsIds, field), true);
|
|
21
|
+
if (!isEmpty(value)) {
|
|
22
|
+
return {
|
|
23
|
+
value,
|
|
24
|
+
display: this.getDisplayValue(field, value)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
},
|
|
30
|
+
getDisplayValue: (field, value)=>{
|
|
31
|
+
const rendering = field.questionOptions.rendering;
|
|
32
|
+
if (isEmpty(value)) {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
if (value instanceof Date) {
|
|
36
|
+
return formatDateAsDisplayString(field, value);
|
|
37
|
+
}
|
|
38
|
+
if (rendering === 'checkbox') {
|
|
39
|
+
return value.map((selected)=>field.questionOptions.answers?.find((option)=>option.concept == selected)?.label);
|
|
40
|
+
}
|
|
41
|
+
if (rendering === 'toggle') {
|
|
42
|
+
return value ? field.questionOptions.toggleOptions.labelTrue : field.questionOptions.toggleOptions.labelFalse;
|
|
43
|
+
}
|
|
44
|
+
if (codedTypes.includes(rendering)) {
|
|
45
|
+
return field.questionOptions.answers?.find((option)=>option.concept == value)?.label;
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
},
|
|
49
|
+
transformFieldValue: (field, value, context)=>{
|
|
50
|
+
// clear previous submission
|
|
51
|
+
clearSubmission(field);
|
|
52
|
+
if (!field.meta.initialValue?.omrsObject && isEmpty(value)) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (hasRendering(field, 'checkbox')) {
|
|
56
|
+
return handleMultiSelect(field, Array.isArray(value) ? value : [
|
|
57
|
+
value
|
|
58
|
+
]);
|
|
59
|
+
}
|
|
60
|
+
if (hasRendering(field, 'file')) {
|
|
61
|
+
return handleAttachments(field, value);
|
|
62
|
+
}
|
|
63
|
+
if (!isEmpty(value) && hasPreviousObsValueChanged(field, value)) {
|
|
64
|
+
return gracefullySetSubmission(field, editObs(field, value), undefined);
|
|
65
|
+
}
|
|
66
|
+
if (field.meta.initialValue?.omrsObject && isEmpty(value)) {
|
|
67
|
+
return gracefullySetSubmission(field, undefined, voidObs(field.meta.initialValue.omrsObject));
|
|
68
|
+
}
|
|
69
|
+
if (!isEmpty(value)) {
|
|
70
|
+
return gracefullySetSubmission(field, constructObs(field, value), undefined);
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
},
|
|
74
|
+
tearDown: function() {
|
|
75
|
+
assignedObsIds = [];
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
// Helpers
|
|
79
|
+
/**
|
|
80
|
+
* Extracts field's primitive value from obs
|
|
81
|
+
*/ function extractFieldValue(field, obsList = [], makeFieldDirty = false) {
|
|
82
|
+
const rendering = field.questionOptions.rendering;
|
|
83
|
+
if (!field.meta) {
|
|
84
|
+
field.meta = {
|
|
85
|
+
initialValue: {
|
|
86
|
+
omrsObject: null,
|
|
87
|
+
refinedValue: null
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
if (obsList.length) {
|
|
92
|
+
if (rendering == 'checkbox') {
|
|
93
|
+
assignedObsIds.push(...obsList.map((obs)=>obs.uuid));
|
|
94
|
+
field.meta.initialValue.omrsObject = makeFieldDirty ? obsList : null;
|
|
95
|
+
return obsList.map((o)=>o.value.uuid);
|
|
96
|
+
}
|
|
97
|
+
const obs = obsList[0];
|
|
98
|
+
if (makeFieldDirty) {
|
|
99
|
+
field.meta.initialValue.omrsObject = {
|
|
100
|
+
...obs
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
assignedObsIds.push(obs.uuid);
|
|
104
|
+
if (typeof obs.value === 'string' || typeof obs.value === 'number') {
|
|
105
|
+
if (rendering.startsWith('date')) {
|
|
106
|
+
const dateObject = parseToLocalDateTime(obs.value);
|
|
107
|
+
if (makeFieldDirty) {
|
|
108
|
+
const obsObject = field.meta.initialValue.omrsObject;
|
|
109
|
+
obsObject.value = dayjs(dateObject).format('YYYY-MM-DD HH:mm');
|
|
110
|
+
}
|
|
111
|
+
return dateObject;
|
|
112
|
+
}
|
|
113
|
+
return obs.value;
|
|
114
|
+
}
|
|
115
|
+
if (rendering == 'toggle') {
|
|
116
|
+
return obs.value.uuid === ConceptTrue;
|
|
117
|
+
}
|
|
118
|
+
if (rendering == 'fixed-value') {
|
|
119
|
+
return field['fixedValue'];
|
|
120
|
+
}
|
|
121
|
+
return obs.value?.uuid;
|
|
122
|
+
}
|
|
123
|
+
return '';
|
|
124
|
+
}
|
|
125
|
+
export function constructObs(field, value) {
|
|
126
|
+
if (isEmpty(value) && field.type !== 'obsGroup') {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
const draftObs = field.type === 'obsGroup' ? {
|
|
130
|
+
groupMembers: []
|
|
131
|
+
} : {
|
|
132
|
+
value: field.questionOptions.rendering.startsWith('date') ? formatDateByPickerType(field, value) : value
|
|
133
|
+
};
|
|
134
|
+
return {
|
|
135
|
+
...draftObs,
|
|
136
|
+
concept: field.questionOptions.concept,
|
|
137
|
+
formFieldNamespace: 'rfe-forms',
|
|
138
|
+
formFieldPath: `rfe-forms-${field.id}`
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
export function voidObs(obs) {
|
|
142
|
+
return {
|
|
143
|
+
uuid: obs.uuid,
|
|
144
|
+
voided: true
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
export function editObs(field, newValue) {
|
|
148
|
+
const oldObs = field.meta.initialValue?.omrsObject;
|
|
149
|
+
const formattedValue = field.questionOptions.rendering.startsWith('date') ? formatDateByPickerType(field, newValue) : newValue;
|
|
150
|
+
return {
|
|
151
|
+
uuid: oldObs.uuid,
|
|
152
|
+
value: formattedValue,
|
|
153
|
+
formFieldNamespace: 'rfe-forms',
|
|
154
|
+
formFieldPath: `rfe-forms-${field.id}`
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function formatDateByPickerType(field, value) {
|
|
158
|
+
if (field.datePickerFormat) {
|
|
159
|
+
switch(field.datePickerFormat){
|
|
160
|
+
case 'calendar':
|
|
161
|
+
return dayjs(value).format('YYYY-MM-DD');
|
|
162
|
+
case 'timer':
|
|
163
|
+
return dayjs(value).format('HH:mm');
|
|
164
|
+
case 'both':
|
|
165
|
+
return dayjs(value).format('YYYY-MM-DD HH:mm');
|
|
166
|
+
default:
|
|
167
|
+
return dayjs(value).format('YYYY-MM-DD');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return value;
|
|
171
|
+
}
|
|
172
|
+
export function hasPreviousObsValueChanged(field, newValue) {
|
|
173
|
+
const previousObs = field.meta.initialValue?.omrsObject;
|
|
174
|
+
if (isEmpty(previousObs)) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
if (codedTypes.includes(field.questionOptions.rendering)) {
|
|
178
|
+
return previousObs.value.uuid !== newValue;
|
|
179
|
+
}
|
|
180
|
+
if (hasRendering(field, 'date')) {
|
|
181
|
+
return dayjs(newValue).diff(dayjs(previousObs.value), 'D') !== 0;
|
|
182
|
+
}
|
|
183
|
+
if (hasRendering(field, 'datetime') || field.datePickerFormat === 'both') {
|
|
184
|
+
return dayjs(newValue).diff(dayjs(previousObs.value), 'minute') !== 0;
|
|
185
|
+
}
|
|
186
|
+
if (hasRendering(field, 'toggle')) {
|
|
187
|
+
return previousObs.value.uuid === ConceptTrue !== newValue;
|
|
188
|
+
}
|
|
189
|
+
return previousObs.value !== newValue;
|
|
190
|
+
}
|
|
191
|
+
function handleMultiSelect(field, values = []) {
|
|
192
|
+
// three possible scenarios
|
|
193
|
+
// 1. we have a previous value and an empty current value
|
|
194
|
+
// 2. a mix of both (previous and current)
|
|
195
|
+
// 3. we only have a current value
|
|
196
|
+
const obsArray = field.meta.initialValue?.omrsObject;
|
|
197
|
+
if (obsArray?.length && isEmpty(values)) {
|
|
198
|
+
// we assume the user cleared the existing value(s)
|
|
199
|
+
// so we void all previous values
|
|
200
|
+
return gracefullySetSubmission(field, null, obsArray.map((previousValue)=>voidObs(previousValue)));
|
|
201
|
+
}
|
|
202
|
+
if (obsArray?.length && !isEmpty(values)) {
|
|
203
|
+
const toBeVoided = obsArray.filter((obs)=>!values.includes(obs.value.uuid));
|
|
204
|
+
const toBeCreated = values.filter((v)=>!obsArray.some((obs)=>obs.value.uuid === v));
|
|
205
|
+
return gracefullySetSubmission(field, toBeCreated.map((value)=>constructObs(field, value)), toBeVoided.map((obs)=>voidObs(obs)));
|
|
206
|
+
}
|
|
207
|
+
return gracefullySetSubmission(field, values.map((value)=>constructObs(field, value)), undefined);
|
|
208
|
+
}
|
|
209
|
+
function handleAttachments(field, attachments = []) {
|
|
210
|
+
const voided = attachments.filter((attachment)=>attachment.uuid && attachment.voided).map((voided)=>({
|
|
211
|
+
uuid: voided.uuid,
|
|
212
|
+
voided: true
|
|
213
|
+
}));
|
|
214
|
+
const newAttachments = field.meta.submission.newValue = attachments.filter((attachment)=>!attachment.uuid).map((newAttachment)=>({
|
|
215
|
+
formFieldNamespace: 'rfe-forms',
|
|
216
|
+
formFieldPath: `rfe-forms-${field.id}`,
|
|
217
|
+
...newAttachment
|
|
218
|
+
}));
|
|
219
|
+
return gracefullySetSubmission(field, newAttachments, voided);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Retrieves a list of observations from a given `obsList` that correspond to the specified field.
|
|
223
|
+
*
|
|
224
|
+
* Notes:
|
|
225
|
+
* If the query by field-path returns an empty list, the function falls back to querying
|
|
226
|
+
* by concept and uses `claimedObsIds` to exclude already assigned observations.
|
|
227
|
+
*/ export function findObsByFormField(obsList, claimedObsIds, field) {
|
|
228
|
+
const obs = obsList.filter((candidate)=>{
|
|
229
|
+
// we ignore the concept for attachments because they're managed from the backend
|
|
230
|
+
if (hasRendering(field, 'file') && candidate.formFieldPath == `rfe-forms-${field.id}`) {
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
return candidate.formFieldPath == `rfe-forms-${field.id}` && candidate.concept.uuid == field.questionOptions.concept;
|
|
234
|
+
});
|
|
235
|
+
// We shall fall back to mapping by the associated concept
|
|
236
|
+
// That being said, we shall find all matching obs and pick the one that wasn't previously claimed.
|
|
237
|
+
if (!obs?.length) {
|
|
238
|
+
const obsByConcept = obsList.filter((obs)=>obs.concept.uuid == field.questionOptions.concept);
|
|
239
|
+
return claimedObsIds?.length ? obsByConcept.filter((obs)=>!claimedObsIds.includes(obs.uuid)) : obsByConcept;
|
|
240
|
+
}
|
|
241
|
+
return obs;
|
|
242
|
+
}
|
|
243
|
+
async function resolveAttachmentsFromObs(field, obs) {
|
|
244
|
+
const abortController = new AbortController();
|
|
245
|
+
const attachments = await Promise.all(obs.map((obs)=>getAttachmentByUuid(obs.uuid, abortController).then((response)=>response.data).catch((error)=>{
|
|
246
|
+
console.error(`Failed to fetch attachment ${obs.uuid}:`, error);
|
|
247
|
+
return null;
|
|
248
|
+
})));
|
|
249
|
+
field.meta.initialValue = {
|
|
250
|
+
omrsObject: obs
|
|
251
|
+
};
|
|
252
|
+
return attachments.filter(Boolean).map((attachment)=>({
|
|
253
|
+
uuid: attachment.uuid,
|
|
254
|
+
base64Content: `${window.openmrsBase}${attachmentUrl}/${attachment.uuid}/bytes`,
|
|
255
|
+
fileName: attachment.filename,
|
|
256
|
+
fileDescription: attachment.comment,
|
|
257
|
+
fileType: attachment.bytesContentFamily?.toLowerCase()
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type FormField, type FormFieldValueAdapter } from '../types';
|
|
2
|
+
export declare const ObsCommentAdapter: FormFieldValueAdapter;
|
|
3
|
+
export declare function isNewSubmissionEffective(targetField: FormField, targetFieldCurrentValue: any): boolean;
|
|
4
|
+
//# sourceMappingURL=obs-comment-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obs-comment-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/obs-comment-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,qBAAqB,EAAkC,MAAM,UAAU,CAAC;AAKtG,eAAO,MAAM,iBAAiB,EAAE,qBA8C/B,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,SAAS,EAAE,uBAAuB,EAAE,GAAG,WAK5F"}
|