From d23c172770477798d0c7086ac1435aca1bf3efba Mon Sep 17 00:00:00 2001 From: Michael Seaton Date: Thu, 9 Jan 2025 17:38:10 -0500 Subject: [PATCH] HTML-848 - Order widget should consider time of order expiry when determining whether it can be revised. --- .../openmrs/module/htmlformentry/widget/OrderWidget.java | 4 ++-- omod/src/main/webapp/resources/orderWidget.js | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/org/openmrs/module/htmlformentry/widget/OrderWidget.java b/api/src/main/java/org/openmrs/module/htmlformentry/widget/OrderWidget.java index 48511591c..a9c74ff2c 100644 --- a/api/src/main/java/org/openmrs/module/htmlformentry/widget/OrderWidget.java +++ b/api/src/main/java/org/openmrs/module/htmlformentry/widget/OrderWidget.java @@ -118,7 +118,7 @@ public JsonObject constructJavascriptConfig(FormEntryContext context) { JsonObject jsonConfig = new JsonObject(); jsonConfig.addString("fieldName", fieldName); - jsonConfig.addString("defaultDate", new SimpleDateFormat("yyyy-MM-dd").format(defaultDate)); + jsonConfig.addString("defaultDate", getValueForProperty(defaultDate)); jsonConfig.addString("patientId", patId.toString()); jsonConfig.addString("encounterId", encId == null ? "" : encId.toString()); jsonConfig.addString("mode", context.getMode().name()); @@ -263,7 +263,7 @@ public String getValueForProperty(Object propertyValue) { val = ((OpenmrsObject) propertyValue).getId().toString(); } else if (propertyValue instanceof Date) { Date dateVal = (Date) propertyValue; - val = new SimpleDateFormat("yyyy-MM-dd").format(dateVal); + val = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(dateVal); } else if (propertyValue instanceof Class) { Class classValue = (Class) propertyValue; val = classValue.getName(); diff --git a/omod/src/main/webapp/resources/orderWidget.js b/omod/src/main/webapp/resources/orderWidget.js index 60148d217..0b7130de8 100644 --- a/omod/src/main/webapp/resources/orderWidget.js +++ b/omod/src/main/webapp/resources/orderWidget.js @@ -7,6 +7,14 @@ if (!encDate || encDate === '') { encDate = defaultDate; } + if (encDate.length === 10) { + if (defaultDate.startsWith(encDate)) { + encDate = defaultDate; + } + else { + encDate += 'T00:00:00'; + } + } return encDate; }