Bladeren bron

历史排班

28169 1 jaar geleden
bovenliggende
commit
58b929cedd

+ 6 - 4
controllers/statistics_api_controller.go Bestand weergeven

@@ -22,6 +22,8 @@ func StatisticsApiRegistRouters() {
22 22
 
23 23
 	beego.Router("/api/qc/patientstatistiscall/get", &StatisticsApiController{}, "get:GetPatientInspectionStatistisc")
24 24
 
25
+	//beego.Router("/api/qc/patientstatistiscall/get", &StatisticsApiController{}, "get:GetPatientInspectionStatistisc")
26
+
25 27
 	//beego.Router("/api/qc/statistiscperson/export", &StatisticsApiController{}, "get:ExportPersonInspectionStatistisc")
26 28
 
27 29
 }
@@ -31,8 +33,8 @@ func (c *StatisticsApiController) GetPatientInspectionStatistisc() {
31 33
 	project_id, _ := c.GetInt64("project_id")
32 34
 	item_id, _ := c.GetInt64("item_id")
33 35
 	item_type, _ := c.GetInt64("item_type")
34
-	order_type, _ := c.GetInt64("order_type")
35
-	keyword := c.GetString("key_word")
36
+	//order_type,  _ := c.GetInt64("order_type")
37
+	keyword := c.GetString("keyword")
36 38
 
37 39
 	timeLayout := "2006-01-02"
38 40
 	loc, _ := time.LoadLocation("Local")
@@ -69,7 +71,7 @@ func (c *StatisticsApiController) GetPatientInspectionStatistisc() {
69 71
 
70 72
 		break
71 73
 	case 1:
72
-		list, _ := service.GetUnusualInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID, max, min, order_type, keyword)
74
+		list, _ := service.GetUnusualInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID, max, min, keyword)
73 75
 		c.ServeSuccessJSON(map[string]interface{}{
74 76
 			"list":      list,
75 77
 			"reference": reference,
@@ -83,7 +85,7 @@ func (c *StatisticsApiController) GetPatientInspectionStatistisc() {
83 85
 		})
84 86
 		break
85 87
 	case 3:
86
-		list, _ := service.GetNormalInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID, max, min, order_type, keyword)
88
+		list, _ := service.GetNormalInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID, max, min, keyword)
87 89
 		c.ServeSuccessJSON(map[string]interface{}{
88 90
 			"list":      list,
89 91
 			"reference": reference,

+ 22 - 0
models/inspection_models.go Bestand weergeven

@@ -16,6 +16,9 @@ type Inspection struct {
16 16
 	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
17 17
 	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
18 18
 	InspectDesc  string `gorm:"column:inspect_desc" json:"inspect_desc" form:"inspect_desc"`
19
+	Name         string `gorm:"-" json:"name" form:"name"`
20
+	DialysisNo   string `gorm:"-" json:"dialysis_no" form:"dialysis_no"`
21
+	Date         string `gorm:"-" json:"date" form:"date"`
19 22
 }
20 23
 
21 24
 func (Inspection) TableName() string {
@@ -194,3 +197,22 @@ type XtCheckRemindCinfig struct {
194 197
 func (XtCheckRemindCinfig) TableName() string {
195 198
 	return "xt_check_remind_config"
196 199
 }
200
+
201
+type XtPatientsTen struct {
202
+	ID              int64  `gorm:"column:id" json:"id" form:"id"`
203
+	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
204
+	UserId          int64  `gorm:"column:user_id" json:"user_id" form:"user_id"`
205
+	Avatar          string `gorm:"column:avatar" json:"avatar" form:"avatar"`
206
+	PatientType     int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
207
+	DialysisNo      string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
208
+	AdmissionNumber string `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
209
+	Source          int64  `gorm:"column:source" json:"source" form:"source"`
210
+	Lapseto         int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
211
+	PartitionId     int64  `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
212
+	BedId           int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
213
+	Name            string `gorm:"column:name" json:"name" form:"name"`
214
+}
215
+
216
+func (XtPatientsTen) TableName() string {
217
+	return "xt_patients"
218
+}

+ 1 - 1
service/patient_dataconfig_service.go Bestand weergeven

@@ -9,7 +9,7 @@ import (
9 9
 
10 10
 func GetPatientByID(orgID int64, patientID int64) (*models.Patients, error) {
11 11
 	var patient models.Patients
12
-	err := readDb.Model(&models.Patients{}).Where("id = ? and user_org_id=? and status=1", patientID, orgID).First(&patient).Error
12
+	err := readDb.Model(&models.Patients{}).Where("id = ? and user_org_id=? and status=1 and lapseto = 1", patientID, orgID).First(&patient).Error
13 13
 	if err != nil {
14 14
 		if err == gorm.ErrRecordNotFound {
15 15
 			return nil, nil

+ 1 - 2
service/patient_service.go Bestand weergeven

@@ -513,10 +513,9 @@ func GetPatientListById(orgID int64, patientId int64) (patients models.PatientLi
513 513
 }
514 514
 
515 515
 func GetPatientCount(orgID int64) (total int64) {
516
-	readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1", orgID).Count(&total)
516
+	readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Count(&total)
517 517
 	return
518 518
 }
519
-
520 519
 func GetLapsetoPatientCount(orgID int64, lapseto int64) (total int64) {
521 520
 	readDb.Model(&models.Patients{}).Where("user_org_id=? and lapseto=? and status=1", orgID, lapseto).Count(&total)
522 521
 	return

+ 25 - 10
service/patientmanage_service.go Bestand weergeven

@@ -1961,7 +1961,7 @@ type InspectionCount struct {
1961 1961
 
1962 1962
 func GetNormalInspectionTotalByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64) (total int64, err error) {
1963 1963
 	var count []*InspectionCount
1964
-	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x  WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE (xti.status = 1) AND (xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` < ? and xti.inspect_value > ? ) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, min_value).Scan(&count).Error
1964
+	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x Join xt_patients pp on pp.id = x.patient_id and pp.lapseto = 1  WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE (xti.status = 1) AND (xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` < ? and xti.inspect_value > ? ) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, min_value).Scan(&count).Error
1965 1965
 	for _, items := range count {
1966 1966
 		total = total + items.Count
1967 1967
 	}
@@ -1969,7 +1969,7 @@ func GetNormalInspectionTotalByID(startime int64, endtime int64, orgid int64, pr
1969 1969
 }
1970 1970
 func GetUnusualInspectionTotalByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64) (total int64, err error) {
1971 1971
 	var count []*InspectionCount
1972
-	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x  WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE   (xti.status = 1 AND xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, orgid, projectid, item_id, startime, endtime, min_value).Scan(&count).Error
1972
+	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x JOIN xt_patients pp on pp.id = x.patient_id and pp.status = 1 and pp.lapseto = 1  WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE   (xti.status = 1 AND xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, orgid, projectid, item_id, startime, endtime, min_value).Scan(&count).Error
1973 1973
 	for _, items := range count {
1974 1974
 		total = total + items.Count
1975 1975
 	}
@@ -1977,12 +1977,12 @@ func GetUnusualInspectionTotalByID(startime int64, endtime int64, orgid int64, p
1977 1977
 }
1978 1978
 
1979 1979
 func GetPatientNotInspectionTotal(startime int64, endtime int64, orgid int64, projectid int64, item_id int64) (total int64, err error) {
1980
-	err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.reference_project_id = ? and pd.reference_item_id = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, projectid, item_id, startime, endtime).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and pd.patient_id IS NULL", orgid).Count(&total).Error
1980
+	err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.reference_project_id = ? and pd.reference_item_id = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, projectid, item_id, startime, endtime).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and pd.patient_id IS NULL and xt_patients.lapseto = 1", orgid).Count(&total).Error
1981 1981
 	return total, err
1982 1982
 }
1983 1983
 
1984 1984
 func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, patient_id int64) (inspections []*models.Inspection, err error) {
1985
-	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Where("x.status = 1")
1985
+	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("xt_patient p On p.id = xt_inspection.patient_id and p.status = 1 and p.lapseto = 1").Where("x.status = 1")
1986 1986
 	if startime > 0 {
1987 1987
 		db = db.Where("x.inspect_date >= ?", startime)
1988 1988
 	}
@@ -2006,15 +2006,30 @@ func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, projec
2006 2006
 	return inspections, err
2007 2007
 }
2008 2008
 
2009
-func GetNormalInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64, order_type int64, keyword string) (xti []*models.Inspection, err error) {
2010
-	err2 := XTReadDB().Table("xt_inspection as xti ").Select("xti.patient_id as patient_id,xti.inspect_date as inspect_date,xti.inspect_value as value").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x  WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE (xti.status = 1) AND (xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` < ? and xti.inspect_value > ? ) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, min_value).Scan(&xti).Error
2009
+func GetNormalInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64, keyword string) (xti []*models.Inspection, err error) {
2010
+	db := XTReadDB().Table("xt_inspection as xti ")
2011
+	if len(keyword) > 0 {
2012
+		keyword = "%" + keyword + "%"
2013
+		db = db.Select("xti.patient_id as patient_id,FROM_UNIXTIME(xti.inspect_date,'%Y-%m-%d') as date,xti.inspect_value as inspect_value,pp.name as name, pp.dialysis_no as dialysis_no").Joins("join xt_patients pp On pp.id = xti.patient_id and pp.status = 1 and pp.lapseto = 1 and name like ?", keyword)
2014
+	} else {
2015
+		db = db.Select("xti.patient_id as patient_id,FROM_UNIXTIME(xti.inspect_date,'%Y-%m-%d') as date,xti.inspect_value as inspect_value,pp.name as name, pp.dialysis_no as dialysis_no").Joins("join xt_patients pp On pp.id = xti.patient_id and pp.status = 1 and pp.lapseto = 1")
2016
+	}
2017
+	err2 := db.Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x  WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE (xti.status = 1) AND (xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` < ? and xti.inspect_value > ? ) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, min_value).Scan(&xti).Error
2011 2018
 	return xti, err2
2012 2019
 }
2013
-func GetUnusualInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64, order_type int64, keyword string) (xti []*models.Inspection, err error) {
2014
-	err2 := XTReadDB().Table("xt_inspection as xti ").Select("xti.patient_id as patient_id,xti.inspect_date as inspect_date,xti.inspect_value as value").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x  WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE   (xti.status = 1 AND xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, orgid, projectid, item_id, startime, endtime, min_value).Scan(&xti).Error
2020
+func GetUnusualInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64, keyword string) (xti []*models.Inspection, err error) {
2021
+	db := XTReadDB().Table("xt_inspection as xti ")
2022
+	if len(keyword) > 0 {
2023
+		keyword = "%" + keyword + "%"
2024
+		db = db.Select("xti.patient_id as patient_id,FROM_UNIXTIME(xti.inspect_date,'%Y-%m-%d') as date,xti.inspect_value as inspect_value,pp.name as name, pp.dialysis_no as dialysis_no").Joins("join xt_patients pp On pp.id = xti.patient_id and pp.status = 1 and pp.lapseto = 1   and name like ?", keyword)
2025
+	} else {
2026
+
2027
+		db = db.Select("xti.patient_id as patient_id,FROM_UNIXTIME(xti.inspect_date,'%Y-%m-%d') as date,xti.inspect_value as inspect_value,pp.name as name, pp.dialysis_no as dialysis_no").Joins("join xt_patients pp On pp.id = xti.patient_id and pp.status = 1 and pp.lapseto = 1 ")
2028
+	}
2029
+	err2 := db.Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x  WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE   (xti.status = 1 AND xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, orgid, projectid, item_id, startime, endtime, min_value).Scan(&xti).Error
2015 2030
 	return xti, err2
2016 2031
 }
2017
-func GetPatientNotInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, keyword string) (patient models.XtPatients, err error) {
2018
-	err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.reference_project_id = ? and pd.reference_item_id = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, projectid, item_id, startime, endtime).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and pd.patient_id IS NULL", orgid).Find(&patient).Error
2032
+func GetPatientNotInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, keyword string) (patient []*models.XtPatientsTen, err error) {
2033
+	err = XTReadDB().Model(models.XtPatientsTen{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.reference_project_id = ? and pd.reference_item_id = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, projectid, item_id, startime, endtime).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and pd.patient_id IS NULL and xt_patients.lapseto = 1", orgid).Find(&patient).Error
2019 2034
 	return patient, err
2020 2035
 }