소스 검색

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

陈少旭 3 달 전
부모
커밋
5f65a9e0d0
34개의 변경된 파일928개의 추가작업 그리고 141개의 파일을 삭제
  1. BIN
      XT_New.exe
  2. 6 6
      controllers/base_api_controller.go
  3. 68 2
      controllers/dialysis_api_controller.go
  4. 41 10
      controllers/drug_stock_api_contorller.go
  5. 29 0
      controllers/gobal_config_api_controller.go
  6. 19 10
      controllers/his_api_controller.go
  7. 57 3
      controllers/mobile_api_controllers/dialysis_api_controller.go
  8. 168 46
      controllers/mobile_api_controllers/patient_api_controller.go
  9. 5 2
      controllers/new_mobile_api_controllers/index_evaluation_api_controller.go
  10. 1 6
      controllers/new_mobile_api_controllers/new_dialysis_api_controller.go
  11. 7 7
      controllers/new_mobile_api_controllers/staff_schedule_api_controller.go
  12. 7 0
      controllers/patient_api_controller.go
  13. 110 0
      controllers/print_data_api_controller.go
  14. 5 4
      controllers/schedule_template_api_controller.go
  15. 20 0
      controllers/self_drug_api_congtroller.go
  16. 143 0
      controllers/sign_api_controller.go
  17. 10 2
      controllers/stock_in_api_controller.go
  18. 6 5
      models/patient_models.go
  19. 7 5
      models/smart_sch.go
  20. 1 1
      service/common_service.go
  21. 7 0
      service/his_service.go
  22. 14 4
      service/mobile_dialysis_service.go
  23. 6 2
      service/patient_schedule_template_service.go
  24. 23 3
      service/patient_service.go
  25. 7 1
      service/patientmanage_service.go
  26. 6 0
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go
  27. 11 1
      service/schedule_service.go
  28. 14 0
      service/self_drug_service.go
  29. 85 0
      service/sign_service.go
  30. 2 2
      service/smart_sch.go
  31. 12 10
      service/statistics_service/index_evaluation_service.go
  32. 24 2
      service/stock_service.go
  33. 1 1
      service/user_service.go
  34. 6 6
      service/warhouse_service.go

BIN
XT_New.exe 파일 보기


+ 6 - 6
controllers/base_api_controller.go 파일 보기

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

+ 68 - 2
controllers/dialysis_api_controller.go 파일 보기

2178
 	}
2178
 	}
2179
 
2179
 
2180
 	_, receiveTreatment := service.FindReceiveTreatmentAssesByReordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
2180
 	_, receiveTreatment := service.FindReceiveTreatmentAssesByReordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
2181
+
2182
+	if adminUserInfo.CurrentOrgId == 10340 {
2183
+		if condition == 1 {
2184
+			lastAcceptTreatment, _ := service.GetLastAcceptTreatment(adminUserInfo.CurrentOrgId, id)
2185
+			if admission_number == "" {
2186
+				admission_number = lastAcceptTreatment.AdmissionNumber
2187
+				his_bed = lastAcceptTreatment.HisBed
2188
+				his_department = lastAcceptTreatment.HisDepartment
2189
+				tumble = lastAcceptTreatment.Tumble
2190
+			}
2191
+		}
2192
+	}
2181
 	receiveTreatmentAsses := models.ReceiveTreatmentAsses{
2193
 	receiveTreatmentAsses := models.ReceiveTreatmentAsses{
2182
 		UserOrgId:                    adminUserInfo.CurrentOrgId,
2194
 		UserOrgId:                    adminUserInfo.CurrentOrgId,
2183
 		PatientId:                    id,
2195
 		PatientId:                    id,
2858
 			service.CreateDialysisFinish(finish)
2870
 			service.CreateDialysisFinish(finish)
2859
 		}
2871
 		}
2860
 
2872
 
2861
-		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 || adminUserInfo.CurrentOrgId == 10585 || adminUserInfo.CurrentOrgId == 10344 || adminUserInfo.CurrentOrgId == 10622 || adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10751 {
2873
+		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 || adminUserInfo.CurrentOrgId == 10585 || adminUserInfo.CurrentOrgId == 10344 || adminUserInfo.CurrentOrgId == 10622 || adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10752 {
2862
 			var dewater_amount float64
2874
 			var dewater_amount float64
2863
 			dewater_amount = 0
2875
 			dewater_amount = 0
2864
 			if dry_weight > 0 {
2876
 			if dry_weight > 0 {
3505
 		}
3517
 		}
3506
 
3518
 
3507
 		//针对孝昌康桥超滤率计算问题
3519
 		//针对孝昌康桥超滤率计算问题
3508
-		if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10742 || adminUserInfo.CurrentOrgId == 10751 {
3520
+		if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10742 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10752 {
3509
 			if assessmentBeforeDislysis.ID == 0 {
3521
 			if assessmentBeforeDislysis.ID == 0 {
3510
 				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3522
 				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3511
 				if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {
3523
 				if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {
4957
 	lastSchedule, _ := service.FindLastSchedule(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4969
 	lastSchedule, _ := service.FindLastSchedule(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4958
 
4970
 
4959
 	numberList, _ := service.GetAllBedNumberList(adminUserInfo.CurrentOrgId)
4971
 	numberList, _ := service.GetAllBedNumberList(adminUserInfo.CurrentOrgId)
4972
+
4973
+	now := time.Now()
4974
+
4975
+	// 计算当前是周几,周一为第1天,周日为第0天
4976
+	weekday := now.Weekday()
4977
+
4978
+	// 计算当前日期是周几,并计算出周一的日期
4979
+	// 通过减去当前是周几的偏移量再加1来实现(因为Weekday()返回的是从周日开始的索引,而我们想要从周一开始)
4980
+	mondayone := now.AddDate(0, 0, -(int(weekday)+6)%7) // 或者使用 monday := now.Add(-time.Hour * 24 * (int(weekday)+6)%7)
4981
+
4982
+	// 设置开始时间为周一的00:00:00
4983
+	startOfTheWeek := time.Date(mondayone.Year(), mondayone.Month(), mondayone.Day(), 0, 0, 0, 0, mondayone.Location())
4984
+
4985
+	// 设置结束时间为周日的23:59:59(周一的日期基础上加6天)
4986
+	endOfTheWeek := startOfTheWeek.AddDate(0, 0, 6).Add(24*time.Hour - time.Second) // 或者使用 endOfTheWeek := monday.AddDate(0, 0, 7).Add(-time.Second)
4987
+
4988
+	var start_time = startOfTheWeek.Format("2006-01-02")
4989
+
4990
+	var end_time = endOfTheWeek.Format("2006-01-02")
4991
+
4992
+	var startTime int64
4993
+	if len(start_time) > 0 {
4994
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4995
+		if err != nil {
4996
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4997
+			return
4998
+		}
4999
+		startTime = theTime.Unix()
5000
+	}
5001
+	var endTime int64
5002
+	if len(end_time) > 0 {
5003
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
5004
+		if err != nil {
5005
+			utils.ErrorLog(err.Error())
5006
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5007
+			return
5008
+		}
5009
+		endTime = theTime.Unix()
5010
+	}
5011
+
5012
+	scheduleDialyCount, _ := service.GetPatientScheduleDialyCount(patientInfo.ID, startTime, endTime, adminUserInfo.CurrentOrgId)
5013
+
5014
+	dialysis_count := len(scheduleDialyCount)
5015
+
5016
+	var dialysis_count_str = "一周" + strconv.Itoa(dialysis_count) + "次"
5017
+	if adminUserInfo.CurrentOrgId == 10742 {
5018
+		PredialysisEvaluation.DialysisCount = dialysis_count_str
5019
+	}
5020
+
4960
 	//if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
5021
 	//if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
4961
 	//	for _, item := range projects {
5022
 	//	for _, item := range projects {
4962
 	//		var advice *models.HisDoctorAdviceInfo
5023
 	//		var advice *models.HisDoctorAdviceInfo
5666
 			}
5727
 			}
5667
 		}
5728
 		}
5668
 
5729
 
5730
+		if advice.DrugId == 0 {
5731
+			drug, _ := service.GetDoctorAdviceByAdviceName(advice.AdviceName, adminUserInfo.CurrentOrgId)
5732
+			advice.DrugId = drug.ID
5733
+		}
5734
+
5669
 		advices = append(advices, &advice)
5735
 		advices = append(advices, &advice)
5670
 	}
5736
 	}
5671
 
5737
 

+ 41 - 10
controllers/drug_stock_api_contorller.go 파일 보기

1170
 	warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1170
 	warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1171
 	number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1171
 	number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1172
 	number = number + total
1172
 	number = number + total
1173
-	warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
1173
+	warehousing_out_order = "YPCKM" + strconv.FormatInt(number, 10)
1174
 	operation_time := time.Now().Unix()
1174
 	operation_time := time.Now().Unix()
1175
 	creater := adminUserInfo.AdminUser.Id
1175
 	creater := adminUserInfo.AdminUser.Id
1176
 	//创建一个出库单
1176
 	//创建一个出库单
1189
 
1189
 
1190
 	if warehouse_out_id == 0 {
1190
 	if warehouse_out_id == 0 {
1191
 		//查询是否生成出库单
1191
 		//查询是否生成出库单
1192
-		outIsExit, _ := service.GetNewDrugWarehouseOutIsExit(adminUserInfo.CurrentOrgId, 0, operation_time, warehousing_out_order, tx)
1192
+		outIsExit, _ := service.GetNewDrugWarehouseOutIsExit(adminUserInfo.CurrentOrgId, 0, warehousingOutDate.Unix(), warehousing_out_order, tx)
1193
+
1194
+		fmt.Println("outIsExit---------------------", outIsExit)
1193
 		if outIsExit.ID == 0 {
1195
 		if outIsExit.ID == 0 {
1194
 			service.AddNewSigleDrugWarehouseOut(&warehouseOut, tx)
1196
 			service.AddNewSigleDrugWarehouseOut(&warehouseOut, tx)
1195
 		}
1197
 		}
3246
 	dealerList, _ := service.GetAllDealerList(orgId)
3248
 	dealerList, _ := service.GetAllDealerList(orgId)
3247
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3249
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3248
 	if order_type == 2 {
3250
 	if order_type == 2 {
3249
-		list, err := service.GetDrugOutOrderInfoPrintList(startTime, endTime, orgId, storehouse_id, drug_id, order_way)
3250
-		if err == nil {
3251
-			c.ServeSuccessJSON(map[string]interface{}{
3252
-				"list":             list,
3253
-				"dealerList":       dealerList,
3254
-				"manufacturerList": manufacturerList,
3255
-			})
3256
-			return
3251
+		list, _ := service.GetDrugOutOrderInfoPrintList(startTime, endTime, orgId, storehouse_id, drug_id, order_way)
3252
+		if len(list) > 0 {
3253
+			if orgId == 10721 {
3254
+
3255
+				if len(list) > 0 {
3256
+					for _, item := range list {
3257
+						if item.IsSys == 1 {
3258
+							var is_number = item.Count % item.XtBaseDrug.MinNumber
3259
+							if is_number == 0 {
3260
+								item.Count = item.Count / item.XtBaseDrug.MinNumber
3261
+								item.TotalPrice = float64(item.Count) * item.Price
3262
+								item.CountUnit = item.XtBaseDrug.MaxUnit
3263
+							}
3264
+							if is_number != 0 {
3265
+								item.TotalPrice = float64(item.Count) * item.Price
3266
+								item.CountUnit = item.XtBaseDrug.MinUnit
3267
+							}
3268
+
3269
+						}
3270
+					}
3271
+				}
3272
+			}
3257
 		}
3273
 		}
3274
+
3275
+		c.ServeSuccessJSON(map[string]interface{}{
3276
+			"list":             list,
3277
+			"dealerList":       dealerList,
3278
+			"manufacturerList": manufacturerList,
3279
+		})
3280
+		return
3281
+
3258
 	}
3282
 	}
3259
 
3283
 
3260
 }
3284
 }
3281
 func (c *StockDrugApiController) CheckWarehousingInfo() {
3305
 func (c *StockDrugApiController) CheckWarehousingInfo() {
3282
 
3306
 
3283
 	warehousing_id, _ := c.GetInt64("warehousing_id")
3307
 	warehousing_id, _ := c.GetInt64("warehousing_id")
3308
+
3284
 	orgId := c.GetAdminUserInfo().CurrentOrgId
3309
 	orgId := c.GetAdminUserInfo().CurrentOrgId
3285
 	// 开始外部循环的事务
3310
 	// 开始外部循环的事务
3286
 	db := service.XTWriteDB()
3311
 	db := service.XTWriteDB()
3447
 		}
3472
 		}
3448
 
3473
 
3449
 		flowList, _ := service.GetNewDrugFlowList(item.DrugId, item.OrgId, item.ID, tx)
3474
 		flowList, _ := service.GetNewDrugFlowList(item.DrugId, item.OrgId, item.ID, tx)
3475
+
3476
+		fmt.Println("FlowList=================", flowList)
3450
 		var his_count int64
3477
 		var his_count int64
3451
 		if len(flowList) > 0 {
3478
 		if len(flowList) > 0 {
3452
 			for _, item := range flowList {
3479
 			for _, item := range flowList {
3462
 				}
3489
 				}
3463
 			}
3490
 			}
3464
 		}
3491
 		}
3492
+		fmt.Println("incount_0000000000000000", in_cout)
3493
+		fmt.Println("his_count--------------", his_count)
3465
 
3494
 
3466
 		if in_cout != his_count {
3495
 		if in_cout != his_count {
3467
 			is_success = 1
3496
 			is_success = 1
3737
 				}
3766
 				}
3738
 			}
3767
 			}
3739
 
3768
 
3769
+			fmt.Println("now_count=-------------------", now_count)
3770
+			fmt.Println("flow_count_one=-------------------", flow_count_one)
3740
 			if now_count != flow_count_one {
3771
 			if now_count != flow_count_one {
3741
 				is_success = 1
3772
 				is_success = 1
3742
 				tx.Rollback()
3773
 				tx.Rollback()

+ 29 - 0
controllers/gobal_config_api_controller.go 파일 보기

1862
 	drug_id, _ := c.GetInt64("drug_id")
1862
 	drug_id, _ := c.GetInt64("drug_id")
1863
 	order_way, _ := c.GetInt64("order_way")
1863
 	order_way, _ := c.GetInt64("order_way")
1864
 	order, total, err := service.GetDrugOutOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id, drug_id, order_way)
1864
 	order, total, err := service.GetDrugOutOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id, drug_id, order_way)
1865
+	if adminInfo.CurrentOrgId == 10721 {
1866
+
1867
+		if len(order) > 0 {
1868
+			for _, item := range order {
1869
+				if item.IsSys == 1 {
1870
+
1871
+					var is_number = item.Count % item.MinNumber
1872
+
1873
+					if is_number == 0 {
1874
+						item.Count = item.Count / item.MinNumber
1875
+						item.TotalPrice = float64(item.Count) * item.Price
1876
+						item.CountUnit = item.MaxUnit
1877
+					}
1878
+					if is_number != 0 {
1879
+						item.TotalPrice = float64(item.Count) * item.Price
1880
+						item.CountUnit = item.MinUnit
1881
+					}
1882
+				}
1883
+			}
1884
+		}
1885
+	}
1865
 
1886
 
1866
 	houseList, _ := service.GetAllStoreHouseList(adminInfo.CurrentOrgId)
1887
 	houseList, _ := service.GetAllStoreHouseList(adminInfo.CurrentOrgId)
1867
 	patientsList, _ := service.GetAllpatient(adminInfo.CurrentOrgId)
1888
 	patientsList, _ := service.GetAllpatient(adminInfo.CurrentOrgId)
2509
 
2530
 
2510
 	list, total, _ := service.GetDrugFlow(drug_id, orgId, limit, page, startTime, endTime, stock_type)
2531
 	list, total, _ := service.GetDrugFlow(drug_id, orgId, limit, page, startTime, endTime, stock_type)
2511
 
2532
 
2533
+	if len(list) > 0 {
2534
+		for _, item := range list {
2535
+			adviceMap, _ := service.HisDoctorAdviceMap(item.PatientId, item.SystemTime, item.DrugId, item.UserOrgId)
2536
+			item.DrugCode = adviceMap.DrugCode
2537
+		}
2538
+	}
2539
+
2512
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2540
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2513
 	dealerList, _ := service.GetAllDealerList(orgId)
2541
 	dealerList, _ := service.GetAllDealerList(orgId)
2514
 	medical, _ := service.GetBaseDrugMedical(drug_id)
2542
 	medical, _ := service.GetBaseDrugMedical(drug_id)
2515
 	houseList, _ := service.GetAllStoreHouseList(orgId)
2543
 	houseList, _ := service.GetAllStoreHouseList(orgId)
2516
 	patientList, _ := service.GetAllPatientListSix(orgId)
2544
 	patientList, _ := service.GetAllPatientListSix(orgId)
2545
+
2517
 	c.ServeSuccessJSON(map[string]interface{}{
2546
 	c.ServeSuccessJSON(map[string]interface{}{
2518
 		"list":             list,
2547
 		"list":             list,
2519
 		"total":            total,
2548
 		"total":            total,

+ 19 - 10
controllers/his_api_controller.go 파일 보기

3494
 	var adviceList []models.HisDoctorAdviceInfo
3494
 	var adviceList []models.HisDoctorAdviceInfo
3495
 	var projectList []models.HisPrescriptionProject
3495
 	var projectList []models.HisPrescriptionProject
3496
 
3496
 
3497
-	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10635 || adminInfo.CurrentOrgId == 10598 || adminInfo.CurrentOrgId == 10028 || adminInfo.CurrentOrgId == 10721 || adminInfo.CurrentOrgId == 10726 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10571 || adminInfo.CurrentOrgId == 10724 || adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10653 || adminInfo.CurrentOrgId == 10567 {
3497
+	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10635 || adminInfo.CurrentOrgId == 10598 || adminInfo.CurrentOrgId == 10028 || adminInfo.CurrentOrgId == 10721 || adminInfo.CurrentOrgId == 10726 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10571 || adminInfo.CurrentOrgId == 10724 || adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10653 || adminInfo.CurrentOrgId == 10567 || adminInfo.CurrentOrgId == 10751 || adminInfo.CurrentOrgId == 10752 {
3498
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3498
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3499
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3499
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3500
 
3500
 
3523
 					new_prescription, _ := service.GetPrescriptionById(id, adminInfo.CurrentOrgId)
3523
 					new_prescription, _ := service.GetPrescriptionById(id, adminInfo.CurrentOrgId)
3524
 					tempPrescription = &new_prescription
3524
 					tempPrescription = &new_prescription
3525
 					if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
3525
 					if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
3526
+
3526
 						utils.ErrorLog("type")
3527
 						utils.ErrorLog("type")
3527
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3528
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3528
 						return
3529
 						return
3871
 											}
3872
 											}
3872
 										}
3873
 										}
3873
 
3874
 
3874
-										fmt.Println("药品名称----------------------", drug.DrugName)
3875
-										fmt.Println("药品名称----------------------", drug.IsUse)
3876
-										fmt.Println("drug_iiiiiiiiiiiiiiiiiiii", drug.ID)
3877
-										fmt.Println("is_user_total-------------------------", is_user_total)
3878
-										fmt.Println("no_user_total-------------------------", no_user_total)
3879
-										fmt.Println("drug.IsUse---------------", drug.IsUse)
3880
-										fmt.Println("00000000000000000000", s.UserOrgId)
3875
+										//fmt.Println("药品名称----------------------", drug.DrugName)
3876
+										//fmt.Println("药品名称----------------------", drug.IsUse)
3877
+										//fmt.Println("drug_iiiiiiiiiiiiiiiiiiii", drug.ID)
3878
+										//fmt.Println("is_user_total-------------------------", is_user_total)
3879
+										//fmt.Println("no_user_total-------------------------", no_user_total)
3880
+										//fmt.Println("drug.IsUse---------------", drug.IsUse)
3881
+										//fmt.Println("00000000000000000000", s.UserOrgId)
3881
 
3882
 
3882
 										if is_user_total != no_user_total {
3883
 										if is_user_total != no_user_total {
3883
 											//出库
3884
 											//出库
4020
 													history_count += prescribingNumberSevenTy
4021
 													history_count += prescribingNumberSevenTy
4021
 												}
4022
 												}
4022
 
4023
 
4023
-												fmt.Println("local_count---------------", local_count)
4024
-												fmt.Println("history_count---------------", history_count)
4024
+												//fmt.Println("local_count---------------", local_count)
4025
+												//fmt.Println("history_count---------------", history_count)
4025
 
4026
 
4026
 												//如果当前出库数量大于历史出库数量则需要出库
4027
 												//如果当前出库数量大于历史出库数量则需要出库
4027
 												if local_count > history_count {
4028
 												if local_count > history_count {
4478
 
4479
 
4479
 									//用机构ID区分
4480
 									//用机构ID区分
4480
 									if adminInfo.CurrentOrgId != 9671 {
4481
 									if adminInfo.CurrentOrgId != 9671 {
4482
+
4481
 										if goodOutConfig.IsOpen == 1 {
4483
 										if goodOutConfig.IsOpen == 1 {
4482
 											//耗材出库
4484
 											//耗材出库
4483
 											if p.Type == 3 {
4485
 											if p.Type == 3 {
4528
 												//	}
4530
 												//	}
4529
 												//}
4531
 												//}
4530
 
4532
 
4533
+												fmt.Println("nowCount222=================", nowCount)
4534
+												fmt.Println("historyCount-333----------------", historyCount)
4531
 												//如果当前处方数量大于历史数据,则需要出库
4535
 												//如果当前处方数量大于历史数据,则需要出库
4536
+
4532
 												if nowCount > historyCount {
4537
 												if nowCount > historyCount {
4533
 
4538
 
4534
 													var cha_count int64
4539
 													var cha_count int64
4651
 												}
4656
 												}
4652
 
4657
 
4653
 												if nowCount == historyCount {
4658
 												if nowCount == historyCount {
4659
+
4654
 													if historyCount == 0 {
4660
 													if historyCount == 0 {
4655
 														recordDateStr := time.Now().Format("2006-01-02")
4661
 														recordDateStr := time.Now().Format("2006-01-02")
4656
 														recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
4662
 														recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
6065
 				}
6071
 				}
6066
 			}
6072
 			}
6067
 
6073
 
6074
+			fmt.Println("耗材----------------------------------", goodOutConfig.IsOpen)
6068
 			//耗材保存处方出库
6075
 			//耗材保存处方出库
6069
 			if goodOutConfig.IsOpen == 1 {
6076
 			if goodOutConfig.IsOpen == 1 {
6070
 
6077
 
6082
 
6089
 
6083
 					parseIntCount, _ := strconv.ParseInt(item.Count, 10, 64)
6090
 					parseIntCount, _ := strconv.ParseInt(item.Count, 10, 64)
6084
 
6091
 
6092
+					fmt.Println("out_count_five-------------------", out_count_five)
6093
+					fmt.Println("parseIntCount---------------", parseIntCount)
6085
 					if out_count_five != parseIntCount {
6094
 					if out_count_five != parseIntCount {
6086
 
6095
 
6087
 						//查询耗材最后一次出库记录
6096
 						//查询耗材最后一次出库记录

+ 57 - 3
controllers/mobile_api_controllers/dialysis_api_controller.go 파일 보기

1327
 			lastAcceptTreatment, _ := service.GetLastAcceptTreatment(adminUserInfo.Org.Id, id)
1327
 			lastAcceptTreatment, _ := service.GetLastAcceptTreatment(adminUserInfo.Org.Id, id)
1328
 			if admission_number == "" {
1328
 			if admission_number == "" {
1329
 				admission_number = lastAcceptTreatment.AdmissionNumber
1329
 				admission_number = lastAcceptTreatment.AdmissionNumber
1330
+				his_bed = lastAcceptTreatment.HisBed
1331
+				his_department = lastAcceptTreatment.HisDepartment
1332
+				tumble = lastAcceptTreatment.Tumble
1330
 			}
1333
 			}
1331
 		}
1334
 		}
1332
 	}
1335
 	}
4036
 				ultrafiltration_rate = ultrafiltration_rate / 1000
4039
 				ultrafiltration_rate = ultrafiltration_rate / 1000
4037
 			}
4040
 			}
4038
 
4041
 
4042
+			if adminUserInfo.Org.Id == 10752 {
4043
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)
4044
+				ultrafiltration_rate = ultrafiltration_rate / 1000
4045
+			}
4046
+
4039
 			if adminUserInfo.Org.Id == 10723 {
4047
 			if adminUserInfo.Org.Id == 10723 {
4040
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)
4048
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)
4041
 				ultrafiltration_rate = ultrafiltration_rate / 1000
4049
 				ultrafiltration_rate = ultrafiltration_rate / 1000
4061
 				}
4069
 				}
4062
 			}
4070
 			}
4063
 
4071
 
4072
+			fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhh", adminUserInfo.Org.Id)
4073
+			if adminUserInfo.Org.Id == 10752 {
4074
+
4075
+				if prescription.ModeId == 2 {
4076
+					totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
4077
+					if totalMin == 0 {
4078
+						totalMin = 240
4079
+					}
4080
+					if prescription.ReplacementTotal == 0 {
4081
+						prescription.ReplacementTotal = 15
4082
+					}
4083
+
4084
+					//乘10 除10是为了保留一位小数
4085
+					replacement_rate = math.Floor(prescription.DisplaceLiquiValue*1000/float64(totalMin)*10) / 10
4086
+
4087
+					fmt.Println("hhhhhhhhhhhhhhhhhhhhh", replacement_rate)
4088
+				}
4089
+			}
4090
+
4064
 			if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10731 || adminUserInfo.Org.Id == 10727 {
4091
 			if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10731 || adminUserInfo.Org.Id == 10727 {
4065
 				if prescription.ModeId == 2 {
4092
 				if prescription.ModeId == 2 {
4066
 					totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
4093
 					totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5308
 				record.UltrafiltrationRate = ultrafiltration_rate / 1000
5335
 				record.UltrafiltrationRate = ultrafiltration_rate / 1000
5309
 			}
5336
 			}
5310
 
5337
 
5338
+			if adminInfo.Org.Id == 10752 {
5339
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)
5340
+				record.UltrafiltrationRate = ultrafiltration_rate / 1000
5341
+			}
5342
+
5311
 			if adminInfo.Org.Id == 10597 || adminInfo.Org.Id == 10599 || adminInfo.Org.Id == 10679 {
5343
 			if adminInfo.Org.Id == 10597 || adminInfo.Org.Id == 10599 || adminInfo.Org.Id == 10679 {
5312
 				record.UltrafiltrationRate = 0
5344
 				record.UltrafiltrationRate = 0
5313
 			}
5345
 			}
5425
 		record.UltrafiltrationVolume = 0
5457
 		record.UltrafiltrationVolume = 0
5426
 	}
5458
 	}
5427
 
5459
 
5428
-	if adminInfo.Org.Id == 10721 || adminInfo.Org.Id == 10164 || adminInfo.Org.Id == 10731 {
5460
+	if adminInfo.Org.Id == 10721 || adminInfo.Org.Id == 10164 || adminInfo.Org.Id == 10731 || adminInfo.Org.Id == 10752 {
5429
 		if ultrafiltration_rate > 0 {
5461
 		if ultrafiltration_rate > 0 {
5430
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5462
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5431
 			record.UltrafiltrationVolume = ultrafiltration_volume / 1000
5463
 			record.UltrafiltrationVolume = ultrafiltration_volume / 1000
5454
 		var displacement_quantity float64
5486
 		var displacement_quantity float64
5455
 		totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5487
 		totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5456
 		replacement_rate = math.Floor(prescription.ReplacementTotal*1000/float64(totalMin)*60) / 1000
5488
 		replacement_rate = math.Floor(prescription.ReplacementTotal*1000/float64(totalMin)*60) / 1000
5489
+		record.ReplacementRate = replacement_rate
5490
+		fmt.Println("hhhhhhhhhhhhhhhhhh", record.ReplacementRate)
5491
+		fmt.Println(math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600))
5492
+		displacement_quantity = math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime)/3600) * replacement_rate
5493
+		record.DisplacementQuantity = displacement_quantity
5494
+
5495
+	}
5457
 
5496
 
5497
+	if adminInfo.Org.Id == 10752 {
5498
+		var replacement_rate float64
5499
+		var displacement_quantity float64
5500
+		totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5501
+		replacement_rate = math.Floor(prescription.DisplaceLiquiValue*1000/float64(totalMin)*60) / 1000
5458
 		record.ReplacementRate = replacement_rate
5502
 		record.ReplacementRate = replacement_rate
5459
 
5503
 
5460
 		fmt.Println(math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600))
5504
 		fmt.Println(math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600))
6168
 
6212
 
6169
 		advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.Org.Id, patient_id, theStartTime)
6213
 		advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.Org.Id, patient_id, theStartTime)
6170
 
6214
 
6215
+		fmt.Println("theStartTime-----------------------", theStartTime)
6171
 		advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.Org.Id, patient_id, theStartTime)
6216
 		advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.Org.Id, patient_id, theStartTime)
6172
 
6217
 
6173
 		for _, advice := range advices {
6218
 		for _, advice := range advices {
6226
 			count, _ := strconv.ParseInt(dayStr2, 10, 64)
6271
 			count, _ := strconv.ParseInt(dayStr2, 10, 64)
6227
 			oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
6272
 			oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
6228
 			advices, _ := service.FindAllDoctorAdviceByTime(now, oldTime, patient_id, adminUserInfo.Org.Id, advice.TemplateId)
6273
 			advices, _ := service.FindAllDoctorAdviceByTime(now, oldTime, patient_id, adminUserInfo.Org.Id, advice.TemplateId)
6229
-
6274
+			fmt.Println("advices-==---------------", advices)
6230
 			for _, ad := range advices {
6275
 			for _, ad := range advices {
6231
 				advice_three = append(advice_three, ad)
6276
 				advice_three = append(advice_three, ad)
6232
 			}
6277
 			}
11513
 		}
11558
 		}
11514
 	}
11559
 	}
11515
 
11560
 
11561
+	if pat_type == 13 {
11562
+		for _, item := range monitor {
11563
+			if len(item.MonitoringRecord) < 3 {
11564
+				mds = append(mds, item)
11565
+			}
11566
+		}
11567
+	}
11568
+
11516
 	if pat_type == 10 {
11569
 	if pat_type == 10 {
11517
 		for _, item := range monitor {
11570
 		for _, item := range monitor {
11518
 			if len(item.MonitoringRecord) == 0 {
11571
 			if len(item.MonitoringRecord) == 0 {
11590
 func (c *DialysisAPIController) GetLastAcceptRecrods() {
11643
 func (c *DialysisAPIController) GetLastAcceptRecrods() {
11591
 
11644
 
11592
 	patient_id, _ := c.GetInt64("patient_id")
11645
 	patient_id, _ := c.GetInt64("patient_id")
11593
-	recrods, _ := service.GetLastAcceptRecrods(patient_id)
11646
+	org_id := c.GetMobileAdminUserInfo().Org.Id
11647
+	recrods, _ := service.GetLastAcceptRecrods(patient_id, org_id)
11594
 	c.ServeSuccessJSON(map[string]interface{}{
11648
 	c.ServeSuccessJSON(map[string]interface{}{
11595
 		"recrods": recrods,
11649
 		"recrods": recrods,
11596
 	})
11650
 	})

+ 168 - 46
controllers/mobile_api_controllers/patient_api_controller.go 파일 보기

339
 				}
339
 				}
340
 			}
340
 			}
341
 			//判断前端上传上来的开始时间和数据库中想要修改的那条医嘱的开始时间是否相同,如果不同,需要修改子医嘱的开始时间,如果相同直接修改,不需要修改子医嘱的开始时间
341
 			//判断前端上传上来的开始时间和数据库中想要修改的那条医嘱的开始时间是否相同,如果不同,需要修改子医嘱的开始时间,如果相同直接修改,不需要修改子医嘱的开始时间
342
-			if advice.StartTime == sourceAdvice.StartTime {
343
-				err = service.UpdateDoctorAdvice(&advice)
344
-				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
345
-
346
-				defer redis.Close()
347
-				redis.Set(key, "", time.Second)
348
-				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
349
-				redis.Set(keyOne, "", time.Second)
350
-				isChangeGroup = false
351
-			} else {
352
-				err = service.UpdateDoctorAdviceAndSubAdvice(&advice)
353
-				isChangeGroup = false
354
-				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
355
-
356
-				defer redis.Close()
357
-				redis.Set(key, "", time.Second)
358
-				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
359
-				redis.Set(keyOne, "", time.Second)
342
+			if adminUserInfo.Org.Id != 9779 {
343
+
344
+				if advice.StartTime == sourceAdvice.StartTime {
345
+					err = service.UpdateDoctorAdvice(&advice)
346
+					key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
347
+
348
+					defer redis.Close()
349
+					redis.Set(key, "", time.Second)
350
+					keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
351
+					redis.Set(keyOne, "", time.Second)
352
+					isChangeGroup = false
353
+				} else {
354
+					err = service.UpdateDoctorAdviceAndSubAdvice(&advice)
355
+					isChangeGroup = false
356
+					key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
357
+
358
+					defer redis.Close()
359
+					redis.Set(key, "", time.Second)
360
+					keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
361
+					redis.Set(keyOne, "", time.Second)
362
+				}
360
 			}
363
 			}
364
+
361
 		} else if len(adviceSlice) > 1 {
365
 		} else if len(adviceSlice) > 1 {
362
 			infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
366
 			infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
363
 			if infor.ID > 0 {
367
 			if infor.ID > 0 {
382
 				}
386
 				}
383
 			}
387
 			}
384
 			//判断前端上传上来的开始时间和数据库中想要修改的那条医嘱的开始时间是否相同,如果不同,需要重新分配组,如果相同直接修改,不需要分配组
388
 			//判断前端上传上来的开始时间和数据库中想要修改的那条医嘱的开始时间是否相同,如果不同,需要重新分配组,如果相同直接修改,不需要分配组
385
-			if advice.StartTime == sourceAdvice.StartTime {
386
-				err = service.UpdateDoctorAdvice(&advice)
387
-				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
388
 
389
 
389
-				defer redis.Close()
390
-				redis.Set(key, "", time.Second)
391
-				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
392
-				redis.Set(keyOne, "", time.Second)
393
-				isChangeGroup = false
390
+			if adminUserInfo.Org.Id != 9779 {
394
 
391
 
395
-			} else {
396
-				gruopNo := service.GetMaxAdviceGroupID(adminUserInfo.Org.Id)
397
-				gruopNo = gruopNo + 1
398
-				advice.GroupNo = gruopNo
399
-				advice.AdviceDoctor = adminUserInfo.AdminUser.Id
400
-				err = service.UpdateDoctorAdviceAndSubAdvice(&advice)
401
-				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
392
+				if advice.StartTime == sourceAdvice.StartTime {
393
+					err = service.UpdateDoctorAdvice(&advice)
394
+					key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
402
 
395
 
403
-				defer redis.Close()
404
-				redis.Set(key, "", time.Second)
405
-				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
406
-				redis.Set(keyOne, "", time.Second)
407
-				isChangeGroup = true
396
+					defer redis.Close()
397
+					redis.Set(key, "", time.Second)
398
+					keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
399
+					redis.Set(keyOne, "", time.Second)
400
+					isChangeGroup = false
401
+
402
+				} else {
403
+					gruopNo := service.GetMaxAdviceGroupID(adminUserInfo.Org.Id)
404
+					gruopNo = gruopNo + 1
405
+					advice.GroupNo = gruopNo
406
+					advice.AdviceDoctor = adminUserInfo.AdminUser.Id
407
+					err = service.UpdateDoctorAdviceAndSubAdvice(&advice)
408
+					key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
409
+
410
+					defer redis.Close()
411
+					redis.Set(key, "", time.Second)
412
+					keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
413
+					redis.Set(keyOne, "", time.Second)
414
+					isChangeGroup = true
408
 
415
 
416
+				}
409
 			}
417
 			}
418
+
410
 		}
419
 		}
411
 	} else {
420
 	} else {
412
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
421
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
757
 				service.CreateDoctorAdviceLog(adviceLog)
766
 				service.CreateDoctorAdviceLog(adviceLog)
758
 			}
767
 			}
759
 			advicesOne, _ := service.FindAllDoctorAdviceByGoroupNoOne(adminUserInfo.Org.Id, groupno)
768
 			advicesOne, _ := service.FindAllDoctorAdviceByGoroupNoOne(adminUserInfo.Org.Id, groupno)
769
+
760
 			for _, item := range advicesOne {
770
 			for _, item := range advicesOne {
761
 
771
 
762
 				//自备药
772
 				//自备药
775
 					}()
785
 					}()
776
 
786
 
777
 					if strings.Contains(item.AdviceName, "自备") {
787
 					if strings.Contains(item.AdviceName, "自备") {
778
-						fmt.Println("hahhahahahahhh")
779
 						if item.DrugId == 0 {
788
 						if item.DrugId == 0 {
789
+
780
 							c.ServeSuccessJSON(map[string]interface{}{
790
 							c.ServeSuccessJSON(map[string]interface{}{
781
 								"msg":    "12",
791
 								"msg":    "12",
782
 								"advice": item,
792
 								"advice": item,
783
 								"ids":    ids,
793
 								"ids":    ids,
784
 							})
794
 							})
795
+							tx.Rollback()
785
 							return
796
 							return
786
 						}
797
 						}
787
 					}
798
 					}
810
 									"advice": item,
821
 									"advice": item,
811
 									"ids":    ids,
822
 									"ids":    ids,
812
 								})
823
 								})
824
+								tx.Rollback()
813
 								return
825
 								return
814
 							}
826
 							}
815
 						}
827
 						}
843
 									"msg":    "3",
855
 									"msg":    "3",
844
 									"advice": item,
856
 									"advice": item,
845
 								})
857
 								})
858
+								tx.Rollback()
846
 								return
859
 								return
847
 							}
860
 							}
848
 						}
861
 						}
1114
 
1127
 
1115
 				}
1128
 				}
1116
 				//恒泰中医院
1129
 				//恒泰中医院
1117
-				if item.UserOrgId == 10490 || item.UserOrgId == 10602 {
1130
+				if item.UserOrgId == 10490 || item.UserOrgId == 10602 || item.UserOrgId == 10697 {
1118
 					if item.DrugId == 0 || item.DrugNameId == 0 {
1131
 					if item.DrugId == 0 || item.DrugNameId == 0 {
1119
 						//从字典里面查找
1132
 						//从字典里面查找
1120
 						drug, _ := service.GetBaseDrugByName(item.AdviceName, item.UserOrgId)
1133
 						drug, _ := service.GetBaseDrugByName(item.AdviceName, item.UserOrgId)
1147
 
1160
 
1148
 					selfBasedrug, _ := service.GetSelfBasedrugById(item.DrugId, item.UserOrgId, tx)
1161
 					selfBasedrug, _ := service.GetSelfBasedrugById(item.DrugId, item.UserOrgId, tx)
1149
 
1162
 
1163
+					if strings.Contains(item.AdviceName, "自备") {
1164
+						if item.DrugId == 0 {
1165
+
1166
+							c.ServeSuccessJSON(map[string]interface{}{
1167
+								"msg":    "12",
1168
+								"advice": item,
1169
+								"ids":    ids,
1170
+							})
1171
+							tx.Rollback()
1172
+							return
1173
+						}
1174
+					}
1175
+
1150
 					if selfBasedrug.IsSelfDrug == 1 {
1176
 					if selfBasedrug.IsSelfDrug == 1 {
1151
 
1177
 
1152
 						//查询是否有库存
1178
 						//查询是否有库存
1170
 									"advice": item,
1196
 									"advice": item,
1171
 									"ids":    ids,
1197
 									"ids":    ids,
1172
 								})
1198
 								})
1199
+								tx.Rollback()
1173
 								return
1200
 								return
1174
 							}
1201
 							}
1175
 						}
1202
 						}
1202
 									"msg":    "3",
1229
 									"msg":    "3",
1203
 									"advice": item,
1230
 									"advice": item,
1204
 								})
1231
 								})
1232
+								tx.Rollback()
1205
 								return
1233
 								return
1206
 							}
1234
 							}
1207
 						}
1235
 						}
1521
 
1549
 
1522
 				}
1550
 				}
1523
 			}
1551
 			}
1552
+
1524
 			err = service.BatchExceOldDoctorAdvice(&advices, ids)
1553
 			err = service.BatchExceOldDoctorAdvice(&advices, ids)
1525
 
1554
 
1526
 			//记录日志
1555
 			//记录日志
1576
 		//药品管理信息
1605
 		//药品管理信息
1577
 		_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminUserInfo.Org.Id)
1606
 		_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminUserInfo.Org.Id)
1578
 
1607
 
1579
-		//自备药信息
1580
-		//privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.Org.Id)
1581
-
1582
 		storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.Org.Id)
1608
 		storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.Org.Id)
1583
 
1609
 
1584
 		if drugStockConfig.IsOpen == 1 {
1610
 		if drugStockConfig.IsOpen == 1 {
1997
 		//	}
2023
 		//	}
1998
 		//}
2024
 		//}
1999
 
2025
 
2026
+		//自备药
2027
+		selfPrescriptionOutOpen, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
2028
+
2029
+		if selfPrescriptionOutOpen.IsOpen == 1 {
2030
+
2031
+			if groupno > 0 {
2032
+				advices, _ := service.FindAllDoctorAdviceByGoroupNoThree(adminUserInfo.Org.Id, groupno, patient_id, record_date)
2033
+
2034
+				if len(advices) > 0 {
2035
+
2036
+					for _, item := range advices {
2037
+
2038
+						if item.DrugId > 0 && item.ExecutionStaff == 0 {
2039
+
2040
+							//查询这个病人 这个药是否已经出库
2041
+							outInfo, _ := service.GetSelfDrugOutInfo(item.PatientId, item.AdviceDate, item.DrugId)
2042
+
2043
+							if len(outInfo) > 0 {
2044
+
2045
+								service.ModifyExecutionAdvice(item.ID, execution_staff, theTime.Unix())
2046
+							}
2047
+						}
2048
+
2049
+					}
2050
+				}
2051
+
2052
+			} else {
2053
+				advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
2054
+
2055
+				if len(advices) > 0 {
2056
+
2057
+					for _, item := range advices {
2058
+
2059
+						if item.DrugId > 0 && item.ExecutionStaff == 0 {
2060
+
2061
+							//查询这个病人 这个药是否已经出库
2062
+							outInfo, _ := service.GetSelfDrugOutInfo(item.PatientId, item.AdviceDate, item.DrugId)
2063
+
2064
+							if len(outInfo) > 0 {
2065
+
2066
+								service.ModifyExecutionAdvice(item.ID, execution_staff, theTime.Unix())
2067
+							}
2068
+						}
2069
+
2070
+					}
2071
+				}
2072
+			}
2073
+		}
2074
+
2000
 		c.ServeSuccessJSON(map[string]interface{}{
2075
 		c.ServeSuccessJSON(map[string]interface{}{
2001
 			"msg":    "1",
2076
 			"msg":    "1",
2002
 			"advice": advice,
2077
 			"advice": advice,
3753
 	if evaluation.DryWeight > 0 {
3828
 	if evaluation.DryWeight > 0 {
3754
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3829
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3755
 
3830
 
3756
-		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10551 || adminUserInfo.Org.Id == 10579 || adminUserInfo.Org.Id == 10580 || adminUserInfo.Org.Id == 10585 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10727 || adminUserInfo.Org.Id == 10751 {
3831
+		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10551 || adminUserInfo.Org.Id == 10579 || adminUserInfo.Org.Id == 10580 || adminUserInfo.Org.Id == 10585 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10727 || adminUserInfo.Org.Id == 10751 || adminUserInfo.Org.Id == 10752 {
3757
 
3832
 
3758
-			if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 && adminUserInfo.Org.Id != 10585 {
3833
+			if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 && adminUserInfo.Org.Id != 10585 && adminUserInfo.Org.Id != 10752 {
3759
 				dewater_amount = dewater_amount * 1000
3834
 				dewater_amount = dewater_amount * 1000
3760
 			}
3835
 			}
3761
 
3836
 
4478
 	}
4553
 	}
4479
 
4554
 
4480
 	//针对孝昌康桥超滤率计算问题
4555
 	//针对孝昌康桥超滤率计算问题
4481
-	if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10726 || adminUserInfo.Org.Id == 10164 || adminUserInfo.Org.Id == 10751 {
4556
+	if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10726 || adminUserInfo.Org.Id == 10164 || adminUserInfo.Org.Id == 10751 || adminUserInfo.Org.Id == 10752 {
4482
 		if evaluation.ID == 0 {
4557
 		if evaluation.ID == 0 {
4483
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4558
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4484
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
4559
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
6107
 	dialysiscount, err := service.GetDialysisCountByPatientId(firstMonthDate, xttime, patientInfo.ID, adminUserInfo.Org.Id)
6182
 	dialysiscount, err := service.GetDialysisCountByPatientId(firstMonthDate, xttime, patientInfo.ID, adminUserInfo.Org.Id)
6108
 	lastWeight, _ := service.MobileGetLast(adminUserInfo.Org.Id, patientInfo.ID, xttime)
6183
 	lastWeight, _ := service.MobileGetLast(adminUserInfo.Org.Id, patientInfo.ID, xttime)
6109
 	numberList, _ := service.GetAllBedNumberList(adminUserInfo.Org.Id)
6184
 	numberList, _ := service.GetAllBedNumberList(adminUserInfo.Org.Id)
6185
+
6186
+	now := time.Now()
6187
+
6188
+	// 计算当前是周几,周一为第1天,周日为第0天
6189
+	weekday := now.Weekday()
6190
+
6191
+	// 计算当前日期是周几,并计算出周一的日期
6192
+	// 通过减去当前是周几的偏移量再加1来实现(因为Weekday()返回的是从周日开始的索引,而我们想要从周一开始)
6193
+	mondayone := now.AddDate(0, 0, -(int(weekday)+6)%7) // 或者使用 monday := now.Add(-time.Hour * 24 * (int(weekday)+6)%7)
6194
+
6195
+	// 设置开始时间为周一的00:00:00
6196
+	startOfTheWeek := time.Date(mondayone.Year(), mondayone.Month(), mondayone.Day(), 0, 0, 0, 0, mondayone.Location())
6197
+
6198
+	// 设置结束时间为周日的23:59:59(周一的日期基础上加6天)
6199
+	endOfTheWeek := startOfTheWeek.AddDate(0, 0, 6).Add(24*time.Hour - time.Second) // 或者使用 endOfTheWeek := monday.AddDate(0, 0, 7).Add(-time.Second)
6200
+
6201
+	var start_time = startOfTheWeek.Format("2006-01-02")
6202
+
6203
+	var end_time = endOfTheWeek.Format("2006-01-02")
6204
+
6205
+	var startTime int64
6206
+	if len(start_time) > 0 {
6207
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
6208
+		if err != nil {
6209
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6210
+			return
6211
+		}
6212
+		startTime = theTime.Unix()
6213
+	}
6214
+	var endTime int64
6215
+	if len(end_time) > 0 {
6216
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
6217
+		if err != nil {
6218
+			utils.ErrorLog(err.Error())
6219
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6220
+			return
6221
+		}
6222
+		endTime = theTime.Unix()
6223
+	}
6224
+
6225
+	scheduleDialyCount, _ := service.GetPatientScheduleDialyCount(patientInfo.ID, startTime, endTime, adminUserInfo.Org.Id)
6226
+
6227
+	dialysis_count_one := len(scheduleDialyCount)
6228
+
6229
+	var dialysis_count_str = "一周" + strconv.Itoa(dialysis_count_one) + "次"
6230
+	PredialysisEvaluation.DialysisCount = dialysis_count_str
6231
+
6110
 	if config.IsOpen == 1 {
6232
 	if config.IsOpen == 1 {
6111
 		c.ServeSuccessJSON(map[string]interface{}{
6233
 		c.ServeSuccessJSON(map[string]interface{}{
6112
 			"users":                   adminUser,
6234
 			"users":                   adminUser,

+ 5 - 2
controllers/new_mobile_api_controllers/index_evaluation_api_controller.go 파일 보기

1
 package new_mobile_api_controllers
1
 package new_mobile_api_controllers
2
 
2
 
3
 import (
3
 import (
4
+	"fmt"
5
+	"time"
6
+
4
 	"XT_New/enums"
7
 	"XT_New/enums"
5
 	"XT_New/models"
8
 	"XT_New/models"
6
 	"XT_New/service/statistics_service"
9
 	"XT_New/service/statistics_service"
7
 	"XT_New/utils"
10
 	"XT_New/utils"
8
-	"fmt"
9
-	"time"
10
 )
11
 )
11
 
12
 
12
 type IndexEvaluationApiController struct {
13
 type IndexEvaluationApiController struct {
912
 }
913
 }
913
 
914
 
914
 func (this *IndexEvaluationApiController) GetAllPatients() {
915
 func (this *IndexEvaluationApiController) GetAllPatients() {
916
+
915
 	adminUserInfo := this.GetMobileAdminUserInfo()
917
 	adminUserInfo := this.GetMobileAdminUserInfo()
918
+
916
 	patients, _ := statistics_service.GetOrgPatients(adminUserInfo.Org.Id)
919
 	patients, _ := statistics_service.GetOrgPatients(adminUserInfo.Org.Id)
917
 	if patients == nil {
920
 	if patients == nil {
918
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
921
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)

+ 1 - 6
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go 파일 보기

728
 	timeLayout := "2006-01-02"
728
 	timeLayout := "2006-01-02"
729
 	loc, _ := time.LoadLocation("Local")
729
 	loc, _ := time.LoadLocation("Local")
730
 	id, _ := this.GetInt64("id")
730
 	id, _ := this.GetInt64("id")
731
-	fmt.Print("id", id)
732
 	patient, _ := service.GetPatientDetailTwo(id)
731
 	patient, _ := service.GetPatientDetailTwo(id)
733
 	start := this.GetString("startime")
732
 	start := this.GetString("startime")
734
 	startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
733
 	startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
735
 	startime := startTimes.Unix()
734
 	startime := startTimes.Unix()
736
-	fmt.Print("startime", startime)
735
+
737
 	end := this.GetString("endtime")
736
 	end := this.GetString("endtime")
738
 	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 23:59:59", loc)
737
 	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 23:59:59", loc)
739
-
740
 	endtime := endTimes.Unix()
738
 	endtime := endTimes.Unix()
741
-	fmt.Print("endtime", endtime)
742
 	limit, _ := this.GetInt64("limit")
739
 	limit, _ := this.GetInt64("limit")
743
-	fmt.Print("limit", limit)
744
 	page, _ := this.GetInt64("page")
740
 	page, _ := this.GetInt64("page")
745
-	fmt.Print("page", page)
746
 	adminInfo := this.GetMobileAdminUserInfo()
741
 	adminInfo := this.GetMobileAdminUserInfo()
747
 	orgid := adminInfo.Org.Id
742
 	orgid := adminInfo.Org.Id
748
 	dryweight, total, err := service.GetDryWeight(patient.BloodId, startime, endtime, limit, page, orgid)
743
 	dryweight, total, err := service.GetDryWeight(patient.BloodId, startime, endtime, limit, page, orgid)

+ 7 - 7
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go 파일 보기

1039
 	}
1039
 	}
1040
 	schedule.ScheduleDate = theTime.Unix()
1040
 	schedule.ScheduleDate = theTime.Unix()
1041
 
1041
 
1042
-	timeNow := time.Now().Format("2006-01-02")
1043
-	if timeNow > scheduleDate {
1044
-		utils.ErrorLog(timeNow)
1045
-		utils.ErrorLog(scheduleDate)
1046
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
1047
-		return
1048
-	}
1042
+	//timeNow := time.Now().Format("2006-01-02")
1043
+	//if timeNow > scheduleDate {
1044
+	//	utils.ErrorLog(timeNow)
1045
+	//	utils.ErrorLog(scheduleDate)
1046
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
1047
+	//	return
1048
+	//}
1049
 
1049
 
1050
 	if dataBody["schedule_type"] == nil || reflect.TypeOf(dataBody["schedule_type"]).String() != "float64" {
1050
 	if dataBody["schedule_type"] == nil || reflect.TypeOf(dataBody["schedule_type"]).String() != "float64" {
1051
 		utils.ErrorLog("schedule_type")
1051
 		utils.ErrorLog("schedule_type")

+ 7 - 0
controllers/patient_api_controller.go 파일 보기

1981
 			}
1981
 			}
1982
 		}
1982
 		}
1983
 
1983
 
1984
+		if advice.DrugId == 0 {
1985
+			drug, _ := service.GetDoctorAdviceByAdviceName(advice.AdviceName, adminUserInfo.CurrentOrgId)
1986
+			advice.DrugId = drug.ID
1987
+		}
1988
+
1984
 		advices = append(advices, &advice)
1989
 		advices = append(advices, &advice)
1985
 	}
1990
 	}
1986
 
1991
 
4482
 }
4487
 }
4483
 
4488
 
4484
 func (c *PatientApiController) DeleteGroupAdvice() {
4489
 func (c *PatientApiController) DeleteGroupAdvice() {
4490
+
4485
 	groupNo, _ := c.GetInt64("groupno", 0)
4491
 	groupNo, _ := c.GetInt64("groupno", 0)
4492
+
4486
 	if groupNo <= 0 {
4493
 	if groupNo <= 0 {
4487
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4494
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4488
 		return
4495
 		return

+ 110 - 0
controllers/print_data_api_controller.go 파일 보기

2
 
2
 
3
 import (
3
 import (
4
 	"fmt"
4
 	"fmt"
5
+	"strconv"
5
 	"strings"
6
 	"strings"
6
 	"time"
7
 	"time"
7
 
8
 
63
 
64
 
64
 			//透前评估
65
 			//透前评估
65
 			assessmentBeforeDislysisVM, _ := service.GetBatchAssessmentBeforeDislysisVM(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
66
 			assessmentBeforeDislysisVM, _ := service.GetBatchAssessmentBeforeDislysisVM(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
67
+
68
+			now := time.Now()
69
+
70
+			// 计算当前是周几,周一为第1天,周日为第0天
71
+			weekday := now.Weekday()
72
+
73
+			// 计算当前日期是周几,并计算出周一的日期
74
+			// 通过减去当前是周几的偏移量再加1来实现(因为Weekday()返回的是从周日开始的索引,而我们想要从周一开始)
75
+			mondayone := now.AddDate(0, 0, -(int(weekday)+6)%7) // 或者使用 monday := now.Add(-time.Hour * 24 * (int(weekday)+6)%7)
76
+
77
+			// 设置开始时间为周一的00:00:00
78
+			startOfTheWeek := time.Date(mondayone.Year(), mondayone.Month(), mondayone.Day(), 0, 0, 0, 0, mondayone.Location())
79
+
80
+			// 设置结束时间为周日的23:59:59(周一的日期基础上加6天)
81
+			endOfTheWeek := startOfTheWeek.AddDate(0, 0, 6).Add(24*time.Hour - time.Second) // 或者使用 endOfTheWeek := monday.AddDate(0, 0, 7).Add(-time.Second)
82
+
83
+			var start_time = startOfTheWeek.Format("2006-01-02")
84
+
85
+			var end_time = endOfTheWeek.Format("2006-01-02")
86
+
87
+			timeLayout := "2006-01-02"
88
+			loc, _ := time.LoadLocation("Local")
89
+
90
+			var startTime int64
91
+			if len(start_time) > 0 {
92
+				theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
93
+				if err != nil {
94
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
95
+					return
96
+				}
97
+				startTime = theTime.Unix()
98
+			}
99
+			var endTime int64
100
+			if len(end_time) > 0 {
101
+				theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
102
+				if err != nil {
103
+					utils.ErrorLog(err.Error())
104
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
105
+					return
106
+				}
107
+				endTime = theTime.Unix()
108
+			}
109
+			scheduleDialyCount, _ := service.GetPatientScheduleDialyCount(item.PatientID, startTime, endTime, adminUserInfo.CurrentOrgId)
110
+
111
+			dialysis_count := len(scheduleDialyCount)
112
+
113
+			var dialysis_count_str = "一周" + strconv.Itoa(dialysis_count) + "次"
114
+
115
+			if adminUserInfo.CurrentOrgId == 10742 {
116
+				assessmentBeforeDislysisVM.DialysisCount = dialysis_count_str
117
+			}
118
+
66
 			item.AssessmentBeforeDislysis = assessmentBeforeDislysisVM
119
 			item.AssessmentBeforeDislysis = assessmentBeforeDislysisVM
67
 
120
 
68
 			//透后评估
121
 			//透后评估
159
 		schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
212
 		schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
160
 		for _, item := range schedules {
213
 		for _, item := range schedules {
161
 
214
 
215
+			//透前评估
216
+			assessmentBeforeDislysisVM, _ := service.GetBatchAssessmentBeforeDislysisVM(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
217
+
218
+			now := time.Now()
219
+
220
+			// 计算当前是周几,周一为第1天,周日为第0天
221
+			weekday := now.Weekday()
222
+
223
+			// 计算当前日期是周几,并计算出周一的日期
224
+			// 通过减去当前是周几的偏移量再加1来实现(因为Weekday()返回的是从周日开始的索引,而我们想要从周一开始)
225
+			mondayone := now.AddDate(0, 0, -(int(weekday)+6)%7) // 或者使用 monday := now.Add(-time.Hour * 24 * (int(weekday)+6)%7)
226
+
227
+			// 设置开始时间为周一的00:00:00
228
+			startOfTheWeek := time.Date(mondayone.Year(), mondayone.Month(), mondayone.Day(), 0, 0, 0, 0, mondayone.Location())
229
+
230
+			// 设置结束时间为周日的23:59:59(周一的日期基础上加6天)
231
+			endOfTheWeek := startOfTheWeek.AddDate(0, 0, 6).Add(24*time.Hour - time.Second) // 或者使用 endOfTheWeek := monday.AddDate(0, 0, 7).Add(-time.Second)
232
+
233
+			var start_time = startOfTheWeek.Format("2006-01-02")
234
+
235
+			var end_time = endOfTheWeek.Format("2006-01-02")
236
+
237
+			timeLayout := "2006-01-02"
238
+			loc, _ := time.LoadLocation("Local")
239
+
240
+			var startTime int64
241
+			if len(start_time) > 0 {
242
+				theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
243
+				if err != nil {
244
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
245
+					return
246
+				}
247
+				startTime = theTime.Unix()
248
+			}
249
+			var endTime int64
250
+			if len(end_time) > 0 {
251
+				theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
252
+				if err != nil {
253
+					utils.ErrorLog(err.Error())
254
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
255
+					return
256
+				}
257
+				endTime = theTime.Unix()
258
+			}
259
+
260
+			scheduleDialyCount, _ := service.GetPatientScheduleDialyCount(item.PatientID, startTime, endTime, adminUserInfo.CurrentOrgId)
261
+
262
+			fmt.Println("scheduleDialyCount------------------", scheduleDialyCount)
263
+			dialysis_count := len(scheduleDialyCount)
264
+
265
+			var dialysis_count_str = "一周" + strconv.Itoa(dialysis_count) + "次"
266
+			if adminUserInfo.CurrentOrgId == 10742 {
267
+				assessmentBeforeDislysisVM.DialysisCount = dialysis_count_str
268
+			}
269
+
270
+			item.AssessmentBeforeDislysis = assessmentBeforeDislysisVM
271
+
162
 			list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
272
 			list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
163
 			if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 && this.GetAdminUserInfo().CurrentOrgId != 10345 {
273
 			if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 && this.GetAdminUserInfo().CurrentOrgId != 10345 {
164
 				if this.GetAdminUserInfo().CurrentOrgId == 10445 {
274
 				if this.GetAdminUserInfo().CurrentOrgId == 10445 {

+ 5 - 4
controllers/schedule_template_api_controller.go 파일 보기

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
-	"XT_New/enums"
5
-	"XT_New/models"
6
-	"XT_New/service"
7
 	"encoding/json"
4
 	"encoding/json"
8
 	"fmt"
5
 	"fmt"
9
 	"strconv"
6
 	"strconv"
10
 	"strings"
7
 	"strings"
11
 	"time"
8
 	"time"
12
 
9
 
10
+	"XT_New/enums"
11
+	"XT_New/models"
12
+	"XT_New/service"
13
+
13
 	"github.com/astaxie/beego"
14
 	"github.com/astaxie/beego"
14
 )
15
 )
15
 
16
 
1166
 
1167
 
1167
 	deviceNumbers, getDeviceNumbersErr := service.GetScheduleValidDeviceNumbers(adminUserInfo.CurrentOrgId, ids)
1168
 	deviceNumbers, getDeviceNumbersErr := service.GetScheduleValidDeviceNumbers(adminUserInfo.CurrentOrgId, ids)
1168
 
1169
 
1169
-	fmt.Println("deviceNumbers233323232332232323223233223323232323", deviceNumbers)
1170
 	if getDeviceNumbersErr != nil {
1170
 	if getDeviceNumbersErr != nil {
1171
 		this.ErrorLog("获取床位号失败:%v", getDeviceNumbersErr)
1171
 		this.ErrorLog("获取床位号失败:%v", getDeviceNumbersErr)
1172
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1172
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1747
 }
1747
 }
1748
 
1748
 
1749
 func (this *PatientScheduleTemplateAPIController) GetPatientList() {
1749
 func (this *PatientScheduleTemplateAPIController) GetPatientList() {
1750
+
1750
 	patients, err := service.GetSchTemplatePatientList(this.GetAdminUserInfo().CurrentOrgId)
1751
 	patients, err := service.GetSchTemplatePatientList(this.GetAdminUserInfo().CurrentOrgId)
1751
 	if err != nil {
1752
 	if err != nil {
1752
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1753
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)

+ 20 - 0
controllers/self_drug_api_congtroller.go 파일 보기

195
 
195
 
196
 	beego.Router("/api/drug/getpatientadvicelistdetail", &SelfDrugApiController{}, "Get:GetPatientAdviceListDetail")
196
 	beego.Router("/api/drug/getpatientadvicelistdetail", &SelfDrugApiController{}, "Get:GetPatientAdviceListDetail")
197
 
197
 
198
+	beego.Router("/api/drug/getselfdrugwarehouseinfo", &SelfDrugApiController{}, "Get:GetSelfDrugWarhouseInfo")
199
+
198
 }
200
 }
199
 
201
 
200
 func (this *SelfDrugApiController) GetCurrentPatient() {
202
 func (this *SelfDrugApiController) GetCurrentPatient() {
6514
 	orgId := this.GetAdminUserInfo().CurrentOrgId
6516
 	orgId := this.GetAdminUserInfo().CurrentOrgId
6515
 
6517
 
6516
 	adviceList, _ := service.GetNewPatientAdviceList(patient_id, startTime, endTime, orgId)
6518
 	adviceList, _ := service.GetNewPatientAdviceList(patient_id, startTime, endTime, orgId)
6519
+
6520
+	drugInfo, _ := service.GetSelfDrugWarehouseInfoByPatientId(patient_id, orgId)
6517
 	this.ServeSuccessJSON(map[string]interface{}{
6521
 	this.ServeSuccessJSON(map[string]interface{}{
6518
 		"adviceList": adviceList,
6522
 		"adviceList": adviceList,
6523
+		"drugInfo":   drugInfo,
6519
 	})
6524
 	})
6520
 }
6525
 }
6521
 
6526
 
6560
 	})
6565
 	})
6561
 
6566
 
6562
 }
6567
 }
6568
+
6569
+func (this *SelfDrugApiController) GetSelfDrugWarhouseInfo() {
6570
+
6571
+	orgId := this.GetAdminUserInfo().CurrentOrgId
6572
+	patient_id, _ := this.GetInt64("patient_id")
6573
+
6574
+	drug_id, _ := this.GetInt64("drug_id")
6575
+
6576
+	drugInfo, _ := service.GetSelfDrugWarhouseInfoByPatient(drug_id, patient_id, orgId)
6577
+
6578
+	this.ServeSuccessJSON(map[string]interface{}{
6579
+		"drugInfo": drugInfo,
6580
+	})
6581
+
6582
+}

+ 143 - 0
controllers/sign_api_controller.go 파일 보기

1439
 	//}
1439
 	//}
1440
 	//tx.Commit()
1440
 	//tx.Commit()
1441
 
1441
 
1442
+	//adminInfo := this.GetAdminUserInfo()
1443
+	//prescriptionList, _ := service.GetHisPRrescriptionByUserOrgId(10752)
1444
+	//
1445
+	//fmt.Println("prescriptionList", prescriptionList)
1446
+	//
1447
+	//db := service.XTWriteDB()
1448
+	//tx := db.Begin()
1449
+	//if len(prescriptionList) > 0 {
1450
+	//	for _, item := range prescriptionList {
1451
+	//
1452
+	//		// 在函数结束时处理事务回滚
1453
+	//		defer func() {
1454
+	//			if r := recover(); r != nil {
1455
+	//				tx.Rollback()
1456
+	//			}
1457
+	//		}()
1458
+	//		var cha_count int64
1459
+	//
1460
+	//		historyCount, _ := strconv.ParseInt(item.Count, 10, 64)
1461
+	//
1462
+	//		cha_count = historyCount
1463
+	//
1464
+	//		timeStr := "2025-02-04"
1465
+	//		timeArr := strings.Split(timeStr, "-")
1466
+	//
1467
+	//		total, _ := service.FindAllWarehouseOut(adminInfo.CurrentOrgId)
1468
+	//
1469
+	//		total = total + 1
1470
+	//		warehousing_out_order := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1471
+	//		number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1472
+	//		number = number + total
1473
+	//		warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
1474
+	//
1475
+	//		operation_time := item.RecordDate
1476
+	//		creater := this.GetAdminUserInfo().AdminUser.Id
1477
+	//
1478
+	//		recordDateStr := "2025-02-04"
1479
+	//		recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
1480
+	//		nowtime := recordDate.Unix()
1481
+	//		storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
1482
+	//		warehouseOut := models.WarehouseOut{
1483
+	//			WarehouseOutOrderNumber: warehousing_out_order,
1484
+	//			OperationTime:           operation_time,
1485
+	//			OrgId:                   adminInfo.CurrentOrgId,
1486
+	//			Creater:                 5685,
1487
+	//			Ctime:                   nowtime,
1488
+	//			Status:                  1,
1489
+	//			WarehouseOutTime:        nowtime,
1490
+	//			Type:                    1,
1491
+	//			StorehouseId:            storeConfig.StorehouseOutInfo,
1492
+	//			IsCheck:                 1,
1493
+	//			IsSys:                   1,
1494
+	//		}
1495
+	//		//查询是否生成出库单
1496
+	//		out, _ := service.FindNewPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
1497
+	//		if out.ID == 0 {
1498
+	//			service.AddNewSigleWarehouseOut(&warehouseOut, tx)
1499
+	//		}
1500
+	//
1501
+	//		lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
1502
+	//
1503
+	//		goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.ProjectId, tx)
1504
+	//		houseConfig, _ := service.GetNewAllStoreHouseConfig(item.UserOrgId, tx)
1505
+	//
1506
+	//		dialyPrepareOne := models.DialysisBeforePrepare{
1507
+	//			GoodTypeId:   goodObj.GoodTypeId,
1508
+	//			GoodId:       item.ProjectId,
1509
+	//			PatientId:    item.PatientId,
1510
+	//			RecordDate:   item.RecordDate,
1511
+	//			UserOrgId:    adminInfo.CurrentOrgId,
1512
+	//			Count:        cha_count,
1513
+	//			Ctime:        time.Now().Unix(),
1514
+	//			Creater:      5685,
1515
+	//			Status:       1,
1516
+	//			StorehouseId: houseConfig.StorehouseOutInfo,
1517
+	//			ProjectId:    item.ID,
1518
+	//		}
1519
+	//		//出库
1520
+	//		service.ConsumableNewHisPrescriptionDelivery(adminInfo.CurrentOrgId, item.PatientId, item.RecordDate, &dialyPrepareOne, &lastOut, creater, tx)
1521
+	//	}
1522
+	//}
1523
+	//tx.Commit()
1524
+	//return
1525
+
1526
+	//
1527
+
1528
+	adviceInfo, _ := service.GetHisDoctorAdviceByUserOrgId(10752)
1529
+	adminInfo := this.GetAdminUserInfo()
1530
+	db := service.XTWriteDB()
1531
+	tx := db.Begin()
1532
+	if len(adviceInfo) > 0 {
1533
+		for _, item := range adviceInfo {
1534
+
1535
+			drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, item.DrugId)
1536
+			var local_count int64
1537
+			if item.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
1538
+
1539
+				prescribingNumberTenty := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 64)
1540
+				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
1541
+
1542
+				local_count += prescribingNumberSevenTy * drug.MinNumber
1543
+			}
1544
+
1545
+			if item.PrescribingNumberUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
1546
+
1547
+				prescribingNumberTenty := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 64)
1548
+				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
1549
+				local_count += prescribingNumberSevenTy
1550
+			}
1551
+
1552
+			if item.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
1553
+
1554
+				prescribingNumberTenty := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 64)
1555
+				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
1556
+				local_count += prescribingNumberSevenTy
1557
+			}
1558
+
1559
+			item.PrescribingNumberUnit = drug.MinUnit
1560
+
1561
+			service.BloodNewHisDrugsDelivery(item.UserOrgId, 5685, item, tx)
1562
+
1563
+			storeConfig, _ := service.GetNewAllStoreHouseConfig(item.UserOrgId, tx)
1564
+
1565
+			stockInfo, _ := service.GetNewDrugAllStockInfo(storeConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId, tx)
1566
+			var sum_count int64
1567
+			for _, its := range stockInfo {
1568
+				baseDrug, _ := service.GetNewBaseDrugMedical(its.DrugId, tx)
1569
+				if its.MaxUnit == baseDrug.MaxUnit {
1570
+					its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
1571
+				}
1572
+				sum_count += its.StockMaxNumber + its.StockMinNumber
1573
+			}
1574
+			//更新基础库存
1575
+			service.UpdateNewBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId, tx)
1576
+			//剩余库存
1577
+			service.UpdateNewDrugStockCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, sum_count, tx)
1578
+
1579
+			over, _ := service.FindNewOverCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, tx)
1580
+			service.UpdateNewActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount, tx)
1581
+		}
1582
+	}
1583
+
1584
+	tx.Commit()
1442
 	this.ServeSuccessJSON(map[string]interface{}{
1585
 	this.ServeSuccessJSON(map[string]interface{}{
1443
 		"msg": "ok",
1586
 		"msg": "ok",
1444
 	})
1587
 	})

+ 10 - 2
controllers/stock_in_api_controller.go 파일 보기

1238
 	warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1238
 	warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1239
 	number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1239
 	number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1240
 	number = number + total
1240
 	number = number + total
1241
-	warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
1241
+	warehousing_out_order = "CKM" + strconv.FormatInt(number, 10)
1242
 
1242
 
1243
 	operation_time := time.Now().Unix()
1243
 	operation_time := time.Now().Unix()
1244
 	creater := adminUserInfo.AdminUser.Id
1244
 	creater := adminUserInfo.AdminUser.Id
1277
 
1277
 
1278
 	if warehouseOut_id == 0 {
1278
 	if warehouseOut_id == 0 {
1279
 		//查询是否生成出库单
1279
 		//查询是否生成出库单
1280
-		warehouseOutObj, _ := service.FindStockOutByIsSysOne(adminUserInfo.CurrentOrgId, 0, operation_time, warehousing_out_order, tx)
1280
+		warehouseOutObj, _ := service.FindStockOutByIsSysOne(adminUserInfo.CurrentOrgId, 0, warehousingOutDate.Unix(), warehousing_out_order, tx)
1281
 
1281
 
1282
 		if warehouseOutObj.ID == 0 {
1282
 		if warehouseOutObj.ID == 0 {
1283
 			service.AddSigleWarehouseOut(&warehouseOut, tx)
1283
 			service.AddSigleWarehouseOut(&warehouseOut, tx)
5171
 	}
5171
 	}
5172
 
5172
 
5173
 	list, total, _ := service.GetStockFlowList(limit, page, consumable_type, orgId, startTime, endTime, good_id)
5173
 	list, total, _ := service.GetStockFlowList(limit, page, consumable_type, orgId, startTime, endTime, good_id)
5174
+
5175
+	//if len(list) > 0 {
5176
+	//	for _, item := range list {
5177
+	//		hisPrescription, _ := service.GetHidsDoctorAdvice(item.GoodId, orgId, item.PatientId, item.SystemTime)
5178
+	//		item.GoodCode = hisPrescription.good
5179
+	//	}
5180
+	//}
5174
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
5181
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
5175
 	good, _ := service.GetGoodInformationByGoodId(good_id)
5182
 	good, _ := service.GetGoodInformationByGoodId(good_id)
5176
 	houseList, _ := service.GetAllStoreHouseList(adminUserInfo.CurrentOrgId)
5183
 	houseList, _ := service.GetAllStoreHouseList(adminUserInfo.CurrentOrgId)
5177
 	patients, _ := service.GetAllPatientListSix(adminUserInfo.CurrentOrgId)
5184
 	patients, _ := service.GetAllPatientListSix(adminUserInfo.CurrentOrgId)
5185
+
5178
 	this.ServeSuccessJSON(map[string]interface{}{
5186
 	this.ServeSuccessJSON(map[string]interface{}{
5179
 		"list":             list,
5187
 		"list":             list,
5180
 		"total":            total,
5188
 		"total":            total,

+ 6 - 5
models/patient_models.go 파일 보기

1150
 }
1150
 }
1151
 
1151
 
1152
 type BloodXtPatients struct {
1152
 type BloodXtPatients struct {
1153
-	ID         int64  `gorm:"column:id" json:"id" form:"id"`
1154
-	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1155
-	DialysisNo string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
1156
-	Name       string `gorm:"column:name" json:"name" form:"name"`
1157
-	IdCardNo   string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
1153
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
1154
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1155
+	DialysisNo  string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
1156
+	Name        string `gorm:"column:name" json:"name" form:"name"`
1157
+	IdCardNo    string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
1158
+	PatientType int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
1158
 }
1159
 }
1159
 
1160
 
1160
 func (BloodXtPatients) TableName() string {
1161
 func (BloodXtPatients) TableName() string {

+ 7 - 5
models/smart_sch.go 파일 보기

1
 package models
1
 package models
2
 
2
 
3
 type SmartSchPatient struct {
3
 type SmartSchPatient struct {
4
-	ID         int64  `gorm:"column:id" json:"id" form:"id"`
5
-	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
-	Name       string `gorm:"column:name" json:"name" form:"name"`
7
-	DialysisNo string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
8
-	Lapseto    int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
4
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	Name        string `gorm:"column:name" json:"name" form:"name"`
7
+	DialysisNo  string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
8
+	Lapseto     int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
9
+	PatientType int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
10
+
9
 	//SmartSchedule []*SmartSchedule `gorm:"-" json:"sch"`
11
 	//SmartSchedule []*SmartSchedule `gorm:"-" json:"sch"`
10
 }
12
 }
11
 
13
 

+ 1 - 1
service/common_service.go 파일 보기

482
 
482
 
483
 func GetCurentOrgPatients(orgid int64) (patients []*models.BloodXtPatients, err error) {
483
 func GetCurentOrgPatients(orgid int64) (patients []*models.BloodXtPatients, err error) {
484
 
484
 
485
-	err = XTReadDB().Where("user_org_id = ? and status =1", orgid).Order("created_time desc").Find(&patients).Error
485
+	err = XTReadDB().Where("user_org_id = ? and status =1 and patient_type =1", orgid).Order("created_time desc").Find(&patients).Error
486
 	return patients, err
486
 	return patients, err
487
 }
487
 }
488
 
488
 

+ 7 - 0
service/his_service.go 파일 보기

1066
 	return prescriptionProject, err
1066
 	return prescriptionProject, err
1067
 }
1067
 }
1068
 
1068
 
1069
+func GetHisWarehouseOutInfo(patient_id int64, user_org_id int64, sys_record_time int64, tx *gorm.DB, good_id int64) (outinfo []*models.WarehouseOutInfo, err error) {
1070
+
1071
+	err = tx.Where("patient_id = ? and user_org_id = ? and sys_record_time = ? and good_id = ? an status=1", patient_id, user_org_id, sys_record_time, good_id).Find(&outinfo).Error
1072
+
1073
+	return outinfo, err
1074
+}
1075
+
1069
 func CreateHisProjectThree(project *models.HisPrescriptionProject) (err error) {
1076
 func CreateHisProjectThree(project *models.HisPrescriptionProject) (err error) {
1070
 	tx := writeDb.Begin()
1077
 	tx := writeDb.Begin()
1071
 	if err = tx.Model(&models.HisPrescriptionProject{}).Save(project).Error; err != nil {
1078
 	if err = tx.Model(&models.HisPrescriptionProject{}).Save(project).Error; err != nil {

+ 14 - 4
service/mobile_dialysis_service.go 파일 보기

2120
 }
2120
 }
2121
 
2121
 
2122
 type MobileUrgentSchedulePatientVM struct {
2122
 type MobileUrgentSchedulePatientVM struct {
2123
-	ID         int64  `gorm:"column:id" json:"id"`
2124
-	Name       string `gorm:"column:name" json:"name"`
2125
-	DialysisNo string `gorm:"column:dialysis_no" json:"dialysis_no"`
2123
+	ID          int64  `gorm:"column:id" json:"id"`
2124
+	Name        string `gorm:"column:name" json:"name"`
2125
+	DialysisNo  string `gorm:"column:dialysis_no" json:"dialysis_no"`
2126
+	PatientType int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
2126
 }
2127
 }
2127
 
2128
 
2128
 func (MobileUrgentSchedulePatientVM) TableName() string {
2129
 func (MobileUrgentSchedulePatientVM) TableName() string {
2140
 
2141
 
2141
 func MobileGetAllPatientsForUrgentSchedule(orgID int64, record_date int64) ([]*MobileUrgentSchedulePatientVM, error) {
2142
 func MobileGetAllPatientsForUrgentSchedule(orgID int64, record_date int64) ([]*MobileUrgentSchedulePatientVM, error) {
2142
 	var vms []*MobileUrgentSchedulePatientVM = make([]*MobileUrgentSchedulePatientVM, 0)
2143
 	var vms []*MobileUrgentSchedulePatientVM = make([]*MobileUrgentSchedulePatientVM, 0)
2143
-	rows, err := readDb.Raw("SELECT p.*  FROM xt_patients as p  WHERE (p.user_org_id = ? AND p.status = 1 AND p.lapseto = 1) AND NOT EXISTS (Select * FROM `xt_dialysis_order` as d Where d.`dialysis_date` = ? AND d.`status` = 1 AND d.`patient_id` = p.id AND  d.user_org_id = p.user_org_id  )", orgID, record_date).Rows()
2144
+
2145
+	rows, err := readDb.Raw("SELECT p.*  FROM xt_patients as p  WHERE (p.user_org_id = ? AND p.status = 1 AND p.lapseto = 1 and p.patient_type =1) AND NOT EXISTS (Select * FROM `xt_dialysis_order` as d Where d.`dialysis_date` = ? AND d.`status` = 1 AND d.`patient_id` = p.id AND  d.user_org_id = p.user_org_id  )", orgID, record_date).Rows()
2144
 	defer rows.Close()
2146
 	defer rows.Close()
2145
 	if err != nil {
2147
 	if err != nil {
2146
 		return nil, err
2148
 		return nil, err
10049
 
10051
 
10050
 	return baseDrug, err
10052
 	return baseDrug, err
10051
 }
10053
 }
10054
+
10055
+func GetDoctorAdviceByAdviceName(advice_name string, user_org_id int64) (models.BaseDrugLibSeven, error) {
10056
+
10057
+	drugLib := models.BaseDrugLibSeven{}
10058
+	err := XTReadDB().Where("drug_name = ? and org_id = ? and status=1", advice_name, user_org_id).Find(&drugLib).Error
10059
+
10060
+	return drugLib, err
10061
+}

+ 6 - 2
service/patient_schedule_template_service.go 파일 보기

301
 	DialysisNo  string                      `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
301
 	DialysisNo  string                      `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
302
 	FirstLetter string                      `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
302
 	FirstLetter string                      `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
303
 	Contagions  []*PatientScheduleContagion `gorm:"ForeignKey:PatientID" json:"contagions"`
303
 	Contagions  []*PatientScheduleContagion `gorm:"ForeignKey:PatientID" json:"contagions"`
304
+	PatientType int64                       `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
304
 }
305
 }
305
 
306
 
306
 func (PatientScheduleTemplatePatientVM) TableName() string {
307
 func (PatientScheduleTemplatePatientVM) TableName() string {
319
 }
320
 }
320
 
321
 
321
 func PatientScheduleTemplateGetAllValidPatient(orgID int64) ([]*PatientScheduleTemplatePatientVM, error) {
322
 func PatientScheduleTemplateGetAllValidPatient(orgID int64) ([]*PatientScheduleTemplatePatientVM, error) {
323
+
322
 	var vms []*PatientScheduleTemplatePatientVM
324
 	var vms []*PatientScheduleTemplatePatientVM
323
 	err := readDb.
325
 	err := readDb.
324
 		Model(&PatientScheduleTemplatePatientVM{}).
326
 		Model(&PatientScheduleTemplatePatientVM{}).
325
 		Preload("Contagions", "status = 1").
327
 		Preload("Contagions", "status = 1").
326
-		Where("user_org_id = ? and lapseto=1 AND status = 1", orgID).
328
+		Where("user_org_id = ? and lapseto=1 AND status = 1 and patient_type =1", orgID).
327
 		Find(&vms).
329
 		Find(&vms).
328
 		Error
330
 		Error
329
 	if err != nil {
331
 	if err != nil {
898
 	DialysisNo   string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
900
 	DialysisNo   string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
899
 	IsInfectious int64  `gorm:"column:is_infectious" json:"is_infectious"`
901
 	IsInfectious int64  `gorm:"column:is_infectious" json:"is_infectious"`
900
 	FirstLetter  string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
902
 	FirstLetter  string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
903
+	PatientType  int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
901
 }
904
 }
902
 
905
 
903
 func (SchTemplatePatient) TableName() string {
906
 func (SchTemplatePatient) TableName() string {
905
 }
908
 }
906
 
909
 
907
 func GetSchTemplatePatientList(orgID int64) ([]*SchTemplatePatient, error) {
910
 func GetSchTemplatePatientList(orgID int64) ([]*SchTemplatePatient, error) {
911
+
908
 	var patients []*SchTemplatePatient
912
 	var patients []*SchTemplatePatient
909
-	err := readDb.Model(&SchTemplatePatient{}).Where("user_org_id = ? AND status = 1 AND lapseto = 1", orgID).Find(&patients).Error
913
+	err := readDb.Model(&SchTemplatePatient{}).Where("user_org_id = ? AND status = 1 AND lapseto = 1 and patient_type =1", orgID).Find(&patients).Error
910
 	return patients, err
914
 	return patients, err
911
 }
915
 }
912
 
916
 

+ 23 - 3
service/patient_service.go 파일 보기

1936
 }
1936
 }
1937
 
1937
 
1938
 func GetSchedualPatientByKeyWord(orgID int64, keywords string, date int64) (patient []*models.Patients, err error) {
1938
 func GetSchedualPatientByKeyWord(orgID int64, keywords string, date int64) (patient []*models.Patients, err error) {
1939
-	db := readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1 and lapseto = 1 ", orgID)
1939
+
1940
+	db := readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1 and lapseto = 1 and patient_type =1 ", orgID)
1940
 	if len(keywords) > 0 {
1941
 	if len(keywords) > 0 {
1941
 		likekey := "%" + keywords + "%"
1942
 		likekey := "%" + keywords + "%"
1942
 		err = db.Where("(name LIKE ? OR dialysis_no LIKE ?) AND NOT EXISTS (Select * FROM `xt_dialysis_order` as d Where d.`dialysis_date` = ? AND d.`status` = 1 AND d.`patient_id` = xt_patients.id AND  d.user_org_id = xt_patients.user_org_id)", likekey, likekey, date).Find(&patient).Error
1943
 		err = db.Where("(name LIKE ? OR dialysis_no LIKE ?) AND NOT EXISTS (Select * FROM `xt_dialysis_order` as d Where d.`dialysis_date` = ? AND d.`status` = 1 AND d.`patient_id` = xt_patients.id AND  d.user_org_id = xt_patients.user_org_id)", likekey, likekey, date).Find(&patient).Error
3332
 }
3333
 }
3333
 
3334
 
3334
 func GetNewAllMonitorList(orgID int64, scheduleDate int64, pat_type int64) (monitor []*models.VMMonitoringRecord, err error) {
3335
 func GetNewAllMonitorList(orgID int64, scheduleDate int64, pat_type int64) (monitor []*models.VMMonitoringRecord, err error) {
3336
+
3335
 	if pat_type == 0 || pat_type == 9 {
3337
 	if pat_type == 0 || pat_type == 9 {
3336
 		err = readDb.Model(&models.VMMonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ?", orgID, scheduleDate).Order("monitoring_date asc").Find(&monitor).Error
3338
 		err = readDb.Model(&models.VMMonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ?", orgID, scheduleDate).Order("monitoring_date asc").Find(&monitor).Error
3337
 	}
3339
 	}
3338
 
3340
 
3341
+	if pat_type == 13 {
3342
+		err = readDb.Model(&models.VMMonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ? and ultrafiltration_volume>0", orgID, scheduleDate).Order("monitoring_date asc").Find(&monitor).Error
3343
+	}
3344
+
3339
 	if pat_type == 10 {
3345
 	if pat_type == 10 {
3340
 		err = readDb.Model(&models.VMMonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ? AND accumulated_blood_volume = 0", orgID, scheduleDate).Order("monitoring_date asc").Find(&monitor).Error
3346
 		err = readDb.Model(&models.VMMonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ? AND accumulated_blood_volume = 0", orgID, scheduleDate).Order("monitoring_date asc").Find(&monitor).Error
3341
 	}
3347
 	}
3617
 	return order, err
3623
 	return order, err
3618
 }
3624
 }
3619
 
3625
 
3620
-func GetLastAcceptRecrods(patient_id int64) (models.ReceiveTreatmentAsses, error) {
3626
+func GetLastAcceptRecrods(patient_id int64, user_org_id int64) (models.ReceiveTreatmentAsses, error) {
3621
 
3627
 
3622
 	treatmentAsses := models.ReceiveTreatmentAsses{}
3628
 	treatmentAsses := models.ReceiveTreatmentAsses{}
3623
-	err := XTReadDB().Where("patient_id = ? and status= 1 and admission_number!=''", patient_id).Last(&treatmentAsses).Error
3629
+	err := XTReadDB().Where("patient_id = ? and status= 1 and admission_number!='' and user_org_id =? ", patient_id, user_org_id).Last(&treatmentAsses).Error
3624
 	return treatmentAsses, err
3630
 	return treatmentAsses, err
3625
 }
3631
 }
3626
 
3632
 
5020
 
5026
 
5021
 	return inspection, err
5027
 	return inspection, err
5022
 }
5028
 }
5029
+
5030
+func GetSelfDrugOutInfo(patient_id int64, sys_record_time int64, drug_id int64) (outInfo []*models.XtSelfDrugWarehouseOutInfo, err error) {
5031
+
5032
+	err = XTReadDB().Where("patient_id = ? and sys_record_time = ? and drug_id = ? and status=1", patient_id, sys_record_time, drug_id).Find(&outInfo).Error
5033
+
5034
+	return outInfo, err
5035
+}
5036
+
5037
+func ModifyExecutionAdvice(id int64, execution_staff int64, ExecutionTime int64) error {
5038
+
5039
+	err := XTWriteDB().Model(&models.DoctorAdvice{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"execution_staff": execution_staff, "execution_state": 1, "execution_time": ExecutionTime}).Error
5040
+
5041
+	return err
5042
+}

+ 7 - 1
service/patientmanage_service.go 파일 보기

585
 	}
585
 	}
586
 	offset := (page - 1) * limit
586
 	offset := (page - 1) * limit
587
 	err = db.Count(&total).Order("x.ctime desc").Offset(offset).Limit(limit).Group("x.id").
587
 	err = db.Count(&total).Order("x.ctime desc").Offset(offset).Limit(limit).Group("x.id").
588
-		Select("x.id,x.dry_weight,x.creator,x.remakes,x.patient_id,x.ctime,x.adjusted_value,x.user_id,x.user_org_id,r.user_name").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creator").Scan(&dryWeight).Error
588
+		Select("x.id,x.dry_weight,x.creator,x.remakes,x.patient_id,x.ctime,x.adjusted_value,x.user_id,x.user_org_id,r.user_name").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creator and r.org_id = x.user_org_id").Scan(&dryWeight).Error
589
 	return dryWeight, total, err
589
 	return dryWeight, total, err
590
 }
590
 }
591
 
591
 
1183
 	return number, err
1183
 	return number, err
1184
 }
1184
 }
1185
 
1185
 
1186
+func GetPatientScheduleDialyCount(patient_id int64, start_time int64, end_time int64, org_id int64) (schedule []*models.XtSchedule, err error) {
1187
+
1188
+	err = XTReadDB().Where("patient_id = ? and schedule_date>=? and schedule_date<=? and user_org_id = ? and status=1", patient_id, start_time, end_time, org_id).Find(&schedule).Error
1189
+	return schedule, err
1190
+}
1191
+
1186
 func GetAllGroupOne(orgid int64) (group []*models.DeviceGroup, err error) {
1192
 func GetAllGroupOne(orgid int64) (group []*models.DeviceGroup, err error) {
1187
 
1193
 
1188
 	err = XTReadDB().Model(&group).Where("org_id =?", orgid).Find(&group).Error
1194
 	err = XTReadDB().Model(&group).Where("org_id =?", orgid).Find(&group).Error

+ 6 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go 파일 보기

489
 	return AssessmentBeforeDislysisVM, err
489
 	return AssessmentBeforeDislysisVM, err
490
 }
490
 }
491
 
491
 
492
+func GetPatientScheduleDialyCount(patient_id int64, start_time int64, end_time int64, org_id int64) (schedule []*models.XtSchedule, err error) {
493
+
494
+	err = p_service.XTReadDB().Where("patient_id = ? and schedule_date>=? and schedule_date<=? and user_org_id = ? and status=1", patient_id, start_time, end_time, org_id).Find(&schedule).Error
495
+	return schedule, err
496
+}
497
+
492
 func GetBatchAssessmentAfterDislysisVM(orgid int64, patient_id int64, assessment_date int64) (AssessmentAfterDislysisVM, error) {
498
 func GetBatchAssessmentAfterDislysisVM(orgid int64, patient_id int64, assessment_date int64) (AssessmentAfterDislysisVM, error) {
493
 
499
 
494
 	assessmentAfterDislysisVM := AssessmentAfterDislysisVM{}
500
 	assessmentAfterDislysisVM := AssessmentAfterDislysisVM{}

+ 11 - 1
service/schedule_service.go 파일 보기

46
 		Preload("DialysisSolutions", "user_org_id=? and initiate_mode=1 and affirm_state=1 and parent_id=0 and status=1", orgID).
46
 		Preload("DialysisSolutions", "user_org_id=? and initiate_mode=1 and affirm_state=1 and parent_id=0 and status=1", orgID).
47
 		Preload("Schedules", "user_org_id=? and schedule_date>=? and schedule_date<= ? and status=1", orgID, weekStart, weekEnd).
47
 		Preload("Schedules", "user_org_id=? and schedule_date>=? and schedule_date<= ? and status=1", orgID, weekStart, weekEnd).
48
 		Preload("Contagions", "status=1").
48
 		Preload("Contagions", "status=1").
49
-		Where("p.user_org_id=? and p.lapseto=1 and p.status=1", orgID)
49
+		Where("p.user_org_id=? and p.lapseto=1 and p.status=1 and p.patient_type =1", orgID)
50
 	if len(keywords) > 0 {
50
 	if len(keywords) > 0 {
51
 		likeKey := "%" + keywords + "%"
51
 		likeKey := "%" + keywords + "%"
52
 		db = db.Where("p.name LIKE ? or p.first_letter LIKE ?", likeKey, likeKey)
52
 		db = db.Where("p.name LIKE ? or p.first_letter LIKE ?", likeKey, likeKey)
1206
 	if startime > 0 {
1206
 	if startime > 0 {
1207
 		db = db.Where("x.schedule_date >=?", startime)
1207
 		db = db.Where("x.schedule_date >=?", startime)
1208
 	}
1208
 	}
1209
+
1210
+	if startime == 0 {
1211
+		db = db.Where("x.schedule_date >=1739116800")
1212
+	}
1213
+
1209
 	if endtime > 0 {
1214
 	if endtime > 0 {
1210
 		db = db.Where("x.schedule_date <=?", endtime)
1215
 		db = db.Where("x.schedule_date <=?", endtime)
1211
 	}
1216
 	}
1217
+
1218
+	if endtime == 0 {
1219
+		db = db.Where("x.schedule_date <=1739635200")
1220
+	}
1221
+
1212
 	if orgid > 0 {
1222
 	if orgid > 0 {
1213
 		db = db.Where("x.user_org_id = ?", orgid)
1223
 		db = db.Where("x.user_org_id = ?", orgid)
1214
 	}
1224
 	}

+ 14 - 0
service/self_drug_service.go 파일 보기

3951
 	return lib, err
3951
 	return lib, err
3952
 }
3952
 }
3953
 
3953
 
3954
+func FindNewSelfBaseDrugLibRecord(org_id int64, id int64) (lib models.BaseDrugLib, err error) {
3955
+
3956
+	err = XTReadDB().Model(&models.BaseDrugLib{}).Where("id = ? AND org_id = ?  AND status = 1", id, org_id).First(&lib).Error
3957
+
3958
+	return lib, err
3959
+}
3960
+
3954
 func GetSelfBaseDrugMedical(id int64, tx *gorm.DB) (models.XtBaseDrug, error) {
3961
 func GetSelfBaseDrugMedical(id int64, tx *gorm.DB) (models.XtBaseDrug, error) {
3955
 	drug := models.XtBaseDrug{}
3962
 	drug := models.XtBaseDrug{}
3956
 	err := tx.Model(&drug).Where("id = ? and status = 1", id).Find(&drug).Error
3963
 	err := tx.Model(&drug).Where("id = ? and status = 1", id).Find(&drug).Error
5418
 
5425
 
5419
 	return info, err
5426
 	return info, err
5420
 }
5427
 }
5428
+
5429
+func GetSelfDrugWarhouseInfoByPatient(drug_id int64, patient_id int64, user_org_id int64) (info []*models.XtSelfDrugWarehouseInfo, err error) {
5430
+
5431
+	err = XTReadDB().Where("drug_id = ? and patient_id = ? and org_id = ? and status=1 and is_check=1", drug_id, patient_id, user_org_id).Order("ctime desc").Find(&info).Error
5432
+
5433
+	return info, err
5434
+}

+ 85 - 0
service/sign_service.go 파일 보기

6
 	"crypto/sha1"
6
 	"crypto/sha1"
7
 	"encoding/base64"
7
 	"encoding/base64"
8
 	"encoding/json"
8
 	"encoding/json"
9
+	"errors"
9
 	"fmt"
10
 	"fmt"
11
+	"strconv"
12
+	"strings"
10
 
13
 
11
 	"XT_New/models"
14
 	"XT_New/models"
12
 	"XT_New/utils"
15
 	"XT_New/utils"
13
 	"github.com/astaxie/beego"
16
 	"github.com/astaxie/beego"
17
+	"github.com/jinzhu/gorm"
18
+
14
 	//"github.com/jung-kurt/gofpdf"
19
 	//"github.com/jung-kurt/gofpdf"
15
 	"io/ioutil"
20
 	"io/ioutil"
16
 	"net/http"
21
 	"net/http"
2400
 
2405
 
2401
 	return outInfo, err
2406
 	return outInfo, err
2402
 }
2407
 }
2408
+
2409
+func GetHisPRrescriptionByUserOrgId(user_org_id int64) (prescription []*models.HisPrescriptionProject, err error) {
2410
+
2411
+	err = XTReadDB().Where("user_org_id = ? and status = 1 and type =3 and record_date =1738598400", 10752).Find(&prescription).Error
2412
+
2413
+	return prescription, err
2414
+}
2415
+
2416
+func GetHisDoctorAdviceByUserOrgId(user_org_id int64) (info []*models.HisDoctorAdviceInfo, err error) {
2417
+
2418
+	err = XTReadDB().Where("user_org_id = ? and status =1 and advice_date = 1738512000", user_org_id).Find(&info).Error
2419
+
2420
+	return info, err
2421
+}
2422
+
2423
+func BloodNewHisDrugsDelivery(orgID int64, creater int64, advice *models.HisDoctorAdviceInfo, tx *gorm.DB) (err error) {
2424
+
2425
+	// 1.判断药品是否来自专用字典的药品库
2426
+	// 2.判断当天当前机构有没有创建出库单,没有则创建
2427
+	// 3.创建出库流程
2428
+	// 3.1 实现先进先出逻辑 由于药品执行后,不可以修改和删除,所以不考虑出库后的退库和修改出库数量等
2429
+
2430
+	isHasWay := false
2431
+	record_time := int64(0)
2432
+	isHasWay = true
2433
+	record_time = advice.RecordDate
2434
+
2435
+	if isHasWay {
2436
+		//判断当天当前机构有没有创建出库单,没有则创建
2437
+		out, err := FindNewDrugStockOutByIsSys(orgID, 1, record_time, tx)
2438
+		houseConfig, _ := GetAllStoreHouseConfig(orgID)
2439
+		if err == gorm.ErrRecordNotFound {
2440
+			timeStr := "2025-02-03"
2441
+			timeArr := strings.Split(timeStr, "-")
2442
+			total, _ := FindAllDrugWarehouseOut(orgID)
2443
+			total = total + 1
2444
+			warehousing_out_order := strconv.FormatInt(orgID, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
2445
+			number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
2446
+			number = number + total
2447
+			warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
2448
+
2449
+			warehouseOut := models.DrugWarehouseOut{
2450
+				WarehouseOutOrderNumber: warehousing_out_order,
2451
+				OperationTime:           record_time,
2452
+				OrgId:                   orgID,
2453
+				Creater:                 creater,
2454
+				Ctime:                   record_time,
2455
+				Status:                  1,
2456
+				WarehouseOutTime:        record_time,
2457
+				Dealer:                  0,
2458
+				Manufacturer:            0,
2459
+				Type:                    1,
2460
+				IsSys:                   1,
2461
+				StorehouseId:            houseConfig.DrugStorehouseOut,
2462
+				IsCheck:                 1,
2463
+			}
2464
+			err := AddNewSigleDrugWarehouseOut(&warehouseOut, tx)
2465
+			if err != nil {
2466
+				utils.TraceLog("创建出库单失败 err = %v", err)
2467
+				return err
2468
+			} else {
2469
+				out = warehouseOut
2470
+			}
2471
+		}
2472
+
2473
+		//出库流程
2474
+		//1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
2475
+		drup, _ := FindNewBaseDrugLibRecord(orgID, advice.DrugId, tx)
2476
+		if drup.ID > 0 {
2477
+			prescribingNumber := advice.PrescribingNumber
2478
+			HisStoryBloodHisDrugDeliverInfo(orgID, prescribingNumber, &out, &drup, advice, prescribingNumber, advice.PrescribingNumberUnit, tx)
2479
+
2480
+		} else {
2481
+			return errors.New("药品信息不存在")
2482
+		}
2483
+
2484
+	}
2485
+
2486
+	return
2487
+}

+ 2 - 2
service/smart_sch.go 파일 보기

9
 
9
 
10
 func GetSmartSchPatientByKeyWord(orgID int64, keywords string) (patient []*models.SmartSchPatient, err error) {
10
 func GetSmartSchPatientByKeyWord(orgID int64, keywords string) (patient []*models.SmartSchPatient, err error) {
11
 	if orgID != 10517 {
11
 	if orgID != 10517 {
12
-		db := readDb.Model(&models.SmartSchPatient{}).Where("user_org_id=? and status=1 and  lapseto !=3", orgID)
12
+		db := readDb.Model(&models.SmartSchPatient{}).Where("user_org_id=? and status=1 and  lapseto !=3 and patient_type =1", orgID)
13
 		if len(keywords) > 0 {
13
 		if len(keywords) > 0 {
14
 			likekey := "%" + keywords + "%"
14
 			likekey := "%" + keywords + "%"
15
 			err = db.Where("name LIKE ? OR dialysis_no LIKE ?", likekey, likekey).Find(&patient).Error
15
 			err = db.Where("name LIKE ? OR dialysis_no LIKE ?", likekey, likekey).Find(&patient).Error
19
 	}
19
 	}
20
 
20
 
21
 	if orgID == 10517 {
21
 	if orgID == 10517 {
22
-		db := readDb.Model(&models.SmartSchPatient{}).Where("user_org_id=? and status=1 and  lapseto =1", orgID)
22
+		db := readDb.Model(&models.SmartSchPatient{}).Where("user_org_id=? and status=1 and  lapseto =1 and patient_type =1", orgID)
23
 		if len(keywords) > 0 {
23
 		if len(keywords) > 0 {
24
 			likekey := "%" + keywords + "%"
24
 			likekey := "%" + keywords + "%"
25
 			err = db.Where("name LIKE ? OR dialysis_no LIKE ?", likekey, likekey).Find(&patient).Error
25
 			err = db.Where("name LIKE ? OR dialysis_no LIKE ?", likekey, likekey).Find(&patient).Error

+ 12 - 10
service/statistics_service/index_evaluation_service.go 파일 보기

1
 package statistics_service
1
 package statistics_service
2
 
2
 
3
 import (
3
 import (
4
-	"XT_New/models"
5
-	"XT_New/service"
6
 	"fmt"
4
 	"fmt"
7
-	"github.com/jinzhu/gorm"
8
 	"math"
5
 	"math"
9
 	"strconv"
6
 	"strconv"
10
 	"strings"
7
 	"strings"
8
+
9
+	"XT_New/models"
10
+	"XT_New/service"
11
+	"github.com/jinzhu/gorm"
11
 )
12
 )
12
 
13
 
13
 func GetOrgFirstPatientInfo(user_org_id int64) (patient *models.Patients, err error) {
14
 func GetOrgFirstPatientInfo(user_org_id int64) (patient *models.Patients, err error) {
1930
 }
1931
 }
1931
 
1932
 
1932
 type VMPatient struct {
1933
 type VMPatient struct {
1933
-	ID        int64  `gorm:"column:id" json:"id" form:"id"`
1934
-	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1935
-	UserId    int64  `gorm:"column:user_id" json:"user_id" form:"user_id"`
1936
-	Name      string `gorm:"column:name" json:"name" form:"name"`
1937
-	Lapseto   int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
1938
-	Status    int64  `gorm:"column:status" json:"status" form:"status"`
1934
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
1935
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1936
+	UserId      int64  `gorm:"column:user_id" json:"user_id" form:"user_id"`
1937
+	Name        string `gorm:"column:name" json:"name" form:"name"`
1938
+	Lapseto     int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
1939
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
1940
+	PatientType int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
1939
 }
1941
 }
1940
 
1942
 
1941
 func (VMPatient) TableName() string {
1943
 func (VMPatient) TableName() string {
1945
 func GetOrgPatients(user_org_id int64) (patient *[]VMPatient, err error) {
1947
 func GetOrgPatients(user_org_id int64) (patient *[]VMPatient, err error) {
1946
 	db := service.XTReadDB()
1948
 	db := service.XTReadDB()
1947
 	var tempPatient []VMPatient
1949
 	var tempPatient []VMPatient
1948
-	findErr := db.Model(&models.Patients{}).Where("user_org_id = ? AND status = 1 AND lapseto = 1", user_org_id).Find(&tempPatient).Error
1950
+	findErr := db.Model(&models.Patients{}).Where("user_org_id = ? AND status = 1 AND lapseto = 1 and patient_type =1", user_org_id).Find(&tempPatient).Error
1949
 	if findErr == gorm.ErrRecordNotFound {
1951
 	if findErr == gorm.ErrRecordNotFound {
1950
 		return nil, nil
1952
 		return nil, nil
1951
 	}
1953
 	}

+ 24 - 2
service/stock_service.go 파일 보기

1821
 
1821
 
1822
 func FindAllSelfDrugWarehouseOut(org_id int64, tx *gorm.DB) (total int64, err error) {
1822
 func FindAllSelfDrugWarehouseOut(org_id int64, tx *gorm.DB) (total int64, err error) {
1823
 
1823
 
1824
-	err = tx.Model(&models.XtSelfDrugWarehouseOut{}).Where("org_id = ?", org_id).Count(&total).Error
1824
+	err = tx.Model(&models.XtDrugWarehouseOut{}).Where("org_id = ?", org_id).Count(&total).Error
1825
 	if err != gorm.ErrRecordNotFound {
1825
 	if err != gorm.ErrRecordNotFound {
1826
 		if err != nil {
1826
 		if err != nil {
1827
 			tx.Rollback()
1827
 			tx.Rollback()
6234
 	return flow, total, err
6234
 	return flow, total, err
6235
 }
6235
 }
6236
 
6236
 
6237
+func GetHidsDoctorAdvice(good_id int64, user_org_id int64, patient_id int64, record_date int64) (models.HisPrescriptionProject, error) {
6238
+
6239
+	project := models.HisPrescriptionProject{}
6240
+	err = XTReadDB().Where("project_id = ? and type =3 and user_org_id = ? and record_date =? and patient_id = ?", good_id, user_org_id, record_date, patient_id).Find(&project).Error
6241
+	return project, err
6242
+}
6243
+
6237
 func GetLastGoodListByPatientId(recordtime int64, patientid int64, goodid int64, goodtypeid int64) (models.AutomaticReduceDetail, error) {
6244
 func GetLastGoodListByPatientId(recordtime int64, patientid int64, goodid int64, goodtypeid int64) (models.AutomaticReduceDetail, error) {
6238
 
6245
 
6239
 	detail := models.AutomaticReduceDetail{}
6246
 	detail := models.AutomaticReduceDetail{}
6371
 	return drug_flow, total, err
6378
 	return drug_flow, total, err
6372
 }
6379
 }
6373
 
6380
 
6381
+func HisDoctorAdviceMap(patient_id int64, advice_date int64, drug_id int64, user_org_id int64) (models.HisDoctorAdviceInfo, error) {
6382
+
6383
+	advicelist := models.HisDoctorAdviceInfo{}
6384
+	err = XTReadDB().Where("patient_id = ? and  drug_id = ? and user_org_id = ? and advice_date = ? and status=1", patient_id, drug_id, user_org_id, advice_date).Find(&advicelist).Error
6385
+
6386
+	return advicelist, err
6387
+}
6388
+
6374
 func GetDrugWarehouseOutInfoIsExit(drug_id int64, patient_id int64, recordtime int64) (*models.DrugWarehouseOutInfo, error) {
6389
 func GetDrugWarehouseOutInfoIsExit(drug_id int64, patient_id int64, recordtime int64) (*models.DrugWarehouseOutInfo, error) {
6375
 
6390
 
6376
 	outInfo := models.DrugWarehouseOutInfo{}
6391
 	outInfo := models.DrugWarehouseOutInfo{}
11093
 	if user_org_id > 0 {
11108
 	if user_org_id > 0 {
11094
 		db = db.Where("user_org_id = ?", user_org_id)
11109
 		db = db.Where("user_org_id = ?", user_org_id)
11095
 	}
11110
 	}
11096
-	err = db.Find(&advice).Error
11111
+	err = db.Order("drug_id desc").Find(&advice).Error
11097
 
11112
 
11098
 	return advice, err
11113
 	return advice, err
11099
 }
11114
 }
11100
 
11115
 
11116
+func GetSelfDrugWarehouseInfoByPatientId(patient_id int64, user_org_id int64) (drugInfo []*models.XtSelfDrugWarehouseInfo, err error) {
11117
+
11118
+	err = XTReadDB().Where("patient_id = ? and org_id = ? and status =1 and is_check =1", patient_id, user_org_id).Find(&drugInfo).Error
11119
+	return drugInfo, err
11120
+
11121
+}
11122
+
11101
 func GetPatientAdviceListDetail(patient_id int64, start_time int64, end_time int64, user_org_id int64, advice_name string) (advice []*models.DoctorAdvice, err error) {
11123
 func GetPatientAdviceListDetail(patient_id int64, start_time int64, end_time int64, user_org_id int64, advice_name string) (advice []*models.DoctorAdvice, err error) {
11102
 
11124
 
11103
 	db := XTReadDB().Model(&advice).Where("status = 1")
11125
 	db := XTReadDB().Model(&advice).Where("status = 1")

+ 1 - 1
service/user_service.go 파일 보기

101
 	err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("uar.status=1 and uar.org_id=?  and ua.status=1", orgId).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&list).Error
101
 	err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("uar.status=1 and uar.org_id=?  and ua.status=1", orgId).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&list).Error
102
 
102
 
103
 	if orgId == 10724 {
103
 	if orgId == 10724 {
104
-		err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("uar.status=1 and uar.org_id=?", orgId).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&list).Error
104
+		err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("uar.org_id=?", orgId).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&list).Error
105
 	} else {
105
 	} else {
106
 		err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("uar.status=1 and uar.org_id=?  and ua.status=1", orgId).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&list).Error
106
 		err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("uar.status=1 and uar.org_id=?  and ua.status=1", orgId).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&list).Error
107
 	}
107
 	}

+ 6 - 6
service/warhouse_service.go 파일 보기

11190
 			over_count += its.StockMaxNumber + its.StockMinNumber
11190
 			over_count += its.StockMaxNumber + its.StockMinNumber
11191
 		}
11191
 		}
11192
 
11192
 
11193
-		drugWareInfo, _ := GetLastNewWarehouseOutInfoById(advice.DrugId, tx)
11193
+		//drugWareInfo, _ := GetLastNewWarehouseOutInfoById(advice.DrugId, tx)
11194
 		drugflow := models.DrugFlow{
11194
 		drugflow := models.DrugFlow{
11195
 			WarehouseOutId:          warehouseout.ID,
11195
 			WarehouseOutId:          warehouseout.ID,
11196
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
11196
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
11212
 			IsEdit:                  1,
11212
 			IsEdit:                  1,
11213
 			Creator:                 0,
11213
 			Creator:                 0,
11214
 			IsSys:                   0,
11214
 			IsSys:                   0,
11215
-			WarehouseOutDetailId:    drugWareInfo.ID,
11215
+			WarehouseOutDetailId:    advice.ID,
11216
 			AdviceId:                advice.ID,
11216
 			AdviceId:                advice.ID,
11217
 			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
11217
 			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
11218
 			StorehouseId:            advice.StorehouseId,
11218
 			StorehouseId:            advice.StorehouseId,
11237
 		outInfoLog := models.XtDrugWarehouseOutInfoLog{
11237
 		outInfoLog := models.XtDrugWarehouseOutInfoLog{
11238
 			UserOrgId:          advice.OrgId,
11238
 			UserOrgId:          advice.OrgId,
11239
 			DrugId:             advice.DrugId,
11239
 			DrugId:             advice.DrugId,
11240
-			WarehouseOutInfoId: drugWareInfo.ID,
11240
+			WarehouseOutInfoId: advice.ID,
11241
 			RecordDate:         advice.SysRecordTime,
11241
 			RecordDate:         advice.SysRecordTime,
11242
 			Status:             1,
11242
 			Status:             1,
11243
 			Ctime:              time.Now().Unix(),
11243
 			Ctime:              time.Now().Unix(),
11275
 			}
11275
 			}
11276
 			over_count += its.StockMaxNumber + its.StockMinNumber
11276
 			over_count += its.StockMaxNumber + its.StockMinNumber
11277
 		}
11277
 		}
11278
-		drugWareInfo, _ := GetLastNewWarehouseOutInfoById(advice.DrugId, tx)
11278
+		//drugWareInfo, _ := GetLastNewWarehouseOutInfoById(advice.DrugId, tx)
11279
 		drugflow := models.DrugFlow{
11279
 		drugflow := models.DrugFlow{
11280
 			WarehouseOutId:          warehouseout.ID,
11280
 			WarehouseOutId:          warehouseout.ID,
11281
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
11281
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
11297
 			IsEdit:                  1,
11297
 			IsEdit:                  1,
11298
 			Creator:                 0,
11298
 			Creator:                 0,
11299
 			IsSys:                   0,
11299
 			IsSys:                   0,
11300
-			WarehouseOutDetailId:    drugWareInfo.ID,
11300
+			WarehouseOutDetailId:    advice.ID,
11301
 			AdviceId:                advice.ID,
11301
 			AdviceId:                advice.ID,
11302
 			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
11302
 			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
11303
 			StorehouseId:            advice.StorehouseId,
11303
 			StorehouseId:            advice.StorehouseId,
11319
 		outInfoLog := models.XtDrugWarehouseOutInfoLog{
11319
 		outInfoLog := models.XtDrugWarehouseOutInfoLog{
11320
 			UserOrgId:          advice.OrgId,
11320
 			UserOrgId:          advice.OrgId,
11321
 			DrugId:             advice.DrugId,
11321
 			DrugId:             advice.DrugId,
11322
-			WarehouseOutInfoId: drugWareInfo.ID,
11322
+			WarehouseOutInfoId: advice.ID,
11323
 			RecordDate:         advice.SysRecordTime,
11323
 			RecordDate:         advice.SysRecordTime,
11324
 			Status:             1,
11324
 			Status:             1,
11325
 			Ctime:              time.Now().Unix(),
11325
 			Ctime:              time.Now().Unix(),