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

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

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

Obs.getValueAsBoolean介绍

[英]Coerces a value to a Boolean representation
[中]将值强制为布尔表示形式

代码示例

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

/**
 * @see Obs#getValueAsBoolean()
 */
@Test
public void getValueAsBoolean_shouldReturnTrueForValue_numericConceptsIfValueIs1() throws Exception {
  Obs obs = new Obs();
  obs.setValueNumeric(1.0);
  Assert.assertEquals(true, obs.getValueAsBoolean());
}

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

/**
 * @see Obs#getValueAsBoolean()
 */
@Test
public void getValueAsBoolean_shouldReturnNullForValue_numericConceptsIfValueIsNeither1Nor0() throws Exception {
  Obs obs = new Obs();
  obs.setValueNumeric(24.8);
  Assert.assertNull(obs.getValueAsBoolean());
}

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

/**
 * @see Obs#getValueAsBoolean()
 */
@Test
public void getValueAsBoolean_shouldReturnFalseForValue_numericConceptsIfValueIs0() throws Exception {
  Obs obs = new Obs();
  obs.setValueNumeric(0.0);
  Assert.assertEquals(false, obs.getValueAsBoolean());
}

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

String abbrev = getConcept().getDatatype().getHl7Abbreviation();
if ("BIT".equals(abbrev)) {
  return getValueAsBoolean() == null ? "" : getValueAsBoolean().toString();
} else if ("CWE".equals(abbrev)) {
  if (getValueCoded() == null) {

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

this(obs.getObsDatetime(), null, obs.getValueAsBoolean(), obs.getValueCoded(), obs.getValueDatetime(), obs
    .getValueNumeric(), obs.getValueText(), obs);

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

/**
 * Removes (and returns) an Obs or ObsGroup associated with a specified Concept from existingObs.
 * Use this version for obs whose concept's datatype is boolean that are checkbox-style.
 * 
 * @param question - the concept associated with the Obs to remove
 * @param answer - the boolean value of the Obs
 * @return
 */
public Obs removeExistingObs(Concept question, Boolean answer) {
  List<Obs> list = existingObs.get(question);
  if (list != null) {
    for (Iterator<Obs> iter = list.iterator(); iter.hasNext(); ) {
      Obs test = iter.next();
      if (test.getValueAsBoolean() == null) {
        throw new RuntimeException("Invalid boolean value for concept " + question + "; possibly caused by TRUNK-3150");
      }
      if (answer == test.getValueAsBoolean()) {
        iter.remove();
        if (list.size() == 0)
          existingObs.remove(question);
        return test;
      }
    }
  }
  return null;
}

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

valueWidget.setInitialValue(existingObs.getValueAsBoolean());
} else if (defaultValue != null && Mode.ENTER.equals(context.getMode())) {
  defaultValue = defaultValue.trim();

代码示例来源:origin: org.motechproject/motech-openmrs-api

MRSObservation convertOpenMRSToMRSObservation(Obs obs) {
  ConceptDatatype datatype = obs.getConcept().getDatatype();
  if (datatype.isAnswerOnly()) {
    return createMRSObservation(obs, null);
  } else if (datatype.isBoolean()) {
    return createMRSObservation(obs, obs.getValueAsBoolean());
  } else if (datatype.isDateTime()) {
    return createMRSObservation(obs, obs.getValueDatetime());
  } else if (datatype.isNumeric()) {
    return createMRSObservation(obs, obs.getValueNumeric());
  } else if (datatype.isText()) {
    return createMRSObservation(obs, obs.getValueText());
  } else if (datatype.isCoded()) {
    return createMRSObservation(obs, new OpenMRSConcept(new OpenMRSConceptName(obs.getValueCoded().getName().getName())));
  } else {
    throw new IllegalArgumentException("Invalid value of the createMRSObservation from DB-" + obs);
  }
}

相关文章