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

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

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

Obs.getValueCoded介绍

暂无

代码示例

代码示例来源: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

return getValueAsBoolean() == null ? "" : getValueAsBoolean().toString();
  } else if ("CWE".equals(abbrev)) {
    if (getValueCoded() == null) {
      return "";
      ConceptName codedName = getValueCodedName();
      if (codedName != null) {
        return getValueCoded().getName(locale, false).getName();
      } else {
        ConceptName fallbackName = getValueCoded().getName();
        if (fallbackName != null) {
          return fallbackName.getName();
} else if (getValueCoded() != null) {
  if (getValueDrug() != null) {
    return getValueDrug().getFullName(locale);

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

@Test
  public void setValueBoolean_shouldNotSetValueForNonBooleanConcept() throws Exception {
    Obs obs = createObs(2);
    ConceptDatatype dataType = new ConceptDatatype();
    dataType.setUuid(ConceptDatatype.CODED_UUID);
    obs.getConcept().setDatatype(dataType);
    assertNotNull(obs.getValueCoded());
    obs.setValueBoolean(null);
    assertNotNull(obs.getValueCoded());
  }
}

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

if (obs.getValueCoded() != null) {
    errors.rejectValue("valueCoded", "error.not.null");
else if (obs.getValueBoolean() == null && obs.getValueCoded() == null && obs.getValueCodedName() == null
    && obs.getValueComplex() == null && obs.getValueDatetime() == null && obs.getValueDrug() == null
    && obs.getValueModifier() == null && obs.getValueNumeric() == null && obs.getValueText() == null
        errors.rejectValue("groupMembers", "Obs.error.inGroupMember");
    } else if (dt.isCoded() && obs.getValueCoded() == null) {
      if (atRootNode) {
        errors.rejectValue("valueCoded", "error.null");
if (obs.getValueCoded() != null && obs.getValueDrug() != null && obs.getValueDrug().getConcept() != null) {
  Concept trueConcept = Context.getConceptService().getTrueConcept();
  Concept falseConcept = Context.getConceptService().getFalseConcept();
  if (!obs.getValueCoded().equals(trueConcept) && !obs.getValueCoded().equals(falseConcept)
      && !obs.getValueDrug().getConcept().equals(obs.getValueCoded())) {
    errors.rejectValue("valueDrug", "Obs.error.invalidDrug");

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

assertEquals("There should be a contact method", 1, contactMethodObsForPatient2.size());
Obs firstContactMethodObs = (Obs) contactMethodObsForPatient2.toArray()[0];
assertEquals("The contact method should be phone", phoneContact, firstContactMethodObs.getValueCoded());

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

@Test
@Verifies(value="shouldSetValueCodedNameGivenAConceptName",method="createObs(Concept concept, Object value, Date datetime, String accessionNumber)")
public void createObs_shouldSetValueCodedNameGivenAConceptName() {
  Concept answerConcept = new Concept();
  ConceptName answer = new ConceptName("Answer", Context.getLocale());
  answerConcept.addName(answer);
  Concept question = new Concept();
  question.setUuid(UUID.randomUUID().toString());
  question.setDatatype(Context.getConceptService().getConceptDatatypeByName("Coded"));
  Obs created = HtmlFormEntryUtil.createObs(question, answer, new Date(), "");
  assertThat(created.getValueCodedName(), is(answerConcept.getPreferredName(Context.getLocale())));
  assertThat(created.getValueCoded(), is(answerConcept));
}

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

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

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

/**
 * @see ORUR01Handler#processMessage(Message)
 */
@Test
public void processMessage_shouldSetValue_CodedMatchingABooleanConceptForObsIfTheAnswerIs0Or1AndQuestionDatatypeIsCoded()
    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|2|NM|21^CIVIL STATUS^99DCT||1|||||||||20080206";
  // the expected question for the obs in the hl7 message has to be coded
  Assert.assertEquals("Coded", Context.getConceptService().getConcept(21).getDatatype().getName());
  List<Obs> oldList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(21));
  Message hl7message = parser.parse(hl7string);
  router.processMessage(hl7message);
  // hacky way to get the newly added obs and make tests on it
  List<Obs> newList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(21));
  Obs newObservation = null;
  for (Obs newObs : newList) {
    if (!oldList.contains(newObs) && !newObs.isObsGrouping()) {
      newObservation = newObs;
    }
  }
  Assert.assertEquals(Context.getConceptService().getTrueConcept(), newObservation.getValueCoded());
}

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

private Concept findObsCodedValue(Encounter encounter, Concept concept) {
  for (Obs candidate : encounter.getAllObs(false)) {
    if (candidate.getConcept().equals(concept)) {
      return candidate.getValueCoded();
    }
  }
  return null;
}

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

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

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

newObs.setValueCoded(obsToCopy.getValueCoded());
newObs.setValueDrug(obsToCopy.getValueDrug());
newObs.setValueGroupId(obsToCopy.getValueGroupId());

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

@Override
public void testEditedResults(SubmissionResults results) {
  results.assertNoErrors();
  Encounter encounter = results.getEncounterCreated();
  assertThat(encounter.getAllObs(false).size(), is(2));   // should be two non-voided obs of value 1002 & 1003
  assertThat(encounter.getAllObs(true).size(), is(3));   // should be three obs included the voided obs for 1001
  Set<Integer> valueCoded = new HashSet<Integer>();
  for (Obs obs : encounter.getAllObs(true)) {
    if (obs.isVoided()) {
      assertThat(obs.getValueCoded().getId(), is(1001));
    }
    else {
      valueCoded.add(obs.getValueCoded().getId());
    }
  }
  assertTrue(valueCoded.contains(1002));
  assertTrue(valueCoded.contains(1003));
}

代码示例来源: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

@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());
    }
  }
  assertTrue(valueCoded.contains(1002));
  assertTrue(valueCoded.contains(1001));
}

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

@Override
public void testResults(SubmissionResults results) {
  results.assertNoErrors();
  List<Obs> obsList = os.getObservationsByPersonAndConcept(results.getPatient(), cs.getConcept("4200"));
  List<Obs> obsDeathList = os.getObservationsByPersonAndConcept(results.getPatient(), cs.getConcept("4300"));
  Assert.assertEquals(obsList.size(),1);
  Assert.assertEquals(obsDeathList.size(),1);
  Assert.assertEquals("PATIENT DIED",obsList.get(0).getValueCoded().getDisplayString());
  Assert.assertEquals(dateAsString(date),dateAsString(obsList.get(0).getObsDatetime()));
  Assert.assertEquals("OTHER NON-CODED",obsDeathList.get(0).getValueCoded().getDisplayString());
  Assert.assertEquals("Died from cancer",obsDeathList.get(0).getValueText());
}

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

@Override
public void testResults(SubmissionResults results) {
  results.assertNoErrors();
  List<Obs> obsList = os.getObservationsByPersonAndConcept(results.getPatient(), cs.getConcept("4200"));
  List<Obs> obsDeathList = os.getObservationsByPersonAndConcept(results.getPatient(), cs.getConcept("4300"));
  Assert.assertEquals(obsList.size(),1);
  Assert.assertEquals(obsDeathList.size(),1);
  Assert.assertEquals("PATIENT DIED",obsList.get(0).getValueCoded().getDisplayString());
  Assert.assertEquals(dateAsString(date),dateAsString(obsList.get(0).getObsDatetime()));
  Assert.assertEquals("STROKE",obsDeathList.get(0).getValueCoded().getDisplayString());
  Assert.assertEquals(null,obsList.get(0).getValueText());
}

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

@Override
public void testResults(SubmissionResults results) {
  results.assertNoErrors();
  results.assertEncounterCreated();
  results.assertObsGroupCreatedCount(2);
  
  Set<Concept> immunizations = new HashSet<Concept>();
  Set<String> dates = new HashSet<String>();
  
  Set<Obs> observations = results.getEncounterCreated().getObs();
  for (Obs obs : observations) {
    if (obs.getConcept().getId().equals(984)) {
      immunizations.add(obs.getValueCoded());
    }
    if (obs.getConcept().getId().equals(1410)) {
      dates.add(dateAsString(obs.getValueDate()));
    }
  }
  assertThat(immunizations, containsInAnyOrder(hasId(886), hasId(783)));
  assertThat(dates, contains(dateAsString(date)));
}

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

@Override
public void testResults(SubmissionResults results) {
  results.assertNoErrors();
  List<Obs> obsList = os.getObservationsByPersonAndConcept(results.getPatient(), cs.getConcept("4200"));
  Assert.assertEquals(obsList.size(),1);
  Assert.assertEquals("RECOVERED",obsList.get(0).getValueCoded().getDisplayString());
  Assert.assertEquals(dateAsString(date),dateAsString(obsList.get(0).getObsDatetime()));
}

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

@Override
public void testEditedResults(SubmissionResults results) {
  results.assertNoErrors();;
  results.assertProvider(502);
  results.assertLocation(2);
  results.assertObsCreatedCount(1);
  Obs locationObs = results.getEncounterCreated().getObs().iterator().next();
  Assert.assertEquals("3", locationObs.getValueText());
  Assert.assertNull(locationObs.getValueCoded());
  Assert.assertEquals("org.openmrs.Location", locationObs.getComment());
};

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

@Override
  public void testResults(SubmissionResults results) {
    results.assertNoErrors();
    results.assertEncounterCreated();
    results.assertProvider(502);
    results.assertLocation(2);
    results.assertObsCreatedCount(1);
    Obs locationObs = results.getEncounterCreated().getObs().iterator().next();
    Assert.assertEquals("2", locationObs.getValueText());
    Assert.assertNull(locationObs.getValueCoded());
    Assert.assertEquals("org.openmrs.Location", locationObs.getComment());
  }
}.run();

相关文章

微信公众号

最新文章

更多