Browse Source

修改分子查询sql

zhanghang 4 years ago
parent
commit
532917aa4b
1 changed files with 22 additions and 11 deletions
  1. 22 11
      src/main/resources/mapper/BehospitalInfoMapper.xml

+ 22 - 11
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -17641,7 +17641,7 @@
         count(
         DISTINCT
         CASE
-        WHEN q.type=5 THEN
+        WHEN a.type=5 THEN
         a.behospital_code
         ELSE
         NULL
@@ -17650,7 +17650,7 @@
         count(
         DISTINCT
         CASE
-        WHEN q.type = 4 THEN
+        WHEN a.type = 4 THEN
         a.behospital_code
         ELSE
         NULL
@@ -17659,7 +17659,7 @@
         count(
         DISTINCT
         CASE
-        WHEN q.type = 6 THEN
+        WHEN a.type = 6 THEN
         a.behospital_code
         ELSE
         NULL
@@ -17668,7 +17668,7 @@
         count(
         DISTINCT
         CASE
-        WHEN q.type = 7 THEN
+        WHEN a.type = 7 THEN
         a.behospital_code
         ELSE
         NULL
@@ -17677,7 +17677,7 @@
         count(
         DISTINCT
         CASE
-        WHEN q.type=8 THEN
+        WHEN a.type=8 THEN
         a.behospital_code
         ELSE
         NULL
@@ -17686,7 +17686,7 @@
         count(
         DISTINCT
         CASE
-        WHEN q.type = 9 THEN
+        WHEN a.type = 9 THEN
         a.behospital_code
         ELSE
         NULL
@@ -17695,7 +17695,7 @@
         count(
         DISTINCT
         CASE
-        WHEN q.type = 10 THEN
+        WHEN a.type = 10 THEN
         a.behospital_code
         ELSE
         NULL
@@ -17704,7 +17704,7 @@
         count(
         DISTINCT
         CASE
-        WHEN q.type = 15 THEN
+        WHEN a.type = 15 THEN
         a.behospital_code
         ELSE
         NULL
@@ -17713,7 +17713,7 @@
         count(
         DISTINCT
         CASE
-        WHEN q.type = 17 THEN
+        WHEN a.type = 17 THEN
         a.behospital_code
         ELSE
         NULL
@@ -17722,7 +17722,7 @@
         count(
         DISTINCT
         CASE
-        WHEN q.type = 18 THEN
+        WHEN a.type = 18 THEN
         a.behospital_code
         ELSE
         NULL
@@ -17731,7 +17731,7 @@
         count(
         DISTINCT
         CASE
-        WHEN q.type = 19 THEN
+        WHEN a.type = 19 THEN
         a.behospital_code
         ELSE
         NULL
@@ -17741,6 +17741,12 @@
         (
         SELECT
         a.behospital_code,
+        a.hospital_id,
+        q.type
+        FROM
+        (
+        SELECT
+        a.behospital_code,
         a.cases_entry_id,
         a.hospital_id
         FROM
@@ -17778,6 +17784,11 @@
         ) a
         JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
         AND a.hospital_id = q.hospital_id
+        ) a
+        JOIN med_index_relevance r ON r.behospital_code = a.behospital_code
+        AND r.relevance_type = a.type
+        AND r.is_deleted = 'N'
+        AND a.hospital_id = r.hospital_id
     </select>
 
 <!--    跟病案首页关联的出院病历-->