-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RA-950: Add LastVisit and EditVisit require an EndDate #275
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,31 +31,30 @@ public Object create(@SpringBean("adtService") AdtService adtService, | |
@RequestParam(value = "stopDate", required = false) Date stopDate, | ||
HttpServletRequest request, UiUtils ui) { | ||
|
||
// if no stop date, set it to start date | ||
if (stopDate == null) { | ||
stopDate = startDate; | ||
} | ||
|
||
// set the startDate time component to the start of day | ||
startDate = new DateTime(startDate).withTime(0,0,0,0).toDate(); | ||
|
||
// if stopDate is today, set stopDate to current datetime, otherwise set time component to end of date | ||
if (stopDate != null){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why enclose these in if stopDate != null? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the methods enclosed here are for formatting the endDate which is not neccessary when the stopDate is null.... |
||
if (new DateTime().withTime(0,0,0,0).equals(new DateTime(stopDate).withTime(0,0,0,0))) { | ||
stopDate = new Date(); | ||
} | ||
else { | ||
stopDate = new DateTime(stopDate).withTime(23, 59, 59, 999).toDate(); | ||
} | ||
} | ||
|
||
try { | ||
|
||
VisitDomainWrapper createdVisit = adtService.createRetrospectiveVisit(patient, location, startDate, stopDate); | ||
|
||
request.getSession().setAttribute(AppUiConstants.SESSION_ATTRIBUTE_INFO_MESSAGE, | ||
ui.message("coreapps.retrospectiveVisit.addedVisitMessage")); | ||
request.getSession().setAttribute(AppUiConstants.SESSION_ATTRIBUTE_TOAST_MESSAGE, "true"); | ||
|
||
return SimpleObject.create("success", true, "id", createdVisit.getVisit().getId().toString(), "uuid", createdVisit.getVisit().getUuid()); | ||
} | ||
|
||
} | ||
catch (ExistingVisitDuringTimePeriodException e) { | ||
|
||
// if there are existing visit(s), return these existing visits | ||
|
@@ -70,6 +69,7 @@ public Object create(@SpringBean("adtService") AdtService adtService, | |
} | ||
} | ||
|
||
|
||
return simpleVisits; | ||
} | ||
catch (Exception e) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,12 +37,16 @@ public SimpleObject setDuration(@SpringBean("visitService") VisitService visitSe | |
@RequestParam(value="stopDate", required = false) Date stopDate, | ||
HttpServletRequest request, UiUtils ui) { | ||
|
||
|
||
if (!isSameDay(startDate, visit.getStartDatetime())) { | ||
visit.setStartDatetime(new DateTime(startDate).toDateMidnight().toDate()); | ||
} | ||
|
||
if ( (stopDate!=null) && !isSameDay(stopDate, visit.getStopDatetime())) { | ||
if(stopDate == null){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the motivation for this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This same logic is mantained on line 48, which still is for analysing to see if the stopDate is now...And so i introduced this method to allow the retrospective stopdate to be set to null thus make it active and not default it to startDate as it was |
||
|
||
visit.setStopDatetime(null); | ||
|
||
} else if (!isSameDay(stopDate, visit.getStopDatetime())) { | ||
|
||
Date now = new DateTime().toDate(); | ||
if (isSameDay(stopDate, now)) { | ||
visit.setStopDatetime(now); | ||
|
@@ -54,15 +58,16 @@ public SimpleObject setDuration(@SpringBean("visitService") VisitService visitSe | |
.withMillisOfSecond(999) | ||
.toDate()); | ||
} | ||
|
||
} | ||
|
||
visitService.saveVisit(visit); | ||
|
||
request.getSession().setAttribute(AppUiConstants.SESSION_ATTRIBUTE_INFO_MESSAGE, ui.message("coreapps.editVisitDate.visitSavedMessage")); | ||
request.getSession().setAttribute(AppUiConstants.SESSION_ATTRIBUTE_TOAST_MESSAGE, "true"); | ||
|
||
return SimpleObject.create("success", true, "search", "?patientId=" + visit.getPatient().getId() + "&visitId=" + visit.getId()); | ||
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
defaultDate: config.defaultStartDate | ||
])} | ||
</p> | ||
<% if(config.defaultEndDate != null) { %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why change this from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was really a hack to allow the user to have a null defaultEndDate yet at the same time preventing the user setting an end date on an Active visit which was already in place.... |
||
<% if(config.visitEndDate != null) { %> | ||
<p> | ||
<label for="stopDate" class="required"> | ||
${ ui.message("coreapps.stopDate.label") } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,14 +78,28 @@ | |
${ ui.message("coreapps.stopDate.label") } | ||
</label> | ||
${ ui.includeFragment("uicommons", "field/datetimepicker", [ | ||
<% if(activeVisits){ %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason for changing the formatting here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not an intended change... |
||
${ ui.includeFragment("uicommons", "field/datetimepicker", [ | ||
id: "retrospectiveVisitStopDate", | ||
formFieldName: "retrospectiveVisitStopDate", | ||
label:"", | ||
defaultDate: visitEndTime, | ||
endDate: editDateFormat.format(visitEndTime), | ||
useTime: false, | ||
])} | ||
])} | ||
<% } else { %> | ||
${ ui.includeFragment("uicommons", "field/datetimepicker", [ | ||
id: "noActiveVisitStopDate", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we adding this field/fragment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From line 81. This is to force the user have a default stop date if they are entering a retrospective Visit yet we are currently having an active visit otherwise if there is no active visit then we can allow them create a retrospective visit that has a null end date thus making it Active(there is already a catch implemented if the restrospective visit is overlaping with another) |
||
formFieldName: "retrospectiveVisitStopDate", | ||
label:"", | ||
defaultDate: null, | ||
endDate: editDateFormat.format(visitEndTime), | ||
useTime: false, | ||
])} | ||
<% } %> | ||
</p> | ||
<br><br> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,7 +103,8 @@ | |
startDateLowerLimit: (idx + 1 == visits.size || visits[idx + 1].stopDatetime == null) ? null : editDateFormat.format(org.apache.commons.lang.time.DateUtils.addDays(visits[idx + 1].stopDatetime, 1)), | ||
startDateUpperLimit: wrapper.oldestEncounter == null && wrapper.stopDatetime == null ? editDateFormat.format(new Date()) : editDateFormat.format(wrapper.oldestEncounter == null ? wrapper.stopDatetime : wrapper.oldestEncounter.encounterDatetime), | ||
defaultStartDate: wrapper.startDatetime, | ||
defaultEndDate: wrapper.stopDatetime | ||
defaultEndDate:idx == 0 ? null : wrapper.stopDatetime, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the motivation for this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to allow user to make a most recent Visit endDate null so as to make it an active visit otherwise if the visit is behind another visit in time then you are forced to have a default end Date |
||
visitEndDate: wrapper.stopDatetime | ||
]) } | ||
${ ui.includeFragment("coreapps", "patientdashboard/editVisit", [ | ||
visit: wrapper.visit, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,11 +95,10 @@ public void test_shouldCreateNewRetrospectiveVisit_whenNoStopDateSpecified() thr | |
|
||
// should round to the time components to the start and end of the days, respectively | ||
Date expectedStartDate = new DateTime(2012, 1, 1, 0, 0, 0, 0).toDate(); | ||
Date expectedStopDate = new DateTime(2012, 1, 1, 23, 59, 59, 999).toDate(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove the above line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is to verify what I had changed in the sense that now we can allow the user to pass a null end Date and not default it to the startDate |
||
|
||
Visit visit = createVisit(); | ||
|
||
when(adtService.createRetrospectiveVisit(patient, location, expectedStartDate, expectedStopDate)).thenReturn(new VisitDomainWrapper(visit)); | ||
when(adtService.createRetrospectiveVisit(patient, location, expectedStartDate, null)).thenReturn(new VisitDomainWrapper(visit)); | ||
|
||
SimpleObject result = (SimpleObject) controller.create(adtService, patient, location, startDate, null, request, ui); | ||
|
||
|
@@ -118,7 +117,7 @@ public void test_shouldReturnConflictingVisits() throws Exception { | |
Patient patient = new Patient(); | ||
Location location = new Location(); | ||
Date startDate = new DateTime(2012, 1, 1, 12, 12, 12).toDate(); | ||
|
||
Date stopDate = startDate; | ||
// should round to the time components to the start and end of the days, respectively | ||
Date expectedStartDate = new DateTime(2012, 1, 1, 0, 0, 0, 0).toDate(); | ||
Date expectedStopDate = new DateTime(2012, 1, 1, 23, 59, 59, 999).toDate(); | ||
|
@@ -135,7 +134,7 @@ public void test_shouldReturnConflictingVisits() throws Exception { | |
|
||
when(ui.format(any())).thenReturn("someDate"); | ||
|
||
List<SimpleObject> result = (List<SimpleObject>) controller.create(adtService, patient, location, startDate, null, request, ui); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why replace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method is to catch any overlaps which was automatically parsing any null endDate to startDate which this enhancement altered and thus for it to pass and still be logical it works only if there is an assigned endDate since i enclosed it in an If condition on line 39 in RetrospectiveVisitFragmentController |
||
List<SimpleObject> result = (List<SimpleObject>) controller.create(adtService, patient, location, startDate, stopDate, request, ui); | ||
|
||
assertThat(result.size(), is(1)); | ||
assertThat(result.get(0).toJson(), is("{\"startDate\":\"someDate\",\"stopDate\":\"someDate\",\"id\":null,\"uuid\":\"" + conflictingVisit.getUuid() + "\"}")); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the motivation for removing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because with this enhancement we can allow a user to pass a null stopDate which will make that retrospective visit an active visit....this code was instead forcing any such action to default the end date to startDate