temp.sql 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. USE `med_2021`;
  2. -- 临时表
  3. DROP TABLE IF EXISTS `temp_msg`;
  4. CREATE TABLE `temp_msg` (
  5. `cond_id` bigint(20) DEFAULT NULL COMMENT 'con_id',
  6. `msg` varchar(255) DEFAULT NULL COMMENT '提示语',
  7. KEY (`cond_id`)
  8. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
  9. -- 更新提示语:原因及建议
  10. update kl_rule_condition a, temp_msg b set a.msg = b.msg where a.id = b.cond_id;
  11. -- 查询已有的开单条目
  12. SELECT
  13. tt1.cond_id,
  14. tt1.par_name,
  15. tt1.par_type,
  16. tt2.lib_name base_name,
  17. xx2. NAME base_type,
  18. CASE tt1.type
  19. WHEN '4' THEN
  20. '过敏原'
  21. WHEN '5' THEN
  22. '辅检开单互斥'
  23. ELSE
  24. ''
  25. END other_type,
  26. tt1.max_value,
  27. tt1.max_operator,
  28. tt1.min_value,
  29. tt1.min_operator,
  30. tt1.cond_msg
  31. FROM
  32. (
  33. SELECT
  34. c1.lib_name par_name,
  35. c1.id par_id,
  36. x1.`name` par_type,
  37. t1.id rule_id,
  38. t1.description,
  39. t1.rule_type,
  40. t1.has_sub_cond,
  41. t1.msg,
  42. t3.type,
  43. t3.concept_id base_id,
  44. t3.eq_value,
  45. t3.min_value,
  46. t3.min_operator,
  47. t3.min_unit,
  48. t3.max_value,
  49. t3.max_operator,
  50. t3.max_unit,
  51. t2.id cond_id,
  52. t2.msg cond_msg
  53. FROM
  54. kl_concept c1,
  55. kl_lexicon x1,
  56. kl_rule t1,
  57. kl_rule_condition t2,
  58. kl_rule_base t3
  59. WHERE
  60. c1.is_deleted = 'N'
  61. AND t1.is_deleted = 'N'
  62. AND t2.is_deleted = 'N'
  63. AND t3.is_deleted = 'N'
  64. AND c1.`status` = 1
  65. AND t1.`status` = 1
  66. AND c1.id = t1.concept_id
  67. AND t1.id = t2.rule_id
  68. AND t2.rule_base_id = t3.id
  69. AND t1.rule_type = 1
  70. AND x1.`code` = c1.lib_type
  71. ) tt1
  72. LEFT JOIN kl_concept tt2 ON tt2.is_deleted = 'N'
  73. AND tt2.`status` = 1
  74. AND tt1.base_id = tt2.id
  75. LEFT JOIN kl_lexicon xx2 ON tt2.lib_type = xx2. CODE
  76. ORDER BY
  77. rule_id;