-- SQL statements to register the W-BTNM rule in the QCS database
-- This file is INSERT-based and can seed this rule in an empty DB.

-- Step 1: Add validation message for W-BTNM
INSERT INTO validationMessage(id,code,type,reference,description) VALUES
(129,'W-BTNM','WARNING','Inconsistencies between behaviour and TNM/EOD, page 33','Behaviour + TNM not valid (p.33)');

-- Step 2: Add rule definition (RuleDefinition ID = 240)
INSERT INTO ruledefinition(ID,NAME,DESCRIPTION,POSITIVE,CASESENSITIVITY,LOCATION,IMPLEMENTATION,VALIDATIONMESSAGE_ID,RULETYPE_ID) VALUES
(240,'Disease extent 10','Disease extent 10',true,'INSENSITIVE','eu.europa.ec.jrc.qcs.engine.rule.crossfield.encr2014','DiseaseExtentRule10',129,8);

-- Step 3: Add rule to protocols
INSERT INTO protocolToRule(id,protocol_id,priority,block,ruleDefinition_id,enabled) VALUES
(59,1,7,false,240,true),
(343,11,7,false,240,true);

-- Step 4: Rule-to-Field mappings
-- Protocol 1 (ENCR 2014): Behaviour=15, pT=30, cT=33, Stage=36
INSERT INTO ruletofield(id,protocol_id,ruledefinition_id,target_id,position,key,field_id) VALUES
(272,1,240,3,1,false,15),
(273,1,240,3,2,false,30),
(274,1,240,3,3,false,33),
(275,1,240,3,4,false,36);

-- Protocol 11 (ENCR 2020): Behaviour=82, pT=95, cT=92, Stage=99
INSERT INTO ruletofield(id,protocol_id,ruledefinition_id,target_id,position,key,field_id) VALUES
(1310,11,240,3,1,false,82),
(1311,11,240,3,2,false,95),
(1312,11,240,3,3,false,92),
(1313,11,240,3,4,false,99);

