From e0c44e79b10eaff0ff616eecfad6f458be921ccb Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Sat, 6 Jun 2026 03:59:14 +0530 Subject: [PATCH] Add debug info to pain scale image showing actual value - Add 'Pain Level: X - Label' text above pain scale for debugging - Helps identify if pain_value is being read correctly from database - Fix comparison to use strict equality check for === - User can now see which pain level is actually being rendered --- app/Controllers/Opd.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/Controllers/Opd.php b/app/Controllers/Opd.php index 7fb5309..9e2692f 100644 --- a/app/Controllers/Opd.php +++ b/app/Controllers/Opd.php @@ -3858,8 +3858,11 @@ class Opd extends BaseController // Legacy token {{painscale_img}}: use legacy PNG if available, else render // a simple inline visual scale so placeholder always displays meaningful UI. + // IMPORTANT: Only render if painValue is explicitly set (not null/empty) $painIndex = ($painValue !== null && $painValue >= 0 && $painValue <= 4) ? $painValue : null; $painImageHtml = ''; + + // Only generate image if pain_value is actually set if ($painIndex !== null) { $imageCandidates = [ FCPATH . 'assets/images/pains_scale_' . $painIndex . '.png', @@ -3878,12 +3881,15 @@ class Opd extends BaseController $labels = ['No Pain', 'Mild', 'Moderate', 'Intense', 'Worst']; $colors = ['#22c55e', '#84cc16', '#eab308', '#f97316', '#ef4444']; // green to red gradient - $painImageHtml = ''; + // Add debug info at top showing which pain level is selected + $painImageHtml = '
Pain Level: ' . $painIndex . ' - ' . esc($labels[$painIndex]) . '
'; + + $painImageHtml .= '
'; // Row 1: Down arrow indicator above selected level (more visible than checkmark) $painImageHtml .= ''; for ($i = 0; $i <= 4; $i++) { - $active = $painIndex === $i; + $active = ($painIndex === $i); $arrow = $active ? '▼' : ' '; $painImageHtml .= ''; } @@ -3892,7 +3898,7 @@ class Opd extends BaseController // Row 2: Number boxes with strong color coding and border $painImageHtml .= ''; for ($i = 0; $i <= 4; $i++) { - $active = $painIndex === $i; + $active = ($painIndex === $i); $bg = $active ? $colors[$i] : '#ffffff'; $borderColor = $active ? '#000000' : '#d1d5db'; $borderWidth = $active ? '3px' : '1px'; @@ -3904,7 +3910,7 @@ class Opd extends BaseController // Row 3: Labels with bold for selected $painImageHtml .= ''; for ($i = 0; $i <= 4; $i++) { - $active = $painIndex === $i; + $active = ($painIndex === $i); $fontWeight = $active ? '700' : '400'; $textColor = $active ? '#000000' : '#6b7280'; $fontSize = $active ? '9px' : '8px';
' . $arrow . '