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

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

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

Obs.setValueCoded介绍

暂无

代码示例

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

/**
 * Sets the value of this obs to the specified valueBoolean if this obs has a boolean concept.
 * 
 * @param valueBoolean the boolean value matching the boolean coded concept to set to
 */
public void setValueBoolean(Boolean valueBoolean) {
  if (getConcept() != null && getConcept().getDatatype() != null && getConcept().getDatatype().isBoolean()) {
    if (valueBoolean != null) {
      setValueCoded(valueBoolean ? Context.getConceptService().getTrueConcept() : Context
          .getConceptService().getFalseConcept());
    } else {
      setValueCoded(null);
    }
  }
}

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

obsExit.setValueCoded(cause);

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

@Override
  public Obs setValue(Obs obs, Object value) {
    obs.setValueCoded((Concept) value);
    return obs;
  }},
BOOLEAN {

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

obsDeath.setValueCoded(currCause);

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

@Test
public void saveConcept_shouldUpdateConceptIfConceptIsAttachedToAnObservationAndItIsANonDatatypeChange()
{
  executeDataSet(INITIAL_CONCEPTS_XML);
  
  Concept concept = conceptService.getConcept(1);
  assertNotNull(concept);
  
  ObsService obsService = Context.getObsService();
  Obs obs = new Obs(new Person(1), concept, new Date(), new Location(1));
  obs.setValueCoded(Context.getConceptService().getConcept(7));
  obsService.saveObs(obs, "Creating a new observation with a concept");
  
  conceptService.saveConcept(concept);
}

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

for (ConceptAnswer conceptAnswer : conceptAnswers) {
        if (conceptAnswer.getAnswerConcept().getId().equals(answer.getId())) {
          obs.setValueCoded(answer);
          isValidAnswer = true;
          break;
  try {
    Concept valueConcept = getConcept(value, uid);
    obs.setValueCoded(valueConcept);
    if (HL7Constants.HL7_LOCAL_DRUG.equals(value.getNameOfAlternateCodingSystem().getValue())) {
      Drug valueDrug = new Drug();
} else {
  try {
    obs.setValueCoded(getConcept(value, uid));
    obs.setValueCodedName(getConceptName(value));

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

@Test(expected = ConceptInUseException.class)
public void saveConcept_shouldNotUpdateConceptDataTypeIfConceptIsAttachedToAnObservation() {
  executeDataSet(INITIAL_CONCEPTS_XML);
  
  Concept concept = conceptService.getConcept(2);
  assertNotNull(concept);
  
  ObsService obsService = Context.getObsService();
  Obs obs = new Obs(Context.getPersonService().getPerson(1), concept, new Date(), Context.getLocationService()
      .getLocation(1));
  obs.setValueCoded(Context.getConceptService().getConcept(7));
  obsService.saveObs(obs, "Creating a new observation with a concept");
  
  ConceptDatatype newDatatype = conceptService.getConceptDatatypeByName("Text");
  concept.setDatatype(newDatatype);
  conceptService.saveConcept(concept);
}

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

@Test
public void getValueAsString_shouldReturnLocalizedCodedConcept() throws Exception {
  ConceptDatatype cdt = new ConceptDatatype();
  cdt.setHl7Abbreviation("CWE");
  
  Concept cn = new Concept();
  cn.setDatatype(cdt);
  cn.addName(new ConceptName(VERO, Locale.ITALIAN));
  
  Obs obs = new Obs();
  obs.setValueCoded(cn);
  obs.setConcept(cn);
  obs.setValueCodedName(new ConceptName("True", Locale.US));
  
  Assert.assertEquals(VERO, obs.getValueAsString(Locale.ITALIAN));
}

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

/**
 * @see ObsValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldPassIfAnswerConceptAndConceptOfValueDrugMatch() {
  Obs obs = new Obs();
  obs.setPerson(new Person(7));
  obs.setObsDatetime(new Date());
  Concept questionConcept = new Concept(100);
  ConceptDatatype dt = new ConceptDatatype(1);
  dt.setUuid(ConceptDatatype.CODED_UUID);
  questionConcept.setDatatype(dt);
  obs.setConcept(questionConcept);
  Concept answerConcept = new Concept(101);
  obs.setValueCoded(answerConcept);
  
  Drug drug = new Drug();
  drug.setConcept(answerConcept);
  obs.setValueDrug(drug);
  
  Errors errors = new BindException(obs, "obs");
  obsValidator.validate(obs, errors);
  assertFalse(errors.hasFieldErrors());
}

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

ob.setEncounter(cp.getEncounter());
ob.setConcept(cp.getObsConcept());
ob.setValueCoded(cp.getMappedConcept());
if (cp.getState().equals(OpenmrsConstants.CONCEPT_PROPOSAL_SYNONYM)) {
  ob.setValueCodedName(conceptName);

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

/**
 * @see ObsValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldRejectAnInvalidConceptAndDrugCombination() {
  Obs obs = new Obs();
  obs.setPerson(new Person(7));
  obs.setObsDatetime(new Date());
  Concept questionConcept = new Concept(100);
  ConceptDatatype dt = new ConceptDatatype(1);
  dt.setUuid(ConceptDatatype.CODED_UUID);
  questionConcept.setDatatype(dt);
  obs.setConcept(questionConcept);
  obs.setValueCoded(new Concept(101));
  
  Drug drug = new Drug();
  drug.setConcept(new Concept(102));
  obs.setValueDrug(drug);
  
  Errors errors = new BindException(obs, "obs");
  obsValidator.validate(obs, errors);
  assertTrue(errors.hasFieldErrors("valueDrug"));
}

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

if (value instanceof Drug) {
  obs.setValueDrug((Drug) value);
  obs.setValueCoded(((Drug) value).getConcept());
} else if (value instanceof ConceptName) {
  obs.setValueCodedName((ConceptName) value);
  obs.setValueCoded(obs.getValueCodedName().getConcept());
} else if (value instanceof Concept) {
  obs.setValueCoded((Concept) value);
} else {
  obs.setValueCoded((Concept) convertToType(value.toString(), Concept.class));

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

<T> void writeValueToOpenMRSObservation(T value, Obs openMRSObservation) {
  if ((value instanceof Number) && isNumber(value.toString())) {
    openMRSObservation.setValueNumeric(Double.parseDouble(value.toString()));
  } else if (value instanceof String) {
    openMRSObservation.setValueText((String) value);
  } else if (value instanceof Boolean) {
    openMRSObservation.setValueNumeric(Boolean.TRUE.equals(value) ? 1.0 : 0.0);
  } else if (value instanceof Date) {
    openMRSObservation.setValueDatetime((Date) value);
  } else if (value instanceof OpenMRSConcept) {
    openMRSObservation.setValueCoded(openMRSConceptAdapter.getConceptByName(((OpenMRSConcept) value).getName().getName()));
  } else if (value != null) {
    throw new IllegalArgumentException("Invalid value of the createMRSObservation- " + value);
  }
}

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

obs.setValueCoded(Context.getConceptService().getConcept(18));
obs.setValueComplex("test");
obs.setValueDatetime(new Date());

代码示例来源:origin: openmrs/openmrs-module-webservices.rest

obs.setValueCoded(valueDrug.getConcept());
  obs.setValueDrug(valueDrug);
} else {
obs.setValueCoded(valueCoded);

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

obs.setValueGroupId(valueGroupId);
obs.setValueDatetime(valueDatetime);
obs.setValueCoded(valueCoded);
obs.setValueNumeric(valueNumeric);
obs.setValueModifier(valueModifier);

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

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

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

/**
 * 
 * Utility to give us a ready-to-save (without violating foreign-key constraints) Obs
 * 
 * @param encounter
 * @param conceptId
 * @param value
 * @param date
 * @return
 */
public static Obs createObs(Encounter encounter, Integer conceptId, Object value, Date date){
  Obs obs = new Obs(encounter.getPatient(), Context.getConceptService().getConcept(conceptId), date, encounter.getLocation());
  if (value != null) {
    if (value instanceof Number)
      obs.setValueNumeric(((Number) value).doubleValue());
    else if (value instanceof String)
      obs.setValueText((String) value);
    else if (value instanceof Date)
      obs.setValueDatetime((Date) value);
    else if (value instanceof Concept)
      obs.setValueCoded((Concept) value);
  }
  obs.setDateCreated(new Date());
  return obs;
}

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

@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);
  action.applyAction(formEntrySession);
  assertThat(patient.isDead(), is(true));
  assertThat(patient.getCauseOfDeath(), is(lungCancer));
  verify(patientService).savePatient(patient);
}

代码示例来源:origin: openmrs/openmrs-module-webservices.rest

private void clearAndSetValue(Obs obs, ObsType type, Object value) {
  obs.setValueCoded(type.equals(ObsType.CODED) ? (Concept) value : null);
  obs.setValueComplex(type.equals(ObsType.COMPLEX) ? (String) value : null);
  obs.setValueDatetime(type.equals(ObsType.DATETIME) ? (Date) value : null);
  obs.setValueDrug(type.equals(ObsType.DRUG) ? (Drug) value : null);
  obs.setValueNumeric(type.equals(ObsType.NUMERIC) ? (Double) value : null);
  obs.setValueText(type.equals(ObsType.TEXT) ? (String) value : null);
}

相关文章