@measurequick/measurequick-report-generator 1.5.223 → 1.5.224

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.223",
3
+ "version": "1.5.224",
4
4
  "description": "Generates PDF documents for various measureQuick applications.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -256,18 +256,67 @@ export async function getReport(payload, _test) {
256
256
  var coAmbRaw = toNum(data && data.co_ambient);
257
257
  var coRetRaw = toNum(data && data.co_return);
258
258
  var coSupRaw = toNum(data && data.co_supply);
259
- if (isFinite(coAmbRaw) && coAmbRaw > 9) {
260
- safeSetText(
261
- form,
262
- "COWarning",
263
- "WARNING: Elevated CO Above 9 ppm Detected!\nVentilate the area and investigate the source."
264
- );
265
- safeSetText(
266
- form,
267
- "COWarning2",
268
- "WARNING: Elevated CO Above 9 ppm Detected! Ventilate the area and investigate the source."
269
- );
259
+
260
+ // CO level helper function
261
+ // Normal: 0-8 ppm, Elevated: 9-35 ppm, Dangerous: 36-69 ppm, Emergency: 70+ ppm
262
+ function getCOLevel(ppm) {
263
+ if (!isFinite(ppm) || ppm <= 8) return "Normal";
264
+ if (ppm >= 9 && ppm <= 35) return "Elevated";
265
+ if (ppm >= 36 && ppm <= 69) return "Dangerous";
266
+ return "Emergency";
267
+ }
268
+
269
+ var reasons = [];
270
+ if (isFinite(coAmbRaw) && coAmbRaw > 8) reasons.push({ type: "Ambient", value: coAmbRaw, level: getCOLevel(coAmbRaw) });
271
+ if (isFinite(coRetRaw) && coRetRaw > 8) reasons.push({ type: "Return", value: coRetRaw, level: getCOLevel(coRetRaw) });
272
+ if (isFinite(coSupRaw) && coSupRaw > 8) reasons.push({ type: "Supply", value: coSupRaw, level: getCOLevel(coSupRaw) });
273
+ var coHigh = reasons.length > 0;
274
+
275
+ if (coHigh) {
276
+ // Find the highest severity level and the ambient CO reading
277
+ var highestLevel = "Elevated";
278
+ var ambientReading = null;
279
+ for (var r = 0; r < reasons.length; r++) {
280
+ if (reasons[r].type === "Ambient") ambientReading = reasons[r];
281
+ if (reasons[r].level === "Emergency") highestLevel = "Emergency";
282
+ else if (reasons[r].level === "Dangerous" && highestLevel !== "Emergency") highestLevel = "Dangerous";
283
+ }
284
+
285
+ // Build warning message focused on ambient CO
286
+ var warningMsg, warningMsg2;
287
+ if (ambientReading) {
288
+ warningMsg = "WARNING: " + ambientReading.level + " Ambient CO " + Math.round(ambientReading.value) + " ppm\nVentilate the area and investigate source.";
289
+ warningMsg2 = "WARNING: " + ambientReading.level + " Ambient CO " + Math.round(ambientReading.value) + " ppm. Ventilate the area and investigate source.";
290
+ } else {
291
+ // Fallback if no ambient reading (use first reading)
292
+ var firstReading = reasons[0];
293
+ warningMsg = "WARNING: " + firstReading.level + " " + firstReading.type + " CO " + Math.round(firstReading.value) + " ppm\nVentilate the area and investigate source.";
294
+ warningMsg2 = "WARNING: " + firstReading.level + " " + firstReading.type + " CO " + Math.round(firstReading.value) + " ppm. Ventilate the area and investigate source.";
295
+ }
296
+
297
+ // Set text with color based on severity level
298
+ // Orange for Elevated, Red for Dangerous, Dark Red for Emergency
299
+ var warningColor;
300
+ if (highestLevel === "Emergency") {
301
+ warningColor = rgb(0.72, 0.11, 0.11); // Dark red (#b71c1c)
302
+ } else if (highestLevel === "Dangerous") {
303
+ warningColor = rgb(0.96, 0.26, 0.21); // Red (#f44336)
304
+ } else {
305
+ warningColor = rgb(1, 0.6, 0); // Orange (#ff9800)
306
+ }
307
+
308
+ try {
309
+ var tf1 = form.getTextField("COWarning");
310
+ tf1.setText(warningMsg);
311
+ tf1.setTextColor(warningColor);
312
+ } catch (e) {}
313
+ try {
314
+ var tf2 = form.getTextField("COWarning2");
315
+ tf2.setText(warningMsg2);
316
+ tf2.setTextColor(warningColor);
317
+ } catch (e) {}
270
318
  } else {
319
+ // clear warnings if not applicable
271
320
  safeSetText(form, "COWarning", "");
272
321
  safeSetText(form, "COWarning2", "");
273
322
  }