org.openmrs.Obs类的使用及代码示例

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

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

Obs介绍

[英]An observation is a single unit of clinical information.

Observations are collected and grouped together into one Encounter (one visit). Obs can be grouped in a hierarchical fashion.

The #getObsGroup() method returns an optional parent. That parent object is also an Obs. The parent Obs object knows about its child objects through the #getGroupMembers()method.

(Multi-level hierarchies are achieved by an Obs parent object being a member of another Obs (grand)parent object) Read up on the obs table: http://openmrs.org/wiki/Obs_Table_Primer In an OpenMRS installation, there may be an occasion need to change an Obs.

For example, a site may decide to replace a concept in the dictionary with a more specific set of concepts. An observation is part of the official record of an encounter. There may be legal, ethical, and auditing consequences from altering a record. It is recommended that you create a new Obs and void the old one:
Obs newObs = Obs.newInstance(oldObs); //copies values from oldObs newObs.setPreviousVersion(oldObs); Context.getObsService().saveObs(newObs,"Your reason for the change here"); Context.getObsService().voidObs(oldObs, "Your reason for the change here");
[中]观察是临床信息的单一单位。
收集观察结果并将其分组为一次会面(一次访问)。OB可以分层方式分组。
#getObsGroup()方法返回可选的父级。该父对象也是Obs。父Obs对象通过#getGroupMembers()方法了解其子对象。
(通过Obs父对象是另一个Obs(大)父对象的成员来实现多级层次结构)在Obs表上读取:http://openmrs.org/wiki/Obs_Table_Primer在OpenMRS安装中,可能需要更改Obs。
例如,网站可能会决定用一组更具体的概念替换词典中的一个概念。观察是一次邂逅的官方记录的一部分。更改记录可能会带来法律、道德和审计方面的后果。建议您创建一个新的Obs,并将旧的Obs作废:
Obs newObs=Obs。新实例(oldObs)//从oldObs-newObs复制值。setPreviousVersion(旧版本);上下文getObsService()。saveObs(newObs,“您在此处更改的原因”);上下文getObsService()。voidObs(oldObs,你在这里更改的原因);

代码示例

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

Obs newObs = new Obs(obsToCopy.getPerson(), obsToCopy.getConcept(), obsToCopy.getObsDatetime(),
    obsToCopy.getLocation());
newObs.setObsGroup(obsToCopy.getObsGroup());
newObs.setAccessionNumber(obsToCopy.getAccessionNumber());
newObs.setValueCoded(obsToCopy.getValueCoded());
newObs.setValueDrug(obsToCopy.getValueDrug());
newObs.setValueGroupId(obsToCopy.getValueGroupId());
newObs.setValueDatetime(obsToCopy.getValueDatetime());
newObs.setValueNumeric(obsToCopy.getValueNumeric());
newObs.setValueModifier(obsToCopy.getValueModifier());
newObs.setValueText(obsToCopy.getValueText());
newObs.setComment(obsToCopy.getComment());
newObs.setEncounter(obsToCopy.getEncounter());
newObs.setCreator(obsToCopy.getCreator());
newObs.setDateCreated(obsToCopy.getDateCreated());
newObs.setVoided(obsToCopy.getVoided());
newObs.setVoidedBy(obsToCopy.getVoidedBy());
newObs.setDateVoided(obsToCopy.getDateVoided());
newObs.setVoidReason(obsToCopy.getVoidReason());
newObs.setStatus(obsToCopy.getStatus());
newObs.setInterpretation(obsToCopy.getInterpretation());
newObs.setValueComplex(obsToCopy.getValueComplex());
newObs.setComplexData(obsToCopy.getComplexData());
newObs.setFormField(obsToCopy.getFormFieldNamespace(),obsToCopy.getFormFieldPath());
if (obsToCopy.hasGroupMembers(true)) {
  for (Obs member : obsToCopy.getGroupMembers(true)) {

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

obsExit = new Obs();
obsExit.setPerson(patient);
obsExit.setConcept(reasonForExit);
  obsExit.setLocation(loc);
} else {
  log.error("Could not find a suitable location for which to create this new Obs");
obsExit.setValueCoded(cause);
obsExit.setValueCodedName(cause.getName()); // ABKTODO: presume current locale?
obsExit.setObsDatetime(exitDate);
Context.getObsService().saveObs(obsExit, "updated by PatientService.saveReasonForExit");

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

log.debug("getConcept() == " + getConcept());
if (getConcept() != null && !StringUtils.isBlank(s)) {
  String abbrev = getConcept().getDatatype().getHl7Abbreviation();
  if ("BIT".equals(abbrev)) {
    setValueBoolean(Boolean.valueOf(s));
  } else if ("CWE".equals(abbrev)) {
    throw new RuntimeException("Not Yet Implemented");
  } else if ("NM".equals(abbrev) || "SN".equals(abbrev)) {
    setValueNumeric(Double.valueOf(s));
  } else if ("DT".equals(abbrev)) {
    DateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN);
    setValueDatetime(dateFormat.parse(s));
  } else if ("TM".equals(abbrev)) {
    DateFormat timeFormat = new SimpleDateFormat(TIME_PATTERN);
    setValueDatetime(timeFormat.parse(s));
  } else if ("TS".equals(abbrev)) {
    DateFormat datetimeFormat = new SimpleDateFormat(DATE_TIME_PATTERN);
    setValueDatetime(datetimeFormat.parse(s));
  } else if ("ST".equals(abbrev)) {
    setValueText(s);
  } else {
    throw new RuntimeException("Don't know how to handle " + abbrev);

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

this(obs.getObsDatetime(), null, obs.getValueAsBoolean(), obs.getValueCoded(), obs.getValueDatetime(), obs
    .getValueNumeric(), obs.getValueText(), obs);
Concept concept = obs.getConcept();
ConceptDatatype conceptDatatype;

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

Obs obs = new Obs();
obs.setOrder(order);
obs.setConcept(concept);
obs.setPerson(patient);
obs.setEncounter(encounter);
obs.setObsDatetime(datetime);
obs.setLocation(location);
obs.setValueGroupId(valueGroupId);
obs.setValueDatetime(valueDatetime);
obs.setValueCoded(valueCoded);
obs.setValueNumeric(valueNumeric);
obs.setValueModifier(valueModifier);
obs.setValueText(valueText);
obs.setComment(comment);
assertEquals(order, saved.getOrder());
assertEquals(patient, saved.getPerson());
assertEquals(comment, saved.getComment());
assertEquals(concept, saved.getConcept());
assertEquals(encounter, saved.getEncounter());
assertEquals(DateUtil.truncateToSeconds(datetime), saved.getObsDatetime());
assertEquals(location, saved.getLocation());
assertEquals(valueGroupId, saved.getValueGroupId());
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

Obs obs = new Obs();
obs.setPerson(encounter.getPatient());
obs.setConcept(concept);
obs.setEncounter(encounter);
obs.setObsDatetime(datetime);
obs.setLocation(encounter.getLocation());
obs.setCreator(encounter.getCreator());
obs.setDateCreated(encounter.getDateCreated());
  obs.setComment(comments.toString());
  } else if ("0".equals(value) || "1".equals(value)) {
    concept = concept.hydrate(concept.getConceptId().toString());
    obs.setConcept(concept);
    if (concept.getDatatype().isBoolean()) {
      obs.setValueBoolean("1".equals(value));
    } else if (concept.getDatatype().isNumeric()) {
      try {
        obs.setValueNumeric(Double.valueOf(value));
        for (ConceptAnswer conceptAnswer : conceptAnswers) {
          if (conceptAnswer.getAnswerConcept().getId().equals(answer.getId())) {
            obs.setValueCoded(answer);
            isValidAnswer = true;
            break;
        new Object[] { obs.getConcept().getConceptId() }, null));
      obs.setValueNumeric(Double.valueOf(value));

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

/**
 * @see ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldPassValidationIfAllValuesPresent() {
  Obs obs = new Obs();
  obs.setPerson(Context.getPersonService().getPerson(2));
  obs.setConcept(Context.getConceptService().getConcept(5089));
  obs.setObsDatetime(new Date());
  obs.setValueNumeric(1.0);
  
  Errors errors = new BindException(obs, "obs");
  obsValidator.validate(obs, errors);
  
  assertFalse(errors.hasErrors());
}

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

Obs o = new Obs();
o.setConcept(cs.getConcept(3));
o.setDateCreated(new Date());
o.setCreator(Context.getAuthenticatedUser());
o.setLocation(new Location(1));
o.setObsDatetime(new Date());
o.setPerson(new Patient(2));
o.setValueText("original obs value text");
Obs o2 = new Obs();
o2.setConcept(cs.getConcept(3));
o2.setDateCreated(new Date());
o2.setCreator(Context.getAuthenticatedUser());
o2.setLocation(new Location(1));
o2.setObsDatetime(new Date());
o2.setValueText("second obs value text");
o2.setPerson(new Patient(2));
Obs oParent = new Obs();
oParent.setConcept(cs.getConcept(23)); //in the concept set table as a set
oParent.setDateCreated(new Date());
oParent.setCreator(Context.getAuthenticatedUser());
oParent.setLocation(new Location(1));
oParent.setObsDatetime(new Date());
oParent.setPerson(new Patient(2));
oParent.addGroupMember(o2);
oParent.addGroupMember(o);

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

if (obs.getPersonId() == null) {
  errors.rejectValue("person", "error.null");
if (obs.getObsDatetime() == null) {
  errors.rejectValue("obsDatetime", "error.null");
if (obs.hasGroupMembers()) {
  if (obs.getValueCoded() != null) {
    errors.rejectValue("valueCoded", "error.not.null");
  if (obs.getValueDrug() != null) {
    errors.rejectValue("valueDrug", "error.not.null");
  if (obs.getValueDatetime() != null) {
    errors.rejectValue("valueDatetime", "error.not.null");
  if (obs.getValueNumeric() != null) {
    errors.rejectValue("valueNumeric", "error.not.null");
  if (obs.getValueModifier() != null) {
    errors.rejectValue("valueModifier", "error.not.null");
  if (obs.getValueText() != null) {
    errors.rejectValue("valueText", "error.not.null");
  if (obs.getValueBoolean() != null) {
    errors.rejectValue("valueBoolean", "error.not.null");
  if (obs.getValueComplex() != null) {

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

if (getConcept() != null) {
  String abbrev = getConcept().getDatatype().getHl7Abbreviation();
  if ("BIT".equals(abbrev)) {
    return getValueAsBoolean() == null ? "" : getValueAsBoolean().toString();
  } else if ("CWE".equals(abbrev)) {
    if (getValueCoded() == null) {
      return "";
    if (getValueDrug() != null) {
      return getValueDrug().getFullName(locale);
    } else {
      ConceptName codedName = getValueCodedName();
      if (codedName != null) {
        return getValueCoded().getName(locale, false).getName();
      } else {
        ConceptName fallbackName = getValueCoded().getName();
        if (fallbackName != null) {
          return fallbackName.getName();
    if (getValueNumeric() == null) {
      return "";
    } else {
      if (getConcept() instanceof ConceptNumeric) {
        ConceptNumeric cn = (ConceptNumeric) getConcept();
        if (!cn.getAllowDecimal()) {
          double d = getValueNumeric();
          int i = (int) d;
          return Integer.toString(i);
        } else {

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

obs.setObsDatetime(new Date());
Obs child = null;
for(Obs member : obs.getGroupMembers()) {
  member.setObsDatetime(newDate);
  if(member.getId() == 17) {
    child = member;
Obs child1 = child.getGroupMembers().iterator().next();
child1.setObsDatetime(newDate);
Obs o1 = new Obs();
o1.setConcept(cs.getConcept(3));
o1.setDateCreated(newDate);
o1.setCreator(Context.getAuthenticatedUser());
o1.setLocation(new Location(1));
o1.setObsDatetime(newDate);
o1.setValueText("NewObs Value");
o1.setPerson(new Patient(2));
child.addGroupMember(o1);
Assert.assertEquals(newObs.getObsDatetime().toString(), newDate.toString());
for(Obs member : newObs.getGroupMembers()) {
  Assert.assertEquals(member.getObsDatetime().toString(), newDate.toString());
  if(member.getGroupMembers()!= null) {
    for (Obs memberChild : member.getGroupMembers()) {
      Assert.assertEquals(memberChild.getObsDatetime().toString(), newDate.toString());
      if (memberChild.getValueText()!= null && memberChild.getValueText().equals("NewObs Value")) {

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

public void validate_shouldFailIfParentObshasValues() {
  Obs obs = new Obs();
  obs.setPerson(Context.getPersonService().getPerson(2));
  obs.setConcept(Context.getConceptService().getConcept(18));
  obs.setValueBoolean(false);
  obs.setValueCoded(Context.getConceptService().getConcept(18));
  obs.setValueComplex("test");
  obs.setValueDatetime(new Date());
  obs.setValueDrug(Context.getConceptService().getDrug(3));
  obs.setValueGroupId(getLoadCount());
  obs.setValueModifier("test");
  obs.setValueNumeric(1212.0);
  obs.setValueText("test");
  obs.setGroupMembers(group);

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

@Test
public void saveEncounter_shouldUpdateExistingEncounterWhenNewObsIsAddedToParentObs() {
  executeDataSet(ENC_OBS_HIERARCHY_DATA_XML);
  ConceptService cs = Context.getConceptService();
  EncounterService es = Context.getEncounterService();
  ObsService os = Context.getObsService();
  Encounter enc = es.getEncounter(100);
  Obs o3 = new Obs();
  o3.setConcept(cs.getConcept(3));
  o3.setDateCreated(new Date());
  o3.setCreator(Context.getAuthenticatedUser());
  o3.setLocation(new Location(1));
  o3.setObsDatetime(new Date());
  o3.setPerson(Context.getPersonService().getPerson(3));
  o3.setValueText("third obs value text");
  o3.setEncounter(enc);
  Obs oParent = os.getObs(100);
  oParent.addGroupMember(o3);
  es.saveEncounter(enc);
  Context.flushSession();
  Context.clearSession();
  enc = es.getEncounter(100);
  Set<Obs> obsAtTopLevelUpdated = enc.getObsAtTopLevel(true);
  assertEquals(1,obsAtTopLevelUpdated.size());
  assertEquals(3, obsAtTopLevelUpdated.iterator().next().getGroupMembers(true).size());
  oParent = os.getObs(100);
  assertTrue(oParent.getGroupMembers(true).contains(os.getObs(101)));
  assertTrue(oParent.getGroupMembers(true).contains(os.getObs(102)));
  assertTrue(oParent.getGroupMembers(true).contains(os.getObs(o3.getObsId())));
}

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

Obs ob = new Obs();
ob.setEncounter(cp.getEncounter());
ob.setConcept(cp.getObsConcept());
ob.setValueCoded(cp.getMappedConcept());
if (cp.getState().equals(OpenmrsConstants.CONCEPT_PROPOSAL_SYNONYM)) {
  ob.setValueCodedName(conceptName);
ob.setCreator(Context.getAuthenticatedUser());
ob.setDateCreated(new Date());
ob.setObsDatetime(cp.getEncounter().getEncounterDatetime());
ob.setLocation(cp.getEncounter().getLocation());
ob.setPerson(cp.getEncounter().getPatient());
if (ob.getUuid() == null) {
  ob.setUuid(UUID.randomUUID().toString());

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

/**
 * @see ObsService#saveObs(Obs,String)
 */
@Test
public void saveObs_shouldSetCreatorAndDateCreatedOnNewObs() {
  Obs o = new Obs();
  o.setConcept(Context.getConceptService().getConcept(3));
  o.setPerson(new Patient(2));
  o.setEncounter(new Encounter(3));
  o.setObsDatetime(new Date());
  o.setLocation(new Location(1));
  o.setValueNumeric(50d);
  
  Context.getObsService().saveObs(o, null);
  assertNotNull(o.getDateCreated());
  assertNotNull(o.getCreator());
}

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

/**
 * @see ObsService#saveObs(Obs,String)
 */
@Test
public void saveObs_shouldCreateVeryBasicObsAndAddNewObsId() {
  Obs o = new Obs();
  o.setConcept(Context.getConceptService().getConcept(3));
  o.setPerson(new Patient(2));
  o.setEncounter(new Encounter(3));
  o.setObsDatetime(new Date());
  o.setLocation(new Location(1));
  o.setValueNumeric(50d);
  
  Obs oSaved = Context.getObsService().saveObs(o, null);
  
  // make sure the returned Obs and the passed in obs
  // now both have primary key obsIds
  assertTrue(oSaved.getObsId().equals(o.getObsId()));
}

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

/**
 * @see Obs#getValueAsString(Locale)
 */
@Test
public void getValueAsString_shouldUseCommasOrDecimalPlacesDependingOnLocale() throws Exception {
  Obs obs = new Obs();
  obs.setValueNumeric(123456789.3);
  String str = "123456789,3";
  Assert.assertEquals(str, obs.getValueAsString(Locale.GERMAN));
}

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

ConceptDatatype datatype = field.getQuestion().getDatatype();
if (datatype.isDateTime()) {
  value = field.getExistingObs().getValueDate() != null ?
      datetimeFormat.format(field.getExistingObs().getValueDate()) : "";
} else if (datatype.isDate()) {
  value = field.getExistingObs().getValueDate() != null ?
      dateFormat.format(field.getExistingObs().getValueDate()) : "";
} else if (datatype.isTime()) {
  value = field.getExistingObs().getValueDate() != null ?
      timeFormat.format(field.getExistingObs().getValueDate()) : "";
} else if (datatype.isNumeric()) {
  value = field.getExistingObs().getValueNumeric() != null ?
      field.getExistingObs().getValueNumeric().toString() : "";
} else if (datatype.isBoolean()) {
  value = field.getExistingObs().getValueBoolean() != null ?
      field.getExistingObs().getValueBoolean().toString() : "";
} else if (datatype.isText()) {
  if ("org.openmrs.Location".equals(field.getExistingObs().getComment())) {
    value = locationService.getLocation(new Integer(field.getExistingObs().getValueText())).getName();
    value = field.getExistingObs().getValueText();
  value = field.getExistingObs().getValueCodedName() != null ?
      field.getExistingObs().getValueCodedName().getName() :
      field.getExistingObs().getValueCoded() != null ?
          field.getExistingObs().getValueCoded().getName().getName() : "";

相关文章