Search in sources :

Example 1 with TreatmentCriteria

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

the class CaseDao method deleteCaseAndAllDependingEntities.

public void deleteCaseAndAllDependingEntities(String caseUuid) throws SQLException {
    Case caze = queryUuidWithEmbedded(caseUuid);
    // Cancel if not in local database
    if (caze == null) {
        return;
    }
    // Delete contacts, contact tasks and visits
    List<Contact> contacts = DatabaseHelper.getContactDao().getByCase(caze);
    for (Contact contact : contacts) {
        DatabaseHelper.getContactDao().deleteContactAndAllDependingEntities(contact);
    }
    // Delete samples, pathogen tests and additional tests
    List<Sample> samples = DatabaseHelper.getSampleDao().queryByCase(caze);
    for (Sample sample : samples) {
        DatabaseHelper.getSampleDao().deleteSampleAndAllDependingEntities(sample);
    }
    // Delete case tasks
    List<Task> tasks = DatabaseHelper.getTaskDao().queryByCase(caze);
    for (Task task : tasks) {
        DatabaseHelper.getTaskDao().deleteCascade(task);
    }
    // Delete treatments and prescriptions
    if (caze.getTherapy() != null) {
        for (Treatment treatment : DatabaseHelper.getTreatmentDao().findBy(new TreatmentCriteria().therapy(caze.getTherapy()))) {
            DatabaseHelper.getTreatmentDao().delete(treatment);
        }
        for (Prescription prescription : DatabaseHelper.getPrescriptionDao().findBy(new PrescriptionCriteria().therapy(caze.getTherapy()))) {
            DatabaseHelper.getPrescriptionDao().delete(prescription);
        }
    }
    // Delete clinical visits
    if (caze.getClinicalCourse() != null) {
        for (ClinicalVisit clinicalVisit : DatabaseHelper.getClinicalVisitDao().findBy(new ClinicalVisitCriteria().clinicalCourse(caze.getClinicalCourse()))) {
            DatabaseHelper.getClinicalVisitDao().delete(clinicalVisit);
        }
    }
    // Remove events linked to case by removing case_id from event participants - delete event participant and
    List<EventParticipant> eventParticipants = DatabaseHelper.getEventParticipantDao().getByCase(caze);
    for (EventParticipant eventParticipant : eventParticipants) {
        DatabaseHelper.getEventParticipantDao().deleteEventParticipant(eventParticipant);
    }
    // Remove events outside jurisdiction which were pulled in due to linking with an accessible case
    EventCriteria eventCriteria = new EventCriteria();
    eventCriteria.caze(caze);
    List<Event> eventList = DatabaseHelper.getEventDao().queryByCriteria(eventCriteria, 0, 0);
    for (Event event : eventList) {
        List<EventParticipant> eventParticipantByEventList = DatabaseHelper.getEventParticipantDao().getByEvent(event);
        if (eventParticipantByEventList.isEmpty()) {
            Boolean isEventInJurisdiction = EventEditAuthorization.isEventEditAllowed(event);
            if (!isEventInJurisdiction) {
                DatabaseHelper.getEventDao().delete(event);
            }
        }
    }
    // Delete case
    deleteCascade(caze);
}
Also used : Prescription(de.symeda.sormas.app.backend.therapy.Prescription) PrescriptionCriteria(de.symeda.sormas.app.backend.therapy.PrescriptionCriteria) Task(de.symeda.sormas.app.backend.task.Task) Sample(de.symeda.sormas.app.backend.sample.Sample) ClinicalVisit(de.symeda.sormas.app.backend.clinicalcourse.ClinicalVisit) ClinicalVisitCriteria(de.symeda.sormas.app.backend.clinicalcourse.ClinicalVisitCriteria) EventCriteria(de.symeda.sormas.app.backend.event.EventCriteria) ActivityAsCase(de.symeda.sormas.app.backend.activityascase.ActivityAsCase) Contact(de.symeda.sormas.app.backend.contact.Contact) Treatment(de.symeda.sormas.app.backend.therapy.Treatment) TreatmentCriteria(de.symeda.sormas.app.backend.therapy.TreatmentCriteria) Event(de.symeda.sormas.app.backend.event.Event) EventParticipant(de.symeda.sormas.app.backend.event.EventParticipant)

Example 2 with TreatmentCriteria

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

the class TreatmentListViewModel method initializeViewModel.

public void initializeViewModel(Therapy therapy) {
    treatmentDataFactory = new TreatmentDataFactory();
    TreatmentCriteria treatmentCriteria = new TreatmentCriteria();
    treatmentCriteria.therapy(therapy);
    treatmentDataFactory.setTreatmentCriteria(treatmentCriteria);
    PagedList.Config config = new PagedList.Config.Builder().setEnablePlaceholders(true).setInitialLoadSizeHint(16).setPageSize(8).build();
    LivePagedListBuilder treatmentListBuilder = new LivePagedListBuilder(treatmentDataFactory, config);
    treatments = treatmentListBuilder.build();
}
Also used : PagedList(androidx.paging.PagedList) LivePagedListBuilder(androidx.paging.LivePagedListBuilder) LivePagedListBuilder(androidx.paging.LivePagedListBuilder) TreatmentCriteria(de.symeda.sormas.app.backend.therapy.TreatmentCriteria)

Aggregations

TreatmentCriteria (de.symeda.sormas.app.backend.therapy.TreatmentCriteria)2 LivePagedListBuilder (androidx.paging.LivePagedListBuilder)1 PagedList (androidx.paging.PagedList)1 ActivityAsCase (de.symeda.sormas.app.backend.activityascase.ActivityAsCase)1 ClinicalVisit (de.symeda.sormas.app.backend.clinicalcourse.ClinicalVisit)1 ClinicalVisitCriteria (de.symeda.sormas.app.backend.clinicalcourse.ClinicalVisitCriteria)1 Contact (de.symeda.sormas.app.backend.contact.Contact)1 Event (de.symeda.sormas.app.backend.event.Event)1 EventCriteria (de.symeda.sormas.app.backend.event.EventCriteria)1 EventParticipant (de.symeda.sormas.app.backend.event.EventParticipant)1 Sample (de.symeda.sormas.app.backend.sample.Sample)1 Task (de.symeda.sormas.app.backend.task.Task)1 Prescription (de.symeda.sormas.app.backend.therapy.Prescription)1 PrescriptionCriteria (de.symeda.sormas.app.backend.therapy.PrescriptionCriteria)1 Treatment (de.symeda.sormas.app.backend.therapy.Treatment)1