use of de.symeda.sormas.api.sormastosormas.immunization.SormasToSormasImmunizationDto in project SORMAS-Project by hzi-braunschweig.
the class ReceivedImmunizationProcessor method handleReceivedData.
@Override
public void handleReceivedData(SormasToSormasImmunizationDto sharedData, Immunization existingData) {
updateReportingUser(sharedData.getEntity(), existingData);
handleIgnoredProperties(sharedData.getEntity(), immunizationFacadeEjb.toDto(existingData));
ImmunizationDto im = sharedData.getEntity();
im.getVaccinations().forEach(vaccination -> {
Vaccination existingVaccination;
if (existingData == null) {
existingVaccination = null;
} else {
existingVaccination = existingData.getVaccinations().stream().filter(v -> v.getUuid().equals(vaccination.getUuid())).findFirst().orElse(null);
}
UserReferenceDto reportingUser;
if (existingVaccination == null) {
reportingUser = userService.getCurrentUser().toReference();
} else {
reportingUser = existingVaccination.getReportingUser().toReference();
}
vaccination.setReportingUser(reportingUser);
});
}
use of de.symeda.sormas.api.sormastosormas.immunization.SormasToSormasImmunizationDto in project SORMAS-Project by hzi-braunschweig.
the class SormasToSormasImmunizationDtoValidator method validate.
@Override
public ValidationErrors validate(SormasToSormasImmunizationDto sharedData, ValidationDirection direction) {
final ImmunizationDto im = sharedData.getEntity();
ValidationErrors validationErrors = new ValidationErrors(buildImmunizationValidationGroupName(im));
final String groupNameTag = Captions.Immunization;
infraValidator.validateCountry(im.getCountry(), groupNameTag, validationErrors, im::setCountry, direction);
infraValidator.validateResponsibleRegion(im.getResponsibleRegion(), groupNameTag, validationErrors, im::setResponsibleRegion, direction);
infraValidator.validateResponsibleDistrict(im.getResponsibleDistrict(), groupNameTag, validationErrors, im::setResponsibleDistrict, direction);
infraValidator.validateResponsibleCommunity(im.getResponsibleCommunity(), groupNameTag, validationErrors, im::setResponsibleCommunity, direction);
infraValidator.validateFacility(im.getHealthFacility(), im.getFacilityType(), im.getHealthFacilityDetails(), groupNameTag, validationErrors, f -> {
im.setHealthFacility(f.getEntity());
im.setHealthFacilityDetails(f.getDetails());
});
return validationErrors;
}
use of de.symeda.sormas.api.sormastosormas.immunization.SormasToSormasImmunizationDto in project SORMAS-Project by hzi-braunschweig.
the class ImmunizationShareDataBuilder method doBuildShareData.
@Override
protected SormasToSormasImmunizationDto doBuildShareData(Immunization immunization, ShareRequestInfo requestInfo) {
Pseudonymizer pseudonymizer = dataBuilderHelper.createPseudonymizer(requestInfo.isPseudonymizedPersonalData(), requestInfo.isPseudonymizedSensitiveData());
ImmunizationDto immunizationDto = immunizationFacade.convertToDto(immunization, pseudonymizer);
immunizationDto.setReportingUser(null);
immunizationDto.setSormasToSormasOriginInfo(null);
dataBuilderHelper.clearIgnoredProperties(immunizationDto);
return new SormasToSormasImmunizationDto(immunizationDto);
}
use of de.symeda.sormas.api.sormastosormas.immunization.SormasToSormasImmunizationDto in project SORMAS-Project by hzi-braunschweig.
the class InfraValidationSoundnessTest method testShareImmunizationValidation.
@Test
public void testShareImmunizationValidation() throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchFieldException {
class ImmunizationDtoRootNode extends DtoRootNode<SormasToSormasImmunizationDto> {
public ImmunizationDtoRootNode(SormasToSormasImmunizationDto dtoUnderTest) {
super(dtoUnderTest);
}
}
class ImmunizationPreviewRootNode extends DtoRootNode<PreviewNotImplementedDto> {
// todo add test once preview is available for this entity
public ImmunizationPreviewRootNode(PreviewNotImplementedDto dtoUnderTest) {
super(dtoUnderTest);
}
}
before();
SormasToSormasImmunizationDto immunizationDto = new SormasToSormasImmunizationDto();
ImmunizationDtoRootNode rootNode = new ImmunizationDtoRootNode(immunizationDto);
assertValidationDto(immunizationDto, rootNode, immunizationDtoValidator);
}
use of de.symeda.sormas.api.sormastosormas.immunization.SormasToSormasImmunizationDto in project SORMAS-Project by hzi-braunschweig.
the class ProcessedEntitiesPersister method persistSharedData.
public void persistSharedData(SormasToSormasDto processedData, SormasToSormasOriginInfoDto originInfo, ShareDataExistingEntities existingEntities) throws SormasToSormasValidationException {
List<SormasToSormasCaseDto> cases = processedData.getCases();
if (CollectionUtils.isNotEmpty(cases)) {
for (SormasToSormasCaseDto c : cases) {
caseDataPersister.persistSharedData(c, originInfo, existingEntities.getCases().get(c.getEntity().getUuid()));
}
}
List<SormasToSormasContactDto> contacts = processedData.getContacts();
if (CollectionUtils.isNotEmpty(contacts)) {
for (SormasToSormasContactDto c : contacts) {
contactDataPersister.persistSharedData(c, originInfo, existingEntities.getContacts().get(c.getEntity().getUuid()));
}
}
List<SormasToSormasEventDto> events = processedData.getEvents();
if (CollectionUtils.isNotEmpty(events)) {
for (SormasToSormasEventDto e : events) {
eventDataPersister.persistSharedData(e, originInfo, existingEntities.getEvents().get(e.getEntity().getUuid()));
}
}
List<SormasToSormasEventParticipantDto> eventParticipants = processedData.getEventParticipants();
if (CollectionUtils.isNotEmpty(eventParticipants)) {
for (SormasToSormasEventParticipantDto ep : eventParticipants) {
eventParticipantDataPersister.persistSharedData(ep, originInfo, existingEntities.getEventParticipants().get(ep.getEntity().getUuid()));
}
}
List<SormasToSormasSampleDto> samples = processedData.getSamples();
if (CollectionUtils.isNotEmpty(samples)) {
for (SormasToSormasSampleDto s : samples) {
sampleDataPersister.persistSharedData(s, originInfo, existingEntities.getSamples().get(s.getEntity().getUuid()));
}
}
List<SormasToSormasImmunizationDto> immunizations = processedData.getImmunizations();
if (CollectionUtils.isNotEmpty(immunizations)) {
for (SormasToSormasImmunizationDto s : immunizations) {
immunizationDataPersister.persistSharedData(s, originInfo, existingEntities.getImmunizations().get(s.getEntity().getUuid()));
}
}
}
Aggregations