Ver código fonte

患者检验检查统计开发

XMLWAN 4 anos atrás
pai
commit
d1354fbf9c

+ 11 - 7
controllers/new_mobile_api_controllers/common_api_controller.go Ver arquivo

@@ -1287,9 +1287,10 @@ func (this *CommonApiController) GetPatientscontrol() {
1287 1287
 	limit, _ := this.GetInt64("limit")
1288 1288
 	fmt.Println("limit", limit)
1289 1289
 	patients, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
1290
-	fmt.Println("============================================================")
1290
+	//统计非传染病类型
1291 1291
 	control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1292
-	//获取最后一次数据
1292
+	//统计传染病类型
1293
+	infectiousControl, err := service.GetInfectiousControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1293 1294
 
1294 1295
 	if err != nil {
1295 1296
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -1297,9 +1298,10 @@ func (this *CommonApiController) GetPatientscontrol() {
1297 1298
 	}
1298 1299
 
1299 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,6 +1325,7 @@ func (this *CommonApiController) GetCartogramList() {
1323 1325
 	limit, _ := this.GetInt64("limit")
1324 1326
 	page, _ := this.GetInt64("page")
1325 1327
 	cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1328
+	infectiouscontrol, err := service.GetInfectiousPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1326 1329
 	_, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
1327 1330
 	if err != nil {
1328 1331
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -1330,8 +1333,9 @@ func (this *CommonApiController) GetCartogramList() {
1330 1333
 	}
1331 1334
 
1332 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 Ver arquivo

@@ -828,16 +828,18 @@ func (this *NewCommonApiController) GetMobilePatientControl() {
828 828
 
829 829
 	control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
830 830
 	//获取最后一次数据
831
-
831
+	//统计传染病类型
832
+	infectiousControl, err := service.GetInfectiousControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
832 833
 	if err != nil {
833 834
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
834 835
 		return
835 836
 	}
836 837
 
837 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,14 +863,16 @@ func (this *NewCommonApiController) GetMobileCartogramlist() {
861 863
 	page, _ := this.GetInt64("page")
862 864
 	cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
863 865
 	_, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
866
+	infectiouscontrol, err := service.GetInfectiousPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
864 867
 	if err != nil {
865 868
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
866 869
 		return
867 870
 	}
868 871
 
869 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,13 +919,13 @@ func (this *NewCommonApiController) GetSeachPatientsControl() {
915 919
 	endtimeStrsUnix := endtimeStrs.Unix()
916 920
 	fmt.Println("结束时间搓", endtimeStrsUnix)
917 921
 	control, err := service.GetLastPatientsControlTwo(orgid, id, startimeStrUnix, endtimeStrsUnix)
922
+
918 923
 	if err != nil {
919 924
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
920 925
 		return
921 926
 	}
922 927
 
923 928
 	this.ServeSuccessJSON(map[string]interface{}{
924
-
925 929
 		"control": control,
926 930
 	})
927 931
 }

+ 3 - 0
models/common_models.go Ver arquivo

@@ -419,6 +419,9 @@ type PatientInspectionCount struct {
419 419
 	DialysisNo   string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
420 420
 	RangeValue   string `gorm:"column:range_value" json:"range_value" form:"range_value"`
421 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 427
 func (PatientInspectionCount) TableName() string {

+ 70 - 6
service/common_service.go Ver arquivo

@@ -59,7 +59,7 @@ func GetConfigurationlist(orgid int64, limit int64, page int64) (standard []*mod
59 59
 	table := XTReadDB().Table("xt_inspection_reference as s")
60 60
 	fmt.Println(table)
61 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 63
 		Joins("left join xt_inspection_reference as s on s.id = x.inspection_minor").Offset(offset).Limit(limit).Scan(&standard).Error
64 64
 	return standard, total, err
65 65
 }
@@ -301,7 +301,7 @@ func TotalDialysisCount(startime int64, endtime int64, orgid int64) (order []*mo
301 301
 
302 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 305
 	return order, err
306 306
 }
307 307
 
@@ -584,7 +584,7 @@ func GetInspectionDetailById(id int64, orgid int64, startime int64, endtime int6
584 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 588
 	return
589 589
 }
590 590
 
@@ -2332,7 +2332,7 @@ func GetLastPatientsControl(orgid int64, lapstor int64, startime int64, endtime
2332 2332
 	d2 := readDb.Table("xt_quality_control_standard as d")
2333 2333
 	fmt.Println("d2", d2)
2334 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 2337
 	if lapstor == 0 {
2338 2338
 		table = table.Where("s.lapseto = 1 or s.lapseto = 2")
@@ -2350,7 +2350,71 @@ func GetLastPatientsControl(orgid int64, lapstor int64, startime int64, endtime
2350 2350
 	if endtime > 0 {
2351 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 2419
 	return inspection, err
2356 2420
 }
@@ -2484,7 +2548,7 @@ func GetLastPatientsControlTwo(orgid int64, patientid int64, startime int64, end
2484 2548
 	if endtime > 0 {
2485 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 2553
 	return inspection, err
2490 2554
 }