Search in sources :

Example 1 with Case

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

the class CaseEditFragment method setUpButtonListeners.

private void setUpButtonListeners(FragmentCaseEditLayoutBinding contentBinding) {
    contentBinding.referCaseFromPoe.setOnClickListener(e -> {
        final CaseEditActivity activity = (CaseEditActivity) CaseEditFragment.this.getActivity();
        activity.saveData(caze -> {
            final Case caseClone = (Case) caze.clone();
            final ReferCaseFromPoeDialog referCaseFromPoeDialog = new ReferCaseFromPoeDialog(BaseActivity.getActiveActivity(), caze);
            referCaseFromPoeDialog.setPositiveCallback(() -> {
                record = caseClone;
                requestLayoutRebind();
            });
            referCaseFromPoeDialog.show();
        });
    });
    contentBinding.showClassificationRules.setOnClickListener(v -> {
        final InfoDialog classificationDialog = new InfoDialog(CaseEditFragment.this.getContext(), R.layout.dialog_classification_rules_layout, null);
        WebView classificationView = ((DialogClassificationRulesLayoutBinding) classificationDialog.getBinding()).content;
        classificationView.loadData(DiseaseClassificationAppHelper.buildDiseaseClassificationHtml(record.getDisease()), "text/html", "utf-8");
        classificationDialog.show();
    });
}
Also used : DialogClassificationRulesLayoutBinding(de.symeda.sormas.app.databinding.DialogClassificationRulesLayoutBinding) InfoDialog(de.symeda.sormas.app.component.dialog.InfoDialog) WebView(android.webkit.WebView) Case(de.symeda.sormas.app.backend.caze.Case)

Example 2 with Case

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

the class CaseEditMaternalHistoryFragment method prepareFragmentData.

@Override
protected void prepareFragmentData() {
    Case caze = getActivityRootData();
    record = caze.getMaternalHistory();
}
Also used : Case(de.symeda.sormas.app.backend.caze.Case)

Example 3 with Case

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

the class CaseNewFragment method onAfterLayoutBinding.

@Override
public void onAfterLayoutBinding(final FragmentCaseNewLayoutBinding contentBinding) {
    InfrastructureDaoHelper.initializeHealthFacilityDetailsFieldVisibility(contentBinding.caseDataHealthFacility, contentBinding.caseDataHealthFacilityDetails);
    InfrastructureDaoHelper.initializePointOfEntryDetailsFieldVisibility(contentBinding.caseDataPointOfEntry, contentBinding.caseDataPointOfEntryDetails);
    if (!ConfigProvider.isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY) && !ConfigProvider.isConfiguredServer(CountryHelper.COUNTRY_CODE_SWITZERLAND)) {
        contentBinding.caseDataExternalID.setVisibility(GONE);
        contentBinding.caseDataExternalToken.setVisibility(GONE);
    } else {
        contentBinding.caseDataEpidNumber.setVisibility(GONE);
    }
    contentBinding.caseDataResponsibleRegion.setEnabled(false);
    contentBinding.caseDataResponsibleRegion.setRequired(false);
    contentBinding.caseDataResponsibleDistrict.setEnabled(false);
    contentBinding.caseDataResponsibleDistrict.setRequired(false);
    User user = ConfigProvider.getUser();
    if (user.getPointOfEntry() == null) {
        contentBinding.facilityOrHome.setValue(TypeOfPlace.FACILITY);
    }
    if (user.hasUserRole(UserRole.HOSPITAL_INFORMANT) && user.getHealthFacility() != null) {
        // Hospital Informants are not allowed to create cases in another health facility
        contentBinding.caseDataCommunity.setEnabled(false);
        contentBinding.caseDataCommunity.setRequired(false);
        contentBinding.caseDataHealthFacility.setEnabled(false);
        contentBinding.caseDataHealthFacility.setRequired(false);
        contentBinding.facilityOrHome.setEnabled(false);
        contentBinding.facilityTypeGroup.setEnabled(false);
        contentBinding.caseDataFacilityType.setEnabled(false);
        contentBinding.caseDataDifferentPlaceOfStayJurisdiction.setEnabled(false);
        contentBinding.caseDataDifferentPlaceOfStayJurisdiction.setVisibility(GONE);
    }
    if (user.hasUserRole(UserRole.POE_INFORMANT) && user.getPointOfEntry() != null) {
        contentBinding.caseDataPointOfEntry.setEnabled(false);
        contentBinding.caseDataPointOfEntry.setRequired(false);
    }
    if (user.hasUserRole(UserRole.COMMUNITY_INFORMANT) && user.getCommunity() != null) {
        // Community Informants are not allowed to create cases in another community
        contentBinding.caseDataCommunity.setEnabled(false);
        contentBinding.caseDataCommunity.setRequired(false);
    }
    // Disable personal details and disease fields when case is created from contact
    // or event person
    Bundler bundler = new Bundler(getArguments());
    if (bundler.getContactUuid() != null || bundler.getEventParticipantUuid() != null) {
        contentBinding.caseDataFirstName.setEnabled(false);
        contentBinding.caseDataLastName.setEnabled(false);
        contentBinding.personSex.setEnabled(false);
        contentBinding.personBirthdateYYYY.setEnabled(false);
        contentBinding.personBirthdateMM.setEnabled(false);
        contentBinding.personBirthdateDD.setEnabled(false);
        contentBinding.caseDataDisease.setEnabled(false);
        contentBinding.caseDataDiseaseDetails.setEnabled(false);
        contentBinding.caseDataPlagueType.setEnabled(false);
        contentBinding.caseDataDengueFeverType.setEnabled(false);
        contentBinding.caseDataHumanRabiesType.setEnabled(false);
    }
    // Set up port health visibilities
    if (UserRole.isPortHealthUser(ConfigProvider.getUser().getUserRoles())) {
        contentBinding.caseDataCaseOrigin.setVisibility(GONE);
        contentBinding.caseDataDisease.setVisibility(GONE);
        contentBinding.facilityOrHome.setVisibility(GONE);
        contentBinding.caseDataCommunity.setVisibility(GONE);
        contentBinding.facilityTypeFieldsLayout.setVisibility(GONE);
        contentBinding.caseDataHealthFacility.setVisibility(GONE);
        contentBinding.facilityTypeGroup.setRequired(false);
        contentBinding.caseDataFacilityType.setRequired(false);
        contentBinding.caseDataHealthFacility.setRequired(false);
        contentBinding.caseDataHealthFacilityDetails.setRequired(false);
    } else if (DatabaseHelper.getPointOfEntryDao().hasActiveEntriesInDistrict()) {
        if (record.getCaseOrigin() == CaseOrigin.IN_COUNTRY) {
            contentBinding.caseDataPointOfEntry.setRequired(false);
            contentBinding.caseDataPointOfEntry.setVisibility(GONE);
        } else {
            contentBinding.caseDataHealthFacility.setRequired(false);
        }
        contentBinding.caseDataCaseOrigin.addValueChangedListener(e -> {
            if (e.getValue() == CaseOrigin.IN_COUNTRY) {
                contentBinding.caseDataPointOfEntry.setVisibility(GONE);
                contentBinding.caseDataPointOfEntry.setRequired(false);
                contentBinding.caseDataPointOfEntry.setValue(null);
                contentBinding.caseDataHealthFacility.setRequired(true);
            } else {
                contentBinding.caseDataPointOfEntry.setVisibility(VISIBLE);
                contentBinding.caseDataHealthFacility.setRequired(false);
                contentBinding.caseDataPointOfEntry.setRequired(true);
            }
        });
    } else {
        contentBinding.caseDataCaseOrigin.setVisibility(GONE);
        contentBinding.caseDataPointOfEntry.setVisibility(GONE);
    }
}
Also used : PlagueType(de.symeda.sormas.api.caze.PlagueType) DataUtils(de.symeda.sormas.app.util.DataUtils) PersonValidator(de.symeda.sormas.app.person.edit.PersonValidator) DateHelper(de.symeda.sormas.api.utils.DateHelper) Facility(de.symeda.sormas.app.backend.facility.Facility) ArrayList(java.util.ArrayList) CustomizableEnumType(de.symeda.sormas.api.customizableenum.CustomizableEnumType) User(de.symeda.sormas.app.backend.user.User) Calendar(java.util.Calendar) ConfigProvider(de.symeda.sormas.app.backend.config.ConfigProvider) VISIBLE(android.view.View.VISIBLE) CountryHelper(de.symeda.sormas.api.CountryHelper) Item(de.symeda.sormas.app.component.Item) UserRole(de.symeda.sormas.api.user.UserRole) InfrastructureFieldsDependencyHandler(de.symeda.sormas.app.util.InfrastructureFieldsDependencyHandler) Bundler(de.symeda.sormas.app.util.Bundler) Case(de.symeda.sormas.app.backend.caze.Case) FragmentCaseNewLayoutBinding(de.symeda.sormas.app.databinding.FragmentCaseNewLayoutBinding) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) Sex(de.symeda.sormas.api.person.Sex) CaseOrigin(de.symeda.sormas.api.caze.CaseOrigin) DengueFeverType(de.symeda.sormas.api.caze.DengueFeverType) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) TypeOfPlace(de.symeda.sormas.api.event.TypeOfPlace) R(de.symeda.sormas.app.R) InfrastructureDaoHelper(de.symeda.sormas.app.util.InfrastructureDaoHelper) PresentCondition(de.symeda.sormas.api.person.PresentCondition) List(java.util.List) Disease(de.symeda.sormas.api.Disease) DiseaseConfigurationCache(de.symeda.sormas.app.util.DiseaseConfigurationCache) GONE(android.view.View.GONE) RabiesType(de.symeda.sormas.api.caze.RabiesType) DatabaseHelper(de.symeda.sormas.app.backend.common.DatabaseHelper) BaseEditFragment(de.symeda.sormas.app.BaseEditFragment) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) JurisdictionLevel(de.symeda.sormas.api.user.JurisdictionLevel) User(de.symeda.sormas.app.backend.user.User) Bundler(de.symeda.sormas.app.util.Bundler)

Example 4 with Case

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

the class CaseListFragment method onListItemClick.

@Override
public void onListItemClick(View view, int position, Object item) {
    Case caze = (Case) item;
    CaseReadActivity.startActivity(getContext(), caze.getUuid(), false);
}
Also used : Case(de.symeda.sormas.app.backend.caze.Case)

Example 5 with Case

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

the class EventNewActivity 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 Event eventToSave = (Event) getActiveFragment().getPrimaryData();
    EventEditFragment fragment = (EventEditFragment) getActiveFragment();
    if (caseUuid != null) {
        Case linkedCase = DatabaseHelper.getCaseDao().getByReferenceDto(new CaseReferenceDto(caseUuid));
        if (eventToSave.getDisease() != null && !eventToSave.getDisease().equals(linkedCase.getDisease())) {
            NotificationHelper.showNotification(this, WARNING, getString(R.string.message_Event_and_Case_disease_mismatch) + " " + linkedCase.getDisease());
            return;
        }
    }
    fragment.setLiveValidationDisabled(false);
    try {
        FragmentValidator.validate(getContext(), fragment.getContentBinding());
    } catch (ValidationException e) {
        NotificationHelper.showNotification(this, ERROR, e.getMessage());
        return;
    }
    saveTask = new SavingAsyncTask(getRootView(), eventToSave) {

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

        @Override
        public void doInBackground(TaskResultHolder resultHolder) throws DaoException {
            DatabaseHelper.getEventDao().saveAndSnapshot(eventToSave);
        }

        @Override
        protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
            hidePreloader();
            super.onPostExecute(taskResult);
            if (taskResult.getResultStatus().isSuccess()) {
                finish();
                if (caseUuid != null) {
                    EventParticipant eventParticipantToSave = DatabaseHelper.getEventParticipantDao().build();
                    Case linkedCase = DatabaseHelper.getCaseDao().getByReferenceDto(new CaseReferenceDto(caseUuid));
                    eventParticipantToSave.setPerson(linkedCase.getPerson());
                    eventParticipantToSave.setEvent(eventToSave);
                    eventParticipantToSave.setResultingCaseUuid(linkedCase.getUuid());
                    EventParticipantSaver eventParticipantSaver = new EventParticipantSaver(EventNewActivity.this);
                    eventParticipantSaver.saveEventParticipantLinkedToCase(eventParticipantToSave);
                } else {
                    EventEditActivity.startActivity(getContext(), eventToSave.getUuid(), EventSection.EVENT_PARTICIPANTS);
                }
            }
            saveTask = null;
        }
    }.executeOnThreadPool();
}
Also used : EventParticipantSaver(de.symeda.sormas.app.event.eventparticipant.EventParticipantSaver) ValidationException(de.symeda.sormas.api.utils.ValidationException) TaskResultHolder(de.symeda.sormas.app.core.async.TaskResultHolder) Event(de.symeda.sormas.app.backend.event.Event) AsyncTaskResult(de.symeda.sormas.app.core.async.AsyncTaskResult) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) SavingAsyncTask(de.symeda.sormas.app.core.async.SavingAsyncTask) EventParticipant(de.symeda.sormas.app.backend.event.EventParticipant) Case(de.symeda.sormas.app.backend.caze.Case)

Aggregations

Case (de.symeda.sormas.app.backend.caze.Case)69 Contact (de.symeda.sormas.app.backend.contact.Contact)20 Test (org.junit.Test)18 Person (de.symeda.sormas.app.backend.person.Person)15 User (de.symeda.sormas.app.backend.user.User)13 CaseDao (de.symeda.sormas.app.backend.caze.CaseDao)12 EventParticipant (de.symeda.sormas.app.backend.event.EventParticipant)12 District (de.symeda.sormas.app.backend.region.District)12 Date (java.util.Date)12 Event (de.symeda.sormas.app.backend.event.Event)11 Facility (de.symeda.sormas.app.backend.facility.Facility)10 Task (de.symeda.sormas.app.backend.task.Task)10 Immunization (de.symeda.sormas.app.backend.immunization.Immunization)9 Community (de.symeda.sormas.app.backend.region.Community)9 Region (de.symeda.sormas.app.backend.region.Region)8 Sample (de.symeda.sormas.app.backend.sample.Sample)8 Disease (de.symeda.sormas.api.Disease)7 UserRole (de.symeda.sormas.api.user.UserRole)7 TaskDao (de.symeda.sormas.app.backend.task.TaskDao)7 Visit (de.symeda.sormas.app.backend.visit.Visit)7