-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdummy-triage-service.js
94 lines (80 loc) · 3.09 KB
/
dummy-triage-service.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const pdfCreator = require('pdf-creator-node');
const fs = require('fs');
const path = require("path");
const config = require('../../env-variables');
class TriageService {
async upsertTriageDetails(person, triage) {
// Nothing to return
console.log('Upsert Triage');
console.log(JSON.stringify(triage));
}
async getTriageDetailsForPerson(person) {
const userData = {
"uuid": "9f9896c6-1e9f-4d8b-ac5a-0163670f0bf8",
"c19_triage": {
"created_at": "2021-04-23T17:04:16.978548+00:00",
"comorbidities": "true",
"rt_pcr_status": null,
"symptoms": null
},
"c19_vitals": [
{
"created_at": "2021-04-23T17:28:16.359211+00:00",
"spo2": "good",
"temperature": "bad"
},
{
"created_at": "2021-04-27T15:01:21.462757+00:00",
"spo2": "bad",
"temperature": "good"
}
]
}
return userData;
}
async downloadReportForPerson(person, locale) {
const html = fs.readFileSync(path.resolve(__dirname, "../../../resources/pdf-template-download-report.html")).toString()
const options = {
format: "A3",
orientation: "portrait",
border: "10mm",
header: {
height: "45mm",
contents: '<div style="text-align: center;">Vitals</div>'
}
};
const userData = await this.getTriageDetailsForPerson(person);
const c19_vitals = JSON.parse(JSON.stringify(userData.c19_vitals));
c19_vitals.forEach(vital => {
vital.created_date = new Date(vital.created_at).toDateString();
vital.created_time = new Date(vital.created_at).toLocaleTimeString()
});
const variables = {
person: {
first_name: person.first_name,
gender: person.gender,
age: person.age
},
c19_triage: {
...userData.c19_triage,
'hasComorbidities': userData.c19_triage.comorbidities == 'true' ? 'Yes' : 'No',
'hasSymptoms': userData.c19_triage.symptoms == 'true' ? 'Yes' : 'No',
'created_date': new Date(userData.c19_triage.created_at).toDateString()
},
c19_vitals: c19_vitals
};
const today = new Date().toDateString();
const filePath = `${config.dynamicMediaPath}/${person.first_name}-vitals-report-${today}.pdf`;
const document = {
html: html,
data: variables,
path: path.resolve(__dirname, `../../../${filePath}`),
type: "pdf",
};
await pdfCreator.create(document, options)
return filePath;
}
async exitProgram(person, exitSlots) {
}
}
module.exports = new TriageService();