4 Commits 7eeee314b7 ... a22033eedb

Author SHA1 Message Date
  陈少旭 a22033eedb Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch 1 month ago
  陈少旭 6caa8c02c5 提交代码 1 month ago
  陈少旭 2b52d7bfca 提交代码 1 month ago
  陈少旭 4d78b2dbf5 提交代码 1 month ago

+ 169 - 69
controllers/statistics_api_controller.go View File

@@ -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() {

+ 80 - 0
models/bwfapiao/baiwang.go View File

@@ -0,0 +1,80 @@
1
+package bwfapiao
2
+
3
+// 定义响应结构体
4
+type UnifiedLoginResponse struct {
5
+	Success       bool               `json:"success"`                 // 接口调用成功或失败的标志
6
+	Method        string             `json:"method"`                  // 接口的唯一标识
7
+	RequestId     string             `json:"requestId"`               // 请求唯一标识
8
+	Response      *LoginResponseData `json:"response,omitempty"`      // 业务响应信息
9
+	ErrorResponse *ErrorResponse     `json:"errorResponse,omitempty"` // 错误响应信息
10
+}
11
+
12
+type LoginResponseData struct {
13
+	DigitAccount  string `json:"digitAccount"`  // 数电账号
14
+	LoginType     string `json:"loginType"`     // 登录方式
15
+	BatchNo       string `json:"batchNo"`       // 批次号 (操作类型为2时返回)
16
+	Status        string `json:"status"`        // 状态: 1-成功, 2-进行中, 3-失败
17
+	StatusMessage string `json:"statusMessage"` // 状态描述
18
+	QRCode        string `json:"qrCode"`        // 二维码 (操作类型为2,状态为1时返回)
19
+	QRCodeId      string `json:"qrCodeId"`      // 二维码字符串
20
+	EndTime       string `json:"endTime"`       // 二维码/短信有效期截止时间
21
+}
22
+
23
+type ErrorResponse struct {
24
+	Code       int    `json:"code"`       // 错误码 (开放平台错误码)
25
+	Message    string `json:"message"`    // 错误信息 (开放平台错误信息)
26
+	SubCode    string `json:"subCode"`    // 业务端返回错误码
27
+	SubMessage string `json:"subMessage"` // 业务端返回错误信息
28
+}
29
+
30
+type SEinvoicebasicGetLoginResultResponse struct {
31
+	Success       bool          `json:"success"`       // 接口调用是否成功
32
+	Method        string        `json:"method"`        // 接口的唯一标识
33
+	RequestID     string        `json:"requestId"`     // 请求唯一标识
34
+	Response      LoginResponse `json:"response"`      // 业务响应数据
35
+	ErrorResponse ErrorResponse `json:"errorResponse"` // 错误响应信息
36
+}
37
+
38
+// 登录状态的业务数据
39
+type LoginResponse struct {
40
+	DigitAccount string `json:"digitAccount"` // 数电账号(电子税局实名手机号)
41
+	LoginStatus  string `json:"loginStatus"`  // 登录状态 (0-未登录, 1-已登录, 2-登录中)
42
+	LoginType    string `json:"loginType"`    // 登录方式 (0-账号密码, 1-短信验证码, 2-税务APP扫码, 3-个税APP扫码)
43
+}
44
+
45
+type GetCertifyQrcodeResponse struct {
46
+	Success       bool                  `json:"success"`
47
+	Response      GetCertifyQrcodeData  `json:"response"`
48
+	ErrorResponse GetCertifyQrcodeError `json:"error_response"`
49
+}
50
+
51
+type GetCertifyQrcodeData struct {
52
+	QRCode     string `json:"qrCode"`     // 二维码链接
53
+	ExpireTime string `json:"expireTime"` // 有效期截止时间
54
+}
55
+
56
+type GetCertifyQrcodeError struct {
57
+	Code    int    `json:"code"`
58
+	Message string `json:"message"`
59
+}
60
+
61
+type GetQrcodeCertifyResultResponse struct {
62
+	Success       bool                     `json:"success"`
63
+	Response      QrcodeCertifyResultData  `json:"response"`
64
+	ErrorResponse QrcodeCertifyResultError `json:"error_response"`
65
+}
66
+
67
+type QrcodeCertifyResultData struct {
68
+	TaxNo               string `json:"taxNo"`               // 税号
69
+	DigitAccount        string `json:"digitAccount"`        // 数电账号
70
+	AuthId              string `json:"authId"`              // 认证编号
71
+	CertificationStatus string `json:"certificationStatus"` // 认证状态
72
+	CertStatusMessage   string `json:"certStatusMessage"`   // 状态描述
73
+}
74
+
75
+type QrcodeCertifyResultError struct {
76
+	Code       int    `json:"code"`       // 错误码
77
+	Message    string `json:"message"`    // 错误信息
78
+	SubCode    string `json:"subCode"`    // 子错误码
79
+	SubMessage string `json:"subMessage"` // 子错误信息
80
+}

+ 14 - 1
service/inspection_service.go View File

@@ -288,6 +288,10 @@ func GetInspectionReferenceFour(project_id int64, item_id int64, org_id int64) (
288 288
 	return
289 289
 }
290 290
 
291
+func GetInspectionReferenceFive(project_id int64, item_id int64, org_id int64) (reference models.InspectionReference, err error) {
292
+	err = readDb.Model(&models.InspectionReference{}).Where("project_id = ? and id = ? and status = 1 and org_id = ?", project_id, item_id, 0).Order("project_id").Find(&reference).Error
293
+	return
294
+}
291 295
 func GetInspectionTwo(startime int64, endtime int64, orgid int64, projectid int64, itemid int64) (inspection []*models.Inspection, total int64, err error) {
292 296
 	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
293 297
 	db = db.Where("project_id = ? and item_id = ?", projectid, itemid)
@@ -346,13 +350,22 @@ func GetLastInspectionDetail(patientid int64, date int64, projectid int64, orgid
346 350
 }
347 351
 
348 352
 func GetInsepctionConfigurationList(orgid int64) (standard []*models.QualityControlStandard, err error) {
353
+
349 354
 	db := XTReadDB().Table("xt_quality_control_standard as x").Where("x.status =1")
350
-	db = db.Where("x.user_org_id = ? and x.is_status =1", orgid)
355
+	db = db.Where("x.user_org_id = ? and x.is_status =1", orgid)
351 356
 	err = db.Order("x.sort asc,x.created_time desc").Group("x.id").Select("x.id,x.inspection_major,x.inspection_minor,x.min_range,x.large_range,x.sort,x.user_org_id,x.range_value,x.range_type,s.unit,s.project_name,s.item_name,x.is_status").
352 357
 		Joins("left join xt_inspection_reference as s on s.item_id = x.inspection_minor and s.project_id = x.inspection_major").Where("s.org_id = ? and s.status = 1", orgid).Scan(&standard).Error
353 358
 	return standard, err
354 359
 }
355 360
 
361
+func GetInsepctionConfigurationListTwo(orgid int64) (standard []*models.QualityControlStandard, err error) {
362
+	db := XTReadDB().Table("xt_quality_control_standard as x").Where("x.status =1")
363
+	db = db.Where("x.user_org_id = ? and x.is_status =1", orgid)
364
+	err = db.Order("x.sort asc,x.created_time desc").Group("x.id").Select("x.id,x.inspection_major,x.inspection_minor,x.min_range,x.large_range,x.sort,x.user_org_id,x.range_value,x.range_type,s.unit,s.project_name,s.item_name,x.is_status").
365
+		Joins("left join xt_inspection_reference as s on s.id = x.inspection_minor and s.project_id = x.inspection_major").Where("s.org_id = 0 and s.status = 1").Scan(&standard).Error
366
+	return standard, err
367
+}
368
+
356 369
 func GetInspectionGroup(patient_id int64, org_id int64) (inspection []*models.NewInspection, err error) {
357 370
 
358 371
 	db := XTReadDB().Table("xt_inspection").Where("status =1")

+ 6 - 6
service/statistis_qc_service.go View File

@@ -718,8 +718,8 @@ func GetDialysisCompletionRate(org_id int64, start_time int64, end_time int64) (
718 718
         SELECT
719 719
             CASE
720 720
                 WHEN ABS(TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0))) <= 15 THEN '达到透析处方时间'
721
-                WHEN TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) < -15 THEN '超出处方时间'
722
-                ELSE '未达到处方时间'
721
+                WHEN TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) < -15 THEN '未达到处方时间'
722
+                ELSE '超出处方时间'
723 723
             END AS dialysis_status,
724 724
             COUNT(*) AS count
725 725
         FROM
@@ -845,13 +845,13 @@ func GetDialysisCompletionDetail(org_id int64, start_time int64, end_time int64,
845 845
 	   JOIN
846 846
 	       xt_assessment_after_dislysis a ON o.dialysis_date = a.assessment_date AND o.patient_id = a.patient_id AND a.user_org_id = ?
847 847
 	   WHERE
848
-	       o.stage = 2 AND o.user_org_id = ? AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) < -15
848
+	       o.stage = 2 AND o.user_org_id = ? AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) > 15
849 849
 	`
850 850
 		readDb.Table("xt_dialysis_order o").
851 851
 			Joins("JOIN xt_patients pp ON o.patient_id = pp.id AND pp.user_org_id = ?", org_id).
852 852
 			Joins("JOIN xt_dialysis_prescription p ON o.dialysis_date = p.record_date AND o.patient_id = p.patient_id AND p.user_org_id = ?", org_id).
853 853
 			Joins("JOIN xt_assessment_after_dislysis a ON o.dialysis_date = a.assessment_date AND o.patient_id = a.patient_id AND a.user_org_id = ?", org_id).
854
-			Where("o.stage = 2 AND o.user_org_id = ? AND o.dialysis_date >= ? AND o.dialysis_date <= ? and TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) < 0", org_id, start_time, end_time).Count(&total)
854
+			Where("o.stage = 2 AND o.user_org_id = ? AND o.dialysis_date >= ? AND o.dialysis_date <= ? and TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) > 15", org_id, start_time, end_time).Count(&total)
855 855
 
856 856
 	} else if mode == 3 {
857 857
 		query = `
@@ -874,13 +874,13 @@ func GetDialysisCompletionDetail(org_id int64, start_time int64, end_time int64,
874 874
 	   JOIN
875 875
 	       xt_assessment_after_dislysis a ON o.dialysis_date = a.assessment_date AND o.patient_id = a.patient_id AND a.user_org_id = ?
876 876
 	   WHERE
877
-	       o.stage = 2 AND o.user_org_id = ? AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) > 15
877
+	       o.stage = 2 AND o.user_org_id = ? AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) < -15
878 878
 	`
879 879
 		readDb.Table("xt_dialysis_order o").
880 880
 			Joins("JOIN xt_patients pp ON o.patient_id = pp.id AND pp.user_org_id = ?", org_id).
881 881
 			Joins("JOIN xt_dialysis_prescription p ON o.dialysis_date = p.record_date AND o.patient_id = p.patient_id AND p.user_org_id = ?", org_id).
882 882
 			Joins("JOIN xt_assessment_after_dislysis a ON o.dialysis_date = a.assessment_date AND o.patient_id = a.patient_id AND a.user_org_id = ?", org_id).
883
-			Where("o.stage = 2 AND o.user_org_id = ? AND o.dialysis_date >= ? AND o.dialysis_date <= ? and TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) > 15", org_id, start_time, end_time).Count(&total)
883
+			Where("o.stage = 2 AND o.user_org_id = ? AND o.dialysis_date >= ? AND o.dialysis_date <= ? and TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) < 0", org_id, start_time, end_time).Count(&total)
884 884
 
885 885
 	}
886 886