Browse Source

静态知识检索

zhaops 4 years ago
parent
commit
30e600ea0e
1 changed files with 133 additions and 18 deletions
  1. 133 18
      src/main/resources/mapper/KlConceptMapper.xml

+ 133 - 18
src/main/resources/mapper/KlConceptMapper.xml

@@ -151,8 +151,13 @@
 		FROM
 		(
 		SELECT
-		distinct
-		s.*,
+		s.id,
+		s.name,
+		s.retrievalName,
+		s.isConcept,
+		s.type,
+		s.typeName,
+		group_concat(distinct s.code SEPARATOR '') as code,
 		s1.concept_id AS conceptId,
 		s1.clinical_pathway_name,
 		s1.notice_name,
@@ -171,7 +176,7 @@
 		t.isConcept,
 		t.type,
 		t.typeName,
-		l1.icd10_code AS code
+		'' AS code
 		FROM
 		(
 		SELECT
@@ -199,14 +204,11 @@
 			</foreach>
 		</if>
 		) t
-		LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
-		AND l1.is_deleted = 'N'
 		WHERE
 		1=1
 		<if test="inputStr!=null and inputStr!=''">
 			AND ( t.retrievalName = #{inputStr}
-			OR LOWER(t.spell) = LOWER(#{inputStr})
-			OR LOWER(l1.icd10_code) = LOWER(#{inputStr}))
+			OR LOWER(t.spell) = LOWER(#{inputStr}))
 		</if>
 		UNION
 		SELECT
@@ -216,7 +218,7 @@
 		t.isConcept,
 		t.type,
 		t.typeName,
-		l1.icd10_code AS code
+		'' AS code
 		FROM
 		(
 		SELECT
@@ -244,14 +246,11 @@
 			</foreach>
 		</if>
 		) t
-		LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
-		AND l1.is_deleted = 'N'
 		WHERE
 		1=1
 		<if test="inputStr!=null and inputStr!=''">
 			AND ( t.retrievalName LIKE concat(#{inputStr},'%')
-			OR LOWER(t.spell) LIKE LOWER( concat(#{inputStr},'%'))
-			OR LOWER(l1.icd10_code) LIKE LOWER( concat(#{inputStr},'%')))
+			OR LOWER(t.spell) LIKE LOWER( concat(#{inputStr},'%')))
 		</if>
 		UNION
 		SELECT
@@ -261,7 +260,7 @@
 		t.isConcept,
 		t.type,
 		t.typeName,
-		l1.icd10_code AS code
+		'' AS code
 		FROM
 		(
 		SELECT
@@ -289,16 +288,13 @@
 			</foreach>
 		</if>
 		) t
-		LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
-		AND l1.is_deleted = 'N'
 		WHERE
 		1=1
 		<if test="inputStr!=null and inputStr!=''">
 			AND ( t.retrievalName LIKE concat('%',#{inputStr},'%')
-			OR LOWER(t.spell) LIKE LOWER( concat('%',#{inputStr},'%'))
-			OR LOWER(l1.icd10_code) LIKE LOWER( concat('%',#{inputStr},'%')))
+			OR LOWER(t.spell) LIKE LOWER( concat('%',#{inputStr},'%')))
 		</if>
-		<if test="(types != null and types.size > 0 and (types.contains(0) or types.contains(3))) or types==null or types.size==0">
+		<if test="typeIds.contains(107) or typeIds.contains(108)">
 			UNION
 			SELECT DISTINCT
 			e.id AS id,
@@ -396,6 +392,125 @@
 				AND ( a.name LIKE concat('%',#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat('%',#{inputStr},'%')))
 			</if>
 		</if>
+		<if test="typeIds.contains(100) ">
+			UNION
+			SELECT
+			t.id,
+			t.NAME,
+			IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
+			t.isConcept,
+			t.type,
+			t.typeName,
+			l1.icd10_code AS code
+			FROM
+			(
+			SELECT
+			a.NAME AS retrievalName,
+			a.spell AS spell,
+			a.is_concept AS isConcept,
+			b.id AS id,
+			b.lib_name AS NAME,
+			b.lib_type AS type,
+			c.NAME AS typeName
+			FROM
+			kl_library_info a,
+			kl_concept b,
+			kl_lexicon c
+			WHERE
+			a.is_deleted = 'N'
+			AND b.is_deleted = 'N'
+			AND c.is_deleted = 'N'
+			AND a.concept_id = b.id
+			AND b.lib_type = c.code
+			AND b.`status` = 1
+			AND a.type_id =100
+			) t
+			LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
+			AND l1.is_deleted = 'N'
+			WHERE
+			1=1
+			<if test="inputStr!=null and inputStr!=''">
+				AND  LOWER(l1.icd10_code) = LOWER(#{inputStr})
+			</if>
+			UNION
+			SELECT
+			t.id,
+			t.NAME,
+			IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
+			t.isConcept,
+			t.type,
+			t.typeName,
+			l1.icd10_code AS code
+			FROM
+			(
+			SELECT
+			a.NAME AS retrievalName,
+			a.spell AS spell,
+			a.is_concept AS isConcept,
+			b.id AS id,
+			b.lib_name AS NAME,
+			b.lib_type AS type,
+			c.NAME AS typeName
+			FROM
+			kl_library_info a,
+			kl_concept b,
+			kl_lexicon c
+			WHERE
+			a.is_deleted = 'N'
+			AND b.is_deleted = 'N'
+			AND c.is_deleted = 'N'
+			AND a.concept_id = b.id
+			AND b.lib_type = c.code
+			AND b.`status` = 1
+			AND a.type_id =100
+			) t
+			LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
+			AND l1.is_deleted = 'N'
+			WHERE
+			1=1
+			<if test="inputStr!=null and inputStr!=''">
+				AND LOWER(l1.icd10_code) LIKE LOWER( concat(#{inputStr},'%'))
+			</if>
+			UNION
+			SELECT
+			t.id,
+			t.NAME,
+			IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
+			t.isConcept,
+			t.type,
+			t.typeName,
+			l1.icd10_code AS code
+			FROM
+			(
+			SELECT
+			a.NAME AS retrievalName,
+			a.spell AS spell,
+			a.is_concept AS isConcept,
+			b.id AS id,
+			b.lib_name AS NAME,
+			b.lib_type AS type,
+			c.NAME AS typeName
+			FROM
+			kl_library_info a,
+			kl_concept b,
+			kl_lexicon c
+			WHERE
+			a.is_deleted = 'N'
+			AND b.is_deleted = 'N'
+			AND c.is_deleted = 'N'
+			AND a.concept_id = b.id
+			AND b.lib_type = c.code
+			AND b.`status` = 1
+			AND a.type_id =100
+			) t
+			LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
+			AND l1.is_deleted = 'N'
+			WHERE
+			1=1
+			<if test="inputStr!=null and inputStr!=''">
+				AND LOWER(l1.icd10_code) LIKE LOWER( concat('%',#{inputStr},'%'))
+			</if>
+		</if>
 		) s
 		LEFT JOIN kl_concept_static s1 ON s.id = s1.concept_id
 		AND s1.is_deleted = 'N'