Package org.openmrs

Examples of org.openmrs.PatientProgram.statesInWorkflow()


   * @return
   */
  private PatientState getActivePatientState(Patient patient, Date encounterDatetime, ProgramWorkflow workflow) {
    PatientProgram patientProgram = HtmlFormEntryUtil.getPatientProgramByWorkflow(patient, workflow);
    if (patientProgram != null) {
      for (PatientState patientState : patientProgram.statesInWorkflow(workflow,false)) {
        if (patientState.getActive(encounterDatetime)) {
          return patientState;
        }
      }
    }
View Full Code Here


            if (existingPatientStateOnNewEncounterDate != null &&  !existingPatientStateOnNewEncounterDate.equals(oldPatientState)) {
              existingPatientStateOnNewEncounterDate.setEndDate(newEncounterDate);
            }
           
            // we also need to void any other states for this workflow that may have started between the new and old encounter dates
            for (PatientState state : patientProgram.statesInWorkflow(workflow, false)) {
              if (!state.equals(oldPatientState) && (state.getStartDate().after(newEncounterDate) || state.getStartDate().compareTo(newEncounterDate) == 0)
                  && state.getStartDate().before(previousEncounterDate)) {
                state.setVoided(true);
                state.setVoidedBy(Context.getAuthenticatedUser());
                state.setVoidReason("voided during htmlformentry submission");
View Full Code Here

            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) {
                state.setEndDate(newEncounterDate);
              }
            }
          }
View Full Code Here

       
        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()));
View Full Code Here

       
        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()));
View Full Code Here

      patientProgram.setCreator(Context.getAuthenticatedUser());
      patientProgram.setUuid(UUID.randomUUID().toString());
     
    }
   
    for (PatientState patientState : patientProgram.statesInWorkflow(state.getProgramWorkflow(), false)) {
      if (patientState.getActive(encounter.getEncounterDatetime())) {
        if (patientState.getState().equals(state)) {
          return;
        }
      }
View Full Code Here

        }
        return result;
      }
     
    });
    sortedStates.addAll(patientProgram.statesInWorkflow(state.getProgramWorkflow(), false));
    for (PatientState currentState : sortedStates) {
     
      Date newStartDate = newState.getStartDate();
      Date currentStartDate = currentState.getStartDate();
      Date currentEndDate = currentState.getEndDate();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.