/** * @see org.openmrs.api.ConceptService#hasAnyObservation(org.openmrs.Concept) */ @Override @Transactional(readOnly = true) public boolean hasAnyObservation(Concept concept) { List<Concept> concepts = new ArrayList<>(); concepts.add(concept); Integer count = Context.getObsService().getObservationCount(null, null, concepts, null, null, null, null, null, null, true); return count > 0; }
/** * @see org.openmrs.api.ConceptService#hasAnyObservation(org.openmrs.ConceptName) */ @Override @Transactional(readOnly = true) public boolean hasAnyObservation(ConceptName conceptName) throws APIException { List<ConceptName> conceptNames = new ArrayList<>(); conceptNames.add(conceptName); Integer count = Context.getObsService().getObservationCount(conceptNames, true); return count > 0; }
/** * @see ObsService#getObservationCount(List, boolean) */ @Test public void getObservationCount_shouldReturnZeroIfNoObservationIsUsingAnyOfTheConcepNamesInTheList() { List<ConceptName> names = new LinkedList<>(); names.add(new ConceptName(1847)); names.add(new ConceptName(2453)); Assert.assertEquals(0, Context.getObsService().getObservationCount(names, true).intValue()); }
/** * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean) * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean,String) */ @Test public void getObservationCount_shouldReturnCountOfObsWhosePersonIsAPatientOnly() { executeDataSet(INITIAL_OBS_XML); ObsService obsService = Context.getObsService(); Integer count = obsService.getObservationCount(null, null, null, null, Collections.singletonList(PERSON_TYPE.PATIENT), null, null, null, null, false, null); Assert.assertEquals(15, count.intValue()); }
/** * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean) * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean,String) */ @Test public void getObservationCount_shouldReturnCountOfObsWhosePersonIsAUserOnly() { executeDataSet(INITIAL_OBS_XML); ObsService obsService = Context.getObsService(); Integer count = obsService.getObservationCount(null, null, null, null, Collections.singletonList(PERSON_TYPE.USER), null, null, null, null, false, null); Assert.assertEquals(1, count.intValue()); }
/** * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean) * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean,String) */ @Test public void getObservationCount_shouldReturnCountOfObsWithLocationInGivenLocationsParameter() { ObsService obsService = Context.getObsService(); Integer count = obsService.getObservationCount(null, null, null, null, null, Collections.singletonList(new Location(1)), null, null, null, false, null); Assert.assertEquals(8, count.intValue()); }
/** * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean) * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean,String) */ @Test public void getObservationCount_shouldGetCountOfObsAssignedToGivenEncounters() { ObsService obsService = Context.getObsService(); Integer count = obsService.getObservationCount(null, Collections.singletonList(new Encounter(4)), null, null, null, null, null, null, null, false, null); Assert.assertEquals(6, count.intValue()); }
/** * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean) * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean,String) */ @Test public void getObservationCount_shouldGetCountOfObsWithQuestionConceptInGivenQuestionsParameter() { ObsService obsService = Context.getObsService(); Integer count = obsService.getObservationCount(null, null, Collections.singletonList(new Concept(5497)), null, null, null, null, null, null, false, null); Assert.assertEquals(2, count.intValue()); }
/** * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean) * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean,String) */ @Test public void getObservationCount_shouldReturnCountOfAllObsWhosePersonIsAPersonOnly() { executeDataSet(INITIAL_OBS_XML); ObsService obsService = Context.getObsService(); Integer count = obsService.getObservationCount(null, null, null, null, Collections.singletonList(PERSON_TYPE.PERSON), null, null, null, null, false, null); Assert.assertEquals(17, count.intValue()); }
/** * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean) * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean,String) */ @Test public void getObservationCount_shouldGetCountOfObsWithAnswerConceptInGivenAnswersParameter() { executeDataSet(INITIAL_OBS_XML); ObsService obsService = Context.getObsService(); Integer count = obsService.getObservationCount(null, null, null, Collections.singletonList(new Concept(7)), null, null, null, null, null, false, null); Assert.assertEquals(3, count.intValue()); }
/** * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean,String) */ @Test public void getObservationCount_shouldReturnCountOfObsWithMatchingAccessionNumber() { executeDataSet(INITIAL_OBS_XML); ObsService obsService = Context.getObsService(); Integer count = obsService.getObservationCount(null, null, null, null, null, null, null, null, null, false, "AN1"); Assert.assertEquals(2, count.intValue()); }
/** * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean) * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean,String) */ @Test public void getObservationCount_shouldReturnCountOfObsWhoseGroupIdIsGivenObsGroupId() { executeDataSet(INITIAL_OBS_XML); ObsService obsService = Context.getObsService(); Integer count = obsService.getObservationCount(null, null, null, null, null, null, 2 /*obsGroupId*/, null, null, false, null); Assert.assertEquals(2, count.intValue()); }
/** * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean) * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean,String) */ @Test public void getObservationCount_shouldIncludeVoidedObsInTheCountIfIncludeVoidedObsIsTrue() { executeDataSet(INITIAL_OBS_XML); ObsService obsService = Context.getObsService(); Integer obss = obsService.getObservationCount(Collections.singletonList(new Person(9)), null, null, null, null, null, null, null, null, true, null); Assert.assertEquals(2, obss.intValue()); }
/** * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean) * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean,String) */ @Test public void getObservationCount_shouldNotIncludeVoidedObsInCount() { executeDataSet(INITIAL_OBS_XML); ObsService obsService = Context.getObsService(); Integer obss = obsService.getObservationCount(Collections.singletonList(new Person(9)), null, null, null, null, null, null, null, null, false, null); Assert.assertEquals(1, obss.intValue()); }
names.add(cn1); names.add(cn2); Assert.assertEquals(2, os.getObservationCount(names, true).intValue());
names.add(cn1); names.add(cn2); Assert.assertEquals(2, os.getObservationCount(names, true).intValue());
@Override public long getAllCount() { return Context.getObsService().getObservationCount(null, true); }