@epcare/esm-report-builder 0.1.1-pre.2 → 0.1.1-pre.20
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/README.md +19 -0
- package/dist/162.js +1 -0
- package/dist/162.js.map +1 -0
- package/dist/184.js +2 -0
- package/dist/184.js.map +1 -0
- package/dist/242.js +2 -0
- package/dist/{d1aa59bd9c702dc4.js.LICENSE.txt → 242.js.LICENSE.txt} +0 -11
- package/dist/242.js.map +1 -0
- package/dist/271.js +2 -0
- package/dist/{377971e519bf3f4a.js.LICENSE.txt → 271.js.LICENSE.txt} +6 -0
- package/dist/271.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/382.js +2 -0
- package/dist/382.js.LICENSE.txt +77 -0
- package/dist/382.js.map +1 -0
- package/dist/478.js +2 -0
- package/dist/478.js.map +1 -0
- package/dist/540.js +2 -0
- package/dist/540.js.map +1 -0
- package/dist/698.js +1 -0
- package/dist/698.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/764.js +1 -0
- package/dist/764.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.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 +506 -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/tsconfig.json +11 -0
- package/example.env +5 -0
- package/jest.config.js +28 -0
- package/package.json +34 -17
- package/playwright.config.ts +28 -0
- package/src/components/admin/admin-page.component.tsx +5 -0
- package/src/components/app-shell/report-builder-shell.component.tsx +3 -0
- package/src/components/data-themes/data-theme-modal.component.tsx +3 -3
- package/src/components/data-themes/sections/data-theme-condition-columns.section.tsx +1 -1
- package/src/components/data-themes/sections/data-theme-source.section.tsx +3 -3
- package/src/components/indicators/create-base-indicator-modal.component.tsx +1 -0
- package/src/components/indicators/create-composite-base-indicator-modal.component.tsx +4 -0
- package/src/components/indicators/create-final-indicator-modal.component.tsx +8 -0
- package/src/components/indicators/handler/question-answer-concept-search.component.tsx +2 -2
- package/src/components/indicators/sections/indicator-conditions.section.tsx +39 -1
- package/src/components/indicators/utils/indicator-sql.utils.ts +33 -0
- package/src/components/landing/report-builder-landing-page.component.tsx +26 -1
- package/src/components/landing/report-builder-landing-page.scss +1 -1
- 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/report/design/report-design-editor.component.tsx +1 -1
- package/src/components/run-reports/run-reports-page.component.tsx +2 -17
- package/src/components/shared/preview/query-results-preview.component.tsx +2 -2
- package/src/data-visualizer/components/cqi-components/cqi-data-table.component.tsx +214 -0
- package/src/data-visualizer/components/cqi-components/cqi-elements.ts +203 -0
- package/src/data-visualizer/components/cqi-components/detail.component.tsx +110 -0
- package/src/data-visualizer/components/cqi-components/detail.scss +22 -0
- package/src/data-visualizer/components/data-table/data-table.component.tsx +208 -0
- package/src/data-visualizer/components/data-table/data-tables.scss +206 -0
- package/src/data-visualizer/components/empty-state/empty-state-illustration.component.tsx +53 -0
- package/src/data-visualizer/components/header/header.component.tsx +43 -0
- package/src/data-visualizer/components/header/header.scss +71 -0
- package/src/data-visualizer/components/model/confirm.component.tsx +40 -0
- package/src/data-visualizer/components/panel/panel.component.tsx +20 -0
- package/src/data-visualizer/components/panel/panel.scss +25 -0
- package/src/data-visualizer/components/popover/modifier-panel.tsx +53 -0
- package/src/data-visualizer/constants.ts +445 -0
- package/src/data-visualizer/data-visualizer-illustration.component.tsx +31 -0
- package/src/data-visualizer/data-visualizer.component.tsx +1453 -0
- package/src/data-visualizer/data-visualizer.resource.ts +467 -0
- package/src/data-visualizer/data-visualizer.scss +363 -0
- package/src/data-visualizer/declarations.d.ts +131 -0
- package/src/data-visualizer/types.ts +206 -0
- package/src/hooks/theme/useMambaTableMeta.ts +4 -4
- package/src/hooks/theme/useMambaTables.ts +2 -2
- package/src/index.ts +6 -0
- package/src/resources/indicator/indicators.api.ts +1 -1
- package/src/resources/legacy-reports/legacy-reports.api.ts +156 -0
- package/src/resources/theme/{mamba-table-meta.api.ts → etl-table-meta.api.ts} +2 -2
- package/src/routes/report-builder.routes.tsx +10 -1
- package/src/routes.json +6 -0
- package/tools/setup-tests.ts +1 -0
- package/translations/en.json +65 -0
- package/tsconfig.json +43 -0
- package/webpack.config.js +14 -0
- package/dist/0081d5d3d536cb23.js +0 -1
- package/dist/02acc4469a2fe2e4.woff2 +0 -0
- package/dist/081587ca0db8e63f.woff2 +0 -0
- package/dist/08cf53c4e5e71cf1.woff2 +0 -0
- package/dist/090b2bc014d24ea4.woff2 +0 -0
- package/dist/09de5db63ef7b579.js +0 -1
- package/dist/0ae92bcea615e948.woff2 +0 -0
- package/dist/0be8520d8945b3b7.woff2 +0 -0
- package/dist/0e7dd073cd8bb0ad.woff2 +0 -0
- package/dist/0edb77cd19e43550.js +0 -1
- package/dist/14869ac5d1830304.woff2 +0 -0
- package/dist/14aaceff85fc8b28.woff2 +0 -0
- package/dist/14c3abea79fc1389.js +0 -1
- package/dist/155a4ac079785bfd.js +0 -1
- package/dist/155a4ac079785bfd.js.map +0 -1
- package/dist/16f443eed01776ca.woff2 +0 -0
- package/dist/183bae0e53a22182.woff2 +0 -0
- package/dist/19c8f94ccd6289f5.woff2 +0 -0
- package/dist/1ae86565eab7451c.woff2 +0 -0
- package/dist/1c7bf8797e0a9be6.woff2 +0 -0
- package/dist/1f266d3619b30f16.woff2 +0 -0
- package/dist/1f8c5a4087a524fd.woff2 +0 -0
- package/dist/20ba2b23c5c0cd0b.woff2 +0 -0
- package/dist/22a32bd51591301b.js +0 -1
- package/dist/273c72d90e432a3d.js +0 -1
- package/dist/295dd01a1fbfee6d.woff2 +0 -0
- package/dist/29cbe6827c3f03ef.js +0 -1
- package/dist/2f686985e26e7107.woff2 +0 -0
- package/dist/315eff729e4ccbd9.woff2 +0 -0
- package/dist/368d16e3259bf207.woff2 +0 -0
- package/dist/36c49aa341a7079a.woff2 +0 -0
- package/dist/36e1e0430475edee.woff2 +0 -0
- package/dist/374c3ee36d9e040a.js +0 -1
- package/dist/377971e519bf3f4a.js +0 -2
- package/dist/377971e519bf3f4a.js.map +0 -1
- package/dist/3b0ea8395009dcf3.js +0 -2
- package/dist/3b0ea8395009dcf3.js.map +0 -1
- package/dist/3bc19662b8630ee9.woff2 +0 -0
- package/dist/3f645f473b3f8fba.woff2 +0 -0
- package/dist/41320d8930d23b36.js +0 -1
- package/dist/4218ac9901b9d36d.woff2 +0 -0
- package/dist/4659f3ca46d928b5.js +0 -1
- package/dist/4659f3ca46d928b5.js.map +0 -1
- package/dist/4680ba68412e4da9.woff2 +0 -0
- package/dist/48e37bd7ebf85a1f.woff2 +0 -0
- package/dist/4aabceefe5a2494a.js +0 -1
- package/dist/4c188cbaefba58cd.js +0 -1
- package/dist/4e11b8a7c445255f.woff2 +0 -0
- package/dist/537ddd61c5c1fce2.woff2 +0 -0
- package/dist/54f5eee3a7989556.js +0 -1
- package/dist/55c9107b50dd747c.js +0 -1
- package/dist/56c4118c0907f151.woff2 +0 -0
- package/dist/5938bc2ae7ec60c0.woff2 +0 -0
- package/dist/5c6586155f0d278a.woff2 +0 -0
- package/dist/5e50c92017029ca3.js +0 -1
- package/dist/5e50c92017029ca3.js.map +0 -1
- package/dist/600aca7295d8bcb7.js +0 -2
- package/dist/600aca7295d8bcb7.js.map +0 -1
- package/dist/60ec587649ba812a.woff2 +0 -0
- package/dist/64cf08a5ac3266d8.js +0 -1
- package/dist/652f476a8a1603d3.js +0 -2
- package/dist/652f476a8a1603d3.js.LICENSE.txt +0 -9
- package/dist/652f476a8a1603d3.js.map +0 -1
- package/dist/65e6511e035870e1.woff2 +0 -0
- package/dist/661425f6798cd16a.woff2 +0 -0
- package/dist/66b864fe213caf46.woff2 +0 -0
- package/dist/680eb791e6266590.js +0 -2
- package/dist/680eb791e6266590.js.map +0 -1
- package/dist/69d087d970ee9455.woff2 +0 -0
- package/dist/69e3aa4276b4cb4b.js +0 -1
- package/dist/6a88f03fc4e7c3da.js +0 -1
- package/dist/6c6c45e66ff54281.woff2 +0 -0
- package/dist/6d9009857c6df878.js +0 -1
- package/dist/6ebe7cea59ed2853.js +0 -1
- package/dist/6f3181849e740935.js +0 -1
- package/dist/6f3181849e740935.js.map +0 -1
- package/dist/7073a7323e92bd11.woff2 +0 -0
- package/dist/70ac433ae2a89a89.js +0 -1
- package/dist/70ee4ee625ac0ec1.js +0 -1
- package/dist/718c6cc31274ab1a.woff2 +0 -0
- package/dist/727696c3934d0966.js +0 -1
- package/dist/727763c0f0df59dc.js +0 -1
- package/dist/727763c0f0df59dc.js.map +0 -1
- package/dist/72cdbedfe04be9f9.woff2 +0 -0
- package/dist/7509c9f56fe9e532.woff2 +0 -0
- package/dist/75dc5c5b04adc8bf.woff2 +0 -0
- package/dist/77b48bc05299ecca.woff2 +0 -0
- package/dist/7a0a0215c248c73d.woff2 +0 -0
- package/dist/7c0d0c5180de8729.js +0 -1
- package/dist/7f00bebb24e40167.woff2 +0 -0
- package/dist/802c6176541eeed7.woff2 +0 -0
- package/dist/8080081b3379c637.woff2 +0 -0
- package/dist/81cfdaeaa0bbca1f.js +0 -1
- package/dist/8605507b7a8487c4.woff2 +0 -0
- package/dist/893a160d06428365.js +0 -1
- package/dist/893a160d06428365.js.map +0 -1
- package/dist/8a83d654702f6534.woff2 +0 -0
- package/dist/8fe71173a13fe571.woff2 +0 -0
- package/dist/94aa912dcac90114.js +0 -1
- package/dist/9624cec0f9bdd81e.woff2 +0 -0
- package/dist/98a3af55a1698171.woff2 +0 -0
- package/dist/99823aaebba56f46.js +0 -1
- package/dist/9ba85996af74c5ce.woff2 +0 -0
- package/dist/9ddb22faa35006e7.woff2 +0 -0
- package/dist/a167fb2799dd741b.woff2 +0 -0
- package/dist/a2045a5cc4fdf94f.woff2 +0 -0
- package/dist/a246c73905a31c93.woff2 +0 -0
- package/dist/a325099b0a580ce2.js +0 -2
- package/dist/a325099b0a580ce2.js.map +0 -1
- package/dist/a401aa7939cb6e6f.woff2 +0 -0
- package/dist/a40fef67997d3b2c.js +0 -1
- package/dist/a62897b000a24b86.js +0 -1
- package/dist/a6ed036f17a1ea29.woff2 +0 -0
- package/dist/a77bac4877483a0a.js +0 -1
- package/dist/a9f25ca430709a1a.woff2 +0 -0
- package/dist/aa0dfbdd569b1c24.js +0 -2
- package/dist/aa0dfbdd569b1c24.js.LICENSE.txt +0 -5
- package/dist/aa0dfbdd569b1c24.js.map +0 -1
- package/dist/ab0f637d6cff12e4.js +0 -1
- package/dist/afa9121a49e95351.woff2 +0 -0
- package/dist/afcda12d9f805543.woff2 +0 -0
- package/dist/b09ded85a7da77f1.woff2 +0 -0
- package/dist/b10dbe5318a91a12.js +0 -1
- package/dist/b2f4e9d1e821b71c.woff2 +0 -0
- package/dist/b4a074bf828bb757.woff2 +0 -0
- package/dist/b7f447da43f6e596.woff2 +0 -0
- package/dist/bcca84a524572d10.woff2 +0 -0
- package/dist/be093e052a6d50eb.js +0 -1
- package/dist/be4d1f97b11d087c.woff2 +0 -0
- package/dist/bec14780d81164de.woff2 +0 -0
- package/dist/c31657fe213c1b5e.js +0 -1
- package/dist/c49ef726d3f0420b.js +0 -1
- package/dist/c553f7e0199c5084.woff2 +0 -0
- package/dist/c94ac2fdc1ff1418.js +0 -1
- package/dist/c9d9ce9f465df4fe.woff2 +0 -0
- package/dist/cbbb57b397433964.js +0 -2
- package/dist/cbbb57b397433964.js.LICENSE.txt +0 -14
- package/dist/cbbb57b397433964.js.map +0 -1
- package/dist/d188f7f036ac5779.woff2 +0 -0
- package/dist/d1aa59bd9c702dc4.js +0 -2
- package/dist/d1aa59bd9c702dc4.js.map +0 -1
- package/dist/d265d81c58525ae4.woff2 +0 -0
- package/dist/d5942cd81663e136.woff2 +0 -0
- package/dist/d66b8ff73d95cabb.woff2 +0 -0
- package/dist/d84bac6d07672dd2.js +0 -1
- package/dist/d84bac6d07672dd2.js.map +0 -1
- package/dist/d88899ef0fd16719.woff2 +0 -0
- package/dist/d92b5ecf31fc187b.js +0 -1
- package/dist/d9a5d958e69e058d.woff2 +0 -0
- package/dist/dac90d495be353a0.woff2 +0 -0
- package/dist/db0550511978dc47.js +0 -1
- package/dist/dd8ce598529c3fab.woff2 +0 -0
- package/dist/de013f1be25103fa.woff2 +0 -0
- package/dist/df222fceeffca849.woff2 +0 -0
- package/dist/df22bda08ec7964c.js +0 -1
- package/dist/e05b7f902b02a251.js +0 -1
- package/dist/e05b7f902b02a251.js.map +0 -1
- package/dist/e465f1481f0d2e1c.js +0 -1
- package/dist/e62b00b9199c1ac9.woff2 +0 -0
- package/dist/e696cef1407b2610.woff2 +0 -0
- package/dist/eb42de5422d9af00.js +0 -1
- package/dist/eed48feba743e21c.woff2 +0 -0
- package/dist/f135ef54213f8975.js +0 -1
- package/dist/f260e50923d4283b.js +0 -1
- package/dist/f543c88feb236d11.woff2 +0 -0
- package/dist/f591b0079faa93fe.woff2 +0 -0
- package/dist/f6ed27923769ad1d.woff2 +0 -0
- package/dist/f8d066e92ea157c6.js +0 -1
- package/dist/fae042506530c1e6.js +0 -1
- package/dist/favicon.ico +0 -0
- package/dist/fbebeb4336e67012.woff2 +0 -0
- package/dist/fd574df77d31a5eb.js +0 -1
- package/dist/icon_128x128.3dde25c6e69b1c010a6a5d6b27b3f436.png +0 -0
- package/dist/icon_144x144.e263e02b838d229b02ff9133e6e0f2ba.png +0 -0
- package/dist/icon_192x192.d3d318638bbe8a10a3c687d3d302d01a.png +0 -0
- package/dist/icon_256x256.c729f6e7e914b58fcea5ce91d7aa9bad.png +0 -0
- package/dist/icon_384x384.c8923df6b6bd08eba5c79b78d7fcecc0.png +0 -0
- package/dist/icon_512x512.7163efb26df832de513bc58d925ea22e.png +0 -0
- package/dist/icon_96x96.682ee334ae19d49894217370b8596f61.png +0 -0
- package/dist/index.html +0 -9
- package/dist/logo-512.png +0 -0
- package/dist/logo.svg +0 -30
- package/dist/manifest.266df36f2271d27ae9bcaa196a2976ae.json +0 -47
- package/dist/openmrs.39723c21cec4b1fc.css +0 -1
- package/dist/openmrs.39723c21cec4b1fc.css.map +0 -1
- package/dist/openmrs.44bac4c8520ee42f.css +0 -2
- package/dist/openmrs.44bac4c8520ee42f.css.map +0 -1
- package/dist/openmrs.936e8cf6a4b1599d.css +0 -2
- package/dist/openmrs.936e8cf6a4b1599d.css.map +0 -1
- package/dist/openmrs.c3adea28ef850516.js +0 -1
- package/dist/openmrs.c3adea28ef850516.js.map +0 -1
- package/dist/openmrs.e4daba1e3b840e70.css +0 -25
- package/dist/openmrs.e4daba1e3b840e70.css.map +0 -1
- package/dist/service-worker.js +0 -1
- package/dist/service-worker.js.map +0 -1
- /package/dist/{a325099b0a580ce2.js.LICENSE.txt → 184.js.LICENSE.txt} +0 -0
- /package/dist/{600aca7295d8bcb7.js.LICENSE.txt → 478.js.LICENSE.txt} +0 -0
- /package/dist/{3b0ea8395009dcf3.js.LICENSE.txt → 540.js.LICENSE.txt} +0 -0
- /package/dist/{680eb791e6266590.js.LICENSE.txt → 961.js.LICENSE.txt} +0 -0
- /package/src/resources/theme/{mamba-schema.api.ts → etl-schema.api.ts} +0 -0
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
import useSWR from "swr";
|
|
2
|
+
import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
|
|
3
|
+
import { CQIReportingCohort } from "./data-visualizer.component";
|
|
4
|
+
import dayjs from "dayjs";
|
|
5
|
+
import { indicatorIdsWithoutEndPoints } from "./constants";
|
|
6
|
+
|
|
7
|
+
type ReportRequest = {
|
|
8
|
+
uuid: string;
|
|
9
|
+
startDate: string;
|
|
10
|
+
endDate: string;
|
|
11
|
+
type: string;
|
|
12
|
+
reportCategory?: {
|
|
13
|
+
category: ReportCategory;
|
|
14
|
+
renderType?: RenderType;
|
|
15
|
+
};
|
|
16
|
+
reportIndicators?: Array<Indicator>;
|
|
17
|
+
reportType: ReportType;
|
|
18
|
+
reportingCohort?: CQIReportingCohort;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type saveReportRequest = {
|
|
22
|
+
reportName: string;
|
|
23
|
+
reportDescription?: string;
|
|
24
|
+
reportType?: string;
|
|
25
|
+
columns?: string;
|
|
26
|
+
rows: string;
|
|
27
|
+
report_request_object: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type ReportDownloadParams = {
|
|
31
|
+
uuid: string;
|
|
32
|
+
startDate: string;
|
|
33
|
+
endDate: string;
|
|
34
|
+
reportCategory?: ReportCategory;
|
|
35
|
+
reportingCohort?: CQIReportingCohort;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
type ReportLibraryCategoryRef = {
|
|
39
|
+
uuid: string;
|
|
40
|
+
display?: string;
|
|
41
|
+
name?: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type ReportLibraryItem = {
|
|
46
|
+
uuid: string;
|
|
47
|
+
display?: string;
|
|
48
|
+
name: string;
|
|
49
|
+
description?: string;
|
|
50
|
+
code?: string;
|
|
51
|
+
sourceType?: string;
|
|
52
|
+
reportDefinitionUuid?: string;
|
|
53
|
+
reportBuilderReportUuid?: string;
|
|
54
|
+
reportType?: string;
|
|
55
|
+
migrated?: boolean;
|
|
56
|
+
retired?: boolean;
|
|
57
|
+
category?: ReportLibraryCategoryRef;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
type ReportLibraryResponse = {
|
|
61
|
+
data: {
|
|
62
|
+
results: ReportLibraryItem[];
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
type ReportCategoryItem = {
|
|
67
|
+
uuid: string;
|
|
68
|
+
display?: string;
|
|
69
|
+
name: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
retired?: boolean;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
type ReportCategoryResponse = {
|
|
75
|
+
data: {
|
|
76
|
+
results: ReportCategoryItem[];
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export async function getReport(params: ReportRequest, signal?: AbortSignal) {
|
|
81
|
+
if (params.reportType === "fixed") {
|
|
82
|
+
const query = new URLSearchParams({
|
|
83
|
+
startDate: params.startDate,
|
|
84
|
+
endDate: params.endDate,
|
|
85
|
+
uuid: params.uuid,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
if (params.reportCategory?.category === "cqi" && params.reportingCohort) {
|
|
89
|
+
query.set("cohortList", params.reportingCohort);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (params.reportCategory?.renderType) {
|
|
93
|
+
query.set("renderType", params.reportCategory.renderType);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return openmrsFetch(
|
|
97
|
+
`${restBaseUrl}/reportbuilder/reportingDefinition?${query.toString()}`,
|
|
98
|
+
{ signal },
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const columns =
|
|
103
|
+
params.reportIndicators?.length
|
|
104
|
+
? formatReportArray(params.reportIndicators)
|
|
105
|
+
: [];
|
|
106
|
+
|
|
107
|
+
return openmrsFetch(`${restBaseUrl}/reportbuilder/dataExport`, {
|
|
108
|
+
method: "POST",
|
|
109
|
+
signal,
|
|
110
|
+
headers: {
|
|
111
|
+
"Content-Type": "application/json",
|
|
112
|
+
},
|
|
113
|
+
body: {
|
|
114
|
+
cohort: {
|
|
115
|
+
type: params.type,
|
|
116
|
+
uuid: params.uuid,
|
|
117
|
+
name: "",
|
|
118
|
+
description: "",
|
|
119
|
+
parameters: [
|
|
120
|
+
{ startDate: params.startDate },
|
|
121
|
+
{ endDate: params.endDate },
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
columns,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function downloadReport(params: ReportDownloadParams) {
|
|
130
|
+
const abortController = new AbortController();
|
|
131
|
+
let apiUrl = `${restBaseUrl}/reportbuilder/reportDownload?startDate=${params.startDate}&endDate=${params.endDate}&uuid=${params.uuid}`;
|
|
132
|
+
if (params.reportCategory === "cqi") {
|
|
133
|
+
apiUrl += `&cohortList=${params.reportingCohort}`;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return openmrsFetch(apiUrl, {
|
|
137
|
+
signal: abortController.signal,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export async function getCategoryIndicator(id: string, type?: string) {
|
|
142
|
+
let apiUrl: string;
|
|
143
|
+
if (id === "IDN") {
|
|
144
|
+
apiUrl = `${restBaseUrl}/patientidentifiertype`;
|
|
145
|
+
} else if (id === "PAT") {
|
|
146
|
+
apiUrl = `${restBaseUrl}/personattributetype`;
|
|
147
|
+
} else if (id === "CON") {
|
|
148
|
+
apiUrl = `${restBaseUrl}/reportbuilder/concepts/conditions`;
|
|
149
|
+
} else if (indicatorIdsWithoutEndPoints.includes(id)) {
|
|
150
|
+
return null;
|
|
151
|
+
} else {
|
|
152
|
+
if (type === "Orders") {
|
|
153
|
+
apiUrl = `${restBaseUrl}/reportbuilder/order/indications?uuid=${id}`;
|
|
154
|
+
} else {
|
|
155
|
+
apiUrl = `${restBaseUrl}/reportbuilder/concepts/encountertype?uuid=${id}`;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const { data } = await openmrsFetch(apiUrl);
|
|
160
|
+
return data;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function useGetEncounterType() {
|
|
164
|
+
const apiUrl = `${restBaseUrl}/encountertype`;
|
|
165
|
+
const { data, error, isLoading } = useSWR<{ data: { results: any } }, Error>(
|
|
166
|
+
apiUrl,
|
|
167
|
+
openmrsFetch
|
|
168
|
+
);
|
|
169
|
+
return {
|
|
170
|
+
encounterTypes: data ? mapDataElements(data?.data["results"]) : [],
|
|
171
|
+
isError: error,
|
|
172
|
+
isLoadingEncounterTypes: isLoading,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function useGetOrderTypes() {
|
|
177
|
+
const apiUrl = `${restBaseUrl}/ordertype?v=custom:(uuid,display,name)`;
|
|
178
|
+
const { data, error, isLoading } = useSWR<{ data: { results: any } }, Error>(
|
|
179
|
+
apiUrl,
|
|
180
|
+
openmrsFetch
|
|
181
|
+
);
|
|
182
|
+
return {
|
|
183
|
+
orderTypes: data
|
|
184
|
+
? mapDataOrderTypeElements(data?.data["results"], "Orders")
|
|
185
|
+
: [],
|
|
186
|
+
isError: error,
|
|
187
|
+
isLoadingOrderTypes: isLoading,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export async function saveReport(params: saveReportRequest) {
|
|
192
|
+
const apiUrl = `${restBaseUrl}/dashboardReport`;
|
|
193
|
+
const abortController = new AbortController();
|
|
194
|
+
|
|
195
|
+
return openmrsFetch(apiUrl, {
|
|
196
|
+
method: "POST",
|
|
197
|
+
signal: abortController.signal,
|
|
198
|
+
headers: {
|
|
199
|
+
"Content-Type": "application/json",
|
|
200
|
+
},
|
|
201
|
+
body: {
|
|
202
|
+
name: params.reportName,
|
|
203
|
+
description: params?.reportDescription,
|
|
204
|
+
type: params?.reportType,
|
|
205
|
+
columns: params?.columns,
|
|
206
|
+
rows: params?.rows,
|
|
207
|
+
report_request_object: params.report_request_object,
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export async function sendReportToDHIS2(report, dhis2Json) {
|
|
213
|
+
const apiUrl = `${restBaseUrl}/sendreport?uuid=${report}`;
|
|
214
|
+
const abortController = new AbortController();
|
|
215
|
+
|
|
216
|
+
return openmrsFetch(apiUrl, {
|
|
217
|
+
method: "POST",
|
|
218
|
+
signal: abortController.signal,
|
|
219
|
+
headers: {
|
|
220
|
+
"Content-Type": "application/json",
|
|
221
|
+
},
|
|
222
|
+
body: {
|
|
223
|
+
...dhis2Json,
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export async function getCohortCategory(type: string) {
|
|
229
|
+
let apiUrl: string;
|
|
230
|
+
if (type === "patientSearch") {
|
|
231
|
+
apiUrl = `${restBaseUrl}/reportbuilder/patientsearch`;
|
|
232
|
+
} else {
|
|
233
|
+
apiUrl = `${restBaseUrl}/${type}?v=custom:(uuid,name)`;
|
|
234
|
+
}
|
|
235
|
+
const { data } = await openmrsFetch(apiUrl);
|
|
236
|
+
return data;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/* report library */
|
|
240
|
+
|
|
241
|
+
export function useGetReportLibrary() {
|
|
242
|
+
const apiUrl = `${restBaseUrl}/reportbuilder/reportlibrary?v=full`;
|
|
243
|
+
|
|
244
|
+
const { data, error, isLoading, mutate } = useSWR<ReportLibraryResponse, Error>(
|
|
245
|
+
apiUrl,
|
|
246
|
+
openmrsFetch
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
reportLibrary: data?.data?.results ?? [],
|
|
251
|
+
isError: error,
|
|
252
|
+
isLoadingReportLibrary: isLoading,
|
|
253
|
+
mutate,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export function useGetReportCategories() {
|
|
258
|
+
const apiUrl = `${restBaseUrl}/reportbuilder/reportcategory?v=full`;
|
|
259
|
+
|
|
260
|
+
const { data, error, isLoading, mutate } = useSWR<ReportCategoryResponse, Error>(
|
|
261
|
+
apiUrl,
|
|
262
|
+
openmrsFetch
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
return {
|
|
266
|
+
reportCategories: data?.data?.results ?? [],
|
|
267
|
+
isError: error,
|
|
268
|
+
isLoadingReportCategories: isLoading,
|
|
269
|
+
mutate,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export const getReportFromRegistry = (
|
|
274
|
+
reportLibrary: ReportLibraryItem[],
|
|
275
|
+
type: string
|
|
276
|
+
) => {
|
|
277
|
+
return reportLibrary?.filter(
|
|
278
|
+
(report) =>
|
|
279
|
+
report?.category?.name?.toLowerCase() === type?.toLowerCase() ||
|
|
280
|
+
report?.category?.display?.toLowerCase() === type?.toLowerCase()
|
|
281
|
+
);
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
export const createColumns = (columns: Array<string>) => {
|
|
285
|
+
return columns.map((column: string, index) => ({
|
|
286
|
+
id: `${index}`,
|
|
287
|
+
key: column,
|
|
288
|
+
header: column,
|
|
289
|
+
accessor: column,
|
|
290
|
+
}));
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export const mapDataOrderTypeElements = (
|
|
294
|
+
dataArray: Array<Record<string, string>>,
|
|
295
|
+
type?: string,
|
|
296
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
297
|
+
_category?: string
|
|
298
|
+
) => {
|
|
299
|
+
if (!dataArray) return [];
|
|
300
|
+
return dataArray.map((ordertype: Record<string, string>) => ({
|
|
301
|
+
id: ordertype.uuid,
|
|
302
|
+
label: ordertype.name + " Indicators",
|
|
303
|
+
type: type,
|
|
304
|
+
}));
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
export const mapDataElements = (
|
|
308
|
+
dataArray: Array<Record<string, string>>,
|
|
309
|
+
type?: string,
|
|
310
|
+
category?: string
|
|
311
|
+
) => {
|
|
312
|
+
if (!dataArray) return [];
|
|
313
|
+
if (category === "concepts") {
|
|
314
|
+
return dataArray.map((encounterType: Record<string, string>) => ({
|
|
315
|
+
id: encounterType.uuid,
|
|
316
|
+
label: encounterType.conceptName,
|
|
317
|
+
type: encounterType.type,
|
|
318
|
+
modifier: 1,
|
|
319
|
+
showModifierPanel: false,
|
|
320
|
+
extras: [],
|
|
321
|
+
attributes: [],
|
|
322
|
+
}));
|
|
323
|
+
}
|
|
324
|
+
return dataArray.map((encounterType: Record<string, string>) => ({
|
|
325
|
+
id: encounterType.uuid,
|
|
326
|
+
label: encounterType.display,
|
|
327
|
+
type: type ?? "",
|
|
328
|
+
modifier: 1,
|
|
329
|
+
showModifierPanel: false,
|
|
330
|
+
extras: [],
|
|
331
|
+
attributes: [],
|
|
332
|
+
}));
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export const mapOrderDataElements = (
|
|
336
|
+
dataArray: Array<string>,
|
|
337
|
+
type?: string,
|
|
338
|
+
category?: string
|
|
339
|
+
) => {
|
|
340
|
+
if (!dataArray) return [];
|
|
341
|
+
return dataArray.map((indication: string) => ({
|
|
342
|
+
id: category,
|
|
343
|
+
label: indication,
|
|
344
|
+
type: type,
|
|
345
|
+
modifier: 1,
|
|
346
|
+
showModifierPanel: false,
|
|
347
|
+
extras: [],
|
|
348
|
+
attributes: [],
|
|
349
|
+
}));
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
export const formatReportArray = (selectedItems: Array<Indicator>) => {
|
|
353
|
+
if (!selectedItems) return [];
|
|
354
|
+
return selectedItems.map((item: Indicator) => ({
|
|
355
|
+
label: item.label,
|
|
356
|
+
type: item.type,
|
|
357
|
+
expression: item.id,
|
|
358
|
+
modifier: item?.modifier,
|
|
359
|
+
extras: item?.extras,
|
|
360
|
+
}));
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
export const getDateRange = (selectedPeriod: ReportingPeriod) => {
|
|
364
|
+
const currentDate = new Date();
|
|
365
|
+
|
|
366
|
+
switch (selectedPeriod) {
|
|
367
|
+
case "today": {
|
|
368
|
+
return {
|
|
369
|
+
start: currentDate,
|
|
370
|
+
end: currentDate,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
case "week": {
|
|
374
|
+
const startOfWeek = new Date(currentDate);
|
|
375
|
+
startOfWeek.setDate(currentDate.getDate() - currentDate.getDay());
|
|
376
|
+
|
|
377
|
+
const endOfWeek = new Date(currentDate);
|
|
378
|
+
endOfWeek.setDate(currentDate.getDate() + (6 - currentDate.getDay()));
|
|
379
|
+
|
|
380
|
+
return {
|
|
381
|
+
start: startOfWeek,
|
|
382
|
+
end: endOfWeek,
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
case "month": {
|
|
386
|
+
const startOfMonth = new Date(
|
|
387
|
+
currentDate.getFullYear(),
|
|
388
|
+
currentDate.getMonth(),
|
|
389
|
+
1
|
|
390
|
+
);
|
|
391
|
+
const endOfMonth = new Date(
|
|
392
|
+
currentDate.getFullYear(),
|
|
393
|
+
currentDate.getMonth() + 1,
|
|
394
|
+
0
|
|
395
|
+
);
|
|
396
|
+
return {
|
|
397
|
+
start: startOfMonth,
|
|
398
|
+
end: endOfMonth,
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
case "quarter": {
|
|
402
|
+
const quarter = Math.floor(currentDate.getMonth() / 3);
|
|
403
|
+
const startOfQuarter = new Date(
|
|
404
|
+
currentDate.getFullYear(),
|
|
405
|
+
Math.floor(currentDate.getMonth() / 3) * 3,
|
|
406
|
+
1
|
|
407
|
+
);
|
|
408
|
+
const endOfQuarter = new Date(
|
|
409
|
+
currentDate.getFullYear(),
|
|
410
|
+
(quarter + 1) * 3,
|
|
411
|
+
0
|
|
412
|
+
);
|
|
413
|
+
return {
|
|
414
|
+
start: startOfQuarter,
|
|
415
|
+
end: endOfQuarter,
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
case "lastQuarter": {
|
|
419
|
+
const currentQuarter = Math.floor(currentDate.getMonth() / 3) + 1;
|
|
420
|
+
let previousQuarter;
|
|
421
|
+
let previousQuarterYear;
|
|
422
|
+
|
|
423
|
+
if (currentQuarter === 1) {
|
|
424
|
+
previousQuarter = 4;
|
|
425
|
+
previousQuarterYear = currentDate.getFullYear() - 1;
|
|
426
|
+
} else {
|
|
427
|
+
previousQuarter = currentQuarter - 1;
|
|
428
|
+
previousQuarterYear = currentDate.getFullYear();
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
const startOfPreviousQuarter = new Date(
|
|
432
|
+
previousQuarterYear,
|
|
433
|
+
(previousQuarter - 1) * 3,
|
|
434
|
+
1
|
|
435
|
+
);
|
|
436
|
+
|
|
437
|
+
const endOfPreviousQuarter = new Date(
|
|
438
|
+
previousQuarterYear,
|
|
439
|
+
previousQuarter * 3,
|
|
440
|
+
0
|
|
441
|
+
);
|
|
442
|
+
|
|
443
|
+
return {
|
|
444
|
+
start: startOfPreviousQuarter,
|
|
445
|
+
end: endOfPreviousQuarter,
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
default:
|
|
449
|
+
return {
|
|
450
|
+
start: null,
|
|
451
|
+
end: null,
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
export const extractDate = (timestamp: string): string => {
|
|
457
|
+
const dateObject = new Date(timestamp);
|
|
458
|
+
const year = dateObject.getFullYear();
|
|
459
|
+
const month = (dateObject.getMonth() + 1).toString().padStart(2, "0");
|
|
460
|
+
const day = dateObject.getDate().toString().padStart(2, "0");
|
|
461
|
+
|
|
462
|
+
return `${year}-${month}-${day}`;
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
export const formatDate = (date: Date): string => {
|
|
466
|
+
return dayjs(date).format("YYYY-MM-DD");
|
|
467
|
+
};
|