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

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

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

Obs.getObsId介绍

暂无

代码示例

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

/**
 * @since 1.5
 * @see org.openmrs.OpenmrsObject#getId()
 */
@Override
public Integer getId() {
  return getObsId();
  
}

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

/**
 * @see org.openmrs.obs.ComplexObsHandler#purgeComplexData(org.openmrs.Obs)
 */
public boolean purgeComplexData(Obs obs) {
  File file = getComplexDataFile(obs);
  if (!file.exists()) {
    return true;
  } else if (file.delete()) {
    obs.setComplexData(null);
    return true;
  }
  
  log.warn(
    "Could not delete complex data object for obsId=" + obs.getObsId() + " located at " + file.getAbsolutePath());
  return false;
}

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

private void ensureRequirePrivilege(Obs obs){
  if (obs.getObsId() == null) {
    Context.requirePrivilege(PrivilegeConstants.ADD_OBS);
  } else {
    Context.requirePrivilege(PrivilegeConstants.EDIT_OBS);
  }
}

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

/**
 * @see org.openmrs.api.db.ObsDAO#saveObs(org.openmrs.Obs)
 */
@Override
public Obs saveObs(Obs obs) throws DAOException {
  if (obs.hasGroupMembers() && obs.getObsId() != null) {
    // hibernate has a problem updating child collections
    // if the parent object was already saved so we do it
    // explicitly here
    for (Obs member : obs.getGroupMembers()) {
      if (member.getObsId() == null) {
        saveObs(member);
      }
    }
  }
  
  sessionFactory.getCurrentSession().saveOrUpdate(obs);
  
  return obs;
}

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

/**
 * @see ObsService#getObservations(List,List,List,List,List,List,List,Integer,Integer,Date,Date,boolean)
 * @see ObsService#getObservations(List,List,List,List,List,List,List,Integer,Integer,Date,Date,boolean,String)
 */
@Test
public void getObservations_shouldSortReturnedObsByConceptIdIfSortIsConcept() {
  ObsService obsService = Context.getObsService();
  
  List<Obs> obss = obsService.getObservations(Collections.singletonList(new Person(7)), null, null, null, null, null,
    Arrays.asList("concept", "obsDatetime"), null, null, null, null, false, null);
  
  // check the order of a few of the obs returned
  Assert.assertEquals(11, obss.get(0).getObsId().intValue());
  Assert.assertEquals(9, obss.get(1).getObsId().intValue());
  Assert.assertEquals(16, obss.get(2).getObsId().intValue());
}

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

/**
 * @see ObsService#getObservationsByPersonAndConcept(Person,Concept)
 */
@Test
public void getObservationsByPersonAndConcept_shouldGetObservationsMatchingPersonAndQuestion() {
  ObsService obsService = Context.getObsService();
  
  List<Obs> obss = obsService.getObservationsByPersonAndConcept(new Person(7), new Concept(5089));
  
  Assert.assertEquals(3, obss.size());
  Assert.assertEquals(16, obss.get(0).getObsId().intValue());
  Assert.assertEquals(10, obss.get(1).getObsId().intValue());
  Assert.assertEquals(7, obss.get(2).getObsId().intValue());
}

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

/**
 * @see ObsService#getObservationsByPerson(Person)
 */
@Test
public void getObservationsByPerson_shouldGetAllObservationsAssignedToGivenPerson() {
  ObsService obsService = Context.getObsService();
  
  List<Obs> obss = obsService.getObservationsByPerson(new Person(7));
  
  Assert.assertEquals(9, obss.size());
  Assert.assertEquals(16, obss.get(0).getObsId().intValue());
  Assert.assertEquals(7, obss.get(8).getObsId().intValue());
}

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

/**
 * @see ObsService#getObservations(List,List,List,List,List,List,List,Integer,Integer,Date,Date,boolean)
 * @see ObsService#getObservations(List,List,List,List,List,List,List,Integer,Integer,Date,Date,boolean,String)
 */
@Test
public void getObservations_shouldSortReturnedObsByObsDatetimeIfSortIsEmpty() {
  executeDataSet(INITIAL_OBS_XML);
  
  ObsService obsService = Context.getObsService();
  
  List<Obs> obss = obsService.getObservations(Collections.singletonList(new Person(8)), null, null, null, null, null,
      new ArrayList<>(), null, null, null, null, false, null);
  
  Assert.assertEquals(8, obss.get(0).getObsId().intValue());
  Assert.assertEquals(7, obss.get(1).getObsId().intValue());
}

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

/**
 * @see ObsService#getObservations(String)
 */
@Test
public void getObservations_shouldGetObsMatchingPatientIdentifierInSearchString() {
  executeDataSet(INITIAL_OBS_XML);
  updateSearchIndex();
  
  ObsService obsService = Context.getObsService();
  
  List<Obs> obss = obsService.getObservations("12345K");
  
  Assert.assertEquals(2, obss.size());
  Assert.assertEquals(4, obss.get(0).getObsId().intValue());
  Assert.assertEquals(3, obss.get(1).getObsId().intValue());
}

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

/**
 * @see ObsService#getObservations(List,List,List,List,List,List,List,Integer,Integer,Date,Date,boolean)
 * @see ObsService#getObservations(List,List,List,List,List,List,List,Integer,Integer,Date,Date,boolean,String)
 */
@Test
public void getObservations_shouldIncludeVoidedObsIfIncludeVoidedObsIsTrue() {
  executeDataSet(INITIAL_OBS_XML);
  
  ObsService obsService = Context.getObsService();
  
  List<Obs> obss = obsService.getObservations(Collections.singletonList(new Person(9)), null, null, null, null, null,
    null, null, null, null, null, true, null);
  
  Assert.assertEquals(2, obss.size());
  
  Assert.assertEquals(10, obss.get(0).getObsId().intValue());
  Assert.assertEquals(9, obss.get(1).getObsId().intValue());
}

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

/**
 * @see ObsService#getObservations(String)
 */
@Test
public void getObservations_shouldGetObsMatchingEncounterIdInSearchString() {
  ObsService obsService = Context.getObsService();
  
  List<Obs> obss = obsService.getObservations("5");
  
  Assert.assertEquals(1, obss.size());
  Assert.assertEquals(16, obss.get(0).getObsId().intValue());
}

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

/**
 * @see ObsService#saveObs(Obs,String)
 */
@Test
public void saveObs_shouldReturnADifferentObjectWhenUpdatingAnObs() {
  ObsService obsService = Context.getObsService();
  
  Obs obs = obsService.getObs(7);
  
  // change something on the obs and save it again
  obs.setComment("A new comment");
  Obs obsSaved = obsService.saveObs(obs, "Testing that a new obs is returned");
  
  assertFalse(obsSaved.getObsId().equals(obs.getObsId()));
}

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

/**
 * @see ObsService#getObservations(String)
 */
@Test
public void getObservations_shouldGetObsMatchingObsIdInSearchString() {
  ObsService obsService = Context.getObsService();
  
  List<Obs> obss = obsService.getObservations("15");
  
  Assert.assertEquals(1, obss.size());
  Assert.assertEquals(15, obss.get(0).getObsId().intValue());
}

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

/**
 * @see org.openmrs.api.db.ObsDAO#getSavedStatus(org.openmrs.Obs)
 */
@Override
public Obs.Status getSavedStatus(Obs obs) {
  // avoid premature flushes when this internal method is called from inside a service method
  Session session = sessionFactory.getCurrentSession();
  FlushMode flushMode = session.getFlushMode();
  session.setFlushMode(FlushMode.MANUAL);
  try {
    SQLQuery sql = session.createSQLQuery("select status from obs where obs_id = :obsId");
    sql.setInteger("obsId", obs.getObsId());
    return Obs.Status.valueOf((String) sql.uniqueResult());
  }
  finally {
    session.setFlushMode(flushMode);
  }
}

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

/**
 * @see ObsService#getObservations(List,List,List,List,List,List,List,Integer,Integer,Date,Date,boolean)
 * @see ObsService#getObservations(List,List,List,List,List,List,List,Integer,Integer,Date,Date,boolean,String)
 */
@Test
public void getObservations_shouldNotIncludeVoidedObs() {
  executeDataSet(INITIAL_OBS_XML);
  
  ObsService obsService = Context.getObsService();
  
  List<Obs> obss = obsService.getObservations(Collections.singletonList(new Person(9)), null, null, null, null, null,
    null, null, null, null, null, false, null);
  
  Assert.assertEquals(1, obss.size());
  
  Assert.assertEquals(9, obss.get(0).getObsId().intValue());
}

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

/**
 * @see ObsService#getObservations(List,List,List,List,List,List,List,Integer,Integer,Date,Date,boolean)
 * @see ObsService#getObservations(List,List,List,List,List,List,List,Integer,Integer,Date,Date,boolean,String)
 */
@Test
public void getObservations_shouldGetAllObsWithAnswerConceptInGivenAnswersParameter() {
  executeDataSet(INITIAL_OBS_XML);
  
  ObsService obsService = Context.getObsService();
  
  List<Obs> obss = obsService.getObservations(null, null, null, Collections.singletonList(new Concept(7)), null, null,
    null, null, null, null, null, false, null);
  
  // obs 11 in INITIAL_OBS_XML and obs 13 in standardTestDataset
  Assert.assertEquals(3, obss.size());
  Set<Integer> ids = new HashSet<>();
  for (Obs o : obss) {
    ids.add(o.getObsId());
  }
  Assert.assertTrue(ids.contains(11));
  Assert.assertTrue(ids.contains(13));
}

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

private void voidExistingObs(Obs obs, String changeMessage, Obs newObs) {
  // void out the original observation to keep it around for
  // historical purposes
  try {
    Context.addProxyPrivilege(PrivilegeConstants.DELETE_OBS);
    // fetch a clean copy of this obs from the database so that
    // we don't write the changes to the database when we save
    // the fact that the obs is now voided
    evictObsAndChildren(obs);
    obs = Context.getObsService().getObs(obs.getObsId());
    //delete the previous file from the appdata/complex_obs folder
    if (newObs.hasPreviousVersion() && newObs.getPreviousVersion().isComplex()) {
      File previousFile = AbstractHandler.getComplexDataFile(obs);
      previousFile.delete();
    }
    // calling this via the service so that AOP hooks are called
    Context.getObsService().voidObs(obs, changeMessage);
  }
  finally {
    Context.removeProxyPrivilege(PrivilegeConstants.DELETE_OBS);
  }
}

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

@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

/**
 * @see ObsService#saveObs(Obs,String)
 */
@Test
public void saveObs_shouldCopyTheFormNamespaceAndPathFieldInEditedObs() {
  executeDataSet(INITIAL_OBS_XML);
  Obs obs = Context.getObsService().getObs(7);
  obs.setValueNumeric(5.0);
  Obs o2 = Context.getObsService().saveObs(obs, "just testing");
  Assert.assertNotNull(obs.getFormFieldNamespace());
  // fetch the obs from the database again
  obs = Context.getObsService().getObs(o2.getObsId());
  Assert.assertNotNull(obs.getFormFieldNamespace());
  Assert.assertNotNull(obs.getFormFieldPath());
}

相关文章