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()));
}
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()));
}
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;
}
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);
}
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;
}
Aggregations