@measurequick/measurequick-report-generator 1.4.78 → 1.5.1
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/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import * as photosReportS3 from "./report-gen-scripts/photos-report-s3.js";
|
|
|
8
8
|
import * as ptcsHeatPumpReport from "./report-gen-scripts/ptcs-heat-pump-report.js";
|
|
9
9
|
import * as vitalsCoolingReport from "./report-gen-scripts/vitals-cooling-report.js";
|
|
10
10
|
import * as vitalsHeatingReport from "./report-gen-scripts/vitals-heating-report.js";
|
|
11
|
-
import * as ductScreeningReport from "./report-gen-scripts/
|
|
11
|
+
import * as ductScreeningReport from "./report-gen-scripts/nci-report.js";
|
|
12
12
|
import * as bluvacReport from "./report-gen-scripts/bluvac-report.js";
|
|
13
13
|
import * as classicReport from "./report-gen-scripts/classic-report.js";
|
|
14
14
|
import * as accaCertificate from "./report-gen-scripts/acca-certificate.js";
|
|
@@ -27,7 +27,8 @@ export function getReport(payload) {
|
|
|
27
27
|
case "PtcsHeatPumpReport": return ptcsHeatPumpReport.getReport(payload);
|
|
28
28
|
case "VitalsCoolingReport": return vitalsCoolingReport.getReport(payload, false);
|
|
29
29
|
case "VitalsHeatingReport": return vitalsHeatingReport.getReport(payload, false);
|
|
30
|
-
case "DuctScreeningReport":
|
|
30
|
+
case "DuctScreeningReport":
|
|
31
|
+
case "NCIReport": return ductScreeningReport.getReport(payload, false);
|
|
31
32
|
case "BluVacReport": return bluvacReport.getReport(payload);
|
|
32
33
|
case "ClassicReport": return classicReport.getReport(payload);
|
|
33
34
|
case "AccaVeoCertificate":
|
package/package.json
CHANGED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { PDFDocument } from 'pdf-lib';
|
|
2
|
+
import * as base64 from '../base-64/icons.js';
|
|
3
|
+
import * as pdf from '../base-64/nci-report.js';
|
|
4
|
+
import * as systemInfoPage from './system-info-page.js';
|
|
5
|
+
import * as util from '../util.js';
|
|
6
|
+
|
|
7
|
+
export async function getReport(payload, _test) {
|
|
8
|
+
try {
|
|
9
|
+
// fetch and load form
|
|
10
|
+
const formPdfBytes = util._base64ToArrayBuffer(pdf.base64);
|
|
11
|
+
const pdfDoc = await PDFDocument.load(formPdfBytes);
|
|
12
|
+
|
|
13
|
+
// fetch resources
|
|
14
|
+
const iconRangeGreenBytes = util._base64ToArrayBuffer(base64.iconRangeGreen);
|
|
15
|
+
const iconRangeRedBytes = util._base64ToArrayBuffer(base64.iconRangeRed);
|
|
16
|
+
const iconFlagBlackBytes = util._base64ToArrayBuffer(base64.iconFlagBlack);
|
|
17
|
+
const iconFlagGreenBytes = util._base64ToArrayBuffer(base64.iconFlagGreen);
|
|
18
|
+
const iconFlagRedBytes = util._base64ToArrayBuffer(base64.iconFlagRed);
|
|
19
|
+
const iconFlagYellowBytes = util._base64ToArrayBuffer(base64.iconFlagYellow);
|
|
20
|
+
const iconStabilityBytes = util._base64ToArrayBuffer(base64.iconStability);
|
|
21
|
+
const iconThumbprintGreenBytes = util._base64ToArrayBuffer(base64.iconThumbprintGreen);
|
|
22
|
+
const iconThumbprintRedBytes = util._base64ToArrayBuffer(base64.iconThumbprintRed);
|
|
23
|
+
const mqLogoBytes = util._base64ToArrayBuffer(base64.mqLogo);
|
|
24
|
+
|
|
25
|
+
// load resources
|
|
26
|
+
const iconRangeGreen = await pdfDoc.embedPng(iconRangeGreenBytes);
|
|
27
|
+
const iconRangeRed = await pdfDoc.embedPng(iconRangeRedBytes);
|
|
28
|
+
const iconFlagBlack = await pdfDoc.embedPng(iconFlagBlackBytes);
|
|
29
|
+
const iconFlagGreen = await pdfDoc.embedPng(iconFlagGreenBytes);
|
|
30
|
+
const iconFlagRed = await pdfDoc.embedPng(iconFlagRedBytes);
|
|
31
|
+
const iconFlagYellow = await pdfDoc.embedPng(iconFlagYellowBytes);
|
|
32
|
+
const iconStability = await pdfDoc.embedPng(iconStabilityBytes);
|
|
33
|
+
const iconThumbprintGreen = await pdfDoc.embedPng(iconThumbprintGreenBytes);
|
|
34
|
+
const iconThumbprintRed = await pdfDoc.embedPng(iconThumbprintRedBytes);
|
|
35
|
+
const mqLogo = await pdfDoc.embedPng(mqLogoBytes);
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
//Setup fields
|
|
39
|
+
let filter_pressure_drop = 1,
|
|
40
|
+
return_pressure_drop = 2,
|
|
41
|
+
coil_pressure_drop = 3,
|
|
42
|
+
supply_pressure = 4,
|
|
43
|
+
test = payload&&payload.test ? payload.test : {};
|
|
44
|
+
|
|
45
|
+
if (test.ductScreeningSystemType === 'Package Draw Through' && test.ductScreeningFilterLocation === 'Grille'){
|
|
46
|
+
filter_pressure_drop = 1,
|
|
47
|
+
return_pressure_drop = 2,
|
|
48
|
+
coil_pressure_drop = 3,
|
|
49
|
+
supply_pressure = 4;
|
|
50
|
+
} else if (test.ductScreeningSystemType === 'Package Draw Through' && test.ductScreeningFilterLocation === 'Slot'){
|
|
51
|
+
filter_pressure_drop = 2,
|
|
52
|
+
return_pressure_drop = 1,
|
|
53
|
+
coil_pressure_drop = 3,
|
|
54
|
+
supply_pressure = 4;
|
|
55
|
+
} else if (test.ductScreeningSystemType === 'Package Blow Through' && test.ductScreeningFilterLocation === 'Grille') {
|
|
56
|
+
filter_pressure_drop = 1,
|
|
57
|
+
return_pressure_drop = 2,
|
|
58
|
+
coil_pressure_drop = 3,
|
|
59
|
+
supply_pressure = 4;
|
|
60
|
+
} else if (test.ductScreeningSystemType === 'Package Blow Through' && test.ductScreeningFilterLocation === 'Slot') {
|
|
61
|
+
filter_pressure_drop = 2,
|
|
62
|
+
return_pressure_drop = 1,
|
|
63
|
+
coil_pressure_drop = 3,
|
|
64
|
+
supply_pressure = 4;
|
|
65
|
+
} else if (test.ductScreeningSystemType === 'AHU Draw Through' && test.ductScreeningFilterLocation === 'Grille'){
|
|
66
|
+
filter_pressure_drop = 1,
|
|
67
|
+
return_pressure_drop = 2,
|
|
68
|
+
coil_pressure_drop = 3,
|
|
69
|
+
supply_pressure = 4;
|
|
70
|
+
} else if (test.ductScreeningSystemType === 'AHU Draw Through' && test.ductScreeningFilterLocation === 'Slot'){
|
|
71
|
+
filter_pressure_drop = 2,
|
|
72
|
+
return_pressure_drop = 1,
|
|
73
|
+
coil_pressure_drop = 3,
|
|
74
|
+
supply_pressure = 4;
|
|
75
|
+
} else if (test.ductScreeningSystemType === 'AHU Blow Through' && test.ductScreeningFilterLocation === 'Grille'){
|
|
76
|
+
filter_pressure_drop = 1,
|
|
77
|
+
return_pressure_drop = 2,
|
|
78
|
+
coil_pressure_drop = 3,
|
|
79
|
+
supply_pressure = 4;
|
|
80
|
+
} else if (test.ductScreeningSystemType === 'AHU Blow Through' && test.ductScreeningFilterLocation === 'Slot'){
|
|
81
|
+
filter_pressure_drop = 2,
|
|
82
|
+
return_pressure_drop = 1,
|
|
83
|
+
coil_pressure_drop = 3,
|
|
84
|
+
supply_pressure = 4;
|
|
85
|
+
} else if (test.ductScreeningSystemType === 'Furnace' && test.ductScreeningFilterLocation === 'Grille'){
|
|
86
|
+
filter_pressure_drop = 1,
|
|
87
|
+
return_pressure_drop = 2,
|
|
88
|
+
coil_pressure_drop = 3,
|
|
89
|
+
supply_pressure = 4;
|
|
90
|
+
} else if (test.ductScreeningSystemType === 'Furnace' && test.ductScreeningFilterLocation === 'Slot'){
|
|
91
|
+
filter_pressure_drop = 2,
|
|
92
|
+
return_pressure_drop = 1,
|
|
93
|
+
coil_pressure_drop = 3,
|
|
94
|
+
supply_pressure = 4;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// embed company logo and profile picture
|
|
98
|
+
let profileImage, companyImage;
|
|
99
|
+
let profileImageType = util.checkProfilePicture(payload.meta);
|
|
100
|
+
let companyImageType = util.checkCompanyLogo(payload.meta);
|
|
101
|
+
if (profileImageType) {
|
|
102
|
+
if (profileImageType.shape == "square") profileImage = payload.meta.profile_settings.profilePicSquareBase64;
|
|
103
|
+
else if (profileImageType.shape == "circle") profileImage = payload.meta.profile_settings.profilePicCircleBase64;
|
|
104
|
+
if (profileImageType.type == "jpg") profileImage = await pdfDoc.embedJpg(util._base64ToArrayBuffer(profileImage));
|
|
105
|
+
else if (profileImageType.type == "png") profileImage = await pdfDoc.embedPng(util._base64ToArrayBuffer(profileImage));
|
|
106
|
+
}
|
|
107
|
+
if (companyImageType == "jpg") companyImage = await pdfDoc.embedJpg(util._base64ToArrayBuffer(payload.meta.profile_settings.companyLogoBase64));
|
|
108
|
+
else if (companyImageType == "png") companyImage = await pdfDoc.embedPng(util._base64ToArrayBuffer(payload.meta.profile_settings.companyLogoBase64));
|
|
109
|
+
|
|
110
|
+
const form = pdfDoc.getForm();
|
|
111
|
+
|
|
112
|
+
// print company logo and profile picture
|
|
113
|
+
if (profileImage) { // no company logo is embedded in the document
|
|
114
|
+
form.getButton("ProfilePicture").setImage(profileImage);
|
|
115
|
+
if (payload.meta.profile_settings.techFirstName || payload.meta.profile_settings.techLastName)
|
|
116
|
+
form.getTextField('TechName').setText(`${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
let date = test.datetime ? test.datetime : new Date();
|
|
120
|
+
if (payload.cName&&payload.address&&payload.city&&payload.state&&payload.zip){
|
|
121
|
+
form.getTextField('Name').setText(`${payload.cName}`);
|
|
122
|
+
form.getTextField('Address 1').setText(`${payload.address}`);
|
|
123
|
+
form.getTextField('Address 2').setText(`${payload.address2}`);
|
|
124
|
+
form.getTextField('City State Zip').setText(`${payload.city}, ${payload.state} ${payload.zip}`);
|
|
125
|
+
form.getTextField('Date of Service').setText(`${payload.address}`);
|
|
126
|
+
form.getTextField('Time of Service').setText(`${payload.address}`);
|
|
127
|
+
form.getTextField('DateOfServiceLabelUpper').setText("");
|
|
128
|
+
form.getTextField('TimeOfServiceLabelUpper').setText("");
|
|
129
|
+
form.getTextField('DateOfServiceLabelLower').setText("Date of Service:");
|
|
130
|
+
form.getTextField('TimeOfServiceLabelLower').setText("Time of Service:");
|
|
131
|
+
form.getTextField('DateOfServiceLower').setText(date.toLocaleDateString("en-US"));
|
|
132
|
+
form.getTextField('TimeOfServiceLower').setText(date.toLocaleTimeString("en-US"));
|
|
133
|
+
} else if (companyImage){
|
|
134
|
+
form.getButton("CompanyLogo").setImage(companyImage);
|
|
135
|
+
form.getTextField('DateOfServiceLabelUpper').setText("");
|
|
136
|
+
form.getTextField('TimeOfServiceLabelUpper').setText("");
|
|
137
|
+
form.getTextField('DateOfServiceLabelLower').setText("Date of Service:");
|
|
138
|
+
form.getTextField('TimeOfServiceLabelLower').setText("Time of Service:");
|
|
139
|
+
form.getTextField('DateOfServiceLower').setText(date.toLocaleDateString("en-US"));
|
|
140
|
+
form.getTextField('TimeOfServiceLower').setText(date.toLocaleTimeString("en-US"));
|
|
141
|
+
} else { //no address or company logo.. place date and time at the top
|
|
142
|
+
form.getTextField('DateOfServiceLabelLower').setText("");
|
|
143
|
+
form.getTextField('TimeOfServiceLabelLower').setText("");
|
|
144
|
+
form.getTextField('DateOfServiceLabelUpper').setText("Date of Service:");
|
|
145
|
+
form.getTextField('TimeOfServiceLabelUpper').setText("Time of Service:");
|
|
146
|
+
form.getTextField('DateOfServiceUpper').setText(date.toLocaleDateString("en-US"));
|
|
147
|
+
form.getTextField('TimeOfServiceUpper').setText(date.toLocaleTimeString("en-US"));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
form.getTextField('HeaderText').setText(`Duct System Screening`);
|
|
151
|
+
|
|
152
|
+
if (test.ductScreeningResult === 'PASS'){
|
|
153
|
+
form.getTextField('TestResultGreen').setText(`PASS`);
|
|
154
|
+
} else if (test.ductScreeningResult === 'PASS<br>w/Recommendations'){
|
|
155
|
+
form.getTextField('TestResultYellow').setText(`PASS*`);
|
|
156
|
+
} else if (test.ductScreeningResult === 'FAIL'){
|
|
157
|
+
form.getTextField('TestResultRed').setText(`FAIL`);
|
|
158
|
+
}
|
|
159
|
+
//Not used//form.getTextField('TestResultOrange').setText(`PASS`);
|
|
160
|
+
|
|
161
|
+
//Airflow
|
|
162
|
+
if (test.ductScreeningAirflow){
|
|
163
|
+
form.getTextField('FanAirflow').setText(`${test.ductScreeningAirflow}`);
|
|
164
|
+
}
|
|
165
|
+
if (test.ductScreeningAirflowTarget){
|
|
166
|
+
form.getTextField('FanAirflowTarget').setText(`${test.ductScreeningAirflowTarget}`);
|
|
167
|
+
}
|
|
168
|
+
//Add logic here for which image
|
|
169
|
+
let meas = ""; //Low , High
|
|
170
|
+
if (test["ductScreeningAirflowResult"]&&test["ductScreeningAirflowResult"]!==1){
|
|
171
|
+
meas = test["ductScreeningAirflowResult"]===-1 ? 'Low' : 'High';
|
|
172
|
+
} else if (test["ductScreeningAirflowResult"]&&test["ductScreeningAirflowResult"]===1){
|
|
173
|
+
meas = 'Mid';
|
|
174
|
+
}
|
|
175
|
+
let icon = meas == "Mid" ? iconRangeGreen : iconRangeRed;
|
|
176
|
+
if (meas)
|
|
177
|
+
form.getButton('ImageFanAirflow'+meas).setImage(icon);
|
|
178
|
+
|
|
179
|
+
//TESP
|
|
180
|
+
if (test.ductScreeningTESP){
|
|
181
|
+
form.getTextField('TotalExternalStaticPressure').setText(`${test.ductScreeningTESP}`);
|
|
182
|
+
}
|
|
183
|
+
if (test.ductScreeningTESPTarget){
|
|
184
|
+
form.getTextField('TotalExternalStaticPressureTarget').setText(`${test.ductScreeningTESPTarget}`);
|
|
185
|
+
}
|
|
186
|
+
//Add logic here for which image
|
|
187
|
+
meas = "";
|
|
188
|
+
if (test["ductScreeningTESPResult"]&&test["ductScreeningTESPResult"]!==1){
|
|
189
|
+
meas = test["ductScreeningTESPResult"]===-1 ? 'Low' : 'High';
|
|
190
|
+
} else if (test["ductScreeningTESPResult"]&&test["ductScreeningTESPResult"]===1){
|
|
191
|
+
meas = 'Mid';
|
|
192
|
+
}
|
|
193
|
+
icon = meas == "Mid" ? iconRangeGreen : iconRangeRed;
|
|
194
|
+
if (meas)
|
|
195
|
+
form.getButton('ImageTotalExternalStaticPressure'+meas).setImage(icon);
|
|
196
|
+
|
|
197
|
+
//Filter Pressure Drop
|
|
198
|
+
if (test["ductScreeningPressureDrop"+filter_pressure_drop])
|
|
199
|
+
form.getTextField('FilterPressureDrop').setText(test['ductScreeningPressureDrop'+filter_pressure_drop]);
|
|
200
|
+
if (test['ductScreeningPressureDrop'+filter_pressure_drop+'Target'])
|
|
201
|
+
form.getTextField('FilterPressureDropTarget').setText(test['ductScreeningPressureDrop'+filter_pressure_drop+'Target']);
|
|
202
|
+
//Add logic here for which image
|
|
203
|
+
meas = "";
|
|
204
|
+
if (test["ductScreeningPressureDrop"+filter_pressure_drop+"Result"]&&test["ductScreeningPressureDrop"+filter_pressure_drop+"Result"]!==1){
|
|
205
|
+
meas = test["ductScreeningPressureDrop"+filter_pressure_drop+"Result"]===-1 ? 'Low' : 'High';
|
|
206
|
+
} else if (test["ductScreeningPressureDrop"+filter_pressure_drop+"Result"]&&test["ductScreeningPressureDrop"+filter_pressure_drop+"Result"]===1){
|
|
207
|
+
meas = 'Mid';
|
|
208
|
+
}
|
|
209
|
+
icon = meas == "Mid" ? iconRangeGreen : iconRangeRed;
|
|
210
|
+
if (meas)
|
|
211
|
+
form.getButton('ImageFilterPressureDrop'+meas).setImage(icon);
|
|
212
|
+
|
|
213
|
+
//Coil Pressure Drop
|
|
214
|
+
if (test["ductScreeningPressureDrop"+coil_pressure_drop])
|
|
215
|
+
form.getTextField('IndoorCoilPressureDrop').setText(test["ductScreeningPressureDrop"+coil_pressure_drop]);
|
|
216
|
+
if (test["ductScreeningPressureDrop"+coil_pressure_drop+'Target'])
|
|
217
|
+
form.getTextField('IndoorCoilPressureDropTarget').setText(test["ductScreeningPressureDrop"+coil_pressure_drop+'Target']);
|
|
218
|
+
//Add logic here for which image
|
|
219
|
+
meas = "";
|
|
220
|
+
if (test["ductScreeningPressureDrop"+coil_pressure_drop+"Result"]&&test["ductScreeningPressureDrop"+coil_pressure_drop+"Result"]!==1){
|
|
221
|
+
meas = test["ductScreeningPressureDrop"+coil_pressure_drop+"Result"]===-1 ? 'Low' : 'High';
|
|
222
|
+
} else if (test["ductScreeningPressureDrop"+coil_pressure_drop+"Result"]&&test["ductScreeningPressureDrop"+coil_pressure_drop+"Result"]===1){
|
|
223
|
+
meas = 'Mid';
|
|
224
|
+
}
|
|
225
|
+
icon = meas == "Mid" ? iconRangeGreen : iconRangeRed;
|
|
226
|
+
if (meas)
|
|
227
|
+
form.getButton('ImageIndoorCoilPressureDrop'+meas).setImage(icon);
|
|
228
|
+
|
|
229
|
+
//Return Duct Pressure
|
|
230
|
+
if (test["ductScreeningPressureDrop"+return_pressure_drop])
|
|
231
|
+
form.getTextField('ReturnDuctPressure').setText(test["ductScreeningPressureDrop"+return_pressure_drop]);
|
|
232
|
+
if (test["ductScreeningPressureDrop"+return_pressure_drop+'Target'])
|
|
233
|
+
form.getTextField('ReturnDuctPressureTarget').setText(test["ductScreeningPressureDrop"+return_pressure_drop+'Target']);
|
|
234
|
+
//Add logic here for which image
|
|
235
|
+
meas = "";
|
|
236
|
+
if (test["ductScreeningPressureDrop"+return_pressure_drop+"Result"]&&test["ductScreeningPressureDrop"+return_pressure_drop+"Result"]!==1){
|
|
237
|
+
meas = test["ductScreeningPressureDrop"+return_pressure_drop+"Result"]===-1 ? 'Low' : 'High';
|
|
238
|
+
} else if (test["ductScreeningPressureDrop"+return_pressure_drop+"Result"]&&test["ductScreeningPressureDrop"+return_pressure_drop+"Result"]===1){
|
|
239
|
+
meas = 'Mid';
|
|
240
|
+
}
|
|
241
|
+
icon = meas == "Mid" ? iconRangeGreen : iconRangeRed;
|
|
242
|
+
if (meas)
|
|
243
|
+
form.getButton('ImageReturnDuctPressure'+meas).setImage(icon);
|
|
244
|
+
|
|
245
|
+
//Supply Duct Pressure
|
|
246
|
+
if (test["ductScreeningPressureDrop"+supply_pressure])
|
|
247
|
+
form.getTextField('SupplyDuctPressure').setText(test["ductScreeningPressureDrop"+supply_pressure]);
|
|
248
|
+
if (test["ductScreeningPressureDrop"+supply_pressure+'Target'])
|
|
249
|
+
form.getTextField('SupplyDuctPressureTarget').setText(test["ductScreeningPressureDrop"+supply_pressure+'Target']);
|
|
250
|
+
//Add logic here for which image
|
|
251
|
+
meas = "";
|
|
252
|
+
if (test["ductScreeningPressureDrop"+supply_pressure+"Result"]&&test["ductScreeningPressureDrop"+supply_pressure+"Result"]!==1){
|
|
253
|
+
meas = test["ductScreeningPressureDrop"+supply_pressure+"Result"]===-1 ? 'Low' : 'High';
|
|
254
|
+
} else if (test["ductScreeningPressureDrop"+supply_pressure+"Result"]&&test["ductScreeningPressureDrop"+supply_pressure+"Result"]===1){
|
|
255
|
+
meas = 'Mid';
|
|
256
|
+
}
|
|
257
|
+
icon = meas == "Mid" ? iconRangeGreen : iconRangeRed;
|
|
258
|
+
if (meas)
|
|
259
|
+
form.getButton('ImageSupplyDuctPressure'+meas).setImage(icon);
|
|
260
|
+
|
|
261
|
+
//Additional Supporting Data
|
|
262
|
+
form.getTextField('AdditionalSupportingDataLabel1').setText(``);
|
|
263
|
+
form.getTextField('AdditionalSupportingDataValue1').setText(``);
|
|
264
|
+
form.getButton('ImageAdditionalSupportingData1').setImage(icon);
|
|
265
|
+
form.getTextField('AdditionalSupportingDataLabel2').setText(``);
|
|
266
|
+
form.getTextField('AdditionalSupportingDataValue2').setText(``);
|
|
267
|
+
form.getButton('ImageAdditionalSupportingData2').setImage(icon);
|
|
268
|
+
form.getTextField('AdditionalSupportingDataLabel3').setText(``);
|
|
269
|
+
form.getTextField('AdditionalSupportingDataValue3').setText(``);
|
|
270
|
+
form.getButton('ImageAdditionalSupportingData3').setImage(icon);
|
|
271
|
+
form.getTextField('AdditionalSupportingDataLabel4').setText(``);
|
|
272
|
+
form.getTextField('AdditionalSupportingDataValue4').setText(``);
|
|
273
|
+
form.getButton('ImageAdditionalSupportingData4').setImage(icon);
|
|
274
|
+
form.getTextField('AdditionalSupportingDataLabel5').setText(``);
|
|
275
|
+
form.getTextField('AdditionalSupportingDataValue5').setText(``);
|
|
276
|
+
form.getButton('ImageAdditionalSupportingData5').setImage(icon);
|
|
277
|
+
form.getTextField('AdditionalSupportingDataLabel6').setText(``);
|
|
278
|
+
form.getTextField('AdditionalSupportingDataValue6').setText(``);
|
|
279
|
+
form.getButton('ImageAdditionalSupportingData6').setImage(icon);
|
|
280
|
+
form.getTextField('AdditionalSupportingDataLabel7').setText(``);
|
|
281
|
+
form.getTextField('AdditionalSupportingDataValue7').setText(``);
|
|
282
|
+
form.getButton('ImageAdditionalSupportingData7').setImage(icon);
|
|
283
|
+
form.getTextField('AdditionalSupportingDataLabel8').setText(``);
|
|
284
|
+
form.getTextField('AdditionalSupportingDataValue8').setText(``);
|
|
285
|
+
form.getButton('ImageAdditionalSupportingData8').setImage(icon);
|
|
286
|
+
form.getTextField('AdditionalSupportingDataLabel9').setText(``);
|
|
287
|
+
form.getTextField('AdditionalSupportingDataValue9').setText(``);
|
|
288
|
+
form.getButton('ImageAdditionalSupportingData9').setImage(icon);
|
|
289
|
+
|
|
290
|
+
form.getTextField('Recommendations').setText(``);
|
|
291
|
+
if (test.ductScreeningPressureDrop1Result)
|
|
292
|
+
form.getTextField('FanAirflowPassFail').setText(``);
|
|
293
|
+
if (test.ductScreeningPressureDrop1Result)
|
|
294
|
+
form.getTextField('StaticPressurePassFail').setText(``);
|
|
295
|
+
if (test['ductScreeningPressureDrop'+filter_pressure_drop+'Result'])
|
|
296
|
+
form.getTextField('AirFilterPassFail').setText(``);
|
|
297
|
+
if (test['ductScreeningPressureDrop'+coil_pressure_drop+'Result'])
|
|
298
|
+
form.getTextField('CoilPassFail').setText(``);
|
|
299
|
+
if (test['ductScreeningPressureDrop'+supply_pressure+'Result'])
|
|
300
|
+
form.getTextField('SupplyDuctPassFail').setText(``);
|
|
301
|
+
if (test['ductScreeningPressureDrop'+return_pressure_drop+'Result'])
|
|
302
|
+
form.getTextField('ReturnDuctPassFail').setText(``);
|
|
303
|
+
if (test.ductScreeningResult){
|
|
304
|
+
if (test.ductScreeningResult === 'PASS'){
|
|
305
|
+
form.getTextField('TestResultBreakdownPage').setText('PASS');
|
|
306
|
+
} else if (test.ductScreeningResult === 'PASS<br>w/Recommendations'){
|
|
307
|
+
form.getTextField('TestResultBreakdownPage').setText(`PASS*`);
|
|
308
|
+
} else if (test.ductScreeningResult === 'FAIL'){
|
|
309
|
+
form.getTextField('TestResultBreakdownPage').setText(`FAIL`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
/*
|
|
315
|
+
form.getTextField('Name').setText(`${payload.cName}`);
|
|
316
|
+
form.getTextField('Address 1').setText(`${payload.address}`);
|
|
317
|
+
form.getTextField('Address 2').setText(`${payload.address2}`);
|
|
318
|
+
form.getTextField('City State Zip').setText(`${payload.city}, ${payload.state} ${payload.zip}`);
|
|
319
|
+
form.getTextField('Date of Service').setText(`${payload.address}`);
|
|
320
|
+
form.getTextField('Time of Service').setText(`${payload.address}`);
|
|
321
|
+
|
|
322
|
+
form.getTextField('Your System Score').setText(`${payload.address}`);
|
|
323
|
+
|
|
324
|
+
form.getTextField('Fan Airflow').setText(`${payload.address}`);
|
|
325
|
+
form.getButton(`Fan Airflow Mid`).setImage(iconRangeGreen);
|
|
326
|
+
|
|
327
|
+
form.getTextField('Static Pressure').setText(`${payload.address}`);
|
|
328
|
+
form.getButton(`Static Pressure Mid`).setImage(iconRangeGreen);
|
|
329
|
+
|
|
330
|
+
form.getTextField('Filter Pressure').setText(`${payload.address}`);
|
|
331
|
+
form.getButton(`Filter Pressure Mid`).setImage(iconRangeGreen);
|
|
332
|
+
|
|
333
|
+
form.getTextField('Coil').setText(`${payload.address}`);
|
|
334
|
+
form.getButton(`Coil Mid`).setImage(iconRangeGreen);
|
|
335
|
+
|
|
336
|
+
form.getTextField('Return Duct').setText(`${payload.address}`);
|
|
337
|
+
form.getButton(`Return Duct Mid`).setImage(iconRangeGreen);
|
|
338
|
+
|
|
339
|
+
form.getTextField('Supply Duct').setText(`${payload.address}`);
|
|
340
|
+
form.getButton(`Supply Duct Mid`).setImage(iconRangeGreen);
|
|
341
|
+
|
|
342
|
+
form.getTextField('Fan Airflow Score').setText(`${payload.address}`);
|
|
343
|
+
form.getTextField('Static Pressure Score').setText(`${payload.address}`);
|
|
344
|
+
form.getTextField('Air Filter Score').setText(`${payload.address}`);
|
|
345
|
+
form.getTextField('Coil Score').setText(`${payload.address}`);
|
|
346
|
+
form.getTextField('Return Duct Score').setText(`${payload.address}`);
|
|
347
|
+
form.getTextField('Supply Duct Score').setText(`${payload.address}`);
|
|
348
|
+
form.getTextField('System Score').setText(`${payload.address}`);
|
|
349
|
+
|
|
350
|
+
for (let i = 1; i <= 16; i++) {
|
|
351
|
+
form.getTextField(`System Diagnostics ${i}`).setText(`${payload.address}`);
|
|
352
|
+
form.getButton(`Icon${i}_af_image`).setImage(iconRangeGreen);
|
|
353
|
+
if (i <= 8) {
|
|
354
|
+
form.getTextField(`Pass Fail ${i}`).setText(`${payload.address}`);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
*/
|
|
358
|
+
// flatten and return as base64
|
|
359
|
+
form.flatten();
|
|
360
|
+
|
|
361
|
+
return { status: 200, data: await pdfDoc.saveAsBase64({ dataUri: true }) };
|
|
362
|
+
} catch (error) {
|
|
363
|
+
return { status: 400, data: error };
|
|
364
|
+
}
|
|
365
|
+
}
|
|
@@ -26,6 +26,7 @@ export async function getReport(payload) {
|
|
|
26
26
|
let docIndex = 0;
|
|
27
27
|
let initialProjectPhotoPageLoaded = false;
|
|
28
28
|
let photoSectionKeys = Object.keys(payload.photos.project);
|
|
29
|
+
let hasPhotos = false;
|
|
29
30
|
if (photoSectionKeys && photoSectionKeys.length > 0) {
|
|
30
31
|
let photoPosition = 1;
|
|
31
32
|
for (let pskIndex = 0; pskIndex < photoSectionKeys.length; pskIndex++) { // Iterate over X user-defined photo sections within each photo collection
|
|
@@ -38,6 +39,7 @@ export async function getReport(payload) {
|
|
|
38
39
|
let photo = photos[pIndex - 1];
|
|
39
40
|
//If image has proper photo data, continue processing, else do not try and make an empty page.
|
|
40
41
|
if (photo && photo.base64 && typeof photo.base64 == 'string') {
|
|
42
|
+
hasPhotos = true;
|
|
41
43
|
if (!initialProjectPhotoPageLoaded) {
|
|
42
44
|
initialProjectPhotoPageLoaded = true;
|
|
43
45
|
canProcessReport = true;
|
|
@@ -72,12 +74,15 @@ export async function getReport(payload) {
|
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
}
|
|
77
|
+
if (hasPhotos)
|
|
78
|
+
this.docIndex++;
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
let initialEquipmentPhotoPageLoaded = false;
|
|
78
82
|
photoSectionKeys = Object.keys(payload.photos.equipment);
|
|
79
|
-
|
|
83
|
+
hasPhotos = payload.photos.equipment && payload.photos.equipment.photo_models_serials && payload.photos.equipment.photo_models_serials.photos && payload.photos.equipment.photo_models_serials.photos.length > 0;
|
|
80
84
|
if (photoSectionKeys && photoSectionKeys.length > 0 && hasPhotos) {
|
|
85
|
+
hasPhotos = false;
|
|
81
86
|
let photoPosition = 1;
|
|
82
87
|
for (let pskIndex = 0; pskIndex < photoSectionKeys.length; pskIndex++) { // Iterate over X user-defined photo sections within each photo collection
|
|
83
88
|
let photoSectionKey = photoSectionKeys[pskIndex];
|
|
@@ -88,6 +93,7 @@ export async function getReport(payload) {
|
|
|
88
93
|
for (let pIndex = 1; pIndex <= photos.length; pIndex++) { // Iterate over X user-defined photos within each photo section
|
|
89
94
|
let photo = photos[pIndex - 1];
|
|
90
95
|
if (photo && photo.base64 && typeof photo.base64 == 'string') {
|
|
96
|
+
hasPhotos = true;
|
|
91
97
|
//Initial page load, this should wait until we know there is VALID image data
|
|
92
98
|
if (!initialEquipmentPhotoPageLoaded) {
|
|
93
99
|
initialEquipmentPhotoPageLoaded = true;
|
|
@@ -131,7 +137,8 @@ export async function getReport(payload) {
|
|
|
131
137
|
}
|
|
132
138
|
}
|
|
133
139
|
}
|
|
134
|
-
|
|
140
|
+
if (hasPhotos)
|
|
141
|
+
docIndex++;
|
|
135
142
|
}
|
|
136
143
|
|
|
137
144
|
// Prepare Deliverable
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { PDFDocument } from 'pdf-lib';
|
|
2
|
-
import * as base64 from '../base-64/icons.js';
|
|
3
|
-
import * as pdf from '../base-64/mq-vitals-nci.js';
|
|
4
|
-
import * as systemInfoPage from './system-info-page.js';
|
|
5
|
-
import * as util from '../util.js';
|
|
6
|
-
|
|
7
|
-
export async function getReport(payload, _test) {
|
|
8
|
-
try {
|
|
9
|
-
// fetch and load form
|
|
10
|
-
const formPdfBytes = util._base64ToArrayBuffer(pdf.base64);
|
|
11
|
-
const pdfDoc = await PDFDocument.load(formPdfBytes);
|
|
12
|
-
|
|
13
|
-
// fetch resources
|
|
14
|
-
const iconRangeGreenBytes = util._base64ToArrayBuffer(base64.iconRangeGreen);
|
|
15
|
-
const iconRangeRedBytes = util._base64ToArrayBuffer(base64.iconRangeRed);
|
|
16
|
-
const iconFlagBlackBytes = util._base64ToArrayBuffer(base64.iconFlagBlack);
|
|
17
|
-
const iconFlagGreenBytes = util._base64ToArrayBuffer(base64.iconFlagGreen);
|
|
18
|
-
const iconFlagRedBytes = util._base64ToArrayBuffer(base64.iconFlagRed);
|
|
19
|
-
const iconFlagYellowBytes = util._base64ToArrayBuffer(base64.iconFlagYellow);
|
|
20
|
-
const iconStabilityBytes = util._base64ToArrayBuffer(base64.iconStability);
|
|
21
|
-
const iconThumbprintGreenBytes = util._base64ToArrayBuffer(base64.iconThumbprintGreen);
|
|
22
|
-
const iconThumbprintRedBytes = util._base64ToArrayBuffer(base64.iconThumbprintRed);
|
|
23
|
-
const mqLogoBytes = util._base64ToArrayBuffer(base64.mqLogo);
|
|
24
|
-
|
|
25
|
-
// load resources
|
|
26
|
-
const iconRangeGreen = await pdfDoc.embedPng(iconRangeGreenBytes);
|
|
27
|
-
const iconRangeRed = await pdfDoc.embedPng(iconRangeRedBytes);
|
|
28
|
-
const iconFlagBlack = await pdfDoc.embedPng(iconFlagBlackBytes);
|
|
29
|
-
const iconFlagGreen = await pdfDoc.embedPng(iconFlagGreenBytes);
|
|
30
|
-
const iconFlagRed = await pdfDoc.embedPng(iconFlagRedBytes);
|
|
31
|
-
const iconFlagYellow = await pdfDoc.embedPng(iconFlagYellowBytes);
|
|
32
|
-
const iconStability = await pdfDoc.embedPng(iconStabilityBytes);
|
|
33
|
-
const iconThumbprintGreen = await pdfDoc.embedPng(iconThumbprintGreenBytes);
|
|
34
|
-
const iconThumbprintRed = await pdfDoc.embedPng(iconThumbprintRedBytes);
|
|
35
|
-
const mqLogo = await pdfDoc.embedPng(mqLogoBytes);
|
|
36
|
-
|
|
37
|
-
const form = pdfDoc.getForm();
|
|
38
|
-
|
|
39
|
-
form.getTextField('Name').setText(`${payload.cName}`);
|
|
40
|
-
form.getTextField('Address 1').setText(`${payload.address}`);
|
|
41
|
-
form.getTextField('Address 2').setText(`${payload.address2}`);
|
|
42
|
-
form.getTextField('City State Zip').setText(`${payload.city}, ${payload.state} ${payload.zip}`);
|
|
43
|
-
form.getTextField('Date of Service').setText(`${payload.address}`);
|
|
44
|
-
form.getTextField('Time of Service').setText(`${payload.address}`);
|
|
45
|
-
|
|
46
|
-
form.getTextField('Your System Score').setText(`${payload.address}`);
|
|
47
|
-
|
|
48
|
-
form.getTextField('Fan Airflow').setText(`${payload.address}`);
|
|
49
|
-
form.getButton(`Fan Airflow Mid`).setImage(iconRangeGreen);
|
|
50
|
-
|
|
51
|
-
form.getTextField('Static Pressure').setText(`${payload.address}`);
|
|
52
|
-
form.getButton(`Static Pressure Mid`).setImage(iconRangeGreen);
|
|
53
|
-
|
|
54
|
-
form.getTextField('Filter Pressure').setText(`${payload.address}`);
|
|
55
|
-
form.getButton(`Filter Pressure Mid`).setImage(iconRangeGreen);
|
|
56
|
-
|
|
57
|
-
form.getTextField('Coil').setText(`${payload.address}`);
|
|
58
|
-
form.getButton(`Coil Mid`).setImage(iconRangeGreen);
|
|
59
|
-
|
|
60
|
-
form.getTextField('Return Duct').setText(`${payload.address}`);
|
|
61
|
-
form.getButton(`Return Duct Mid`).setImage(iconRangeGreen);
|
|
62
|
-
|
|
63
|
-
form.getTextField('Supply Duct').setText(`${payload.address}`);
|
|
64
|
-
form.getButton(`Supply Duct Mid`).setImage(iconRangeGreen);
|
|
65
|
-
|
|
66
|
-
form.getTextField('Fan Airflow Score').setText(`${payload.address}`);
|
|
67
|
-
form.getTextField('Static Pressure Score').setText(`${payload.address}`);
|
|
68
|
-
form.getTextField('Air Filter Score').setText(`${payload.address}`);
|
|
69
|
-
form.getTextField('Coil Score').setText(`${payload.address}`);
|
|
70
|
-
form.getTextField('Return Duct Score').setText(`${payload.address}`);
|
|
71
|
-
form.getTextField('Supply Duct Score').setText(`${payload.address}`);
|
|
72
|
-
form.getTextField('System Score').setText(`${payload.address}`);
|
|
73
|
-
|
|
74
|
-
for (let i = 1; i <= 16; i++) {
|
|
75
|
-
form.getTextField(`System Diagnostics ${i}`).setText(`${payload.address}`);
|
|
76
|
-
form.getButton(`Icon${i}_af_image`).setImage(iconRangeGreen);
|
|
77
|
-
if (i <= 8) {
|
|
78
|
-
form.getTextField(`Pass Fail ${i}`).setText(`${payload.address}`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// flatten and return as base64
|
|
83
|
-
form.flatten();
|
|
84
|
-
return { status: 200, data: await pdfDoc.saveAsBase64({ dataUri: true }) };
|
|
85
|
-
} catch (error) {
|
|
86
|
-
return { status: 400, data: error };
|
|
87
|
-
}
|
|
88
|
-
}
|