Commit 560847b0b610cfe48d6c82a6850245d7eaefd97b

Authored by liquanyu
1 parent 79ec28d588

update

Showing 1 changed file with 214 additions and 165 deletions

platform-biz-service/src/main/resources/mainOrm/master/MasterMysqlAntexc.xml View file @ 560847b
... ... @@ -1479,7 +1479,7 @@
1479 1479 report_antexchu l on tp.patientId=l.sourceId
1480 1480 INNER JOIN report_risk_level r on r.foreignId = l.cid
1481 1481 INNER JOIN organization o on l.hospitalId=o.id
1482   - where r.type = 2 and c.type=1 and riskLevel > 1
  1482 + where r.type = 2 and l.type=1 and riskLevel > 1
1483 1483 GROUP BY o.name
1484 1484 </select>
1485 1485  
... ... @@ -1501,7 +1501,7 @@
1501 1501 report_antexchu l on tp.patientId=l.sourceId
1502 1502 INNER JOIN report_risk_level r on r.foreignId = l.cid
1503 1503 INNER JOIN organization o on l.hospitalId=o.id
1504   - where r.type = 2 and c.type=1 and riskLevel = 2
  1504 + where r.type = 2 and l.type=1 and riskLevel = 2
1505 1505 GROUP BY o.name
1506 1506 </select>
1507 1507 <select id="getColorOrangeCounts" resultType="java.util.Map" parameterType="java.util.Map">
... ... @@ -1523,7 +1523,7 @@
1523 1523 report_antexchu l on tp.patientId=l.sourceId
1524 1524 INNER JOIN report_risk_level r on r.foreignId = l.cid
1525 1525 INNER JOIN organization o on l.hospitalId=o.id
1526   - where r.type = 2 and c.type=1 and riskLevel = 3
  1526 + where r.type = 2 and l.type=1 and riskLevel = 3
1527 1527 GROUP BY o.name
1528 1528  
1529 1529 </select>
... ... @@ -1547,7 +1547,7 @@
1547 1547 report_antexchu l on tp.patientId=l.sourceId
1548 1548 INNER JOIN report_risk_level r on r.foreignId = l.cid
1549 1549 INNER JOIN organization o on l.hospitalId=o.id
1550   - where r.type = 2 and c.type=1 and riskLevel = 4
  1550 + where r.type = 2 and l.type=1 and riskLevel = 4
1551 1551 GROUP BY o.name
1552 1552  
1553 1553  
... ... @@ -1574,7 +1574,7 @@
1574 1574 report_antexchu l on tp.patientId=l.sourceId
1575 1575 INNER JOIN report_risk_level r on r.foreignId = l.cid
1576 1576 INNER JOIN organization o on l.hospitalId=o.id
1577   - where r.type = 2 and c.type=1 and riskLevel = 5
  1577 + where r.type = 2 and l.type=1 and riskLevel = 5
1578 1578 GROUP BY o.name
1579 1579  
1580 1580 </select>
... ... @@ -1599,7 +1599,7 @@
1599 1599 report_antexchu l on tp.patientId=l.sourceId
1600 1600 INNER JOIN report_risk_level r on r.foreignId = l.cid
1601 1601 INNER JOIN organization o on l.hospitalId=o.id
1602   - where r.type = 2 and c.type=1 and riskLevel = 1
  1602 + where r.type = 2 and l.type=1 and riskLevel = 1
1603 1603 GROUP BY o.name
1604 1604 </select>
1605 1605  
1606 1606  
1607 1607  
1608 1608  
1609 1609  
1610 1610  
1611 1611  
1612 1612  
1613 1613  
1614 1614  
1615 1615  
1616 1616  
1617 1617  
1618 1618  
1619 1619  
1620 1620  
1621 1621  
1622 1622  
1623 1623  
1624 1624  
1625 1625  
1626 1626  
1627 1627  
1628 1628  
1629 1629  
1630 1630  
1631 1631  
1632 1632  
1633 1633  
1634 1634  
1635 1635  
1636 1636  
1637 1637  
1638 1638  
1639 1639  
1640 1640  
1641 1641  
1642 1642  
1643 1643  
1644 1644  
1645 1645  
1646 1646  
1647 1647  
1648 1648  
1649 1649  
1650 1650  
1651 1651  
1652 1652  
1653 1653  
1654 1654  
1655 1655  
1656 1656  
1657 1657  
1658 1658  
1659 1659  
1660 1660  
1661 1661  
1662 1662  
1663 1663  
... ... @@ -1733,205 +1733,233 @@
1733 1733 GROUP BY o.name
1734 1734 </select>
1735 1735 <select id="getCheckRiskPersonCounts" resultType="java.util.Map" parameterType="java.util.Map">
  1736 +
  1737 +
1736 1738 select count(DISTINCT(l.sourceId))as checkRiskPersonCount,o.id as hospitalId,o.name as hospitalName
1737 1739 from (select p.patientId from report_patients p
1738 1740 where p.type=1 and p.enable is NULL
1739 1741 <if test="hospitalId != null and hospitalId != ''">
1740 1742 and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
1741 1743 </if>
1742   -
1743 1744 ) tp
1744 1745 INNER JOIN
1745   - (SELECT c.sourceId as sourceId,c.hospitalId from report_risk_level r
1746   - INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel > 1
  1746 + report_antexchu l on tp.patientId=l.sourceId
  1747 + INNER JOIN
  1748 + report_risk_level r on r.foreignId = l.cid
  1749 + INNER JOIN organization o on l.hospitalId=o.id
  1750 + where r.type = 2 and l.type=1 and riskLevel > 1
1747 1751 <if test="startDate != null">
1748   - and c.checkTime >= #{startDate}
  1752 + and l.checkTime >= #{startDate}
1749 1753 </if>
1750 1754 <if test="endDate != null">
1751   - and c.checkTime <![CDATA[ <= ]]> #{endDate}
  1755 + and l.checkTime <![CDATA[ <= ]]> #{endDate}
1752 1756 </if>
1753   - )
1754   - l on tp.patientId=l.sourceId
1755   - INNER JOIN organization o on l.hospitalId=o.id
1756 1757 GROUP BY o.name
1757 1758 </select>
1758 1759 <select id="getCheckColorYellowCounts" resultType="java.util.Map" parameterType="java.util.Map">
1759   - select count(l.sourceId) as checkColorYellowCount,o.name as hospitalName,o.id as hospitalId
1760   - from (select p.patientId from report_patients p
1761   - where p.type=1 and p.enable is NULL
  1760 +
  1761 +
  1762 + select count(DISTINCT(l.sourceId))as checkColorYellowCount,o.id as hospitalId,o.name as hospitalName
  1763 + from (select p.patientId from report_patients p
  1764 + where p.type=1 and p.enable is NULL
1762 1765 <if test="hospitalId != null and hospitalId != ''">
1763 1766 and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
1764 1767 </if>
1765   -
1766 1768 ) tp
1767 1769 INNER JOIN
1768   - (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
1769   - INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 2
  1770 + report_antexchu l on tp.patientId=l.sourceId
  1771 + INNER JOIN
  1772 + report_risk_level r on r.foreignId = l.cid
  1773 + INNER JOIN organization o on l.hospitalId=o.id
  1774 + where r.type = 2 and l.type=1 and riskLevel = 2
1770 1775 <if test="startDate != null">
1771   - and c.checkTime >= #{startDate}
  1776 + and l.checkTime >= #{startDate}
1772 1777 </if>
1773 1778 <if test="endDate != null">
1774   - and c.checkTime <![CDATA[ <= ]]> #{endDate}
1775   - </if>)
1776   - l on tp.patientId=l.sourceId
1777   - INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
  1779 + and l.checkTime <![CDATA[ <= ]]> #{endDate}
  1780 + </if>
  1781 + GROUP BY o.name
  1782 +
1778 1783 </select>
1779 1784 <select id="getCheckColorOrangeCounts" resultType="java.util.Map" parameterType="java.util.Map">
1780   - select count(l.sourceId) as checkColorOrangeCount,o.name as hospitalName,o.id as hospitalId
1781   - from (select p.patientId from report_patients p
1782   - where p.type=1 and p.enable is NULL
  1785 +
  1786 + select count(DISTINCT(l.sourceId))as checkColorOrangeCount,o.id as hospitalId,o.name as hospitalName
  1787 + from (select p.patientId from report_patients p
  1788 + where p.type=1 and p.enable is NULL
1783 1789 <if test="hospitalId != null and hospitalId != ''">
1784 1790 and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
1785 1791 </if>
1786   -
1787 1792 ) tp
1788 1793 INNER JOIN
1789   - (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
1790   - INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 3
  1794 + report_antexchu l on tp.patientId=l.sourceId
  1795 + INNER JOIN
  1796 + report_risk_level r on r.foreignId = l.cid
  1797 + INNER JOIN organization o on l.hospitalId=o.id
  1798 + where r.type = 2 and l.type=1 and riskLevel = 3
1791 1799 <if test="startDate != null">
1792   - and c.checkTime >= #{startDate}
  1800 + and l.checkTime >= #{startDate}
1793 1801 </if>
1794 1802 <if test="endDate != null">
1795   - and c.checkTime <![CDATA[ <= ]]> #{endDate}
1796   - </if>)
1797   - l on tp.patientId=l.sourceId
1798   - INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
  1803 + and l.checkTime <![CDATA[ <= ]]> #{endDate}
  1804 + </if>
  1805 + GROUP BY o.name
1799 1806  
1800 1807 </select>
1801 1808 <select id="getCheckColorRedCounts" resultType="java.util.Map" parameterType="java.util.Map">
1802   - select count(l.sourceId) as checkColorRedCount,o.name as hospitalName,o.id as hospitalId
1803   - from (select p.patientId from report_patients p
1804   - where p.type=1 and p.enable is NULL
  1809 +
  1810 + select count(DISTINCT(l.sourceId))as checkColorRedCount,o.id as hospitalId,o.name as hospitalName
  1811 + from (select p.patientId from report_patients p
  1812 + where p.type=1 and p.enable is NULL
1805 1813 <if test="hospitalId != null and hospitalId != ''">
1806 1814 and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
1807 1815 </if>
1808   -
1809 1816 ) tp
1810 1817 INNER JOIN
1811   - (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
1812   - INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 4
  1818 + report_antexchu l on tp.patientId=l.sourceId
  1819 + INNER JOIN
  1820 + report_risk_level r on r.foreignId = l.cid
  1821 + INNER JOIN organization o on l.hospitalId=o.id
  1822 + where r.type = 2 and l.type=1 and riskLevel = 4
1813 1823 <if test="startDate != null">
1814   - and c.checkTime >= #{startDate}
  1824 + and l.checkTime >= #{startDate}
1815 1825 </if>
1816 1826 <if test="endDate != null">
1817   - and c.checkTime <![CDATA[ <= ]]> #{endDate}
1818   - </if>)
1819   - l on tp.patientId=l.sourceId
1820   - INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
  1827 + and l.checkTime <![CDATA[ <= ]]> #{endDate}
  1828 + </if>
  1829 + GROUP BY o.name
  1830 +
1821 1831 </select>
1822 1832 <select id="getCheckColorVioletCounts" resultType="java.util.Map" parameterType="java.util.Map">
1823   - select count(l.sourceId) as checkColorVioletCount,o.name as hospitalName,o.id as hospitalId
1824   - from (select p.patientId from report_patients p
1825   - where p.type=1 and p.enable is NULL
  1833 +
  1834 + select count(DISTINCT(l.sourceId))as checkColorVioletCount,o.id as hospitalId,o.name as hospitalName
  1835 + from (select p.patientId from report_patients p
  1836 + where p.type=1 and p.enable is NULL
1826 1837 <if test="hospitalId != null and hospitalId != ''">
1827 1838 and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
1828 1839 </if>
1829   -
1830 1840 ) tp
1831 1841 INNER JOIN
1832   - (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
1833   - INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 5
  1842 + report_antexchu l on tp.patientId=l.sourceId
  1843 + INNER JOIN
  1844 + report_risk_level r on r.foreignId = l.cid
  1845 + INNER JOIN organization o on l.hospitalId=o.id
  1846 + where r.type = 2 and l.type=1 and riskLevel = 5
1834 1847 <if test="startDate != null">
1835   - and c.checkTime >= #{startDate}
  1848 + and l.checkTime >= #{startDate}
1836 1849 </if>
1837 1850 <if test="endDate != null">
1838   - and c.checkTime <![CDATA[ <= ]]> #{endDate}
1839   - </if>)
1840   - l on tp.patientId=l.sourceId
1841   - INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
  1851 + and l.checkTime <![CDATA[ <= ]]> #{endDate}
  1852 + </if>
  1853 + GROUP BY o.name
  1854 +
1842 1855 </select>
1843 1856 <select id="getCheckColorGreenCounts" resultType="java.util.Map" parameterType="java.util.Map">
1844   - select count(l.sourceId) as checkColorGreenCount,o.name as hospitalName,o.id as hospitalId
1845   - from (select p.patientId from report_patients p
1846   - where p.type=1 and p.enable is NULL
  1857 +
  1858 + select count(DISTINCT(l.sourceId))as checkColorGreenCount,o.id as hospitalId,o.name as hospitalName
  1859 + from (select p.patientId from report_patients p
  1860 + where p.type=1 and p.enable is NULL
1847 1861 <if test="hospitalId != null and hospitalId != ''">
1848 1862 and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
1849 1863 </if>
1850   -
1851 1864 ) tp
1852 1865 INNER JOIN
1853   - (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
1854   - INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 5
  1866 + report_antexchu l on tp.patientId=l.sourceId
  1867 + INNER JOIN
  1868 + report_risk_level r on r.foreignId = l.cid
  1869 + INNER JOIN organization o on l.hospitalId=o.id
  1870 + where r.type = 2 and l.type=1 and riskLevel = 1
1855 1871 <if test="startDate != null">
1856   - and c.checkTime >= #{startDate}
  1872 + and l.checkTime >= #{startDate}
1857 1873 </if>
1858 1874 <if test="endDate != null">
1859   - and c.checkTime <![CDATA[ <= ]]> #{endDate}
1860   - </if>)
1861   - l on tp.patientId=l.sourceId
1862   - INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
  1875 + and l.checkTime <![CDATA[ <= ]]> #{endDate}
  1876 + </if>
  1877 + GROUP BY o.name
1863 1878 </select>
1864 1879 <select id="getCheckOneRiskCounts" resultType="java.util.Map" parameterType="java.util.Map">
1865   - 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
  1880 + select count(a.sourceId) as checkOneRiskCount,o.name as hospitalName,o.id as hospitalId from report_patients p
1866 1881 INNER JOIN organization o on p.hospitalId=o.id
1867   - where p.hospitalId=#{hospitalId} and p.type=1 and p.enable is NULL
1868 1882  
1869   - ) tp
  1883 + INNER JOIN report_antexchu a
  1884 + on p.patientId=a.sourceId
1870 1885 INNER JOIN
1871 1886 (
1872   - 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
1873   - group by r.foreignId having t=1 and r.type = 2 and r.riskLevel >1
  1887 + SELECT r.foreignId,count(r.foreignId) as t from report_risk_level r
  1888 + where r.type = 2 and r.riskLevel >1 group by r.foreignId having t=1
  1889 + ) l on l.foreignId = a.cid
  1890 + where p.hospitalId=#{hospitalId} and p.type=1 and p.enable is NULL
1874 1891 <if test="startDate != null">
1875   - and c.checkTime >= #{startDate}
  1892 + and a.checkTime >= #{startDate}
1876 1893 </if>
1877 1894 <if test="endDate != null">
1878   - and c.checkTime <![CDATA[ <= ]]> #{endDate}
  1895 + and a.checkTime <![CDATA[ <= ]]> #{endDate}
1879 1896 </if>
1880   - ) l on tp.patientId=l.sourceId GROUP BY tp.name
  1897 + GROUP BY o.name
  1898 +
1881 1899 </select>
1882 1900 <select id="getCheckTwoRiskCounts" resultType="java.util.Map" parameterType="java.util.Map">
1883   - 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
  1901 +
  1902 + select count(a.sourceId) as checkTwoRiskCount,o.name as hospitalName,o.id as hospitalId from report_patients p
1884 1903 INNER JOIN organization o on p.hospitalId=o.id
1885   - where p.hospitalId=#{hospitalId} and p.type=1 and p.enable is NULL
1886 1904  
1887   - ) tp
  1905 + INNER JOIN report_antexchu a
  1906 + on p.patientId=a.sourceId
1888 1907 INNER JOIN
1889 1908 (
1890   - 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
1891   - group by r.foreignId having t=2 and r.type = 2 and r.riskLevel >1
  1909 + SELECT r.foreignId,count(r.foreignId) as t from report_risk_level r
  1910 + where r.type = 2 and r.riskLevel >1 group by r.foreignId having t=2
  1911 + ) l on l.foreignId = a.cid
  1912 + where p.hospitalId=#{hospitalId} and p.type=1 and p.enable is NULL
1892 1913 <if test="startDate != null">
1893   - and c.checkTime >= #{startDate}
  1914 + and a.checkTime >= #{startDate}
1894 1915 </if>
1895 1916 <if test="endDate != null">
1896   - and c.checkTime <![CDATA[ <= ]]> #{endDate}
  1917 + and a.checkTime <![CDATA[ <= ]]> #{endDate}
1897 1918 </if>
1898   - ) l on tp.patientId=l.sourceId GROUP BY tp.name
  1919 + GROUP BY o.name
  1920 +
1899 1921 </select>
1900 1922 <select id="getCheckThreeRiskCounts" resultType="java.util.Map" parameterType="java.util.Map">
1901   - 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
  1923 + select count(a.sourceId) as checkThreeRiskCount,o.name as hospitalName,o.id as hospitalId from report_patients p
1902 1924 INNER JOIN organization o on p.hospitalId=o.id
1903   - where p.hospitalId=#{hospitalId} and p.type=1 and p.enable is NULL
1904 1925  
1905   - ) tp
  1926 + INNER JOIN report_antexchu a
  1927 + on p.patientId=a.sourceId
1906 1928 INNER JOIN
1907 1929 (
1908   - 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
1909   - group by r.foreignId having t=3 and r.type = 2 and r.riskLevel >1
  1930 + SELECT r.foreignId,count(r.foreignId) as t from report_risk_level r
  1931 + where r.type = 2 and r.riskLevel >1 group by r.foreignId having t=3
  1932 + ) l on l.foreignId = a.cid
  1933 + where p.hospitalId=#{hospitalId} and p.type=1 and p.enable is NULL
1910 1934 <if test="startDate != null">
1911   - and c.checkTime >= #{startDate}
  1935 + and a.checkTime >= #{startDate}
1912 1936 </if>
1913 1937 <if test="endDate != null">
1914   - and c.checkTime <![CDATA[ <= ]]> #{endDate}
  1938 + and a.checkTime <![CDATA[ <= ]]> #{endDate}
1915 1939 </if>
1916   - ) l on tp.patientId=l.sourceId GROUP BY tp.name
  1940 + GROUP BY o.name
  1941 +
  1942 +
1917 1943 </select>
1918 1944 <select id="getCheckFourRiskCounts" resultType="java.util.Map" parameterType="java.util.Map">
1919   - 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
  1945 + select count(a.sourceId) as checkFourRiskCount,o.name as hospitalName,o.id as hospitalId from report_patients p
1920 1946 INNER JOIN organization o on p.hospitalId=o.id
1921   - where p.hospitalId=#{hospitalId} and p.type=1 and p.enable is NULL
1922 1947  
1923   - ) tp
  1948 + INNER JOIN report_antexchu a
  1949 + on p.patientId=a.sourceId
1924 1950 INNER JOIN
1925 1951 (
1926   - 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
1927   - group by r.foreignId having t=4 and r.type = 2 and r.riskLevel >1
  1952 + SELECT r.foreignId,count(r.foreignId) as t from report_risk_level r
  1953 + where r.type = 2 and r.riskLevel >1 group by r.foreignId having t=4
  1954 + ) l on l.foreignId = a.cid
  1955 + where p.hospitalId=#{hospitalId} and p.type=1 and p.enable is NULL
1928 1956 <if test="startDate != null">
1929   - and c.checkTime >= #{startDate}
  1957 + and a.checkTime >= #{startDate}
1930 1958 </if>
1931 1959 <if test="endDate != null">
1932   - and c.checkTime <![CDATA[ <= ]]> #{endDate}
  1960 + and a.checkTime <![CDATA[ <= ]]> #{endDate}
1933 1961 </if>
1934   - ) l on tp.patientId=l.sourceId GROUP BY tp.name
  1962 + GROUP BY o.name
1935 1963 </select>
1936 1964  
1937 1965  
... ... @@ -1954,6 +1982,7 @@
1954 1982  
1955 1983 </select>
1956 1984 <select id="getMatDeliverRiskPersonCounts" resultType="java.util.Map" parameterType="java.util.Map">
  1985 +
1957 1986 select count(DISTINCT(l.sourceId))as matDeliverRiskPersonCount,o.id as hospitalId,o.name as hospitalName
1958 1987 from (select p.patientId from report_patients p
1959 1988 where p.type=3 and p.enable is NULL
1960 1989  
1961 1990  
... ... @@ -1968,18 +1997,17 @@
1968 1997 </if>
1969 1998 ) tp
1970 1999 INNER JOIN
1971   - (SELECT c.sourceId as sourceId,c.hospitalId from report_risk_level r
1972   - INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel > 1 )
1973   - l on tp.patientId=l.sourceId
  2000 + report_antexchu l on tp.patientId=l.sourceId
  2001 + INNER JOIN report_risk_level r on r.foreignId = l.cid
  2002 +
1974 2003 INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
1975 2004 INNER JOIN organization o on l.hospitalId=o.id
1976   - GROUP BY o.name
1977   -
  2005 + where r.type = 2 and r.riskLevel > 1 and l.type=1 GROUP BY o.name
1978 2006 </select>
1979 2007 <select id="getMatDeliverColorYellowCounts" resultType="java.util.Map" parameterType="java.util.Map">
1980   - select count(l.sourceId) as matDeliverColorYellowCount,o.name as hospitalName,o.id as hospitalId
1981   - from (select p.patientId from report_patients p
1982   - where p.type=3 and p.enable is NULL
  2008 + select count(DISTINCT(l.sourceId))as matDeliverColorYellowCount,o.id as hospitalId,o.name as hospitalName
  2009 + from (select p.patientId from report_patients p
  2010 + where p.type=3 and p.enable is NULL
1983 2011 <if test="hospitalId != null and hospitalId != ''">
1984 2012 and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
1985 2013 </if>
1986 2014  
1987 2015  
... ... @@ -1991,16 +2019,18 @@
1991 2019 </if>
1992 2020 ) tp
1993 2021 INNER JOIN
1994   - (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
1995   - INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 2 )
1996   - l on tp.patientId=l.sourceId
  2022 + report_antexchu l on tp.patientId=l.sourceId
  2023 + INNER JOIN report_risk_level r on r.foreignId = l.cid
  2024 +
1997 2025 INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
1998   - INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
  2026 + INNER JOIN organization o on l.hospitalId=o.id
  2027 + where r.type = 2 and r.riskLevel = 2 and l.type=1 GROUP BY o.name
1999 2028 </select>
2000 2029 <select id="getMatDeliverColorOrangeCounts" resultType="java.util.Map" parameterType="java.util.Map">
2001   - select count(l.sourceId) as matDeliverColorOrangeCount,o.name as hospitalName,o.id as hospitalId
2002   - from (select p.patientId from report_patients p
2003   - where p.type=3 and p.enable is NULL
  2030 +
  2031 + select count(DISTINCT(l.sourceId))as matDeliverColorOrangeCount,o.id as hospitalId,o.name as hospitalName
  2032 + from (select p.patientId from report_patients p
  2033 + where p.type=3 and p.enable is NULL
2004 2034 <if test="hospitalId != null and hospitalId != ''">
2005 2035 and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
2006 2036 </if>
2007 2037  
2008 2038  
... ... @@ -2012,16 +2042,19 @@
2012 2042 </if>
2013 2043 ) tp
2014 2044 INNER JOIN
2015   - (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
2016   - INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 3 )
2017   - l on tp.patientId=l.sourceId
  2045 + report_antexchu l on tp.patientId=l.sourceId
  2046 + INNER JOIN report_risk_level r on r.foreignId = l.cid
  2047 +
2018 2048 INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
2019   - INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
  2049 + INNER JOIN organization o on l.hospitalId=o.id
  2050 + where r.type = 2 and r.riskLevel = 3 and l.type=1 GROUP BY o.name
  2051 +
2020 2052 </select>
2021 2053 <select id="getMatDeliverColorRedCounts" resultType="java.util.Map" parameterType="java.util.Map">
2022   - select count(l.sourceId) as matDeliverColorRedCount,o.name as hospitalName,o.id as hospitalId
2023   - from (select p.patientId from report_patients p
2024   - where p.type=3 and p.enable is NULL
  2054 +
  2055 + select count(DISTINCT(l.sourceId))as matDeliverColorRedCount,o.id as hospitalId,o.name as hospitalName
  2056 + from (select p.patientId from report_patients p
  2057 + where p.type=3 and p.enable is NULL
2025 2058 <if test="hospitalId != null and hospitalId != ''">
2026 2059 and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
2027 2060 </if>
2028 2061  
2029 2062  
... ... @@ -2033,16 +2066,20 @@
2033 2066 </if>
2034 2067 ) tp
2035 2068 INNER JOIN
2036   - (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
2037   - INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 4 )
2038   - l on tp.patientId=l.sourceId
  2069 + report_antexchu l on tp.patientId=l.sourceId
  2070 + INNER JOIN report_risk_level r on r.foreignId = l.cid
  2071 +
2039 2072 INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
2040   - INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
  2073 + INNER JOIN organization o on l.hospitalId=o.id
  2074 + where r.type = 2 and r.riskLevel = 4 and l.type=1 GROUP BY o.name
  2075 +
2041 2076 </select>
2042 2077 <select id="getMatDeliverColorVioletCounts" resultType="java.util.Map" parameterType="java.util.Map">
2043   - select count(l.sourceId) as matDeliverColorVioletCount,o.name as hospitalName,o.id as hospitalId
2044   - from (select p.patientId from report_patients p
2045   - where p.type=3 and p.enable is NULL
  2078 +
  2079 +
  2080 + select count(DISTINCT(l.sourceId))as matDeliverColorVioletCount,o.id as hospitalId,o.name as hospitalName
  2081 + from (select p.patientId from report_patients p
  2082 + where p.type=3 and p.enable is NULL
2046 2083 <if test="hospitalId != null and hospitalId != ''">
2047 2084 and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
2048 2085 </if>
2049 2086  
2050 2087  
... ... @@ -2054,16 +2091,19 @@
2054 2091 </if>
2055 2092 ) tp
2056 2093 INNER JOIN
2057   - (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
2058   - INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 5 )
2059   - l on tp.patientId=l.sourceId
  2094 + report_antexchu l on tp.patientId=l.sourceId
  2095 + INNER JOIN report_risk_level r on r.foreignId = l.cid
  2096 +
2060 2097 INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
2061   - INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
  2098 + INNER JOIN organization o on l.hospitalId=o.id
  2099 + where r.type = 2 and r.riskLevel = 5 and l.type=1 GROUP BY o.name
  2100 +
2062 2101 </select>
2063 2102 <select id="getMatDeliverColorGreenCounts" resultType="java.util.Map" parameterType="java.util.Map">
2064   - select count(l.sourceId) as matDeliverColorGreenCount,o.name as hospitalName,o.id as hospitalId
2065   - from (select p.patientId from report_patients p
2066   - where p.type=3 and p.enable is NULL
  2103 +
  2104 + select count(DISTINCT(l.sourceId))as matDeliverColorGreenCount,o.id as hospitalId,o.name as hospitalName
  2105 + from (select p.patientId from report_patients p
  2106 + where p.type=3 and p.enable is NULL
2067 2107 <if test="hospitalId != null and hospitalId != ''">
2068 2108 and p.hospitalId = #{hospitalId,jdbcType=VARCHAR}
2069 2109 </if>
2070 2110  
2071 2111  
... ... @@ -2075,14 +2115,16 @@
2075 2115 </if>
2076 2116 ) tp
2077 2117 INNER JOIN
2078   - (SELECT DISTINCT(c.sourceId) as sourceId ,c.hospitalId from report_risk_level r
2079   - INNER JOIN report_antexchu c on r.foreignId = c.cid where r.type = 2 and c.type=1 and riskLevel = 1 )
2080   - l on tp.patientId=l.sourceId
  2118 + report_antexchu l on tp.patientId=l.sourceId
  2119 + INNER JOIN report_risk_level r on r.foreignId = l.cid
  2120 +
2081 2121 INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
2082   - INNER JOIN organization o on l.hospitalId=o.id GROUP BY o.name
  2122 + INNER JOIN organization o on l.hospitalId=o.id
  2123 + where r.type = 2 and r.riskLevel = 1 and l.type=1 GROUP BY o.name
2083 2124 </select>
2084 2125 <select id="getMatDeliverOneRiskCounts" resultType="java.util.Map" parameterType="java.util.Map">
2085   - 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
  2126 +
  2127 + 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
2086 2128 INNER JOIN organization o on p.hospitalId=o.id
2087 2129 where p.type=3 and p.enable is NULL
2088 2130 <if test="hospitalId != null and hospitalId != ''">
2089 2131  
2090 2132  
... ... @@ -2095,16 +2137,18 @@
2095 2137 and p.bookbuildingDate <![CDATA[ <= ]]> #{endDate}
2096 2138 </if>
2097 2139 ) tp
  2140 + INNER JOIN report_antexchu a
  2141 + on tp.patientId=a.sourceId
2098 2142 INNER JOIN
2099 2143 (
2100   - 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
2101   - group by r.foreignId having t=1 and r.type = 2 and r.riskLevel >1
2102   - ) l on tp.patientId=l.sourceId
2103   - INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
2104   - GROUP BY tp.name
  2144 + SELECT r.foreignId,count(r.foreignId) as t,r.type,r.riskLevel from report_risk_level r
  2145 + where r.type = 2 and r.riskLevel >1 group by r.foreignId having t=1
  2146 + ) l on l.foreignId = a.cid GROUP BY tp.name
  2147 +
2105 2148 </select>
2106 2149 <select id="getMatDeliverTwoRiskCounts" resultType="java.util.Map" parameterType="java.util.Map">
2107   - 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
  2150 +
  2151 + 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
2108 2152 INNER JOIN organization o on p.hospitalId=o.id
2109 2153 where p.type=3 and p.enable is NULL
2110 2154 <if test="hospitalId != null and hospitalId != ''">
2111 2155  
2112 2156  
... ... @@ -2117,16 +2161,19 @@
2117 2161 and p.bookbuildingDate <![CDATA[ <= ]]> #{endDate}
2118 2162 </if>
2119 2163 ) tp
  2164 + INNER JOIN report_antexchu a
  2165 + on tp.patientId=a.sourceId
2120 2166 INNER JOIN
2121 2167 (
2122   - 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
2123   - group by r.foreignId having t=2 and r.type = 2 and r.riskLevel >1
2124   - ) l on tp.patientId=l.sourceId
2125   - INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
2126   - GROUP BY tp.name
  2168 + SELECT r.foreignId,count(r.foreignId) as t,r.type,r.riskLevel from report_risk_level r
  2169 + where r.type = 2 and r.riskLevel >1 group by r.foreignId having t=2
  2170 + ) l on l.foreignId = a.cid GROUP BY tp.name
  2171 +
2127 2172 </select>
2128 2173 <select id="getMatDeliverThreeRiskCounts" resultType="java.util.Map" parameterType="java.util.Map">
2129   - 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
  2174 +
  2175 +
  2176 + 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
2130 2177 INNER JOIN organization o on p.hospitalId=o.id
2131 2178 where p.type=3 and p.enable is NULL
2132 2179 <if test="hospitalId != null and hospitalId != ''">
2133 2180  
2134 2181  
... ... @@ -2139,16 +2186,18 @@
2139 2186 and p.bookbuildingDate <![CDATA[ <= ]]> #{endDate}
2140 2187 </if>
2141 2188 ) tp
  2189 + INNER JOIN report_antexchu a
  2190 + on tp.patientId=a.sourceId
2142 2191 INNER JOIN
2143 2192 (
2144   - 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
2145   - group by r.foreignId having t=3 and r.type = 2 and r.riskLevel >1
2146   - ) l on tp.patientId=l.sourceId
2147   - INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
2148   - GROUP BY tp.name
  2193 + SELECT r.foreignId,count(r.foreignId) as t,r.type,r.riskLevel from report_risk_level r
  2194 + where r.type = 2 and r.riskLevel >1 group by r.foreignId having t=3
  2195 + ) l on l.foreignId = a.cid GROUP BY tp.name
  2196 +
2149 2197 </select>
2150 2198 <select id="getMatDeliverFourRiskCounts" resultType="java.util.Map" parameterType="java.util.Map">
2151   - 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
  2199 +
  2200 + 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
2152 2201 INNER JOIN organization o on p.hospitalId=o.id
2153 2202 where p.type=3 and p.enable is NULL
2154 2203 <if test="hospitalId != null and hospitalId != ''">
2155 2204  
... ... @@ -2161,13 +2210,13 @@
2161 2210 and p.bookbuildingDate <![CDATA[ <= ]]> #{endDate}
2162 2211 </if>
2163 2212 ) tp
  2213 + INNER JOIN report_antexchu a
  2214 + on tp.patientId=a.sourceId
2164 2215 INNER JOIN
2165 2216 (
2166   - 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
2167   - group by r.foreignId having t=4 and r.type = 2 and r.riskLevel >1
2168   - ) l on tp.patientId=l.sourceId
2169   - INNER JOIN report_matdeliver m on m.sourceId=tp.patientId
2170   - GROUP BY tp.name
  2217 + SELECT r.foreignId,count(r.foreignId) as t,r.type,r.riskLevel from report_risk_level r
  2218 + where r.type = 2 and r.riskLevel >1 group by r.foreignId having t=4
  2219 + ) l on l.foreignId = a.cid GROUP BY tp.name
2171 2220 </select>
2172 2221  
2173 2222 </mapper>