-- SQL statements to register the W-ASMI rule in the QCS database
-- This file should be executed against both qcs.db files in quality-check-software and qcs-admin projects
-- All Stage variables are Missing/unknown, stage cannot be computed.

-- Step 1: Add validation message for W-ASMI
INSERT INTO validationMessage(id,code,type,reference,description) VALUES
('215','W-ASMI','WARNING','','All TNM variables are missing/unknown, stage cannot be computed.');

-- Step 2: Add rule definition for W-ASMI
INSERT INTO ruledefinition(ID,NAME,DESCRIPTION,POSITIVE,CASESENSITIVITY,LOCATION,IMPLEMENTATION,VALIDATIONMESSAGE_ID,RULETYPE_ID) VALUES
(320,'Stage Variables All Missing','Stage Variables All Missing',true,'INSENSITIVE','eu.europa.ec.jrc.qcs.engine.rule.crossfield.encr2020','StageVariablesAllMissingRule',215,8);

-- Step 3: Add rule to ENCR 2020 protocol (protocol_id=11) with priority 7 (cross-field rules level)
INSERT INTO protocolToRule(id,protocol_id,priority,block,ruleDefinition_id) VALUES 
(373,11,7,0,320);

-- Step 4: Rule-to-Field Mappings (7 fields)
INSERT INTO ruletofield(id,protocol_id,ruledefinition_id,target_id,position,key,field_id) VALUES
(1654,11,320,3,1,0,99),  -- Stage (field_id=99 - INCIDENCE_STAGE)
(1655,11,320,3,2,0,92),  -- cT (field_id=92 - INCIDENCE_CT)
(1656,11,320,3,3,0,95),  -- pT (field_id=95 - INCIDENCE_PT)
(1657,11,320,3,4,0,93),  -- cN (field_id=93 - INCIDENCE_CN)
(1658,11,320,3,5,0,96),  -- pN (field_id=96 - INCIDENCE_PN)
(1659,11,320,3,6,0,94),  -- cM (field_id=94 - INCIDENCE_CM)
(1660,11,320,3,7,0,97);  -- pM (field_id=97 - INCIDENCE_PM)

