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 diff --git a/ehr/resources/web/ehr/DataEntryUtils.js b/ehr/resources/web/ehr/DataEntryUtils.js index fde22bc77..180149642 100644 --- a/ehr/resources/web/ehr/DataEntryUtils.js +++ b/ehr/resources/web/ehr/DataEntryUtils.js @@ -726,7 +726,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, @@ -872,7 +872,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 } }