@ampath/esm-reports-app 1.0.0-next.6 → 1.0.0-next.60

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 (229) hide show
  1. package/dist/197.js +1 -1
  2. package/dist/282.js +1 -1
  3. package/dist/282.js.map +1 -1
  4. package/dist/295.css +1 -0
  5. package/dist/295.css.map +1 -0
  6. package/dist/295.js +1 -0
  7. package/dist/295.js.map +1 -0
  8. package/dist/300.js +1 -1
  9. package/dist/311.js +1 -1
  10. package/dist/311.js.map +1 -1
  11. package/dist/335.js +1 -1
  12. package/dist/353.js +1 -1
  13. package/dist/353.js.map +1 -1
  14. package/dist/410.js +1 -0
  15. package/dist/410.js.map +1 -0
  16. package/dist/478.js +1 -1
  17. package/dist/478.js.map +1 -1
  18. package/dist/540.js +1 -1
  19. package/dist/540.js.map +1 -1
  20. package/dist/55.js +1 -1
  21. package/dist/580.js +1 -0
  22. package/dist/580.js.map +1 -0
  23. package/dist/652.js +1 -1
  24. package/dist/876.css +1 -0
  25. package/dist/876.css.map +1 -0
  26. package/dist/876.js +1 -0
  27. package/dist/876.js.map +1 -0
  28. package/dist/907.js +2 -0
  29. package/dist/907.js.LICENSE.txt +35 -0
  30. package/dist/907.js.map +1 -0
  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/daily-summary-table.tsx +55 -0
  39. package/src/common/linelist-table/index.ts +3 -0
  40. package/src/common/linelist-table/linelist-columns.ts +48 -0
  41. package/src/common/linelist-table/linelist-table.component.tsx +442 -0
  42. package/src/common/linelist-table/linelist-table.scss +306 -0
  43. package/src/common/linelist-table/linelist-table.test.tsx +120 -0
  44. package/src/common/linelist-table/use-all-rows.ts +93 -0
  45. package/src/common/linelist-table/use-column-layout.ts +123 -0
  46. package/src/common/report-error/index.ts +1 -0
  47. package/src/common/report-error/show-report-error.ts +25 -0
  48. package/src/common/report-filters/date-range.ts +137 -0
  49. package/src/common/report-filters/index.ts +4 -0
  50. package/src/common/report-filters/report-filters.component.tsx +297 -100
  51. package/src/common/report-filters/report-filters.scss +255 -32
  52. package/src/common/report-filters/types.ts +66 -0
  53. package/src/common/report-filters/use-restore-period.ts +43 -0
  54. package/src/common/report-header/index.ts +1 -0
  55. package/src/common/report-header/use-location-details.ts +58 -0
  56. package/src/common/report-page/index.ts +2 -0
  57. package/src/common/report-page/report-page.component.tsx +32 -0
  58. package/src/common/report-page/report-page.scss +45 -0
  59. package/src/common/report-page/use-page-scale.ts +60 -0
  60. package/src/common/report-placeholder/has-report-data.ts +15 -0
  61. package/src/common/report-placeholder/index.ts +3 -0
  62. package/src/common/report-placeholder/report-placeholder.component.tsx +81 -0
  63. package/src/common/report-placeholder/report-placeholder.scss +48 -0
  64. package/src/common/report-placeholder/use-generated-location.ts +62 -0
  65. package/src/common/report-register/index.ts +6 -0
  66. package/src/common/report-register/register-columns.ts +46 -0
  67. package/src/common/report-register/register-layout.component.tsx +265 -0
  68. package/src/common/report-register/register-layout.scss +150 -0
  69. package/src/common/report-register/register-table.scss +71 -0
  70. package/src/common/report-register/report-parents.ts +27 -0
  71. package/src/common/report-register/rows-to-csv.ts +89 -0
  72. package/src/common/report-register/use-location-name.ts +54 -0
  73. package/src/common/report-register/use-patient-list.ts +92 -0
  74. package/src/common/report-skeleton/index.ts +1 -0
  75. package/src/common/report-skeleton/report-skeleton.component.tsx +46 -0
  76. package/src/common/report-skeleton/report-skeleton.scss +29 -0
  77. package/src/config-schema.ts +9 -1
  78. package/src/dashboard/report-catalog.ts +173 -0
  79. package/src/dashboard/reports-dasboard.tsx +101 -17
  80. package/src/dashboard/reports-dashboard.module.scss +269 -11
  81. package/src/index.ts +13 -1
  82. package/src/reports/datatable-wrapper/datatable-wrapper.component.tsx +69 -0
  83. package/src/reports/moh-240/moh-240-header.component.tsx +62 -0
  84. package/src/reports/moh-240/moh-240.columns.ts +113 -0
  85. package/src/reports/moh-240/moh-240.component.tsx +75 -0
  86. package/src/reports/moh-240/moh-240.scss +40 -0
  87. package/src/reports/moh-240/sub-reports/moh-240-register.component.tsx +36 -0
  88. package/src/reports/moh-240/sub-reports/page-summary.component.tsx +148 -0
  89. package/src/reports/moh-505/moh-505-header.component.tsx +67 -0
  90. package/src/reports/moh-505/moh-505.component.tsx +441 -0
  91. package/src/reports/moh-505/moh-505.scss +117 -0
  92. package/src/reports/moh-705B/moh-204b-register.component.tsx +244 -0
  93. package/src/reports/moh-705B/moh-204b.columns.ts +39 -0
  94. package/src/reports/moh-705B/moh-705b.component.tsx +658 -0
  95. package/src/reports/moh-705B/moh-705b.scss +172 -0
  96. package/src/reports/moh-705a/moh-705a.component.tsx +660 -0
  97. package/src/reports/moh-705a/moh-705a.scss +172 -0
  98. package/src/reports/moh-705a/registers/moh-204a-register.component.tsx +329 -0
  99. package/src/reports/moh-705a/registers/moh-204a.columns.ts +57 -0
  100. package/src/reports/moh-705a/type.ts +6 -0
  101. package/src/reports/moh-706/moh-706-header.component.tsx +66 -0
  102. package/src/reports/moh-706/moh-706.component.tsx +150 -24
  103. package/src/reports/moh-706/moh-706.scss +119 -11
  104. package/src/reports/moh-706/sub-reports/bacteriology/bacteriology.component.tsx +36 -44
  105. package/src/reports/moh-706/sub-reports/blood-chemistry/blood-chemistry.component.tsx +232 -318
  106. package/src/reports/moh-706/sub-reports/drug-susceptibility-testing/drug-susceptibility-testing.component.tsx +32 -47
  107. package/src/reports/moh-706/sub-reports/haematology/haematology.component.tsx +44 -52
  108. package/src/reports/moh-706/sub-reports/histology-and-cytology/histology-and-cytology.component.tsx +25 -40
  109. package/src/reports/moh-706/sub-reports/parasitology/parasitology.component.tsx +31 -39
  110. package/src/reports/moh-706/sub-reports/serology/serology.component.tsx +26 -34
  111. package/src/reports/moh-706/sub-reports/specimen-referral-to-higher-levels/specimen-referral-to-higher-levels.component.tsx +10 -25
  112. package/src/reports/moh-706/sub-reports/urine-analysis/urine-analysis.component.tsx +42 -50
  113. package/src/reports/moh-710/moh-710.component.tsx +799 -632
  114. package/src/reports/moh-710/moh-710.scss +142 -21
  115. package/src/reports/moh-710/registers/moh-510/moh-510.columns.ts +40 -0
  116. package/src/reports/moh-710/registers/moh-510/moh-510.component.tsx +144 -0
  117. package/src/reports/moh-710/registers/moh-510/moh-510.scss +130 -0
  118. package/src/reports/moh-710/registers/moh-511-710-register.component.tsx +268 -0
  119. package/src/reports/moh-710/registers/moh-511-710.columns.ts +52 -0
  120. package/src/reports/moh-710/registers/type.ts +31 -0
  121. package/src/reports/moh-711/moh-711.component.tsx +138 -1269
  122. package/src/reports/moh-711/moh711.scss +135 -20
  123. package/src/reports/moh-711/registers/moh-333-register.component.tsx +637 -0
  124. package/src/reports/moh-711/registers/moh-333.columns.ts +119 -0
  125. package/src/reports/moh-711/registers/moh-405-register.component.tsx +520 -0
  126. package/src/reports/moh-711/registers/moh-405.columns.ts +120 -0
  127. package/src/reports/moh-711/registers/moh-406-register.component.tsx +530 -0
  128. package/src/reports/moh-711/registers/moh-406.columns.ts +133 -0
  129. package/src/reports/moh-711/registers/moh-510-register.component.tsx +55 -0
  130. package/src/reports/moh-711/registers/moh-511-register.component.tsx +270 -0
  131. package/src/reports/moh-711/registers/moh-511.columns.ts +59 -0
  132. package/src/reports/moh-711/registers/type.ts +192 -0
  133. package/src/reports/moh-711/sections/anc.component.tsx +159 -0
  134. package/src/reports/moh-711/sections/cervical-cancer.component.tsx +148 -0
  135. package/src/reports/moh-711/sections/chanis.component.tsx +366 -0
  136. package/src/reports/moh-711/sections/family-planning.component.tsx +221 -0
  137. package/src/reports/moh-711/sections/gbv.component.tsx +115 -0
  138. package/src/reports/moh-711/sections/maternity.component.tsx +321 -0
  139. package/src/reports/moh-711/sections/medical-social-work.component.tsx +73 -0
  140. package/src/reports/moh-711/sections/other.component.tsx +47 -0
  141. package/src/reports/moh-711/sections/physiotherapy.component.tsx +61 -0
  142. package/src/reports/moh-711/sections/pnc.component.tsx +127 -0
  143. package/src/reports/moh-711/sections/post-abortion.component.tsx +42 -0
  144. package/src/reports/moh-711/sections/rehabilitation.component.tsx +57 -0
  145. package/src/reports/moh-711/sections/report-compiled-by.component.tsx +50 -0
  146. package/src/reports/moh-711/sections/tb-screening.component.tsx +57 -0
  147. package/src/reports/moh-717/moh-717.component.tsx +149 -985
  148. package/src/reports/moh-717/moh717.scss +217 -21
  149. package/src/reports/moh-717/registers/nutrition-register.component.tsx +48 -0
  150. package/src/reports/moh-717/sections/finance.component.tsx +42 -0
  151. package/src/reports/moh-717/sections/inpatient.component.tsx +374 -0
  152. package/src/reports/moh-717/sections/maternity.component.tsx +126 -0
  153. package/src/reports/moh-717/sections/medical-records.component.tsx +35 -0
  154. package/src/reports/moh-717/sections/mortuary.component.tsx +43 -0
  155. package/src/reports/moh-717/sections/operations.component.tsx +53 -0
  156. package/src/reports/moh-717/sections/orthopaedic-trauma.component.tsx +98 -0
  157. package/src/reports/moh-717/sections/outpatient.component.tsx +597 -0
  158. package/src/reports/moh-717/sections/pharmacy.component.tsx +43 -0
  159. package/src/reports/moh-717/sections/preparedby.component.tsx +52 -0
  160. package/src/reports/moh-717/sections/special-services.component.tsx +114 -0
  161. package/src/reports/moh-731/linelist/moh-731-indicators.ts +1040 -0
  162. package/src/reports/moh-731/linelist/moh-731-linelist-sections.ts +423 -0
  163. package/src/reports/moh-731/linelist/moh-731-linelist.component.tsx +102 -0
  164. package/src/reports/moh-731/linelist/use-open-moh-731-linelist.ts +50 -0
  165. package/src/reports/moh-731/moh-731.component.tsx +251 -0
  166. package/src/reports/moh-731/moh-731.scss +493 -0
  167. package/src/reports/moh-731/registers/moh-366.columns.ts +38 -0
  168. package/src/reports/moh-731/registers/moh-366.component.tsx +471 -0
  169. package/src/reports/moh-731/registers/prep-register.component.tsx +284 -0
  170. package/src/reports/moh-731/registers/prep.columns.ts +34 -0
  171. package/src/reports/moh-731/sections/hiv-and-tb-treatment.component.tsx +1209 -0
  172. package/src/reports/moh-731/sections/hiv-testing-and-pre-exposure.component.tsx +727 -0
  173. package/src/reports/moh-731/sections/pmtct.component.tsx +572 -0
  174. package/src/reports/moh-731/summary/moh-731-summary.component.tsx +313 -0
  175. package/src/reports/moh-731/summary/moh-731-summary.config.ts +520 -0
  176. package/src/reports/moh-731/summary/moh-731-summary.scss +242 -0
  177. package/src/reports/moh-740/moh-740.component.scss +202 -0
  178. package/src/reports/moh-740/moh-740.component.tsx +1312 -0
  179. package/src/reports/moh-740/moh-740.resource.ts +49 -0
  180. package/src/reports/moh-740/registers/moh-222-daily-register/moh-222-daily-register.tsx +89 -0
  181. package/src/reports/moh-740/registers/moh-270-permanent-register/moh-270-permanent-register.tsx +61 -0
  182. package/src/reports/moh-740/registers/moh-740-patient-list.scss +0 -0
  183. package/src/reports/moh-740/registers/moh-740-patient-list.tsx +95 -0
  184. package/src/reports/moh-740/registers/moh-740.columns.ts +52 -0
  185. package/src/reports/moh-740/shared/data-cell/data-cell.scss +6 -0
  186. package/src/reports/moh-740/shared/data-cell/data-cell.tsx +23 -0
  187. package/src/reports/moh-740/shared/utils/indicator-register-map.ts +157 -0
  188. package/src/reports/moh-740/types/index.ts +220 -0
  189. package/src/reports/moh-745/moh-745.component.tsx +1021 -0
  190. package/src/reports/moh-745/moh-745.scss +132 -0
  191. package/src/reports/moh-745/registers/moh-412-register.component.tsx +199 -0
  192. package/src/reports/moh-745/registers/moh-412.columns.ts +52 -0
  193. package/src/reports/moh-745/registers/type.ts +181 -0
  194. package/src/reports/table-wrapper/table-row-mapper.component.tsx +53 -0
  195. package/src/reports/table-wrapper/table-wrapper.component.tsx +30 -0
  196. package/src/reports/{moh-706/table-wrapper → table-wrapper}/table-wrapper.scss +1 -16
  197. package/src/resources/moh-505.resource.ts +69 -0
  198. package/src/resources/moh-705.resource.ts +106 -0
  199. package/src/resources/moh-706.resource.ts +80 -0
  200. package/src/resources/moh-710.resource.ts +32 -9
  201. package/src/resources/moh-711.resource.ts +137 -9
  202. package/src/resources/moh-717.resource.ts +26 -9
  203. package/src/resources/moh-731.resource.ts +90 -0
  204. package/src/resources/moh-745.resource.ts +76 -0
  205. package/src/resources/patient-list-page.ts +65 -0
  206. package/src/root.component.tsx +50 -7
  207. package/src/root.scss +36 -0
  208. package/src/routes.json +3 -1
  209. package/src/utils/format-indicator.ts +22 -0
  210. package/src/utils/get-base-url.ts +39 -7
  211. package/src/utils/utils.ts +36 -0
  212. package/tsconfig.json +1 -1
  213. package/webpack.config.js +22 -1
  214. package/dist/184.js +0 -2
  215. package/dist/184.js.LICENSE.txt +0 -14
  216. package/dist/184.js.map +0 -1
  217. package/dist/260.js +0 -1
  218. package/dist/260.js.map +0 -1
  219. package/dist/402.js +0 -1
  220. package/dist/402.js.map +0 -1
  221. package/dist/812.js +0 -1
  222. package/dist/812.js.map +0 -1
  223. package/dist/959.js +0 -2
  224. package/dist/959.js.LICENSE.txt +0 -20
  225. package/dist/959.js.map +0 -1
  226. package/dist/ampath-esm-reports-app.js.buildmanifest.json +0 -539
  227. package/dist/main.js +0 -1
  228. package/dist/main.js.map +0 -1
  229. package/src/reports/moh-706/table-wrapper/table-wrapper.component.tsx +0 -21
@@ -0,0 +1,69 @@
1
+ import { openmrsFetch } from '@openmrs/esm-framework';
2
+ import { buildEtlUrl } from '../utils/get-base-url';
3
+ import {
4
+ PAGE_SIZE,
5
+ pageParams,
6
+ toPatientListPage,
7
+ type PatientListPage,
8
+ type PatientListParams,
9
+ } from './patient-list-page';
10
+
11
+ interface Moh505Params {
12
+ locationUuids: string;
13
+ startDate?: string;
14
+ endDate?: string;
15
+ }
16
+
17
+ interface Moh505Response {
18
+ result: Array<Record<string, unknown>>;
19
+ }
20
+
21
+ export async function getMoh505(params: Moh505Params): Promise<Array<Record<string, unknown>>> {
22
+ const url = await buildEtlUrl('moh-505', {
23
+ locationUuids: params.locationUuids || '',
24
+ startDate: params.startDate || '',
25
+ endDate: params.endDate || '',
26
+ });
27
+ try {
28
+ const response = await openmrsFetch(url);
29
+
30
+ if (!response.ok) {
31
+ const errorText = await response.text();
32
+ throw new Error(`Failed to fetch MOH-505 report: ${response.status} - ${errorText}`);
33
+ }
34
+
35
+ const data = await response.json();
36
+
37
+ if (!Array.isArray(data.result)) {
38
+ throw new Error('Invalid MOH-505 response format: missing result array.');
39
+ }
40
+
41
+ return data.result;
42
+ } catch (error: any) {
43
+ throw new Error(`An error occurred while fetching the MOH-505 report: ${error.message}`);
44
+ }
45
+ }
46
+
47
+ export async function getMoh505PatientList(params: PatientListParams): Promise<PatientListPage> {
48
+ const url = await buildEtlUrl('moh-505/patient-list', {
49
+ locationUuids: params.locationUuids || '',
50
+ startDate: params.startDate || '',
51
+ endDate: params.endDate || '',
52
+ indicators: params.indicators || '',
53
+ ...pageParams(params),
54
+ });
55
+ try {
56
+ const response = await openmrsFetch(url);
57
+
58
+ if (!response.ok) {
59
+ const errorText = await response.text();
60
+ throw new Error(`Failed to fetch MOH-505 patient list: ${response.status} - ${errorText}`);
61
+ }
62
+
63
+ const data = await response.json();
64
+
65
+ return toPatientListPage(data, params.startIndex ?? 0, params.limit ?? PAGE_SIZE);
66
+ } catch (error: any) {
67
+ throw new Error(`An error occurred while fetching the MOH-505 patient list: ${error.message}`);
68
+ }
69
+ }
@@ -0,0 +1,106 @@
1
+ import { openmrsFetch } from '@openmrs/esm-framework';
2
+ import { buildEtlUrl } from '../utils/get-base-url';
3
+ import {
4
+ PAGE_SIZE,
5
+ pageParams,
6
+ toPatientListPage,
7
+ type PatientListPage,
8
+ type PatientListParams,
9
+ } from './patient-list-page';
10
+
11
+ interface Moh710Params {
12
+ locationUuids: string;
13
+ startDate?: string;
14
+ endDate?: string;
15
+ indicator?: string | string[];
16
+ }
17
+
18
+ export async function getMoh705a(params: Moh710Params): Promise<any> {
19
+ const url = await buildEtlUrl('moh-705a', {
20
+ locationUuids: params.locationUuids || '',
21
+ startDate: params.startDate || '',
22
+ endDate: params.endDate || '',
23
+ });
24
+ try {
25
+ const response = await openmrsFetch(url);
26
+
27
+ if (!response.ok) {
28
+ const errorText = await response.text();
29
+ throw new Error(`Failed to fetch dashboard summary: ${response.status} - ${errorText}`);
30
+ }
31
+
32
+ const data = await response.json();
33
+ return data;
34
+ } catch (error: any) {
35
+ throw new Error(`An error occurred while fetching the MOH-710 report: ${error.message}`);
36
+ }
37
+ }
38
+
39
+ export async function getMoh705aPatientList(params: PatientListParams): Promise<PatientListPage> {
40
+ const url = await buildEtlUrl('moh-705a-patient-list', {
41
+ locationUuids: params.locationUuids || '',
42
+ startDate: params.startDate || '',
43
+ endDate: params.endDate || '',
44
+ indicator: Array.isArray(params.indicator) ? params.indicator.join(',') : params.indicator || '',
45
+ ...pageParams(params),
46
+ });
47
+ try {
48
+ const response = await openmrsFetch(url);
49
+
50
+ if (!response.ok) {
51
+ const errorText = await response.text();
52
+ throw new Error(`Failed to fetch patient list: ${response.status} - ${errorText}`);
53
+ }
54
+
55
+ const data = await response.json();
56
+
57
+ return toPatientListPage(data, params.startIndex ?? 0, params.limit ?? PAGE_SIZE);
58
+ } catch (error: any) {
59
+ throw new Error(`An error occurred while fetching the MOH-705 patient list: ${error.message}`);
60
+ }
61
+ }
62
+
63
+ export async function getMoh705b(params: Moh710Params): Promise<any> {
64
+ const url = await buildEtlUrl('moh-705b', {
65
+ locationUuids: params.locationUuids || '',
66
+ startDate: params.startDate || '',
67
+ endDate: params.endDate || '',
68
+ });
69
+ try {
70
+ const response = await openmrsFetch(url);
71
+
72
+ if (!response.ok) {
73
+ const errorText = await response.text();
74
+ throw new Error(`Failed to fetch dashboard summary: ${response.status} - ${errorText}`);
75
+ }
76
+
77
+ const data = await response.json();
78
+ return data;
79
+ } catch (error: any) {
80
+ throw new Error(`An error occurred while fetching the MOH-710 report: ${error.message}`);
81
+ }
82
+ }
83
+
84
+ export async function getMoh705bPatientList(params: PatientListParams): Promise<PatientListPage> {
85
+ const url = await buildEtlUrl('moh-705b-patient-list', {
86
+ locationUuids: params.locationUuids || '',
87
+ startDate: params.startDate || '',
88
+ endDate: params.endDate || '',
89
+ indicator: Array.isArray(params.indicator) ? params.indicator.join(',') : params.indicator || '',
90
+ ...pageParams(params),
91
+ });
92
+ try {
93
+ const response = await openmrsFetch(url);
94
+
95
+ if (!response.ok) {
96
+ const errorText = await response.text();
97
+ throw new Error(`Failed to fetch patient list: ${response.status} - ${errorText}`);
98
+ }
99
+
100
+ const data = await response.json();
101
+
102
+ return toPatientListPage(data, params.startIndex ?? 0, params.limit ?? PAGE_SIZE);
103
+ } catch (error: any) {
104
+ throw new Error(`An error occurred while fetching the MOH-705 patient list: ${error.message}`);
105
+ }
106
+ }
@@ -0,0 +1,80 @@
1
+ import { openmrsFetch } from '@openmrs/esm-framework';
2
+ import { buildEtlUrl } from '../utils/get-base-url';
3
+ import {
4
+ PAGE_SIZE,
5
+ pageParams,
6
+ toPatientListPage,
7
+ type PatientListPage,
8
+ type PatientListParams,
9
+ } from './patient-list-page';
10
+
11
+ interface Moh706Params {
12
+ locationUuids: string;
13
+ startDate?: string;
14
+ endDate?: string;
15
+ }
16
+
17
+ interface Moh706Response {
18
+ result: Array<Record<string, unknown>>;
19
+ }
20
+
21
+ interface Moh706PatientListResponse {
22
+ result: Array<Record<string, unknown>>;
23
+ }
24
+
25
+ /**
26
+ * The ETL server validates the OpenMRS session cookie (JSESSIONID), so every
27
+ * request must carry it. `credentials: 'include'` keeps same-origin proxies
28
+ * working and is required when the ETL base URL is another origin.
29
+ */
30
+ const WITH_SESSION_COOKIE = { credentials: 'include' as RequestCredentials };
31
+
32
+ export async function getMoh706(params: Moh706Params): Promise<Array<Record<string, unknown>>> {
33
+ const url = await buildEtlUrl('lab-706', {
34
+ locationUuids: params.locationUuids || '',
35
+ startDate: params.startDate || '',
36
+ endDate: params.endDate || '',
37
+ });
38
+ try {
39
+ const response = await openmrsFetch(url, WITH_SESSION_COOKIE);
40
+
41
+ if (!response.ok) {
42
+ const errorText = await response.text();
43
+ throw new Error(`Failed to fetch MOH-706 report: ${response.status} - ${errorText}`);
44
+ }
45
+
46
+ const data = await response.json();
47
+
48
+ if (!Array.isArray(data.result)) {
49
+ throw new Error('Invalid MOH-706 response format: missing result array.');
50
+ }
51
+
52
+ return data.result;
53
+ } catch (error: any) {
54
+ throw new Error(`An error occurred while fetching the MOH-706 report: ${error.message}`);
55
+ }
56
+ }
57
+
58
+ export async function getMoh706PatientList(params: PatientListParams): Promise<PatientListPage> {
59
+ const url = await buildEtlUrl('lab-706/patient-list', {
60
+ locationUuids: params.locationUuids || '',
61
+ startDate: params.startDate || '',
62
+ endDate: params.endDate || '',
63
+ indicators: params.indicators || '',
64
+ ...pageParams(params),
65
+ });
66
+ try {
67
+ const response = await openmrsFetch(url, WITH_SESSION_COOKIE);
68
+
69
+ if (!response.ok) {
70
+ const errorText = await response.text();
71
+ throw new Error(`Failed to fetch MOH-706 patient list: ${response.status} - ${errorText}`);
72
+ }
73
+
74
+ const data = await response.json();
75
+
76
+ return toPatientListPage(data, params.startIndex ?? 0, params.limit ?? PAGE_SIZE);
77
+ } catch (error: any) {
78
+ throw new Error(`An error occurred while fetching the MOH-706 patient list: ${error.message}`);
79
+ }
80
+ }
@@ -1,25 +1,48 @@
1
1
  import { openmrsFetch } from '@openmrs/esm-framework';
2
- import { getEtlBaseUrl } from '../utils/get-base-url';
2
+ import { buildEtlUrl } from '../utils/get-base-url';
3
3
 
4
4
  interface Moh710Params {
5
5
  locationUuids: string;
6
6
  startDate?: string;
7
7
  endDate?: string;
8
+ indicator?: string | string[];
9
+ startIndex?: number;
10
+ limit?: number;
11
+ reportName?: string;
8
12
  }
9
13
 
10
14
  export async function getMoh710(params: Moh710Params): Promise<any> {
11
- const etlBaseUrl = await getEtlBaseUrl();
12
- const url = `${etlBaseUrl}/moh-710`;
13
- const queryparams = {
15
+ const url = await buildEtlUrl('moh-710', {
14
16
  locationUuids: params.locationUuids || '',
15
17
  startDate: params.startDate || '',
16
18
  endDate: params.endDate || '',
17
- };
18
- const queryString = new URLSearchParams(
19
- Object.fromEntries(Object.entries(queryparams).filter(([_, v]) => v !== undefined && v !== null)),
20
- ).toString();
19
+ });
21
20
  try {
22
- const response = await openmrsFetch(`${url}?${queryString}`);
21
+ const response = await openmrsFetch(url);
22
+
23
+ if (!response.ok) {
24
+ const errorText = await response.text();
25
+ throw new Error(`Failed to fetch dashboard summary: ${response.status} - ${errorText}`);
26
+ }
27
+
28
+ const data = await response.json();
29
+ return data;
30
+ } catch (error: any) {
31
+ throw new Error(`An error occurred while fetching the MOH-710 report: ${error.message}`);
32
+ }
33
+ }
34
+
35
+ export async function getMoh710PatientList(params: Moh710Params): Promise<any> {
36
+ const url = await buildEtlUrl('moh-510-patient-list', {
37
+ locationUuids: params.locationUuids || '',
38
+ startDate: params.startDate || '',
39
+ endDate: params.endDate || '',
40
+ indicator: Array.isArray(params.indicator) ? params.indicator.join(',') : params.indicator || '',
41
+ reportName: params.reportName || 'moh710Report',
42
+ });
43
+
44
+ try {
45
+ const response = await openmrsFetch(url);
23
46
 
24
47
  if (!response.ok) {
25
48
  const errorText = await response.text();
@@ -1,25 +1,29 @@
1
1
  import { openmrsFetch } from '@openmrs/esm-framework';
2
- import { getEtlBaseUrl } from '../utils/get-base-url';
2
+ import { buildEtlUrl } from '../utils/get-base-url';
3
+ import {
4
+ PAGE_SIZE,
5
+ pageParams,
6
+ toPatientListPage,
7
+ type PatientListPage,
8
+ type PatientListParams,
9
+ } from './patient-list-page';
3
10
 
4
11
  interface Moh711Params {
5
12
  locationUuids: string;
6
13
  startDate?: string;
7
14
  endDate?: string;
15
+ indicator?: string | string[];
16
+ reportName?: string;
8
17
  }
9
18
 
10
19
  export async function getMoh711(params: Moh711Params): Promise<any> {
11
- const etlBaseUrl = await getEtlBaseUrl();
12
- const url = `${etlBaseUrl}/moh-711`;
13
- const queryparams = {
20
+ const url = await buildEtlUrl('moh-711', {
14
21
  locationUuids: params.locationUuids || '',
15
22
  startDate: params.startDate || '',
16
23
  endDate: params.endDate || '',
17
- };
18
- const queryString = new URLSearchParams(
19
- Object.fromEntries(Object.entries(queryparams).filter(([_, v]) => v !== undefined && v !== null)),
20
- ).toString();
24
+ });
21
25
  try {
22
- const response = await openmrsFetch(`${url}?${queryString}`);
26
+ const response = await openmrsFetch(url);
23
27
 
24
28
  if (!response.ok) {
25
29
  const errorText = await response.text();
@@ -32,3 +36,127 @@ export async function getMoh711(params: Moh711Params): Promise<any> {
32
36
  throw new Error(`An error occurred while fetching the MOH-711 report: ${error.message}`);
33
37
  }
34
38
  }
39
+
40
+ export async function getMoh406PatientList(params: PatientListParams): Promise<PatientListPage> {
41
+ const url = await buildEtlUrl('moh-406-patient-list', {
42
+ locationUuids: params.locationUuids || '',
43
+ startDate: params.startDate || '',
44
+ endDate: params.endDate || '',
45
+ indicator: Array.isArray(params.indicator) ? params.indicator.join(',') : params.indicator || '',
46
+ reportName: params.reportName || '',
47
+ ...pageParams(params),
48
+ });
49
+ try {
50
+ const response = await openmrsFetch(url);
51
+
52
+ if (!response.ok) {
53
+ const errorText = await response.text();
54
+ throw new Error(`Failed to fetch patient list: ${response.status} - ${errorText}`);
55
+ }
56
+
57
+ const data = await response.json();
58
+
59
+ return toPatientListPage(data, params.startIndex ?? 0, params.limit ?? PAGE_SIZE);
60
+ } catch (error: any) {
61
+ throw new Error(`An error occurred while fetching the MOH-705 patient list: ${error.message}`);
62
+ }
63
+ }
64
+
65
+ export async function getMoh405PatientList(params: PatientListParams): Promise<PatientListPage> {
66
+ const url = await buildEtlUrl('moh-405-patient-list', {
67
+ locationUuids: params.locationUuids || '',
68
+ startDate: params.startDate || '',
69
+ endDate: params.endDate || '',
70
+ indicator: Array.isArray(params.indicator) ? params.indicator.join(',') : params.indicator || '',
71
+ reportName: params.reportName || '',
72
+ ...pageParams(params),
73
+ });
74
+ try {
75
+ const response = await openmrsFetch(url);
76
+
77
+ if (!response.ok) {
78
+ const errorText = await response.text();
79
+ throw new Error(`Failed to fetch patient list: ${response.status} - ${errorText}`);
80
+ }
81
+
82
+ const data = await response.json();
83
+
84
+ return toPatientListPage(data, params.startIndex ?? 0, params.limit ?? PAGE_SIZE);
85
+ } catch (error: any) {
86
+ throw new Error(`An error occurred while fetching the MOH-705 patient list: ${error.message}`);
87
+ }
88
+ }
89
+
90
+ export async function getMoh333PatientList(params: PatientListParams): Promise<PatientListPage> {
91
+ const url = await buildEtlUrl('moh-333-patient-list', {
92
+ locationUuids: params.locationUuids || '',
93
+ startDate: params.startDate || '',
94
+ endDate: params.endDate || '',
95
+ indicator: Array.isArray(params.indicator) ? params.indicator.join(',') : params.indicator || '',
96
+ reportName: params.reportName || '',
97
+ ...pageParams(params),
98
+ });
99
+ try {
100
+ const response = await openmrsFetch(url);
101
+
102
+ if (!response.ok) {
103
+ const errorText = await response.text();
104
+ throw new Error(`Failed to fetch patient list: ${response.status} - ${errorText}`);
105
+ }
106
+
107
+ const data = await response.json();
108
+
109
+ return toPatientListPage(data, params.startIndex ?? 0, params.limit ?? PAGE_SIZE);
110
+ } catch (error: any) {
111
+ throw new Error(`An error occurred while fetching the MOH-705 patient list: ${error.message}`);
112
+ }
113
+ }
114
+
115
+ export async function getMoh510PatientList(params: PatientListParams): Promise<PatientListPage> {
116
+ const url = await buildEtlUrl('moh-510-patient-list', {
117
+ locationUuids: params.locationUuids || '',
118
+ startDate: params.startDate || '',
119
+ endDate: params.endDate || '',
120
+ indicator: Array.isArray(params.indicator) ? params.indicator.join(',') : params.indicator || '',
121
+ ...pageParams(params),
122
+ });
123
+ try {
124
+ const response = await openmrsFetch(url);
125
+
126
+ if (!response.ok) {
127
+ const errorText = await response.text();
128
+ throw new Error(`Failed to fetch patient list: ${response.status} - ${errorText}`);
129
+ }
130
+
131
+ const data = await response.json();
132
+
133
+ return toPatientListPage(data, params.startIndex ?? 0, params.limit ?? PAGE_SIZE);
134
+ } catch (error: any) {
135
+ throw new Error(`An error occurred while fetching the MOH-705 patient list: ${error.message}`);
136
+ }
137
+ }
138
+
139
+ export async function getMoh511PatientList(params: PatientListParams): Promise<PatientListPage> {
140
+ const url = await buildEtlUrl('moh-511-patient-list', {
141
+ locationUuids: params.locationUuids || '',
142
+ startDate: params.startDate || '',
143
+ endDate: params.endDate || '',
144
+ indicator: Array.isArray(params.indicator) ? params.indicator.join(',') : params.indicator || '',
145
+ reportName: params.reportName || '',
146
+ ...pageParams(params),
147
+ });
148
+ try {
149
+ const response = await openmrsFetch(url);
150
+
151
+ if (!response.ok) {
152
+ const errorText = await response.text();
153
+ throw new Error(`Failed to fetch patient list: ${response.status} - ${errorText}`);
154
+ }
155
+
156
+ const data = await response.json();
157
+
158
+ return toPatientListPage(data, params.startIndex ?? 0, params.limit ?? PAGE_SIZE);
159
+ } catch (error: any) {
160
+ throw new Error(`An error occurred while fetching the MOH-705 patient list: ${error.message}`);
161
+ }
162
+ }
@@ -1,5 +1,5 @@
1
1
  import { openmrsFetch } from '@openmrs/esm-framework';
2
- import { getEtlBaseUrl } from '../utils/get-base-url';
2
+ import { buildEtlUrl } from '../utils/get-base-url';
3
3
 
4
4
  interface Moh717Params {
5
5
  locationUuids: string;
@@ -8,19 +8,36 @@ interface Moh717Params {
8
8
  }
9
9
 
10
10
  export async function getMoh717(params: Moh717Params): Promise<any> {
11
- const etlBaseUrl = await getEtlBaseUrl();
12
- const url = `${etlBaseUrl}/moh-717`;
13
- const queryparams = {
11
+ const url = await buildEtlUrl('moh-717', {
14
12
  locationUuids: params.locationUuids || '',
15
13
  startDate: params.startDate || '',
16
14
  endDate: params.endDate || '',
17
- };
18
- const queryString = new URLSearchParams(
19
- Object.fromEntries(Object.entries(queryparams).filter(([_, v]) => v !== undefined && v !== null)),
20
- ).toString();
15
+ });
21
16
 
22
17
  try {
23
- const response = await openmrsFetch(`${url}?${queryString}`);
18
+ const response = await openmrsFetch(url);
19
+
20
+ if (!response.ok) {
21
+ const errorText = await response.text();
22
+ throw new Error(`Failed to fetch dashboard summary: ${response.status} - ${errorText}`);
23
+ }
24
+
25
+ const data = await response.json();
26
+ return data;
27
+ } catch (error: any) {
28
+ throw new Error(`An error occurred while fetching the MOH-717 report: ${error.message}`);
29
+ }
30
+ }
31
+
32
+ export async function getNutritionRegister(params: Moh717Params): Promise<any> {
33
+ const url = await buildEtlUrl('moh-717', {
34
+ locationUuids: params.locationUuids || '',
35
+ startDate: params.startDate || '',
36
+ endDate: params.endDate || '',
37
+ });
38
+
39
+ try {
40
+ const response = await openmrsFetch(url);
24
41
 
25
42
  if (!response.ok) {
26
43
  const errorText = await response.text();
@@ -0,0 +1,90 @@
1
+ import { openmrsFetch } from '@openmrs/esm-framework';
2
+ import { buildEtlUrl } from '../utils/get-base-url';
3
+ import {
4
+ PAGE_SIZE,
5
+ pageParams,
6
+ toPatientListPage,
7
+ type PatientListPage,
8
+ type PatientListParams,
9
+ } from './patient-list-page';
10
+
11
+ interface Moh745Params {
12
+ locationUuids: string;
13
+ startDate?: string;
14
+ endDate?: string;
15
+ indicator?: string;
16
+ gender?: string;
17
+ }
18
+
19
+ export async function getMoh731(params: Moh745Params): Promise<any> {
20
+ const url = await buildEtlUrl('moh-731-monthly-summary', {
21
+ locationUuids: params.locationUuids || '',
22
+ startDate: params.startDate || '',
23
+ endDate: params.endDate || '',
24
+ });
25
+ try {
26
+ const response = await openmrsFetch(url);
27
+
28
+ if (!response.ok) {
29
+ const errorText = await response.text();
30
+ throw new Error(`Failed to fetch dashboard summary: ${response.status} - ${errorText}`);
31
+ }
32
+
33
+ const data = await response.json();
34
+ return data;
35
+ } catch (error: any) {
36
+ throw new Error(`An error occurred while fetching the MOH-731 report: ${error.message}`);
37
+ }
38
+ }
39
+
40
+ export async function getMoh366PatientList(params: PatientListParams): Promise<PatientListPage> {
41
+ const url = await buildEtlUrl('moh-731-monthly-summary-patient-list', {
42
+ locationUuids: params.locationUuids || '',
43
+ startDate: params.startDate || '',
44
+ endDate: params.endDate || '',
45
+ indicator: params.indicator || '',
46
+ gender: params.gender || '',
47
+ ...pageParams(params),
48
+ });
49
+ try {
50
+ const response = await openmrsFetch(url);
51
+
52
+ if (!response.ok) {
53
+ const errorText = await response.text();
54
+ throw new Error(`Failed to fetch patient list: ${response.status} - ${errorText}`);
55
+ }
56
+
57
+ const data = await response.json();
58
+
59
+ return toPatientListPage(data, params.startIndex ?? 0, params.limit ?? PAGE_SIZE);
60
+ } catch (error: any) {
61
+ console.error('Failed to fetch MOH 412 PATIENT LIST data', error);
62
+ throw new Error(`An error occurred while fetching the MOH-705 patient list: ${error.message}`);
63
+ }
64
+ }
65
+
66
+ export async function getPrepPatientList(params: PatientListParams): Promise<PatientListPage> {
67
+ const url = await buildEtlUrl('prep-patient-list', {
68
+ locationUuids: params.locationUuids || '',
69
+ startDate: params.startDate || '',
70
+ endDate: params.endDate || '',
71
+ indicator: params.indicator || '',
72
+ gender: params.gender || '',
73
+ ...pageParams(params),
74
+ });
75
+ try {
76
+ const response = await openmrsFetch(url);
77
+
78
+ if (!response.ok) {
79
+ const errorText = await response.text();
80
+ throw new Error(`Failed to fetch patient list: ${response.status} - ${errorText}`);
81
+ }
82
+
83
+ const data = await response.json();
84
+
85
+ return toPatientListPage(data, params.startIndex ?? 0, params.limit ?? PAGE_SIZE);
86
+ } catch (error: any) {
87
+ console.error('Failed to fetch MOH 412 PATIENT LIST data', error);
88
+ throw new Error(`An error occurred while fetching the MOH-705 patient list: ${error.message}`);
89
+ }
90
+ }