Search in sources :

Example 26 with EventDto

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

the class PersonFacadeEjbTest method testGetMatchingNameDtos.

@Test
public void testGetMatchingNameDtos() {
    RDCFEntities rdcf = creator.createRDCFEntities();
    UserDto user = creator.createUser(rdcf, UserRole.SURVEILLANCE_SUPERVISOR);
    // 1-3 = Active persons; 4 = Person without reference; 5-7 = Inactive persons
    PersonDto person1 = creator.createPerson("James", "Smith", Sex.MALE, 1980, 1, 1);
    PersonDto person2 = creator.createPerson("James", "Smith", Sex.MALE, 1979, 5, 12);
    PersonDto person3 = creator.createPerson("James", "Smith", Sex.MALE, 1980, 1, 5);
    PersonDto person4 = creator.createPerson("Maria", "Garcia", Sex.FEMALE, 1984, 12, 2);
    PersonDto person5 = creator.createPerson("Maria", "Garcia", Sex.UNKNOWN, 1984, 7, 12);
    PersonDto person6 = creator.createPerson("Maria", "Garcia", Sex.FEMALE, 1984, null, null);
    PersonDto person7 = creator.createPerson("James", "Smith", Sex.MALE, null, null, null);
    CaseDataDto activeCase = creator.createCase(user.toReference(), person1.toReference(), rdcf);
    creator.createContact(user.toReference(), person2.toReference(), activeCase);
    EventDto activeEvent = creator.createEvent(user.toReference());
    creator.createEventParticipant(activeEvent.toReference(), person3, user.toReference());
    CaseDataDto inactiveCase = creator.createCase(user.toReference(), person5.toReference(), rdcf);
    creator.createContact(user.toReference(), person6.toReference(), inactiveCase);
    EventDto inactiveEvent = creator.createEvent(user.toReference());
    creator.createEventParticipant(inactiveEvent.toReference(), person7, user.toReference());
    getCaseFacade().archive(inactiveCase.getUuid(), null);
    getEventFacade().archive(inactiveEvent.getUuid(), null);
    // Only persons that have active case, contact or event participant associations should be retrieved
    List<String> relevantNameUuids = getPersonFacade().getSimilarPersonDtos(new PersonSimilarityCriteria()).stream().map(dto -> dto.getUuid()).collect(Collectors.toList());
    assertThat(relevantNameUuids, hasSize(6));
    assertThat(relevantNameUuids, containsInAnyOrder(person1.getUuid(), person2.getUuid(), person3.getUuid(), person5.getUuid(), person6.getUuid(), person7.getUuid()));
    creator.createCase(user.toReference(), person4.toReference(), rdcf);
    getCaseFacade().dearchive(Collections.singletonList(inactiveCase.getUuid()), null);
    getEventFacade().dearchive(Collections.singletonList(inactiveEvent.getUuid()), null);
    PersonSimilarityCriteria criteria = new PersonSimilarityCriteria().sex(Sex.MALE).birthdateYYYY(1980).birthdateMM(1).birthdateDD(1);
    List<String> matchingUuids = getPersonFacade().getSimilarPersonDtos(criteria).stream().map(person -> person.getUuid()).collect(Collectors.toList());
    assertThat(matchingUuids, hasSize(2));
    assertThat(matchingUuids, containsInAnyOrder(person1.getUuid(), person7.getUuid()));
    criteria.birthdateMM(null).birthdateDD(null);
    matchingUuids = getPersonFacade().getSimilarPersonDtos(criteria).stream().map(person -> person.getUuid()).collect(Collectors.toList());
    assertThat(matchingUuids, hasSize(3));
    assertThat(matchingUuids, containsInAnyOrder(person1.getUuid(), person3.getUuid(), person7.getUuid()));
    criteria.sex(Sex.FEMALE).birthdateYYYY(1984);
    matchingUuids = getPersonFacade().getSimilarPersonDtos(criteria).stream().map(person -> person.getUuid()).collect(Collectors.toList());
    assertThat(matchingUuids, hasSize(3));
    assertThat(matchingUuids, containsInAnyOrder(person4.getUuid(), person5.getUuid(), person6.getUuid()));
    criteria.sex(null);
    matchingUuids = getPersonFacade().getSimilarPersonDtos(criteria).stream().map(person -> person.getUuid()).collect(Collectors.toList());
    assertThat(matchingUuids, hasSize(4));
    assertThat(matchingUuids, containsInAnyOrder(person4.getUuid(), person5.getUuid(), person6.getUuid(), person7.getUuid()));
    final String passportNr = "passportNr";
    final String otherPassportNr = "otherPassportNr";
    final String healthId = "healthId";
    final String otherHealthId = "otherHealthId";
    PersonDto person8 = creator.createPerson("James", "Smith", Sex.MALE, 1980, 1, 1, passportNr, healthId);
    PersonDto person9 = creator.createPerson("James", "Smith", Sex.MALE, 1980, 1, 1, null, otherHealthId);
    PersonDto person10 = creator.createPerson("Maria", "Garcia", Sex.FEMALE, 1970, 1, 1, passportNr, null);
    PersonDto person11 = creator.createPerson("John", "Doe", Sex.MALE, 1970, 1, 1, otherPassportNr, null);
    creator.createCase(user.toReference(), person8.toReference(), rdcf);
    creator.createCase(user.toReference(), person9.toReference(), rdcf);
    creator.createCase(user.toReference(), person10.toReference(), rdcf);
    creator.createCase(user.toReference(), person11.toReference(), rdcf);
    criteria.sex(Sex.MALE).birthdateYYYY(1980);
    criteria.passportNumber(passportNr);
    matchingUuids = getPersonFacade().getSimilarPersonDtos(criteria).stream().map(person -> person.getUuid()).collect(Collectors.toList());
    assertThat(matchingUuids, hasSize(6));
    assertThat(matchingUuids, containsInAnyOrder(person1.getUuid(), person3.getUuid(), person7.getUuid(), person8.getUuid(), person9.getUuid(), person10.getUuid()));
    criteria.nationalHealthId(healthId).passportNumber(null);
    matchingUuids = getPersonFacade().getSimilarPersonDtos(criteria).stream().map(person -> person.getUuid()).collect(Collectors.toList());
    assertThat(matchingUuids, hasSize(4));
    assertThat(matchingUuids, containsInAnyOrder(person1.getUuid(), person3.getUuid(), person7.getUuid(), person8.getUuid()));
    criteria.nationalHealthId(otherHealthId);
    matchingUuids = getPersonFacade().getSimilarPersonDtos(criteria).stream().map(person -> person.getUuid()).collect(Collectors.toList());
    assertThat(matchingUuids, hasSize(4));
    assertThat(matchingUuids, containsInAnyOrder(person1.getUuid(), person3.getUuid(), person7.getUuid(), person9.getUuid()));
    criteria.passportNumber(otherPassportNr);
    matchingUuids = getPersonFacade().getSimilarPersonDtos(criteria).stream().map(person -> person.getUuid()).collect(Collectors.toList());
    assertThat(matchingUuids, hasSize(5));
    assertThat(matchingUuids, containsInAnyOrder(person1.getUuid(), person3.getUuid(), person7.getUuid(), person9.getUuid(), person11.getUuid()));
}
Also used : FollowUpStatus(de.symeda.sormas.api.contact.FollowUpStatus) Arrays(java.util.Arrays) Date(java.util.Date) PersonAssociation(de.symeda.sormas.api.person.PersonAssociation) Matchers.not(org.hamcrest.Matchers.not) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) PersonDto(de.symeda.sormas.api.person.PersonDto) EntityDto(de.symeda.sormas.api.EntityDto) PersonContext(de.symeda.sormas.api.person.PersonContext) UserRole(de.symeda.sormas.api.user.UserRole) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) PersonExportDto(de.symeda.sormas.api.person.PersonExportDto) Sex(de.symeda.sormas.api.person.Sex) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) InvestigationStatus(de.symeda.sormas.api.caze.InvestigationStatus) EventDto(de.symeda.sormas.api.event.EventDto) Collectors(java.util.stream.Collectors) PhoneNumberType(de.symeda.sormas.api.person.PhoneNumberType) RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) PersonFollowUpEndDto(de.symeda.sormas.api.person.PersonFollowUpEndDto) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Assert.assertFalse(org.junit.Assert.assertFalse) ContactDto(de.symeda.sormas.api.contact.ContactDto) PersonContactDetailType(de.symeda.sormas.api.person.PersonContactDetailType) SymptomJournalStatus(de.symeda.sormas.api.person.SymptomJournalStatus) Optional(java.util.Optional) PersonSimilarityCriteria(de.symeda.sormas.api.person.PersonSimilarityCriteria) Matchers.is(org.hamcrest.Matchers.is) PersonIndexDto(de.symeda.sormas.api.person.PersonIndexDto) ExternalSurveillanceToolException(de.symeda.sormas.api.externalsurveillancetool.ExternalSurveillanceToolException) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) DateHelper(de.symeda.sormas.api.utils.DateHelper) PersonFacade(de.symeda.sormas.api.person.PersonFacade) PersonContactDetailDto(de.symeda.sormas.api.person.PersonContactDetailDto) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) LocationDto(de.symeda.sormas.api.location.LocationDto) PersonCriteria(de.symeda.sormas.api.person.PersonCriteria) Matchers.empty(org.hamcrest.Matchers.empty) JournalPersonDto(de.symeda.sormas.api.person.JournalPersonDto) Assert.assertNotNull(org.junit.Assert.assertNotNull) UserDto(de.symeda.sormas.api.user.UserDto) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) SortProperty(de.symeda.sormas.api.utils.SortProperty) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) PresentCondition(de.symeda.sormas.api.person.PresentCondition) Assert.assertNull(org.junit.Assert.assertNull) Disease(de.symeda.sormas.api.Disease) RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) TravelEntryDto(de.symeda.sormas.api.travelentry.TravelEntryDto) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) JournalPersonDto(de.symeda.sormas.api.person.JournalPersonDto) UserDto(de.symeda.sormas.api.user.UserDto) EventDto(de.symeda.sormas.api.event.EventDto) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) PersonSimilarityCriteria(de.symeda.sormas.api.person.PersonSimilarityCriteria) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 27 with EventDto

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

the class PersonFacadeEjbPseudonymizationTest method testGetEventParticipantPersonInSameJurisdiction.

@Test
public void testGetEventParticipantPersonInSameJurisdiction() {
    loginWith(districtUser2);
    person = createPerson();
    EventDto event = creator.createEvent(districtUser2.toReference());
    creator.createEventParticipant(event.toReference(), person, districtUser2.toReference());
    assertNotPseudonymized(getPersonFacade().getPersonByUuid(person.getUuid()));
}
Also used : EventDto(de.symeda.sormas.api.event.EventDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 28 with EventDto

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

the class EventFacadeEjb method convertToDetailedReferenceDto.

public EventDto convertToDetailedReferenceDto(Event source, Pseudonymizer pseudonymizer) {
    EventDto eventDto = toDto(source);
    eventDto.setSuperordinateEvent(EventFacadeEjb.toDetailedReferenceDto(source.getSuperordinateEvent()));
    pseudonymizeDto(source, eventDto, pseudonymizer);
    return eventDto;
}
Also used : EventDto(de.symeda.sormas.api.event.EventDto)

Example 29 with EventDto

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

the class EventFacadeEjb method save.

public EventDto save(@NotNull EventDto dto, boolean checkChangeDate, boolean internal) {
    Event existingEvent = dto.getUuid() != null ? service.getByUuid(dto.getUuid()) : null;
    if (internal && existingEvent != null && !service.isEventEditAllowed(existingEvent)) {
        throw new AccessDeniedException(I18nProperties.getString(Strings.errorEventNotEditable));
    }
    EventDto existingDto = toDto(existingEvent);
    Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight);
    restorePseudonymizedDto(dto, existingDto, existingEvent, pseudonymizer);
    if (dto.getReportDateTime() == null) {
        throw new ValidationRuntimeException(I18nProperties.getValidationError(Validations.validReportDateTime));
    }
    Event event = fillOrBuildEntity(dto, existingEvent, checkChangeDate);
    service.ensurePersisted(event);
    onEventChange(toDto(event), internal);
    return convertToDto(event, pseudonymizer);
}
Also used : AccessDeniedException(de.symeda.sormas.api.utils.AccessDeniedException) Pseudonymizer(de.symeda.sormas.backend.util.Pseudonymizer) EventDto(de.symeda.sormas.api.event.EventDto) ValidationRuntimeException(de.symeda.sormas.api.utils.ValidationRuntimeException)

Example 30 with EventDto

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

the class EventFacadeEjb method toDto.

public EventDto toDto(Event source) {
    if (source == null) {
        return null;
    }
    EventDto target = new EventDto();
    DtoHelper.fillDto(target, source);
    target.setEventStatus(source.getEventStatus());
    target.setRiskLevel(source.getRiskLevel());
    target.setSpecificRisk(source.getSpecificRisk());
    target.setEventInvestigationStatus(source.getEventInvestigationStatus());
    target.setEventInvestigationStartDate(source.getEventInvestigationStartDate());
    target.setEventInvestigationEndDate(source.getEventInvestigationEndDate());
    target.setExternalId(source.getExternalId());
    target.setExternalToken(source.getExternalToken());
    target.setEventTitle(source.getEventTitle());
    target.setEventDesc(source.getEventDesc());
    target.setNosocomial(source.getNosocomial());
    target.setStartDate(source.getStartDate());
    target.setEndDate(source.getEndDate());
    target.setReportDateTime(source.getReportDateTime());
    target.setReportingUser(UserFacadeEjb.toReferenceDto(source.getReportingUser()));
    target.setEvolutionDate(source.getEvolutionDate());
    target.setEvolutionComment(source.getEvolutionComment());
    target.setEventLocation(LocationFacadeEjb.toDto(source.getEventLocation()));
    target.setTypeOfPlace(source.getTypeOfPlace());
    target.setMeansOfTransport(source.getMeansOfTransport());
    target.setMeansOfTransportDetails(source.getMeansOfTransportDetails());
    target.setConnectionNumber(source.getConnectionNumber());
    target.setTravelDate(source.getTravelDate());
    target.setWorkEnvironment(source.getWorkEnvironment());
    target.setSrcType(source.getSrcType());
    target.setSrcInstitutionalPartnerType(source.getSrcInstitutionalPartnerType());
    target.setSrcInstitutionalPartnerTypeDetails(source.getSrcInstitutionalPartnerTypeDetails());
    target.setSrcFirstName(source.getSrcFirstName());
    target.setSrcLastName(source.getSrcLastName());
    target.setSrcTelNo(source.getSrcTelNo());
    target.setSrcEmail(source.getSrcEmail());
    target.setSrcMediaWebsite(source.getSrcMediaWebsite());
    target.setSrcMediaName(source.getSrcMediaName());
    target.setSrcMediaDetails(source.getSrcMediaDetails());
    target.setDisease(source.getDisease());
    target.setDiseaseVariant(source.getDiseaseVariant());
    target.setDiseaseDetails(source.getDiseaseDetails());
    target.setDiseaseVariantDetails(source.getDiseaseVariantDetails());
    target.setResponsibleUser(UserFacadeEjb.toReferenceDto(source.getResponsibleUser()));
    target.setTypeOfPlaceText(source.getTypeOfPlaceText());
    target.setTransregionalOutbreak(source.getTransregionalOutbreak());
    target.setDiseaseTransmissionMode(source.getDiseaseTransmissionMode());
    target.setSuperordinateEvent(EventFacadeEjb.toReferenceDto(source.getSuperordinateEvent()));
    target.setEventManagementStatus(source.getEventManagementStatus());
    target.setReportLat(source.getReportLat());
    target.setReportLon(source.getReportLon());
    target.setReportLatLonAccuracy(source.getReportLatLonAccuracy());
    target.setInfectionPathCertainty(source.getInfectionPathCertainty());
    target.setHumanTransmissionMode(source.getHumanTransmissionMode());
    target.setParenteralTransmissionMode(source.getParenteralTransmissionMode());
    target.setMedicallyAssociatedTransmissionMode(source.getMedicallyAssociatedTransmissionMode());
    target.setEpidemiologicalEvidence(source.getEpidemiologicalEvidence());
    target.setEpidemiologicalEvidenceDetails(source.getEpidemiologicalEvidenceDetails());
    target.setLaboratoryDiagnosticEvidence(source.getLaboratoryDiagnosticEvidence());
    target.setLaboratoryDiagnosticEvidenceDetails(source.getLaboratoryDiagnosticEvidenceDetails());
    target.setInternalToken(source.getInternalToken());
    target.setSormasToSormasOriginInfo(SormasToSormasOriginInfoFacadeEjb.toDto(source.getSormasToSormasOriginInfo()));
    target.setOwnershipHandedOver(source.getSormasToSormasShares().stream().anyMatch(ShareInfoHelper::isOwnerShipHandedOver));
    target.setEventIdentificationSource(source.getEventIdentificationSource());
    return target;
}
Also used : EventDto(de.symeda.sormas.api.event.EventDto)

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