Search in sources :

Example 1 with SormasToSormasCaseDto

use of de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto in project SORMAS-Project by hzi-braunschweig.

the class CaseShareDataBuilder method doBuildShareData.

@Override
protected SormasToSormasCaseDto doBuildShareData(Case caze, ShareRequestInfo requestInfo) {
    Pseudonymizer pseudonymizer = dataBuilderHelper.createPseudonymizer(requestInfo.isPseudonymizedPersonalData(), requestInfo.isPseudonymizedSensitiveData());
    PersonDto personDto = dataBuilderHelper.getPersonDto(caze.getPerson(), pseudonymizer, requestInfo.isPseudonymizedPersonalData(), requestInfo.isPseudonymizedSensitiveData());
    CaseDataDto cazeDto = getCazeDto(caze, pseudonymizer);
    dataBuilderHelper.clearIgnoredProperties(cazeDto);
    return new SormasToSormasCaseDto(personDto, cazeDto);
}
Also used : Pseudonymizer(de.symeda.sormas.backend.util.Pseudonymizer) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) SormasToSormasCaseDto(de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto)

Example 2 with SormasToSormasCaseDto

use of de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto in project SORMAS-Project by hzi-braunschweig.

the class SormasToSormasCaseFacadeEjbTest method testSaveSharedCaseWithContacts.

@Test
public void testSaveSharedCaseWithContacts() throws SormasToSormasException, SormasToSormasValidationException {
    PersonDto person = createPersonDto(rdcf);
    CaseDataDto caze = createRemoteCaseDto(rdcf, person);
    ContactDto contact = createRemoteContactDto(rdcf, caze);
    PersonDto contactPerson = createPersonDto(rdcf);
    contact.setPerson(contactPerson.toReference());
    SormasToSormasDto shareData = new SormasToSormasDto();
    shareData.setOriginInfo(createSormasToSormasOriginInfo(DEFAULT_SERVER_ID, false));
    shareData.setCases(Collections.singletonList(new SormasToSormasCaseDto(person, caze)));
    shareData.setContacts(Collections.singletonList(new SormasToSormasContactDto(contactPerson, contact)));
    SormasToSormasEncryptedDataDto encryptedData = encryptShareData(shareData);
    getSormasToSormasCaseFacade().saveSharedEntities(encryptedData);
    CaseDataDto savedCase = getCaseFacade().getCaseDataByUuid(caze.getUuid());
    ContactDto savedContact = getContactFacade().getByUuid(contact.getUuid());
    assertThat(savedContact, is(notNullValue()));
    assertThat(savedContact.getRegion(), is(rdcf.region));
    assertThat(savedContact.getDistrict(), is(rdcf.district));
    assertThat(savedContact.getCommunity(), is(rdcf.community));
    assertThat(savedCase.getSormasToSormasOriginInfo().getUuid(), is(savedContact.getSormasToSormasOriginInfo().getUuid()));
}
Also used : SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) SormasToSormasContactDto(de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto) SormasToSormasContactDto(de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto) SormasToSormasCaseDto(de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Example 3 with SormasToSormasCaseDto

use of de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto in project SORMAS-Project by hzi-braunschweig.

the class SormasToSormasCaseFacadeEjbTest method testSaveSharedPointOfEntryCaseWithInfrastructureExternalId.

@Test
public void testSaveSharedPointOfEntryCaseWithInfrastructureExternalId() throws SormasToSormasException, SormasToSormasValidationException {
    PersonDto person = createPersonDto(rdcf);
    CaseDataDto caze = CaseDataDto.build(person.toReference(), Disease.CORONAVIRUS);
    caze.setCaseOrigin(CaseOrigin.POINT_OF_ENTRY);
    caze.setResponsibleRegion(rdcf.region);
    caze.setResponsibleDistrict(rdcf.district);
    caze.setResponsibleCommunity(rdcf.community);
    caze.setPointOfEntry(rdcf.pointOfEntry);
    PortHealthInfoDto portHealthInfo = PortHealthInfoDto.build();
    portHealthInfo.setAirlineName("Test Airline");
    caze.setPortHealthInfo(portHealthInfo);
    SormasToSormasDto shareData = new SormasToSormasDto();
    shareData.setOriginInfo(createSormasToSormasOriginInfo(DEFAULT_SERVER_ID, false));
    shareData.setCases(Collections.singletonList(new SormasToSormasCaseDto(person, caze)));
    SormasToSormasEncryptedDataDto encryptedData = encryptShareData(shareData);
    getSormasToSormasCaseFacade().saveSharedEntities(encryptedData);
    CaseDataDto savedCase = getCaseFacade().getCaseDataByUuid(caze.getUuid());
    assertThat(savedCase.getResponsibleRegion(), is(rdcf.region));
    assertThat(savedCase.getResponsibleDistrict(), is(rdcf.district));
    assertThat(savedCase.getResponsibleCommunity(), is(rdcf.community));
    assertThat(savedCase.getPointOfEntry(), is(rdcf.pointOfEntry));
    assertThat(savedCase.getPortHealthInfo().getAirlineName(), is("Test Airline"));
}
Also used : SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) PortHealthInfoDto(de.symeda.sormas.api.caze.porthealthinfo.PortHealthInfoDto) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) SormasToSormasCaseDto(de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Example 4 with SormasToSormasCaseDto

use of de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto in project SORMAS-Project by hzi-braunschweig.

the class SormasToSormasCaseFacadeEjbTest method testSaveSharedCaseWithInfrastructureExternalId.

@Test
public void testSaveSharedCaseWithInfrastructureExternalId() throws SormasToSormasException, SormasToSormasValidationException {
    PersonDto person = createPersonDto(rdcf);
    person.setFirstName("James");
    person.setLastName("Smith");
    CaseDataDto caze = createRemoteCaseDto(rdcf, person);
    caze.getHospitalization().setAdmittedToHealthFacility(YesNoUnknown.YES);
    caze.getSymptoms().setAgitation(SymptomState.YES);
    ExposureDto exposure = ExposureDto.build(ExposureType.ANIMAL_CONTACT);
    exposure.setAnimalContactType(AnimalContactType.TOUCH);
    caze.getEpiData().getExposures().add(exposure);
    caze.getHealthConditions().setAsplenia(YesNoUnknown.YES);
    caze.getMaternalHistory().setChildrenNumber(2);
    SormasToSormasDto shareData = new SormasToSormasDto();
    shareData.setOriginInfo(createSormasToSormasOriginInfo(DEFAULT_SERVER_ID, false));
    shareData.setCases(Collections.singletonList(new SormasToSormasCaseDto(person, caze)));
    SormasToSormasEncryptedDataDto encryptedData = encryptShareData(shareData);
    getSormasToSormasCaseFacade().saveSharedEntities(encryptedData);
    CaseDataDto savedCase = getCaseFacade().getCaseDataByUuid(caze.getUuid());
    assertThat(savedCase, is(notNullValue()));
    assertThat(savedCase.getResponsibleRegion(), is(rdcf.region));
    assertThat(savedCase.getResponsibleDistrict(), is(rdcf.district));
    assertThat(savedCase.getResponsibleCommunity(), is(rdcf.community));
    assertThat(savedCase.getHealthFacility(), is(rdcf.facility));
    assertThat(savedCase.getHospitalization().getAdmittedToHealthFacility(), is(YesNoUnknown.YES));
    assertThat(savedCase.getSymptoms().getAgitation(), is(SymptomState.YES));
    assertThat(savedCase.getEpiData().getExposures().get(0).getAnimalContactType(), is(AnimalContactType.TOUCH));
    assertThat(savedCase.getHealthConditions().getAsplenia(), is(YesNoUnknown.YES));
    assertThat(savedCase.getMaternalHistory().getChildrenNumber(), is(2));
    assertThat(savedCase.getSormasToSormasOriginInfo().getOrganizationId(), is(DEFAULT_SERVER_ID));
    assertThat(savedCase.getSormasToSormasOriginInfo().getSenderName(), is("John doe"));
    PersonDto savedPerson = getPersonFacade().getPersonByUuid(savedCase.getPerson().getUuid());
    assertThat(savedPerson, is(notNullValue()));
    assertThat(savedPerson.getAddress().getRegion(), is(rdcf.region));
    assertThat(savedPerson.getAddress().getDistrict(), is(rdcf.district));
    assertThat(savedPerson.getAddress().getCommunity(), is(rdcf.community));
    assertThat(savedPerson.getFirstName(), is("James"));
    assertThat(savedPerson.getLastName(), is("Smith"));
}
Also used : SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) ExposureDto(de.symeda.sormas.api.exposure.ExposureDto) PersonDto(de.symeda.sormas.api.person.PersonDto) SormasToSormasCaseDto(de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Example 5 with SormasToSormasCaseDto

use of de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto in project SORMAS-Project by hzi-braunschweig.

the class SormasToSormasCaseFacadeEjbTest method testSaveSharedCaseWithSamples.

@Test
public void testSaveSharedCaseWithSamples() throws SormasToSormasException, SormasToSormasValidationException {
    PersonDto person = createPersonDto(rdcf);
    CaseDataDto caze = createRemoteCaseDto(rdcf, person);
    SormasToSormasSampleDto sample = createRemoteSampleDtoWithTests(rdcf, caze.toReference(), null);
    SormasToSormasDto shareData = new SormasToSormasDto();
    shareData.setOriginInfo(createSormasToSormasOriginInfo(DEFAULT_SERVER_ID, false));
    shareData.setCases(Collections.singletonList(new SormasToSormasCaseDto(person, caze)));
    shareData.setSamples(Collections.singletonList(sample));
    SormasToSormasEncryptedDataDto encryptedData = encryptShareData(shareData);
    getSormasToSormasCaseFacade().saveSharedEntities(encryptedData);
    CaseDataDto savedCase = getCaseFacade().getCaseDataByUuid(caze.getUuid());
    SampleDto savedSample = getSampleFacade().getSampleByUuid(sample.getEntity().getUuid());
    assertThat(savedSample, is(notNullValue()));
    assertThat(savedSample.getLab(), is(rdcf.facility));
    assertThat(getPathogenTestFacade().getAllBySample(savedSample.toReference()), hasSize(1));
    assertThat(getAdditionalTestFacade().getAllBySample(savedSample.getUuid()), hasSize(1));
    assertThat(savedCase.getSormasToSormasOriginInfo().getUuid(), is(savedSample.getSormasToSormasOriginInfo().getUuid()));
}
Also used : SormasToSormasEncryptedDataDto(de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto) SormasToSormasDto(de.symeda.sormas.api.sormastosormas.SormasToSormasDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) SormasToSormasSampleDto(de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto) SormasToSormasSampleDto(de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) SormasToSormasCaseDto(de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto) SormasToSormasTest(de.symeda.sormas.backend.sormastosormas.SormasToSormasTest) Test(org.junit.Test)

Aggregations

SormasToSormasCaseDto (de.symeda.sormas.api.sormastosormas.caze.SormasToSormasCaseDto)22 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)17 PersonDto (de.symeda.sormas.api.person.PersonDto)17 SormasToSormasDto (de.symeda.sormas.api.sormastosormas.SormasToSormasDto)17 Test (org.junit.Test)17 SormasToSormasTest (de.symeda.sormas.backend.sormastosormas.SormasToSormasTest)16 SormasToSormasEncryptedDataDto (de.symeda.sormas.api.sormastosormas.SormasToSormasEncryptedDataDto)13 SormasToSormasContactDto (de.symeda.sormas.api.sormastosormas.contact.SormasToSormasContactDto)9 SormasToSormasSampleDto (de.symeda.sormas.api.sormastosormas.sample.SormasToSormasSampleDto)9 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)8 PortHealthInfoDto (de.symeda.sormas.api.caze.porthealthinfo.PortHealthInfoDto)7 SormasServerDescriptor (de.symeda.sormas.api.sormastosormas.SormasServerDescriptor)7 SormasToSormasOptionsDto (de.symeda.sormas.api.sormastosormas.SormasToSormasOptionsDto)7 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)7 ExposureDto (de.symeda.sormas.api.exposure.ExposureDto)6 SormasToSormasOriginInfoDto (de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto)6 ContactDto (de.symeda.sormas.api.contact.ContactDto)5 FacilityReferenceDto (de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto)5 PointOfEntryReferenceDto (de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto)5 SormasToSormasShareInfoCriteria (de.symeda.sormas.api.sormastosormas.shareinfo.SormasToSormasShareInfoCriteria)5