Package org.openmrs

Examples of org.openmrs.Obs


   */
  private void createObsFromPost(SimpleObject post, Encounter encounter) throws ResponseException {
    List<LinkedHashMap> obsObjects = (List<LinkedHashMap>) post.get("obs");
    List<Obs> encounterObs = new ArrayList();
    for (int i = 0; i < obsObjects.size(); i++) {
      Obs obs = new Obs();
      obs.setPerson(encounter.getPatient());
      obs.setConcept(Context.getConceptService().getConceptByUuid(obsObjects.get(i).get("concept").toString()));
      obs.setObsDatetime(encounter.getEncounterDatetime());
      if (encounter.getLocation() != null) {
        obs.setLocation(encounter.getLocation());
      }
      obs.setEncounter(encounter);
      if (obsObjects.get(i).get("value") != null) {
        setObsValue(obs, obsObjects.get(i).get("value").toString());
      }
      if (obsObjects.get(i).get("comment") != null) {
        obs.setComment(obsObjects.get(i).get("comment").toString());
      }
      encounter.addObs(obs);
      //Context.getObsService().saveObs(obs, "saving new obs");
    }
  }
View Full Code Here


    Set<Obs> obs = encounter.getObs();
    if (!encounter.getObs().isEmpty()) {
      ArrayList obsObjects = new ArrayList();
      Iterator<Obs> obsIter = obs.iterator();
      while (obsIter.hasNext()) {
        Obs currentObs = obsIter.next();
        obsObjects.add(createObjectFromObs(currentObs));
      }
      obj.add("obs", obsObjects);
    }
    Set<Order> orders = encounter.getOrders();
View Full Code Here

    @Test
    public void testSettingCauseOfDeath() throws Exception {
        Concept causeOfDeath = new Concept();
        Concept lungCancer = new Concept();
        Obs causeOfDeathObs = new Obs();
        causeOfDeathObs.setConcept(causeOfDeath);
        causeOfDeathObs.setValueCoded(lungCancer);
        encounter.addObs(causeOfDeathObs);

        MarkPatientDeadTagHandler.Action action = tagHandler.newAction();
        action.setCauseOfDeathFromObs(causeOfDeath);
View Full Code Here

        // avoid lazy init exception
        groupingConcept.getDatatype().getHl7Abbreviation();
              
        String name = attributes.get("label");
        // find relevant obs group to display for this element
        Obs thisGroup = findObsGroup(session, node, attributes.get("groupingConceptId"));
       
        boolean digDeeper = true;
       
        if (thisGroup == null && (session.getContext().getMode() == Mode.EDIT || session.getContext().getMode() == Mode.VIEW)) {
          if (!session.getContext().isUnmatchedMode()) {
View Full Code Here

  public void earliestObs_shouldReturnTheFirstObsGivenThePassedConceptId() throws Exception {

    VelocityFunctions functions = setupFunctionsForPatient(7);
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
       
        Obs earliestWeight = functions.earliestObs(5089);
        Assert.assertEquals(50, earliestWeight.getValueNumeric().intValue());
        // this is a bit of a hack because for some reason the obsDatetime set for this obs in the standard test dataset changed between 1.7 and 1.8
        Assert.assertTrue("Obs datetime not correct", (StringUtils.equals("2008-08-01", df.format(earliestWeight.getObsDatetime()))
                || StringUtils.equals("2008-07-01", df.format(earliestWeight.getObsDatetime()))));
    }
View Full Code Here

    public void earliestObs_shouldReturnTheFirstObsGivenThePassedConcepUuid() throws Exception {

        VelocityFunctions functions = setupFunctionsForPatient(7);
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

        Obs earliestWeight = functions.earliestObs("c607c80f-1ea9-4da3-bb88-6276ce8868dd");
        Assert.assertEquals(50, earliestWeight.getValueNumeric().intValue());
        // this is a bit of a hack because for some reason the obsDatetime set for this obs in the standard test dataset changed between 1.7 and 1.8
        Assert.assertTrue("Obs datetime not correct", (StringUtils.equals("2008-08-01", df.format(earliestWeight.getObsDatetime()))
                || StringUtils.equals("2008-07-01", df.format(earliestWeight.getObsDatetime()))));
    }
View Full Code Here

  public void latestObs_shouldReturnTheMostRecentObsGivenThePassedConceptId() throws Exception {

    VelocityFunctions functions = setupFunctionsForPatient(7);
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
       
        Obs earliestWeight = functions.latestObs(5089);
        Assert.assertEquals(61, earliestWeight.getValueNumeric().intValue());
        Assert.assertEquals("2008-08-19", df.format(earliestWeight.getObsDatetime()));
  }
View Full Code Here

    public void latestObs_shouldReturnTheMostRecentObsGivenThePassedConceptUuid() throws Exception {

        VelocityFunctions functions = setupFunctionsForPatient(7);
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");

        Obs earliestWeight = functions.latestObs("c607c80f-1ea9-4da3-bb88-6276ce8868dd");
        Assert.assertEquals(61, earliestWeight.getValueNumeric().intValue());
        Assert.assertEquals("2008-08-19", df.format(earliestWeight.getObsDatetime()));
    }
View Full Code Here

        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);
        resultParent.addGroupMember(colonies1);

        //saving the enconter in order to see obsGroupId in export
        Context.getEncounterService().saveEncounter(e);
        encounters.add(e);
View Full Code Here

        if (causeOfDeathWidget != null) {

            if (context.getMode() == FormEntryContext.Mode.VIEW) {
                if (obsList != null && obsList.size() == 1) {
                    Obs obs = obsList.get(0);
                    if (obs.getValueCoded().getConceptId().equals(patientDiedConcept.getConceptId())) {
                        sb.append(causeOfDeathWidget.generateHtml(context));
                    }
                } else if (obsList != null && obsList.size() == 0) {
                    // this state may not be happen often, but in case that there is no exit from case
                    // observation, but however patient is dead, we are displaying cause of death then
                    if (obsDeath != null && obsDeath.size() == 1) {
                        sb.append(causeOfDeathWidget.generateHtml(context));
                    }
                }
            } else {
                sb.append(causeOfDeathWidget.generateHtml(context));
            }

            if (context.getMode() != FormEntryContext.Mode.VIEW) {
                sb.append(causeOfDeathErrorWidget.generateHtml(context));
            }

            // only show causeOfDeathWidget if there is an initial value, else hide it
            if (context.getMode() == FormEntryContext.Mode.ENTER) {
                sb.append("<script>");
                sb.append("$j(document).ready(function(){");
                sb.append(" if($j(\"#" + causeWidgetId + "\").val() != \"\" && "
                        + "$j(\"#" + reasonWidgetId + "\").val() == \"" + patientDiedConId + "\"){\n");
                sb.append(" $j(\"#" + causeWidgetId + "\").show();}\n");
                sb.append(" if($j(\"#" + causeWidgetId + "\").val() == \"\"){\n");
                sb.append(" $j(\"#" + causeWidgetId + "\").hide();}\n");
                sb.append("});");
                sb.append("</script>");
            }
            if (context.getMode() == FormEntryContext.Mode.EDIT) {
                sb.append("<script>");
                sb.append("$j(document).ready(function(){");
                sb.append("var cVal = $j(\"#" + causeWidgetId + "\").val();");
                sb.append("if (cVal == \"" + otherNonCodedConId + "\")\n"
                        + " { $j(\"#" + otherTextWidgetId + "\").show();}\n"
                        + "if (cVal != \"" + otherNonCodedConId + "\")\n"
                        + " { $j(\"#" + otherTextWidgetId + "\").val(\"\"); $j(\"#" + otherTextWidgetId + "\").hide();}");
                sb.append("});");
                sb.append("</script>");
            }
        }

        // adding a jquery event handler to causeOfDeathWidget
        sb.append("<script>");
        sb.append("$j(\"#" + causeWidgetId + "\").change(function(){");
        sb.append("var causeVal = $j(\"#" + causeWidgetId + "\").val();");
        sb.append("if (causeVal == \"" + otherNonCodedConId + "\")\n"
                + " { $j(\"#" + otherTextWidgetId + "\").show();}\n"
                + "if (causeVal != \"" + otherNonCodedConId + "\")\n"
                + " { $j(\"#" + otherTextWidgetId + "\").val(\"\"); $j(\"#" + otherTextWidgetId + "\").hide();}");
        sb.append("});");
        sb.append("</script>");

        // providing a blank space between the widgets
        sb.append("&nbsp;&nbsp;");

        if (otherReasonWidget != null) {
            if (context.getMode() == FormEntryContext.Mode.VIEW) {
                if (obsDeath != null && obsDeath.size() == 1) {
                    Obs obs = obsDeath.get(0);

                    if (obsList != null && obsList.size() == 0) {
                        if (obs.getValueCoded().getConceptId().equals(otherNonCodedConcept.getConceptId())) {
                            sb.append(otherReasonWidget.generateHtml(context));
                        }
                    } else if (obsList != null && obsList.size() == 1) {
                        Obs exitObs = obsList.get(0);
                        if (exitObs.getValueCoded().getConceptId().equals(patientDiedConcept.getConceptId())
                                && obs.getValueCoded().getConceptId().equals(otherNonCodedConcept.getConceptId())) {
                            sb.append(otherReasonWidget.generateHtml(context));
                        }
                    }
                }
View Full Code Here

TOP

Related Classes of org.openmrs.Obs

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.