Search in sources :

Example 1 with EventDto

use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.

the class EventGroupList method drawDisplayedEntries.

@Override
protected void drawDisplayedEntries() {
    EventDto event = FacadeProvider.getEventFacade().getEventByUuid(this.event.getUuid(), false);
    List<EventGroupIndexDto> displayedEntries = getDisplayedEntries();
    for (int i = 0, displayedEntriesSize = displayedEntries.size(); i < displayedEntriesSize; i++) {
        EventGroupIndexDto eventGroup = displayedEntries.get(i);
        EventGroupListEntry listEntry = new EventGroupListEntry(eventGroup);
        UserProvider userProvider = UserProvider.getCurrent();
        if (userProvider != null && userProvider.hasUserRight(UserRight.EVENTGROUP_LINK)) {
            listEntry.addUnlinkEventListener(i, (ClickListener) clickEvent -> {
                if (!userProvider.hasNationalJurisdictionLevel() && !userProvider.hasRegion(event.getEventLocation().getRegion())) {
                    new Notification(I18nProperties.getString(Strings.headingEventGroupUnlinkEventIssue), I18nProperties.getString(Strings.errorEventFromAnotherJurisdiction), Notification.Type.ERROR_MESSAGE, false).show(Page.getCurrent());
                    return;
                }
                ControllerProvider.getEventGroupController().unlinkEventGroup(this.event, listEntry.getEventGroup().toReference());
                reload();
            });
        }
        if (userProvider != null && userProvider.hasUserRight(UserRight.EVENTGROUP_EDIT)) {
            listEntry.addEditListener(i, (ClickListener) clickEvent -> {
                ControllerProvider.getEventGroupController().navigateToData(listEntry.getEventGroup().getUuid());
            });
        }
        listEntry.addListEventsListener(i, (ClickListener) clickEvent -> {
            EventCriteria eventCriteria = new EventCriteria();
            eventCriteria.setEventGroup(listEntry.getEventGroup().toReference());
            ControllerProvider.getEventController().navigateTo(eventCriteria);
        });
        listLayout.addComponent(listEntry);
    }
}
Also used : PaginationList(de.symeda.sormas.ui.utils.PaginationList) EventGroupIndexDto(de.symeda.sormas.api.event.EventGroupIndexDto) ClickListener(com.vaadin.ui.Button.ClickListener) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) EntityRelevanceStatus(de.symeda.sormas.api.EntityRelevanceStatus) EventDto(de.symeda.sormas.api.event.EventDto) EventGroupCriteria(de.symeda.sormas.api.event.EventGroupCriteria) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) UserRight(de.symeda.sormas.api.user.UserRight) List(java.util.List) EventCriteria(de.symeda.sormas.api.event.EventCriteria) Notification(com.vaadin.ui.Notification) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) Page(com.vaadin.server.Page) Label(com.vaadin.ui.Label) Strings(de.symeda.sormas.api.i18n.Strings) UserProvider(de.symeda.sormas.ui.UserProvider) UserProvider(de.symeda.sormas.ui.UserProvider) EventDto(de.symeda.sormas.api.event.EventDto) EventCriteria(de.symeda.sormas.api.event.EventCriteria) Notification(com.vaadin.ui.Notification) EventGroupIndexDto(de.symeda.sormas.api.event.EventGroupIndexDto)

Example 2 with EventDto

use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.

the class CaseClassificationFacadeEjb method getClassification.

@Override
public CaseClassification getClassification(CaseDataDto caze) {
    if (criteriaMap.isEmpty()) {
        buildCriteria();
    }
    PersonDto person = personFacade.getPersonByUuid(caze.getPerson().getUuid());
    List<PathogenTestDto> pathogenTests = pathogenTestService.getAllByCase(caze.getUuid()).stream().map(PathogenTestFacadeEjb.PathogenTestFacadeEjbLocal::toDto).collect(Collectors.toList());
    List<EventDto> caseEvents = eventService.getAllByCase(caze.getUuid()).stream().map(eventFacade::toDto).collect(Collectors.toList());
    Date lastVaccinationDate = null;
    if (caze.getDisease() == Disease.YELLOW_FEVER && caze.getVaccinationStatus() == VaccinationStatus.VACCINATED) {
        lastVaccinationDate = immunizationService.getLastVaccinationDateBefore(person.getUuid(), caze.getDisease(), CaseLogic.getStartDate(caze));
    }
    DiseaseClassificationCriteriaDto criteria = criteriaMap.get(caze.getDisease());
    if (criteria != null) {
        if (criteria.getConfirmedCriteria() != null && criteria.getConfirmedCriteria().eval(caze, person, pathogenTests, caseEvents, lastVaccinationDate)) {
            return CaseClassification.CONFIRMED;
        } else if (criteria.getNotACaseCriteria() != null && criteria.getNotACaseCriteria().eval(caze, person, pathogenTests, caseEvents, lastVaccinationDate)) {
            return CaseClassification.NO_CASE;
        } else if (criteria.getProbableCriteria() != null && criteria.getProbableCriteria().eval(caze, person, pathogenTests, caseEvents, lastVaccinationDate)) {
            return CaseClassification.PROBABLE;
        } else if (criteria.getSuspectCriteria() != null && criteria.getSuspectCriteria().eval(caze, person, pathogenTests, caseEvents, lastVaccinationDate)) {
            return CaseClassification.SUSPECT;
        } else if (configFacade.isConfiguredCountry(CountryHelper.COUNTRY_CODE_GERMANY)) {
            if (criteria.getConfirmedNoSymptomsCriteria() != null && criteria.getConfirmedNoSymptomsCriteria().eval(caze, person, pathogenTests, caseEvents, lastVaccinationDate)) {
                return CaseClassification.CONFIRMED_NO_SYMPTOMS;
            } else if (criteria.getConfirmedUnknownSymptomsCriteria() != null && criteria.getConfirmedUnknownSymptomsCriteria().eval(caze, person, pathogenTests, caseEvents, lastVaccinationDate)) {
                return CaseClassification.CONFIRMED_UNKNOWN_SYMPTOMS;
            }
        }
    }
    return CaseClassification.NOT_CLASSIFIED;
}
Also used : PathogenTestFacadeEjb(de.symeda.sormas.backend.sample.PathogenTestFacadeEjb) PersonDto(de.symeda.sormas.api.person.PersonDto) EventDto(de.symeda.sormas.api.event.EventDto) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) Date(java.util.Date) DiseaseClassificationCriteriaDto(de.symeda.sormas.api.caze.classification.DiseaseClassificationCriteriaDto)

Example 3 with EventDto

use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.

the class CaseFacadeEjbTest method testMergeCase.

@Test
public void testMergeCase() throws IOException {
    useNationalUserLogin();
    // 1. Create
    // Create leadCase
    UserDto leadUser = creator.createUser("", "", "", "First", "User");
    UserReferenceDto leadUserReference = new UserReferenceDto(leadUser.getUuid());
    PersonDto leadPerson = creator.createPerson("Alex", "Miller");
    PersonReferenceDto leadPersonReference = new PersonReferenceDto(leadPerson.getUuid());
    RDCF leadRdcf = creator.createRDCF();
    CaseDataDto leadCase = creator.createCase(leadUserReference, leadPersonReference, Disease.DENGUE, CaseClassification.SUSPECT, InvestigationStatus.PENDING, new Date(), leadRdcf, (c) -> {
        c.setAdditionalDetails("Test additional details");
        c.setFollowUpComment("Test followup comment");
    });
    leadCase.setClinicianEmail("mail");
    leadCase.getEpiData().setActivityAsCaseDetailsKnown(YesNoUnknown.NO);
    getCaseFacade().save(leadCase);
    VisitDto leadVisit = creator.createVisit(leadCase.getDisease(), leadCase.getPerson(), leadCase.getReportDate());
    leadVisit.getSymptoms().setAnorexiaAppetiteLoss(SymptomState.YES);
    getVisitFacade().saveVisit(leadVisit);
    // Create otherCase
    UserDto otherUser = creator.createUser("", "", "", "Second", "User");
    UserReferenceDto otherUserReference = new UserReferenceDto(otherUser.getUuid());
    PersonDto otherPerson = creator.createPerson("Max", "Smith");
    otherPerson.setBirthWeight(2);
    getPersonFacade().savePerson(otherPerson);
    PersonReferenceDto otherPersonReference = new PersonReferenceDto(otherPerson.getUuid());
    RDCF otherRdcf = creator.createRDCF("Reg2", "Dis2", "Comm2", "Fac2", "Poe2");
    CaseDataDto otherCase = creator.createCase(otherUserReference, otherPersonReference, Disease.CHOLERA, CaseClassification.SUSPECT, InvestigationStatus.PENDING, new Date(), otherRdcf, (c) -> {
        c.setAdditionalDetails("Test other additional details");
        c.setFollowUpComment("Test other followup comment");
    });
    otherCase.setClinicianName("name");
    CaseReferenceDto otherCaseReference = getCaseFacade().getReferenceByUuid(otherCase.getUuid());
    ContactDto contact = creator.createContact(otherUserReference, otherUserReference, otherPersonReference, otherCase, new Date(), new Date(), null);
    Region region = creator.createRegion("");
    District district = creator.createDistrict("", region);
    SampleDto sample = creator.createSample(otherCaseReference, otherUserReference, creator.createFacility("", region, district, creator.createCommunity("", district)));
    TaskDto task = creator.createTask(TaskContext.CASE, TaskType.CASE_INVESTIGATION, TaskStatus.PENDING, otherCaseReference, new ContactReferenceDto(), new EventReferenceDto(), new Date(), otherUserReference);
    TreatmentDto treatment = creator.createTreatment(otherCase);
    PrescriptionDto prescription = creator.createPrescription(otherCase);
    ClinicalVisitDto visit = creator.createClinicalVisit(otherCase);
    otherCase.getEpiData().setActivityAsCaseDetailsKnown(YesNoUnknown.YES);
    final ArrayList<ActivityAsCaseDto> otherActivitiesAsCase = new ArrayList<>();
    ActivityAsCaseDto activityAsCaseDto = new ActivityAsCaseDto();
    activityAsCaseDto.setActivityAsCaseType(ActivityAsCaseType.GATHERING);
    otherActivitiesAsCase.add(activityAsCaseDto);
    otherCase.getEpiData().setActivitiesAsCase(otherActivitiesAsCase);
    getCaseFacade().save(otherCase);
    VisitDto otherVisit = creator.createVisit(otherCase.getDisease(), otherCase.getPerson(), otherCase.getReportDate());
    otherVisit.getSymptoms().setAbdominalPain(SymptomState.YES);
    getVisitFacade().saveVisit(otherVisit);
    EventDto event = creator.createEvent(otherUserReference);
    event.setDisease(otherCase.getDisease());
    getEventFacade().save(event);
    EventParticipantDto otherCaseEventParticipant = creator.createEventParticipant(event.toReference(), otherPerson, otherUserReference);
    otherCaseEventParticipant.setResultingCase(otherCaseReference);
    getEventParticipantFacade().saveEventParticipant(otherCaseEventParticipant);
    creator.createSurveillanceReport(otherUserReference, otherCaseReference);
    TravelEntryDto travelEntry = creator.createTravelEntry(otherPersonReference, otherUserReference, otherCase.getDisease(), otherRdcf.region, otherRdcf.district, otherRdcf.pointOfEntry);
    travelEntry.setResultingCase(otherCaseReference);
    travelEntry = getTravelEntryFacade().save(travelEntry);
    DocumentDto document = creator.createDocument(leadUserReference, "document.pdf", "application/pdf", 42L, DocumentRelatedEntityType.CASE, leadCase.getUuid(), "content".getBytes(StandardCharsets.UTF_8));
    DocumentDto otherDocument = creator.createDocument(leadUserReference, "other_document.pdf", "application/pdf", 42L, DocumentRelatedEntityType.CASE, otherCase.getUuid(), "other content".getBytes(StandardCharsets.UTF_8));
    // 2. Merge
    getCaseFacade().mergeCase(leadCase.getUuid(), otherCase.getUuid());
    // 3. Test
    CaseDataDto mergedCase = getCaseFacade().getCaseDataByUuid(leadCase.getUuid());
    // Check no values
    assertNull(mergedCase.getClassificationComment());
    // Check 'lead and other have different values'
    assertEquals(leadCase.getDisease(), mergedCase.getDisease());
    // Check 'lead has value, other has not'
    assertEquals(leadCase.getClinicianEmail(), mergedCase.getClinicianEmail());
    // Check 'lead has no value, other has'
    assertEquals(otherCase.getClinicianName(), mergedCase.getClinicianName());
    PersonDto mergedPerson = getPersonFacade().getPersonByUuid(mergedCase.getPerson().getUuid());
    // Check no values
    assertNull(mergedPerson.getBirthdateDD());
    // Check 'lead and other have different values'
    assertEquals(leadCase.getPerson().getFirstName(), mergedPerson.getFirstName());
    // Check 'lead has value, other has not'
    assertEquals(leadCase.getPerson().getLastName(), mergedPerson.getLastName());
    // Check 'lead has no value, other has'
    assertEquals(otherPerson.getBirthWeight(), mergedPerson.getBirthWeight());
    // Check merge comments
    assertEquals("Test additional details Test other additional details", mergedCase.getAdditionalDetails());
    assertEquals("Test followup comment Test other followup comment", mergedCase.getFollowUpComment());
    // 4. Test Reference Changes
    // 4.1 Contacts
    List<String> contactUuids = new ArrayList<>();
    contactUuids.add(contact.getUuid());
    assertEquals(leadCase.getUuid(), getContactFacade().getByUuids(contactUuids).get(0).getCaze().getUuid());
    // 4.2 Samples
    List<String> sampleUuids = new ArrayList<>();
    sampleUuids.add(sample.getUuid());
    assertEquals(leadCase.getUuid(), getSampleFacade().getByUuids(sampleUuids).get(0).getAssociatedCase().getUuid());
    // 4.3 Tasks
    List<String> taskUuids = new ArrayList<>();
    taskUuids.add(task.getUuid());
    assertEquals(leadCase.getUuid(), getTaskFacade().getByUuids(taskUuids).get(0).getCaze().getUuid());
    // 4.4 Treatments
    List<String> treatmentUuids = new ArrayList<>();
    treatmentUuids.add(treatment.getUuid());
    assertEquals(leadCase.getTherapy().getUuid(), getTreatmentFacade().getByUuids(treatmentUuids).get(0).getTherapy().getUuid());
    // 4.5 Prescriptions
    List<String> prescriptionUuids = new ArrayList<>();
    prescriptionUuids.add(prescription.getUuid());
    assertEquals(leadCase.getTherapy().getUuid(), getPrescriptionFacade().getByUuids(prescriptionUuids).get(0).getTherapy().getUuid());
    // 4.6 Clinical Visits
    List<String> visitUuids = new ArrayList<>();
    visitUuids.add(visit.getUuid());
    assertEquals(leadCase.getClinicalCourse().getUuid(), getClinicalVisitFacade().getByUuids(visitUuids).get(0).getClinicalCourse().getUuid());
    // 4.7 Visits;
    List<String> mergedVisits = getVisitFacade().getIndexList(new VisitCriteria().caze(mergedCase.toReference()), null, null, null).stream().map(VisitIndexDto::getUuid).collect(Collectors.toList());
    assertEquals(2, mergedVisits.size());
    assertTrue(mergedVisits.contains(leadVisit.getUuid()));
    assertTrue(mergedVisits.contains(otherVisit.getUuid()));
    // and symptoms
    assertEquals(SymptomState.YES, mergedCase.getSymptoms().getAbdominalPain());
    assertEquals(SymptomState.YES, mergedCase.getSymptoms().getAnorexiaAppetiteLoss());
    assertTrue(mergedCase.getSymptoms().getSymptomatic());
    // 4.8 Linked Events
    assertEquals(1, getEventFacade().count(new EventCriteria().caze(mergedCase.toReference())));
    // 4.8 Linked Surveillance Reports
    List<SurveillanceReportDto> surveillanceReportList = getSurveillanceReportFacade().getByCaseUuids(Collections.singletonList(mergedCase.getUuid()));
    MatcherAssert.assertThat(surveillanceReportList, hasSize(1));
    // 5 Documents
    List<DocumentDto> mergedDocuments = getDocumentFacade().getDocumentsRelatedToEntity(DocumentRelatedEntityType.CASE, leadCase.getUuid());
    assertEquals(2, mergedDocuments.size());
    List<String> documentUuids = mergedDocuments.stream().map(DocumentDto::getUuid).collect(Collectors.toList());
    assertTrue(documentUuids.contains(document.getUuid()));
    assertTrue(documentUuids.contains(otherDocument.getUuid()));
    // 10 Activities as case
    final EpiDataDto epiData = mergedCase.getEpiData();
    assertEquals(YesNoUnknown.YES, epiData.getActivityAsCaseDetailsKnown());
    final List<ActivityAsCaseDto> activitiesAsCase = epiData.getActivitiesAsCase();
    assertEquals(1, activitiesAsCase.size());
    assertEquals(ActivityAsCaseType.GATHERING, activitiesAsCase.get(0).getActivityAsCaseType());
    // Travel entry
    travelEntry = getTravelEntryFacade().getByUuid(travelEntry.getUuid());
    assertEquals(mergedCase.toReference(), travelEntry.getResultingCase());
}
Also used : UserDto(de.symeda.sormas.api.user.UserDto) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) ArrayList(java.util.ArrayList) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) EventCriteria(de.symeda.sormas.api.event.EventCriteria) TreatmentDto(de.symeda.sormas.api.therapy.TreatmentDto) ActivityAsCaseDto(de.symeda.sormas.api.activityascase.ActivityAsCaseDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) PrescriptionDto(de.symeda.sormas.api.therapy.PrescriptionDto) VisitCriteria(de.symeda.sormas.api.visit.VisitCriteria) EpiDataDto(de.symeda.sormas.api.epidata.EpiDataDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) CasePersonDto(de.symeda.sormas.api.caze.CasePersonDto) PersonDto(de.symeda.sormas.api.person.PersonDto) TravelEntryDto(de.symeda.sormas.api.travelentry.TravelEntryDto) EventDto(de.symeda.sormas.api.event.EventDto) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) TaskDto(de.symeda.sormas.api.task.TaskDto) Date(java.util.Date) LocalDate(java.time.LocalDate) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) EventReferenceDto(de.symeda.sormas.api.event.EventReferenceDto) ClinicalVisitDto(de.symeda.sormas.api.clinicalcourse.ClinicalVisitDto) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) DocumentDto(de.symeda.sormas.api.document.DocumentDto) Region(de.symeda.sormas.backend.infrastructure.region.Region) ClinicalVisitDto(de.symeda.sormas.api.clinicalcourse.ClinicalVisitDto) VisitDto(de.symeda.sormas.api.visit.VisitDto) SurveillanceReportDto(de.symeda.sormas.api.caze.surveillancereport.SurveillanceReportDto) District(de.symeda.sormas.backend.infrastructure.district.District) SampleDto(de.symeda.sormas.api.sample.SampleDto) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 4 with EventDto

use of de.symeda.sormas.api.event.EventDto in project SORMAS-Project by hzi-braunschweig.

the class CaseFacadeEjbTest method testGetIndexListByEventFreeText.

@Test
public void testGetIndexListByEventFreeText() {
    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();
    PersonDto person2 = creator.createPerson();
    EventDto event1 = creator.createEvent(EventStatus.SIGNAL, EventInvestigationStatus.PENDING, "Signal foo", "A long description for this event", user.toReference(), eventDto -> {
    });
    EventParticipantDto event1Participant1 = creator.createEventParticipant(event1.toReference(), person1, user.toReference());
    EventParticipantDto event1Participant2 = creator.createEventParticipant(event1.toReference(), person2, user.toReference());
    CaseDataDto case1 = creator.createCase(user.toReference(), person1.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
    CaseDataDto case2 = creator.createCase(user.toReference(), person2.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
    event1Participant1.setResultingCase(case1.toReference());
    getEventParticipantFacade().saveEventParticipant(event1Participant1);
    Assert.assertEquals(2, getCaseFacade().getIndexList(null, 0, 100, null).size());
    Assert.assertEquals(1, getCaseFacade().getIndexList(new CaseCriteria().eventLike("signal"), 0, 100, null).size());
    Assert.assertEquals(1, getCaseFacade().getIndexList(new CaseCriteria().eventLike(event1.getUuid()), 0, 100, null).size());
    Assert.assertEquals(1, getCaseFacade().getIndexList(new CaseCriteria().eventLike("signal description"), 0, 100, null).size());
}
Also used : RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) CasePersonDto(de.symeda.sormas.api.caze.CasePersonDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) EventDto(de.symeda.sormas.api.event.EventDto) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 5 with EventDto

use of de.symeda.sormas.api.event.EventDto 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)

Aggregations

EventDto (de.symeda.sormas.api.event.EventDto)125 Test (org.junit.Test)71 UserDto (de.symeda.sormas.api.user.UserDto)49 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)46 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)39 PersonDto (de.symeda.sormas.api.person.PersonDto)38 Date (java.util.Date)38 EventReferenceDto (de.symeda.sormas.api.event.EventReferenceDto)23 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)22 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)22 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)19 ContactDto (de.symeda.sormas.api.contact.ContactDto)17 SormasToSormasEventDto (de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto)16 RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)16 SampleDto (de.symeda.sormas.api.sample.SampleDto)14 SormasToSormasTest (de.symeda.sormas.backend.sormastosormas.SormasToSormasTest)14 List (java.util.List)13 CommitDiscardWrapperComponent (de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)11 LocalDate (java.time.LocalDate)11 EventParticipantCriteria (de.symeda.sormas.api.event.EventParticipantCriteria)10