Commit 32c1c909 authored by 吴霞's avatar 吴霞

缓存和修改sql

parent 50827879
......@@ -194,6 +194,11 @@ public class DataPlatController {
return ResponseUtil.error(e.toString(), "获取医院相关统计(申请数、认证数、开展筛查数)失败!");
}
}
@GetMapping("/name")
public Object getnamelist() {
return dataPlatService.getnamDtos();
}
}
package com.sict.data.dto;
import lombok.Data;
@Data
public class NameDTO {
private Integer id;
private String name;
}
......@@ -79,4 +79,7 @@ public interface DataPlatMapper extends BaseMapper<DataPlat> {
* @return com.sict.data.dto.HospStatisticsDTO
*/
HospStatisticsDTO getHospStatistics();
List<NameDTO> getNameDTOs();
}
......@@ -83,4 +83,6 @@ public interface IDataPlatService extends IService<DataPlat> {
* @return com.sict.data.dto.HospStatisticsDTO
*/
HospStatisticsDTO getHospStatistics();
List<NameDTO> getnamDtos();
}
......@@ -224,4 +224,11 @@ public class DataPlatServiceImpl extends ServiceImpl<DataPlatMapper, DataPlat> i
}
}
@Cacheable(cacheNames = {"getnamDtos"})
@Override
public List<NameDTO> getnamDtos() {
// TODO Auto-generated method stub
return dataPlatMapper.getNameDTOs();
}
}
......@@ -2,20 +2,13 @@
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
updateCheck="false">
<defaultCache
eternal="false"
maxElementsInMemory="10000"
overflowToDisk="false"
timeToIdleSeconds="300"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getScreeningRank"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
......@@ -23,10 +16,10 @@
<cache
name="getScreeningRankEn"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
......@@ -34,73 +27,82 @@
<cache
name="getSerumStatistics"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getGastroscopyStatistics"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getScreeningStatistics"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getGastroscopyDetailResultStatistics"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getRiskAssessStatistics"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getGastroscopyDetailStatistics"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getHospStatistics"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getComplexStatistics"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getnamDtos"
eternal="false"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="6"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
</ehcache>
\ No newline at end of file
......@@ -2,735 +2,556 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sict.data.mapper.DataPlatMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.sict.data.model.DataPlat">
<id column="id" property="id"/>
<result column="name" property="name"/>
</resultMap>
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap"
type="com.sict.data.model.DataPlat">
<id column="id" property="id" />
<result column="name" property="name" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, `name`
</sql>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, `name`
</sql>
<!-- 获取各医联体下筛查人数排行榜 -->
<select id="getHospScreeningRank" resultType="com.sict.data.dto.HospScreeningDTO">
SELECT
hospNum,
hospName,
count( * ) hospScreeningTotal,
count( screeningStatus = 1 OR NULL ) hospApplyScreeningTotal
FROM
(
SELECT
p.id patientId,
p.`name` patientName,
rel5.number hospNum,
rel5.`name` hospName,
CASE
rel1.igg
WHEN 1 THEN
'阳性'
WHEN 0 THEN
'阴性' ELSE ''
END iggDetection,
CASE
rel2.grade
WHEN 1 THEN
'低风险'
WHEN 2 THEN
'中风险'
WHEN 3 THEN
'高风险' ELSE ''
END riskLevel,
CASE
rel3.is_inspect
WHEN 1 THEN
'是'
WHEN 0 THEN
'否' ELSE '否'
END isGastroscopy,
rel3.inspect_way gastroscopyWay,
CASE
rel3.capsule
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见异常' ELSE ''
END gastroscopyResult,
rel3.precise_way gastroscopyDetailWay,
CASE
rel3.diagnose_result
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见明显异常' ELSE ''
END gastroscopyDetailResult,
rel3.diagnose_info gastroscopyDetailInfo,
CASE
rel4.continue_flup
WHEN 1 THEN
'继续随访'
WHEN 0 THEN
'停止随访' ELSE ''
END isContinueFlup,
rel4.content_type planFlupContent,
rel1.`status` screeningStatus
FROM
tb_patient p
RIGHT JOIN ( SELECT patient_id, igg, step, `status` FROM tb_lab_inspect WHERE `status` NOT IN ( 0, 5 ) ) rel1 ON rel1.patient_id = p.id
RIGHT JOIN ( SELECT patient_id, step, score, grade, `status` FROM tb_risk_assess WHERE `status` NOT IN ( 0, 5 ) ) rel2 ON rel2.patient_id = p.id
AND rel2.step = rel1.step
AND rel2.`status` = rel1.`status`
LEFT JOIN (
SELECT
patient_id,
step,
is_inspect,
inspect_way,
capsule,
precise_way,
diagnose_result,
diagnose_info,
`status`
FROM
tb_gastro_inspect
WHERE
`status` NOT IN ( 0, 5 )
) rel3 ON rel3.patient_id = p.id
AND rel3.step = rel2.step
AND rel3.`status` = rel2.`status`
LEFT JOIN ( SELECT patient_id, step, continue_flup, content_type, `status` FROM tb_flup_plan WHERE `status` NOT IN ( 0, 5 ) ) rel4 ON rel4.patient_id = p.id
AND rel4.step = rel3.step
AND rel4.`status` = rel3.`status`
INNER JOIN ( SELECT number, `name` FROM tb_hosp ) rel5 ON rel5.number = p.hosp_number
) rel
GROUP BY
hospName
ORDER BY
hospScreeningTotal DESC
</select>
<!-- 获取各医联体下筛查人数排行榜 英文-->
<select id="getHospScreeningRankEn" resultType="com.sict.data.dto.HospScreeningDTO">
SELECT
hospNum,
ehospName hospName,
count( * ) hospScreeningTotal,
count( screeningStatus = 1 OR NULL ) hospApplyScreeningTotal
FROM
(
SELECT
p.id patientId,
p.`name` patientName,
rel5.number hospNum,
rel5.name hospName,rel5.ename ehospName,
CASE
rel1.igg
WHEN 1 THEN
'阳性'
WHEN 0 THEN
'阴性' ELSE ''
END iggDetection,
CASE
rel2.grade
WHEN 1 THEN
'低风险'
WHEN 2 THEN
'中风险'
WHEN 3 THEN
'高风险' ELSE ''
END riskLevel,
CASE
rel3.is_inspect
WHEN 1 THEN
'是'
WHEN 0 THEN
'否' ELSE '否'
END isGastroscopy,
rel3.inspect_way gastroscopyWay,
CASE
rel3.capsule
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见异常' ELSE ''
END gastroscopyResult,
rel3.precise_way gastroscopyDetailWay,
CASE
rel3.diagnose_result
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见明显异常' ELSE ''
END gastroscopyDetailResult,
rel3.diagnose_info gastroscopyDetailInfo,
CASE
rel4.continue_flup
WHEN 1 THEN
'继续随访'
WHEN 0 THEN
'停止随访' ELSE ''
END isContinueFlup,
rel4.content_type planFlupContent,
rel1.`status` screeningStatus
FROM
tb_patient p
RIGHT JOIN ( SELECT patient_id, igg, step, `status` FROM tb_lab_inspect WHERE `status` NOT IN ( 0, 5 ) ) rel1 ON rel1.patient_id = p.id
RIGHT JOIN ( SELECT patient_id, step, score, grade, `status` FROM tb_risk_assess WHERE `status` NOT IN ( 0, 5 ) ) rel2 ON rel2.patient_id = p.id
AND rel2.step = rel1.step
AND rel2.`status` = rel1.`status`
LEFT JOIN (
SELECT
patient_id,
step,
is_inspect,
inspect_way,
capsule,
precise_way,
diagnose_result,
diagnose_info,
`status`
FROM
tb_gastro_inspect
WHERE
`status` NOT IN ( 0, 5 )
) rel3 ON rel3.patient_id = p.id
AND rel3.step = rel2.step
AND rel3.`status` = rel2.`status`
LEFT JOIN ( SELECT patient_id, step, continue_flup, content_type, `status` FROM tb_flup_plan WHERE `status` NOT IN ( 0, 5 ) ) rel4 ON rel4.patient_id = p.id
AND rel4.step = rel3.step
AND rel4.`status` = rel3.`status`
INNER JOIN ( SELECT number,`name`, ename FROM tb_hosp_en ) rel5 ON rel5.number = p.hosp_number
) rel
GROUP BY
hospName
ORDER BY
hospScreeningTotal DESC
</select>
<!-- 获取各医联体下筛查人数排行榜 -->
<select id="getHospScreeningRank"
resultType="com.sict.data.dto.HospScreeningDTO">
SELECT
hospNum,
hospName,
count( * ) hospScreeningTotal,
count( NULL ) hospApplyScreeningTotal
FROM
(
SELECT
p.id patientId,
p.hosp_number,
p.`name` patientName,
rel1.number hospNum,
rel1.`name`
hospName
FROM
tb_patient p
INNER JOIN ( SELECT number, `name` FROM
tb_hosp ) rel1 ON rel1.number = p.hosp_number
WHERE p.step=0
) rel
GROUP
BY
hospName
ORDER BY
hospScreeningTotal DESC
</select>
<!-- 获取各医联体下筛查人数排行榜 英文 -->
<select id="getHospScreeningRankEn"
resultType="com.sict.data.dto.HospScreeningDTO">
SELECT
hospNum,
ehospName hospName,
count( * )
hospScreeningTotal,
count( NULL ) hospApplyScreeningTotal
FROM
(
SELECT
p.id patientId,
p.hosp_number,
p.`name` patientName,
rel1.number hospNum,
rel1.`name` hospName,
rel1.ename ehospName
FROM
tb_patient p
INNER JOIN (
SELECT number, `name`,ename FROM tb_hosp_en ) rel1 ON rel1.number =
p.hosp_number
WHERE p.step=0
) rel
GROUP BY
hospName
ORDER BY
hospScreeningTotal DESC LIMIT 30
</select>
<!-- 获取各省份血检人次统计结果 -->
<select id="getProvinceSerumStatistics"
resultType="com.sict.data.dto.ProvinceSerumDTO">
SELECT
provinceName,
sum( serumTestPlan + serumTestActual )
serumTestTotal,
sum( serumTestPlan ) serumTestPlan,
sum( serumTestActual
) serumTestActual,
sum( iggPositive ) iggPositive,
sum( earlyCancer )
earlyCancer
FROM
(
(
SELECT
provinceName,
count( NULL ) serumTestPlan,
count( * ) serumTestActual,
count( iggDetection = '阳性' OR
NULL )
iggPositive,
count( NULL ) earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step labInspectStep,
rel1.g17 G17,
rel1.pg1
PG1,
rel1.pg2 PG2,
CASE
rel1.igg
WHEN 1 THEN
'阳性'
WHEN 0 THEN
'阴性' ELSE ''
END iggDetection,
rel1.`status` labInspectStatus
FROM
tb_patient AS p
INNER JOIN ( SELECT patient_id, step, g17, pg1, pg2, igg, `status`
FROM
tb_lab_inspect ) rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT
`name`, number FROM tb_hosp ) rel2 ON rel2.number =
p.hosp_number
INNER
JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON
rel3.`name`
= rel2.`name`
WHERE
rel1.`status` NOT IN ( 0, 5 )
) rel
GROUP BY
provinceName
) UNION
(
SELECT
provinceName,
count( NULL ) serumTestPlan,
count( NULL ) serumTestActual,
count( NULL ) iggPositive,
count(
gastroscopyDetailInfo LIKE '%"b":1%' OR NULL ) + count(
gastroscopyDetailInfo LIKE '%"g":1%' OR NULL ) earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step gastroscopyStep,
rel1.is_inspect isGastroscopy,
rel1.inspect_way gastroscopyWay,
rel1.capsule gastroscopyResult,
rel1.precise_way gastroscopyDetailWay,
rel1.diagnose_result gastroscopyDetailResult,
rel1.diagnose_info
gastroscopyDetailInfo,
rel1.`status` gastroscopyAuditStatus
FROM
tb_patient p
INNER JOIN (
SELECT
patient_id,
step,
is_inspect,
inspect_way,
capsule,
precise_way,
diagnose_result,
diagnose_info,
`status`
FROM
tb_gastro_inspect
WHERE
is_inspect = 1
AND `status` NOT IN ( 0, 5 )
AND
diagnose_result = 1
) rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT
`name`, number FROM tb_hosp ) rel2 ON rel2.number =
p.hosp_number
LEFT
JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON
rel3.`name`
= rel2.`name`
) rel
GROUP BY
provinceName
)
) rel
GROUP BY
provinceName
</select>
<!-- 获取各省份胃镜检查人次统计结果 -->
<select id="getProvinceGastroscopyStatistics"
resultType="com.sict.data.dto.ProvinceGastroscopyDTO">
SELECT
provinceName,
sum( gastroscopyPlan + gastroscopyActual
) gastroscopyTotal,
sum( gastroscopyPlan ) gastroscopyPlan,
sum(
gastroscopyActual ) gastroscopyActual,
sum( gastroscopyDetail )
gastroscopyDetail,
sum( earlyCancer ) earlyCancer
FROM
(
(
SELECT
provinceName,
count( * ) gastroscopyPlan,
count( NULL )
gastroscopyActual,
count( NULL ) gastroscopyDetail,
count( NULL )
earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step
planFlupStep,
CASE
rel1.continue_flup
WHEN 1 THEN
'继续随访'
WHEN 0 THEN
'停止随访'
ELSE ''
END isContinueFlup,
rel1.content_type planFlupContent
FROM
tb_patient p
RIGHT JOIN ( SELECT patient_id, step, continue_flup,
content_type FROM
tb_flup_plan WHERE continue_flup = 1 AND content_type
LIKE '%a%' )
rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT `name`,
number FROM tb_hosp ) rel2 ON rel2.number =
p.hosp_number
LEFT JOIN (
SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON
rel3.`name` =
rel2.`name`
) rel
GROUP BY
provinceName
) UNION
(
SELECT
provinceName,
count(
NULL ) gastroscopyPlan,
count( * ) gastroscopyActual,
count(
gastroscopyDetailWay &lt;&gt; '[]' OR NULL ) gastroscopyDetail,
count(
gastroscopyDetailDetail LIKE '%"b":1%' OR NULL ) + count(
gastroscopyDetailDetail LIKE '%"g":1%' OR NULL ) earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step gastroscopyStep,
CASE
rel1.is_inspect
WHEN 1 THEN
'是'
WHEN 0 THEN
'否' ELSE ''
END
isGastroscopy,
rel1.inspect_way gastroscopyWay,
CASE
rel1.capsule
WHEN 1
THEN
'异常'
WHEN 2 THEN
'未见异常' ELSE ''
END gastroscopyResult,
rel1.precise_way gastroscopyDetailWay,
CASE
WHEN rel1.diagnose_result =
1 THEN
'异常'
WHEN rel1.diagnose_result = 2 THEN
'未见明显异常' ELSE ''
END
gastroscopyDetailResult,
rel1.diagnose_info gastroscopyDetailDetail,
rel1.STATUS gastroscopyAuditStatus
FROM
tb_patient p
INNER JOIN (
SELECT
patient_id,
step,
inspect_way,
precise_way,
capsule,
diagnose_result,
diagnose_info,
is_inspect,
`status`
FROM
tb_gastro_inspect
WHERE
is_inspect
= 1
AND `status` NOT IN ( 0, 5 )
) rel1 ON rel1.patient_id = p.id
INNER
JOIN ( SELECT `name`, number FROM tb_hosp ) rel2 ON rel2.number =
p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area )
rel3 ON
rel3.`name` = rel2.`name`
) rel
GROUP BY
provinceName
)
) rel
GROUP
BY
provinceName
</select>
<!-- 获取各省份筛查人次统计结果 -->
<select id="getProvinceScreeningStatistics"
resultType="com.sict.data.dto.ProvinceScreeningDTO">
SELECT
area provinceName,
count( * ) provinceScreeningTotal,
count( NULL ) provinceApplyScreeningTotal,
count( hospaudditStatus = 0
OR NULL ) hospApply
FROM(
SELECT p.id patientId,rel2.area
area,rel3.is_auddit hospAudditStatus FROM
tb_patient p
INNER JOIN (
SELECT number, `name` FROM tb_hosp ) rel1 ON rel1.number =
p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area )
rel2 ON
rel2.`name` = rel1.`name`
LEFT JOIN ( SELECT hosp_number,
is_auddit FROM tmp_tb_hosp_apply ) rel3 ON
rel3.hosp_number =
rel1.number
WHERE p.step=0
)rel
GROUP BY provinceName
</select>
<!-- 获取省份胃镜精查最终诊断异常统计结果 -->
<select id="getProvinceGastroscopyResult"
resultType="com.sict.data.dto.ProvinceGastroscopyResultDTO">
SELECT
provinceName,
(
count( gastroDetailInfo LIKE '%"a":1%'
OR NULL ) + count( gastroDetailInfo
LIKE '%"b":1%' OR NULL )
+ count(
gastroDetailInfo LIKE '%"c":1%' OR NULL ) + count(
gastroDetailInfo
LIKE '%"d":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"e":1%' OR
NULL ) + count(
gastroDetailInfo LIKE '%"f":1%' OR NULL )
+ count(
gastroDetailInfo LIKE '%"g":1%' OR NULL ) + count(
gastroDetailInfo
LIKE '%"h":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"i":1%' OR
NULL ) + count(
gastroDetailInfo LIKE '%"j":1%' OR NULL )
+ count(
gastroDetailInfo LIKE '%"k":1%' OR NULL ) + count(
gastroDetailInfo
LIKE '%"l":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"m":1%' OR
NULL ) + count(
gastroDetailInfo LIKE '%"n":%' OR NULL )
) total,
count(
gastroDetailInfo LIKE '%"a":1%' OR NULL ) AS esophagusTumor,
count(
gastroDetailInfo LIKE '%"b":1%' OR NULL ) AS earlyEsophagealCancer,
count( gastroDetailInfo LIKE '%"c":1%' OR NULL ) AS
progressEsophagealCancer,
count( gastroDetailInfo LIKE '%"d":1%' OR
NULL ) AS barretEsophagus,
count( gastroDetailInfo LIKE '%"e":1%' OR
NULL ) AS refluxEsophagitis,
count( gastroDetailInfo LIKE '%"f":1%' OR
NULL ) AS
gastricMucosaTumor,
count( gastroDetailInfo LIKE '%"g":1%' OR
NULL ) AS earlyGastricCancer,
count( gastroDetailInfo LIKE '%"h":1%' OR
NULL ) AS
progressGastricCancer,
count( gastroDetailInfo LIKE '%"i":1%'
OR NULL ) AS atrophicGastritis,
count( gastroDetailInfo LIKE '%"j":1%'
OR NULL ) AS stomachUlcer,
count( gastroDetailInfo LIKE '%"k":1%' OR
NULL ) AS gastricPolyp,
count( gastroDetailInfo LIKE '%"l":1%' OR NULL
) AS
nonAtrophicGastritis,
count( gastroDetailInfo LIKE '%"m":1%' OR
NULL ) AS duodenalUlcer,
count( gastroDetailInfo LIKE '%"n":%' OR NULL
) AS others,
count( gastroDetailInfo LIKE '%"type_a":"a"%' OR
gastroDetailInfo LIKE
'%"type_f":"a"%' OR NULL ) AS highEsophagusTumor
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step gastroStep,
rel1.is_inspect isGastro,
rel1.inspect_way gastroWay,
rel1.capsule
gastroResult,
rel1.precise_way gastroDetailWay,
rel1.diagnose_result
gastroDetailResult,
rel1.diagnose_info gastroDetailInfo,
rel1.`status`
auditStatus
FROM
tb_patient p
INNER JOIN (
SELECT
patient_id,
step,
is_inspect,
inspect_way,
capsule,
precise_way,
diagnose_result,
diagnose_info,
`status`
FROM
tb_gastro_inspect
WHERE
is_inspect = 1
AND
`status` NOT IN ( 0, 5 )
AND diagnose_result = 1
) rel1 ON
rel1.patient_id = p.id
INNER JOIN ( SELECT `name`, number FROM tb_hosp
) rel2 ON rel2.number =
p.hosp_number
LEFT JOIN ( SELECT area, `name`
FROM tmp_tb_hosp_area ) rel3 ON
rel3.`name` = rel2.`name`
) rel
GROUP BY
provinceName
</select>
<!-- 获取患病风险等级评估统计 -->
<select id="getRiskAssessStatistics"
resultType="com.sict.data.dto.RiskAssessDTO">
SELECT
count( riskLevel = '高风险' OR NULL ) highRisk,
count(
riskLevel = '中风险' OR NULL) mediumRisk,
count( riskLevel = '低风险' OR
NULL) lowRisk
FROM
(
SELECT
p.id patientId,
rel1.score riskScore,
CASE
rel1.grade
WHEN 1 THEN
'低风险'
WHEN 2 THEN
'中风险'
WHEN 3 THEN
'高风险' ELSE ''
END
riskLevel
FROM
tb_patient p
INNER JOIN ( SELECT patient_id, score,
grade
FROM tb_risk_assess ) rel1 ON
rel1.patient_id = p.id
INNER JOIN (SELECT
name,number FROM tb_hosp )rel2 ON rel2.number = p.hosp_number
) rel
</select>
<!-- 获取胃镜精查统计结果 -->
<select id="getGastroscopyDetailStatistics"
resultType="com.sict.data.dto.GastroscopyDetailDTO">
SELECT sum(total )total,sum(actual) actual
FROM
(
(SELECT
COUNT(DISTINCT p2.patient_id) total,COUNT(NULL) actual from
tb_patient
p1 INNER JOIN tb_risk_assess p2 on p1.id = p2.patient_id
INNER JOIN
(SELECT `name`,number FROM tb_hosp )rel2 ON rel2.number =
p1.hosp_number
WHERE p2.grade >1 AND p2.step=0
)
UNION
(SELECT COUNT(NULL)
total, COUNT(*) actual FROM
tb_patient p1 INNER JOIN tb_gastro_inspect
p2 ON p1.id=p2.patient_id
INNER JOIN (SELECT `name`,number FROM tb_hosp )rel2 ON rel2.number =
p1.hosp_number
WHERE p2.capsule =1)
)rel
</select>
<!-- 获取医院相关统计(申请数、认证数) -->
<select id="getHospStatistics"
resultType="com.sict.data.dto.HospStatisticsDTO">
SELECT
count( is_auddit = 1 OR NULL ) certifiedHosp,
count(
is_auddit = 0 OR NULL ) applyHosp
FROM
tmp_tb_hosp_apply
</select>
<!-- 获取各省份血检人次统计结果 -->
<select id="getProvinceSerumStatistics" resultType="com.sict.data.dto.ProvinceSerumDTO">
SELECT
provinceName,
sum( serumTestPlan + serumTestActual ) serumTestTotal,
sum( serumTestPlan ) serumTestPlan,
sum( serumTestActual ) serumTestActual,
sum( iggPositive ) iggPositive,
sum( earlyCancer ) earlyCancer
FROM
(
(
SELECT
provinceName,
count( * ) serumTestPlan,
count( NULL ) serumTestActual,
count( NULL ) iggPositive,
count( NULL ) earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step planFlupStep,
CASE
rel1.continue_flup
WHEN 1 THEN
'继续随访'
WHEN 0 THEN
'停止随访' ELSE ''
END isContinueFlup,
rel1.content_type planFlupContent,
rel1.`status` planFlupAuditStatus
FROM
tb_patient p
RIGHT JOIN ( SELECT patient_id, step, continue_flup, content_type, `status` FROM tb_flup_plan WHERE continue_flup = 1 AND content_type LIKE '%b%' ) rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT `name`, number FROM tb_hosp ) rel2 ON rel2.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON rel3.`name` = rel2.`name`
) rel
GROUP BY
provinceName
) UNION
(
SELECT
provinceName,
count( NULL ) serumTestPlan,
count( * ) serumTestActual,
count( iggDetection = '阳性' OR NULL ) iggPositive,
count( NULL ) earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step labInspectStep,
rel1.g17 G17,
rel1.pg1 PG1,
rel1.pg2 PG2,
CASE
rel1.igg
WHEN 1 THEN
'阳性'
WHEN 0 THEN
'阴性' ELSE ''
END iggDetection,
rel1.`status` labInspectStatus
FROM
tb_patient AS p
RIGHT JOIN ( SELECT patient_id, step, g17, pg1, pg2, igg, `status` FROM tb_lab_inspect ) rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT `name`, number FROM tb_hosp ) rel2 ON rel2.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON rel3.`name` = rel2.`name`
WHERE
rel1.`status` NOT IN ( 0, 5 )
) rel
GROUP BY
provinceName
) UNION
(
SELECT
provinceName,
count( NULL ) serumTestPlan,
count( NULL ) serumTestActual,
count( NULL ) iggPositive,
count( gastroscopyDetailInfo LIKE '%"b":1%' OR NULL ) + count( gastroscopyDetailInfo LIKE '%"g":1%' OR NULL ) earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step gastroscopyStep,
rel1.is_inspect isGastroscopy,
rel1.inspect_way gastroscopyWay,
rel1.capsule gastroscopyResult,
rel1.precise_way gastroscopyDetailWay,
rel1.diagnose_result gastroscopyDetailResult,
rel1.diagnose_info gastroscopyDetailInfo,
rel1.`status` gastroscopyAuditStatus
FROM
tb_patient p
RIGHT JOIN (
SELECT
patient_id,
step,
is_inspect,
inspect_way,
capsule,
precise_way,
diagnose_result,
diagnose_info,
`status`
FROM
tb_gastro_inspect
WHERE
is_inspect = 1
AND `status` NOT IN ( 0, 5 )
AND diagnose_result = 1
) rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT `name`, number FROM tb_hosp ) rel2 ON rel2.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON rel3.`name` = rel2.`name`
) rel
GROUP BY
provinceName
)
) rel
GROUP BY
provinceName
</select>
<!-- 获取各省份胃镜检查人次统计结果 -->
<select id="getProvinceGastroscopyStatistics" resultType="com.sict.data.dto.ProvinceGastroscopyDTO">
SELECT
provinceName,
sum( gastroscopyPlan + gastroscopyActual ) gastroscopyTotal,
sum( gastroscopyPlan ) gastroscopyPlan,
sum( gastroscopyActual ) gastroscopyActual,
sum( gastroscopyDetail ) gastroscopyDetail,
sum( earlyCancer ) earlyCancer
FROM
(
(
SELECT
provinceName,
count( * ) gastroscopyPlan,
count( NULL ) gastroscopyActual,
count( NULL ) gastroscopyDetail,
count( NULL ) earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step planFlupStep,
CASE
rel1.continue_flup
WHEN 1 THEN
'继续随访'
WHEN 0 THEN
'停止随访' ELSE ''
END isContinueFlup,
rel1.content_type planFlupContent
FROM
tb_patient p
RIGHT JOIN ( SELECT patient_id, step, continue_flup, content_type FROM tb_flup_plan WHERE continue_flup = 1 AND content_type LIKE '%a%' ) rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT `name`, number FROM tb_hosp ) rel2 ON rel2.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON rel3.`name` = rel2.`name`
) rel
GROUP BY
provinceName
) UNION
(
SELECT
provinceName,
count( NULL ) gastroscopyPlan,
count( * ) gastroscopyActual,
count( gastroscopyDetailWay &lt;&gt; '[]' OR NULL ) gastroscopyDetail,
count( gastroscopyDetailDetail LIKE '%"b":1%' OR NULL ) + count( gastroscopyDetailDetail LIKE '%"g":1%' OR NULL ) earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step gastroscopyStep,
CASE
rel1.is_inspect
WHEN 1 THEN
'是'
WHEN 0 THEN
'否' ELSE ''
END isGastroscopy,
rel1.inspect_way gastroscopyWay,
CASE
rel1.capsule
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见异常' ELSE ''
END gastroscopyResult,
rel1.precise_way gastroscopyDetailWay,
CASE
WHEN rel1.diagnose_result = 1 THEN
'异常'
WHEN rel1.diagnose_result = 2 THEN
'未见明显异常' ELSE ''
END gastroscopyDetailResult,
rel1.diagnose_info gastroscopyDetailDetail,
rel1.STATUS gastroscopyAuditStatus
FROM
tb_patient p
RIGHT JOIN (
SELECT
patient_id,
step,
inspect_way,
precise_way,
capsule,
diagnose_result,
diagnose_info,
is_inspect,
`status`
FROM
tb_gastro_inspect
WHERE
is_inspect = 1
AND `status` NOT IN ( 0, 5 )
) rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT `name`, number FROM tb_hosp ) rel2 ON rel2.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON rel3.`name` = rel2.`name`
) rel
GROUP BY
provinceName
)
) rel
GROUP BY
provinceName
</select>
<!-- 获取各省份筛查人次统计结果 -->
<select id="getProvinceScreeningStatistics" resultType="com.sict.data.dto.ProvinceScreeningDTO">
SELECT
provinceName,
count( * ) provinceScreeningTotal,
count( screeningStatus = 1 OR NULL ) provinceApplyScreeningTotal,
count( hospaudditStatus = 0 OR NULL ) hospApply
FROM
(
SELECT
p.id patientId,
p.`name` patientName,
rel6.area provinceName,
CASE
rel1.igg
WHEN 1 THEN
'阳性'
WHEN 0 THEN
'阴性' ELSE ''
END iggDetection,
CASE
rel2.grade
WHEN 1 THEN
'低风险'
WHEN 2 THEN
'中风险'
WHEN 3 THEN
'高风险' ELSE ''
END riskLevel,
CASE
rel3.is_inspect
WHEN 1 THEN
'是'
WHEN 0 THEN
'否' ELSE '否'
END isGastroscopy,
rel3.inspect_way gastroscopyWay,
CASE
rel3.capsule
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见异常' ELSE ''
END gastroscopyResult,
rel3.precise_way gastroscopyDetailWay,
CASE
rel3.diagnose_result
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见明显异常' ELSE ''
END gastroscopyDetailResult,
rel3.diagnose_info gastroscopyDetailInfo,
CASE
rel4.continue_flup
WHEN 1 THEN
'继续随访'
WHEN 0 THEN
'停止随访' ELSE ''
END isContinueFlup,
rel4.content_type planFlupContent,
rel1.`status` screeningStatus,
rel7.is_auddit hospAudditStatus
FROM
tb_patient p
RIGHT JOIN ( SELECT patient_id, igg, step, `status` FROM tb_lab_inspect WHERE `status` NOT IN ( 0, 5 ) ) rel1 ON rel1.patient_id = p.id
LEFT JOIN ( SELECT patient_id, step, score, grade, `status` FROM tb_risk_assess WHERE `status` NOT IN ( 0, 5 ) ) rel2 ON rel2.patient_id = p.id
AND rel2.step = rel1.step
AND rel2.`status` = rel1.`status`
LEFT JOIN (
SELECT
patient_id,
step,
is_inspect,
inspect_way,
capsule,
precise_way,
diagnose_result,
diagnose_info,
`status`
FROM
tb_gastro_inspect
WHERE
`status` NOT IN ( 0, 5 )
) rel3 ON rel3.patient_id = p.id
AND rel3.step = rel2.step
AND rel3.`status` = rel2.`status`
LEFT JOIN ( SELECT patient_id, step, continue_flup, content_type, `status` FROM tb_flup_plan WHERE `status` NOT IN ( 0, 5 ) ) rel4 ON rel4.patient_id = p.id
AND rel4.step = rel3.step
AND rel4.`status` = rel3.`status`
INNER JOIN ( SELECT number, `name` FROM tb_hosp ) rel5 ON rel5.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel6 ON rel6.`name` = rel5.`name`
LEFT JOIN ( SELECT hosp_number, is_auddit FROM tmp_tb_hosp_apply ) rel7 ON rel7.hosp_number = rel5.number
) rel
GROUP BY
provinceName
</select>
<!-- 获取省份胃镜精查最终诊断异常统计结果 -->
<select id="getProvinceGastroscopyResult" resultType="com.sict.data.dto.ProvinceGastroscopyResultDTO">
SELECT
provinceName,
(
count( gastroDetailInfo LIKE '%"a":1%' OR NULL ) + count( gastroDetailInfo LIKE '%"b":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"c":1%' OR NULL ) + count( gastroDetailInfo LIKE '%"d":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"e":1%' OR NULL ) + count( gastroDetailInfo LIKE '%"f":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"g":1%' OR NULL ) + count( gastroDetailInfo LIKE '%"h":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"i":1%' OR NULL ) + count( gastroDetailInfo LIKE '%"j":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"k":1%' OR NULL ) + count( gastroDetailInfo LIKE '%"l":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"m":1%' OR NULL ) + count( gastroDetailInfo LIKE '%"n":%' OR NULL )
) total,
count( gastroDetailInfo LIKE '%"a":1%' OR NULL ) AS esophagusTumor,
count( gastroDetailInfo LIKE '%"b":1%' OR NULL ) AS earlyEsophagealCancer,
count( gastroDetailInfo LIKE '%"c":1%' OR NULL ) AS progressEsophagealCancer,
count( gastroDetailInfo LIKE '%"d":1%' OR NULL ) AS barretEsophagus,
count( gastroDetailInfo LIKE '%"e":1%' OR NULL ) AS refluxEsophagitis,
count( gastroDetailInfo LIKE '%"f":1%' OR NULL ) AS gastricMucosaTumor,
count( gastroDetailInfo LIKE '%"g":1%' OR NULL ) AS earlyGastricCancer,
count( gastroDetailInfo LIKE '%"h":1%' OR NULL ) AS progressGastricCancer,
count( gastroDetailInfo LIKE '%"i":1%' OR NULL ) AS atrophicGastritis,
count( gastroDetailInfo LIKE '%"j":1%' OR NULL ) AS stomachUlcer,
count( gastroDetailInfo LIKE '%"k":1%' OR NULL ) AS gastricPolyp,
count( gastroDetailInfo LIKE '%"l":1%' OR NULL ) AS nonAtrophicGastritis,
count( gastroDetailInfo LIKE '%"m":1%' OR NULL ) AS duodenalUlcer,
count( gastroDetailInfo LIKE '%"n":%' OR NULL ) AS others,
count( gastroDetailInfo LIKE '%"type_a":"a"%' OR gastroDetailInfo LIKE '%"type_f":"a"%' OR NULL ) AS highEsophagusTumor
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step gastroStep,
rel1.is_inspect isGastro,
rel1.inspect_way gastroWay,
rel1.capsule gastroResult,
rel1.precise_way gastroDetailWay,
rel1.diagnose_result gastroDetailResult,
rel1.diagnose_info gastroDetailInfo,
rel1.`status` auditStatus
FROM
tb_patient p
RIGHT JOIN (
SELECT
patient_id,
step,
is_inspect,
inspect_way,
capsule,
precise_way,
diagnose_result,
diagnose_info,
`status`
FROM
tb_gastro_inspect
WHERE
is_inspect = 1
AND `status` NOT IN ( 0, 5 )
AND diagnose_result = 1
) rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT `name`, number FROM tb_hosp ) rel2 ON rel2.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON rel3.`name` = rel2.`name`
) rel
GROUP BY
provinceName
</select>
<!-- 获取患病风险等级评估统计 -->
<select id="getRiskAssessStatistics" resultType="com.sict.data.dto.RiskAssessDTO">
SELECT
count( riskLevel = '高风险' OR NULL ) highRisk,
count( riskLevel = '中风险' OR NULL) mediumRisk,
count( riskLevel = '低风险' OR NULL) lowRisk
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.score riskScore,
CASE
rel1.grade
WHEN 1 THEN
'低风险'
WHEN 2 THEN
'中风险'
WHEN 3 THEN
'高风险' ELSE ''
END riskLevel
FROM
tb_patient p
RIGHT JOIN ( SELECT patient_id, igg, step, `status` FROM tb_lab_inspect WHERE `status` NOT IN ( 0, 5 ) ) rel4 ON rel4.patient_id = p.id
LEFT JOIN ( SELECT patient_id, score, grade, step, `status` FROM tb_risk_assess ) rel1 ON rel1.patient_id = p.id AND rel1.step=rel4.step AND rel1.`status` = rel4.`status`
INNER JOIN ( SELECT `name`, number FROM tb_hosp ) rel2 ON rel2.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON rel3.`name` = rel2.`name`
) rel
</select>
<!-- 获取胃镜精查统计结果 -->
<select id="getGastroscopyDetailStatistics" resultType="com.sict.data.dto.GastroscopyDetailDTO">
SELECT
count( * ) total,
count( gastroscopyResult = '异常' OR NULL ) actual
FROM
(
SELECT
p.id patientId,
p.`name` patientName,
rel6.area provinceName,
CASE
rel1.igg
WHEN 1 THEN
'阳性'
WHEN 0 THEN
'阴性' ELSE ''
END iggDetection,
CASE
rel2.grade
WHEN 1 THEN
'低风险'
WHEN 2 THEN
'中风险'
WHEN 3 THEN
'高风险' ELSE ''
END riskLevel,
CASE
rel3.is_inspect
WHEN 1 THEN
'是'
WHEN 0 THEN
'否' ELSE '否'
END isGastroscopy,
rel3.inspect_way gastroscopyWay,
CASE
rel3.capsule
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见异常' ELSE ''
END gastroscopyResult,
rel3.precise_way gastroscopyDetailWay,
CASE
rel3.diagnose_result
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见明显异常' ELSE ''
END gastroscopyDetailResult,
rel3.diagnose_info gastroscopyDetailInfo,
rel1.`status` screeningStatus
FROM
tb_patient p
RIGHT JOIN ( SELECT patient_id, igg, step, `status` FROM tb_lab_inspect WHERE `status` NOT IN ( 0, 5 ) ) rel1 ON rel1.patient_id = p.id
LEFT JOIN ( SELECT patient_id, step, score, grade, `status` FROM tb_risk_assess ) rel2 ON rel2.patient_id = p.id
AND rel2.step = rel1.step
AND rel2.`status` = rel1.`status`
LEFT JOIN ( SELECT patient_id, step, is_inspect, inspect_way, capsule, precise_way, diagnose_result, diagnose_info, `status` FROM tb_gastro_inspect ) rel3 ON rel3.patient_id = p.id
AND rel3.step = rel2.step
AND rel3.`status` = rel2.`status`
INNER JOIN ( SELECT number, `name` FROM tb_hosp ) rel5 ON rel5.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel6 ON rel6.`name` = rel5.`name`
WHERE
rel2.grade = 2 OR rel2.grade = 3
) rel
</select>
<!-- 获取医院相关统计(申请数、认证数) -->
<select id="getHospStatistics" resultType="com.sict.data.dto.HospStatisticsDTO">
SELECT
count( is_auddit = 1 OR NULL ) certifiedHosp,
count( is_auddit = 0 OR NULL ) applyHosp
FROM
tmp_tb_hosp_apply
</select>
<select id="getNameDTOs" resultType="com.sict.data.dto.NameDTO">
SELECT id,`name` FROM tb_name
</select>
</mapper>
#Generated by Maven Integration for Eclipse
#Tue Nov 26 13:15:55 CST 2019
#Fri Nov 29 10:02:44 CST 2019
version=1.0-SNAPSHOT
groupId=dataplat
m2e.projectName=data-plat
......
......@@ -2,20 +2,13 @@
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
updateCheck="false">
<defaultCache
eternal="false"
maxElementsInMemory="10000"
overflowToDisk="false"
timeToIdleSeconds="300"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getScreeningRank"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
......@@ -23,10 +16,10 @@
<cache
name="getScreeningRankEn"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
......@@ -34,73 +27,82 @@
<cache
name="getSerumStatistics"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getGastroscopyStatistics"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getScreeningStatistics"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getGastroscopyDetailResultStatistics"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getRiskAssessStatistics"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getGastroscopyDetailStatistics"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getHospStatistics"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getComplexStatistics"
eternal="false"
maxElementsInMemory="10000"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
<cache
name="getnamDtos"
eternal="false"
maxElementsInMemory="100000"
overflowToDisk="false"
diskPersistent="false"
timeToIdleSeconds="300"
timeToIdleSeconds="6"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LRU" />
</ehcache>
\ No newline at end of file
......@@ -2,735 +2,556 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sict.data.mapper.DataPlatMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.sict.data.model.DataPlat">
<id column="id" property="id"/>
<result column="name" property="name"/>
</resultMap>
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap"
type="com.sict.data.model.DataPlat">
<id column="id" property="id" />
<result column="name" property="name" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, `name`
</sql>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, `name`
</sql>
<!-- 获取各医联体下筛查人数排行榜 -->
<select id="getHospScreeningRank" resultType="com.sict.data.dto.HospScreeningDTO">
SELECT
hospNum,
hospName,
count( * ) hospScreeningTotal,
count( screeningStatus = 1 OR NULL ) hospApplyScreeningTotal
FROM
(
SELECT
p.id patientId,
p.`name` patientName,
rel5.number hospNum,
rel5.`name` hospName,
CASE
rel1.igg
WHEN 1 THEN
'阳性'
WHEN 0 THEN
'阴性' ELSE ''
END iggDetection,
CASE
rel2.grade
WHEN 1 THEN
'低风险'
WHEN 2 THEN
'中风险'
WHEN 3 THEN
'高风险' ELSE ''
END riskLevel,
CASE
rel3.is_inspect
WHEN 1 THEN
'是'
WHEN 0 THEN
'否' ELSE '否'
END isGastroscopy,
rel3.inspect_way gastroscopyWay,
CASE
rel3.capsule
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见异常' ELSE ''
END gastroscopyResult,
rel3.precise_way gastroscopyDetailWay,
CASE
rel3.diagnose_result
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见明显异常' ELSE ''
END gastroscopyDetailResult,
rel3.diagnose_info gastroscopyDetailInfo,
CASE
rel4.continue_flup
WHEN 1 THEN
'继续随访'
WHEN 0 THEN
'停止随访' ELSE ''
END isContinueFlup,
rel4.content_type planFlupContent,
rel1.`status` screeningStatus
FROM
tb_patient p
RIGHT JOIN ( SELECT patient_id, igg, step, `status` FROM tb_lab_inspect WHERE `status` NOT IN ( 0, 5 ) ) rel1 ON rel1.patient_id = p.id
RIGHT JOIN ( SELECT patient_id, step, score, grade, `status` FROM tb_risk_assess WHERE `status` NOT IN ( 0, 5 ) ) rel2 ON rel2.patient_id = p.id
AND rel2.step = rel1.step
AND rel2.`status` = rel1.`status`
LEFT JOIN (
SELECT
patient_id,
step,
is_inspect,
inspect_way,
capsule,
precise_way,
diagnose_result,
diagnose_info,
`status`
FROM
tb_gastro_inspect
WHERE
`status` NOT IN ( 0, 5 )
) rel3 ON rel3.patient_id = p.id
AND rel3.step = rel2.step
AND rel3.`status` = rel2.`status`
LEFT JOIN ( SELECT patient_id, step, continue_flup, content_type, `status` FROM tb_flup_plan WHERE `status` NOT IN ( 0, 5 ) ) rel4 ON rel4.patient_id = p.id
AND rel4.step = rel3.step
AND rel4.`status` = rel3.`status`
INNER JOIN ( SELECT number, `name` FROM tb_hosp ) rel5 ON rel5.number = p.hosp_number
) rel
GROUP BY
hospName
ORDER BY
hospScreeningTotal DESC
</select>
<!-- 获取各医联体下筛查人数排行榜 英文-->
<select id="getHospScreeningRankEn" resultType="com.sict.data.dto.HospScreeningDTO">
SELECT
hospNum,
ehospName hospName,
count( * ) hospScreeningTotal,
count( screeningStatus = 1 OR NULL ) hospApplyScreeningTotal
FROM
(
SELECT
p.id patientId,
p.`name` patientName,
rel5.number hospNum,
rel5.name hospName,rel5.ename ehospName,
CASE
rel1.igg
WHEN 1 THEN
'阳性'
WHEN 0 THEN
'阴性' ELSE ''
END iggDetection,
CASE
rel2.grade
WHEN 1 THEN
'低风险'
WHEN 2 THEN
'中风险'
WHEN 3 THEN
'高风险' ELSE ''
END riskLevel,
CASE
rel3.is_inspect
WHEN 1 THEN
'是'
WHEN 0 THEN
'否' ELSE '否'
END isGastroscopy,
rel3.inspect_way gastroscopyWay,
CASE
rel3.capsule
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见异常' ELSE ''
END gastroscopyResult,
rel3.precise_way gastroscopyDetailWay,
CASE
rel3.diagnose_result
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见明显异常' ELSE ''
END gastroscopyDetailResult,
rel3.diagnose_info gastroscopyDetailInfo,
CASE
rel4.continue_flup
WHEN 1 THEN
'继续随访'
WHEN 0 THEN
'停止随访' ELSE ''
END isContinueFlup,
rel4.content_type planFlupContent,
rel1.`status` screeningStatus
FROM
tb_patient p
RIGHT JOIN ( SELECT patient_id, igg, step, `status` FROM tb_lab_inspect WHERE `status` NOT IN ( 0, 5 ) ) rel1 ON rel1.patient_id = p.id
RIGHT JOIN ( SELECT patient_id, step, score, grade, `status` FROM tb_risk_assess WHERE `status` NOT IN ( 0, 5 ) ) rel2 ON rel2.patient_id = p.id
AND rel2.step = rel1.step
AND rel2.`status` = rel1.`status`
LEFT JOIN (
SELECT
patient_id,
step,
is_inspect,
inspect_way,
capsule,
precise_way,
diagnose_result,
diagnose_info,
`status`
FROM
tb_gastro_inspect
WHERE
`status` NOT IN ( 0, 5 )
) rel3 ON rel3.patient_id = p.id
AND rel3.step = rel2.step
AND rel3.`status` = rel2.`status`
LEFT JOIN ( SELECT patient_id, step, continue_flup, content_type, `status` FROM tb_flup_plan WHERE `status` NOT IN ( 0, 5 ) ) rel4 ON rel4.patient_id = p.id
AND rel4.step = rel3.step
AND rel4.`status` = rel3.`status`
INNER JOIN ( SELECT number,`name`, ename FROM tb_hosp_en ) rel5 ON rel5.number = p.hosp_number
) rel
GROUP BY
hospName
ORDER BY
hospScreeningTotal DESC
</select>
<!-- 获取各医联体下筛查人数排行榜 -->
<select id="getHospScreeningRank"
resultType="com.sict.data.dto.HospScreeningDTO">
SELECT
hospNum,
hospName,
count( * ) hospScreeningTotal,
count( NULL ) hospApplyScreeningTotal
FROM
(
SELECT
p.id patientId,
p.hosp_number,
p.`name` patientName,
rel1.number hospNum,
rel1.`name`
hospName
FROM
tb_patient p
INNER JOIN ( SELECT number, `name` FROM
tb_hosp ) rel1 ON rel1.number = p.hosp_number
WHERE p.step=0
) rel
GROUP
BY
hospName
ORDER BY
hospScreeningTotal DESC
</select>
<!-- 获取各医联体下筛查人数排行榜 英文 -->
<select id="getHospScreeningRankEn"
resultType="com.sict.data.dto.HospScreeningDTO">
SELECT
hospNum,
ehospName hospName,
count( * )
hospScreeningTotal,
count( NULL ) hospApplyScreeningTotal
FROM
(
SELECT
p.id patientId,
p.hosp_number,
p.`name` patientName,
rel1.number hospNum,
rel1.`name` hospName,
rel1.ename ehospName
FROM
tb_patient p
INNER JOIN (
SELECT number, `name`,ename FROM tb_hosp_en ) rel1 ON rel1.number =
p.hosp_number
WHERE p.step=0
) rel
GROUP BY
hospName
ORDER BY
hospScreeningTotal DESC LIMIT 30
</select>
<!-- 获取各省份血检人次统计结果 -->
<select id="getProvinceSerumStatistics"
resultType="com.sict.data.dto.ProvinceSerumDTO">
SELECT
provinceName,
sum( serumTestPlan + serumTestActual )
serumTestTotal,
sum( serumTestPlan ) serumTestPlan,
sum( serumTestActual
) serumTestActual,
sum( iggPositive ) iggPositive,
sum( earlyCancer )
earlyCancer
FROM
(
(
SELECT
provinceName,
count( NULL ) serumTestPlan,
count( * ) serumTestActual,
count( iggDetection = '阳性' OR
NULL )
iggPositive,
count( NULL ) earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step labInspectStep,
rel1.g17 G17,
rel1.pg1
PG1,
rel1.pg2 PG2,
CASE
rel1.igg
WHEN 1 THEN
'阳性'
WHEN 0 THEN
'阴性' ELSE ''
END iggDetection,
rel1.`status` labInspectStatus
FROM
tb_patient AS p
INNER JOIN ( SELECT patient_id, step, g17, pg1, pg2, igg, `status`
FROM
tb_lab_inspect ) rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT
`name`, number FROM tb_hosp ) rel2 ON rel2.number =
p.hosp_number
INNER
JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON
rel3.`name`
= rel2.`name`
WHERE
rel1.`status` NOT IN ( 0, 5 )
) rel
GROUP BY
provinceName
) UNION
(
SELECT
provinceName,
count( NULL ) serumTestPlan,
count( NULL ) serumTestActual,
count( NULL ) iggPositive,
count(
gastroscopyDetailInfo LIKE '%"b":1%' OR NULL ) + count(
gastroscopyDetailInfo LIKE '%"g":1%' OR NULL ) earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step gastroscopyStep,
rel1.is_inspect isGastroscopy,
rel1.inspect_way gastroscopyWay,
rel1.capsule gastroscopyResult,
rel1.precise_way gastroscopyDetailWay,
rel1.diagnose_result gastroscopyDetailResult,
rel1.diagnose_info
gastroscopyDetailInfo,
rel1.`status` gastroscopyAuditStatus
FROM
tb_patient p
INNER JOIN (
SELECT
patient_id,
step,
is_inspect,
inspect_way,
capsule,
precise_way,
diagnose_result,
diagnose_info,
`status`
FROM
tb_gastro_inspect
WHERE
is_inspect = 1
AND `status` NOT IN ( 0, 5 )
AND
diagnose_result = 1
) rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT
`name`, number FROM tb_hosp ) rel2 ON rel2.number =
p.hosp_number
LEFT
JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON
rel3.`name`
= rel2.`name`
) rel
GROUP BY
provinceName
)
) rel
GROUP BY
provinceName
</select>
<!-- 获取各省份胃镜检查人次统计结果 -->
<select id="getProvinceGastroscopyStatistics"
resultType="com.sict.data.dto.ProvinceGastroscopyDTO">
SELECT
provinceName,
sum( gastroscopyPlan + gastroscopyActual
) gastroscopyTotal,
sum( gastroscopyPlan ) gastroscopyPlan,
sum(
gastroscopyActual ) gastroscopyActual,
sum( gastroscopyDetail )
gastroscopyDetail,
sum( earlyCancer ) earlyCancer
FROM
(
(
SELECT
provinceName,
count( * ) gastroscopyPlan,
count( NULL )
gastroscopyActual,
count( NULL ) gastroscopyDetail,
count( NULL )
earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step
planFlupStep,
CASE
rel1.continue_flup
WHEN 1 THEN
'继续随访'
WHEN 0 THEN
'停止随访'
ELSE ''
END isContinueFlup,
rel1.content_type planFlupContent
FROM
tb_patient p
RIGHT JOIN ( SELECT patient_id, step, continue_flup,
content_type FROM
tb_flup_plan WHERE continue_flup = 1 AND content_type
LIKE '%a%' )
rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT `name`,
number FROM tb_hosp ) rel2 ON rel2.number =
p.hosp_number
LEFT JOIN (
SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON
rel3.`name` =
rel2.`name`
) rel
GROUP BY
provinceName
) UNION
(
SELECT
provinceName,
count(
NULL ) gastroscopyPlan,
count( * ) gastroscopyActual,
count(
gastroscopyDetailWay &lt;&gt; '[]' OR NULL ) gastroscopyDetail,
count(
gastroscopyDetailDetail LIKE '%"b":1%' OR NULL ) + count(
gastroscopyDetailDetail LIKE '%"g":1%' OR NULL ) earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step gastroscopyStep,
CASE
rel1.is_inspect
WHEN 1 THEN
'是'
WHEN 0 THEN
'否' ELSE ''
END
isGastroscopy,
rel1.inspect_way gastroscopyWay,
CASE
rel1.capsule
WHEN 1
THEN
'异常'
WHEN 2 THEN
'未见异常' ELSE ''
END gastroscopyResult,
rel1.precise_way gastroscopyDetailWay,
CASE
WHEN rel1.diagnose_result =
1 THEN
'异常'
WHEN rel1.diagnose_result = 2 THEN
'未见明显异常' ELSE ''
END
gastroscopyDetailResult,
rel1.diagnose_info gastroscopyDetailDetail,
rel1.STATUS gastroscopyAuditStatus
FROM
tb_patient p
INNER JOIN (
SELECT
patient_id,
step,
inspect_way,
precise_way,
capsule,
diagnose_result,
diagnose_info,
is_inspect,
`status`
FROM
tb_gastro_inspect
WHERE
is_inspect
= 1
AND `status` NOT IN ( 0, 5 )
) rel1 ON rel1.patient_id = p.id
INNER
JOIN ( SELECT `name`, number FROM tb_hosp ) rel2 ON rel2.number =
p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area )
rel3 ON
rel3.`name` = rel2.`name`
) rel
GROUP BY
provinceName
)
) rel
GROUP
BY
provinceName
</select>
<!-- 获取各省份筛查人次统计结果 -->
<select id="getProvinceScreeningStatistics"
resultType="com.sict.data.dto.ProvinceScreeningDTO">
SELECT
area provinceName,
count( * ) provinceScreeningTotal,
count( NULL ) provinceApplyScreeningTotal,
count( hospaudditStatus = 0
OR NULL ) hospApply
FROM(
SELECT p.id patientId,rel2.area
area,rel3.is_auddit hospAudditStatus FROM
tb_patient p
INNER JOIN (
SELECT number, `name` FROM tb_hosp ) rel1 ON rel1.number =
p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area )
rel2 ON
rel2.`name` = rel1.`name`
LEFT JOIN ( SELECT hosp_number,
is_auddit FROM tmp_tb_hosp_apply ) rel3 ON
rel3.hosp_number =
rel1.number
WHERE p.step=0
)rel
GROUP BY provinceName
</select>
<!-- 获取省份胃镜精查最终诊断异常统计结果 -->
<select id="getProvinceGastroscopyResult"
resultType="com.sict.data.dto.ProvinceGastroscopyResultDTO">
SELECT
provinceName,
(
count( gastroDetailInfo LIKE '%"a":1%'
OR NULL ) + count( gastroDetailInfo
LIKE '%"b":1%' OR NULL )
+ count(
gastroDetailInfo LIKE '%"c":1%' OR NULL ) + count(
gastroDetailInfo
LIKE '%"d":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"e":1%' OR
NULL ) + count(
gastroDetailInfo LIKE '%"f":1%' OR NULL )
+ count(
gastroDetailInfo LIKE '%"g":1%' OR NULL ) + count(
gastroDetailInfo
LIKE '%"h":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"i":1%' OR
NULL ) + count(
gastroDetailInfo LIKE '%"j":1%' OR NULL )
+ count(
gastroDetailInfo LIKE '%"k":1%' OR NULL ) + count(
gastroDetailInfo
LIKE '%"l":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"m":1%' OR
NULL ) + count(
gastroDetailInfo LIKE '%"n":%' OR NULL )
) total,
count(
gastroDetailInfo LIKE '%"a":1%' OR NULL ) AS esophagusTumor,
count(
gastroDetailInfo LIKE '%"b":1%' OR NULL ) AS earlyEsophagealCancer,
count( gastroDetailInfo LIKE '%"c":1%' OR NULL ) AS
progressEsophagealCancer,
count( gastroDetailInfo LIKE '%"d":1%' OR
NULL ) AS barretEsophagus,
count( gastroDetailInfo LIKE '%"e":1%' OR
NULL ) AS refluxEsophagitis,
count( gastroDetailInfo LIKE '%"f":1%' OR
NULL ) AS
gastricMucosaTumor,
count( gastroDetailInfo LIKE '%"g":1%' OR
NULL ) AS earlyGastricCancer,
count( gastroDetailInfo LIKE '%"h":1%' OR
NULL ) AS
progressGastricCancer,
count( gastroDetailInfo LIKE '%"i":1%'
OR NULL ) AS atrophicGastritis,
count( gastroDetailInfo LIKE '%"j":1%'
OR NULL ) AS stomachUlcer,
count( gastroDetailInfo LIKE '%"k":1%' OR
NULL ) AS gastricPolyp,
count( gastroDetailInfo LIKE '%"l":1%' OR NULL
) AS
nonAtrophicGastritis,
count( gastroDetailInfo LIKE '%"m":1%' OR
NULL ) AS duodenalUlcer,
count( gastroDetailInfo LIKE '%"n":%' OR NULL
) AS others,
count( gastroDetailInfo LIKE '%"type_a":"a"%' OR
gastroDetailInfo LIKE
'%"type_f":"a"%' OR NULL ) AS highEsophagusTumor
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step gastroStep,
rel1.is_inspect isGastro,
rel1.inspect_way gastroWay,
rel1.capsule
gastroResult,
rel1.precise_way gastroDetailWay,
rel1.diagnose_result
gastroDetailResult,
rel1.diagnose_info gastroDetailInfo,
rel1.`status`
auditStatus
FROM
tb_patient p
INNER JOIN (
SELECT
patient_id,
step,
is_inspect,
inspect_way,
capsule,
precise_way,
diagnose_result,
diagnose_info,
`status`
FROM
tb_gastro_inspect
WHERE
is_inspect = 1
AND
`status` NOT IN ( 0, 5 )
AND diagnose_result = 1
) rel1 ON
rel1.patient_id = p.id
INNER JOIN ( SELECT `name`, number FROM tb_hosp
) rel2 ON rel2.number =
p.hosp_number
LEFT JOIN ( SELECT area, `name`
FROM tmp_tb_hosp_area ) rel3 ON
rel3.`name` = rel2.`name`
) rel
GROUP BY
provinceName
</select>
<!-- 获取患病风险等级评估统计 -->
<select id="getRiskAssessStatistics"
resultType="com.sict.data.dto.RiskAssessDTO">
SELECT
count( riskLevel = '高风险' OR NULL ) highRisk,
count(
riskLevel = '中风险' OR NULL) mediumRisk,
count( riskLevel = '低风险' OR
NULL) lowRisk
FROM
(
SELECT
p.id patientId,
rel1.score riskScore,
CASE
rel1.grade
WHEN 1 THEN
'低风险'
WHEN 2 THEN
'中风险'
WHEN 3 THEN
'高风险' ELSE ''
END
riskLevel
FROM
tb_patient p
INNER JOIN ( SELECT patient_id, score,
grade
FROM tb_risk_assess ) rel1 ON
rel1.patient_id = p.id
INNER JOIN (SELECT
name,number FROM tb_hosp )rel2 ON rel2.number = p.hosp_number
) rel
</select>
<!-- 获取胃镜精查统计结果 -->
<select id="getGastroscopyDetailStatistics"
resultType="com.sict.data.dto.GastroscopyDetailDTO">
SELECT sum(total )total,sum(actual) actual
FROM
(
(SELECT
COUNT(DISTINCT p2.patient_id) total,COUNT(NULL) actual from
tb_patient
p1 INNER JOIN tb_risk_assess p2 on p1.id = p2.patient_id
INNER JOIN
(SELECT `name`,number FROM tb_hosp )rel2 ON rel2.number =
p1.hosp_number
WHERE p2.grade >1 AND p2.step=0
)
UNION
(SELECT COUNT(NULL)
total, COUNT(*) actual FROM
tb_patient p1 INNER JOIN tb_gastro_inspect
p2 ON p1.id=p2.patient_id
INNER JOIN (SELECT `name`,number FROM tb_hosp )rel2 ON rel2.number =
p1.hosp_number
WHERE p2.capsule =1)
)rel
</select>
<!-- 获取医院相关统计(申请数、认证数) -->
<select id="getHospStatistics"
resultType="com.sict.data.dto.HospStatisticsDTO">
SELECT
count( is_auddit = 1 OR NULL ) certifiedHosp,
count(
is_auddit = 0 OR NULL ) applyHosp
FROM
tmp_tb_hosp_apply
</select>
<!-- 获取各省份血检人次统计结果 -->
<select id="getProvinceSerumStatistics" resultType="com.sict.data.dto.ProvinceSerumDTO">
SELECT
provinceName,
sum( serumTestPlan + serumTestActual ) serumTestTotal,
sum( serumTestPlan ) serumTestPlan,
sum( serumTestActual ) serumTestActual,
sum( iggPositive ) iggPositive,
sum( earlyCancer ) earlyCancer
FROM
(
(
SELECT
provinceName,
count( * ) serumTestPlan,
count( NULL ) serumTestActual,
count( NULL ) iggPositive,
count( NULL ) earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step planFlupStep,
CASE
rel1.continue_flup
WHEN 1 THEN
'继续随访'
WHEN 0 THEN
'停止随访' ELSE ''
END isContinueFlup,
rel1.content_type planFlupContent,
rel1.`status` planFlupAuditStatus
FROM
tb_patient p
RIGHT JOIN ( SELECT patient_id, step, continue_flup, content_type, `status` FROM tb_flup_plan WHERE continue_flup = 1 AND content_type LIKE '%b%' ) rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT `name`, number FROM tb_hosp ) rel2 ON rel2.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON rel3.`name` = rel2.`name`
) rel
GROUP BY
provinceName
) UNION
(
SELECT
provinceName,
count( NULL ) serumTestPlan,
count( * ) serumTestActual,
count( iggDetection = '阳性' OR NULL ) iggPositive,
count( NULL ) earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step labInspectStep,
rel1.g17 G17,
rel1.pg1 PG1,
rel1.pg2 PG2,
CASE
rel1.igg
WHEN 1 THEN
'阳性'
WHEN 0 THEN
'阴性' ELSE ''
END iggDetection,
rel1.`status` labInspectStatus
FROM
tb_patient AS p
RIGHT JOIN ( SELECT patient_id, step, g17, pg1, pg2, igg, `status` FROM tb_lab_inspect ) rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT `name`, number FROM tb_hosp ) rel2 ON rel2.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON rel3.`name` = rel2.`name`
WHERE
rel1.`status` NOT IN ( 0, 5 )
) rel
GROUP BY
provinceName
) UNION
(
SELECT
provinceName,
count( NULL ) serumTestPlan,
count( NULL ) serumTestActual,
count( NULL ) iggPositive,
count( gastroscopyDetailInfo LIKE '%"b":1%' OR NULL ) + count( gastroscopyDetailInfo LIKE '%"g":1%' OR NULL ) earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step gastroscopyStep,
rel1.is_inspect isGastroscopy,
rel1.inspect_way gastroscopyWay,
rel1.capsule gastroscopyResult,
rel1.precise_way gastroscopyDetailWay,
rel1.diagnose_result gastroscopyDetailResult,
rel1.diagnose_info gastroscopyDetailInfo,
rel1.`status` gastroscopyAuditStatus
FROM
tb_patient p
RIGHT JOIN (
SELECT
patient_id,
step,
is_inspect,
inspect_way,
capsule,
precise_way,
diagnose_result,
diagnose_info,
`status`
FROM
tb_gastro_inspect
WHERE
is_inspect = 1
AND `status` NOT IN ( 0, 5 )
AND diagnose_result = 1
) rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT `name`, number FROM tb_hosp ) rel2 ON rel2.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON rel3.`name` = rel2.`name`
) rel
GROUP BY
provinceName
)
) rel
GROUP BY
provinceName
</select>
<!-- 获取各省份胃镜检查人次统计结果 -->
<select id="getProvinceGastroscopyStatistics" resultType="com.sict.data.dto.ProvinceGastroscopyDTO">
SELECT
provinceName,
sum( gastroscopyPlan + gastroscopyActual ) gastroscopyTotal,
sum( gastroscopyPlan ) gastroscopyPlan,
sum( gastroscopyActual ) gastroscopyActual,
sum( gastroscopyDetail ) gastroscopyDetail,
sum( earlyCancer ) earlyCancer
FROM
(
(
SELECT
provinceName,
count( * ) gastroscopyPlan,
count( NULL ) gastroscopyActual,
count( NULL ) gastroscopyDetail,
count( NULL ) earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step planFlupStep,
CASE
rel1.continue_flup
WHEN 1 THEN
'继续随访'
WHEN 0 THEN
'停止随访' ELSE ''
END isContinueFlup,
rel1.content_type planFlupContent
FROM
tb_patient p
RIGHT JOIN ( SELECT patient_id, step, continue_flup, content_type FROM tb_flup_plan WHERE continue_flup = 1 AND content_type LIKE '%a%' ) rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT `name`, number FROM tb_hosp ) rel2 ON rel2.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON rel3.`name` = rel2.`name`
) rel
GROUP BY
provinceName
) UNION
(
SELECT
provinceName,
count( NULL ) gastroscopyPlan,
count( * ) gastroscopyActual,
count( gastroscopyDetailWay &lt;&gt; '[]' OR NULL ) gastroscopyDetail,
count( gastroscopyDetailDetail LIKE '%"b":1%' OR NULL ) + count( gastroscopyDetailDetail LIKE '%"g":1%' OR NULL ) earlyCancer
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step gastroscopyStep,
CASE
rel1.is_inspect
WHEN 1 THEN
'是'
WHEN 0 THEN
'否' ELSE ''
END isGastroscopy,
rel1.inspect_way gastroscopyWay,
CASE
rel1.capsule
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见异常' ELSE ''
END gastroscopyResult,
rel1.precise_way gastroscopyDetailWay,
CASE
WHEN rel1.diagnose_result = 1 THEN
'异常'
WHEN rel1.diagnose_result = 2 THEN
'未见明显异常' ELSE ''
END gastroscopyDetailResult,
rel1.diagnose_info gastroscopyDetailDetail,
rel1.STATUS gastroscopyAuditStatus
FROM
tb_patient p
RIGHT JOIN (
SELECT
patient_id,
step,
inspect_way,
precise_way,
capsule,
diagnose_result,
diagnose_info,
is_inspect,
`status`
FROM
tb_gastro_inspect
WHERE
is_inspect = 1
AND `status` NOT IN ( 0, 5 )
) rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT `name`, number FROM tb_hosp ) rel2 ON rel2.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON rel3.`name` = rel2.`name`
) rel
GROUP BY
provinceName
)
) rel
GROUP BY
provinceName
</select>
<!-- 获取各省份筛查人次统计结果 -->
<select id="getProvinceScreeningStatistics" resultType="com.sict.data.dto.ProvinceScreeningDTO">
SELECT
provinceName,
count( * ) provinceScreeningTotal,
count( screeningStatus = 1 OR NULL ) provinceApplyScreeningTotal,
count( hospaudditStatus = 0 OR NULL ) hospApply
FROM
(
SELECT
p.id patientId,
p.`name` patientName,
rel6.area provinceName,
CASE
rel1.igg
WHEN 1 THEN
'阳性'
WHEN 0 THEN
'阴性' ELSE ''
END iggDetection,
CASE
rel2.grade
WHEN 1 THEN
'低风险'
WHEN 2 THEN
'中风险'
WHEN 3 THEN
'高风险' ELSE ''
END riskLevel,
CASE
rel3.is_inspect
WHEN 1 THEN
'是'
WHEN 0 THEN
'否' ELSE '否'
END isGastroscopy,
rel3.inspect_way gastroscopyWay,
CASE
rel3.capsule
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见异常' ELSE ''
END gastroscopyResult,
rel3.precise_way gastroscopyDetailWay,
CASE
rel3.diagnose_result
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见明显异常' ELSE ''
END gastroscopyDetailResult,
rel3.diagnose_info gastroscopyDetailInfo,
CASE
rel4.continue_flup
WHEN 1 THEN
'继续随访'
WHEN 0 THEN
'停止随访' ELSE ''
END isContinueFlup,
rel4.content_type planFlupContent,
rel1.`status` screeningStatus,
rel7.is_auddit hospAudditStatus
FROM
tb_patient p
RIGHT JOIN ( SELECT patient_id, igg, step, `status` FROM tb_lab_inspect WHERE `status` NOT IN ( 0, 5 ) ) rel1 ON rel1.patient_id = p.id
LEFT JOIN ( SELECT patient_id, step, score, grade, `status` FROM tb_risk_assess WHERE `status` NOT IN ( 0, 5 ) ) rel2 ON rel2.patient_id = p.id
AND rel2.step = rel1.step
AND rel2.`status` = rel1.`status`
LEFT JOIN (
SELECT
patient_id,
step,
is_inspect,
inspect_way,
capsule,
precise_way,
diagnose_result,
diagnose_info,
`status`
FROM
tb_gastro_inspect
WHERE
`status` NOT IN ( 0, 5 )
) rel3 ON rel3.patient_id = p.id
AND rel3.step = rel2.step
AND rel3.`status` = rel2.`status`
LEFT JOIN ( SELECT patient_id, step, continue_flup, content_type, `status` FROM tb_flup_plan WHERE `status` NOT IN ( 0, 5 ) ) rel4 ON rel4.patient_id = p.id
AND rel4.step = rel3.step
AND rel4.`status` = rel3.`status`
INNER JOIN ( SELECT number, `name` FROM tb_hosp ) rel5 ON rel5.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel6 ON rel6.`name` = rel5.`name`
LEFT JOIN ( SELECT hosp_number, is_auddit FROM tmp_tb_hosp_apply ) rel7 ON rel7.hosp_number = rel5.number
) rel
GROUP BY
provinceName
</select>
<!-- 获取省份胃镜精查最终诊断异常统计结果 -->
<select id="getProvinceGastroscopyResult" resultType="com.sict.data.dto.ProvinceGastroscopyResultDTO">
SELECT
provinceName,
(
count( gastroDetailInfo LIKE '%"a":1%' OR NULL ) + count( gastroDetailInfo LIKE '%"b":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"c":1%' OR NULL ) + count( gastroDetailInfo LIKE '%"d":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"e":1%' OR NULL ) + count( gastroDetailInfo LIKE '%"f":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"g":1%' OR NULL ) + count( gastroDetailInfo LIKE '%"h":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"i":1%' OR NULL ) + count( gastroDetailInfo LIKE '%"j":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"k":1%' OR NULL ) + count( gastroDetailInfo LIKE '%"l":1%' OR NULL )
+ count( gastroDetailInfo LIKE '%"m":1%' OR NULL ) + count( gastroDetailInfo LIKE '%"n":%' OR NULL )
) total,
count( gastroDetailInfo LIKE '%"a":1%' OR NULL ) AS esophagusTumor,
count( gastroDetailInfo LIKE '%"b":1%' OR NULL ) AS earlyEsophagealCancer,
count( gastroDetailInfo LIKE '%"c":1%' OR NULL ) AS progressEsophagealCancer,
count( gastroDetailInfo LIKE '%"d":1%' OR NULL ) AS barretEsophagus,
count( gastroDetailInfo LIKE '%"e":1%' OR NULL ) AS refluxEsophagitis,
count( gastroDetailInfo LIKE '%"f":1%' OR NULL ) AS gastricMucosaTumor,
count( gastroDetailInfo LIKE '%"g":1%' OR NULL ) AS earlyGastricCancer,
count( gastroDetailInfo LIKE '%"h":1%' OR NULL ) AS progressGastricCancer,
count( gastroDetailInfo LIKE '%"i":1%' OR NULL ) AS atrophicGastritis,
count( gastroDetailInfo LIKE '%"j":1%' OR NULL ) AS stomachUlcer,
count( gastroDetailInfo LIKE '%"k":1%' OR NULL ) AS gastricPolyp,
count( gastroDetailInfo LIKE '%"l":1%' OR NULL ) AS nonAtrophicGastritis,
count( gastroDetailInfo LIKE '%"m":1%' OR NULL ) AS duodenalUlcer,
count( gastroDetailInfo LIKE '%"n":%' OR NULL ) AS others,
count( gastroDetailInfo LIKE '%"type_a":"a"%' OR gastroDetailInfo LIKE '%"type_f":"a"%' OR NULL ) AS highEsophagusTumor
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.step gastroStep,
rel1.is_inspect isGastro,
rel1.inspect_way gastroWay,
rel1.capsule gastroResult,
rel1.precise_way gastroDetailWay,
rel1.diagnose_result gastroDetailResult,
rel1.diagnose_info gastroDetailInfo,
rel1.`status` auditStatus
FROM
tb_patient p
RIGHT JOIN (
SELECT
patient_id,
step,
is_inspect,
inspect_way,
capsule,
precise_way,
diagnose_result,
diagnose_info,
`status`
FROM
tb_gastro_inspect
WHERE
is_inspect = 1
AND `status` NOT IN ( 0, 5 )
AND diagnose_result = 1
) rel1 ON rel1.patient_id = p.id
INNER JOIN ( SELECT `name`, number FROM tb_hosp ) rel2 ON rel2.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON rel3.`name` = rel2.`name`
) rel
GROUP BY
provinceName
</select>
<!-- 获取患病风险等级评估统计 -->
<select id="getRiskAssessStatistics" resultType="com.sict.data.dto.RiskAssessDTO">
SELECT
count( riskLevel = '高风险' OR NULL ) highRisk,
count( riskLevel = '中风险' OR NULL) mediumRisk,
count( riskLevel = '低风险' OR NULL) lowRisk
FROM
(
SELECT
p.id patientId,
rel3.area provinceName,
rel1.score riskScore,
CASE
rel1.grade
WHEN 1 THEN
'低风险'
WHEN 2 THEN
'中风险'
WHEN 3 THEN
'高风险' ELSE ''
END riskLevel
FROM
tb_patient p
RIGHT JOIN ( SELECT patient_id, igg, step, `status` FROM tb_lab_inspect WHERE `status` NOT IN ( 0, 5 ) ) rel4 ON rel4.patient_id = p.id
LEFT JOIN ( SELECT patient_id, score, grade, step, `status` FROM tb_risk_assess ) rel1 ON rel1.patient_id = p.id AND rel1.step=rel4.step AND rel1.`status` = rel4.`status`
INNER JOIN ( SELECT `name`, number FROM tb_hosp ) rel2 ON rel2.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel3 ON rel3.`name` = rel2.`name`
) rel
</select>
<!-- 获取胃镜精查统计结果 -->
<select id="getGastroscopyDetailStatistics" resultType="com.sict.data.dto.GastroscopyDetailDTO">
SELECT
count( * ) total,
count( gastroscopyResult = '异常' OR NULL ) actual
FROM
(
SELECT
p.id patientId,
p.`name` patientName,
rel6.area provinceName,
CASE
rel1.igg
WHEN 1 THEN
'阳性'
WHEN 0 THEN
'阴性' ELSE ''
END iggDetection,
CASE
rel2.grade
WHEN 1 THEN
'低风险'
WHEN 2 THEN
'中风险'
WHEN 3 THEN
'高风险' ELSE ''
END riskLevel,
CASE
rel3.is_inspect
WHEN 1 THEN
'是'
WHEN 0 THEN
'否' ELSE '否'
END isGastroscopy,
rel3.inspect_way gastroscopyWay,
CASE
rel3.capsule
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见异常' ELSE ''
END gastroscopyResult,
rel3.precise_way gastroscopyDetailWay,
CASE
rel3.diagnose_result
WHEN 1 THEN
'异常'
WHEN 2 THEN
'未见明显异常' ELSE ''
END gastroscopyDetailResult,
rel3.diagnose_info gastroscopyDetailInfo,
rel1.`status` screeningStatus
FROM
tb_patient p
RIGHT JOIN ( SELECT patient_id, igg, step, `status` FROM tb_lab_inspect WHERE `status` NOT IN ( 0, 5 ) ) rel1 ON rel1.patient_id = p.id
LEFT JOIN ( SELECT patient_id, step, score, grade, `status` FROM tb_risk_assess ) rel2 ON rel2.patient_id = p.id
AND rel2.step = rel1.step
AND rel2.`status` = rel1.`status`
LEFT JOIN ( SELECT patient_id, step, is_inspect, inspect_way, capsule, precise_way, diagnose_result, diagnose_info, `status` FROM tb_gastro_inspect ) rel3 ON rel3.patient_id = p.id
AND rel3.step = rel2.step
AND rel3.`status` = rel2.`status`
INNER JOIN ( SELECT number, `name` FROM tb_hosp ) rel5 ON rel5.number = p.hosp_number
LEFT JOIN ( SELECT area, `name` FROM tmp_tb_hosp_area ) rel6 ON rel6.`name` = rel5.`name`
WHERE
rel2.grade = 2 OR rel2.grade = 3
) rel
</select>
<!-- 获取医院相关统计(申请数、认证数) -->
<select id="getHospStatistics" resultType="com.sict.data.dto.HospStatisticsDTO">
SELECT
count( is_auddit = 1 OR NULL ) certifiedHosp,
count( is_auddit = 0 OR NULL ) applyHosp
FROM
tmp_tb_hosp_apply
</select>
<select id="getNameDTOs" resultType="com.sict.data.dto.NameDTO">
SELECT id,`name` FROM tb_name
</select>
</mapper>
......@@ -18,5 +18,6 @@ E:\BIGDATA\HadoopSpace\早筛综合统计页面展示\data-plat\src\main\java\co
E:\BIGDATA\HadoopSpace\早筛综合统计页面展示\data-plat\src\main\java\com\sict\data\dto\ScreeningDTO.java
E:\BIGDATA\HadoopSpace\早筛综合统计页面展示\data-plat\src\main\java\com\sict\data\dto\SerumDTO.java
E:\BIGDATA\HadoopSpace\早筛综合统计页面展示\data-plat\src\main\java\com\sict\data\dto\GastroscopyDetailDTO.java
E:\BIGDATA\HadoopSpace\早筛综合统计页面展示\data-plat\src\main\java\com\sict\data\dto\NameDTO.java
E:\BIGDATA\HadoopSpace\早筛综合统计页面展示\data-plat\src\main\java\com\sict\data\model\DataPlat.java
E:\BIGDATA\HadoopSpace\早筛综合统计页面展示\data-plat\src\main\java\com\sict\data\dto\GastroscopyDTO.java
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment