Browse Source

历史排班

28169 1 year ago
parent
commit
58b929cedd

+ 6 - 4
controllers/statistics_api_controller.go View File

22
 
22
 
23
 	beego.Router("/api/qc/patientstatistiscall/get", &StatisticsApiController{}, "get:GetPatientInspectionStatistisc")
23
 	beego.Router("/api/qc/patientstatistiscall/get", &StatisticsApiController{}, "get:GetPatientInspectionStatistisc")
24
 
24
 
25
+	//beego.Router("/api/qc/patientstatistiscall/get", &StatisticsApiController{}, "get:GetPatientInspectionStatistisc")
26
+
25
 	//beego.Router("/api/qc/statistiscperson/export", &StatisticsApiController{}, "get:ExportPersonInspectionStatistisc")
27
 	//beego.Router("/api/qc/statistiscperson/export", &StatisticsApiController{}, "get:ExportPersonInspectionStatistisc")
26
 
28
 
27
 }
29
 }
31
 	project_id, _ := c.GetInt64("project_id")
33
 	project_id, _ := c.GetInt64("project_id")
32
 	item_id, _ := c.GetInt64("item_id")
34
 	item_id, _ := c.GetInt64("item_id")
33
 	item_type, _ := c.GetInt64("item_type")
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
 	timeLayout := "2006-01-02"
39
 	timeLayout := "2006-01-02"
38
 	loc, _ := time.LoadLocation("Local")
40
 	loc, _ := time.LoadLocation("Local")
69
 
71
 
70
 		break
72
 		break
71
 	case 1:
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
 		c.ServeSuccessJSON(map[string]interface{}{
75
 		c.ServeSuccessJSON(map[string]interface{}{
74
 			"list":      list,
76
 			"list":      list,
75
 			"reference": reference,
77
 			"reference": reference,
83
 		})
85
 		})
84
 		break
86
 		break
85
 	case 3:
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
 		c.ServeSuccessJSON(map[string]interface{}{
89
 		c.ServeSuccessJSON(map[string]interface{}{
88
 			"list":      list,
90
 			"list":      list,
89
 			"reference": reference,
91
 			"reference": reference,

+ 22 - 0
models/inspection_models.go View File

16
 	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
16
 	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
17
 	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
17
 	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
18
 	InspectDesc  string `gorm:"column:inspect_desc" json:"inspect_desc" form:"inspect_desc"`
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
 func (Inspection) TableName() string {
24
 func (Inspection) TableName() string {
194
 func (XtCheckRemindCinfig) TableName() string {
197
 func (XtCheckRemindCinfig) TableName() string {
195
 	return "xt_check_remind_config"
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 View File

9
 
9
 
10
 func GetPatientByID(orgID int64, patientID int64) (*models.Patients, error) {
10
 func GetPatientByID(orgID int64, patientID int64) (*models.Patients, error) {
11
 	var patient models.Patients
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
 	if err != nil {
13
 	if err != nil {
14
 		if err == gorm.ErrRecordNotFound {
14
 		if err == gorm.ErrRecordNotFound {
15
 			return nil, nil
15
 			return nil, nil

+ 1 - 2
service/patient_service.go View File

513
 }
513
 }
514
 
514
 
515
 func GetPatientCount(orgID int64) (total int64) {
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
 	return
517
 	return
518
 }
518
 }
519
-
520
 func GetLapsetoPatientCount(orgID int64, lapseto int64) (total int64) {
519
 func GetLapsetoPatientCount(orgID int64, lapseto int64) (total int64) {
521
 	readDb.Model(&models.Patients{}).Where("user_org_id=? and lapseto=? and status=1", orgID, lapseto).Count(&total)
520
 	readDb.Model(&models.Patients{}).Where("user_org_id=? and lapseto=? and status=1", orgID, lapseto).Count(&total)
522
 	return
521
 	return

+ 25 - 10
service/patientmanage_service.go View File

1961
 
1961
 
1962
 func GetNormalInspectionTotalByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64) (total int64, err error) {
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
 	var count []*InspectionCount
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
 	for _, items := range count {
1965
 	for _, items := range count {
1966
 		total = total + items.Count
1966
 		total = total + items.Count
1967
 	}
1967
 	}
1969
 }
1969
 }
1970
 func GetUnusualInspectionTotalByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64) (total int64, err error) {
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
 	var count []*InspectionCount
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
 	for _, items := range count {
1973
 	for _, items := range count {
1974
 		total = total + items.Count
1974
 		total = total + items.Count
1975
 	}
1975
 	}
1977
 }
1977
 }
1978
 
1978
 
1979
 func GetPatientNotInspectionTotal(startime int64, endtime int64, orgid int64, projectid int64, item_id int64) (total int64, err error) {
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
 	return total, err
1981
 	return total, err
1982
 }
1982
 }
1983
 
1983
 
1984
 func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, patient_id int64) (inspections []*models.Inspection, err error) {
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
 	if startime > 0 {
1986
 	if startime > 0 {
1987
 		db = db.Where("x.inspect_date >= ?", startime)
1987
 		db = db.Where("x.inspect_date >= ?", startime)
1988
 	}
1988
 	}
2006
 	return inspections, err
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
 	return xti, err2
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
 	return xti, err2
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
 	return patient, err
2034
 	return patient, err
2020
 }
2035
 }