Search in sources :

Example 1 with ClinicalVisit

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

the class ClinicalVisitEditActivity 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 ClinicalVisit clinicalVisit = getStoredRootEntity();
    try {
        FragmentValidator.validate(getContext(), getActiveFragment().getContentBinding());
    } catch (ValidationException e) {
        NotificationHelper.showNotification(this, ERROR, e.getMessage());
        return;
    }
    saveTask = new SavingAsyncTask(getRootView(), clinicalVisit) {

        @Override
        protected void onPreExecute() {
            showPreloader();
        }

        @Override
        public void doInBackground(TaskResultHolder resultHolder) throws Exception {
            DatabaseHelper.getClinicalVisitDao().saveAndSnapshot(clinicalVisit);
        }

        @Override
        protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
            hidePreloader();
            super.onPostExecute(taskResult);
            if (taskResult.getResultStatus().isSuccess()) {
                goToNextPage();
            } else {
                // reload data
                onResume();
            }
            saveTask = null;
        }
    }.executeOnThreadPool();
}
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) ClinicalVisit(de.symeda.sormas.app.backend.clinicalcourse.ClinicalVisit) SavingAsyncTask(de.symeda.sormas.app.core.async.SavingAsyncTask)

Example 2 with ClinicalVisit

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

the class ClinicalVisitNewActivity 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 ClinicalVisit clinicalVisit = getStoredRootEntity();
    ClinicalVisitEditFragment fragment = (ClinicalVisitEditFragment) getActiveFragment();
    fragment.setLiveValidationDisabled(false);
    try {
        FragmentValidator.validate(getContext(), getActiveFragment().getContentBinding());
    } catch (ValidationException e) {
        NotificationHelper.showNotification(this, ERROR, e.getMessage());
        return;
    }
    saveTask = new SavingAsyncTask(getRootView(), clinicalVisit) {

        @Override
        protected void onPreExecute() {
            showPreloader();
        }

        @Override
        public void doInBackground(TaskResultHolder resultHolder) throws Exception {
            DatabaseHelper.getClinicalVisitDao().saveAndSnapshot(clinicalVisit);
        }

        @Override
        protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
            hidePreloader();
            super.onPostExecute(taskResult);
            if (taskResult.getResultStatus().isSuccess()) {
                finish();
                ClinicalVisitEditActivity.startActivity(getContext(), clinicalVisit.getUuid(), caseUuid, ClinicalVisitSection.CLINICAL_MEASUREMENTS);
            }
            saveTask = null;
        }
    }.executeOnThreadPool();
}
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) ClinicalVisit(de.symeda.sormas.app.backend.clinicalcourse.ClinicalVisit) SavingAsyncTask(de.symeda.sormas.app.core.async.SavingAsyncTask)

Example 3 with ClinicalVisit

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

the class CaseReadClinicalVisitListFragment method onListItemClick.

@Override
public void onListItemClick(View view, int position, Object item) {
    ClinicalVisit clinicalVisit = (ClinicalVisit) item;
    ClinicalVisitReadActivity.startActivity(getActivity(), clinicalVisit.getUuid(), getActivityRootData().getUuid(), ClinicalVisitSection.VISIT_INFO);
}
Also used : ClinicalVisit(de.symeda.sormas.app.backend.clinicalcourse.ClinicalVisit)

Example 4 with ClinicalVisit

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

the class ClinicalVisitListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
    super.onBindViewHolder(holder, position);
    if (getItemViewType(position) == TYPE_ITEM) {
        BindingViewHolder<ClinicalVisit, RowClinicalVisitListItemLayoutBinding> pagedHolder = (BindingViewHolder) holder;
        ClinicalVisit item = getItem(position);
        pagedHolder.binding.setSymptoms(item.getSymptoms());
        pagedHolder.setOnListItemClickListener(this.mOnListItemClickListener);
        if (item.isModifiedOrChildModified()) {
            pagedHolder.binding.imgSyncIcon.setVisibility(View.VISIBLE);
            pagedHolder.binding.imgSyncIcon.setImageResource(R.drawable.ic_sync_blue_24dp);
        } else {
            pagedHolder.binding.imgSyncIcon.setVisibility(View.GONE);
        }
    }
// TODO #704
// updateUnreadIndicator(holder, record);
}
Also used : BindingViewHolder(de.symeda.sormas.app.core.adapter.databinding.BindingViewHolder) RowClinicalVisitListItemLayoutBinding(de.symeda.sormas.app.databinding.RowClinicalVisitListItemLayoutBinding) ClinicalVisit(de.symeda.sormas.app.backend.clinicalcourse.ClinicalVisit)

Example 5 with ClinicalVisit

use of de.symeda.sormas.app.backend.clinicalcourse.ClinicalVisit 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)

Aggregations

ClinicalVisit (de.symeda.sormas.app.backend.clinicalcourse.ClinicalVisit)10 Case (de.symeda.sormas.app.backend.caze.Case)4 Visit (de.symeda.sormas.app.backend.visit.Visit)4 ActivityAsCase (de.symeda.sormas.app.backend.activityascase.ActivityAsCase)3 Contact (de.symeda.sormas.app.backend.contact.Contact)3 Event (de.symeda.sormas.app.backend.event.Event)3 EventParticipant (de.symeda.sormas.app.backend.event.EventParticipant)3 Person (de.symeda.sormas.app.backend.person.Person)3 MeansOfImmunization (de.symeda.sormas.api.immunization.MeansOfImmunization)2 ValidationException (de.symeda.sormas.api.utils.ValidationException)2 Campaign (de.symeda.sormas.app.backend.campaign.Campaign)2 CampaignFormData (de.symeda.sormas.app.backend.campaign.data.CampaignFormData)2 CampaignFormMeta (de.symeda.sormas.app.backend.campaign.form.CampaignFormMeta)2 MaternalHistory (de.symeda.sormas.app.backend.caze.maternalhistory.MaternalHistory)2 PortHealthInfo (de.symeda.sormas.app.backend.caze.porthealthinfo.PortHealthInfo)2 DiseaseClassificationCriteria (de.symeda.sormas.app.backend.classification.DiseaseClassificationCriteria)2 ClinicalCourse (de.symeda.sormas.app.backend.clinicalcourse.ClinicalCourse)2 HealthConditions (de.symeda.sormas.app.backend.clinicalcourse.HealthConditions)2 CustomizableEnumValue (de.symeda.sormas.app.backend.customizableenum.CustomizableEnumValue)2 DiseaseConfiguration (de.symeda.sormas.app.backend.disease.DiseaseConfiguration)2