diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditActivity.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditActivity.java index 179e2b7205d..2f3c62ca52e 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditActivity.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/caze/edit/CaseEditActivity.java @@ -23,12 +23,15 @@ import android.content.Context; import android.os.AsyncTask; import android.view.Menu; + import de.symeda.sormas.api.Disease; import de.symeda.sormas.api.caze.CaseClassification; import de.symeda.sormas.api.caze.CaseOrigin; import de.symeda.sormas.api.caze.CaseReferenceDto; import de.symeda.sormas.api.feature.FeatureType; import de.symeda.sormas.api.feature.FeatureTypeProperty; +import de.symeda.sormas.api.i18n.I18nProperties; +import de.symeda.sormas.api.i18n.Strings; import de.symeda.sormas.api.user.UserRight; import de.symeda.sormas.api.utils.DataHelper; import de.symeda.sormas.api.utils.ValidationException; @@ -351,9 +354,15 @@ private void linkEventToCase() { eventParticipantToSave.setResultingCaseUuid(caze.getUuid()); EventParticipantSaver eventParticipantSaver = new EventParticipantSaver(this); - if (!isEventLinkedToCase(caze, event) - && !DatabaseHelper.getEventParticipantDao().eventParticipantAlreadyExists(event, caze.getPerson())) { - eventParticipantSaver.saveEventParticipantLinkedToCase(eventParticipantToSave); + if (!isEventLinkedToCase(caze, event)) { + boolean eventParticipantAlreadyExists = + DatabaseHelper.getEventParticipantDao().eventParticipantAlreadyExists(event, caze.getPerson()); + eventParticipantSaver.saveEventParticipantLinkedToCase(eventParticipantToSave, eventParticipantAlreadyExists); + + if (eventParticipantAlreadyExists) { + NotificationHelper.showNotification(this, WARNING, I18nProperties.getString(Strings.messagePersonAlreadyEventParticipant)); + } + } else { NotificationHelper .showNotification(this, WARNING, getString(R.string.message_Event_already_linked_to_Case) + " " + caze.getUuid()); diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/event/edit/EventNewActivity.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/event/edit/EventNewActivity.java index b024977ac19..bb275c23ca8 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/event/edit/EventNewActivity.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/event/edit/EventNewActivity.java @@ -175,7 +175,7 @@ protected void onPostExecute(AsyncTaskResult taskResult) { eventParticipantToSave.setEvent(eventToSave); eventParticipantToSave.setResultingCaseUuid(linkedCase.getUuid()); EventParticipantSaver eventParticipantSaver = new EventParticipantSaver(EventNewActivity.this); - eventParticipantSaver.saveEventParticipantLinkedToCase(eventParticipantToSave); + eventParticipantSaver.saveEventParticipantLinkedToCase(eventParticipantToSave, false); } else { EventEditActivity.startActivity(getContext(), eventToSave.getUuid(), EventSection.EVENT_PARTICIPANTS); } diff --git a/sormas-app/app/src/main/java/de/symeda/sormas/app/event/eventparticipant/EventParticipantSaver.java b/sormas-app/app/src/main/java/de/symeda/sormas/app/event/eventparticipant/EventParticipantSaver.java index 0e39523a2b3..d4a8ccbd1d0 100644 --- a/sormas-app/app/src/main/java/de/symeda/sormas/app/event/eventparticipant/EventParticipantSaver.java +++ b/sormas-app/app/src/main/java/de/symeda/sormas/app/event/eventparticipant/EventParticipantSaver.java @@ -15,7 +15,7 @@ public EventParticipantSaver(BaseActivity parentActivity) { this.parentActivity = parentActivity; } - public void saveEventParticipantLinkedToCase(EventParticipant eventParticipantToSave) { + public void saveEventParticipantLinkedToCase(EventParticipant eventParticipantToSave, boolean eventParticipantAlreadyExists) { new SavingAsyncTask(parentActivity.getRootView(), eventParticipantToSave) { @@ -32,7 +32,11 @@ protected void doInBackground(TaskResultHolder resultHolder) throws Exception { @Override protected void onPostExecute(AsyncTaskResult taskResult) { parentActivity.hidePreloader(); - super.onPostExecute(taskResult); + + if (!eventParticipantAlreadyExists) { + super.onPostExecute(taskResult); + } + if (taskResult.getResultStatus().isSuccess()) { parentActivity.finish(); }