@ampath/esm-reports-app 1.0.0-next.7 → 1.0.0-next.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/197.js +1 -1
- package/dist/282.js +1 -1
- package/dist/282.js.map +1 -1
- package/dist/295.css +1 -0
- package/dist/295.css.map +1 -0
- package/dist/295.js +1 -0
- package/dist/295.js.map +1 -0
- package/dist/299.js +2 -0
- package/dist/299.js.LICENSE.txt +3 -0
- package/dist/299.js.map +1 -0
- package/dist/300.js +1 -1
- package/dist/311.js +1 -1
- package/dist/311.js.map +1 -1
- package/dist/335.js +1 -1
- package/dist/353.js +1 -1
- package/dist/353.js.map +1 -1
- package/dist/354.js +2 -0
- package/dist/354.js.LICENSE.txt +20 -0
- package/dist/354.js.map +1 -0
- package/dist/410.js +1 -0
- package/dist/410.js.map +1 -0
- package/dist/457.js +2 -0
- package/dist/457.js.LICENSE.txt +261 -0
- package/dist/457.js.map +1 -0
- package/dist/478.js +1 -1
- package/dist/478.js.map +1 -1
- package/dist/480.js +1 -0
- package/dist/540.js +1 -1
- package/dist/540.js.map +1 -1
- package/dist/55.js +1 -1
- package/dist/580.js +1 -0
- package/dist/580.js.map +1 -0
- package/dist/600.js +2 -0
- package/dist/600.js.LICENSE.txt +35 -0
- package/dist/600.js.map +1 -0
- package/dist/652.js +1 -1
- package/dist/781.js +1 -0
- package/dist/781.js.map +1 -0
- package/dist/919.css +1 -0
- package/dist/919.css.map +1 -0
- package/dist/919.js +1 -0
- package/dist/919.js.map +1 -0
- package/dist/961.js +1 -1
- package/dist/961.js.map +1 -1
- package/dist/99.js +1 -1
- package/dist/99.js.map +1 -0
- package/dist/ampath-esm-reports-app.js +1 -1
- package/dist/ampath-esm-reports-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +4 -2
- package/src/common/daily-summary-table.tsx +55 -0
- package/src/common/linelist-table/index.ts +3 -0
- package/src/common/linelist-table/linelist-columns.ts +48 -0
- package/src/common/linelist-table/linelist-table.component.tsx +442 -0
- package/src/common/linelist-table/linelist-table.scss +306 -0
- package/src/common/linelist-table/linelist-table.test.tsx +120 -0
- package/src/common/linelist-table/use-all-rows.ts +93 -0
- package/src/common/linelist-table/use-column-layout.ts +123 -0
- package/src/common/report-error/index.ts +1 -0
- package/src/common/report-error/show-report-error.ts +25 -0
- package/src/common/report-filters/date-range.ts +137 -0
- package/src/common/report-filters/index.ts +4 -0
- package/src/common/report-filters/report-filters.component.tsx +317 -99
- package/src/common/report-filters/report-filters.scss +255 -32
- package/src/common/report-filters/types.ts +79 -0
- package/src/common/report-filters/use-restore-period.ts +43 -0
- package/src/common/report-header/index.ts +1 -0
- package/src/common/report-header/use-location-details.ts +58 -0
- package/src/common/report-page/download-sheet-pdf.ts +59 -0
- package/src/common/report-page/index.ts +3 -0
- package/src/common/report-page/report-page.component.tsx +32 -0
- package/src/common/report-page/report-page.scss +45 -0
- package/src/common/report-page/use-page-scale.ts +60 -0
- package/src/common/report-placeholder/has-report-data.ts +15 -0
- package/src/common/report-placeholder/index.ts +3 -0
- package/src/common/report-placeholder/report-placeholder.component.tsx +81 -0
- package/src/common/report-placeholder/report-placeholder.scss +48 -0
- package/src/common/report-placeholder/use-generated-location.ts +62 -0
- package/src/common/report-register/index.ts +6 -0
- package/src/common/report-register/register-columns.ts +46 -0
- package/src/common/report-register/register-layout.component.tsx +265 -0
- package/src/common/report-register/register-layout.scss +150 -0
- package/src/common/report-register/register-table.scss +71 -0
- package/src/common/report-register/report-parents.ts +27 -0
- package/src/common/report-register/rows-to-csv.ts +89 -0
- package/src/common/report-register/use-location-name.ts +54 -0
- package/src/common/report-register/use-patient-list.ts +92 -0
- package/src/common/report-skeleton/index.ts +1 -0
- package/src/common/report-skeleton/report-skeleton.component.tsx +46 -0
- package/src/common/report-skeleton/report-skeleton.scss +29 -0
- package/src/config-schema.ts +9 -1
- package/src/dashboard/report-catalog.ts +173 -0
- package/src/dashboard/reports-dasboard.tsx +189 -18
- package/src/dashboard/reports-dashboard.module.scss +357 -14
- package/src/index.ts +13 -1
- package/src/registers/moh-240/moh-240-register.scss +41 -0
- package/src/registers/moh-240/moh-240.component.test.tsx +166 -0
- package/src/registers/moh-240/moh-240.component.tsx +164 -0
- package/src/registers/moh-362/moh-362-lab-register.component.tsx +392 -0
- package/src/registers/moh-362/moh-362-linkage-register.component.tsx +120 -0
- package/src/registers/moh-362/moh-362-register.scss +222 -0
- package/src/registers/moh-362/moh-362.component.tsx +99 -0
- package/src/registers/moh-362/moh-362.scss +11 -0
- package/src/registers/moh-362/moh-362.types.ts +97 -0
- package/src/registers/register-catalog.ts +96 -0
- package/src/registers/tb-lab-register/tb-lab-register-table.component.tsx +116 -0
- package/src/registers/tb-lab-register/tb-lab-register-table.scss +123 -0
- package/src/registers/tb-lab-register/tb-lab-register.columns.ts +164 -0
- package/src/registers/tb-lab-register/tb-lab-register.component.test.tsx +232 -0
- package/src/registers/tb-lab-register/tb-lab-register.component.tsx +153 -0
- package/src/reports/datatable-wrapper/datatable-wrapper.component.tsx +63 -48
- package/src/reports/moh-240/moh-240-header.component.tsx +62 -0
- package/src/reports/moh-240/moh-240.columns.ts +113 -0
- package/src/reports/moh-240/moh-240.component.tsx +72 -9
- package/src/reports/moh-240/moh-240.scss +40 -0
- package/src/reports/moh-240/sub-reports/moh-240-register.component.tsx +31 -37
- package/src/reports/moh-240/sub-reports/page-summary.component.tsx +143 -106
- package/src/reports/moh-505/moh-505-header.component.tsx +67 -0
- package/src/reports/moh-505/moh-505.component.tsx +441 -0
- package/src/reports/moh-505/moh-505.scss +117 -0
- package/src/reports/moh-705B/moh-204b-register.component.tsx +244 -0
- package/src/reports/moh-705B/moh-204b.columns.ts +39 -0
- package/src/reports/moh-705B/moh-705b.component.tsx +659 -0
- package/src/reports/moh-705B/moh-705b.scss +172 -0
- package/src/reports/moh-705a/moh-705a.component.tsx +661 -0
- package/src/reports/moh-705a/moh-705a.scss +172 -0
- package/src/reports/moh-705a/registers/moh-204a-register.component.tsx +329 -0
- package/src/reports/moh-705a/registers/moh-204a.columns.ts +57 -0
- package/src/reports/moh-705a/type.ts +6 -0
- package/src/reports/moh-706/moh-706-header.component.tsx +66 -0
- package/src/reports/moh-706/moh-706.component.tsx +150 -24
- package/src/reports/moh-706/moh-706.scss +119 -11
- package/src/reports/moh-706/sub-reports/bacteriology/bacteriology.component.tsx +54 -62
- package/src/reports/moh-706/sub-reports/blood-chemistry/blood-chemistry.component.tsx +228 -317
- package/src/reports/moh-706/sub-reports/drug-susceptibility-testing/drug-susceptibility-testing.component.tsx +31 -46
- package/src/reports/moh-706/sub-reports/haematology/haematology.component.tsx +47 -55
- package/src/reports/moh-706/sub-reports/histology-and-cytology/histology-and-cytology.component.tsx +43 -58
- package/src/reports/moh-706/sub-reports/parasitology/parasitology.component.tsx +31 -39
- package/src/reports/moh-706/sub-reports/serology/serology.component.tsx +26 -34
- package/src/reports/moh-706/sub-reports/specimen-referral-to-higher-levels/specimen-referral-to-higher-levels.component.tsx +9 -24
- package/src/reports/moh-706/sub-reports/urine-analysis/urine-analysis.component.tsx +43 -51
- package/src/reports/moh-710/moh-710.component.tsx +799 -632
- package/src/reports/moh-710/moh-710.scss +142 -21
- package/src/reports/moh-710/registers/moh-510/moh-510.columns.ts +40 -0
- package/src/reports/moh-710/registers/moh-510/moh-510.component.tsx +144 -0
- package/src/reports/moh-710/registers/moh-510/moh-510.scss +130 -0
- package/src/reports/moh-710/registers/moh-511-710-register.component.tsx +268 -0
- package/src/reports/moh-710/registers/moh-511-710.columns.ts +52 -0
- package/src/reports/moh-710/registers/type.ts +31 -0
- package/src/reports/moh-711/moh-711.component.tsx +138 -1269
- package/src/reports/moh-711/moh711.scss +135 -20
- package/src/reports/moh-711/registers/moh-333-register.component.tsx +637 -0
- package/src/reports/moh-711/registers/moh-333.columns.ts +119 -0
- package/src/reports/moh-711/registers/moh-405-register.component.tsx +520 -0
- package/src/reports/moh-711/registers/moh-405.columns.ts +120 -0
- package/src/reports/moh-711/registers/moh-406-register.component.tsx +530 -0
- package/src/reports/moh-711/registers/moh-406.columns.ts +133 -0
- package/src/reports/moh-711/registers/moh-510-register.component.tsx +55 -0
- package/src/reports/moh-711/registers/moh-511-register.component.tsx +270 -0
- package/src/reports/moh-711/registers/moh-511.columns.ts +59 -0
- package/src/reports/moh-711/registers/type.ts +192 -0
- package/src/reports/moh-711/sections/anc.component.tsx +159 -0
- package/src/reports/moh-711/sections/cervical-cancer.component.tsx +148 -0
- package/src/reports/moh-711/sections/chanis.component.tsx +366 -0
- package/src/reports/moh-711/sections/family-planning.component.tsx +221 -0
- package/src/reports/moh-711/sections/gbv.component.tsx +115 -0
- package/src/reports/moh-711/sections/maternity.component.tsx +321 -0
- package/src/reports/moh-711/sections/medical-social-work.component.tsx +73 -0
- package/src/reports/moh-711/sections/other.component.tsx +47 -0
- package/src/reports/moh-711/sections/physiotherapy.component.tsx +61 -0
- package/src/reports/moh-711/sections/pnc.component.tsx +127 -0
- package/src/reports/moh-711/sections/post-abortion.component.tsx +42 -0
- package/src/reports/moh-711/sections/rehabilitation.component.tsx +57 -0
- package/src/reports/moh-711/sections/report-compiled-by.component.tsx +50 -0
- package/src/reports/moh-711/sections/tb-screening.component.tsx +57 -0
- package/src/reports/moh-717/moh-717.component.tsx +149 -985
- package/src/reports/moh-717/moh717.scss +217 -21
- package/src/reports/moh-717/registers/nutrition-register.component.tsx +48 -0
- package/src/reports/moh-717/sections/finance.component.tsx +42 -0
- package/src/reports/moh-717/sections/inpatient.component.tsx +374 -0
- package/src/reports/moh-717/sections/maternity.component.tsx +126 -0
- package/src/reports/moh-717/sections/medical-records.component.tsx +35 -0
- package/src/reports/moh-717/sections/mortuary.component.tsx +43 -0
- package/src/reports/moh-717/sections/operations.component.tsx +53 -0
- package/src/reports/moh-717/sections/orthopaedic-trauma.component.tsx +98 -0
- package/src/reports/moh-717/sections/outpatient.component.tsx +597 -0
- package/src/reports/moh-717/sections/pharmacy.component.tsx +43 -0
- package/src/reports/moh-717/sections/preparedby.component.tsx +52 -0
- package/src/reports/moh-717/sections/special-services.component.tsx +114 -0
- package/src/reports/moh-731/linelist/moh-731-indicators.ts +1122 -0
- package/src/reports/moh-731/linelist/moh-731-linelist-sections.ts +472 -0
- package/src/reports/moh-731/linelist/moh-731-linelist.component.tsx +102 -0
- package/src/reports/moh-731/linelist/use-open-moh-731-linelist.ts +50 -0
- package/src/reports/moh-731/moh-731.component.tsx +266 -0
- package/src/reports/moh-731/moh-731.scss +499 -0
- package/src/reports/moh-731/registers/moh-366.columns.ts +38 -0
- package/src/reports/moh-731/registers/moh-366.component.tsx +471 -0
- package/src/reports/moh-731/registers/prep-register.component.tsx +284 -0
- package/src/reports/moh-731/registers/prep.columns.ts +34 -0
- package/src/reports/moh-731/sections/hiv-and-tb-treatment.component.tsx +1206 -0
- package/src/reports/moh-731/sections/hiv-testing-and-pre-exposure.component.tsx +727 -0
- package/src/reports/moh-731/sections/pmtct.component.tsx +572 -0
- package/src/reports/moh-731/summary/moh-731-summary.component.tsx +313 -0
- package/src/reports/moh-731/summary/moh-731-summary.config.ts +529 -0
- package/src/reports/moh-731/summary/moh-731-summary.scss +242 -0
- package/src/reports/moh-740/moh-740.component.scss +202 -0
- package/src/reports/moh-740/moh-740.component.tsx +1332 -0
- package/src/reports/moh-740/moh-740.resource.ts +54 -0
- package/src/reports/moh-740/registers/moh-222-daily-register/moh-222-daily-register.tsx +149 -0
- package/src/reports/moh-740/registers/moh-270-permanent-register/moh-270-permanent-register.tsx +123 -0
- package/src/reports/moh-740/registers/moh-740-patient-list.scss +0 -0
- package/src/reports/moh-740/registers/moh-740-patient-list.tsx +60 -0
- package/src/reports/moh-740/registers/moh-740.columns.ts +54 -0
- package/src/reports/moh-740/shared/data-cell/data-cell.scss +6 -0
- package/src/reports/moh-740/shared/data-cell/data-cell.tsx +23 -0
- package/src/reports/moh-740/shared/utils/indicator-register-map.ts +159 -0
- package/src/reports/moh-740/types/index.ts +223 -0
- package/src/reports/moh-745/moh-745.component.tsx +1021 -0
- package/src/reports/moh-745/moh-745.scss +132 -0
- package/src/reports/moh-745/registers/moh-412-register.component.tsx +249 -0
- package/src/reports/moh-745/registers/moh-412.columns.ts +52 -0
- package/src/reports/moh-745/registers/type.ts +181 -0
- package/src/reports/table-wrapper/table-row-mapper.component.tsx +57 -0
- package/src/reports/table-wrapper/table-wrapper.component.tsx +23 -14
- package/src/reports/table-wrapper/table-wrapper.scss +1 -16
- package/src/resources/moh-362.resource.ts +27 -0
- package/src/resources/moh-505.resource.ts +69 -0
- package/src/resources/moh-705.resource.ts +106 -0
- package/src/resources/moh-706.resource.ts +80 -0
- package/src/resources/moh-710.resource.ts +32 -9
- package/src/resources/moh-711.resource.ts +137 -9
- package/src/resources/moh-717.resource.ts +26 -9
- package/src/resources/moh-731.resource.ts +90 -0
- package/src/resources/moh-745.resource.ts +76 -0
- package/src/resources/patient-list-page.ts +65 -0
- package/src/root.component.tsx +59 -8
- package/src/root.scss +36 -0
- package/src/routes.json +3 -1
- package/src/utils/format-indicator.ts +39 -0
- package/src/utils/get-base-url.ts +39 -7
- package/src/utils/utils.ts +36 -0
- package/tsconfig.json +1 -1
- package/webpack.config.js +22 -1
- package/dist/138.js +0 -2
- package/dist/138.js.LICENSE.txt +0 -20
- package/dist/138.js.map +0 -1
- package/dist/184.js +0 -2
- package/dist/184.js.LICENSE.txt +0 -14
- package/dist/184.js.map +0 -1
- package/dist/205.js +0 -1
- package/dist/205.js.map +0 -1
- package/dist/711.js +0 -1
- package/dist/711.js.map +0 -1
- package/dist/812.js +0 -1
- package/dist/812.js.map +0 -1
- package/dist/ampath-esm-reports-app.js.buildmanifest.json +0 -539
- package/dist/main.js +0 -1
- package/dist/main.js.map +0 -1
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { Button, Tab, TabList, TabPanel, TabPanels, Tabs, Toggle } from '@carbon/react';
|
|
4
|
+
import { Download } from '@carbon/react/icons';
|
|
5
|
+
|
|
6
|
+
import { columnsToCsv, downloadCsv } from '../../../common/report-register';
|
|
7
|
+
import { MOH_731_INDICATORS } from '../linelist/moh-731-indicators';
|
|
8
|
+
import { type Moh731LinelistTotal } from '../linelist/use-open-moh-731-linelist';
|
|
9
|
+
import {
|
|
10
|
+
MOH_731_SUMMARY,
|
|
11
|
+
rowTotalCodes,
|
|
12
|
+
type SummaryRow,
|
|
13
|
+
type SummarySection,
|
|
14
|
+
type SummaryTable,
|
|
15
|
+
} from './moh-731-summary.config';
|
|
16
|
+
import styles from './moh-731-summary.scss';
|
|
17
|
+
|
|
18
|
+
interface Moh731SummaryProps {
|
|
19
|
+
/** The report as generated: indicator key -> value */
|
|
20
|
+
data: Record<string, unknown>;
|
|
21
|
+
openLinelist: (figure: string | Moh731LinelistTotal) => void;
|
|
22
|
+
/** The section tab shown, by id */
|
|
23
|
+
sectionId: string;
|
|
24
|
+
onSectionChange: (sectionId: string) => void;
|
|
25
|
+
/** Used to name the export */
|
|
26
|
+
period: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const SHOW_CODES_KEY = 'ampath-moh731-summary-show-codes';
|
|
30
|
+
|
|
31
|
+
/** A figure's value, 0 where the report has none */
|
|
32
|
+
const valueOf = (data: Record<string, unknown>, code: string) => {
|
|
33
|
+
const indicator = MOH_731_INDICATORS[code]?.indicator;
|
|
34
|
+
return Number((indicator && data[indicator]) || 0);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const sum = (data: Record<string, unknown>, codes: string[]) =>
|
|
38
|
+
codes.reduce((total, code) => total + valueOf(data, code), 0);
|
|
39
|
+
|
|
40
|
+
/** The codes a table's Total row adds up: every row that counts towards the total */
|
|
41
|
+
const tableCodes = (table: SummaryTable) =>
|
|
42
|
+
table.rows.filter((row) => !row.ofWhich && !row.excluded).flatMap(rowTotalCodes);
|
|
43
|
+
|
|
44
|
+
const rowLabel = (row: SummaryRow) => (row.ofWhich ? `of which ${row.label}` : row.label);
|
|
45
|
+
|
|
46
|
+
const readShowCodes = () => {
|
|
47
|
+
try {
|
|
48
|
+
return localStorage.getItem(SHOW_CODES_KEY) === 'true';
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The MOH 731 report regrouped for reading: a tab per section, each sub-section
|
|
56
|
+
* as a compact table with a Total column and a Total row. Every number opens its
|
|
57
|
+
* linelist, and a total opens the linelists of the figures it adds up.
|
|
58
|
+
*/
|
|
59
|
+
const Moh731Summary: React.FC<Moh731SummaryProps> = ({ data, openLinelist, sectionId, onSectionChange, period }) => {
|
|
60
|
+
const [showCodes, setShowCodes] = useState(readShowCodes);
|
|
61
|
+
const selectedIndex = Math.max(
|
|
62
|
+
0,
|
|
63
|
+
MOH_731_SUMMARY.findIndex((section) => section.id === sectionId),
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const toggleCodes = (checked: boolean) => {
|
|
67
|
+
setShowCodes(checked);
|
|
68
|
+
try {
|
|
69
|
+
localStorage.setItem(SHOW_CODES_KEY, String(checked));
|
|
70
|
+
} catch {
|
|
71
|
+
/* not remembered, still applied */
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/* One figure opens its own linelist; several open as a total */
|
|
76
|
+
const open = (codes: string[], label: string, block: string) => {
|
|
77
|
+
if (codes.length === 1) {
|
|
78
|
+
openLinelist(codes[0]);
|
|
79
|
+
} else if (codes.length > 1) {
|
|
80
|
+
openLinelist({ codes, label, block });
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/** A figure or total: its value, opening its linelist; the MOH code on hover (or shown) */
|
|
85
|
+
const value = (codes: string[], label: string, block: string, options: { strong?: boolean; code?: boolean } = {}) => {
|
|
86
|
+
if (codes.length === 0) {
|
|
87
|
+
return <span className={styles.none}>–</span>;
|
|
88
|
+
}
|
|
89
|
+
const amount = sum(data, codes);
|
|
90
|
+
const code = codes.length === 1 ? codes[0] : undefined;
|
|
91
|
+
return (
|
|
92
|
+
<button
|
|
93
|
+
type="button"
|
|
94
|
+
className={classNames(styles.value, { [styles.zero]: amount === 0, [styles.strong]: options.strong })}
|
|
95
|
+
onClick={() => open(codes, label, block)}
|
|
96
|
+
title={code ? `${code} · open the linelist` : `Open the ${label} linelist`}
|
|
97
|
+
>
|
|
98
|
+
{amount.toLocaleString()}
|
|
99
|
+
{showCodes && code && options.code !== false && <span className={styles.code}>{code}</span>}
|
|
100
|
+
</button>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const exportCsv = () => {
|
|
105
|
+
const lines: Array<Record<string, unknown>> = [];
|
|
106
|
+
MOH_731_SUMMARY.forEach((section) =>
|
|
107
|
+
section.subsections.forEach((sub) =>
|
|
108
|
+
sub.tables.forEach((table) => {
|
|
109
|
+
table.rows.forEach((row) => {
|
|
110
|
+
(row.cells ?? []).forEach((cell, index) => {
|
|
111
|
+
if (cell) {
|
|
112
|
+
lines.push({
|
|
113
|
+
section: section.title,
|
|
114
|
+
block: sub.block,
|
|
115
|
+
row: rowLabel(row),
|
|
116
|
+
column: table.columns[index],
|
|
117
|
+
code: cell,
|
|
118
|
+
value: valueOf(data, cell),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
lines.push({
|
|
123
|
+
section: section.title,
|
|
124
|
+
block: sub.block,
|
|
125
|
+
row: rowLabel(row),
|
|
126
|
+
column: 'Total',
|
|
127
|
+
code: row.only ?? '',
|
|
128
|
+
value: sum(data, rowTotalCodes(row)),
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
if (table.totalLabel) {
|
|
132
|
+
lines.push({
|
|
133
|
+
section: section.title,
|
|
134
|
+
block: sub.block,
|
|
135
|
+
row: table.totalLabel,
|
|
136
|
+
column: 'Total',
|
|
137
|
+
code: '',
|
|
138
|
+
value: sum(data, tableCodes(table)),
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}),
|
|
142
|
+
),
|
|
143
|
+
);
|
|
144
|
+
downloadCsv(
|
|
145
|
+
columnsToCsv(lines, [
|
|
146
|
+
{ header: 'Section', value: (line) => line.section },
|
|
147
|
+
{ header: 'Sub-section', value: (line) => line.block },
|
|
148
|
+
{ header: 'Row', value: (line) => line.row },
|
|
149
|
+
{ header: 'Column', value: (line) => line.column },
|
|
150
|
+
{ header: 'MOH 731 Code', value: (line) => line.code, text: true },
|
|
151
|
+
{ header: 'Value', value: (line) => line.value },
|
|
152
|
+
]),
|
|
153
|
+
`moh-731-summary-${period}.csv`.replace(/[^a-z0-9.-]+/gi, '-').toLowerCase(),
|
|
154
|
+
);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const renderTable = (table: SummaryTable, block: string, key: number) => {
|
|
158
|
+
const included = table.rows.filter((row) => !row.ofWhich && !row.excluded);
|
|
159
|
+
const hasTotalColumn = table.rowTotals !== false;
|
|
160
|
+
return (
|
|
161
|
+
<div key={key} className={styles.tableScroll}>
|
|
162
|
+
{table.title && <p className={styles.tableTitle}>{table.title}</p>}
|
|
163
|
+
<table className={classNames(styles.table, { [styles.single]: table.columns.length === 0 })}>
|
|
164
|
+
<thead>
|
|
165
|
+
<tr>
|
|
166
|
+
<th scope="col" className={styles.labelCol} />
|
|
167
|
+
{table.columns.map((column) => (
|
|
168
|
+
<th scope="col" key={column}>
|
|
169
|
+
{column}
|
|
170
|
+
</th>
|
|
171
|
+
))}
|
|
172
|
+
{/* a table without a breakdown has one column of figures, not totals */}
|
|
173
|
+
{hasTotalColumn && (
|
|
174
|
+
<th scope="col" className={styles.totalCol}>
|
|
175
|
+
{table.columns.length ? 'Total' : 'Number'}
|
|
176
|
+
</th>
|
|
177
|
+
)}
|
|
178
|
+
</tr>
|
|
179
|
+
</thead>
|
|
180
|
+
<tbody>
|
|
181
|
+
{table.rows.map((row) => (
|
|
182
|
+
<tr
|
|
183
|
+
key={row.label}
|
|
184
|
+
className={classNames({ [styles.ofWhich]: row.ofWhich, [styles.excluded]: row.excluded })}
|
|
185
|
+
>
|
|
186
|
+
<th scope="row" className={styles.labelCol}>
|
|
187
|
+
{row.group && <span className={styles.group}>{row.group} · </span>}
|
|
188
|
+
{rowLabel(row)}
|
|
189
|
+
</th>
|
|
190
|
+
{table.columns.map((column, index) => (
|
|
191
|
+
<td key={column}>
|
|
192
|
+
{row.only
|
|
193
|
+
? null
|
|
194
|
+
: value(row.cells?.[index] ? [row.cells[index] as string] : [], `${row.label} ${column}`, block)}
|
|
195
|
+
</td>
|
|
196
|
+
))}
|
|
197
|
+
{/* the code is beside the row's own figures already; only a figure
|
|
198
|
+
shown in the Total column alone carries it here */}
|
|
199
|
+
{hasTotalColumn && (
|
|
200
|
+
<td className={styles.totalCol}>
|
|
201
|
+
{value(rowTotalCodes(row), `${row.label} total`, block, { code: Boolean(row.only) })}
|
|
202
|
+
</td>
|
|
203
|
+
)}
|
|
204
|
+
</tr>
|
|
205
|
+
))}
|
|
206
|
+
</tbody>
|
|
207
|
+
{table.totalLabel && (
|
|
208
|
+
<tfoot>
|
|
209
|
+
<tr>
|
|
210
|
+
<th scope="row" className={styles.labelCol}>
|
|
211
|
+
{table.totalLabel}
|
|
212
|
+
</th>
|
|
213
|
+
{table.columns.map((column, index) => (
|
|
214
|
+
<td key={column}>
|
|
215
|
+
{value(
|
|
216
|
+
included.map((row) => row.cells?.[index]).filter((cell): cell is string => Boolean(cell)),
|
|
217
|
+
`${table.totalLabel} – ${column}`,
|
|
218
|
+
block,
|
|
219
|
+
{ strong: true, code: false },
|
|
220
|
+
)}
|
|
221
|
+
</td>
|
|
222
|
+
))}
|
|
223
|
+
{hasTotalColumn && (
|
|
224
|
+
<td className={styles.totalCol}>
|
|
225
|
+
{value(tableCodes(table), table.totalLabel, block, { strong: true, code: false })}
|
|
226
|
+
</td>
|
|
227
|
+
)}
|
|
228
|
+
</tr>
|
|
229
|
+
</tfoot>
|
|
230
|
+
)}
|
|
231
|
+
</table>
|
|
232
|
+
</div>
|
|
233
|
+
);
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const renderSection = (section: SummarySection) => (
|
|
237
|
+
<>
|
|
238
|
+
{section.headlines.length > 0 && (
|
|
239
|
+
<div className={styles.strip}>
|
|
240
|
+
{section.headlines.map((headline) => {
|
|
241
|
+
const table = section.subsections
|
|
242
|
+
.find((sub) => sub.block === headline.block)
|
|
243
|
+
?.tables.find((t) => t.totalLabel);
|
|
244
|
+
const codes = table ? tableCodes(table) : [];
|
|
245
|
+
return (
|
|
246
|
+
<button
|
|
247
|
+
type="button"
|
|
248
|
+
key={headline.block}
|
|
249
|
+
className={styles.headline}
|
|
250
|
+
onClick={() => open(codes, table?.totalLabel ?? headline.label, headline.block)}
|
|
251
|
+
>
|
|
252
|
+
<span className={styles.headlineLabel}>{headline.label}</span>
|
|
253
|
+
<span className={styles.headlineValue}>{sum(data, codes).toLocaleString()}</span>
|
|
254
|
+
</button>
|
|
255
|
+
);
|
|
256
|
+
})}
|
|
257
|
+
</div>
|
|
258
|
+
)}
|
|
259
|
+
<div className={styles.grid}>
|
|
260
|
+
{section.subsections.map((sub) => (
|
|
261
|
+
<div key={sub.block} className={styles.card}>
|
|
262
|
+
<h5 className={styles.cardTitle}>{sub.block}</h5>
|
|
263
|
+
{sub.note && <p className={styles.note}>{sub.note}</p>}
|
|
264
|
+
{sub.tables.map((table, index) => renderTable(table, sub.block, index))}
|
|
265
|
+
</div>
|
|
266
|
+
))}
|
|
267
|
+
</div>
|
|
268
|
+
</>
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
return (
|
|
272
|
+
<div className={styles.summary}>
|
|
273
|
+
<Tabs
|
|
274
|
+
selectedIndex={selectedIndex}
|
|
275
|
+
onChange={({ selectedIndex: index }) => onSectionChange(MOH_731_SUMMARY[index].id)}
|
|
276
|
+
>
|
|
277
|
+
<div className={styles.bar}>
|
|
278
|
+
<TabList aria-label="MOH 731 sections" className={styles.sectionTabs}>
|
|
279
|
+
{MOH_731_SUMMARY.map((section) => (
|
|
280
|
+
<Tab key={section.id} title={section.title}>
|
|
281
|
+
{section.tab}
|
|
282
|
+
</Tab>
|
|
283
|
+
))}
|
|
284
|
+
</TabList>
|
|
285
|
+
<div className={styles.tools}>
|
|
286
|
+
<Toggle
|
|
287
|
+
id="moh731-summary-codes"
|
|
288
|
+
size="sm"
|
|
289
|
+
labelText="Show MOH codes"
|
|
290
|
+
hideLabel
|
|
291
|
+
labelA="MOH codes"
|
|
292
|
+
labelB="MOH codes"
|
|
293
|
+
toggled={showCodes}
|
|
294
|
+
onToggle={toggleCodes}
|
|
295
|
+
/>
|
|
296
|
+
<Button kind="ghost" size="sm" renderIcon={Download} onClick={exportCsv}>
|
|
297
|
+
Export CSV
|
|
298
|
+
</Button>
|
|
299
|
+
</div>
|
|
300
|
+
</div>
|
|
301
|
+
<TabPanels>
|
|
302
|
+
{MOH_731_SUMMARY.map((section) => (
|
|
303
|
+
<TabPanel key={section.id} className={styles.panel}>
|
|
304
|
+
{renderSection(section)}
|
|
305
|
+
</TabPanel>
|
|
306
|
+
))}
|
|
307
|
+
</TabPanels>
|
|
308
|
+
</Tabs>
|
|
309
|
+
</div>
|
|
310
|
+
);
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
export default Moh731Summary;
|