Skip to content

Commit 8325c25

Browse files
committed
HTML-871 - Drug Order Widget does not clear out dosage information when saving free text dosage
1 parent 746c973 commit 8325c25

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

omod/src/main/webapp/resources/orderWidget.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@
305305
} else if (action === 'REVISE' || action === 'NEW') {
306306
$orderForm.find('.order-orderReason').show();
307307
$orderForm.find('.order-orderReasonNonCoded').show();
308-
orderWidget.enableOrderDoseWidgets($orderForm);
308+
orderWidget.enableOrderDoseWidgets($orderForm, false);
309309
$orderForm.find('.order-urgency').show();
310310
orderWidget.enableOrderDurationWidgets($orderForm);
311311
orderWidget.enableServiceOrderWidgets($orderForm);
@@ -314,7 +314,7 @@
314314
// Set up ability to toggle between free-text and simple dosing instructions
315315
$orderForm.find('.order-dosingType').find('input:radio').change(function () {
316316
if (action === 'REVISE' || action === 'NEW') {
317-
orderWidget.enableOrderDoseWidgets($orderForm);
317+
orderWidget.enableOrderDoseWidgets($orderForm, true);
318318
}
319319
});
320320

@@ -489,17 +489,19 @@
489489
}
490490
};
491491

492-
orderWidget.enableOrderDoseWidgets = function($orderForm) {
492+
orderWidget.enableOrderDoseWidgets = function($orderForm, clearExistingValues) {
493493
var $dosingTypeSection = $orderForm.find('.order-dosingType');
494494
var dosingTypeVal = $dosingTypeSection.find('input:checked').val();
495495

496-
$orderForm.find('.order-field-widget.order-dose').find(':input').val("");
497-
$orderForm.find('.order-field-widget.order-doseUnits').find(':input').val("");
498-
$orderForm.find('.order-field-widget.order-frequency').find(':input').val("");
499-
$orderForm.find('.order-field-widget.order-route').find(':input').val("");
500-
$orderForm.find('.order-field-widget.order-asNeeded').find(':input').removeAttr("checked");
501-
$orderForm.find('.order-field-widget.order-instructions').find(':input').val("");
502-
$orderForm.find('.order-field-widget.order-dosingInstructions').find(':input').val("");
496+
if (clearExistingValues) {
497+
$orderForm.find('.order-field-widget.order-dose').find(':input').val("");
498+
$orderForm.find('.order-field-widget.order-doseUnits').find(':input').val("");
499+
$orderForm.find('.order-field-widget.order-frequency').find(':input').val("");
500+
$orderForm.find('.order-field-widget.order-route').find(':input').val("");
501+
$orderForm.find('.order-field-widget.order-asNeeded').find(':input').removeAttr("checked");
502+
$orderForm.find('.order-field-widget.order-instructions').find(':input').val("");
503+
$orderForm.find('.order-field-widget.order-dosingInstructions').find(':input').val("");
504+
}
503505

504506
if (dosingTypeVal === 'org.openmrs.FreeTextDosingInstructions') {
505507
$orderForm.find('.order-dose').hide();

0 commit comments

Comments
 (0)