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

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

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

Obs.setEncounter介绍

暂无

代码示例

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

o.setEncounter(this);

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

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));
o2.setConcept(Context.getConceptService().getConcept(3));
o2.setPerson(new Patient(2));
o2.setEncounter(new Encounter(3));
o2.setObsDatetime(new Date());
o2.setLocation(new Location(1));

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

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));
o2.setConcept(Context.getConceptService().getConcept(3));
o2.setPerson(new Patient(2));
o2.setEncounter(new Encounter(3));
o2.setObsDatetime(new Date());
o2.setLocation(new Location(1));

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

childObs.setEncounter(enc);
enc.addObs(childObs);

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

childObs.setEncounter(enc);
enc.addObs(childObs);

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

childObs.setEncounter(enc);
enc.addObs(childObs);

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

/**
 * @see PatientService#mergePatients(Patient,Patient)
 */
@Test
public void mergePatients_shouldAuditMovedIndependentObservations() throws Exception {
  //retrieve patients
  Patient preferred = patientService.getPatient(999);
  Patient notPreferred = patientService.getPatient(7);
  voidOrders(Collections.singleton(notPreferred));
  
  //get an observation for notPreferred and make it independent from any encounter
  Obs obs = Context.getObsService().getObs(7);
  obs.setEncounter(null);
  obs.setComment("this observation is for testing the merge");
  Context.getObsService().saveObs(obs, "Reason cannot be blank");
  
  //merge the two patients and retrieve the audit object
  PersonMergeLog audit = mergeAndRetrieveAudit(preferred, notPreferred);
  String uuid = null;
  List<Obs> observations = Context.getObsService().getObservationsByPerson(preferred);
  for (Obs o : observations) {
    if (obs.getComment().equals(o.getComment())) {
      uuid = o.getUuid();
    }
  }
  Assert.assertTrue("moving of independent observation was not audited",
    isValueInList(uuid, audit.getPersonMergeLogData().getMovedIndependentObservations()));
}

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

childObs.setEncounter(enc);
enc.addObs(childObs);

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

/**
 * @see ConceptService#purgeConcept(Concept)
 */
@Test(expected = ConceptNameInUseException.class)
public void purgeConcept_shouldFailIfAnyOfTheConceptNamesOfTheConceptIsBeingUsedByAnObs() {
  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));
  ConceptName conceptName = new ConceptName(1847);
  o.setValueCodedName(conceptName);
  Context.getObsService().saveObs(o, null);
  //ensure that the association between the conceptName and the obs has been established
  Assert.assertEquals(true, conceptService.hasAnyObservation(conceptName));
  
  Concept concept = conceptService.getConceptByName("cd4 count");
  //make sure the name concept name exists
  Assert.assertNotNull(concept);
  conceptService.purgeConcept(concept);
}

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

obsCopy.setEncounter(target);
obsCopy.setPerson(patient);
target.addObs(obsCopy);

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

obs.setConcept(concept);
obs.setPerson(patient);
obs.setEncounter(encounter);
obs.setObsDatetime(datetime);
obs.setLocation(location);

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

newObs.setValueText(obsToCopy.getValueText());
newObs.setComment(obsToCopy.getComment());
newObs.setEncounter(obsToCopy.getEncounter());
newObs.setCreator(obsToCopy.getCreator());
newObs.setDateCreated(obsToCopy.getDateCreated());

相关文章

微信公众号

最新文章

更多