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

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

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

Obs.setPersonId介绍

[英]Set the person id on this obs object. This method is here for convenience, but really the #setPerson(Person) method should be used like setPerson(new Person(personId))
[中]设置此obs对象上的人员id。这里的这个方法是为了方便起见,但实际上#setPerson(Person)方法应该像setPerson(new Person(personId))那样使用

代码示例

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

/**
 * Set the person object to this obs object. This will also set the personId on this obs object
 * 
 * @see #setPersonId(Integer)
 * @param person the Patient/Person object that this obs is acting on
 */
public void setPerson(Person person) {
  markAsDirty(this.person, person);
  this.person = person;
  if (person != null) {
    setPersonId(person.getPersonId());
  }
}

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

private void updateImmutableFieldsAndAssert(Obs obs, boolean assertion) throws Exception {
  //Set all fields to some random values via reflection
  List<Field> fields = Reflect.getAllFields(Obs.class);
  final Integer originalPersonId = obs.getPersonId();
  //call each setter and check that dirty has been set to true for each
  for (Field field : fields) {
    String fieldName = field.getName();
    if (IGNORED_FIELDS.contains(fieldName)) {
      continue;
    }
    if ("personId".equals(fieldName)) {
      //call setPersonId because it is protected so BeanUtils.setProperty won't work
      obs.setPersonId((Integer) generateValue(field, true));
    } else {
      BeanUtils.setProperty(obs, fieldName, generateValue(field, true));
    }
    assertEquals("Obs was not marked as dirty after changing: " + fieldName, obs.isDirty(), assertion);
    if ("person".equals(fieldName)) {
      //Because setPerson updates the personId we need to reset personId to its original value 
      //that matches that of person otherwise the test will fail for the personId field
      obs.setPersonId(originalPersonId);
    }
    
    //reset for next field
    resetObs(obs);
  }
}

相关文章