@SuppressWarnings("deprecation")
@Override
public Patient getPatient() {
Patient patient = Context.getPatientService().getPatient(2);
Program program = Context.getProgramWorkflowService().getProgram(1);
// as a sanity check, make sure the patient is currently enrolled in the program before we run the test
Assert.assertTrue("Patient should be in program", Context.getProgramWorkflowService().isInProgram(patient, program, new Date(), null));
return patient;
};
@Override
public String[] widgetLabels() {
return new String[] { "Date:", "Location:", "Provider:" };
}
@Override
public void setupRequest(MockHttpServletRequest request, Map<String, String> widgets) {
request.addParameter(widgets.get("Date:"), dateAsString(date));
request.addParameter(widgets.get("Location:"), "2");
request.addParameter(widgets.get("Provider:"), "502");
}
@SuppressWarnings("deprecation")
@Override
public void testResults(SubmissionResults results) {
// do all the basic assertions to make sure the program was processed correctly
results.assertNoErrors();
results.assertEncounterCreated();
results.assertProvider(502);
results.assertLocation(2);
// confirm that that patient is no longer in the program
Patient patient = Context.getPatientService().getPatient(2);
Program program = Context.getProgramWorkflowService().getProgram(1);
Assert.assertFalse("Patient should no longer be in program", Context.getProgramWorkflowService().isInProgram(patient, program, new Date(), null));
// but confirm that the patient was in the program in the past
Assert.assertTrue("Patient should still be in program in the past", Context.getProgramWorkflowService().isInProgram(patient, program, null, new Date()));