@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,77 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
width: 100%;
|
|
3
|
+
padding: 1rem;
|
|
4
|
+
border: 1px solid #e0e0e0;
|
|
5
|
+
border-radius: 0.5rem;
|
|
6
|
+
background-color: #fafafa;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.header {
|
|
10
|
+
margin-bottom: 1rem;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.sectionTitle {
|
|
14
|
+
font-size: 0.875rem;
|
|
15
|
+
font-weight: 600;
|
|
16
|
+
margin-bottom: 0.25rem;
|
|
17
|
+
color: #525252;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.description {
|
|
21
|
+
font-size: 0.875rem;
|
|
22
|
+
color: #525252;
|
|
23
|
+
margin: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.sortTable {
|
|
27
|
+
margin-top: 1rem;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.priorityCell {
|
|
31
|
+
width: 3rem;
|
|
32
|
+
text-align: center;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.columnCell {
|
|
36
|
+
min-width: 12rem;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.columnName {
|
|
40
|
+
font-weight: 500;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.actionsCell {
|
|
44
|
+
width: 12rem;
|
|
45
|
+
white-space: nowrap;
|
|
46
|
+
|
|
47
|
+
.cds--btn-set {
|
|
48
|
+
display: flex;
|
|
49
|
+
gap: 0.25rem;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.expandedRow {
|
|
54
|
+
background-color: #f4f4f4;
|
|
55
|
+
|
|
56
|
+
td {
|
|
57
|
+
padding: 1rem !important;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.expandedContent {
|
|
62
|
+
width: 100%;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.helperText {
|
|
66
|
+
font-size: 0.875rem;
|
|
67
|
+
color: #525252;
|
|
68
|
+
margin-top: 0.25rem;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.emptyState {
|
|
72
|
+
padding: 2rem;
|
|
73
|
+
text-align: center;
|
|
74
|
+
background-color: #f4f4f4;
|
|
75
|
+
border-radius: 0.5rem;
|
|
76
|
+
color: #525252;
|
|
77
|
+
}
|
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cohort SQL Editor Component for Linelist Reports
|
|
3
|
+
*
|
|
4
|
+
* This component provides a SQL editor for writing patient selection queries.
|
|
5
|
+
* It includes:
|
|
6
|
+
* - SQL code editor with syntax highlighting
|
|
7
|
+
* - Visual filter builder for non-SQL users
|
|
8
|
+
* - Parameter validation (must include :startDate and :endDate)
|
|
9
|
+
* - Quick templates for common queries
|
|
10
|
+
* - SQL preview with validation
|
|
11
|
+
*
|
|
12
|
+
* Reuses patterns from indicator-sql-preview.section.tsx
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import React, { useState, useEffect } from 'react';
|
|
16
|
+
import {
|
|
17
|
+
Stack,
|
|
18
|
+
Button,
|
|
19
|
+
InlineNotification,
|
|
20
|
+
ComposedModal,
|
|
21
|
+
ModalBody,
|
|
22
|
+
ModalFooter,
|
|
23
|
+
DataTable,
|
|
24
|
+
TableRow,
|
|
25
|
+
TableCell,
|
|
26
|
+
TableBody,
|
|
27
|
+
} from '@carbon/react';
|
|
28
|
+
import { Information, Checkmark, Warning } from '@carbon/react/icons';
|
|
29
|
+
import VisualFilterBuilder from './visual-filter-panel.component';
|
|
30
|
+
import type { VisualFilterState, FilterFieldType, FilterMap } from '../../../../types/linelist-types';
|
|
31
|
+
import styles from './cohort-sql-editor.scss';
|
|
32
|
+
import FilterMapEditor from './filtermap-editor.component';
|
|
33
|
+
|
|
34
|
+
type Props = {
|
|
35
|
+
sql: string;
|
|
36
|
+
onChange: (sql: string) => void;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
error?: string;
|
|
39
|
+
visualFilter?: VisualFilterState;
|
|
40
|
+
onVisualFilterChange?: (visualFilter: VisualFilterState) => void;
|
|
41
|
+
availableFields?: Array<{ name: string; label: string; type: FilterFieldType }>;
|
|
42
|
+
filterMap?: FilterMap;
|
|
43
|
+
onFilterMapChange?: (filterMap: FilterMap | undefined) => void;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Common SQL templates for linelist cohort queries
|
|
48
|
+
*/
|
|
49
|
+
const SQL_TEMPLATES: Array<{
|
|
50
|
+
id: string;
|
|
51
|
+
label: string;
|
|
52
|
+
description: string;
|
|
53
|
+
sql: string;
|
|
54
|
+
}> = [
|
|
55
|
+
{
|
|
56
|
+
id: 'all_patients',
|
|
57
|
+
label: 'All Patients',
|
|
58
|
+
description: 'Select all patients registered in the system',
|
|
59
|
+
sql: `SELECT DISTINCT client_id
|
|
60
|
+
FROM mamba_fact_patients_latest_patient_demographics
|
|
61
|
+
WHERE 1=1
|
|
62
|
+
AND :startDate <= :endDate`,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'art_patients',
|
|
66
|
+
label: 'ART Patients',
|
|
67
|
+
description: 'Patients on ART treatment',
|
|
68
|
+
sql: `SELECT DISTINCT client_id
|
|
69
|
+
FROM mamba_fact_patients_latest_patient_demographics
|
|
70
|
+
WHERE art_start_date IS NOT NULL
|
|
71
|
+
AND art_start_date BETWEEN :startDate AND :endDate`,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: 'new_art_patients',
|
|
75
|
+
label: 'New ART Patients',
|
|
76
|
+
description: 'Patients newly initiated on ART',
|
|
77
|
+
sql: `SELECT DISTINCT client_id
|
|
78
|
+
FROM mamba_fact_patients_latest_patient_demographics
|
|
79
|
+
WHERE art_start_date BETWEEN :startDate AND :endDate`,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: 'encounter_patients',
|
|
83
|
+
label: 'Patients with Encounters',
|
|
84
|
+
description: 'Patients who had clinical encounters',
|
|
85
|
+
sql: `SELECT DISTINCT client_id
|
|
86
|
+
FROM mamba_fact_encounter
|
|
87
|
+
WHERE encounter_date BETWEEN :startDate AND :endDate`,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: 'appointment_missed',
|
|
91
|
+
label: 'Missed Appointments',
|
|
92
|
+
description: 'Patients who missed appointments',
|
|
93
|
+
sql: `SELECT DISTINCT client_id
|
|
94
|
+
FROM mamba_fact_appointment
|
|
95
|
+
WHERE appointment_date BETWEEN :startDate AND :endDate
|
|
96
|
+
AND attendance_status = 'Missed'`,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: 'due_vl',
|
|
100
|
+
label: 'Due for Viral Load',
|
|
101
|
+
description: 'Patients due for viral load testing',
|
|
102
|
+
sql: `SELECT DISTINCT client_id
|
|
103
|
+
FROM mamba_fact_patients_latest_viral_load
|
|
104
|
+
WHERE (
|
|
105
|
+
last_vl_result IS NULL
|
|
106
|
+
OR last_vl_date IS NULL
|
|
107
|
+
OR DATEDIFF(:endDate, last_vl_date) > 365
|
|
108
|
+
)
|
|
109
|
+
AND :startDate <= :endDate`,
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: 'high_vl',
|
|
113
|
+
label: 'High Viral Load',
|
|
114
|
+
description: 'Patients with viral load > 1000 copies',
|
|
115
|
+
sql: `SELECT DISTINCT client_id
|
|
116
|
+
FROM mamba_fact_patients_latest_viral_load
|
|
117
|
+
WHERE last_vl_result > 1000
|
|
118
|
+
AND last_vl_date BETWEEN :startDate AND :endDate`,
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* SQL keywords for syntax highlighting
|
|
124
|
+
*/
|
|
125
|
+
const SQL_KEYWORDS = [
|
|
126
|
+
'SELECT',
|
|
127
|
+
'FROM',
|
|
128
|
+
'WHERE',
|
|
129
|
+
'AND',
|
|
130
|
+
'OR',
|
|
131
|
+
'NOT',
|
|
132
|
+
'IN',
|
|
133
|
+
'NOT IN',
|
|
134
|
+
'BETWEEN',
|
|
135
|
+
'LIKE',
|
|
136
|
+
'IS NULL',
|
|
137
|
+
'IS NOT NULL',
|
|
138
|
+
'JOIN',
|
|
139
|
+
'LEFT JOIN',
|
|
140
|
+
'INNER JOIN',
|
|
141
|
+
'ON',
|
|
142
|
+
'AS',
|
|
143
|
+
'DISTINCT',
|
|
144
|
+
'ORDER BY',
|
|
145
|
+
'GROUP BY',
|
|
146
|
+
'HAVING',
|
|
147
|
+
'UNION',
|
|
148
|
+
'UNION ALL',
|
|
149
|
+
'EXISTS',
|
|
150
|
+
'NOT EXISTS',
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Validate SQL for required parameters
|
|
155
|
+
*/
|
|
156
|
+
function validateSql(sql: string): { valid: boolean; errors: string[]; warnings: string[] } {
|
|
157
|
+
const errors: string[] = [];
|
|
158
|
+
const warnings: string[] = [];
|
|
159
|
+
const trimmed = sql.trim();
|
|
160
|
+
|
|
161
|
+
if (!trimmed) {
|
|
162
|
+
errors.push('SQL query is required');
|
|
163
|
+
return { valid: false, errors, warnings };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Check for required parameters
|
|
167
|
+
if (!trimmed.includes(':startDate')) {
|
|
168
|
+
errors.push('SQL must include :startDate parameter');
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (!trimmed.includes(':endDate')) {
|
|
172
|
+
errors.push('SQL must include :endDate parameter');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Check for SELECT statement
|
|
176
|
+
const upperSql = trimmed.toUpperCase();
|
|
177
|
+
if (!upperSql.includes('SELECT')) {
|
|
178
|
+
errors.push('SQL must include a SELECT statement');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Check for patient_id column
|
|
182
|
+
if (!upperSql.includes('PATIENT_ID') && !upperSql.includes('CLIENT_ID')) {
|
|
183
|
+
warnings.push('SQL should select patient_id or client_id column');
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Check for DISTINCT (recommended for patient lists)
|
|
187
|
+
if (!upperSql.includes('DISTINCT')) {
|
|
188
|
+
warnings.push('Consider using SELECT DISTINCT to avoid duplicate patients');
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
valid: errors.length === 0,
|
|
193
|
+
errors,
|
|
194
|
+
warnings,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Basic SQL syntax highlighting
|
|
200
|
+
*/
|
|
201
|
+
function highlightSql(sql: string): string {
|
|
202
|
+
let highlighted = sql;
|
|
203
|
+
|
|
204
|
+
// Highlight parameters
|
|
205
|
+
highlighted = highlighted.replace(/:(startDate|endDate)/g, '<span class="sql-parameter">:$1</span>');
|
|
206
|
+
|
|
207
|
+
// Highlight strings
|
|
208
|
+
highlighted = highlighted.replace(/'([^']*)'/g, '<span class="sql-string">\'$1\'</span>');
|
|
209
|
+
|
|
210
|
+
// Highlight numbers
|
|
211
|
+
highlighted = highlighted.replace(/\b(\d+)\b/g, '<span class="sql-number">$1</span>');
|
|
212
|
+
|
|
213
|
+
// Highlight comments
|
|
214
|
+
highlighted = highlighted.replace(/--(.*)$/gm, '<span class="sql-comment">--$1</span>');
|
|
215
|
+
|
|
216
|
+
// Highlight keywords
|
|
217
|
+
SQL_KEYWORDS.forEach((keyword) => {
|
|
218
|
+
const regex = new RegExp(`\\b${keyword}\\b`, 'gi');
|
|
219
|
+
highlighted = highlighted.replace(regex, `<span class="sql-keyword">${keyword}</span>`);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
return highlighted;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export default function CohortSQLEditor({
|
|
226
|
+
sql,
|
|
227
|
+
onChange,
|
|
228
|
+
disabled = false,
|
|
229
|
+
error,
|
|
230
|
+
visualFilter,
|
|
231
|
+
onVisualFilterChange,
|
|
232
|
+
availableFields = [],
|
|
233
|
+
filterMap,
|
|
234
|
+
onFilterMapChange,
|
|
235
|
+
}: Props) {
|
|
236
|
+
const [showTemplates, setShowTemplates] = useState(false);
|
|
237
|
+
const [showValidation, setShowValidation] = useState(false);
|
|
238
|
+
const [validation, setValidation] = useState(validateSql(sql));
|
|
239
|
+
|
|
240
|
+
// Update validation when SQL changes
|
|
241
|
+
useEffect(() => {
|
|
242
|
+
setValidation(validateSql(sql));
|
|
243
|
+
}, [sql]);
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Apply a template to the SQL editor
|
|
247
|
+
*/
|
|
248
|
+
const applyTemplate = (template: typeof SQL_TEMPLATES[number]) => {
|
|
249
|
+
onChange(template.sql);
|
|
250
|
+
setShowTemplates(false);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Format SQL (basic formatting)
|
|
255
|
+
*/
|
|
256
|
+
const formatSql = () => {
|
|
257
|
+
let formatted = sql.trim();
|
|
258
|
+
|
|
259
|
+
// Basic formatting: add newlines after major keywords
|
|
260
|
+
SQL_KEYWORDS.forEach((keyword) => {
|
|
261
|
+
const regex = new RegExp(`\\b${keyword}\\b`, 'gi');
|
|
262
|
+
formatted = formatted.replace(regex, `${keyword}\n`);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// Clean up extra newlines
|
|
266
|
+
formatted = formatted.replace(/\n\s*\n/g, '\n');
|
|
267
|
+
|
|
268
|
+
onChange(formatted);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const hasErrors = validation.errors.length > 0;
|
|
272
|
+
const hasWarnings = validation.warnings.length > 0;
|
|
273
|
+
|
|
274
|
+
return (
|
|
275
|
+
<div className={styles.container}>
|
|
276
|
+
<Stack gap={4}>
|
|
277
|
+
{/* Header with actions */}
|
|
278
|
+
<div className={styles.header}>
|
|
279
|
+
<h4 className={styles.title}>Patient Selection SQL</h4>
|
|
280
|
+
<div className={styles.actions}>
|
|
281
|
+
<Button kind="ghost" size="sm" onClick={() => setShowTemplates(true)} disabled={disabled}>
|
|
282
|
+
Load Template
|
|
283
|
+
</Button>
|
|
284
|
+
<Button kind="ghost" size="sm" onClick={formatSql} disabled={disabled || !sql.trim()}>
|
|
285
|
+
Format SQL
|
|
286
|
+
</Button>
|
|
287
|
+
<Button kind="ghost" size="sm" onClick={() => setShowValidation(!showValidation)} disabled={disabled}>
|
|
288
|
+
{showValidation ? 'Hide' : 'Show'} Validation
|
|
289
|
+
</Button>
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
|
|
293
|
+
{/* Helper text */}
|
|
294
|
+
<p className={styles.helperText}>
|
|
295
|
+
Write a SQL query that returns patient IDs. Use <code>:startDate</code> and <code>:endDate</code> parameters
|
|
296
|
+
for date filtering. The query should use <code>SELECT DISTINCT patient_id</code> to ensure unique
|
|
297
|
+
patients.
|
|
298
|
+
</p>
|
|
299
|
+
|
|
300
|
+
{/* Visual Filter Builder */}
|
|
301
|
+
{onVisualFilterChange && visualFilter && (
|
|
302
|
+
<VisualFilterBuilder
|
|
303
|
+
visualFilter={visualFilter}
|
|
304
|
+
onChange={onVisualFilterChange}
|
|
305
|
+
onSqlChange={onChange}
|
|
306
|
+
availableFields={availableFields}
|
|
307
|
+
disabled={disabled}
|
|
308
|
+
/>
|
|
309
|
+
)}
|
|
310
|
+
|
|
311
|
+
{/* FilterMap Editor */}
|
|
312
|
+
{onFilterMapChange && (
|
|
313
|
+
<FilterMapEditor
|
|
314
|
+
filterMap={filterMap}
|
|
315
|
+
onChange={onFilterMapChange}
|
|
316
|
+
disabled={disabled}
|
|
317
|
+
sqlQuery={sql}
|
|
318
|
+
/>
|
|
319
|
+
)}
|
|
320
|
+
|
|
321
|
+
{/* Validation summary */}
|
|
322
|
+
{(hasErrors || hasWarnings) && (
|
|
323
|
+
<div className={styles.validationSummary}>
|
|
324
|
+
{hasErrors && (
|
|
325
|
+
<InlineNotification
|
|
326
|
+
kind="error"
|
|
327
|
+
title="SQL Validation Errors"
|
|
328
|
+
subtitle={validation.errors.join(', ')}
|
|
329
|
+
hideCloseButton
|
|
330
|
+
lowContrast
|
|
331
|
+
/>
|
|
332
|
+
)}
|
|
333
|
+
{!hasErrors && hasWarnings && (
|
|
334
|
+
<InlineNotification
|
|
335
|
+
kind="warning"
|
|
336
|
+
title="SQL Warnings"
|
|
337
|
+
subtitle={validation.warnings.join(', ')}
|
|
338
|
+
hideCloseButton
|
|
339
|
+
lowContrast
|
|
340
|
+
/>
|
|
341
|
+
)}
|
|
342
|
+
{!hasErrors && !hasWarnings && (
|
|
343
|
+
<InlineNotification
|
|
344
|
+
kind="success"
|
|
345
|
+
title="SQL Valid"
|
|
346
|
+
subtitle="Your SQL query looks good!"
|
|
347
|
+
hideCloseButton
|
|
348
|
+
lowContrast
|
|
349
|
+
/>
|
|
350
|
+
)}
|
|
351
|
+
</div>
|
|
352
|
+
)}
|
|
353
|
+
|
|
354
|
+
{/* SQL Editor */}
|
|
355
|
+
<div className={styles.editorWrapper}>
|
|
356
|
+
<textarea
|
|
357
|
+
value={sql}
|
|
358
|
+
onChange={(e) => onChange((e.target as HTMLTextAreaElement).value)}
|
|
359
|
+
disabled={disabled}
|
|
360
|
+
className={styles.sqlEditor}
|
|
361
|
+
placeholder="Enter your SQL query here..."
|
|
362
|
+
spellCheck={false}
|
|
363
|
+
/>
|
|
364
|
+
|
|
365
|
+
{/* Syntax highlighted preview (read-only) */}
|
|
366
|
+
<div className={styles.sqlPreview} dangerouslySetInnerHTML={{ __html: highlightSql(sql) }} />
|
|
367
|
+
</div>
|
|
368
|
+
|
|
369
|
+
{/* Error from parent */}
|
|
370
|
+
{error && <div className={styles.error}>{error}</div>}
|
|
371
|
+
|
|
372
|
+
{/* Validation details panel */}
|
|
373
|
+
{showValidation && (
|
|
374
|
+
<div className={styles.validationDetails}>
|
|
375
|
+
<h5>Validation Results</h5>
|
|
376
|
+
|
|
377
|
+
{validation.errors.length > 0 && (
|
|
378
|
+
<div className={styles.validationSection}>
|
|
379
|
+
<h6>Errors</h6>
|
|
380
|
+
<ul>
|
|
381
|
+
{validation.errors.map((err, idx) => (
|
|
382
|
+
<li key={idx} className={styles.errorItem}>
|
|
383
|
+
<Warning className={styles.errorIcon} />
|
|
384
|
+
{err}
|
|
385
|
+
</li>
|
|
386
|
+
))}
|
|
387
|
+
</ul>
|
|
388
|
+
</div>
|
|
389
|
+
)}
|
|
390
|
+
|
|
391
|
+
{validation.warnings.length > 0 && (
|
|
392
|
+
<div className={styles.validationSection}>
|
|
393
|
+
<h6>Warnings</h6>
|
|
394
|
+
<ul>
|
|
395
|
+
{validation.warnings.map((warn, idx) => (
|
|
396
|
+
<li key={idx} className={styles.warningItem}>
|
|
397
|
+
<Information className={styles.warningIcon} />
|
|
398
|
+
{warn}
|
|
399
|
+
</li>
|
|
400
|
+
))}
|
|
401
|
+
</ul>
|
|
402
|
+
</div>
|
|
403
|
+
)}
|
|
404
|
+
|
|
405
|
+
{validation.errors.length === 0 && validation.warnings.length === 0 && (
|
|
406
|
+
<div className={styles.validationSection}>
|
|
407
|
+
<p className={styles.successItem}>
|
|
408
|
+
<Checkmark className={styles.successIcon} />
|
|
409
|
+
All checks passed! Your SQL query includes the required parameters.
|
|
410
|
+
</p>
|
|
411
|
+
</div>
|
|
412
|
+
)}
|
|
413
|
+
</div>
|
|
414
|
+
)}
|
|
415
|
+
</Stack>
|
|
416
|
+
|
|
417
|
+
{/* Template selection modal */}
|
|
418
|
+
{showTemplates && (
|
|
419
|
+
<ComposedModal
|
|
420
|
+
open={showTemplates}
|
|
421
|
+
onClose={() => setShowTemplates(false)}
|
|
422
|
+
size="lg"
|
|
423
|
+
>
|
|
424
|
+
<ModalBody title="Select SQL Template">
|
|
425
|
+
<p className={styles.templateHelp}>
|
|
426
|
+
Choose a template to get started. Templates provide common SQL patterns that you can
|
|
427
|
+
customize for your needs.
|
|
428
|
+
</p>
|
|
429
|
+
|
|
430
|
+
<DataTable
|
|
431
|
+
rows={SQL_TEMPLATES.map((t, idx) => ({ id: idx, ...t }))}
|
|
432
|
+
headers={[
|
|
433
|
+
{ key: 'label', header: 'Template Name' },
|
|
434
|
+
{ key: 'description', header: 'Description' },
|
|
435
|
+
{ key: 'action', header: '' },
|
|
436
|
+
]}
|
|
437
|
+
>
|
|
438
|
+
{({ rows }) => (
|
|
439
|
+
<TableBody>
|
|
440
|
+
{rows.map((row) => (
|
|
441
|
+
<TableRow key={row.id}>
|
|
442
|
+
<TableCell>
|
|
443
|
+
<strong>{SQL_TEMPLATES[row.id].label}</strong>
|
|
444
|
+
</TableCell>
|
|
445
|
+
<TableCell>{SQL_TEMPLATES[row.id].description}</TableCell>
|
|
446
|
+
<TableCell>
|
|
447
|
+
<Button
|
|
448
|
+
size="sm"
|
|
449
|
+
kind="ghost"
|
|
450
|
+
onClick={() => applyTemplate(SQL_TEMPLATES[row.id])}
|
|
451
|
+
>
|
|
452
|
+
Use Template
|
|
453
|
+
</Button>
|
|
454
|
+
</TableCell>
|
|
455
|
+
</TableRow>
|
|
456
|
+
))}
|
|
457
|
+
</TableBody>
|
|
458
|
+
)}
|
|
459
|
+
</DataTable>
|
|
460
|
+
|
|
461
|
+
<div className={styles.templatePreview}>
|
|
462
|
+
<h6>SQL Preview</h6>
|
|
463
|
+
<pre className={styles.previewCode}>
|
|
464
|
+
{SQL_TEMPLATES.find((t) => t.id)?.sql || '-- Select a template to preview SQL'}
|
|
465
|
+
</pre>
|
|
466
|
+
</div>
|
|
467
|
+
</ModalBody>
|
|
468
|
+
<ModalFooter secondaryButtonText="Cancel" onRequestClose={() => setShowTemplates(false)}>
|
|
469
|
+
{null}
|
|
470
|
+
</ModalFooter>
|
|
471
|
+
</ComposedModal>
|
|
472
|
+
)}
|
|
473
|
+
</div>
|
|
474
|
+
);
|
|
475
|
+
}
|