results.assertProvider(502);
results.assertLocation(2);
ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(START_STATE);
PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), state, null);
PatientState patientState = getPatientState(patientProgram, state, null);
Assert.assertNotNull(patientProgram);
Assert.assertEquals(dateAsString(DATE), dateAsString(patientState.getStartDate()));
Assert.assertNull(patientState.getEndDate());
}
public boolean doViewEncounter() {
return true;
}
public void testViewingEncounter(Encounter encounter, String html) {
Assert.assertTrue("View should contain current state: " + html, html.contains("START STATE"));
}
public boolean doEditEncounter() {
return true;
}
public void testEditFormHtml(String html) {
Assert.assertTrue("Edit should contain current state: " + html,
html.contains("selected=\"true\">START STATE"));
}
}.run();
new RegressionTestHelper() {
@Override
public String getFormName() {
return XML_FORM_NAME;
}
@Override
public String[] widgetLabels() {
return new String[] { "Date:", "Location:", "Provider:", "State:" };
}
@Override
public void setupRequest(MockHttpServletRequest request, Map<String, String> widgets) {
request.addParameter(widgets.get("Location:"), "2");
request.addParameter(widgets.get("Provider:"), "502");
//When: Html form is entered with an encounter date of Jan 2012 in which workflow state Y is selected
request.addParameter(widgets.get("Date:"), dateAsString(DATE));
request.addParameter(widgets.get("State:"), MIDDLE_STATE);
}
@Override
public void testResults(SubmissionResults results) {
results.assertNoErrors();
results.assertEncounterCreated();
results.assertProvider(502);
results.assertLocation(2);
//Then: Workflow state X is stopped with a stop date of Jan 2012, Workflow state Y is created with a start date of Jan 2012 and is still current
ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(START_STATE);
PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), state, null);
PatientState patientState = getPatientState(patientProgram, state, null);
Assert.assertNotNull(patientProgram);
Assert.assertEquals(dateAsString(DATE), dateAsString(patientState.getStartDate()));
Assert.assertEquals(dateAsString(DATE), dateAsString(patientState.getEndDate()));
state = Context.getProgramWorkflowService().getStateByUuid(MIDDLE_STATE);
patientProgram = getPatientProgramByState(results.getPatient(), state, null);
patientState = getPatientState(patientProgram, state, null);
Assert.assertNotNull(patientProgram);
Assert.assertEquals(dateAsString(DATE), dateAsString(patientState.getStartDate()));
Assert.assertNull(patientState.getEndDate());
}
public boolean doViewEncounter() {
return true;
}