use of de.symeda.sormas.api.IntegerRange in project SORMAS-Project by hzi-braunschweig.
the class CaseStatisticsFacadeEjbTest method testQueryCaseCount.
@Test
public void testQueryCaseCount() {
RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
PersonDto cazePerson = creator.createPerson("Case", "Person");
cazePerson.setApproximateAge(30);
cazePerson.setApproximateAgeReferenceDate(new Date());
cazePerson.setApproximateAgeType(ApproximateAgeType.YEARS);
cazePerson = getPersonFacade().savePerson(cazePerson);
CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
caze.setOutcomeDate(DateHelper.addWeeks(caze.getReportDate(), 2));
caze = getCaseFacade().save(caze);
StatisticsCaseCriteria criteria = new StatisticsCaseCriteria();
int year = DateHelper8.toLocalDate(caze.getSymptoms().getOnsetDate()).getYear();
criteria.years(Arrays.asList(new Year(year), new Year(year + 1)), StatisticsCaseAttribute.ONSET_TIME);
criteria.regions(Arrays.asList(new RegionReferenceDto(rdcf.region.getUuid(), null, null)));
criteria.addAgeIntervals(Arrays.asList(new IntegerRange(10, 40)));
List<StatisticsCaseCountDto> results = getCaseStatisticsFacade().queryCaseCount(criteria, null, null, null, null, false, false, null);
// List should have one entry
assertEquals(1, results.size());
// try all groupings
for (StatisticsCaseAttribute groupingAttribute : StatisticsCaseAttribute.values()) {
StatisticsCaseSubAttribute[] subAttributes = groupingAttribute.getSubAttributes();
if (subAttributes.length == 0) {
getCaseStatisticsFacade().queryCaseCount(criteria, groupingAttribute, null, null, null, false, false, null);
} else {
for (StatisticsCaseSubAttribute subGroupingAttribute : groupingAttribute.getSubAttributes()) {
if (subGroupingAttribute.isUsedForGrouping()) {
getCaseStatisticsFacade().queryCaseCount(criteria, groupingAttribute, subGroupingAttribute, null, null, false, false, null);
}
}
}
}
}
Aggregations