Skip to content

Commit 85fd987

Browse files
Merge pull request #13229 from SORMAS-Foundation/#13209-case-outcome-warning
#13209 Update Person when case outcome is changed to "Deceased"
2 parents 71c14e5 + be146e4 commit 85fd987

File tree

6 files changed

+110
-4
lines changed

6 files changed

+110
-4
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,8 @@ public interface Captions {
972972
String Configuration_LineListing = "Configuration.LineListing";
973973
String Configuration_Outbreaks = "Configuration.Outbreaks";
974974
String Configuration_PointsOfEntry = "Configuration.PointsOfEntry";
975+
String confirmChangesField = "confirmChangesField";
976+
String confirmChangesValue = "confirmChangesValue";
975977
String Contact = "Contact";
976978
String Contact_additionalDetails = "Contact.additionalDetails";
977979
String Contact_ageAndBirthDate = "Contact.ageAndBirthDate";

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,7 @@ public interface Strings {
12031203
String messageCasesRestored = "messageCasesRestored";
12041204
String messageCaseTransfered = "messageCaseTransfered";
12051205
String messageChangePathogenTestResult = "messageChangePathogenTestResult";
1206+
String messageChangingCaseOutcome = "messageChangingCaseOutcome";
12061207
String messageCheckInputData = "messageCheckInputData";
12071208
String messageClinicalCourseSaved = "messageClinicalCourseSaved";
12081209
String messageClinicalVisitCreated = "messageClinicalVisitCreated";
@@ -1509,6 +1510,7 @@ public interface Strings {
15091510
String messageRelatedSampleAndLabMessagesFound = "messageRelatedSampleAndLabMessagesFound";
15101511
String messageRelatedSampleFound = "messageRelatedSampleFound";
15111512
String messageRestoreNotPossibleAlreadyInEvent = "messageRestoreNotPossibleAlreadyInEvent";
1513+
String messageReviewChangesAndConfirm = "messageReviewChangesAndConfirm";
15121514
String messageSampleErrors = "messageSampleErrors";
15131515
String messageSampleOpened = "messageSampleOpened";
15141516
String messageSampleSaved = "messageSampleSaved";
@@ -1819,6 +1821,7 @@ public interface Strings {
18191821
String unsavedChanges_warningTitle = "unsavedChanges.warningTitle";
18201822
String until = "until";
18211823
String uuidOf = "uuidOf";
1824+
String warning = "warning";
18221825
String warningDashboardMapTooManyMarkers = "warningDashboardMapTooManyMarkers";
18231826
String warningNetworkDiagramTooManyContacts = "warningNetworkDiagramTooManyContacts";
18241827
String week = "week";

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3392,3 +3392,6 @@ selfReportDeletedEnvironments=Deleted self reports
33923392
selfReportSelfReportsList=Self reports list
33933393
selfReportProcess=Process
33943394

3395+
confirmChangesField=Field:
3396+
confirmChangesValue=Will be changed to:
3397+

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ nameOf = Name of %s
8585
uuidOf = UUID of %s
8686
listOf = List of %s
8787
mapOf = Map of <%s , %s>
88+
warning = Warning
8889

8990
# Aggregate Report
9091
aggregateReportLegend = %s = %s; %s = %s; %s = %s
@@ -1572,6 +1573,8 @@ messageAdverseEventInvestigationSaved=Adverse event investigation saved
15721573
messagePersonNationalHealthIdInvalid=The entered national health ID does not seem to be correct
15731574
messageSyncUsersFromAuthProviderConfigurationError=Syncing users from authentication provider is not possible because the configuration is incorrect. Please contact an admin and inform them about this issue.
15741575
messageCountriesExcludedFromDataProtection=Countries excluded from data protection for this field:
1576+
messageChangingCaseOutcome=Changing this information will also affect the associated person.
1577+
messageReviewChangesAndConfirm=Please review the changes and confirm them:
15751578

15761579
# Notifications
15771580
notificationCaseClassificationChanged = The classification of case %s has changed to %s.

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

Lines changed: 97 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import org.apache.commons.collections4.CollectionUtils;
2929

30+
import com.vaadin.icons.VaadinIcons;
3031
import com.vaadin.navigator.Navigator;
3132
import com.vaadin.server.ExternalResource;
3233
import com.vaadin.server.Page;
@@ -61,6 +62,7 @@
6162
import de.symeda.sormas.api.caze.CaseIndexDto;
6263
import de.symeda.sormas.api.caze.CaseLogic;
6364
import de.symeda.sormas.api.caze.CaseOrigin;
65+
import de.symeda.sormas.api.caze.CaseOutcome;
6466
import de.symeda.sormas.api.caze.CaseSelectionDto;
6567
import de.symeda.sormas.api.caze.CaseSimilarityCriteria;
6668
import de.symeda.sormas.api.caze.classification.ClassificationHtmlRenderer;
@@ -97,8 +99,10 @@
9799
import de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto;
98100
import de.symeda.sormas.api.infrastructure.region.RegionReferenceDto;
99101
import de.symeda.sormas.api.messaging.MessageType;
102+
import de.symeda.sormas.api.person.CauseOfDeath;
100103
import de.symeda.sormas.api.person.PersonDto;
101104
import de.symeda.sormas.api.person.PersonReferenceDto;
105+
import de.symeda.sormas.api.person.PresentCondition;
102106
import de.symeda.sormas.api.symptoms.SymptomsContext;
103107
import de.symeda.sormas.api.symptoms.SymptomsDto;
104108
import de.symeda.sormas.api.symptoms.SymptomsHelper;
@@ -139,6 +143,7 @@
139143
import de.symeda.sormas.ui.utils.ButtonHelper;
140144
import de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent;
141145
import de.symeda.sormas.ui.utils.CssStyles;
146+
import de.symeda.sormas.ui.utils.DateFormatHelper;
142147
import de.symeda.sormas.ui.utils.DeleteRestoreHandlers;
143148
import de.symeda.sormas.ui.utils.DetailSubComponentWrapper;
144149
import de.symeda.sormas.ui.utils.FieldAccessHelper;
@@ -1442,13 +1447,13 @@ public void saveCaseWithFacilityChangedPrompt(CaseDataDto caze, CaseDataDto oldC
14421447
switch (option) {
14431448
case OPTION1: {
14441449
caze.getHospitalization().setAdmittedToHealthFacility((YesNoUnknown) admittedToHealthFacilityField.getNullableValue());
1445-
saveCase(caze);
1450+
saveCaseWithOutcomeChangedWarning(caze, oldCase);
14461451
ControllerProvider.getCaseController().navigateToView(HospitalizationView.VIEW_NAME, caze.getUuid(), null);
14471452
}
14481453
break;
14491454
case OPTION2: {
14501455
caze.getHospitalization().setAdmittedToHealthFacility((YesNoUnknown) admittedToHealthFacilityField.getNullableValue());
1451-
saveCase(caze);
1456+
saveCaseWithOutcomeChangedWarning(caze, oldCase);
14521457
ControllerProvider.getCaseController().navigateToView(CaseDataView.VIEW_NAME, caze.getUuid(), null);
14531458
}
14541459
break;
@@ -1468,12 +1473,100 @@ public void saveCaseWithFacilityChangedPrompt(CaseDataDto caze, CaseDataDto oldC
14681473
500,
14691474
e -> {
14701475
CaseLogic.handleHospitalization(caze, oldCase, e.booleanValue());
1471-
saveCase(caze);
1476+
saveCaseWithOutcomeChangedWarning(caze, oldCase);
14721477
SormasUI.refreshView();
14731478
});
14741479
} else {
1475-
saveCase(caze);
1480+
saveCaseWithOutcomeChangedWarning(caze, oldCase);
1481+
}
1482+
}
1483+
1484+
private void saveCaseWithOutcomeChangedWarning(CaseDataDto caze, CaseDataDto oldCase) {
1485+
PersonDto person = FacadeProvider.getPersonFacade().getByUuid(caze.getPerson().getUuid());
1486+
PresentCondition presentCondition = person.getPresentCondition();
1487+
if (caze.getOutcome() == CaseOutcome.DECEASED
1488+
&& oldCase.getOutcome() != CaseOutcome.DECEASED
1489+
&& presentCondition != PresentCondition.DEAD
1490+
&& presentCondition != PresentCondition.BURIED) {
1491+
1492+
if (!DataHelper.equal(person.getDeathDate(), caze.getOutcomeDate())
1493+
|| !DataHelper.equal(person.getCauseOfDeath(), CauseOfDeath.EPIDEMIC_DISEASE)
1494+
|| !DataHelper.equal(person.getCauseOfDeathDisease(), caze.getDisease())) {
1495+
VerticalLayout warningLayout = new VerticalLayout();
1496+
warningLayout.setSpacing(false);
1497+
CommitDiscardWrapperComponent<VerticalLayout> warningComponent = new CommitDiscardWrapperComponent<>(warningLayout);
1498+
warningComponent.setWidth(100, Unit.PERCENTAGE);
1499+
1500+
Window popupWindow = VaadinUiUtil.showPopupWindow(warningComponent, I18nProperties.getString(Strings.warning));
1501+
Label infoLabel = new Label(I18nProperties.getString(Strings.messageChangingCaseOutcome));
1502+
CssStyles.style(infoLabel, CssStyles.LABEL_LARGE, CssStyles.LABEL_WHITE_SPACE_NORMAL);
1503+
warningLayout.addComponent(infoLabel);
1504+
1505+
// Person information
1506+
warningLayout.addComponent(new Label(person.buildCaption() + " - " + person.getUuid()));
1507+
1508+
// confirmation message
1509+
Label confirmationMessage = new Label(I18nProperties.getString(Strings.messageReviewChangesAndConfirm));
1510+
confirmationMessage.addStyleName(CssStyles.VSPACE_TOP_3);
1511+
warningLayout.addComponent(confirmationMessage);
1512+
1513+
// changes listed
1514+
HorizontalLayout changesLayout = new HorizontalLayout();
1515+
changesLayout.setMargin(false);
1516+
changesLayout.addStyleNames(CssStyles.VSPACE_TOP_1, CssStyles.VSPACE_2);
1517+
1518+
VerticalLayout fieldsLayout = new VerticalLayout();
1519+
fieldsLayout.setMargin(false);
1520+
1521+
Label fieldsLabel = new Label(I18nProperties.getCaption(Captions.confirmChangesField));
1522+
fieldsLayout.addComponent(fieldsLabel);
1523+
fieldsLabel.addStyleName(CssStyles.LABEL_SECONDARY);
1524+
fieldsLayout.addComponent(new Label(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.PRESENT_CONDITION)));
1525+
fieldsLayout.addComponent(new Label(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.CAUSE_OF_DEATH)));
1526+
fieldsLayout.addComponent(new Label(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.CAUSE_OF_DEATH_DISEASE)));
1527+
fieldsLayout.addComponent(new Label(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.DEATH_DATE)));
1528+
1529+
VerticalLayout arrowsLayout = new VerticalLayout();
1530+
arrowsLayout.setMargin(false);
1531+
1532+
arrowsLayout.addComponent(new Label());
1533+
arrowsLayout.addComponent(new Label(VaadinIcons.ARROW_RIGHT.getHtml(), ContentMode.HTML));
1534+
arrowsLayout.addComponent(new Label(VaadinIcons.ARROW_RIGHT.getHtml(), ContentMode.HTML));
1535+
arrowsLayout.addComponent(new Label(VaadinIcons.ARROW_RIGHT.getHtml(), ContentMode.HTML));
1536+
arrowsLayout.addComponent(new Label(VaadinIcons.ARROW_RIGHT.getHtml(), ContentMode.HTML));
1537+
1538+
VerticalLayout valuesLayout = new VerticalLayout();
1539+
valuesLayout.setMargin(false);
1540+
1541+
Label valuesLabel = new Label(I18nProperties.getCaption(Captions.confirmChangesValue));
1542+
valuesLabel.addStyleName(CssStyles.LABEL_SECONDARY);
1543+
valuesLayout.addComponent(valuesLabel);
1544+
valuesLayout.addComponent(
1545+
new Label((person.getPresentCondition() == null ? PresentCondition.DEAD : person.getPresentCondition()).toString()));
1546+
valuesLayout.addComponent(new Label(CauseOfDeath.EPIDEMIC_DISEASE.toString()));
1547+
valuesLayout.addComponent(new Label(caze.getDisease().toString()));
1548+
valuesLayout.addComponent(new Label(DateFormatHelper.formatDate(caze.getOutcomeDate())));
1549+
1550+
changesLayout.addComponent(fieldsLayout);
1551+
changesLayout.addComponent(arrowsLayout);
1552+
changesLayout.addComponent(valuesLayout);
1553+
warningLayout.addComponent(changesLayout);
1554+
1555+
// actions
1556+
warningComponent.addCommitListener(() -> {
1557+
saveCase(caze);
1558+
popupWindow.close();
1559+
});
1560+
warningComponent.addDiscardListener(() -> popupWindow.close());
1561+
1562+
// popup configuration
1563+
popupWindow.addCloseListener(e -> popupWindow.close());
1564+
popupWindow.setWidth(600, Sizeable.Unit.PIXELS);
1565+
1566+
return;
1567+
}
14761568
}
1569+
saveCase(caze);
14771570
}
14781571

14791572
public void referFromPointOfEntry(CaseDataDto caze) {

sormas-ui/src/main/java/de/symeda/sormas/ui/caze/surveillancereport/SurveillanceReportList.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ private HorizontalLayout createRow(@Null String label, Object value, String prop
189189
HorizontalLayout row = new HorizontalLayout();
190190
row.setMargin(false);
191191
row.setSpacing(false);
192+
row.setWidth(100, Unit.PERCENTAGE);
192193

193194
if (label != null) {
194195
Label rowLabel = new Label(DataHelper.toStringNullable(label) + ":");
@@ -197,6 +198,7 @@ private HorizontalLayout createRow(@Null String label, Object value, String prop
197198
}
198199

199200
Label rowValue = new Label(DataHelper.toStringNullable(value));
201+
rowValue.addStyleName(CssStyles.LABEL_WHITE_SPACE_NORMAL);
200202
if (!fieldAccessCheckers.isAccessible(SurveillanceReportDto.class, propertyId)) {
201203
rowValue.addStyleName(CssStyles.INACCESSIBLE_LABEL);
202204
}

0 commit comments

Comments
 (0)