Package org.openmrs

Examples of org.openmrs.Encounter


            @Override
            public void testEditedResults(SubmissionResults results) {

                results.assertNoErrors();
                Encounter encounter = results.getEncounterCreated();

                assertThat(encounter.getAllObs(false).size(), is(1));   // should be one non-voided obs of value 1003
                assertThat(encounter.getAllObs(true).size(), is(3));   // should be three obs included the voided obs for 1001 and 1002

                Set<Integer> valueCoded = new HashSet<Integer>();

                for (Obs obs : encounter.getAllObs(true)) {
                    if (!obs.isVoided()) {
                        assertThat(obs.getValueCoded().getId(), is(1003));
                    }
                    else {
                        valueCoded.add(obs.getValueCoded().getId());
View Full Code Here


            @Override
            public void testEditedResults(SubmissionResults results) {

                results.assertNoErrors();
                Encounter encounter = results.getEncounterCreated();

                assertThat(encounter.getAllObs(false).size(), is(0));   // no none-voided obs
                assertThat(encounter.getAllObs(true).size(), is(2));   // the existing obs should have been voided
            }

        }.run();
    }
View Full Code Here

    public void encounterLocationTag_shouldShowRetiredLocationIfPreviouslySelected() throws Exception {

        // create an encounter associated with a retired location
        Location location = Context.getLocationService().getLocation(3);
        Patient patient = Context.getPatientService().getPatient(2);
        Encounter encounter = Context.getEncounterService().getEncounter(101);

        // (sanity check)
        Assert.assertTrue(location.isRetired());

        // set the location on this encounter to the retired location
        encounter.setLocation(location);

        // now render a form using that encounter
        HtmlForm htmlform = new HtmlForm();
        htmlform.setXmlData( "<htmlform><encounterLocation /></htmlform>");
        FormEntrySession session = new FormEntrySession(patient, encounter, FormEntryContext.Mode.EDIT, htmlform, null);
View Full Code Here

      throw new InvalidActionException("No Person on the stack");
    if (group.getObsId() == null && !obsToCreate.contains(group)) {
      obsToCreate.add(group);
    }
    Person person = highestOnStack(Person.class);
    Encounter encounter = highestOnStack(Encounter.class);
    group.setPerson(person);
    if (encounter != null) {
      addObsToEncounterIfNotAlreadyThere(encounter, group);
    }
    //this is for obs groups within obs groups
View Full Code Here

    Obs obs = HtmlFormEntryUtil.createObs(concept, value, datetime, accessionNumber);
   
    Person person = highestOnStack(Person.class);
    if (person == null)
      throw new IllegalArgumentException("Cannot create an Obs outside of a Person.");
    Encounter encounter = highestOnStack(Encounter.class);
    Obs obsGroup = highestOnStack(Obs.class);
   
    if (person != null)
      obs.setPerson(person);
   
    if(StringUtils.isNotBlank(comment))
      obs.setComment(comment);

    if (encounter != null)
      encounter.addObs(obs);
    if (obsGroup != null) {
      obsGroup.addGroupMember(obs);
    } else {
      obsToCreate.add(obs);
    }
View Full Code Here

    private Concept unknownConcept;

    @Before
    public void setUp() {
        patient = new Patient();
        encounter = new Encounter();
        encounter.setPatient(patient);

        unknownConcept = new Concept();

        patientService = mock(PatientService.class);
View Full Code Here

        }

        @Override
        public void applyAction(FormEntrySession session) {
            Patient patient = session.getPatient();
            Encounter encounter = session.getEncounter();
            patient.setDead(true);
            if (deathDateFromEncounter) {
                if (patient.getDeathDate() == null || !preserveExistingDeathDate) {
                    patient.setDeathDate(encounter.getEncounterDatetime());
                }
            }
            if (patient.getCauseOfDeath() == null || !preserveExistingCauseOfDeath) {
                Concept causeOfDeath = null;
                if (causeOfDeathFromObs != null) {
View Full Code Here

                return "obsGroupShowIfEmptyFalse";
            }

            @Override
            public Encounter getEncounterToView() throws Exception {
                Encounter e = new Encounter();
                e.setPatient(getPatient());
                e.setDateCreated(new Date());

                TestUtil.addObsGroup(e, 23, new Date(), 18, Boolean.TRUE, new Date());
                return e;
            }
View Full Code Here

        return "singlePersonObsForm";
      }
     
      @Override
      public Encounter getEncounterToView() throws Exception {
        Encounter e = new Encounter();
        e.setPatient(getPatient());
        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, 19, "7 - Collet Test Chebaskwony", null);
        return e;
      }
     
      @Override
View Full Code Here

        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

TOP

Related Classes of org.openmrs.Encounter

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.