Search in sources :

Example 1 with Contact

use of de.symeda.sormas.app.backend.contact.Contact in project SORMAS-Project by hzi-braunschweig.

the class CaseReadContactListFragment method onListItemClick.

@Override
public void onListItemClick(View view, int position, Object item) {
    Contact contact = (Contact) item;
    ContactReadActivity.startActivity(getActivity(), contact.getUuid(), true);
}
Also used : Contact(de.symeda.sormas.app.backend.contact.Contact)

Example 2 with Contact

use of de.symeda.sormas.app.backend.contact.Contact in project SORMAS-Project by hzi-braunschweig.

the class ContactEditActivity method saveData.

@Override
public void saveData() {
    if (saveTask != null) {
        NotificationHelper.showNotification(this, WARNING, getString(R.string.message_already_saving));
        // don't save multiple times
        return;
    }
    final Contact contactToSave = getStoredRootEntity();
    if (ContactEditAuthorization.isContactEditAllowed(contactToSave)) {
        try {
            FragmentValidator.validate(getContext(), getActiveFragment().getContentBinding());
        } catch (ValidationException e) {
            NotificationHelper.showNotification(this, ERROR, e.getMessage());
            return;
        }
        saveTask = new SavingAsyncTask(getRootView(), contactToSave) {

            @Override
            public void doInBackground(TaskResultHolder resultHolder) throws DaoException {
                DatabaseHelper.getPersonDao().saveAndSnapshot(contactToSave.getPerson());
                DatabaseHelper.getContactDao().saveAndSnapshot(contactToSave);
            }

            @Override
            protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
                super.onPostExecute(taskResult);
                if (taskResult.getResultStatus().isSuccess()) {
                    if (getActivePage().getPosition() == ContactSection.PERSON_INFO.ordinal()) {
                        finish();
                    } else {
                        goToNextPage();
                    }
                } else {
                    // reload data
                    onResume();
                }
                saveTask = null;
            }
        }.executeOnThreadPool();
    } else {
        NotificationHelper.showNotification(this, WARNING, getString(R.string.message_edit_forbidden));
    }
}
Also used : ValidationException(de.symeda.sormas.api.utils.ValidationException) TaskResultHolder(de.symeda.sormas.app.core.async.TaskResultHolder) AsyncTaskResult(de.symeda.sormas.app.core.async.AsyncTaskResult) SavingAsyncTask(de.symeda.sormas.app.core.async.SavingAsyncTask) Contact(de.symeda.sormas.app.backend.contact.Contact)

Example 3 with Contact

use of de.symeda.sormas.app.backend.contact.Contact in project SORMAS-Project by hzi-braunschweig.

the class ExposureDtoHelper method fillInnerFromAdo.

@Override
protected void fillInnerFromAdo(ExposureDto target, Exposure source) {
    if (source.getLocation() != null) {
        Location location = DatabaseHelper.getLocationDao().queryForId(source.getLocation().getId());
        target.setLocation(locationDtoHelper.adoToDto(location));
    } else {
        target.setLocation(null);
    }
    if (source.getContactToCase() != null) {
        Contact contactToCase = DatabaseHelper.getContactDao().queryForId(source.getContactToCase().getId());
        target.setContactToCase(ContactDtoHelper.toReferenceDto(contactToCase));
    } else {
        target.setContactToCase(null);
    }
    if (source.getReportingUser() != null) {
        User reportingUser = DatabaseHelper.getUserDao().queryForId(source.getReportingUser().getId());
        target.setReportingUser(UserDtoHelper.toReferenceDto(reportingUser));
    } else {
        target.setReportingUser(null);
    }
    target.setAnimalCondition(source.getAnimalCondition());
    target.setTypeOfAnimal(source.getTypeOfAnimal());
    target.setTypeOfAnimalDetails(source.getTypeOfAnimalDetails());
    target.setExposureRole(source.getExposureRole());
    target.setAnimalContactType(source.getAnimalContactType());
    target.setAnimalContactTypeDetails(source.getAnimalContactTypeDetails());
    target.setAnimalMarket(source.getAnimalMarket());
    target.setAnimalVaccinated(source.getAnimalVaccinated());
    target.setContactToBodyFluids(source.getContactToBodyFluids());
    target.setDeceasedPersonIll(source.getDeceasedPersonIll());
    target.setDeceasedPersonName(source.getDeceasedPersonName());
    target.setDeceasedPersonRelation(source.getDeceasedPersonRelation());
    target.setDescription(source.getDescription());
    target.setEatingRawAnimalProducts(source.getEatingRawAnimalProducts());
    target.setEndDate(source.getEndDate());
    target.setExposureType(source.getExposureType());
    target.setExposureTypeDetails(source.getExposureTypeDetails());
    target.setGatheringDetails(source.getGatheringDetails());
    target.setGatheringType(source.getGatheringType());
    target.setHabitationDetails(source.getHabitationDetails());
    target.setHabitationType(source.getHabitationType());
    target.setHandlingAnimals(source.getHandlingAnimals());
    target.setHandlingSamples(source.getHandlingSamples());
    target.setIndoors(source.getIndoors());
    target.setLongFaceToFaceContact(source.getLongFaceToFaceContact());
    target.setOtherProtectiveMeasures(source.getOtherProtectiveMeasures());
    target.setProtectiveMeasuresDetails(source.getProtectiveMeasuresDetails());
    target.setOutdoors(source.getOutdoors());
    target.setPercutaneous(source.getPercutaneous());
    target.setPhysicalContactDuringPreparation(source.getPhysicalContactDuringPreparation());
    target.setPhysicalContactWithBody(source.getPhysicalContactWithBody());
    target.setShortDistance(source.getShortDistance());
    target.setProbableInfectionEnvironment(source.isProbableInfectionEnvironment());
    target.setStartDate(source.getStartDate());
    target.setWearingMask(source.getWearingMask());
    target.setWearingPpe(source.getWearingPpe());
    target.setTypeOfPlace(source.getTypeOfPlace());
    target.setTypeOfPlaceDetails(source.getTypeOfPlaceDetails());
    target.setMeansOfTransport(source.getMeansOfTransport());
    target.setMeansOfTransportDetails(source.getMeansOfTransportDetails());
    target.setConnectionNumber(source.getConnectionNumber());
    target.setSeatNumber(source.getSeatNumber());
    target.setWorkEnvironment(source.getWorkEnvironment());
    target.setBodyOfWater(source.getBodyOfWater());
    target.setWaterSource(source.getWaterSource());
    target.setWaterSourceDetails(source.getWaterSourceDetails());
    target.setProphylaxis(source.getProphylaxis());
    target.setProphylaxisDate(source.getProphylaxisDate());
    target.setRiskArea(source.getRiskArea());
    target.setLargeAttendanceNumber(source.getLargeAttendanceNumber());
}
Also used : User(de.symeda.sormas.app.backend.user.User) Location(de.symeda.sormas.app.backend.location.Location) Contact(de.symeda.sormas.app.backend.contact.Contact)

Example 4 with Contact

use of de.symeda.sormas.app.backend.contact.Contact in project SORMAS-Project by hzi-braunschweig.

the class AbstractAdoDaoTest method testQueryForNew.

@Test
public void testQueryForNew() throws DaoException {
    CaseDao caseDao = DatabaseHelper.getCaseDao();
    // Case with change date 0 should be included
    Case caseChangeDate0 = TestEntityCreator.createCase();
    List<Case> newCases = caseDao.queryForNew();
    assertEquals(1, newCases.size());
    // Case with newer change date should not be included
    Case caseNewChangeDate = TestEntityCreator.createCase();
    caseNewChangeDate.setChangeDate(new Date());
    caseDao.saveAndSnapshot(caseNewChangeDate);
    newCases = caseDao.queryForNew();
    assertEquals(1, newCases.size());
    // Additional tests for other entities
    Contact contact = TestEntityCreator.createContact(caseChangeDate0);
    Visit visit = TestEntityCreator.createVisit(contact);
    Sample sample = TestEntityCreator.createSample(caseChangeDate0);
    Event event = TestEntityCreator.createEvent();
    EventParticipant eventParticipant = TestEntityCreator.createEventParticipant(event);
    assertEquals(1, DatabaseHelper.getContactDao().queryForNew().size());
    assertEquals(1, DatabaseHelper.getVisitDao().queryForNew().size());
    assertEquals(1, DatabaseHelper.getSampleDao().queryForNew().size());
    assertEquals(1, DatabaseHelper.getEventDao().queryForNew().size());
    assertEquals(1, DatabaseHelper.getEventParticipantDao().queryForNew().size());
}
Also used : Visit(de.symeda.sormas.app.backend.visit.Visit) Sample(de.symeda.sormas.app.backend.sample.Sample) CaseDao(de.symeda.sormas.app.backend.caze.CaseDao) Event(de.symeda.sormas.app.backend.event.Event) Date(java.util.Date) EventParticipant(de.symeda.sormas.app.backend.event.EventParticipant) Case(de.symeda.sormas.app.backend.caze.Case) TestCase(junit.framework.TestCase) Contact(de.symeda.sormas.app.backend.contact.Contact) Test(org.junit.Test)

Example 5 with Contact

use of de.symeda.sormas.app.backend.contact.Contact in project SORMAS-Project by hzi-braunschweig.

the class CaseBackendTest method shouldDeleteWithDependingEntities.

@Test
public void shouldDeleteWithDependingEntities() throws DaoException, SQLException {
    // Assure that there are no cases or depending entities in the app to start with
    assertThat(DatabaseHelper.getCaseDao().queryForAll().size(), is(0));
    assertThat(DatabaseHelper.getContactDao().queryForAll().size(), is(0));
    assertThat(DatabaseHelper.getVisitDao().queryForAll().size(), is(0));
    assertThat(DatabaseHelper.getSampleDao().queryForAll().size(), is(0));
    assertThat(DatabaseHelper.getSampleTestDao().queryForAll().size(), is(0));
    assertThat(DatabaseHelper.getTaskDao().queryForAll().size(), is(0));
    Case caze = TestEntityCreator.createCase();
    Contact contact = TestEntityCreator.createContact(caze);
    TestEntityCreator.createVisit(contact);
    Sample sample = TestEntityCreator.createSample(caze);
    TestEntityCreator.createSampleTest(sample);
    TestEntityCreator.createCaseTask(caze, TaskStatus.PENDING, caze.getReportingUser());
    // Assure that the case and depending entities have been successfully created
    assertThat(DatabaseHelper.getCaseDao().queryForAll().size(), is(1));
    assertThat(DatabaseHelper.getContactDao().queryForAll().size(), is(1));
    assertThat(DatabaseHelper.getVisitDao().queryForAll().size(), is(1));
    assertThat(DatabaseHelper.getSampleDao().queryForAll().size(), is(1));
    assertThat(DatabaseHelper.getSampleTestDao().queryForAll().size(), is(1));
    assertThat(DatabaseHelper.getTaskDao().queryForAll().size(), is(1));
    DatabaseHelper.getCaseDao().deleteCaseAndAllDependingEntities(caze.getUuid());
    // Assure that there are no cases or depending entities in the app after the deletion
    assertThat(DatabaseHelper.getCaseDao().queryForAll().size(), is(0));
    assertThat(DatabaseHelper.getContactDao().queryForAll().size(), is(0));
    assertThat(DatabaseHelper.getVisitDao().queryForAll().size(), is(0));
    assertThat(DatabaseHelper.getSampleDao().queryForAll().size(), is(0));
    assertThat(DatabaseHelper.getSampleTestDao().queryForAll().size(), is(0));
    assertThat(DatabaseHelper.getTaskDao().queryForAll().size(), is(0));
}
Also used : Sample(de.symeda.sormas.app.backend.sample.Sample) Case(de.symeda.sormas.app.backend.caze.Case) Contact(de.symeda.sormas.app.backend.contact.Contact) Test(org.junit.Test)

Aggregations

Contact (de.symeda.sormas.app.backend.contact.Contact)32 Case (de.symeda.sormas.app.backend.caze.Case)17 Event (de.symeda.sormas.app.backend.event.Event)9 EventParticipant (de.symeda.sormas.app.backend.event.EventParticipant)9 Person (de.symeda.sormas.app.backend.person.Person)8 Immunization (de.symeda.sormas.app.backend.immunization.Immunization)6 Task (de.symeda.sormas.app.backend.task.Task)6 Visit (de.symeda.sormas.app.backend.visit.Visit)5 Sample (de.symeda.sormas.app.backend.sample.Sample)4 Date (java.util.Date)4 MeansOfImmunization (de.symeda.sormas.api.immunization.MeansOfImmunization)3 ActivityAsCase (de.symeda.sormas.app.backend.activityascase.ActivityAsCase)3 ClinicalVisit (de.symeda.sormas.app.backend.clinicalcourse.ClinicalVisit)3 DaoException (de.symeda.sormas.app.backend.common.DaoException)3 Facility (de.symeda.sormas.app.backend.facility.Facility)3 Location (de.symeda.sormas.app.backend.location.Location)3 District (de.symeda.sormas.app.backend.region.District)3 Region (de.symeda.sormas.app.backend.region.Region)3 User (de.symeda.sormas.app.backend.user.User)3 Test (org.junit.Test)3