|
@@ -4,6 +4,7 @@ import (
|
4
|
4
|
"XT_New/enums"
|
5
|
5
|
"XT_New/models"
|
6
|
6
|
"XT_New/service"
|
|
7
|
+ "XT_New/service/statistics_service"
|
7
|
8
|
"XT_New/utils"
|
8
|
9
|
"fmt"
|
9
|
10
|
"github.com/astaxie/beego"
|
|
@@ -1651,14 +1652,29 @@ func (c *StatisticsApiController) GetDialyzerConfig() {
|
1651
|
1652
|
func (this *StatisticsApiController) GetInsepctionList() {
|
1652
|
1653
|
adminUser := this.GetAdminUserInfo()
|
1653
|
1654
|
orgid := adminUser.CurrentOrgId
|
1654
|
|
- configurationlist, err := service.GetInsepctionConfigurationList(orgid)
|
1655
|
|
- if err != nil {
|
1656
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
1657
|
|
- return
|
|
1655
|
+ count, _ := statistics_service.FindOrgInspectionCount(orgid)
|
|
1656
|
+ if count <= 0 {
|
|
1657
|
+ configurationlist, err := service.GetInsepctionConfigurationListTwo(orgid)
|
|
1658
|
+ if err != nil {
|
|
1659
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
1660
|
+ return
|
|
1661
|
+ }
|
|
1662
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1663
|
+ "configurationlist": configurationlist,
|
|
1664
|
+ })
|
|
1665
|
+
|
|
1666
|
+ } else {
|
|
1667
|
+ configurationlist, err := service.GetInsepctionConfigurationList(orgid)
|
|
1668
|
+ if err != nil {
|
|
1669
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
1670
|
+ return
|
|
1671
|
+ }
|
|
1672
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
1673
|
+ "configurationlist": configurationlist,
|
|
1674
|
+ })
|
|
1675
|
+
|
1658
|
1676
|
}
|
1659
|
|
- this.ServeSuccessJSON(map[string]interface{}{
|
1660
|
|
- "configurationlist": configurationlist,
|
1661
|
|
- })
|
|
1677
|
+
|
1662
|
1678
|
}
|
1663
|
1679
|
func (c *StatisticsApiController) GetAllCommonInspectionStatistisc() {
|
1664
|
1680
|
start_date := c.GetString("start_date")
|
|
@@ -1691,26 +1707,57 @@ func (c *StatisticsApiController) GetAllCommonInspectionStatistisc() {
|
1691
|
1707
|
|
1692
|
1708
|
//患者总数
|
1693
|
1709
|
patientCount := service.GetPatientCount(c.GetAdminUserInfo().CurrentOrgId)
|
1694
|
|
- //获取配置
|
1695
|
|
- reference, _ := service.GetInspectionReferenceFour(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
1696
|
|
- //获取数值在正常范围内的总数
|
1697
|
|
- config, _ := service.GetConfigurationById(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
1698
|
|
- max, _ := strconv.ParseFloat(config.LargeRange, 64)
|
1699
|
|
- min, _ := strconv.ParseFloat(config.MinRange, 64)
|
1700
|
|
-
|
1701
|
|
- normalTotal, _ := service.GetNormalInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName, max, min)
|
1702
|
|
- //获取数值异常的总数
|
1703
|
|
- unusualTotal, _ := service.GetUnusualInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName, max, min)
|
1704
|
|
- //获取没有检查的患者总数
|
1705
|
|
- noCheckTotal, _ := service.GetPatientNotInspectionTotal(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName)
|
1706
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1707
|
|
- "patient_count": patientCount,
|
1708
|
|
- "normal_total": normalTotal,
|
1709
|
|
- "unusual_total": unusualTotal,
|
1710
|
|
- "no_check_total": noCheckTotal,
|
1711
|
|
- "reference": reference,
|
1712
|
|
- "config": config,
|
1713
|
|
- })
|
|
1710
|
+
|
|
1711
|
+ count, _ := statistics_service.FindOrgInspectionCount(c.GetAdminUserInfo().CurrentOrgId)
|
|
1712
|
+
|
|
1713
|
+ if count <= 0 {
|
|
1714
|
+
|
|
1715
|
+ //获取配置
|
|
1716
|
+ reference, _ := service.GetInspectionReferenceFive(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
1717
|
+ //获取数值在正常范围内的总数
|
|
1718
|
+ config, _ := service.GetConfigurationById(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
1719
|
+ max, _ := strconv.ParseFloat(config.LargeRange, 64)
|
|
1720
|
+ min, _ := strconv.ParseFloat(config.MinRange, 64)
|
|
1721
|
+
|
|
1722
|
+ normalTotal, _ := service.GetNormalInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName, max, min)
|
|
1723
|
+ //获取数值异常的总数
|
|
1724
|
+ unusualTotal, _ := service.GetUnusualInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName, max, min)
|
|
1725
|
+ //获取没有检查的患者总数
|
|
1726
|
+ noCheckTotal, _ := service.GetPatientNotInspectionTotal(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName)
|
|
1727
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1728
|
+ "patient_count": patientCount,
|
|
1729
|
+ "normal_total": normalTotal,
|
|
1730
|
+ "unusual_total": unusualTotal,
|
|
1731
|
+ "no_check_total": noCheckTotal,
|
|
1732
|
+ "reference": reference,
|
|
1733
|
+ "config": config,
|
|
1734
|
+ })
|
|
1735
|
+
|
|
1736
|
+ } else {
|
|
1737
|
+
|
|
1738
|
+ //获取配置
|
|
1739
|
+ reference, _ := service.GetInspectionReferenceFour(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
1740
|
+
|
|
1741
|
+ //获取数值在正常范围内的总数
|
|
1742
|
+ config, _ := service.GetConfigurationById(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
1743
|
+ max, _ := strconv.ParseFloat(config.LargeRange, 64)
|
|
1744
|
+ min, _ := strconv.ParseFloat(config.MinRange, 64)
|
|
1745
|
+
|
|
1746
|
+ normalTotal, _ := service.GetNormalInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName, max, min)
|
|
1747
|
+ //获取数值异常的总数
|
|
1748
|
+ unusualTotal, _ := service.GetUnusualInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName, max, min)
|
|
1749
|
+ //获取没有检查的患者总数
|
|
1750
|
+ noCheckTotal, _ := service.GetPatientNotInspectionTotal(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName)
|
|
1751
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1752
|
+ "patient_count": patientCount,
|
|
1753
|
+ "normal_total": normalTotal,
|
|
1754
|
+ "unusual_total": unusualTotal,
|
|
1755
|
+ "no_check_total": noCheckTotal,
|
|
1756
|
+ "reference": reference,
|
|
1757
|
+ "config": config,
|
|
1758
|
+ })
|
|
1759
|
+
|
|
1760
|
+ }
|
1714
|
1761
|
|
1715
|
1762
|
}
|
1716
|
1763
|
func (c *StatisticsApiController) GetPersonCommonInspectionStatistisc() {
|
|
@@ -1743,18 +1790,35 @@ func (c *StatisticsApiController) GetPersonCommonInspectionStatistisc() {
|
1743
|
1790
|
endTime = theTime.Unix()
|
1744
|
1791
|
}
|
1745
|
1792
|
|
1746
|
|
- patient, _ := service.GetFaPiaoPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
|
1747
|
|
- config, _ := service.GetConfigurationById(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
1793
|
+ count, _ := statistics_service.FindOrgInspectionCount(c.GetAdminUserInfo().CurrentOrgId)
|
|
1794
|
+ if count <= 0 {
|
|
1795
|
+ patient, _ := service.GetFaPiaoPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
|
|
1796
|
+ config, _ := service.GetConfigurationById(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
1797
|
+ //获取配置
|
|
1798
|
+ reference, _ := service.GetInspectionReferenceFive(config.InspectionMajor, config.InspectionMinor, c.GetAdminUserInfo().CurrentOrgId)
|
|
1799
|
+ //获取数值在正常范围内的总数
|
|
1800
|
+ inspections, _ := service.GetPatientInspectionByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, patient_id, reference.ItemName)
|
|
1801
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1802
|
+ "patient": patient,
|
|
1803
|
+ "reference": reference,
|
|
1804
|
+ "inspections": inspections,
|
|
1805
|
+ })
|
1748
|
1806
|
|
1749
|
|
- //获取配置
|
1750
|
|
- reference, _ := service.GetInspectionReferenceFour(config.InspectionMajor, config.InspectionMinor, c.GetAdminUserInfo().CurrentOrgId)
|
1751
|
|
- //获取数值在正常范围内的总数
|
1752
|
|
- inspections, _ := service.GetPatientInspectionByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, patient_id, reference.ItemName)
|
1753
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1754
|
|
- "patient": patient,
|
1755
|
|
- "reference": reference,
|
1756
|
|
- "inspections": inspections,
|
1757
|
|
- })
|
|
1807
|
+ } else {
|
|
1808
|
+
|
|
1809
|
+ patient, _ := service.GetFaPiaoPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
|
|
1810
|
+ config, _ := service.GetConfigurationById(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
1811
|
+
|
|
1812
|
+ //获取配置
|
|
1813
|
+ reference, _ := service.GetInspectionReferenceFour(config.InspectionMajor, config.InspectionMinor, c.GetAdminUserInfo().CurrentOrgId)
|
|
1814
|
+ //获取数值在正常范围内的总数
|
|
1815
|
+ inspections, _ := service.GetPatientInspectionByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, patient_id, reference.ItemName)
|
|
1816
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1817
|
+ "patient": patient,
|
|
1818
|
+ "reference": reference,
|
|
1819
|
+ "inspections": inspections,
|
|
1820
|
+ })
|
|
1821
|
+ }
|
1758
|
1822
|
|
1759
|
1823
|
}
|
1760
|
1824
|
func (c *StatisticsApiController) GetPatientCommonInspectionStatistisc() {
|
|
@@ -1787,41 +1851,77 @@ func (c *StatisticsApiController) GetPatientCommonInspectionStatistisc() {
|
1787
|
1851
|
endTime = theTime.Unix()
|
1788
|
1852
|
}
|
1789
|
1853
|
|
1790
|
|
- //获取配置
|
1791
|
|
- reference, _ := service.GetInspectionReferenceFour(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
1792
|
|
- //获取数值在正常范围内的总数
|
|
1854
|
+ count, _ := statistics_service.FindOrgInspectionCount(c.GetAdminUserInfo().CurrentOrgId)
|
|
1855
|
+ if count <= 0 {
|
|
1856
|
+ //获取配置
|
|
1857
|
+ reference, _ := service.GetInspectionReferenceFive(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
1858
|
+ //获取数值在正常范围内的总数
|
1793
|
1859
|
|
1794
|
|
- config, _ := service.GetConfigurationById(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
1795
|
|
- max, _ := strconv.ParseFloat(config.LargeRange, 64)
|
1796
|
|
- min, _ := strconv.ParseFloat(config.MinRange, 64)
|
|
1860
|
+ config, _ := service.GetConfigurationById(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
1861
|
+ max, _ := strconv.ParseFloat(config.LargeRange, 64)
|
|
1862
|
+ min, _ := strconv.ParseFloat(config.MinRange, 64)
|
1797
|
1863
|
|
1798
|
|
- //max, _ := strconv.ParseFloat(reference.RangeMax, 64)
|
1799
|
|
- //min, _ := strconv.ParseFloat(reference.RangeMin, 64)
|
1800
|
|
- //config, _ := service.GetConfigurationById(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
1864
|
+ switch item_type {
|
|
1865
|
+ case 1:
|
|
1866
|
+ list, _ := service.GetUnusualInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName, max, min, keyword)
|
|
1867
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1868
|
+ "list": list,
|
|
1869
|
+ "reference": reference,
|
|
1870
|
+ })
|
|
1871
|
+ break
|
|
1872
|
+ case 2:
|
|
1873
|
+ list, _ := service.GetPatientNotInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName, keyword)
|
|
1874
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1875
|
+ "list": list,
|
|
1876
|
+ "reference": reference,
|
|
1877
|
+ })
|
|
1878
|
+ break
|
|
1879
|
+ case 3:
|
|
1880
|
+ list, _ := service.GetNormalInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName, max, min, keyword)
|
|
1881
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1882
|
+ "list": list,
|
|
1883
|
+ "reference": reference,
|
|
1884
|
+ })
|
|
1885
|
+ break
|
|
1886
|
+ }
|
1801
|
1887
|
|
1802
|
|
- switch item_type {
|
1803
|
|
- case 1:
|
1804
|
|
- list, _ := service.GetUnusualInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName, max, min, keyword)
|
1805
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1806
|
|
- "list": list,
|
1807
|
|
- "reference": reference,
|
1808
|
|
- })
|
1809
|
|
- break
|
1810
|
|
- case 2:
|
1811
|
|
- list, _ := service.GetPatientNotInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName, keyword)
|
1812
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1813
|
|
- "list": list,
|
1814
|
|
- "reference": reference,
|
1815
|
|
- })
|
1816
|
|
- break
|
1817
|
|
- case 3:
|
1818
|
|
- list, _ := service.GetNormalInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName, max, min, keyword)
|
1819
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1820
|
|
- "list": list,
|
1821
|
|
- "reference": reference,
|
1822
|
|
- })
|
1823
|
|
- break
|
|
1888
|
+ } else {
|
|
1889
|
+
|
|
1890
|
+ //获取配置
|
|
1891
|
+ reference, _ := service.GetInspectionReferenceFour(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
1892
|
+ //获取数值在正常范围内的总数
|
|
1893
|
+
|
|
1894
|
+ config, _ := service.GetConfigurationById(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
1895
|
+ max, _ := strconv.ParseFloat(config.LargeRange, 64)
|
|
1896
|
+ min, _ := strconv.ParseFloat(config.MinRange, 64)
|
|
1897
|
+ //max, _ := strconv.ParseFloat(reference.RangeMax, 64)
|
|
1898
|
+ //min, _ := strconv.ParseFloat(reference.RangeMin, 64)
|
|
1899
|
+ //config, _ := service.GetConfigurationById(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
1900
|
+ switch item_type {
|
|
1901
|
+ case 1:
|
|
1902
|
+ list, _ := service.GetUnusualInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName, max, min, keyword)
|
|
1903
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1904
|
+ "list": list,
|
|
1905
|
+ "reference": reference,
|
|
1906
|
+ })
|
|
1907
|
+ break
|
|
1908
|
+ case 2:
|
|
1909
|
+ list, _ := service.GetPatientNotInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName, keyword)
|
|
1910
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1911
|
+ "list": list,
|
|
1912
|
+ "reference": reference,
|
|
1913
|
+ })
|
|
1914
|
+ break
|
|
1915
|
+ case 3:
|
|
1916
|
+ list, _ := service.GetNormalInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.ItemName, max, min, keyword)
|
|
1917
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1918
|
+ "list": list,
|
|
1919
|
+ "reference": reference,
|
|
1920
|
+ })
|
|
1921
|
+ break
|
|
1922
|
+ }
|
1824
|
1923
|
}
|
|
1924
|
+
|
1825
|
1925
|
}
|
1826
|
1926
|
|
1827
|
1927
|
func (c *StatisticsApiController) GetFivePatientInspectionStatistisc() {
|