27
27
28
28
import org .apache .commons .collections4 .CollectionUtils ;
29
29
30
+ import com .vaadin .icons .VaadinIcons ;
30
31
import com .vaadin .navigator .Navigator ;
31
32
import com .vaadin .server .ExternalResource ;
32
33
import com .vaadin .server .Page ;
61
62
import de .symeda .sormas .api .caze .CaseIndexDto ;
62
63
import de .symeda .sormas .api .caze .CaseLogic ;
63
64
import de .symeda .sormas .api .caze .CaseOrigin ;
65
+ import de .symeda .sormas .api .caze .CaseOutcome ;
64
66
import de .symeda .sormas .api .caze .CaseSelectionDto ;
65
67
import de .symeda .sormas .api .caze .CaseSimilarityCriteria ;
66
68
import de .symeda .sormas .api .caze .classification .ClassificationHtmlRenderer ;
97
99
import de .symeda .sormas .api .infrastructure .pointofentry .PointOfEntryDto ;
98
100
import de .symeda .sormas .api .infrastructure .region .RegionReferenceDto ;
99
101
import de .symeda .sormas .api .messaging .MessageType ;
102
+ import de .symeda .sormas .api .person .CauseOfDeath ;
100
103
import de .symeda .sormas .api .person .PersonDto ;
101
104
import de .symeda .sormas .api .person .PersonReferenceDto ;
105
+ import de .symeda .sormas .api .person .PresentCondition ;
102
106
import de .symeda .sormas .api .symptoms .SymptomsContext ;
103
107
import de .symeda .sormas .api .symptoms .SymptomsDto ;
104
108
import de .symeda .sormas .api .symptoms .SymptomsHelper ;
139
143
import de .symeda .sormas .ui .utils .ButtonHelper ;
140
144
import de .symeda .sormas .ui .utils .CommitDiscardWrapperComponent ;
141
145
import de .symeda .sormas .ui .utils .CssStyles ;
146
+ import de .symeda .sormas .ui .utils .DateFormatHelper ;
142
147
import de .symeda .sormas .ui .utils .DeleteRestoreHandlers ;
143
148
import de .symeda .sormas .ui .utils .DetailSubComponentWrapper ;
144
149
import de .symeda .sormas .ui .utils .FieldAccessHelper ;
@@ -1442,13 +1447,13 @@ public void saveCaseWithFacilityChangedPrompt(CaseDataDto caze, CaseDataDto oldC
1442
1447
switch (option ) {
1443
1448
case OPTION1 : {
1444
1449
caze .getHospitalization ().setAdmittedToHealthFacility ((YesNoUnknown ) admittedToHealthFacilityField .getNullableValue ());
1445
- saveCase (caze );
1450
+ saveCaseWithOutcomeChangedWarning (caze , oldCase );
1446
1451
ControllerProvider .getCaseController ().navigateToView (HospitalizationView .VIEW_NAME , caze .getUuid (), null );
1447
1452
}
1448
1453
break ;
1449
1454
case OPTION2 : {
1450
1455
caze .getHospitalization ().setAdmittedToHealthFacility ((YesNoUnknown ) admittedToHealthFacilityField .getNullableValue ());
1451
- saveCase (caze );
1456
+ saveCaseWithOutcomeChangedWarning (caze , oldCase );
1452
1457
ControllerProvider .getCaseController ().navigateToView (CaseDataView .VIEW_NAME , caze .getUuid (), null );
1453
1458
}
1454
1459
break ;
@@ -1468,12 +1473,100 @@ public void saveCaseWithFacilityChangedPrompt(CaseDataDto caze, CaseDataDto oldC
1468
1473
500 ,
1469
1474
e -> {
1470
1475
CaseLogic .handleHospitalization (caze , oldCase , e .booleanValue ());
1471
- saveCase (caze );
1476
+ saveCaseWithOutcomeChangedWarning (caze , oldCase );
1472
1477
SormasUI .refreshView ();
1473
1478
});
1474
1479
} 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
+ }
1476
1568
}
1569
+ saveCase (caze );
1477
1570
}
1478
1571
1479
1572
public void referFromPointOfEntry (CaseDataDto caze ) {
0 commit comments