123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287 |
- <?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(109) or typeIds.contains(110)">
- 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 = 110
- AND e.lib_type = 109
- 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 = 110
- AND e.lib_type = 109
- 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 = 110
- AND e.lib_type = 109
- 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="caseIndex" resultType="com.diagbot.dto.ClassicCaseIndexDTO">
- SELECT DISTINCT t.*
- FROM
- (SELECT
- t1.id AS id,
- t1.lib_name AS NAME,
- -- t2.NAME AS retrievalName,
- t1.lib_type AS type,
- t3.name AS typeName,
- t1.status AS status
- FROM
- kl_concept t1
- INNER JOIN kl_library_info t2 ON t1.id = t2.concept_id
- INNER JOIN kl_lexicon t3 ON t1.lib_type = t3.code
- WHERE
- t1.is_deleted = 'N'
- AND t2.is_deleted = 'N'
- AND t3.is_deleted = 'N'
- AND t1.status = 1
- <if test="inputStr!=null and inputStr!=''">
- AND ( t2.name LIKE concat('%',#{inputStr},'%')
- OR
- LOWER(t2.spell) LIKE LOWER( concat('%',#{inputStr},'%')))
- </if>
- ) t
- LEFT JOIN kl_classic_case t4 ON t.id = t4.concept_id and t4.status = 1
- WHERE
- <if test="hasInfo!=null ">
- <choose>
- <when test="hasInfo==0">
- t4.concept_id IS NULL
- </when>
- <when test="hasInfo==1">
- t4.concept_id IS NOT NULL
- </when>
- </choose>
- </if>
- <if test="typeIds != null and typeIds.size > 0">
- <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")">
- t.type =#{typeId}
- </foreach>
- </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>
- <select id="searchCollectionConceptNew" 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 kc.status = 1
- and kc.lib_name in
- <foreach collection="names" item="name" open="(" separator="," close=")">
- #{name}
- </foreach>
- </select>
- <select id="indexByApproval" resultType="com.diagbot.dto.IndexBatchDTO">
- SELECT
- t1.approvalNum,
- t1.approval,
- t1.id,
- t1.NAME,
- t1.regName,
- t1.form,
- t1.status,
- t2.id AS formConceptId
- FROM
- (
- SELECT
- REPLACE ( a.approval, '国药准字', '' ) AS approvalNum,
- a.approval AS approval,
- c.id AS id,
- c.lib_name AS NAME,
- a.NAME AS regName,
- a.form AS form,
- c.status AS status
- FROM
- kl_drug_register a,
- `kl_drug_mapping` b,
- kl_concept c
- WHERE
- a.id = b.register_id
- AND b.drug_concept = c.id
- AND a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- <if test="status != null">
- AND c.STATUS = #{status}
- </if>
- <if test="approvalList != null and approvalList.size > 0">
- <foreach item="approval" collection="approvalList" open="and(" separator="or" close=")">
- a.approval = #{approval}
- </foreach>
- </if>
- ) t1
- LEFT JOIN ( SELECT * FROM kl_concept WHERE is_deleted = 'N' AND STATUS = 1 AND lib_type = 102 ) t2 ON t1.form = t2.lib_name
- <!--GROUP BY
- t1.approval-->
- </select>
- <!--ICD编码查询-->
- <select id="findDiseaeByCode" resultType="com.diagbot.dto.DiseaseIndexDTO">
- SELECT
- t.id,
- <if test="diseaseIndexPageVO.type != null">
- <choose>
- <when test="diseaseIndexPageVO.type == 1">
- t.lib_name AS NAME,
- t.icd10_code AS CODE,
- </when>
- <when test="diseaseIndexPageVO.type == 2">
- t.guoname AS NAME,
- t.guocode AS CODE,
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </if>
- t.partId
- FROM
- (
- SELECT
- a.id,
- a.lib_name,
- b.spell,
- c.icd10_code,
- c.guoname,
- c.guocode,
- c.guospell,
- CONCAT( '1', a.lib_type ) AS partId
- FROM
- kl_concept a,
- kl_library_info b,
- kl_disease c
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND a.id = b.concept_id
- AND a.id = c.concept_id
- AND b.is_concept = 1
- AND a.lib_type = 100
- AND a.`status` = 1
- <if test="diseaseIndexPageVO.inputStr != null and diseaseIndexPageVO.inputStr != '' and diseaseIndexPageVO.type != null">
- <choose>
- <when test="diseaseIndexPageVO.type == 1">
- AND c.icd10_code != ''
- AND ( a.lib_name = #{diseaseIndexPageVO.inputStr}
- OR b.spell = #{diseaseIndexPageVO.inputStr}
- OR c.icd10_code = #{diseaseIndexPageVO.inputStr} )
- </when>
- <when test="diseaseIndexPageVO.type == 2">
- AND c.guocode != ''
- AND ( c.guoname = #{diseaseIndexPageVO.inputStr}
- OR c.guospell = #{diseaseIndexPageVO.inputStr}
- OR c.guocode = #{diseaseIndexPageVO.inputStr} )
- </when>
- <otherwise></otherwise>
- </choose>
- </if>
- UNION
- SELECT
- a.id,
- a.lib_name,
- b.spell,
- c.icd10_code,
- c.guoname,
- c.guocode,
- c.guospell,
- CONCAT( '2', a.lib_type ) AS partId
- FROM
- kl_concept a,
- kl_library_info b,
- kl_disease c
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND a.id = b.concept_id
- AND a.id = c.concept_id
- AND b.is_concept = 1
- AND a.lib_type = 100
- AND a.`status` = 1
- <if test="diseaseIndexPageVO.inputStr != null and diseaseIndexPageVO.inputStr != '' and diseaseIndexPageVO.type != null">
- <choose>
- <when test="diseaseIndexPageVO.type == 1">
- AND c.icd10_code != ''
- AND ( a.lib_name LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
- OR b.spell LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
- OR c.icd10_code LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' ) )
- </when>
- <when test="diseaseIndexPageVO.type == 2">
- AND c.guocode != ''
- AND ( c.guoname LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
- OR c.guospell LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
- OR c.guocode LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' ) )
- </when>
- <otherwise></otherwise>
- </choose>
- </if>
- UNION
- SELECT
- a.id,
- a.lib_name,
- b.spell,
- c.icd10_code,
- c.guoname,
- c.guocode,
- c.guospell,
- CONCAT( '3', a.lib_type ) AS partId
- FROM
- kl_concept a,
- kl_library_info b,
- kl_disease c
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND a.id = b.concept_id
- AND a.id = c.concept_id
- AND b.is_concept = 1
- AND a.lib_type = 100
- AND a.`status` = 1
- <if test="diseaseIndexPageVO.inputStr != null and diseaseIndexPageVO.inputStr != '' and diseaseIndexPageVO.type != null">
- <choose>
- <when test="diseaseIndexPageVO.type == 1">
- AND c.icd10_code != ''
- AND ( a.lib_name LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' )
- OR b.spell LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' )
- OR c.icd10_code LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' ) )
- AND (
- a.lib_name NOT LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
- AND b.spell NOT LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
- AND c.icd10_code NOT LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
- )
- </when>
- <when test="diseaseIndexPageVO.type == 2">
- AND c.guocode != ''
- AND ( c.guoname LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' )
- OR c.guospell LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' )
- OR c.guocode LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' ) )
- AND (
- c.guoname NOT LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
- AND c.guospell NOT LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
- AND c.guocode NOT LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
- )
- </when>
- <otherwise></otherwise>
- </choose>
- </if>
- ) t
- ORDER BY
- t.partId
- </select>
- <!--ICD编码查询-->
- <select id="diseaseIndex" resultType="com.diagbot.dto.DiseaseIndexDTO">
- SELECT
- k.id,
- k.name,
- k.code,
- k.spell,
- k.pos,
- least( k.nameLen, k.spellLen, k.codeLen ) AS len
- FROM
- (
- SELECT
- t.*,
- LEAST( t.namePos, t.spellPos, t.codePos ) AS pos,
- IF( LEAST( t.namePos, t.spellPos, t.codePos )= namePos, CHAR_LENGTH( t.name ), 999 ) AS nameLen,
- IF( LEAST( t.namePos, t.spellPos, t.codePos )= spellPos, CHAR_LENGTH( t.spell ), 999 ) AS spellLen,
- IF( LEAST( t.namePos, t.spellPos, t.codePos )= codePos, CHAR_LENGTH( t.code ), 999 ) AS codeLen
- FROM
- (
- SELECT
- <if test="diseaseIndexPageVO.inputStr != null and diseaseIndexPageVO.inputStr != '' and diseaseIndexPageVO.type != null">
- <choose>
- <when test="diseaseIndexPageVO.type == 1">
- IF( POSITION( #{diseaseIndexPageVO.inputStr} IN a.lib_name )> 0, POSITION( #{diseaseIndexPageVO.inputStr} IN a.lib_name ), 999 ) AS namePos,
- IF( POSITION( #{diseaseIndexPageVO.inputStr} IN b.spell )> 0, POSITION( #{diseaseIndexPageVO.inputStr} IN b.spell ), 999 ) AS spellPos,
- IF( POSITION( #{diseaseIndexPageVO.inputStr} IN c.icd10_code )> 0, POSITION( #{diseaseIndexPageVO.inputStr} IN c.icd10_code ), 999 ) AS codePos,
- </when>
- <when test="diseaseIndexPageVO.type == 2">
- IF( POSITION( #{diseaseIndexPageVO.inputStr} IN c.guoname )> 0, POSITION( #{diseaseIndexPageVO.inputStr} IN c.guoname ), 999 ) AS namePos,
- IF( POSITION( #{diseaseIndexPageVO.inputStr} IN c.guospell )> 0, POSITION( #{diseaseIndexPageVO.inputStr} IN c.guospell ), 999 ) AS spellPos,
- IF( POSITION( #{diseaseIndexPageVO.inputStr} IN c.guocode )> 0, POSITION( #{diseaseIndexPageVO.inputStr} IN c.guocode ), 999 ) AS codePos,
- </when>
- <otherwise></otherwise>
- </choose>
- </if>
- <if test="diseaseIndexPageVO.type != null">
- <choose>
- <when test="diseaseIndexPageVO.type == 1">
- a.lib_name AS NAME,
- c.icd10_code AS CODE,
- b.spell AS spell,
- </when>
- <when test="diseaseIndexPageVO.type == 2">
- c.guoname AS NAME,
- c.guocode AS CODE,
- c.guospell AS spell,
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </if>
- a.id
- FROM
- kl_concept a,
- kl_library_info b,
- kl_disease c
- WHERE
- a.is_deleted = 'N'
- AND b.is_deleted = 'N'
- AND c.is_deleted = 'N'
- AND a.id = b.concept_id
- AND a.id = c.concept_id
- AND b.is_concept = 1
- AND a.lib_type = 100
- AND a.`status` = 1
- <if test="diseaseIndexPageVO.inputStr != null and diseaseIndexPageVO.inputStr != '' and diseaseIndexPageVO.type != null">
- <choose>
- <when test="diseaseIndexPageVO.type == 1">
- AND c.icd10_code != ''
- AND ( a.lib_name LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' )
- OR b.spell LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' )
- OR c.icd10_code LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' ) )
- </when>
- <when test="diseaseIndexPageVO.type == 2">
- AND c.guocode != ''
- AND ( c.guoname LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' )
- OR c.guospell LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' )
- OR c.guocode LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' ) )
- </when>
- <otherwise></otherwise>
- </choose>
- </if>
- ) t
- ) k
- ORDER BY
- k.pos,
- len
- </select>
- </mapper>
|