org.openmrs.Obs.getValueNumeric()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(12.2k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中org.openmrs.Obs.getValueNumeric()方法的一些代码示例,展示了Obs.getValueNumeric()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Obs.getValueNumeric()方法的具体详情如下:
包路径:org.openmrs.Obs
类名称:Obs
方法名:getValueNumeric

Obs.getValueNumeric介绍

暂无

代码示例

代码示例来源:origin: openmrs/openmrs-core

/**
 * Coerces a value to a Boolean representation
 * 
 * @return Boolean representation of the obs value
 * @should return true for value_numeric concepts if value is 1
 * @should return false for value_numeric concepts if value is 0
 * @should return null for value_numeric concepts if value is neither 1 nor 0
 */
public Boolean getValueAsBoolean() {
  
  if (getValueCoded() != null) {
    if (getValueCoded().equals(Context.getConceptService().getTrueConcept())) {
      return Boolean.TRUE;
    } else if (getValueCoded().equals(Context.getConceptService().getFalseConcept())) {
      return Boolean.FALSE;
    }
  } else if (getValueNumeric() != null) {
    if (getValueNumeric() == 1) {
      return Boolean.TRUE;
    } else if (getValueNumeric() == 0) {
      return Boolean.FALSE;
    }
  }
  //returning null is preferred to defaulting to false to support validation of user input is from a form
  return null;
}

代码示例来源:origin: openmrs/openmrs-core

if (getValueNumeric() == null) {
      return "";
    } else {
        ConceptNumeric cn = (ConceptNumeric) getConcept();
        if (!cn.getAllowDecimal()) {
          double d = getValueNumeric();
          int i = (int) d;
          return Integer.toString(i);
        } else {
          df.format(getValueNumeric());
if (getValueNumeric() != null) {
  return df.format(getValueNumeric());
} else if (getValueCoded() != null) {
  if (getValueDrug() != null) {

代码示例来源:origin: openmrs/openmrs-core

@Test
public void saveObs_shouldNotChangeStatusOfPreliminaryWhenModifyingAnObs() throws Exception {
  Obs existing = obsService.getObs(9);
  existing.setValueNumeric(175.0);
  Obs newObs = obsService.saveObs(existing, "testing");
  assertThat(newObs.getValueNumeric(), is(175.0));
  assertThat(newObs.getStatus(), is(Obs.Status.PRELIMINARY));
}

代码示例来源:origin: openmrs/openmrs-core

@Test
public void saveObs_shouldSetStatusToAmendedWhenModifyingAnObsWithFinalStatus() throws Exception {
  Obs existing = obsService.getObs(7);
  existing.setValueNumeric(60.0);
  Obs amended = obsService.saveObs(existing, "testing");
  assertThat(amended.getValueNumeric(), is(60.0));
  assertThat(amended.getStatus(), is(Obs.Status.AMENDED));
  assertThat(existing.getStatus(), is(Obs.Status.FINAL));
}

代码示例来源:origin: openmrs/openmrs-core

@Test
public void saveObs_shouldLetYouChangeStatusFromPreliminaryToFinalWhenModifyingAnObs() throws Exception {
  Obs existing = obsService.getObs(9);
  existing.setValueNumeric(175.0);
  existing.setStatus(Obs.Status.FINAL);
  Obs newObs = obsService.saveObs(existing, "testing");
  assertThat(newObs.getValueNumeric(), is(175.0));
  assertThat(newObs.getStatus(), is(Obs.Status.FINAL));
}

代码示例来源:origin: org.motechproject/motech-server-core

protected Integer getLargestDoseValue(List<Obs> obsList) {
  Double largestDoseValue = null;
  for (Obs obs : obsList) {
    Double obsValue = obs.getValueNumeric();
    if (obsValue != null) {
      if (largestDoseValue == null || obsValue > largestDoseValue) {
        largestDoseValue = obsValue;
      }
    }
  }
  if (largestDoseValue != null) {
    return largestDoseValue.intValue();
  }
  return null;
}

代码示例来源:origin: openmrs/openmrs-core

.getValueNumeric(), obs.getValueText(), obs);

代码示例来源:origin: openmrs/openmrs-core

@Test
public void newInstance_shouldCopyMostFields() throws Exception {
  Obs obs = new Obs();
  obs.setStatus(Obs.Status.PRELIMINARY);
  obs.setInterpretation(Obs.Interpretation.LOW);
  obs.setConcept(new Concept());
  obs.setValueNumeric(1.2);
  
  Obs copy = Obs.newInstance(obs);
  
  // these fields are not copied
  assertThat(copy.getObsId(), nullValue());
  assertThat(copy.getUuid(), not(obs.getUuid()));
  
  // other fields are copied
  assertThat(copy.getConcept(), is(obs.getConcept()));
  assertThat(copy.getValueNumeric(), is(obs.getValueNumeric()));
  assertThat(copy.getStatus(), is(obs.getStatus()));
  assertThat(copy.getInterpretation(), is(obs.getInterpretation()));
  // TODO test that the rest of the fields are set
}

代码示例来源:origin: openmrs/openmrs-core

if (obs.getValueNumeric() != null) {
  errors.rejectValue("valueNumeric", "error.not.null");
  && obs.getValueModifier() == null && obs.getValueNumeric() == null && obs.getValueText() == null
  && obs.getComplexData() == null) {
errors.reject("error.noValue");
      errors.rejectValue("groupMembers", "Obs.error.inGroupMember");
  } else if (dt.isNumeric() && obs.getValueNumeric() == null) {
    if (atRootNode) {
      errors.rejectValue("valueNumeric", "error.null");
    ConceptNumeric cn = Context.getConceptService().getConceptNumeric(c.getConceptId());
    if (!cn.getAllowDecimal() && Math.ceil(obs.getValueNumeric()) != obs.getValueNumeric()) {
      if (atRootNode) {
        errors.rejectValue("valueNumeric", "Obs.error.precision");
    if (cn.getHiAbsolute() != null && cn.getHiAbsolute() < obs.getValueNumeric()) {
      if (atRootNode) {
        errors.rejectValue("valueNumeric", "error.outOfRange.high");
    if (cn.getLowAbsolute() != null && cn.getLowAbsolute() > obs.getValueNumeric()) {
      if (atRootNode) {
        errors.rejectValue("valueNumeric", "error.outOfRange.low");

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see ORUR01Handler#processMessage(Message)
 */
@Test
public void processMessage_shouldSetValue_NumericForObsIfQuestionDatatypeIsNumeric() throws Exception {
  ObsService os = Context.getObsService();
  String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r"
      + "PID|||7^^^^||Collet^Test^Chebaskwony||\r"
      + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r"
      + "ORC|RE||||||||20080226102537|1^Super User\r"
      + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r"
      + "OBX|1|NM|5497^CD4, BY FACS^99DCT||450|||||||||20080206";
  // the expected question for the obs in the hl7 message has to be
  // numeric
  Assert.assertEquals("Numeric", Context.getConceptService().getConcept(5497).getDatatype().getName());
  List<Obs> oldList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(5497));
  Message hl7message = parser.parse(hl7string);
  router.processMessage(hl7message);
  List<Obs> newList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(5497));
  Obs newObservation = null;
  for (Obs newObs : newList) {
    if (!oldList.contains(newObs) && !newObs.isObsGrouping()) {
      newObservation = newObs;
    }
  }
  Assert.assertEquals(450, newObservation.getValueNumeric().intValue());
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see ORUR01Handler#processMessage(Message)
 */
@Test
public void processMessage_shouldSetValue_NumericForObsIfQuestionDatatypeIsNumericAndTheAnswerIsEither0Or1()
    throws Exception {
  ObsService os = Context.getObsService();
  String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r"
      + "PID|||7^^^^||Collet^Test^Chebaskwony||\r"
      + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r"
      + "ORC|RE||||||||20080226102537|1^Super User\r"
      + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r"
      + "OBX|1|NM|5497^CD4, BY FACS^99DCT||1|||||||||20080206";
  // the expected question for the obs in the hl7 message has to be
  // numeric
  Assert.assertEquals("Numeric", Context.getConceptService().getConcept(5497).getDatatype().getName());
  List<Obs> oldList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(5497));
  Message hl7message = parser.parse(hl7string);
  router.processMessage(hl7message);
  List<Obs> newList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(5497));
  Obs newObservation = null;
  for (Obs newObs : newList) {
    if (!oldList.contains(newObs) && !newObs.isObsGrouping()) {
      newObservation = newObs;
    }
  }
  Assert.assertEquals(1, newObservation.getValueNumeric().intValue());
}

代码示例来源:origin: openmrs/openmrs-module-htmlformentry

@Test
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()))));
}

代码示例来源:origin: openmrs/openmrs-module-htmlformentry

/**
 * @see VelocityFunctions#earliestObs(Integer)
 * @verifies return the first obs given the passed conceptId
 */
@Test
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()))));
 }

代码示例来源:origin: openmrs/openmrs-module-htmlformentry

/**
 * @see VelocityFunctions#latestObs(Integer)
 * @verifies return the most recent obs given the passed conceptId
 */
@Test
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()));
}

代码示例来源:origin: openmrs/openmrs-module-htmlformentry

protected void checkBooleanObsValue(Obs obs, boolean expected) {
    if (OpenmrsConstants.OPENMRS_VERSION_SHORT.equals("1.6")) {
      Double expectedValue = expected ? 1.0 : 0.0;
      Assert.assertEquals(expectedValue, obs.getValueNumeric());
    }
    else {
      String expectedGpProperty = expected ? "concept.true" : "concept.false";
      String conceptId = Context.getAdministrationService().getGlobalProperty(expectedGpProperty);
      Assert.assertEquals(conceptId, obs.getValueCoded().getConceptId().toString());
    }
  }
}

代码示例来源:origin: openmrs/openmrs-module-htmlformentry

@Test
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()));
}

代码示例来源:origin: openmrs/openmrs-module-htmlformentry

@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));
  assertThat(functions.allObs(encounter, "3").size(), is(0));
}

代码示例来源:origin: openmrs/openmrs-core

assertEquals(DateUtil.truncateToSeconds(valueDatetime), saved.getValueDatetime());
assertEquals(valueCoded, saved.getValueCoded());
assertEquals(valueNumeric, saved.getValueNumeric());
assertEquals(valueModifier, saved.getValueModifier());
assertEquals(valueText, saved.getValueText());

代码示例来源:origin: openmrs/openmrs-core

newObs.setValueGroupId(obsToCopy.getValueGroupId());
newObs.setValueDatetime(obsToCopy.getValueDatetime());
newObs.setValueNumeric(obsToCopy.getValueNumeric());
newObs.setValueModifier(obsToCopy.getValueModifier());
newObs.setValueText(obsToCopy.getValueText());

代码示例来源:origin: openmrs/openmrs-module-htmlformentry

@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());
}

相关文章

微信公众号

最新文章

更多