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

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

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

Obs.isObsGrouping介绍

[英]Convenience method that checks for if this obs has 1 or more group members (either voided or non-voided) Note this method differs from hasGroupMembers(), as that method excludes voided obs; logic is that while a obs that has only voided group members should be seen as "having no group members" it still should be considered an "obs grouping"

NOTE: This method could also be called "isObsGroup" for a little less confusion on names. However, jstl in a web layer (or any psuedo-getter) access isn't good with both an "isObsGroup" method and a "getObsGroup" method. Which one should be returned with a simplified jstl call like ${obs.obsGroup} ? With this setup, ${obs.obsGrouping} returns a boolean of whether this obs is a parent and has members. ${obs.obsGroup} returns the parent object to this obs if this obs is a group member of some other group.
[中]检查此obs是否有1个或多个组成员(已作废或未作废)的便利方法注意此方法不同于hasGroupMembers(),因为该方法不包括已作废的obs;逻辑是,虽然只有无效组成员的obs应被视为“没有组成员”,但仍应被视为“obs分组”
注:该方法也可以称为“isObsGroup”,以减少名称上的混淆。然而,web层(或任何psuedo getter)访问中的jstl对于“isObsGroup”方法和“getObsGroup”方法都不好。哪一个应该用简化的jstl调用返回,比如${obs.obsGroup}?在这个设置中,${obs.obsgroubing}返回一个布尔值,表示这个obs是否是父对象,是否有成员${obs.obsGroup}如果此obs是其他组的组成员,则将父对象返回给此obs。

代码示例

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

private void saveObsGroup(Obs obs, String changeMessage){
  if (obs.isObsGrouping()) {
    for (Obs o : obs.getGroupMembers(true)) {
      Context.getObsService().saveObs(o, changeMessage);
    }
  }
}

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

/**
 * Convenience method to recursively get all leaf obs of this encounter. This method goes down
 * into each obs and adds all non-grouping obs to the return list
 *
 * @param obsParent current obs to loop over
 * @return list of leaf obs
 */
private List<Obs> getObsLeaves(Obs obsParent) {
  List<Obs> leaves = new ArrayList<>();
  
  if (obsParent.hasGroupMembers()) {
    for (Obs child : obsParent.getGroupMembers()) {
      if (!child.getVoided()) {
        if (!child.isObsGrouping()) {
          leaves.add(child);
        } else {
          // recurse if this is a grouping obs
          leaves.addAll(getObsLeaves(child));
        }
      }
    }
  } else if (!obsParent.getVoided()) {
    leaves.add(obsParent);
  }
  
  return leaves;
}

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

if (this.isObsGrouping()) {
  ret.addAll(this.getGroupMembers());
  Obs parentObs = this;
  while (parentObs.getObsGroup() != null) {
    for (Obs obsSibling : parentObs.getObsGroup().getGroupMembers()) {
      if (!obsSibling.isObsGrouping()) {
        ret.add(obsSibling);
    if (!obsSibling.isObsGrouping()) {
      ret.add(obsSibling);

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

private Obs saveObsNotDirty(Obs obs, String changeMessage) {
  if(!obs.isObsGrouping()){
    return obs;
  }
  ObsService os = Context.getObsService();
  boolean refreshNeeded = false;
  for (Obs o : obs.getGroupMembers(true)) {
    if (o.getId() == null) {
      os.saveObs(o, null);
    } else {
      Obs newObs = os.saveObs(o, changeMessage);
      refreshNeeded = !newObs.equals(o) || refreshNeeded;
    }
  }
  if(refreshNeeded) {
    Context.refreshEntity(obs);
  }
  return obs;
}

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

/**
 * @see Obs#isObsGrouping()
 */
@Test
public void isObsGrouping_shouldIncludeVoidedObs() throws Exception {
  Obs parent = new Obs(5);
  Obs child = new Obs(33);
  child.setVoided(true);
  parent.addGroupMember(child);
  assertTrue("When checking for Obs grouping, should include voided Obs", parent.isObsGrouping());
}

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

/**
 * @see Encounter#getObs()
 */
@Test
public void getObs_shouldOnlyGetChildObs() {
  Encounter encounter = new Encounter();
  
  //create and add an Obs
  Obs parentObs = new Obs();
  encounter.addObs(parentObs);
  
  //add a child to the obs and make sure that the Obs is an ObsGroup with one child:
  Obs childObs = new Obs();
  parentObs.addGroupMember(childObs);
  
  //obsGroup should recurse and ONLY the child obs should be picked up:
  assertEquals(1, encounter.getObs().size());
  // make sure that the obs is the oChild
  Obs obsInEncounter = (Obs) encounter.getObs().toArray()[0];
  assertTrue(childObs.equals(obsInEncounter));
  assertFalse(obsInEncounter.isObsGrouping());
}

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

/**
 * @see Encounter#getObs()
 */
@Test
public void getObs_shouldNotGetChildObsIfChildAlsoOnEncounter() {
  Encounter encounter = new Encounter();
  
  //create and add an Obs
  Obs parentObs = new Obs();
  encounter.addObs(parentObs);
  
  //add a child to the obs and make sure that now that the Obs is an ObsGroup with one child:
  Obs childObs = new Obs();
  parentObs.addGroupMember(childObs);
  
  // add the child obs directly to the encounter as well
  childObs.setEncounter(encounter);
  encounter.addObs(childObs);
  
  // do the check
  assertEquals(1, encounter.getObs().size());
  Obs obsInEncounter = (Obs) encounter.getObs().toArray()[0];
  assertFalse(obsInEncounter.isObsGrouping());
}

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

/**
 * @see Encounter#getObsAtTopLevel(null)
 */
@Test
public void getObsAtTopLevel_shouldOnlyReturnTheGroupedTopLevelObs() {
  Encounter encounter = new Encounter();
  
  //create and add an Obs
  Obs parentObs = new Obs();
  encounter.addObs(parentObs);
  
  //add a child to the obs and make sure that now that the Obs is an ObsGroup with one child:
  Obs childObs = new Obs();
  parentObs.addGroupMember(childObs);
  
  // add the child obs directly to the encounter as well
  childObs.setEncounter(encounter);
  encounter.addObs(childObs);
  
  // do the check
  assertEquals(1, encounter.getObsAtTopLevel(false).size());
  Obs obsInEncounter = (Obs) encounter.getObsAtTopLevel(false).toArray()[0];
  assertTrue(obsInEncounter.isObsGrouping());
}

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

/**
 * @see Encounter#getAllObs(null)
 */
@Test
public void getAllObs_shouldGetBothParentAndChildObs() {
  Encounter encounter = new Encounter();
  
  //create and add an Obs
  Obs parentObs = new Obs();
  encounter.addObs(parentObs);
  
  //add a child to the obs and make sure that the Obs is an ObsGroup with one child:
  Obs childObs = new Obs();
  parentObs.addGroupMember(childObs);
  
  //assert that the parent obs is returned 
  assertNotNull(encounter.getAllObs(true));
  assertEquals(1, encounter.getAllObs(true).size());
  assertNotNull(encounter.getAllObs(false));
  assertEquals(1, encounter.getAllObs(false).size());
  Obs obsInEncounter = (Obs) encounter.getAllObs(false).toArray()[0];
  assertTrue(obsInEncounter.isObsGrouping());
}

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

/**
 * @see Encounter#getObsAtTopLevel(null)
 */
@Test
public void getObsAtTopLevel_shouldOnlyGetParentsObs() {
  Encounter encounter = new Encounter();
  
  //create and add an Obs
  Obs parentObs = new Obs();
  encounter.addObs(parentObs);
  
  //add a child to the obs and make sure that the Obs is an ObsGroup with one child:
  Obs childObs = new Obs();
  parentObs.addGroupMember(childObs);
  
  //assert that the parent obs is returned by getObsAtTopLevel()
  assertNotNull(encounter.getObsAtTopLevel(true));
  assertEquals(1, encounter.getObsAtTopLevel(true).size());
  assertNotNull(encounter.getObsAtTopLevel(false));
  assertEquals(1, encounter.getObsAtTopLevel(false).size());
  
  // make sure that the obs is the parent obs
  Obs obsInEncounter = (Obs) encounter.getObsAtTopLevel(false).toArray()[0];
  assertTrue(obsInEncounter.isObsGrouping());
}

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

while (newObservation == null && thisIndex < newList.size()) {
  Obs newObs = newList.get(thisIndex++);
  if (!oldList.contains(newObs) && !newObs.isObsGrouping() && newObs.getComment() != null)
    newObservation = newObs;

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

/**
 * @see ORUR01Handler#parseObs(Encounter,OBX,OBR,String)
 */
@Test
public void parseObs_shouldAddCommentsToAnObservationGroup() 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|||23^FOOD CONSTRUCT^99DCT\r"
      + "NTE|1|L|This is a comment\r"
      + "OBX|1|NM|5497^CD4, BY FACS^99DCT||1|||||||||20080206\r"
      + "NTE|1|L|This should not be considered :-)";
  List<Obs> oldList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(23));
  Message hl7message = parser.parse(hl7string);
  router.processMessage(hl7message);
  List<Obs> newList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(23));
  Obs newObservation = null;
  for (Obs newObs : newList) {
    if (!oldList.contains(newObs) && newObs.isObsGrouping()) {
      newObservation = newObs;
    }
  }
  Assert.assertEquals("This is a comment", newObservation.getComment());
}

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

assertFalse(oTmp.isObsGrouping());

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

/**
 * @see ORUR01Handler#processMessage(Message)
 */
@Test
public void processMessage_shouldSetValue_NumericForObsIfQuestionDatatypeIsNumeric() 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|1|NM|5497^CD4, BY FACS^99DCT||450|||||||||20080206";
  // the expected question for the obs in the hl7 message has to be
  // numeric
  Assert.assertEquals("Numeric", Context.getConceptService().getConcept(5497).getDatatype().getName());
  List<Obs> oldList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(5497));
  Message hl7message = parser.parse(hl7string);
  router.processMessage(hl7message);
  List<Obs> newList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(5497));
  Obs newObservation = null;
  for (Obs newObs : newList) {
    if (!oldList.contains(newObs) && !newObs.isObsGrouping()) {
      newObservation = newObs;
    }
  }
  Assert.assertEquals(450, newObservation.getValueNumeric().intValue());
}

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

/**
 * @see ORUR01Handler#processMessage(Message)
 */
@Test
public void processMessage_shouldSetValue_NumericForObsIfQuestionDatatypeIsNumericAndTheAnswerIsEither0Or1()
    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|1|NM|5497^CD4, BY FACS^99DCT||1|||||||||20080206";
  // the expected question for the obs in the hl7 message has to be
  // numeric
  Assert.assertEquals("Numeric", Context.getConceptService().getConcept(5497).getDatatype().getName());
  List<Obs> oldList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(5497));
  Message hl7message = parser.parse(hl7string);
  router.processMessage(hl7message);
  List<Obs> newList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(5497));
  Obs newObservation = null;
  for (Obs newObs : newList) {
    if (!oldList.contains(newObs) && !newObs.isObsGrouping()) {
      newObservation = newObs;
    }
  }
  Assert.assertEquals(1, newObservation.getValueNumeric().intValue());
}

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

int numberofParentObs = 0;
for (Obs oTmp : enc.getAllObs(false)) {
  if (oTmp.isObsGrouping())
    numberofParentObs++;
  else

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

/**
 * @see ORUR01Handler#parseObs(Encounter,OBX,OBR,String)
 */
@Test
public void parseObs_shouldAddCommentsToAnObservationFromNTESegments() 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|1|NM|5497^CD4, BY FACS^99DCT||1|||||||||20080206\r" + "NTE|1|L|This is a comment";
  // the expected question for the obs in the hl7 message has to be
  // numeric
  Assert.assertEquals("Numeric", Context.getConceptService().getConcept(5497).getDatatype().getName());
  List<Obs> oldList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(5497));
  Message hl7message = parser.parse(hl7string);
  router.processMessage(hl7message);
  List<Obs> newList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(5497));
  Obs newObservation = null;
  for (Obs newObs : newList) {
    if (!oldList.contains(newObs) && !newObs.isObsGrouping()) {
      newObservation = newObs;
    }
  }
  Assert.assertEquals("This is a comment", newObservation.getComment());
}

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

assertFalse(obsGroup.isObsGrouping());
assertFalse(obsGroup.hasGroupMembers(false));
assertFalse(obsGroup.hasGroupMembers(true)); // Check both flags for false

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

Obs newObservation = null;
for (Obs newObs : newList) {
  if (!oldList.contains(newObs) && !newObs.isObsGrouping()) {
    newObservation = newObs;

相关文章