@pih/esm-pathology-app 1.0.3 → 1.0.6
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/package.json +21 -10
- package/src/Fonts/georgia/GEORGIA4.TTF +0 -0
- package/src/Fonts/georgia/Georgia Bold Italic font.ttf +0 -0
- package/src/Fonts/georgia/Georgia Regular font.ttf +0 -0
- package/src/Fonts/georgia/Georgia.ttf +0 -0
- package/src/Fonts/georgia/georgia bold italic.ttf +0 -0
- package/src/Fonts/georgia/georgia italic.ttf +0 -0
- package/src/Fonts/georgia/georgia-bold.ttf +0 -0
- package/src/Fonts/georgia/georgiab.ttf +0 -0
- package/src/Fonts/georgia/georgiai.ttf +0 -0
- package/src/Fonts/georgia/georgiaz.ttf +0 -0
- package/src/Fonts/georgia/seriffic.ttf +0 -0
- package/src/Fonts/georgia/sharefonts.net.txt +1 -0
- package/src/Print-to-PDF/Document-Component.tsx +296 -0
- package/src/config-schema.ts +105 -6
- package/src/declarations.d.tsx +3 -0
- package/src/images/ButaroHospitalLogo.gif +0 -0
- package/src/pathology-report/ReportComponent.resource.ts +37 -34
- package/src/pathology-report/ReportComponent.tsx +32 -10
- package/src/test.html +0 -0
- package/webpack.config.js +30 -1
- package/dist/574.pih-esm-pathology-app.js +0 -1
- package/dist/633.pih-esm-pathology-app.js +0 -3
- package/dist/633.pih-esm-pathology-app.js.LICENSE.txt +0 -29
- package/dist/633.pih-esm-pathology-app.js.map +0 -1
- package/dist/66.pih-esm-pathology-app.js +0 -2
- package/dist/66.pih-esm-pathology-app.js.map +0 -1
- package/dist/pih-esm-pathology-app.js +0 -2
- package/dist/pih-esm-pathology-app.js.buildmanifest.json +0 -100
- package/dist/pih-esm-pathology-app.js.map +0 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { openmrsFetch } from "@openmrs/esm-framework";
|
|
2
|
+
import cloneDeep from "lodash-es/cloneDeep";
|
|
3
|
+
|
|
2
4
|
|
|
3
5
|
export interface EncounterResult {
|
|
4
6
|
family_name: string;
|
|
@@ -15,6 +17,11 @@ export interface EncounterResult {
|
|
|
15
17
|
referralStatusObs: string;
|
|
16
18
|
sampleDropoffObs: string;
|
|
17
19
|
resultsEncounterId: string;
|
|
20
|
+
resultsEncounterUuid: string;
|
|
21
|
+
resultsEncounter: [];
|
|
22
|
+
approvedBy: string;
|
|
23
|
+
approvalObsUuid: string;
|
|
24
|
+
pathologicDiagnosisObs: string;
|
|
18
25
|
}
|
|
19
26
|
export interface Patient {
|
|
20
27
|
uuid: string;
|
|
@@ -24,6 +31,7 @@ export interface Concept {
|
|
|
24
31
|
name: string;
|
|
25
32
|
display: string;
|
|
26
33
|
}
|
|
34
|
+
|
|
27
35
|
export interface Obs {
|
|
28
36
|
patientUuid: string;
|
|
29
37
|
obsDateTime: string;
|
|
@@ -34,35 +42,9 @@ export interface Obs {
|
|
|
34
42
|
encounterUuid: string;
|
|
35
43
|
valueCodedName: string;
|
|
36
44
|
voided: boolean;
|
|
45
|
+
resultsEncounterUuid: string;
|
|
37
46
|
}
|
|
38
47
|
|
|
39
|
-
// export async function getPatientEncounters(patientUuid): Promise<Array<EncounterResult>> {
|
|
40
|
-
// const searchPatientEncounters = await openmrsFetch(
|
|
41
|
-
// `/ws/rest/v1/encounter?encounterType=${ENCOUNTERTYPEUUID}&patient=${patientUuid}`,
|
|
42
|
-
// );
|
|
43
|
-
// const fullPatientEncounterData = searchPatientEncounters.data.results.map(async (searchEnc) => {
|
|
44
|
-
// const enc = await openmrsFetch(`/ws/rest/v1/encounter/${searchEnc.uuid}?v=full`);
|
|
45
|
-
// const searchPatient = await openmrsFetch(`/ws/rest/v1/patient/${patientUuid}?v=full`);
|
|
46
|
-
// const retrievedObject = {
|
|
47
|
-
// patientName: searchPatient.data.person.names[0],
|
|
48
|
-
// patientPhoneNumber: searchPatient.data.person.attributes.filter(
|
|
49
|
-
// (attribute) => attribute.attributeType.uuid == PHONENUMBERATTRUUID,
|
|
50
|
-
// )[0],
|
|
51
|
-
// patientHealthCenter: searchPatient.data.person.attributes.filter(
|
|
52
|
-
// (attribute) => attribute.attributeType.uuid == HEALTHCENTERATTRTYPEUUID,
|
|
53
|
-
// )[0],
|
|
54
|
-
// patientUuid: searchPatient.data.uuid,
|
|
55
|
-
// encUuid: enc.data.uuid,
|
|
56
|
-
// encounterDatetime: enc.data.encounterDatetime,
|
|
57
|
-
// sampleStatusObs: enc.data.obs.filter((obs) => obs.concept.uuid === SAMPLESTATUSUUID)[0],
|
|
58
|
-
// referralStatusObs: enc.data.obs.filter((obs) => obs.concept.uuid === REFERRALSTATUSUUID)[0],
|
|
59
|
-
// sampleDropoffObs: enc.data.obs.filter((obs) => obs.concept.uuid === SAMPLEDROPOFFUUID)[0],
|
|
60
|
-
// };
|
|
61
|
-
|
|
62
|
-
// return retrievedObject;
|
|
63
|
-
// });
|
|
64
|
-
// return Promise.all(fullPatientEncounterData);
|
|
65
|
-
// }
|
|
66
48
|
|
|
67
49
|
export async function getUserLocation(healthCenterAttrTypeUUID) {
|
|
68
50
|
const session = await openmrsFetch(`/ws/rest/v1/session`);
|
|
@@ -73,7 +55,7 @@ export async function getUserLocation(healthCenterAttrTypeUUID) {
|
|
|
73
55
|
const hcPersonAttribute = person.data.results.filter(
|
|
74
56
|
(attr) => attr.attributeType.uuid === healthCenterAttrTypeUUID
|
|
75
57
|
);
|
|
76
|
-
return hcPersonAttribute[0]
|
|
58
|
+
return hcPersonAttribute[0] && hcPersonAttribute[0].value.uuid;
|
|
77
59
|
}
|
|
78
60
|
|
|
79
61
|
export async function getConceptAnswers(conceptUuid) {
|
|
@@ -89,11 +71,6 @@ export async function getLocations() {
|
|
|
89
71
|
return location.data.results;
|
|
90
72
|
}
|
|
91
73
|
|
|
92
|
-
// export async function getPatient(patientUuid): Promise<Patient> {
|
|
93
|
-
// const searchPatient = await openmrsFetch(`/ws/rest/v1/patient/c604dabc-2700-102b-80cb-0017a47871b2?v=full`);
|
|
94
|
-
// return searchPatient.data;
|
|
95
|
-
// }
|
|
96
|
-
|
|
97
74
|
export async function getEncounters(
|
|
98
75
|
healthCenterAttrTypeUUID: string,
|
|
99
76
|
pathologyFullAllowedLocationUUID: string
|
|
@@ -113,7 +90,20 @@ export async function getEncounters(
|
|
|
113
90
|
`/ws/rest/v1/reportingrest/reportdata/996cf192-ff54-11eb-a63a-080027ce9ca0`
|
|
114
91
|
);
|
|
115
92
|
}
|
|
116
|
-
|
|
93
|
+
|
|
94
|
+
const EncListClone = searchEncounter.data.dataSets[0].rows.map(async (encObject)=>{
|
|
95
|
+
if(encObject.resultsEncounterUuid){
|
|
96
|
+
const encIndex = searchEncounter.data.dataSets[0].rows.findIndex(
|
|
97
|
+
(enc) => enc.encounterUuid == encObject.encounterUuid
|
|
98
|
+
);
|
|
99
|
+
const resultsEnc =await getEncounter(encObject.resultsEncounterUuid);
|
|
100
|
+
encObject.resultsEncounter = resultsEnc;
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
return encObject;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return Promise.all(EncListClone);
|
|
117
107
|
}
|
|
118
108
|
|
|
119
109
|
export async function postSampleDropoffObs(
|
|
@@ -274,3 +264,16 @@ export async function updateReferralStatusChangeObs(
|
|
|
274
264
|
|
|
275
265
|
return response;
|
|
276
266
|
}
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
export async function getUser(userUuid: string) {
|
|
271
|
+
const user = await openmrsFetch(`/ws/rest/v1/user/${userUuid}`);
|
|
272
|
+
|
|
273
|
+
return user.data;
|
|
274
|
+
}
|
|
275
|
+
export async function getEncounter(encounterUuid) {
|
|
276
|
+
const encResult = await openmrsFetch(`/ws/rest/v1/encounter/${encounterUuid}?v=full`);
|
|
277
|
+
|
|
278
|
+
return encResult.data;
|
|
279
|
+
}
|
|
@@ -9,6 +9,7 @@ import DataTable, {
|
|
|
9
9
|
TableBody,
|
|
10
10
|
TableCell,
|
|
11
11
|
} from "carbon-components-react/es/components/DataTable";
|
|
12
|
+
import { PDFDownloadLink, PDFViewer } from "@react-pdf/renderer";
|
|
12
13
|
|
|
13
14
|
import styles from "./ReportComponent.css";
|
|
14
15
|
import {
|
|
@@ -23,8 +24,11 @@ import {
|
|
|
23
24
|
postReferralStatusChangeObs,
|
|
24
25
|
updateReferralStatusChangeObs,
|
|
25
26
|
EncounterResult,
|
|
27
|
+
getUser,
|
|
26
28
|
Concept,
|
|
29
|
+
getEncounter,
|
|
27
30
|
} from "./ReportComponent.resource";
|
|
31
|
+
import MyDocument from "../Print-to-PDF/Document-Component";
|
|
28
32
|
import { Config } from "../config-schema";
|
|
29
33
|
|
|
30
34
|
const ReportComponent = () => {
|
|
@@ -77,10 +81,18 @@ const ReportComponent = () => {
|
|
|
77
81
|
key: "sampleDropOff",
|
|
78
82
|
header: "Sample drop off?",
|
|
79
83
|
},
|
|
84
|
+
{
|
|
85
|
+
key: "pathologicDiagnosisObs",
|
|
86
|
+
header: "Pathologic diagnosis",
|
|
87
|
+
},
|
|
80
88
|
{
|
|
81
89
|
key: "resultsEncounter",
|
|
82
90
|
header: "Results",
|
|
83
91
|
},
|
|
92
|
+
{
|
|
93
|
+
key: "PDFReport",
|
|
94
|
+
header: "Report",
|
|
95
|
+
},
|
|
84
96
|
];
|
|
85
97
|
|
|
86
98
|
React.useEffect(() => {
|
|
@@ -129,17 +141,9 @@ const ReportComponent = () => {
|
|
|
129
141
|
);
|
|
130
142
|
}
|
|
131
143
|
});
|
|
132
|
-
//replace(/\s+/g, '');
|
|
133
|
-
// const rows = filteredEncList.map(
|
|
134
|
-
// (encounterInfo) => {
|
|
135
|
-
// return {
|
|
136
|
-
// // patientLink: <a href={`/openmrs/patientDashboard.form?patientId=${encounterInfo.personId}`} >Link</a>,
|
|
137
|
-
// ...
|
|
138
144
|
|
|
139
145
|
const rows = filteredEncList.map((encounterInfo) => {
|
|
140
146
|
return {
|
|
141
|
-
// rows.push({
|
|
142
|
-
// patientLink: <a href={`/openmrs/patientDashboard.form?patientId=${encounterInfo.personId}`} >Link</a>,
|
|
143
147
|
id: encounterInfo.encounterId,
|
|
144
148
|
patientNames: (
|
|
145
149
|
<a
|
|
@@ -192,7 +196,10 @@ const ReportComponent = () => {
|
|
|
192
196
|
))}
|
|
193
197
|
</select>
|
|
194
198
|
),
|
|
195
|
-
dateOfRequest: encounterInfo.encounterDatetime
|
|
199
|
+
dateOfRequest: new Date(encounterInfo.encounterDatetime).toLocaleString(
|
|
200
|
+
["en-GB", "en-US", "en", "fr-RW"],
|
|
201
|
+
{ day: "numeric", month: "numeric", year: "numeric" }
|
|
202
|
+
),
|
|
196
203
|
referralStatus: (
|
|
197
204
|
<select
|
|
198
205
|
onChange={(e) =>
|
|
@@ -228,6 +235,7 @@ const ReportComponent = () => {
|
|
|
228
235
|
onChange={(e) => sampleDropOffChange(encounterInfo)}
|
|
229
236
|
/>
|
|
230
237
|
),
|
|
238
|
+
pathologicDiagnosisObs: encounterInfo.pathologicDiagnosisObs,
|
|
231
239
|
resultsEncounter: encounterInfo.resultsEncounterId ? (
|
|
232
240
|
<a
|
|
233
241
|
data-testid="resultsEncounter"
|
|
@@ -247,6 +255,19 @@ const ReportComponent = () => {
|
|
|
247
255
|
</a>
|
|
248
256
|
)
|
|
249
257
|
),
|
|
258
|
+
PDFReport: encounterInfo.resultsEncounterId &&
|
|
259
|
+
encounterInfo.approvedBy && (
|
|
260
|
+
<PDFDownloadLink
|
|
261
|
+
document={
|
|
262
|
+
<MyDocument encounterInfo={encounterInfo} config={config} />
|
|
263
|
+
}
|
|
264
|
+
fileName="Pathology Report"
|
|
265
|
+
>
|
|
266
|
+
{({ loading }) =>
|
|
267
|
+
loading ? "loading..." : <button>Download</button>
|
|
268
|
+
}
|
|
269
|
+
</PDFDownloadLink>
|
|
270
|
+
),
|
|
250
271
|
};
|
|
251
272
|
});
|
|
252
273
|
|
|
@@ -276,7 +297,6 @@ const ReportComponent = () => {
|
|
|
276
297
|
);
|
|
277
298
|
tempEncList[encIndex].sampleDropoffObs = "";
|
|
278
299
|
tempEncList[encIndex].sampleDropoffObsUuid = "";
|
|
279
|
-
|
|
280
300
|
setEncountersList(tempEncList);
|
|
281
301
|
}
|
|
282
302
|
});
|
|
@@ -436,6 +456,7 @@ const ReportComponent = () => {
|
|
|
436
456
|
onChange={(e) => setPatientName(e.target.value)}
|
|
437
457
|
/>
|
|
438
458
|
</div>
|
|
459
|
+
{console.log(encountersList)}
|
|
439
460
|
<div className={styles.tableContainer}>
|
|
440
461
|
<DataTable rows={rows} headers={headers}>
|
|
441
462
|
{({ rows, headers, getTableProps, getHeaderProps, getRowProps }) => (
|
|
@@ -462,6 +483,7 @@ const ReportComponent = () => {
|
|
|
462
483
|
)}
|
|
463
484
|
</DataTable>
|
|
464
485
|
</div>
|
|
486
|
+
<div></div>
|
|
465
487
|
</div>
|
|
466
488
|
);
|
|
467
489
|
};
|
package/src/test.html
ADDED
|
File without changes
|
package/webpack.config.js
CHANGED
|
@@ -1 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
const config = require("openmrs/default-webpack-config");
|
|
3
|
+
const webpack = require("webpack");
|
|
4
|
+
|
|
5
|
+
config.additionalConfig.resolve = {
|
|
6
|
+
fallback: {
|
|
7
|
+
process: require.resolve("process/browser"),
|
|
8
|
+
zlib: require.resolve("browserify-zlib"),
|
|
9
|
+
stream: require.resolve("stream-browserify"),
|
|
10
|
+
util: require.resolve("util"),
|
|
11
|
+
buffer: require.resolve("buffer"),
|
|
12
|
+
asset: require.resolve("assert"),
|
|
13
|
+
},
|
|
14
|
+
}
|
|
15
|
+
config.additionalConfig.plugins = [
|
|
16
|
+
new webpack.ProvidePlugin({
|
|
17
|
+
Buffer: ["buffer", "Buffer"],
|
|
18
|
+
process: "process/browser",
|
|
19
|
+
}),
|
|
20
|
+
]
|
|
21
|
+
config.additionalConfig.module= {
|
|
22
|
+
rules:[
|
|
23
|
+
{
|
|
24
|
+
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
25
|
+
type: 'asset/resource',
|
|
26
|
+
},
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
module.exports = config;
|
|
30
|
+
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_pih_esm_pathology_app=self.webpackChunk_pih_esm_pathology_app||[]).push([[574],{574:p=>{p.exports={}}}]);
|