Search in sources :

Example 1 with PreviousHospitalizationDto

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

the class CaseBackendTest method shouldeMergeCollectionAsExpected.

@Test
public void shouldeMergeCollectionAsExpected() throws DaoException {
    CaseDao caseDao = DatabaseHelper.getCaseDao();
    CaseDtoHelper caseDtoHelper = new CaseDtoHelper();
    // create existing data for app
    Case caze = TestEntityCreator.createCase();
    TestEntityCreator.addPreviousHospitalization(caze);
    caseDao.saveAndSnapshot(caze);
    caseDao.accept(caze);
    caze = caseDao.queryForIdWithEmbedded(caze.getId());
    // add previous hospitalization on "server-side"
    CaseDataDto serverCaseDto = caseDtoHelper.adoToDto(caze);
    serverCaseDto.getHospitalization().getPreviousHospitalizations().get(0).setDescription("Server-side change");
    PreviousHospitalizationDto previousHospitalizationDto = new PreviousHospitalizationDto();
    previousHospitalizationDto.setUuid(DataHelper.createUuid());
    // now
    previousHospitalizationDto.setCreationDate(new Date());
    previousHospitalizationDto.setChangeDate(new Date());
    serverCaseDto.getHospitalization().getPreviousHospitalizations().add(previousHospitalizationDto);
    // add previous hospitalization on app-side
    caze.getHospitalization().getPreviousHospitalizations().get(0).setDescription("App-side change");
    TestEntityCreator.addPreviousHospitalization(caze);
    caseDao.saveAndSnapshot(caze);
    // merge server case
    Case serverCase = caseDtoHelper.fillOrCreateFromDto(null, serverCaseDto);
    DatabaseHelper.getCaseDao().mergeOrCreate(serverCase);
    Case mergedCase = DatabaseHelper.getCaseDao().queryUuidWithEmbedded(serverCase.getUuid());
    assertEquals(3, mergedCase.getHospitalization().getPreviousHospitalizations().size());
    caseDao.accept(mergedCase);
    mergedCase = DatabaseHelper.getCaseDao().queryUuidWithEmbedded(mergedCase.getUuid());
    assertFalse(mergedCase.isModifiedOrChildModified());
}
Also used : CaseDtoHelper(de.symeda.sormas.app.backend.caze.CaseDtoHelper) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) CaseDao(de.symeda.sormas.app.backend.caze.CaseDao) PreviousHospitalizationDto(de.symeda.sormas.api.hospitalization.PreviousHospitalizationDto) Date(java.util.Date) Case(de.symeda.sormas.app.backend.caze.Case) Test(org.junit.Test)

Example 2 with PreviousHospitalizationDto

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

the class HospitalizationFacadeEjbPseudonymizationTest method createCaseWithHospitalization.

public CaseDataDto createCaseWithHospitalization(UserDto user, TestDataCreator.RDCF rdcf) {
    return creator.createCase(user.toReference(), rdcf, c -> {
        PreviousHospitalizationDto prevHospitalization = new PreviousHospitalizationDto();
        prevHospitalization.setRegion(rdcf.region);
        prevHospitalization.setDistrict(rdcf.district);
        prevHospitalization.setCommunity(rdcf.community);
        prevHospitalization.setHealthFacility(rdcf.facility);
        prevHospitalization.setHealthFacilityDetails("Test facility details");
        prevHospitalization.setDescription("Test description");
        c.getHospitalization().getPreviousHospitalizations().add(prevHospitalization);
    });
}
Also used : PreviousHospitalizationDto(de.symeda.sormas.api.hospitalization.PreviousHospitalizationDto)

Example 3 with PreviousHospitalizationDto

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

the class HospitalizationDtoHelper method fillInnerFromAdo.

@Override
public void fillInnerFromAdo(HospitalizationDto a, Hospitalization b) {
    a.setAdmittedToHealthFacility(b.getAdmittedToHealthFacility());
    a.setAdmissionDate(b.getAdmissionDate());
    a.setDischargeDate(b.getDischargeDate());
    a.setIsolated(b.getIsolated());
    a.setIsolationDate(b.getIsolationDate());
    a.setDescription(b.getDescription());
    a.setLeftAgainstAdvice(b.getLeftAgainstAdvice());
    a.setIntensiveCareUnit(b.getIntensiveCareUnit());
    a.setIntensiveCareUnitStart(b.getIntensiveCareUnitStart());
    a.setIntensiveCareUnitEnd(b.getIntensiveCareUnitEnd());
    a.setHospitalizedPreviously(b.getHospitalizedPreviously());
    a.setHospitalizationReason(b.getHospitalizationReason());
    a.setOtherHospitalizationReason(b.getOtherHospitalizationReason());
    List<PreviousHospitalizationDto> previousHospitalizationDtos = new ArrayList<>();
    for (PreviousHospitalization prevHosp : b.getPreviousHospitalizations()) {
        PreviousHospitalizationDto prevHospDto = previousHospitalizationDtoHelper.adoToDto(prevHosp);
        previousHospitalizationDtos.add(prevHospDto);
    }
    a.setPreviousHospitalizations(previousHospitalizationDtos);
}
Also used : ArrayList(java.util.ArrayList) PreviousHospitalizationDto(de.symeda.sormas.api.hospitalization.PreviousHospitalizationDto)

Example 4 with PreviousHospitalizationDto

use of de.symeda.sormas.api.hospitalization.PreviousHospitalizationDto 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 5 with PreviousHospitalizationDto

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

the class HospitalizationForm method updatePrevHospHint.

private void updatePrevHospHint(NullableOptionGroup hospitalizedPreviouslyField, PreviousHospitalizationsField previousHospitalizationsField) {
    YesNoUnknown value = (YesNoUnknown) hospitalizedPreviouslyField.getNullableValue();
    Collection<PreviousHospitalizationDto> previousHospitalizations = previousHospitalizationsField.getValue();
    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_EDIT) && value == YesNoUnknown.YES && (previousHospitalizations == null || previousHospitalizations.size() == 0)) {
        hospitalizedPreviouslyField.setComponentError(new UserError(I18nProperties.getValidationError(Validations.softAddEntryToList)));
    } else {
        hospitalizedPreviouslyField.setComponentError(null);
    }
    if (Objects.nonNull(previousHospitalizationsField.getValue())) {
        hospitalizedPreviouslyField.setEnabled(previousHospitalizationsField.isEmpty());
    } else {
        hospitalizedPreviouslyField.setEnabled(true);
    }
}
Also used : UserError(com.vaadin.server.UserError) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) PreviousHospitalizationDto(de.symeda.sormas.api.hospitalization.PreviousHospitalizationDto)

Aggregations

PreviousHospitalizationDto (de.symeda.sormas.api.hospitalization.PreviousHospitalizationDto)13 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)2 HospitalizationDto (de.symeda.sormas.api.hospitalization.HospitalizationDto)2 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)2 FacilityReferenceDto (de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto)2 Test (org.junit.Test)2 UserError (com.vaadin.server.UserError)1 Window (com.vaadin.ui.Window)1 Table (com.vaadin.v7.ui.Table)1 EntityDto (de.symeda.sormas.api.EntityDto)1 CasePersonDto (de.symeda.sormas.api.caze.CasePersonDto)1 Captions (de.symeda.sormas.api.i18n.Captions)1 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)1 Strings (de.symeda.sormas.api.i18n.Strings)1 CommunityReferenceDto (de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto)1 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)1 PersonDto (de.symeda.sormas.api.person.PersonDto)1 TaskDto (de.symeda.sormas.api.task.TaskDto)1