# W-SSMI Rule Implementation

**HISTORY:**
###### 27/01/2026: ECARS-2281 - new rule W-SSMI
###### 23/02/2026: ECARS-2313 - update W-SSMI in Protocol=11. Reason: logic update
       Logic update: Stage not in_range; (cM,pM) NOT 1;  T or N pair missing. Aligned with W-TNME (M1 = Stage 4).
###### 14/04/2026: update W-SSMI - apply only when Beh=3 (malignant tumours)
###### 30/04/2026: update W-SSMI - apply only (cM and pM) NOT contain '1'

## Overview
This document describes the implementation of the W-SSMI (Stage variables pair missing — stage cannot be computed) validation rule.

## Rule Description
**Rule Code**: W-SSMI  
**Rule Type**: WARNING  
**Description**: Stage cannot be computed if any pair of T,N is missing/unknown/wrong and (cM,pM) are not 1.  
**Protocol**: Incidence 2020 (Protocol ID: 11)  

### Rule Logic
The W-SSMI message must be produced **only** when **all** the following truth:

1. **Stage is not IN_RANGE**
2. **AND Beh = 3**
3. **AND ((cM and pM) not IN_RANGE OR IF IN_RANGE THEN NOT CONTAINS '1')**  — neither cM nor pM indicates M1
4. **AND (((cT and pT) not IN_RANGE) OR ((cN and pN) not IN_RANGE) **

**NOTE**:  If cM or pM is 1, Stage is always 4 regardless of cT,pT and cN,pN values (UICC/AJCC TNM).

## Implementation Files

### 1. Java Implementation
**File**: `src/main/java/eu/europa/ec/jrc/qcs/engine/rule/crossfield/encr2020/StageVariablesPairMissingRule.java`

## Testing

### Expected Behavior (FILE: incidence_1.csv))

TEST CASES PATIENTS: 
ECARS-2313_W-SSMI-TRIGGER1
ECARS-2313_W-SSMI-TRIGGER2
ECARS-2313_W-SSMI-NOT-TRIGGER3
ECARS-2313_W-SSMI-TRIGGER4
ECARS-2313_W-SSMI-NOT-TRIGGER5
ECARS-2313_W-SSMI-TRIGGER6
ECARS-2313_W-SSMI-TRIGGER7
ECARS-2313_W-SSMI-NOT-TRIGGER8
ECARS-2313_W-SSMI-NOT-TRIGGER9
ECARS-2313_W-SSMI-NOT-TRIGGER10
ECARS-2313_W-SSMI-NOT-TRIGGER11
ECARS-2313_W-SSMI-NOT-TRIGGER12
ECARS-2313_W-SSMI-NOT-TRIGGER13
ECARS-2313_W-SSMI-BEH3-TRIGGER14
ECARS-2313_W-SSMI-BEH2-NOT-TRIGGER15
ECARS-2313_W-SSMI-BEH3-TRIGGER14
ECARS-2313_W-SSMI-BEH2-NOT-TRIGGER15

## Files Modified/Created

### quality-check-software project:
1. `src/main/java/eu/europa/ec/jrc/qcs/engine/rule/crossfield/encr2020/StageVariablesPairMissingRule.java`
2. `src/main/java/eu/europa/ec/jrc/qcs/engine/preset/DefaultRuleID.java` (MODIFIED)
3. `docs/rules/W-SSMI/W-SSMI_rule_registration.sql` (NEW)
4. `docs/rules/W-SSMI/W-SSMI_IMPLEMENTATION_README.md` (NEW)

## Rule Positioning
The W-SSMI rule has been positioned:
- **Priority Level**: 7 (Cross-field validation rules)
- **Protocol**: ENCR 2020
