# W-SUBA Rule Implementation

**HISTORY:**
###### 04/03/2026: ECARS-2336 - new rule W-SUBA ( to replace W-AUBS)
###### 01/04/2026: ECARS-2369 - update W-SUBA for Survival analysis

## Overview

This document describes the implementation of the **W-SUBA** (Survival time zero with ambiguous BoD/Autopsy) validation rule for survival analysis in the QCS.

## Rule Description

**Rule Code**: W-SUBA  
**Rule Type**: WARNING  
**Description**: Survival time zero with ambiguous/unlikely values of BoD/Autopsy  
**Protocol**: Incidence 2020 (Protocol ID: 11)  

### Rule Logic

The W-SUBA message must be produced only when all of the following hold:

1. **`Survival time` == 0**  
   - Survival time in days (`Surv_time`) is in_range and equal to 0.

2. **AND Basis of Diagnosis (`BoD`) <> 0**  
   - Implemented as:
     - If `BoD` is IN_RANGE AND EQUAL `0` DO NOT APPLY this rule
     - OTHERWISE, If `BoD` (NOT IN_RANGE) OR (is IN_RANGE AND not equal `0`) APPLY this rule  

3. **AND `Autopsy` <> 1**  
   - Implemented as:
     - If `Autopsy` is IN_RANGE AND EQUAL `1` DO NOT APPLY this rule
     - OTHERWISE, If `Autopsy` (NOT IN_RANGE) OR (is IN_RANGE AND not equal `1`) APPLY this rule

4. **AND `Vital status` IS in_range**

**Meaning**:  
All cases with survival time 0 and ambiguous/unlikely combinations of BoD and Autopsy 
and with Vital status dead/alive must be verified/confirmed by CRs.
If not corrected/confirmed, they should be excluded from survival analysis. 
Possible but very rare situations with no Autopsy, no DCO and Vital status dead (aggressive tumours) / alive (lost to follow-up) 
should be carefully evaluated for possible inclusion.

### Rule Positioning

The W-SUBA rule is positioned as:

- **Priority Level**: 7 (Cross-field validation rules)  
- **Protocol**: ENCR 2020 (Incidence 2020, protocol_id = 11)  
- Executed together with other survival-related cross-field rules (e.g. W-SUMU, W-SUDA, W-AUBS) before cross-record rules (priority 8).

## Implementation Files

### 1. Java Implementation

**File**: `src/main/java/eu/europa/ec/jrc/qcs/engine/rule/crossfield/encr2020/SurvivalZeroWithBoDAutopsyRule.java`

## Testing

###  Test Scenarios

Please check existing test data set  ENCR 2020 incidence for test cases (file name: `incidence_2.csv`)

- **PAT Should trigger W-SUBA**: ECARS-2336-3-p, ECARS-2336-4-p, ECARS-2336-7-p, ECARS-2336-9-p, ECARS-2336-10-p
- 
- **Should NOT trigger W-SUBA**: ECARS-2336-1, ECARS-2336-2, ECARS-2336-5, ECARS-2336-6, ECARS-2336-8, ECARS-2336-11, ECARS-2336-12

## Files Modified / Created
1. `src/main/java/eu/europa/ec/jrc/qcs/engine/rule/crossfield/encr2020/SurvivalZeroWithBoDAutopsyRule.java` (NEW)
2. `src/main/java/eu/europa/ec/jrc/qcs/engine/preset/DefaultRuleID.java` (modified)
3. `src/main/resources/qcs.db` (MODIFIED)
4. `docs/rules/E-SUBA/W-SUBA_rule_registration.sql` (NEW)
5. `docs/rules/E-SUBA/W-SUBA_IMPLEMENTATION_README.md` (NEW)

