本文整理了Java中org.openmrs.Obs.addGroupMember()
方法的一些代码示例,展示了Obs.addGroupMember()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Obs.addGroupMember()
方法的具体详情如下:
包路径:org.openmrs.Obs
类名称:Obs
方法名:addGroupMember
[英]Convenience method to add the given obs
to this grouping. Will implicitly make this obs an ObsGroup.
[中]将给定obs
添加到此分组的便捷方法。将隐式地使此obs成为obs组。
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#addGroupMember(Obs)
*/
@Test
public void addGroupMember_shouldReturnFalseWhenADuplicateObsIsAddedAsAMemberToNewObs() throws Exception {
Obs obs = new Obs();
Obs member = new Obs();
obs.addGroupMember(member);
assertFalse(obs.isDirty());
resetObs(obs);
obs.addGroupMember(member);
assertFalse(obs.isDirty());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#addGroupMember(Obs)
*/
@Test
public void addGroupMember_shouldReturnFalseWhenADuplicateObsIsAddedAsAMember() throws Exception {
Obs obs = new Obs(2);
Obs member = new Obs();
obs.addGroupMember(member);
assertFalse(obs.isDirty());
resetObs(obs);
obs.addGroupMember(member);
assertFalse(obs.isDirty());
}
代码示例来源:origin: openmrs/openmrs-core
parentObs.addGroupMember(childObs);
Obs greatGrandChildObsOne = new Obs();
Obs greatGrandChildObsTwo = new Obs();
childObs.addGroupMember(grandChildObsOne);
childObs.addGroupMember(grandChildObsTwo);
grandChildObsOne.addGroupMember(greatGrandChildObsOne);
grandChildObsOne.addGroupMember(greatGrandChildObsTwo);
greatGrandChildObsTwo.addGroupMember(greatGreatGrandChildObsOne);
greatGrandChildObsTwo.addGroupMember(greatGreatGrandChildObsTwo);
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#addGroupMember(Obs)
*/
@Test
public void addGroupMember_shouldReturnFalseWhenANewObsIsAddedAsAMember() throws Exception {
Obs obs = new Obs(2);
Obs member1 = new Obs();
obs.addGroupMember(member1);
assertFalse(obs.isDirty());
resetObs(obs);
Obs member2 = new Obs();
obs.addGroupMember(member2);
assertFalse(obs.isDirty());
}
代码示例来源: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_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#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#getAllObs(null)
*/
@Test
public void getAllObs_shouldGetBothChildAndParentObsAfterRemovingChildFromParentGrouping() {
Encounter enc = new Encounter();
//create and add an Obs
Obs parentObs = new Obs();
enc.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(enc);
enc.addObs(childObs);
//remove the obsGrouping, so that both obs are now just children of the Encounter
parentObs.removeGroupMember(childObs);
assertEquals(2, enc.getAllObs(true).size());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Encounter#getObsAtTopLevel(null)
*/
@Test
public void getObsAtTopLevel_shouldGetBothChildAndParentObsAfterRemovingChildFromParentGrouping() {
Encounter enc = new Encounter();
//create and add an Obs
Obs parentObs = new Obs();
enc.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(enc);
enc.addObs(childObs);
//remove the obsGrouping, so that both obs are now just children of the Encounter
parentObs.removeGroupMember(childObs);
assertEquals(2, enc.getObsAtTopLevel(false).size());
}
代码示例来源: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#getObs()
*/
@Test
public void getObs_shouldGetBothChildAndParentObsAfterRemovingChildFromParentGrouping() {
Encounter enc = new Encounter();
//create and add an Obs
Obs parentObs = new Obs();
enc.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(enc);
enc.addObs(childObs);
//remove the obsGrouping, so that both obs are now just children of the Encounter
parentObs.removeGroupMember(childObs);
// do the check
assertEquals(2, enc.getObs().size());
}
代码示例来源: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
/**
* @see Obs#removeGroupMember(Obs)
*/
@Test
public void removeGroupMember_shouldReturnDirtyFalseWhenAnObsIsRemoved() throws Exception {
Obs obs = new Obs(2);
Obs member = new Obs();
obs.addGroupMember(member);
assertFalse(obs.isDirty());
resetObs(obs);
obs.removeGroupMember(member);
assertFalse(obs.isDirty());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#removeGroupMember(Obs)
*/
@Test
public void removeGroupMember_shouldReturnFalseForDirtyFlagWhenAnObsIsRemovedFromGroup() throws Exception {
Obs obs = new Obs();
Obs member = new Obs();
obs.addGroupMember(member);
assertFalse(obs.isDirty());
resetObs(obs);
obs.removeGroupMember(member);
assertFalse(obs.isDirty());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#hasGroupMembers(boolean)
*/
@Test
public void hasGroupMembers_shouldReturnTrueIfThisObsHasGroupMembersBasedOnParameter() throws Exception {
Obs parent = new Obs(5);
Obs child = new Obs(33);
child.setVoided(true);
parent.addGroupMember(child); // Only contains 1 voided child
assertTrue("When checking for all members, should return true", parent.hasGroupMembers(true));
assertFalse("When checking for non-voided, should return false", parent.hasGroupMembers(false));
assertFalse("Default should check for non-voided", parent.hasGroupMembers());
}
代码示例来源:origin: openmrs/openmrs-core
groupMember.setLocation(new Location(2));
groupMember.setValueNumeric(50d);
origParentObs.addGroupMember(groupMember);
assertNotNull(groupMember.getObsGroup());
代码示例来源:origin: openmrs/openmrs-core
parentObs.addGroupMember(childObs);
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsValidator#validate(Object, Errors)
*/
@Test
public void validate_shouldNotValidateAVoidedChildObs() {
Obs obs = new Obs();
obs.setPerson(Context.getPersonService().getPerson(2));
obs.setConcept(Context.getConceptService().getConcept(5089));
obs.setObsDatetime(new Date());
Obs validChild = new Obs();
validChild.setPerson(Context.getPersonService().getPerson(2));
validChild.setConcept(Context.getConceptService().getConcept(5089));
validChild.setObsDatetime(new Date());
validChild.setValueNumeric(80.0);
obs.addGroupMember(validChild);
Obs inValidChild = new Obs();
obs.addGroupMember(inValidChild);
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertTrue(errors.hasErrors());
inValidChild.setVoided(true);
errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertFalse(errors.hasErrors());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsService#saveObs(Obs,String)
*/
@Test
public void saveObs_shouldCascadeSaveToChildObsGroups() {
ObsService obsService = Context.getObsService();
Obs parentObs = new Obs();
parentObs.setConcept(Context.getConceptService().getConcept(3));
parentObs.setObsDatetime(new Date());
parentObs.setPerson(new Patient(2));
parentObs.setLocation(new Location(1));
Obs groupMember = new Obs();
groupMember.setConcept(Context.getConceptService().getConcept(3));
groupMember.setValueNumeric(1.0);
groupMember.setObsDatetime(new Date());
groupMember.setPerson(new Patient(2));
groupMember.setLocation(new Location(1));
parentObs.addGroupMember(groupMember);
obsService.saveObs(parentObs, null);
// make sure the child obs was saved
Assert.assertNotNull(groupMember.getObsId());
}
内容来源于网络,如有侵权,请联系作者删除!