Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sormas-api/src/main/java/de/symeda/sormas/api/Disease.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public enum Disease
implements
StatisticsGroupingKey {

AFP(true, true, true, false, false, 0, true, false, false),
AFP(true, true, true, false, true, 60, true, false, false),
CHOLERA(true, true, true, false, true, 5, true, false, false),
CONGENITAL_RUBELLA(true, true, true, false, true, 21, true, false, false),
CSM(true, true, true, false, false, 10, true, false, false),
Expand Down Expand Up @@ -70,9 +70,9 @@ public enum Disease
YAWS_ENDEMIC_SYPHILIS(true, false, false, true, false, 0, true, false, false),
MATERNAL_DEATHS(true, false, false, true, false, 0, true, false, false),
PERINATAL_DEATHS(true, false, false, true, false, 0, true, false, false),
INFLUENZA(false, false, false, false, false, 0, true, false, false),
INFLUENZA_A(true, true, true, false, false, 0, true, false, false),
INFLUENZA_B(true, true, true, false, false, 0, true, false, false),
INFLUENZA(true, false, false, false, false, 0, true, false, false),
INFLUENZA_A(false, true, true, false, false, 0, true, false, false),
INFLUENZA_B(false, true, true, false, false, 0, true, false, false),
Comment on lines +73 to +75

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

INFLUENZA tuples likely wrong: case surveillance disabled for INFLUENZA, A/B marked primary while inactive

Per constructor order (lines 106–115), you set:

  • INFLUENZA: defaultCaseSurveillanceEnabled=false and defaultPrimary=false
  • INFLUENZA_A/B: defaultActive=false but defaultPrimary=true

If the intent is only “INFLUENZA_A and INFLUENZA_B inactive by default” while keeping INFLUENZA as the active, primary disease with case surveillance enabled, adjust as below.

Apply this diff:

-	INFLUENZA(true, false, false, false, false, 0, true, false, false),
-	INFLUENZA_A(false, true, true, false, false, 0, true, false, false),
-	INFLUENZA_B(false, true, true, false, false, 0, true, false, false),
+	INFLUENZA(true, true, true, false, false, 0, true, false, false),
+	INFLUENZA_A(false, false, true, false, false, 0, true, false, false),
+	INFLUENZA_B(false, false, true, false, false, 0, true, false, false),

Optional maintainability tweak: add inline argument comments to avoid boolean mis-ordering in future, e.g.
INFLUENZA(/*active*/true, /*primary*/true, /*case*/true, /*aggregate*/false, /*followUp*/false, /*days*/0, /*variant*/true, /*ext*/false, /*extMulti*/false).

Run this quick grep to see where these flags drive behavior and confirm no invariants are violated:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Call sites of case surveillance flag:"
rg -nP '\.isDefaultCaseSurveillanceEnabled\s*\(' -C3 || true

echo "Call sites of primary flag:"
rg -nP '\.isDefaultPrimary\s*\(' -C3 || true

echo "References to INFLUENZA and subtypes:"
rg -nP 'Disease\.(INFLUENZA|INFLUENZA_A|INFLUENZA_B)\b' -n -C2

Length of output: 44146


🏁 Script executed:

#!/bin/bash
# Extract Disease enum constructor definition
cat sormas-api/src/main/java/de/symeda/sormas/api/Disease.java | grep -A 20 "Disease(boolean"

Length of output: 90


🏁 Script executed:

#!/bin/bash
# Find Disease.java file
fd -name "Disease.java" -type f

Length of output: 230


🏁 Script executed:

#!/bin/bash
# Find Disease.java using find
find . -name "Disease.java" -type f 2>/dev/null | head -5

Length of output: 64


🏁 Script executed:

#!/bin/bash
# Extract constructor from Disease.java around lines 106-115
sed -n '106,115p' ./git/sormas-api/src/main/java/de/symeda/sormas/api/Disease.java

Length of output: 326


🏁 Script executed:

#!/bin/bash
# Search for tests related to Disease defaults or INFLUENZA configuration
find . -path "*/test/*" -name "*.java" -type f 2>/dev/null | xargs grep -l "INFLUENZA\|defaultPrimary\|defaultCaseSurveillanceEnabled" 2>/dev/null | head -10

Length of output: 312


🏁 Script executed:

#!/bin/bash
# Extract DiseasesConfigurationTest.java to check for INFLUENZA assertions
cat ./git/sormas-api/src/test/java/de/symeda/sormas/api/utils/DiseasesConfigurationTest.java

Length of output: 3107


🏁 Script executed:

#!/bin/bash
# Check for any logic combining INFLUENZA_A/B with primary or active checks
rg -n 'INFLUENZA_A|INFLUENZA_B' --type=java -C5 | grep -E '(primary|active|Primary|Active)' | head -20

Length of output: 0


INFLUENZA tuples have inconsistent defaults: A/B inactive but marked primary; INFLUENZA active but case surveillance disabled

Constructor parameter order (lines 106–115) is: defaultActive, defaultPrimary, defaultCaseSurveillanceEnabled, ...

Current state:

  • INFLUENZA(true, false, false, ...): active, not primary, no case surveillance
  • INFLUENZA_A(false, true, true, ...): inactive, primary, case surveillance enabled
  • INFLUENZA_B(false, true, true, ...): inactive, primary, case surveillance enabled

This contradicts typical enum semantics. If INFLUENZA_A and INFLUENZA_B are inactive by design, they should not be marked as primary. If INFLUENZA is the active parent disease, it should be both primary and have case surveillance enabled by default.

Apply this fix:

-	INFLUENZA(true, false, false, false, false, 0, true, false, false),
-	INFLUENZA_A(false, true, true, false, false, 0, true, false, false),
-	INFLUENZA_B(false, true, true, false, false, 0, true, false, false),
+	INFLUENZA(true, true, true, false, false, 0, true, false, false),
+	INFLUENZA_A(false, false, true, false, false, 0, true, false, false),
+	INFLUENZA_B(false, false, true, false, false, 0, true, false, false),

Optional: Add inline comments to prevent future boolean parameter mix-ups:

INFLUENZA(/*active*/true, /*primary*/true, /*case*/true, /*aggregate*/false, /*followUp*/false, /*days*/0, /*variant*/true, /*ext*/false, /*extMulti*/false)

H_METAPNEUMOVIRUS(true, false, true, false, false, 0, true, false, false),
RESPIRATORY_SYNCYTIAL_VIRUS(true, false, true, false, false, 0, true, false, false),
PARAINFLUENZA_1_4(true, false, true, false, false, 0, true, false, false),
Expand Down
Loading