@ampath/esm-reports-app 1.0.0-next.41 → 1.0.0-next.45

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 (183) hide show
  1. package/dist/143.css +1 -0
  2. package/dist/143.css.map +1 -0
  3. package/dist/143.js +1 -0
  4. package/dist/143.js.map +1 -0
  5. package/dist/197.js +1 -1
  6. package/dist/282.js +1 -1
  7. package/dist/282.js.map +1 -1
  8. package/dist/295.css +1 -0
  9. package/dist/295.css.map +1 -0
  10. package/dist/295.js +1 -0
  11. package/dist/295.js.map +1 -0
  12. package/dist/300.js +1 -1
  13. package/dist/311.js +1 -1
  14. package/dist/311.js.map +1 -1
  15. package/dist/335.js +1 -1
  16. package/dist/353.js +1 -1
  17. package/dist/353.js.map +1 -1
  18. package/dist/410.js +1 -0
  19. package/dist/410.js.map +1 -0
  20. package/dist/427.js +2 -0
  21. package/dist/427.js.LICENSE.txt +35 -0
  22. package/dist/427.js.map +1 -0
  23. package/dist/441.js +1 -0
  24. package/dist/441.js.map +1 -0
  25. package/dist/478.js +1 -1
  26. package/dist/478.js.map +1 -1
  27. package/dist/540.js +1 -1
  28. package/dist/540.js.map +1 -1
  29. package/dist/55.js +1 -1
  30. package/dist/652.js +1 -1
  31. package/dist/961.js +1 -1
  32. package/dist/961.js.map +1 -1
  33. package/dist/99.js +1 -1
  34. package/dist/ampath-esm-reports-app.js +1 -1
  35. package/dist/ampath-esm-reports-app.js.map +1 -1
  36. package/dist/routes.json +1 -1
  37. package/package.json +2 -2
  38. package/src/common/report-error/index.ts +1 -0
  39. package/src/common/report-error/show-report-error.ts +25 -0
  40. package/src/common/report-filters/date-range.ts +137 -0
  41. package/src/common/report-filters/index.ts +4 -0
  42. package/src/common/report-filters/report-filters.component.tsx +281 -151
  43. package/src/common/report-filters/report-filters.scss +180 -55
  44. package/src/common/report-filters/types.ts +66 -0
  45. package/src/common/report-filters/use-restore-period.ts +43 -0
  46. package/src/common/report-page/index.ts +2 -0
  47. package/src/common/report-page/report-page.component.tsx +32 -0
  48. package/src/common/report-page/report-page.scss +45 -0
  49. package/src/common/report-page/use-page-scale.ts +50 -0
  50. package/src/common/report-placeholder/has-report-data.ts +15 -0
  51. package/src/common/report-placeholder/index.ts +2 -0
  52. package/src/common/report-placeholder/report-placeholder.component.tsx +56 -0
  53. package/src/common/report-placeholder/report-placeholder.scss +46 -0
  54. package/src/common/report-register/index.ts +5 -0
  55. package/src/common/report-register/register-columns.ts +34 -0
  56. package/src/common/report-register/register-layout.component.tsx +237 -0
  57. package/src/common/report-register/register-layout.scss +140 -0
  58. package/src/common/report-register/register-table.scss +62 -0
  59. package/src/common/report-register/report-parents.ts +27 -0
  60. package/src/common/report-register/rows-to-csv.ts +59 -0
  61. package/src/common/report-register/use-patient-list.ts +92 -0
  62. package/src/common/report-skeleton/index.ts +1 -0
  63. package/src/common/report-skeleton/report-skeleton.component.tsx +46 -0
  64. package/src/common/report-skeleton/report-skeleton.scss +29 -0
  65. package/src/config-schema.ts +9 -1
  66. package/src/dashboard/report-catalog.ts +173 -0
  67. package/src/dashboard/reports-dasboard.tsx +101 -35
  68. package/src/dashboard/reports-dashboard.module.scss +269 -11
  69. package/src/index.ts +13 -1
  70. package/src/reports/datatable-wrapper/datatable-wrapper.component.tsx +50 -48
  71. package/src/reports/moh-240/moh-240-header.component.tsx +54 -56
  72. package/src/reports/moh-240/moh-240.columns.ts +64 -0
  73. package/src/reports/moh-240/moh-240.component.tsx +65 -84
  74. package/src/reports/moh-240/moh-240.scss +36 -7
  75. package/src/reports/moh-240/sub-reports/moh-240-register.component.tsx +27 -65
  76. package/src/reports/moh-240/sub-reports/page-summary.component.tsx +2 -2
  77. package/src/reports/moh-505/moh-505-header.component.tsx +59 -57
  78. package/src/reports/moh-505/moh-505.component.tsx +51 -56
  79. package/src/reports/moh-505/moh-505.scss +116 -2
  80. package/src/reports/moh-705B/moh-204b-register.component.tsx +41 -42
  81. package/src/reports/moh-705B/moh-204b.columns.ts +39 -0
  82. package/src/reports/moh-705B/moh-705b.component.tsx +492 -473
  83. package/src/reports/moh-705B/moh-705b.scss +110 -24
  84. package/src/reports/moh-705a/moh-705a.component.tsx +496 -476
  85. package/src/reports/moh-705a/moh-705a.scss +109 -24
  86. package/src/reports/moh-705a/registers/moh-204a-register.component.tsx +41 -42
  87. package/src/reports/moh-705a/registers/moh-204a.columns.ts +57 -0
  88. package/src/reports/moh-706/moh-706-header.component.tsx +58 -56
  89. package/src/reports/moh-706/moh-706.component.tsx +84 -55
  90. package/src/reports/moh-706/moh-706.scss +115 -19
  91. package/src/reports/moh-710/moh-710.component.tsx +743 -727
  92. package/src/reports/moh-710/moh-710.scss +140 -23
  93. package/src/reports/moh-710/registers/moh-511-710-register.component.tsx +48 -43
  94. package/src/reports/moh-710/registers/moh-511-710.columns.ts +52 -0
  95. package/src/reports/moh-711/moh-711.component.tsx +94 -106
  96. package/src/reports/moh-711/moh711.scss +95 -64
  97. package/src/reports/moh-711/registers/moh-333-register.component.tsx +92 -94
  98. package/src/reports/moh-711/registers/moh-333.columns.ts +119 -0
  99. package/src/reports/moh-711/registers/moh-405-register.component.tsx +88 -89
  100. package/src/reports/moh-711/registers/moh-405.columns.ts +120 -0
  101. package/src/reports/moh-711/registers/moh-406-register.component.tsx +85 -88
  102. package/src/reports/moh-711/registers/moh-406.columns.ts +133 -0
  103. package/src/reports/moh-711/registers/moh-510-register.component.tsx +38 -44
  104. package/src/reports/moh-711/registers/moh-511-register.component.tsx +42 -43
  105. package/src/reports/moh-711/registers/moh-511.columns.ts +59 -0
  106. package/src/reports/moh-711/sections/anc.component.tsx +3 -3
  107. package/src/reports/moh-711/sections/cervical-cancer.component.tsx +3 -3
  108. package/src/reports/moh-711/sections/chanis.component.tsx +2 -3
  109. package/src/reports/moh-711/sections/family-planning.component.tsx +2 -2
  110. package/src/reports/moh-711/sections/gbv.component.tsx +2 -2
  111. package/src/reports/moh-711/sections/maternity.component.tsx +3 -8
  112. package/src/reports/moh-711/sections/medical-social-work.component.tsx +2 -12
  113. package/src/reports/moh-711/sections/other.component.tsx +2 -2
  114. package/src/reports/moh-711/sections/physiotherapy.component.tsx +2 -2
  115. package/src/reports/moh-711/sections/pnc.component.tsx +7 -5
  116. package/src/reports/moh-711/sections/post-abortion.component.tsx +2 -2
  117. package/src/reports/moh-711/sections/rehabilitation.component.tsx +2 -2
  118. package/src/reports/moh-711/sections/report-compiled-by.component.tsx +12 -4
  119. package/src/reports/moh-711/sections/tb-screening.component.tsx +2 -2
  120. package/src/reports/moh-717/moh-717.component.tsx +100 -121
  121. package/src/reports/moh-717/moh717.scss +163 -102
  122. package/src/reports/moh-717/sections/maternity.component.tsx +1 -1
  123. package/src/reports/moh-717/sections/orthopaedic-trauma.component.tsx +1 -1
  124. package/src/reports/moh-717/sections/outpatient.component.tsx +23 -23
  125. package/src/reports/moh-717/sections/preparedby.component.tsx +7 -2
  126. package/src/reports/moh-717/sections/special-services.component.tsx +1 -1
  127. package/src/reports/moh-731/moh-731.component.tsx +127 -110
  128. package/src/reports/moh-731/moh-731.scss +396 -68
  129. package/src/reports/moh-731/registers/moh-366.columns.ts +38 -0
  130. package/src/reports/moh-731/registers/moh-366.component.tsx +76 -83
  131. package/src/reports/moh-731/registers/prep-register.component.tsx +70 -78
  132. package/src/reports/moh-731/registers/prep.columns.ts +34 -0
  133. package/src/reports/moh-731/sections/hiv-and-tb-treatment.component.tsx +1031 -751
  134. package/src/reports/moh-731/sections/hiv-testing-and-pre-exposure.component.tsx +230 -86
  135. package/src/reports/moh-731/sections/pmtct.component.tsx +185 -64
  136. package/src/reports/moh-740/moh-740.component.scss +159 -79
  137. package/src/reports/moh-740/moh-740.component.tsx +261 -230
  138. package/src/reports/moh-740/moh-740.resource.ts +17 -10
  139. package/src/reports/moh-740/registers/moh-222-daily-register/moh-222-daily-register.tsx +77 -96
  140. package/src/reports/moh-740/registers/moh-270-permanent-register/moh-270-permanent-register.tsx +50 -70
  141. package/src/reports/moh-740/registers/moh-740-patient-list.tsx +61 -32
  142. package/src/reports/moh-740/registers/moh-740.columns.ts +52 -0
  143. package/src/reports/moh-740/shared/utils/indicator-register-map.ts +3 -3
  144. package/src/reports/moh-740/types/index.ts +3 -3
  145. package/src/reports/moh-745/moh-745.component.tsx +897 -877
  146. package/src/reports/moh-745/moh-745.scss +104 -46
  147. package/src/reports/moh-745/registers/moh-412-register.component.tsx +42 -43
  148. package/src/reports/moh-745/registers/moh-412.columns.ts +52 -0
  149. package/src/reports/table-wrapper/table-wrapper.component.tsx +23 -14
  150. package/src/reports/table-wrapper/table-wrapper.scss +1 -16
  151. package/src/resources/moh-505.resource.ts +18 -35
  152. package/src/resources/moh-705.resource.ts +28 -39
  153. package/src/resources/moh-706.resource.ts +17 -30
  154. package/src/resources/moh-710.resource.ts +7 -17
  155. package/src/resources/moh-711.resource.ts +46 -64
  156. package/src/resources/moh-717.resource.ts +7 -17
  157. package/src/resources/moh-731.resource.ts +26 -32
  158. package/src/resources/moh-745.resource.ts +18 -20
  159. package/src/resources/patient-list-page.ts +66 -0
  160. package/src/root.component.tsx +28 -26
  161. package/src/root.scss +36 -0
  162. package/src/utils/get-base-url.ts +39 -7
  163. package/tsconfig.json +1 -1
  164. package/dist/110.js +0 -1
  165. package/dist/110.js.map +0 -1
  166. package/dist/184.js +0 -2
  167. package/dist/184.js.LICENSE.txt +0 -14
  168. package/dist/184.js.map +0 -1
  169. package/dist/205.js +0 -1
  170. package/dist/205.js.map +0 -1
  171. package/dist/812.js +0 -1
  172. package/dist/812.js.map +0 -1
  173. package/dist/822.js +0 -2
  174. package/dist/822.js.LICENSE.txt +0 -20
  175. package/dist/822.js.map +0 -1
  176. package/dist/ampath-esm-reports-app.js.buildmanifest.json +0 -560
  177. package/dist/main.js +0 -1
  178. package/dist/main.js.map +0 -1
  179. package/src/reports/moh-731/registers/moh-366.scss +0 -45
  180. package/src/reports/moh-731/registers/prep-registers.scss +0 -45
  181. package/src/reports/moh-740/registers/moh-222-daily-register/moh-222-daily-register.scss +0 -18
  182. package/src/reports/moh-740/registers/moh-270-permanent-register/moh-270-permanent-register.scss +0 -18
  183. /package/src/{reports/moh-740/shared/utils → utils}/format-indicator.ts +0 -0
@@ -1,62 +1,64 @@
1
- import React, { useMemo } from "react";
2
- import TableWrapper from "../table-wrapper/table-wrapper.component";
3
- import TableRowMapper from "../table-wrapper/table-row-mapper.component";
4
- import { getCell } from "../../utils/utils";
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';
5
6
  import styles from './moh-505.scss';
6
7
 
7
- const MOH505Header: React.FC = () => {
8
- const tableRows = useMemo(() => {
9
- return [
10
- {
11
- tableCells: [
12
- getCell("", "County:", 1, 1, true),
13
- getCell("", "", 3),
14
- ],
15
- },
16
- {
17
- tableCells: [
18
- getCell("", "Sub-County:", 1, 1, true),
19
- getCell("", "", 3),
20
- ],
21
- },
22
- {
23
- tableCells: [
24
- getCell("", "Health Facility:", 1, 1, true),
25
- getCell("", "", 3),
26
- ],
27
- },
28
- {
29
- tableCells: [
30
- getCell("", "KMHFL code:", 1, 1, true),
31
- getCell("", "", 3),
32
- ],
33
- },
34
- {
35
- tableCells: [
36
- getCell("", "Facility 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("", ""),
46
- getCell("", "End date:", 1, 1, true),
47
- getCell("", ""),
48
- ],
49
- },
50
- ];
51
- }, []);
8
+ interface MOH505HeaderProps {
9
+ facility?: string;
10
+ startDate?: string;
11
+ endDate?: string;
12
+ }
13
+
14
+ const asDate = (value?: string) => (value ? dayjs(value).format('DD/MM/YYYY') : '');
52
15
 
53
- return <div className={styles.headerSection}>
54
- <h3>MOH 505 IDSR</h3>
55
- <h3>Weekly Epidemic Monitoring Form</h3>
56
- <TableWrapper>
57
- <TableRowMapper tableRows={tableRows} />
58
- </TableWrapper>
16
+ const MOH505Header: React.FC<MOH505HeaderProps> = ({ facility = '', startDate, endDate }) => {
17
+ const tableRows = useMemo(() => {
18
+ return [
19
+ {
20
+ tableCells: [getCell('', 'County:', 1, 1, true), getCell('', '', 3)],
21
+ },
22
+ {
23
+ tableCells: [getCell('', 'Sub-County:', 1, 1, true), getCell('', '', 3)],
24
+ },
25
+ {
26
+ tableCells: [getCell('', 'Health Facility:', 1, 1, true), getCell('', facility, 3)],
27
+ },
28
+ {
29
+ tableCells: [getCell('', 'KMHFL code:', 1, 1, true), getCell('', '', 3)],
30
+ },
31
+ {
32
+ tableCells: [
33
+ getCell('', 'Facility Type:', 1, 1, true),
34
+ getCell('', ''),
35
+ getCell('', 'Man. Agency:', 1, 1, true),
36
+ getCell('', ''),
37
+ ],
38
+ },
39
+ {
40
+ tableCells: [
41
+ getCell('', 'Start date:', 1, 1, true),
42
+ getCell('', asDate(startDate)),
43
+ getCell('', 'End date:', 1, 1, true),
44
+ getCell('', asDate(endDate)),
45
+ ],
46
+ },
47
+ ];
48
+ }, [facility, startDate, endDate]);
49
+
50
+ return (
51
+ <div className={styles.headerSection}>
52
+ <div className={styles.mainTitleBox}>
53
+ <p className={styles.ministry}>Ministry of Health</p>
54
+ <h3 className={styles.reportTitle}>MOH 505 IDSR</h3>
55
+ <p className={styles.subTitle}>Weekly Epidemic Monitoring Form</p>
56
+ </div>
57
+ <TableWrapper className={styles.headerTable}>
58
+ <TableRowMapper tableRows={tableRows} />
59
+ </TableWrapper>
59
60
  </div>
60
- }
61
+ );
62
+ };
61
63
 
62
- export default MOH505Header;
64
+ export default MOH505Header;
@@ -1,23 +1,32 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { useSession } from '@openmrs/esm-framework';
3
- import { Loading } from '@carbon/react';
2
+ import { formatDate, useSession } from '@openmrs/esm-framework';
4
3
  import TableWrapper from '../table-wrapper/table-wrapper.component';
5
4
  import TableRowMapper from '../table-wrapper/table-row-mapper.component';
6
5
  import { getCell } from '../../utils/utils';
7
- import ReportFiltersComponent from '../../common/report-filters/report-filters.component';
6
+ import { ReportFiltersComponent, type ReportPeriod } from '../../common/report-filters';
7
+ import { showReportError } from '../../common/report-error';
8
+ import { hasReportData, ReportPlaceholder } from '../../common/report-placeholder';
8
9
  import { getMoh505 } from '../../resources/moh-505.resource';
9
10
  import MOH505Header from './moh-505-header.component';
10
11
  import { useSearchParams } from 'react-router-dom';
12
+ import { ReportSkeleton } from '../../common/report-skeleton';
13
+ import { ReportPage } from '../../common/report-page';
14
+ import styles from './moh-505.scss';
11
15
 
12
16
  const Moh505Report: React.FC = () => {
13
17
  const [moh505Data, setMoh505Data] = useState<any>({});
18
+ const isReportGenerated = hasReportData(moh505Data);
14
19
  const [isLoading, setIsLoading] = useState<boolean>(false);
15
- const [errorMessage, setErrorMessage] = useState<string>('');
16
20
  const [filters, setFilters] = useState<{ locationUuids?: string; startDate?: string; endDate?: string }>({});
17
21
 
18
22
  const session = useSession();
19
23
  const locationUuids = session?.sessionLocation?.uuid;
20
24
 
25
+ /* Masthead and sign-off fill themselves in, as on the other reports */
26
+ const facility = session?.sessionLocation?.display ?? '';
27
+ const compiledBy = session?.user?.person?.display ?? session?.user?.display ?? '';
28
+ const compiledOn = formatDate(new Date(), { mode: 'standard', time: false, noToday: true });
29
+
21
30
  const [searchParams] = useSearchParams();
22
31
 
23
32
  useEffect(() => {
@@ -30,29 +39,9 @@ const Moh505Report: React.FC = () => {
30
39
  }
31
40
  }, [searchParams]);
32
41
 
33
- const fetchMoh505Data = async (filters: { startDate?: string; endDate?: string; month?: string }) => {
34
- setErrorMessage('');
42
+ const fetchMoh505Data = async ({ startDate, endDate }: Pick<ReportPeriod, 'startDate' | 'endDate'>) => {
35
43
  setIsLoading(true);
36
44
 
37
- let startDate = filters.startDate;
38
- let endDate = filters.endDate;
39
-
40
- if (filters.month) {
41
- const [year, monthIndex] = filters.month.split('-').map(Number);
42
- const start = new Date(year, monthIndex - 1, 1);
43
- const end = new Date(year, monthIndex, 0);
44
-
45
- const formatLocalDate = (d: Date) => {
46
- const y = d.getFullYear();
47
- const m = String(d.getMonth() + 1).padStart(2, '0');
48
- const day = String(d.getDate()).padStart(2, '0');
49
- return `${y}-${m}-${day}`;
50
- };
51
-
52
- startDate = formatLocalDate(start);
53
- endDate = formatLocalDate(end);
54
- }
55
-
56
45
  const params = {
57
46
  locationUuids: locationUuids || '',
58
47
  startDate,
@@ -65,7 +54,7 @@ const Moh505Report: React.FC = () => {
65
54
  setMoh505Data(flatData);
66
55
  setFilters({ locationUuids: params.locationUuids, startDate, endDate });
67
56
  } catch (error: any) {
68
- setErrorMessage(error instanceof Error ? error.message : String(error));
57
+ showReportError('the MOH-505 report', error);
69
58
  } finally {
70
59
  setIsLoading(false);
71
60
  }
@@ -236,13 +225,7 @@ const Moh505Report: React.FC = () => {
236
225
  ],
237
226
  },
238
227
  {
239
- tableCells: [
240
- getCell('', 'Suspected Malaria***'),
241
- getCell(),
242
- getCell(),
243
- getCell(),
244
- getCell('', '', 5),
245
- ],
228
+ tableCells: [getCell('', 'Suspected Malaria***'), getCell(), getCell(), getCell(), getCell('', '', 5)],
246
229
  },
247
230
  {
248
231
  tableCells: [
@@ -408,33 +391,45 @@ const Moh505Report: React.FC = () => {
408
391
  <>
409
392
  <ReportFiltersComponent
410
393
  reportName="MOH-505 Report"
411
- mode="monthly"
394
+ mode="both"
412
395
  onGenerate={fetchMoh505Data}
413
- isLoding={isLoading}
396
+ isLoading={isLoading}
397
+ isReportGenerated={isReportGenerated}
414
398
  />
415
- {isLoading && <Loading description="Fetching data...." />}
416
- {!isLoading && errorMessage && (
417
- <div>
418
- <a href="#" className="close" data-dismiss="alert">
419
- &times;
420
- </a>
421
- <h4>
422
- <strong>
423
- <span className="glyphicon glyphicon-warning-sign"></span>{' '}
424
- </strong>{' '}
425
- An error occurred while trying to load the report. Please try again.
426
- </h4>
427
- <p>
428
- <small>{errorMessage}</small>
429
- </p>
430
- </div>
399
+ {isLoading && <ReportSkeleton />}
400
+ {!isLoading && !isReportGenerated && <ReportPlaceholder reportName="MOH-505" />}
401
+ {!isLoading && isReportGenerated && (
402
+ <ReportPage>
403
+ <div className={styles.sheet}>
404
+ <MOH505Header facility={facility} startDate={filters.startDate} endDate={filters.endDate} />
405
+ <TableWrapper>
406
+ <TableRowMapper
407
+ tableRows={tableRows}
408
+ data={moh505Data}
409
+ locationUuids={filters.locationUuids}
410
+ startDate={filters.startDate}
411
+ endDate={filters.endDate}
412
+ report="moh-505"
413
+ />
414
+ </TableWrapper>
415
+
416
+ <div className={styles.signOff}>
417
+ <span>
418
+ Compiled by:<span className={styles.line}>{compiledBy}</span>
419
+ </span>
420
+ <span>
421
+ Signature:
422
+ <span className={styles.line} />
423
+ </span>
424
+ <span>
425
+ Date:<span className={styles.shortLine}>{compiledOn}</span>
426
+ </span>
427
+ </div>
428
+ </div>
429
+ </ReportPage>
431
430
  )}
432
- <MOH505Header />
433
- <TableWrapper>
434
- <TableRowMapper tableRows={tableRows} data={moh505Data} locationUuids={filters.locationUuids} startDate={filters.startDate} endDate={filters.endDate} report='moh-505' />
435
- </TableWrapper>
436
431
  </>
437
432
  );
438
433
  };
439
434
 
440
- export default Moh505Report;
435
+ export default Moh505Report;
@@ -1,3 +1,117 @@
1
+ /* MOH-505 laid out for A4, on the same scale as the other reports.
2
+
3
+ This one renders through the shared TableWrapper, so its cells are styled
4
+ from `table-wrapper.scss` rather than here. Those rules are all single-class,
5
+ so scoping these under `.sheet` (a class plus an element, one step more
6
+ specific) wins deterministically -- no reliance on which module loads first.
7
+ The wrapper is asked for a plain table so Carbon's data-table rules, which
8
+ are far more specific, never apply at all. */
9
+
10
+ $ink: #000;
11
+ $rule: 1px solid $ink;
12
+
13
+ $text: 7pt;
14
+ $title: 7.5pt;
15
+ $meta: 6.5pt;
16
+
17
+ $pad: 3mm;
18
+
19
+ .mainTitleBox {
20
+ padding: 2mm $pad;
21
+ text-align: center;
22
+ border: $rule;
23
+ }
24
+
25
+ .ministry {
26
+ font-size: $meta;
27
+ }
28
+
29
+ .reportTitle {
30
+ font-size: $title;
31
+ font-weight: 700;
32
+ color: $ink;
33
+ }
34
+
35
+ .subTitle {
36
+ font-size: $meta;
37
+ font-weight: 600;
38
+ }
39
+
1
40
  .headerSection {
2
- padding: 15px;
3
- }
41
+ padding: 0;
42
+ }
43
+
44
+ .sheet {
45
+ font-size: $text;
46
+
47
+ table {
48
+ width: 100%;
49
+ border-collapse: collapse;
50
+ }
51
+
52
+ td,
53
+ th {
54
+ height: auto;
55
+ min-width: 0;
56
+ padding: 0.7mm 1mm;
57
+ overflow-wrap: anywhere;
58
+ font-size: $text;
59
+ line-height: 1.25;
60
+ text-align: center;
61
+ border: $rule;
62
+ }
63
+
64
+ /* Row labels read as text, not as data */
65
+ td:first-child {
66
+ text-align: left;
67
+ }
68
+
69
+ /* The facility block's labels sit against their values rather than centred */
70
+
71
+ .headerTable td {
72
+ text-align: left;
73
+ }
74
+ }
75
+
76
+ /* Sign-off, enclosed by the form */
77
+
78
+ .signOff {
79
+ display: flex;
80
+ flex-wrap: nowrap;
81
+ align-items: baseline;
82
+ justify-content: space-between;
83
+ gap: 2.5mm;
84
+ padding: $pad;
85
+ font-size: $meta;
86
+ white-space: nowrap;
87
+ border: $rule;
88
+ border-top: none;
89
+
90
+ > span {
91
+ display: flex;
92
+ flex: 1 1 auto;
93
+ align-items: baseline;
94
+ min-width: 0;
95
+ }
96
+ }
97
+
98
+ .line,
99
+ .shortLine {
100
+ padding: 0 0.5mm;
101
+ margin-left: 1mm;
102
+ overflow: hidden;
103
+ font-weight: 600;
104
+ text-align: center;
105
+ text-overflow: ellipsis;
106
+ border-bottom: $rule;
107
+ }
108
+
109
+ .line {
110
+ flex: 1 1 45mm;
111
+ min-width: 15mm;
112
+ }
113
+
114
+ .shortLine {
115
+ flex: 1 1 25mm;
116
+ min-width: 12mm;
117
+ }
@@ -1,58 +1,57 @@
1
- import { Button, Loading, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@carbon/react';
2
- import React, { useEffect, useState } from 'react';
1
+ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@carbon/react';
2
+ import React from 'react';
3
3
 
4
- import styles from './moh-705b.scss';
4
+ import styles from '../../common/report-register/register-table.scss';
5
5
  import classNames from 'classnames';
6
6
  import { useLocation, useNavigate, useSearchParams } from 'react-router-dom';
7
7
  import { getMoh705bPatientList } from '../../resources/moh-705.resource';
8
+ import { moh204bExportColumns } from './moh-204b.columns';
9
+ import { RegisterLayout, usePatientList } from '../../common/report-register';
8
10
 
9
11
  const Moh204BRegisterComponent: React.FC = () => {
10
- const [patientlist, setPatientList] = useState<any[]>([]);
11
- const [isLoading, setIsLoading] = useState<boolean>(false);
12
12
  const [searchParams] = useSearchParams();
13
- const navigate = useNavigate();
14
- const location = useLocation();
15
13
  const startDate = searchParams.get('startDate');
16
14
  const endDate = searchParams.get('endDate');
17
15
  const locationUuids = searchParams.get('locationUuids');
18
16
  const indicator = searchParams.get('indicator');
19
17
 
20
- useEffect(() => {
21
- const fetchData = async () => {
22
- if (!startDate || !endDate || !locationUuids || !indicator) return;
23
-
24
- setIsLoading(true);
25
-
26
- try {
27
- const params = {
28
- startDate,
29
- endDate,
30
- locationUuids,
31
- indicator,
32
- };
33
-
34
- const data = await getMoh705bPatientList(params);
35
- setPatientList(data?.results.results || []);
36
- } catch (error) {
37
- console.error('Failed to fetch register data', error);
38
- } finally {
39
- setIsLoading(false);
40
- }
41
- };
42
-
43
- fetchData();
44
- }, [startDate, endDate, locationUuids, indicator]);
45
-
46
- function navigateBack() {
47
- navigate(location.state?.from || '/moh-705b');
48
- }
18
+ const {
19
+ rows: patientlist,
20
+ total,
21
+ isTotalExact,
22
+ isLoading,
23
+ page,
24
+ pageSize,
25
+ onPageChange,
26
+ fetchAll,
27
+ } = usePatientList(
28
+ ({ startIndex, limit }) =>
29
+ getMoh705bPatientList({
30
+ startDate: startDate!,
31
+ endDate: endDate!,
32
+ locationUuids: locationUuids!,
33
+ indicator: indicator!,
34
+ startIndex,
35
+ limit,
36
+ }),
37
+ [startDate, endDate, locationUuids, indicator],
38
+ );
49
39
 
50
40
  return (
51
- <>
52
- <div className={styles.buttonContainer}>
53
- <Button onClick={navigateBack}>Back</Button>
54
- </div>
55
- <div>{isLoading && <Loading />}</div>
41
+ <RegisterLayout
42
+ parentLabel="MOH-705B Report"
43
+ parentPath="/moh-705b"
44
+ title="MOH 204B Over-5 Outpatient Register"
45
+ isLoading={isLoading}
46
+ isEmpty={patientlist.length === 0}
47
+ page={page}
48
+ pageSize={pageSize}
49
+ total={total}
50
+ isTotalExact={isTotalExact}
51
+ onPageChange={onPageChange}
52
+ fetchAll={fetchAll}
53
+ columns={moh204bExportColumns}
54
+ >
56
55
  <div className={styles.tableContainer}>
57
56
  <Table className={classNames(`${styles.table}`, `${styles.tableBordered}`, `${styles.tableStriped}`)}>
58
57
  <TableHead>
@@ -229,7 +228,7 @@ const Moh204BRegisterComponent: React.FC = () => {
229
228
  </TableBody>
230
229
  </Table>
231
230
  </div>
232
- </>
231
+ </RegisterLayout>
233
232
  );
234
233
  };
235
234
 
@@ -0,0 +1,39 @@
1
+ import { type RegisterColumn } from '../../common/report-register';
2
+
3
+ /**
4
+ * MOH 204B as the register prints it: one column per cell, in the order they appear.
5
+ */
6
+ export const moh204bExportColumns: RegisterColumn[] = [
7
+ { header: 'Date (DD/MM/YYYY) - A', value: (row) => row.date ?? '' },
8
+ { header: 'OPD No. (New) - B', value: (row) => row.opd_number_new_visit ?? '' },
9
+ { header: 'OPD No. (Revisit) - C', value: (row) => row.opd_number_return_visit ?? '' },
10
+ { header: 'Referred From 1=CU, 2=From Other facility, 3= Within 4=N/A - D', value: (row) => row.referred_from ?? '' },
11
+ { header: 'Full Names (THREE names) - E', value: (row) => row.full_names ?? '' },
12
+ { header: 'Age in Years - F', value: (row) => row.age ?? '' },
13
+ { header: 'Sex - G', value: (row) => row.sex ?? '' },
14
+ { header: 'Countu/Sub- county - H', value: (row) => row.county_sub_county ?? '' },
15
+ { header: 'Village /Estate / Landmark - I', value: (row) => row.village_estate_landmark ?? '' },
16
+ { header: "Patient/ Parent/Caregivers's Telephone No. - J", value: (row) => row.phone_number ?? '' },
17
+ { header: 'Weight - K', value: (row) => row.weight ?? '' },
18
+ { header: 'Height - L', value: (row) => row.height ?? '' },
19
+ { header: 'BMI (Kg/m2) - M', value: (row) => row.bmi ?? '' },
20
+ { header: 'Temp (oC) - N', value: (row) => row.temp ?? '' },
21
+ { header: 'BP - O', value: (row) => row.systolic ?? '' },
22
+ { header: 'Visual Aquity "RE (Right Eye)"LE (Left Eye) - P', value: (row) => row.visual_aquity_re ?? '' },
23
+ {
24
+ header: 'TB Screening 1. presumed TB 2. No signs 3. On TB Treatment 4. Not done - Q',
25
+ value: (row) => row.tb_screening ?? '',
26
+ },
27
+ {
28
+ header:
29
+ 'Malaria 1.Presenting with symptoms NOT Tested 2.RDT Tested (-ve) 3.Microscopy Tested (-ve) 4.RDT Tested (+ve) 5. Microscopy Tested (+ve) - R',
30
+ value: (row) => row.malaria ?? '',
31
+ },
32
+ { header: 'Diagnosis - S', value: (row) => row.diagnosis ?? '' },
33
+ { header: 'Treatment/Prescription - T', value: (row) => row.treatment_prescription ?? '' },
34
+ {
35
+ header: 'Referred to (1=CU, 2= to other H/F, 3=within the facility/ 4=N/A) - V',
36
+ value: (row) => row.referred_to ?? '',
37
+ },
38
+ { header: 'REMARKS/ Outcome - W', value: (row) => row.remarks ?? '' },
39
+ ];