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