Search in sources :

Example 26 with CaseDataDto

use of de.symeda.sormas.api.caze.CaseDataDto in project SORMAS-Project by hzi-braunschweig.

the class ContactFacadeEjbTest method testGetIndexListWithLabUser.

@Test
public void testGetIndexListWithLabUser() {
    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");
    CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
    PersonDto contactPerson = creator.createPerson("Contact", "Person");
    ContactDto contact = creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), null);
    UserDto labUser = creator.createUser(null, null, null, "Lab", "Off", UserRole.LAB_USER);
    FacilityReferenceDto laboratory = new FacilityReferenceDto(rdcf.facility.getUuid(), rdcf.facility.toString(), rdcf.facility.getExternalID());
    labUser.setLaboratory(laboratory);
    getUserFacade().saveUser(labUser);
    loginWith(labUser);
    assertEquals(0, getContactFacade().getIndexList(null, 0, 100, null).size());
    loginWith(user);
    creator.createSample(contact.toReference(), user.toReference(), laboratory, s -> {
        s.setSampleDateTime(new Date());
        s.setComment("Test contact sample");
    });
    loginWith(labUser);
    assertEquals(1, getContactFacade().getIndexList(null, 0, 100, null).size());
}
Also used : RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 27 with CaseDataDto

use of de.symeda.sormas.api.caze.CaseDataDto in project SORMAS-Project by hzi-braunschweig.

the class ContactFacadeEjbTest method testGetIndexDetailedList.

@Test
public void testGetIndexDetailedList() {
    ContactCriteria contactCriteria = new ContactCriteria();
    contactCriteria.setIncludeContactsFromOtherJurisdictions(true);
    List<SortProperty> sortProperties = Collections.emptyList();
    List<ContactIndexDetailedDto> result;
    // 0. No data: empty list
    result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
    assertThat(result, is(empty()));
    // Create needed structural data
    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");
    CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
    UserReferenceDto reportingUser = new UserReferenceDto(user.getUuid());
    EventDto event1 = creator.createEvent(reportingUser, DateHelper.subtractDays(new Date(), 1));
    EventDto event2 = creator.createEvent(reportingUser, new Date());
    PersonDto contactPerson = creator.createPerson("Contact", "Person");
    ContactDto contact1 = creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), null);
    // 1a. one Contact without Event
    result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
    assertThat(result, hasSize(1));
    {
        ContactIndexDetailedDto dto = result.get(0);
        assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
        assertThat(dto.getEventCount(), equalTo(0L));
        assertNull(dto.getLatestEventId());
        assertNull(dto.getLatestEventTitle());
        assertThat(dto.getVisitCount(), equalTo(0));
    }
    // 1b. one Contact with one Event
    creator.createEventParticipant(new EventReferenceDto(event1.getUuid()), contactPerson, reportingUser);
    result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
    assertThat(result, hasSize(1));
    {
        ContactIndexDetailedDto dto = result.get(0);
        assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
        assertThat(dto.getEventCount(), equalTo(1L));
        assertThat(dto.getLatestEventId(), equalTo(event1.getUuid()));
        assertThat(dto.getLatestEventTitle(), equalTo(event1.getEventTitle()));
        assertThat(dto.getVisitCount(), equalTo(0));
    }
    // 1c. one Contact with two Events, second is leading
    creator.createEventParticipant(new EventReferenceDto(event2.getUuid()), contactPerson, reportingUser);
    result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
    assertThat(result, hasSize(1));
    {
        ContactIndexDetailedDto dto = result.get(0);
        assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
        assertThat(dto.getEventCount(), equalTo(2L));
        assertThat(dto.getLatestEventId(), equalTo(event2.getUuid()));
        assertThat(dto.getLatestEventTitle(), equalTo(event2.getEventTitle()));
        assertThat(dto.getVisitCount(), equalTo(0));
    }
    // 1d. one Contact with two Events and one visit
    creator.createVisit(new PersonReferenceDto(contactPerson.getUuid()));
    result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
    assertThat(result, hasSize(1));
    {
        ContactIndexDetailedDto dto = result.get(0);
        assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
        assertThat(dto.getEventCount(), equalTo(2L));
        assertThat(dto.getLatestEventId(), equalTo(event2.getUuid()));
        assertThat(dto.getLatestEventTitle(), equalTo(event2.getEventTitle()));
        assertThat(dto.getVisitCount(), equalTo(1));
    }
    // 1e. one Contact with two Events and three visits
    creator.createVisit(new PersonReferenceDto(contactPerson.getUuid()));
    creator.createVisit(new PersonReferenceDto(contactPerson.getUuid()));
    result = getContactFacade().getIndexDetailedList(contactCriteria, null, null, sortProperties);
    assertThat(result, hasSize(1));
    {
        ContactIndexDetailedDto dto = result.get(0);
        assertThat(dto.getUuid(), equalTo(contact1.getUuid()));
        assertThat(dto.getEventCount(), equalTo(2L));
        assertThat(dto.getLatestEventId(), equalTo(event2.getUuid()));
        assertThat(dto.getLatestEventTitle(), equalTo(event2.getEventTitle()));
        assertThat(dto.getVisitCount(), equalTo(3));
    }
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) EventDto(de.symeda.sormas.api.event.EventDto) ContactIndexDetailedDto(de.symeda.sormas.api.contact.ContactIndexDetailedDto) Date(java.util.Date) LocalDate(java.time.LocalDate) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) SortProperty(de.symeda.sormas.api.utils.SortProperty) RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 28 with CaseDataDto

use of de.symeda.sormas.api.caze.CaseDataDto in project SORMAS-Project by hzi-braunschweig.

the class ContactFacadeEjbTest method testGetIndexList.

@Test
public void testGetIndexList() {
    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");
    CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
    PersonDto contactPerson = creator.createPerson("Contact", "Person");
    creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), null);
    // Database should contain one contact, associated visit and task
    assertEquals(1, getContactFacade().getIndexList(null, 0, 100, null).size());
}
Also used : RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 29 with CaseDataDto

use of de.symeda.sormas.api.caze.CaseDataDto in project SORMAS-Project by hzi-braunschweig.

the class ContactFacadeEjbTest method testMapContactListCreation.

@Test
public void testMapContactListCreation() {
    TestDataCreator.RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
    UserDto user = useSurveillanceOfficerLogin(rdcf);
    PersonDto cazePerson = creator.createPerson("Case", "Person");
    CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
    PersonDto contactPerson = creator.createPerson("Contact", "Person", p -> {
        p.getAddress().setLatitude(0.0);
        p.getAddress().setLongitude(0.0);
    });
    creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), caze.getDisease(), rdcf);
    Long count = getContactFacade().countContactsForMap(caze.getRegion(), caze.getDistrict(), caze.getDisease(), DateHelper.subtractDays(new Date(), 1), DateHelper.addDays(new Date(), 1));
    List<MapContactDto> mapContactDtos = getContactFacade().getContactsForMap(caze.getRegion(), caze.getDistrict(), caze.getDisease(), DateHelper.subtractDays(new Date(), 1), DateHelper.addDays(new Date(), 1));
    // List should have one entry
    assertEquals((long) count, mapContactDtos.size());
    assertEquals((long) 1, mapContactDtos.size());
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 30 with CaseDataDto

use of de.symeda.sormas.api.caze.CaseDataDto in project SORMAS-Project by hzi-braunschweig.

the class ContactFacadeEjbTest method testCountMaximumFollowUpDays.

@Test
public void testCountMaximumFollowUpDays() {
    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");
    CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
    PersonDto contactPerson = creator.createPerson("Contact", "Person");
    creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), null);
    VisitDto visit = creator.createVisit(caze.getDisease(), contactPerson.toReference(), new Date(), VisitStatus.COOPERATIVE, VisitOrigin.USER);
    visit.getSymptoms().setAbdominalPain(SymptomState.YES);
    getVisitFacade().saveVisit(visit);
    PersonDto contactPerson2 = creator.createPerson("Contact2", "Person2");
    creator.createContact(user.toReference(), user.toReference(), contactPerson2.toReference(), caze, new Date(), new Date(), null);
    VisitDto visit21 = creator.createVisit(caze.getDisease(), contactPerson2.toReference(), new Date(), VisitStatus.COOPERATIVE, VisitOrigin.USER);
    visit21.getSymptoms().setAbdominalPain(SymptomState.YES);
    getVisitFacade().saveVisit(visit21);
    VisitDto visit22 = creator.createVisit(caze.getDisease(), contactPerson2.toReference(), new Date(), VisitStatus.COOPERATIVE, VisitOrigin.USER);
    visit22.getSymptoms().setAgitation(SymptomState.YES);
    getVisitFacade().saveVisit(visit22);
    PersonDto contactPerson3 = creator.createPerson("Contact3", "Person3");
    creator.createContact(user.toReference(), user.toReference(), contactPerson3.toReference(), caze, new Date(), new Date(), null);
    for (int i = 0; i < 10; i++) {
        creator.createVisit(caze.getDisease(), contactPerson3.toReference(), new Date(), VisitStatus.COOPERATIVE, VisitOrigin.USER);
    }
    assertEquals(10, getContactFacade().countMaximumFollowUpDays(null));
}
Also used : RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) VisitDto(de.symeda.sormas.api.visit.VisitDto) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Aggregations

CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)395 Test (org.junit.Test)287 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)239 PersonDto (de.symeda.sormas.api.person.PersonDto)174 Date (java.util.Date)159 UserDto (de.symeda.sormas.api.user.UserDto)140 ContactDto (de.symeda.sormas.api.contact.ContactDto)102 SampleDto (de.symeda.sormas.api.sample.SampleDto)74 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)62 RDCFEntities (de.symeda.sormas.backend.TestDataCreator.RDCFEntities)58 LocalDate (java.time.LocalDate)57 CaseCriteria (de.symeda.sormas.api.caze.CaseCriteria)43 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)43 RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)43 List (java.util.List)42 Disease (de.symeda.sormas.api.Disease)40 PersonReferenceDto (de.symeda.sormas.api.person.PersonReferenceDto)36 PathogenTestDto (de.symeda.sormas.api.sample.PathogenTestDto)36 ArrayList (java.util.ArrayList)35 SimilarContactDto (de.symeda.sormas.api.contact.SimilarContactDto)34