use of de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto in project SORMAS-Project by hzi-braunschweig.
the class EventShareDataBuilder method doBuildShareData.
@Override
protected SormasToSormasEventDto doBuildShareData(Event data, ShareRequestInfo requestInfo) {
Pseudonymizer pseudonymizer = dataBuilderHelper.createPseudonymizer(requestInfo.isPseudonymizedPersonalData(), requestInfo.isPseudonymizedSensitiveData());
EventDto eventDto = getEventDto(data, pseudonymizer);
return new SormasToSormasEventDto(eventDto);
}
use of de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto in project SORMAS-Project by hzi-braunschweig.
the class SormasToSormasEventFacadeEjbTest method testSaveSharedEventsWithParticipants.
@Test
public void testSaveSharedEventsWithParticipants() throws SormasToSormasException, SormasToSormasValidationException {
EventDto event = createEventDto(rdcf);
EventParticipantDto eventParticipant = createEventParticipantDto(event.toReference(), UserDto.build().toReference(), rdcf);
SormasToSormasDto shareData = new SormasToSormasDto();
shareData.setOriginInfo(createSormasToSormasOriginInfo(DEFAULT_SERVER_ID, false));
shareData.setEvents(Collections.singletonList(new SormasToSormasEventDto(event)));
shareData.setEventParticipants(Collections.singletonList(new SormasToSormasEventParticipantDto(eventParticipant)));
SormasToSormasEncryptedDataDto encryptedData = encryptShareData(shareData);
getSormasToSormasEventFacade().saveSharedEntities(encryptedData);
EventParticipantDto savedParticipant = getEventParticipantFacade().getEventParticipantByUuid(eventParticipant.getUuid());
assertThat(savedParticipant, is(notNullValue()));
assertThat(savedParticipant.getPerson(), is(notNullValue()));
assertThat(savedParticipant.getPerson().getFirstName(), is("John"));
assertThat(savedParticipant.getPerson().getLastName(), is("Smith"));
assertThat(savedParticipant.getPerson().getAddress().getRegion(), is(rdcf.region));
assertThat(savedParticipant.getPerson().getAddress().getDistrict(), is(rdcf.district));
assertThat(savedParticipant.getSormasToSormasOriginInfo().getOrganizationId(), is(DEFAULT_SERVER_ID));
assertThat(savedParticipant.getSormasToSormasOriginInfo().getSenderName(), is("John doe"));
}
use of de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto in project SORMAS-Project by hzi-braunschweig.
the class SormasToSormasEventFacadeEjbTest method testSaveSharedEventsWithSamples.
@Test
public void testSaveSharedEventsWithSamples() throws SormasToSormasException, SormasToSormasValidationException {
FacilityDto remoteLab = FacilityDto.build();
remoteLab.setName("Test Lab");
FacilityDto localLab = creator.createFacility("Test Lab", rdcf.region, rdcf.district, null, FacilityType.LABORATORY);
EventDto event = createEventDto(rdcf);
UserDto sampleUser = UserDto.build();
EventParticipantDto eventParticipant = createEventParticipantDto(event.toReference(), sampleUser.toReference(), rdcf);
SampleDto sample = createSample(eventParticipant.toReference(), sampleUser.toReference(), remoteLab.toReference());
sample.setLabSampleID("Test lab sample id");
PathogenTestDto pathogenTest = PathogenTestDto.build(sample, sampleUser);
pathogenTest.setTestDateTime(new Date());
pathogenTest.setLab(remoteLab.toReference());
pathogenTest.setTestType(PathogenTestType.RAPID_TEST);
pathogenTest.setTestResult(PathogenTestResultType.PENDING);
AdditionalTestDto additionalTest = AdditionalTestDto.build(sample.toReference());
additionalTest.setTestDateTime(new Date());
additionalTest.setHaemoglobin(0.2F);
additionalTest.setConjBilirubin(0.3F);
SormasToSormasDto shareData = new SormasToSormasDto();
shareData.setOriginInfo(createSormasToSormasOriginInfo(DEFAULT_SERVER_ID, false));
shareData.setEvents(Collections.singletonList(new SormasToSormasEventDto(event)));
shareData.setEventParticipants(Collections.singletonList(new SormasToSormasEventParticipantDto(eventParticipant)));
shareData.setSamples(Collections.singletonList(new SormasToSormasSampleDto(sample, Collections.singletonList(pathogenTest), Collections.singletonList(additionalTest))));
SormasToSormasEncryptedDataDto encryptedData = encryptShareData(shareData);
getSormasToSormasEventFacade().saveSharedEntities(encryptedData);
SampleDto savedSample = getSampleFacade().getSampleByUuid(sample.getUuid());
assertThat(savedSample, is(notNullValue()));
assertThat(savedSample.getAssociatedEventParticipant(), is(eventParticipant.toReference()));
assertThat(savedSample.getSampleMaterial(), is(SampleMaterial.BLOOD));
assertThat(savedSample.getLab(), is(localLab.toReference()));
assertThat(savedSample.getLabSampleID(), is("Test lab sample id"));
assertThat(savedSample.getSormasToSormasOriginInfo().getOrganizationId(), is(DEFAULT_SERVER_ID));
assertThat(savedSample.getSormasToSormasOriginInfo().getSenderName(), is("John doe"));
PathogenTestDto savedPathogenTest = getPathogenTestFacade().getByUuid(pathogenTest.getUuid());
assertThat(savedPathogenTest, is(notNullValue()));
assertThat(savedPathogenTest.getLab(), is(localLab.toReference()));
assertThat(savedPathogenTest.getTestType(), is(PathogenTestType.RAPID_TEST));
assertThat(savedPathogenTest.getTestResult(), is(PathogenTestResultType.PENDING));
AdditionalTestDto savedAdditionalTest = getAdditionalTestFacade().getByUuid(additionalTest.getUuid());
assertThat(savedAdditionalTest, is(notNullValue()));
assertThat(savedAdditionalTest.getHaemoglobin(), is(0.2F));
assertThat(savedAdditionalTest.getConjBilirubin(), is(0.3F));
}
use of de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto in project SORMAS-Project by hzi-braunschweig.
the class SormasToSormasEventFacadeEjbTest method testSaveReturnedEvent.
@Test
public void testSaveReturnedEvent() throws SormasToSormasException, SormasToSormasValidationException {
UserReferenceDto officer = creator.createUser(rdcf, UserRole.SURVEILLANCE_OFFICER).toReference();
EventDto event = creator.createEvent(officer);
EventParticipantDto eventParticipant = creator.createEventParticipant(event.toReference(), creator.createPerson(), officer);
EventParticipantDto newEventParticipant = createEventParticipantDto(event.toReference(), UserDto.build().toReference(), rdcf);
FacilityDto lab = creator.createFacility("Test Lab", rdcf.region, rdcf.district, null, FacilityType.LABORATORY);
SampleDto newSample = createSample(newEventParticipant.toReference(), officer, lab.toReference());
User officerUser = getUserService().getByReferenceDto(officer);
ShareRequestInfo shareRequestInfo = createShareRequestInfo(officerUser, DEFAULT_SERVER_ID, true, i -> i.setEvent(getEventService().getByReferenceDto(event.toReference())));
shareRequestInfo.setWithEventParticipants(true);
shareRequestInfo.getShares().add(createShareInfo(DEFAULT_SERVER_ID, true, i -> i.setEventParticipant(getEventParticipantService().getByReferenceDto(eventParticipant.toReference()))));
getShareRequestInfoService().persist(shareRequestInfo);
event.setEventDesc("Test updated description");
eventParticipant.getPerson().setBirthName("Test birth name");
Calendar calendar = Calendar.getInstance();
calendar.setTime(event.getChangeDate());
calendar.add(Calendar.DAY_OF_MONTH, 1);
event.setChangeDate(calendar.getTime());
SormasToSormasDto shareData = new SormasToSormasDto();
shareData.setOriginInfo(createSormasToSormasOriginInfo(DEFAULT_SERVER_ID, true));
shareData.setEvents(Collections.singletonList(new SormasToSormasEventDto(event)));
shareData.setEventParticipants(Arrays.asList(new SormasToSormasEventParticipantDto(eventParticipant), new SormasToSormasEventParticipantDto(newEventParticipant)));
shareData.setSamples(Collections.singletonList(new SormasToSormasSampleDto(newSample, Collections.emptyList(), Collections.emptyList())));
SormasToSormasEncryptedDataDto encryptedData = encryptShareData(shareData);
getSormasToSormasEventFacade().saveSharedEntities(encryptedData);
EventDto returnedEvent = getEventFacade().getEventByUuid(event.getUuid(), false);
assertThat(returnedEvent.getEventDesc(), is("Test updated description"));
assertThat(returnedEvent.getReportingUser(), is(officer));
List<SormasToSormasShareInfoDto> eventShares = getSormasToSormasShareInfoFacade().getIndexList(new SormasToSormasShareInfoCriteria().event(event.toReference()), 0, 100);
assertThat(eventShares.get(0).isOwnershipHandedOver(), is(false));
assertThat(getEventParticipantFacade().getEventParticipantByUuid(eventParticipant.getUuid()).getPerson().getBirthName(), is("Test birth name"));
List<SormasToSormasShareInfoDto> eventParticipantShares = getSormasToSormasShareInfoFacade().getIndexList(new SormasToSormasShareInfoCriteria().eventParticipant(eventParticipant.toReference()), 0, 100);
assertThat(eventParticipantShares.get(0).isOwnershipHandedOver(), is(false));
EventParticipantDto returnedNewEventParticipant = getEventParticipantFacade().getEventParticipantByUuid(newEventParticipant.getUuid());
assertThat(returnedNewEventParticipant.getSormasToSormasOriginInfo().isOwnershipHandedOver(), is(true));
SampleDto returnedNewSample = getSampleFacade().getSampleByUuid(newSample.getUuid());
assertThat(returnedNewSample.getSormasToSormasOriginInfo().isOwnershipHandedOver(), is(true));
}
use of de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto in project SORMAS-Project by hzi-braunschweig.
the class SormasToSormasEventFacadeEjbTest method testSaveSharedEvents.
@Test
public void testSaveSharedEvents() throws SormasToSormasException, SormasToSormasValidationException {
EventDto event = createEventDto(rdcf);
event.setEventDesc("Test description");
event.setEventStatus(EventStatus.SCREENING);
event.setEventInvestigationStatus(EventInvestigationStatus.ONGOING);
event.setRiskLevel(RiskLevel.MODERATE);
event.setMultiDayEvent(true);
Date dateNow = new Date();
event.setStartDate(dateNow);
event.setEndDate(dateNow);
event.setSrcType(EventSourceType.MEDIA_NEWS);
event.setSrcMediaWebsite("Test media name");
event.setSrcMediaName("Test media website");
event.setSrcMediaDetails("Test media details");
SormasToSormasDto shareData = new SormasToSormasDto();
shareData.setOriginInfo(createSormasToSormasOriginInfo(DEFAULT_SERVER_ID, false));
shareData.setEvents(Collections.singletonList(new SormasToSormasEventDto(event)));
SormasToSormasEncryptedDataDto encryptedData = encryptShareData(shareData);
getSormasToSormasEventFacade().saveSharedEntities(encryptedData);
EventDto savedEvent = getEventFacade().getEventByUuid(event.getUuid(), false);
assertThat(savedEvent, is(notNullValue()));
assertThat(savedEvent.getEventTitle(), is("Test event title"));
assertThat(savedEvent.getEventDesc(), is("Test description"));
assertThat(savedEvent.getEventStatus(), is(EventStatus.SCREENING));
assertThat(savedEvent.getEventInvestigationStatus(), is(EventInvestigationStatus.ONGOING));
assertThat(savedEvent.getRiskLevel(), is(RiskLevel.MODERATE));
assertThat(savedEvent.isMultiDayEvent(), is(true));
assertThat(savedEvent.getStartDate().getTime(), is(dateNow.getTime()));
assertThat(savedEvent.getEndDate().getTime(), is(dateNow.getTime()));
assertThat(savedEvent.getSrcType(), is(EventSourceType.MEDIA_NEWS));
assertThat(savedEvent.getSrcMediaWebsite(), is("Test media name"));
assertThat(savedEvent.getSrcMediaName(), is("Test media website"));
assertThat(savedEvent.getSrcMediaDetails(), is("Test media details"));
assertThat(savedEvent.getEventLocation().getRegion(), is(rdcf.region));
assertThat(savedEvent.getEventLocation().getDistrict(), is(rdcf.district));
assertThat(savedEvent.getSormasToSormasOriginInfo().getOrganizationId(), is(DEFAULT_SERVER_ID));
assertThat(savedEvent.getSormasToSormasOriginInfo().getSenderName(), is("John doe"));
}
Aggregations