@Override protected ProgramWorkflow getObjectById(Integer id) { return Context.getProgramWorkflowService().getWorkflow(id); }
@Test public void getWorkflow_shouldReturnNullIfGivenWorkflowIdDoesNotExists() { assertNull(pws.getWorkflow(99999)); }
@Test public void getWorkflow_shouldGetWorkflowAssociatedWithGivenIdIfWorkflowIdExists() { final Integer EXISTING_WORKFLOW_ID = 1; ProgramWorkflow workflow = pws.getWorkflow(EXISTING_WORKFLOW_ID); assertNotNull("ProgramWorkflow not found", workflow); assertThat(workflow.getId(), is(EXISTING_WORKFLOW_ID)); }
/** * @see {@link HtmlFormEntryUtil#getState(String,Program)} */ @SuppressWarnings("deprecation") @Test @Verifies(value = "should return the state with the matching uuid", method = "getState(String,ProgramWorkflow)") public void getStateWorkflow_shouldReturnTheStateWithTheMatchingUuid() throws Exception { Assert.assertEquals("1",HtmlFormEntryUtil.getState("92584cdc-6a20-4c84-a659-e035e45d36b0", Context.getProgramWorkflowService().getWorkflow(1)).getId().toString()); }
/** * @see {@link HtmlFormEntryUtil#getState(String,Program)} */ @SuppressWarnings("deprecation") @Test @Verifies(value = "should return the state with the matching id", method = "getState(String,ProgramWorkflow)") public void getStateWorkflow_shouldReturnTheStateWithTheMatchingId() throws Exception { Assert.assertEquals("92584cdc-6a20-4c84-a659-e035e45d36b0", HtmlFormEntryUtil.getState("1", Context.getProgramWorkflowService().getWorkflow(1)).getUuid()); }
/** * @see {@link HtmlFormEntryUtil#getState(String,Program)} */ @SuppressWarnings("deprecation") @Test @Verifies(value = "should look up a state by a concept mapping", method = "getState(String,ProgramWorkflow)") public void getStateWorkflow_shouldLookUpAStateByAConceptMapping() throws Exception { // load this data set so that we get the additional patient program with concept mapping executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_REGRESSION_TEST_DATASET)); Assert.assertEquals("6de7ed10-53ad-11e1-8cb6-00248140a5eb",HtmlFormEntryUtil.getState("SNOMED CT: Test Code", Context.getProgramWorkflowService().getWorkflow(108)).getUuid()); }
@SuppressWarnings("deprecation") @Override public void testResults(SubmissionResults results) { results.assertNoErrors(); results.assertEncounterCreated(); results.assertProvider(502); results.assertLocation(2); // make sure the enrollment date has NOT been changed (since no state was set) ProgramWorkflow workflow = Context.getProgramWorkflowService().getWorkflow(100); Assert.assertEquals(1, Context.getProgramWorkflowService().getPatientPrograms(patient, workflow.getProgram(), null, null, null, null, false).size()); PatientProgram patientProgram = Context.getProgramWorkflowService().getPatientPrograms(patient, workflow.getProgram(), null, null, null, null, false).get(0); Assert.assertNotNull(patientProgram); Assert.assertEquals(dateAsString(DATE), dateAsString(patientProgram.getDateEnrolled())); // assert that no states have been associated Assert.assertEquals(0, patientProgram.getStates().size()); }
@SuppressWarnings("deprecation") public void testEditedResults(SubmissionResults results) { results.assertNoErrors(); ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(START_STATE); // we should now have two program enrollments, one on PAST_DATE and one on DATE ProgramWorkflow workflow = Context.getProgramWorkflowService().getWorkflow(100); Assert.assertEquals(2, Context.getProgramWorkflowService().getPatientPrograms(patient, workflow.getProgram(), null, null, null, null, false).size()); // now verify that new state is correct PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), state, PAST_DATE); Assert.assertNotNull(patientProgram); Assert.assertEquals(dateAsString(PAST_DATE), dateAsString(patientProgram.getDateEnrolled())); // assert that the program has only one state Assert.assertEquals(1, patientProgram.getStates().size()); // assert that the start state of the state is correct PatientState patientState = getPatientState(patientProgram, state, PAST_DATE); Assert.assertNotNull(patientState); Assert.assertEquals(dateAsString(PAST_DATE), dateAsString(patientState.getStartDate())); Assert.assertNull(patientState.getEndDate()); }
@SuppressWarnings("deprecation") public void testEditedResults(SubmissionResults results) { results.assertNoErrors(); ProgramWorkflow workflow = Context.getProgramWorkflowService().getWorkflow(100); ProgramWorkflowState startState = Context.getProgramWorkflowService().getStateByUuid(START_STATE); ProgramWorkflowState endState = Context.getProgramWorkflowService().getStateByUuid(END_STATE); PatientProgram patientProgram = Context.getProgramWorkflowService().getPatientPrograms(patient, workflow.getProgram(), null, null, null, null, false).get(0); Assert.assertNotNull(patientProgram); // assert that the patient program only has two states Assert.assertEquals(2, patientProgram.statesInWorkflow(workflow, false).size()); // verify that the start state PatientState patientState = getPatientState(patientProgram, startState, FURTHER_PAST_DATE); Assert.assertNotNull(patientState); Assert.assertEquals(dateAsString(FURTHER_PAST_DATE), dateAsString(patientState.getStartDate())); Assert.assertEquals(dateAsString(DATE), dateAsString(patientState.getEndDate())); // verify that the end state starts on DATE and has no current end date patientState = getPatientState(patientProgram, endState, DATE); Assert.assertNotNull(patientState); Assert.assertEquals(dateAsString(DATE), dateAsString(patientState.getStartDate())); Assert.assertNull(patientState.getEndDate()); }
results.assertNoErrors(); ProgramWorkflow workflow = Context.getProgramWorkflowService().getWorkflow(100);