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());
}
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);
});
}
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);
}
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;
}
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);
}
}
Aggregations