@ampath/esm-reports-app 1.0.0-next.40 → 1.0.0-next.42

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.
Files changed (147) hide show
  1. package/dist/110.js +2 -1
  2. package/dist/110.js.LICENSE.txt +35 -0
  3. package/dist/110.js.map +1 -1
  4. package/dist/205.js +1 -1
  5. package/dist/441.js +1 -0
  6. package/dist/441.js.map +1 -0
  7. package/dist/738.js +1 -0
  8. package/dist/738.js.map +1 -0
  9. package/dist/812.js +1 -1
  10. package/dist/812.js.map +1 -1
  11. package/dist/ampath-esm-reports-app.js +1 -1
  12. package/dist/ampath-esm-reports-app.js.buildmanifest.json +66 -39
  13. package/dist/main.js +1 -1
  14. package/dist/main.js.map +1 -1
  15. package/dist/routes.json +1 -1
  16. package/package.json +1 -1
  17. package/src/common/report-error/index.ts +1 -0
  18. package/src/common/report-error/show-report-error.ts +25 -0
  19. package/src/common/report-filters/date-range.ts +137 -0
  20. package/src/common/report-filters/index.ts +4 -0
  21. package/src/common/report-filters/report-filters.component.tsx +291 -104
  22. package/src/common/report-filters/report-filters.scss +199 -32
  23. package/src/common/report-filters/types.ts +66 -0
  24. package/src/common/report-filters/use-restore-period.ts +43 -0
  25. package/src/common/report-page/index.ts +2 -0
  26. package/src/common/report-page/report-page.component.tsx +32 -0
  27. package/src/common/report-page/report-page.scss +45 -0
  28. package/src/common/report-page/use-page-scale.ts +50 -0
  29. package/src/common/report-placeholder/has-report-data.ts +15 -0
  30. package/src/common/report-placeholder/index.ts +2 -0
  31. package/src/common/report-placeholder/report-placeholder.component.tsx +56 -0
  32. package/src/common/report-placeholder/report-placeholder.scss +46 -0
  33. package/src/common/report-register/index.ts +5 -0
  34. package/src/common/report-register/register-columns.ts +34 -0
  35. package/src/common/report-register/register-layout.component.tsx +237 -0
  36. package/src/common/report-register/register-layout.scss +140 -0
  37. package/src/common/report-register/register-table.scss +62 -0
  38. package/src/common/report-register/report-parents.ts +27 -0
  39. package/src/common/report-register/rows-to-csv.ts +59 -0
  40. package/src/common/report-register/use-patient-list.ts +92 -0
  41. package/src/common/report-skeleton/index.ts +1 -0
  42. package/src/common/report-skeleton/report-skeleton.component.tsx +46 -0
  43. package/src/common/report-skeleton/report-skeleton.scss +29 -0
  44. package/src/config-schema.ts +9 -1
  45. package/src/dashboard/report-catalog.ts +173 -0
  46. package/src/dashboard/reports-dasboard.tsx +101 -35
  47. package/src/dashboard/reports-dashboard.module.scss +269 -11
  48. package/src/index.ts +13 -1
  49. package/src/reports/datatable-wrapper/datatable-wrapper.component.tsx +50 -48
  50. package/src/reports/moh-240/moh-240-header.component.tsx +54 -56
  51. package/src/reports/moh-240/moh-240.columns.ts +64 -0
  52. package/src/reports/moh-240/moh-240.component.tsx +65 -84
  53. package/src/reports/moh-240/moh-240.scss +36 -7
  54. package/src/reports/moh-240/sub-reports/moh-240-register.component.tsx +27 -65
  55. package/src/reports/moh-240/sub-reports/page-summary.component.tsx +2 -2
  56. package/src/reports/moh-505/moh-505-header.component.tsx +59 -57
  57. package/src/reports/moh-505/moh-505.component.tsx +51 -56
  58. package/src/reports/moh-505/moh-505.scss +116 -2
  59. package/src/reports/moh-705B/moh-204b-register.component.tsx +41 -42
  60. package/src/reports/moh-705B/moh-204b.columns.ts +39 -0
  61. package/src/reports/moh-705B/moh-705b.component.tsx +492 -473
  62. package/src/reports/moh-705B/moh-705b.scss +110 -24
  63. package/src/reports/moh-705a/moh-705a.component.tsx +496 -476
  64. package/src/reports/moh-705a/moh-705a.scss +109 -24
  65. package/src/reports/moh-705a/registers/moh-204a-register.component.tsx +41 -42
  66. package/src/reports/moh-705a/registers/moh-204a.columns.ts +57 -0
  67. package/src/reports/moh-706/moh-706-header.component.tsx +58 -56
  68. package/src/reports/moh-706/moh-706.component.tsx +84 -55
  69. package/src/reports/moh-706/moh-706.scss +115 -19
  70. package/src/reports/moh-710/moh-710.component.tsx +743 -727
  71. package/src/reports/moh-710/moh-710.scss +140 -23
  72. package/src/reports/moh-710/registers/moh-511-710-register.component.tsx +48 -43
  73. package/src/reports/moh-710/registers/moh-511-710.columns.ts +52 -0
  74. package/src/reports/moh-711/moh-711.component.tsx +94 -106
  75. package/src/reports/moh-711/moh711.scss +95 -64
  76. package/src/reports/moh-711/registers/moh-333-register.component.tsx +92 -94
  77. package/src/reports/moh-711/registers/moh-333.columns.ts +119 -0
  78. package/src/reports/moh-711/registers/moh-405-register.component.tsx +88 -89
  79. package/src/reports/moh-711/registers/moh-405.columns.ts +120 -0
  80. package/src/reports/moh-711/registers/moh-406-register.component.tsx +85 -88
  81. package/src/reports/moh-711/registers/moh-406.columns.ts +133 -0
  82. package/src/reports/moh-711/registers/moh-510-register.component.tsx +38 -44
  83. package/src/reports/moh-711/registers/moh-511-register.component.tsx +42 -43
  84. package/src/reports/moh-711/registers/moh-511.columns.ts +59 -0
  85. package/src/reports/moh-711/sections/anc.component.tsx +3 -3
  86. package/src/reports/moh-711/sections/cervical-cancer.component.tsx +3 -3
  87. package/src/reports/moh-711/sections/chanis.component.tsx +2 -3
  88. package/src/reports/moh-711/sections/family-planning.component.tsx +2 -2
  89. package/src/reports/moh-711/sections/gbv.component.tsx +2 -2
  90. package/src/reports/moh-711/sections/maternity.component.tsx +3 -8
  91. package/src/reports/moh-711/sections/medical-social-work.component.tsx +2 -12
  92. package/src/reports/moh-711/sections/other.component.tsx +2 -2
  93. package/src/reports/moh-711/sections/physiotherapy.component.tsx +2 -2
  94. package/src/reports/moh-711/sections/pnc.component.tsx +7 -5
  95. package/src/reports/moh-711/sections/post-abortion.component.tsx +2 -2
  96. package/src/reports/moh-711/sections/rehabilitation.component.tsx +2 -2
  97. package/src/reports/moh-711/sections/report-compiled-by.component.tsx +12 -4
  98. package/src/reports/moh-711/sections/tb-screening.component.tsx +2 -2
  99. package/src/reports/moh-717/moh-717.component.tsx +100 -121
  100. package/src/reports/moh-717/moh717.scss +163 -102
  101. package/src/reports/moh-717/sections/maternity.component.tsx +1 -1
  102. package/src/reports/moh-717/sections/orthopaedic-trauma.component.tsx +1 -1
  103. package/src/reports/moh-717/sections/outpatient.component.tsx +23 -23
  104. package/src/reports/moh-717/sections/preparedby.component.tsx +7 -2
  105. package/src/reports/moh-717/sections/special-services.component.tsx +1 -1
  106. package/src/reports/moh-731/moh-731.component.tsx +127 -110
  107. package/src/reports/moh-731/moh-731.scss +396 -68
  108. package/src/reports/moh-731/registers/moh-366.columns.ts +38 -0
  109. package/src/reports/moh-731/registers/moh-366.component.tsx +76 -83
  110. package/src/reports/moh-731/registers/prep-register.component.tsx +70 -78
  111. package/src/reports/moh-731/registers/prep.columns.ts +34 -0
  112. package/src/reports/moh-731/sections/hiv-and-tb-treatment.component.tsx +1031 -751
  113. package/src/reports/moh-731/sections/hiv-testing-and-pre-exposure.component.tsx +230 -86
  114. package/src/reports/moh-731/sections/pmtct.component.tsx +185 -64
  115. package/src/reports/moh-740/moh-740.component.scss +159 -79
  116. package/src/reports/moh-740/moh-740.component.tsx +258 -227
  117. package/src/reports/moh-740/moh-740.resource.ts +17 -10
  118. package/src/reports/moh-740/registers/moh-222-daily-register/moh-222-daily-register.tsx +77 -96
  119. package/src/reports/moh-740/registers/moh-270-permanent-register/moh-270-permanent-register.tsx +50 -70
  120. package/src/reports/moh-740/registers/moh-740-patient-list.tsx +61 -32
  121. package/src/reports/moh-740/registers/moh-740.columns.ts +52 -0
  122. package/src/reports/moh-745/moh-745.component.tsx +897 -877
  123. package/src/reports/moh-745/moh-745.scss +104 -46
  124. package/src/reports/moh-745/registers/moh-412-register.component.tsx +42 -43
  125. package/src/reports/moh-745/registers/moh-412.columns.ts +52 -0
  126. package/src/reports/table-wrapper/table-wrapper.component.tsx +23 -14
  127. package/src/reports/table-wrapper/table-wrapper.scss +1 -16
  128. package/src/resources/moh-505.resource.ts +18 -35
  129. package/src/resources/moh-705.resource.ts +28 -39
  130. package/src/resources/moh-706.resource.ts +17 -30
  131. package/src/resources/moh-710.resource.ts +7 -17
  132. package/src/resources/moh-711.resource.ts +46 -64
  133. package/src/resources/moh-717.resource.ts +7 -17
  134. package/src/resources/moh-731.resource.ts +26 -32
  135. package/src/resources/moh-745.resource.ts +18 -20
  136. package/src/resources/patient-list-page.ts +66 -0
  137. package/src/root.component.tsx +28 -26
  138. package/src/root.scss +39 -0
  139. package/src/utils/get-base-url.ts +39 -7
  140. package/dist/822.js +0 -2
  141. package/dist/822.js.LICENSE.txt +0 -20
  142. package/dist/822.js.map +0 -1
  143. package/src/reports/moh-731/registers/moh-366.scss +0 -45
  144. package/src/reports/moh-731/registers/prep-registers.scss +0 -45
  145. package/src/reports/moh-740/registers/moh-222-daily-register/moh-222-daily-register.scss +0 -18
  146. package/src/reports/moh-740/registers/moh-270-permanent-register/moh-270-permanent-register.scss +0 -18
  147. /package/src/{reports/moh-740/shared/utils → utils}/format-indicator.ts +0 -0
@@ -1,16 +1,18 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
 
3
3
  import styles from './moh-731.scss';
4
- import ReportFiltersComponent from '../../common/report-filters/report-filters.component';
5
- import { type ReportFilters } from '../moh-705a/type';
6
- import { useSession } from '@openmrs/esm-framework';
4
+ import { ReportFiltersComponent, type ReportPeriod } from '../../common/report-filters';
5
+ import { showReportError } from '../../common/report-error';
6
+ import { hasReportData, ReportPlaceholder } from '../../common/report-placeholder';
7
+ import { formatDate, useSession } from '@openmrs/esm-framework';
8
+ import dayjs from 'dayjs';
7
9
  import { useNavigate } from 'react-router-dom';
8
10
  import { getMoh731 } from '../../resources/moh-731.resource';
9
11
  import HivTestingandPreExposusreProphylaxis from './sections/hiv-testing-and-pre-exposure.component';
10
12
  import PmtctComponent from './sections/pmtct.component';
11
13
  import HivAndTBTreatmentComponent from './sections/hiv-and-tb-treatment.component';
12
- import classNames from 'classnames';
13
- import { Loading } from '@carbon/react';
14
+ import { ReportSkeleton } from '../../common/report-skeleton';
15
+ import { usePageScale } from '../../common/report-page';
14
16
 
15
17
  interface Moh731Props {}
16
18
 
@@ -38,42 +40,37 @@ const Moh731Report: React.FC<Moh731Props> = () => {
38
40
  useEffect(() => {
39
41
  sessionStorage.setItem('moh731EndDate', endDate);
40
42
  }, [endDate]);
41
- const [errorMessage, setErrorMessage] = useState<any>();
42
43
 
43
44
  const session = useSession();
44
45
  const locationUuids = session?.sessionLocation?.uuid;
45
46
  const navigate = useNavigate();
46
47
 
47
- const getReportParams = (filters: ReportFilters) => {
48
- let { startDate: sDate, endDate: eDate } = filters;
49
-
50
- if (filters.month) {
51
- const [year, monthIndex] = filters.month.split('-').map(Number);
52
-
53
- const start = new Date(year, monthIndex - 1, 1);
54
- const end = new Date(year, monthIndex, 0);
55
-
56
- const formatLocalDate = (d: Date) => {
57
- const y = d.getFullYear();
58
- const m = String(d.getMonth() + 1).padStart(2, '0');
59
- const day = String(d.getDate()).padStart(2, '0');
60
- return `${y}-${m}-${day}`;
61
- };
62
-
63
- sDate = formatLocalDate(start);
64
- eDate = formatLocalDate(end);
65
- }
66
-
67
- setStartDate(sDate || '');
68
- setEndDate(eDate || '');
69
-
70
- return { startDate: sDate, endDate: eDate };
71
- };
72
-
73
- const fetchMoh731ReportData = async (filters: { startDate?: string; endDate?: string; month?: string }) => {
48
+ const isReportGenerated = hasReportData(moh731Data);
49
+
50
+ /* The sign-off records who produced the return and when. Designation and
51
+ signature stay blank -- those are filled in by hand on the printed sheet. */
52
+ /* The masthead names the location the report was generated from, so the
53
+ session location leads and the ETL's own facility field is the fallback.
54
+ County, sub-county and MFL come from the response where the ETL supplies
55
+ them (the same keys MOH-740 returns). Month and year come from the period
56
+ the report was actually generated for, not from today. */
57
+ const facility = session?.sessionLocation?.display ?? moh731Data?.facility ?? '';
58
+ const county = moh731Data?.county ?? '';
59
+ const subCounty = moh731Data?.sub_county ?? '';
60
+ const mflCode = moh731Data?.mfl_code ?? '';
61
+ const reportMonth = startDate ? dayjs(startDate).format('MMMM') : '';
62
+ const reportYear = startDate ? dayjs(startDate).format('YYYY') : '';
63
+
64
+ const generatedBy = session?.user?.person?.display ?? session?.user?.display ?? '';
65
+ const generatedOn = formatDate(new Date(), { mode: 'standard', time: false, noToday: true });
66
+
67
+ /** Fills the available width, never rendering below A4 */
68
+ const { ref: viewportRef, scale } = usePageScale<HTMLDivElement>();
69
+
70
+ const fetchMoh731ReportData = async ({ startDate, endDate }: ReportPeriod) => {
74
71
  setIsLoading(true);
75
-
76
- const { startDate, endDate } = getReportParams(filters);
72
+ setStartDate(startDate);
73
+ setEndDate(endDate);
77
74
 
78
75
  const params = {
79
76
  locationUuids: locationUuids || '',
@@ -86,94 +83,114 @@ const Moh731Report: React.FC<Moh731Props> = () => {
86
83
  setMoh731Data(flatData);
87
84
  setIsLoading(false);
88
85
  } catch (error: any) {
89
- setErrorMessage(error.message);
90
86
  setIsLoading(false);
91
- throw new Error(`Failed to fetch MOH-710 report data: ${error instanceof Error ? error.message : String(error)}`);
87
+ showReportError('the MOH-731 report', error);
92
88
  }
93
89
  };
94
90
 
95
- const navigateToRegister = (indicator: string) => {
96
- navigate(
97
- `/moh-405-register?startDate=${startDate}&endDate=${endDate}&locationUuids=${locationUuids}&indicator=${indicator}`,
98
- );
99
- };
100
91
  return (
101
92
  <>
102
93
  <ReportFiltersComponent
103
94
  reportName="MOH-731 Report"
104
95
  mode="monthly"
105
96
  onGenerate={fetchMoh731ReportData}
106
- isLoding={isLoading}
97
+ isLoading={isLoading}
98
+ isReportGenerated={isReportGenerated}
99
+ generatedPeriod={{ startDate, endDate }}
107
100
  />
108
- <div
109
- className={classNames(`${styles.table}`, `${styles.tableBordered}`, `${styles.border}`, `${styles.border2}`)}
110
- >
111
- <table style={{ width: '100%' }}>
112
- <tr>
113
- <td style={{ textAlign: 'center', fontWeight: 'bold' }}>
114
- National AIDS & STI Control Program- NASCOP <br />
115
- Comprehensive HIV/ AIDS reporting form
116
- <div style={{ textAlign: 'right', marginBottom: '1%' }}>
117
- <span style={{ textAlign: 'right', border: '2px dotted #000' }}>(MOH 731-Ver. July 2023)</span>
101
+ {isLoading && <ReportSkeleton blocks={3} />}
102
+ {!isLoading && !isReportGenerated && <ReportPlaceholder reportName="MOH-731" />}
103
+ {!isLoading && isReportGenerated && (
104
+ <>
105
+ {/* The sheet is a fixed A4 page, so it scrolls inside this viewport
106
+ rather than forcing the whole app to scroll sideways. */}
107
+ <div className={styles.viewport} ref={viewportRef}>
108
+ {/* The scale is a custom property rather than an inline `zoom`, so
109
+ the print stylesheet can still reset it to 1 */}
110
+ <div className={styles.form} style={{ '--page-zoom': scale } as React.CSSProperties}>
111
+ {/* Ministry line sits above the ruled sheet, as on the printed form */}
112
+ <div className={styles.ministryLine}>
113
+ <span>Ministry of Health</span>
114
+ <span>Ver. July 2023</span>
115
+ </div>
116
+
117
+ <div className={styles.sheet}>
118
+ <div className={styles.formHeader}>
119
+ <div className={styles.formTitle}>
120
+ <strong>National AIDS &amp; STI Control Program- NASCOP</strong>
121
+ <strong>Comprehensive HIV/ AIDS reporting form</strong>
122
+ </div>
123
+ <span className={styles.formVersion}>(MOH 731-Ver. July 2023)</span>
124
+ </div>
125
+
126
+ {/* Each label and its rule is one flex item, so the six pairs stay
127
+ on a single centred line and cannot run together. */}
128
+ <p className={styles.locationContainer}>
129
+ <span>
130
+ County<span className={styles.line}>{county}</span>
131
+ </span>
132
+ <span>
133
+ Sub County<span className={styles.line}>{subCounty}</span>
134
+ </span>
135
+ <span>
136
+ Facility<span className={styles.line}>{facility}</span>
137
+ </span>
138
+ <span>
139
+ MFL<span className={styles.shortLine}>{mflCode}</span>
140
+ </span>
141
+ <span>
142
+ Month<span className={styles.shortLine}>{reportMonth}</span>
143
+ </span>
144
+ <span>
145
+ year<span className={styles.shortLine}>{reportYear}</span>
146
+ </span>
147
+ </p>
148
+
149
+ <h5 className={styles.sectionHeader}>1. HIV Testing Services &amp; Pre exposure Prophylaxis</h5>
150
+ <HivTestingandPreExposusreProphylaxis
151
+ MOH731Data={moh731Data}
152
+ startDate={startDate}
153
+ endDate={endDate}
154
+ locationUuids={locationUuids!}
155
+ />
156
+
157
+ <h5 className={styles.sectionHeader}>2. Elimination of Mother-to-Child Transmission (EMTCT)</h5>
158
+ <PmtctComponent
159
+ MOH731Data={moh731Data}
160
+ startDate={startDate}
161
+ endDate={endDate}
162
+ locationUuids={locationUuids!}
163
+ />
164
+
165
+ {/* The sign-off is the bottom band of columns 1 and 2 on the printed
166
+ sheet, with section 5 continuing beside it, so it is handed to
167
+ section 3 rather than rendered after it. */}
168
+ <HivAndTBTreatmentComponent
169
+ MOH731Data={moh731Data}
170
+ startDate={startDate}
171
+ endDate={endDate}
172
+ locationUuids={locationUuids!}
173
+ footer={
174
+ <div className={styles.reviewSection}>
175
+ <span className={styles.reviewLabel}>Reviewed by:</span>
176
+ <span>Name</span>
177
+ <span>Designation</span>
178
+ <span>Signature</span>
179
+ <span>Date</span>
180
+
181
+ <span />
182
+ <span className={styles.reviewRule}>{generatedBy}</span>
183
+ <span className={styles.reviewRule} />
184
+ <span className={styles.reviewRule} />
185
+ <span className={styles.reviewRule}>{generatedOn}</span>
186
+ </div>
187
+ }
188
+ />
118
189
  </div>
119
- </td>
120
- </tr>
121
- </table>
122
- </div>
123
- <table className={styles.locationContainer} style={{ marginTop: '0.5%' }}>
124
- <tr>
125
- <td style={{ paddingLeft: '5rem', paddingBottom: '1%' }}>
126
- County______________________SubCounty___________________Facility___________________MFL_______Month______year______
127
- </td>
128
- </tr>
129
- </table>
130
- <table className={styles.table} style={{ marginTop: '1%' }}>
131
- <thead>
132
- <tr>
133
- <th className={styles.border}>1. HIV Testing & Pre exposure Prophylaxis</th>
134
- </tr>
135
- </thead>
136
- <HivTestingandPreExposusreProphylaxis
137
- MOH731Data={moh731Data}
138
- startDate={startDate}
139
- endDate={endDate}
140
- locationUuids={locationUuids!}
141
- />
142
- <thead>
143
- <tr>
144
- <th className={styles.border2}>2. Elimination of Mother-to-Child Transmission(EMTCT)</th>
145
- </tr>
146
- </thead>
147
- <PmtctComponent
148
- MOH731Data={moh731Data}
149
- startDate={startDate}
150
- endDate={endDate}
151
- locationUuids={locationUuids!}
152
- />
153
-
154
- <HivAndTBTreatmentComponent
155
- MOH731Data={moh731Data}
156
- startDate={startDate}
157
- endDate={endDate}
158
- locationUuids={locationUuids!}
159
- />
160
- <thead>
161
- <div className={classNames(styles.reviewSection, styles.border3)}>
162
- <div>Reviewed by:</div>
163
- <div>Name</div>
164
- <div>Designation</div>
165
- <div>Signature</div>
166
- <div>Date</div>
167
-
168
- <div></div>
169
- <div>_______________________________________</div>
170
- <div>______________________</div>
171
- <div>_____________</div>
172
- <div>____________</div>
190
+ </div>
173
191
  </div>
174
- </thead>
175
- </table>
176
- {isLoading && <Loading />}
192
+ </>
193
+ )}
177
194
  </>
178
195
  );
179
196
  };