# E-AUBS Rule Implementation (DISABLED)

**HISTORY:**
###### 16/02/2026: ECARS-2309 - new rule E-AUBS
###### 11/03/2026: ECARS-2339 - disable E-AUBS in Protocol=11. Reason: replaced by W-SUBA

## Overview
This document describes the implementation of the E-AUBS (Autopsy + BoD + Surv_time/DoI/DoF – exclude from survival analysis) validation rule.

## Rule Description
**Rule Definition ID**: 321
**Rule Code**: E-AUBS  
**Rule Type**: ERROR  
**Description**: Autopsy not in range AND BoD != 0 AND (Surv_time=0 or DoI=DoF): record excluded from survival analysis  
**Protocol**: Incidence 2022 (Protocol ID: 11)

### Notes
Autopsy might be 1 if BoD=7 and survival time is 0, but in doubt this record should be excluded from survival analysis.

### Rule Logic
The E-AUBS message must be produced only if **all** of the following conditions hold:

1. **Autopsy not in_range**  
   The Autopsy field is not in range (invalid, unknown, missing, or failed preparatory rules such as range check).

2. **BoD NOT EQUAL 0**  
   Basis of diagnosis (BoD) is present, parseable, and its value is not 0.

3. **(Surv_time = 0) OR (DoI = DoF)**  
   - **Surv_time = 0**: Duration of survival in days is 0, or  
   - **DoI = DoF**: Date of Incidence equals Date of Followup 

### Rule Positioning
- **Priority Level**: 7 (Cross-field )
- **Before**: Cross-record validation rules (priority 8)

## Implementation Files

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

**Key features**:
- Extends `CrossFieldRule` (encr2020)
- Fields: Autopsy (84), BoD (79), Surv_time (88), MoI (77), YoI (78), MoF (86), YoF (87)
- Default rule ID: `AUTOPSY_BOD_SURVIVAL_EXCLUSION` (321)

## Testing

### Expected Behavior

#### Triggers E-AUBS


### Running Tests

## Files Modified / Created
1. `src/main/java/eu/europa/ec/jrc/qcs/engine/rule/crossfield/encr2020/AutopsyBoDSurvivalExclusionRule.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-AUBS/E-AUBS_rule_registration.sql` (NEW)
5. `docs/rules/E-AUBS/E-AUBS_IMPLEMENTATION_README.md` (NEW)
