28169 hace 2 años
padre
commit
46602b19c8
Se han modificado 2 ficheros con 63 adiciones y 61 borrados
  1. 3 0
      controllers/doctors_api_controller.go
  2. 60 61
      service/pharmacy_service.go

+ 3 - 0
controllers/doctors_api_controller.go Ver fichero

@@ -123,6 +123,8 @@ func (c *DoctorsApiController) ScheduleAdvices() {
123 123
 		hisAdvices, err := service.GetHisDoctorAdvicesTwentyOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id, excution_way, 0, execution_frequency)
124 124
 		adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
125 125
 		project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id, excution_way)
126
+
127
+		drug, _ := service.GetAllBaseDrugListTwenty(orgID)
126 128
 		for _, item := range project {
127 129
 			index := 0
128 130
 			for _, subItem := range item.HisPrescriptionTeamProject {
@@ -152,6 +154,7 @@ func (c *DoctorsApiController) ScheduleAdvices() {
152 154
 				"config":         config,
153 155
 				"project_config": project_config,
154 156
 				"project":        project,
157
+				"drug":           drug,
155 158
 			})
156 159
 		}
157 160
 	}

+ 60 - 61
service/pharmacy_service.go Ver fichero

@@ -30,7 +30,6 @@ func SaveErrs(org_id int64, input *context.BeegoInput, err error) {
30 30
 	XTWriteDB().Create(&tmp)
31 31
 }
32 32
 
33
-//
34 33
 func SavePharmacy() (err error) {
35 34
 	var advice_info []*models.HisDoctorAdviceInfo
36 35
 	err = XTReadDB().Raw("select * from xt_doctor_advice where id > 21780 and id < 21790").Scan(&advice_info).Error
@@ -40,7 +39,7 @@ func SavePharmacy() (err error) {
40 39
 	return nil
41 40
 }
42 41
 
43
-//查询药房中某一天的患者人数,is_medicine:0未发,1已发(改)
42
+// 查询药房中某一天的患者人数,is_medicine:0未发,1已发(改)
44 43
 func GetTodayPharmacy(stime, etime, orgid, is_medicine int64) (num int, err error) {
45 44
 	//orgid = 9675
46 45
 	InitDrugidIsNil(orgid, stime, etime)
@@ -75,7 +74,7 @@ func GetTodayPharmacy(stime, etime, orgid, is_medicine int64) (num int, err erro
75 74
 
76 75
 }
77 76
 
78
-//(改)
77
+// (改)
79 78
 func GetTodayDrug(stime, etime, orgid, is_medicine int64, keyword string) (list []*models.TmpPatient, err error) {
80 79
 	InitDrugidIsNil(orgid, stime, etime)
81 80
 	//病人
@@ -150,7 +149,7 @@ func GetTodayDrug(stime, etime, orgid, is_medicine int64, keyword string) (list
150 149
 
151 150
 }
152 151
 
153
-//查询患者(改)
152
+// 查询患者(改)
154 153
 func GetManyUsers(tmp []int64) (list []*models.TmpPatient, err error) {
155 154
 
156 155
 	for i := 0; i < len(tmp); i++ {
@@ -167,7 +166,7 @@ func GetManyUsers(tmp []int64) (list []*models.TmpPatient, err error) {
167 166
 	return
168 167
 }
169 168
 
170
-//查询患者当天时间段中的药,is_medicine:0未发,1已发(改)
169
+// 查询患者当天时间段中的药,is_medicine:0未发,1已发(改)
171 170
 func GetPatientMedication(orgid, patient_id, stime, etime, is_medicine int64) (pp []*models.PharmacyContent, err error) {
172 171
 	InitDrugidIsNil(orgid, stime, etime)
173 172
 	var tmp []*models.HisDoctorAdviceInfoL
@@ -230,14 +229,14 @@ func GetPatientMedication(orgid, patient_id, stime, etime, is_medicine int64) (p
230 229
 	return
231 230
 }
232 231
 
233
-//获取创建者姓名(改)
232
+// 获取创建者姓名(改)
234 233
 func GetAdminUserName(doctor, orgid int64) string {
235 234
 	var tmp models.VmUserAdminRole
236 235
 	XTReadDB().Model(&models.VmUserAdminRole{}).Where("admin_user_id = ? and org_id = ? and status = 1", doctor, orgid).Find(&tmp)
237 236
 	return tmp.UserName
238 237
 }
239 238
 
240
-//查询该机构的药房配置,true: 通过药房发药,false:不通过药房发药。如果没有该机构的信息则生成一条数据
239
+// 查询该机构的药房配置,true: 通过药房发药,false:不通过药房发药。如果没有该机构的信息则生成一条数据
241 240
 func GetOrgIdPharmacyConfig(orgid int64) bool {
242 241
 	var total int
243 242
 	var tmp_pharmacy models.PharmacyConfig
@@ -263,7 +262,7 @@ func GetOrgIdPharmacyConfig(orgid int64) bool {
263 262
 	}
264 263
 }
265 264
 
266
-//修改该机构的药房配置
265
+// 修改该机构的药房配置
267 266
 func ModifyPharmacyConfig(orgid, isopen int64) (err error) {
268 267
 	if isopen == 1 || isopen == 2 {
269 268
 		err = XTWriteDB().Model(&models.PharmacyConfig{}).Where("user_org_id = ? and status = 1", orgid).Updates(map[string]interface{}{
@@ -276,21 +275,21 @@ func ModifyPharmacyConfig(orgid, isopen int64) (err error) {
276 275
 	return
277 276
 }
278 277
 
279
-//查询该药品是否通过药房发药.0否;1是
278
+// 查询该药品是否通过药房发药.0否;1是
280 279
 func DrugAllocation(drug_id int64) (is_pharmacy int64, err error) {
281 280
 	tmp := models.BaseDrugLib{}
282 281
 	err = XTReadDB().Model(&models.BaseDrugLib{}).Where("id = ?", drug_id).Find(&tmp).Error
283 282
 	return tmp.IsPharmacy, err
284 283
 }
285 284
 
286
-//根据id查询该药是否发药
285
+// 根据id查询该药是否发药
287 286
 func MedicineState(id int64) (is_medicine models.HisDoctorAdviceInfoL, err error) {
288 287
 	tmp := models.HisDoctorAdviceInfoL{}
289 288
 	err = XTReadDB().Model(&models.HisDoctorAdviceInfoL{}).Where("id = ?", id).Find(&tmp).Error
290 289
 	return tmp, err
291 290
 }
292 291
 
293
-//发药明细列表(
292
+// 发药明细列表(
294 293
 func DispensingDetailsList(stime, etime, orgid, page, limit int64, keyword string) (dislist []*models.DispensingList, total int64, err error) {
295 294
 	var fenye []*models.Pharmary //分页用的
296 295
 	offset := (page - 1) * limit
@@ -329,7 +328,7 @@ func DispensingDetailsList(stime, etime, orgid, page, limit int64, keyword strin
329 328
 	return
330 329
 }
331 330
 
332
-//处方详情//////////////////////
331
+// 处方详情//////////////////////
333 332
 func PrescriptionDetails(patient_id, record_date, orgid int64) (pre []*models.PrescripDetails, err error) {
334 333
 	var tmp []*models.HisDoctorAdviceInfoL
335 334
 	err = XTReadDB().Model(&models.HisDoctorAdviceInfoL{}).Where(
@@ -371,7 +370,7 @@ func PrescriptionDetails(patient_id, record_date, orgid int64) (pre []*models.Pr
371 370
 	return
372 371
 }
373 372
 
374
-//查询病人的his id
373
+// 查询病人的his id
375 374
 func GetHisID(prescription_id, orgid int64) (id int64) {
376 375
 	var tmp models.HisPrintPrescription
377 376
 	XTReadDB().Model(&models.HisPrintPrescription{}).Where("id = ?", prescription_id).Find(&tmp)
@@ -380,7 +379,7 @@ func GetHisID(prescription_id, orgid int64) (id int64) {
380 379
 	return fin.ID
381 380
 }
382 381
 
383
-//根据药品id获取药品信息
382
+// 根据药品id获取药品信息
384 383
 func GetDrugNameTX(id int64, tx *gorm.DB) (tmp models.SpBaseDrug, err error) {
385 384
 	err = tx.Model(&models.SpBaseDrug{}).Where("id = ? and status = 1", id).Find(&tmp).Error
386 385
 	return
@@ -392,7 +391,7 @@ func GetXtManufacturer(id int64, tx *gorm.DB) (name string, err error) {
392 391
 	return
393 392
 }
394 393
 
395
-//查询药品(使用keyword)
394
+// 查询药品(使用keyword)
396 395
 func GetManyDrugs(orgid int64, keyword string) (map[int64]models.PharmacyBaseDrug, error) {
397 396
 	var tmp []*models.PharmacyBaseDrug
398 397
 	tt := make(map[int64]models.PharmacyBaseDrug)
@@ -403,7 +402,7 @@ func GetManyDrugs(orgid int64, keyword string) (map[int64]models.PharmacyBaseDru
403 402
 	return tt, err
404 403
 }
405 404
 
406
-//查询(
405
+// 查询(
407 406
 func GetTodayMedicine(stime, etime, orgid, is_medicine int64, keyword string) (finlly []*models.ListOfDrugs, err error) {
408 407
 	InitDrugidIsNil(orgid, stime, etime)
409 408
 	var tmp []*models.TmpLLL
@@ -474,7 +473,7 @@ func GetTodayMedicine(stime, etime, orgid, is_medicine int64, keyword string) (f
474 473
 	return
475 474
 }
476 475
 
477
-//根据药品id获取药品规格(
476
+// 根据药品id获取药品规格(
478 477
 func FindDrugSpecifications(id int64) (name, specifications string) {
479 478
 	var tmp models.PharmacyBaseDrug
480 479
 	XTReadDB().Model(&models.PharmacyBaseDrug{}).Where("id = ?", id).Find(&tmp)
@@ -483,7 +482,7 @@ func FindDrugSpecifications(id int64) (name, specifications string) {
483 482
 	return
484 483
 }
485 484
 
486
-//根据药品id获取当前药品出库仓库的库存数量
485
+// 根据药品id获取当前药品出库仓库的库存数量
487 486
 func GetInventoryQuantity(orgid, drugid int64) (number string, err error) {
488 487
 	//获取药品拆零数量
489 488
 	var phar models.PharmacyBaseDrug
@@ -516,7 +515,7 @@ func GetInventoryQuantity(orgid, drugid int64) (number string, err error) {
516 515
 	return
517 516
 }
518 517
 
519
-//获取该药品的病人信息(
518
+// 获取该药品的病人信息(
520 519
 func FindMedicationList(orgid, drug_id, stime, etime, is_medicine int64) (pp []*models.PatientInformation, err error) { ///////////////
521 520
 	InitDrugidIsNil(orgid, stime, etime)
522 521
 	var tmp []*models.HisDoctorAdviceInfoL
@@ -566,7 +565,7 @@ func FindMedicationList(orgid, drug_id, stime, etime, is_medicine int64) (pp []*
566 565
 	return
567 566
 }
568 567
 
569
-//患者发药按钮点击(
568
+// 患者发药按钮点击(
570 569
 func DispensingMedicine(orgid, patient_id, stime, etime, creater int64) (err error) {
571 570
 	//开事务
572 571
 	tx := XTWriteDB().Begin()
@@ -688,7 +687,7 @@ func DispensingMedicine(orgid, patient_id, stime, etime, creater int64) (err err
688 687
 	return
689 688
 }
690 689
 
691
-//患者退药按钮点击
690
+// 患者退药按钮点击
692 691
 func DrugWithdrawal(orgid, patient_id, stime, etime, creater int64) (err error) {
693 692
 	//开事务
694 693
 	tx := XTWriteDB().Begin()
@@ -829,7 +828,7 @@ func DrugWithdrawal(orgid, patient_id, stime, etime, creater int64) (err error)
829 828
 	return
830 829
 }
831 830
 
832
-//获取患者名称
831
+// 获取患者名称
833 832
 func FindUserName(patient_id int64) (name string) {
834 833
 	var tmp models.GetHisName
835 834
 	XTReadDB().Model(&models.GetHisName{}).Where("id = ?", patient_id).Find(&tmp)
@@ -837,7 +836,7 @@ func FindUserName(patient_id int64) (name string) {
837 836
 	return
838 837
 }
839 838
 
840
-//获取药品名称
839
+// 获取药品名称
841 840
 func FindDrugsName(drug_id int64) (name string) {
842 841
 	var tmp models.Drug
843 842
 	XTReadDB().Model(&models.Drug{}).Where("id = ?", drug_id).Find(&tmp)
@@ -845,7 +844,7 @@ func FindDrugsName(drug_id int64) (name string) {
845 844
 	return
846 845
 }
847 846
 
848
-//药品发药按钮点击(
847
+// 药品发药按钮点击(
849 848
 func MedicineDeparture(ids string, creater, orgid int64) (err error) {
850 849
 	//开事务
851 850
 	tx := XTWriteDB().Begin()
@@ -995,14 +994,14 @@ func MedicineDeparture(ids string, creater, orgid int64) (err error) {
995 994
 	return
996 995
 }
997 996
 
998
-//获取领药人姓名(
997
+// 获取领药人姓名(
999 998
 func GetUserAdminName(id, orgID int64) string {
1000 999
 	var tmp models.XTSgjUserAdminRole
1001 1000
 	XTReadDB().Model(&models.XTSgjUserAdminRole{}).Where("admin_user_id = ? and org_id = ?", id, orgID).Find(&tmp)
1002 1001
 	return tmp.UserName
1003 1002
 }
1004 1003
 
1005
-//根据id查询是否已发药,true已发药,false未发药gai
1004
+// 根据id查询是否已发药,true已发药,false未发药gai
1006 1005
 func GiveTheMedicine(id int64) bool {
1007 1006
 	var xue models.PharmacyDoctorAdvice
1008 1007
 	XTReadDB().Model(&models.PharmacyDoctorAdvice{}).Where("id = ?", id).Find(&xue)
@@ -1012,7 +1011,7 @@ func GiveTheMedicine(id int64) bool {
1012 1011
 	return false
1013 1012
 }
1014 1013
 
1015
-//查询改组中的药品是否包含已发药的,true已发药,false未发药
1014
+// 查询改组中的药品是否包含已发药的,true已发药,false未发药
1016 1015
 func GiveGroupMedicine(orgid, groupNo int64) bool {
1017 1016
 	var total int
1018 1017
 	XTReadDB().Model(&models.DoctorAdvice{}).Where("user_org_id = ? and groupno = ? and status = 1 and is_medicine = 1", orgid, groupNo).Count(&total)
@@ -1022,7 +1021,7 @@ func GiveGroupMedicine(orgid, groupNo int64) bool {
1022 1021
 	return false
1023 1022
 }
1024 1023
 
1025
-//查询处方中是否包含已发药的
1024
+// 查询处方中是否包含已发药的
1026 1025
 func GiveChuMedicine(id int64) bool {
1027 1026
 	var total int
1028 1027
 	XTReadDB().Model(&models.HisDoctorAdviceInfoL{}).Where("prescription_id = ? and status = 1 and is_medicine = 1", id).Count(&total)
@@ -1032,7 +1031,7 @@ func GiveChuMedicine(id int64) bool {
1032 1031
 	return false
1033 1032
 }
1034 1033
 
1035
-//根据处方id查找该处方中是否存在已发药的药品
1034
+// 根据处方id查找该处方中是否存在已发药的药品
1036 1035
 func IsChuIssuedDrugs(prescription_id int64) bool {
1037 1036
 	var total int
1038 1037
 	XTReadDB().Model(&models.HisDoctorAdviceInfoL{}).Where("prescription_id = ? and status = 1 and is_medicine = 1", prescription_id).Count(&total)
@@ -1042,8 +1041,8 @@ func IsChuIssuedDrugs(prescription_id int64) bool {
1042 1041
 	return false
1043 1042
 }
1044 1043
 
1045
-//判断该药品是否通过药房管理出库,true是,false否
1046
-//id 药品id,org_id 机构id
1044
+// 判断该药品是否通过药房管理出库,true是,false否
1045
+// id 药品id,org_id 机构id
1047 1046
 func IsPharmacyDelivery(id, org_id int64) bool {
1048 1047
 	//判断药品是否通过药房管理
1049 1048
 	var total01 int
@@ -1057,7 +1056,7 @@ func IsPharmacyDelivery(id, org_id int64) bool {
1057 1056
 	return false
1058 1057
 }
1059 1058
 
1060
-//判断机构是否通过药房管理出库
1059
+// 判断机构是否通过药房管理出库
1061 1060
 func IsPharmacyConfig(orgid int64) (bo bool) {
1062 1061
 	var total int
1063 1062
 	XTReadDB().Model(&models.PharmacyConfig{}).Where("user_org_id = ? and is_open = 1 and status = 1", orgid).Count(&total)
@@ -1067,7 +1066,7 @@ func IsPharmacyConfig(orgid int64) (bo bool) {
1067 1066
 	return false
1068 1067
 }
1069 1068
 
1070
-//根据患者id和发药时间,获取医生的id和姓名
1069
+// 根据患者id和发药时间,获取医生的id和姓名
1071 1070
 func GetDoctorIds(id, recordtime, orgid int64) (doctor_id int64, doctor_name string, err error) {
1072 1071
 	var tmp []*models.TmpAdviceDoctor
1073 1072
 	//var tmp []int64
@@ -1091,7 +1090,7 @@ func MapToJson(param map[string]interface{}) string {
1091 1090
 	return dataString
1092 1091
 }
1093 1092
 
1094
-//封装扣减库存
1093
+// 封装扣减库存
1095 1094
 func FenStock(orgid, creater int64, v *models.HisDoctorAdviceInfo) (err error) {
1096 1095
 
1097 1096
 	err = HisDrugsDelivery(orgid, creater, v)
@@ -1118,7 +1117,7 @@ func FenStock(orgid, creater int64, v *models.HisDoctorAdviceInfo) (err error) {
1118 1117
 	return
1119 1118
 }
1120 1119
 
1121
-//封装查询药品库存是否足够
1120
+// 封装查询药品库存是否足够
1122 1121
 func FenDrugInventory(item *models.HisDoctorAdviceInfo, orgid int64) bool {
1123 1122
 	var total int64
1124 1123
 	var prescribing_number_total int64
@@ -1233,7 +1232,7 @@ func GetAdviceId2(id, orgid, execution_staff int64, thetime time.Time) (bo bool,
1233 1232
 	return false, err
1234 1233
 }
1235 1234
 
1236
-//判断药品是否零用
1235
+// 判断药品是否零用
1237 1236
 func PettyCash(id int64) bool {
1238 1237
 	drug := models.XtBaseDrug{}
1239 1238
 	XTReadDB().Model(&drug).Where("id = ? and status = 1", id).Find(&drug)
@@ -1243,16 +1242,16 @@ func PettyCash(id int64) bool {
1243 1242
 	return false
1244 1243
 }
1245 1244
 
1246
-//初始化
1245
+// 初始化
1247 1246
 func InitDrugidIsNil(orgid, stime, etime int64) {
1248 1247
 	var advice []*models.DoctorAdvice
1249 1248
 	XTReadDB().Model(&models.DoctorAdvice{}).Where("drug_id = 0 and user_org_id = ? and status = 1 and created_time >= ? and created_time <= ?", orgid, stime, etime).Find(&advice)
1250 1249
 	for _, v := range advice {
1251
-		XTWriteDB().Exec("update xt_doctor_advice set drug_id = (select id from xt_base_drug where drug_name = ? and org_id = ?) where id = ?", v.AdviceName, v.UserOrgId, v.ID)
1250
+		XTWriteDB().Exec("update xt_doctor_advice set drug_id = (select id from xt_base_drug where drug_name = ? and org_id = ? and status = 1 limit 1) where id = ?", v.AdviceName, v.UserOrgId, v.ID)
1252 1251
 	}
1253 1252
 }
1254 1253
 
1255
-//改变处方状态(发药
1254
+// 改变处方状态(发药
1256 1255
 func ChangeHisPrescription(tmp []int64) (err error) {
1257 1256
 	var advice_info []*models.HisDoctorAdviceInfo
1258 1257
 	err = XTReadDB().Model(&models.HisDoctorAdviceInfo{}).Where("id in (?) and status = 1", tmp).Find(&advice_info).Error
@@ -1279,7 +1278,7 @@ func ChangeHisPrescription(tmp []int64) (err error) {
1279 1278
 	return
1280 1279
 }
1281 1280
 
1282
-//改变处方状态(退药
1281
+// 改变处方状态(退药
1283 1282
 func ChangeHisPrescriptionT(tmp []int64) (err error) {
1284 1283
 	var advice_info []*models.HisDoctorAdviceInfo
1285 1284
 	err = XTReadDB().Model(&models.HisDoctorAdviceInfo{}).Where("id in (?) and status = 1", tmp).Find(&advice_info).Error
@@ -1311,7 +1310,7 @@ func ChangeHisPrescriptionT(tmp []int64) (err error) {
1311 1310
 	return
1312 1311
 }
1313 1312
 
1314
-//改变处方状态
1313
+// 改变处方状态
1315 1314
 func ChangeHisPrescriptionid(id string) (err error) {
1316 1315
 	var advice models.HisDoctorAdviceInfo
1317 1316
 	err = XTReadDB().Model(&models.HisDoctorAdviceInfo{}).Where("id = ? and status = 1", id).Find(&advice).Error
@@ -1331,7 +1330,7 @@ func ChangeHisPrescriptionid(id string) (err error) {
1331 1330
 	return
1332 1331
 }
1333 1332
 
1334
-//获取药品规格
1333
+// 获取药品规格
1335 1334
 func ReplacementDrugs(orgid int64, special bool) (list []*models.ReplacementDrugs, err error) {
1336 1335
 	var g errgroup.Group
1337 1336
 	var lib []*models.BaseDrugLib
@@ -1368,7 +1367,7 @@ func ReplacementDrugs(orgid int64, special bool) (list []*models.ReplacementDrug
1368 1367
 	return
1369 1368
 }
1370 1369
 
1371
-//获取药品规格,不考虑特殊病
1370
+// 获取药品规格,不考虑特殊病
1372 1371
 func ReplacementDrugsT(orgid int64) (list []*models.ReplacementDrugs, err error) {
1373 1372
 	var lib []*models.BaseDrugLib
1374 1373
 	err = readDb.Model(&models.BaseDrugLib{}).Where("org_id = ?  AND status = 1 and drug_status not like '%停用%' ", orgid).Find(&lib).Error
@@ -1390,14 +1389,14 @@ func ReplacementDrugsT(orgid int64) (list []*models.ReplacementDrugs, err error)
1390 1389
 	return
1391 1390
 }
1392 1391
 
1393
-//根据药品id获取药品名字
1392
+// 根据药品id获取药品名字
1394 1393
 func IdToDrugName(id int64) (name string) {
1395 1394
 	var lib models.BaseDrugLib
1396 1395
 	readDb.Model(&models.BaseDrugLib{}).Where("id = ?", id).Find(&lib)
1397 1396
 	return lib.DrugName
1398 1397
 }
1399 1398
 
1400
-//获取项目和耗材和套餐
1399
+// 获取项目和耗材和套餐
1401 1400
 func ProjectConsumables3(orgid int64) (list []*models.DropDownList, err error) {
1402 1401
 
1403 1402
 	var project []*models.XtHisProject
@@ -1439,7 +1438,7 @@ func ProjectConsumables3(orgid int64) (list []*models.DropDownList, err error) {
1439 1438
 	return
1440 1439
 }
1441 1440
 
1442
-//获取项目和耗材
1441
+// 获取项目和耗材
1443 1442
 func ProjectConsumables2(orgid int64, special bool) (list []*models.DropDownList, err error) {
1444 1443
 
1445 1444
 	var project []*models.XtHisProject
@@ -1477,7 +1476,7 @@ func ProjectConsumables2(orgid int64, special bool) (list []*models.DropDownList
1477 1476
 	return
1478 1477
 }
1479 1478
 
1480
-//获取项目和耗材不考虑特殊病
1479
+// 获取项目和耗材不考虑特殊病
1481 1480
 func ProjectConsumables2T(orgid int64) (list []*models.DropDownList, err error) {
1482 1481
 
1483 1482
 	var project []*models.XtHisProject
@@ -1507,7 +1506,7 @@ func ProjectConsumables2T(orgid int64) (list []*models.DropDownList, err error)
1507 1506
 	return
1508 1507
 }
1509 1508
 
1510
-//查询药品
1509
+// 查询药品
1511 1510
 func FindPatientDrug(orgid, patient_id, drugid, mode int64) bool {
1512 1511
 	var total int
1513 1512
 	XTReadDB().Model(&models.HisPrescriptionAdviceTemplate{}).Where("user_org_id = ? and patient_id = ? and drug_id = ? and status = 1 and "+
@@ -1519,7 +1518,7 @@ func FindPatientDrug(orgid, patient_id, drugid, mode int64) bool {
1519 1518
 	return false
1520 1519
 }
1521 1520
 
1522
-//查询项目
1521
+// 查询项目
1523 1522
 func FindPatientXiang(orgid, patient_id, drugid, mode int64) bool {
1524 1523
 	var total int
1525 1524
 	XTReadDB().Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? and patient_id = ? and project_id = ? and status = 1 and type = 2 and "+
@@ -1531,7 +1530,7 @@ func FindPatientXiang(orgid, patient_id, drugid, mode int64) bool {
1531 1530
 	return false
1532 1531
 }
1533 1532
 
1534
-//查询耗材
1533
+// 查询耗材
1535 1534
 func FindPatientXiang2(orgid, patient_id, drugid, mode int64) bool {
1536 1535
 	var total int
1537 1536
 	XTReadDB().Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? and patient_id = ? and project_id = ? and status = 1 and type = 3 and "+
@@ -1543,7 +1542,7 @@ func FindPatientXiang2(orgid, patient_id, drugid, mode int64) bool {
1543 1542
 	return false
1544 1543
 }
1545 1544
 
1546
-//types处方类型,1.药品 2.项目,model透析模式
1545
+// types处方类型,1.药品 2.项目,model透析模式
1547 1546
 func GetHisInfoTempalteId(model, orgid, types int64) (tp []int64) {
1548 1547
 	type tmpid struct {
1549 1548
 		Id int64
@@ -1557,7 +1556,7 @@ func GetHisInfoTempalteId(model, orgid, types int64) (tp []int64) {
1557 1556
 	return
1558 1557
 }
1559 1558
 
1560
-//替换药品处方模板
1559
+// 替换药品处方模板
1561 1560
 func ReplaceDrugPrescriptionTemplate(orgid, patient_id, drugid int64, ids []int64, s models.HisPrescriptionAdviceTemplate, tx *gorm.DB) (err error) {
1562 1561
 	err = tx.Model(&models.HisPrescriptionAdviceTemplate{}).Where("user_org_id = ? and patient_id = ? and drug_id = ? and "+
1563 1562
 		"status = 1 and prescription_id in (?)", orgid, patient_id, drugid, ids).Updates(map[string]interface{}{
@@ -1577,7 +1576,7 @@ func ReplaceDrugPrescriptionTemplate(orgid, patient_id, drugid int64, ids []int6
1577 1576
 	return err
1578 1577
 }
1579 1578
 
1580
-//替换项目模板
1579
+// 替换项目模板
1581 1580
 func ReplaceProjectPrescriptionTemplate(orgid, patient_id, drugid int64, ids []int64, s models.HisPrescriptionProjectTemplate, tx *gorm.DB) (err error) {
1582 1581
 	err = tx.Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? and patient_id = ? and project_id = ? and "+
1583 1582
 		"status = 1 and prescription_id in (?)", orgid, patient_id, drugid, ids).Updates(map[string]interface{}{
@@ -1599,7 +1598,7 @@ func ReplaceProjectPrescriptionTemplate(orgid, patient_id, drugid int64, ids []i
1599 1598
 	return err
1600 1599
 }
1601 1600
 
1602
-//删除项目模板
1601
+// 删除项目模板
1603 1602
 func DeleteProjectTemplate(orgid, patient_id, drugid int64, ids []int64, tx *gorm.DB) (err error) {
1604 1603
 	err = tx.Model(&models.HisPrescriptionProjectTemplate{}).Where("user_org_id = ? and patient_id = ? and project_id = ? and "+
1605 1604
 		"prescription_id in (?)", orgid, patient_id, drugid, ids).Updates(map[string]interface{}{
@@ -1609,7 +1608,7 @@ func DeleteProjectTemplate(orgid, patient_id, drugid int64, ids []int64, tx *gor
1609 1608
 	return err
1610 1609
 }
1611 1610
 
1612
-//删除处方模板
1611
+// 删除处方模板
1613 1612
 func DeletePrescriptionTemplate(orgid, patient_id, drugid int64, ids []int64, tx *gorm.DB) (err error) {
1614 1613
 	err = tx.Model(&models.HisPrescriptionAdviceTemplate{}).Where("user_org_id = ? and patient_id = ? and drug_id = ? and "+
1615 1614
 		"prescription_id in (?)", orgid, patient_id, drugid, ids).Updates(map[string]interface{}{
@@ -1619,7 +1618,7 @@ func DeletePrescriptionTemplate(orgid, patient_id, drugid int64, ids []int64, tx
1619 1618
 	return err
1620 1619
 }
1621 1620
 
1622
-//根据透析模式和患者id获取该患者的处方内容
1621
+// 根据透析模式和患者id获取该患者的处方内容
1623 1622
 func PTemplateInformation(orgid, mode_id, patient_id int64) (tmp interface{}, err error) {
1624 1623
 	//获取处方id
1625 1624
 	var tt []*models.HisPrescriptionTemplate
@@ -1695,7 +1694,7 @@ func DeleteOne(types, id int64) (err error) {
1695 1694
 
1696 1695
 }
1697 1696
 
1698
-//收尾工作
1697
+// 收尾工作
1699 1698
 func Scavenger(orgid int64) (err error) {
1700 1699
 	//开事务
1701 1700
 	tx := XTWriteDB().Begin()
@@ -1764,7 +1763,7 @@ func Scavenger(orgid int64) (err error) {
1764 1763
 	return
1765 1764
 }
1766 1765
 
1767
-//分区和收费(患者发药
1766
+// 分区和收费(患者发药
1768 1767
 func PartitionAndLayout(stime, etime, orgid, shift, partition int64, flist []*models.TmpPatient) (tmp []*models.TmpPatient, err error) {
1769 1768
 	//获取排班
1770 1769
 	var sch []*models.XtScheduleTwo
@@ -1794,7 +1793,7 @@ func PartitionAndLayout(stime, etime, orgid, shift, partition int64, flist []*mo
1794 1793
 	return
1795 1794
 }
1796 1795
 
1797
-//分区和收费(药品发药
1796
+// 分区和收费(药品发药
1798 1797
 func PartitionAndLayoutDrug(deliveryway string, stime, etime, orgid, shift, partition int64, flist []*models.PatientInformation) (tmp []*models.PatientInformation, err error) {
1799 1798
 	//获取排班
1800 1799
 	var sch []*models.XtScheduleTwo
@@ -1833,7 +1832,7 @@ func PartitionAndLayoutDrug(deliveryway string, stime, etime, orgid, shift, part
1833 1832
 	return
1834 1833
 }
1835 1834
 
1836
-//给药途径
1835
+// 给药途径
1837 1836
 func Administration(deliveryway string, orgid int64, flist []*models.ListOfDrugs) (tmp []*models.ListOfDrugs, err error) {
1838 1837
 	//查询药品
1839 1838
 	var pp []*models.PharmacyBaseDrug
@@ -1860,7 +1859,7 @@ func Administration(deliveryway string, orgid int64, flist []*models.ListOfDrugs
1860 1859
 	return
1861 1860
 }
1862 1861
 
1863
-//计算总量
1862
+// 计算总量
1864 1863
 func CalculateTheTotalAmount(tmp []*models.PatientInformation, drug_id int64) (total string, err error) {
1865 1864
 	//获取药品信息
1866 1865
 	var t models.SpBaseDrug