@ampath/esm-reports-app 1.0.0-next.9 → 1.0.0-next.90
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/README.md +2 -0
- package/dist/197.js +1 -1
- package/dist/249.css +1 -0
- package/dist/249.css.map +1 -0
- package/dist/249.js +1 -0
- package/dist/249.js.map +1 -0
- 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/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/757.js +1 -0
- package/dist/757.js.map +1 -0
- package/dist/781.js +1 -0
- package/dist/781.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/local-config.json +5 -0
- package/package.json +5 -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 +319 -99
- package/src/common/report-filters/report-filters.scss +269 -32
- package/src/common/report-filters/types.ts +83 -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 +225 -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 +31 -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 +215 -0
- package/src/dashboard/reports-dasboard.tsx +189 -21
- 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-267/moh-267-register.component.tsx +409 -0
- package/src/registers/moh-267/moh-267-register.scss +298 -0
- package/src/registers/moh-267/moh-267-summary.ts +103 -0
- package/src/registers/moh-267/moh-267.component.tsx +94 -0
- package/src/registers/moh-267/moh-267.types.ts +47 -0
- package/src/registers/moh-362/moh-362-lab-register.component.tsx +551 -0
- package/src/registers/moh-362/moh-362-lab-register.scss +412 -0
- package/src/registers/moh-362/moh-362-linkage-register.component.tsx +215 -0
- package/src/registers/moh-362/moh-362-linkage-register.scss +91 -0
- package/src/registers/moh-362/moh-362.component.tsx +117 -0
- package/src/registers/moh-362/moh-362.scss +11 -0
- package/src/registers/moh-362/moh-362.types.ts +87 -0
- package/src/registers/presumptive-tb/presumptive-tb-register.component.tsx +391 -0
- package/src/registers/presumptive-tb/presumptive-tb-register.scss +262 -0
- package/src/registers/presumptive-tb/presumptive-tb.component.tsx +92 -0
- package/src/registers/presumptive-tb/presumptive-tb.types.ts +88 -0
- package/src/registers/register-catalog.ts +251 -0
- package/src/registers/register-file-name.ts +18 -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/registers/tb4/tb4-parts.tsx +164 -0
- package/src/registers/tb4/tb4-patient-sheet.component.tsx +418 -0
- package/src/registers/tb4/tb4-register.scss +282 -0
- package/src/registers/tb4/tb4-treatment-sheet.component.tsx +349 -0
- package/src/registers/tb4/tb4.component.tsx +120 -0
- package/src/registers/tb4/tb4.types.ts +129 -0
- package/src/reports/acf-summary/acf-summary-form.component.tsx +176 -0
- package/src/reports/acf-summary/acf-summary-linelist.component.tsx +86 -0
- package/src/reports/acf-summary/acf-summary.component.tsx +97 -0
- package/src/reports/acf-summary/acf-summary.counts.ts +37 -0
- package/src/reports/acf-summary/acf-summary.scss +162 -0
- package/src/reports/datatable-wrapper/datatable-wrapper.component.tsx +63 -48
- package/src/reports/moh-240/line-list.columns.test.tsx +156 -0
- package/src/reports/moh-240/line-list.columns.ts +139 -0
- 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.test.tsx +109 -0
- package/src/reports/moh-240/moh-240.component.tsx +85 -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 -90
- package/src/reports/moh-505/moh-505-header.component.tsx +67 -0
- package/src/reports/moh-505/moh-505.component.tsx +436 -229
- package/src/reports/moh-505/moh-505.scss +117 -0
- package/src/reports/moh-643/moh-643.component.tsx +222 -0
- package/src/reports/moh-643/moh-643.rows.ts +77 -0
- package/src/reports/moh-643/moh-643.scss +164 -0
- package/src/reports/moh-643/registers/moh-643-register.component.tsx +112 -0
- package/src/reports/moh-643/registers/moh-643.columns.ts +32 -0
- package/src/reports/moh-645/moh-645.component.tsx +331 -0
- package/src/reports/moh-645/moh-645.scss +147 -0
- package/src/reports/moh-645/registers/moh-645-register.component.tsx +125 -0
- package/src/reports/moh-645/registers/moh-645.columns.ts +40 -0
- package/src/reports/moh-705B/moh-204b-register.component.tsx +318 -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 +404 -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 +42 -33
- package/src/reports/moh-706/sub-reports/blood-chemistry/blood-chemistry.component.tsx +229 -305
- package/src/reports/moh-706/sub-reports/haematology/haematology.component.tsx +26 -19
- package/src/reports/moh-706/sub-reports/histology-and-cytology/histology-and-cytology.component.tsx +23 -23
- package/src/reports/moh-706/sub-reports/parasitology/parasitology.component.tsx +25 -18
- package/src/reports/moh-706/sub-reports/serology/serology.component.tsx +21 -14
- package/src/reports/moh-706/sub-reports/specimen-referral-to-higher-levels/specimen-referral-to-higher-levels.component.tsx +2 -2
- package/src/reports/moh-706/sub-reports/urine-analysis/urine-analysis.component.tsx +27 -20
- package/src/reports/moh-710/moh-710.component.tsx +815 -632
- package/src/reports/moh-710/moh-710.scss +142 -21
- package/src/reports/moh-710/registers/moh-413/moh-413-columns.ts +22 -0
- package/src/reports/moh-710/registers/moh-413/moh-413.component.tsx +140 -0
- package/src/reports/moh-710/registers/moh-413/moh-413.scss +64 -0
- 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 +191 -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 +153 -1269
- package/src/reports/moh-711/moh711.scss +135 -20
- package/src/reports/moh-711/registers/moh-333-register.component.tsx +680 -0
- package/src/reports/moh-711/registers/moh-333.columns.ts +119 -0
- package/src/reports/moh-711/registers/moh-405-register.component.tsx +566 -0
- package/src/reports/moh-711/registers/moh-405.columns.ts +120 -0
- package/src/reports/moh-711/registers/moh-406-register.component.tsx +581 -0
- package/src/reports/moh-711/registers/moh-406.columns.ts +133 -0
- package/src/reports/moh-711/registers/moh-407-register.component.tsx +157 -0
- package/src/reports/moh-711/registers/moh-407.columns.ts +24 -0
- package/src/reports/moh-711/registers/moh-407.scss +64 -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/moh-512-columns.ts +94 -0
- package/src/reports/moh-711/registers/moh-512.component.tsx +191 -0
- package/src/reports/moh-711/registers/moh-512.scss +64 -0
- package/src/reports/moh-711/registers/tb-register-columns.ts +17 -0
- package/src/reports/moh-711/registers/tb-register.component.tsx +96 -0
- package/src/reports/moh-711/registers/tb-register.scss +64 -0
- package/src/reports/moh-711/registers/type.ts +192 -0
- package/src/reports/moh-711/sections/anc.component.tsx +161 -0
- package/src/reports/moh-711/sections/cervical-cancer.component.tsx +107 -0
- package/src/reports/moh-711/sections/chanis.component.tsx +389 -0
- package/src/reports/moh-711/sections/family-planning.component.tsx +299 -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 +94 -0
- package/src/reports/moh-717/moh-717.component.tsx +154 -985
- package/src/reports/moh-717/moh717.scss +227 -21
- package/src/reports/moh-717/registers/moh-209-register.component.tsx +159 -0
- package/src/reports/moh-717/registers/moh-209.columns.ts +30 -0
- 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 +168 -0
- package/src/reports/moh-729b/moh-729b-form.component.tsx +404 -0
- package/src/reports/moh-729b/moh-729b-linelist.component.tsx +278 -0
- package/src/reports/moh-729b/moh-729b-summary.component.tsx +258 -0
- package/src/reports/moh-729b/moh-729b-summary.config.ts +291 -0
- package/src/reports/moh-729b/moh-729b.component.tsx +161 -0
- package/src/reports/moh-729b/moh-729b.config.ts +241 -0
- package/src/reports/moh-729b/moh-729b.scss +276 -0
- package/src/reports/moh-729b/moh-729b.types.ts +177 -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 +269 -0
- package/src/reports/moh-731/moh-731.scss +496 -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 +527 -0
- package/src/reports/moh-731/summary/moh-731-summary.scss +247 -0
- package/src/reports/moh-733/moh-733.component.tsx +29 -0
- package/src/reports/moh-733/moh-733.scss +191 -0
- package/src/reports/moh-733/sections/client-category.component.tsx +246 -0
- package/src/reports/moh-733/sections/nutrition-intervention-pregnant-breastfeeding.component.tsx +233 -0
- package/src/reports/moh-733/sections/nutrition-intervention.component.tsx +216 -0
- package/src/reports/moh-733/sections/nutrition-status-weight.component.tsx +212 -0
- package/src/reports/moh-733/sections/nutrition-status.component.tsx +216 -0
- package/src/reports/moh-740/moh-740.component.scss +202 -0
- package/src/reports/moh-740/moh-740.component.tsx +1339 -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.scss +20 -0
- package/src/reports/moh-740/registers/moh-222-daily-register/moh-222-daily-register.tsx +183 -0
- package/src/reports/moh-740/registers/moh-270-permanent-register/moh-270-permanent-register.scss +6 -0
- package/src/reports/moh-740/registers/moh-270-permanent-register/moh-270-permanent-register.tsx +151 -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 +2058 -0
- package/src/reports/moh-745/moh-745.scss +142 -0
- package/src/reports/moh-745/registers/moh-412-register.component.scss +6 -0
- package/src/reports/moh-745/registers/moh-412-register.component.tsx +275 -0
- package/src/reports/moh-745/registers/moh-412.columns.ts +52 -0
- package/src/reports/moh-745/registers/type.ts +223 -0
- package/src/reports/table-wrapper/table-row-mapper.component.tsx +19 -4
- 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-267.resource.ts +27 -0
- package/src/resources/moh-362.resource.ts +27 -0
- package/src/resources/moh-505.resource.ts +69 -0
- package/src/resources/moh-643.resource.ts +61 -0
- package/src/resources/moh-645.resource.ts +61 -0
- package/src/resources/moh-705.resource.ts +122 -0
- package/src/resources/moh-706.resource.ts +80 -0
- package/src/resources/moh-710.resource.ts +60 -9
- package/src/resources/moh-711.resource.ts +206 -9
- package/src/resources/moh-717.resource.ts +57 -9
- package/src/resources/moh-729b.resource.ts +25 -0
- 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 +66 -0
- package/src/resources/presumptive-tb.resource.ts +27 -0
- package/src/root.component.tsx +90 -9
- 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 +30 -1
- 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/574.js +0 -1
- package/dist/574.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,156 @@
|
|
|
1
|
+
import { lineListShowColumns, moh240LineListColumns, moh240LineListLabColumns } from './line-list.columns';
|
|
2
|
+
import { MOH_240_HEADERS } from './moh-240.columns';
|
|
3
|
+
|
|
4
|
+
/** The DHA requirements' column order, transcribed from the CSV */
|
|
5
|
+
const REQUIRED_HEADERS = [
|
|
6
|
+
'Serial No',
|
|
7
|
+
'Facility Name',
|
|
8
|
+
'Visit Date',
|
|
9
|
+
'Encounter Type',
|
|
10
|
+
'CR Number',
|
|
11
|
+
'Client Name',
|
|
12
|
+
'Sex',
|
|
13
|
+
'Age (years)',
|
|
14
|
+
'Nutrition Assessment Type',
|
|
15
|
+
'Nutrition Value',
|
|
16
|
+
'Nutrition Status',
|
|
17
|
+
'Systolic BP (mmHg)',
|
|
18
|
+
'Diastolic BP (mmHg)',
|
|
19
|
+
'RBS (mmol/L)',
|
|
20
|
+
'RBS Date',
|
|
21
|
+
'TB Screening Date',
|
|
22
|
+
'TB Screening Result',
|
|
23
|
+
'Ebola Screening Status',
|
|
24
|
+
'Cervical Screening Eligible',
|
|
25
|
+
'Cervical Screening Date',
|
|
26
|
+
'Cervical Screening Method',
|
|
27
|
+
'Cervical Screening Result',
|
|
28
|
+
'Diagnosis',
|
|
29
|
+
'Return-to-Clinic Date',
|
|
30
|
+
'Days to RTC',
|
|
31
|
+
'SHA Enrolled',
|
|
32
|
+
'SHA Status',
|
|
33
|
+
'Provider Name',
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
const valueOf = (header: string, row: Record<string, any>) => {
|
|
37
|
+
const column = moh240LineListColumns('Test Facility').find((column) => column.header === header);
|
|
38
|
+
/* the way LinelistTable's cellValue renders it: undefined and null show blank */
|
|
39
|
+
return String((column?.value ? column.value(row) : row[column?.field ?? '']) ?? '');
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
describe('moh240LineListColumns', () => {
|
|
43
|
+
it('carries the requirements' + ' ' + 'columns in their order', () => {
|
|
44
|
+
expect(moh240LineListColumns('Test Facility').map((column) => column.header)).toEqual(REQUIRED_HEADERS);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('names the facility on every row and fills the register' + ' ' + 'fields', () => {
|
|
48
|
+
const row = {
|
|
49
|
+
lab_no: 'LAB-12',
|
|
50
|
+
date: '2026-08-01T09:00:00.000Z',
|
|
51
|
+
encounter_type: 6,
|
|
52
|
+
full_name: 'Jane Akinyi',
|
|
53
|
+
sex: 'F',
|
|
54
|
+
age: 34,
|
|
55
|
+
clinical_diagnosis: 'Type 2 diabetes',
|
|
56
|
+
clinician_name: 'Dr. Otieno',
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
expect(valueOf('Serial No', row)).toBe('LAB-12');
|
|
60
|
+
expect(valueOf('Facility Name', row)).toBe('Test Facility');
|
|
61
|
+
expect(valueOf('Visit Date', row)).toBe('01/08/2026');
|
|
62
|
+
expect(valueOf('Encounter Type', row)).toBe('6');
|
|
63
|
+
expect(valueOf('Client Name', row)).toBe('Jane Akinyi');
|
|
64
|
+
expect(valueOf('Diagnosis', row)).toBe('Type 2 diabetes');
|
|
65
|
+
expect(valueOf('Provider Name', row)).toBe('Dr. Otieno');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('shows the resolved encounter type name, falling back to the raw id', () => {
|
|
69
|
+
expect(valueOf('Encounter Type', { encounter_type: 6, encounter_type_name: 'POC OPD Triage' })).toBe(
|
|
70
|
+
'POC OPD Triage',
|
|
71
|
+
);
|
|
72
|
+
expect(valueOf('Encounter Type', { encounter_type: 6, encounter_type_name: '' })).toBe('6');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('fills RBS from the row' + ' ' + 's own blood-sugar result, and never from a fasting one', () => {
|
|
76
|
+
const random = {
|
|
77
|
+
investigation_required: 'Random Blood Sugar',
|
|
78
|
+
results: '6.5',
|
|
79
|
+
test_datetime: '2026-08-01T09:00:00.000Z',
|
|
80
|
+
};
|
|
81
|
+
const fasting = {
|
|
82
|
+
investigation_required: 'Fasting Blood Sugar',
|
|
83
|
+
results: '4.1',
|
|
84
|
+
test_datetime: '2026-08-01T09:00:00.000Z',
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
expect(valueOf('RBS (mmol/L)', random)).toBe('6.5');
|
|
88
|
+
expect(valueOf('RBS Date', random)).toBe('01/08/2026');
|
|
89
|
+
expect(valueOf('RBS (mmol/L)', fasting)).toBe('');
|
|
90
|
+
expect(valueOf('RBS Date', fasting)).toBe('');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('prefers the patient' + ' ' + 's CDM values over the row' + ' ' + 's own result', () => {
|
|
94
|
+
const row = { rbs: 7.2, rbs_date: '2026-07-30', investigation_required: 'Random Blood Sugar', results: '6.5' };
|
|
95
|
+
|
|
96
|
+
expect(valueOf('RBS (mmol/L)', row)).toBe('7.2');
|
|
97
|
+
expect(valueOf('RBS Date', row)).toBe('30/07/2026');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('counts days to the return-to-clinic date only when it exists', () => {
|
|
101
|
+
expect(valueOf('Days to RTC', { date: '01/10/2026', rtc_date: '05/10/2026' })).toBe('4');
|
|
102
|
+
expect(valueOf('Days to RTC', { date: '01/10/2026', rtc_date: '2026-10-05' })).toBe('4');
|
|
103
|
+
expect(valueOf('Days to RTC', { date: '01/10/2026' })).toBe('');
|
|
104
|
+
expect(valueOf('Days to RTC', { date: '01/10/2026', rtc_date: '25/09/2026' })).toBe('');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('leaves the columns the ETL does not carry yet blank', () => {
|
|
108
|
+
const row = { full_name: 'Jane Akinyi' };
|
|
109
|
+
[
|
|
110
|
+
'CR Number',
|
|
111
|
+
'Nutrition Assessment Type',
|
|
112
|
+
'Systolic BP (mmHg)',
|
|
113
|
+
'TB Screening Date',
|
|
114
|
+
'Ebola Screening Status',
|
|
115
|
+
'Cervical Screening Date',
|
|
116
|
+
'Return-to-Clinic Date',
|
|
117
|
+
'SHA Enrolled',
|
|
118
|
+
'SHA Status',
|
|
119
|
+
].forEach((header) => expect(valueOf(header, row)).toBe(''));
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe('moh240LineListLabColumns', () => {
|
|
124
|
+
it('keeps the register' + ' ' + 's own columns available but hidden', () => {
|
|
125
|
+
const labColumns = moh240LineListLabColumns('total_tb_smear');
|
|
126
|
+
|
|
127
|
+
expect(labColumns.map((column) => column.header)).toEqual(MOH_240_HEADERS.map(({ header }) => header));
|
|
128
|
+
expect(labColumns.every((column) => column.hidden)).toBe(true);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe('lineListShowColumns', () => {
|
|
133
|
+
it('opens TB drill-downs onto the specimen, stain and result', () => {
|
|
134
|
+
expect(lineListShowColumns('total_tb_smear')).toEqual([
|
|
135
|
+
'Type of Specimen',
|
|
136
|
+
'Investigation Required',
|
|
137
|
+
'Results',
|
|
138
|
+
'Date Sample Collected',
|
|
139
|
+
'Date Sample Analysed',
|
|
140
|
+
]);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('opens urinalysis and sugar drill-downs onto the result', () => {
|
|
144
|
+
expect(lineListShowColumns('positive_urine_glucose_with_members')).toEqual([
|
|
145
|
+
'Type of Specimen',
|
|
146
|
+
'Investigation Required',
|
|
147
|
+
'Results',
|
|
148
|
+
]);
|
|
149
|
+
expect(lineListShowColumns('total_blood_sugar')).toContain('Results');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('auto-shows nothing for a clinical indicator', () => {
|
|
153
|
+
expect(lineListShowColumns('total_exam')).toEqual([]);
|
|
154
|
+
expect(lineListShowColumns('')).toEqual([]);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
|
|
3
|
+
import { type LinelistColumn } from '../../common/linelist-table';
|
|
4
|
+
import { MOH_240_HEADERS, formatRegisterDate, moh240Columns } from './moh-240.columns';
|
|
5
|
+
|
|
6
|
+
/** Blank rather than "null" / "undefined" in a cell */
|
|
7
|
+
const text = (value: unknown) => (value === null || value === undefined ? '' : String(value).trim());
|
|
8
|
+
|
|
9
|
+
/** The ISO date behind either an ISO datetime or a DD/MM/YYYY cell, else '' */
|
|
10
|
+
const toIsoDate = (value: unknown): string => {
|
|
11
|
+
const raw = text(value);
|
|
12
|
+
if (/^\d{4}-\d{2}-\d{2}/.test(raw)) {
|
|
13
|
+
return raw.slice(0, 10);
|
|
14
|
+
}
|
|
15
|
+
const parts = raw.match(/^(\d{2})\/(\d{2})\/(\d{4})/);
|
|
16
|
+
return parts ? `${parts[3]}-${parts[2]}-${parts[1]}` : '';
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** A row whose own test is a random blood sugar (not the fasting one) */
|
|
20
|
+
const isRandomBloodSugar = (row: Record<string, any>) =>
|
|
21
|
+
/\brbs\b|random blood sugar/i.test(text(row.investigation_required));
|
|
22
|
+
|
|
23
|
+
/** Whole days from the visit to the return-to-clinic date, when both exist */
|
|
24
|
+
const daysToRtc = (row: Record<string, any>): string => {
|
|
25
|
+
const from = toIsoDate(row.date);
|
|
26
|
+
const to = toIsoDate(row.rtc_date);
|
|
27
|
+
if (!from || !to) {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
const days = dayjs(to).diff(dayjs(from), 'day');
|
|
31
|
+
return days >= 0 ? String(days) : '';
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The drill-down line list behind every clickable figure on the MOH 706 (and
|
|
36
|
+
* MOH 505) report: the DHA "Line List Summary minimum Requirements" columns,
|
|
37
|
+
* in the requirements' own order. Values come from the lab-706 patient-list
|
|
38
|
+
* payload -- the register's own fields plus the columns the template prefills
|
|
39
|
+
* from the clinical flat tables (etl-rest-server v1.10). A column the payload
|
|
40
|
+
* does not carry yet reads blank against its named field, so it fills with no
|
|
41
|
+
* frontend change once the ETL layer grows it.
|
|
42
|
+
*/
|
|
43
|
+
export function moh240LineListColumns(facility: string): LinelistColumn[] {
|
|
44
|
+
return [
|
|
45
|
+
// A. RECORD & VISIT
|
|
46
|
+
{ header: 'Serial No', field: 'lab_no', text: true },
|
|
47
|
+
{ header: 'Facility Name', value: () => facility },
|
|
48
|
+
{ header: 'Visit Date', value: (row) => formatRegisterDate(row.date), sortValue: (row) => toIsoDate(row.date) },
|
|
49
|
+
// the ETL resolves the lab encounter's type to its dictionary name
|
|
50
|
+
// (encounter_type_name); the raw id stays as the fallback until it does
|
|
51
|
+
{ header: 'Encounter Type', value: (row) => row.encounter_type_name || row.encounter_type },
|
|
52
|
+
{ header: 'CR Number', field: 'cr_number', text: true },
|
|
53
|
+
// B. CLIENT
|
|
54
|
+
{ header: 'Client Name', field: 'full_name', wrap: true },
|
|
55
|
+
{ header: 'Sex', field: 'sex' },
|
|
56
|
+
{ header: 'Age (years)', field: 'age' },
|
|
57
|
+
// C. NUTRITION
|
|
58
|
+
{ header: 'Nutrition Assessment Type', field: 'nutrition_assessment_type' },
|
|
59
|
+
{ header: 'Nutrition Value', field: 'nutrition_value' },
|
|
60
|
+
{ header: 'Nutrition Status', field: 'nutrition_status' },
|
|
61
|
+
// D. VITALS & LABS
|
|
62
|
+
{ header: 'Systolic BP (mmHg)', field: 'systolic' },
|
|
63
|
+
{ header: 'Diastolic BP (mmHg)', field: 'diastolic' },
|
|
64
|
+
// the row's own blood-sugar result stands in until the patient's CDM
|
|
65
|
+
// encounter prefills rbs, so an RBS test never shows as blank
|
|
66
|
+
{
|
|
67
|
+
header: 'RBS (mmol/L)',
|
|
68
|
+
value: (row) => row.rbs ?? (isRandomBloodSugar(row) ? row.results : undefined),
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
header: 'RBS Date',
|
|
72
|
+
value: (row) =>
|
|
73
|
+
row.rbs_date
|
|
74
|
+
? formatRegisterDate(row.rbs_date)
|
|
75
|
+
: isRandomBloodSugar(row)
|
|
76
|
+
? formatRegisterDate(row.test_datetime)
|
|
77
|
+
: '',
|
|
78
|
+
sortValue: (row) => toIsoDate(row.rbs_date || (isRandomBloodSugar(row) ? row.test_datetime : '')),
|
|
79
|
+
},
|
|
80
|
+
// E. SCREENING
|
|
81
|
+
{ header: 'TB Screening Date', field: 'tb_screening_date' },
|
|
82
|
+
{ header: 'TB Screening Result', field: 'tb_screening_result' },
|
|
83
|
+
{ header: 'Ebola Screening Status', field: 'ebola_screening_status' },
|
|
84
|
+
{ header: 'Cervical Screening Eligible', field: 'cervical_screening_eligible' },
|
|
85
|
+
{ header: 'Cervical Screening Date', field: 'cervical_screening_date' },
|
|
86
|
+
{ header: 'Cervical Screening Method', field: 'cervical_screening_method' },
|
|
87
|
+
{ header: 'Cervical Screening Result', field: 'cervical_screening_result' },
|
|
88
|
+
{ header: 'Diagnosis', field: 'clinical_diagnosis', wrap: true },
|
|
89
|
+
{ header: 'Return-to-Clinic Date', field: 'rtc_date' },
|
|
90
|
+
{ header: 'Days to RTC', value: daysToRtc },
|
|
91
|
+
// G. FINANCING & PROVIDER
|
|
92
|
+
{ header: 'SHA Enrolled', field: 'sha_enrolled' },
|
|
93
|
+
{ header: 'SHA Status', field: 'sha_status' },
|
|
94
|
+
{ header: 'Provider Name', field: 'clinician_name' },
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The register's own 27 columns, kept available behind the requirements'
|
|
100
|
+
* minimum set: rebuilt from the register's single column spec (so both views
|
|
101
|
+
* stay one source of truth) and started hidden -- a user shows them from the
|
|
102
|
+
* Columns menu when a drill-down needs the lab detail.
|
|
103
|
+
*/
|
|
104
|
+
export function moh240LineListLabColumns(indicators: string): LinelistColumn[] {
|
|
105
|
+
return moh240Columns(indicators).map((column) => ({
|
|
106
|
+
header: column.header,
|
|
107
|
+
// the register's column values take the row's running index for the CSV;
|
|
108
|
+
// the line list renders each row on its own, so 0 is the honest index
|
|
109
|
+
value: (row: Record<string, any>) => column.value(row, 0),
|
|
110
|
+
text: column.text,
|
|
111
|
+
wrap: column.wrap,
|
|
112
|
+
hidden: true,
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The register columns a lab indicator's drill-down starts un-hidden, so e.g.
|
|
118
|
+
* a TB smear figure opens onto its specimen, stain and result. Unknown
|
|
119
|
+
* indicators auto-show nothing; the user can always show more.
|
|
120
|
+
*/
|
|
121
|
+
export function lineListShowColumns(indicators: string): string[] {
|
|
122
|
+
const list = indicators.toLowerCase();
|
|
123
|
+
const show = new Set<string>();
|
|
124
|
+
|
|
125
|
+
if (/tb_|sputum|smear|culture/.test(list)) {
|
|
126
|
+
['Type of Specimen', 'Investigation Required', 'Results', 'Date Sample Collected', 'Date Sample Analysed'].forEach(
|
|
127
|
+
(header) => show.add(header),
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (/urine|urinalysis|glucose|ketone|protein|blood_sugar|ogtt|hba1c|cd4|viral/.test(list)) {
|
|
132
|
+
['Type of Specimen', 'Investigation Required', 'Results'].forEach((header) => show.add(header));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return [...show];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** The register's own column headings, for tests and layout tooling */
|
|
139
|
+
export const MOH_240_LAB_COLUMN_HEADERS = MOH_240_HEADERS.map(({ header }) => header);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import TableWrapper from '../table-wrapper/table-wrapper.component';
|
|
4
|
+
import TableRowMapper from '../table-wrapper/table-row-mapper.component';
|
|
5
|
+
import { getCell } from '../../utils/utils';
|
|
6
|
+
import { useLocationDetails } from '../../common/report-header';
|
|
7
|
+
import styles from './moh-240.scss';
|
|
8
|
+
|
|
9
|
+
interface MOH240HeaderProps {
|
|
10
|
+
facility?: string;
|
|
11
|
+
startDate?: string;
|
|
12
|
+
endDate?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const asDate = (value?: string) => (value ? dayjs(value).format('DD/MM/YYYY') : '');
|
|
16
|
+
|
|
17
|
+
const MOH240Header: React.FC<MOH240HeaderProps> = ({ facility = '', startDate, endDate }) => {
|
|
18
|
+
const { county, subCounty, kmhflCode } = useLocationDetails();
|
|
19
|
+
|
|
20
|
+
const tableRows = useMemo(() => {
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
tableCells: [getCell('', 'County:', 1, 1, true), getCell('', county ?? '', 3)],
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
tableCells: [getCell('', 'Sub-County:', 1, 1, true), getCell('', subCounty ?? '', 3)],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
tableCells: [getCell('', 'Health Facility:', 1, 1, true), getCell('', facility, 3)],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
tableCells: [getCell('', 'KMHFL Code:', 1, 1, true), getCell('', kmhflCode ?? '', 3)],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
tableCells: [
|
|
36
|
+
getCell('', 'Type:', 1, 1, true),
|
|
37
|
+
getCell('', ''),
|
|
38
|
+
getCell('', 'Man. Agency:', 1, 1, true),
|
|
39
|
+
getCell('', ''),
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
tableCells: [
|
|
44
|
+
getCell('', 'Start date:', 1, 1, true),
|
|
45
|
+
getCell('', asDate(startDate)),
|
|
46
|
+
getCell('', 'End date:', 1, 1, true),
|
|
47
|
+
getCell('', asDate(endDate)),
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
}, [county, subCounty, kmhflCode, facility, startDate, endDate]);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div className={styles.headerSection}>
|
|
55
|
+
<TableWrapper className={styles.formTable}>
|
|
56
|
+
<TableRowMapper tableRows={tableRows} />
|
|
57
|
+
</TableWrapper>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default MOH240Header;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { type RegisterColumn } from '../../common/report-register';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
|
|
4
|
+
/** The register's columns, in the order the printed MOH 240 prints them */
|
|
5
|
+
export const MOH_240_HEADERS = [
|
|
6
|
+
{ key: 'date', header: 'Date (DD/MM/YYYY)' },
|
|
7
|
+
{ key: 'opd_ip_ref_no', header: 'OPD / IPD Ref. No.' },
|
|
8
|
+
{ key: 'lab_no', header: 'Lab. No. (new client)' },
|
|
9
|
+
{ key: 'revisit_no', header: 'Revisit No.' },
|
|
10
|
+
{ key: 'full_name', header: 'Full Names (Three names)' },
|
|
11
|
+
{ key: 'age', header: 'Age' },
|
|
12
|
+
{ key: 'sex', header: 'Sex' },
|
|
13
|
+
{ key: 'county_sub_county', header: 'County / Sub County' },
|
|
14
|
+
{ key: 'village_estate_landmark', header: 'Village / Estate / Landmark' },
|
|
15
|
+
{ key: 'telephone_number', header: 'Telephone Number' },
|
|
16
|
+
{ key: 'clinical_diagnosis', header: 'Clinical Diagnosis' },
|
|
17
|
+
{ key: 'prior_treatment', header: 'Prior Treatment' },
|
|
18
|
+
{ key: 'type_of_specimen', header: 'Type of Specimen' },
|
|
19
|
+
{ key: 'condition_of_specimen', header: 'Condition of Specimen' },
|
|
20
|
+
{ key: 'investigation_required', header: 'Investigation Required' },
|
|
21
|
+
{ key: 'test_datetime', header: 'Date Sample Collected' },
|
|
22
|
+
{ key: 'date_sample_received', header: 'Date Sample Received' },
|
|
23
|
+
{ key: 'clinician_name', header: 'Clinician Name' },
|
|
24
|
+
{ key: 'date_sample_analysed', header: 'Date Sample Analysed' },
|
|
25
|
+
{ key: 'results', header: 'Results' },
|
|
26
|
+
{ key: 'date_results_dispatched', header: 'Date Results Dispatched' },
|
|
27
|
+
{ key: 'amount_charged', header: 'Amount Charged' },
|
|
28
|
+
{ key: 'receipt_number', header: 'Receipt Number' },
|
|
29
|
+
{ key: 'referrals', header: 'Referrals (From Other HF / To Other HF / 3rd Tier Reference Laboratories)' },
|
|
30
|
+
{ key: 'comments', header: 'Comments' },
|
|
31
|
+
{ key: 'testing_officer', header: 'Name of Analysing/Testing Officer' },
|
|
32
|
+
{ key: 'signature', header: 'Signature' },
|
|
33
|
+
] as const;
|
|
34
|
+
|
|
35
|
+
/** The column letters the printed register runs across the top */
|
|
36
|
+
export const MOH_240_SUB_HEADERS = MOH_240_HEADERS.map((_, i) =>
|
|
37
|
+
i < 26 ? String.fromCharCode(65 + i) : `A${String.fromCharCode(65 + i - 26)}`,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Columns whose values must stay text in the CSV: identifiers lose leading
|
|
42
|
+
* zeros and phone numbers open as `#NAME?` formulas when Excel parses them
|
|
43
|
+
* as numbers.
|
|
44
|
+
*/
|
|
45
|
+
export const MOH_240_TEXT_KEYS = ['lab_no', 'opd_ip_ref_no', 'telephone_number', 'receipt_number'];
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Prose columns allowed to wrap on screen; everything else stays `nowrap` so
|
|
49
|
+
* one long value cannot stretch the 27-column row past the fold.
|
|
50
|
+
* `results` wraps because full-panel rows (v1.2) compose every analyte,
|
|
51
|
+
* including 'Not done' placeholders, into one long string.
|
|
52
|
+
*/
|
|
53
|
+
export const MOH_240_WRAP_KEYS = [
|
|
54
|
+
'clinical_diagnosis',
|
|
55
|
+
'type_of_specimen',
|
|
56
|
+
'referrals',
|
|
57
|
+
'comments',
|
|
58
|
+
'results',
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The results column carries whichever indicator the drill-down was opened for,
|
|
63
|
+
* so it is read from a field named by that indicator rather than from `results`.
|
|
64
|
+
*/
|
|
65
|
+
export function resultFieldFor(indicator: string): string {
|
|
66
|
+
if (indicator.startsWith('min_') || indicator.startsWith('max_')) {
|
|
67
|
+
return indicator.substring(4);
|
|
68
|
+
}
|
|
69
|
+
if (indicator.startsWith('total_')) {
|
|
70
|
+
return indicator.substring(6);
|
|
71
|
+
}
|
|
72
|
+
if (indicator.startsWith('positive_')) {
|
|
73
|
+
return indicator.substring(9);
|
|
74
|
+
}
|
|
75
|
+
return indicator;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Formats a datetime column the way the printed form reads it. Values the
|
|
80
|
+
* payload already sends as `DD/MM/YYYY` pass through untouched; only raw ISO
|
|
81
|
+
* datetimes (`2026-08-19T10:18:14.000Z`) are reformatted, so screen and CSV
|
|
82
|
+
* agree no matter which shape the endpoint returns.
|
|
83
|
+
*/
|
|
84
|
+
export function formatRegisterDate(value: unknown): string {
|
|
85
|
+
if (value === null || value === undefined || value === '') {
|
|
86
|
+
return '';
|
|
87
|
+
}
|
|
88
|
+
const text = String(value).trim();
|
|
89
|
+
return /^\d{4}-\d{2}-\d{2}/.test(text) ? dayjs(text).format('DD/MM/YYYY') : text;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Exported with the register's own headings, so the CSV matches the form */
|
|
93
|
+
export function moh240Columns(indicator: string): RegisterColumn[] {
|
|
94
|
+
const resultField = resultFieldFor(indicator);
|
|
95
|
+
|
|
96
|
+
return MOH_240_HEADERS.map(({ key, header }) => ({
|
|
97
|
+
header,
|
|
98
|
+
value: (row: Record<string, any>) => {
|
|
99
|
+
if (key === 'results') {
|
|
100
|
+
// The lab-706 register sends the row's translated result directly;
|
|
101
|
+
// the per-indicator field remains the fallback for payloads that
|
|
102
|
+
// only carry the test slots.
|
|
103
|
+
return row.results ?? row[resultField] ?? '';
|
|
104
|
+
}
|
|
105
|
+
if (key === 'test_datetime') {
|
|
106
|
+
return formatRegisterDate(row[key]);
|
|
107
|
+
}
|
|
108
|
+
return row[key] ?? '';
|
|
109
|
+
},
|
|
110
|
+
text: (MOH_240_TEXT_KEYS as readonly string[]).includes(key) || undefined,
|
|
111
|
+
wrap: (MOH_240_WRAP_KEYS as readonly string[]).includes(key) || undefined,
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, waitFor, within } from '@testing-library/react';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
import Moh240Report from './moh-240.component';
|
|
6
|
+
import { getMoh706PatientList } from '../../resources/moh-706.resource';
|
|
7
|
+
import { getMoh505PatientList } from '../../resources/moh-505.resource';
|
|
8
|
+
|
|
9
|
+
jest.mock('../../resources/moh-706.resource', () => ({
|
|
10
|
+
getMoh706PatientList: jest.fn(),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
jest.mock('../../resources/moh-505.resource', () => ({
|
|
14
|
+
getMoh505PatientList: jest.fn(),
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
jest.mock('@openmrs/esm-framework', () => ({
|
|
18
|
+
useSession: () => ({ sessionLocation: { uuid: 'session-loc', display: 'Session Facility' } }),
|
|
19
|
+
openmrsFetch: jest.fn().mockResolvedValue({ ok: false }),
|
|
20
|
+
showSnackbar: jest.fn(),
|
|
21
|
+
formatDate: (value: Date) => (value instanceof Date ? value.toISOString().slice(0, 10) : String(value ?? '')),
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
const aRow = (overrides: Record<string, unknown> = {}) => ({
|
|
25
|
+
lab_no: 'LAB-12',
|
|
26
|
+
date: '2026-08-01T09:00:00.000Z',
|
|
27
|
+
full_name: 'Jane Akinyi',
|
|
28
|
+
sex: 'F',
|
|
29
|
+
age: 34,
|
|
30
|
+
investigation_required: 'Random Blood Sugar',
|
|
31
|
+
results: '6.5',
|
|
32
|
+
clinical_diagnosis: 'Type 2 diabetes',
|
|
33
|
+
clinician_name: 'Dr. Otieno',
|
|
34
|
+
...overrides,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const page = (results: Array<Record<string, unknown>>) => ({ results, total: results.length, isTotalExact: true });
|
|
38
|
+
|
|
39
|
+
const renderAt = (query: string) =>
|
|
40
|
+
render(
|
|
41
|
+
<MemoryRouter initialEntries={[`/moh-240?${query}`]}>
|
|
42
|
+
<Moh240Report />
|
|
43
|
+
</MemoryRouter>,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
describe('Moh240Report', () => {
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
jest.mocked(getMoh706PatientList).mockReset();
|
|
49
|
+
jest.mocked(getMoh505PatientList).mockReset();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('renders the requirements' + ' ' + 'line list behind a clicked 706 figure', async () => {
|
|
53
|
+
jest.mocked(getMoh706PatientList).mockResolvedValue(page([aRow()]));
|
|
54
|
+
|
|
55
|
+
renderAt(
|
|
56
|
+
'report=moh-706&indicators=total_tb_smear&label=5.29+Total+TB+smears&startDate=2026-08-01&endDate=2026-08-31&locationUuids=loc-1',
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
await waitFor(() => expect(screen.getByText('Jane Akinyi')).toBeInTheDocument());
|
|
60
|
+
|
|
61
|
+
expect(getMoh706PatientList).toHaveBeenCalledWith(
|
|
62
|
+
expect.objectContaining({
|
|
63
|
+
locationUuids: 'loc-1',
|
|
64
|
+
startDate: '2026-08-01',
|
|
65
|
+
endDate: '2026-08-31',
|
|
66
|
+
indicators: 'total_tb_smear',
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
69
|
+
expect(getMoh505PatientList).not.toHaveBeenCalled();
|
|
70
|
+
|
|
71
|
+
/* the clicked figure names the list */
|
|
72
|
+
expect(screen.getAllByText('5.29 Total TB smears').length).toBeGreaterThan(0);
|
|
73
|
+
|
|
74
|
+
const table = within(screen.getByRole('table'));
|
|
75
|
+
const headers = table.getAllByRole('columnheader').map((cell) => cell.textContent);
|
|
76
|
+
/* the requirements' minimum set is on screen... */
|
|
77
|
+
expect(headers).toContain('CR Number');
|
|
78
|
+
expect(headers).toContain('Systolic BP (mmHg)');
|
|
79
|
+
expect(headers).toContain('SHA Enrolled');
|
|
80
|
+
/* ...and a TB drill-down opens with the lab detail columns shown */
|
|
81
|
+
expect(headers).toContain('Results');
|
|
82
|
+
expect(headers).toContain('Type of Specimen');
|
|
83
|
+
|
|
84
|
+
/* the RBS column reads the row's own blood-sugar result */
|
|
85
|
+
const firstRow = within(table.getAllByRole('rowgroup')[1]).getAllByRole('row')[0];
|
|
86
|
+
expect(
|
|
87
|
+
within(firstRow)
|
|
88
|
+
.getAllByRole('cell')
|
|
89
|
+
.map((cell) => cell.textContent)
|
|
90
|
+
.join('|'),
|
|
91
|
+
).toContain('6.5');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('reads the MOH 505 endpoint when the drill-down came from the 505 report', async () => {
|
|
95
|
+
jest.mocked(getMoh505PatientList).mockResolvedValue(page([aRow()]));
|
|
96
|
+
|
|
97
|
+
renderAt('report=moh-505&indicators=total_exam&startDate=2026-08-01&endDate=2026-08-31&locationUuids=loc-1');
|
|
98
|
+
|
|
99
|
+
await waitFor(() => expect(getMoh505PatientList).toHaveBeenCalled());
|
|
100
|
+
expect(getMoh706PatientList).not.toHaveBeenCalled();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('fetches nothing without a period and facility', () => {
|
|
104
|
+
renderAt('report=moh-706');
|
|
105
|
+
|
|
106
|
+
expect(getMoh706PatientList).not.toHaveBeenCalled();
|
|
107
|
+
expect(getMoh505PatientList).not.toHaveBeenCalled();
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -1,12 +1,88 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { useSearchParams } from 'react-router-dom';
|
|
3
|
+
import { useSession } from '@openmrs/esm-framework';
|
|
4
4
|
|
|
5
|
+
import { LinelistTable, useAllRows } from '../../common/linelist-table';
|
|
6
|
+
import { RegisterLayout, useLocationName } from '../../common/report-register';
|
|
7
|
+
import { getMoh505PatientList } from '../../resources/moh-505.resource';
|
|
8
|
+
import { getMoh706PatientList } from '../../resources/moh-706.resource';
|
|
9
|
+
import { lineListShowColumns, moh240LineListColumns, moh240LineListLabColumns } from './line-list.columns';
|
|
10
|
+
|
|
11
|
+
/** The reports that drill down into this register */
|
|
12
|
+
const PARENTS: Record<string, { label: string; path: string }> = {
|
|
13
|
+
'moh-505': { label: 'MOH-505 Report', path: '/moh-505' },
|
|
14
|
+
'moh-706': { label: 'MOH-706 Report', path: '/moh-706' },
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The line list behind every clickable figure on the MOH 706 (and MOH 505)
|
|
19
|
+
* report. The same register route and lab-706 patient-list endpoint the
|
|
20
|
+
* printed register shares, rendered as a line list rather than the printed
|
|
21
|
+
* sheet: the DHA minimum requirements' columns, with the register's own lab
|
|
22
|
+
* detail columns kept behind the Columns menu and lab indicators opening
|
|
23
|
+
* with the relevant ones shown.
|
|
24
|
+
*/
|
|
5
25
|
const Moh240Report: React.FC = () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
26
|
+
const [searchParams] = useSearchParams();
|
|
27
|
+
const session = useSession();
|
|
28
|
+
|
|
29
|
+
const locationUuids = searchParams.get('locationUuids') ?? '';
|
|
30
|
+
const startDate = searchParams.get('startDate') ?? '';
|
|
31
|
+
const endDate = searchParams.get('endDate') ?? '';
|
|
32
|
+
const indicators = searchParams.get('indicators') ?? '';
|
|
33
|
+
const report = searchParams.get('report') || 'moh-706';
|
|
34
|
+
const label = searchParams.get('label');
|
|
35
|
+
|
|
36
|
+
const parent = PARENTS[report] ?? PARENTS['moh-706'];
|
|
37
|
+
const locationName = useLocationName(locationUuids || null);
|
|
38
|
+
const facility = locationName || session?.sessionLocation?.display || '';
|
|
39
|
+
|
|
40
|
+
/* Sorting, filtering and the export have to see the whole list, so the
|
|
41
|
+
fetcher reads every page (the moh-731 linelist pattern). */
|
|
42
|
+
const { rows, isLoading } = useAllRows(
|
|
43
|
+
({ startIndex, limit }) => {
|
|
44
|
+
/* The line list only means something behind a generated figure */
|
|
45
|
+
if (!locationUuids || !startDate || !endDate) {
|
|
46
|
+
return Promise.resolve({ results: [], total: 0, isTotalExact: true });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const params = { locationUuids, startDate, endDate, indicators, startIndex, limit };
|
|
50
|
+
|
|
51
|
+
return report === 'moh-505' ? getMoh505PatientList(params) : getMoh706PatientList(params);
|
|
52
|
+
},
|
|
53
|
+
[locationUuids, startDate, endDate, indicators, report],
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const showColumns = lineListShowColumns(indicators);
|
|
57
|
+
const columns = useMemo(
|
|
58
|
+
() =>
|
|
59
|
+
moh240LineListColumns(facility).concat(
|
|
60
|
+
moh240LineListLabColumns(indicators).map((column) =>
|
|
61
|
+
showColumns.includes(column.header) ? { ...column, hidden: false } : column,
|
|
62
|
+
),
|
|
63
|
+
),
|
|
64
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
|
+
[facility, indicators],
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<RegisterLayout
|
|
70
|
+
parentLabel={parent.label}
|
|
71
|
+
parentPath={parent.path}
|
|
72
|
+
title="Laboratory (LAB) Register MOH 240"
|
|
73
|
+
heading={label ?? undefined}
|
|
74
|
+
location={locationName}
|
|
75
|
+
isLoading={isLoading}
|
|
76
|
+
isEmpty={rows.length === 0}
|
|
77
|
+
>
|
|
78
|
+
<LinelistTable
|
|
79
|
+
rows={rows}
|
|
80
|
+
columns={columns}
|
|
81
|
+
layoutKey={`moh-240:${report}:${indicators}${showColumns.length ? `:${showColumns.join(',')}` : ''}`}
|
|
82
|
+
exportName={`laboratory-lab-register-moh-240 ${startDate} ${endDate}`}
|
|
83
|
+
/>
|
|
84
|
+
</RegisterLayout>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
11
87
|
|
|
12
|
-
export default Moh240Report;
|
|
88
|
+
export default Moh240Report;
|