# W-BDpM Rule Implementation

**HISTORY:**
###### ECARS-1106 - initial W-BDpM implementation (DiseaseExtentRule5)
###### ECARS-1571 / ECARS-1634 / ECARS-1674 - updates around pM=1 and BoD allowances
###### 08/04/2026: ECARS-2372 update - apply only for Beh=3 and allow BoD in {5,6,7}

## Overview
This document describes the implementation of the W-BDpM (pM + BoD/c,pT consistency) validation rule.

## Rule Description
**Rule Definition ID**: 218  
**Rule Code**: W-BDpM  
**Rule Type**: WARNING  
**Description**: pM + BoD/c,pT not valid  
**Protocol**: Incidence

### Rule Logic
The W-BDpM warning is evaluated only when all common preconditions are true:

1. `Beh = 3` 
2. `pM` is in_range (valid, not missing, not unknown)

Then the warning is produced when one of the following conditions is true:

1. (`pM` does not contain `X` and does not contain `1`) AND (`BoD` is not in `{5,6,7}`) OR
    OR
2. (`pM` contains `1`) AND (`BoD` is not in `{5,6,7}` or `cT`/`pT` contains `is`)

### Notes

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

### 2. Rule Registration / ID Reference
**File**: `docs/rules/W-BDpM/W-BDpM_rule_registration.sql`  

