# W-BTNM Rule Implementation

**HISTORY:**
###### 2020: ECARS-1301 - replace old W-BTNM logic (former Rule8) with Rule10
###### 2020: ECARS-1360 - fix handling when pT is not in range
###### 2021: ECARS-1637 - add Behaviour=2 => Stage must be 0
###### 2026: ECARS-2377 - apply W-BTNM only when Stage is in_range

## Overview
This document describes the implementation of the W-BTNM (Inconsistencies between Behaviour and TNM/EOD) validation rule.

## Rule Description
**Rule Definition ID**: 240  
**Rule Code**: W-BTNM  
**Rule Type**: WARNING  
**Description**: Inconsistencies between Behaviour and TNM/EOD  
**Protocol**: Incidence

### Rule Logic
The W-BTNM message is evaluated only when **Stage is in_range** (valid, not missing, not unknown).

Then the warning is produced when one of the following holds:

1. ('Behaviour' = "3" and 'pT' = "is") or
2. ('Behaviour' = "3" and 'pT' not valid/defined and 'cT' = "is") or
3. ('Behaviour' in (0,1,2) and 'pT' >= 1) or
4. ('Behaviour' in (0,1,2) and 'pT' not valid/defined and 'cT' >= 1) or
5. ('Behaviour' = "2" and 'Stage prefix' != "0" (e.g. "0a" is treated as "0"))

### Notes
- If Stage is unknown (e.g. `9`), missing, or invalid/out of range, W-BTNM is not applied.

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

### 2. Rule Registration / ID Reference
**File**: `src/main/java/eu/europa/ec/jrc/qcs/engine/preset/DefaultRuleID.java`

