Search in sources :

Example 1 with HospitalizationDto

use of de.symeda.sormas.api.hospitalization.HospitalizationDto in project SORMAS-Project by hzi-braunschweig.

the class EntityDtoAccessHelperTest method setup.

@Before
public void setup() {
    caseDataDto = new CaseDataDto();
    caseDataDto.setDisease(Disease.DENGUE);
    caseDataDto.setUuid("ABCDEF");
    hospitalizationDto = new HospitalizationDto();
    hospitalizationDto.setDischargeDate(new Date(1600387200000L));
    hospitalizationDto.setIsolated(YesNoUnknown.NO);
    personReferenceDto = new PersonReferenceDto();
    personReferenceDto.setUuid("GHIJKL");
    personDto = new PersonDto();
    personDto.setUuid("GHIJKL");
    personDto.setFirstName("Tenzing");
    personDto.setLastName("Mike");
    personDto.setBirthdateDD(26);
    personDto.setBirthdateMM(11);
    personDto.setBirthdateYYYY(1973);
    personDto.setPhone("+49 681 1234");
    LocationDto address = new LocationDto();
    address.setStreet("Elm Street");
    personDto.setAddress(address);
    referenceDtoResolver = new IReferenceDtoResolver() {

        @Override
        public EntityDto resolve(ReferenceDto referenceDto) {
            if (referenceDto != null && "GHIJKL".equals(referenceDto.getUuid())) {
                return personDto;
            }
            return null;
        }
    };
}
Also used : PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) HospitalizationDto(de.symeda.sormas.api.hospitalization.HospitalizationDto) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) IReferenceDtoResolver(de.symeda.sormas.api.EntityDtoAccessHelper.IReferenceDtoResolver) Date(java.util.Date) LocationDto(de.symeda.sormas.api.location.LocationDto) Before(org.junit.Before)

Example 2 with HospitalizationDto

use of de.symeda.sormas.api.hospitalization.HospitalizationDto in project SORMAS-Project by hzi-braunschweig.

the class HospitalizationFacadeEjb method toDto.

public static HospitalizationDto toDto(Hospitalization hospitalization) {
    if (hospitalization == null) {
        return null;
    }
    HospitalizationDto target = new HospitalizationDto();
    Hospitalization source = hospitalization;
    DtoHelper.fillDto(target, source);
    target.setAdmittedToHealthFacility(source.getAdmittedToHealthFacility());
    target.setAdmissionDate(source.getAdmissionDate());
    target.setDischargeDate(source.getDischargeDate());
    target.setHospitalizedPreviously(source.getHospitalizedPreviously());
    target.setIsolated(source.getIsolated());
    target.setIsolationDate(source.getIsolationDate());
    target.setLeftAgainstAdvice(source.getLeftAgainstAdvice());
    target.setHospitalizationReason(source.getHospitalizationReason());
    target.setOtherHospitalizationReason(source.getOtherHospitalizationReason());
    List<PreviousHospitalizationDto> previousHospitalizations = new ArrayList<>();
    for (PreviousHospitalization prevDto : source.getPreviousHospitalizations()) {
        PreviousHospitalizationDto prevHosp = toDto(prevDto);
        previousHospitalizations.add(prevHosp);
    }
    target.setPreviousHospitalizations(previousHospitalizations);
    target.setIntensiveCareUnit(source.getIntensiveCareUnit());
    target.setIntensiveCareUnitStart(source.getIntensiveCareUnitStart());
    target.setIntensiveCareUnitEnd(source.getIntensiveCareUnitEnd());
    target.setDescription(source.getDescription());
    return target;
}
Also used : HospitalizationDto(de.symeda.sormas.api.hospitalization.HospitalizationDto) PreviousHospitalizationDto(de.symeda.sormas.api.hospitalization.PreviousHospitalizationDto) ArrayList(java.util.ArrayList) PreviousHospitalizationDto(de.symeda.sormas.api.hospitalization.PreviousHospitalizationDto)

Example 3 with HospitalizationDto

use of de.symeda.sormas.api.hospitalization.HospitalizationDto in project SORMAS-Project by hzi-braunschweig.

the class SormasToSormasCaseDtoValidator method validate.

@Override
public ValidationErrors validate(SormasToSormasCaseDto sharedData, ValidationDirection direction) {
    CaseDataDto caze = sharedData.getEntity();
    ValidationErrors validationErrors = new ValidationErrors(buildCaseValidationGroupName(caze));
    ValidationErrors personValidationErrors = validatePerson(sharedData.getPerson(), direction);
    validationErrors.addAll(personValidationErrors);
    final String groupNameTag = Captions.CaseData;
    infraValidator.validateResponsibleRegion(caze.getResponsibleRegion(), groupNameTag, validationErrors, caze::setResponsibleRegion, direction);
    infraValidator.validateResponsibleDistrict(caze.getResponsibleDistrict(), groupNameTag, validationErrors, caze::setResponsibleDistrict, direction);
    infraValidator.validateResponsibleCommunity(caze.getResponsibleCommunity(), groupNameTag, validationErrors, caze::setResponsibleCommunity, direction);
    infraValidator.validateRegion(caze.getRegion(), groupNameTag, validationErrors, caze::setRegion, direction);
    infraValidator.validateDistrict(caze.getDistrict(), groupNameTag, validationErrors, caze::setDistrict, direction);
    infraValidator.validateCommunity(caze.getCommunity(), groupNameTag, validationErrors, caze::setCommunity, direction);
    infraValidator.validateFacility(caze.getHealthFacility(), caze.getFacilityType(), caze.getHealthFacilityDetails(), groupNameTag, validationErrors, f -> {
        caze.setHealthFacility(f.getEntity());
        caze.setHealthFacilityDetails(f.getDetails());
    });
    infraValidator.validatePointOfEntry(caze.getPointOfEntry(), caze.getPointOfEntryDetails(), groupNameTag, validationErrors, p -> {
        caze.setPointOfEntry(p.getEntity());
        caze.setPointOfEntryDetails(p.getDetails());
    });
    final HospitalizationDto hospitalization = caze.getHospitalization();
    if (hospitalization != null) {
        hospitalization.getPreviousHospitalizations().forEach(ph -> validatePreviousHospitalization(validationErrors, ph, direction));
    }
    final MaternalHistoryDto maternalHistory = caze.getMaternalHistory();
    if (maternalHistory != null) {
        validateMaternalHistory(validationErrors, maternalHistory, direction);
    }
    validateEpiData(caze.getEpiData(), validationErrors, direction);
    return validationErrors;
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) ValidationErrors(de.symeda.sormas.api.sormastosormas.validation.ValidationErrors) HospitalizationDto(de.symeda.sormas.api.hospitalization.HospitalizationDto) MaternalHistoryDto(de.symeda.sormas.api.caze.maternalhistory.MaternalHistoryDto)

Example 4 with HospitalizationDto

use of de.symeda.sormas.api.hospitalization.HospitalizationDto in project SORMAS-Project by hzi-braunschweig.

the class CaseBackendTest method shouldPullWithCollection.

@Test
public void shouldPullWithCollection() throws DaoException {
    CaseDtoHelper caseDtoHelper = new CaseDtoHelper();
    Person person = TestEntityCreator.createPerson("Some", "Guy");
    PersonReferenceDto personDto = new PersonDtoHelper().toReferenceDto(person);
    CaseDataDto serverCaseDto = new CaseDataDto();
    // TODO find a better way to fill DTO with default embedded objects
    TestDtoCreator.fillNewDto(serverCaseDto);
    serverCaseDto.setCaseClassification(CaseClassification.NOT_CLASSIFIED);
    serverCaseDto.setInvestigationStatus(InvestigationStatus.PENDING);
    serverCaseDto.setPerson(personDto);
    SymptomsDto symptomsDto = new SymptomsDto();
    TestDtoCreator.fillNewDto(symptomsDto);
    serverCaseDto.setSymptoms(symptomsDto);
    HospitalizationDto hospitalizationDto = new HospitalizationDto();
    TestDtoCreator.fillNewDto(hospitalizationDto);
    serverCaseDto.setHospitalization(hospitalizationDto);
    EpiDataDto epiDataDto = new EpiDataDto();
    TestDtoCreator.fillNewDto(epiDataDto);
    serverCaseDto.setEpiData(epiDataDto);
    ExposureDto exposureDto = ExposureDto.build(ExposureType.TRAVEL);
    TestDtoCreator.fillNewDto(exposureDto);
    TestDtoCreator.fillNewDto(exposureDto.getLocation());
    epiDataDto.getExposures().add(exposureDto);
    // merge server case
    Case serverCase = caseDtoHelper.fillOrCreateFromDto(null, serverCaseDto);
    DatabaseHelper.getCaseDao().mergeOrCreate(serverCase);
    Case mergedCase = DatabaseHelper.getCaseDao().queryUuidWithEmbedded(serverCase.getUuid());
    assertEquals(1, mergedCase.getEpiData().getExposures().size());
}
Also used : PersonDtoHelper(de.symeda.sormas.app.backend.person.PersonDtoHelper) SymptomsDto(de.symeda.sormas.api.symptoms.SymptomsDto) EpiDataDto(de.symeda.sormas.api.epidata.EpiDataDto) CaseDtoHelper(de.symeda.sormas.app.backend.caze.CaseDtoHelper) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) ExposureDto(de.symeda.sormas.api.exposure.ExposureDto) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) PreviousHospitalizationDto(de.symeda.sormas.api.hospitalization.PreviousHospitalizationDto) HospitalizationDto(de.symeda.sormas.api.hospitalization.HospitalizationDto) Person(de.symeda.sormas.app.backend.person.Person) Case(de.symeda.sormas.app.backend.caze.Case) Test(org.junit.Test)

Aggregations

HospitalizationDto (de.symeda.sormas.api.hospitalization.HospitalizationDto)4 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)3 PreviousHospitalizationDto (de.symeda.sormas.api.hospitalization.PreviousHospitalizationDto)2 PersonReferenceDto (de.symeda.sormas.api.person.PersonReferenceDto)2 IReferenceDtoResolver (de.symeda.sormas.api.EntityDtoAccessHelper.IReferenceDtoResolver)1 MaternalHistoryDto (de.symeda.sormas.api.caze.maternalhistory.MaternalHistoryDto)1 EpiDataDto (de.symeda.sormas.api.epidata.EpiDataDto)1 ExposureDto (de.symeda.sormas.api.exposure.ExposureDto)1 LocationDto (de.symeda.sormas.api.location.LocationDto)1 PersonDto (de.symeda.sormas.api.person.PersonDto)1 ValidationErrors (de.symeda.sormas.api.sormastosormas.validation.ValidationErrors)1 SymptomsDto (de.symeda.sormas.api.symptoms.SymptomsDto)1 Case (de.symeda.sormas.app.backend.caze.Case)1 CaseDtoHelper (de.symeda.sormas.app.backend.caze.CaseDtoHelper)1 Person (de.symeda.sormas.app.backend.person.Person)1 PersonDtoHelper (de.symeda.sormas.app.backend.person.PersonDtoHelper)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Before (org.junit.Before)1 Test (org.junit.Test)1