Search in sources :

Example 16 with CaseCriteria

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());
}
Also used : RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) CaseExportDto(de.symeda.sormas.api.caze.CaseExportDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) ExposureDto(de.symeda.sormas.api.exposure.ExposureDto) CasePersonDto(de.symeda.sormas.api.caze.CasePersonDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 17 with CaseCriteria

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());
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) CasePersonDto(de.symeda.sormas.api.caze.CasePersonDto) PersonDto(de.symeda.sormas.api.person.PersonDto) SampleCriteria(de.symeda.sormas.api.sample.SampleCriteria) UserDto(de.symeda.sormas.api.user.UserDto) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) Date(java.util.Date) LocalDate(java.time.LocalDate) RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) TaskCriteria(de.symeda.sormas.api.task.TaskCriteria) SampleDto(de.symeda.sormas.api.sample.SampleDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 18 with CaseCriteria

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()));
}
Also used : RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) CaseIndexDto(de.symeda.sormas.api.caze.CaseIndexDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 19 with CaseCriteria

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());
}
Also used : RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) CasePersonDto(de.symeda.sormas.api.caze.CasePersonDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 20 with CaseCriteria

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());
}
Also used : RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) CasePersonDto(de.symeda.sormas.api.caze.CasePersonDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Aggregations

CaseCriteria (de.symeda.sormas.api.caze.CaseCriteria)59 Test (org.junit.Test)39 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)38 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)37 Date (java.util.Date)25 CaseIndexDto (de.symeda.sormas.api.caze.CaseIndexDto)22 PersonDto (de.symeda.sormas.api.person.PersonDto)21 UserDto (de.symeda.sormas.api.user.UserDto)19 CasePersonDto (de.symeda.sormas.api.caze.CasePersonDto)17 LocalDate (java.time.LocalDate)17 RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)14 RDCFEntities (de.symeda.sormas.backend.TestDataCreator.RDCFEntities)12 CaseExportDto (de.symeda.sormas.api.caze.CaseExportDto)11 SortProperty (de.symeda.sormas.api.utils.SortProperty)8 Disease (de.symeda.sormas.api.Disease)7 CaseReferenceDto (de.symeda.sormas.api.caze.CaseReferenceDto)7 SampleDto (de.symeda.sormas.api.sample.SampleDto)7 DeletionDetails (de.symeda.sormas.api.common.DeletionDetails)6 ContactDto (de.symeda.sormas.api.contact.ContactDto)6 EditPermissionType (de.symeda.sormas.api.EditPermissionType)5