Skip to content

Commit

Permalink
RESTWS-655: Program Enrollment Resource should not return voided pati…
Browse files Browse the repository at this point in the history
…ent programs
  • Loading branch information
mogoodrich committed May 26, 2017
1 parent 2044bde commit e8b6ee1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,18 @@ public void shouldGetAll() throws Exception {
SimpleObject result = deserialize(handle(req));

Patient patient = patientService.getPatientByUuid(RestTestConstants1_8.PATIENT_IN_A_PROGRAM_UUID);
List<PatientProgram> patientPrograms = service.getPatientPrograms(patient, null, null, null, null, null, true);
List<PatientProgram> patientPrograms = service.getPatientPrograms(patient, null, null, null, null, null, false);
Assert.assertEquals(patientPrograms.size(), Util.getResultsSize(result));
}

@Test
public void shouldExcludeRetired() throws Exception {
MockHttpServletRequest req = request(RequestMethod.GET, getURI());
req.setParameter("patient", RestTestConstants1_8.PATIENT_WITH_VOIDED_PROGRAM_UUID);
SimpleObject result = deserialize(handle(req));

Patient patient = patientService.getPatientByUuid(RestTestConstants1_8.PATIENT_WITH_VOIDED_PROGRAM_UUID);
List<PatientProgram> patientPrograms = service.getPatientPrograms(patient, null, null, null, null, null, false);
Assert.assertEquals(patientPrograms.size(), Util.getResultsSize(result));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public DelegatingResourceDescription getCreatableProperties() {
}

/**
* Gets all the programs (including voided) of the given patient
* Gets all the programs (excluding voided) of the given patient
*
* @param context
* @return all programs of the given patient
Expand All @@ -129,7 +129,7 @@ protected PageableResult doSearch(RequestContext context) {
}

List<PatientProgram> patientPrograms = Context.getProgramWorkflowService().getPatientPrograms(patient, null,
null, null, null, null, true);
null, null, null, null, false);
return new NeedsPaging<PatientProgram>(patientPrograms, context);
}
return super.doSearch(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public class RestTestConstants1_8 {

public static final String PATIENT_IN_A_PROGRAM_UUID = "da7f524f-27ce-4bb2-86d6-6d1d05312bd5";

public static final String PATIENT_WITH_VOIDED_PROGRAM_UUID = "8adf539e-4b5a-47aa-80c0-ba1025c957fa";

public static final String STATE_UUID = "92584cdc-6a20-4c84-a659-e035e45d36b0";

public static final String PATIENT_STATE_UUID = "ea89deaa-23cc-4840-92fe-63d199c37e4c";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ public void shouldGetAll() throws Exception {
Assert.assertEquals(patientPrograms.size(), Util.getResultsSize(result));
}

@Test
public void shouldExcludeRetired() throws Exception {
MockHttpServletRequest req = request(RequestMethod.GET, getURI());
req.setParameter("patient", RestTestConstants1_8.PATIENT_WITH_VOIDED_PROGRAM_UUID);
SimpleObject result = deserialize(handle(req));

Patient patient = patientService.getPatientByUuid(RestTestConstants1_8.PATIENT_WITH_VOIDED_PROGRAM_UUID);
List<PatientProgram> patientPrograms = service.getPatientPrograms(patient, null, null, null, null, null, false);
Assert.assertEquals(patientPrograms.size(), Util.getResultsSize(result));
}

@Test
public void shouldGetTheDefaultRepresentationOfPatientProgram() throws Exception {
MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid());
Expand Down

0 comments on commit e8b6ee1

Please sign in to comment.