use of de.symeda.sormas.app.backend.region.District 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.District in project SORMAS-Project by hzi-braunschweig.
the class UserBackendTest method shouldGetByDistrictAndRole.
@Test
public void shouldGetByDistrictAndRole() {
assertThat(DatabaseHelper.getUserDao().queryForAll().size(), is(3));
District district = DatabaseHelper.getDistrictDao().queryUuid(TestHelper.DISTRICT_UUID);
assertThat(DatabaseHelper.getUserDao().getByDistrictAndRole(district, UserRole.SURVEILLANCE_OFFICER, User.FIRST_NAME).size(), is(1));
List<User> informants = DatabaseHelper.getUserDao().getByDistrictAndRole(district, UserRole.HOSPITAL_INFORMANT, User.FIRST_NAME);
assertThat(informants.size(), is(1));
assertThat(informants.get(0).getUserRoles(), contains(UserRole.HOSPITAL_INFORMANT));
}
use of de.symeda.sormas.app.backend.region.District in project SORMAS-Project by hzi-braunschweig.
the class FacilityBackendTest method shouldGetHealthFacilitiesByDistrict.
@Test
public void shouldGetHealthFacilitiesByDistrict() throws SQLException {
District district = DatabaseHelper.getDistrictDao().queryUuid(TestHelper.DISTRICT_UUID);
Region region = district.getRegion();
// There should be exactly one health facility and one laboratory in this district
assertThat(DatabaseHelper.getFacilityDao().getActiveHealthFacilitiesByDistrictAndType(district, FacilityType.LABORATORY, false, false).size(), is(1));
assertThat(DatabaseHelper.getFacilityDao().getActiveHealthFacilitiesByDistrictAndType(district, FacilityType.HOSPITAL, false, false).size(), is(1));
assertThat(DatabaseHelper.getFacilityDao().getActiveHealthFacilitiesByDistrictAndType(district, null, false, false).size(), is(2));
assertThat(DatabaseHelper.getFacilityDao().getActiveHealthFacilitiesByDistrictAndType(district, null, false, true).size(), is(3));
assertThat(DatabaseHelper.getFacilityDao().getActiveHealthFacilitiesByDistrictAndType(district, null, true, false).size(), is(3));
assertThat(DatabaseHelper.getFacilityDao().getActiveHealthFacilitiesByDistrictAndType(district, null, true, true).size(), is(4));
assertThat(DatabaseHelper.getFacilityDao().getActiveHealthFacilitiesByDistrictAndType(district, FacilityType.HOSPITAL, true, true).size(), is(3));
}
use of de.symeda.sormas.app.backend.region.District 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.District 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());
}
Aggregations