Package org.openmrs

Examples of org.openmrs.ProgramWorkflowState


        results.assertNoErrors();
        results.assertEncounterCreated();
        results.assertProvider(502);
        results.assertLocation(2);
       
        ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(START_STATE);
        PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), state, null);
        PatientState patientState = getPatientState(patientProgram, state, null);
        Assert.assertNotNull(patientProgram);
        Assert.assertEquals(dateAsString(DATE), dateAsString(patientState.getStartDate()));
        Assert.assertNull(patientState.getEndDate());
      }
     
      public boolean doViewEncounter() {
        return true;
      }
     
      public void testViewingEncounter(Encounter encounter, String html) {
        Assert.assertTrue("View should contain current state: " + html, html.contains("START STATE"));
      }
     
      public boolean doEditEncounter() {
        return true;
      }
     
      public void testEditFormHtml(String html) {
        Assert.assertTrue("Edit should contain current state: " + html,
            html.contains("selected=\"true\">START STATE"));
      }
    }.run();
   
   
    new RegressionTestHelper() {
     
      @Override
      public String getFormName() {
        return XML_FORM_NAME;
      }
     
      @Override
      public String[] widgetLabels() {
        return new String[] { "Date:", "Location:", "Provider:", "State:" };
      }
     
      @Override
      public void setupRequest(MockHttpServletRequest request, Map<String, String> widgets) {
        request.addParameter(widgets.get("Location:"), "2");
        request.addParameter(widgets.get("Provider:"), "502");
        //When: Html form is entered with an encounter date of Jan 2012 in which workflow state Y is selected
        request.addParameter(widgets.get("Date:"), dateAsString(DATE));
        request.addParameter(widgets.get("State:"), MIDDLE_STATE);
      }
     
      @Override
      public void testResults(SubmissionResults results) {
        results.assertNoErrors();
        results.assertEncounterCreated();
        results.assertProvider(502);
        results.assertLocation(2);
       
        //Then: Workflow state X is stopped with a stop date of Jan 2012, Workflow state Y is created with a start date of Jan 2012 and is still current
        ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(START_STATE);
        PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), state, null);
        PatientState patientState = getPatientState(patientProgram, state, null);
        Assert.assertNotNull(patientProgram);
        Assert.assertEquals(dateAsString(DATE), dateAsString(patientState.getStartDate()));
        Assert.assertEquals(dateAsString(DATE), dateAsString(patientState.getEndDate()));
View Full Code Here


        results.assertEncounterCreated();
        results.assertProvider(502);
        results.assertLocation(2);
       
        //Then: Workflow X is changed to a stop date of Sept 2011, Workflow Z is created with a start date of Sept 2011 and a stop date of Jan 2012
        ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(START_STATE);
        PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), state, PAST_DATE);
        PatientState patientState = getPatientState(patientProgram, state, PAST_DATE);
        Assert.assertNotNull(patientProgram);
        Assert.assertEquals(dateAsString(PAST_DATE), dateAsString(patientState.getStartDate()));
        Assert.assertEquals(dateAsString(DATE), dateAsString(patientState.getEndDate()));
View Full Code Here

        results.assertEncounterCreated();
        results.assertProvider(502);
        results.assertLocation(2);
       
        //Then: No action
        ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(START_STATE);
        PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), state, PAST_DATE);
        PatientState patientState = getPatientState(patientProgram, state, PAST_DATE);
        Assert.assertNotNull(patientProgram);
        Assert.assertEquals(dateAsString(PAST_DATE), dateAsString(patientState.getStartDate()));
        Assert.assertNull(patientState.getEndDate());
View Full Code Here

        results.assertNoErrors();
        results.assertEncounterCreated();
        results.assertProvider(502);
        results.assertLocation(2);
       
        ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(START_STATE);
        PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), state, DATE);
        PatientState patientState = getPatientState(patientProgram, state, DATE);
        Assert.assertNotNull(patientProgram);
        Assert.assertEquals(dateAsString(DATE), dateAsString(patientState.getStartDate()));
        Assert.assertNull(patientState.getEndDate());
      }
     
      public boolean doViewEncounter() {
        return true;
      }
     
      public void testViewingEncounter(Encounter encounter, String html) {
        Assert.assertTrue("View should contain current state: " + html, html.contains("START STATE"));
      }
     
      public boolean doEditEncounter() {
        return true;
      }
     
      public String[] widgetLabelsForEdit() {
        return new String[] { "Date:", "Location:", "Provider:", "State:" };
      }
     
      public void setupEditRequest(MockHttpServletRequest request, Map<String,String> widgets) {
        request.setParameter(widgets.get("Location:"), "2");
        request.setParameter(widgets.get("Provider:"), "502");
        request.setParameter(widgets.get("Date:"), dateAsString(DATE));
        request.setParameter(widgets.get("State:"), MIDDLE_STATE);
      }
     
      public void testEditedResults(SubmissionResults results) {
        results.assertNoErrors();
       
        ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(MIDDLE_STATE);
        PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), state, DATE);
        PatientState patientState = getPatientState(patientProgram, state, DATE);
        Assert.assertNotNull(patientProgram);
        Assert.assertEquals(dateAsString(DATE), dateAsString(patientState.getStartDate()));
        Assert.assertNull(patientState.getEndDate());
View Full Code Here

        results.assertNoErrors();
        results.assertEncounterCreated();
        results.assertProvider(502);
        results.assertLocation(2);
       
        ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(START_STATE);
        PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), state, DATE);
        PatientState patientState = getPatientState(patientProgram, state, DATE);
        Assert.assertNotNull(patientProgram);
        Assert.assertEquals(dateAsString(DATE), dateAsString(patientState.getStartDate()));
        Assert.assertNull(patientState.getEndDate());
      }
     
      public boolean doViewEncounter() {
        return true;
      }
     
      public void testViewingEncounter(Encounter encounter, String html) {
        Assert.assertTrue("View should contain current state: " + html, html.contains("START STATE"));
      }
     
      public boolean doEditEncounter() {
        return true;
      }
     
      public String[] widgetLabelsForEdit() {
        return new String[] { "Date:", "Location:", "Provider:", "State:" };
      }
     
      public void setupEditRequest(MockHttpServletRequest request, Map<String,String> widgets) {
        request.setParameter(widgets.get("Location:"), "2");
        request.setParameter(widgets.get("Provider:"), "502");
        request.setParameter(widgets.get("Date:"), dateAsString(PAST_DATE));
        request.setParameter(widgets.get("State:"), MIDDLE_STATE);
      }
     
      public void testEditedResults(SubmissionResults results) {
        ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(MIDDLE_STATE);
        PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), state, DATE);
        PatientState patientState = getPatientState(patientProgram, state, DATE);
        Assert.assertNotNull(patientProgram);
       
        // assert that the start dates of the program and state have been moved
View Full Code Here

        results.assertNoErrors();
        results.assertEncounterCreated();
        results.assertProvider(502);
        results.assertLocation(2);
       
        ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(START_STATE);
        PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), state, PAST_DATE);
        PatientState patientState = getPatientState(patientProgram, state, PAST_DATE);
        Assert.assertNotNull(patientProgram);
        Assert.assertEquals(dateAsString(PAST_DATE), dateAsString(patientState.getStartDate()));
        Assert.assertNull(patientState.getEndDate());
      }
     
      public boolean doViewEncounter() {
        return true;
      }
     
      public void testViewingEncounter(Encounter encounter, String html) {
        Assert.assertTrue("View should contain current state: " + html, html.contains("START STATE"));
      }
     
      public boolean doEditEncounter() {
        return true;
      }
     
      public String[] widgetLabelsForEdit() {
        return new String[] { "Date:", "Location:", "Provider:", "State:" };
      }
     
      public void setupEditRequest(MockHttpServletRequest request, Map<String,String> widgets) {
        request.setParameter(widgets.get("Location:"), "2");
        request.setParameter(widgets.get("Provider:"), "502");
        request.setParameter(widgets.get("Date:"), dateAsString(DATE));
        request.setParameter(widgets.get("State:"), MIDDLE_STATE);
      }
     
      public void testEditedResults(SubmissionResults results) {
        results.assertNoErrors();
       
        ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(MIDDLE_STATE);
        PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), state, DATE);
        PatientState patientState = getPatientState(patientProgram, state, DATE);
        Assert.assertNotNull(patientProgram);
       
        // assert that the start date of the program is the same
View Full Code Here

      }
     
      public void testEditedResults(SubmissionResults results) {
        results.assertNoErrors();
       
        ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(START_STATE);
       
        // first verify that the existing patient program still exists and that the enrollment date has not been changed
        PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), state, DATE);
        Assert.assertNotNull(patientProgram);
        Assert.assertEquals(dateAsString(DATE), dateAsString(patientProgram.getDateEnrolled()));
View Full Code Here

     
      @SuppressWarnings("deprecation")
            public void testEditedResults(SubmissionResults results) {
        results.assertNoErrors();
       
        ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(START_STATE);
       
        // we should now have two program enrollments, one on PAST_DATE and one on DATE
        ProgramWorkflow workflow = Context.getProgramWorkflowService().getWorkflow(100);
        Assert.assertEquals(2, Context.getProgramWorkflowService().getPatientPrograms(patient, workflow.getProgram(), null, null, null, null, false).size());
       
View Full Code Here

        results.assertEncounterCreated();
        results.assertProvider(502);
        results.assertLocation(2);
       
        // do a sanity check here
        ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(END_STATE);
        PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), state, DATE);
        PatientState patientState = getPatientState(patientProgram, state, DATE);
        Assert.assertNotNull(patientProgram);
        Assert.assertEquals(dateAsString(DATE), dateAsString(patientState.getStartDate()));
        Assert.assertNull(patientState.getEndDate());
      }
     
      public boolean doViewEncounter() {
        return true;
      }
     
      public void testViewingEncounter(Encounter encounter, String html) {
        Assert.assertTrue("View should contain current state: " + html, html.contains("END STATE"));
      }
     
      public boolean doEditEncounter() {
        return true;
      }
     
      public String[] widgetLabelsForEdit() {
        return new String[] { "Date:", "Location:", "Provider:", "State:" };
      }
     
      public void setupEditRequest(MockHttpServletRequest request, Map<String,String> widgets) {
        request.setParameter(widgets.get("Location:"), "2");
        request.setParameter(widgets.get("Provider:"), "502");
        request.setParameter(widgets.get("Date:"), dateAsString(PAST_DATE));
        request.setParameter(widgets.get("State:"), MIDDLE_STATE);
      }
     
      public void testEditedResults(SubmissionResults results) {
        results.assertNoErrors();
       
        ProgramWorkflowState startState = Context.getProgramWorkflowService().getStateByUuid(START_STATE);
        ProgramWorkflowState middleState = Context.getProgramWorkflowService().getStateByUuid(MIDDLE_STATE);
       
        PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), startState, FURTHER_PAST_DATE);
        Assert.assertNotNull(patientProgram);
       
        // assert that the patient program only has two states
View Full Code Here

            public void testEditedResults(SubmissionResults results) {
        results.assertNoErrors();
       
        ProgramWorkflow workflow = Context.getProgramWorkflowService().getWorkflow(100);
       
        ProgramWorkflowState startState = Context.getProgramWorkflowService().getStateByUuid(START_STATE);
        ProgramWorkflowState middleState = Context.getProgramWorkflowService().getStateByUuid(MIDDLE_STATE);
        ProgramWorkflowState endState = Context.getProgramWorkflowService().getStateByUuid(END_STATE);
       
        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
View Full Code Here

TOP

Related Classes of org.openmrs.ProgramWorkflowState

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.