@openmrs/esm-report-builder 0.1.1-pre.87
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/.eslintignore +5 -0
- package/.eslintrc.js +19 -0
- package/.prettierrc +8 -0
- package/.tx/config +12 -0
- package/LICENSE +401 -0
- package/README.md +336 -0
- package/__mocks__/react-i18next.js +12 -0
- package/dist/162.js +1 -0
- package/dist/162.js.map +1 -0
- package/dist/184.js +2 -0
- package/dist/184.js.LICENSE.txt +14 -0
- package/dist/184.js.map +1 -0
- package/dist/242.js +2 -0
- package/dist/242.js.LICENSE.txt +21 -0
- package/dist/242.js.map +1 -0
- package/dist/253.js +1 -0
- package/dist/253.js.map +1 -0
- package/dist/300.js +1 -0
- package/dist/311.js +1 -0
- package/dist/311.js.map +1 -0
- package/dist/469.js +2 -0
- package/dist/469.js.LICENSE.txt +45 -0
- package/dist/469.js.map +1 -0
- package/dist/478.js +2 -0
- package/dist/478.js.LICENSE.txt +9 -0
- package/dist/478.js.map +1 -0
- package/dist/539.js +1 -0
- package/dist/539.js.map +1 -0
- package/dist/540.js +2 -0
- package/dist/540.js.LICENSE.txt +9 -0
- package/dist/540.js.map +1 -0
- package/dist/669.js +1 -0
- package/dist/669.js.map +1 -0
- package/dist/710.js +1 -0
- package/dist/710.js.map +1 -0
- package/dist/729.js +1 -0
- package/dist/729.js.map +1 -0
- package/dist/838.js +2 -0
- package/dist/838.js.LICENSE.txt +9 -0
- package/dist/838.js.map +1 -0
- package/dist/917.js +1 -0
- package/dist/917.js.map +1 -0
- package/dist/961.js +2 -0
- package/dist/961.js.LICENSE.txt +19 -0
- package/dist/961.js.map +1 -0
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -0
- package/dist/openmrs-esm-report-builder.js +1 -0
- package/dist/openmrs-esm-report-builder.js.buildmanifest.json +530 -0
- package/dist/openmrs-esm-report-builder.js.map +1 -0
- package/dist/routes.json +1 -0
- package/e2e/core/env.ts +5 -0
- package/e2e/core/global-setup.ts +34 -0
- package/e2e/core/test.ts +21 -0
- package/e2e/pages/app-shell.page.ts +34 -0
- package/e2e/pages/etl-sources.page.ts +35 -0
- package/e2e/pages/report-sections.page.ts +20 -0
- package/e2e/pages/section-preview.modal.ts +29 -0
- package/e2e/specs/etl-sources.spec.ts +51 -0
- package/e2e/specs/navigation.spec.ts +13 -0
- package/e2e/specs/section-preview-validation.spec.ts +38 -0
- package/e2e/specs/section-preview.spec.ts +94 -0
- package/e2e/support/github/Dockerfile +22 -0
- package/e2e/support/github/Dockerfile.dockerignore +13 -0
- package/e2e/support/github/docker-compose.yml +31 -0
- package/e2e/support/github/run-e2e-docker-env.sh +131 -0
- package/e2e/support/github/spa-assemble-config.json +9 -0
- package/e2e/tsconfig.json +11 -0
- package/example.env +5 -0
- package/jest.config.js +28 -0
- package/linelist_report_builder_design_spec.md +816 -0
- package/package.json +111 -0
- package/playwright.config.ts +28 -0
- package/routes.json +22 -0
- package/src/__debug__/all-designs.test.tsx +30 -0
- package/src/admin-card-link.extension.module.scss +55 -0
- package/src/admin-card-link.extension.tsx +24 -0
- package/src/components/admin/admin-page.component.tsx +75 -0
- package/src/components/admin/age-categories-page.component.tsx +109 -0
- package/src/components/admin/age-groups-page.component.tsx +146 -0
- package/src/components/admin/etl-browser/columns-tab.component.tsx +80 -0
- package/src/components/admin/etl-browser/etl-browser-page.component.tsx +309 -0
- package/src/components/admin/etl-browser/etl-browser.component.scss +424 -0
- package/src/components/admin/etl-browser/metadata-tab.component.tsx +65 -0
- package/src/components/admin/etl-browser/preview-grid.component.tsx +189 -0
- package/src/components/admin/etl-browser/relationships-tab.component.tsx +21 -0
- package/src/components/admin/etl-browser/sources-tree.component.tsx +118 -0
- package/src/components/admin/etl-browser/table-detail.component.tsx +124 -0
- package/src/components/admin/etl-browser/table-info-strip.component.tsx +51 -0
- package/src/components/admin/etl-browser/table-list.component.tsx +136 -0
- package/src/components/admin/etl-browser/use-table-preview.ts +47 -0
- package/src/components/admin/etl-sources-page.component.tsx +355 -0
- package/src/components/admin/etl-tasks-page.component.scss +370 -0
- package/src/components/admin/etl-tasks-page.component.tsx +768 -0
- package/src/components/admin/report-categories-page.component.tsx +267 -0
- package/src/components/admin/report-library-page.component.tsx +551 -0
- package/src/components/ai-support/ai-assist-button.component.tsx +30 -0
- package/src/components/ai-support/ai-assist-modal.component.tsx +81 -0
- package/src/components/ai-support/ai.service.ts +21 -0
- package/src/components/ai-support/ai.types.ts +12 -0
- package/src/components/app-shell/report-builder-shell.component.tsx +242 -0
- package/src/components/app-shell/report-builder-shell.scss +18 -0
- package/src/components/dashboards/dashboard-config.schema.ts +97 -0
- package/src/components/dashboards/dashboard-form-modal.component.tsx +150 -0
- package/src/components/dashboards/dashboards-admin.scss +62 -0
- package/src/components/dashboards/dashboards-page.component.tsx +153 -0
- package/src/components/dashboards/dashboards-table.component.tsx +130 -0
- package/src/components/dashboards/sections/dashboard-autoinclude.section.tsx +75 -0
- package/src/components/dashboards/sections/dashboard-basics.section.tsx +80 -0
- package/src/components/dashboards/sections/dashboard-json.section.tsx +79 -0
- package/src/components/dashboards/sections/dashboard-sections-editor.section.tsx +130 -0
- package/src/components/dashboards/sections/dashboard-widgets-editor.section.tsx +184 -0
- package/src/components/data-themes/data-theme-form.component.tsx +59 -0
- package/src/components/data-themes/data-theme-modal.component.tsx +349 -0
- package/src/components/data-themes/data-themes-page.component.tsx +139 -0
- package/src/components/data-themes/data-themes-table.component.tsx +98 -0
- package/src/components/data-themes/icon-registry.ts +35 -0
- package/src/components/data-themes/sections/data-theme-basics.section.tsx +63 -0
- package/src/components/data-themes/sections/data-theme-condition-columns.section.tsx +397 -0
- package/src/components/data-themes/sections/data-theme-fields-editor.section.tsx +125 -0
- package/src/components/data-themes/sections/data-theme-metadata.section.tsx +245 -0
- package/src/components/data-themes/sections/data-theme-preview.section.tsx +115 -0
- package/src/components/data-themes/sections/data-theme-source.section.tsx +184 -0
- package/src/components/data-visualizer/components/cqi-components/cqi-data-table.component.tsx +214 -0
- package/src/components/data-visualizer/components/cqi-components/cqi-elements.ts +203 -0
- package/src/components/data-visualizer/components/cqi-components/detail.component.tsx +110 -0
- package/src/components/data-visualizer/components/cqi-components/detail.scss +22 -0
- package/src/components/data-visualizer/components/data-table/data-table.component.tsx +208 -0
- package/src/components/data-visualizer/components/data-table/data-tables.scss +206 -0
- package/src/components/data-visualizer/components/empty-state/empty-state-illustration.component.tsx +53 -0
- package/src/components/data-visualizer/components/header/header.component.tsx +43 -0
- package/src/components/data-visualizer/components/header/header.scss +71 -0
- package/src/components/data-visualizer/components/model/confirm.component.tsx +40 -0
- package/src/components/data-visualizer/components/panel/panel.component.tsx +20 -0
- package/src/components/data-visualizer/components/panel/panel.scss +25 -0
- package/src/components/data-visualizer/components/popover/modifier-panel.tsx +53 -0
- package/src/components/data-visualizer/constants.ts +445 -0
- package/src/components/data-visualizer/data-visualizer-illustration.component.tsx +31 -0
- package/src/components/data-visualizer/data-visualizer.component.tsx +1935 -0
- package/src/components/data-visualizer/data-visualizer.resource.ts +462 -0
- package/src/components/data-visualizer/data-visualizer.scss +449 -0
- package/src/components/data-visualizer/declarations.d.ts +131 -0
- package/src/components/data-visualizer/parameter-inputs/boolean-parameter-input.component.tsx +34 -0
- package/src/components/data-visualizer/parameter-inputs/concept-parameter-input.component.tsx +81 -0
- package/src/components/data-visualizer/parameter-inputs/date-parameter-input.component.tsx +110 -0
- package/src/components/data-visualizer/parameter-inputs/date-range-input.component.scss +47 -0
- package/src/components/data-visualizer/parameter-inputs/date-range-input.component.tsx +228 -0
- package/src/components/data-visualizer/parameter-inputs/identifier-type-parameter-input.component.tsx +69 -0
- package/src/components/data-visualizer/parameter-inputs/list-parameter-input.component.tsx +73 -0
- package/src/components/data-visualizer/parameter-inputs/location-parameter-input.component.tsx +81 -0
- package/src/components/data-visualizer/parameter-inputs/number-parameter-input.component.tsx +40 -0
- package/src/components/data-visualizer/parameter-inputs/person-attribute-parameter-input.component.tsx +71 -0
- package/src/components/data-visualizer/parameter-inputs/text-parameter-input.component.tsx +52 -0
- package/src/components/data-visualizer/report-parameter-modal.component.tsx +383 -0
- package/src/components/data-visualizer/types.ts +206 -0
- package/src/components/etl-monitor/builder/builder-state-machine.ts +381 -0
- package/src/components/etl-monitor/builder/design-registry.tsx +139 -0
- package/src/components/etl-monitor/builder/etl-monitor-builder-context.tsx +702 -0
- package/src/components/etl-monitor/builder/etl-monitor-builder-modal.component.tsx +461 -0
- package/src/components/etl-monitor/builder/etl-monitor-builder-modal.scss +256 -0
- package/src/components/etl-monitor/builder/etl-monitor-builder-page.component.tsx +387 -0
- package/src/components/etl-monitor/builder/etl-monitor-builder-page.scss +976 -0
- package/src/components/etl-monitor/builder/generated-config-panel.component.tsx +168 -0
- package/src/components/etl-monitor/builder/generated-config-panel.scss +198 -0
- package/src/components/etl-monitor/builder/index.ts +5 -0
- package/src/components/etl-monitor/builder/monitor-preview.tsx +124 -0
- package/src/components/etl-monitor/builder/steps/data-source-step.component.tsx +667 -0
- package/src/components/etl-monitor/builder/steps/data-source-step.scss +284 -0
- package/src/components/etl-monitor/builder/steps/design-samples.ts +278 -0
- package/src/components/etl-monitor/builder/steps/design-step.component.tsx +299 -0
- package/src/components/etl-monitor/builder/steps/design-step.scss +479 -0
- package/src/components/etl-monitor/builder/steps/fields-step.component.tsx +859 -0
- package/src/components/etl-monitor/builder/steps/fields-step.scss +459 -0
- package/src/components/etl-monitor/builder/steps/general-step.component.tsx +288 -0
- package/src/components/etl-monitor/builder/steps/general-step.scss +103 -0
- package/src/components/etl-monitor/builder/steps/index.ts +5 -0
- package/src/components/etl-monitor/builder/steps/preview-step.component.tsx +245 -0
- package/src/components/etl-monitor/builder/steps/preview-step.scss +236 -0
- package/src/components/etl-monitor/etl-monitor-card-shell.component.tsx +154 -0
- package/src/components/etl-monitor/etl-monitor-card-shell.scss +103 -0
- package/src/components/etl-monitor/etl-monitor-dashboard.component.tsx +227 -0
- package/src/components/etl-monitor/etl-monitor-dashboard.scss +148 -0
- package/src/components/etl-monitor/etl-monitor-status-card.component.tsx +192 -0
- package/src/components/etl-monitor/etl-monitors-page.component.tsx +621 -0
- package/src/components/etl-monitor/renderers/DetailsRenderer.tsx +2 -0
- package/src/components/etl-monitor/renderers/ErrorLogRenderer.tsx +2 -0
- package/src/components/etl-monitor/renderers/EtlMonitorWidget.tsx +97 -0
- package/src/components/etl-monitor/renderers/MetricsGridRenderer.tsx +2 -0
- package/src/components/etl-monitor/renderers/MonitorRenderer.tsx +175 -0
- package/src/components/etl-monitor/renderers/ProgressRenderer.tsx +2 -0
- package/src/components/etl-monitor/renderers/StatusCardRenderer.tsx +2 -0
- package/src/components/etl-monitor/renderers/SummaryCardRenderer.tsx +2 -0
- package/src/components/etl-monitor/renderers/TableRenderer.tsx +2 -0
- package/src/components/etl-monitor/renderers/component-icons.tsx +33 -0
- package/src/components/etl-monitor/renderers/components/details-renderer.tsx +195 -0
- package/src/components/etl-monitor/renderers/components/error-log-renderer.tsx +104 -0
- package/src/components/etl-monitor/renderers/components/index.ts +6 -0
- package/src/components/etl-monitor/renderers/components/log-renderer.tsx +86 -0
- package/src/components/etl-monitor/renderers/components/metrics-grid-renderer.tsx +133 -0
- package/src/components/etl-monitor/renderers/components/progress-renderer.tsx +188 -0
- package/src/components/etl-monitor/renderers/components/status-card-renderer.tsx +247 -0
- package/src/components/etl-monitor/renderers/components/summary-card-renderer.tsx +160 -0
- package/src/components/etl-monitor/renderers/components/table-renderer.tsx +175 -0
- package/src/components/etl-monitor/renderers/components/time-series-renderer.tsx +310 -0
- package/src/components/etl-monitor/renderers/data-transformer.ts +361 -0
- package/src/components/etl-monitor/renderers/index.ts +11 -0
- package/src/components/etl-monitor/renderers/legacy-monitor-renderer.tsx +69 -0
- package/src/components/etl-monitor/renderers/monitor-renderer.tsx +6 -0
- package/src/components/etl-monitor/renderers/monitor-renderers.scss +1621 -0
- package/src/components/etl-monitor/renderers/monitor-widget-card.component.tsx +54 -0
- package/src/components/etl-monitor/renderers/monitor-widget-card.scss +16 -0
- package/src/components/etl-monitor/renderers/v2-monitor-renderer.tsx +227 -0
- package/src/components/import-export/artifact-groups.ts +153 -0
- package/src/components/import-export/export-report-modal.component.tsx +265 -0
- package/src/components/import-export/import-export-page.component.tsx +610 -0
- package/src/components/import-export/import-export.styles.scss +825 -0
- package/src/components/import-export/import-package-modal.component.tsx +401 -0
- package/src/components/import-export/index.ts +3 -0
- package/src/components/indicators/README.md +24 -0
- package/src/components/indicators/base-indicator-basic-fields.component.tsx +18 -0
- package/src/components/indicators/base-indicator-basics.section.tsx +54 -0
- package/src/components/indicators/base-indicator-countby.section.tsx +25 -0
- package/src/components/indicators/base-indicator-criteria.section.tsx +83 -0
- package/src/components/indicators/base-indicator-details-form.component.tsx +80 -0
- package/src/components/indicators/base-indicator-theme-unit-fields.component.tsx +39 -0
- package/src/components/indicators/create-base-indicator-modal.component.tsx +623 -0
- package/src/components/indicators/create-composite-base-indicator-modal.component.tsx +295 -0
- package/src/components/indicators/create-custom-indicator-modal.component.tsx +548 -0
- package/src/components/indicators/create-final-indicator-modal.component.tsx +285 -0
- package/src/components/indicators/custom-condition-input.component.tsx +310 -0
- package/src/components/indicators/diagnosis-filters-form.component.tsx +101 -0
- package/src/components/indicators/disaggregation-panel.component.tsx +93 -0
- package/src/components/indicators/handler/concept-search-multiselect.component.tsx +153 -0
- package/src/components/indicators/handler/question-answer-concept-search.component.tsx +336 -0
- package/src/components/indicators/indicator-run-preview-modal.component.tsx +391 -0
- package/src/components/indicators/indicator-search-select.component.tsx +297 -0
- package/src/components/indicators/indicator-status-tag.component.tsx +9 -0
- package/src/components/indicators/indicators-page.component.tsx +673 -0
- package/src/components/indicators/indicators-page.scss +121 -0
- package/src/components/indicators/indicators-table.component.tsx +188 -0
- package/src/components/indicators/preview-table.component.tsx +31 -0
- package/src/components/indicators/sections/composite-indicator-basics.section.tsx +36 -0
- package/src/components/indicators/sections/composite-indicator-picker.section.tsx +116 -0
- package/src/components/indicators/sections/composite-indicator-sql-preview.section.tsx +31 -0
- package/src/components/indicators/sections/custom-indicator-basics.section.tsx +65 -0
- package/src/components/indicators/sections/custom-indicator-disaggregation.section.tsx +93 -0
- package/src/components/indicators/sections/custom-indicator-filters.section.tsx +203 -0
- package/src/components/indicators/sections/custom-indicator-population.section.tsx +107 -0
- package/src/components/indicators/sections/custom-indicator-sql-preview.section.tsx +108 -0
- package/src/components/indicators/sections/final-indicator-basics.section.tsx +46 -0
- package/src/components/indicators/sections/final-indicator-disaggregation.section.tsx +47 -0
- package/src/components/indicators/sections/final-indicator-picker.section.tsx +60 -0
- package/src/components/indicators/sections/final-indicator-preview.section.tsx +20 -0
- package/src/components/indicators/sections/final-indicator-results-preview.section.tsx +65 -0
- package/src/components/indicators/sections/indicator-basics.section.tsx +40 -0
- package/src/components/indicators/sections/indicator-conditions.section.tsx +279 -0
- package/src/components/indicators/sections/indicator-sql-preview.section.tsx +63 -0
- package/src/components/indicators/sections/indicator-theme.section.tsx +48 -0
- package/src/components/indicators/sql-preview.component.tsx +19 -0
- package/src/components/indicators/tag-input.component.tsx +177 -0
- package/src/components/indicators/types/base-indicator-form.types.ts +17 -0
- package/src/components/indicators/types/base-indicator-theme.constants.ts +8 -0
- package/src/components/indicators/types/composite-indicator.types.ts +27 -0
- package/src/components/indicators/types/condition-ui.types.ts +11 -0
- package/src/components/indicators/types/custom-indicator.types.ts +161 -0
- package/src/components/indicators/types/data-theme-config.types.ts +88 -0
- package/src/components/indicators/types/indicator-types.ts +57 -0
- package/src/components/indicators/types/sql-builders.ts +43 -0
- package/src/components/indicators/utils/composite-indicator-sql.utils.test.ts +143 -0
- package/src/components/indicators/utils/composite-indicator-sql.utils.ts +426 -0
- package/src/components/indicators/utils/concept-preload.utils.ts +21 -0
- package/src/components/indicators/utils/custom-indicator-interpreter.test.ts +493 -0
- package/src/components/indicators/utils/custom-indicator-interpreter.ts +702 -0
- package/src/components/indicators/utils/final-indicator-sql.utils.ts +190 -0
- package/src/components/indicators/utils/indicator-conditions-hydration.utils.ts +254 -0
- package/src/components/indicators/utils/indicator-sql-resolution.utils.ts +204 -0
- package/src/components/indicators/utils/indicator-sql.utils.ts +721 -0
- package/src/components/indicators/utils/population-sql.compiler.test.ts +999 -0
- package/src/components/indicators/utils/population-sql.compiler.ts +858 -0
- package/src/components/landing/landing-action-item.component.tsx +50 -0
- package/src/components/landing/landing-action-list.component.tsx +12 -0
- package/src/components/landing/landing-activity-list.component.tsx +47 -0
- package/src/components/landing/landing-footer-grid.component.tsx +45 -0
- package/src/components/landing/landing-hero.component.tsx +18 -0
- package/src/components/landing/landing-section-card.component.tsx +33 -0
- package/src/components/landing/report-builder-landing-page.component.tsx +186 -0
- package/src/components/landing/report-builder-landing-page.scss +131 -0
- package/src/components/legacy-reports/legacy-report-detail-page.component.tsx +300 -0
- package/src/components/legacy-reports/legacy-report-editor-page.component.tsx +324 -0
- package/src/components/legacy-reports/legacy-report-upload-modal.component.tsx +307 -0
- package/src/components/legacy-reports/legacy-reports-page.component.tsx +206 -0
- package/src/components/legacy-reports/legacy-reports-table.component.tsx +154 -0
- package/src/components/legacy-reports/tabs/legacy-report-datasets-tab.component.tsx +344 -0
- package/src/components/legacy-reports/tabs/legacy-report-dimensions-tab.component.tsx +590 -0
- package/src/components/legacy-reports/tabs/legacy-report-indicators-tab.component.tsx +490 -0
- package/src/components/legacy-reports/tabs/legacy-report-json-preview-tab.component.tsx +272 -0
- package/src/components/legacy-reports/tabs/legacy-report-overview-tab.component.tsx +218 -0
- package/src/components/legacy-reports/tabs/legacy-report-parameters-tab.component.tsx +279 -0
- package/src/components/linelist/definition/indicator-to-sql.utils.ts +281 -0
- package/src/components/linelist/definition/linelist-definition-editor.component.tsx +1676 -0
- package/src/components/linelist/definition/linelist-definition-editor.scss +461 -0
- package/src/components/linelist/definition/linelist-definition.types.ts +108 -0
- package/src/components/linelist/definition/panels/column-properties-panel.component.tsx +328 -0
- package/src/components/linelist/definition/panels/column-selector-panel.component.tsx +1082 -0
- package/src/components/linelist/definition/panels/column-selector-panel.scss +100 -0
- package/src/components/linelist/definition/panels/custom-sql-column-modal.component.tsx +248 -0
- package/src/components/linelist/definition/panels/encounter-diagnosis-column-modal.component.tsx +300 -0
- package/src/components/linelist/definition/panels/encounter-diagnosis-column-modal.scss +21 -0
- package/src/components/linelist/definition/panels/multi-datasource-selector.component.tsx +332 -0
- package/src/components/linelist/definition/panels/multi-datasource-selector.scss +161 -0
- package/src/components/linelist/definition/panels/observation-column-modal.component.tsx +450 -0
- package/src/components/linelist/definition/panels/observation-column-modal.scss +29 -0
- package/src/components/linelist/definition/panels/parameter-panel.component.tsx +659 -0
- package/src/components/linelist/definition/panels/parameter-panel.scss +64 -0
- package/src/components/linelist/definition/panels/population-source-selector.component.tsx +407 -0
- package/src/components/linelist/definition/panels/population-source-selector.scss +187 -0
- package/src/components/linelist/design/panels/column-category-selector.component.tsx +433 -0
- package/src/components/linelist/design/panels/column-category-selector.scss +329 -0
- package/src/components/linelist/design/panels/column-debug-panel.component.tsx +197 -0
- package/src/components/linelist/design/panels/column-debug-panel.scss +141 -0
- package/src/components/linelist/design/panels/data-catalogue.component.tsx +1062 -0
- package/src/components/linelist/design/panels/data-catalogue.scss +263 -0
- package/src/components/linelist/design/panels/display-settings-panel.component.tsx +405 -0
- package/src/components/linelist/design/panels/display-settings-panel.scss +78 -0
- package/src/components/linelist/design/panels/filtermap-editor.component.tsx +434 -0
- package/src/components/linelist/design/panels/filtermap-editor.scss +176 -0
- package/src/components/linelist/design/panels/json-preview.component.tsx +114 -0
- package/src/components/linelist/design/panels/json-preview.scss +85 -0
- package/src/components/linelist/design/panels/query-config-panel.component.tsx +1137 -0
- package/src/components/linelist/design/panels/query-config-panel.scss +342 -0
- package/src/components/linelist/design/panels/sort-config-panel.component.tsx +330 -0
- package/src/components/linelist/design/panels/sort-config-panel.scss +77 -0
- package/src/components/linelist/design/panels/sql-builder-panel.component.tsx +475 -0
- package/src/components/linelist/design/panels/sql-builder-panel.scss +226 -0
- package/src/components/linelist/design/panels/transformation-panel.component.tsx +687 -0
- package/src/components/linelist/design/panels/transformation-panel.scss +81 -0
- package/src/components/linelist/design/panels/visual-filter-panel.component.tsx +595 -0
- package/src/components/linelist/design/panels/visual-filter-panel.scss +76 -0
- package/src/components/linelist/linelist-dashboard.page.component.tsx +756 -0
- package/src/components/linelist/linelist-dashboard.page.scss +240 -0
- package/src/components/linelist/linelist-editor.page.component.tsx +134 -0
- package/src/components/linelist/linelist-editor.page.scss +28 -0
- package/src/components/linelist/linelist-run-report.page.component.tsx +715 -0
- package/src/components/linelist/linelist-run-report.page.scss +136 -0
- package/src/components/linelist/modals/linelist-report-builder-modal.component.tsx +1454 -0
- package/src/components/linelist/modals/linelist-report-builder-modal.scss +164 -0
- package/src/components/linelist/modals/preview-parameter-modal.component.tsx +361 -0
- package/src/components/report/dashboard/reports-table.component.tsx +186 -0
- package/src/components/report/definition/panels/properties-panel.component.tsx +38 -0
- package/src/components/report/definition/panels/report-structure-panel.component.tsx +61 -0
- package/src/components/report/definition/panels/selection-panel.component.tsx +58 -0
- package/src/components/report/definition/report-definition-editor.component.tsx +99 -0
- package/src/components/report/definition/report-definition.types.ts +66 -0
- package/src/components/report/design/panels/IndicatorPropertiesPanel.scss +33 -0
- package/src/components/report/design/panels/IndicatorPropertiesPanel.tsx +389 -0
- package/src/components/report/design/panels/JsonPreviewPanel.scss +32 -0
- package/src/components/report/design/panels/JsonPreviewPanel.tsx +104 -0
- package/src/components/report/design/panels/mapping-preview-panel.component.tsx +82 -0
- package/src/components/report/design/panels/mapping-preview-panel.scss +55 -0
- package/src/components/report/design/panels/template-structure-panel.component.tsx +296 -0
- package/src/components/report/design/panels/template-structure-panel.scss +81 -0
- package/src/components/report/design/report-design-editor.component.tsx +1170 -0
- package/src/components/report/design/report-design.types.ts +48 -0
- package/src/components/report/design/report-design.utils.ts +86 -0
- package/src/components/report/panels/report-detail.component.tsx +71 -0
- package/src/components/report/panels/report-panel-shell.component.tsx +60 -0
- package/src/components/report/report-dashboard.page.component.tsx +554 -0
- package/src/components/report/report-editor.page.component.tsx +590 -0
- package/src/components/report/report.routes.tsx +32 -0
- package/src/components/report-sections/create-report-section-modal.component.tsx +388 -0
- package/src/components/report-sections/hooks/useAgeCategories.ts +25 -0
- package/src/components/report-sections/hooks/useSectionEditorState.ts +449 -0
- package/src/components/report-sections/panels/Dhis2MappingPanel.tsx +157 -0
- package/src/components/report-sections/panels/DisaggregationPanel.tsx +97 -0
- package/src/components/report-sections/panels/IndicatorPickerPanel.tsx +201 -0
- package/src/components/report-sections/panels/SectionBasicsPanel.tsx +27 -0
- package/src/components/report-sections/report-section-preview-modal.component.tsx +548 -0
- package/src/components/report-sections/report-sections-page.component.tsx +325 -0
- package/src/components/report-sections/section-disaggregation.utils.ts +637 -0
- package/src/components/report-sections/section-types.ts +55 -0
- package/src/components/report-sections/section-utils.ts +50 -0
- package/src/components/report-sections/sections-page.scss +79 -0
- package/src/components/run-reports/run-reports-page.component.tsx +8 -0
- package/src/components/security/access-denied-page.component.tsx +69 -0
- package/src/components/security/access-denied-page.scss +39 -0
- package/src/components/security/privilege-route.component.test.tsx +79 -0
- package/src/components/security/privilege-route.component.tsx +39 -0
- package/src/components/shared/compile-setup-modal.component.tsx +182 -0
- package/src/components/shared/concept-selector.component.tsx +245 -0
- package/src/components/shared/concept-selector.scss +121 -0
- package/src/components/shared/header/builder-header-actions.component.tsx +38 -0
- package/src/components/shared/header/header.component.tsx +85 -0
- package/src/components/shared/header/header.scss +150 -0
- package/src/components/shared/header/illustration.component.tsx +34 -0
- package/src/components/shared/indicator-properties-panel/IndicatorPropertiesPanel.scss +33 -0
- package/src/components/shared/indicator-properties-panel/IndicatorPropertiesPanel.tsx +389 -0
- package/src/components/shared/json-preview-panel/JsonPreviewPanel.scss +32 -0
- package/src/components/shared/json-preview-panel/JsonPreviewPanel.tsx +104 -0
- package/src/components/shared/mapping-preview-panel/mapping-preview-panel.component.tsx +82 -0
- package/src/components/shared/mapping-preview-panel/mapping-preview-panel.scss +55 -0
- package/src/components/shared/preview/query-results-preview.component.tsx +204 -0
- package/src/components/shared/template-structure-panel/template-structure-panel.component.tsx +296 -0
- package/src/components/shared/template-structure-panel/template-structure-panel.scss +81 -0
- package/src/config-schema.ts +43 -0
- package/src/constants/privileges.test.ts +53 -0
- package/src/constants/privileges.ts +118 -0
- package/src/features/dashboards/DashboardRendererPage.tsx +174 -0
- package/src/features/dashboards/DashboardsPage.tsx +164 -0
- package/src/features/dashboards/EtlDashboardPage.tsx +32 -0
- package/src/features/dashboards/components/DashboardEmptyState.tsx +41 -0
- package/src/features/dashboards/components/DashboardGrid.tsx +48 -0
- package/src/features/dashboards/components/DashboardHeader.tsx +58 -0
- package/src/features/dashboards/components/DashboardSection.tsx +46 -0
- package/src/features/dashboards/components/ReportLaunchCard.tsx +51 -0
- package/src/features/dashboards/components/WidgetSlotDispatcher.tsx +61 -0
- package/src/features/dashboards/components/WidgetUnavailableCard.tsx +36 -0
- package/src/features/dashboards/dashboards.scss +196 -0
- package/src/features/dashboards/hooks/useDashboard.ts +61 -0
- package/src/features/dashboards/hooks/useDashboardWidgets.ts +74 -0
- package/src/features/dashboards/hooks/useDashboards.ts +56 -0
- package/src/features/dashboards/hooks/useMonitorDataMap.ts +84 -0
- package/src/features/dashboards/index.ts +11 -0
- package/src/features/dashboards/utils/dashboard-config.util.test.ts +255 -0
- package/src/features/dashboards/utils/dashboard-config.util.ts +382 -0
- package/src/features/report-visualizer/ReportVisualizerPage.tsx +448 -0
- package/src/features/report-visualizer/components/Export/ExportMenu.tsx +141 -0
- package/src/features/report-visualizer/components/Export/index.ts +2 -0
- package/src/features/report-visualizer/components/ReportExplorer/QuickFilters.tsx +152 -0
- package/src/features/report-visualizer/components/ReportExplorer/ReportCategoryFilter.tsx +54 -0
- package/src/features/report-visualizer/components/ReportExplorer/ReportExplorerPanel.tsx +201 -0
- package/src/features/report-visualizer/components/ReportExplorer/ReportExplorerRail.tsx +202 -0
- package/src/features/report-visualizer/components/ReportExplorer/ReportList.tsx +287 -0
- package/src/features/report-visualizer/components/ReportExplorer/ReportSearch.tsx +151 -0
- package/src/features/report-visualizer/components/ReportExplorer/ReportTagFilter.tsx +100 -0
- package/src/features/report-visualizer/components/ReportExplorer/RunReportButton.tsx +42 -0
- package/src/features/report-visualizer/components/ReportExplorer/RuntimeParameterForm.tsx +259 -0
- package/src/features/report-visualizer/components/ReportExplorer/index.ts +8 -0
- package/src/features/report-visualizer/components/ReportWorkspace/ReportLayer.tsx +33 -0
- package/src/features/report-visualizer/components/ReportWorkspace/ReportSummary.tsx +88 -0
- package/src/features/report-visualizer/components/ReportWorkspace/ReportViewTabs.tsx +72 -0
- package/src/features/report-visualizer/components/ReportWorkspace/ReportWorkspaceHeader.tsx +92 -0
- package/src/features/report-visualizer/components/ReportWorkspace/ReportWorkspacePanel.tsx +242 -0
- package/src/features/report-visualizer/components/ReportWorkspace/index.ts +5 -0
- package/src/features/report-visualizer/components/TableView/ColumnVisibilityMenu.tsx +206 -0
- package/src/features/report-visualizer/components/TableView/ReportTable.tsx +253 -0
- package/src/features/report-visualizer/components/TableView/index.ts +2 -0
- package/src/features/report-visualizer/hooks/index.ts +4 -0
- package/src/features/report-visualizer/hooks/useExplorerPreferences.ts +103 -0
- package/src/features/report-visualizer/hooks/useReportCapabilities.ts +112 -0
- package/src/features/report-visualizer/hooks/useReportParameters.ts +152 -0
- package/src/features/report-visualizer/hooks/useReports.ts +135 -0
- package/src/features/report-visualizer/index.ts +6 -0
- package/src/features/report-visualizer/report-visualizer.scss +593 -0
- package/src/features/report-visualizer/types/index.ts +1 -0
- package/src/features/report-visualizer/types/report-visualizer.types.ts +104 -0
- package/src/features/report-visualizer/utils/status-colors.ts +117 -0
- package/src/globals.d.ts +14 -0
- package/src/hooks/address-template.ts +86 -0
- package/src/hooks/concept.ts +112 -0
- package/src/hooks/indicator/index.ts +1 -0
- package/src/hooks/indicator/useIndicatorsByTheme.ts +41 -0
- package/src/hooks/openmrs-reference-data.ts +432 -0
- package/src/hooks/theme/index.ts +4 -0
- package/src/hooks/theme/useDataTheme.ts +61 -0
- package/src/hooks/theme/useDataThemes.ts +28 -0
- package/src/hooks/theme/useMambaTableMeta.ts +34 -0
- package/src/hooks/theme/useMambaTables.ts +95 -0
- package/src/hooks/use-report-builder-privileges.test.tsx +98 -0
- package/src/hooks/use-report-builder-privileges.ts +58 -0
- package/src/index.ts +29 -0
- package/src/resources/address-template/address-template.api.ts +180 -0
- package/src/resources/agegroup/agegroups.api.ts +58 -0
- package/src/resources/concept/concept.api.ts +116 -0
- package/src/resources/concepts/concept-mapper.ts +21 -0
- package/src/resources/concepts/concept-types.ts +31 -0
- package/src/resources/concepts/concepts.resource.ts +44 -0
- package/src/resources/concepts/useConceptSearch.ts +41 -0
- package/src/resources/dashboard/dashboard.api.ts +107 -0
- package/src/resources/etl-monitor/etl-monitor-test.api.ts +409 -0
- package/src/resources/etl-monitor/etl-monitor.api.ts +381 -0
- package/src/resources/etl-source/etl-source.api.ts +65 -0
- package/src/resources/etl-task/etl-task.api.ts +96 -0
- package/src/resources/etl-task/etl-task.types.ts +31 -0
- package/src/resources/indicator/indicators.api.ts +125 -0
- package/src/resources/legacy-reports/legacy-reports.api.ts +144 -0
- package/src/resources/linelist/linelist-reports.api.ts +616 -0
- package/src/resources/location/location.api.ts +135 -0
- package/src/resources/openmrs-api.ts +40 -0
- package/src/resources/patient-identifier-type/patient-identifier-type.api.ts +65 -0
- package/src/resources/person-attribute-type/person-attribute-type.api.ts +71 -0
- package/src/resources/preview/sql-preview.api.ts +54 -0
- package/src/resources/report/reports.api.ts +140 -0
- package/src/resources/report-category/report-category.api.ts +41 -0
- package/src/resources/report-import-export/import-export-api.ts +164 -0
- package/src/resources/report-library/report-library.api.ts +63 -0
- package/src/resources/report-section/report-sections.api.ts +73 -0
- package/src/resources/report-section/section-preview.api.ts +25 -0
- package/src/resources/theme/data-theme.api.ts +88 -0
- package/src/resources/theme/etl-schema.api.ts +101 -0
- package/src/resources/theme/etl-table-meta.api.ts +45 -0
- package/src/root.component.tsx +20 -0
- package/src/routes/report-builder.routes.tsx +160 -0
- package/src/routes/report-builder.scss +56 -0
- package/src/routes.json +28 -0
- package/src/sample-template.ts +121 -0
- package/src/template-utils.ts +110 -0
- package/src/types/carbon-react-inert.d.ts +13 -0
- package/src/types/condition-operators.ts +63 -0
- package/src/types/dashboard/dashboard.types.ts +137 -0
- package/src/types/dashboard/index.ts +4 -0
- package/src/types/etl/etl-types.ts +238 -0
- package/src/types/etl-monitor/etl-monitor-builder.types.ts +555 -0
- package/src/types/etl-monitor/etl-monitor-v2.types.ts +397 -0
- package/src/types/etl-monitor/etl-monitor.types.ts +188 -0
- package/src/types/etl-monitor/index.ts +6 -0
- package/src/types/linelist/compile-config.ts +455 -0
- package/src/types/linelist-types.ts +2059 -0
- package/src/types/theme/data-theme.types.ts +88 -0
- package/src/utils/api-error.utils.test.ts +151 -0
- package/src/utils/api-error.utils.ts +131 -0
- package/src/utils/config-enhancer.ts +62 -0
- package/src/utils/etl-browser/etl-browser.util.test.ts +145 -0
- package/src/utils/etl-browser/export-csv.util.ts +43 -0
- package/src/utils/etl-browser/group-tables.util.ts +84 -0
- package/src/utils/etl-browser/index.ts +4 -0
- package/src/utils/etl-browser/summarize-columns.util.ts +27 -0
- package/src/utils/etl-browser/table-sql.util.ts +20 -0
- package/src/utils/etl-monitor/config-v2-adapter.util.ts +460 -0
- package/src/utils/etl-monitor/endpoint-config-normalizer.util.ts +383 -0
- package/src/utils/etl-monitor/index.ts +10 -0
- package/src/utils/etl-monitor/jsonpath-resolver.util.ts +118 -0
- package/src/utils/etl-monitor/normalization-examples.ts +0 -0
- package/src/utils/etl-monitor/schema-inspector.util.ts +76 -0
- package/src/utils/etl-monitor/semantic-type-detector.util.ts +76 -0
- package/src/utils/etl-monitor/status-mapper.util.ts +105 -0
- package/src/utils/etl-monitor/value-formatters.util.ts +167 -0
- package/src/utils/etl-task/etl-task-card.util.test.ts +239 -0
- package/src/utils/etl-task/etl-task-card.util.ts +276 -0
- package/src/utils/etl-task/index.ts +1 -0
- package/src/utils/html-entities.utils.ts +34 -0
- package/src/utils/parameter-resolution.ts +218 -0
- package/src/views/etl-monitor-builder/add-monitor-modal.component.scss +0 -0
- package/src/views/etl-monitor-builder/add-monitor-modal.component.tsx +210 -0
- package/src/views/etl-monitor-builder/etl-monitor-builder.component.scss +157 -0
- package/src/views/etl-monitor-builder/etl-monitor-builder.component.tsx +252 -0
- package/src/views/etl-monitor-builder/etl-monitor-builder.store.ts +126 -0
- package/tools/scss-stub.js +12 -0
- package/tools/setup-tests.ts +1 -0
- package/translations/en.json +65 -0
- package/tsconfig.json +43 -0
- package/webpack.config.js +30 -0
|
@@ -0,0 +1,1082 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Column Selector Component for Linelist Reports
|
|
3
|
+
*
|
|
4
|
+
* This component allows users to select and configure columns for their linelist report.
|
|
5
|
+
* It leverages existing ETL table metadata infrastructure.
|
|
6
|
+
*
|
|
7
|
+
* Reuses patterns from:
|
|
8
|
+
* - data-theme-fields-editor.section.tsx for field definition
|
|
9
|
+
* - useETLTables and useETLTableMeta hooks for table/column discovery
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import React, { useState } from 'react';
|
|
13
|
+
import {
|
|
14
|
+
Stack,
|
|
15
|
+
TextInput,
|
|
16
|
+
Select,
|
|
17
|
+
SelectItem,
|
|
18
|
+
Button,
|
|
19
|
+
Toggle,
|
|
20
|
+
Tag,
|
|
21
|
+
ComboBox,
|
|
22
|
+
DataTable,
|
|
23
|
+
DataTableSkeleton,
|
|
24
|
+
TableRow,
|
|
25
|
+
TableCell,
|
|
26
|
+
TableBody,
|
|
27
|
+
ButtonSet,
|
|
28
|
+
} from '@carbon/react';
|
|
29
|
+
import { TrashCan, Add, ChevronDown, ChevronUp, Information } from '@carbon/react/icons';
|
|
30
|
+
import type {
|
|
31
|
+
LinelistColumnDraft,
|
|
32
|
+
RepeatResolutionStrategy,
|
|
33
|
+
LinelistRepeatResolution,
|
|
34
|
+
} from '../../../../types/linelist-types';
|
|
35
|
+
import { useETLTables, useETLTableMeta } from '../../../../hooks/theme';
|
|
36
|
+
import type { TableColumn } from '../../../../resources/theme/etl-table-meta.api';
|
|
37
|
+
import TransformationPipeline from '../../design/panels/transformation-panel.component';
|
|
38
|
+
import styles from './column-selector.scss';
|
|
39
|
+
|
|
40
|
+
type ColumnDataType =
|
|
41
|
+
| 'SQL'
|
|
42
|
+
| 'IDENTIFIER'
|
|
43
|
+
| 'PERSON_NAME'
|
|
44
|
+
| 'PERSON_ATTRIBUTE'
|
|
45
|
+
| 'CALCULATION'
|
|
46
|
+
| 'PERSON_ADDRESS';
|
|
47
|
+
|
|
48
|
+
type Props = {
|
|
49
|
+
columns: LinelistColumnDraft[];
|
|
50
|
+
onChange: (columns: LinelistColumnDraft[]) => void;
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
error?: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Create a new column draft with all required v2 fields
|
|
57
|
+
* This ensures all columns have proper source tracking even when created manually
|
|
58
|
+
*/
|
|
59
|
+
function createNewColumnDraft(
|
|
60
|
+
name: string,
|
|
61
|
+
dataDefinitionType: ColumnDataType,
|
|
62
|
+
dataDefinitionConfig: Record<string, any>,
|
|
63
|
+
sortOrder: number
|
|
64
|
+
): LinelistColumnDraft {
|
|
65
|
+
const now = new Date().toISOString();
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
id: `col-${Date.now()}`,
|
|
69
|
+
name,
|
|
70
|
+
description: '',
|
|
71
|
+
source: {
|
|
72
|
+
dataSourceUuid: '', // Will be filled in by parent
|
|
73
|
+
dataSourceName: '',
|
|
74
|
+
table: '',
|
|
75
|
+
field: name,
|
|
76
|
+
fieldType: 'UNKNOWN',
|
|
77
|
+
},
|
|
78
|
+
dataDefinitionType,
|
|
79
|
+
dataDefinitionConfig,
|
|
80
|
+
additionInfo: {
|
|
81
|
+
addedVia: 'SQL_BUILDER',
|
|
82
|
+
addedAt: now,
|
|
83
|
+
orderAdded: sortOrder,
|
|
84
|
+
},
|
|
85
|
+
display: {
|
|
86
|
+
width: 150,
|
|
87
|
+
align: 'left',
|
|
88
|
+
sortable: true,
|
|
89
|
+
filterable: true,
|
|
90
|
+
format: 'text',
|
|
91
|
+
},
|
|
92
|
+
sortOrder,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Available data definition types with descriptions
|
|
98
|
+
*/
|
|
99
|
+
const DATA_DEFINITION_TYPES: Array<{
|
|
100
|
+
id: ColumnDataType;
|
|
101
|
+
label: string;
|
|
102
|
+
description: string;
|
|
103
|
+
needsConfig: boolean;
|
|
104
|
+
}> = [
|
|
105
|
+
{
|
|
106
|
+
id: 'SQL',
|
|
107
|
+
label: 'Custom SQL',
|
|
108
|
+
description: 'Custom SQL expression for complex column values',
|
|
109
|
+
needsConfig: true,
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: 'IDENTIFIER',
|
|
113
|
+
label: 'Patient Identifier',
|
|
114
|
+
description: 'Patient identifier (e.g., Clinic Number, EID Number)',
|
|
115
|
+
needsConfig: true,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: 'PERSON_NAME',
|
|
119
|
+
label: 'Person Name',
|
|
120
|
+
description: 'Patient name (given, family, or full name)',
|
|
121
|
+
needsConfig: false,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: 'PERSON_ATTRIBUTE',
|
|
125
|
+
label: 'Person Attribute',
|
|
126
|
+
description: 'Person attribute value',
|
|
127
|
+
needsConfig: true,
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
id: 'CALCULATION',
|
|
131
|
+
label: 'Calculation',
|
|
132
|
+
description: 'Calculated value (e.g., Age, BMI)',
|
|
133
|
+
needsConfig: true,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
id: 'PERSON_ADDRESS',
|
|
137
|
+
label: 'Person Address',
|
|
138
|
+
description: 'Address field (village, district, etc.)',
|
|
139
|
+
needsConfig: true,
|
|
140
|
+
},
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Common SQL column templates
|
|
145
|
+
*/
|
|
146
|
+
const SQL_TEMPLATES: Record<string, string> = {
|
|
147
|
+
'client_id': 'client_id',
|
|
148
|
+
'given_name': 'given_name',
|
|
149
|
+
'family_name': 'family_name',
|
|
150
|
+
'gender': 'gender',
|
|
151
|
+
'birthdate': 'birthdate',
|
|
152
|
+
'age_at_visit': 'TIMESTAMPDIFF(YEAR, birthdate, :endDate)',
|
|
153
|
+
'art_start_date': 'art_start_date',
|
|
154
|
+
'current_regimen': 'current_regimen',
|
|
155
|
+
'last_vl_date': 'last_vl_date',
|
|
156
|
+
'last_vl_result': 'last_vl_result',
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Common OpenMRS person attribute columns
|
|
161
|
+
* Uses standard OpenMRS attribute type UUIDs
|
|
162
|
+
*/
|
|
163
|
+
const PERSON_ATTRIBUTE_TEMPLATES: Record<string, { uuid: string; label: string }> = {
|
|
164
|
+
'Gender': {
|
|
165
|
+
uuid: '',
|
|
166
|
+
label: 'Gender (built-in)',
|
|
167
|
+
},
|
|
168
|
+
'Birth Date': {
|
|
169
|
+
uuid: '',
|
|
170
|
+
label: 'Birth Date (built-in)',
|
|
171
|
+
},
|
|
172
|
+
'Telephone': {
|
|
173
|
+
uuid: '14d4f066-15f5-102d-96e4-000c29c2a5d7',
|
|
174
|
+
label: 'Telephone Number',
|
|
175
|
+
},
|
|
176
|
+
'Civil Status': {
|
|
177
|
+
uuid: '8d872362-c2cc-11e0-8d4b-48f3e89c1fc1',
|
|
178
|
+
label: 'Civil Status',
|
|
179
|
+
},
|
|
180
|
+
'Education': {
|
|
181
|
+
uuid: '8d8718c8-c2cc-11e0-8d4b-48f3e89c1fc1',
|
|
182
|
+
label: 'Education Level',
|
|
183
|
+
},
|
|
184
|
+
'Occupation': {
|
|
185
|
+
uuid: '8d8728c4-c2cc-11e0-8d4b-48f3e89c1fc1',
|
|
186
|
+
label: 'Occupation',
|
|
187
|
+
},
|
|
188
|
+
'Religion': {
|
|
189
|
+
uuid: '8d871d66-c2cc-11e0-8d4b-48f3e89c1fc1',
|
|
190
|
+
label: 'Religion',
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Common patient identifier columns
|
|
196
|
+
* Uses standard OpenMRS identifier type UUIDs
|
|
197
|
+
*/
|
|
198
|
+
const IDENTIFIER_TEMPLATES: Record<string, { uuid: string; label: string }> = {
|
|
199
|
+
'Clinic Number': {
|
|
200
|
+
uuid: 'e1731641-30ab-102d-86b0-7a5022ba4115',
|
|
201
|
+
label: 'Clinic Number',
|
|
202
|
+
},
|
|
203
|
+
'EID Number': {
|
|
204
|
+
uuid: 'e1731642-30ab-102d-86b0-7a5022ba4115',
|
|
205
|
+
label: 'EID Number',
|
|
206
|
+
},
|
|
207
|
+
'National ID': {
|
|
208
|
+
uuid: 'e1731643-30ab-102d-86b0-7a5022ba4115',
|
|
209
|
+
label: 'National ID',
|
|
210
|
+
},
|
|
211
|
+
'Old Clinician Number': {
|
|
212
|
+
uuid: 'e1731644-30ab-102d-86b0-7a5022ba4115',
|
|
213
|
+
label: 'Old Clinician Number',
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Map SQL data types to Carbon icon colors for visual indication
|
|
219
|
+
*/
|
|
220
|
+
const TYPE_COLORS: Record<ColumnDataType, string> = {
|
|
221
|
+
SQL: 'gray',
|
|
222
|
+
IDENTIFIER: 'blue',
|
|
223
|
+
PERSON_NAME: 'green',
|
|
224
|
+
PERSON_ATTRIBUTE: 'purple',
|
|
225
|
+
CALCULATION: 'orange',
|
|
226
|
+
PERSON_ADDRESS: 'teal',
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Repeat resolution strategies with descriptions
|
|
231
|
+
*/
|
|
232
|
+
const REPEAT_RESOLUTION_STRATEGIES: Array<{
|
|
233
|
+
value: RepeatResolutionStrategy;
|
|
234
|
+
label: string;
|
|
235
|
+
description: string;
|
|
236
|
+
needsOrderBy: boolean;
|
|
237
|
+
}> = [
|
|
238
|
+
{
|
|
239
|
+
value: 'LATEST',
|
|
240
|
+
label: 'Latest Value',
|
|
241
|
+
description: 'Most recent value based on order by field',
|
|
242
|
+
needsOrderBy: true,
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
value: 'EARLIEST',
|
|
246
|
+
label: 'Earliest Value',
|
|
247
|
+
description: 'Oldest value based on order by field',
|
|
248
|
+
needsOrderBy: true,
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
value: 'HIGHEST',
|
|
252
|
+
label: 'Highest Value',
|
|
253
|
+
description: 'Maximum value',
|
|
254
|
+
needsOrderBy: false,
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
value: 'LOWEST',
|
|
258
|
+
label: 'Lowest Value',
|
|
259
|
+
description: 'Minimum value',
|
|
260
|
+
needsOrderBy: false,
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
value: 'CLOSEST_TO_START',
|
|
264
|
+
label: 'Closest to Start Date',
|
|
265
|
+
description: 'Value closest to report start date',
|
|
266
|
+
needsOrderBy: false,
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
value: 'CLOSEST_TO_END',
|
|
270
|
+
label: 'Closest to End Date',
|
|
271
|
+
description: 'Value closest to report end date',
|
|
272
|
+
needsOrderBy: false,
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
value: 'FIRST_WITHIN_PERIOD',
|
|
276
|
+
label: 'First Within Period',
|
|
277
|
+
description: 'First value within reporting period',
|
|
278
|
+
needsOrderBy: true,
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
value: 'LAST_WITHIN_PERIOD',
|
|
282
|
+
label: 'Last Within Period',
|
|
283
|
+
description: 'Last value within reporting period',
|
|
284
|
+
needsOrderBy: true,
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
value: 'CONCATENATE',
|
|
288
|
+
label: 'Concatenate Values',
|
|
289
|
+
description: 'Combine all values into a single string',
|
|
290
|
+
needsOrderBy: false,
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
value: 'ALL_VALUES',
|
|
294
|
+
label: 'Return All Values',
|
|
295
|
+
description: 'Generate one row per value (changes row grain)',
|
|
296
|
+
needsOrderBy: false,
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
value: 'NONE',
|
|
300
|
+
label: 'No Resolution',
|
|
301
|
+
description: 'Leave unresolved (advanced users only)',
|
|
302
|
+
needsOrderBy: false,
|
|
303
|
+
},
|
|
304
|
+
];
|
|
305
|
+
|
|
306
|
+
export default function ColumnSelector({ columns, onChange, disabled = false, error }: Props) {
|
|
307
|
+
const [selectedTable, setSelectedTable] = useState<string | null>(null);
|
|
308
|
+
const [expandedRows, setExpandedRows] = useState<Set<number>>(new Set());
|
|
309
|
+
|
|
310
|
+
// Fetch available ETL tables
|
|
311
|
+
const { tables, loading: tablesLoading, error: tablesError } = useETLTables(true);
|
|
312
|
+
|
|
313
|
+
// Fetch column metadata for selected table
|
|
314
|
+
const { columns: tableColumns, loading: columnsLoading } = useETLTableMeta(selectedTable ?? undefined, true);
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Add a new column based on selected table column
|
|
318
|
+
*/
|
|
319
|
+
const addColumnFromTable = (tableColumn: TableColumn) => {
|
|
320
|
+
const newColumn = createNewColumnDraft(
|
|
321
|
+
tableColumn.name,
|
|
322
|
+
'SQL',
|
|
323
|
+
{ sql: tableColumn.name },
|
|
324
|
+
columns.length
|
|
325
|
+
);
|
|
326
|
+
onChange([...columns, newColumn]);
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Add a custom column
|
|
331
|
+
*/
|
|
332
|
+
const addCustomColumn = () => {
|
|
333
|
+
const newColumn = createNewColumnDraft(
|
|
334
|
+
'',
|
|
335
|
+
'SQL',
|
|
336
|
+
{ sql: '' },
|
|
337
|
+
columns.length
|
|
338
|
+
);
|
|
339
|
+
onChange([...columns, newColumn]);
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Remove a column
|
|
344
|
+
*/
|
|
345
|
+
const removeColumn = (columnId: string) => {
|
|
346
|
+
onChange(columns.filter((col) => col.id !== columnId));
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Update a column
|
|
351
|
+
*/
|
|
352
|
+
const updateColumn = (columnId: string, updates: Partial<LinelistColumnDraft>) => {
|
|
353
|
+
onChange(
|
|
354
|
+
columns.map((col) =>
|
|
355
|
+
col.id === columnId
|
|
356
|
+
? {
|
|
357
|
+
...col,
|
|
358
|
+
...updates,
|
|
359
|
+
}
|
|
360
|
+
: col
|
|
361
|
+
)
|
|
362
|
+
);
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Move column up or down in the list
|
|
367
|
+
*/
|
|
368
|
+
const moveColumn = (index: number, direction: 'up' | 'down') => {
|
|
369
|
+
const newColumns = [...columns];
|
|
370
|
+
const targetIndex = direction === 'up' ? index - 1 : index + 1;
|
|
371
|
+
|
|
372
|
+
if (targetIndex < 0 || targetIndex >= newColumns.length) return;
|
|
373
|
+
|
|
374
|
+
[newColumns[index], newColumns[targetIndex]] = [newColumns[targetIndex], newColumns[index]];
|
|
375
|
+
|
|
376
|
+
// Update sort orders
|
|
377
|
+
newColumns.forEach((col, idx) => {
|
|
378
|
+
col.sortOrder = idx;
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
onChange(newColumns);
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Toggle row expansion for column details
|
|
386
|
+
*/
|
|
387
|
+
const toggleRowExpansion = (index: number) => {
|
|
388
|
+
const newExpanded = new Set(expandedRows);
|
|
389
|
+
if (newExpanded.has(index)) {
|
|
390
|
+
newExpanded.delete(index);
|
|
391
|
+
} else {
|
|
392
|
+
newExpanded.add(index);
|
|
393
|
+
}
|
|
394
|
+
setExpandedRows(newExpanded);
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Get config fields based on data definition type
|
|
399
|
+
*/
|
|
400
|
+
const renderConfigFields = (column: LinelistColumnDraft) => {
|
|
401
|
+
switch (column.dataDefinitionType) {
|
|
402
|
+
case 'SQL':
|
|
403
|
+
return (
|
|
404
|
+
<TextInput
|
|
405
|
+
id={`sql-${column.id}`}
|
|
406
|
+
labelText="SQL Expression"
|
|
407
|
+
placeholder="e.g., patient_id, given_name, TIMESTAMPDIFF(YEAR, birthdate, :endDate)"
|
|
408
|
+
value={column.dataDefinitionConfig.sql || ''}
|
|
409
|
+
onChange={(e) =>
|
|
410
|
+
updateColumn(column.id, {
|
|
411
|
+
dataDefinitionConfig: { ...column.dataDefinitionConfig, sql: (e.target as HTMLInputElement).value },
|
|
412
|
+
})
|
|
413
|
+
}
|
|
414
|
+
disabled={disabled}
|
|
415
|
+
/>
|
|
416
|
+
);
|
|
417
|
+
|
|
418
|
+
case 'IDENTIFIER':
|
|
419
|
+
return (
|
|
420
|
+
<>
|
|
421
|
+
<TextInput
|
|
422
|
+
id={`identifier-uuid-${column.id}`}
|
|
423
|
+
labelText="Identifier Type UUID"
|
|
424
|
+
placeholder="e.g., 05a0e144-1f5d-11e8-b646-0e37ffca28c8"
|
|
425
|
+
value={column.dataDefinitionConfig.identifierTypeUuid || ''}
|
|
426
|
+
onChange={(e) =>
|
|
427
|
+
updateColumn(column.id, {
|
|
428
|
+
dataDefinitionConfig: { ...column.dataDefinitionConfig, identifierTypeUuid: (e.target as HTMLInputElement).value },
|
|
429
|
+
})
|
|
430
|
+
}
|
|
431
|
+
disabled={disabled}
|
|
432
|
+
/>
|
|
433
|
+
<Toggle
|
|
434
|
+
id={`preferred-${column.id}`}
|
|
435
|
+
labelText="Preferred identifier"
|
|
436
|
+
toggled={column.dataDefinitionConfig.preferred || false}
|
|
437
|
+
onToggle={(checked) =>
|
|
438
|
+
updateColumn(column.id, {
|
|
439
|
+
dataDefinitionConfig: { ...column.dataDefinitionConfig, preferred: checked },
|
|
440
|
+
})
|
|
441
|
+
}
|
|
442
|
+
disabled={disabled}
|
|
443
|
+
/>
|
|
444
|
+
</>
|
|
445
|
+
);
|
|
446
|
+
|
|
447
|
+
case 'PERSON_NAME':
|
|
448
|
+
return (
|
|
449
|
+
<Select
|
|
450
|
+
id={`name-type-${column.id}`}
|
|
451
|
+
labelText="Name Type"
|
|
452
|
+
value={column.dataDefinitionConfig.type || 'FULL_NAME'}
|
|
453
|
+
onChange={(e) =>
|
|
454
|
+
updateColumn(column.id, {
|
|
455
|
+
dataDefinitionConfig: { ...column.dataDefinitionConfig, type: (e.target as HTMLSelectElement).value },
|
|
456
|
+
})
|
|
457
|
+
}
|
|
458
|
+
disabled={disabled}
|
|
459
|
+
>
|
|
460
|
+
<SelectItem value="FULL_NAME" text="Full Name" />
|
|
461
|
+
<SelectItem value="GIVEN_NAME" text="Given Name" />
|
|
462
|
+
<SelectItem value="MIDDLE_NAME" text="Middle Name" />
|
|
463
|
+
<SelectItem value="FAMILY_NAME" text="Family Name" />
|
|
464
|
+
</Select>
|
|
465
|
+
);
|
|
466
|
+
|
|
467
|
+
case 'PERSON_ATTRIBUTE':
|
|
468
|
+
return (
|
|
469
|
+
<TextInput
|
|
470
|
+
id={`attribute-uuid-${column.id}`}
|
|
471
|
+
labelText="Attribute Type UUID"
|
|
472
|
+
placeholder="e.g., 8c860e40-1f5d-11e8-b646-0e37ffca28c8"
|
|
473
|
+
value={column.dataDefinitionConfig.attributeTypeUuid || ''}
|
|
474
|
+
onChange={(e) =>
|
|
475
|
+
updateColumn(column.id, {
|
|
476
|
+
dataDefinitionConfig: { ...column.dataDefinitionConfig, attributeTypeUuid: (e.target as HTMLInputElement).value },
|
|
477
|
+
})
|
|
478
|
+
}
|
|
479
|
+
disabled={disabled}
|
|
480
|
+
/>
|
|
481
|
+
);
|
|
482
|
+
|
|
483
|
+
case 'CALCULATION':
|
|
484
|
+
return (
|
|
485
|
+
<>
|
|
486
|
+
<Select
|
|
487
|
+
id={`calculation-type-${column.id}`}
|
|
488
|
+
labelText="Calculation Type"
|
|
489
|
+
value={column.dataDefinitionConfig.calculation || 'AGE'}
|
|
490
|
+
onChange={(e) =>
|
|
491
|
+
updateColumn(column.id, {
|
|
492
|
+
dataDefinitionConfig: { ...column.dataDefinitionConfig, calculation: (e.target as HTMLSelectElement).value },
|
|
493
|
+
})
|
|
494
|
+
}
|
|
495
|
+
disabled={disabled}
|
|
496
|
+
>
|
|
497
|
+
<SelectItem value="AGE" text="Age" />
|
|
498
|
+
<SelectItem value="AGE_IN_MONTHS" text="Age in Months" />
|
|
499
|
+
<SelectItem value="AGE_IN_YEARS" text="Age in Years" />
|
|
500
|
+
<SelectItem value="BMI" text="BMI" />
|
|
501
|
+
</Select>
|
|
502
|
+
<Toggle
|
|
503
|
+
id={`on-date-${column.id}`}
|
|
504
|
+
labelText="Calculate as of end date"
|
|
505
|
+
toggled={column.dataDefinitionConfig.onDate || false}
|
|
506
|
+
onToggle={(checked) =>
|
|
507
|
+
updateColumn(column.id, {
|
|
508
|
+
dataDefinitionConfig: { ...column.dataDefinitionConfig, onDate: checked },
|
|
509
|
+
})
|
|
510
|
+
}
|
|
511
|
+
disabled={disabled}
|
|
512
|
+
/>
|
|
513
|
+
</>
|
|
514
|
+
);
|
|
515
|
+
|
|
516
|
+
case 'PERSON_ADDRESS':
|
|
517
|
+
return (
|
|
518
|
+
<>
|
|
519
|
+
<TextInput
|
|
520
|
+
id={`address-field-${column.id}`}
|
|
521
|
+
labelText="Address Field"
|
|
522
|
+
placeholder="e.g., city_village, state_province"
|
|
523
|
+
value={column.dataDefinitionConfig.field || ''}
|
|
524
|
+
onChange={(e) =>
|
|
525
|
+
updateColumn(column.id, {
|
|
526
|
+
dataDefinitionConfig: { ...column.dataDefinitionConfig, field: (e.target as HTMLInputElement).value },
|
|
527
|
+
})
|
|
528
|
+
}
|
|
529
|
+
disabled={disabled}
|
|
530
|
+
/>
|
|
531
|
+
<Select
|
|
532
|
+
id={`address-type-${column.id}`}
|
|
533
|
+
labelText="Address Type"
|
|
534
|
+
value={column.dataDefinitionConfig.type || 'PERSON_ADDRESS'}
|
|
535
|
+
onChange={(e) =>
|
|
536
|
+
updateColumn(column.id, {
|
|
537
|
+
dataDefinitionConfig: { ...column.dataDefinitionConfig, type: (e.target as HTMLSelectElement).value },
|
|
538
|
+
})
|
|
539
|
+
}
|
|
540
|
+
disabled={disabled}
|
|
541
|
+
>
|
|
542
|
+
<SelectItem value="PERSON_ADDRESS" text="Person Address" />
|
|
543
|
+
<SelectItem value="BIRTHPLACE" text="Birthplace" />
|
|
544
|
+
</Select>
|
|
545
|
+
</>
|
|
546
|
+
);
|
|
547
|
+
|
|
548
|
+
default:
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Render repeat resolution configuration for columns that may have multiple values
|
|
555
|
+
*/
|
|
556
|
+
const renderRepeatResolutionConfig = (column: LinelistColumnDraft) => {
|
|
557
|
+
const resolution = column.repeatResolution;
|
|
558
|
+
|
|
559
|
+
return (
|
|
560
|
+
<Stack gap={3}>
|
|
561
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
|
|
562
|
+
<Information size={16} />
|
|
563
|
+
<span style={{ fontSize: '0.875rem', fontWeight: 600 }}>
|
|
564
|
+
Repeat Value Resolution
|
|
565
|
+
</span>
|
|
566
|
+
</div>
|
|
567
|
+
<p style={{ fontSize: '0.875rem', color: '#525252' }}>
|
|
568
|
+
This column may return multiple values per patient. Configure how to handle this.
|
|
569
|
+
</p>
|
|
570
|
+
|
|
571
|
+
<Select
|
|
572
|
+
id={`repeat-strategy-${column.id}`}
|
|
573
|
+
labelText="Resolution Strategy"
|
|
574
|
+
value={resolution?.strategy || 'NONE'}
|
|
575
|
+
onChange={(e) => {
|
|
576
|
+
const strategy = (e.target as HTMLSelectElement).value as RepeatResolutionStrategy;
|
|
577
|
+
updateColumn(column.id, {
|
|
578
|
+
repeatResolution: {
|
|
579
|
+
...resolution,
|
|
580
|
+
strategy,
|
|
581
|
+
} as LinelistRepeatResolution,
|
|
582
|
+
});
|
|
583
|
+
}}
|
|
584
|
+
disabled={disabled}
|
|
585
|
+
>
|
|
586
|
+
{REPEAT_RESOLUTION_STRATEGIES.map((strategy) => (
|
|
587
|
+
<SelectItem
|
|
588
|
+
key={strategy.value}
|
|
589
|
+
value={strategy.value}
|
|
590
|
+
text={strategy.label}
|
|
591
|
+
title={strategy.description}
|
|
592
|
+
/>
|
|
593
|
+
))}
|
|
594
|
+
</Select>
|
|
595
|
+
|
|
596
|
+
{resolution?.strategy && resolution.strategy !== 'NONE' && (
|
|
597
|
+
<>
|
|
598
|
+
{REPEAT_RESOLUTION_STRATEGIES.find((s) => s.value === resolution.strategy)
|
|
599
|
+
?.needsOrderBy && (
|
|
600
|
+
<TextInput
|
|
601
|
+
id={`repeat-orderby-${column.id}`}
|
|
602
|
+
labelText="Order By Field (required)"
|
|
603
|
+
placeholder="e.g., return_visit_date, encounter_datetime"
|
|
604
|
+
value={resolution?.orderBy || ''}
|
|
605
|
+
onChange={(e) =>
|
|
606
|
+
updateColumn(column.id, {
|
|
607
|
+
repeatResolution: {
|
|
608
|
+
...resolution,
|
|
609
|
+
orderBy: (e.target as HTMLInputElement).value,
|
|
610
|
+
} as LinelistRepeatResolution,
|
|
611
|
+
})
|
|
612
|
+
}
|
|
613
|
+
disabled={disabled}
|
|
614
|
+
helperText="Field to use for ordering values"
|
|
615
|
+
/>
|
|
616
|
+
)}
|
|
617
|
+
|
|
618
|
+
<Toggle
|
|
619
|
+
id={`repeat-restrict-period-${column.id}`}
|
|
620
|
+
labelText="Restrict to Reporting Period"
|
|
621
|
+
toggled={resolution?.restrictToPeriod || false}
|
|
622
|
+
onToggle={(checked) =>
|
|
623
|
+
updateColumn(column.id, {
|
|
624
|
+
repeatResolution: {
|
|
625
|
+
...resolution,
|
|
626
|
+
restrictToPeriod: checked,
|
|
627
|
+
} as LinelistRepeatResolution,
|
|
628
|
+
})
|
|
629
|
+
}
|
|
630
|
+
disabled={disabled}
|
|
631
|
+
/>
|
|
632
|
+
|
|
633
|
+
<Toggle
|
|
634
|
+
id={`repeat-ignore-voided-${column.id}`}
|
|
635
|
+
labelText="Ignore Voided Records"
|
|
636
|
+
toggled={resolution?.ignoreVoided !== false}
|
|
637
|
+
onToggle={(checked) =>
|
|
638
|
+
updateColumn(column.id, {
|
|
639
|
+
repeatResolution: {
|
|
640
|
+
...resolution,
|
|
641
|
+
ignoreVoided: checked,
|
|
642
|
+
} as LinelistRepeatResolution,
|
|
643
|
+
})
|
|
644
|
+
}
|
|
645
|
+
disabled={disabled}
|
|
646
|
+
/>
|
|
647
|
+
|
|
648
|
+
<TextInput
|
|
649
|
+
id={`repeat-tiebreak-${column.id}`}
|
|
650
|
+
labelText="Tie-break Field (optional)"
|
|
651
|
+
placeholder="e.g., date_created"
|
|
652
|
+
value={resolution?.tieBreakField || ''}
|
|
653
|
+
onChange={(e) =>
|
|
654
|
+
updateColumn(column.id, {
|
|
655
|
+
repeatResolution: {
|
|
656
|
+
...resolution,
|
|
657
|
+
tieBreakField: (e.target as HTMLInputElement).value || undefined,
|
|
658
|
+
} as LinelistRepeatResolution,
|
|
659
|
+
})
|
|
660
|
+
}
|
|
661
|
+
disabled={disabled}
|
|
662
|
+
helperText="Field to use when values are equal"
|
|
663
|
+
/>
|
|
664
|
+
</>
|
|
665
|
+
)}
|
|
666
|
+
</Stack>
|
|
667
|
+
);
|
|
668
|
+
};
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Render SQL template quick-add buttons
|
|
672
|
+
*/
|
|
673
|
+
const renderSqlTemplates = () => {
|
|
674
|
+
return (
|
|
675
|
+
<div className={styles['sqlTemplates']}>
|
|
676
|
+
<p className={styles['templateLabel']}>Quick add common columns:</p>
|
|
677
|
+
<div className={styles['templateButtons']}>
|
|
678
|
+
{Object.entries(SQL_TEMPLATES).map(([key, sql]) => (
|
|
679
|
+
<Button
|
|
680
|
+
key={key}
|
|
681
|
+
kind="ghost"
|
|
682
|
+
size="sm"
|
|
683
|
+
onClick={() => {
|
|
684
|
+
const newColumn = createNewColumnDraft(
|
|
685
|
+
key,
|
|
686
|
+
'SQL',
|
|
687
|
+
{ sql },
|
|
688
|
+
columns.length
|
|
689
|
+
);
|
|
690
|
+
onChange([...columns, newColumn]);
|
|
691
|
+
}}
|
|
692
|
+
disabled={disabled}
|
|
693
|
+
>
|
|
694
|
+
{key.replace(/_/g, ' ')}
|
|
695
|
+
</Button>
|
|
696
|
+
))}
|
|
697
|
+
</div>
|
|
698
|
+
</div>
|
|
699
|
+
);
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
return (
|
|
703
|
+
<div className={styles['container']}>
|
|
704
|
+
<Stack gap={4}>
|
|
705
|
+
{/* Error message */}
|
|
706
|
+
{error && <div className={styles['error']}>{error}</div>}
|
|
707
|
+
|
|
708
|
+
{/* Table and Column Selection */}
|
|
709
|
+
<div className={styles['tableSelector']}>
|
|
710
|
+
<h4 className={styles['sectionTitle']}>Add from ETL Tables</h4>
|
|
711
|
+
|
|
712
|
+
{tablesLoading ? (
|
|
713
|
+
<DataTableSkeleton rowCount={5} />
|
|
714
|
+
) : tablesError ? (
|
|
715
|
+
<div className={styles['error']}>Failed to load tables: {tablesError}</div>
|
|
716
|
+
) : (
|
|
717
|
+
<Stack gap={2}>
|
|
718
|
+
{/* Table selector */}
|
|
719
|
+
<ComboBox
|
|
720
|
+
id="etl-table-selector"
|
|
721
|
+
titleText="Select ETL Table"
|
|
722
|
+
items={tables.map((t) => t)}
|
|
723
|
+
selectedItem={selectedTable}
|
|
724
|
+
onChange={({ selectedItem }) => {
|
|
725
|
+
setSelectedTable(selectedItem || null);
|
|
726
|
+
}}
|
|
727
|
+
placeholder="Select a table to view columns"
|
|
728
|
+
disabled={disabled}
|
|
729
|
+
/>
|
|
730
|
+
|
|
731
|
+
{/* Column list from selected table */}
|
|
732
|
+
{selectedTable && columnsLoading && <DataTableSkeleton rowCount={3} />}
|
|
733
|
+
|
|
734
|
+
{selectedTable &&
|
|
735
|
+
!columnsLoading &&
|
|
736
|
+
tableColumns.length > 0 && (
|
|
737
|
+
<div className={styles['columnList']}>
|
|
738
|
+
<p className={styles['helperText']}>
|
|
739
|
+
Click a column to add it to your linelist report:
|
|
740
|
+
</p>
|
|
741
|
+
<div className={styles['columnChips']}>
|
|
742
|
+
{tableColumns.map((col) => (
|
|
743
|
+
<Button
|
|
744
|
+
key={col.name}
|
|
745
|
+
kind="ghost"
|
|
746
|
+
size="sm"
|
|
747
|
+
renderIcon={Add}
|
|
748
|
+
onClick={() => addColumnFromTable(col)}
|
|
749
|
+
disabled={disabled}
|
|
750
|
+
>
|
|
751
|
+
{col.name}
|
|
752
|
+
{col.type && <span className={styles['columnType']}> ({col.type})</span>}
|
|
753
|
+
</Button>
|
|
754
|
+
))}
|
|
755
|
+
</div>
|
|
756
|
+
</div>
|
|
757
|
+
)}
|
|
758
|
+
|
|
759
|
+
{selectedTable && !columnsLoading && tableColumns.length === 0 && (
|
|
760
|
+
<div className={styles['emptyState']}>No columns found for this table</div>
|
|
761
|
+
)}
|
|
762
|
+
</Stack>
|
|
763
|
+
)}
|
|
764
|
+
</div>
|
|
765
|
+
|
|
766
|
+
{/* SQL Templates */}
|
|
767
|
+
<div className={styles['sqlTemplateSection']}>
|
|
768
|
+
<h4 className={styles['sectionTitle']}>Common Columns (SQL)</h4>
|
|
769
|
+
{renderSqlTemplates()}
|
|
770
|
+
</div>
|
|
771
|
+
|
|
772
|
+
{/* Person Attributes */}
|
|
773
|
+
<div className={styles['sqlTemplateSection']}>
|
|
774
|
+
<h4 className={styles['sectionTitle']}>Person Attributes</h4>
|
|
775
|
+
<div className={styles['templateButtons']}>
|
|
776
|
+
{Object.entries(PERSON_ATTRIBUTE_TEMPLATES).map(([key, template]) => (
|
|
777
|
+
<Button
|
|
778
|
+
key={key}
|
|
779
|
+
kind="ghost"
|
|
780
|
+
size="sm"
|
|
781
|
+
onClick={() => {
|
|
782
|
+
const newColumn = createNewColumnDraft(
|
|
783
|
+
key,
|
|
784
|
+
'PERSON_ATTRIBUTE',
|
|
785
|
+
{ attributeTypeUuid: template.uuid },
|
|
786
|
+
columns.length
|
|
787
|
+
);
|
|
788
|
+
onChange([...columns, newColumn]);
|
|
789
|
+
}}
|
|
790
|
+
disabled={disabled}
|
|
791
|
+
>
|
|
792
|
+
{template.label}
|
|
793
|
+
</Button>
|
|
794
|
+
))}
|
|
795
|
+
</div>
|
|
796
|
+
</div>
|
|
797
|
+
|
|
798
|
+
{/* Patient Identifiers */}
|
|
799
|
+
<div className={styles['sqlTemplateSection']}>
|
|
800
|
+
<h4 className={styles['sectionTitle']}>Patient Identifiers</h4>
|
|
801
|
+
<div className={styles['templateButtons']}>
|
|
802
|
+
{Object.entries(IDENTIFIER_TEMPLATES).map(([key, template]) => (
|
|
803
|
+
<Button
|
|
804
|
+
key={key}
|
|
805
|
+
kind="ghost"
|
|
806
|
+
size="sm"
|
|
807
|
+
onClick={() => {
|
|
808
|
+
const newColumn = createNewColumnDraft(
|
|
809
|
+
template.label,
|
|
810
|
+
'IDENTIFIER',
|
|
811
|
+
{ identifierTypeUuid: template.uuid, preferred: false },
|
|
812
|
+
columns.length
|
|
813
|
+
);
|
|
814
|
+
onChange([...columns, newColumn]);
|
|
815
|
+
}}
|
|
816
|
+
disabled={disabled}
|
|
817
|
+
>
|
|
818
|
+
{template.label}
|
|
819
|
+
</Button>
|
|
820
|
+
))}
|
|
821
|
+
</div>
|
|
822
|
+
</div>
|
|
823
|
+
|
|
824
|
+
{/* Person Name */}
|
|
825
|
+
<div className={styles['sqlTemplateSection']}>
|
|
826
|
+
<h4 className={styles['sectionTitle']}>Person Name</h4>
|
|
827
|
+
<div className={styles['templateButtons']}>
|
|
828
|
+
<Button
|
|
829
|
+
kind="ghost"
|
|
830
|
+
size="sm"
|
|
831
|
+
onClick={() => {
|
|
832
|
+
const newColumn = createNewColumnDraft(
|
|
833
|
+
'Patient Name',
|
|
834
|
+
'PERSON_NAME',
|
|
835
|
+
{ type: 'FULL_NAME' },
|
|
836
|
+
columns.length
|
|
837
|
+
);
|
|
838
|
+
onChange([...columns, newColumn]);
|
|
839
|
+
}}
|
|
840
|
+
disabled={disabled}
|
|
841
|
+
>
|
|
842
|
+
Full Name
|
|
843
|
+
</Button>
|
|
844
|
+
<Button
|
|
845
|
+
kind="ghost"
|
|
846
|
+
size="sm"
|
|
847
|
+
onClick={() => {
|
|
848
|
+
const newColumn = createNewColumnDraft(
|
|
849
|
+
'Given Name',
|
|
850
|
+
'PERSON_NAME',
|
|
851
|
+
{ type: 'GIVEN_NAME' },
|
|
852
|
+
columns.length
|
|
853
|
+
);
|
|
854
|
+
onChange([...columns, newColumn]);
|
|
855
|
+
}}
|
|
856
|
+
disabled={disabled}
|
|
857
|
+
>
|
|
858
|
+
Given Name
|
|
859
|
+
</Button>
|
|
860
|
+
<Button
|
|
861
|
+
kind="ghost"
|
|
862
|
+
size="sm"
|
|
863
|
+
onClick={() => {
|
|
864
|
+
const newColumn = createNewColumnDraft(
|
|
865
|
+
'Family Name',
|
|
866
|
+
'PERSON_NAME',
|
|
867
|
+
{ type: 'FAMILY_NAME' },
|
|
868
|
+
columns.length
|
|
869
|
+
);
|
|
870
|
+
onChange([...columns, newColumn]);
|
|
871
|
+
}}
|
|
872
|
+
disabled={disabled}
|
|
873
|
+
>
|
|
874
|
+
Family Name
|
|
875
|
+
</Button>
|
|
876
|
+
</div>
|
|
877
|
+
</div>
|
|
878
|
+
|
|
879
|
+
{/* Calculations */}
|
|
880
|
+
<div className={styles['sqlTemplateSection']}>
|
|
881
|
+
<h4 className={styles['sectionTitle']}>Calculations</h4>
|
|
882
|
+
<div className={styles['templateButtons']}>
|
|
883
|
+
<Button
|
|
884
|
+
kind="ghost"
|
|
885
|
+
size="sm"
|
|
886
|
+
onClick={() => {
|
|
887
|
+
const newColumn = createNewColumnDraft(
|
|
888
|
+
'Age',
|
|
889
|
+
'CALCULATION',
|
|
890
|
+
{ calculation: 'AGE', onDate: true },
|
|
891
|
+
columns.length
|
|
892
|
+
);
|
|
893
|
+
onChange([...columns, newColumn]);
|
|
894
|
+
}}
|
|
895
|
+
disabled={disabled}
|
|
896
|
+
>
|
|
897
|
+
Age
|
|
898
|
+
</Button>
|
|
899
|
+
<Button
|
|
900
|
+
kind="ghost"
|
|
901
|
+
size="sm"
|
|
902
|
+
onClick={() => {
|
|
903
|
+
const newColumn = createNewColumnDraft(
|
|
904
|
+
'Age (Months)',
|
|
905
|
+
'CALCULATION',
|
|
906
|
+
{ calculation: 'AGE_IN_MONTHS', onDate: true },
|
|
907
|
+
columns.length
|
|
908
|
+
);
|
|
909
|
+
onChange([...columns, newColumn]);
|
|
910
|
+
}}
|
|
911
|
+
disabled={disabled}
|
|
912
|
+
>
|
|
913
|
+
Age (Months)
|
|
914
|
+
</Button>
|
|
915
|
+
</div>
|
|
916
|
+
</div>
|
|
917
|
+
|
|
918
|
+
{/* Custom Column Button */}
|
|
919
|
+
<Button kind="secondary" renderIcon={Add} onClick={addCustomColumn} disabled={disabled}>
|
|
920
|
+
Add Custom Column
|
|
921
|
+
</Button>
|
|
922
|
+
|
|
923
|
+
{/* Selected Columns Table */}
|
|
924
|
+
{columns.length > 0 && (
|
|
925
|
+
<div className={styles['columnsTable']}>
|
|
926
|
+
<h4 className={styles['sectionTitle']}>Selected Columns ({columns.length})</h4>
|
|
927
|
+
|
|
928
|
+
<DataTable rows={columns.map((col, idx) => ({ id: idx, ...col }))} headers={[]}>
|
|
929
|
+
{({ rows }) => (
|
|
930
|
+
<TableBody>
|
|
931
|
+
{rows.map((row, idx) => {
|
|
932
|
+
const col = columns[idx];
|
|
933
|
+
const isExpanded = expandedRows.has(idx);
|
|
934
|
+
const typeInfo = DATA_DEFINITION_TYPES.find((t) => t.id === col.dataDefinitionType);
|
|
935
|
+
|
|
936
|
+
return (
|
|
937
|
+
<React.Fragment key={col.id}>
|
|
938
|
+
<TableRow>
|
|
939
|
+
{/* Order number */}
|
|
940
|
+
<TableCell className={styles['orderCell']}>
|
|
941
|
+
{idx + 1}
|
|
942
|
+
</TableCell>
|
|
943
|
+
|
|
944
|
+
{/* Column name */}
|
|
945
|
+
<TableCell>
|
|
946
|
+
<TextInput
|
|
947
|
+
id={`column-name-${col.id}`}
|
|
948
|
+
labelText=""
|
|
949
|
+
hideLabel
|
|
950
|
+
value={col.name}
|
|
951
|
+
onChange={(e) =>
|
|
952
|
+
updateColumn(col.id, {
|
|
953
|
+
name: (e.target as HTMLInputElement).value,
|
|
954
|
+
})
|
|
955
|
+
}
|
|
956
|
+
disabled={disabled}
|
|
957
|
+
/>
|
|
958
|
+
</TableCell>
|
|
959
|
+
|
|
960
|
+
{/* Data definition type */}
|
|
961
|
+
<TableCell>
|
|
962
|
+
<Tag type={TYPE_COLORS[col.dataDefinitionType]}>
|
|
963
|
+
{typeInfo?.label || col.dataDefinitionType}
|
|
964
|
+
</Tag>
|
|
965
|
+
</TableCell>
|
|
966
|
+
|
|
967
|
+
{/* Actions */}
|
|
968
|
+
<TableCell className={styles['actionsCell']}>
|
|
969
|
+
<ButtonSet>
|
|
970
|
+
<Button
|
|
971
|
+
hasIconOnly
|
|
972
|
+
kind="ghost"
|
|
973
|
+
size="sm"
|
|
974
|
+
renderIcon={ChevronUp}
|
|
975
|
+
onClick={() => moveColumn(idx, 'up')}
|
|
976
|
+
disabled={disabled || idx === 0}
|
|
977
|
+
iconDescription="Move up"
|
|
978
|
+
/>
|
|
979
|
+
<Button
|
|
980
|
+
hasIconOnly
|
|
981
|
+
kind="ghost"
|
|
982
|
+
size="sm"
|
|
983
|
+
renderIcon={ChevronDown}
|
|
984
|
+
onClick={() => moveColumn(idx, 'down')}
|
|
985
|
+
disabled={disabled || idx === columns.length - 1}
|
|
986
|
+
iconDescription="Move down"
|
|
987
|
+
/>
|
|
988
|
+
<Button
|
|
989
|
+
hasIconOnly
|
|
990
|
+
kind="ghost"
|
|
991
|
+
size="sm"
|
|
992
|
+
renderIcon={TrashCan}
|
|
993
|
+
onClick={() => removeColumn(col.id)}
|
|
994
|
+
disabled={disabled}
|
|
995
|
+
iconDescription="Remove column"
|
|
996
|
+
/>
|
|
997
|
+
<Button
|
|
998
|
+
kind="ghost"
|
|
999
|
+
size="sm"
|
|
1000
|
+
onClick={() => toggleRowExpansion(idx)}
|
|
1001
|
+
disabled={disabled}
|
|
1002
|
+
>
|
|
1003
|
+
{isExpanded ? 'Less' : 'More'}
|
|
1004
|
+
</Button>
|
|
1005
|
+
</ButtonSet>
|
|
1006
|
+
</TableCell>
|
|
1007
|
+
</TableRow>
|
|
1008
|
+
|
|
1009
|
+
{/* Expanded config row */}
|
|
1010
|
+
{isExpanded && (
|
|
1011
|
+
<TableRow className={styles['expandedRow']}>
|
|
1012
|
+
<TableCell colSpan={4}>
|
|
1013
|
+
<div className={styles['expandedContent']}>
|
|
1014
|
+
<Stack gap={3}>
|
|
1015
|
+
{/* Data definition type selector */}
|
|
1016
|
+
<Select
|
|
1017
|
+
id={`data-definition-type-${col.id}`}
|
|
1018
|
+
labelText="Data Definition Type"
|
|
1019
|
+
value={col.dataDefinitionType}
|
|
1020
|
+
onChange={(e) =>
|
|
1021
|
+
updateColumn(col.id, {
|
|
1022
|
+
dataDefinitionType: (e.target as HTMLSelectElement).value as ColumnDataType,
|
|
1023
|
+
dataDefinitionConfig: {},
|
|
1024
|
+
})
|
|
1025
|
+
}
|
|
1026
|
+
disabled={disabled}
|
|
1027
|
+
>
|
|
1028
|
+
{DATA_DEFINITION_TYPES.map((type) => (
|
|
1029
|
+
<SelectItem
|
|
1030
|
+
key={type.id}
|
|
1031
|
+
value={type.id}
|
|
1032
|
+
text={type.label}
|
|
1033
|
+
title={type.description}
|
|
1034
|
+
/>
|
|
1035
|
+
))}
|
|
1036
|
+
</Select>
|
|
1037
|
+
|
|
1038
|
+
{/* Type-specific config fields */}
|
|
1039
|
+
{renderConfigFields(col)}
|
|
1040
|
+
|
|
1041
|
+
{/* Helper text */}
|
|
1042
|
+
{typeInfo?.description && (
|
|
1043
|
+
<p className={styles['helperText']}>{typeInfo.description}</p>
|
|
1044
|
+
)}
|
|
1045
|
+
|
|
1046
|
+
{/* Repeat resolution configuration */}
|
|
1047
|
+
{renderRepeatResolutionConfig(col)}
|
|
1048
|
+
|
|
1049
|
+
{/* Transformation pipeline */}
|
|
1050
|
+
<div className={styles['transformationSection']}>
|
|
1051
|
+
<TransformationPipeline
|
|
1052
|
+
transformations={col.transformations || []}
|
|
1053
|
+
onChange={(transformations) =>
|
|
1054
|
+
updateColumn(col.id, { transformations })
|
|
1055
|
+
}
|
|
1056
|
+
disabled={disabled}
|
|
1057
|
+
/>
|
|
1058
|
+
</div>
|
|
1059
|
+
</Stack>
|
|
1060
|
+
</div>
|
|
1061
|
+
</TableCell>
|
|
1062
|
+
</TableRow>
|
|
1063
|
+
)}
|
|
1064
|
+
</React.Fragment>
|
|
1065
|
+
);
|
|
1066
|
+
})}
|
|
1067
|
+
</TableBody>
|
|
1068
|
+
)}
|
|
1069
|
+
</DataTable>
|
|
1070
|
+
</div>
|
|
1071
|
+
)}
|
|
1072
|
+
|
|
1073
|
+
{/* Empty state */}
|
|
1074
|
+
{columns.length === 0 && (
|
|
1075
|
+
<div className={styles['emptyState']}>
|
|
1076
|
+
<p>No columns selected. Add columns from an ETL table or add custom columns above.</p>
|
|
1077
|
+
</div>
|
|
1078
|
+
)}
|
|
1079
|
+
</Stack>
|
|
1080
|
+
</div>
|
|
1081
|
+
);
|
|
1082
|
+
}
|