Skip to content

Commit

Permalink
[Bug] enable retrieving deleted Visits (openmrs#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
chibujax authored and dkayiwa committed Oct 23, 2017
1 parent 7dc17bf commit 191e0b6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ private SimpleObject getVisits(RequestContext context, String patientParameter,
Collection<Patient> patients = patientParameter == null ? null : Arrays.asList(getPatient(patientParameter));
boolean includeInactive = includeInactiveParameter == null ? true : Boolean.parseBoolean(includeInactiveParameter);
return new NeedsPaging<Visit>(Context.getVisitService().getVisits(null, patients, null, null, minStartDate, null,
null, null, null, includeInactive, false), context).toSimpleObject(this);
null, null, null, includeInactive, context.getIncludeAll()), context).toSimpleObject(this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,32 @@ public void searchByPatient_shouldGetUnretiredVisitsForThePatient() throws Excep
Assert.assertEquals(3, Util.getResultsSize(result));
}

@Test
public void searchByPatient_shouldGetRetiredVisitsIfIncludeAllIsTrue() throws Exception {
String patientUUid = "da7f524f-27ce-4bb2-86d6-6d1d05312bd5";

SimpleObject resultWithVoidedVisits = deserialize(handle(newGetRequest(getURI(),
new Parameter("patient", patientUUid),
new Parameter("includeAll", "true"))));
SimpleObject resultWithoutVoidedVisits = deserialize(handle(newGetRequest(getURI(),
new Parameter("patient", patientUUid))));

int visitIncludingVoidedSize = Util.getResultsSize(resultWithVoidedVisits);
int visitExcludingVoidedSize = Util.getResultsSize(resultWithoutVoidedVisits);

Assert.assertEquals(visitIncludingVoidedSize, 4);
Assert.assertEquals(visitExcludingVoidedSize, 3);

handle(newDeleteRequest(getURI() + "/" + getUuid(), new Parameter("reason",
"void test reason")));

resultWithVoidedVisits = deserialize(handle(newGetRequest(getURI(),
new Parameter("patient", patientUUid),
new Parameter("includeAll", "true"))));
resultWithoutVoidedVisits = deserialize(handle(newGetRequest(getURI(),
new Parameter("patient", patientUUid))));
Assert.assertEquals(Util.getResultsSize(resultWithoutVoidedVisits), 2);
Assert.assertEquals(Util.getResultsSize(resultWithVoidedVisits), 4);
}

}

0 comments on commit 191e0b6

Please sign in to comment.