Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 4b684c2

Browse files
Ensure that case and contact creation is only available for event with a disease SORMAS-Foundation#3919 (SORMAS-Foundation#4114)
1 parent 3fc0748 commit 4b684c2

4 files changed

Lines changed: 41 additions & 0 deletions

File tree

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Strings.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,10 @@ public interface Strings {
269269
String headingCreateNewAggregateReport = "headingCreateNewAggregateReport";
270270
String headingCreateNewCampaign = "headingCreateNewCampaign";
271271
String headingCreateNewCase = "headingCreateNewCase";
272+
String headingCreateNewCaseIssue = "headingCreateNewCaseIssue";
272273
String headingCreateNewClinicalVisit = "headingCreateNewClinicalVisit";
273274
String headingCreateNewContact = "headingCreateNewContact";
275+
String headingCreateNewContactIssue = "headingCreateNewContactIssue";
274276
String headingCreateNewEvent = "headingCreateNewEvent";
275277
String headingCreateNewEventParticipant = "headingCreateNewEventParticipant";
276278
String headingCreateNewFacility = "headingCreateNewFacility";
@@ -595,6 +597,7 @@ public interface Strings {
595597
String messageCaseDuplicateDeleted = "messageCaseDuplicateDeleted";
596598
String messageCaseIncidenceUnsupportedAgeGroup = "messageCaseIncidenceUnsupportedAgeGroup";
597599
String messageCaseReferredFromPoe = "messageCaseReferredFromPoe";
600+
String messageCaseRelationToEventWithoutDisease = "messageCaseRelationToEventWithoutDisease";
598601
String messageCasesArchived = "messageCasesArchived";
599602
String messageCaseSaved = "messageCaseSaved";
600603
String messageCaseSavedClassificationChanged = "messageCaseSavedClassificationChanged";
@@ -661,6 +664,8 @@ public interface Strings {
661664
String messageEventParticipantResponsibleJurisdictionUpdated = "messageEventParticipantResponsibleJurisdictionUpdated";
662665
String messageEventParticipantSaved = "messageEventParticipantSaved";
663666
String messageEventParticipantsDeleted = "messageEventParticipantsDeleted";
667+
String messageEventParticipantToCaseWithoutEventDisease = "messageEventParticipantToCaseWithoutEventDisease";
668+
String messageEventParticipantToContactWithoutEventDisease = "messageEventParticipantToContactWithoutEventDisease";
664669
String messageEventsArchived = "messageEventsArchived";
665670
String messageEventSaved = "messageEventSaved";
666671
String messageEventsDearchived = "messageEventsDearchived";

sormas-api/src/main/resources/strings.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,10 @@ headingCreateNewAction = Create new action
300300
headingCreateNewAggregateReport = Create a new aggregated report
301301
headingCreateNewCampaign = Create new campaign
302302
headingCreateNewCase = Create new case
303+
headingCreateNewCaseIssue = Case creation issue
303304
headingCreateNewClinicalVisit = Create new clinical assessment
304305
headingCreateNewContact = Create new contact
306+
headingCreateNewContactIssue = Contact creation issue
305307
headingCreateNewEvent = Create new event
306308
headingCreateNewEventParticipant = Add new event participant
307309
headingCreateNewFacility = Create new facility
@@ -632,6 +634,7 @@ messageCaseDearchived = Case has been de-archived
632634
messageCaseDuplicateDeleted = The duplicate case has been deleted.
633635
messageCaseIncidenceUnsupportedAgeGroup = Case incidence proportion can only be generated for 5 year intervals. Please remove all other age stratification filters and visualization groupings.
634636
messageCaseReferredFromPoe = Case has been referred to the specified facility
637+
messageCaseRelationToEventWithoutDisease=It is not possible to link a case to an event if the disease of the event has not been set
635638
messageCaseSaved = Case saved
636639
messageCaseSavedClassificationChanged = Case saved. The classification was automatically changed to %s.
637640
messageCaseTransfered = Case has been transfered to another facility
@@ -675,6 +678,8 @@ messageEventParticipantCreated = New person created
675678
messageEventParticipantSaved = Person data saved
676679
messageEventParticipantsDeleted = All selected event participants have been deleted
677680
messageEventParticipantResponsibleJurisdictionUpdated = Changing or removing the responsible jurisdiction of this event participant could make you lose access to its personal details and/or disallow you to edit it in the future. Are you sure you want to proceed?
681+
messageEventParticipantToCaseWithoutEventDisease=It is not possible to create cases from an event participant if the disease of the event has not been set
682+
messageEventParticipantToContactWithoutEventDisease=It is not possible to create a contact from an event participant if the disease of the event has not been set
678683
messageEventSaved = Event data saved
679684
messageEventsArchived = All selected events have been archived
680685
messageEventsDearchived = All selected events have been de-archived

sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseController.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,30 @@ public void create() {
158158
}
159159

160160
public void createFromEventParticipant(EventParticipantDto eventParticipant) {
161+
EventDto event = FacadeProvider.getEventFacade().getEventByUuid(eventParticipant.getEvent().getUuid());
162+
if (event.getDisease() == null) {
163+
new Notification(
164+
I18nProperties.getString(Strings.headingCreateNewCaseIssue),
165+
I18nProperties.getString(Strings.messageEventParticipantToCaseWithoutEventDisease),
166+
Notification.Type.ERROR_MESSAGE,
167+
false).show(Page.getCurrent());
168+
return;
169+
}
170+
161171
CommitDiscardWrapperComponent<CaseCreateForm> caseCreateComponent = getCaseCreateComponent(null, eventParticipant, null, false);
162172
VaadinUiUtil.showModalPopupWindow(caseCreateComponent, I18nProperties.getString(Strings.headingCreateNewCase));
163173
}
164174

165175
public void createFromEventParticipantDifferentDisease(EventParticipantDto eventParticipant, Disease disease) {
176+
if (disease == null) {
177+
new Notification(
178+
I18nProperties.getString(Strings.headingCreateNewCaseIssue),
179+
I18nProperties.getString(Strings.messageEventParticipantToCaseWithoutEventDisease),
180+
Notification.Type.ERROR_MESSAGE,
181+
false).show(Page.getCurrent());
182+
return;
183+
}
184+
166185
CommitDiscardWrapperComponent<CaseCreateForm> caseCreateComponent = getCaseCreateComponent(null, eventParticipant, disease, false);
167186
VaadinUiUtil.showModalPopupWindow(caseCreateComponent, I18nProperties.getString(Strings.headingCreateNewCase));
168187
}

sormas-ui/src/main/java/de/symeda/sormas/ui/contact/ContactController.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.Map;
2828
import java.util.function.Consumer;
2929

30+
import de.symeda.sormas.api.event.EventDto;
3031
import org.apache.commons.lang3.StringUtils;
3132
import org.jsoup.Jsoup;
3233
import org.jsoup.nodes.Document;
@@ -139,6 +140,17 @@ public void create(CaseReferenceDto caseRef, boolean asResultingCase, Runnable a
139140

140141
public void create(EventParticipantReferenceDto eventParticipantRef) {
141142
EventParticipantDto eventParticipant = FacadeProvider.getEventParticipantFacade().getEventParticipantByUuid(eventParticipantRef.getUuid());
143+
EventDto event = FacadeProvider.getEventFacade().getEventByUuid(eventParticipant.getEvent().getUuid());
144+
145+
if (event.getDisease() == null) {
146+
new Notification(
147+
I18nProperties.getString(Strings.headingCreateNewContactIssue),
148+
I18nProperties.getString(Strings.messageEventParticipantToContactWithoutEventDisease),
149+
Notification.Type.ERROR_MESSAGE,
150+
false).show(Page.getCurrent());
151+
return;
152+
}
153+
142154
CommitDiscardWrapperComponent<ContactCreateForm> createComponent = getContactCreateComponent(eventParticipant);
143155
VaadinUiUtil.showModalPopupWindow(createComponent, I18nProperties.getString(Strings.headingCreateNewContact));
144156
}

0 commit comments

Comments
 (0)