浏览代码

患者检验检查统计开发

XMLWAN 5 年前
父节点
当前提交
d1354fbf9c

+ 11 - 7
controllers/new_mobile_api_controllers/common_api_controller.go 查看文件

1287
 	limit, _ := this.GetInt64("limit")
1287
 	limit, _ := this.GetInt64("limit")
1288
 	fmt.Println("limit", limit)
1288
 	fmt.Println("limit", limit)
1289
 	patients, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
1289
 	patients, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
1290
-	fmt.Println("============================================================")
1290
+	//统计非传染病类型
1291
 	control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1291
 	control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1292
-	//获取最后一次数据
1292
+	//统计传染病类型
1293
+	infectiousControl, err := service.GetInfectiousControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1293
 
1294
 
1294
 	if err != nil {
1295
 	if err != nil {
1295
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1296
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1297
 	}
1298
 	}
1298
 
1299
 
1299
 	this.ServeSuccessJSON(map[string]interface{}{
1300
 	this.ServeSuccessJSON(map[string]interface{}{
1300
-		"patients": patients,
1301
-		"total":    total,
1302
-		"control":  control,
1301
+		"patients":          patients,
1302
+		"total":             total,
1303
+		"control":           control,
1304
+		"infectiousControl": infectiousControl,
1303
 	})
1305
 	})
1304
 }
1306
 }
1305
 
1307
 
1323
 	limit, _ := this.GetInt64("limit")
1325
 	limit, _ := this.GetInt64("limit")
1324
 	page, _ := this.GetInt64("page")
1326
 	page, _ := this.GetInt64("page")
1325
 	cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1327
 	cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1328
+	infectiouscontrol, err := service.GetInfectiousPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1326
 	_, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
1329
 	_, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
1327
 	if err != nil {
1330
 	if err != nil {
1328
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1331
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1330
 	}
1333
 	}
1331
 
1334
 
1332
 	this.ServeSuccessJSON(map[string]interface{}{
1335
 	this.ServeSuccessJSON(map[string]interface{}{
1333
-		"cartogramlist": cartogramlist,
1334
-		"total":         total,
1336
+		"cartogramlist":     cartogramlist,
1337
+		"total":             total,
1338
+		"infectiouscontrol": infectiouscontrol,
1335
 	})
1339
 	})
1336
 }
1340
 }
1337
 
1341
 

+ 11 - 7
controllers/new_mobile_api_controllers/new_common_api_controller.go 查看文件

828
 
828
 
829
 	control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
829
 	control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
830
 	//获取最后一次数据
830
 	//获取最后一次数据
831
-
831
+	//统计传染病类型
832
+	infectiousControl, err := service.GetInfectiousControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
832
 	if err != nil {
833
 	if err != nil {
833
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
834
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
834
 		return
835
 		return
835
 	}
836
 	}
836
 
837
 
837
 	this.ServeSuccessJSON(map[string]interface{}{
838
 	this.ServeSuccessJSON(map[string]interface{}{
838
-		"patients": patients,
839
-		"total":    total,
840
-		"control":  control,
839
+		"patients":          patients,
840
+		"total":             total,
841
+		"control":           control,
842
+		"infectiousControl": infectiousControl,
841
 	})
843
 	})
842
 }
844
 }
843
 
845
 
861
 	page, _ := this.GetInt64("page")
863
 	page, _ := this.GetInt64("page")
862
 	cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
864
 	cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
863
 	_, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
865
 	_, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
866
+	infectiouscontrol, err := service.GetInfectiousPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
864
 	if err != nil {
867
 	if err != nil {
865
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
868
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
866
 		return
869
 		return
867
 	}
870
 	}
868
 
871
 
869
 	this.ServeSuccessJSON(map[string]interface{}{
872
 	this.ServeSuccessJSON(map[string]interface{}{
870
-		"cartogramlist": cartogramlist,
871
-		"total":         total,
873
+		"cartogramlist":     cartogramlist,
874
+		"total":             total,
875
+		"infectiouscontrol": infectiouscontrol,
872
 	})
876
 	})
873
 }
877
 }
874
 
878
 
915
 	endtimeStrsUnix := endtimeStrs.Unix()
919
 	endtimeStrsUnix := endtimeStrs.Unix()
916
 	fmt.Println("结束时间搓", endtimeStrsUnix)
920
 	fmt.Println("结束时间搓", endtimeStrsUnix)
917
 	control, err := service.GetLastPatientsControlTwo(orgid, id, startimeStrUnix, endtimeStrsUnix)
921
 	control, err := service.GetLastPatientsControlTwo(orgid, id, startimeStrUnix, endtimeStrsUnix)
922
+
918
 	if err != nil {
923
 	if err != nil {
919
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
924
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
920
 		return
925
 		return
921
 	}
926
 	}
922
 
927
 
923
 	this.ServeSuccessJSON(map[string]interface{}{
928
 	this.ServeSuccessJSON(map[string]interface{}{
924
-
925
 		"control": control,
929
 		"control": control,
926
 	})
930
 	})
927
 }
931
 }

+ 3 - 0
models/common_models.go 查看文件

419
 	DialysisNo   string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
419
 	DialysisNo   string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
420
 	RangeValue   string `gorm:"column:range_value" json:"range_value" form:"range_value"`
420
 	RangeValue   string `gorm:"column:range_value" json:"range_value" form:"range_value"`
421
 	Sort         int64  `gorm:"column:sort" json:"sort" form:"sort"`
421
 	Sort         int64  `gorm:"column:sort" json:"sort" form:"sort"`
422
+	LargeRange   string `gorm:"column:large_range" json:"large_range" form:"large_range"`
423
+	MinRange     string `gorm:"column:min_range" json:"min_range" form:"min_range"`
424
+	RangeType    int64  `gorm:"column:range_type" json:"range_type" form:"range_type"`
422
 }
425
 }
423
 
426
 
424
 func (PatientInspectionCount) TableName() string {
427
 func (PatientInspectionCount) TableName() string {

+ 70 - 6
service/common_service.go 查看文件

59
 	table := XTReadDB().Table("xt_inspection_reference as s")
59
 	table := XTReadDB().Table("xt_inspection_reference as s")
60
 	fmt.Println(table)
60
 	fmt.Println(table)
61
 	offset := (page - 1) * limit
61
 	offset := (page - 1) * limit
62
-	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,s.unit,s.project_name,s.item_name").Count(&total).
62
+	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").Count(&total).
63
 		Joins("left join xt_inspection_reference as s on s.id = x.inspection_minor").Offset(offset).Limit(limit).Scan(&standard).Error
63
 		Joins("left join xt_inspection_reference as s on s.id = x.inspection_minor").Offset(offset).Limit(limit).Scan(&standard).Error
64
 	return standard, total, err
64
 	return standard, total, err
65
 }
65
 }
301
 
301
 
302
 	db := XTReadDB().Table("xt_dialysis_order as o")
302
 	db := XTReadDB().Table("xt_dialysis_order as o")
303
 
303
 
304
-	err = db.Raw("select count(o.id) as count,o.patient_id from xt_dialysis_order as o where o.status = 1 and o.dialysis_date>=? and o.dialysis_date<=? and o.user_org_id = ?", startime, endtime, orgid).Group("o.patient_id").Scan(&order).Error
304
+	err = db.Raw("select count(o.id) as count,o.patient_id from xt_dialysis_order as o left join xt_schedule AS x ON x.patient_id = o.patient_id   where o.status = 1 and o.dialysis_date>=? and o.dialysis_date<=? and o.user_org_id = ? and x.schedule_date = o.dialysis_date and x.status = 1", startime, endtime, orgid).Group("o.patient_id").Scan(&order).Error
305
 	return order, err
305
 	return order, err
306
 }
306
 }
307
 
307
 
584
 		db = db.Where("x.inspect_date <=?", endtime)
584
 		db = db.Where("x.inspect_date <=?", endtime)
585
 	}
585
 	}
586
 
586
 
587
-	err = db.Select("count(distinct x.inspect_date) as count,x.patient_id,x.project_id,r.project_name,t.inspection_frequency").Joins("left join xt_check_configuration as t on t.inspection_major = x.project_id").Joins("left  join xt_inspection_reference as r on r.project_id = x.project_id").Group("project_id,patient_id").Scan(&projectCounts).Error
587
+	err = db.Select("count(distinct x.inspect_date) as count,x.patient_id,x.project_id,r.project_name,t.inspection_frequency,t.sort").Joins("left join xt_check_configuration as t on t.inspection_major = x.project_id").Joins("left  join xt_inspection_reference as r on r.project_id = x.project_id").Group("project_id,patient_id").Scan(&projectCounts).Error
588
 	return
588
 	return
589
 }
589
 }
590
 
590
 
2332
 	d2 := readDb.Table("xt_quality_control_standard as d")
2332
 	d2 := readDb.Table("xt_quality_control_standard as d")
2333
 	fmt.Println("d2", d2)
2333
 	fmt.Println("d2", d2)
2334
 	if orgid > 0 {
2334
 	if orgid > 0 {
2335
-		db = db.Where("x.org_id = ? and x.inspect_value <> 0", orgid)
2335
+		db = db.Where("x.org_id = ? and x.inspect_value+0 <> 0 and x.inspect_type = 1", orgid)
2336
 	}
2336
 	}
2337
 	if lapstor == 0 {
2337
 	if lapstor == 0 {
2338
 		table = table.Where("s.lapseto = 1 or s.lapseto = 2")
2338
 		table = table.Where("s.lapseto = 1 or s.lapseto = 2")
2350
 	if endtime > 0 {
2350
 	if endtime > 0 {
2351
 		db = db.Where("x.inspect_date <=?", endtime)
2351
 		db = db.Where("x.inspect_date <=?", endtime)
2352
 	}
2352
 	}
2353
-	err = db.Group("x.id").Select("x.id,x.patient_id,x.item_id,x.item_name,x.inspect_value,x.inspect_date,s.name,s.dialysis_no,r.range_max,r.range_min,d.sort").Joins("left join xt_patients as s on s.id = x.patient_id").Joins("left join xt_inspection_reference as r on r.item_id = x.item_id AND r.org_id > 0 OR ( x.item_id = r.id AND r.org_id = 0)").Joins("left join xt_quality_control_standard as d on d.inspection_minor = x.item_id").Order("x.inspect_date desc").Scan(&inspection).Error
2353
+	err = db.Group("x.id").Select("x.id,x.patient_id,x.item_id,x.item_name,x.inspect_value,x.inspect_date,s.name,s.dialysis_no,r.range_max,r.range_min,d.sort,d.min_range,d.large_range,d.range_value,d.range_type").Joins("left join xt_patients as s on s.id = x.patient_id").Joins("left join xt_inspection_reference as r on r.item_id = x.item_id AND r.org_id > 0 OR ( x.item_id = r.id AND r.org_id = 0)").Joins("left join xt_quality_control_standard as d on d.inspection_minor = x.item_id").Order("x.inspect_date desc").Scan(&inspection).Error
2354
+
2355
+	return inspection, err
2356
+}
2357
+
2358
+func GetInfectiousPatientsControl(orgid int64, lapstor int64, startime int64, endtime int64) (inspection []*models.PatientInspectionCount, err error) {
2359
+	db := readDb.Table("xt_inspection as x").Where("x.status =1")
2360
+	table := readDb.Table("xt_patients as s")
2361
+	fmt.Println(table)
2362
+	d := readDb.Table(" xt_inspection_reference as r")
2363
+	fmt.Println(d)
2364
+	d2 := readDb.Table("xt_quality_control_standard as d")
2365
+	fmt.Println("d2", d2)
2366
+	if orgid > 0 {
2367
+		db = db.Where("x.org_id = ? and x.inspect_value <> '' and x.inspect_type = 2", orgid)
2368
+	}
2369
+	if lapstor == 0 {
2370
+		table = table.Where("s.lapseto = 1 or s.lapseto = 2")
2371
+	}
2372
+
2373
+	if lapstor == 1 {
2374
+		table = table.Where("s.lapseto = 1")
2375
+	}
2376
+	if lapstor == 2 {
2377
+		table = table.Where("s.lapseto = 2")
2378
+	}
2379
+	if startime > 0 {
2380
+		db = db.Where("x.inspect_date >=?", startime)
2381
+	}
2382
+	if endtime > 0 {
2383
+		db = db.Where("x.inspect_date <=?", endtime)
2384
+	}
2385
+	err = db.Group("x.id").Select("x.id,x.patient_id,x.item_id,x.item_name,x.inspect_value,x.inspect_date,s.name,s.dialysis_no,r.range_max,r.range_min,d.sort,d.min_range,d.large_range,d.range_value,d.range_type").Joins("left join xt_patients as s on s.id = x.patient_id").Joins("left join xt_inspection_reference as r on r.item_id = x.item_id AND r.org_id > 0 OR ( x.item_id = r.id AND r.org_id = 0)").Joins("left join xt_quality_control_standard as d on d.inspection_minor = x.item_id").Order("x.inspect_date desc").Scan(&inspection).Error
2386
+
2387
+	return inspection, err
2388
+}
2389
+
2390
+func GetInfectiousControl(orgid int64, lapstor int64, startime int64, endtime int64) (inspection []*models.PatientInspectionCount, err error) {
2391
+	db := readDb.Table("xt_inspection as x").Where("x.status =1")
2392
+	table := readDb.Table("xt_patients as s")
2393
+	fmt.Println(table)
2394
+	d := readDb.Table(" xt_inspection_reference as r")
2395
+	fmt.Println(d)
2396
+	d2 := readDb.Table("xt_quality_control_standard as d")
2397
+	fmt.Println("d2", d2)
2398
+	if orgid > 0 {
2399
+		db = db.Where("x.org_id = ? and x.inspect_value <> '' and x.inspect_type = 2", orgid)
2400
+	}
2401
+	if lapstor == 0 {
2402
+		table = table.Where("s.lapseto = 1 or s.lapseto = 2")
2403
+	}
2404
+
2405
+	if lapstor == 1 {
2406
+		table = table.Where("s.lapseto = 1")
2407
+	}
2408
+	if lapstor == 2 {
2409
+		table = table.Where("s.lapseto = 2")
2410
+	}
2411
+	if startime > 0 {
2412
+		db = db.Where("x.inspect_date >=?", startime)
2413
+	}
2414
+	if endtime > 0 {
2415
+		db = db.Where("x.inspect_date <=?", endtime)
2416
+	}
2417
+	err = db.Group("x.id").Select("x.id,x.patient_id,x.item_id,x.item_name,x.inspect_value,x.inspect_date,s.name,s.dialysis_no,r.range_max,r.range_min,d.sort,d.min_range,d.large_range,d.range_value,d.range_type").Joins("left join xt_patients as s on s.id = x.patient_id").Joins("left join xt_inspection_reference as r on r.item_id = x.item_id AND r.org_id > 0 OR ( x.item_id = r.id AND r.org_id = 0)").Joins("left join xt_quality_control_standard as d on d.inspection_minor = x.item_id").Order("x.inspect_date desc").Scan(&inspection).Error
2354
 
2418
 
2355
 	return inspection, err
2419
 	return inspection, err
2356
 }
2420
 }
2484
 	if endtime > 0 {
2548
 	if endtime > 0 {
2485
 		db = db.Where("x.inspect_date <=?", endtime)
2549
 		db = db.Where("x.inspect_date <=?", endtime)
2486
 	}
2550
 	}
2487
-	err = db.Group("x.id").Select("x.id,x.patient_id,x.item_id,x.item_name,x.inspect_value,x.inspect_date,s.name,s.dialysis_no,r.range_max,r.range_min,d.sort").Joins("left join xt_patients as s on s.id = x.patient_id").Joins("left join xt_inspection_reference as r on r.id = x.item_id").Joins("left join xt_quality_control_standard as d on d.inspection_minor = x.item_id").Order("x.inspect_date desc").Scan(&inspection).Error
2551
+	err = db.Group("x.id").Select("x.id,x.patient_id,x.item_id,x.item_name,x.inspect_value,x.inspect_date,s.name,s.dialysis_no,r.range_max,r.range_min,d.sort,d.large_range,d.min_range,d.range_type").Joins("left join xt_patients as s on s.id = x.patient_id").Joins("left join xt_inspection_reference as r on r.id = x.item_id").Joins("left join xt_quality_control_standard as d on d.inspection_minor = x.item_id").Order("x.inspect_date desc").Scan(&inspection).Error
2488
 
2552
 
2489
 	return inspection, err
2553
 	return inspection, err
2490
 }
2554
 }