@measurequick/measurequick-report-generator 1.5.131 → 1.5.132

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measurequick/measurequick-report-generator",
3
- "version": "1.5.131",
3
+ "version": "1.5.132",
4
4
  "description": "Generates PDF documents for various measureQuick applications.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -4,6 +4,17 @@ import * as pdf from "../base-64/mq-vitals-heating-no-combustion.js";
4
4
  import * as systemInfoPage from "./system-info-page.js";
5
5
  import * as util from "../util.js";
6
6
 
7
+ function safeSetText(form, name, value = "") {
8
+ try {
9
+ form.getTextField(name).setText(value ?? "");
10
+ } catch (e) {}
11
+ }
12
+ function safeSetImage(form, name, image) {
13
+ try {
14
+ if (image) form.getButton(name).setImage(image);
15
+ } catch (e) {}
16
+ }
17
+
7
18
  export async function getReport(payload, _test) {
8
19
  try {
9
20
  // fetch and load form
@@ -81,7 +92,7 @@ export async function getReport(payload, _test) {
81
92
  const form = pdfDoc.getForm();
82
93
 
83
94
  let header = "Heating System Vitals";
84
- form.getTextField("Header").setText(header);
95
+ safeSetText(form, "Header", header);
85
96
 
86
97
  let test = payload.tests[0];
87
98
  if (_test) test = _test;
@@ -96,32 +107,32 @@ export async function getReport(payload, _test) {
96
107
 
97
108
  // print company logo and profile picture
98
109
  if (profileImage && companyImage) {
99
- form.getButton("ProfilePicture").setImage(profileImage);
100
- form.getButton("HalfWidthLogo").setImage(companyImage);
110
+ safeSetImage(form, "ProfilePicture", profileImage);
111
+ safeSetImage(form, "HalfWidthLogo", companyImage);
101
112
  if (
102
113
  payload.meta.profile_settings.techFirstName ||
103
114
  payload.meta.profile_settings.techLastName
104
115
  )
105
- form
106
- .getTextField("TechName")
107
- .setText(
108
- `${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
109
- );
116
+ safeSetText(
117
+ form,
118
+ "TechName",
119
+ `${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
120
+ );
110
121
  } else if (profileImage) {
111
- form.getButton("ProfilePicture").setImage(profileImage);
112
- form.getButton("HalfWidthLogo").setImage(mqLogo);
122
+ safeSetImage(form, "ProfilePicture", profileImage);
123
+ safeSetImage(form, "HalfWidthLogo", mqLogo);
113
124
  if (
114
125
  payload.meta.profile_settings.techFirstName ||
115
126
  payload.meta.profile_settings.techLastName
116
127
  )
117
- form
118
- .getTextField("TechName")
119
- .setText(
120
- `${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
121
- );
128
+ safeSetText(
129
+ form,
130
+ "TechName",
131
+ `${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
132
+ );
122
133
  } else {
123
- if (companyImage) form.getButton("FullWidthLogo").setImage(companyImage);
124
- else form.getButton("FullWidthLogo").setImage(mqLogo);
134
+ if (companyImage) safeSetImage(form, "FullWidthLogo", companyImage);
135
+ else safeSetImage(form, "FullWidthLogo", mqLogo);
125
136
  }
126
137
 
127
138
  // print customer data
@@ -138,38 +149,34 @@ export async function getReport(payload, _test) {
138
149
  textFields.zip
139
150
  ) {
140
151
  dateTimePlacement = "Lower";
141
- form.getTextField("Name").setText(`${textFields.cName}`);
142
- form.getTextField("Address1").setText(`${textFields.address}`);
152
+ safeSetText(form, "Name", `${textFields.cName}`);
153
+ safeSetText(form, "Address1", `${textFields.address}`);
143
154
  if (textFields.address2) {
144
- form.getTextField("Address2").setText(`${textFields.address2}`);
145
- form
146
- .getTextField("CityStateZip")
147
- .setText(`${textFields.city}${textFields.state}${textFields.zip}`);
155
+ safeSetText(form, "Address2", `${textFields.address2}`);
156
+ safeSetText(
157
+ form,
158
+ "CityStateZip",
159
+ `${textFields.city}${textFields.state}${textFields.zip}`
160
+ );
148
161
  } else
149
- form
150
- .getTextField("Address2")
151
- .setText(`${textFields.city}${textFields.state}${textFields.zip}`);
152
- form.getTextField("DateOfServiceLabelUpper").setText("");
153
- form.getTextField("TimeOfServiceLabelUpper").setText("");
154
- form.getTextField("DateOfServiceLabelLower").setText("Date of Service:");
155
- form.getTextField("TimeOfServiceLabelLower").setText("Time of Service:");
156
- form
157
- .getTextField("DateOfServiceLower")
158
- .setText(date.toLocaleDateString("en-US"));
159
- form
160
- .getTextField("TimeOfServiceLower")
161
- .setText(date.toLocaleTimeString("en-US"));
162
+ safeSetText(
163
+ form,
164
+ "Address2",
165
+ `${textFields.city}${textFields.state}${textFields.zip}`
166
+ );
167
+ safeSetText(form, "DateOfServiceLabelUpper", "");
168
+ safeSetText(form, "TimeOfServiceLabelUpper", "");
169
+ safeSetText(form, "DateOfServiceLabelLower", "Date of Service:");
170
+ safeSetText(form, "TimeOfServiceLabelLower", "Time of Service:");
171
+ safeSetText(form, "DateOfServiceLower", date.toLocaleDateString("en-US"));
172
+ safeSetText(form, "TimeOfServiceLower", date.toLocaleTimeString("en-US"));
162
173
  } else {
163
- form.getTextField("DateOfServiceLabelLower").setText("");
164
- form.getTextField("TimeOfServiceLabelLower").setText("");
165
- form.getTextField("DateOfServiceLabelUpper").setText("Date of Service:");
166
- form.getTextField("TimeOfServiceLabelUpper").setText("Time of Service:");
167
- form
168
- .getTextField("DateOfServiceUpper")
169
- .setText(date.toLocaleDateString("en-US"));
170
- form
171
- .getTextField("TimeOfServiceUpper")
172
- .setText(date.toLocaleTimeString("en-US"));
174
+ safeSetText(form, "DateOfServiceLabelLower", "");
175
+ safeSetText(form, "TimeOfServiceLabelLower", "");
176
+ safeSetText(form, "DateOfServiceLabelUpper", "Date of Service:");
177
+ safeSetText(form, "TimeOfServiceLabelUpper", "Time of Service:");
178
+ safeSetText(form, "DateOfServiceUpper", date.toLocaleDateString("en-US"));
179
+ safeSetText(form, "TimeOfServiceUpper", date.toLocaleTimeString("en-US"));
173
180
  }
174
181
 
175
182
  let systemScorePercentage = test.testInfo.data.vitals_score
@@ -182,55 +189,75 @@ export async function getReport(payload, _test) {
182
189
  systemScoreGrade = "";
183
190
  } else systemScorePercentage += "%";
184
191
  // print measurement data
185
- form
186
- .getTextField(`YourSystemScore${systemScoreColor}`)
187
- .setText(`${systemScorePercentage} ${systemScoreGrade}`);
192
+ safeSetText(
193
+ form,
194
+ `YourSystemScore${systemScoreColor}`,
195
+ `${systemScorePercentage} ${systemScoreGrade}`
196
+ );
188
197
 
189
- form.getTextField("COaf").setText(`${textFields.coaf} ppm`);
190
- form.getTextField("Efficiency").setText(`${textFields.efficiency}`);
191
- form
192
- .getTextField("ManifoldPressure")
193
- .setText(`${textFields.manifoldPressure} inH2O`);
194
- form
195
- .getTextField("TemperatureSplit")
196
- .setText(`${textFields.tempSplit} °${payload.units.temperature}`);
197
- form
198
- .getTextField("TotalExternalStaticPressure")
199
- .setText(`${textFields.tesp} inH2O`);
200
- form
201
- .getTextField("FilterFaceVelocity")
202
- .setText(`${textFields.fltrFace} FPM`);
198
+ //form.getTextField("COaf").setText(`${textFields.coaf} ppm`);
199
+ safeSetText(form, "Efficiency", `${textFields.efficiency}`);
200
+ safeSetText(
201
+ form,
202
+ "ManifoldPressure",
203
+ `${textFields.manifoldPressure} inH2O`
204
+ );
205
+ safeSetText(
206
+ form,
207
+ "TemperatureSplit",
208
+ `${textFields.tempSplit} °${payload.units.temperature}`
209
+ );
210
+ safeSetText(
211
+ form,
212
+ "TotalExternalStaticPressure",
213
+ `${textFields.tesp} inH2O`
214
+ );
215
+ safeSetText(form, "FilterFaceVelocity", `${textFields.fltrFace} FPM`);
203
216
 
204
217
  // print losses data (second page)
205
218
  let prefix;
206
219
  let lossColor = textFields.ageLoss < 3 ? "Green" : "Red";
207
220
  prefix = textFields.ageLoss == 0 ? "" : "-";
208
- form
209
- .getTextField(`AgeLosses${lossColor}`)
210
- .setText(`${prefix}${textFields.ageLoss}`);
221
+ safeSetText(
222
+ form,
223
+ `AgeLosses${lossColor}`,
224
+ `${prefix}${textFields.ageLoss}`
225
+ );
226
+
227
+ /*
211
228
  lossColor = textFields.coafLoss < 3 ? "Green" : "Red";
212
229
  prefix = textFields.coafLoss == 0 ? "" : "-";
213
230
  form
214
231
  .getTextField(`CoafLosses${lossColor}`)
215
232
  .setText(`${prefix}${textFields.coafLoss}`);
233
+ */
234
+
216
235
  lossColor = textFields.tempSplitLoss < 3 ? "Green" : "Red";
217
236
  prefix = textFields.tempSplitLoss == 0 ? "" : "-";
218
- form
219
- .getTextField(`HeatTransferLosses${lossColor}`)
220
- .setText(`${prefix}${textFields.tempSplitLoss}`);
237
+ safeSetText(
238
+ form,
239
+ `HeatTransferLosses${lossColor}`,
240
+ `${prefix}${textFields.tempSplitLoss}`
241
+ );
221
242
  lossColor = textFields.gasInputLoss < 3 ? "Green" : "Red";
222
243
  prefix = textFields.gasInputLoss == 0 ? "" : "-";
223
- form
224
- .getTextField(`FuelInputLosses${lossColor}`)
225
- .setText(`${prefix}${textFields.gasInputLoss}`);
244
+ safeSetText(
245
+ form,
246
+ `FuelInputLosses${lossColor}`,
247
+ `${prefix}${textFields.gasInputLoss}`
248
+ );
226
249
  lossColor = textFields.staticLoss < 3 ? "Green" : "Red";
227
250
  prefix = textFields.staticLoss == 0 ? "" : "-";
228
- form
229
- .getTextField(`AirDistributionLosses${lossColor}`)
230
- .setText(`${prefix}${textFields.staticLoss}`);
231
- form
232
- .getTextField("YourSystemScorePage2")
233
- .setText(`${systemScorePercentage} ${systemScoreGrade}`);
251
+ safeSetText(
252
+ form,
253
+ `AirDistributionLosses${lossColor}`,
254
+ `${prefix}${textFields.staticLoss}`
255
+ );
256
+ safeSetText(
257
+ form,
258
+ "YourSystemScorePage2",
259
+ `${systemScorePercentage} ${systemScoreGrade}`
260
+ );
234
261
 
235
262
  // print targets and range icons
236
263
  const measureLabels = [
@@ -262,9 +289,7 @@ export async function getReport(payload, _test) {
262
289
  else if (actual > high) iconPlacement = "High";
263
290
  else if (val) icon = iconRangeGreen;
264
291
  if (icon)
265
- form
266
- .getButton(`Image${measureLabels[i]}${iconPlacement}`)
267
- .setImage(icon);
292
+ safeSetImage(form, `Image${measureLabels[i]}${iconPlacement}`, icon);
268
293
  let targetZone = "";
269
294
  if (
270
295
  targetKeys[i] == "pressure_static_total_external" ||
@@ -273,7 +298,7 @@ export async function getReport(payload, _test) {
273
298
  targetZone = `(< ${high.toFixed(1)})`;
274
299
  else if (!isNaN(low) && low != "NaN" && !isNaN(high) && high != "NaN")
275
300
  targetZone = `(${low.toFixed(1)} - ${high.toFixed(1)})`;
276
- form.getTextField(`${measureLabels[i]}Target`).setText(targetZone);
301
+ safeSetText(form, `${measureLabels[i]}Target`, targetZone);
277
302
  }
278
303
 
279
304
  // if (payload.meta.boiler_type == '') {
@@ -294,9 +319,11 @@ export async function getReport(payload, _test) {
294
319
  specialCaseIcon = iconRangeGreen;
295
320
  specialCasePlacement = "Low";
296
321
  } else if (test.testInfo.data.coaf > 400) specialCasePlacement = "High";
322
+ /*
297
323
  form
298
324
  .getButton(`ImageCOaf${specialCasePlacement}`)
299
325
  .setImage(specialCaseIcon);
326
+ */
300
327
 
301
328
  specialCasePlacement = "Low";
302
329
  let efficiency = test.testInfo.data.efficiency
@@ -304,9 +331,11 @@ export async function getReport(payload, _test) {
304
331
  : test.testInfo.data.efficiency_gcv;
305
332
  if (efficiency >= 90) specialCasePlacement = "High";
306
333
  else if (efficiency >= 80) specialCasePlacement = "Mid";
307
- form
308
- .getButton(`ImageEfficiency${specialCasePlacement}`)
309
- .setImage(iconRangeGreen);
334
+ safeSetImage(
335
+ form,
336
+ `ImageEfficiency${specialCasePlacement}`,
337
+ iconRangeGreen
338
+ );
310
339
 
311
340
  // print pass fail measures
312
341
  if (test.testInfo.subsystem_review_complete) {
@@ -327,7 +356,7 @@ export async function getReport(payload, _test) {
327
356
  "heat_exchanger_pass_fail",
328
357
  "safety_system_pass_fail",
329
358
  "heating_operation_pass_fail",
330
- "combustion_pass_fail",
359
+ //"combustion_pass_fail",
331
360
  "heating_efficiency_pass_fail",
332
361
  ];
333
362
  let pfLabels = [
@@ -344,7 +373,7 @@ export async function getReport(payload, _test) {
344
373
  "Heat exchanger",
345
374
  "Safety system",
346
375
  "Heating operation",
347
- "Combustion Safety",
376
+ //"Combustion Safety",
348
377
  "Combustion efficiency",
349
378
  ];
350
379
  if (payload.meta.boiler_type != "") {
@@ -364,11 +393,11 @@ export async function getReport(payload, _test) {
364
393
  if (meas == "Caution") icon = iconRangeYellow;
365
394
  if (passFails[i] == "heating_efficiency_pass_fail")
366
395
  icon = iconRangeGreen;
367
- form.getButton(`ImageSubsystem${i + 1}_af_image`).setImage(icon);
396
+ safeSetImage(form, `ImageSubsystem${i + 1}_af_image`, icon);
368
397
  let suffix = test.testInfo[passFails[i] + "_override"] ? " *" : "";
369
- form.getTextField(`SSR${i + 1}`).setText(pfLabels[i] + suffix);
398
+ safeSetText(form, `SSR${i + 1}`, pfLabels[i] + suffix);
370
399
  }
371
- } else form.getTextField(`SSR1`).setText("Not yet reviewed");
400
+ } else safeSetText(form, `SSR1`, "Not yet reviewed");
372
401
 
373
402
  if (payload.meta.report_type != "FullReport") {
374
403
  let systemInfoPageBase64 = await systemInfoPage.getReport(payload);
@@ -407,10 +436,11 @@ function getTextFields(payload, test) {
407
436
  ? `, ${payload.site.location.state}`
408
437
  : "",
409
438
  zip: payload.site.location.zip ? ` ${payload.site.location.zip}` : "",
439
+ /*
410
440
  coaf:
411
441
  test.data.coaf || test.data.coaf === 0
412
442
  ? (+test.data.coaf).toFixed(1)
413
- : "--",
443
+ : "--",*/
414
444
  efficiency: test.data.efficiency
415
445
  ? (+test.data.efficiency).toFixed(1)
416
446
  : test.data.efficiency_gcv
@@ -429,7 +459,7 @@ function getTextFields(payload, test) {
429
459
  ? (+test.data.velocity_face_filter1).toFixed(1)
430
460
  : "--",
431
461
  ageLoss: test.data.age_loss ? (+test.data.age_loss).toFixed(0) : 0,
432
- coafLoss: test.data.coaf_loss ? (+test.data.coaf_loss).toFixed(0) : 0,
462
+ //coafLoss: test.data.coaf_loss ? (+test.data.coaf_loss).toFixed(0) : 0,
433
463
  tempSplitLoss: test.data.temp_split_loss
434
464
  ? (+test.data.temp_split_loss).toFixed(0)
435
465
  : 0,
@@ -4,6 +4,17 @@ import * as pdf from "../base-64/mq-vitals-heating.js";
4
4
  import * as systemInfoPage from "./system-info-page.js";
5
5
  import * as util from "../util.js";
6
6
 
7
+ function safeSetText(form, name, value = "") {
8
+ try {
9
+ form.getTextField(name).setText(value ?? "");
10
+ } catch (e) {}
11
+ }
12
+ function safeSetImage(form, name, image) {
13
+ try {
14
+ if (image) form.getButton(name).setImage(image);
15
+ } catch (e) {}
16
+ }
17
+
7
18
  export async function getReport(payload, _test) {
8
19
  try {
9
20
  // fetch and load form
@@ -81,7 +92,7 @@ export async function getReport(payload, _test) {
81
92
  const form = pdfDoc.getForm();
82
93
 
83
94
  let header = "Heating System Vitals";
84
- form.getTextField("Header").setText(header);
95
+ safeSetText(form, "Header", header);
85
96
 
86
97
  let test = payload.tests[0];
87
98
  if (_test) test = _test;
@@ -96,32 +107,32 @@ export async function getReport(payload, _test) {
96
107
 
97
108
  // print company logo and profile picture
98
109
  if (profileImage && companyImage) {
99
- form.getButton("ProfilePicture").setImage(profileImage);
100
- form.getButton("HalfWidthLogo").setImage(companyImage);
110
+ safeSetImage(form, "ProfilePicture", profileImage);
111
+ safeSetImage(form, "HalfWidthLogo", companyImage);
101
112
  if (
102
113
  payload.meta.profile_settings.techFirstName ||
103
114
  payload.meta.profile_settings.techLastName
104
115
  )
105
- form
106
- .getTextField("TechName")
107
- .setText(
108
- `${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
109
- );
116
+ safeSetText(
117
+ form,
118
+ "TechName",
119
+ `${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
120
+ );
110
121
  } else if (profileImage) {
111
- form.getButton("ProfilePicture").setImage(profileImage);
112
- form.getButton("HalfWidthLogo").setImage(mqLogo);
122
+ safeSetImage(form, "ProfilePicture", profileImage);
123
+ safeSetImage(form, "HalfWidthLogo", mqLogo);
113
124
  if (
114
125
  payload.meta.profile_settings.techFirstName ||
115
126
  payload.meta.profile_settings.techLastName
116
127
  )
117
- form
118
- .getTextField("TechName")
119
- .setText(
120
- `${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
121
- );
128
+ safeSetText(
129
+ form,
130
+ "TechName",
131
+ `${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
132
+ );
122
133
  } else {
123
- if (companyImage) form.getButton("FullWidthLogo").setImage(companyImage);
124
- else form.getButton("FullWidthLogo").setImage(mqLogo);
134
+ if (companyImage) safeSetImage(form, "FullWidthLogo", companyImage);
135
+ else safeSetImage(form, "FullWidthLogo", mqLogo);
125
136
  }
126
137
 
127
138
  // print customer data
@@ -138,38 +149,34 @@ export async function getReport(payload, _test) {
138
149
  textFields.zip
139
150
  ) {
140
151
  dateTimePlacement = "Lower";
141
- form.getTextField("Name").setText(`${textFields.cName}`);
142
- form.getTextField("Address1").setText(`${textFields.address}`);
152
+ safeSetText(form, "Name", `${textFields.cName}`);
153
+ safeSetText(form, "Address1", `${textFields.address}`);
143
154
  if (textFields.address2) {
144
- form.getTextField("Address2").setText(`${textFields.address2}`);
145
- form
146
- .getTextField("CityStateZip")
147
- .setText(`${textFields.city}${textFields.state}${textFields.zip}`);
155
+ safeSetText(form, "Address2", `${textFields.address2}`);
156
+ safeSetText(
157
+ form,
158
+ "CityStateZip",
159
+ `${textFields.city}${textFields.state}${textFields.zip}`
160
+ );
148
161
  } else
149
- form
150
- .getTextField("Address2")
151
- .setText(`${textFields.city}${textFields.state}${textFields.zip}`);
152
- form.getTextField("DateOfServiceLabelUpper").setText("");
153
- form.getTextField("TimeOfServiceLabelUpper").setText("");
154
- form.getTextField("DateOfServiceLabelLower").setText("Date of Service:");
155
- form.getTextField("TimeOfServiceLabelLower").setText("Time of Service:");
156
- form
157
- .getTextField("DateOfServiceLower")
158
- .setText(date.toLocaleDateString("en-US"));
159
- form
160
- .getTextField("TimeOfServiceLower")
161
- .setText(date.toLocaleTimeString("en-US"));
162
+ safeSetText(
163
+ form,
164
+ "Address2",
165
+ `${textFields.city}${textFields.state}${textFields.zip}`
166
+ );
167
+ safeSetText(form, "DateOfServiceLabelUpper", "");
168
+ safeSetText(form, "TimeOfServiceLabelUpper", "");
169
+ safeSetText(form, "DateOfServiceLabelLower", "Date of Service:");
170
+ safeSetText(form, "TimeOfServiceLabelLower", "Time of Service:");
171
+ safeSetText(form, "DateOfServiceLower", date.toLocaleDateString("en-US"));
172
+ safeSetText(form, "TimeOfServiceLower", date.toLocaleTimeString("en-US"));
162
173
  } else {
163
- form.getTextField("DateOfServiceLabelLower").setText("");
164
- form.getTextField("TimeOfServiceLabelLower").setText("");
165
- form.getTextField("DateOfServiceLabelUpper").setText("Date of Service:");
166
- form.getTextField("TimeOfServiceLabelUpper").setText("Time of Service:");
167
- form
168
- .getTextField("DateOfServiceUpper")
169
- .setText(date.toLocaleDateString("en-US"));
170
- form
171
- .getTextField("TimeOfServiceUpper")
172
- .setText(date.toLocaleTimeString("en-US"));
174
+ safeSetText(form, "DateOfServiceLabelLower", "");
175
+ safeSetText(form, "TimeOfServiceLabelLower", "");
176
+ safeSetText(form, "DateOfServiceLabelUpper", "Date of Service:");
177
+ safeSetText(form, "TimeOfServiceLabelUpper", "Time of Service:");
178
+ safeSetText(form, "DateOfServiceUpper", date.toLocaleDateString("en-US"));
179
+ safeSetText(form, "TimeOfServiceUpper", date.toLocaleTimeString("en-US"));
173
180
  }
174
181
 
175
182
  let systemScorePercentage = test.testInfo.data.vitals_score
@@ -182,55 +189,75 @@ export async function getReport(payload, _test) {
182
189
  systemScoreGrade = "";
183
190
  } else systemScorePercentage += "%";
184
191
  // print measurement data
185
- form
186
- .getTextField(`YourSystemScore${systemScoreColor}`)
187
- .setText(`${systemScorePercentage} ${systemScoreGrade}`);
192
+ safeSetText(
193
+ form,
194
+ `YourSystemScore${systemScoreColor}`,
195
+ `${systemScorePercentage} ${systemScoreGrade}`
196
+ );
188
197
 
189
- form.getTextField("COaf").setText(`${textFields.coaf} ppm`);
190
- form.getTextField("Efficiency").setText(`${textFields.efficiency}`);
191
- form
192
- .getTextField("ManifoldPressure")
193
- .setText(`${textFields.manifoldPressure} inH2O`);
194
- form
195
- .getTextField("TemperatureSplit")
196
- .setText(`${textFields.tempSplit} °${payload.units.temperature}`);
197
- form
198
- .getTextField("TotalExternalStaticPressure")
199
- .setText(`${textFields.tesp} inH2O`);
200
- form
198
+ safeSetText(form, "COaf", `${textFields.coaf} ppm`);
199
+ safeSetText(form, "Efficiency", `${textFields.efficiency}`);
200
+ safeSetText(
201
+ form,
202
+ "ManifoldPressure",
203
+ `${textFields.manifoldPressure} inH2O`
204
+ );
205
+ safeSetText(
206
+ form,
207
+ "TemperatureSplit",
208
+ `${textFields.tempSplit} °${payload.units.temperature}`
209
+ );
210
+ safeSetText(
211
+ form,
212
+ "TotalExternalStaticPressure",
213
+ `${textFields.tesp} inH2O`
214
+ );
215
+ /*form
201
216
  .getTextField("FilterFaceVelocity")
202
- .setText(`${textFields.fltrFace} FPM`);
217
+ .setText(`${textFields.fltrFace} FPM`);*/
203
218
 
204
219
  // print losses data (second page)
205
220
  let prefix;
206
221
  let lossColor = textFields.ageLoss < 3 ? "Green" : "Red";
207
222
  prefix = textFields.ageLoss == 0 ? "" : "-";
208
- form
209
- .getTextField(`AgeLosses${lossColor}`)
210
- .setText(`${prefix}${textFields.ageLoss}`);
223
+ safeSetText(
224
+ form,
225
+ `AgeLosses${lossColor}`,
226
+ `${prefix}${textFields.ageLoss}`
227
+ );
211
228
  lossColor = textFields.coafLoss < 3 ? "Green" : "Red";
212
229
  prefix = textFields.coafLoss == 0 ? "" : "-";
213
- form
214
- .getTextField(`CoafLosses${lossColor}`)
215
- .setText(`${prefix}${textFields.coafLoss}`);
230
+ safeSetText(
231
+ form,
232
+ `CoafLosses${lossColor}`,
233
+ `${prefix}${textFields.coafLoss}`
234
+ );
216
235
  lossColor = textFields.tempSplitLoss < 3 ? "Green" : "Red";
217
236
  prefix = textFields.tempSplitLoss == 0 ? "" : "-";
218
- form
219
- .getTextField(`HeatTransferLosses${lossColor}`)
220
- .setText(`${prefix}${textFields.tempSplitLoss}`);
237
+ safeSetText(
238
+ form,
239
+ `HeatTransferLosses${lossColor}`,
240
+ `${prefix}${textFields.tempSplitLoss}`
241
+ );
221
242
  lossColor = textFields.gasInputLoss < 3 ? "Green" : "Red";
222
243
  prefix = textFields.gasInputLoss == 0 ? "" : "-";
223
- form
224
- .getTextField(`FuelInputLosses${lossColor}`)
225
- .setText(`${prefix}${textFields.gasInputLoss}`);
244
+ safeSetText(
245
+ form,
246
+ `FuelInputLosses${lossColor}`,
247
+ `${prefix}${textFields.gasInputLoss}`
248
+ );
226
249
  lossColor = textFields.staticLoss < 3 ? "Green" : "Red";
227
250
  prefix = textFields.staticLoss == 0 ? "" : "-";
228
- form
229
- .getTextField(`AirDistributionLosses${lossColor}`)
230
- .setText(`${prefix}${textFields.staticLoss}`);
231
- form
232
- .getTextField("YourSystemScorePage2")
233
- .setText(`${systemScorePercentage} ${systemScoreGrade}`);
251
+ safeSetText(
252
+ form,
253
+ `AirDistributionLosses${lossColor}`,
254
+ `${prefix}${textFields.staticLoss}`
255
+ );
256
+ safeSetText(
257
+ form,
258
+ "YourSystemScorePage2",
259
+ `${systemScorePercentage} ${systemScoreGrade}`
260
+ );
234
261
 
235
262
  // print targets and range icons
236
263
  const measureLabels = [
@@ -262,9 +289,7 @@ export async function getReport(payload, _test) {
262
289
  else if (actual > high) iconPlacement = "High";
263
290
  else if (val) icon = iconRangeGreen;
264
291
  if (icon)
265
- form
266
- .getButton(`Image${measureLabels[i]}${iconPlacement}`)
267
- .setImage(icon);
292
+ safeSetImage(form, `Image${measureLabels[i]}${iconPlacement}`, icon);
268
293
  let targetZone = "";
269
294
  if (
270
295
  targetKeys[i] == "pressure_static_total_external" ||
@@ -273,7 +298,7 @@ export async function getReport(payload, _test) {
273
298
  targetZone = `(< ${high.toFixed(1)})`;
274
299
  else if (!isNaN(low) && low != "NaN" && !isNaN(high) && high != "NaN")
275
300
  targetZone = `(${low.toFixed(1)} - ${high.toFixed(1)})`;
276
- form.getTextField(`${measureLabels[i]}Target`).setText(targetZone);
301
+ safeSetText(form, `${measureLabels[i]}Target`, targetZone);
277
302
  }
278
303
 
279
304
  // if (payload.meta.boiler_type == '') {
@@ -294,9 +319,7 @@ export async function getReport(payload, _test) {
294
319
  specialCaseIcon = iconRangeGreen;
295
320
  specialCasePlacement = "Low";
296
321
  } else if (test.testInfo.data.coaf > 400) specialCasePlacement = "High";
297
- form
298
- .getButton(`ImageCOaf${specialCasePlacement}`)
299
- .setImage(specialCaseIcon);
322
+ safeSetImage(form, `ImageCOaf${specialCasePlacement}`, specialCaseIcon);
300
323
 
301
324
  specialCasePlacement = "Low";
302
325
  let efficiency = test.testInfo.data.efficiency
@@ -304,9 +327,11 @@ export async function getReport(payload, _test) {
304
327
  : test.testInfo.data.efficiency_gcv;
305
328
  if (efficiency >= 90) specialCasePlacement = "High";
306
329
  else if (efficiency >= 80) specialCasePlacement = "Mid";
307
- form
308
- .getButton(`ImageEfficiency${specialCasePlacement}`)
309
- .setImage(iconRangeGreen);
330
+ safeSetImage(
331
+ form,
332
+ `ImageEfficiency${specialCasePlacement}`,
333
+ iconRangeGreen
334
+ );
310
335
 
311
336
  // print pass fail measures
312
337
  if (test.testInfo.subsystem_review_complete) {
@@ -364,11 +389,11 @@ export async function getReport(payload, _test) {
364
389
  if (meas == "Caution") icon = iconRangeYellow;
365
390
  if (passFails[i] == "heating_efficiency_pass_fail")
366
391
  icon = iconRangeGreen;
367
- form.getButton(`ImageSubsystem${i + 1}_af_image`).setImage(icon);
392
+ safeSetImage(form, `ImageSubsystem${i + 1}_af_image`, icon);
368
393
  let suffix = test.testInfo[passFails[i] + "_override"] ? " *" : "";
369
- form.getTextField(`SSR${i + 1}`).setText(pfLabels[i] + suffix);
394
+ safeSetText(form, `SSR${i + 1}`, pfLabels[i] + suffix);
370
395
  }
371
- } else form.getTextField(`SSR1`).setText("Not yet reviewed");
396
+ } else safeSetText(form, `SSR1`, "Not yet reviewed");
372
397
 
373
398
  if (payload.meta.report_type != "FullReport") {
374
399
  let systemInfoPageBase64 = await systemInfoPage.getReport(payload);