Examples of Encounter


Examples of org.openmrs.Encounter

        htmlform.setXmlData(new TestUtil().loadXmlFromFile(XML_DATASET_PATH + "returnSectionsAndConceptsInSectionsTestFormWithGroups.xml"));
        String newXml = HtmlFormEntryExportUtil.getSectionAsFormXml(htmlform, 0);
        htmlform.setXmlData(newXml);
       

        Encounter e = new Encounter();
        e.setPatient(Context.getPatientService().getPatient(2));
        Date date = Context.getDateFormat().parse("01/02/2003");
        e.setDateCreated(new Date());
        e.setEncounterDatetime(date);
        e.setLocation(Context.getLocationService().getLocation(2));
        e.setProvider(Context.getPersonService().getPerson(502));
       
        TestUtil.addObs(e, 2474, Context.getConceptService().getConcept(656), date);
        TestUtil.addObs(e, 3017, Context.getConceptService().getConcept(767), date);
        TestUtil.addObs(e, 3032, new Date(), date);
        TestUtil.addObs(e, 1, 5000, date);
        TestUtil.addObs(e, 2, 5000, date); //not in form schema, should not be included after trimEncounter
        TestUtil.addObs(e, 3, 5000, date); //not in form schema, should not be included after trimEncounter
        TestUtil.addObs(e, 6, "blah blah", date);
            //1004 is ANOTHER ALLERGY CONSTRUCT, 1005 is HYPER-ALLERGY CODED, 1001 is PENICILLIN
        TestUtil.addObsGroup(e, 1004, new Date(), 1005, Context.getConceptService().getConcept(1001), new Date());
            //7 IS ALLERGY CONSTRUCT, 1000 IS ALLERGY CODED, 1003 IS OPENMRS
        TestUtil.addObsGroup(e, 7, new Date(), 1000, Context.getConceptService().getConcept(1003), new Date());
        Context.getEncounterService().saveEncounter(e);
        e = HtmlFormEntryExportUtil.trimEncounterToMatchForm(e, htmlform);
        if (log.isDebugEnabled()){
            for (Obs otmp : e.getAllObs()){
                log.debug("trimEncounterToMatchForm returned an obs with concept: " + otmp.getConcept());
            }
        }
        //Note, this assertion corresponds to section index 0 in the form, so 5 obs should be returned
            // the form has 6 obs under section 0, but we didn't create the obs for conceptId = 9
        Assert.assertEquals(5, e.getAllObs().size());
       
    }
View Full Code Here

Examples of org.openmrs.Encounter

        //Build a couple of encounters for the form
        List<Encounter> encounters = new ArrayList<Encounter>();
       
       
        //encounter1
        Encounter e = new Encounter();
        e.setPatient(Context.getPatientService().getPatient(2));
        Date date = Context.getDateFormat().parse("01/02/2003");
        e.setDateCreated(new Date());
        e.setEncounterDatetime(date);
        e.setLocation(Context.getLocationService().getLocation(2));
        e.setProvider(Context.getPersonService().getPerson(502));
        //top of form
        TestUtil.addObs(e, 3032, date, date);
        TestUtil.addObs(e, 1441, Context.getConceptService().getConcept(656), date);
        TestUtil.addObsGroup(e, 1004, date, 1005, Context.getConceptService().getConcept(1001), new Date());
        TestUtil.addObs(e, 1119, new Date(), date);
        TestUtil.addObs(e, 2474, Context.getConceptService().getConcept(767), date);
        //DST RESULT
        Obs dstParent = TestUtil.createObs(e, 3040, null, date);
        e.addObs(dstParent);
        Obs resultParent = TestUtil.createObs(e, 3025, null, date);
        dstParent.addGroupMember(resultParent);
        Obs drugResult = TestUtil.createObs(e, 3017, Context.getConceptService().getConcept(656), date);
        resultParent.addGroupMember(drugResult);
        Obs colonies1 = TestUtil.createObs(e, 3016, 200, date);
View Full Code Here

Examples of org.openmrs.Encounter

        //Build a couple of encounters for the form
        List<Encounter> encounters = new ArrayList<Encounter>();
       
       
        //encounter1
        Encounter e = new Encounter();
        e.setPatient(Context.getPatientService().getPatient(2));
        Date date = Context.getDateFormat().parse("01/02/2003");
        e.setDateCreated(new Date());
        e.setEncounterDatetime(date);
        e.setLocation(Context.getLocationService().getLocation(2));
        e.setProvider(Context.getPersonService().getPerson(502));
       
        Context.getEncounterService().saveEncounter(e);
        encounters.add(e);

        StringBuffer ret = HtmlFormEntryExportUtil.buildHtmlFormExport(encounters, htmlform, extraCols, new StringBuffer(""), new Locale("en"),pitList);
View Full Code Here

Examples of org.openmrs.Encounter

        //Build a couple of encounters for the form
        List<Encounter> encounters = new ArrayList<Encounter>();
       
       
        //encounter1
        Encounter e = new Encounter();
        e.setPatient(Context.getPatientService().getPatient(2));
        Date date = Context.getDateFormat().parse("01/02/2003");
        e.setDateCreated(new Date());
        e.setEncounterDatetime(date);
        e.setLocation(Context.getLocationService().getLocation(2));
        e.setProvider(Context.getPersonService().getPerson(502));
       
       
        TestUtil.addObs(e, 1119, date, date);
        TestUtil.addObs(e, 1007, date, date);
       
View Full Code Here

Examples of org.openmrs.Encounter

   * @verifies return the most recent encounter if encounter type is null
   */
  @Test
  public void latestEncounter_shouldReturnTheMostRecentEncounterByType() throws Exception {
    VelocityFunctions functions = setupFunctionsForPatient(7);
    Encounter latestEncounter = functions.latestEncounter("2");
        Assert.assertEquals(new Integer(3), latestEncounter.getEncounterId());
  }
View Full Code Here

Examples of org.openmrs.Encounter

    Assert.assertEquals(concept.getDisplayString (), functions.getConcept ("5089").getDisplayString ());
  }

    @Test
    public void getObs_shouldReturnObsWithGivenConcept() throws Exception {
        Encounter encounter = Context.getEncounterService().getEncounter(4);
        VelocityFunctions functions = setupFunctionsForPatient(7);

        assertThat(functions.getObs(encounter, "5089").getValueNumeric(), is(55d));
        assertThat(functions.getObs(encounter, "3"), nullValue());
    }
View Full Code Here

Examples of org.openmrs.Encounter

        assertThat(functions.getObs(encounter, "3"), nullValue());
    }

    @Test
    public void allObs_shouldReturnObsWithGivenConcept() throws Exception {
        Encounter encounter = Context.getEncounterService().getEncounter(4);
        VelocityFunctions functions = setupFunctionsForPatient(7);

        List<Obs> allObs = functions.allObs(encounter, "5089");
        assertThat(allObs.size(), is(1));
        assertThat(allObs.get(0).getValueNumeric(), is(55d));
View Full Code Here

Examples of org.openmrs.Encounter

     
      @Override
      public void testResults(SubmissionResults results) {
        results.assertNoErrors();
        results.assertEncounterCreated();
        Encounter e = results.getEncounterCreated();
       
        Set<Order> orders = e.getOrders();
       
        Drug drug = Context.getConceptService().getDrug(2);
        assertThat(orders, contains(allOf(hasProperty("drug", is(drug)), hasProperty("dose", is(1.0)),
          hasProperty("startDate", is(ymdToDate(dateAsString(date)))))));
      }
View Full Code Here

Examples of org.openmrs.Encounter

  public void standardRegimenToDrugOrders_shouldCreateDrugOrders() throws Exception {
    List<RegimenSuggestion> regList = Context.getOrderService().getStandardRegimens();
    Assert.assertTrue(regList.size() > 0);
   
    //Add regimens to an encounter:
    Encounter e = new Encounter();
    e.setPatient(Context.getPatientService().getPatient(2));
    Date date = new Date();
    e.setDateCreated(new Date());
    e.setEncounterDatetime(date);
    e.setLocation(Context.getLocationService().getLocation(2));
    e.setProvider(Context.getPersonService().getPerson(502));
   
    //And, add some drugOrders
    Patient p = Context.getPatientService().getPatient(2);
    Set<Order> dos = RegimenUtil.standardRegimenToDrugOrders(regList.get(0), new Date(), p);
    Assert.assertTrue(dos.size() == 2);
    for (Order o : dos)
      e.addOrder(o);
   
    //save the encounter
    e = Context.getEncounterService().saveEncounter(e);
    Integer encId = e.getId();
    Context.flushSession();
    Context.clearSession();
   
    //now retrieve it and make sure that there are two orders in the Encounter  (checks to ensure adequate values are set in creation of DrugOrder for not null constraints)
    Encounter enc = Context.getEncounterService().getEncounter(encId);
    Assert.assertTrue(enc.getOrders().size() == 2);
  }
View Full Code Here

Examples of org.openmrs.Encounter

    Integer encId = regimenTestBuildEncounterHelper("drug2and3");
    Context.flushSession();
    Context.clearSession();
   
    //Check to see that method returns drug2and3
    Encounter e = Context.getEncounterService().getEncounter(encId);
    List<Order> dors = new ArrayList<Order>();
    dors.addAll(e.getOrders());
    Map<RegimenSuggestion, List<DrugOrder>>  m = RegimenUtil.findStrongestStandardRegimenInDrugOrders(Context.getOrderService().getStandardRegimens(),dors);
    Assert.assertTrue(m.size() > 0);
    RegimenSuggestion rs = m.keySet().iterator().next();
    log.debug("findStrongestStandardRegimenInDrugOrders found standard regimen " + rs.getCodeName());
    Assert.assertTrue(rs.getCodeName().equals("drug2and3"));
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.