use of de.symeda.sormas.app.backend.region.Community in project SORMAS-Project by hzi-braunschweig.
the class ContactDtoHelper method fillInnerFromAdo.
@Override
public void fillInnerFromAdo(ContactDto target, Contact source) {
if (source.getPerson() != null) {
Person person = DatabaseHelper.getPersonDao().queryForId(source.getPerson().getId());
target.setPerson(PersonDtoHelper.toReferenceDto(person));
} else {
target.setPerson(null);
}
if (source.getRegion() != null) {
Region region = DatabaseHelper.getRegionDao().queryForId(source.getRegion().getId());
target.setRegion(RegionDtoHelper.toReferenceDto(region));
} else {
target.setRegion(null);
}
if (source.getDistrict() != null) {
District district = DatabaseHelper.getDistrictDao().queryForId(source.getDistrict().getId());
target.setDistrict(DistrictDtoHelper.toReferenceDto(district));
} else {
target.setDistrict(null);
}
if (source.getCommunity() != null) {
Community community = DatabaseHelper.getCommunityDao().queryForId(source.getCommunity().getId());
target.setCommunity(CommunityDtoHelper.toReferenceDto(community));
} else {
target.setCommunity(null);
}
if (source.getCaseUuid() != null) {
target.setCaze(new CaseReferenceDto(source.getCaseUuid()));
} else {
target.setCaze(null);
}
if (source.getResultingCaseUuid() != null) {
target.setResultingCase(new CaseReferenceDto(source.getResultingCaseUuid()));
} else {
target.setResultingCase(null);
}
target.setDisease(source.getDisease());
target.setDiseaseDetails(source.getDiseaseDetails());
if (source.getReportingUser() != null) {
User user = DatabaseHelper.getUserDao().queryForId(source.getReportingUser().getId());
target.setReportingUser(UserDtoHelper.toReferenceDto(user));
} else {
target.setReportingUser(null);
}
target.setReportDateTime(source.getReportDateTime());
target.setMultiDayContact(source.isMultiDayContact());
target.setFirstContactDate(source.getFirstContactDate());
target.setLastContactDate(source.getLastContactDate());
target.setContactIdentificationSource(source.getContactIdentificationSource());
target.setContactIdentificationSourceDetails(source.getContactIdentificationSourceDetails());
target.setTracingApp(source.getTracingApp());
target.setTracingAppDetails(source.getTracingAppDetails());
target.setContactProximity(source.getContactProximity());
target.setContactClassification(source.getContactClassification());
target.setContactStatus(source.getContactStatus());
target.setRelationToCase(source.getRelationToCase());
target.setRelationDescription(source.getRelationDescription());
target.setFollowUpStatus(source.getFollowUpStatus());
target.setFollowUpComment(source.getFollowUpComment());
target.setFollowUpUntil(source.getFollowUpUntil());
if (source.getContactOfficer() != null) {
User user = DatabaseHelper.getUserDao().queryForId(source.getContactOfficer().getId());
target.setContactOfficer(UserDtoHelper.toReferenceDto(user));
} else {
target.setContactOfficer(null);
}
target.setDescription(source.getDescription());
target.setReportLat(source.getReportLat());
target.setReportLon(source.getReportLon());
target.setReportLatLonAccuracy(source.getReportLatLonAccuracy());
target.setExternalID(source.getExternalID());
target.setExternalToken(source.getExternalToken());
target.setInternalToken(source.getInternalToken());
target.setHighPriority(source.isHighPriority());
target.setImmunosuppressiveTherapyBasicDisease(source.getImmunosuppressiveTherapyBasicDisease());
target.setImmunosuppressiveTherapyBasicDiseaseDetails(source.getImmunosuppressiveTherapyBasicDiseaseDetails());
target.setCareForPeopleOver60(source.getCareForPeopleOver60());
target.setQuarantine(source.getQuarantine());
target.setQuarantineTypeDetails(source.getQuarantineTypeDetails());
target.setQuarantineFrom(source.getQuarantineFrom());
target.setQuarantineTo(source.getQuarantineTo());
target.setCaseIdExternalSystem(source.getCaseIdExternalSystem());
target.setCaseOrEventInformation(source.getCaseOrEventInformation());
target.setQuarantineHelpNeeded(source.getQuarantineHelpNeeded());
target.setQuarantineOrderedVerbally(source.isQuarantineOrderedVerbally());
target.setQuarantineOrderedOfficialDocument(source.isQuarantineOrderedOfficialDocument());
target.setQuarantineOrderedVerballyDate(source.getQuarantineOrderedVerballyDate());
target.setQuarantineOrderedOfficialDocumentDate(source.getQuarantineOrderedOfficialDocumentDate());
target.setQuarantineExtended(source.isQuarantineExtended());
target.setQuarantineReduced(source.isQuarantineReduced());
target.setQuarantineHomePossible(source.getQuarantineHomePossible());
target.setQuarantineHomePossibleComment(source.getQuarantineHomePossibleComment());
target.setQuarantineHomeSupplyEnsured(source.getQuarantineHomeSupplyEnsured());
target.setQuarantineHomeSupplyEnsuredComment(source.getQuarantineHomeSupplyEnsuredComment());
target.setQuarantineOfficialOrderSent(source.isQuarantineOfficialOrderSent());
target.setQuarantineOfficialOrderSentDate(source.getQuarantineOfficialOrderSentDate());
target.setAdditionalDetails(source.getAdditionalDetails());
if (source.getEpiData() != null) {
EpiData epiData = DatabaseHelper.getEpiDataDao().queryForId(source.getEpiData().getId());
target.setEpiData(epiDataDtoHelper.adoToDto(epiData));
} else {
target.setEpiData(null);
}
if (source.getHealthConditions() != null) {
HealthConditions healthConditions = DatabaseHelper.getHealthConditionsDao().queryForId(source.getHealthConditions().getId());
target.setHealthConditions(healthConditionsDtoHelper.adoToDto(healthConditions));
} else {
target.setHealthConditions(null);
}
if (source.getSormasToSormasOriginInfo() != null) {
target.setSormasToSormasOriginInfo(sormasToSormasOriginInfoDtoHelper.adoToDto(source.getSormasToSormasOriginInfo()));
}
target.setEndOfQuarantineReason(source.getEndOfQuarantineReason());
target.setEndOfQuarantineReasonDetails(source.getEndOfQuarantineReasonDetails());
target.setPseudonymized(source.isPseudonymized());
target.setReturningTraveler(source.getReturningTraveler());
target.setProhibitionToWork(source.getProhibitionToWork());
target.setProhibitionToWorkFrom(source.getProhibitionToWorkFrom());
target.setProhibitionToWorkUntil(source.getProhibitionToWorkUntil());
if (source.getReportingDistrict() != null) {
District district = DatabaseHelper.getDistrictDao().queryForId(source.getReportingDistrict().getId());
target.setReportingDistrict(DistrictDtoHelper.toReferenceDto(district));
} else {
target.setReportingDistrict(null);
}
target.setFollowUpStatusChangeDate(source.getFollowUpStatusChangeDate());
target.setFollowUpStatusChangeUser(UserDtoHelper.toReferenceDto(source.getFollowUpStatusChangeUser()));
target.setVaccinationStatus(source.getVaccinationStatus());
}
use of de.symeda.sormas.app.backend.region.Community in project SORMAS-Project by hzi-braunschweig.
the class TestEntityCreator method createCase.
public static Case createCase(Person person) {
Disease disease = Disease.EVD;
Region region = DatabaseHelper.getRegionDao().queryUuid(TestHelper.REGION_UUID);
District district = DatabaseHelper.getDistrictDao().queryUuid(TestHelper.DISTRICT_UUID);
Community community = DatabaseHelper.getCommunityDao().queryUuid(TestHelper.COMMUNITY_UUID);
Facility facility = DatabaseHelper.getFacilityDao().queryUuid(TestHelper.FACILITY_UUID);
CaseClassification caseClassification = CaseClassification.SUSPECT;
InvestigationStatus investigationStatus = InvestigationStatus.PENDING;
Case caze = DatabaseHelper.getCaseDao().build(person);
caze.setDisease(disease);
caze.setResponsibleRegion(region);
caze.setResponsibleDistrict(district);
caze.setResponsibleCommunity(community);
caze.setHealthFacility(facility);
caze.setFacilityType(FacilityType.HOSPITAL);
caze.setCaseClassification(caseClassification);
caze.setInvestigationStatus(investigationStatus);
caze.setReportDate(new Date());
try {
DatabaseHelper.getCaseDao().saveAndSnapshot(caze);
DatabaseHelper.getCaseDao().accept(caze);
} catch (DaoException e) {
throw new RuntimeException(e);
}
return DatabaseHelper.getCaseDao().queryForIdWithEmbedded(caze.getId());
}
use of de.symeda.sormas.app.backend.region.Community in project SORMAS-Project by hzi-braunschweig.
the class CaseBackendTest method testTaskReassignmentAfterChangedCaseDistrict.
@Test
public void testTaskReassignmentAfterChangedCaseDistrict() throws DaoException {
CaseDao caseDao = DatabaseHelper.getCaseDao();
Case caze = TestEntityCreator.createCase();
caze.setRegion(caze.getResponsibleRegion());
caze.setDistrict(caze.getResponsibleDistrict());
caze.setCommunity(caze.getResponsibleCommunity());
caseDao.saveAndSnapshot(caze);
User user = ConfigProvider.getUser();
UserRole userRole = UserRole.SURVEILLANCE_OFFICER;
Set<UserRole> userRoles = new HashSet<>();
userRoles.add(userRole);
user.setUserRoles(userRoles);
DatabaseHelper.getUserDao().saveAndSnapshot(user);
TaskDao taskDao = DatabaseHelper.getTaskDao();
Task task = TestEntityCreator.createCaseTask(caze, TaskStatus.PENDING, user);
assertEquals(caze.getResponsibleRegion().getUuid(), TestHelper.REGION_UUID);
assertEquals(caze.getResponsibleDistrict().getUuid(), TestHelper.DISTRICT_UUID);
assertEquals(caze.getResponsibleCommunity().getUuid(), TestHelper.COMMUNITY_UUID);
assertEquals(caze.getRegion().getUuid(), TestHelper.REGION_UUID);
assertEquals(caze.getDistrict().getUuid(), TestHelper.DISTRICT_UUID);
assertEquals(caze.getCommunity().getUuid(), TestHelper.COMMUNITY_UUID);
assertEquals(caze.getHealthFacility().getUuid(), TestHelper.FACILITY_UUID);
task = taskDao.queryUuid(task.getUuid());
assertEquals(TestHelper.USER_UUID, task.getAssigneeUser().getUuid());
// ResponsibleDistrict changed, but District still in user's jurisdiction
District secondDistrict = DatabaseHelper.getDistrictDao().queryUuid(TestHelper.SECOND_DISTRICT_UUID);
Community secondCommunity = DatabaseHelper.getCommunityDao().queryUuid(TestHelper.SECOND_COMMUNITY_UUID);
caze.setResponsibleDistrict(secondDistrict);
caze.setResponsibleCommunity(secondCommunity);
caseDao.saveAndSnapshot(caze);
task = taskDao.queryUuid(task.getUuid());
assertEquals(TestHelper.USER_UUID, task.getAssigneeUser().getUuid());
// Case not in user's jurisdiction anymore
caze.setDistrict(secondDistrict);
caze.setCommunity(null);
caseDao.saveAndSnapshot(caze);
task = taskDao.queryUuid(task.getUuid());
assertEquals(TestHelper.SECOND_USER_UUID, task.getAssigneeUser().getUuid());
}
use of de.symeda.sormas.app.backend.region.Community in project SORMAS-Project by hzi-braunschweig.
the class CaseDtoHelper method fillInnerFromAdo.
@Override
public void fillInnerFromAdo(CaseDataDto target, Case source) {
target.setClinicalConfirmation(source.getClinicalConfirmation());
target.setEpidemiologicalConfirmation(source.getEpidemiologicalConfirmation());
target.setLaboratoryDiagnosticConfirmation(source.getLaboratoryDiagnosticConfirmation());
target.setCaseClassification(source.getCaseClassification());
target.setCaseIdentificationSource(source.getCaseIdentificationSource());
target.setScreeningType(source.getScreeningType());
if (source.getClassificationUser() != null) {
User user = DatabaseHelper.getUserDao().queryForId(source.getClassificationUser().getId());
target.setClassificationUser(UserDtoHelper.toReferenceDto(user));
} else {
target.setClassificationUser(null);
}
target.setClassificationDate(source.getClassificationDate());
target.setClassificationComment(source.getClassificationComment());
target.setInvestigationStatus(source.getInvestigationStatus());
target.setDisease(source.getDisease());
target.setDiseaseVariant(source.getDiseaseVariant());
target.setDiseaseDetails(source.getDiseaseDetails());
target.setDiseaseVariantDetails(source.getDiseaseVariantDetails());
target.setPlagueType(source.getPlagueType());
target.setDengueFeverType(source.getDengueFeverType());
if (source.getHealthFacility() != null) {
Facility facility = DatabaseHelper.getFacilityDao().queryForId(source.getHealthFacility().getId());
target.setHealthFacility(FacilityDtoHelper.toReferenceDto(facility));
} else {
target.setHealthFacility(null);
}
target.setHealthFacilityDetails(source.getHealthFacilityDetails());
if (source.getPerson() != null) {
Person person = DatabaseHelper.getPersonDao().queryForId(source.getPerson().getId());
target.setPerson(PersonDtoHelper.toReferenceDto(person));
}
target.setInvestigatedDate(source.getInvestigatedDate());
target.setReportDate(source.getReportDate());
target.setDistrictLevelDate(source.getDistrictLevelDate());
if (source.getReportingUser() != null) {
User user = DatabaseHelper.getUserDao().queryForId(source.getReportingUser().getId());
target.setReportingUser(UserDtoHelper.toReferenceDto(user));
} else {
target.setReportingUser(null);
}
if (source.getSymptoms() != null) {
Symptoms symptoms = DatabaseHelper.getSymptomsDao().queryForId(source.getSymptoms().getId());
SymptomsDto symptomsDto = symptomsDtoHelper.adoToDto(symptoms);
target.setSymptoms(symptomsDto);
} else {
target.setSymptoms(null);
}
if (source.getResponsibleRegion() != null) {
Region region = DatabaseHelper.getRegionDao().queryForId(source.getResponsibleRegion().getId());
target.setResponsibleRegion(RegionDtoHelper.toReferenceDto(region));
} else {
target.setResponsibleRegion(null);
}
if (source.getResponsibleDistrict() != null) {
District district = DatabaseHelper.getDistrictDao().queryForId(source.getResponsibleDistrict().getId());
target.setResponsibleDistrict(DistrictDtoHelper.toReferenceDto(district));
} else {
target.setResponsibleDistrict(null);
}
if (source.getResponsibleCommunity() != null) {
Community community = DatabaseHelper.getCommunityDao().queryForId(source.getResponsibleCommunity().getId());
target.setResponsibleCommunity(CommunityDtoHelper.toReferenceDto(community));
} else {
target.setResponsibleCommunity(null);
}
if (source.getRegion() != null) {
Region region = DatabaseHelper.getRegionDao().queryForId(source.getRegion().getId());
target.setRegion(RegionDtoHelper.toReferenceDto(region));
} else {
target.setRegion(null);
}
if (source.getDistrict() != null) {
District district = DatabaseHelper.getDistrictDao().queryForId(source.getDistrict().getId());
target.setDistrict(DistrictDtoHelper.toReferenceDto(district));
} else {
target.setDistrict(null);
}
if (source.getCommunity() != null) {
Community community = DatabaseHelper.getCommunityDao().queryForId(source.getCommunity().getId());
target.setCommunity(CommunityDtoHelper.toReferenceDto(community));
} else {
target.setCommunity(null);
}
if (source.getPointOfEntry() != null) {
PointOfEntry pointOfEntry = DatabaseHelper.getPointOfEntryDao().queryForId(source.getPointOfEntry().getId());
target.setPointOfEntry(PointOfEntryDtoHelper.toReferenceDto(pointOfEntry));
} else {
target.setPointOfEntry(null);
}
target.setPointOfEntryDetails(source.getPointOfEntryDetails());
if (source.getSurveillanceOfficer() != null) {
User user = DatabaseHelper.getUserDao().queryForId(source.getSurveillanceOfficer().getId());
target.setSurveillanceOfficer(UserDtoHelper.toReferenceDto(user));
} else {
target.setSurveillanceOfficer(null);
}
if (source.getHospitalization() != null) {
Hospitalization hospitalization = DatabaseHelper.getHospitalizationDao().queryForId(source.getHospitalization().getId());
target.setHospitalization(hospitalizationDtoHelper.adoToDto(hospitalization));
} else {
target.setHospitalization(null);
}
if (source.getEpiData() != null) {
EpiData epiData = DatabaseHelper.getEpiDataDao().queryForId(source.getEpiData().getId());
target.setEpiData(epiDataDtoHelper.adoToDto(epiData));
} else {
target.setEpiData(null);
}
if (source.getTherapy() != null) {
Therapy therapy = DatabaseHelper.getTherapyDao().queryForId(source.getTherapy().getId());
target.setTherapy(therapyDtoHelper.adoToDto(therapy));
} else {
target.setTherapy(null);
}
if (source.getClinicalCourse() != null) {
ClinicalCourse clinicalCourse = DatabaseHelper.getClinicalCourseDao().queryForId(source.getClinicalCourse().getId());
target.setClinicalCourse(clinicalCourseDtoHelper.adoToDto(clinicalCourse));
} else {
target.setClinicalCourse(null);
}
if (source.getMaternalHistory() != null) {
target.setMaternalHistory(maternalHistoryDtoHelper.adoToDto(DatabaseHelper.getMaternalHistoryDao().queryForId(source.getMaternalHistory().getId())));
} else {
target.setMaternalHistory(null);
}
if (source.getPortHealthInfo() != null) {
target.setPortHealthInfo(portHealthInfoDtoHelper.adoToDto(DatabaseHelper.getPortHealthInfoDao().queryForId(source.getPortHealthInfo().getId())));
} else {
target.setPortHealthInfo(null);
}
target.setClinicianName(source.getClinicianName());
target.setClinicianPhone(source.getClinicianPhone());
target.setClinicianEmail(source.getClinicianEmail());
target.setPregnant(source.getPregnant());
target.setVaccinationStatus(source.getVaccinationStatus());
target.setSmallpoxVaccinationScar(source.getSmallpoxVaccinationScar());
target.setSmallpoxVaccinationReceived(source.getSmallpoxVaccinationReceived());
target.setSmallpoxLastVaccinationDate(source.getSmallpoxLastVaccinationDate());
target.setEpidNumber(source.getEpidNumber());
target.setCaseOrigin(source.getCaseOrigin());
target.setReportLat(source.getReportLat());
target.setReportLon(source.getReportLon());
target.setReportLatLonAccuracy(source.getReportLatLonAccuracy());
target.setOutcome(source.getOutcome());
target.setOutcomeDate(source.getOutcomeDate());
target.setSequelae(source.getSequelae());
target.setSequelaeDetails(source.getSequelaeDetails());
target.setNotifyingClinic(source.getNotifyingClinic());
target.setNotifyingClinicDetails(source.getNotifyingClinicDetails());
target.setRabiesType(source.getRabiesType());
target.setCreationVersion(source.getCreationVersion());
target.setAdditionalDetails(source.getAdditionalDetails());
target.setExternalID(source.getExternalID());
target.setExternalToken(source.getExternalToken());
target.setInternalToken(source.getInternalToken());
target.setQuarantine(source.getQuarantine());
target.setQuarantineTypeDetails(source.getQuarantineTypeDetails());
target.setQuarantineFrom(source.getQuarantineFrom());
target.setQuarantineTo(source.getQuarantineTo());
target.setQuarantineHelpNeeded(source.getQuarantineHelpNeeded());
target.setQuarantineOrderedVerbally(source.isQuarantineOrderedVerbally());
target.setQuarantineOrderedOfficialDocument(source.isQuarantineOrderedOfficialDocument());
target.setQuarantineOrderedVerballyDate(source.getQuarantineOrderedVerballyDate());
target.setQuarantineOrderedOfficialDocumentDate(source.getQuarantineOrderedOfficialDocumentDate());
target.setQuarantineExtended(source.isQuarantineExtended());
target.setQuarantineReduced(source.isQuarantineReduced());
target.setQuarantineHomePossible(source.getQuarantineHomePossible());
target.setQuarantineHomePossibleComment(source.getQuarantineHomePossibleComment());
target.setQuarantineHomeSupplyEnsured(source.getQuarantineHomeSupplyEnsured());
target.setQuarantineHomeSupplyEnsuredComment(source.getQuarantineHomeSupplyEnsuredComment());
target.setQuarantineOfficialOrderSent(source.isQuarantineOfficialOrderSent());
target.setQuarantineOfficialOrderSentDate(source.getQuarantineOfficialOrderSentDate());
target.setPostpartum(source.getPostpartum());
target.setTrimester(source.getTrimester());
target.setPseudonymized(source.isPseudonymized());
target.setFacilityType(source.getFacilityType());
target.setCaseIdIsm(source.getCaseIdIsm());
target.setContactTracingFirstContactType(source.getContactTracingFirstContactType());
target.setContactTracingFirstContactDate(source.getContactTracingFirstContactDate());
target.setWasInQuarantineBeforeIsolation(source.getWasInQuarantineBeforeIsolation());
target.setQuarantineReasonBeforeIsolation(source.getQuarantineReasonBeforeIsolation());
target.setQuarantineReasonBeforeIsolationDetails(source.getQuarantineReasonBeforeIsolationDetails());
target.setEndOfIsolationReason(source.getEndOfIsolationReason());
target.setEndOfIsolationReasonDetails(source.getEndOfIsolationReasonDetails());
target.setNosocomialOutbreak(source.isNosocomialOutbreak());
target.setInfectionSetting(source.getInfectionSetting());
target.setProhibitionToWork(source.getProhibitionToWork());
target.setProhibitionToWorkFrom(source.getProhibitionToWorkFrom());
target.setProhibitionToWorkUntil(source.getProhibitionToWorkUntil());
target.setReInfection(source.getReInfection());
target.setPreviousInfectionDate(source.getPreviousInfectionDate());
target.setBloodOrganOrTissueDonated(source.getBloodOrganOrTissueDonated());
if (source.getSormasToSormasOriginInfo() != null) {
target.setSormasToSormasOriginInfo(sormasToSormasOriginInfoDtoHelper.adoToDto(source.getSormasToSormasOriginInfo()));
}
target.setOwnershipHandedOver(source.isOwnershipHandedOver());
target.setNotACaseReasonNegativeTest(source.isNotACaseReasonNegativeTest());
target.setNotACaseReasonPhysicianInformation(source.isNotACaseReasonPhysicianInformation());
target.setNotACaseReasonDifferentPathogen(source.isNotACaseReasonDifferentPathogen());
target.setNotACaseReasonOther(source.isNotACaseReasonOther());
target.setNotACaseReasonDetails(source.getNotACaseReasonDetails());
target.setFollowUpStatusChangeDate(source.getFollowUpStatusChangeDate());
target.setFollowUpStatusChangeUser(UserDtoHelper.toReferenceDto(source.getFollowUpStatusChangeUser()));
if (source.getHealthConditions() != null) {
HealthConditions healthConditions = DatabaseHelper.getHealthConditionsDao().queryForId(source.getHealthConditions().getId());
target.setHealthConditions(healthConditionsDtoHelper.adoToDto(healthConditions));
} else {
target.setHealthConditions(null);
}
}
use of de.symeda.sormas.app.backend.region.Community in project SORMAS-Project by hzi-braunschweig.
the class JurisdictionHelper method createResponsibleJurisdiction.
private static ResponsibleJurisdictionDto createResponsibleJurisdiction(Case caze) {
Region responsibleRegion = caze.getResponsibleRegion();
District responsibleDistrict = caze.getResponsibleDistrict();
Community responsibleCommunity = caze.getResponsibleCommunity();
return createResponsibleJurisdiction(responsibleRegion, responsibleDistrict, responsibleCommunity);
}
Aggregations