@measurequick/measurequick-report-generator 1.5.219 → 1.5.221

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.219",
3
+ "version": "1.5.221",
4
4
  "description": "Generates PDF documents for various measureQuick applications.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -318,23 +318,48 @@ export async function getReport(payload, _test) {
318
318
 
319
319
  if (coHigh) {
320
320
  VH_LOG("Setting CO warnings in form fields: COWarning / COWarning2");
321
- // Find the highest severity level
321
+ // Find the highest severity level and the ambient CO reading
322
322
  var highestLevel = "Elevated";
323
- var maxPpm = 0;
323
+ var ambientReading = null;
324
324
  for (var r = 0; r < reasons.length; r++) {
325
- if (reasons[r].value > maxPpm) maxPpm = reasons[r].value;
325
+ if (reasons[r].type === "Ambient") ambientReading = reasons[r];
326
326
  if (reasons[r].level === "Emergency") highestLevel = "Emergency";
327
327
  else if (reasons[r].level === "Dangerous" && highestLevel !== "Emergency") highestLevel = "Dangerous";
328
328
  }
329
329
 
330
- // Build details string showing each elevated reading
331
- var details = reasons.map(function(r) { return r.type + ": " + Math.round(r.value) + " ppm (" + r.level + ")"; }).join(", ");
330
+ // Build warning message focused on ambient CO
331
+ var warningMsg, warningMsg2;
332
+ if (ambientReading) {
333
+ warningMsg = "WARNING: " + ambientReading.level + " Ambient CO Detected: " + Math.round(ambientReading.value) + " ppm\nVentilate the area and investigate source.";
334
+ warningMsg2 = "WARNING: " + ambientReading.level + " Ambient CO Detected: " + Math.round(ambientReading.value) + " ppm. Ventilate the area and investigate source.";
335
+ } else {
336
+ // Fallback if no ambient reading (use first reading)
337
+ var firstReading = reasons[0];
338
+ warningMsg = "WARNING: " + firstReading.level + " " + firstReading.type + " CO Detected: " + Math.round(firstReading.value) + " ppm\nVentilate the area and investigate source.";
339
+ warningMsg2 = "WARNING: " + firstReading.level + " " + firstReading.type + " CO Detected: " + Math.round(firstReading.value) + " ppm. Ventilate the area and investigate source.";
340
+ }
332
341
 
333
- var warningMsg = "WARNING: " + highestLevel + " CO Detected! " + details + "\nVentilate the area and investigate the source.";
334
- var warningMsg2 = "WARNING: " + highestLevel + " CO Detected! " + details + " Ventilate the area and investigate the source.";
342
+ // Set text with color based on severity level
343
+ // Orange for Elevated, Red for Dangerous, Dark Red for Emergency
344
+ var warningColor;
345
+ if (highestLevel === "Emergency") {
346
+ warningColor = rgb(0.72, 0.11, 0.11); // Dark red (#b71c1c)
347
+ } else if (highestLevel === "Dangerous") {
348
+ warningColor = rgb(0.96, 0.26, 0.21); // Red (#f44336)
349
+ } else {
350
+ warningColor = rgb(1, 0.6, 0); // Orange (#ff9800)
351
+ }
335
352
 
336
- safeSetText(form, "COWarning", warningMsg);
337
- safeSetText(form, "COWarning2", warningMsg2);
353
+ try {
354
+ var tf1 = form.getTextField("COWarning");
355
+ tf1.setText(warningMsg);
356
+ tf1.setTextColor(warningColor);
357
+ } catch (e) {}
358
+ try {
359
+ var tf2 = form.getTextField("COWarning2");
360
+ tf2.setText(warningMsg2);
361
+ tf2.setTextColor(warningColor);
362
+ } catch (e) {}
338
363
  } else {
339
364
  VH_LOG("Clearing CO warnings (values within threshold)");
340
365
  // clear warnings if not applicable
@@ -644,29 +669,39 @@ export async function getReport(payload, _test) {
644
669
 
645
670
  // Special handling for Ambient CO
646
671
  if (passFails[i] === "ambient_pass_fail") {
647
- const coValue = test.data && test.data.co_ambient !== undefined && test.data.co_ambient !== null
648
- ? Number(test.data.co_ambient)
649
- : null;
672
+ // Use coAmbRaw which is already defined and validated earlier in the function
673
+ const coValue = isFinite(coAmbRaw) ? coAmbRaw : null;
650
674
 
651
675
  // Use CO-specific icon based on actual value
652
- if (coValue !== null && !isNaN(coValue)) {
676
+ if (coValue !== null) {
653
677
  icon = getCOIcon(coValue);
654
678
  const stateText = getCOStateText(coValue);
655
- label = "Ambient CO: " + Math.round(coValue) + " ppm" + (stateText ? " (" + stateText + ")" : "") + suffix;
679
+
680
+ // Format label based on CO level
681
+ if (coValue <= 8) {
682
+ // Normal - just show value
683
+ label = "Ambient CO: " + Math.round(coValue) + " ppm" + suffix;
684
+ } else {
685
+ // Elevated/Dangerous/Emergency - show level and "Investigate!"
686
+ label = "CO Ambient " + stateText + " " + Math.round(coValue) + " ppm, Investigate!" + suffix;
687
+ }
656
688
 
657
689
  // Set text color based on CO level
658
- if (coValue >= 36) {
659
- textColor = rgb(1, 0, 0); // Red for Dangerous/Emergency
690
+ // Orange for Elevated, Red for Dangerous, Dark Red for Emergency
691
+ if (coValue >= 70) {
692
+ textColor = rgb(0.72, 0.11, 0.11); // Dark red for Emergency
693
+ } else if (coValue >= 36) {
694
+ textColor = rgb(0.96, 0.26, 0.21); // Red for Dangerous
660
695
  } else if (coValue >= 9) {
661
- textColor = rgb(0.8, 0.4, 0); // Orange for Elevated
696
+ textColor = rgb(1, 0.6, 0); // Orange for Elevated
662
697
  }
663
698
  } else {
664
699
  // No CO value, use pass/fail status
665
700
  const isFail = !(meas === "Pass" || meas === "High" || meas === "Mid" || meas === "Caution");
666
701
  if (isFail) {
667
- label = "CO Ambient High, Investigate Source!" + suffix;
668
- textColor = rgb(1, 0, 0);
669
- icon = iconRangeRed;
702
+ label = "CO Ambient Elevated, Investigate!" + suffix;
703
+ textColor = rgb(1, 0.6, 0); // Orange
704
+ icon = iconRangeYellow;
670
705
  }
671
706
  }
672
707
  }