-- 影像质控因子初始化
-- 说明：用于智能影像质控演示

-- 1. 插入影像质控因子
INSERT INTO `qc_factor` (`id`, `factor_code`, `factor_name`, `factor_category`, `factor_type`, `description`, `check_rule`, `data_source`, `status`, `create_time`, `update_time`) VALUES
('FACTOR_001', 'CHECK_RANGE', '检查范围', 2, 'enum', '影像检查的检查范围是否符合规范', '{"options":[{"label":"过大","value":"large"},{"label":"正常","value":"normal"},{"label":"过小","value":"small"}]}', 'exams.body_part_examined', 1, NOW(), NOW()),

('FACTOR_002', 'BODY_POSITION', '体位', 2, 'enum', '影像检查的体位是否符合标准', '{"options":[{"label":"标准","value":"standard"},{"label":"不标准","value":"non_standard"}]}', 'exams.patient_position', 1, NOW(), NOW()),

('FACTOR_003', 'IMAGE_ARTIFACT', '图像伪影', 2, 'enum', '影像图像是否存在伪影', '{"options":[{"label":"无伪影","value":"none"},{"label":"体外异物伪影","value":"foreign_body"},{"label":"设备伪影","value":"device"}]}', 'exams.image_quality', 1, NOW(), NOW()),

('FACTOR_004', 'CENTER_LINE', '中心线', 2, 'enum', '影像检查的中心线位置是否正确', '{"options":[{"label":"偏上","value":"up"},{"label":"偏下","value":"down"},{"label":"偏左","value":"left"},{"label":"偏右","value":"right"},{"label":"正常","value":"normal"}]}', 'exams.position', 1, NOW(), NOW()),

('FACTOR_005', 'IMAGE_QUALITY_LEVEL', '图像质控等级', 2, 'level', '影像图像的质控等级评定', '{"xr":[{"label":"甲级","value":1},{"label":"乙级","value":2},{"label":"丙级","value":3},{"label":"丁级","value":4}],"ct_mr":[{"label":"0级","value":0},{"label":"1级","value":1},{"label":"2级","value":2},{"label":"3级","value":3}]}', 'exams.modality,exams.quality_score', 1, NOW(), NOW());


-- 2. 插入默认质控标准（影像质控标准）
INSERT INTO `qc_standard` (`id`, `standard_code`, `standard_name`, `standard_category`, `description`, `status`, `create_time`, `update_time`) VALUES
('STD_IMAGE_001', 'IMAGE_QC_STANDARD', '影像质控标准', 2, '医学影像质量质控标准，包含检查范围、体位、伪影、中心线、质控等级5个维度', 1, NOW(), NOW());


-- 3. 关联质控因子到标准
INSERT INTO `qc_standard_factor` (`id`, `standard_id`, `factor_id`, `check_rule`, `pass_value`, `weight`, `create_time`, `update_time`) VALUES
('SF_001', 'STD_IMAGE_001', 'FACTOR_001', '检查范围必须为正常', 'normal', 20, NOW(), NOW()),
('SF_002', 'STD_IMAGE_001', 'FACTOR_002', '体位必须为标准', 'standard', 20, NOW(), NOW()),
('SF_003', 'STD_IMAGE_001', 'FACTOR_003', '图像伪影必须为无伪影', 'none', 20, NOW(), NOW()),
('SF_004', 'STD_IMAGE_001', 'FACTOR_004', '中心线必须为正常', 'normal', 20, NOW(), NOW()),
('SF_005', 'STD_IMAGE_001', 'FACTOR_005', '图像质控等级必须达到乙级/1级及以上', '{"xr":2,"ct_mr":1}', 20, NOW(), NOW());
