From d93ac70f788ca271c94f545105c8dacba047e1e4 Mon Sep 17 00:00:00 2001 From: stephen waite Date: Sat, 27 Jan 2024 16:22:30 -0500 Subject: [PATCH] fix: support multiple modifiers in fee sheet (#7166) * fix: support multiple modifiers in fee sheet * add function for modifier work * disable text template for fee sheet * validate modifiers * nice catch by Brady, bring new coding tab to custom json menu * use recursive last char function --- interface/forms/fee_sheet/new.php | 48 +++++++++++++++++-- interface/main/tabs/menu/menus/standard.json | 8 ++-- .../patient_file/encounter/load_form.php | 2 +- interface/super/edit_list.php | 5 +- .../documents/custom_menus/Custom.json | 8 ++-- 5 files changed, 58 insertions(+), 13 deletions(-) diff --git a/interface/forms/fee_sheet/new.php b/interface/forms/fee_sheet/new.php index c689445e0bd..831529b0232 100644 --- a/interface/forms/fee_sheet/new.php +++ b/interface/forms/fee_sheet/new.php @@ -220,7 +220,7 @@ function echoServiceLines() if ($codetype != 'COPAY' && (!empty($code_types[$codetype]['mod']) || $modifier)) { echo " \n"; + "value='" . attr($modifier) . "' size='" . attr($code_types[$codetype]['mod']) . "' onkeyup='policykeyup(this)' onblur='formatModifier(this)' />\n"; } else { echo "  \n"; } @@ -670,7 +670,12 @@ function echoProductLines() $arrcode = explode('|', $codestring); if (strpos($arrcode[1], ':') !== false) { - list($code, $modifier) = explode(":", $arrcode[1]); + $tmp = explode(':', $arrcode[1]); + $code = $tmp[0] ?? ''; + $modifier = $tmp[1] ?? ''; + $modifier .= ($tmp[2] ?? '') ? ":" . $tmp[2] : ''; + $modifier .= ($tmp[3] ?? '') ? ":" . $tmp[3] : ''; + $modifier .= ($tmp[4] ?? '') ? ":" . $tmp[4] : ''; } else { $code = $arrcode[1]; $modifier = ''; @@ -906,6 +911,38 @@ function defaultPriceLevelChanged(sel) { } } +function formatModifier(e) { + let mods = e.value; + mods = mods.substring(0, 11).trim(); + let modArray = mods.includes(':') ? mods.split(":") : mods.split(" "); + let cntr = 0; + modArray.forEach( function(m) { + let l = m.length; + if (l) { + cntr++; + if (l !== 2) { + alert("Removing invalid modifier " + m); + modArray.pop(); + } + } else { + modArray.pop(); + } + }); + + let modString = modArray.join(":"); + e.value = checkLastChar(modString); +} + +function checkLastChar(s) { + let last_char = s.slice(-1); + if (last_char === ':') { + s = s.substring(0, s.length - 1); + return checkLastChar(s); + } else { + return s; + } +} +