From 9c286cb2e535628cc020b513d594c311840860de Mon Sep 17 00:00:00 2001 From: Marty Pradere Date: Fri, 28 Feb 2025 12:03:13 -0800 Subject: [PATCH 1/3] Add frequency.meaning to formulary store (#897) --- ehr/resources/web/ehr/DataEntryUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ehr/resources/web/ehr/DataEntryUtils.js b/ehr/resources/web/ehr/DataEntryUtils.js index 99ff5eea7..7833a71af 100644 --- a/ehr/resources/web/ehr/DataEntryUtils.js +++ b/ehr/resources/web/ehr/DataEntryUtils.js @@ -728,7 +728,7 @@ EHR.DataEntryUtils = new function(){ type: 'labkey-store', schemaName: 'ehr_lookups', queryName: 'drug_defaults', - columns: 'code,code/meaning,dosage,dosage_units,concentration,conc_units,amount,amount_units,amount_rounding,volume,vol_units,volume_rounding,route,frequency,duration,remark,offset', + columns: 'code,code/meaning,dosage,dosage_units,concentration,conc_units,amount,amount_units,amount_rounding,volume,vol_units,volume_rounding,route,frequency,frequency/meaning,duration,remark,offset', sort: 'code', storeId: storeId, autoLoad: true, From 48ab18dc84d1ed037bbf48f6133c863e3eaf34b2 Mon Sep 17 00:00:00 2001 From: Marty Pradere Date: Sun, 2 Mar 2025 13:28:15 -0800 Subject: [PATCH 2/3] Create CODEOWNERS (#898) --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..623678e23 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +@labkey-martyp \ No newline at end of file From b5a5ebc82af8670e8a85cc5393cbe34bba0a8ed1 Mon Sep 17 00:00:00 2001 From: Marty Pradere Date: Mon, 3 Mar 2025 13:35:29 -0800 Subject: [PATCH 3/3] Formulary rounding fixes (#899) * Fix conditional when amount rounding should be done * Update rounding to nearest function to handle floating point precision issues. * Allow greater precision in rounding field --- ehr/resources/web/ehr/DataEntryUtils.js | 2 +- ehr/resources/web/ehr/utils.js | 16 +++------------- ehr/resources/web/ehr/window/DrugAmountWindow.js | 3 ++- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/ehr/resources/web/ehr/DataEntryUtils.js b/ehr/resources/web/ehr/DataEntryUtils.js index 7833a71af..b3219d0f7 100644 --- a/ehr/resources/web/ehr/DataEntryUtils.js +++ b/ehr/resources/web/ehr/DataEntryUtils.js @@ -874,7 +874,7 @@ EHR.DataEntryUtils = new function(){ } } - if (!amount && Ext4.isEmpty(rounding)){ + if (amount && !Ext4.isEmpty(rounding)){ amount = EHR.Utils.roundToNearest(amount, rounding); } diff --git a/ehr/resources/web/ehr/utils.js b/ehr/resources/web/ehr/utils.js index aa0c3926b..580e6909e 100644 --- a/ehr/resources/web/ehr/utils.js +++ b/ehr/resources/web/ehr/utils.js @@ -497,19 +497,9 @@ EHR.Utils = new function(){ return val; } - var remainder = val % round; - var remainderPct = remainder / round; - var base = Math.floor(val / round); - if (remainder === 0){ - return val; - } - //note: JS seems to handle division poorly in situations like 4 / 0.1 - else if (remainderPct < 0.5 || remainderPct > 0.9999){ - return (base * round); - } - else { - return (base * round) + round; - } + let rounded = Math.round(val / round) * round; + let precision = (round.toString().split('.')[1] || "").length; // Get decimal places in `round` + return rounded.toFixed(precision); // toFixed handles floating point precision issues }, editUIButtonCore: function(schemaName, queryName, dataRegionName, paramMap, copyFilters, params){ diff --git a/ehr/resources/web/ehr/window/DrugAmountWindow.js b/ehr/resources/web/ehr/window/DrugAmountWindow.js index 852ceb509..1fa08fb93 100644 --- a/ehr/resources/web/ehr/window/DrugAmountWindow.js +++ b/ehr/resources/web/ehr/window/DrugAmountWindow.js @@ -394,7 +394,8 @@ Ext4.define('EHR.window.DrugAmountWindow', { found = true; editor = { xtype: 'ldk-numberfield', - fieldName: fieldName + fieldName: fieldName, + decimalPrecision: 6 } }