Search in sources :

Example 1 with District

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());
}
Also used : HealthConditions(de.symeda.sormas.app.backend.clinicalcourse.HealthConditions) User(de.symeda.sormas.app.backend.user.User) Region(de.symeda.sormas.app.backend.region.Region) EpiData(de.symeda.sormas.app.backend.epidata.EpiData) Person(de.symeda.sormas.app.backend.person.Person) District(de.symeda.sormas.app.backend.region.District) Community(de.symeda.sormas.app.backend.region.Community) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto)

Example 2 with District

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));
}
Also used : User(de.symeda.sormas.app.backend.user.User) District(de.symeda.sormas.app.backend.region.District) Test(org.junit.Test)

Example 3 with District

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));
}
Also used : Region(de.symeda.sormas.app.backend.region.Region) District(de.symeda.sormas.app.backend.region.District) Test(org.junit.Test)

Example 4 with District

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());
}
Also used : Disease(de.symeda.sormas.api.Disease) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) Region(de.symeda.sormas.app.backend.region.Region) Facility(de.symeda.sormas.app.backend.facility.Facility) InvestigationStatus(de.symeda.sormas.api.caze.InvestigationStatus) DaoException(de.symeda.sormas.app.backend.common.DaoException) District(de.symeda.sormas.app.backend.region.District) Community(de.symeda.sormas.app.backend.region.Community) Date(java.util.Date) Case(de.symeda.sormas.app.backend.caze.Case)

Example 5 with District

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());
}
Also used : Task(de.symeda.sormas.app.backend.task.Task) User(de.symeda.sormas.app.backend.user.User) UserRole(de.symeda.sormas.api.user.UserRole) CaseDao(de.symeda.sormas.app.backend.caze.CaseDao) TaskDao(de.symeda.sormas.app.backend.task.TaskDao) District(de.symeda.sormas.app.backend.region.District) Community(de.symeda.sormas.app.backend.region.Community) Case(de.symeda.sormas.app.backend.caze.Case) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

District (de.symeda.sormas.app.backend.region.District)26 Region (de.symeda.sormas.app.backend.region.Region)17 Community (de.symeda.sormas.app.backend.region.Community)15 Facility (de.symeda.sormas.app.backend.facility.Facility)12 User (de.symeda.sormas.app.backend.user.User)12 Case (de.symeda.sormas.app.backend.caze.Case)10 Person (de.symeda.sormas.app.backend.person.Person)7 Item (de.symeda.sormas.app.component.Item)6 Test (org.junit.Test)6 PointOfEntry (de.symeda.sormas.app.backend.infrastructure.PointOfEntry)5 Country (de.symeda.sormas.app.backend.region.Country)5 Task (de.symeda.sormas.app.backend.task.Task)5 InfrastructureDaoHelper.isEmptyDistrict (de.symeda.sormas.app.util.InfrastructureDaoHelper.isEmptyDistrict)5 InfrastructureDaoHelper.isUnknownDistrict (de.symeda.sormas.app.util.InfrastructureDaoHelper.isUnknownDistrict)5 InfrastructureDaoHelper.unknownDistrict (de.symeda.sormas.app.util.InfrastructureDaoHelper.unknownDistrict)5 ArrayList (java.util.ArrayList)5 CaseDao (de.symeda.sormas.app.backend.caze.CaseDao)4 TaskDao (de.symeda.sormas.app.backend.task.TaskDao)4 MeansOfImmunization (de.symeda.sormas.api.immunization.MeansOfImmunization)3 FacilityType (de.symeda.sormas.api.infrastructure.facility.FacilityType)3