Browse Source

Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch

陈少旭 1 month ago
parent
commit
c2696f3b46

BIN
XT_New.exe View File


+ 4 - 4
controllers/base_api_controller.go View File

@@ -83,7 +83,7 @@ func (this *BaseAuthAPIController) Prepare() {
83 83
 		userAdmin.ModifyTime = 1530786071
84 84
 		var subscibe models.ServeSubscibe
85 85
 		subscibe.ID = 11
86
-		subscibe.OrgId = 10742 //机构id
86
+		subscibe.OrgId = 10138 //机构id
87 87
 		subscibe.PeriodStart = 1547447814
88 88
 		subscibe.PeriodEnd = 1550039814
89 89
 		subscibe.State = 1
@@ -93,7 +93,7 @@ func (this *BaseAuthAPIController) Prepare() {
93 93
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
94 94
 		subscibes[4] = &subscibe
95 95
 		var adminUserInfo service.AdminUserInfo
96
-		adminUserInfo.CurrentOrgId = 10742 //机构id小英9675或4
96
+		adminUserInfo.CurrentOrgId = 10138 //机构id小英9675或4
97 97
 		adminUserInfo.CurrentAppId = 12123 //4
98 98
 		adminUserInfo.AdminUser = &userAdmin
99 99
 		adminUserInfo.Subscibes = subscibes
@@ -329,7 +329,7 @@ func (this *BaseServeAPIController) Prepare() {
329 329
 		userAdmin.ModifyTime = 1530786071
330 330
 		var subscibe models.ServeSubscibe
331 331
 		subscibe.ID = 11
332
-		subscibe.OrgId = 10742 //机构id小英9675或4
332
+		subscibe.OrgId = 10138 //机构id小英9675或4
333 333
 		subscibe.PeriodStart = 1538035409
334 334
 		subscibe.PeriodEnd = 1569571409
335 335
 		subscibe.State = 1
@@ -339,7 +339,7 @@ func (this *BaseServeAPIController) Prepare() {
339 339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
340 340
 		subscibes[4] = &subscibe
341 341
 		var adminUserInfo service.AdminUserInfo
342
-		adminUserInfo.CurrentOrgId = 10742 //机构id小英9675或4
342
+		adminUserInfo.CurrentOrgId = 10138 //机构id小英9675或4
343 343
 		adminUserInfo.CurrentAppId = 12123 //4
344 344
 		adminUserInfo.AdminUser = &userAdmin
345 345
 		adminUserInfo.Subscibes = subscibes

+ 2 - 0
controllers/gobal_config_api_controller.go View File

@@ -2368,7 +2368,9 @@ func (c *GobalConfigApiController) GetSingleOrderDetail() {
2368 2368
 	manufacturerList, err := service.GetAllManufacturerList(orgId)
2369 2369
 	drugFlowList, _ := service.GetDrugStockFlowDetail(start_time, orgId)
2370 2370
 	flowlist, _ := service.GetSingeOrderFlow(id, orgId)
2371
+
2371 2372
 	drugList, _ := service.GetDrugFlowList(id, orgId)
2373
+
2372 2374
 	drugListOne, _ := service.GetDrugFlowListGroupByIdOne(id, orgId)
2373 2375
 	drugListFlow, err := service.GetDrugFlowListGroupById(id, orgId)
2374 2376
 

+ 12 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -5355,6 +5355,13 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5355 5355
 
5356 5356
 				record.UltrafiltrationRate = ultrafiltration_rate / 1000
5357 5357
 			}
5358
+
5359
+			//湘潭爱心美白石
5360
+			if adminInfo.Org.Id == 9850 {
5361
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 1000 / float64(totalMin) * 60 * 1000)
5362
+				record.UltrafiltrationRate = ultrafiltration_rate / 1000
5363
+			}
5364
+
5358 5365
 			//if template.TemplateId == 47 {
5359 5366
 			//	ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
5360 5367
 			//	record.UltrafiltrationRate = ultrafiltration_rate
@@ -5547,6 +5554,11 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5547 5554
 		record.DisplacementQuantity = displacement_quantity
5548 5555
 	}
5549 5556
 
5557
+	if adminInfo.Org.Id == 9850 {
5558
+		ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5559
+		record.UltrafiltrationVolume = ultrafiltration_volume / 1000
5560
+	}
5561
+
5550 5562
 	lastMonitorRecordList, _ := service.GetLastMonitorRecordList(patientID, monitorDate, adminInfo.Org.Id)
5551 5563
 
5552 5564
 	this.ServeSuccessJSON(map[string]interface{}{

+ 42 - 0
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -309,6 +309,7 @@ func (c *PatientApiController) EditDoctorAdvice() {
309 309
 	//2.一组医嘱内有多条医嘱(不包括子医嘱)的情况下,需要为修改的那条医嘱重新分配组号,并修改医嘱开始时间
310 310
 	var err error
311 311
 	var isChangeGroup bool
312
+
312 313
 	if advice.ParentId == 0 {
313 314
 		adviceSlice, _ := service.FindAdviceByGoroupNo(adminUserInfo.Org.Id, advice.GroupNo)
314 315
 		sourceAdvice, _ := service.FindOldDoctorAdvice(adminUserInfo.Org.Id, advice.ID)
@@ -360,6 +361,8 @@ func (c *PatientApiController) EditDoctorAdvice() {
360 361
 					keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
361 362
 					redis.Set(keyOne, "", time.Second)
362 363
 				}
364
+			} else {
365
+				err = service.UpdateDoctorAdvice(&advice)
363 366
 			}
364 367
 
365 368
 		} else if len(adviceSlice) > 1 {
@@ -414,6 +417,8 @@ func (c *PatientApiController) EditDoctorAdvice() {
414 417
 					isChangeGroup = true
415 418
 
416 419
 				}
420
+			} else {
421
+				err = service.UpdateDoctorAdvice(&advice)
417 422
 			}
418 423
 
419 424
 		}
@@ -687,6 +692,24 @@ func (c *PatientApiController) ExecDoctorAdvice() {
687 692
 
688 693
 			for _, item := range advices {
689 694
 
695
+				if item.ExecutionState == 1 {
696
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExced)
697
+					return
698
+				}
699
+
700
+				if item.Checker >= 0 && item.Checker == adminUserInfo.AdminUser.Id {
701
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
702
+					return
703
+				}
704
+
705
+				//针对普宁
706
+				if adminUserInfo.Org.Id != 10599 {
707
+
708
+					if item.StartTime > theTime.Unix() {
709
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExceBeforeStart)
710
+						return
711
+					}
712
+				}
690 713
 				//自备药
691 714
 				selfPrescriptionOutOpenOne, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
692 715
 
@@ -1143,6 +1166,25 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1143 1166
 			advicesOne, _ := service.FindDoctorAdviceByIdsOne(adminUserInfo.Org.Id, ids)
1144 1167
 			for _, item := range advicesOne {
1145 1168
 
1169
+				if item.ExecutionState == 1 {
1170
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExced)
1171
+					return
1172
+				}
1173
+
1174
+				if item.Checker >= 0 && item.Checker == adminUserInfo.AdminUser.Id {
1175
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
1176
+					return
1177
+				}
1178
+
1179
+				//针对普宁
1180
+				if adminUserInfo.Org.Id != 10599 {
1181
+
1182
+					if item.StartTime > theTime.Unix() {
1183
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExceBeforeStart)
1184
+						return
1185
+					}
1186
+				}
1187
+
1146 1188
 				//自备药
1147 1189
 				selfPrescriptionOutOpen, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
1148 1190
 

+ 43 - 0
service/stock_service.go View File

@@ -11050,6 +11050,49 @@ func GetHisDrugCodeQuery(orgId int64, start_time int64, end_time int64, limit in
11050 11050
 	return list, total, err
11051 11051
 }
11052 11052
 
11053
+func GetDoctorAdviceInfoList(page int64, limit int64, orgId int64, start_time int64, end_time int64, is_sale int64) ([]models.HisDoctorAdviceInfo, int64, error) {
11054
+	var list []models.HisDoctorAdviceInfo
11055
+	var total int64
11056
+
11057
+	// 计算偏移量
11058
+	offset := (page - 1) * limit
11059
+
11060
+	// 初始化数据库查询
11061
+	db := XTReadDB().Model(&models.HisDoctorAdviceInfo{})
11062
+
11063
+	// 构建 WHERE 子句
11064
+	query := db.Where("status=1")
11065
+	if orgId > 0 {
11066
+		query = query.Where("user_org_id=?", orgId)
11067
+	}
11068
+	if start_time > 0 {
11069
+		query = query.Where("advice_date >= ?", start_time)
11070
+	}
11071
+	if end_time > 0 {
11072
+		query = query.Where("advice_date <= ?", end_time)
11073
+	}
11074
+	if is_sale == 1 {
11075
+		query = query.Where("is_upload = 1")
11076
+	}
11077
+	if is_sale == 2 {
11078
+		query = query.Where("is_upload IN (?, ?)", 2, 0) // 使用 IN 替代 OR,通常性能更好
11079
+	}
11080
+
11081
+	// 获取总记录数
11082
+	err := query.Count(&total).Error
11083
+	if err != nil {
11084
+		return nil, 0, err
11085
+	}
11086
+
11087
+	// 获取分页后的数据
11088
+	err = query.Offset(offset).Limit(limit).Order("record_date desc").Find(&list).Error
11089
+	if err != nil {
11090
+		return nil, 0, err
11091
+	}
11092
+
11093
+	return list, total, nil
11094
+}
11095
+
11053 11096
 func GetDrugWarehouseOutInfoByDrugCode(drug_id int64, patient_id int64, advice_date int64, user_org_id int64) (outinfo []*models.XtDrugWarehouseOutInfo, err error) {
11054 11097
 
11055 11098
 	err = XTReadDB().Where("drug_id = ? and patient_id = ? and sys_record_time =? and org_id = ? and status =1", drug_id, patient_id, advice_date, user_org_id).Find(&outinfo).Error