@measurequick/measurequick-report-generator 1.5.217 → 1.5.218

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.217",
3
+ "version": "1.5.218",
4
4
  "description": "Generates PDF documents for various measureQuick applications.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -283,25 +283,41 @@ export async function getReport(payload, _test) {
283
283
  coSupRaw,
284
284
  });
285
285
 
286
+ // CO level helper function
287
+ // Normal: 0-8 ppm, Elevated: 9-35 ppm, Dangerous: 36-69 ppm, Emergency: 70+ ppm
288
+ function getCOLevel(ppm) {
289
+ if (!isFinite(ppm) || ppm <= 8) return "Normal";
290
+ if (ppm >= 9 && ppm <= 35) return "Elevated";
291
+ if (ppm >= 36 && ppm <= 69) return "Dangerous";
292
+ return "Emergency";
293
+ }
294
+
286
295
  var reasons = [];
287
- if (isFinite(coAmbRaw) && coAmbRaw > 9) reasons.push("ambient=" + coAmbRaw);
288
- if (isFinite(coRetRaw) && coRetRaw > 9) reasons.push("return=" + coRetRaw);
289
- if (isFinite(coSupRaw) && coSupRaw > 9) reasons.push("supply=" + coSupRaw);
296
+ if (isFinite(coAmbRaw) && coAmbRaw > 8) reasons.push({ type: "Ambient", value: coAmbRaw, level: getCOLevel(coAmbRaw) });
297
+ if (isFinite(coRetRaw) && coRetRaw > 8) reasons.push({ type: "Return", value: coRetRaw, level: getCOLevel(coRetRaw) });
298
+ if (isFinite(coSupRaw) && coSupRaw > 8) reasons.push({ type: "Supply", value: coSupRaw, level: getCOLevel(coSupRaw) });
290
299
  var coHigh = reasons.length > 0;
291
- VH_LOG("CO threshold check > 9 ppm:", { coHigh, reasons });
300
+ VH_LOG("CO threshold check > 8 ppm:", { coHigh, reasons });
292
301
 
293
302
  if (coHigh) {
294
303
  VH_LOG("Setting CO warnings in form fields: COWarning / COWarning2");
295
- safeSetText(
296
- form,
297
- "COWarning",
298
- "WARNING: Elevated CO above 9 ppm Detected!\nVentilate the area and investigate the source."
299
- );
300
- safeSetText(
301
- form,
302
- "COWarning2",
303
- "WARNING: Elevated CO above 9 ppm Detected! Ventilate the area and investigate the source."
304
- );
304
+ // Find the highest severity level
305
+ var highestLevel = "Elevated";
306
+ var maxPpm = 0;
307
+ for (var r = 0; r < reasons.length; r++) {
308
+ if (reasons[r].value > maxPpm) maxPpm = reasons[r].value;
309
+ if (reasons[r].level === "Emergency") highestLevel = "Emergency";
310
+ else if (reasons[r].level === "Dangerous" && highestLevel !== "Emergency") highestLevel = "Dangerous";
311
+ }
312
+
313
+ // Build details string showing each elevated reading
314
+ var details = reasons.map(function(r) { return r.type + ": " + Math.round(r.value) + " ppm (" + r.level + ")"; }).join(", ");
315
+
316
+ var warningMsg = "WARNING: " + highestLevel + " CO Detected! " + details + "\nVentilate the area and investigate the source.";
317
+ var warningMsg2 = "WARNING: " + highestLevel + " CO Detected! " + details + " Ventilate the area and investigate the source.";
318
+
319
+ safeSetText(form, "COWarning", warningMsg);
320
+ safeSetText(form, "COWarning2", warningMsg2);
305
321
  } else {
306
322
  VH_LOG("Clearing CO warnings (values within threshold)");
307
323
  // clear warnings if not applicable