Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@labkey-martyp
4 changes: 2 additions & 2 deletions ehr/resources/web/ehr/DataEntryUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -874,7 +874,7 @@ EHR.DataEntryUtils = new function(){
}
}

if (!amount && Ext4.isEmpty(rounding)){
if (amount && !Ext4.isEmpty(rounding)){
amount = EHR.Utils.roundToNearest(amount, rounding);
}

Expand Down
16 changes: 3 additions & 13 deletions ehr/resources/web/ehr/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
3 changes: 2 additions & 1 deletion ehr/resources/web/ehr/window/DrugAmountWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ Ext4.define('EHR.window.DrugAmountWindow', {
found = true;
editor = {
xtype: 'ldk-numberfield',
fieldName: fieldName
fieldName: fieldName,
decimalPrecision: 6
}
}

Expand Down