@ampath/esm-reports-app 1.0.0-next.11 → 1.0.0-next.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/812.js +1 -1
- package/dist/{339.js → 925.js} +1 -1
- package/dist/925.js.map +1 -0
- package/dist/ampath-esm-reports-app.js.buildmanifest.json +26 -26
- package/dist/main.js +1 -1
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/reports/moh-706/moh-706.component.tsx +95 -24
- package/src/reports/moh-706/sub-reports/bacteriology/bacteriology.component.tsx +7 -3
- package/src/reports/moh-706/sub-reports/blood-chemistry/blood-chemistry.component.tsx +45 -41
- package/src/reports/moh-706/sub-reports/haematology/haematology.component.tsx +16 -12
- package/src/reports/moh-706/sub-reports/parasitology/parasitology.component.tsx +18 -14
- package/src/reports/moh-706/sub-reports/serology/serology.component.tsx +15 -11
- package/src/reports/moh-706/sub-reports/urine-analysis/urine-analysis.component.tsx +22 -18
- package/src/reports/moh-740/moh-740.resource.ts +2 -1
- package/src/reports/table-wrapper/table-row-mapper.component.tsx +4 -3
- package/src/resources/moh-706.resource.ts +43 -0
- package/src/utils/utils.ts +30 -1
- package/dist/339.js.map +0 -1
|
@@ -3,7 +3,11 @@ import TableWrapper from "../../../table-wrapper/table-wrapper.component";
|
|
|
3
3
|
import TableRowMapper from "../../../table-wrapper/table-row-mapper.component";
|
|
4
4
|
import { getCell } from "../../../../utils/utils";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
interface UrineAnalysisProps {
|
|
7
|
+
data?: any
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const UrineAnalysis: React.FC<UrineAnalysisProps> = ({ data }) => {
|
|
7
11
|
const tableRows = useMemo(() => {
|
|
8
12
|
return [
|
|
9
13
|
{
|
|
@@ -22,29 +26,29 @@ const UrineAnalysis: React.FC = () => {
|
|
|
22
26
|
{
|
|
23
27
|
tableCells: [
|
|
24
28
|
getCell("", "1.1 Urine Chemistry", 1, 1, true),
|
|
25
|
-
getCell(),
|
|
26
|
-
getCell(),
|
|
29
|
+
getCell("total_urinalysis"),
|
|
30
|
+
getCell("positive_urinalysis"),
|
|
27
31
|
]
|
|
28
32
|
},
|
|
29
33
|
{
|
|
30
34
|
tableCells: [
|
|
31
35
|
getCell("", "1.2 Glucose", 1, 1, false),
|
|
32
|
-
getCell(),
|
|
33
|
-
getCell(),
|
|
36
|
+
getCell("total_urine_glucose"),
|
|
37
|
+
getCell("positive_urine_glucose"),
|
|
34
38
|
]
|
|
35
39
|
},
|
|
36
40
|
{
|
|
37
41
|
tableCells: [
|
|
38
42
|
getCell("", "1.3 Ketones", 1, 1, false),
|
|
39
|
-
getCell(),
|
|
40
|
-
getCell(),
|
|
43
|
+
getCell("total_urine_ketones"),
|
|
44
|
+
getCell("positive_urine_ketones"),
|
|
41
45
|
]
|
|
42
46
|
},
|
|
43
47
|
{
|
|
44
48
|
tableCells: [
|
|
45
49
|
getCell("", "1.4 Proteins", 1, 1, false),
|
|
46
|
-
getCell(),
|
|
47
|
-
getCell(),
|
|
50
|
+
getCell("total_urine_proteins"),
|
|
51
|
+
getCell("positive_urine_proteins"),
|
|
48
52
|
]
|
|
49
53
|
},
|
|
50
54
|
{
|
|
@@ -57,29 +61,29 @@ const UrineAnalysis: React.FC = () => {
|
|
|
57
61
|
{
|
|
58
62
|
tableCells: [
|
|
59
63
|
getCell("", "1.6 Pus cells (>5/hpf)", 1, 1, false),
|
|
60
|
-
getCell(),
|
|
61
|
-
getCell(),
|
|
64
|
+
getCell("total_urine_pus_cells"),
|
|
65
|
+
getCell("positive_urine_pus_cells"),
|
|
62
66
|
]
|
|
63
67
|
},
|
|
64
68
|
{
|
|
65
69
|
tableCells: [
|
|
66
70
|
getCell("", "1.7 Shistosoma haematobium", 1, 1, false),
|
|
67
|
-
getCell(),
|
|
68
|
-
getCell(),
|
|
71
|
+
getCell("total_urine_s_haematobium"),
|
|
72
|
+
getCell("positive_urine_s_haematobium"),
|
|
69
73
|
]
|
|
70
74
|
},
|
|
71
75
|
{
|
|
72
76
|
tableCells: [
|
|
73
77
|
getCell("", "1.8 Trichomona vaginalis", 1, 1, false),
|
|
74
|
-
getCell(),
|
|
75
|
-
getCell(),
|
|
78
|
+
getCell("total_urine_t_vaginalis"),
|
|
79
|
+
getCell("positive_urine_t_vaginalis"),
|
|
76
80
|
]
|
|
77
81
|
},
|
|
78
82
|
{
|
|
79
83
|
tableCells: [
|
|
80
84
|
getCell("", "1.9 Yeast cells", 1, 1, false),
|
|
81
|
-
getCell(),
|
|
82
|
-
getCell(),
|
|
85
|
+
getCell("total_urine_yeast_cells"),
|
|
86
|
+
getCell("positive_urine_yeast_cells"),
|
|
83
87
|
]
|
|
84
88
|
},
|
|
85
89
|
{
|
|
@@ -94,7 +98,7 @@ const UrineAnalysis: React.FC = () => {
|
|
|
94
98
|
|
|
95
99
|
|
|
96
100
|
return <TableWrapper>
|
|
97
|
-
<TableRowMapper tableRows={tableRows} />
|
|
101
|
+
<TableRowMapper tableRows={tableRows} data={data} />
|
|
98
102
|
</TableWrapper>
|
|
99
103
|
}
|
|
100
104
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { openmrsFetch } from '@openmrs/esm-framework';
|
|
1
2
|
import { getEtlBaseUrl } from '../../utils/get-base-url';
|
|
2
3
|
import { type Moh740Resp, type Moh740Dto, type Moh740Data } from './types';
|
|
3
4
|
|
|
4
5
|
export async function fetchMoh740Report(params: Moh740Dto): Promise<Moh740Data> {
|
|
5
6
|
const etlBaseUrl = await getEtlBaseUrl();
|
|
6
7
|
const moh740Url = `${etlBaseUrl}/moh-740-report?endDate=${params.endDate}&locationUuids=${params.locationUuid}`;
|
|
7
|
-
const resp = await
|
|
8
|
+
const resp = await openmrsFetch(moh740Url);
|
|
8
9
|
const data: Moh740Resp = await resp.json();
|
|
9
10
|
if (data && data.result) {
|
|
10
11
|
return data.result[0];
|
|
@@ -13,10 +13,11 @@ interface TableRowMapperProps {
|
|
|
13
13
|
rowSpan: number;
|
|
14
14
|
}>
|
|
15
15
|
}[],
|
|
16
|
-
data?: any
|
|
16
|
+
data?: any,
|
|
17
|
+
redirectTo?: string
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
const TableRowMapper: React.FC<TableRowMapperProps> = ({ tableRows, data }) => {
|
|
20
|
+
const TableRowMapper: React.FC<TableRowMapperProps> = ({ tableRows, data, redirectTo = "home/reports/moh-240" }) => {
|
|
20
21
|
return <>
|
|
21
22
|
{tableRows.map((tR) => (
|
|
22
23
|
<TableRow>
|
|
@@ -25,7 +26,7 @@ const TableRowMapper: React.FC<TableRowMapperProps> = ({ tableRows, data }) => {
|
|
|
25
26
|
|
|
26
27
|
const onClick = () => {
|
|
27
28
|
if (!tC.label) {
|
|
28
|
-
navigate({ to:
|
|
29
|
+
navigate({ to: redirectTo });
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
32
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { openmrsFetch } from '@openmrs/esm-framework';
|
|
2
|
+
import { getEtlBaseUrl } from '../utils/get-base-url';
|
|
3
|
+
|
|
4
|
+
interface Moh706Params {
|
|
5
|
+
locationUuids: string;
|
|
6
|
+
startDate?: string;
|
|
7
|
+
endDate?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface Moh706Response {
|
|
11
|
+
result: Array<Record<string, unknown>>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function getMoh706(params: Moh706Params): Promise<Array<Record<string, unknown>>> {
|
|
15
|
+
const etlBaseUrl = await getEtlBaseUrl();
|
|
16
|
+
const url = `${etlBaseUrl}/lab-706`;
|
|
17
|
+
const queryparams = {
|
|
18
|
+
locationUuids: params.locationUuids || '',
|
|
19
|
+
startDate: params.startDate || '',
|
|
20
|
+
endDate: params.endDate || '',
|
|
21
|
+
};
|
|
22
|
+
const queryString = new URLSearchParams(
|
|
23
|
+
Object.fromEntries(Object.entries(queryparams).filter(([_, v]) => v !== undefined && v !== null)),
|
|
24
|
+
).toString();
|
|
25
|
+
try {
|
|
26
|
+
const response = await openmrsFetch(`${url}?${queryString}`);
|
|
27
|
+
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
const errorText = await response.text();
|
|
30
|
+
throw new Error(`Failed to fetch MOH-706 report: ${response.status} - ${errorText}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const data = await response.json();
|
|
34
|
+
|
|
35
|
+
if (!Array.isArray(data.result)) {
|
|
36
|
+
throw new Error('Invalid MOH-706 response format: missing result array.');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return data.result;
|
|
40
|
+
} catch (error: any) {
|
|
41
|
+
throw new Error(`An error occurred while fetching the MOH-706 report: ${error.message}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
package/src/utils/utils.ts
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
1
|
+
import { openmrsFetch } from '@openmrs/esm-framework';
|
|
2
|
+
|
|
1
3
|
export const getCell = (key = "", label = "", colSpan = 1, rowSpan = 1, strong = false) => ({
|
|
2
4
|
key,
|
|
3
5
|
label,
|
|
4
6
|
strong,
|
|
5
7
|
colSpan,
|
|
6
8
|
rowSpan
|
|
7
|
-
});
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export async function getJson<T>(url: string, payload: Record<string, unknown> | null = null): Promise<T> {
|
|
12
|
+
let requestUrl = url;
|
|
13
|
+
|
|
14
|
+
if (payload && Object.keys(payload).length > 0) {
|
|
15
|
+
const queryString = new URLSearchParams(
|
|
16
|
+
Object.entries(payload).filter(([, value]) => value !== undefined && value !== null) as Array<[string, string]>,
|
|
17
|
+
).toString();
|
|
18
|
+
|
|
19
|
+
if (queryString) {
|
|
20
|
+
requestUrl = `${url}?${queryString}`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const response = await openmrsFetch(requestUrl);
|
|
25
|
+
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
const errorText = await response.text();
|
|
28
|
+
throw new Error(`Request failed with ${response.status}: ${errorText}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (response.status === 204 || response.headers.get('content-length') === '0') {
|
|
32
|
+
return Promise.resolve({} as T);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return response.json() as Promise<T>;
|
|
36
|
+
}
|