/** * Check whether it is allowable to transition from <code>fromState</code> to * <code>toState</code>. * * @param fromState {@link ProgramWorkflowState} to check transition from * @param toState {@link ProgramWorkflowState} to check transition to * @return boolean true if it is allowable to transition from <code>fromState</code> to * <code>toState</code> */ public boolean isLegalTransition(ProgramWorkflowState fromState, ProgramWorkflowState toState) { // If there's no current state then we need tom move into an initial state if (fromState == null) { return toState.getInitial(); } // Does not allow patient to move into the same state return !fromState.equals(toState); }
@Override public void testResults(SubmissionResults results) { results.assertNoErrors(); results.assertEncounterCreated(); List<PatientProgram> pps = pws.getPatientPrograms(ps.getPatient(patientId), pws.getProgram(programId), null, null, null, null, false); Assert.assertEquals(1, pps.size()); // make sure the state has been set Set<PatientState> states = pps.get(0).getStates(); Assert.assertEquals(1, states.size()); Assert.assertTrue(((PatientState) states.toArray()[0]).getState().equals(Context.getProgramWorkflowService().getStateByUuid("6de7ed10-53ad-11e1-8cb6-00248140a5eb"))); };
boolean select = state.getValue().equals(currentState); singleOption.addOption(new Option(state.getKey(), state.getValue().getUuid(), select));
/** * @param patientProgram * @param state * @param activeDate * @return */ private PatientState getPatientState(PatientProgram patientProgram, ProgramWorkflowState state, Date activeDate) { for (PatientState patientState : patientProgram.getStates()) { if (patientState.getState().equals(state)) { if (activeDate != null) { if (patientState.getActive(activeDate)) { return patientState; } } else { return patientState; } } } return null; }
if (patientState.getState().equals(state)) { return;
/** * @param results * @param state * @return */ private PatientProgram getPatientProgramByState(Patient patient, ProgramWorkflowState state, Date activeDate) { List<PatientProgram> patientPrograms = Context.getProgramWorkflowService().getPatientPrograms(patient, state.getProgramWorkflow().getProgram(), null, null, null, null, false); for (PatientProgram patientProgram : patientPrograms) { for (PatientState patientState : patientProgram.getStates()) { if (patientState.getState().equals(state)) { if (activeDate != null) { if (patientState.getActive(activeDate)) { return patientProgram; } } else { return patientProgram; } } } } return null; }
if (!newState.equals(oldPatientState.getState())) { oldPatientState.setState(newState);