Search in sources :

Example 1 with SormasToSormasImmunizationDto

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);
    });
}
Also used : Stateless(javax.ejb.Stateless) Validations(de.symeda.sormas.api.i18n.Validations) ValidationErrors(de.symeda.sormas.api.sormastosormas.validation.ValidationErrors) SormasToSormasImmunizationDto(de.symeda.sormas.api.sormastosormas.immunization.SormasToSormasImmunizationDto) Immunization(de.symeda.sormas.backend.immunization.entity.Immunization) ImmunizationService(de.symeda.sormas.backend.immunization.ImmunizationService) Captions(de.symeda.sormas.api.i18n.Captions) ImmunizationFacadeEjb(de.symeda.sormas.backend.immunization.ImmunizationFacadeEjb) Inject(javax.inject.Inject) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) UserService(de.symeda.sormas.backend.user.UserService) ReceivedDataProcessor(de.symeda.sormas.backend.sormastosormas.data.received.ReceivedDataProcessor) LocalBean(javax.ejb.LocalBean) Vaccination(de.symeda.sormas.backend.vaccination.Vaccination) ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) PreviewNotImplementedDto(de.symeda.sormas.api.sormastosormas.sharerequest.PreviewNotImplementedDto) EJB(javax.ejb.EJB) ConfigFacadeEjb(de.symeda.sormas.backend.common.ConfigFacadeEjb) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) SormasToSormasImmunizationDto(de.symeda.sormas.api.sormastosormas.immunization.SormasToSormasImmunizationDto) ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) Vaccination(de.symeda.sormas.backend.vaccination.Vaccination)

Example 2 with SormasToSormasImmunizationDto

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;
}
Also used : SormasToSormasImmunizationDto(de.symeda.sormas.api.sormastosormas.immunization.SormasToSormasImmunizationDto) ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) ValidationErrors(de.symeda.sormas.api.sormastosormas.validation.ValidationErrors)

Example 3 with SormasToSormasImmunizationDto

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);
}
Also used : SormasToSormasImmunizationDto(de.symeda.sormas.api.sormastosormas.immunization.SormasToSormasImmunizationDto) ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) Pseudonymizer(de.symeda.sormas.backend.util.Pseudonymizer) SormasToSormasImmunizationDto(de.symeda.sormas.api.sormastosormas.immunization.SormasToSormasImmunizationDto)

Example 4 with SormasToSormasImmunizationDto

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);
}
Also used : PreviewNotImplementedDto(de.symeda.sormas.api.sormastosormas.sharerequest.PreviewNotImplementedDto) SormasToSormasImmunizationDto(de.symeda.sormas.api.sormastosormas.immunization.SormasToSormasImmunizationDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 5 with SormasToSormasImmunizationDto

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()));
        }
    }
}
Also used : SormasToSormasEventDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto) SormasToSormasEventParticipantDto(de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventParticipantDto) SormasToSormasSampleDto(de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto) SormasToSormasContactDto(de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto) SormasToSormasCaseDto(de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto) SormasToSormasImmunizationDto(de.symeda.sormas.api.sormastosormas.immunization.SormasToSormasImmunizationDto)

Aggregations

SormasToSormasImmunizationDto (de.symeda.sormas.api.sormastosormas.immunization.SormasToSormasImmunizationDto)9 ImmunizationDto (de.symeda.sormas.api.immunization.ImmunizationDto)4 SormasToSormasCaseDto (de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto)4 SormasToSormasContactDto (de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto)4 SormasToSormasEventDto (de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventDto)4 SormasToSormasEventParticipantDto (de.symeda.sormas.api.sormastosormas.event.SormasToSormasEventParticipantDto)4 SormasToSormasSampleDto (de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto)4 ValidationErrors (de.symeda.sormas.api.sormastosormas.validation.ValidationErrors)4 PreviewNotImplementedDto (de.symeda.sormas.api.sormastosormas.sharerequest.PreviewNotImplementedDto)2 ArrayList (java.util.ArrayList)2 Captions (de.symeda.sormas.api.i18n.Captions)1 Validations (de.symeda.sormas.api.i18n.Validations)1 SormasToSormasDto (de.symeda.sormas.api.sormastosormas.SormasToSormasDto)1 SormasToSormasOriginInfoDto (de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto)1 SormasToSormasValidationException (de.symeda.sormas.api.sormastosormas.validation.SormasToSormasValidationException)1 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)1 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)1 ConfigFacadeEjb (de.symeda.sormas.backend.common.ConfigFacadeEjb)1 ImmunizationFacadeEjb (de.symeda.sormas.backend.immunization.ImmunizationFacadeEjb)1 ImmunizationService (de.symeda.sormas.backend.immunization.ImmunizationService)1