123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.diagbot.mapper.KlConceptMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.diagbot.entity.KlConcept">
- <id column="id" property="id" />
- <result column="is_deleted" property="isDeleted" />
- <result column="gmt_create" property="gmtCreate" />
- <result column="gmt_modified" property="gmtModified" />
- <result column="creator" property="creator" />
- <result column="modifier" property="modifier" />
- <result column="lib_id" property="libId" />
- <result column="lib_name" property="libName" />
- <result column="lib_type" property="libType" />
- <result column="status" property="status" />
- </resultMap>
- <select id="index" resultType="com.diagbot.dto.IndexDTO">
- SELECT DISTINCT
- t.id as id,
- t.lib_name as name
- <if test="typeId!=null and typeId==100">
- ,t.icd10Code as icd10Code
- </if>
- <if test="typeId!=null and typeId==127">
- ,t.code as code
- </if>
- <if test="typeId!=null and typeId==128">
- ,t.code as code
- </if>
- <if test="typeId!=null and typeId==108">
- ,
- t1.max_value as `maxValue`,
- t1.min_value as minValue,
- t1.unit as units,
- t1.type as `range`,
- t4.lib_name AS packName,
- t4.id as packId
- </if>
- FROM
- (
- SELECT DISTINCT
- b.id,
- b.lib_name
- <if test="typeId!=null and typeId==100">
- ,c.icd10_code as icd10Code
- </if>
- <if test="typeId!=null and typeId==127">
- ,c.code as code
- </if>
- <if test="typeId!=null and typeId==128">
- ,c.code as code
- </if>
- FROM
- kl_library_info a,
- kl_concept b
- <if test="typeId!=null and typeId==100">
- left join kl_disease c
- on c.is_deleted = 'N'
- and b.id = c.concept_id
- </if>
- <if test="typeId!=null and typeId==127">
- left join kl_tcm_disease c
- on c.is_deleted = 'N'
- and b.id = c.concept_id
- </if>
- <if test="typeId!=null and typeId==128">
- left join kl_tcm_syndrome c
- on c.is_deleted = 'N'
- and b.id = c.concept_id
- </if>
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND a.concept_id = b.id
- AND a.id = b.lib_id
- AND b.status = 1
- <if test="inputStr!=null and inputStr!=''">
- AND ( a.`name` = #{inputStr} OR LOWER(a.spell) = LOWER(#{inputStr})
- <if test="typeId!=null and typeId==100">
- OR LOWER(c.icd10_code) = LOWER(#{inputStr})
- </if>
- <if test="typeId!=null and typeId==127">
- OR LOWER(c.code) = LOWER(#{inputStr})
- </if>
- <if test="typeId!=null and typeId==128">
- OR LOWER(c.code) = LOWER(#{inputStr})
- </if>
- )
- </if>
- <if test="typeIds != null and typeIds.size > 0">
- <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
- a.type_id =#{typeId}
- </foreach>
- </if>
- UNION
- SELECT DISTINCT
- b.id,
- b.lib_name
- <if test="typeId!=null and typeId==100">
- ,c.icd10_code as icd10Code
- </if>
- <if test="typeId!=null and typeId==127">
- ,c.code as code
- </if>
- <if test="typeId!=null and typeId==128">
- ,c.code as code
- </if>
- FROM
- kl_library_info a,
- kl_concept b
- <if test="typeId!=null and typeId==100">
- left join kl_disease c
- on c.is_deleted = 'N'
- and b.id = c.concept_id
- </if>
- <if test="typeId!=null and typeId==127">
- left join kl_tcm_disease c
- on c.is_deleted = 'N'
- and b.id = c.concept_id
- </if>
- <if test="typeId!=null and typeId==128">
- left join kl_tcm_syndrome c
- on c.is_deleted = 'N'
- and b.id = c.concept_id
- </if>
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND a.concept_id = b.id
- AND a.id = b.lib_id
- AND b.status = 1
- <if test="inputStr!=null and inputStr!=''">
- AND ( a.`name` LIKE concat(#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER(concat(#{inputStr},'%'))
- <if test="typeId!=null and typeId==100">
- OR LOWER(c.icd10_code) LIKE LOWER(concat(#{inputStr},'%'))
- </if>
- <if test="typeId!=null and typeId==127">
- OR LOWER(c.code) LIKE LOWER(concat(#{inputStr},'%'))
- </if>
- <if test="typeId!=null and typeId==128">
- OR LOWER(c.code) LIKE LOWER(concat(#{inputStr},'%'))
- </if>
- )
- </if>
- <if test="typeIds != null and typeIds.size > 0">
- <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
- a.type_id =#{typeId}
- </foreach>
- </if>
- UNION
- SELECT DISTINCT
- b.id,
- b.lib_name
- <if test="typeId!=null and typeId==100">
- ,c.icd10_code as icd10Code
- </if>
- <if test="typeId!=null and typeId==127">
- ,c.code as code
- </if>
- <if test="typeId!=null and typeId==128">
- ,c.code as code
- </if>
- FROM
- kl_library_info a,
- kl_concept b
- <if test="typeId!=null and typeId==100">
- left join kl_disease c
- on c.is_deleted = 'N'
- and b.id = c.concept_id
- </if>
- <if test="typeId!=null and typeId==127">
- left join kl_tcm_disease c
- on c.is_deleted = 'N'
- and b.id = c.concept_id
- </if>
- <if test="typeId!=null and typeId==128">
- left join kl_tcm_syndrome c
- on c.is_deleted = 'N'
- and b.id = c.concept_id
- </if>
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND a.concept_id = b.id
- AND a.id = b.lib_id
- AND b.status = 1
- <if test="inputStr!=null and inputStr!=''">
- AND ( a.`name` LIKE concat('%',#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat('%',#{inputStr},'%'))
- <if test="typeId!=null and typeId==100">
- OR LOWER(c.icd10_code) LIKE LOWER( concat('%',#{inputStr},'%'))
- </if>
- <if test="typeId!=null and typeId==127">
- OR LOWER(c.code) LIKE LOWER( concat('%',#{inputStr},'%'))
- </if>
- <if test="typeId!=null and typeId==128">
- OR LOWER(c.code) LIKE LOWER( concat('%',#{inputStr},'%'))
- </if>
- )
- </if>
- <if test="typeIds != null and typeIds.size > 0">
- <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
- a.type_id =#{typeId}
- </foreach>
- </if>
- ) t
- <if test="typeId!=null and typeId==108">
- LEFT JOIN kl_lis t1 ON t.id = t1.concept_id
- AND t1.is_deleted = 'N'
- LEFT JOIN kl_relation t3 ON t.id = t3.end_id
- AND t3.relation_id = 600
- AND t3.is_deleted = 'N'
- LEFT JOIN kl_concept t4 ON t3.start_id = t4.id
- AND t4.lib_type = 107
- AND t4.is_deleted = 'N'
- </if>
- <if test="size!=null">
- LIMIT #{size}
- </if>
- </select>
- <select id="staticIndex" resultType="com.diagbot.dto.StaticKnowledgeIndexDTO">
- SELECT
- f.*
- FROM
- (
- SELECT
- s.moduleNo,
- s.id,
- s.name,
- s.retrievalName,
- s.isConcept,
- s.type,
- s.typeName,
- s.code,
- s1.concept_id AS conceptId,
- s1.clinical_pathway_name,
- s1.notice_name,
- s1.`status` AS status,
- IF( count( s2.id )> 0, 1, 0 ) AS hasInfo ,
- IF( sum( IF ( FIND_IN_SET( 1, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasStaticKnowledge,
- IF( sum( IF ( FIND_IN_SET( 2, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasNotice,
- IF( sum( IF ( FIND_IN_SET( 3, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasClinicalPathway,
- IF( sum( IF ( FIND_IN_SET( 4, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasTreatInfo
- FROM
- (
- SELECT
- t.moduleNo,
- t.id,
- t.NAME,
- IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
- t.isConcept,
- t.type,
- t.typeName,
- t1.icd10_code AS code
- FROM
- (
- SELECT
- concat( '1', b.lib_type ) AS moduleNo,
- 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
- <if test="typeIds != null and typeIds.size > 0">
- <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
- a.type_id =#{typeId}
- </foreach>
- </if>
- <if test="inputStr!=null and inputStr!=''">
- AND ( a.name = #{inputStr}
- OR LOWER(a.spell) = LOWER(#{inputStr}))
- </if>
- ) t left join kl_disease t1 on t.id = t1.concept_id and t1.is_deleted='N'
- UNION
- SELECT
- t.moduleNo,
- t.id,
- t.NAME,
- IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
- t.isConcept,
- t.type,
- t.typeName,
- t1.icd10_code AS code
- FROM
- (
- SELECT
- concat( '2', b.lib_type ) AS moduleNo,
- 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
- <if test="typeIds != null and typeIds.size > 0">
- <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
- a.type_id =#{typeId}
- </foreach>
- </if>
- <if test="inputStr!=null and inputStr!=''">
- AND ( a.name LIKE concat(#{inputStr},'%')
- OR LOWER(a.spell) LIKE LOWER( concat(#{inputStr},'%')))
- </if>
- ) t left join kl_disease t1 on t.id = t1.concept_id and t1.is_deleted='N'
- UNION
- SELECT
- t.moduleNo,
- t.id,
- t.NAME,
- IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
- t.isConcept,
- t.type,
- t.typeName,
- t1.icd10_code AS code
- FROM
- (
- SELECT
- concat( '3', b.lib_type ) AS moduleNo,
- 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
- <if test="typeIds != null and typeIds.size > 0">
- <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
- a.type_id =#{typeId}
- </foreach>
- </if>
- <if test="inputStr!=null and inputStr!=''">
- AND ( a.name LIKE concat('%',#{inputStr},'%')
- OR LOWER(a.spell) LIKE LOWER( concat('%',#{inputStr},'%')))
- </if>
- ) t left join kl_disease t1 on t.id = t1.concept_id and t1.is_deleted='N'
- <if test="typeIds.contains(107) or typeIds.contains(108)">
- UNION
- SELECT DISTINCT
- concat( '1', e.lib_type ) AS moduleNo,
- e.id AS id,
- e.lib_name AS NAME,
- b.lib_name AS retrievalName,
- 1 AS isConcept,
- e.lib_type AS type,
- c.name AS typeName,
- NULL AS code
- FROM
- kl_library_info a,
- kl_concept b,
- kl_lexicon c,
- kl_relation d,
- kl_concept e
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND a.concept_id = b.id
- AND b.id = d.end_id
- AND e.id = d.start_id
- AND e.lib_type = c.code
- AND b.lib_type = 108
- AND e.lib_type = 107
- AND d.relation_id = 600
- AND b.`status` = 1
- <if test="inputStr!=null and inputStr!=''">
- AND ( a.name = #{inputStr} OR LOWER(a.spell) = LOWER(#{inputStr}))
- </if>
- UNION
- SELECT DISTINCT
- concat( '2', e.lib_type ) AS moduleNo,
- e.id AS id,
- e.lib_name AS NAME,
- b.lib_name AS retrievalName,
- 1 AS isConcept,
- e.lib_type AS type,
- c.name AS typeName,
- NULL AS code
- FROM
- kl_library_info a,
- kl_concept b,
- kl_lexicon c,
- kl_relation d,
- kl_concept e
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND a.concept_id = b.id
- AND b.id = d.end_id
- AND e.id = d.start_id
- AND e.lib_type = c.code
- AND b.lib_type = 108
- AND e.lib_type = 107
- AND d.relation_id = 600
- AND b.`status` = 1
- <if test="inputStr!=null and inputStr!=''">
- AND ( a.name LIKE concat(#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat(#{inputStr},'%')))
- </if>
- UNION
- SELECT DISTINCT
- concat( '3', e.lib_type ) AS moduleNo,
- e.id AS id,
- e.lib_name AS NAME,
- b.lib_name AS retrievalName,
- 1 AS isConcept,
- e.lib_type AS type,
- c.name AS typeName,
- NULL AS code
- FROM
- kl_library_info a,
- kl_concept b,
- kl_lexicon c,
- kl_relation d,
- kl_concept e
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND d.is_deleted = 'N'
- AND e.is_deleted = 'N'
- AND a.concept_id = b.id
- AND b.id = d.end_id
- AND e.id = d.start_id
- AND e.lib_type = c.code
- AND b.lib_type = 108
- AND e.lib_type = 107
- AND d.relation_id = 600
- AND b.`status` = 1
- <if test="inputStr!=null and inputStr!=''">
- AND ( a.name LIKE concat('%',#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat('%',#{inputStr},'%')))
- </if>
- </if>
- <if test="typeIds.contains(100) ">
- UNION
- SELECT
- t.moduleNo,
- 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
- concat( '1', b.lib_type ) AS moduleNo,
- 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.moduleNo,
- 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
- concat( '2', b.lib_type ) AS moduleNo,
- 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.moduleNo,
- 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
- concat( '3', b.lib_type ) AS moduleNo,
- 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'
- LEFT JOIN kl_concept_detail s2 ON s.id = s2.concept_id
- AND s2.is_deleted = 'N'
- GROUP BY s.id
- ) f
- WHERE
- 1 = 1
- <if test="hasInfo!=null ">
- <choose>
- <when test="hasInfo==0">
- AND f.conceptId IS NULL
- </when>
- <when test="hasInfo==1">
- AND f.conceptId IS NOT NULL
- </when>
- </choose>
- </if>
- order by f.type asc,f.moduleNo ASC,f.isConcept DESC
- <if test="size!=null">
- LIMIT #{size}
- </if>
- </select>
- <select id="getLisDetaisByNames" parameterType="com.diagbot.vo.KllisDetailVO" resultType="com.diagbot.dto.KllisDetailDTO">
- SELECT
- t1.lib_name,
- t1.id,
- t2.min_value,
- t2.max_value,
- t2.type,
- t2.unit
- FROM
- `kl_concept` t1,
- kl_lis t2
- WHERE
- t1.is_deleted = "N"
- AND t2.is_deleted = "N"
- AND t1.id = t2.concept_id
- AND t1.lib_type = 108
- AND t1.`status` = 1
- <if test="names != null and names.size > 0">
- and t1.lib_name in
- <foreach item="name" collection="names" open="(" separator="," close=")">
- #{name}
- </foreach>
- </if>
- </select>
- </mapper>
|