|
40 | 40 | import java.util.Objects; |
41 | 41 | import java.util.stream.Collectors; |
42 | 42 |
|
43 | | -import de.symeda.sormas.api.person.PersonReferenceDto; |
44 | 43 | import org.apache.commons.collections4.CollectionUtils; |
45 | 44 | import org.apache.commons.lang3.StringUtils; |
46 | 45 |
|
|
54 | 53 | import com.vaadin.ui.GridLayout; |
55 | 54 | import com.vaadin.ui.Image; |
56 | 55 | import com.vaadin.ui.Label; |
| 56 | +import com.vaadin.ui.VerticalLayout; |
57 | 57 | import com.vaadin.ui.Window; |
58 | 58 | import com.vaadin.ui.Window.CloseListener; |
59 | 59 | import com.vaadin.ui.themes.ValoTheme; |
|
70 | 70 | import com.vaadin.v7.ui.TextArea; |
71 | 71 | import com.vaadin.v7.ui.TextField; |
72 | 72 |
|
| 73 | +import de.symeda.sormas.api.CaseClassificationCalculationMode; |
73 | 74 | import de.symeda.sormas.api.CountryHelper; |
74 | 75 | import de.symeda.sormas.api.Disease; |
75 | 76 | import de.symeda.sormas.api.DiseaseHelper; |
|
115 | 116 | import de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup; |
116 | 117 | import de.symeda.sormas.api.infrastructure.region.RegionReferenceDto; |
117 | 118 | import de.symeda.sormas.api.person.PersonDto; |
| 119 | +import de.symeda.sormas.api.person.PersonReferenceDto; |
118 | 120 | import de.symeda.sormas.api.person.Sex; |
119 | 121 | import de.symeda.sormas.api.sample.PathogenTestDto; |
120 | 122 | import de.symeda.sormas.api.sample.SampleDto; |
@@ -1361,15 +1363,26 @@ && isVisibleAllowed(CaseDataDto.CASE_CLASSIFICATION)) { |
1361 | 1363 |
|
1362 | 1364 | // Automatic case classification rules button - invisible for other diseases |
1363 | 1365 | DiseaseClassificationCriteriaDto diseaseClassificationCriteria = FacadeProvider.getCaseClassificationFacade().getByDisease(disease); |
1364 | | - if (diseaseClassificationExists()) { |
1365 | | - Button classificationRulesButton = ButtonHelper.createIconButton( |
1366 | | - Captions.info, |
1367 | | - VaadinIcons.INFO_CIRCLE, |
1368 | | - e -> ControllerProvider.getCaseController().openClassificationRulesPopup(diseaseClassificationCriteria), |
1369 | | - ValoTheme.BUTTON_PRIMARY, |
1370 | | - FORCE_CAPTION); |
1371 | | - |
1372 | | - getContent().addComponent(classificationRulesButton, CLASSIFICATION_RULES_LOC); |
| 1366 | + |
| 1367 | + CaseClassificationCalculationMode caseClassificationCalculationMode = |
| 1368 | + FacadeProvider.getConfigFacade().getCaseClassificationCalculationMode(disease); |
| 1369 | + // If case classification is not disabled for the disease. |
| 1370 | + if (CaseClassificationCalculationMode.DISABLED != caseClassificationCalculationMode) { |
| 1371 | + // If automatic classification is enabled for the disease and it has the classification criteria. |
| 1372 | + if (FacadeProvider.getConfigFacade().getCaseClassificationCalculationMode(disease).isAutomaticEnabled() |
| 1373 | + && diseaseClassificationExists()) { |
| 1374 | + Button classificationRulesButton = ButtonHelper.createIconButton( |
| 1375 | + Captions.info, |
| 1376 | + VaadinIcons.INFO_CIRCLE, |
| 1377 | + e -> ControllerProvider.getCaseController().openClassificationRulesPopup(diseaseClassificationCriteria), |
| 1378 | + ValoTheme.BUTTON_PRIMARY, |
| 1379 | + FORCE_CAPTION); |
| 1380 | + |
| 1381 | + getContent().addComponent(classificationRulesButton, CLASSIFICATION_RULES_LOC); |
| 1382 | + } else { |
| 1383 | + // If Manual classification is enabled for the disease. |
| 1384 | + getManualCaseDefinition(); |
| 1385 | + } |
1373 | 1386 | } |
1374 | 1387 |
|
1375 | 1388 | addField(CaseDataDto.DELETION_REASON); |
@@ -1525,6 +1538,37 @@ public String getFormattedHtmlMessage() { |
1525 | 1538 | CaseDataDto.ADDITIONAL_DETAILS); |
1526 | 1539 | } |
1527 | 1540 |
|
| 1541 | + /** |
| 1542 | + * If a manual case definition is configured in the properties files and has the case definition in the disease configuration, |
| 1543 | + * then display the button with case definition. |
| 1544 | + */ |
| 1545 | + private void getManualCaseDefinition() { |
| 1546 | + // If a disease has caseDefinitionText, it should display; otherwise criteria will display as it is. |
| 1547 | + String caseDefinitionText = FacadeProvider.getDiseaseConfigurationFacade().getCaseDefinitionText(disease); |
| 1548 | + if (caseDefinitionText == null) { |
| 1549 | + return; |
| 1550 | + } |
| 1551 | + |
| 1552 | + Button caseDefinitionButton = ButtonHelper.createIconButton(Captions.info, VaadinIcons.INFO_CIRCLE, e -> { |
| 1553 | + VerticalLayout classificationRulesLayout = new VerticalLayout(); |
| 1554 | + classificationRulesLayout.setMargin(true); |
| 1555 | + Label suspectContent = new Label(); |
| 1556 | + suspectContent.setContentMode(ContentMode.HTML); |
| 1557 | + suspectContent.setWidth(100, Unit.PERCENTAGE); |
| 1558 | + suspectContent.setValue(caseDefinitionText); |
| 1559 | + classificationRulesLayout.addComponent(suspectContent); |
| 1560 | + Window popupWindow = VaadinUiUtil.showPopupWindow(classificationRulesLayout); |
| 1561 | + popupWindow.addCloseListener(e1 -> { |
| 1562 | + popupWindow.close(); |
| 1563 | + }); |
| 1564 | + popupWindow.setWidth(860, Unit.PIXELS); |
| 1565 | + popupWindow.setHeight(80, Unit.PERCENTAGE); |
| 1566 | + popupWindow.setCaption(I18nProperties.getString(Strings.classificationRulesFor) + " " + disease); |
| 1567 | + }, ValoTheme.BUTTON_PRIMARY, FORCE_CAPTION); |
| 1568 | + |
| 1569 | + getContent().addComponent(caseDefinitionButton, CLASSIFICATION_RULES_LOC); |
| 1570 | + } |
| 1571 | + |
1528 | 1572 | private void hideJurisdictionFields() { |
1529 | 1573 | getField(CaseDataDto.CASE_ORIGIN).setVisible(false); |
1530 | 1574 | getContent().getComponent(RESPONSIBLE_JURISDICTION_HEADING_LOC).setVisible(false); |
|
0 commit comments