# W-TOST Rule Implementation

**HISTORY:**
###### 26/01/2026: ECARS-2282 - new rule W-TOST (ToS = (UNKN or blank)) AND (Stage (in_range) and (NOT EQUAL to (UNKN or blank))).
###### 18/02/2026: ECARS-2314 - update IF (ToS is NOT "in_range") AND (Stage is "in_range").
###### 16/04/2026: ECARS-2390 - update - IF (ToS = Not in_range (missing/unknown/out of range/wrong format)) AND (Stage in_range AND NOT EQUAL to (Unknown or blank)).

## Overview
This document describes the implementation of the W-TOST (Staging system is not defined) validation rule in the QCS.

## Rule Description
**Rule Code**: W-TOST  
**Rule Type**: WARNING  
**Description**: Staging system is not defined.  
**Protocol**: Incidence 2020 (Protocol ID: 11)  

### Rule Logic
The W-TOST message must be produced only in the following conditions:  
IF (ToS = Not in_range (missing/unknown/out of range/wrong format))  
AND (Stage in_range AND NOT EQUAL to (Unknown or blank)).

**Meaning**: Stage is valid but staging system is not defined.

## Implementation Files

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

### 2. SQL Registration
**File**: `docs/rules/W-TOST/W-TOST_rule_registration.sql`

## Testing

### Expected Behavior (incidence_2.txt. ECARS-2314 01-03 test cases)

#### Case '01' - TRIGGER W-TOST
- **ToS**: (value=5, OUTR )
- **Stage**: "IV" (in range)

#### Case '02' - TRIGGER W-TOST
- **ToS**: (value=55AA, E-FORM )
- **Stage**: "IV" (in range)

#### Case '03' - TRIGGER W-TOST
- **ToS**: (value=9, UNKN )
- **Stage**: "IV" (in range)

#### Case 'PAT  ECARS_2211_02' - TRIGGER W-TOST
- **ToS**: "" (MISS)
- **Stage**: "3"
- 

## Files Modified/Created

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

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