widget.setInitialValue(state.getValue().getUuid()); } else if (tagParams.getType().equals("checkbox")) { widget = new CheckboxWidget(state.getKey(), state.getValue().getUuid()); } else { SingleOptionWidget singleOption; singleOption.addOption(new Option(state.getKey(), state.getValue().getUuid(), select)); if (widget instanceof CheckboxWidget) { if (currentState.getUuid().equals(((CheckboxWidget) widget).getValue())) { widget.setInitialValue(currentState.getUuid()); widget.setInitialValue(currentState.getUuid());
/** * Sets states to PatientProgram. * * @param instance * @param states */ @PropertySetter("states") public static void setStates(PatientProgram instance, List<PatientState> patientStates) { sortPatientStatesBasedOnStartDate(patientStates); if (!patientStates.isEmpty()) { for (PatientState patientState : patientStates) { PatientState existingState = getMatchingPatientState(patientState, instance.getStates()); if (existingState == null) { Date onDate = patientState.getStartDate() == null ? new Date() : patientState.getStartDate(); instance.transitionToState( Context.getProgramWorkflowService().getStateByUuid(patientState.getState().getUuid()), onDate); } } } }
/** * @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)} */ @Test @Verifies(value = "should return the state with the matching id", method = "getState(String,Program)") public void getStateProgram_shouldReturnTheStateWithTheMatchingId() throws Exception { Assert.assertEquals("92584cdc-6a20-4c84-a659-e035e45d36b0", HtmlFormEntryUtil.getState("1", Context.getProgramWorkflowService().getProgram(1)).getUuid()); }
@Test public void shouldTransitPatientState() throws Exception { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); String stateStartDate = "2015-08-04"; String json = "{ \"states\": [{ \"state\": {\"uuid\" : \"" + RestTestConstants1_8.STATE_UUID + "\"}, \"startDate\": \"" + stateStartDate + "\"}]}"; PatientProgram patientProgram = service.getPatientProgramByUuid(getUuid()); Assert.assertEquals(1, patientProgram.getStates().size()); MockHttpServletRequest req = newPostRequest(getURI() + "/" + getUuid(), SimpleObject.parseJson(json)); SimpleObject result = deserialize(handle(req)); patientProgram = service.getPatientProgramByUuid(getUuid()); Assert.assertNotNull(result); List<PatientState> states = new ArrayList<PatientState>(patientProgram.getStates()); Assert.assertEquals(2, states.size()); sortPatientStatesBasedOnStartDate(states); Assert.assertEquals(RestTestConstants1_8.STATE_UUID, states.get(1).getState().getUuid()); String existingStateEndDate = dateFormat.format(states.get(0).getEndDate()); Assert.assertEquals(stateStartDate, existingStateEndDate); }
/** * @see {@link HtmlFormEntryUtil#getState(String,Program)} */ @Test @Verifies(value = "should look up a state by a concept mapping", method = "getState(String,Program)") public void getStateProgram_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().getProgram(10)).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()); }