diff --git a/platform-biz-service/src/main/resources/mainOrm/master/MasterMysqlAntexc.xml b/platform-biz-service/src/main/resources/mainOrm/master/MasterMysqlAntexc.xml
index 32f63a9..eabd17f 100644
--- a/platform-biz-service/src/main/resources/mainOrm/master/MasterMysqlAntexc.xml
+++ b/platform-biz-service/src/main/resources/mainOrm/master/MasterMysqlAntexc.xml
@@ -1479,7 +1479,7 @@
report_antexchu l on tp.patientId=l.sourceId
INNER JOIN report_risk_level r on r.foreignId = l.cid
INNER JOIN organization o on l.hospitalId=o.id
- where r.type = 2 and c.type=1 and riskLevel > 1
+ where r.type = 2 and l.type=1 and riskLevel > 1
GROUP BY o.name
@@ -1501,7 +1501,7 @@
report_antexchu l on tp.patientId=l.sourceId
INNER JOIN report_risk_level r on r.foreignId = l.cid
INNER JOIN organization o on l.hospitalId=o.id
- where r.type = 2 and c.type=1 and riskLevel = 2
+ where r.type = 2 and l.type=1 and riskLevel = 2
GROUP BY o.name
@@ -1523,7 +1523,7 @@
report_antexchu l on tp.patientId=l.sourceId
INNER JOIN report_risk_level r on r.foreignId = l.cid
INNER JOIN organization o on l.hospitalId=o.id
- where r.type = 2 and c.type=1 and riskLevel = 3
+ where r.type = 2 and l.type=1 and riskLevel = 3
GROUP BY o.name
@@ -1547,7 +1547,7 @@
report_antexchu l on tp.patientId=l.sourceId
INNER JOIN report_risk_level r on r.foreignId = l.cid
INNER JOIN organization o on l.hospitalId=o.id
- where r.type = 2 and c.type=1 and riskLevel = 4
+ where r.type = 2 and l.type=1 and riskLevel = 4
GROUP BY o.name
@@ -1574,7 +1574,7 @@
report_antexchu l on tp.patientId=l.sourceId
INNER JOIN report_risk_level r on r.foreignId = l.cid
INNER JOIN organization o on l.hospitalId=o.id
- where r.type = 2 and c.type=1 and riskLevel = 5
+ where r.type = 2 and l.type=1 and riskLevel = 5
GROUP BY o.name
@@ -1599,7 +1599,7 @@
report_antexchu l on tp.patientId=l.sourceId
INNER JOIN report_risk_level r on r.foreignId = l.cid
INNER JOIN organization o on l.hospitalId=o.id
- where r.type = 2 and c.type=1 and riskLevel = 1
+ where r.type = 2 and l.type=1 and riskLevel = 1
GROUP BY o.name
@@ -1733,205 +1733,233 @@
GROUP BY o.name
+
+
select count(DISTINCT(l.sourceId))as checkRiskPersonCount,o.id as hospitalId,o.name as hospitalName
from (select p.patientId from report_patients p
where p.type=1 and p.enable is NULL
and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
-
) tp
INNER JOIN
- (SELECT c.sourceId as sourceId,c.hospitalId from report_risk_level r
- INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel > 1
+ report_antexchu l on tp.patientId=l.sourceId
+ INNER JOIN
+ report_risk_level r on r.foreignId = l.cid
+ INNER JOIN organization o on l.hospitalId=o.id
+ where r.type = 2 and l.type=1 and riskLevel > 1
- and c.checkTime >= #{startDate}
+ and l.checkTime >= #{startDate}
- and c.checkTime #{endDate}
+ and l.checkTime #{endDate}
- )
- l on tp.patientId=l.sourceId
- INNER JOIN organization o on l.hospitalId=o.id
GROUP BY o.name
- select count(l.sourceId) as checkColorYellowCount,o.name as hospitalName,o.id as hospitalId
- from (select p.patientId from report_patients p
- where p.type=1 and p.enable is NULL
+
+
+ select count(DISTINCT(l.sourceId))as checkColorYellowCount,o.id as hospitalId,o.name as hospitalName
+ from (select p.patientId from report_patients p
+ where p.type=1 and p.enable is NULL
and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
-
) tp
INNER JOIN
- (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
- INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 2
+ report_antexchu l on tp.patientId=l.sourceId
+ INNER JOIN
+ report_risk_level r on r.foreignId = l.cid
+ INNER JOIN organization o on l.hospitalId=o.id
+ where r.type = 2 and l.type=1 and riskLevel = 2
- and c.checkTime >= #{startDate}
+ and l.checkTime >= #{startDate}
- and c.checkTime #{endDate}
- )
- l on tp.patientId=l.sourceId
- INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
+ and l.checkTime #{endDate}
+
+ GROUP BY o.name
+
- select count(l.sourceId) as checkColorOrangeCount,o.name as hospitalName,o.id as hospitalId
- from (select p.patientId from report_patients p
- where p.type=1 and p.enable is NULL
+
+ select count(DISTINCT(l.sourceId))as checkColorOrangeCount,o.id as hospitalId,o.name as hospitalName
+ from (select p.patientId from report_patients p
+ where p.type=1 and p.enable is NULL
and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
-
) tp
INNER JOIN
- (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
- INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 3
+ report_antexchu l on tp.patientId=l.sourceId
+ INNER JOIN
+ report_risk_level r on r.foreignId = l.cid
+ INNER JOIN organization o on l.hospitalId=o.id
+ where r.type = 2 and l.type=1 and riskLevel = 3
- and c.checkTime >= #{startDate}
+ and l.checkTime >= #{startDate}
- and c.checkTime #{endDate}
- )
- l on tp.patientId=l.sourceId
- INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
+ and l.checkTime #{endDate}
+
+ GROUP BY o.name
- select count(l.sourceId) as checkColorRedCount,o.name as hospitalName,o.id as hospitalId
- from (select p.patientId from report_patients p
- where p.type=1 and p.enable is NULL
+
+ select count(DISTINCT(l.sourceId))as checkColorRedCount,o.id as hospitalId,o.name as hospitalName
+ from (select p.patientId from report_patients p
+ where p.type=1 and p.enable is NULL
and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
-
) tp
INNER JOIN
- (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
- INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 4
+ report_antexchu l on tp.patientId=l.sourceId
+ INNER JOIN
+ report_risk_level r on r.foreignId = l.cid
+ INNER JOIN organization o on l.hospitalId=o.id
+ where r.type = 2 and l.type=1 and riskLevel = 4
- and c.checkTime >= #{startDate}
+ and l.checkTime >= #{startDate}
- and c.checkTime #{endDate}
- )
- l on tp.patientId=l.sourceId
- INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
+ and l.checkTime #{endDate}
+
+ GROUP BY o.name
+
- select count(l.sourceId) as checkColorVioletCount,o.name as hospitalName,o.id as hospitalId
- from (select p.patientId from report_patients p
- where p.type=1 and p.enable is NULL
+
+ select count(DISTINCT(l.sourceId))as checkColorVioletCount,o.id as hospitalId,o.name as hospitalName
+ from (select p.patientId from report_patients p
+ where p.type=1 and p.enable is NULL
and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
-
) tp
INNER JOIN
- (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
- INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 5
+ report_antexchu l on tp.patientId=l.sourceId
+ INNER JOIN
+ report_risk_level r on r.foreignId = l.cid
+ INNER JOIN organization o on l.hospitalId=o.id
+ where r.type = 2 and l.type=1 and riskLevel = 5
- and c.checkTime >= #{startDate}
+ and l.checkTime >= #{startDate}
- and c.checkTime #{endDate}
- )
- l on tp.patientId=l.sourceId
- INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
+ and l.checkTime #{endDate}
+
+ GROUP BY o.name
+
- select count(l.sourceId) as checkColorGreenCount,o.name as hospitalName,o.id as hospitalId
- from (select p.patientId from report_patients p
- where p.type=1 and p.enable is NULL
+
+ select count(DISTINCT(l.sourceId))as checkColorGreenCount,o.id as hospitalId,o.name as hospitalName
+ from (select p.patientId from report_patients p
+ where p.type=1 and p.enable is NULL
and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
-
) tp
INNER JOIN
- (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
- INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 5
+ report_antexchu l on tp.patientId=l.sourceId
+ INNER JOIN
+ report_risk_level r on r.foreignId = l.cid
+ INNER JOIN organization o on l.hospitalId=o.id
+ where r.type = 2 and l.type=1 and riskLevel = 1
- and c.checkTime >= #{startDate}
+ and l.checkTime >= #{startDate}
- and c.checkTime #{endDate}
- )
- l on tp.patientId=l.sourceId
- INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
+ and l.checkTime #{endDate}
+
+ GROUP BY o.name
- select count(l.sourceId) as checkOneRiskCount,tp.name as hospitalName,tp.id as hospitalId from (select p.patientId,o.id,o.name from report_patients p
+ select count(a.sourceId) as checkOneRiskCount,o.name as hospitalName,o.id as hospitalId from report_patients p
INNER JOIN organization o on p.hospitalId=o.id
- where p.hospitalId=#{hospitalId} and p.type=1 and p.enable is NULL
- ) tp
+ INNER JOIN report_antexchu a
+ on p.patientId=a.sourceId
INNER JOIN
(
- SELECT r.foreignId,count(r.foreignId) as t,r.type,c.checkTime,r.riskLevel,c.sourceId from report_risk_level r LEFT JOIN report_antexchu c on r.foreignId = c.cid
- group by r.foreignId having t=1 and r.type = 2 and r.riskLevel >1
+ SELECT r.foreignId,count(r.foreignId) as t from report_risk_level r
+ where r.type = 2 and r.riskLevel >1 group by r.foreignId having t=1
+ ) l on l.foreignId = a.cid
+ where p.hospitalId=#{hospitalId} and p.type=1 and p.enable is NULL
- and c.checkTime >= #{startDate}
+ and a.checkTime >= #{startDate}
- and c.checkTime #{endDate}
+ and a.checkTime #{endDate}
- ) l on tp.patientId=l.sourceId GROUP BY tp.name
+ GROUP BY o.name
+
- select count(l.sourceId) as checkTwoRiskCount,tp.name as hospitalName,tp.id as hospitalId from (select p.patientId,o.id,o.name from report_patients p
+
+ select count(a.sourceId) as checkTwoRiskCount,o.name as hospitalName,o.id as hospitalId from report_patients p
INNER JOIN organization o on p.hospitalId=o.id
- where p.hospitalId=#{hospitalId} and p.type=1 and p.enable is NULL
- ) tp
+ INNER JOIN report_antexchu a
+ on p.patientId=a.sourceId
INNER JOIN
(
- SELECT r.foreignId,count(r.foreignId) as t,r.type,c.checkTime,r.riskLevel,c.sourceId from report_risk_level r LEFT JOIN report_antexchu c on r.foreignId = c.cid
- group by r.foreignId having t=2 and r.type = 2 and r.riskLevel >1
+ SELECT r.foreignId,count(r.foreignId) as t from report_risk_level r
+ where r.type = 2 and r.riskLevel >1 group by r.foreignId having t=2
+ ) l on l.foreignId = a.cid
+ where p.hospitalId=#{hospitalId} and p.type=1 and p.enable is NULL
- and c.checkTime >= #{startDate}
+ and a.checkTime >= #{startDate}
- and c.checkTime #{endDate}
+ and a.checkTime #{endDate}
- ) l on tp.patientId=l.sourceId GROUP BY tp.name
+ GROUP BY o.name
+
- select count(l.sourceId) as checkThreeRiskCount,tp.name as hospitalName,tp.id as hospitalId from (select p.patientId,o.id,o.name from report_patients p
+ select count(a.sourceId) as checkThreeRiskCount,o.name as hospitalName,o.id as hospitalId from report_patients p
INNER JOIN organization o on p.hospitalId=o.id
- where p.hospitalId=#{hospitalId} and p.type=1 and p.enable is NULL
- ) tp
+ INNER JOIN report_antexchu a
+ on p.patientId=a.sourceId
INNER JOIN
(
- SELECT r.foreignId,count(r.foreignId) as t,r.type,c.checkTime,r.riskLevel,c.sourceId from report_risk_level r LEFT JOIN report_antexchu c on r.foreignId = c.cid
- group by r.foreignId having t=3 and r.type = 2 and r.riskLevel >1
+ SELECT r.foreignId,count(r.foreignId) as t from report_risk_level r
+ where r.type = 2 and r.riskLevel >1 group by r.foreignId having t=3
+ ) l on l.foreignId = a.cid
+ where p.hospitalId=#{hospitalId} and p.type=1 and p.enable is NULL
- and c.checkTime >= #{startDate}
+ and a.checkTime >= #{startDate}
- and c.checkTime #{endDate}
+ and a.checkTime #{endDate}
- ) l on tp.patientId=l.sourceId GROUP BY tp.name
+ GROUP BY o.name
+
+
- select count(l.sourceId) as checkFourRiskCount,tp.name as hospitalName,tp.id as hospitalId from (select p.patientId,o.id,o.name from report_patients p
+ select count(a.sourceId) as checkFourRiskCount,o.name as hospitalName,o.id as hospitalId from report_patients p
INNER JOIN organization o on p.hospitalId=o.id
- where p.hospitalId=#{hospitalId} and p.type=1 and p.enable is NULL
- ) tp
+ INNER JOIN report_antexchu a
+ on p.patientId=a.sourceId
INNER JOIN
(
- SELECT r.foreignId,count(r.foreignId) as t,r.type,c.checkTime,r.riskLevel,c.sourceId from report_risk_level r LEFT JOIN report_antexchu c on r.foreignId = c.cid
- group by r.foreignId having t=4 and r.type = 2 and r.riskLevel >1
+ SELECT r.foreignId,count(r.foreignId) as t from report_risk_level r
+ where r.type = 2 and r.riskLevel >1 group by r.foreignId having t=4
+ ) l on l.foreignId = a.cid
+ where p.hospitalId=#{hospitalId} and p.type=1 and p.enable is NULL
- and c.checkTime >= #{startDate}
+ and a.checkTime >= #{startDate}
- and c.checkTime #{endDate}
+ and a.checkTime #{endDate}
- ) l on tp.patientId=l.sourceId GROUP BY tp.name
+ GROUP BY o.name
@@ -1954,6 +1982,7 @@
+
select count(DISTINCT(l.sourceId))as matDeliverRiskPersonCount,o.id as hospitalId,o.name as hospitalName
from (select p.patientId from report_patients p
where p.type=3 and p.enable is NULL
@@ -1968,18 +1997,17 @@
) tp
INNER JOIN
- (SELECT c.sourceId as sourceId,c.hospitalId from report_risk_level r
- INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel > 1 )
- l on tp.patientId=l.sourceId
+ report_antexchu l on tp.patientId=l.sourceId
+ INNER JOIN report_risk_level r on r.foreignId = l.cid
+
INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
INNER JOIN organization o on l.hospitalId=o.id
- GROUP BY o.name
-
+ where r.type = 2 and r.riskLevel > 1 and l.type=1 GROUP BY o.name
- select count(l.sourceId) as matDeliverColorYellowCount,o.name as hospitalName,o.id as hospitalId
- from (select p.patientId from report_patients p
- where p.type=3 and p.enable is NULL
+ select count(DISTINCT(l.sourceId))as matDeliverColorYellowCount,o.id as hospitalId,o.name as hospitalName
+ from (select p.patientId from report_patients p
+ where p.type=3 and p.enable is NULL
and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
@@ -1991,16 +2019,18 @@
) tp
INNER JOIN
- (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
- INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 2 )
- l on tp.patientId=l.sourceId
+ report_antexchu l on tp.patientId=l.sourceId
+ INNER JOIN report_risk_level r on r.foreignId = l.cid
+
INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
- INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
+ INNER JOIN organization o on l.hospitalId=o.id
+ where r.type = 2 and r.riskLevel = 2 and l.type=1 GROUP BY o.name
- select count(l.sourceId) as matDeliverColorOrangeCount,o.name as hospitalName,o.id as hospitalId
- from (select p.patientId from report_patients p
- where p.type=3 and p.enable is NULL
+
+ select count(DISTINCT(l.sourceId))as matDeliverColorOrangeCount,o.id as hospitalId,o.name as hospitalName
+ from (select p.patientId from report_patients p
+ where p.type=3 and p.enable is NULL
and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
@@ -2012,16 +2042,19 @@
) tp
INNER JOIN
- (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
- INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 3 )
- l on tp.patientId=l.sourceId
+ report_antexchu l on tp.patientId=l.sourceId
+ INNER JOIN report_risk_level r on r.foreignId = l.cid
+
INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
- INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
+ INNER JOIN organization o on l.hospitalId=o.id
+ where r.type = 2 and r.riskLevel = 3 and l.type=1 GROUP BY o.name
+
- select count(l.sourceId) as matDeliverColorRedCount,o.name as hospitalName,o.id as hospitalId
- from (select p.patientId from report_patients p
- where p.type=3 and p.enable is NULL
+
+ select count(DISTINCT(l.sourceId))as matDeliverColorRedCount,o.id as hospitalId,o.name as hospitalName
+ from (select p.patientId from report_patients p
+ where p.type=3 and p.enable is NULL
and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
@@ -2033,16 +2066,20 @@
) tp
INNER JOIN
- (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
- INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 4 )
- l on tp.patientId=l.sourceId
+ report_antexchu l on tp.patientId=l.sourceId
+ INNER JOIN report_risk_level r on r.foreignId = l.cid
+
INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
- INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
+ INNER JOIN organization o on l.hospitalId=o.id
+ where r.type = 2 and r.riskLevel = 4 and l.type=1 GROUP BY o.name
+
- select count(l.sourceId) as matDeliverColorVioletCount,o.name as hospitalName,o.id as hospitalId
- from (select p.patientId from report_patients p
- where p.type=3 and p.enable is NULL
+
+
+ select count(DISTINCT(l.sourceId))as matDeliverColorVioletCount,o.id as hospitalId,o.name as hospitalName
+ from (select p.patientId from report_patients p
+ where p.type=3 and p.enable is NULL
and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
@@ -2054,16 +2091,19 @@
) tp
INNER JOIN
- (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
- INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 5 )
- l on tp.patientId=l.sourceId
+ report_antexchu l on tp.patientId=l.sourceId
+ INNER JOIN report_risk_level r on r.foreignId = l.cid
+
INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
- INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
+ INNER JOIN organization o on l.hospitalId=o.id
+ where r.type = 2 and r.riskLevel = 5 and l.type=1 GROUP BY o.name
+
- select count(l.sourceId) as matDeliverColorGreenCount,o.name as hospitalName,o.id as hospitalId
- from (select p.patientId from report_patients p
- where p.type=3 and p.enable is NULL
+
+ select count(DISTINCT(l.sourceId))as matDeliverColorGreenCount,o.id as hospitalId,o.name as hospitalName
+ from (select p.patientId from report_patients p
+ where p.type=3 and p.enable is NULL
and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
@@ -2075,14 +2115,16 @@
) tp
INNER JOIN
- (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
- INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 1 )
- l on tp.patientId=l.sourceId
+ report_antexchu l on tp.patientId=l.sourceId
+ INNER JOIN report_risk_level r on r.foreignId = l.cid
+
INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
- INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
+ INNER JOIN organization o on l.hospitalId=o.id
+ where r.type = 2 and r.riskLevel = 1 and l.type=1 GROUP BY o.name
- select count(l.sourceId) as matDeliverOneRiskCount,tp.name as hospitalName,tp.id as hospitalId from (select p.patientId,o.id,o.name from report_patients p
+
+ select count(a.sourceId) as matDeliverOneRiskCount,tp.name as hospitalName,tp.id as hospitalId from (select p.patientId,o.id,o.name from report_patients p
INNER JOIN organization o on p.hospitalId=o.id
where p.type=3 and p.enable is NULL
@@ -2095,16 +2137,18 @@
and p.bookbuildingDate #{endDate}
) tp
+ INNER JOIN report_antexchu a
+ on tp.patientId=a.sourceId
INNER JOIN
(
- SELECT r.foreignId,count(r.foreignId) as t,r.type,r.riskLevel,c.sourceId from report_risk_level r LEFT JOIN report_antexchu c on r.foreignId = c.cid
- group by r.foreignId having t=1 and r.type = 2 and r.riskLevel >1
- ) l on tp.patientId=l.sourceId
- INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
- GROUP BY tp.name
+ SELECT r.foreignId,count(r.foreignId) as t,r.type,r.riskLevel from report_risk_level r
+ where r.type = 2 and r.riskLevel >1 group by r.foreignId having t=1
+ ) l on l.foreignId = a.cid GROUP BY tp.name
+
- select count(l.sourceId) as matDeliverTwoRiskCount,tp.name as hospitalName,tp.id as hospitalId from (select p.patientId,o.id,o.name from report_patients p
+
+ select count(a.sourceId) as matDeliverTwoRiskCount,tp.name as hospitalName,tp.id as hospitalId from (select p.patientId,o.id,o.name from report_patients p
INNER JOIN organization o on p.hospitalId=o.id
where p.type=3 and p.enable is NULL
@@ -2117,16 +2161,19 @@
and p.bookbuildingDate #{endDate}
) tp
+ INNER JOIN report_antexchu a
+ on tp.patientId=a.sourceId
INNER JOIN
(
- SELECT r.foreignId,count(r.foreignId) as t,r.type,r.riskLevel,c.sourceId from report_risk_level r LEFT JOIN report_antexchu c on r.foreignId = c.cid
- group by r.foreignId having t=2 and r.type = 2 and r.riskLevel >1
- ) l on tp.patientId=l.sourceId
- INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
- GROUP BY tp.name
+ SELECT r.foreignId,count(r.foreignId) as t,r.type,r.riskLevel from report_risk_level r
+ where r.type = 2 and r.riskLevel >1 group by r.foreignId having t=2
+ ) l on l.foreignId = a.cid GROUP BY tp.name
+
- select count(l.sourceId) as matDeliverThreeRiskCount,tp.name as hospitalName,tp.id as hospitalId from (select p.patientId,o.id,o.name from report_patients p
+
+
+ select count(a.sourceId) as matDeliverThreeRiskCount,tp.name as hospitalName,tp.id as hospitalId from (select p.patientId,o.id,o.name from report_patients p
INNER JOIN organization o on p.hospitalId=o.id
where p.type=3 and p.enable is NULL
@@ -2139,16 +2186,18 @@
and p.bookbuildingDate #{endDate}
) tp
+ INNER JOIN report_antexchu a
+ on tp.patientId=a.sourceId
INNER JOIN
(
- SELECT r.foreignId,count(r.foreignId) as t,r.type,r.riskLevel,c.sourceId from report_risk_level r LEFT JOIN report_antexchu c on r.foreignId = c.cid
- group by r.foreignId having t=3 and r.type = 2 and r.riskLevel >1
- ) l on tp.patientId=l.sourceId
- INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
- GROUP BY tp.name
+ SELECT r.foreignId,count(r.foreignId) as t,r.type,r.riskLevel from report_risk_level r
+ where r.type = 2 and r.riskLevel >1 group by r.foreignId having t=3
+ ) l on l.foreignId = a.cid GROUP BY tp.name
+
- select count(l.sourceId) as matDeliverFourRiskCount,tp.name as hospitalName,tp.id as hospitalId from (select p.patientId,o.id,o.name from report_patients p
+
+ select count(a.sourceId) as matDeliverFourRiskCount,tp.name as hospitalName,tp.id as hospitalId from (select p.patientId,o.id,o.name from report_patients p
INNER JOIN organization o on p.hospitalId=o.id
where p.type=3 and p.enable is NULL
@@ -2161,13 +2210,13 @@
and p.bookbuildingDate #{endDate}
) tp
+ INNER JOIN report_antexchu a
+ on tp.patientId=a.sourceId
INNER JOIN
(
- SELECT r.foreignId,count(r.foreignId) as t,r.type,r.riskLevel,c.sourceId from report_risk_level r LEFT JOIN report_antexchu c on r.foreignId = c.cid
- group by r.foreignId having t=4 and r.type = 2 and r.riskLevel >1
- ) l on tp.patientId=l.sourceId
- INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
- GROUP BY tp.name
+ SELECT r.foreignId,count(r.foreignId) as t,r.type,r.riskLevel from report_risk_level r
+ where r.type = 2 and r.riskLevel >1 group by r.foreignId having t=4
+ ) l on l.foreignId = a.cid GROUP BY tp.name