123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836 |
- <?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.code as code
- </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==106">
- ,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 code
- </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>
- <if test="typeId!=null and typeId==106">
- ,c.operation_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>
- <if test="typeId!=null and typeId==106">
- LEFT JOIN `kl_operation` 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 test="typeId!=null and typeId==106">
- OR LOWER(c.operation_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 code
- </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>
- <if test="typeId!=null and typeId==106">
- ,c.operation_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>
- <if test="typeId!=null and typeId==106">
- LEFT JOIN `kl_operation` 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 test="typeId!=null and typeId==106">
- OR LOWER(c.operation_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 code
- </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>
- <if test="typeId!=null and typeId==106">
- ,c.operation_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>
- <if test="typeId!=null and typeId==106">
- LEFT JOIN `kl_operation` 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 test="typeId!=null and typeId==106">
- OR LOWER(c.operation_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,
- IF( s2.concept_id IS NOT NULL, s2.concept_id, s3.concept_id ) AS conceptId,
- s1.clinical_pathway_name,
- s1.notice_name,
- s1.`status` AS status,
- IF( count( s2.id )> 0, 1, IF( count( s3.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
- o1.*
- 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>AND ( a.name = #{inputStr}
- </if>
- <if test="inputStr!=null and 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>
- <if test="inputStr!=null and inputStr!=''">
- AND LOWER(l1.icd10_code) = LOWER(#{inputStr})
- </if>
- </where>
- 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>
- <if test="inputStr!=null and inputStr!=''">
- AND LOWER(l1.icd10_code) LIKE LOWER( concat(#{inputStr},'%'))
- </if>
- </where>
- 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>
- <if test="inputStr!=null and inputStr!=''">
- AND LOWER(l1.icd10_code) LIKE LOWER( concat('%',#{inputStr},'%'))
- </if>
- </where>
- </if>
- )o1
- order by o1.type asc,o1.moduleNo ASC,o1.isConcept DESC
- Limit 1000
- ) 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'
- LEFT JOIN kl_concept_scale s3 ON s.id = s3.concept_id
- AND s3.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>
- <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>
- <select id="searchByTypeAndName" parameterType="com.diagbot.vo.SearchConceptVO"
- resultType="com.diagbot.dto.GetAllForRelationDTO">
- <!-- SELECT-->
- <!-- kc.id AS conceptId,-->
- <!-- kc.lib_name AS conceptName,-->
- <!-- kc.lib_type AS libType,-->
- <!-- kc.lib_name AS conceptNameType-->
- <!-- FROM-->
- <!-- `kl_concept` kc-->
- <!-- WHERE-->
- <!-- kc.`status` = 1-->
- <!-- <if test="libType!=null">-->
- <!-- AND kc.lib_type = #{libType}-->
- <!-- </if>-->
- <!-- <if test="name != null and name != ''">-->
- <!-- AND UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')-->
- <!-- </if>-->
- <!-- <if test="excludedConceptIds != null and excludedConceptIds.size > 0">-->
- <!-- AND kc.id not in-->
- <!-- <foreach item="id" collection="excludedConceptIds" open="(" separator="," close=")">-->
- <!-- #{id}-->
- <!-- </foreach>-->
- <!-- </if>-->
- <!-- AND kc.is_deleted = 'N'-->
- <!-- AND kc.id NOT IN (1)-->
- <!-- AND kc.id IN (-->
- <!-- SELECT DISTINCT-->
- <!-- start_id-->
- <!-- FROM-->
- <!-- kl_relation-->
- <!-- WHERE-->
- <!-- is_deleted = 'N'-->
- <!-- AND relation_id = 600-->
- <!-- )-->
- select kc.id AS conceptId,
- kc.lib_name AS conceptName,
- kc.lib_type AS libType,
- kc.lib_name AS conceptNameType
- from (SELECT
- a.*,
- <choose>
- <when test="libType gte 308 and libType lte 328"> b.id as tRelationId</when>
- <otherwise>null as tRelationId</otherwise>
- </choose>
- FROM
- kl_concept a
- <choose>
- <when test="libType gte 308 and libType lte 328"> LEFT JOIN kl_relation b ON a.id = b.start_id
- AND a.lib_type = #{libType} AND b.relation_id = 600 and UPPER(a.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')</when>
- <otherwise>where a.lib_type = #{libType} and UPPER(a.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')</otherwise>
- </choose>
- GROUP BY
- a.id)kc
- where
- <choose>
- <when test="libType gte 308 and libType lte 328"> kc.tRelationId is not null</when>
- <otherwise>kc.tRelationId is null</otherwise>
- </choose>
- limit 100
- </select>
- <select id="searchByTypeAndNameAdd" parameterType="com.diagbot.vo.SearchConceptVO"
- resultType="com.diagbot.dto.GetAllForRelationDTO">
- SELECT
- kc.id AS conceptId,
- kc.lib_name AS conceptName,
- kc.lib_type AS libType,
- kc.lib_name AS conceptNameType,
- kli.remark
- FROM
- `kl_concept` kc,
- kl_library_info kli
- WHERE
- <if test="libType!=null">
- kc.lib_type = #{libType}
- </if>
- AND kc.`status` = 1
- AND kc.is_deleted = 'N'
- <if test="name != null and name != ''">
- AND UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')
- </if>
- <if test="excludedConceptIds != null and excludedConceptIds.size > 0">
- AND kc.id not in
- <foreach item="id" collection="excludedConceptIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- AND kc.id NOT IN (
- SELECT DISTINCT
- start_id
- FROM
- kl_relation
- WHERE
- is_deleted = 'N'
- AND relation_id = 600
- )
- AND kc.id = kli.concept_id
- AND kli.is_deleted = 'N'
- AND kli.is_concept = 1
- limit 100
- </select>
- <select id="searchCollectionConcept" parameterType="com.diagbot.vo.SearchCollectionConceptVO"
- resultType="com.diagbot.dto.GetAllForRelationDTO">
- select kc.id AS conceptId,
- kc.lib_name AS conceptName,
- kc.lib_type AS libType,
- kc.lib_name AS conceptNameType
- from kl_concept kc
- where
- <if test="libType!=null">
- kc.lib_type = #{libType}
- </if>
- AND kc.status = 1
- <if test="excludedConceptIds != null and excludedConceptIds.size > 0">
- AND kc.id not in
- <foreach item="id" collection="excludedConceptIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test="names != null and names.size > 0">
- and
- <choose>
- <when test="logicalOperator != null and logicalOperator eq 0">
- <foreach collection="names" item="id" open="(" separator="and" close=")">
- <if test="id != null and id != ''">
- UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{id})), '%')
- </if>
- </foreach>
- </when>
- <when test="logicalOperator != null and logicalOperator eq 1">
- <foreach collection="names" item="id" open="(" separator="or" close=")">
- <if test="id != null and id != ''">
- UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{id})), '%')
- </if>
- </foreach>
- </when>
- </choose>
- </if>
- LIMIT 100
- </select>
- </mapper>
|