use of de.symeda.sormas.api.event.EventParticipantCriteria in project SORMAS-Project by hzi-braunschweig.
the class PersonFacadeEjb method onPersonChanged.
public void onPersonChanged(PersonDto existingPerson, Person newPerson, boolean syncShares) {
List<Case> personCases = null;
// Do not bother to update existing cases/contacts/eventparticipants on new Persons, as none should exist yet
if (existingPerson != null) {
personCases = caseService.findBy(new CaseCriteria().person(new PersonReferenceDto(newPerson.getUuid())), true);
// Attention: this may lead to infinite recursion when not properly implemented
for (Case personCase : personCases) {
CaseDataDto existingCase = caseFacade.toDto(personCase);
caseFacade.onCaseChanged(existingCase, personCase, syncShares);
}
List<Contact> personContacts = contactService.findBy(new ContactCriteria().setPerson(new PersonReferenceDto(newPerson.getUuid())), null);
// Attention: this may lead to infinite recursion when not properly implemented
for (Contact personContact : personContacts) {
contactFacade.onContactChanged(contactFacade.toDto(personContact), syncShares);
}
List<EventParticipant> personEventParticipants = eventParticipantService.findBy(new EventParticipantCriteria().withPerson(new PersonReferenceDto(newPerson.getUuid())), null);
// Attention: this may lead to infinite recursion when not properly implemented
for (EventParticipant personEventParticipant : personEventParticipants) {
eventParticipantFacade.onEventParticipantChanged(eventFacade.toDto(personEventParticipant.getEvent()), eventParticipantFacade.toDto(personEventParticipant), personEventParticipant, syncShares);
}
// get the updated personCases
personCases = caseService.findBy(new CaseCriteria().person(new PersonReferenceDto(newPerson.getUuid())), true);
// sort cases based on recency
Collections.sort(personCases, (c1, c2) -> CaseLogic.getStartDate(c1.getSymptoms().getOnsetDate(), c1.getReportDate()).before(CaseLogic.getStartDate(c2.getSymptoms().getOnsetDate(), c2.getReportDate())) ? 1 : -1);
if (newPerson.getPresentCondition() != null && existingPerson.getPresentCondition() != newPerson.getPresentCondition()) {
// get the latest case with disease==causeofdeathdisease
Case personCase = personCases.stream().filter(caze -> caze.getDisease() == newPerson.getCauseOfDeathDisease()).findFirst().orElse(null);
if (newPerson.getPresentCondition().isDeceased() && newPerson.getDeathDate() != null && newPerson.getCauseOfDeath() == CauseOfDeath.EPIDEMIC_DISEASE && newPerson.getCauseOfDeathDisease() != null) {
// update the latest associated case
if (personCase != null && personCase.getOutcome() != CaseOutcome.DECEASED && (personCase.getReportDate().before(DateHelper.addDays(newPerson.getDeathDate(), 30)) && personCase.getReportDate().after(DateHelper.subtractDays(newPerson.getDeathDate(), 30)))) {
CaseDataDto existingCase = caseFacade.toDto(personCase);
personCase.setOutcome(CaseOutcome.DECEASED);
personCase.setOutcomeDate(newPerson.getDeathDate());
caseFacade.onCaseChanged(existingCase, personCase, syncShares);
}
} else if (!newPerson.getPresentCondition().isDeceased() && (existingPerson.getPresentCondition() == PresentCondition.DEAD || existingPerson.getPresentCondition() == PresentCondition.BURIED)) {
// Person was put "back alive"
// make sure other values are set to null
newPerson.setCauseOfDeath(null);
newPerson.setCauseOfDeathDisease(null);
newPerson.setDeathPlaceDescription(null);
newPerson.setDeathPlaceType(null);
newPerson.setBurialDate(null);
newPerson.setCauseOfDeathDisease(null);
// update the latest associated case, if it was set to deceased && and if the case-disease was also the causeofdeath-disease
if (personCase != null && personCase.getOutcome() == CaseOutcome.DECEASED) {
CaseDataDto existingCase = caseFacade.toDto(personCase);
personCase.setOutcome(CaseOutcome.NO_OUTCOME);
personCase.setOutcomeDate(null);
caseFacade.onCaseChanged(existingCase, personCase, syncShares);
}
}
} else if (newPerson.getPresentCondition() != null && newPerson.getPresentCondition().isDeceased() && !Objects.equals(newPerson.getDeathDate(), existingPerson.getDeathDate()) && newPerson.getDeathDate() != null) {
// only Deathdate has changed
// update the latest associated case to the new deathdate, if causeOfDeath matches
Case personCase = personCases.isEmpty() ? null : personCases.get(0);
if (personCase != null && personCase.getOutcome() == CaseOutcome.DECEASED && newPerson.getCauseOfDeath() == CauseOfDeath.EPIDEMIC_DISEASE) {
CaseDataDto existingCase = caseFacade.toDto(personCase);
personCase.setOutcomeDate(newPerson.getDeathDate());
caseFacade.onCaseChanged(existingCase, personCase, syncShares);
}
}
}
// Set approximate age if it hasn't been set before
if (newPerson.getApproximateAge() == null && newPerson.getBirthdateYYYY() != null) {
Pair<Integer, ApproximateAgeType> pair = ApproximateAgeHelper.getApproximateAge(newPerson.getBirthdateYYYY(), newPerson.getBirthdateMM(), newPerson.getBirthdateDD(), newPerson.getDeathDate());
newPerson.setApproximateAge(pair.getElement0());
newPerson.setApproximateAgeType(pair.getElement1());
newPerson.setApproximateAgeReferenceDate(newPerson.getDeathDate() != null ? newPerson.getDeathDate() : new Date());
}
// Update caseAge of all associated cases when approximateAge has changed
if (existingPerson != null && existingPerson.getApproximateAge() != newPerson.getApproximateAge()) {
// Update case list after previous onCaseChanged
personCases = caseService.findBy(new CaseCriteria().person(new PersonReferenceDto(newPerson.getUuid())), true);
for (Case personCase : personCases) {
CaseDataDto existingCase = caseFacade.toDto(personCase);
if (newPerson.getApproximateAge() == null) {
personCase.setCaseAge(null);
} else if (newPerson.getApproximateAgeType() == ApproximateAgeType.MONTHS) {
personCase.setCaseAge(0);
} else {
Date now = new Date();
personCase.setCaseAge(newPerson.getApproximateAge() - DateHelper.getYearsBetween(personCase.getReportDate(), now));
if (personCase.getCaseAge() < 0) {
personCase.setCaseAge(0);
}
}
caseFacade.onCaseChanged(existingCase, personCase, syncShares);
}
}
// For newly created persons, assume no registration in external journals
if (existingPerson == null && newPerson.getSymptomJournalStatus() == null) {
newPerson.setSymptomJournalStatus(SymptomJournalStatus.UNREGISTERED);
}
cleanUp(newPerson);
}
use of de.symeda.sormas.api.event.EventParticipantCriteria in project SORMAS-Project by hzi-braunschweig.
the class CaseController method convertSamePersonContactsAndEventparticipants.
private void convertSamePersonContactsAndEventparticipants(CaseDataDto caze, Date relevantDate) {
ContactSimilarityCriteria contactCriteria = new ContactSimilarityCriteria().withPerson(caze.getPerson()).withDisease(caze.getDisease()).withContactClassification(ContactClassification.CONFIRMED).withExcludePseudonymized(true).withNoResultingCase(true);
List<SimilarContactDto> matchingContacts = FacadeProvider.getContactFacade().getMatchingContacts(contactCriteria);
EventParticipantCriteria eventParticipantCriteria = new EventParticipantCriteria().withPerson(caze.getPerson()).withDisease(caze.getDisease()).withExcludePseudonymized(true).withNoResultingCase(true);
List<SimilarEventParticipantDto> matchingEventParticipants = FacadeProvider.getEventParticipantFacade().getMatchingEventParticipants(eventParticipantCriteria);
if (matchingContacts.size() > 0 || matchingEventParticipants.size() > 0) {
String infoText = matchingEventParticipants.isEmpty() ? String.format(I18nProperties.getString(Strings.infoConvertToCaseContacts), matchingContacts.size(), caze.getDisease()) : (matchingContacts.isEmpty() ? String.format(I18nProperties.getString(Strings.infoConvertToCaseEventParticipants), matchingEventParticipants.size(), caze.getDisease()) : String.format(I18nProperties.getString(Strings.infoConvertToCaseContactsAndEventParticipants), matchingContacts.size(), caze.getDisease(), matchingEventParticipants.size(), caze.getDisease()));
HorizontalLayout infoComponent = VaadinUiUtil.createInfoComponent(infoText);
infoComponent.setWidth(600, Sizeable.Unit.PIXELS);
CommitDiscardWrapperComponent<HorizontalLayout> convertToCaseConfirmComponent = new CommitDiscardWrapperComponent<>(infoComponent);
convertToCaseConfirmComponent.getCommitButton().setCaption(I18nProperties.getCaption(Captions.actionYesForAll));
convertToCaseConfirmComponent.getDiscardButton().setCaption(I18nProperties.getCaption(Captions.actionNo));
convertToCaseConfirmComponent.addCommitListener(() -> {
CaseDataDto refreshedCaze = FacadeProvider.getCaseFacade().getCaseDataByUuid(caze.getUuid());
refreshedCaze.getEpiData().setContactWithSourceCaseKnown(YesNoUnknown.YES);
saveCase(refreshedCaze);
setResultingCase(refreshedCaze, matchingContacts, matchingEventParticipants);
SormasUI.refreshView();
});
Button convertSomeButton = ButtonHelper.createButton("convertSome", I18nProperties.getCaption(Captions.actionYesForSome), (Button.ClickListener) event -> {
convertToCaseConfirmComponent.discard();
showConvertToCaseSelection(caze, matchingContacts, matchingEventParticipants);
}, ValoTheme.BUTTON_PRIMARY);
HorizontalLayout buttonsPanel = convertToCaseConfirmComponent.getButtonsPanel();
buttonsPanel.addComponent(convertSomeButton, convertToCaseConfirmComponent.getComponentCount() - 1);
buttonsPanel.setComponentAlignment(convertSomeButton, Alignment.BOTTOM_RIGHT);
buttonsPanel.setExpandRatio(convertSomeButton, 0);
VaadinUiUtil.showModalPopupWindow(convertToCaseConfirmComponent, I18nProperties.getString(Strings.headingCaseConversion));
}
}
use of de.symeda.sormas.api.event.EventParticipantCriteria in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantFacadeEjb method getExportList.
@Override
public List<EventParticipantExportDto> getExportList(EventParticipantCriteria eventParticipantCriteria, Collection<String> selectedRows, int first, int max, Language userLanguage, ExportConfigurationDto exportConfiguration) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<EventParticipantExportDto> cq = cb.createQuery(EventParticipantExportDto.class);
Root<EventParticipant> eventParticipant = cq.from(EventParticipant.class);
EventParticipantQueryContext eventParticipantQueryContext = new EventParticipantQueryContext(cb, cq, eventParticipant);
EventParticipantJoins<EventParticipant> joins = (EventParticipantJoins<EventParticipant>) eventParticipantQueryContext.getJoins();
Join<EventParticipant, Person> person = joins.getPerson();
PersonQueryContext personQueryContext = new PersonQueryContext(cb, cq, person);
Join<Person, Location> address = joins.getAddress();
Join<Person, Country> birthCountry = person.join(Person.BIRTH_COUNTRY, JoinType.LEFT);
Join<Person, Country> citizenship = person.join(Person.CITIZENSHIP, JoinType.LEFT);
Join<EventParticipant, Event> event = joins.getEvent();
Join<Event, Location> eventLocation = joins.getEventAddress();
Join<EventParticipant, Case> resultingCase = joins.getResultingCase();
cq.multiselect(eventParticipant.get(EventParticipant.ID), person.get(Person.ID), person.get(Person.UUID), eventParticipant.get(EventParticipant.UUID), person.get(Person.NATIONAL_HEALTH_ID), person.get(Location.ID), JurisdictionHelper.booleanSelector(cb, service.inJurisdictionOrOwned(eventParticipantQueryContext)), event.get(Event.UUID), event.get(Event.EVENT_STATUS), event.get(Event.EVENT_INVESTIGATION_STATUS), event.get(Event.DISEASE), event.get(Event.TYPE_OF_PLACE), event.get(Event.START_DATE), event.get(Event.END_DATE), event.get(Event.EVENT_TITLE), event.get(Event.EVENT_DESC), eventLocation.join(Location.REGION, JoinType.LEFT).get(Region.NAME), eventLocation.join(Location.DISTRICT, JoinType.LEFT).get(District.NAME), eventLocation.join(Location.COMMUNITY, JoinType.LEFT).get(Community.NAME), eventLocation.get(Location.CITY), eventLocation.get(Location.STREET), eventLocation.get(Location.HOUSE_NUMBER), person.get(Person.FIRST_NAME), person.get(Person.LAST_NAME), person.get(Person.SALUTATION), person.get(Person.OTHER_SALUTATION), person.get(Person.SEX), eventParticipant.get(EventParticipant.INVOLVEMENT_DESCRIPTION), person.get(Person.APPROXIMATE_AGE), person.get(Person.APPROXIMATE_AGE_TYPE), person.get(Person.BIRTHDATE_DD), person.get(Person.BIRTHDATE_MM), person.get(Person.BIRTHDATE_YYYY), person.get(Person.PRESENT_CONDITION), person.get(Person.DEATH_DATE), person.get(Person.BURIAL_DATE), person.get(Person.BURIAL_CONDUCTOR), person.get(Person.BURIAL_PLACE_DESCRIPTION), joins.getAddressRegion().get(Region.NAME), joins.getAddressDistrict().get(District.NAME), joins.getAddressCommunity().get(Community.NAME), address.get(Location.CITY), address.get(Location.STREET), address.get(Location.HOUSE_NUMBER), address.get(Location.ADDITIONAL_INFORMATION), address.get(Location.POSTAL_CODE), personQueryContext.getSubqueryExpression(PersonQueryContext.PERSON_PHONE_SUBQUERY), personQueryContext.getSubqueryExpression(PersonQueryContext.PERSON_EMAIL_SUBQUERY), resultingCase.get(Case.UUID), person.get(Person.BIRTH_NAME), birthCountry.get(Country.ISO_CODE), birthCountry.get(Country.DEFAULT_NAME), citizenship.get(Country.ISO_CODE), citizenship.get(Country.DEFAULT_NAME), eventParticipant.get(EventParticipant.VACCINATION_STATUS));
Predicate filter = service.buildCriteriaFilter(eventParticipantCriteria, eventParticipantQueryContext);
filter = CriteriaBuilderHelper.andInValues(selectedRows, filter, cb, eventParticipant.get(EventParticipant.UUID));
cq.where(filter);
List<EventParticipantExportDto> eventParticipantResultList = QueryHelper.getResultList(em, cq, first, max);
if (!eventParticipantResultList.isEmpty()) {
Map<String, Long> eventParticipantContactCount = getContactCountPerEventParticipant(eventParticipantResultList.stream().map(EventParticipantExportDto::getEventParticipantUuid).collect(Collectors.toList()), eventParticipantCriteria);
Map<Long, Location> personAddresses = null;
if (ExportHelper.shouldExportFields(exportConfiguration, PersonDto.ADDRESS, CaseExportDto.ADDRESS_GPS_COORDINATES)) {
CriteriaQuery<Location> personAddressesCq = cb.createQuery(Location.class);
Root<Location> personAddressesRoot = personAddressesCq.from(Location.class);
Expression<String> personAddressesIdsExpr = personAddressesRoot.get(Location.ID);
personAddressesCq.where(personAddressesIdsExpr.in(eventParticipantResultList.stream().map(EventParticipantExportDto::getPersonAddressId).collect(Collectors.toList())));
List<Location> personAddressesList = em.createQuery(personAddressesCq).setHint(ModelConstants.HINT_HIBERNATE_READ_ONLY, true).getResultList();
personAddresses = personAddressesList.stream().collect(Collectors.toMap(Location::getId, Function.identity()));
}
Map<Long, List<Sample>> samples = null;
if (ExportHelper.shouldExportFields(exportConfiguration, EventParticipantExportDto.SAMPLE_INFORMATION)) {
List<Sample> samplesList = null;
CriteriaQuery<Sample> samplesCq = cb.createQuery(Sample.class);
Root<Sample> samplesRoot = samplesCq.from(Sample.class);
Join<Sample, EventParticipant> samplesEventParticipantJoin = samplesRoot.join(Sample.ASSOCIATED_EVENT_PARTICIPANT, JoinType.LEFT);
Expression<String> eventParticipantIdsExpr = samplesEventParticipantJoin.get(EventParticipant.ID);
samplesCq.where(eventParticipantIdsExpr.in(eventParticipantResultList.stream().map(EventParticipantExportDto::getId).collect(Collectors.toList())));
samplesList = em.createQuery(samplesCq).setHint(ModelConstants.HINT_HIBERNATE_READ_ONLY, true).getResultList();
samples = samplesList.stream().collect(Collectors.groupingBy(s -> s.getAssociatedEventParticipant().getId()));
}
Map<Long, List<Immunization>> immunizations = null;
if (exportConfiguration == null || exportConfiguration.getProperties().stream().anyMatch(p -> StringUtils.equalsAny(p, ExportHelper.getVaccinationExportProperties()))) {
List<Immunization> immunizationList;
CriteriaQuery<Immunization> immunizationsCq = cb.createQuery(Immunization.class);
Root<Immunization> immunizationsCqRoot = immunizationsCq.from(Immunization.class);
Join<Immunization, Person> personJoin = immunizationsCqRoot.join(Immunization.PERSON, JoinType.LEFT);
Expression<String> personIdsExpr = personJoin.get(Person.ID);
immunizationsCq.where(CriteriaBuilderHelper.and(cb, cb.or(cb.equal(immunizationsCqRoot.get(Immunization.MEANS_OF_IMMUNIZATION), MeansOfImmunization.VACCINATION), cb.equal(immunizationsCqRoot.get(Immunization.MEANS_OF_IMMUNIZATION), MeansOfImmunization.VACCINATION_RECOVERY)), personIdsExpr.in(eventParticipantResultList.stream().map(EventParticipantExportDto::getPersonId).collect(Collectors.toList()))));
immunizationList = em.createQuery(immunizationsCq).setHint(ModelConstants.HINT_HIBERNATE_READ_ONLY, true).getResultList();
immunizations = immunizationList.stream().collect(Collectors.groupingBy(i -> i.getPerson().getId()));
}
Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight, I18nProperties.getCaption(Captions.inaccessibleValue));
for (EventParticipantExportDto exportDto : eventParticipantResultList) {
final boolean inJurisdiction = exportDto.getInJurisdiction();
if (personAddresses != null) {
Optional.ofNullable(personAddresses.get(exportDto.getPersonAddressId())).ifPresent(personAddress -> exportDto.setAddressGpsCoordinates(personAddress.buildGpsCoordinatesCaption()));
}
if (samples != null) {
Optional.ofNullable(samples.get(exportDto.getId())).ifPresent(eventParticipantSamples -> {
int count = 0;
for (Sample sample : eventParticipantSamples) {
EmbeddedSampleExportDto sampleDto = new EmbeddedSampleExportDto(sample.getUuid(), sample.getSampleDateTime(), sample.getLab() != null ? FacilityHelper.buildFacilityString(sample.getLab().getUuid(), sample.getLab().getName(), sample.getLabDetails()) : null, sample.getPathogenTestResult());
exportDto.addEventParticipantSample(sampleDto);
}
});
}
if (immunizations != null) {
Optional.ofNullable(immunizations.get(exportDto.getPersonId())).ifPresent(epImmunizations -> {
List<Immunization> filteredImmunizations = epImmunizations.stream().filter(i -> i.getDisease() == exportDto.getEventDisease()).collect(Collectors.toList());
filteredImmunizations.sort(Comparator.comparing(i -> ImmunizationEntityHelper.getDateForComparison(i, false)));
Immunization mostRecentImmunization = filteredImmunizations.get(filteredImmunizations.size() - 1);
exportDto.setVaccinationDoses(String.valueOf(mostRecentImmunization.getNumberOfDoses()));
if (CollectionUtils.isNotEmpty(mostRecentImmunization.getVaccinations())) {
List<Vaccination> sortedVaccinations = mostRecentImmunization.getVaccinations().stream().sorted(Comparator.comparing(ImmunizationEntityHelper::getVaccinationDateForComparison)).collect(Collectors.toList());
Vaccination firstVaccination = sortedVaccinations.get(0);
Vaccination lastVaccination = sortedVaccinations.get(sortedVaccinations.size() - 1);
exportDto.setFirstVaccinationDate(firstVaccination.getVaccinationDate());
exportDto.setLastVaccinationDate(lastVaccination.getVaccinationDate());
exportDto.setVaccineName(lastVaccination.getVaccineName());
exportDto.setOtherVaccineName(lastVaccination.getOtherVaccineName());
exportDto.setVaccineManufacturer(lastVaccination.getVaccineManufacturer());
exportDto.setOtherVaccineManufacturer(lastVaccination.getOtherVaccineManufacturer());
exportDto.setVaccinationInfoSource(lastVaccination.getVaccinationInfoSource());
exportDto.setVaccineAtcCode(lastVaccination.getVaccineAtcCode());
exportDto.setVaccineBatchNumber(lastVaccination.getVaccineBatchNumber());
exportDto.setVaccineUniiCode(lastVaccination.getVaccineUniiCode());
exportDto.setVaccineInn(lastVaccination.getVaccineInn());
}
});
}
Optional.ofNullable(eventParticipantContactCount.get(exportDto.getEventParticipantUuid())).ifPresent(exportDto::setContactCount);
pseudonymizer.pseudonymizeDto(EventParticipantExportDto.class, exportDto, inJurisdiction, (c) -> {
pseudonymizer.pseudonymizeDto(BirthDateDto.class, c.getBirthdate(), inJurisdiction, null);
pseudonymizer.pseudonymizeDtoCollection(EmbeddedSampleExportDto.class, c.getEventParticipantSamples(), s -> inJurisdiction, null);
pseudonymizer.pseudonymizeDto(BurialInfoDto.class, c.getBurialInfo(), inJurisdiction, null);
});
}
}
return eventParticipantResultList;
}
use of de.symeda.sormas.api.event.EventParticipantCriteria in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantFacadeEjbTest method testGetExportList.
@Test
public void testGetExportList() {
TestDataCreator.RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
EventDto event = creator.createEvent(EventStatus.SIGNAL, EventInvestigationStatus.PENDING, "Title", "Description", "First", "Name", "12345", TypeOfPlace.PUBLIC_PLACE, DateHelper.subtractDays(new Date(), 1), new Date(), user.toReference(), user.toReference(), Disease.EVD, rdcf.district);
PersonDto eventPerson = creator.createPerson("Event", "Organizer");
creator.createEventParticipant(event.toReference(), eventPerson, "event Director", user.toReference());
PersonDto eventPerson1 = creator.createPerson("Event", "Participant");
creator.createEventParticipant(event.toReference(), eventPerson1, "event fan", user.toReference());
ImmunizationDto immunization = creator.createImmunization(event.getDisease(), eventPerson.toReference(), event.getReportingUser(), ImmunizationStatus.ACQUIRED, MeansOfImmunization.VACCINATION, ImmunizationManagementStatus.COMPLETED, rdcf, DateHelper.subtractDays(new Date(), 10), DateHelper.subtractDays(new Date(), 5), DateHelper.subtractDays(new Date(), 1), null);
creator.createImmunization(event.getDisease(), eventPerson.toReference(), event.getReportingUser(), ImmunizationStatus.ACQUIRED, MeansOfImmunization.VACCINATION, ImmunizationManagementStatus.COMPLETED, rdcf, DateHelper.subtractDays(new Date(), 8), DateHelper.subtractDays(new Date(), 7), null, null);
VaccinationDto firstVaccination = creator.createVaccination(event.getReportingUser(), immunization.toReference(), HealthConditionsDto.build(), DateHelper.subtractDays(new Date(), 7), Vaccine.OXFORD_ASTRA_ZENECA, VaccineManufacturer.ASTRA_ZENECA);
creator.createVaccination(event.getReportingUser(), immunization.toReference(), HealthConditionsDto.build(), DateHelper.subtractDays(new Date(), 4), Vaccine.MRNA_1273, VaccineManufacturer.MODERNA);
VaccinationDto thirdVaccination = creator.createVaccination(event.getReportingUser(), immunization.toReference(), HealthConditionsDto.build(), new Date(), Vaccine.COMIRNATY, VaccineManufacturer.BIONTECH_PFIZER);
EventParticipantCriteria eventParticipantCriteria = new EventParticipantCriteria();
eventParticipantCriteria.withEvent(event.toReference());
List<EventParticipantExportDto> results = getEventParticipantFacade().getExportList(eventParticipantCriteria, Collections.emptySet(), 0, 100, Language.EN, null);
// List should have two entries
assertThat(results, Matchers.hasSize(2));
assertEquals(VaccinationStatus.VACCINATED, results.get(0).getVaccinationStatus());
assertEquals(thirdVaccination.getVaccineName(), results.get(0).getVaccineName());
assertEquals(firstVaccination.getVaccinationDate(), results.get(0).getFirstVaccinationDate());
assertEquals(thirdVaccination.getVaccinationDate(), results.get(0).getLastVaccinationDate());
}
use of de.symeda.sormas.api.event.EventParticipantCriteria in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantImporterTest method testImportEventParticipantSimilarityCreate.
@Test
public void testImportEventParticipantSimilarityCreate() throws IOException, InvalidColumnException, InterruptedException, CsvValidationException, URISyntaxException {
EventParticipantFacadeEjbLocal eventParticipantFacade = getBean(EventParticipantFacadeEjbLocal.class);
RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
EventDto event = creator.createEvent(EventStatus.SIGNAL, "Title", "Description", "First", "Name", "12345", TypeOfPlace.PUBLIC_PLACE, DateHelper.subtractDays(new Date(), 2), new Date(), user.toReference(), user.toReference(), Disease.EVD);
EventReferenceDto eventRef = event.toReference();
PersonDto person = creator.createPerson("Günther", "Heinze");
creator.createCase(user.toReference(), person.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
// Person Similarity: create
File csvFile = new File(getClass().getClassLoader().getResource("sormas_eventparticipant_import_test_similarities.csv").toURI());
EventParticipantImporterExtension eventParticipantImporter = new EventParticipantImporterExtension(csvFile, user, event);
ImportResultStatus importResult = eventParticipantImporter.runImport();
EventParticipantIndexDto importedEventParticipant = eventParticipantFacade.getIndexList(new EventParticipantCriteria().withEvent(eventRef), null, null, null).get(0);
assertEquals(ImportResultStatus.COMPLETED, importResult);
assertEquals(1, eventParticipantFacade.count(new EventParticipantCriteria().withEvent(eventRef)));
assertNotEquals(person.getUuid(), importedEventParticipant.getPersonUuid());
assertEquals(2, getPersonFacade().getAllUuids().size());
}
Aggregations