|
4 | 4 | import org.apache.commons.lang.StringEscapeUtils; |
5 | 5 | import org.apache.commons.logging.Log; |
6 | 6 | import org.apache.commons.logging.LogFactory; |
| 7 | +import org.codehaus.jackson.map.ext.JodaDeserializers; |
| 8 | +import org.joda.time.DateMidnight; |
| 9 | +import org.joda.time.DateTime; |
| 10 | +import org.joda.time.LocalTime; |
7 | 11 | import org.openmrs.Encounter; |
8 | 12 | import org.openmrs.EncounterType; |
9 | 13 | import org.openmrs.Location; |
@@ -682,9 +686,17 @@ protected void validateDateWidget(FormEntryContext context, DateWidget dateWidge |
682 | 686 | } |
683 | 687 |
|
684 | 688 | if (context.getVisit() != null) { |
685 | | - if (date.before(((Visit) context.getVisit()).getStartDatetime())) { |
686 | | - throw new Exception("htmlformentry.error.cannotBeBeforeVisitStart"); |
| 689 | + // if the date is at midnight, just compare date components, on the assumption that HFE-UI will adjust as needed |
| 690 | + if (new DateTime(date).getMillisOfDay() == 0) { |
| 691 | + if (new DateTime(date).isBefore((new DateTime(((Visit) context.getVisit()).getStartDatetime()).withTimeAtStartOfDay()))) { |
| 692 | + throw new Exception("htmlformentry.error.cannotBeBeforeVisitStart"); |
| 693 | + } |
| 694 | + } else { |
| 695 | + if (date.before(((Visit) context.getVisit()).getStartDatetime())) { |
| 696 | + throw new Exception("htmlformentry.error.cannotBeBeforeVisitStart"); |
| 697 | + } |
687 | 698 | } |
| 699 | + |
688 | 700 | if (((Visit) context.getVisit()).getStopDatetime() != null && date.after(((Visit) context.getVisit()).getStopDatetime())) { |
689 | 701 | throw new Exception("htmlformentry.error.cannotBeAfterVisitStop"); |
690 | 702 | } |
|
0 commit comments