/** * 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); }
/** @see Object#toString() */ @Override public String toString() { return "State " + getConcept().getName() + " initial=" + getInitial() + " terminal=" + getTerminal(); }
/** * @see org.openmrs.api.ProgramWorkflowService#saveProgram(org.openmrs.Program) */ @Override public Program saveProgram(Program program) throws APIException { // Program if (program.getConcept() == null) { throw new APIException("Program.concept.required", (Object[]) null); } for (ProgramWorkflow workflow : program.getAllWorkflows()) { if (workflow.getConcept() == null) { throw new APIException("ProgramWorkflow.concept.required", (Object[]) null); } ensureProgramIsSet(workflow, program); for (ProgramWorkflowState state : workflow.getStates()) { if (state.getConcept() == null || state.getInitial() == null || state.getTerminal() == null) { throw new APIException("ProgramWorkflowState.requires", (Object[]) null); } ensureProgramWorkflowIsSet(state, workflow); } } return dao.saveProgram(program); }
throw new FormEntryException("Cannot find a program work flow state " + errorMsgPart + " that matches '" + value + "'"); } else if (!state.getInitial()) { throw new FormEntryException("The program work flow state that matches '" + value + "' is not marked as initial");
if (Boolean.FALSE.equals(state.getInitial())) { it.remove();