use of de.symeda.sormas.api.caze.CaseCriteria in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testCaseExportWithPrescriptionsTreatmentsVisits.
@Test
public void testCaseExportWithPrescriptionsTreatmentsVisits() {
RDCFEntities rdcfEntities = creator.createRDCFEntities("Region", "District", "Community", "Facility");
UserDto user = getUser(rdcfEntities);
PersonDto cazePerson = creator.createPerson("Case", "Person");
CaseDataDto caze = getCaze(user, cazePerson, rdcfEntities);
cazePerson.getAddress().setCity("City");
getPersonFacade().savePerson(cazePerson);
ExposureDto exposure = ExposureDto.build(ExposureType.TRAVEL);
exposure.getLocation().setDetails("Ghana");
exposure.setStartDate(new Date());
exposure.setEndDate(new Date());
caze.getEpiData().getExposures().add(exposure);
caze.getSymptoms().setAbdominalPain(SymptomState.YES);
caze = getCaseFacade().save(caze);
creator.createPrescription(caze);
creator.createTreatment(caze);
creator.createTreatment(caze);
creator.createClinicalVisit(caze);
getPersonFacade().savePerson(cazePerson);
List<CaseExportDto> results = getCaseFacade().getExportList(new CaseCriteria(), Collections.emptySet(), CaseExportType.CASE_MANAGEMENT, 0, 100, null, Language.EN);
assertEquals(1, results.size());
CaseExportDto exportDto = results.get(0);
assertNotNull(exportDto.getSymptoms());
assertEquals(1, exportDto.getNumberOfPrescriptions());
assertEquals(2, exportDto.getNumberOfTreatments());
assertEquals(1, exportDto.getNumberOfClinicalVisits());
}
use of de.symeda.sormas.api.caze.CaseCriteria in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testFilterByResponsibleRegionAndDistrictOfCase.
@Test
public void testFilterByResponsibleRegionAndDistrictOfCase() {
RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility");
RDCFEntities rdcf2 = creator.createRDCFEntities("Region2", "District2", "Community2", "Facility2");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
PersonDto cazePerson = creator.createPerson("Case", "Person", Sex.MALE, 1980, 1, 1);
CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
SampleDto caseSample = creator.createSample(caze.toReference(), user.toReference(), rdcf.facility);
ContactDto contact = creator.createContact(user.toReference(), null, creator.createPerson("John", "Smith").toReference(), caze, new Date(), new Date(), Disease.CORONAVIRUS, null);
SampleDto contactSample = creator.createSample(contact.toReference(), new Date(), new Date(), user.toReference(), SampleMaterial.BLOOD, rdcf.facility);
ContactDto otherContact = creator.createContact(user.toReference(), creator.createPerson("John", "Doe").toReference(), new Date());
SampleDto otherContactSample = creator.createSample(otherContact.toReference(), new Date(), new Date(), user.toReference(), SampleMaterial.BLOOD, rdcf.facility);
otherContact.setResultingCase(caze.toReference());
getContactFacade().save(otherContact);
caze.setRegion(new RegionReferenceDto(rdcf2.region.getUuid(), null, null));
caze.setDistrict(new DistrictReferenceDto(rdcf2.district.getUuid(), null, null));
caze.setCommunity(new CommunityReferenceDto(rdcf2.community.getUuid(), null, null));
caze.setHealthFacility(new FacilityReferenceDto(rdcf2.facility.getUuid(), null, null));
getCaseFacade().save(caze);
final CaseCriteria caseCriteria = new CaseCriteria().region(new RegionReferenceDto(rdcf.region.getUuid(), null, null)).district(new DistrictReferenceDto(rdcf.district.getUuid(), null, null));
Assert.assertEquals(1, getCaseFacade().getIndexList(caseCriteria, 0, 100, null).size());
Assert.assertEquals(3, getSampleFacade().getIndexList(new SampleCriteria(), 0, 100, null).size());
final SampleCriteria sampleCriteria = new SampleCriteria().region(new RegionReferenceDto(rdcf.region.getUuid(), null, null)).district(new DistrictReferenceDto(rdcf.district.getUuid(), null, null));
Assert.assertEquals(2, getSampleFacade().getIndexList(sampleCriteria, 0, 100, null).size());
Assert.assertEquals(1, getTaskFacade().getIndexList(new TaskCriteria(), 0, 100, null).size());
final TaskCriteria taskCriteria = new TaskCriteria().region(new RegionReferenceDto(rdcf.region.getUuid(), null, null)).district(new DistrictReferenceDto(rdcf.district.getUuid(), null, null));
Assert.assertEquals(1, getTaskFacade().getIndexList(taskCriteria, 0, 100, null).size());
Assert.assertEquals(2, getContactFacade().getIndexList(new ContactCriteria(), 0, 100, null).size());
final ContactCriteria contactCriteriaRdcf2 = new ContactCriteria().region(new RegionReferenceDto(rdcf2.region.getUuid(), null, null)).district(new DistrictReferenceDto(rdcf2.district.getUuid(), null, null)).community(new CommunityReferenceDto(rdcf2.community.getUuid(), null, null));
Assert.assertEquals(1, getContactFacade().getIndexList(contactCriteriaRdcf2, 0, 100, null).size());
final ContactCriteria contactCriteriaRdcf1 = new ContactCriteria().region(new RegionReferenceDto(rdcf.region.getUuid(), null, null)).district(new DistrictReferenceDto(rdcf.district.getUuid(), null, null));
Assert.assertEquals(1, getContactFacade().getIndexList(contactCriteriaRdcf1, 0, 100, null).size());
}
use of de.symeda.sormas.api.caze.CaseCriteria in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testSearchCasesWithReducedQuarantine.
@Test
public void testSearchCasesWithReducedQuarantine() {
RDCF rdcf = creator.createRDCF();
CaseDataDto caze = creator.createCase(creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER).toReference(), creator.createPerson().toReference(), rdcf);
caze.setQuarantineReduced(true);
getCaseFacade().save(caze);
List<CaseIndexDto> indexList = getCaseFacade().getIndexList(new CaseCriteria(), 0, 100, Collections.emptyList());
assertThat(indexList.get(0).getUuid(), is(caze.getUuid()));
CaseCriteria caseCriteria = new CaseCriteria();
caseCriteria.setWithReducedQuarantine(true);
List<CaseIndexDto> indexListFiltered = getCaseFacade().getIndexList(caseCriteria, 0, 100, Collections.emptyList());
assertThat(indexListFiltered.get(0).getUuid(), is(caze.getUuid()));
}
use of de.symeda.sormas.api.caze.CaseCriteria in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testGetDuplicateCasesOfSameSexAndDifferentBirthDateIsEmpty.
@Test
public void testGetDuplicateCasesOfSameSexAndDifferentBirthDateIsEmpty() {
final Date today = new Date();
RDCFEntities rdcf = creator.createRDCFEntities("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", Sex.MALE, 1980, 1, 1);
creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, today, rdcf);
PersonDto cazePerson2 = creator.createPerson("Case", "Person", Sex.MALE, 1980, 1, 2);
creator.createCase(user.toReference(), cazePerson2.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, DateUtils.addMinutes(today, -3), rdcf);
Assert.assertEquals(0, getCaseFacade().getCasesForDuplicateMerging(new CaseCriteria().creationDateFrom(today).creationDateTo(today), true).size());
}
use of de.symeda.sormas.api.caze.CaseCriteria in project SORMAS-Project by hzi-braunschweig.
the class CaseFacadeEjbTest method testGetIndexListByFreeText.
@Test
public void testGetIndexListByFreeText() {
String districtName = "District";
RDCF rdcf = creator.createRDCF("Region", districtName, "Community", "Facility");
useSurveillanceOfficerLogin(rdcf);
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
PersonDto person1 = creator.createPerson("FirstName1", "LastName1", p -> {
p.getAddress().setPostalCode("10115");
p.getAddress().setCity("Berlin");
p.setPhone("+4930-90-1820");
});
creator.createCase(user.toReference(), person1.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
PersonDto person2 = creator.createPerson("FirstName2", "LastName2", p -> {
p.getAddress().setPostalCode("20095");
p.getAddress().setCity("Hamburg");
p.setPhone("+49-30-901822");
});
creator.createCase(user.toReference(), person2.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
PersonDto person3 = creator.createPerson("FirstName3", "Last Name3", p -> {
p.getAddress().setPostalCode("80331");
p.getAddress().setCity("Munich");
p.setPhone("+49 31 9018 20");
});
creator.createCase(user.toReference(), person3.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
Assert.assertEquals(3, getCaseFacade().getIndexList(null, 0, 100, null).size());
Assert.assertEquals(1, getCaseFacade().getIndexList(new CaseCriteria().personLike("Munich"), 0, 100, null).size());
Assert.assertEquals(1, getCaseFacade().getIndexList(new CaseCriteria().personLike("Last Name3"), 0, 100, null).size());
Assert.assertEquals(1, getCaseFacade().getIndexList(new CaseCriteria().personLike("20095"), 0, 100, null).size());
Assert.assertEquals(2, getCaseFacade().getIndexList(new CaseCriteria().personLike("+49-31-901-820"), 0, 100, null).size());
Assert.assertEquals(1, getCaseFacade().getIndexList(new CaseCriteria().personLike("4930901822"), 0, 100, null).size());
}
Aggregations