Package org.openmrs.module.htmlformentry

Examples of org.openmrs.module.htmlformentry.FormEntryException


         
          // if the encounter date has been moved later
          if (previousEncounterDate != null && newEncounterDate.after(previousEncounterDate)) {
            // make sure we aren't trying to move the state start date past its end date
            if (oldPatientState.getEndDate() != null && newEncounterDate.after(oldPatientState.getEndDate())) {
              throw new FormEntryException("Cannot move encounter date ahead of end date of current active state");
            }
           
            // if there is a state that ended on the previous encounter date, its end date needs to be set to the new encounter date
            for (PatientState state : patientProgram.statesInWorkflow(workflow, false)) {
              if (!state.equals(oldPatientState) && state.getEndDate().compareTo(previousEncounterDate) == 0) {
View Full Code Here


 
  public EnrollInProgramElement(FormEntryContext context, Map<String, String> parameters) {
    try {
      program = HtmlFormEntryUtil.getProgram(parameters.get("programId"));
      if (program == null)
        throw new FormEntryException("");
    }
    catch (Exception ex) {
      throw new IllegalArgumentException("Couldn't find program in: " + parameters);
    }
   
    if ("true".equalsIgnoreCase(parameters.get("showDate"))) {
      dateWidget = new DateWidget();
      dateErrorWidget = new ErrorWidget();
      context.registerWidget(dateWidget);
      context.registerErrorWidget(dateWidget, dateErrorWidget);
    }
   
    String stateIdsStr = parameters.get("stateIds");
    if (StringUtils.isNotBlank(stateIdsStr)) {
      states = new ArrayList<ProgramWorkflowState>();
      String[] stateIdsUuidsOrPrefNames = stateIdsStr.split(",");
      //set to store unique work flow state combinations so as to determine multiple states in same work flow
      Set<String> workflowsAndStates = new HashSet<String>()
      for (String value : stateIdsUuidsOrPrefNames) {
        value = value.trim();
        ProgramWorkflowState state = HtmlFormEntryUtil.getState(value, program);
        if (state == null) {
          String errorMsgPart = "with an id or uuid";
          if (value.indexOf(":") > -1)
            errorMsgPart = "associated to a concept with a concept mapping";
          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");
        } else if (!workflowsAndStates.add(state.getProgramWorkflow().getUuid())) {
          throw new FormEntryException("A patient cannot be in multiple states in the same workflow");
        }
        if (!states.contains(state))
          states.add(state);
      }
     
View Full Code Here

TOP

Related Classes of org.openmrs.module.htmlformentry.FormEntryException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.