浏览代码

11月9日库存管理

XMLWAN 2 年前
父节点
当前提交
9ce7d5e302

+ 1 - 1
conf/app.conf 查看文件

1
 appname = 血透
1
 appname = 血透
2
-httpport = 9529
2
+httpport = 9531
3
 runmode = dev
3
 runmode = dev
4
 #dev/prod
4
 #dev/prod
5
 
5
 

+ 314 - 5
controllers/dialysis_api_controller.go 查看文件

105
 	beego.Router("/api/schedule/checknewdoctoradvice", &DialysisApiController{}, "Get:CheckNewDoctorAdvice")
105
 	beego.Router("/api/schedule/checknewdoctoradvice", &DialysisApiController{}, "Get:CheckNewDoctorAdvice")
106
 
106
 
107
 	beego.Router("/api/schedule/settlenewdoctoradvice", &DialysisApiController{}, "Get:SettleNewDoctorAdvice")
107
 	beego.Router("/api/schedule/settlenewdoctoradvice", &DialysisApiController{}, "Get:SettleNewDoctorAdvice")
108
+
109
+	beego.Router("/api/schedule/excutiondoctoradvicebyid", &DialysisApiController{}, "Get:ExcutionDoctorAdviceById")
108
 }
110
 }
109
 
111
 
110
 func (c *DialysisApiController) GetQueueCall() {
112
 func (c *DialysisApiController) GetQueueCall() {
3473
 		advice.UserOrgId = adminUserInfo.CurrentOrgId
3475
 		advice.UserOrgId = adminUserInfo.CurrentOrgId
3474
 		advice.PatientId = patient
3476
 		advice.PatientId = patient
3475
 		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
3477
 		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
3476
-
3478
+		advice.IsSettle = 2
3477
 		if adviceNameM["advice_name"] == nil || reflect.TypeOf(adviceNameM["advice_name"]).String() != "string" {
3479
 		if adviceNameM["advice_name"] == nil || reflect.TypeOf(adviceNameM["advice_name"]).String() != "string" {
3478
 			utils.ErrorLog("advice_name")
3480
 			utils.ErrorLog("advice_name")
3479
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3481
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3600
 					child.UserOrgId = adminUserInfo.CurrentOrgId
3602
 					child.UserOrgId = adminUserInfo.CurrentOrgId
3601
 					child.PatientId = patient
3603
 					child.PatientId = patient
3602
 					child.AdviceDoctor = adminUserInfo.AdminUser.Id
3604
 					child.AdviceDoctor = adminUserInfo.AdminUser.Id
3603
-
3605
+					child.IsSettle = 2
3604
 					if childMap["advice_name"] == nil || reflect.TypeOf(childMap["advice_name"]).String() != "string" {
3606
 					if childMap["advice_name"] == nil || reflect.TypeOf(childMap["advice_name"]).String() != "string" {
3605
 						utils.ErrorLog("child advice_name")
3607
 						utils.ErrorLog("child advice_name")
3606
 						return
3608
 						return
4767
 		groupList, _ := service.GetHisExcutionDoctorAdviceListGroupList(recordIDStrs, startTime, orgId)
4769
 		groupList, _ := service.GetHisExcutionDoctorAdviceListGroupList(recordIDStrs, startTime, orgId)
4768
 		//查找未执行医嘱
4770
 		//查找未执行医嘱
4769
 		list, _ := service.GetHisExcutionDoctorAdviceList(recordIDStrs, startTime, orgId)
4771
 		list, _ := service.GetHisExcutionDoctorAdviceList(recordIDStrs, startTime, orgId)
4772
+		for _, item := range list {
4773
+			if item.Checker == this.GetAdminUserInfo().AdminUser.Id {
4774
+				this.ServeSuccessJSON(map[string]interface{}{
4775
+					"msg": "3",
4776
+				})
4777
+				return
4778
+			}
4779
+		}
4770
 		for _, item := range groupList {
4780
 		for _, item := range groupList {
4771
 			for _, it := range list {
4781
 			for _, it := range list {
4772
 				if item.DrugId == it.DrugId {
4782
 				if item.DrugId == it.DrugId {
5043
 func (this *DialysisApiController) CheckNewDoctorAdvice() {
5053
 func (this *DialysisApiController) CheckNewDoctorAdvice() {
5044
 
5054
 
5045
 	orgId := this.GetAdminUserInfo().CurrentOrgId
5055
 	orgId := this.GetAdminUserInfo().CurrentOrgId
5046
-	is_open, _ := this.GetInt64("is_open")
5047
 	idsStr := this.GetString("str")
5056
 	idsStr := this.GetString("str")
5048
 	recordIDStrs := strings.Split(idsStr, ",")
5057
 	recordIDStrs := strings.Split(idsStr, ",")
5049
 	start_time := this.GetString("advice_date")
5058
 	start_time := this.GetString("advice_date")
5060
 		startTime = theTime.Unix()
5069
 		startTime = theTime.Unix()
5061
 	}
5070
 	}
5062
 
5071
 
5063
-	if is_open == 1 {
5072
+	config, _ := service.FindXTHisRecordByOrgIdSix(orgId)
5073
+
5074
+	if config.IsOpen == 1 {
5064
 
5075
 
5065
 		creater := this.GetAdminUserInfo().AdminUser.Id
5076
 		creater := this.GetAdminUserInfo().AdminUser.Id
5066
 		//查询未核对的医嘱
5077
 		//查询未核对的医嘱
5075
 			}
5086
 			}
5076
 
5087
 
5077
 			service.CheckHisDoctorAdvice(item.ID, creater)
5088
 			service.CheckHisDoctorAdvice(item.ID, creater)
5089
+
5090
+			key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
5091
+			redis := service.RedisClient()
5092
+			//清空key 值
5093
+			redis.Set(key, "", time.Second)
5094
+			keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
5095
+			redis.Set(keyTwo, "", time.Second)
5096
+			keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
5097
+			redis.Set(keyThree, "", time.Second)
5098
+			theTime := time.Now()
5099
+			recordDate := theTime.Format("2006-01-02")
5100
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
5101
+
5102
+			redis.Set(keyFour, "", time.Second)
5103
+			keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
5104
+			redis.Set(keyFive, "", time.Second)
5105
+
5078
 		}
5106
 		}
5079
 	} else {
5107
 	} else {
5080
 
5108
 
5090
 				return
5118
 				return
5091
 			}
5119
 			}
5092
 
5120
 
5093
-			service.CheckHisDoctorAdvice(item.ID, creater)
5121
+			service.CheckDoctorAdvice(item.ID, creater)
5122
+			key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
5123
+			redis := service.RedisClient()
5124
+			//清空key 值
5125
+			redis.Set(key, "", time.Second)
5126
+			keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
5127
+			redis.Set(keyTwo, "", time.Second)
5128
+			keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
5129
+			redis.Set(keyThree, "", time.Second)
5130
+			theTime := time.Now()
5131
+			recordDate := theTime.Format("2006-01-02")
5132
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
5133
+
5134
+			redis.Set(keyFour, "", time.Second)
5135
+			keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
5136
+			redis.Set(keyFive, "", time.Second)
5094
 		}
5137
 		}
5095
 	}
5138
 	}
5096
 
5139
 
5130
 	})
5173
 	})
5131
 	return
5174
 	return
5132
 }
5175
 }
5176
+
5177
+func (this *DialysisApiController) ExcutionDoctorAdviceById() {
5178
+
5179
+	advice_id, _ := this.GetInt64("advice_id")
5180
+	start_time := this.GetString("advice_date")
5181
+	orgId := this.GetAdminUserInfo().CurrentOrgId
5182
+	config, _ := service.FindXTHisRecordByOrgIdSix(orgId)
5183
+	exec_time, _ := this.GetInt64("exec_time")
5184
+
5185
+	//his医嘱
5186
+	if config.IsOpen == 1 {
5187
+
5188
+		//查询医嘱
5189
+		advice, _ := service.GetHisDocById(advice_id, orgId)
5190
+		if advice.Checker == this.GetAdminUserInfo().AdminUser.Id {
5191
+			this.ServeSuccessJSON(map[string]interface{}{
5192
+				"msg": "3",
5193
+			})
5194
+			return
5195
+		}
5196
+		medical, _ := service.GetBaseDrugMedical(orgId)
5197
+		var prescribing_number int64
5198
+		stringPrescribingNumber := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 64)
5199
+		parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
5200
+		if advice.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
5201
+			prescribing_number = parseIntPrescribingNumber * medical.MinNumber
5202
+		}
5203
+		if advice.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
5204
+			prescribing_number = parseIntPrescribingNumber
5205
+		}
5206
+		if advice.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
5207
+			prescribing_number = parseIntPrescribingNumber
5208
+		}
5209
+
5210
+		drugStockOut, _ := service.GetDrugSumOutCountByDrugId(advice.DrugId, orgId)
5211
+		//库存不足
5212
+		if prescribing_number > drugStockOut.FlushCount {
5213
+			this.ServeSuccessJSON(map[string]interface{}{
5214
+				"msg":  "2",
5215
+				"drug": medical,
5216
+			})
5217
+			return
5218
+		}
5219
+		info := models.HisDoctorAdviceInfo{
5220
+			ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
5221
+			ExecutionTime:  exec_time,
5222
+			ExecutionState: 1,
5223
+			UpdatedTime:    time.Now().Unix(),
5224
+		}
5225
+		//执行医嘱
5226
+		service.UpdateHisDoctorAdviceExecution(info, advice.ID)
5227
+
5228
+		key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
5229
+		redis := service.RedisClient()
5230
+		//清空key 值
5231
+		redis.Set(key, "", time.Second)
5232
+		keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
5233
+
5234
+		redis.Set(keyTwo, "", time.Second)
5235
+		keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
5236
+		redis.Set(keyThree, "", time.Second)
5237
+		toTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", start_time)
5238
+		theTime := toTime.Format("2006-01-02")
5239
+
5240
+		fmt.Println("theTIME", theTime)
5241
+		keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(orgId, 10)
5242
+
5243
+		redis.Set(keyFour, "", time.Second)
5244
+		keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
5245
+		redis.Set(keyFive, "", time.Second)
5246
+
5247
+		//出库
5248
+		if prescribing_number <= drugStockOut.FlushCount {
5249
+			pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
5250
+			//执行出库逻辑
5251
+			hisadvice := &models.HisDoctorAdviceInfo{
5252
+				ID:                    advice.ID,
5253
+				UserOrgId:             advice.UserOrgId,
5254
+				PatientId:             advice.PatientId,
5255
+				AdviceType:            advice.AdviceType,
5256
+				AdviceDate:            advice.AdviceDate,
5257
+				StartTime:             advice.StartTime,
5258
+				AdviceName:            advice.AdviceName,
5259
+				AdviceDesc:            advice.AdviceDesc,
5260
+				ReminderDate:          advice.ReminderDate,
5261
+				SingleDose:            advice.SingleDose,
5262
+				SingleDoseUnit:        advice.SingleDoseUnit,
5263
+				DrugSpec:              advice.DrugSpec,
5264
+				DrugSpecUnit:          advice.DrugSpecUnit,
5265
+				PrescribingNumber:     advice.PrescribingNumber,
5266
+				PrescribingNumberUnit: advice.PrescribingNumberUnit,
5267
+				DeliveryWay:           advice.DeliveryWay,
5268
+				ExecutionFrequency:    advice.ExecutionFrequency,
5269
+				AdviceDoctor:          advice.AdviceDoctor,
5270
+				Status:                1,
5271
+				CreatedTime:           advice.CreatedTime,
5272
+				UpdatedTime:           advice.UpdatedTime,
5273
+				AdviceAffirm:          advice.AdviceAffirm,
5274
+				Remark:                advice.Remark,
5275
+				StopTime:              advice.StopTime,
5276
+				StopReason:            advice.StopReason,
5277
+				StopDoctor:            advice.StopDoctor,
5278
+				StopState:             advice.StopState,
5279
+				ParentId:              advice.ParentId,
5280
+				ExecutionTime:         advice.ExecutionTime,
5281
+				ExecutionStaff:        this.GetAdminUserInfo().AdminUser.Id,
5282
+				ExecutionState:        advice.ExecutionState,
5283
+				Checker:               advice.Checker,
5284
+				RecordDate:            advice.RecordDate,
5285
+				DialysisOrderId:       advice.DialysisOrderId,
5286
+				CheckTime:             advice.CheckTime,
5287
+				CheckState:            advice.CheckState,
5288
+				RemindType:            advice.RemindType,
5289
+				FrequencyType:         advice.FrequencyType,
5290
+				DayCount:              advice.DayCount,
5291
+				WeekDay:               advice.WeekDay,
5292
+				TemplateId:            advice.TemplateId,
5293
+				Modifier:              advice.Modifier,
5294
+				Way:                   advice.Way,
5295
+				DrugId:                advice.DrugId,
5296
+				ExecutionFrequencyId:  advice.ExecutionFrequencyId,
5297
+			}
5298
+			if medical.IsUse == 2 {
5299
+				if config.IsOpen != 1 {
5300
+					if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
5301
+						service.HisDrugsDelivery(advice.UserOrgId, advice.ExecutionStaff, hisadvice)
5302
+
5303
+					}
5304
+					//不通过药房发药
5305
+					if pharmacyConfig.IsOpen != 1 {
5306
+						service.HisDrugsDelivery(advice.UserOrgId, advice.ExecutionStaff, hisadvice)
5307
+					}
5308
+					//查询默认仓库
5309
+					storeHouseConfig, _ := service.GetAllStoreHouseConfig(advice.UserOrgId)
5310
+					//查询默认仓库剩余多少库存
5311
+					var sum_count int64
5312
+					stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, advice.UserOrgId, advice.DrugId)
5313
+					for _, its := range stockInfo {
5314
+						if its.MaxUnit == medical.MaxUnit {
5315
+							its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
5316
+						}
5317
+						sum_count += its.StockMaxNumber + its.StockMinNumber
5318
+					}
5319
+					service.UpdateBaseDrugSumTwo(advice.DrugId, sum_count, advice.UserOrgId)
5320
+					service.UpdateDrugStockCount(advice.DrugId, advice.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
5321
+				}
5322
+			}
5323
+		}
5324
+
5325
+		this.ServeSuccessJSON(map[string]interface{}{
5326
+			"msg": "1",
5327
+		})
5328
+		return
5329
+	}
5330
+
5331
+	if config.IsOpen == 2 || config.IsOpen == 0 {
5332
+
5333
+		advice, _ := service.GetBloodDocById(advice_id, orgId)
5334
+		medical, _ := service.GetBaseDrugMedical(orgId)
5335
+		pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
5336
+		storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
5337
+		var prescribing_number int64
5338
+		stringPrescribingNumber := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 64)
5339
+		parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
5340
+		if advice.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
5341
+			prescribing_number = parseIntPrescribingNumber * medical.MinNumber
5342
+		}
5343
+		if advice.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
5344
+			prescribing_number = parseIntPrescribingNumber
5345
+		}
5346
+		if advice.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
5347
+			prescribing_number = parseIntPrescribingNumber
5348
+		}
5349
+		drugStockOut, _ := service.GetDrugSumOutCountByDrugId(advice.DrugId, orgId)
5350
+		//库存不足
5351
+		if prescribing_number > drugStockOut.FlushCount {
5352
+			this.ServeSuccessJSON(map[string]interface{}{
5353
+				"msg":  "2",
5354
+				"drug": medical,
5355
+			})
5356
+			return
5357
+		}
5358
+		info := models.DoctorAdvice{
5359
+			ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
5360
+			ExecutionTime:  exec_time,
5361
+			ExecutionState: 1,
5362
+			UpdatedTime:    time.Now().Unix(),
5363
+		}
5364
+		//执行医嘱
5365
+		service.UpdateDoctorAdviceExecution(info, advice.ID)
5366
+
5367
+		dadvice := &models.DoctorAdvice{
5368
+			ID:                    advice.ID,
5369
+			UserOrgId:             advice.UserOrgId,
5370
+			PatientId:             advice.PatientId,
5371
+			AdviceType:            advice.AdviceType,
5372
+			AdviceDate:            advice.AdviceDate,
5373
+			StartTime:             advice.StartTime,
5374
+			AdviceName:            advice.AdviceName,
5375
+			AdviceDesc:            advice.AdviceDesc,
5376
+			ReminderDate:          advice.ReminderDate,
5377
+			SingleDose:            advice.SingleDose,
5378
+			SingleDoseUnit:        advice.SingleDoseUnit,
5379
+			DrugSpec:              advice.DrugSpec,
5380
+			DrugSpecUnit:          advice.DrugSpecUnit,
5381
+			PrescribingNumber:     advice.PrescribingNumber,
5382
+			PrescribingNumberUnit: advice.PrescribingNumberUnit,
5383
+			DeliveryWay:           advice.DeliveryWay,
5384
+			ExecutionFrequency:    advice.ExecutionFrequency,
5385
+			AdviceDoctor:          advice.AdviceDoctor,
5386
+			Status:                1,
5387
+			CreatedTime:           advice.CreatedTime,
5388
+			UpdatedTime:           advice.UpdatedTime,
5389
+			AdviceAffirm:          advice.AdviceAffirm,
5390
+			Remark:                advice.Remark,
5391
+			StopTime:              advice.StopTime,
5392
+			StopReason:            advice.StopReason,
5393
+			StopDoctor:            advice.StopDoctor,
5394
+			StopState:             advice.StopState,
5395
+			ParentId:              advice.ParentId,
5396
+			ExecutionTime:         advice.ExecutionTime,
5397
+			ExecutionStaff:        advice.ExecutionStaff,
5398
+			ExecutionState:        advice.ExecutionState,
5399
+			Checker:               advice.Checker,
5400
+			RecordDate:            advice.ReminderDate,
5401
+			DialysisOrderId:       advice.DialysisOrderId,
5402
+			CheckTime:             advice.CheckTime,
5403
+			CheckState:            advice.CheckState,
5404
+			RemindType:            advice.RemindType,
5405
+			FrequencyType:         advice.FrequencyType,
5406
+			DayCount:              advice.DayCount,
5407
+			WeekDay:               advice.WeekDay,
5408
+			TemplateId:            advice.TemplateId,
5409
+			Modifier:              advice.Modifier,
5410
+			Way:                   advice.Way,
5411
+			DrugId:                advice.DrugId,
5412
+		}
5413
+		if medical.IsUse == 2 {
5414
+			if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
5415
+				service.DrugsDelivery(advice.UserOrgId, advice.ExecutionStaff, dadvice)
5416
+			}
5417
+			if pharmacyConfig.IsOpen != 1 {
5418
+				service.DrugsDelivery(advice.UserOrgId, advice.ExecutionStaff, dadvice)
5419
+			}
5420
+
5421
+			//更新字典里面的库存
5422
+			stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, advice.UserOrgId, advice.DrugId)
5423
+			var sum_count int64
5424
+			for _, its := range stockInfo {
5425
+				baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
5426
+				if its.MaxUnit == baseDrug.MaxUnit {
5427
+					its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
5428
+				}
5429
+				sum_count += its.StockMaxNumber + its.StockMinNumber
5430
+			}
5431
+			service.UpdateBaseDrugSumTwo(advice.DrugId, sum_count, advice.UserOrgId)
5432
+			//剩余库存
5433
+			service.UpdateDrugStockCount(advice.DrugId, advice.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
5434
+		}
5435
+	}
5436
+	this.ServeSuccessJSON(map[string]interface{}{
5437
+		"msg": "1",
5438
+	})
5439
+	return
5440
+
5441
+}

+ 16 - 2
controllers/dialysis_record_api_controller.go 查看文件

787
 	blood_access_id, _ := this.GetInt64("blood_access_id")
787
 	blood_access_id, _ := this.GetInt64("blood_access_id")
788
 	bedID, _ := this.GetInt64("bed")
788
 	bedID, _ := this.GetInt64("bed")
789
 	nuclein_date := this.GetString("nuclein_date")
789
 	nuclein_date := this.GetString("nuclein_date")
790
-
790
+	schedule_remark := this.GetString("schedule_remark")
791
+	order_remark := this.GetString("order_remark")
791
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
792
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
792
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
793
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
793
 		return
794
 		return
1001
 		DialysisIrrigation:     dialysis_irrigation,
1002
 		DialysisIrrigation:     dialysis_irrigation,
1002
 		BloodAccessId:          blood_access_id,
1003
 		BloodAccessId:          blood_access_id,
1003
 		NucleinDate:            theNucleinDate,
1004
 		NucleinDate:            theNucleinDate,
1005
+		ScheduleRemark:         schedule_remark,
1006
+		OrderRemark:            order_remark,
1004
 	}
1007
 	}
1005
 
1008
 
1006
 	createErr := service.MobileCreateDialysisOrder(adminUserInfo.CurrentOrgId, patientID, dialysisRecord)
1009
 	createErr := service.MobileCreateDialysisOrder(adminUserInfo.CurrentOrgId, patientID, dialysisRecord)
1010
+	//更新患者表排班备注
1011
+	service.UpdateMobilePatient(adminUserInfo.CurrentOrgId, patientID, schedule_remark)
1007
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
1012
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
1008
 	redis := service.RedisClient()
1013
 	redis := service.RedisClient()
1009
 	//清空key 值
1014
 	//清空key 值
1539
 	dialysis_irrigation := this.GetString("dialysis_irrigation")
1544
 	dialysis_irrigation := this.GetString("dialysis_irrigation")
1540
 	blood_access_id, _ := this.GetInt64("blood_access_id")
1545
 	blood_access_id, _ := this.GetInt64("blood_access_id")
1541
 	nuclein_date := this.GetString("nuclein_date")
1546
 	nuclein_date := this.GetString("nuclein_date")
1547
+	schedule_remark := this.GetString("schedule_remark")
1548
+	order_remark := this.GetString("order_remark")
1542
 	if record_id == 0 {
1549
 	if record_id == 0 {
1543
 		this.ErrorLog("id:%v", record_id)
1550
 		this.ErrorLog("id:%v", record_id)
1544
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1551
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1680
 		}
1687
 		}
1681
 
1688
 
1682
 	}
1689
 	}
1683
-	fmt.Println("theNucleinDate", theNucleinDate)
1690
+
1684
 	dialysisRecord := &models.DialysisOrder{
1691
 	dialysisRecord := &models.DialysisOrder{
1685
 		ID:                     record_id,
1692
 		ID:                     record_id,
1686
 		UserOrgId:              adminUserInfo.CurrentOrgId,
1693
 		UserOrgId:              adminUserInfo.CurrentOrgId,
1702
 		DialysisIrrigation:     dialysis_irrigation,
1709
 		DialysisIrrigation:     dialysis_irrigation,
1703
 		BloodAccessId:          blood_access_id,
1710
 		BloodAccessId:          blood_access_id,
1704
 		NucleinDate:            theNucleinDate,
1711
 		NucleinDate:            theNucleinDate,
1712
+		ScheduleRemark:         schedule_remark,
1713
+		OrderRemark:            order_remark,
1705
 	}
1714
 	}
1706
 
1715
 
1707
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
1716
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
1717
+
1718
+	order, _ := service.GetLastPatientOrder(record_id)
1719
+
1720
+	service.UpdateMobilePatient(adminUserInfo.CurrentOrgId, order.PatientId, schedule_remark)
1721
+
1708
 	redis := service.RedisClient()
1722
 	redis := service.RedisClient()
1709
 	key := strconv.FormatInt(tempDialysisRecord.UserOrgId, 10) + ":" + strconv.FormatInt(tempDialysisRecord.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecord.DialysisDate, 10) + ":dialysis_order"
1723
 	key := strconv.FormatInt(tempDialysisRecord.UserOrgId, 10) + ":" + strconv.FormatInt(tempDialysisRecord.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecord.DialysisDate, 10) + ":dialysis_order"
1710
 	redis.Set(key, "", time.Second)
1724
 	redis.Set(key, "", time.Second)

+ 222 - 5
controllers/his_api_controller.go 查看文件

5341
 
5341
 
5342
 		var goods []*models.DialysisBeforePrepareGoods
5342
 		var goods []*models.DialysisBeforePrepareGoods
5343
 		var newGoods []*models.NewDialysisBeforePrepareGoods
5343
 		var newGoods []*models.NewDialysisBeforePrepareGoods
5344
+		var oldGoods []*models.OldDialysisBeforePrepareGoods
5344
 		var infos []*models.HisDoctorAdviceInfo
5345
 		var infos []*models.HisDoctorAdviceInfo
5346
+		var infoList []*models.HisDoctorAdviceInfo
5345
 		var hisAdvice []*models.HisDoctorAdviceInfo
5347
 		var hisAdvice []*models.HisDoctorAdviceInfo
5346
 		var newGoodOne []*models.NewDialysisBeforePrepareGoods
5348
 		var newGoodOne []*models.NewDialysisBeforePrepareGoods
5347
 		houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
5349
 		houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
5538
 		if err == nil {
5540
 		if err == nil {
5539
 			for _, info := range prescriptions {
5541
 			for _, info := range prescriptions {
5540
 				if info.Type == 1 {
5542
 				if info.Type == 1 {
5541
-					infos = append(infos, info.HisDoctorAdviceInfo...)
5543
+					infoList = append(infoList, info.HisDoctorAdviceInfo...)
5542
 				}
5544
 				}
5543
 				if info.Type == 2 {
5545
 				if info.Type == 2 {
5544
 					for _, sumItem := range info.HisPrescriptionProject {
5546
 					for _, sumItem := range info.HisPrescriptionProject {
5545
 						if sumItem.Type == 3 {
5547
 						if sumItem.Type == 3 {
5546
 							var good models.DialysisBeforePrepareGoods
5548
 							var good models.DialysisBeforePrepareGoods
5547
 							var newGood models.NewDialysisBeforePrepareGoods
5549
 							var newGood models.NewDialysisBeforePrepareGoods
5550
+							var oldGood models.OldDialysisBeforePrepareGoods
5548
 							good.GoodId = sumItem.GoodInfo.ID
5551
 							good.GoodId = sumItem.GoodInfo.ID
5549
 							good.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5552
 							good.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5550
 							count, _ := strconv.Atoi(sumItem.Count)
5553
 							count, _ := strconv.Atoi(sumItem.Count)
5560
 							newGood.StorehouseId = houseConfig.StorehouseOutInfo
5563
 							newGood.StorehouseId = houseConfig.StorehouseOutInfo
5561
 							newGood.ProjectId = sumItem.ID
5564
 							newGood.ProjectId = sumItem.ID
5562
 							newGoods = append(newGoods, &newGood)
5565
 							newGoods = append(newGoods, &newGood)
5566
+
5567
+							oldGood.GoodId = sumItem.GoodInfo.ID
5568
+							oldGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5569
+							count3, _ := strconv.Atoi(sumItem.Count)
5570
+							oldGood.Count = int64(count3)
5571
+							oldGood.StorehouseId = houseConfig.StorehouseOutInfo
5572
+							oldGood.ProjectId = sumItem.ID
5573
+							oldGood.RecordDate = sumItem.RecordDate
5574
+
5575
+							oldGoods = append(oldGoods, &oldGood)
5563
 						}
5576
 						}
5564
 
5577
 
5565
 					}
5578
 					}
5567
 				}
5580
 				}
5568
 			}
5581
 			}
5569
 			if settConfig.IsOpen == 1 {
5582
 			if settConfig.IsOpen == 1 {
5570
-				for _, item := range infos {
5583
+				fmt.Println("infos23233232232323323233223wo", infoList)
5584
+				for _, item := range infoList {
5585
+					medical, _ := service.GetBaseDrugMedical(item.DrugId)
5571
 					service.HisDrugsDelivery(item.UserOrgId, adminUser.AdminUser.Id, item)
5586
 					service.HisDrugsDelivery(item.UserOrgId, adminUser.AdminUser.Id, item)
5587
+					//查询默认仓库
5588
+					storeHouseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
5589
+					//查询默认仓库剩余多少库存
5590
+					var sum_count int64
5591
+					stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
5592
+					for _, its := range stockInfo {
5593
+						if its.MaxUnit == medical.MaxUnit {
5594
+							its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
5595
+						}
5596
+						sum_count += its.StockMaxNumber + its.StockMinNumber
5597
+					}
5598
+					service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
5599
+					service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
5600
+				}
5601
+
5602
+				for _, item := range oldGoods {
5603
+					dialyPrepareOne := models.DialysisBeforePrepare{
5604
+						GoodTypeId:   item.GoodTypeId,
5605
+						GoodId:       item.GoodId,
5606
+						PatientId:    item.PatientId,
5607
+						RecordDate:   item.RecordDate,
5608
+						UserOrgId:    item.UserOrgId,
5609
+						Count:        item.Count,
5610
+						Ctime:        time.Now().Unix(),
5611
+						Creater:      adminUser.AdminUser.Id,
5612
+						CommdityCode: item.CommdityCode,
5613
+						Status:       1,
5614
+						StorehouseId: houseConfig.StorehouseOutInfo,
5615
+					}
5616
+					err = service.CreateDialysisBeforePrepareOne(&dialyPrepareOne)
5572
 				}
5617
 				}
5618
+
5573
 				service.ConsumablesDeliveryTotal(adminUser.CurrentOrgId, his.PatientId, his.RecordDate, goods, newGoods, adminUser.AdminUser.Id)
5619
 				service.ConsumablesDeliveryTotal(adminUser.CurrentOrgId, his.PatientId, his.RecordDate, goods, newGoods, adminUser.AdminUser.Id)
5620
+				//查询默认仓库
5621
+				//storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
5622
+				//stockList, _ := service.GetStockCountByGoodId(goods.GoodId, storeHouseConfig.StorehouseOutInfo,adminUser.CurrentOrgId)
5623
+				//var total_count int64
5624
+				//for _, it := range stockList {
5625
+				//  total_count += it.StockCount
5626
+				//}
5627
+				////基础库插入数据
5628
+				//service.UpdateGoodInfoReduceSumCount(goods.GoodId, total_count, adminUser.CurrentOrgId)
5629
+				//
5630
+				//////更新剩余库存
5631
+				//
5632
+				//goodList, _ := service.GetSumGoodList(adminUser.CurrentOrgId, storeHouseConfig.StorehouseOutInfo, goods.GoodId)
5633
+				//var flush_count int64
5634
+				//for _, it := range goodList {
5635
+				//  flush_count += it.StockCount
5636
+				//}
5637
+				//errs := service.UpdateSumGood(adminUser.CurrentOrgId, storeHouseConfig.StorehouseOutInfo, goods.GoodId, flush_count)
5638
+				//fmt.Println(errs)
5574
 			}
5639
 			}
5575
 
5640
 
5576
 			c.ServeSuccessJSON(map[string]interface{}{
5641
 			c.ServeSuccessJSON(map[string]interface{}{
5607
 				var goods []*models.DialysisBeforePrepareGoods
5672
 				var goods []*models.DialysisBeforePrepareGoods
5608
 				var newGoods []*models.NewDialysisBeforePrepareGoods
5673
 				var newGoods []*models.NewDialysisBeforePrepareGoods
5609
 				var infos []*models.HisDoctorAdviceInfo
5674
 				var infos []*models.HisDoctorAdviceInfo
5610
-
5675
+				var hisAdvice []*models.HisDoctorAdviceInfo
5676
+				var newGoodOne []*models.NewDialysisBeforePrepareGoods
5677
+				var infolist []*models.HisDoctorAdviceInfo
5678
+				var oldGoods []*models.OldDialysisBeforePrepareGoods
5611
 				for _, info := range prescriptions {
5679
 				for _, info := range prescriptions {
5612
 					if info.Type == 1 {
5680
 					if info.Type == 1 {
5613
 						infos = append(infos, info.HisDoctorAdviceInfo...)
5681
 						infos = append(infos, info.HisDoctorAdviceInfo...)
5638
 
5706
 
5639
 					}
5707
 					}
5640
 				}
5708
 				}
5709
+
5641
 				settConfig, _ := service.GetSettleOpenConfigByOrgId(adminUser.CurrentOrgId)
5710
 				settConfig, _ := service.GetSettleOpenConfigByOrgId(adminUser.CurrentOrgId)
5642
 				if settConfig.IsOpen == 1 {
5711
 				if settConfig.IsOpen == 1 {
5643
-					for _, item := range infos {
5712
+
5713
+					//判断库存的地方
5714
+					for _, info := range prescriptions {
5715
+						if info.Type == 1 {
5716
+							infolist = append(infolist, info.HisDoctorAdviceInfo...)
5717
+
5718
+						}
5719
+						if info.Type == 2 {
5720
+							for _, sumItem := range info.HisPrescriptionProject {
5721
+								if sumItem.Type == 3 {
5722
+									var good models.DialysisBeforePrepareGoods
5723
+									var newGood models.NewDialysisBeforePrepareGoods
5724
+									var oldGood models.OldDialysisBeforePrepareGoods
5725
+									good.GoodId = sumItem.GoodInfo.ID
5726
+									good.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5727
+									count, _ := strconv.Atoi(sumItem.Count)
5728
+									good.Count = int64(count)
5729
+									good.StorehouseId = houseConfig.StorehouseOutInfo
5730
+									good.ProjectId = sumItem.ID
5731
+									goods = append(goods, &good)
5732
+
5733
+									newGood.GoodId = sumItem.GoodInfo.ID
5734
+									newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5735
+									count2, _ := strconv.Atoi(sumItem.Count)
5736
+									newGood.Count = int64(count2)
5737
+									newGood.StorehouseId = houseConfig.StorehouseOutInfo
5738
+									newGood.ProjectId = sumItem.ID
5739
+									newGoods = append(newGoods, &newGood)
5740
+
5741
+									oldGood.GoodId = sumItem.GoodInfo.ID
5742
+									oldGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5743
+									count3, _ := strconv.Atoi(sumItem.Count)
5744
+									oldGood.Count = int64(count3)
5745
+									oldGood.StorehouseId = houseConfig.StorehouseOutInfo
5746
+									oldGood.ProjectId = sumItem.ID
5747
+									oldGood.RecordDate = sumItem.RecordDate
5748
+
5749
+									oldGoods = append(oldGoods, &oldGood)
5750
+								}
5751
+							}
5752
+						}
5753
+					}
5754
+
5755
+					for _, info := range prescriptionsOne {
5756
+						if info.Type == 1 {
5757
+							hisAdvice = append(hisAdvice, info.HisDoctorAdviceInfo...)
5758
+						}
5759
+
5760
+						if info.Type == 2 {
5761
+							for _, sumItem := range info.HisPrescriptionProject {
5762
+								if sumItem.Type == 3 {
5763
+									var newGood models.NewDialysisBeforePrepareGoods
5764
+
5765
+									newGood.GoodId = sumItem.GoodInfo.ID
5766
+									newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5767
+									count2, _ := strconv.Atoi(sumItem.Count)
5768
+									newGood.Count = int64(count2)
5769
+									newGood.StorehouseId = houseConfig.StorehouseOutInfo
5770
+									newGood.ProjectId = sumItem.ID
5771
+									newGoodOne = append(newGoodOne, &newGood)
5772
+								}
5773
+							}
5774
+						}
5775
+					}
5776
+
5777
+					//判断
5778
+					for _, itemOne := range infos {
5779
+						for _, itemTwo := range hisAdvice {
5780
+							if itemOne.DrugId == itemTwo.DrugId {
5781
+								itemTwo.Child = append(itemTwo.ChildDoctorAdvice, itemOne)
5782
+							}
5783
+						}
5784
+					}
5785
+
5786
+					for _, itemTwo := range hisAdvice {
5787
+						medical, _ := service.GetBaseDrugMedical(itemTwo.DrugId)
5788
+						var sum_out_count int64
5789
+						for _, itemThree := range itemTwo.Child {
5790
+							var prescribing_number int64
5791
+							stringPrescribingNumber := strconv.FormatFloat(itemThree.PrescribingNumber, 'f', -1, 64)
5792
+							parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
5793
+							if itemThree.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
5794
+								prescribing_number = parseIntPrescribingNumber * medical.MinNumber
5795
+							}
5796
+							if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
5797
+								prescribing_number = parseIntPrescribingNumber
5798
+							}
5799
+							if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
5800
+								prescribing_number = parseIntPrescribingNumber
5801
+							}
5802
+							sum_out_count += prescribing_number
5803
+						}
5804
+						drugStockOut, _ := service.GetDrugSumOutCountByDrugId(itemTwo.DrugId, adminUser.CurrentOrgId)
5805
+
5806
+						if sum_out_count > drugStockOut.FlushCount {
5807
+							c.ServeSuccessJSON(map[string]interface{}{
5808
+								"msg":  "2",
5809
+								"drug": medical,
5810
+							})
5811
+							return
5812
+						}
5813
+					}
5814
+
5815
+					for _, itemOne := range newGoods {
5816
+						for _, item := range newGoodOne {
5817
+							if itemOne.ProjectId == item.ProjectId {
5818
+								item.ChildNewDialysisBeforePrepareGoods = append(item.ChildNewDialysisBeforePrepareGoods, item)
5819
+							}
5820
+						}
5821
+					}
5822
+
5823
+					for _, item := range newGoodOne {
5824
+						var sum_out_count_one int64
5825
+						good, _ := service.GetGoodInformationByGoodIdOne(item.GoodId)
5826
+
5827
+						for _, itemOne := range item.ChildNewDialysisBeforePrepareGoods {
5828
+							sum_out_count_one += itemOne.Count
5829
+						}
5830
+						list, _ := service.GetStockGoodList(item.GoodId, adminUser.CurrentOrgId)
5831
+						fmt.Println("sum_out_count_one", sum_out_count_one)
5832
+						fmt.Println("list.FlushCount", list.FlushCount)
5833
+						if sum_out_count_one > list.FlushCount {
5834
+							c.ServeSuccessJSON(map[string]interface{}{
5835
+								"msg":  "3",
5836
+								"good": good,
5837
+							})
5838
+							return
5839
+						}
5840
+					}
5841
+
5842
+					fmt.Println("infos233232323223323232323232323232", infolist)
5843
+					for _, item := range infolist {
5644
 						service.HisDrugsDelivery(item.UserOrgId, adminUser.AdminUser.Id, item)
5844
 						service.HisDrugsDelivery(item.UserOrgId, adminUser.AdminUser.Id, item)
5645
 					}
5845
 					}
5846
+					for _, item := range oldGoods {
5847
+						dialyPrepareOne := models.DialysisBeforePrepare{
5848
+							GoodTypeId:   item.GoodTypeId,
5849
+							GoodId:       item.GoodId,
5850
+							PatientId:    item.PatientId,
5851
+							RecordDate:   item.RecordDate,
5852
+							UserOrgId:    item.UserOrgId,
5853
+							Count:        item.Count,
5854
+							Ctime:        time.Now().Unix(),
5855
+							Creater:      adminUser.AdminUser.Id,
5856
+							CommdityCode: item.CommdityCode,
5857
+							Status:       1,
5858
+							StorehouseId: houseConfig.StorehouseOutInfo,
5859
+						}
5860
+						err = service.CreateDialysisBeforePrepareOne(&dialyPrepareOne)
5861
+					}
5646
 					service.ConsumablesDeliveryTotal(adminUser.CurrentOrgId, his.PatientId, his.RecordDate, goods, newGoods, adminUser.AdminUser.Id)
5862
 					service.ConsumablesDeliveryTotal(adminUser.CurrentOrgId, his.PatientId, his.RecordDate, goods, newGoods, adminUser.AdminUser.Id)
5647
 				}
5863
 				}
5648
 
5864
 
5710
 			}
5926
 			}
5711
 		}
5927
 		}
5712
 	}
5928
 	}
5713
-	if adminUser.CurrentOrgId == 9671 {
5929
+	settConfig, _ := service.GetSettleOpenConfigByOrgId(adminUser.CurrentOrgId)
5930
+	if settConfig.IsOpen == 1 {
5714
 		for _, item := range infos {
5931
 		for _, item := range infos {
5715
 
5932
 
5716
 			service.DrugAutoAddCancelInfo(item, adminUser.AdminUser.Id)
5933
 			service.DrugAutoAddCancelInfo(item, adminUser.AdminUser.Id)

+ 432 - 6
controllers/mobile_api_controllers/dialysis_api_controller.go 查看文件

1847
 
1847
 
1848
 	}
1848
 	}
1849
 
1849
 
1850
-	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 10233 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 10243 || adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10414 || adminUserInfo.Org.Id == 10430 || adminUserInfo.Org.Id == 10432 {
1850
+	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 10233 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 10243 || adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10414 || adminUserInfo.Org.Id == 10430 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10223 {
1851
 		evaluation, _ := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, recordDate.Unix())
1851
 		evaluation, _ := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, recordDate.Unix())
1852
 		if evaluation.SystolicBloodPressure == 0 {
1852
 		if evaluation.SystolicBloodPressure == 0 {
1853
 			evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
1853
 			evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
2129
 	zone_id, _ := this.GetInt64("zone_id")
2129
 	zone_id, _ := this.GetInt64("zone_id")
2130
 	elecsign := this.GetString("url")
2130
 	elecsign := this.GetString("url")
2131
 	nuclein_date_str := this.GetString("nuclein_date_str")
2131
 	nuclein_date_str := this.GetString("nuclein_date_str")
2132
-
2132
+	schedule_remark := this.GetString("schedule_remark")
2133
+	order_remark := this.GetString("order_remark")
2133
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
2134
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
2134
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2135
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2135
 		return
2136
 		return
2212
 		}
2213
 		}
2213
 		theNucleinDate = theTime.Unix()
2214
 		theNucleinDate = theTime.Unix()
2214
 	}
2215
 	}
2215
-	fmt.Println("wo2o3o23o2o2323oo232o3swo", theNucleinDate)
2216
+
2216
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
2217
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
2217
 
2218
 
2218
 	//查询更改的机号,是否有人用了,如果只是排班了,但是没上机,直接替换,如果排班且上机了,就提示他无法上机
2219
 	//查询更改的机号,是否有人用了,如果只是排班了,但是没上机,直接替换,如果排班且上机了,就提示他无法上机
2330
 		BloodAccessId:          blood_access_id,
2331
 		BloodAccessId:          blood_access_id,
2331
 		Url:                    elecsign,
2332
 		Url:                    elecsign,
2332
 		NucleinDate:            theNucleinDate,
2333
 		NucleinDate:            theNucleinDate,
2334
+		ScheduleRemark:         schedule_remark,
2335
+		OrderRemark:            order_remark,
2333
 	}
2336
 	}
2334
 	//查询该床位是否有人用了
2337
 	//查询该床位是否有人用了
2335
 	_, errorscode := service.GetDialysisOrderByBedId(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
2338
 	_, errorscode := service.GetDialysisOrderByBedId(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
2336
 	if errorscode == gorm.ErrRecordNotFound {
2339
 	if errorscode == gorm.ErrRecordNotFound {
2337
 
2340
 
2338
 		createErr := service.MobileCreateDialysisOrder(adminUserInfo.Org.Id, patientID, dialysisRecord)
2341
 		createErr := service.MobileCreateDialysisOrder(adminUserInfo.Org.Id, patientID, dialysisRecord)
2339
-
2342
+		service.UpdateMobilePatient(adminUserInfo.Org.Id, patientID, schedule_remark)
2340
 		redis := service.RedisClient()
2343
 		redis := service.RedisClient()
2341
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
2344
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
2342
 		redis.Set(key, "", time.Second)
2345
 		redis.Set(key, "", time.Second)
3140
 	dialysis_irrigation := this.GetString("dialysis_irrigation")
3143
 	dialysis_irrigation := this.GetString("dialysis_irrigation")
3141
 	blood_access_id, _ := this.GetInt64("blood_access_id")
3144
 	blood_access_id, _ := this.GetInt64("blood_access_id")
3142
 	nuclein_date_str := this.GetString("nuclein_date_str")
3145
 	nuclein_date_str := this.GetString("nuclein_date_str")
3146
+	order_remark := this.GetString("order_remark")
3147
+	schedule_remark := this.GetString("schedule_remark")
3143
 	if record_id == 0 {
3148
 	if record_id == 0 {
3144
 		this.ErrorLog("id:%v", record_id)
3149
 		this.ErrorLog("id:%v", record_id)
3145
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3150
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3302
 		DialysisIrrigation:     dialysis_irrigation,
3307
 		DialysisIrrigation:     dialysis_irrigation,
3303
 		BloodAccessId:          blood_access_id,
3308
 		BloodAccessId:          blood_access_id,
3304
 		NucleinDate:            theNucleinDate,
3309
 		NucleinDate:            theNucleinDate,
3310
+		OrderRemark:            order_remark,
3311
+		ScheduleRemark:         schedule_remark,
3305
 	}
3312
 	}
3306
 
3313
 
3307
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
3314
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
3315
+	order, _ := service.GetLastPatientOrder(record_id)
3316
+	service.UpdateMobilePatient(adminUserInfo.Org.Id, order.PatientId, schedule_remark)
3308
 	redis := service.RedisClient()
3317
 	redis := service.RedisClient()
3309
 
3318
 
3310
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":dialysis_order"
3319
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":dialysis_order"
3809
 		advice.UserOrgId = adminUserInfo.Org.Id
3818
 		advice.UserOrgId = adminUserInfo.Org.Id
3810
 		advice.PatientId = patient
3819
 		advice.PatientId = patient
3811
 		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
3820
 		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
3812
-
3821
+		advice.IsSettle = 2
3813
 		if adviceNameM["advice_name"] == nil || reflect.TypeOf(adviceNameM["advice_name"]).String() != "string" {
3822
 		if adviceNameM["advice_name"] == nil || reflect.TypeOf(adviceNameM["advice_name"]).String() != "string" {
3814
 			utils.ErrorLog("advice_name")
3823
 			utils.ErrorLog("advice_name")
3815
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3824
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3936
 					child.UserOrgId = adminUserInfo.Org.Id
3945
 					child.UserOrgId = adminUserInfo.Org.Id
3937
 					child.PatientId = patient
3946
 					child.PatientId = patient
3938
 					child.AdviceDoctor = adminUserInfo.AdminUser.Id
3947
 					child.AdviceDoctor = adminUserInfo.AdminUser.Id
3939
-
3948
+					child.IsSettle = 1
3940
 					if childMap["advice_name"] == nil || reflect.TypeOf(childMap["advice_name"]).String() != "string" {
3949
 					if childMap["advice_name"] == nil || reflect.TypeOf(childMap["advice_name"]).String() != "string" {
3941
 						utils.ErrorLog("child advice_name")
3950
 						utils.ErrorLog("child advice_name")
3942
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3951
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
7099
 		"order": order,
7108
 		"order": order,
7100
 	})
7109
 	})
7101
 }
7110
 }
7111
+
7112
+func (this *DialysisAPIController) ExectionMobileAdvice() {
7113
+
7114
+	ids := this.GetString("ids")
7115
+	idSplit := strings.Split(ids, ",")
7116
+	orgId := this.GetMobileAdminUserInfo().Org.Id
7117
+
7118
+	config, _ := service.FindXTHisRecordByOrgIdSix(orgId)
7119
+	execution_time := this.GetString("exce_time")
7120
+	timeLayout2 := "2006-01-02 15:04:05"
7121
+	loc, _ := time.LoadLocation("Local")
7122
+
7123
+	theTime, errs := time.ParseInLocation(timeLayout2, execution_time, loc)
7124
+	if errs != nil {
7125
+		utils.ErrorLog(errs.Error())
7126
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
7127
+		return
7128
+	}
7129
+	//his客户
7130
+	if config.IsOpen == 1 {
7131
+
7132
+		list, _ := service.GetHisMobileAdviceGroupList(orgId, idSplit)
7133
+		adviceList, _ := service.GetHisMobileAdviceList(orgId, idSplit)
7134
+		for _, item := range list {
7135
+			for _, it := range adviceList {
7136
+				if item.DrugId == it.DrugId {
7137
+					item.ChildDoctorAdvice = append(item.ChildDoctorAdvice, it)
7138
+				}
7139
+			}
7140
+		}
7141
+
7142
+		for _, item := range list {
7143
+			medical, _ := service.GetBaseDrugMedical(item.DrugId)
7144
+			var sum_out_count int64
7145
+			for _, itemThree := range item.ChildDoctorAdvice {
7146
+				var prescribing_number int64
7147
+				stringPrescribingNumber := strconv.FormatFloat(itemThree.PrescribingNumber, 'f', -1, 64)
7148
+				parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
7149
+				if itemThree.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
7150
+					prescribing_number = parseIntPrescribingNumber * medical.MinNumber
7151
+				}
7152
+				if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
7153
+					prescribing_number = parseIntPrescribingNumber
7154
+				}
7155
+				if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
7156
+					prescribing_number = parseIntPrescribingNumber
7157
+				}
7158
+				sum_out_count += prescribing_number
7159
+			}
7160
+			drugStockOut, _ := service.GetDrugSumOutCountByDrugId(item.DrugId, orgId)
7161
+
7162
+			//库存不足
7163
+			if sum_out_count > drugStockOut.FlushCount {
7164
+				this.ServeSuccessJSON(map[string]interface{}{
7165
+					"msg":  "2",
7166
+					"drug": medical,
7167
+					"ids":  ids,
7168
+				})
7169
+				return
7170
+			}
7171
+		}
7172
+		creater := this.GetMobileAdminUserInfo().AdminUser.Id
7173
+		//执行医嘱
7174
+		errs := service.ExectionMobileAdvice(orgId, idSplit, theTime.Unix(), creater)
7175
+		advices, _ := service.FindHisDoctorAdviceByIds(orgId, idSplit)
7176
+		for _, item := range advices {
7177
+			key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
7178
+			redis := service.RedisClient()
7179
+			//清空key 值
7180
+			redis.Set(key, "", time.Second)
7181
+			keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
7182
+			redis.Set(keyTwo, "", time.Second)
7183
+			keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
7184
+			redis.Set(keyThree, "", time.Second)
7185
+			recordDate := theTime.Format("2006-01-02")
7186
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
7187
+
7188
+			redis.Set(keyFour, "", time.Second)
7189
+			keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
7190
+			redis.Set(keyFive, "", time.Second)
7191
+
7192
+			defer redis.Close()
7193
+		}
7194
+		if errs == nil {
7195
+
7196
+			//药品管理信息
7197
+			_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(orgId)
7198
+			storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
7199
+			if drugStockConfig.IsOpen == 1 {
7200
+				for _, item := range advices {
7201
+					advice, _ := service.FindHisDoctorAdviceById(orgId, item.ID)
7202
+					config, _ := service.GetDrugOpenConfigOne(orgId)
7203
+					if config.IsOpen != 1 {
7204
+						//查询该药品是否有库存
7205
+						medical, _ := service.GetBaseDrugMedical(item.DrugId)
7206
+						pharmacyConfig, _ := service.FindPharmacyConfig(advice.UserOrgId)
7207
+						if medical.IsUse == 2 {
7208
+							if config.IsOpen != 1 {
7209
+								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
7210
+									service.HisDrugsDelivery(orgId, creater, &advice)
7211
+								}
7212
+								if pharmacyConfig.IsOpen != 1 {
7213
+									service.HisDrugsDelivery(orgId, creater, &advice)
7214
+								}
7215
+
7216
+								//更新字典里面的库存
7217
+								stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
7218
+								var sum_count int64
7219
+								for _, its := range stockInfo {
7220
+									if its.MaxUnit == medical.MaxUnit {
7221
+										its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
7222
+									}
7223
+									sum_count += its.StockMaxNumber + its.StockMinNumber
7224
+								}
7225
+								service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
7226
+								//剩余库存
7227
+								service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
7228
+							}
7229
+
7230
+						}
7231
+
7232
+					}
7233
+				}
7234
+			}
7235
+			this.ServeSuccessJSON(map[string]interface{}{
7236
+				"msg": "1",
7237
+				"ids": ids,
7238
+			})
7239
+			return
7240
+		} else {
7241
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
7242
+		}
7243
+	}
7244
+
7245
+	fmt.Println("config233322333223", config.IsOpen)
7246
+
7247
+	//血透客户
7248
+	if config.IsOpen == 2 || config.IsOpen == 0 {
7249
+
7250
+		//药品管理信息
7251
+		_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(orgId)
7252
+		if drugStockConfig.IsOpen == 1 {
7253
+			list, _ := service.GetBloodMobileAdviceGroupList(orgId, idSplit)
7254
+			adviceList, _ := service.GetBloodMobileAdviceList(orgId, idSplit)
7255
+			for _, item := range list {
7256
+				for _, it := range adviceList {
7257
+					if item.DrugId == it.DrugId {
7258
+						item.ChildDoctorAdvice = append(item.ChildDoctorAdvice, it)
7259
+					}
7260
+				}
7261
+			}
7262
+			for _, item := range list {
7263
+				medical, _ := service.GetBaseDrugMedical(item.DrugId)
7264
+				var sum_out_count int64
7265
+				for _, itemThree := range item.ChildDoctorAdvice {
7266
+					var prescribing_number int64
7267
+					stringPrescribingNumber := strconv.FormatFloat(itemThree.PrescribingNumber, 'f', -1, 64)
7268
+					parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
7269
+					if itemThree.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
7270
+						prescribing_number = parseIntPrescribingNumber * medical.MinNumber
7271
+					}
7272
+					if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
7273
+						prescribing_number = parseIntPrescribingNumber
7274
+					}
7275
+					if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
7276
+						prescribing_number = parseIntPrescribingNumber
7277
+					}
7278
+					sum_out_count += prescribing_number
7279
+				}
7280
+				drugStockOut, _ := service.GetDrugSumOutCountByDrugId(item.DrugId, orgId)
7281
+
7282
+				//库存不足
7283
+				if sum_out_count > drugStockOut.FlushCount {
7284
+					this.ServeSuccessJSON(map[string]interface{}{
7285
+						"msg":  "2",
7286
+						"drug": medical,
7287
+						"ids":  ids,
7288
+					})
7289
+					return
7290
+				}
7291
+			}
7292
+
7293
+			creater := this.GetMobileAdminUserInfo().AdminUser.Id
7294
+			fmt.Println("creater2332243244224242424", creater)
7295
+			//执行医嘱
7296
+			errs := service.ExectionBloodMobileAdvice(orgId, idSplit, theTime.Unix(), creater)
7297
+			advices, _ := service.FindAllDoctorAdviceByIds(orgId, idSplit)
7298
+			for _, item := range advices {
7299
+				key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
7300
+				redis := service.RedisClient()
7301
+				//清空key 值
7302
+				redis.Set(key, "", time.Second)
7303
+				keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
7304
+				redis.Set(keyTwo, "", time.Second)
7305
+				keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
7306
+				redis.Set(keyThree, "", time.Second)
7307
+				recordDate := theTime.Format("2006-01-02")
7308
+				keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
7309
+
7310
+				redis.Set(keyFour, "", time.Second)
7311
+				keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
7312
+				redis.Set(keyFive, "", time.Second)
7313
+
7314
+				defer redis.Close()
7315
+			}
7316
+			if errs == nil {
7317
+
7318
+				for _, item := range advices {
7319
+					storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
7320
+					medical, _ := service.GetBaseDrugMedical(item.DrugId)
7321
+					//查询是否出库按钮开启
7322
+					adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
7323
+					if adviceSetting.IsAdviceOpen == 1 {
7324
+						//查询是否出库按钮开启
7325
+						prescriptionConfig, _ := service.FindPrescriptionConfigById(item.UserOrgId)
7326
+						pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
7327
+						if prescriptionConfig.IsOpen == 1 {
7328
+							if medical.IsUse == 2 {
7329
+								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
7330
+									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
7331
+								}
7332
+								if pharmacyConfig.IsOpen != 1 {
7333
+									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
7334
+								}
7335
+
7336
+								//更新字典里面的库存
7337
+								stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
7338
+								var sum_count int64
7339
+								for _, its := range stockInfo {
7340
+									if its.MaxUnit == medical.MaxUnit {
7341
+										its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
7342
+									}
7343
+									sum_count += its.StockMaxNumber + its.StockMinNumber
7344
+								}
7345
+								service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
7346
+								//剩余库存
7347
+								service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
7348
+							}
7349
+						}
7350
+					} else {
7351
+						pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
7352
+						if medical.IsUse == 2 {
7353
+							if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
7354
+								service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
7355
+							}
7356
+							if pharmacyConfig.IsOpen != 1 {
7357
+								service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
7358
+							}
7359
+
7360
+							stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
7361
+							var sum_count int64
7362
+							for _, its := range stockInfo {
7363
+								if its.MaxUnit == medical.MaxUnit {
7364
+									its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
7365
+								}
7366
+								sum_count += its.StockMaxNumber + its.StockMinNumber
7367
+							}
7368
+							service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
7369
+							//剩余库存
7370
+							service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
7371
+						}
7372
+					}
7373
+				}
7374
+			}
7375
+			this.ServeSuccessJSON(map[string]interface{}{
7376
+				"msg": "1",
7377
+				"ids": ids,
7378
+			})
7379
+			return
7380
+
7381
+		} else {
7382
+
7383
+			creater := this.GetMobileAdminUserInfo().AdminUser.Id
7384
+			//执行医嘱
7385
+			service.ExectionBloodMobileAdvice(orgId, idSplit, theTime.Unix(), creater)
7386
+			advices, _ := service.FindAllDoctorAdviceByIds(orgId, idSplit)
7387
+			for _, item := range advices {
7388
+				key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
7389
+				redis := service.RedisClient()
7390
+				//清空key 值
7391
+				redis.Set(key, "", time.Second)
7392
+				keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
7393
+				redis.Set(keyTwo, "", time.Second)
7394
+				keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
7395
+				redis.Set(keyThree, "", time.Second)
7396
+				recordDate := theTime.Format("2006-01-02")
7397
+				keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
7398
+
7399
+				redis.Set(keyFour, "", time.Second)
7400
+				keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
7401
+				redis.Set(keyFive, "", time.Second)
7402
+
7403
+				defer redis.Close()
7404
+			}
7405
+			this.ServeSuccessJSON(map[string]interface{}{
7406
+				"msg": "1",
7407
+				"ids": ids,
7408
+			})
7409
+			return
7410
+		}
7411
+
7412
+	}
7413
+
7414
+}
7415
+
7416
+func (this *DialysisAPIController) GetSettleMobileAdvice() {
7417
+
7418
+	ids := this.GetString("ids")
7419
+	idSplit := strings.Split(ids, ",")
7420
+	orgId := this.GetMobileAdminUserInfo().Org.Id
7421
+	config, _ := service.FindXTHisRecordByOrgIdSix(orgId)
7422
+
7423
+	if config.IsOpen == 1 {
7424
+		service.UpdateSettleMobileHisAdvice(orgId, idSplit)
7425
+		this.ServeSuccessJSON(map[string]interface{}{
7426
+			"msg": "1",
7427
+			"ids": ids,
7428
+		})
7429
+		return
7430
+	}
7431
+
7432
+	if config.IsOpen == 0 || config.IsOpen == 2 {
7433
+
7434
+		service.UpdateSettleMobileBloodAdvice(orgId, idSplit)
7435
+		this.ServeSuccessJSON(map[string]interface{}{
7436
+			"msg": "1",
7437
+			"ids": ids,
7438
+		})
7439
+		return
7440
+	}
7441
+}
7442
+
7443
+func (this *DialysisAPIController) GetCheckMobileAdvice() {
7444
+
7445
+	ids := this.GetString("ids")
7446
+	idSplit := strings.Split(ids, ",")
7447
+	orgId := this.GetMobileAdminUserInfo().Org.Id
7448
+
7449
+	config, _ := service.FindXTHisRecordByOrgIdSix(orgId)
7450
+
7451
+	//his
7452
+	if config.IsOpen == 1 {
7453
+		checker := this.GetMobileAdminUserInfo().AdminUser.Id
7454
+		theTime := time.Now()
7455
+
7456
+		advices := models.HisDoctorAdviceThirty{
7457
+			CheckTime:   theTime.Unix(),
7458
+			Checker:     checker,
7459
+			UpdatedTime: time.Now().Unix(),
7460
+		}
7461
+		service.CheckHisMobileDoctorAdvice(orgId, idSplit, advices)
7462
+
7463
+		list, _ := service.FindDoctorAdviceByIds(orgId, idSplit)
7464
+		for _, item := range list {
7465
+			key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
7466
+			redis := service.RedisClient()
7467
+			//清空key 值
7468
+			redis.Set(key, "", time.Second)
7469
+			keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
7470
+			redis.Set(keyTwo, "", time.Second)
7471
+			keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
7472
+			redis.Set(keyThree, "", time.Second)
7473
+			recordDate := theTime.Format("2006-01-02")
7474
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
7475
+
7476
+			redis.Set(keyFour, "", time.Second)
7477
+			keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
7478
+			redis.Set(keyFive, "", time.Second)
7479
+			defer redis.Close()
7480
+		}
7481
+
7482
+		this.ServeSuccessJSON(map[string]interface{}{
7483
+			"msg": "1",
7484
+			"ids": ids,
7485
+		})
7486
+		return
7487
+	}
7488
+
7489
+	//血透
7490
+	if config.IsOpen == 0 || config.IsOpen == 2 {
7491
+
7492
+		checker := this.GetMobileAdminUserInfo().AdminUser.Id
7493
+		theTime := time.Now()
7494
+
7495
+		advices := models.DoctorAdvice{
7496
+			CheckTime:   theTime.Unix(),
7497
+			Checker:     checker,
7498
+			UpdatedTime: time.Now().Unix(),
7499
+		}
7500
+
7501
+		service.CheckBloodDoctorAdvice(orgId, idSplit, advices)
7502
+		list, _ := service.FindDoctorAdviceByIds(orgId, idSplit)
7503
+		for _, item := range list {
7504
+			key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
7505
+			redis := service.RedisClient()
7506
+			//清空key 值
7507
+			redis.Set(key, "", time.Second)
7508
+			keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
7509
+			redis.Set(keyTwo, "", time.Second)
7510
+			keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
7511
+			redis.Set(keyThree, "", time.Second)
7512
+			recordDate := theTime.Format("2006-01-02")
7513
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
7514
+
7515
+			redis.Set(keyFour, "", time.Second)
7516
+			keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
7517
+			redis.Set(keyFive, "", time.Second)
7518
+			defer redis.Close()
7519
+		}
7520
+		this.ServeSuccessJSON(map[string]interface{}{
7521
+			"msg": "1",
7522
+			"ids": ids,
7523
+		})
7524
+		return
7525
+	}
7526
+
7527
+}

+ 6 - 2
controllers/mobile_api_controllers/doctor_advice_api_controller.go 查看文件

5
 	"XT_New/models"
5
 	"XT_New/models"
6
 	"XT_New/service"
6
 	"XT_New/service"
7
 	"XT_New/utils"
7
 	"XT_New/utils"
8
+	"fmt"
8
 	"strconv"
9
 	"strconv"
9
 	"time"
10
 	"time"
10
 )
11
 )
26
 		adviceType = 0
27
 		adviceType = 0
27
 	}
28
 	}
28
 
29
 
29
-	if patientType != 1 && patientType != 2 {
30
+	if patientType != 1 && patientType != 2 && patientType != 3 && patientType != 4 {
30
 
31
 
31
 		patientType = 0
32
 		patientType = 0
32
 	}
33
 	}
43
 	key := strconv.FormatInt(orgID, 10) + ":" + ":patient_list_all"
44
 	key := strconv.FormatInt(orgID, 10) + ":" + ":patient_list_all"
44
 	redis.Set(key, "", time.Second)
45
 	redis.Set(key, "", time.Second)
45
 	scheduals, err := service.MobileGetScheduleDoctorAdvicesTwo(orgID, date.Unix(), adviceType, patientType, adminInfo.AdminUser.Id, delivery_way)
46
 	scheduals, err := service.MobileGetScheduleDoctorAdvicesTwo(orgID, date.Unix(), adviceType, patientType, adminInfo.AdminUser.Id, delivery_way)
47
+
48
+	fmt.Println("scheduals00923923999233223", scheduals)
46
 	//获取所有的患者
49
 	//获取所有的患者
47
 	blood_patients, _ := service.GetAllPatientListByListSeven(orgID)
50
 	blood_patients, _ := service.GetAllPatientListByListSeven(orgID)
48
 	//获取透析处方
51
 	//获取透析处方
78
 	config, _ := service.GetHisDoctorConfig(orgID)
81
 	config, _ := service.GetHisDoctorConfig(orgID)
79
 	project_config, _ := service.GetHisProjectConfig(orgID)
82
 	project_config, _ := service.GetHisProjectConfig(orgID)
80
 
83
 
84
+	fmt.Println("project_config23323232322323", project_config.IsOpen)
81
 	if project_config.IsOpen == 1 || project_config.IsOpen == 2 {
85
 	if project_config.IsOpen == 1 || project_config.IsOpen == 2 {
82
 		//获取his医嘱数据
86
 		//获取his医嘱数据
83
 		project, _ := service.GetMobileHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, adminInfo.AdminUser.Id)
87
 		project, _ := service.GetMobileHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, adminInfo.AdminUser.Id)
153
 		} else {
157
 		} else {
154
 			filtedScheduals := []*service.MScheduleDoctorAdviceVMOne{}
158
 			filtedScheduals := []*service.MScheduleDoctorAdviceVMOne{}
155
 			for _, schedual := range scheduals {
159
 			for _, schedual := range scheduals {
156
-				if len(schedual.DoctorAdvices) > 0 {
160
+				if len(schedual.DoctorAdvices) > 0 || len(hisAdvices) > 0 {
157
 					filtedScheduals = append(filtedScheduals, schedual)
161
 					filtedScheduals = append(filtedScheduals, schedual)
158
 				}
162
 				}
159
 			}
163
 			}

+ 6 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go 查看文件

177
 	beego.Router("/m/api/getscheduletypebyidlist", &DialysisAPIController{}, "Get:GetScheduleTypeByIdList")
177
 	beego.Router("/m/api/getscheduletypebyidlist", &DialysisAPIController{}, "Get:GetScheduleTypeByIdList")
178
 
178
 
179
 	beego.Router("/m/api/savepatientpicture", &DialysisAPIController{}, "Get:SavePatientPicture")
179
 	beego.Router("/m/api/savepatientpicture", &DialysisAPIController{}, "Get:SavePatientPicture")
180
+
181
+	beego.Router("/m/api/exectionmobileadvice", &DialysisAPIController{}, "Get:ExectionMobileAdvice")
182
+
183
+	beego.Router("/m/api/settlemobileadvice", &DialysisAPIController{}, "Get:GetSettleMobileAdvice")
184
+
185
+	beego.Router("/m/api/checkmobileadvice", &DialysisAPIController{}, "Get:GetCheckMobileAdvice")
180
 }
186
 }

+ 3 - 4
controllers/mobile_api_controllers/patient_api_controller.go 查看文件

3696
 			advice.UserOrgId = adminUserInfo.Org.Id
3696
 			advice.UserOrgId = adminUserInfo.Org.Id
3697
 			advice.PatientId = patientInfo.ID
3697
 			advice.PatientId = patientInfo.ID
3698
 			advice.AdviceDoctor = adminUserInfo.AdminUser.Id
3698
 			advice.AdviceDoctor = adminUserInfo.AdminUser.Id
3699
-
3699
+			advice.IsSettle = 2
3700
 			//入口
3700
 			//入口
3701
 			errcode := c.setAdviceWithJSON(&advice, adviceNameM)
3701
 			errcode := c.setAdviceWithJSON(&advice, adviceNameM)
3702
 			if errcode > 0 {
3702
 			if errcode > 0 {
3722
 						s.UserOrgId = adminUserInfo.Org.Id
3722
 						s.UserOrgId = adminUserInfo.Org.Id
3723
 						s.PatientId = patientInfo.ID
3723
 						s.PatientId = patientInfo.ID
3724
 						s.AdviceDoctor = adminUserInfo.AdminUser.Id
3724
 						s.AdviceDoctor = adminUserInfo.AdminUser.Id
3725
-
3725
+						s.IsSettle = 2
3726
 						errcode := c.setAdviceWithJSON(&s, subdrug.(map[string]interface{}))
3726
 						errcode := c.setAdviceWithJSON(&s, subdrug.(map[string]interface{}))
3727
 						if errcode > 0 {
3727
 						if errcode > 0 {
3728
 							c.ServeFailJSONWithSGJErrorCode(errcode)
3728
 							c.ServeFailJSONWithSGJErrorCode(errcode)
3809
 		advice.UserOrgId = adminUserInfo.Org.Id
3809
 		advice.UserOrgId = adminUserInfo.Org.Id
3810
 		advice.PatientId = patient
3810
 		advice.PatientId = patient
3811
 		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
3811
 		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
3812
-
3812
+		advice.IsSettle = 2
3813
 		err := service.CreateDoctorAdvice(&advice)
3813
 		err := service.CreateDoctorAdvice(&advice)
3814
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
3814
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
3815
 		redis := service.RedisClient()
3815
 		redis := service.RedisClient()
3817
 		redis.Set(key, "", time.Second)
3817
 		redis.Set(key, "", time.Second)
3818
 		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
3818
 		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
3819
 		redis.Set(keyOne, "", time.Second)
3819
 		redis.Set(keyOne, "", time.Second)
3820
-		fmt.Println("key`2232333332233223233232", key)
3821
 		defer redis.Close()
3820
 		defer redis.Close()
3822
 		if err != nil {
3821
 		if err != nil {
3823
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
3822
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)

+ 3 - 4
controllers/patient_api_controller.go 查看文件

1279
 		advice.UserOrgId = adminUserInfo.CurrentOrgId
1279
 		advice.UserOrgId = adminUserInfo.CurrentOrgId
1280
 		advice.PatientId = patientInfo.ID
1280
 		advice.PatientId = patientInfo.ID
1281
 		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
1281
 		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
1282
-
1282
+		advice.IsSettle = 2
1283
 		if adviceNameM["advice_name"] == nil || reflect.TypeOf(adviceNameM["advice_name"]).String() != "string" {
1283
 		if adviceNameM["advice_name"] == nil || reflect.TypeOf(adviceNameM["advice_name"]).String() != "string" {
1284
 			utils.ErrorLog("advice_name")
1284
 			utils.ErrorLog("advice_name")
1285
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1285
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1432
 					child.UserOrgId = adminUserInfo.CurrentOrgId
1432
 					child.UserOrgId = adminUserInfo.CurrentOrgId
1433
 					child.PatientId = patientInfo.ID
1433
 					child.PatientId = patientInfo.ID
1434
 					child.AdviceDoctor = adminUserInfo.AdminUser.Id
1434
 					child.AdviceDoctor = adminUserInfo.AdminUser.Id
1435
-
1435
+					child.IsSettle = 2
1436
 					if childMap["advice_name"] == nil || reflect.TypeOf(childMap["advice_name"]).String() != "string" {
1436
 					if childMap["advice_name"] == nil || reflect.TypeOf(childMap["advice_name"]).String() != "string" {
1437
 						utils.ErrorLog("child advice_name")
1437
 						utils.ErrorLog("child advice_name")
1438
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1438
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1508
 
1508
 
1509
 	list, err := service.CreateMGroupAdvice(adminUserInfo.CurrentOrgId, advices, groupNo)
1509
 	list, err := service.CreateMGroupAdvice(adminUserInfo.CurrentOrgId, advices, groupNo)
1510
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":doctor_advices"
1510
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":doctor_advices"
1511
-	//fmt.Println("key23323323232323223233223232323",key)
1511
+
1512
 	redis := service.RedisClient()
1512
 	redis := service.RedisClient()
1513
 	defer redis.Close()
1513
 	defer redis.Close()
1514
 	redis.Set(key, "", time.Second)
1514
 	redis.Set(key, "", time.Second)
1515
 	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":advice_list_all"
1515
 	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":advice_list_all"
1516
 	redis.Set(keyOne, "", time.Second)
1516
 	redis.Set(keyOne, "", time.Second)
1517
-	//fmt.Println("keyOne23322322323232323233232332",keyOne)
1518
 	if err != nil {
1517
 	if err != nil {
1519
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
1518
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
1520
 		return
1519
 		return

+ 64 - 2
controllers/schedule_api_controller.go 查看文件

41
 
41
 
42
 	beego.Router("/api/schedule_template/cancel", &ScheduleApiController{}, "post:CancelScheduleTemplate")
42
 	beego.Router("/api/schedule_template/cancel", &ScheduleApiController{}, "post:CancelScheduleTemplate")
43
 	beego.Router("/api/schedule/getnextscheduleweekday", &ScheduleApiController{}, "Get:GetNextWeekDaySchedule")
43
 	beego.Router("/api/schedule/getnextscheduleweekday", &ScheduleApiController{}, "Get:GetNextWeekDaySchedule")
44
+	beego.Router("/api/schedule/getnextscheduleweekdayone", &ScheduleApiController{}, "Get:GetNextWeekDayScheduleOne")
44
 
45
 
45
 	beego.Router("/api/schedule/getthreeweeklist", &ScheduleApiController{}, "Get:GetThreeWeekList")
46
 	beego.Router("/api/schedule/getthreeweeklist", &ScheduleApiController{}, "Get:GetThreeWeekList")
46
 
47
 
2078
 		return
2079
 		return
2079
 	}
2080
 	}
2080
 }
2081
 }
2082
+func (this *ScheduleApiController) GetNextWeekDayScheduleOne() {
2083
+	week_type, _ := this.GetInt64("week_type", -1)
2084
+	week_time, _ := this.GetInt64("week_time")
2085
+	record_date := this.GetString("record_date")
2086
+
2087
+	zons := this.GetString("zone")
2088
+	zone := strings.Split(zons, ",")
2089
+
2090
+	start_time, _ := this.GetInt64("start_time")
2091
+	end_time, _ := this.GetInt64("end_time")
2092
+	timeLayout := "2006-01-02"
2093
+	loc, _ := time.LoadLocation("Local")
2094
+	//theTimeStart, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
2095
+	//theTimeEnd, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
2096
+
2097
+	adminUserInfo := this.GetAdminUserInfo()
2098
+	var theStartTIme int64
2099
+	if len(record_date) > 0 {
2100
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
2101
+		if err != nil {
2102
+			utils.ErrorLog(err.Error())
2103
+		}
2104
+		theStartTIme = theTime.Unix()
2105
+	}
2106
+
2107
+	schedule, err := service.GetNextWeekDaySchedule(week_type, week_time, start_time, end_time, adminUserInfo.CurrentOrgId, zone, theStartTIme)
2108
+	for _, item := range schedule {
2109
+		order, _ := service.GetLastDialysisOrder(adminUserInfo.CurrentOrgId, item.PatientId, theStartTIme)
2110
+		item.XtDialysisOrderSix = order
2111
+		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10340 {
2112
+
2113
+			dialysisprescription, _ := service.GetLastDialysisSolution(adminUserInfo.CurrentOrgId, item.PatientId, item.ModeId, item.ScheduleDate)
2114
+			item.DialysisPrescription = dialysisprescription
2115
+		}
2116
+	}
2117
+	if err != nil {
2118
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2119
+		return
2120
+	}
2121
+	this.ServeSuccessJSON(map[string]interface{}{
2122
+		"schedule": schedule,
2123
+	})
2124
+}
2081
 
2125
 
2082
 func (this *ScheduleApiController) GetNextWeekDaySchedule() {
2126
 func (this *ScheduleApiController) GetNextWeekDaySchedule() {
2083
 
2127
 
2084
 	week_type, _ := this.GetInt64("week_type", -1)
2128
 	week_type, _ := this.GetInt64("week_type", -1)
2085
 	week_time, _ := this.GetInt64("week_time")
2129
 	week_time, _ := this.GetInt64("week_time")
2086
-	//start_time, _ := this.GetInt64("start_time")
2087
-	//end_time, _ := this.GetInt64("end_time")
2088
 	record_date := this.GetString("record_date")
2130
 	record_date := this.GetString("record_date")
2089
 
2131
 
2090
 	zons := this.GetString("zone")
2132
 	zons := this.GetString("zone")
2091
 	zone := strings.Split(zons, ",")
2133
 	zone := strings.Split(zons, ",")
2134
+
2092
 	start_time := this.GetString("start_time")
2135
 	start_time := this.GetString("start_time")
2093
 	end_time := this.GetString("end_time")
2136
 	end_time := this.GetString("end_time")
2094
 	timeLayout := "2006-01-02"
2137
 	timeLayout := "2006-01-02"
2501
 	orgId := this.GetAdminUserInfo().CurrentOrgId
2544
 	orgId := this.GetAdminUserInfo().CurrentOrgId
2502
 	if week_type > 0 {
2545
 	if week_type > 0 {
2503
 		list, err := service.GetWeekDayScheduleByIdThee(orgId, targetDay.Unix(), week_time, zone)
2546
 		list, err := service.GetWeekDayScheduleByIdThee(orgId, targetDay.Unix(), week_time, zone)
2547
+		for _, item := range list {
2548
+			order, _ := service.GetLastDialysisOrder(orgId, item.PatientId, targetDay.Unix())
2549
+			item.XtDialysisOrderSix = order
2550
+			if orgId == 9671 || orgId == 9675 || orgId == 10340 {
2504
 
2551
 
2552
+				solution, _ := service.GetLastDialysisSolution(orgId, item.PatientId, item.ModeId, item.ScheduleDate)
2553
+				item.DialysisPrescription = solution
2554
+			}
2555
+
2556
+		}
2505
 		if err != nil {
2557
 		if err != nil {
2506
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2558
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2507
 			return
2559
 			return
2516
 	if week_type == 0 {
2568
 	if week_type == 0 {
2517
 		startDate, _ := utils.ParseTimeStringToTime("2006-01-02", startTime)
2569
 		startDate, _ := utils.ParseTimeStringToTime("2006-01-02", startTime)
2518
 		list, err := service.GetWeekDayScheduleByIdTwo(orgId, targetDay.Unix(), week_time, startDate.Unix(), zone)
2570
 		list, err := service.GetWeekDayScheduleByIdTwo(orgId, targetDay.Unix(), week_time, startDate.Unix(), zone)
2571
+		for _, item := range list {
2572
+
2573
+			order, _ := service.GetLastDialysisOrder(orgId, item.PatientId, targetDay.Unix())
2574
+			item.XtDialysisOrderSix = order
2575
+			if orgId == 9671 || orgId == 9675 || orgId == 10340 {
2519
 
2576
 
2577
+				solution, _ := service.GetLastDialysisSolution(orgId, item.PatientId, item.ModeId, item.ScheduleDate)
2578
+				item.DialysisPrescription = solution
2579
+			}
2580
+
2581
+		}
2520
 		if err != nil {
2582
 		if err != nil {
2521
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2583
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2522
 			return
2584
 			return

+ 36 - 0
models/dialysis.go 查看文件

457
 	DrugNameId            int64           `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
457
 	DrugNameId            int64           `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
458
 	IsMedicine            int64           `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
458
 	IsMedicine            int64           `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
459
 	PushStartTime         int64           `gorm:"column:push_start_time" json:"push_start_time" form:"push_start_time"`
459
 	PushStartTime         int64           `gorm:"column:push_start_time" json:"push_start_time" form:"push_start_time"`
460
+	IsSettle              int64           `gorm:"column:is_settle" json:"is_settle" form:"is_settle"`
460
 }
461
 }
461
 
462
 
462
 func (DoctorAdvice) TableName() string {
463
 func (DoctorAdvice) TableName() string {
846
 	BloodAccessId              int64         `gorm:"column:blood_access_id" json:"blood_access_id" form:"blood_access_id"`
847
 	BloodAccessId              int64         `gorm:"column:blood_access_id" json:"blood_access_id" form:"blood_access_id"`
847
 	Mission                    string        `gorm:"column:mission" json:"mission" form:"mission"`
848
 	Mission                    string        `gorm:"column:mission" json:"mission" form:"mission"`
848
 	NucleinDate                int64         `gorm:"column:nuclein_date" json:"nuclein_date" form:"nuclein_date"`
849
 	NucleinDate                int64         `gorm:"column:nuclein_date" json:"nuclein_date" form:"nuclein_date"`
850
+	ScheduleRemark             string        `gorm:"column:schedule_remark" json:"schedule_remark" form:"schedule_remark"`
851
+	OrderRemark                string        `gorm:"column:order_remark" json:"order_remark" form:"order_remark"`
849
 }
852
 }
850
 
853
 
851
 func (DialysisOrder) TableName() string {
854
 func (DialysisOrder) TableName() string {
1108
 	ChildNewDialysisBeforePrepareGoods []*NewDialysisBeforePrepareGoods `gorm:"ForeignKey:GoodId;AssociationForeignKey:GoodId" json:"child"`
1111
 	ChildNewDialysisBeforePrepareGoods []*NewDialysisBeforePrepareGoods `gorm:"ForeignKey:GoodId;AssociationForeignKey:GoodId" json:"child"`
1109
 }
1112
 }
1110
 
1113
 
1114
+type OldDialysisBeforePrepareGoods struct {
1115
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
1116
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1117
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1118
+	RecordDate   int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
1119
+	GoodId       int64  `gorm:"column:good_id" json:"good_id" form:"good_id"`
1120
+	GoodTypeId   int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
1121
+	Count        int64  `gorm:"column:count" json:"count" form:"count"`
1122
+	Ctime        int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
1123
+	Mtime        int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
1124
+	Creater      int64  `gorm:"column:creater" json:"creater" form:"creater"`
1125
+	Modifier     int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
1126
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
1127
+	CommdityCode string `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
1128
+	NewCount     int64  `gorm:"column:new_count" json:"new_count" form:"new_count"`
1129
+	ProjectId    int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
1130
+	StorehouseId int64  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1131
+}
1132
+
1111
 type QueueCallConfig struct {
1133
 type QueueCallConfig struct {
1112
 	ID         int64 `gorm:"column:id" json:"id" form:"id"`
1134
 	ID         int64 `gorm:"column:id" json:"id" form:"id"`
1113
 	OrgId      int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
1135
 	OrgId      int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
1341
 func (DoctorAdviceThrity) TableName() string {
1363
 func (DoctorAdviceThrity) TableName() string {
1342
 	return "xt_doctor_advice"
1364
 	return "xt_doctor_advice"
1343
 }
1365
 }
1366
+
1367
+type XtDialysisOrderSix struct {
1368
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
1369
+	DialysisDate       int64  `gorm:"column:dialysis_date" json:"dialysis_date" form:"dialysis_date"`
1370
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1371
+	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1372
+	BloodAccessId      int64  `gorm:"column:blood_access_id" json:"blood_access_id" form:"blood_access_id"`
1373
+	DialysisIrrigation string `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
1374
+	DialysisDialyszers string `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
1375
+}
1376
+
1377
+func (XtDialysisOrderSix) TableName() string {
1378
+	return "xt_dialysis_order"
1379
+}

+ 2 - 0
models/patient_models.go 查看文件

786
 	TrobleShoot                  int64   `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
786
 	TrobleShoot                  int64   `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
787
 	TreatmentPlan                string  `gorm:"column:treatment_plan" json:"treatment_plan" form:"treatment_plan"`
787
 	TreatmentPlan                string  `gorm:"column:treatment_plan" json:"treatment_plan" form:"treatment_plan"`
788
 	Doctor                       int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
788
 	Doctor                       int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
789
+	ScheduleRemark               string  `gorm:"column:schedule_remark" json:"schedule_remark" form:"schedule_remark"`
789
 }
790
 }
790
 
791
 
791
 func (XtPatientsNew) TableName() string {
792
 func (XtPatientsNew) TableName() string {
1151
 	ContactName                  string  `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
1152
 	ContactName                  string  `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
1152
 	UserSysBeforeCount           int64   `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
1153
 	UserSysBeforeCount           int64   `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
1153
 	SchRemark                    string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
1154
 	SchRemark                    string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
1155
+	ScheduleRemark               string  `gorm:"column:schedule_remark" json:"schedule_remark" form:"schedule_remark"`
1154
 }
1156
 }
1155
 
1157
 
1156
 func (XtPatients) TableName() string {
1158
 func (XtPatients) TableName() string {

+ 20 - 15
models/schedule_models.go 查看文件

198
 	DialysisSolution           DialysisSolution           `json:"dialysissolution" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId;"`
198
 	DialysisSolution           DialysisSolution           `json:"dialysissolution" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId;"`
199
 	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `json:"assessmentbefor" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
199
 	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `json:"assessmentbefor" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
200
 	LastAfterWeight            AssessmentAfterDislysis    `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
200
 	LastAfterWeight            AssessmentAfterDislysis    `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
201
+	XtDialysisOrderSix         XtDialysisOrderSix         `json:"dialysis_order" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
201
 }
202
 }
202
 
203
 
203
 func (VmSchedulesRemind) TableName() string {
204
 func (VmSchedulesRemind) TableName() string {
205
 }
206
 }
206
 
207
 
207
 type WeekScheduleSix struct {
208
 type WeekScheduleSix struct {
208
-	ID           int64 `gorm:"column:id" json:"id" form:"id"`
209
-	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
210
-	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
211
-	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
212
-	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
213
-	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
214
-	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
215
-	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
216
-	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
217
-	Status       int64 `gorm:"column:status" json:"status" form:"status"`
218
-	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
219
-	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
220
-	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
221
-
209
+	ID                         int64                      `gorm:"column:id" json:"id" form:"id"`
210
+	UserOrgId                  int64                      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
211
+	PartitionId                int64                      `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
212
+	BedId                      int64                      `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
213
+	PatientId                  int64                      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
214
+	ScheduleDate               int64                      `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
215
+	ScheduleType               int64                      `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
216
+	ScheduleWeek               int64                      `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
217
+	ModeId                     int64                      `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
218
+	Status                     int64                      `gorm:"column:status" json:"status" form:"status"`
219
+	CreatedTime                int64                      `gorm:"column:created_time" json:"created_time" form:"created_time"`
220
+	UpdatedTime                int64                      `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
221
+	IsExport                   int64                      `gorm:"column:is_export" json:"is_export" form:"is_export"`
222
+	IdCardNo                   string                     `gorm:"-" json:"id_card_no" form:"id_card_no"`
223
+	Gender                     string                     `gorm:"-" json:"gender" form:"gender"`
224
+	Phone                      string                     `gorm:"-" json:"phone" form:"phone"`
225
+	DialysisNo                 string                     `gorm:"-" json:"dialysis_no" form:"dialysis_no"`
222
 	Patient                    string                     `gorm:"-" json:"patient" form:"patient"`
226
 	Patient                    string                     `gorm:"-" json:"patient" form:"patient"`
223
 	DeviceZone                 DeviceZone                 `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
227
 	DeviceZone                 DeviceZone                 `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
224
 	DeviceNumber               DeviceNumber               `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
228
 	DeviceNumber               DeviceNumber               `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
225
-	DialysisPrescription       DialysisSolution           `json:"prescription" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
226
 	DoctorAdvice               []*DoctorAdvice            `json:"doctoradvice" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
229
 	DoctorAdvice               []*DoctorAdvice            `json:"doctoradvice" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
227
 	HisDoctorAdviceInfo        []*HisDoctorAdviceInfo     `json:"hisdoctoradviceinfo" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
230
 	HisDoctorAdviceInfo        []*HisDoctorAdviceInfo     `json:"hisdoctoradviceinfo" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
228
 	DialysisSolution           DialysisSolution           `json:"dialysissolution" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
231
 	DialysisSolution           DialysisSolution           `json:"dialysissolution" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
229
 	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `json:"assessmentbefor" gorm:"foreignkey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate"`
232
 	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `json:"assessmentbefor" gorm:"foreignkey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate"`
233
+	XtDialysisOrderSix         XtDialysisOrderSix         `json:"dialysis_order" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
234
+	DialysisPrescription       DialysisPrescription       `json:"prescription" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
230
 }
235
 }
231
 
236
 
232
 func (WeekScheduleSix) TableName() string {
237
 func (WeekScheduleSix) TableName() string {

+ 76 - 1
service/dialysis_service.go 查看文件

1906
 
1906
 
1907
 func UpdateDoctorAdviceExecution(info models.DoctorAdvice, id int64) error {
1907
 func UpdateDoctorAdviceExecution(info models.DoctorAdvice, id int64) error {
1908
 
1908
 
1909
-	err := XTWriteDB().Where("id = ? and status = 1", id).Update(map[string]interface{}{"execution_staff": info.ExecutionStaff, "execution_state": info.ExecutionState, "execution_time": info.ExecutionTime, "updated_time": info.ExecutionTime}).Error
1909
+	err := XTWriteDB().Model(&models.DoctorAdvice{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"execution_staff": info.ExecutionStaff, "execution_state": info.ExecutionState, "execution_time": info.ExecutionTime, "updated_time": info.ExecutionTime}).Error
1910
 	return err
1910
 	return err
1911
 }
1911
 }
1912
 
1912
 
1928
 	return advice, err
1928
 	return advice, err
1929
 }
1929
 }
1930
 
1930
 
1931
+func CheckDoctorAdvice(id int64, creater int64) (models.DoctorAdviceThrity, error) {
1932
+
1933
+	doctoradvice := models.DoctorAdviceThrity{}
1934
+	err := XTWriteDB().Model(&doctoradvice).Where("id = ? and status = 1", id).Update(map[string]interface{}{"checker": creater, "check_time": time.Now().Unix()}).Error
1935
+	return doctoradvice, err
1936
+}
1937
+
1931
 func CheckHisDoctorAdvice(id int64, creater int64) (models.HisDoctorAdviceThirty, error) {
1938
 func CheckHisDoctorAdvice(id int64, creater int64) (models.HisDoctorAdviceThirty, error) {
1932
 
1939
 
1933
 	doctoradvice := models.HisDoctorAdviceThirty{}
1940
 	doctoradvice := models.HisDoctorAdviceThirty{}
1952
 	err = XTWriteDB().Model(&advice).Where("patient_id in(?) and advice_date = ? and user_org_id = ? and status = 1", patinentids, advice_date, orgid).Update(map[string]interface{}{"is_settle": 1}).Error
1959
 	err = XTWriteDB().Model(&advice).Where("patient_id in(?) and advice_date = ? and user_org_id = ? and status = 1", patinentids, advice_date, orgid).Update(map[string]interface{}{"is_settle": 1}).Error
1953
 	return advice, err
1960
 	return advice, err
1954
 }
1961
 }
1962
+
1963
+func GetHisMobileAdviceGroupList(orgid int64, ids []string) (advice []*models.HisDoctorAdvice, err error) {
1964
+
1965
+	err = XTReadDB().Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Group("drug_id").Find(&advice).Error
1966
+	return advice, err
1967
+}
1968
+
1969
+func GetHisMobileAdviceList(orgid int64, ids []string) (advice []*models.HisDoctorAdvice, err error) {
1970
+
1971
+	err = XTReadDB().Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Find(&advice).Error
1972
+	return advice, err
1973
+}
1974
+
1975
+func ExectionMobileAdvice(orgid int64, ids []string, execution_time int64, execution_staff int64) error {
1976
+
1977
+	advice := models.HisDoctorAdvice{}
1978
+	err := XTWriteDB().Model(&advice).Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Updates(map[string]interface{}{"execution_time": execution_time, "execution_staff": execution_staff, "execution_state": 1}).Error
1979
+	return err
1980
+}
1981
+
1982
+func GetBloodMobileAdviceGroupList(orgid int64, ids []string) (advice []*models.DoctorAdviceThrity, err error) {
1983
+
1984
+	err = XTReadDB().Model(&advice).Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Group("drug_id").Find(&advice).Error
1985
+	return advice, err
1986
+}
1987
+
1988
+func GetBloodMobileAdviceList(orgid int64, ids []string) (advice []*models.DoctorAdviceThrity, err error) {
1989
+
1990
+	err = XTReadDB().Model(&advice).Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Find(&advice).Error
1991
+	return advice, err
1992
+}
1993
+
1994
+func FindAllDoctorAdviceByIds(orgID int64, ids []string) (advice []models.DoctorAdvice, err error) {
1995
+	err = readDb.Model(&models.DoctorAdvice{}).Where("user_org_id=?  AND id in(?)  AND status = 1", orgID, ids).Find(&advice).Error
1996
+	return
1997
+}
1998
+
1999
+func ExectionBloodMobileAdvice(orgid int64, ids []string, execution_time int64, execution_staff int64) error {
2000
+	fmt.Println("ids2323232323323223233223wode", ids)
2001
+	advice := models.DoctorAdviceThrity{}
2002
+	err := XTWriteDB().Model(&advice).Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Updates(map[string]interface{}{"execution_time": execution_time, "execution_staff": execution_staff, "execution_state": 1}).Error
2003
+	return err
2004
+}
2005
+
2006
+func UpdateSettleMobileHisAdvice(orgid int64, ids []string) error {
2007
+
2008
+	advice := models.HisDoctorAdviceThirty{}
2009
+	err := XTWriteDB().Model(&advice).Where("user_org_id = ? and id in(?) and status =1", orgid, ids).Updates(map[string]interface{}{"is_settle": 1}).Error
2010
+	return err
2011
+}
2012
+
2013
+func UpdateSettleMobileBloodAdvice(orgid int64, ids []string) error {
2014
+
2015
+	advice := models.DoctorAdvice{}
2016
+	err := XTWriteDB().Model(&advice).Where("user_org_id = ? and id in(?) and status =1", orgid, ids).Updates(map[string]interface{}{"is_settle": 1}).Error
2017
+	return err
2018
+}
2019
+
2020
+func CheckBloodDoctorAdvice(orgid int64, ids []string, advice models.DoctorAdvice) error {
2021
+
2022
+	err := XTWriteDB().Model(&advice).Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Updates(map[string]interface{}{"check_time": advice.CheckTime, "checker": advice.Checker, "check_state": 1}).Error
2023
+	return err
2024
+}
2025
+
2026
+func CheckHisMobileDoctorAdvice(orgid int64, ids []string, advice models.HisDoctorAdviceThirty) error {
2027
+	err := XTWriteDB().Model(&advice).Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Updates(map[string]interface{}{"check_time": advice.CheckTime, "checker": advice.Checker, "check_state": 1}).Error
2028
+	return err
2029
+}

+ 227 - 60
service/mobile_dialysis_service.go 查看文件

1303
 }
1303
 }
1304
 
1304
 
1305
 type MScheduleDoctorAdviceVMOne struct {
1305
 type MScheduleDoctorAdviceVMOne struct {
1306
-	ID              int64                              `gorm:"column:id" json:"id"`
1307
-	UserOrgId       int64                              `gorm:"column:user_org_id" json:"user_org_id"`
1308
-	PartitionId     int64                              `gorm:"column:partition_id" json:"partition_id"`
1309
-	BedId           int64                              `gorm:"column:bed_id" json:"bed_id"`
1310
-	PatientId       int64                              `gorm:"column:patient_id" json:"patient_id"`
1311
-	ScheduleDate    int64                              `gorm:"column:schedule_date" json:"schedule_date"`
1312
-	ScheduleType    int64                              `gorm:"column:schedule_type" json:"schedule_type"`
1313
-	ModeId          int64                              `gorm:"column:mode_id" json:"mode_id"`
1314
-	Status          int64                              `gorm:"column:status" json:"status"`
1315
-	DialysisOrder   *MDialysisOrderVM                  `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysis_order"`
1316
-	SchedualPatient *MSchedualPatientVM                `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
1317
-	DeviceNumber    *MDeviceNumberVM                   `gorm:"ForeignKey:BedId" json:"device_number"`
1318
-	DoctorAdvices   []*MDoctorAdviceVM                 `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
1319
-	Prescription    *models.DialysisPrescriptionTwenty `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
1320
-	//DialysisAssesmentBefor *models.DialysisAssesmentBefor   `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysisassesmentbefor"`
1306
+	ID                     int64                              `gorm:"column:id" json:"id"`
1307
+	UserOrgId              int64                              `gorm:"column:user_org_id" json:"user_org_id"`
1308
+	PartitionId            int64                              `gorm:"column:partition_id" json:"partition_id"`
1309
+	BedId                  int64                              `gorm:"column:bed_id" json:"bed_id"`
1310
+	PatientId              int64                              `gorm:"column:patient_id" json:"patient_id"`
1311
+	ScheduleDate           int64                              `gorm:"column:schedule_date" json:"schedule_date"`
1312
+	ScheduleType           int64                              `gorm:"column:schedule_type" json:"schedule_type"`
1313
+	ModeId                 int64                              `gorm:"column:mode_id" json:"mode_id"`
1314
+	Status                 int64                              `gorm:"column:status" json:"status"`
1315
+	DialysisOrder          *MDialysisOrderVM                  `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysis_order"`
1316
+	SchedualPatient        *MSchedualPatientVM                `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
1317
+	DeviceNumber           *MDeviceNumberVM                   `gorm:"ForeignKey:BedId" json:"device_number"`
1318
+	DoctorAdvices          []*MDoctorAdviceVM                 `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
1319
+	Prescription           *models.DialysisPrescriptionTwenty `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
1320
+	DialysisAssesmentBefor *models.DialysisAssesmentBefor     `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysisassesmentbefor"`
1321
 }
1321
 }
1322
 
1322
 
1323
 func (MScheduleDoctorAdviceVMOne) TableName() string {
1323
 func (MScheduleDoctorAdviceVMOne) TableName() string {
1487
 		} else if patientType == 2 {
1487
 		} else if patientType == 2 {
1488
 			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
1488
 			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
1489
 			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1489
 			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1490
+		} else if patientType == 3 {
1491
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and is_settle = 1"
1492
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1493
+		} else if patientType == 4 {
1494
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and (is_settle = 0 or is_settle = 2)"
1495
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1490
 		}
1496
 		}
1491
 
1497
 
1492
 	} else if adviceType == 1 {
1498
 	} else if adviceType == 1 {
1502
 			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
1508
 			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
1503
 			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1509
 			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1504
 
1510
 
1511
+		} else if patientType == 3 {
1512
+			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ?  and is_settle = 1"
1513
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1514
+		} else if patientType == 4 {
1515
+			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ?  and (is_settle = 0 or is_settle = 2)"
1516
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1505
 		}
1517
 		}
1506
 
1518
 
1507
 	} else if adviceType == 3 {
1519
 	} else if adviceType == 3 {
1515
 		} else if patientType == 2 {
1527
 		} else if patientType == 2 {
1516
 			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0"
1528
 			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0"
1517
 			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1529
 			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1530
+		} else if patientType == 3 {
1531
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  and is_settle = 1"
1532
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1533
+		} else if patientType == 4 {
1534
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  and (is_settle = 0 or is_settle = 2)"
1535
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1518
 		}
1536
 		}
1519
 
1537
 
1520
 	} else if adviceType == 2 && len(deliverWay) > 0 {
1538
 	} else if adviceType == 2 && len(deliverWay) > 0 {
1528
 		} else if patientType == 2 {
1546
 		} else if patientType == 2 {
1529
 			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and delivery_way = ?"
1547
 			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and delivery_way = ?"
1530
 			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
1548
 			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
1549
+		} else if patientType == 3 {
1550
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2   and delivery_way = ? and is_settle = 1"
1551
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
1552
+		} else if patientType == 4 {
1553
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2   and delivery_way = ? and (is_settle = 0 or is_settle =2)"
1554
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
1531
 		}
1555
 		}
1532
 
1556
 
1533
 	} else if adviceType == 2 && len(deliverWay) <= 0 {
1557
 	} else if adviceType == 2 && len(deliverWay) <= 0 {
1542
 		} else if patientType == 2 {
1566
 		} else if patientType == 2 {
1543
 			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0"
1567
 			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0"
1544
 			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1568
 			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1569
+		} else if patientType == 3 {
1570
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 and is_settle = 1"
1571
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1572
+		} else if patientType == 4 {
1573
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 and (is_settle = 0 or is_settle = 2)"
1574
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
1545
 		}
1575
 		}
1546
 
1576
 
1547
 	}
1577
 	}
1554
 		//}).
1584
 		//}).
1555
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1585
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1556
 		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1586
 		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1557
-		//Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1587
+		Preload("DialysisAssesmentBefor", "status = 1 AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
1558
 		Preload("DoctorAdvices", adviceCondition...).
1588
 		Preload("DoctorAdvices", adviceCondition...).
1559
 		Where("status = 1 AND user_org_id = ?", orgID)
1589
 		Where("status = 1 AND user_org_id = ?", orgID)
1560
 	if scheduleDate != 0 {
1590
 	if scheduleDate != 0 {
1661
 				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1691
 				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1662
 					return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1692
 					return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1663
 				}).
1693
 				}).
1694
+				Preload("DialysisAssesmentBefor", "status = 1 AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
1664
 				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1695
 				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1665
 				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1696
 				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1666
 				Where("status = 1 AND user_org_id = ?", orgID)
1697
 				Where("status = 1 AND user_org_id = ?", orgID)
1670
 			err = db.Find(&vms).Error
1701
 			err = db.Find(&vms).Error
1671
 		}
1702
 		}
1672
 		if patientType > 0 {
1703
 		if patientType > 0 {
1673
-			db := readDb.
1674
-				Table("xt_schedule").
1675
-				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1676
-				Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1677
-				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, deliverWay, adminUserId, adminUserId).
1678
-				Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1679
-				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1680
-				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1681
-				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1682
-					return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1683
-				}).Where("status = 1 AND user_org_id = ?", orgID)
1684
-			if scheduleDate != 0 {
1685
-				db = db.Where("schedule_date = ?", scheduleDate)
1704
+			if patientType == 1 {
1705
+				db := readDb.
1706
+					Table("xt_schedule").
1707
+					Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1708
+					Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1709
+					Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, deliverWay, adminUserId, adminUserId).
1710
+					Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1711
+					Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1712
+					Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1713
+					Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1714
+						return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1715
+					}).Preload("DialysisAssesmentBefor", "status = 1 AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
1716
+					Where("status = 1 AND user_org_id = ?", orgID)
1717
+				if scheduleDate != 0 {
1718
+					db = db.Where("schedule_date = ?", scheduleDate)
1719
+				}
1720
+				err = db.Find(&vms).Error
1686
 			}
1721
 			}
1687
-			err = db.Find(&vms).Error
1722
+
1723
+			if patientType == 2 {
1724
+				db := readDb.
1725
+					Table("xt_schedule").
1726
+					Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1727
+					Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1728
+					Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and  (advice_doctor = ? or execution_staff = ?)", orgID, scheduleDate, deliverWay, adminUserId, adminUserId).
1729
+					Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1730
+					Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1731
+					Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1732
+					Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1733
+						return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1734
+					}).Preload("DialysisAssesmentBefor", "status = 1 AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).Where("status = 1 AND user_org_id = ?", orgID)
1735
+				if scheduleDate != 0 {
1736
+					db = db.Where("schedule_date = ?", scheduleDate)
1737
+				}
1738
+				err = db.Find(&vms).Error
1739
+			}
1740
+
1741
+			if patientType == 3 {
1742
+				db := readDb.
1743
+					Table("xt_schedule").
1744
+					Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1745
+					Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1746
+					Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and  (advice_doctor = ? or execution_staff = ?) and is_settle = 1", orgID, scheduleDate, deliverWay, adminUserId, adminUserId).
1747
+					Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1748
+					Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1749
+					Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1750
+					Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1751
+						return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1752
+					}).Preload("DialysisAssesmentBefor", "status = 1 AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).Where("status = 1 AND user_org_id = ?", orgID)
1753
+				if scheduleDate != 0 {
1754
+					db = db.Where("schedule_date = ?", scheduleDate)
1755
+				}
1756
+				err = db.Find(&vms).Error
1757
+			}
1758
+
1759
+			if patientType == 4 {
1760
+				db := readDb.
1761
+					Table("xt_schedule").
1762
+					Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1763
+					Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1764
+					Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and  (advice_doctor = ? or execution_staff = ?) and (is_settle = 0 or  is_settle = 2)", orgID, scheduleDate, deliverWay, adminUserId, adminUserId).
1765
+					Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1766
+					Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1767
+					Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1768
+					Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1769
+						return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1770
+					}).Preload("DialysisAssesmentBefor", "status = 1 AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).Where("status = 1 AND user_org_id = ?", orgID)
1771
+				if scheduleDate != 0 {
1772
+					db = db.Where("schedule_date = ?", scheduleDate)
1773
+				}
1774
+				err = db.Find(&vms).Error
1775
+			}
1776
+
1688
 		}
1777
 		}
1689
 
1778
 
1690
 	} else {
1779
 	} else {
1700
 				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1789
 				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1701
 				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1790
 				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1702
 				Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1791
 				Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1792
+				Preload("DialysisAssesmentBefor", "status = 1 AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
1703
 				Where("status = 1 AND user_org_id = ?", orgID)
1793
 				Where("status = 1 AND user_org_id = ?", orgID)
1704
 			if scheduleDate != 0 {
1794
 			if scheduleDate != 0 {
1705
 				db = db.Where("schedule_date = ?", scheduleDate)
1795
 				db = db.Where("schedule_date = ?", scheduleDate)
1707
 			err = db.Find(&vms).Error
1797
 			err = db.Find(&vms).Error
1708
 		}
1798
 		}
1709
 		if patientType > 0 {
1799
 		if patientType > 0 {
1710
-			db := readDb.
1711
-				Table("xt_schedule").
1712
-				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1713
-				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
1714
-				Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1715
-				Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1716
-				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1717
-					return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1718
-				}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1719
-				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1720
-				Where("status = 1 AND user_org_id = ?", orgID)
1721
-			if scheduleDate != 0 {
1722
-				db = db.Where("schedule_date = ?", scheduleDate)
1800
+			if patientType == 1 {
1801
+				db := readDb.
1802
+					Table("xt_schedule").
1803
+					Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1804
+					Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
1805
+					Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1806
+					Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1807
+					Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1808
+						return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1809
+					}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1810
+					Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1811
+					Preload("DialysisAssesmentBefor", "status = 1 AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
1812
+					Where("status = 1 AND user_org_id = ?", orgID)
1813
+				if scheduleDate != 0 {
1814
+					db = db.Where("schedule_date = ?", scheduleDate)
1815
+				}
1816
+				err = db.Find(&vms).Error
1723
 			}
1817
 			}
1724
-			err = db.Find(&vms).Error
1818
+			if patientType == 2 {
1819
+				db := readDb.
1820
+					Table("xt_schedule").
1821
+					Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1822
+					Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
1823
+					Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1824
+					Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1825
+					Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1826
+						return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1827
+					}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1828
+					Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1829
+					Preload("DialysisAssesmentBefor", "status = 1 AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
1830
+					Where("status = 1 AND user_org_id = ?", orgID)
1831
+				if scheduleDate != 0 {
1832
+					db = db.Where("schedule_date = ?", scheduleDate)
1833
+				}
1834
+				err = db.Find(&vms).Error
1835
+			}
1836
+
1837
+			if patientType == 3 {
1838
+				db := readDb.
1839
+					Table("xt_schedule").
1840
+					Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1841
+					Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) and is_settle = 1", orgID, scheduleDate, adminUserId, adminUserId).
1842
+					Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1843
+					Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1844
+					Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1845
+						return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1846
+					}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1847
+					Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1848
+					Preload("DialysisAssesmentBefor", "status = 1 AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
1849
+					Where("status = 1 AND user_org_id = ?", orgID)
1850
+				if scheduleDate != 0 {
1851
+					db = db.Where("schedule_date = ?", scheduleDate)
1852
+				}
1853
+				err = db.Find(&vms).Error
1854
+			}
1855
+
1856
+			if patientType == 4 {
1857
+				db := readDb.
1858
+					Table("xt_schedule").
1859
+					Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1860
+					Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) and (is_settle = 0 or is_settle =2) ", orgID, scheduleDate, adminUserId, adminUserId).
1861
+					Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1862
+					Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1863
+					Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1864
+						return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1865
+					}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1866
+					Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1867
+					Preload("DialysisAssesmentBefor", "status = 1 AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
1868
+					Where("status = 1 AND user_org_id = ?", orgID)
1869
+				if scheduleDate != 0 {
1870
+					db = db.Where("schedule_date = ?", scheduleDate)
1871
+				}
1872
+				err = db.Find(&vms).Error
1873
+			}
1874
+
1725
 		}
1875
 		}
1726
 
1876
 
1727
 	}
1877
 	}
1813
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1963
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1814
 			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1964
 			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1815
 			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1965
 			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1816
-			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
1817
 			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1966
 			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1818
 				return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
1967
 				return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
1819
 			}).
1968
 			}).
2043
 func ModifyStartDialysisOrder(order *models.DialysisOrder) error {
2192
 func ModifyStartDialysisOrder(order *models.DialysisOrder) error {
2044
 	tx := writeDb.Begin()
2193
 	tx := writeDb.Begin()
2045
 	updateTime := time.Now().Unix()
2194
 	updateTime := time.Now().Unix()
2046
-	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"start_nurse": order.StartNurse, "updated_time": updateTime, "bed_id": order.BedID, "puncture_nurse": order.PunctureNurse, "start_time": order.StartTime, "modifier": order.Modifier, "schedual_type": order.SchedualType, "washpipe_nurse": order.WashpipeNurse, "change_nurse": order.ChangeNurse, "difficult_puncture_nurse": order.DifficultPunctureNurse, "new_fistula_nurse": order.NewFistulaNurse, "quality_nurse_id": order.QualityNurseId, "puncture_needle": order.PunctureNeedle, "puncture_way": order.PunctureWay, "dialysis_dialyszers": order.DialysisDialyszers, "dialysis_irrigation": order.DialysisIrrigation, "blood_access_id": order.BloodAccessId, "nuclein_date": order.NucleinDate}).Error
2195
+	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"start_nurse": order.StartNurse, "updated_time": updateTime, "bed_id": order.BedID, "puncture_nurse": order.PunctureNurse, "start_time": order.StartTime, "modifier": order.Modifier, "schedual_type": order.SchedualType, "washpipe_nurse": order.WashpipeNurse, "change_nurse": order.ChangeNurse, "difficult_puncture_nurse": order.DifficultPunctureNurse, "new_fistula_nurse": order.NewFistulaNurse, "quality_nurse_id": order.QualityNurseId, "puncture_needle": order.PunctureNeedle, "puncture_way": order.PunctureWay, "dialysis_dialyszers": order.DialysisDialyszers, "dialysis_irrigation": order.DialysisIrrigation, "blood_access_id": order.BloodAccessId, "nuclein_date": order.NucleinDate, "schedule_remark": order.ScheduleRemark, "order_remark": order.OrderRemark}).Error
2047
 	if err != nil {
2196
 	if err != nil {
2048
 		tx.Rollback()
2197
 		tx.Rollback()
2049
 		return err
2198
 		return err
3021
 	Prescription           *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
3170
 	Prescription           *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
3022
 	HisDoctorAdviceInfo    []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
3171
 	HisDoctorAdviceInfo    []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
3023
 	HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"project"`
3172
 	HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"project"`
3173
+	DialysisAssesmentBefor *models.DialysisAssesmentBefor   `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysisassesmentbefor"`
3024
 }
3174
 }
3025
 
3175
 
3026
 func (HisMScheduleDoctorAdviceVM) TableName() string {
3176
 func (HisMScheduleDoctorAdviceVM) TableName() string {
3043
 	Prescription           *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
3193
 	Prescription           *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
3044
 	HisDoctorAdviceInfo    []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
3194
 	HisDoctorAdviceInfo    []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
3045
 	HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"project"`
3195
 	HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"project"`
3196
+	DialysisAssesmentBefor *models.DialysisAssesmentBefor   `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysisassesmentbefor"`
3046
 }
3197
 }
3047
 
3198
 
3048
 func (HisMScheduleDoctorAdviceVMOne) TableName() string {
3199
 func (HisMScheduleDoctorAdviceVMOne) TableName() string {
3544
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and patient_id = ? and is_settle", orgID, scheduleDate, deliverWay, patient_id, cost_type).
3695
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and patient_id = ? and is_settle", orgID, scheduleDate, deliverWay, patient_id, cost_type).
3545
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3696
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3546
 							return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3697
 							return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3547
-						}).
3698
+						}).Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
3548
 						Where("status = 1 AND user_org_id = ?", orgID)
3699
 						Where("status = 1 AND user_org_id = ?", orgID)
3549
 					if scheduleDate != 0 {
3700
 					if scheduleDate != 0 {
3550
 						db = db.Where("schedule_date = ?", scheduleDate)
3701
 						db = db.Where("schedule_date = ?", scheduleDate)
3558
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and patient_id = ?", orgID, scheduleDate, deliverWay, patient_id).
3709
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and patient_id = ?", orgID, scheduleDate, deliverWay, patient_id).
3559
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3710
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3560
 							return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3711
 							return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3561
-						}).
3712
+						}).Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
3562
 						Where("status = 1 AND user_org_id = ?", orgID)
3713
 						Where("status = 1 AND user_org_id = ?", orgID)
3563
 					if scheduleDate != 0 {
3714
 					if scheduleDate != 0 {
3564
 						db = db.Where("schedule_date = ?", scheduleDate)
3715
 						db = db.Where("schedule_date = ?", scheduleDate)
3578
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and execution_state = ? and is_settle = ?", orgID, scheduleDate, deliverWay, execution_state, cost_type).
3729
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and execution_state = ? and is_settle = ?", orgID, scheduleDate, deliverWay, execution_state, cost_type).
3579
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3730
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3580
 							return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3731
 							return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3581
-						}).
3732
+						}).Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
3582
 						Where("status = 1 AND user_org_id = ?", orgID)
3733
 						Where("status = 1 AND user_org_id = ?", orgID)
3583
 					if scheduleDate != 0 {
3734
 					if scheduleDate != 0 {
3584
 						db = db.Where("schedule_date = ?", scheduleDate)
3735
 						db = db.Where("schedule_date = ?", scheduleDate)
3592
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and execution_state = ?", orgID, scheduleDate, deliverWay, execution_state).
3743
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and execution_state = ?", orgID, scheduleDate, deliverWay, execution_state).
3593
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3744
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3594
 							return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3745
 							return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3595
-						}).
3746
+						}).Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
3596
 						Where("status = 1 AND user_org_id = ?", orgID)
3747
 						Where("status = 1 AND user_org_id = ?", orgID)
3597
 					if scheduleDate != 0 {
3748
 					if scheduleDate != 0 {
3598
 						db = db.Where("schedule_date = ?", scheduleDate)
3749
 						db = db.Where("schedule_date = ?", scheduleDate)
3609
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and is_settle = ?", orgID, scheduleDate, deliverWay, cost_type).
3760
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and is_settle = ?", orgID, scheduleDate, deliverWay, cost_type).
3610
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3761
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3611
 							return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3762
 							return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3612
-						}).
3763
+						}).Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
3613
 						Where("status = 1 AND user_org_id = ?", orgID)
3764
 						Where("status = 1 AND user_org_id = ?", orgID)
3614
 					if scheduleDate != 0 {
3765
 					if scheduleDate != 0 {
3615
 						db = db.Where("schedule_date = ?", scheduleDate)
3766
 						db = db.Where("schedule_date = ?", scheduleDate)
3623
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
3774
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
3624
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3775
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3625
 							return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3776
 							return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3626
-						}).
3777
+						}).Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
3627
 						Where("status = 1 AND user_org_id = ?", orgID)
3778
 						Where("status = 1 AND user_org_id = ?", orgID)
3628
 					if scheduleDate != 0 {
3779
 					if scheduleDate != 0 {
3629
 						db = db.Where("schedule_date = ?", scheduleDate)
3780
 						db = db.Where("schedule_date = ?", scheduleDate)
3653
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and patient_id = ? and execution_state = ? and is_settle = ?", orgID, scheduleDate, patient_id, execution_state, cost_type).
3804
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and patient_id = ? and execution_state = ? and is_settle = ?", orgID, scheduleDate, patient_id, execution_state, cost_type).
3654
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3805
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3655
 							return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3806
 							return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3656
-						}).
3807
+						}).Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
3657
 						Where("status = 1 AND user_org_id = ?", orgID)
3808
 						Where("status = 1 AND user_org_id = ?", orgID)
3658
 					if scheduleDate != 0 {
3809
 					if scheduleDate != 0 {
3659
 						db = db.Where("schedule_date = ?", scheduleDate)
3810
 						db = db.Where("schedule_date = ?", scheduleDate)
3667
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and patient_id = ? and execution_state = ?", orgID, scheduleDate, patient_id, execution_state).
3818
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and patient_id = ? and execution_state = ?", orgID, scheduleDate, patient_id, execution_state).
3668
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3819
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3669
 							return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3820
 							return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3670
-						}).
3821
+						}).Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
3671
 						Where("status = 1 AND user_org_id = ?", orgID)
3822
 						Where("status = 1 AND user_org_id = ?", orgID)
3672
 					if scheduleDate != 0 {
3823
 					if scheduleDate != 0 {
3673
 						db = db.Where("schedule_date = ?", scheduleDate)
3824
 						db = db.Where("schedule_date = ?", scheduleDate)
3684
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and patient_id = ? and is_settle = ?", orgID, scheduleDate, patient_id, cost_type).
3835
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and patient_id = ? and is_settle = ?", orgID, scheduleDate, patient_id, cost_type).
3685
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3836
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3686
 							return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3837
 							return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3687
-						}).
3838
+						}).Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
3688
 						Where("status = 1 AND user_org_id = ?", orgID)
3839
 						Where("status = 1 AND user_org_id = ?", orgID)
3689
 					if scheduleDate != 0 {
3840
 					if scheduleDate != 0 {
3690
 						db = db.Where("schedule_date = ?", scheduleDate)
3841
 						db = db.Where("schedule_date = ?", scheduleDate)
3698
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
3849
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
3699
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3850
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3700
 							return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3851
 							return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3701
-						}).
3852
+						}).Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
3702
 						Where("status = 1 AND user_org_id = ?", orgID)
3853
 						Where("status = 1 AND user_org_id = ?", orgID)
3703
 					if scheduleDate != 0 {
3854
 					if scheduleDate != 0 {
3704
 						db = db.Where("schedule_date = ?", scheduleDate)
3855
 						db = db.Where("schedule_date = ?", scheduleDate)
3718
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and execution_state = ? and is_settle = ?", orgID, scheduleDate, execution_state, cost_type).
3869
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and execution_state = ? and is_settle = ?", orgID, scheduleDate, execution_state, cost_type).
3719
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3870
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3720
 							return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3871
 							return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3721
-						}).
3872
+						}).Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
3722
 						Where("status = 1 AND user_org_id = ?", orgID)
3873
 						Where("status = 1 AND user_org_id = ?", orgID)
3723
 					if scheduleDate != 0 {
3874
 					if scheduleDate != 0 {
3724
 						db = db.Where("schedule_date = ?", scheduleDate)
3875
 						db = db.Where("schedule_date = ?", scheduleDate)
3732
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and execution_state = ?", orgID, scheduleDate, execution_state).
3883
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and execution_state = ?", orgID, scheduleDate, execution_state).
3733
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3884
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3734
 							return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3885
 							return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3735
-						}).
3886
+						}).Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
3736
 						Where("status = 1 AND user_org_id = ?", orgID)
3887
 						Where("status = 1 AND user_org_id = ?", orgID)
3737
 					if scheduleDate != 0 {
3888
 					if scheduleDate != 0 {
3738
 						db = db.Where("schedule_date = ?", scheduleDate)
3889
 						db = db.Where("schedule_date = ?", scheduleDate)
3749
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and is_settle = ?", orgID, scheduleDate, cost_type).
3900
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and is_settle = ?", orgID, scheduleDate, cost_type).
3750
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3901
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3751
 							return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3902
 							return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3752
-						}).
3903
+						}).Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
3753
 						Where("status = 1 AND user_org_id = ?", orgID)
3904
 						Where("status = 1 AND user_org_id = ?", orgID)
3754
 					if scheduleDate != 0 {
3905
 					if scheduleDate != 0 {
3755
 						db = db.Where("schedule_date = ?", scheduleDate)
3906
 						db = db.Where("schedule_date = ?", scheduleDate)
3763
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
3914
 						Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
3764
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3915
 						Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3765
 							return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3916
 							return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3766
-						}).
3917
+						}).Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
3767
 						Where("status = 1 AND user_org_id = ?", orgID)
3918
 						Where("status = 1 AND user_org_id = ?", orgID)
3768
 					if scheduleDate != 0 {
3919
 					if scheduleDate != 0 {
3769
 						db = db.Where("schedule_date = ?", scheduleDate)
3920
 						db = db.Where("schedule_date = ?", scheduleDate)
5018
 	err := db.Find(&vms).Error
5169
 	err := db.Find(&vms).Error
5019
 	return vms, err
5170
 	return vms, err
5020
 }
5171
 }
5172
+
5173
+func GetLastPatientOrder(id int64) (models.XtDialysisOrder, error) {
5174
+
5175
+	order := models.XtDialysisOrder{}
5176
+	err := XTReadDB().Where("id = ? and status = 1", id).Find(&order).Error
5177
+	return order, err
5178
+}
5179
+
5180
+func UpdateMobilePatient(org_id int64, patient_id int64, schedule_remark string) error {
5181
+
5182
+	order := models.XtPatients{}
5183
+	err := XTWriteDB().Model(&order).Where("user_org_id = ? and id = ? and status = 1", org_id, patient_id).Updates(map[string]interface{}{"schedule_remark": schedule_remark}).Error
5184
+
5185
+	err = XTWriteDB().Model(models.XtPatientsNew{}).Where("user_org_id = ? and id = ? and status = 1", org_id, patient_id).Updates(map[string]interface{}{"schedule_remark": schedule_remark}).Error
5186
+	return err
5187
+}

+ 21 - 6
service/schedule_service.go 查看文件

688
 
688
 
689
 func GetWeekDayScheduleByIdThee(orgid int64, scheduleDate int64, scheduleType int64, zone []string) (list []*models.VmSchedulesRemind, err error) {
689
 func GetWeekDayScheduleByIdThee(orgid int64, scheduleDate int64, scheduleType int64, zone []string) (list []*models.VmSchedulesRemind, err error) {
690
 
690
 
691
-	db := readDb2.Table("xt_schedule as x").Where("x.status = 1")
691
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
692
 	if orgid > 0 {
692
 	if orgid > 0 {
693
 		db = db.Where("x.user_org_id = ?", orgid)
693
 		db = db.Where("x.user_org_id = ?", orgid)
694
 	}
694
 	}
715
 
715
 
716
 func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int64, startDate int64, zone []string) (list []*models.VmSchedulesRemind, err error) {
716
 func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int64, startDate int64, zone []string) (list []*models.VmSchedulesRemind, err error) {
717
 
717
 
718
-	db := readDb2.Table("xt_schedule as x").Where("x.status = 1")
718
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
719
 	if orgid > 0 {
719
 	if orgid > 0 {
720
 		db = db.Where("x.user_org_id = ?", orgid)
720
 		db = db.Where("x.user_org_id = ?", orgid)
721
 	}
721
 	}
729
 		db = db.Where("x.partition_id in (?)", zone)
729
 		db = db.Where("x.partition_id in (?)", zone)
730
 	}
730
 	}
731
 
731
 
732
-	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1 and dialysis_date =?", scheduleDate).Preload("XtAssessmentBeforeDislysis", "status = 1 and assessment_date =?", scheduleDate).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
732
+	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export,x.mode_id").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1 and dialysis_date =?", scheduleDate).Preload("XtAssessmentBeforeDislysis", "status = 1 and assessment_date =?", scheduleDate).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
733
 		return db.Where("status =1 and parent_id = 0 and advice_date = ?", scheduleDate).Preload("ChildDoctorAdvice", "status = 1")
733
 		return db.Where("status =1 and parent_id = 0 and advice_date = ?", scheduleDate).Preload("ChildDoctorAdvice", "status = 1")
734
 	}).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ?", scheduleDate).Preload("DialysisPrescription", "status = 1 and record_date = ?", scheduleDate).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
734
 	}).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ?", scheduleDate).Preload("DialysisPrescription", "status = 1 and record_date = ?", scheduleDate).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
735
 		return db.Where("status =1").Order("id asc")
735
 		return db.Where("status =1").Order("id asc")
894
 
894
 
895
 func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endtime int64, orgID int64, zone []string, record_date int64) (schedules []*models.WeekScheduleSix, err error) {
895
 func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endtime int64, orgID int64, zone []string, record_date int64) (schedules []*models.WeekScheduleSix, err error) {
896
 
896
 
897
-	db := readDb2.Table("xt_schedule as s ").Where("s.status =1")
897
+	db := XTReadDB().Table("xt_schedule as s ").Where("s.status =1")
898
 	if orgID > 0 {
898
 	if orgID > 0 {
899
 		db = db.Where("s.user_org_id = ?", orgID)
899
 		db = db.Where("s.user_org_id = ?", orgID)
900
 	}
900
 	}
925
 	}).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
925
 	}).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
926
 		return db.Where("status =1 and parent_id = 0 and advice_date = ?", record_date).Preload("ChildDoctorAdvice", "status = 1 and advice_date = ?", record_date)
926
 		return db.Where("status =1 and parent_id = 0 and advice_date = ?", record_date).Preload("ChildDoctorAdvice", "status = 1 and advice_date = ?", record_date)
927
 	}).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ?", record_date).Joins("JOIN xt_patients as p ON p.id = s.patient_id").
927
 	}).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ?", record_date).Joins("JOIN xt_patients as p ON p.id = s.patient_id").
928
-		Select("s.id,s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id, s.status, s.created_time, s.updated_time, p.name as patient").
928
+		Select("s.id,s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id, s.status, s.created_time, s.updated_time, p.name as patient,p.id_card_no as id_card_no,p.dialysis_no as dialysis_no,p.gender as gender,p.phone as phone").
929
 		Order("s.partition_id desc").
929
 		Order("s.partition_id desc").
930
 		Find(&schedules).Error
930
 		Find(&schedules).Error
931
 	return schedules, err
931
 	return schedules, err
1089
 
1089
 
1090
 func GetNextWeekPanels(startime int64, endtime int64, orgid int64) (schedule []*models.XtSchedule, err error) {
1090
 func GetNextWeekPanels(startime int64, endtime int64, orgid int64) (schedule []*models.XtSchedule, err error) {
1091
 
1091
 
1092
-	err = readDb2.Model(&schedule).Where("schedule_date >=? and schedule_date<=? and status = 1 and user_org_id = ?", startime, endtime, orgid).Preload("LastAfterWeight", func(db *gorm.DB) *gorm.DB {
1092
+	err = XTReadDB().Model(&schedule).Where("schedule_date >=? and schedule_date<=? and status = 1 and user_org_id = ?", startime, endtime, orgid).Preload("LastAfterWeight", func(db *gorm.DB) *gorm.DB {
1093
 		return db.Where("user_org_id = ? and status = 1 and assessment_date < ?", orgid, endtime)
1093
 		return db.Where("user_org_id = ? and status = 1 and assessment_date < ?", orgid, endtime)
1094
 	}).Find(&schedule).Error
1094
 	}).Find(&schedule).Error
1095
 	return schedule, err
1095
 	return schedule, err
1205
 	err := XTWriteDB().Model(&schedule).Where("patient_id = ? and schedule_date = ? and user_org_id = ? and status = 1", schedule.PatientId, schedule.ScheduleDate, schedule.UserOrgId).Update(map[string]interface{}{"schedule_type": schedule.ScheduleType}).Error
1205
 	err := XTWriteDB().Model(&schedule).Where("patient_id = ? and schedule_date = ? and user_org_id = ? and status = 1", schedule.PatientId, schedule.ScheduleDate, schedule.UserOrgId).Update(map[string]interface{}{"schedule_type": schedule.ScheduleType}).Error
1206
 	return err
1206
 	return err
1207
 }
1207
 }
1208
+
1209
+func GetLastDialysisOrder(org_id int64, patient_id int64, dialysis_date int64) (models.XtDialysisOrderSix, error) {
1210
+
1211
+	order := models.XtDialysisOrderSix{}
1212
+	err := XTReadDB().Where("user_org_id = ? and patient_id = ? and dialysis_date < ? and status = 1", org_id, patient_id, dialysis_date).Order("id desc").First(&order).Error
1213
+	return order, err
1214
+}
1215
+
1216
+func GetLastDialysisSolution(org_id int64, patient_id int64, mode_id int64, schedule_date int64) (models.DialysisPrescription, error) {
1217
+
1218
+	dialysisprescription := models.DialysisPrescription{}
1219
+	err := XTReadDB().Where("user_org_id = ? and patient_id = ? and mode_id = ? and status = 1 and record_date<?", org_id, patient_id, mode_id, schedule_date).Order("id desc").First(&dialysisprescription).Error
1220
+	return dialysisprescription, err
1221
+
1222
+}

+ 21 - 0
service/stock_service.go 查看文件

7113
 	return config, err
7113
 	return config, err
7114
 }
7114
 }
7115
 
7115
 
7116
+func FindXTHisRecordByOrgIdSix(org_id int64) (models.XtHisConfig, error) {
7117
+
7118
+	config := models.XtHisConfig{}
7119
+	err = readDb.Model(&models.XtHisConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&config).Error
7120
+	return config, err
7121
+}
7122
+
7116
 func CreateDrugOutConfig(config models.DrugOutConfig) error {
7123
 func CreateDrugOutConfig(config models.DrugOutConfig) error {
7117
 
7124
 
7118
 	err := XTWriteDB().Create(&config).Error
7125
 	err := XTWriteDB().Create(&config).Error
8142
 	err := XTReadDB().Where("id = ? and status = 1", good_id).Find(&info).Error
8149
 	err := XTReadDB().Where("id = ? and status = 1", good_id).Find(&info).Error
8143
 	return info, err
8150
 	return info, err
8144
 }
8151
 }
8152
+
8153
+func GetHisDocById(id int64, orgid int64) (models.HisDoctorAdvice, error) {
8154
+
8155
+	advice := models.HisDoctorAdvice{}
8156
+	err := XTReadDB().Where("id = ? and user_org_id= ? and status = 1", id, orgid).Find(&advice).Error
8157
+	return advice, err
8158
+}
8159
+
8160
+func GetBloodDocById(id int64, orgid int64) (models.DoctorAdvice, error) {
8161
+
8162
+	advice := models.DoctorAdvice{}
8163
+	err := XTReadDB().Where("id = ? and user_org_id= ? and status = 1", id, orgid).Find(&advice).Error
8164
+	return advice, err
8165
+}