Browse Source

历史排班

28169 10 months ago
parent
commit
43531d6f1a

BIN
XT_New.exe View File


+ 6 - 6
controllers/base_api_controller.go View File

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

+ 22 - 4
controllers/dialysis_api_controller.go View File

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
-	"XT_New/models"
5
-	"XT_New/service"
6
-	"XT_New/utils"
7
 	"encoding/json"
4
 	"encoding/json"
8
 	"fmt"
5
 	"fmt"
9
-	"github.com/jinzhu/gorm"
10
 	"math"
6
 	"math"
11
 	"reflect"
7
 	"reflect"
12
 	"strconv"
8
 	"strconv"
13
 	"strings"
9
 	"strings"
14
 
10
 
11
+	"XT_New/models"
12
+	"XT_New/service"
13
+	"XT_New/utils"
14
+	"github.com/jinzhu/gorm"
15
+
15
 	//"strings"
16
 	//"strings"
16
 	"time"
17
 	"time"
17
 
18
 
143
 	beego.Router("/api/patient/getdialysisgatherlist", &DialysisApiController{}, "Get:GetDialysisGatherList")
144
 	beego.Router("/api/patient/getdialysisgatherlist", &DialysisApiController{}, "Get:GetDialysisGatherList")
144
 
145
 
145
 	beego.Router("/api/getpatientdialysisrecordlist", &DialysisApiController{}, "Get:GetPatientDialysisRecordList")
146
 	beego.Router("/api/getpatientdialysisrecordlist", &DialysisApiController{}, "Get:GetPatientDialysisRecordList")
147
+
148
+	beego.Router("/api/patient/getpatientrecordlist", &DialysisApiController{}, "Get:GetPatientRecordList")
146
 }
149
 }
147
 
150
 
148
 func (c *DialysisApiController) GetQueueCall() {
151
 func (c *DialysisApiController) GetQueueCall() {
2152
 	assessment.TransfusionVolume = data.TransfusionVolume
2155
 	assessment.TransfusionVolume = data.TransfusionVolume
2153
 	assessment.Condenser = data.Condenser
2156
 	assessment.Condenser = data.Condenser
2154
 	assessment.LastAfterWeight = data.LastAfterWeight
2157
 	assessment.LastAfterWeight = data.LastAfterWeight
2158
+	assessment.DisplaceLiquiValue = data.DisplaceLiquiValue
2155
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
2159
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
2156
 
2160
 
2157
 	if assessment.ID > 0 {
2161
 	if assessment.ID > 0 {
7677
 
7681
 
7678
 	return
7682
 	return
7679
 }
7683
 }
7684
+
7685
+func (this *DialysisApiController) GetPatientRecordList() {
7686
+
7687
+	patient_id, _ := this.GetInt64("patient_id")
7688
+	orgId := this.GetAdminUserInfo().CurrentOrgId
7689
+	beforList, _ := service.GetPatientBeforRecordList(patient_id, orgId)
7690
+	afterList, _ := service.GetPatientAfterRecordList(patient_id, orgId)
7691
+
7692
+	this.ServeSuccessJSON(map[string]interface{}{
7693
+		"beforList": beforList,
7694
+		"afterList": afterList,
7695
+	})
7696
+
7697
+}

+ 23 - 1
controllers/his_api_controller.go View File

17
 	"XT_New/utils"
17
 	"XT_New/utils"
18
 	"github.com/astaxie/beego"
18
 	"github.com/astaxie/beego"
19
 	"github.com/jinzhu/gorm"
19
 	"github.com/jinzhu/gorm"
20
+	"github.com/mozillazg/go-pinyin"
20
 	"github.com/shopspring/decimal"
21
 	"github.com/shopspring/decimal"
21
 )
22
 )
22
 
23
 
3101
 	var adviceList []models.HisDoctorAdviceInfo
3102
 	var adviceList []models.HisDoctorAdviceInfo
3102
 	var projectList []models.HisPrescriptionProject
3103
 	var projectList []models.HisPrescriptionProject
3103
 
3104
 
3104
-	if adminInfo.CurrentOrgId == 10489 {
3105
+	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 {
3105
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3106
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3106
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3107
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3107
 
3108
 
11529
 	errLogs, _ := service.FindPatientExportLog(c.GetAdminUserInfo().CurrentOrgId, export_time)
11530
 	errLogs, _ := service.FindPatientExportLog(c.GetAdminUserInfo().CurrentOrgId, export_time)
11530
 	if len(projectList) > 0 {
11531
 	if len(projectList) > 0 {
11531
 		for _, item := range projectList {
11532
 		for _, item := range projectList {
11533
+
11534
+			hans := item.ProjectName // 要转换的汉字字符串
11535
+			// 创建一个拼音转换器
11536
+			p := pinyin.NewArgs()
11537
+
11538
+			// 将汉字转为拼音
11539
+			pinyinSlice := pinyin.Pinyin(hans, p)
11540
+
11541
+			// 输出拼音
11542
+			fmt.Println("Pinyin:", pinyinSlice)
11543
+
11544
+			// 获取首字母
11545
+			firstLetter := ""
11546
+			for _, py := range pinyinSlice {
11547
+				if len(py) > 0 {
11548
+					firstLetter += string(py[0][0])
11549
+				}
11550
+			}
11551
+
11552
+			item.FirstLetter = firstLetter
11532
 			project := models.HisProject{
11553
 			project := models.HisProject{
11533
 				ProjectName:                 item.ProjectName,
11554
 				ProjectName:                 item.ProjectName,
11534
 				Price:                       item.Price,
11555
 				Price:                       item.Price,
11557
 				Remark:                      item.Remark,
11578
 				Remark:                      item.Remark,
11558
 				SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
11579
 				SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
11559
 				ExecutionFrequency:          item.ExecutionFrequency,
11580
 				ExecutionFrequency:          item.ExecutionFrequency,
11581
+				FirstLetter:                 item.FirstLetter,
11560
 			}
11582
 			}
11561
 
11583
 
11562
 			_, errcodeproject := service.GetProjectByNameIsExsit(item.ProjectName, orgId)
11584
 			_, errcodeproject := service.GetProjectByNameIsExsit(item.ProjectName, orgId)

+ 17 - 8
controllers/mobile_api_controllers/dialysis_api_controller.go View File

1399
 	accumulated_blood_volume := c.GetString("accumulated_blood_volume")
1399
 	accumulated_blood_volume := c.GetString("accumulated_blood_volume")
1400
 	transfusion_volume := c.GetString("transfusion_volume")
1400
 	transfusion_volume := c.GetString("transfusion_volume")
1401
 	last_after_weight := c.GetString("last_after_weight")
1401
 	last_after_weight := c.GetString("last_after_weight")
1402
+	displace_liqui_value := c.GetString("displace_liqui_value")
1402
 	if id <= 0 {
1403
 	if id <= 0 {
1403
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1404
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1404
 		return
1405
 		return
1508
 		AccumulatedBloodVolume:       accumulated_blood_volume,
1509
 		AccumulatedBloodVolume:       accumulated_blood_volume,
1509
 		TransfusionVolume:            transfusion_volume,
1510
 		TransfusionVolume:            transfusion_volume,
1510
 		LastAfterWeight:              last_after_weight,
1511
 		LastAfterWeight:              last_after_weight,
1512
+		DisplaceLiquiValue:           displace_liqui_value,
1511
 	}
1513
 	}
1512
 
1514
 
1513
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
1515
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
1642
 		assessmentAfterDislysis.ID = assessmentAfter.ID
1644
 		assessmentAfterDislysis.ID = assessmentAfter.ID
1643
 		recordDialysis, _ := service.GetSigleAssessmentAfterDislysisRecord(assessmentAfterDislysis.PatientId, assessmentAfter.AssessmentDate, assessmentAfter.UserOrgId)
1645
 		recordDialysis, _ := service.GetSigleAssessmentAfterDislysisRecord(assessmentAfterDislysis.PatientId, assessmentAfter.AssessmentDate, assessmentAfter.UserOrgId)
1644
 
1646
 
1645
-		if assessmentAfterDislysis.WeightAfter == 0 {
1646
-			assessmentAfterDislysis.WeightAfter = recordDialysis.WeightAfter
1647
+		if assessmentAfterDislysis.UserOrgId != 10340 {
1648
+			if assessmentAfterDislysis.WeightAfter == 0 {
1649
+				assessmentAfterDislysis.WeightAfter = recordDialysis.WeightAfter
1650
+			}
1647
 		}
1651
 		}
1648
 		err := service.UpdateAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1652
 		err := service.UpdateAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1649
 
1653
 
3381
 		tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
3385
 		tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
3382
 	}
3386
 	}
3383
 
3387
 
3384
-	if blood_drawing > 0 && adminUserInfo.Org.Id == 10629 {
3385
-		tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
3386
-	}
3388
+	//if blood_drawing > 0 && adminUserInfo.Org.Id == 10629 {
3389
+	//	tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
3390
+	//}
3387
 
3391
 
3388
 	var ultrafiltration_rate float64
3392
 	var ultrafiltration_rate float64
3389
 	_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
3393
 	_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
3466
 				ultrafiltration_rate = ultrafiltration_rate / 1000
3470
 				ultrafiltration_rate = ultrafiltration_rate / 1000
3467
 			}
3471
 			}
3468
 
3472
 
3473
+			if adminUserInfo.Org.Id == 10644 {
3474
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3475
+				ultrafiltration_rate = ultrafiltration_rate / 1000
3476
+			}
3477
+
3469
 		}
3478
 		}
3470
 	}
3479
 	}
3471
 
3480
 
4495
 
4504
 
4496
 			}
4505
 			}
4497
 
4506
 
4498
-			if adminInfo.Org.Id == 10460 {
4507
+			if adminInfo.Org.Id == 10460 || adminInfo.Org.Id == 10644 {
4499
 
4508
 
4500
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
4509
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
4501
 				record.UltrafiltrationRate = ultrafiltration_rate / 1000
4510
 				record.UltrafiltrationRate = ultrafiltration_rate / 1000
4559
 		record.UltrafiltrationVolume = ultrafiltration_volume / 1000
4568
 		record.UltrafiltrationVolume = ultrafiltration_volume / 1000
4560
 	}
4569
 	}
4561
 
4570
 
4562
-	if adminInfo.Org.Id == 10460 {
4571
+	if adminInfo.Org.Id == 10460 || adminInfo.Org.Id == 10644 {
4563
 
4572
 
4564
 		ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
4573
 		ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
4565
 
4574
 
9670
 			}
9679
 			}
9671
 
9680
 
9672
 			creater := this.GetMobileAdminUserInfo().AdminUser.Id
9681
 			creater := this.GetMobileAdminUserInfo().AdminUser.Id
9673
-			fmt.Println("creater2332243244224242424", creater)
9682
+
9674
 			//执行医嘱
9683
 			//执行医嘱
9675
 			errs := service.ExectionBloodMobileAdvice(orgId, idSplit, theTime.Unix(), creater)
9684
 			errs := service.ExectionBloodMobileAdvice(orgId, idSplit, theTime.Unix(), creater)
9676
 			advices, _ := service.FindAllDoctorAdviceByIds(orgId, idSplit)
9685
 			advices, _ := service.FindAllDoctorAdviceByIds(orgId, idSplit)

+ 26 - 16
controllers/mobile_api_controllers/patient_api_controller.go View File

1665
 					}
1665
 					}
1666
 				}
1666
 				}
1667
 
1667
 
1668
+				//fmt.Println("config+++++++++++", config.IsOpen)
1669
+				//fmt.Println("config+++++++++++", item.UserOrgId)
1668
 				//
1670
 				//
1669
-				if config.IsOpen == 1 && item.UserOrgId == 10188 {
1670
-
1671
-					service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1672
-					//更新字典里面的库存
1673
-					stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1674
-					var sum_count int64
1675
-					for _, its := range stockInfo {
1676
-						if its.MaxUnit == medical.MaxUnit {
1677
-							its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
1678
-						}
1679
-						sum_count += its.StockMaxNumber + its.StockMinNumber
1680
-					}
1681
-					service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1682
-					//剩余库存
1683
-					service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
1684
-				}
1671
+				//if config.IsOpen == 1 && item.UserOrgId == 10210 {
1672
+				//
1673
+				//	service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1674
+				//	//更新字典里面的库存
1675
+				//	stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1676
+				//	var sum_count int64
1677
+				//	for _, its := range stockInfo {
1678
+				//		if its.MaxUnit == medical.MaxUnit {
1679
+				//			its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
1680
+				//		}
1681
+				//		sum_count += its.StockMaxNumber + its.StockMinNumber
1682
+				//	}
1683
+				//	service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1684
+				//	//剩余库存
1685
+				//	service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
1686
+				//}
1685
 
1687
 
1686
 			}
1688
 			}
1687
 		}
1689
 		}
3278
 
3280
 
3279
 		}
3281
 		}
3280
 	}
3282
 	}
3283
+	//针对长沙南雅的问题
3284
+	if adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10164 {
3285
+		if len(evaluation.SymptomBeforeDialysis) == 0 {
3286
+			predialysisEvaluation, _ := service.GetPredialysisEvaluation(id, adminUserInfo.Org.Id)
3287
+			evaluation.SymptomBeforeDialysis = predialysisEvaluation.SymptomBeforeDialysis
3288
+		}
3289
+
3290
+	}
3281
 
3291
 
3282
 	err = service.UpadatePredialysisEvaluation(&evaluation)
3292
 	err = service.UpadatePredialysisEvaluation(&evaluation)
3283
 
3293
 

+ 18 - 1
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go View File

429
 	}
429
 	}
430
 
430
 
431
 	//查询排班里面的空透析器
431
 	//查询排班里面的空透析器
432
-	if orgid == 10375 {
432
+	if orgid == 10375 || orgid == 10510 || orgid == 9538 {
433
 
433
 
434
 		schedulesFive, _ := service.GetMobileScheduleListByScheduleDateOne(orgid, startTime)
434
 		schedulesFive, _ := service.GetMobileScheduleListByScheduleDateOne(orgid, startTime)
435
 
435
 
451
 				service.UpdateSchOne(item.ID, item.DialysisMachineName)
451
 				service.UpdateSchOne(item.ID, item.DialysisMachineName)
452
 			}
452
 			}
453
 
453
 
454
+			if item.ScheduleDate < timeNewDate.Unix() {
455
+				prescriptionList, _ := service.GetDialysisPrescriptionList(item.PatientId, item.UserOrgId, item.ScheduleDate)
456
+				var DialysisMachineName string
457
+				if len(prescriptionList.DialysisDialyszers) > 0 {
458
+					DialysisMachineName = prescriptionList.DialysisDialyszers
459
+				}
460
+				if len(prescriptionList.DialyzerPerfusionApparatus) > 0 {
461
+					DialysisMachineName = DialysisMachineName + "," + prescriptionList.DialyzerPerfusionApparatus
462
+				}
463
+
464
+				if len(prescriptionList.DialysisIrrigation) > 0 {
465
+					DialysisMachineName = DialysisMachineName + "," + prescriptionList.DialysisIrrigation
466
+				}
467
+				item.DialysisMachineName = DialysisMachineName
468
+				service.UpdateSchOne(item.ID, item.DialysisMachineName)
469
+			}
470
+
454
 		}
471
 		}
455
 
472
 
456
 	}
473
 	}

+ 30 - 3
controllers/patient_api_controller.go View File

372
 	// 将汉字转为拼音
372
 	// 将汉字转为拼音
373
 	pinyinSlice := pinyin.Pinyin(hans, p)
373
 	pinyinSlice := pinyin.Pinyin(hans, p)
374
 
374
 
375
-	// 输出拼音
376
-	fmt.Println("Pinyin:", pinyinSlice)
377
-
378
 	// 获取首字母
375
 	// 获取首字母
379
 	firstLetter := ""
376
 	firstLetter := ""
380
 	for _, py := range pinyinSlice {
377
 	for _, py := range pinyinSlice {
495
 		InfectiousRemark:             patient.InfectiousRemark,
492
 		InfectiousRemark:             patient.InfectiousRemark,
496
 		AllergicHistory:              patient.AllergicHistory,
493
 		AllergicHistory:              patient.AllergicHistory,
497
 		PatientAddress:               patient.PatientAddress,
494
 		PatientAddress:               patient.PatientAddress,
495
+		PrintDate:                    patient.PrintDate,
498
 	}
496
 	}
499
 	patientsNew.FirstLetter = firstLetter
497
 	patientsNew.FirstLetter = firstLetter
500
 
498
 
735
 		InfectiousRemark:          patient.InfectiousRemark,
733
 		InfectiousRemark:          patient.InfectiousRemark,
736
 		AllergicHistory:           patient.AllergicHistory,
734
 		AllergicHistory:           patient.AllergicHistory,
737
 		PatientAddress:            patient.PatientAddress,
735
 		PatientAddress:            patient.PatientAddress,
736
+		PrintDate:                 patient.PrintDate,
738
 	}
737
 	}
739
 	//	//更新病人ID获取新表病人ID
738
 	//	//更新病人ID获取新表病人ID
740
 	err = service.UpdatepatientTwo(&patientsNew, id)
739
 	err = service.UpdatepatientTwo(&patientsNew, id)
5366
 		patient.PatientAddress = patient_address
5365
 		patient.PatientAddress = patient_address
5367
 	}
5366
 	}
5368
 
5367
 
5368
+	if patientBody["print_date"] != nil && reflect.TypeOf(patientBody["print_date"]).String() == "string" {
5369
+		print_date := patientBody["print_date"].(string)
5370
+		printDateTime, err := time.ParseInLocation(timeLayout, print_date, loc)
5371
+		if err == nil {
5372
+			patient.PrintDate = printDateTime.Unix()
5373
+		}
5374
+	}
5375
+
5369
 	return
5376
 	return
5370
 
5377
 
5371
 }
5378
 }
5891
 
5898
 
5892
 	if len(patients) > 0 {
5899
 	if len(patients) > 0 {
5893
 		for _, item := range patients {
5900
 		for _, item := range patients {
5901
+
5902
+			hans := item.Name // 要转换的汉字字符串
5903
+			// 创建一个拼音转换器
5904
+			p := pinyin.NewArgs()
5905
+
5906
+			// 将汉字转为拼音
5907
+			pinyinSlice := pinyin.Pinyin(hans, p)
5908
+
5909
+			// 输出拼音
5910
+			fmt.Println("Pinyin:", pinyinSlice)
5911
+
5912
+			// 获取首字母
5913
+			firstLetter := ""
5914
+			for _, py := range pinyinSlice {
5915
+				if len(py) > 0 {
5916
+					firstLetter += string(py[0][0])
5917
+				}
5918
+			}
5919
+
5920
+			item.FirstLetter = firstLetter
5894
 			service.CreateExportPatient(item, item.ContagionIds, org.Creator)
5921
 			service.CreateExportPatient(item, item.ContagionIds, org.Creator)
5895
 		}
5922
 		}
5896
 
5923
 

+ 41 - 42
controllers/pharmacy_controller.go View File

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
+	"fmt"
5
+	"math"
6
+	"strconv"
7
+	"time"
8
+
4
 	"XT_New/enums"
9
 	"XT_New/enums"
5
 	"XT_New/models"
10
 	"XT_New/models"
6
 	"XT_New/service"
11
 	"XT_New/service"
7
 	"XT_New/utils"
12
 	"XT_New/utils"
8
-	"fmt"
9
 	"github.com/astaxie/beego"
13
 	"github.com/astaxie/beego"
10
-	"math"
11
-	"strconv"
12
-	"time"
13
 )
14
 )
14
 
15
 
15
 type PharmacyController struct {
16
 type PharmacyController struct {
146
 		}
147
 		}
147
 	}()
148
 	}()
148
 	keyword := this.GetString("keyword", "")
149
 	keyword := this.GetString("keyword", "")
150
+	fmt.Println(keyword)
149
 	times := this.GetString("time", "")
151
 	times := this.GetString("time", "")
150
 	orgid := this.GetAdminUserInfo().CurrentOrgId
152
 	orgid := this.GetAdminUserInfo().CurrentOrgId
151
 	shift, err := this.GetInt64("shift", 0) //班次
153
 	shift, err := this.GetInt64("shift", 0) //班次
169
 		etime = stime + 86399
171
 		etime = stime + 86399
170
 	}
172
 	}
171
 
173
 
172
-	if orgid == 10164 || orgid == 3877 || orgid == 10188 || orgid == 10217 || orgid == 9671 || orgid == 10387 || orgid == 10375 || orgid == 10480 || orgid == 10344 {
173
-
174
-		//获取排班班次
175
-		schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
174
+	//获取排班班次
175
+	schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
176
 
176
 
177
-		var ids []int64
178
-		for _, item := range schedule {
179
-			ids = append(ids, item.PatientId)
180
-		}
177
+	var ids []int64
178
+	for _, item := range schedule {
179
+		ids = append(ids, item.PatientId)
180
+	}
181
 
181
 
182
-		list, _ := service.GetTodayAdviceCountOne(stime, etime, orgid, 1, ids)
182
+	list, _ := service.GetTodayAdviceCountOne(stime, etime, orgid, 1, ids)
183
 
183
 
184
-		var flist []models.TmpPatientOne
185
-		if len(list) > 0 {
186
-			for _, item := range list {
187
-				patientlist, _ := service.GetPatientByAdviceId(item.PatientId)
188
-				flist = append(flist, patientlist)
189
-			}
184
+	var flist []models.TmpPatientOne
185
+	if len(list) > 0 {
186
+		for _, item := range list {
187
+			patientlist, _ := service.GetPatientByAdviceId(item.PatientId)
188
+			flist = append(flist, patientlist)
190
 		}
189
 		}
191
-		this.ServeSuccessJSON(map[string]interface{}{
192
-			"list": flist,
193
-		})
194
 	}
190
 	}
191
+	this.ServeSuccessJSON(map[string]interface{}{
192
+		"list": flist,
193
+	})
195
 
194
 
196
-	if orgid != 10164 && orgid == 3877 && orgid != 10188 && orgid != 10217 && orgid != 9671 && orgid != 10387 && orgid != 10375 && orgid != 10480 && orgid == 10344 {
197
-		//查询表里当天的数据
198
-		var flist []*models.TmpPatient
199
-		flist, err = service.GetTodayDrug(stime, etime, orgid, 1, keyword)
200
-		if err != nil {
201
-			utils.ErrorLog(err.Error())
202
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
203
-			return
204
-		}
205
-		listt, err := service.PartitionAndLayout(stime, etime, orgid, shift, partition, flist)
206
-		if err != nil {
207
-			utils.ErrorLog(err.Error())
208
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
209
-			return
210
-		}
211
-		this.ServeSuccessJSON(map[string]interface{}{
212
-			"list": listt,
213
-		})
214
-		return
215
-	}
195
+	//if orgid != 10164 && orgid == 3877 && orgid != 10188 && orgid != 10217 && orgid != 9671 && orgid != 10387 && orgid != 10375 && orgid != 10480 && orgid == 10344 {
196
+	//	//查询表里当天的数据
197
+	//	var flist []*models.TmpPatient
198
+	//	flist, err = service.GetTodayDrug(stime, etime, orgid, 1, keyword)
199
+	//	if err != nil {
200
+	//		utils.ErrorLog(err.Error())
201
+	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
202
+	//		return
203
+	//	}
204
+	//	listt, err := service.PartitionAndLayout(stime, etime, orgid, shift, partition, flist)
205
+	//	if err != nil {
206
+	//		utils.ErrorLog(err.Error())
207
+	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
208
+	//		return
209
+	//	}
210
+	//	this.ServeSuccessJSON(map[string]interface{}{
211
+	//		"list": listt,
212
+	//	})
213
+	//	return
214
+	//}
216
 
215
 
217
 }
216
 }
218
 func (this *PharmacyController) WaitingDrug() {
217
 func (this *PharmacyController) WaitingDrug() {

+ 74 - 31
controllers/schedule_api_controller.go View File

3986
 	loc, _ := time.LoadLocation("Local")
3986
 	loc, _ := time.LoadLocation("Local")
3987
 	//theTimeStart, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
3987
 	//theTimeStart, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
3988
 	//theTimeEnd, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
3988
 	//theTimeEnd, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
3989
-
3989
+	ids := this.GetString("ids")
3990
+	var idStr []string
3991
+	if len(ids) > 0 {
3992
+		idStr = strings.Split(ids, ",")
3993
+	}
3990
 	adminUserInfo := this.GetAdminUserInfo()
3994
 	adminUserInfo := this.GetAdminUserInfo()
3991
 	var theStartTIme int64
3995
 	var theStartTIme int64
3992
 	if len(record_date) > 0 {
3996
 	if len(record_date) > 0 {
3997
 		theStartTIme = theTime.Unix()
4001
 		theStartTIme = theTime.Unix()
3998
 	}
4002
 	}
3999
 
4003
 
4000
-	schedule, err := service.GetNextWeekDayScheduleSix(week_type, week_time, start_time, end_time, adminUserInfo.CurrentOrgId, zone, theStartTIme)
4001
-	fmt.Println("schedule------------------------------------------------", len(schedule))
4004
+	schedule, err := service.GetNextWeekDayScheduleSix(week_type, week_time, start_time, end_time, adminUserInfo.CurrentOrgId, zone, theStartTIme, idStr)
4005
+
4002
 	for _, item := range schedule {
4006
 	for _, item := range schedule {
4003
 		order, _ := service.GetLastDialysisOrder(adminUserInfo.CurrentOrgId, item.PatientId, theStartTIme)
4007
 		order, _ := service.GetLastDialysisOrder(adminUserInfo.CurrentOrgId, item.PatientId, theStartTIme)
4004
 		item.XtDialysisOrderSix = order
4008
 		item.XtDialysisOrderSix = order
4005
 		solutionLastWeek, _ := service.GetDialysisSolutionLastWeek(adminUserInfo.CurrentOrgId, item.PatientId, item.ModeId)
4009
 		solutionLastWeek, _ := service.GetDialysisSolutionLastWeek(adminUserInfo.CurrentOrgId, item.PatientId, item.ModeId)
4006
 		item.DialysisSolution = solutionLastWeek
4010
 		item.DialysisSolution = solutionLastWeek
4007
-		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10340 {
4008
-
4009
-			dialysisprescription, _ := service.GetLastDialysisSolution(adminUserInfo.CurrentOrgId, item.PatientId, item.ModeId, item.ScheduleDate)
4010
-			item.DialysisPrescription = dialysisprescription
4011
-
4012
-		}
4011
+		prescription, _ := service.GetLastDialysisPrescriptionTwo(adminUserInfo.CurrentOrgId, item.PatientId, item.ModeId, item.ScheduleDate)
4012
+		item.DialysisPrescription = prescription
4013
 
4013
 
4014
 	}
4014
 	}
4015
 	if err != nil {
4015
 	if err != nil {
4036
 	loc, _ := time.LoadLocation("Local")
4036
 	loc, _ := time.LoadLocation("Local")
4037
 	theTimeStart, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4037
 	theTimeStart, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4038
 	theTimeEnd, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
4038
 	theTimeEnd, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
4039
-
4039
+	ids := this.GetString("ids")
4040
+	var idStr []string
4041
+	if len(ids) > 0 {
4042
+		idStr = strings.Split(ids, ",")
4043
+	}
4040
 	adminUserInfo := this.GetAdminUserInfo()
4044
 	adminUserInfo := this.GetAdminUserInfo()
4041
 	var theStartTIme int64
4045
 	var theStartTIme int64
4042
 	if len(record_date) > 0 {
4046
 	if len(record_date) > 0 {
4047
 		theStartTIme = theTime.Unix()
4051
 		theStartTIme = theTime.Unix()
4048
 	}
4052
 	}
4049
 
4053
 
4050
-	schedule, err := service.GetNextWeekDaySchedule(week_type, week_time, theTimeStart.Unix(), theTimeEnd.Unix(), adminUserInfo.CurrentOrgId, zone, theStartTIme)
4054
+	schedule, err := service.GetNextWeekDaySchedule(week_type, week_time, theTimeStart.Unix(), theTimeEnd.Unix(), adminUserInfo.CurrentOrgId, zone, theStartTIme, idStr)
4051
 
4055
 
4052
 	for _, item := range schedule {
4056
 	for _, item := range schedule {
4053
 		AssessmentBefor, _ := service.GetAssessmentBeforListLastWeek(item.ScheduleDate, item.PatientId, item.UserOrgId)
4057
 		AssessmentBefor, _ := service.GetAssessmentBeforListLastWeek(item.ScheduleDate, item.PatientId, item.UserOrgId)
4425
 	week_time, _ := this.GetInt64("week_time")
4429
 	week_time, _ := this.GetInt64("week_time")
4426
 	zones := this.GetString("zone")
4430
 	zones := this.GetString("zone")
4427
 	zone := strings.Split(zones, ",")
4431
 	zone := strings.Split(zones, ",")
4432
+	limit, _ := this.GetInt64("limit")
4433
+	page, _ := this.GetInt64("page")
4434
+	ids := this.GetString("ids")
4435
+	var idStr []string
4436
+	if len(ids) > 0 {
4437
+		idStr = strings.Split(ids, ",")
4438
+	}
4428
 	thisTime := time.Now()
4439
 	thisTime := time.Now()
4429
 	weekDay := int(thisTime.Weekday())
4440
 	weekDay := int(thisTime.Weekday())
4430
 	if weekDay == 0 {
4441
 	if weekDay == 0 {
4442
 		weekTitle = append(weekTitle, indexWeek)
4453
 		weekTitle = append(weekTitle, indexWeek)
4443
 		days = append(days, theDay.Format("2006-01-02"))
4454
 		days = append(days, theDay.Format("2006-01-02"))
4444
 	}
4455
 	}
4445
-	fmt.Println(days)
4446
 
4456
 
4447
 	var targetDayStr string
4457
 	var targetDayStr string
4448
 	var startTime string
4458
 	var startTime string
4488
 
4498
 
4489
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4499
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4490
 
4500
 
4491
-	fmt.Println("week_type-------------------------", week_type)
4492
 	if week_type > 0 {
4501
 	if week_type > 0 {
4493
-		list, err := service.GetWeekDayScheduleByIdThee(orgId, targetDay.Unix(), week_time, zone)
4502
+
4503
+		list, total, err := service.GetWeekDayScheduleByIdThee(orgId, targetDay.Unix(), week_time, zone, limit, page, idStr)
4504
+
4494
 		for _, item := range list {
4505
 		for _, item := range list {
4495
 			order, _ := service.GetLastDialysisOrder(orgId, item.PatientId, targetDay.Unix())
4506
 			order, _ := service.GetLastDialysisOrder(orgId, item.PatientId, targetDay.Unix())
4496
-			adviceList, _ := service.GetHisDoctorAdviceList(orgId, item.PatientId, targetDay.Unix())
4497
-			item.HisDoctorAdviceInfo = adviceList
4498
 			item.XtDialysisOrderSix = order
4507
 			item.XtDialysisOrderSix = order
4499
-			if orgId == 10340 {
4500
-
4501
-				solution, _ := service.GetLastDialysisSolution(orgId, item.PatientId, item.ModeId, item.ScheduleDate)
4502
-				item.DialysisPrescription = solution
4503
-			}
4508
+			advicehisList, _ := service.GetHisDoctorAdviceList(orgId, item.PatientId, targetDay.Unix())
4509
+			item.HisDoctorAdviceInfo = advicehisList
4510
+			advices, _ := service.GetDoctorAdviceListSchedule(orgId, item.PatientId)
4511
+			item.DoctorAdvice = advices
4512
+			prescription, _ := service.GetLastDialysisPrescriptionTwo(orgId, item.PatientId, item.ModeId, item.ScheduleDate)
4513
+			item.DialysisPrescription = prescription
4514
+			dialysisSolution, _ := service.GetLastDialysisSolution(orgId, item.PatientId, item.ModeId)
4515
+			item.DialysisSolution = dialysisSolution
4516
+			lastDialysisAfter, _ := service.GetLastDialysisAfter(orgId, item.PatientId, item.ScheduleDate)
4517
+			item.LastAfterWeight = lastDialysisAfter
4518
+			assessmentBeforFourty, _ := service.GetAssessmentBeforFourty(orgId, item.PatientId, item.ScheduleDate)
4519
+			item.XtAssessmentBeforeDislysis = assessmentBeforFourty
4504
 
4520
 
4505
 		}
4521
 		}
4506
 		if err != nil {
4522
 		if err != nil {
4509
 		}
4525
 		}
4510
 
4526
 
4511
 		this.ServeSuccessJSON(map[string]interface{}{
4527
 		this.ServeSuccessJSON(map[string]interface{}{
4512
-			"list": list,
4513
-			"day":  targetDayStr,
4528
+			"list":  list,
4529
+			"day":   targetDayStr,
4530
+			"total": total,
4514
 		})
4531
 		})
4515
 	}
4532
 	}
4516
 
4533
 
4517
 	if week_type == 0 {
4534
 	if week_type == 0 {
4518
 		startDate, _ := utils.ParseTimeStringToTime("2006-01-02", startTime)
4535
 		startDate, _ := utils.ParseTimeStringToTime("2006-01-02", startTime)
4519
-		list, err := service.GetWeekDayScheduleByIdTwo(orgId, targetDay.Unix(), week_time, startDate.Unix(), zone)
4536
+		list, total, err := service.GetWeekDayScheduleByIdTwo(orgId, targetDay.Unix(), week_time, startDate.Unix(), zone, limit, page, idStr)
4520
 		for _, item := range list {
4537
 		for _, item := range list {
4521
 
4538
 
4522
 			order, _ := service.GetLastDialysisOrder(orgId, item.PatientId, targetDay.Unix())
4539
 			order, _ := service.GetLastDialysisOrder(orgId, item.PatientId, targetDay.Unix())
4523
 			item.XtDialysisOrderSix = order
4540
 			item.XtDialysisOrderSix = order
4524
-			if orgId == 9671 || orgId == 9675 || orgId == 10340 {
4541
+			advicehisList, _ := service.GetHisDoctorAdviceList(orgId, item.PatientId, targetDay.Unix())
4542
+			item.HisDoctorAdviceInfo = advicehisList
4543
+			advices, _ := service.GetDoctorAdviceListSchedule(orgId, item.PatientId)
4544
+			item.DoctorAdvice = advices
4545
+			prescription, _ := service.GetLastDialysisPrescriptionTwo(orgId, item.PatientId, item.ModeId, item.ScheduleDate)
4546
+			item.DialysisPrescription = prescription
4547
+			dialysisSolution, _ := service.GetLastDialysisSolution(orgId, item.PatientId, item.ModeId)
4548
+			item.DialysisSolution = dialysisSolution
4525
 
4549
 
4526
-				solution, _ := service.GetLastDialysisSolution(orgId, item.PatientId, item.ModeId, item.ScheduleDate)
4527
-				item.DialysisPrescription = solution
4528
-			}
4550
+			lastDialysisAfter, _ := service.GetLastDialysisAfter(orgId, item.PatientId, item.ScheduleDate)
4551
+			item.LastAfterWeight = lastDialysisAfter
4552
+
4553
+			assessmentBeforFourty, _ := service.GetAssessmentBeforFourty(orgId, item.PatientId, item.ScheduleDate)
4554
+			item.XtAssessmentBeforeDislysis = assessmentBeforFourty
4529
 
4555
 
4530
 		}
4556
 		}
4531
 		if err != nil {
4557
 		if err != nil {
4534
 		}
4560
 		}
4535
 
4561
 
4536
 		this.ServeSuccessJSON(map[string]interface{}{
4562
 		this.ServeSuccessJSON(map[string]interface{}{
4537
-			"list": list,
4538
-			"day":  targetDayStr,
4563
+			"list":  list,
4564
+			"day":   targetDayStr,
4565
+			"total": total,
4539
 		})
4566
 		})
4540
 	}
4567
 	}
4541
 
4568
 
4759
 	}
4786
 	}
4760
 
4787
 
4761
 	//查询排班里面的空透析器
4788
 	//查询排班里面的空透析器
4762
-	if adminInfo.CurrentOrgId == 10375 {
4789
+	if adminInfo.CurrentOrgId == 10375 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 9538 {
4763
 
4790
 
4764
 		schedulesFive, _ := service.GetWeekScheduleFive(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type)
4791
 		schedulesFive, _ := service.GetWeekScheduleFive(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type)
4765
 
4792
 
4780
 				item.DialysisMachineName = DialysisMachineName
4807
 				item.DialysisMachineName = DialysisMachineName
4781
 				service.UpdateSchOne(item.ID, item.DialysisMachineName)
4808
 				service.UpdateSchOne(item.ID, item.DialysisMachineName)
4782
 			}
4809
 			}
4810
+			if item.ScheduleDate < timeNewDate.Unix() {
4811
+				prescriptionList, _ := service.GetDialysisPrescriptionList(item.PatientId, item.UserOrgId, item.ScheduleDate)
4812
+				var DialysisMachineName string
4813
+				if len(prescriptionList.DialysisDialyszers) > 0 {
4814
+					DialysisMachineName = prescriptionList.DialysisDialyszers
4815
+				}
4816
+				if len(prescriptionList.DialyzerPerfusionApparatus) > 0 {
4817
+					DialysisMachineName = DialysisMachineName + "," + prescriptionList.DialyzerPerfusionApparatus
4818
+				}
4819
+
4820
+				if len(prescriptionList.DialysisIrrigation) > 0 {
4821
+					DialysisMachineName = DialysisMachineName + "," + prescriptionList.DialysisIrrigation
4822
+				}
4823
+				item.DialysisMachineName = DialysisMachineName
4824
+				service.UpdateSchOne(item.ID, item.DialysisMachineName)
4825
+			}
4783
 
4826
 
4784
 		}
4827
 		}
4785
 
4828
 

+ 106 - 72
controllers/self_drug_api_congtroller.go View File

123
 	beego.Router("/api/stock/getpurchaseDrugQueryList", &SelfDrugApiController{}, "Get:GetPurchaseDrugQueryList")
123
 	beego.Router("/api/stock/getpurchaseDrugQueryList", &SelfDrugApiController{}, "Get:GetPurchaseDrugQueryList")
124
 
124
 
125
 	beego.Router("/api/stock/getpurchasestockquerylist", &SelfDrugApiController{}, "Get:GetPurchaseStockQueryList")
125
 	beego.Router("/api/stock/getpurchasestockquerylist", &SelfDrugApiController{}, "Get:GetPurchaseStockQueryList")
126
+
127
+	beego.Router("/api/drug/getcheckdrugbatchlist", &SelfDrugApiController{}, "Get:GetCheckDrugBatchList")
128
+
129
+	beego.Router("/api/good/getcheckgoodbatchlist", &SelfDrugApiController{}, "Get:GetCheckGoodBatchList")
130
+
131
+	beego.Router("/api/drug/getdrugpatientname", &SelfDrugApiController{}, "Get:GetDrugPatientName")
126
 }
132
 }
127
 
133
 
128
 func (this *SelfDrugApiController) GetCurrentPatient() {
134
 func (this *SelfDrugApiController) GetCurrentPatient() {
2761
 	limit, _ := this.GetInt64("limit")
2767
 	limit, _ := this.GetInt64("limit")
2762
 
2768
 
2763
 	// 查询该机构所有耗材入库信息
2769
 	// 查询该机构所有耗材入库信息
2764
-	goodList, _ := service.GetAllGoodListSeven(orgId)
2765
-
2766
-	for _, it := range goodList {
2767
-		var sum_total int64
2768
-		//查询该耗材入库信息
2769
-		warehouseinfo, _ := service.GetGoodInformationWarehouseInfo(it.ID, orgId)
2770
-		for _, item := range warehouseinfo {
2771
-			sum_total += item.StockCount
2772
-		}
2773
-		service.UpdateGoodInformation(it.ID, orgId, sum_total)
2774
-
2775
-		//stockListTwo, _ := service.GetGoodStockCountList(orgId, it.ID)
2776
-		//if len(stockListTwo) > 0 {
2777
-		//	for _, item := range stockListTwo {
2778
-		//		var over_count int64
2779
-		//		over_count = item.StockInCount - item.FlushCount
2780
-		//		service.UpdateGoodListCount(item.UserOrgId, over_count, item.GoodId, item.StorehouseId)
2781
-		//
2782
-		//	}
2783
-		//}
2784
-		//
2785
-		//stockListOne, _ := service.GetGoodStockCountList(orgId, it.ID)
2786
-		//if len(stockListOne) > 0 {
2787
-		//	for _, item := range stockListOne {
2788
-		//		var over_count int64
2789
-		//		over_count = item.StockOutCount + item.StockCancelCount
2790
-		//		service.UpdateGoodListCountOne(item.UserOrgId, over_count, item.GoodId, item.StorehouseId)
2791
-		//	}
2792
-		//}
2793
-
2794
-	}
2770
+	//goodList, _ := service.GetAllGoodListSeven(orgId)
2771
+	//
2772
+	//for _, it := range goodList {
2773
+	//	var sum_total int64
2774
+	//	//查询该耗材入库信息
2775
+	//	warehouseinfo, _ := service.GetGoodInformationWarehouseInfo(it.ID, orgId)
2776
+	//	for _, item := range warehouseinfo {
2777
+	//		sum_total += item.StockCount
2778
+	//	}
2779
+	//	service.UpdateGoodInformation(it.ID, orgId, sum_total)
2780
+	//}
2795
 
2781
 
2796
 	var ids []int64
2782
 	var ids []int64
2797
 
2783
 
2798
-	manufacturerList, _ := service.GetManufacturerListByKeyword(orgId, keyword)
2799
-	for _, it := range manufacturerList {
2800
-		ids = append(ids, it.ID)
2784
+	if len(keyword) > 0 {
2785
+		manufacturerList, _ := service.GetManufacturerListByKeyword(orgId, keyword)
2786
+		for _, it := range manufacturerList {
2787
+			ids = append(ids, it.ID)
2788
+		}
2801
 	}
2789
 	}
2802
 
2790
 
2803
 	stockList, total, err := service.GetGoodStockList(orgId, storehouse_id, good_type, keyword, page, limit, ids)
2791
 	stockList, total, err := service.GetGoodStockList(orgId, storehouse_id, good_type, keyword, page, limit, ids)
3432
 	}
3420
 	}
3433
 	var ids []int64
3421
 	var ids []int64
3434
 	var goodIds []int64
3422
 	var goodIds []int64
3435
-	manufacturerList, _ := service.GetManufacturerListByKeyword(orgId, keyword)
3436
 
3423
 
3424
+	if len(keyword) > 0 {
3425
+		manufacturerList, _ := service.GetManufacturerListByKeyword(orgId, keyword)
3426
+		for _, it := range manufacturerList {
3427
+			ids = append(ids, it.ID)
3428
+		}
3429
+	}
3437
 	//查询药品库信息
3430
 	//查询药品库信息
3438
-	drug, _ := service.GetBaseDrugName(orgId)
3439
-
3440
-	for _, it := range drug {
3441
-		var sum_count int64
3442
-		var limit_count int64
3443
-		drugInfo, _ := service.GetDrugWarehouseInfoName(it.ID, orgId)
3444
-		for _, item := range drugInfo {
3431
+	//drug, _ := service.GetBaseDrugName(orgId)
3432
+	//
3433
+	//for _, it := range drug {
3434
+	//	var sum_count int64
3435
+	//	var limit_count int64
3436
+	//	drugInfo, _ := service.GetDrugWarehouseInfoName(it.ID, orgId)
3437
+	//	for _, item := range drugInfo {
3438
+	//
3439
+	//		sum_count += item.StockMaxNumber*it.MinNumber + item.StockMinNumber
3440
+	//	}
3441
+	//	stockInt, _ := strconv.ParseInt(it.DrugStockLimit, 10, 64)
3442
+	//	limit_count = stockInt * it.MinNumber
3443
+	//	service.UpdateDrugById(it.ID, orgId, limit_count, sum_count)
3444
+	//}
3445
 
3445
 
3446
-			sum_count += item.StockMaxNumber*it.MinNumber + item.StockMinNumber
3446
+	if storehouse_id > 0 {
3447
+		infoList, _ := service.GetDrugWarehouseInfoByOrgId(orgId, storehouse_id)
3448
+		for _, it := range infoList {
3449
+			goodIds = append(goodIds, it.DrugId)
3447
 		}
3450
 		}
3448
-		stockInt, _ := strconv.ParseInt(it.DrugStockLimit, 10, 64)
3449
-		limit_count = stockInt * it.MinNumber
3450
-		service.UpdateDrugById(it.ID, orgId, limit_count, sum_count)
3451
-
3452
-		//druglist, _ := service.GetDrugCountMapList(it.ID, orgId)
3453
-		//if len(druglist) > 0 {
3454
-		//	for _, item := range druglist {
3455
-		//		var over_count int64
3456
-		//		over_count = item.SumInCount - item.FlushCount
3457
-		//		service.UpdateDrugStockInCount(item.DrugId, item.StorehouseId, over_count, item.UserOrgId)
3458
-		//	}
3459
-		//}
3460
-
3461
-		//druglistOne, _ := service.GetDrugCountMapList(it.ID, orgId)
3462
-		//if len(druglistOne) > 0 {
3463
-		//	for _, item := range druglistOne {
3464
-		//		var over_count int64
3465
-		//		over_count = item.SumOutCount + item.SumCancelCount
3466
-		//		service.UpdateDrugStockInCountOne(item.DrugId, item.StorehouseId, over_count, item.UserOrgId)
3467
-		//	}
3468
-		//}
3469
-	}
3470
-
3471
-	for _, it := range manufacturerList {
3472
-		ids = append(ids, it.ID)
3473
-	}
3474
-	infoList, _ := service.GetDrugWarehouseInfoByOrgId(orgId, storehouse_id)
3475
-	for _, it := range infoList {
3476
-		goodIds = append(goodIds, it.DrugId)
3477
 	}
3451
 	}
3478
 
3452
 
3479
 	countList, total, err := service.GetDrugStockCountList(orgId, storehouse_id, good_type, keyword, page, limit, ids, goodIds, startTime, endTime)
3453
 	countList, total, err := service.GetDrugStockCountList(orgId, storehouse_id, good_type, keyword, page, limit, ids, goodIds, startTime, endTime)
4387
 	})
4361
 	})
4388
 
4362
 
4389
 }
4363
 }
4364
+
4365
+func (this *SelfDrugApiController) GetCheckDrugBatchList() {
4366
+
4367
+	drug_id, _ := this.GetInt64("drug_id")
4368
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4369
+
4370
+	advicelist, _ := service.GetHisAdviceGroupList(drug_id, orgId)
4371
+
4372
+	outInfo, _ := service.GetDrugWarehousOutInfo(drug_id, orgId)
4373
+
4374
+	outInfoOne, _ := service.GetDrugWarehousOutInfoOne(drug_id, orgId)
4375
+
4376
+	baseDrugList, _ := service.GetDrugByGoodId(drug_id)
4377
+
4378
+	drugflow, _ := service.GetCheckDrugFlow(drug_id, orgId)
4379
+
4380
+	this.ServeSuccessJSON(map[string]interface{}{
4381
+		"advicelist":   advicelist,
4382
+		"outInfo":      outInfo,
4383
+		"outInfoOne":   outInfoOne,
4384
+		"baseDrugList": baseDrugList,
4385
+		"drugflow":     drugflow,
4386
+	})
4387
+}
4388
+
4389
+func (this *SelfDrugApiController) GetCheckGoodBatchList() {
4390
+
4391
+	id, _ := this.GetInt64("id")
4392
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4393
+	projectList, _ := service.GetCheckGoodBatchList(id, orgId)
4394
+
4395
+	warehouseList, _ := service.GetCheckGoodWarehouseList(id, orgId)
4396
+
4397
+	this.ServeSuccessJSON(map[string]interface{}{
4398
+		"projectList":   projectList,
4399
+		"warehouseList": warehouseList,
4400
+	})
4401
+}
4402
+
4403
+func (this *SelfDrugApiController) GetDrugPatientName() {
4404
+
4405
+	drug_id, _ := this.GetInt64("drug_id")
4406
+
4407
+	sys_record_time, _ := this.GetInt64("sys_record_time")
4408
+
4409
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4410
+
4411
+	advicelist, _ := service.GetHisAdviceListBySysRrecordTime(drug_id, sys_record_time, orgId)
4412
+
4413
+	outInfor, _ := service.GetDrugWarehouseOutInfoBySysRecordTime(drug_id, sys_record_time, orgId)
4414
+
4415
+	patients, _ := service.GetAllpatient(orgId)
4416
+
4417
+	this.ServeSuccessJSON(map[string]interface{}{
4418
+		"advicelist": advicelist,
4419
+		"outInfor":   outInfor,
4420
+		"patients":   patients,
4421
+	})
4422
+
4423
+}

+ 238 - 43
controllers/stock_in_api_controller.go View File

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
-	"XT_New/enums"
5
-	"XT_New/models"
6
-	"XT_New/service"
7
-	"XT_New/utils"
8
 	"encoding/json"
4
 	"encoding/json"
9
 	"fmt"
5
 	"fmt"
10
-	"github.com/astaxie/beego"
11
-	"github.com/jinzhu/gorm"
12
 	"reflect"
6
 	"reflect"
13
 	"strconv"
7
 	"strconv"
14
 	"strings"
8
 	"strings"
15
 	"time"
9
 	"time"
10
+
11
+	"XT_New/enums"
12
+	"XT_New/models"
13
+	"XT_New/service"
14
+	"XT_New/utils"
15
+	"github.com/astaxie/beego"
16
+	"github.com/jinzhu/gorm"
17
+	"github.com/mozillazg/go-pinyin"
16
 )
18
 )
17
 
19
 
18
 type StockManagerApiController struct {
20
 type StockManagerApiController struct {
159
 
161
 
160
 	beego.Router("/api/stock/getstockfloworderlist", &StockManagerApiController{}, "Get:GetStockFlowOrderList")
162
 	beego.Router("/api/stock/getstockfloworderlist", &StockManagerApiController{}, "Get:GetStockFlowOrderList")
161
 
163
 
164
+	beego.Router("/api/stock/getgoodpatientname", &StockManagerApiController{}, "Get:GetGoodPatientName")
165
+
162
 }
166
 }
163
 func (c *StockManagerApiController) HandleRefundStock() {
167
 func (c *StockManagerApiController) HandleRefundStock() {
164
 	order_id, _ := c.GetInt64("order_id", 0)
168
 	order_id, _ := c.GetInt64("order_id", 0)
3574
 
3578
 
3575
 		good.GoodUnit = unit_id
3579
 		good.GoodUnit = unit_id
3576
 
3580
 
3581
+		default_count := int64(goodNameM["default_count"].(float64))
3582
+		if default_count == 0 { //名字为空则生成一条导入错误日志
3583
+			err_log := models.ExportErrLog{
3584
+				LogType:    5,
3585
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
3586
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "默认单次用量不能为空",
3587
+				Status:     1,
3588
+				CreateTime: time.Now().Unix(),
3589
+				UpdateTime: time.Now().Unix(),
3590
+				ExportTime: time.Now().Unix(),
3591
+			}
3592
+			service.CreateExportErrLog(&err_log)
3593
+			continue
3594
+		}
3595
+
3596
+		good.DefaultCount = default_count
3597
+
3598
+		default_count_unit := goodNameM["default_count_unit"].(string)
3599
+		if len(default_count_unit) == 0 { //名字为空则生成一条导入错误日志
3600
+			err_log := models.ExportErrLog{
3601
+				LogType:    5,
3602
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
3603
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "默认单次用量单位不能为空",
3604
+				Status:     1,
3605
+				CreateTime: time.Now().Unix(),
3606
+				UpdateTime: time.Now().Unix(),
3607
+				ExportTime: time.Now().Unix(),
3608
+			}
3609
+			service.CreateExportErrLog(&err_log)
3610
+			continue
3611
+		}
3612
+
3613
+		good.DefaultCountUnit = default_count_unit
3614
+
3577
 		retail_prices := goodNameM["retail_price"].(string)
3615
 		retail_prices := goodNameM["retail_price"].(string)
3578
 		retail_price, _ := strconv.ParseFloat(retail_prices, 64)
3616
 		retail_price, _ := strconv.ParseFloat(retail_prices, 64)
3579
 
3617
 
3593
 
3631
 
3594
 		good.RetailPrice = retail_price
3632
 		good.RetailPrice = retail_price
3595
 
3633
 
3634
+		buy_prices := goodNameM["buy_price"].(string)
3635
+		buy_price, _ := strconv.ParseFloat(buy_prices, 64)
3636
+
3637
+		if buy_price <= 0 { //名字为空则生成一条导入错误日志
3638
+			err_log := models.ExportErrLog{
3639
+				LogType:    5,
3640
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
3641
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的进货价不能为空",
3642
+				Status:     1,
3643
+				CreateTime: time.Now().Unix(),
3644
+				UpdateTime: time.Now().Unix(),
3645
+				ExportTime: time.Now().Unix(),
3646
+			}
3647
+			service.CreateExportErrLog(&err_log)
3648
+			continue
3649
+		}
3650
+
3651
+		good.BuyPrice = buy_price
3652
+
3596
 		if goodNameM["stock_warn_count"] == nil || reflect.TypeOf(goodNameM["stock_warn_count"]).String() != "float64" {
3653
 		if goodNameM["stock_warn_count"] == nil || reflect.TypeOf(goodNameM["stock_warn_count"]).String() != "float64" {
3597
 			utils.ErrorLog("stock_warn_count")
3654
 			utils.ErrorLog("stock_warn_count")
3598
 			return
3655
 			return
3658
 
3715
 
3659
 		good.Wubi = wubi
3716
 		good.Wubi = wubi
3660
 
3717
 
3661
-		buy_prices := goodNameM["buy_price"].(string)
3662
-		buy_price, _ := strconv.ParseFloat(buy_prices, 64)
3663
-		good.BuyPrice = buy_price
3664
-
3665
 		if goodNameM["social_security_directory_code"] == nil || reflect.TypeOf(goodNameM["social_security_directory_code"]).String() != "string" {
3718
 		if goodNameM["social_security_directory_code"] == nil || reflect.TypeOf(goodNameM["social_security_directory_code"]).String() != "string" {
3666
 			utils.ErrorLog("social_security_directory_code")
3719
 			utils.ErrorLog("social_security_directory_code")
3667
 			return
3720
 			return
3772
 	if len(goods) > 0 {
3825
 	if len(goods) > 0 {
3773
 
3826
 
3774
 		for _, item := range goods {
3827
 		for _, item := range goods {
3828
+			hans := item.GoodName // 要转换的汉字字符串
3829
+			// 创建一个拼音转换器
3830
+			p := pinyin.NewArgs()
3831
+
3832
+			// 将汉字转为拼音
3833
+			pinyinSlice := pinyin.Pinyin(hans, p)
3775
 
3834
 
3835
+			// 输出拼音
3836
+			fmt.Println("Pinyin:", pinyinSlice)
3837
+
3838
+			// 获取首字母
3839
+			firstLetter := ""
3840
+			for _, py := range pinyinSlice {
3841
+				if len(py) > 0 {
3842
+					firstLetter += string(py[0][0])
3843
+				}
3844
+			}
3845
+
3846
+			item.FirstLetter = firstLetter
3776
 			goodInfo := models.GoodInfo{
3847
 			goodInfo := models.GoodInfo{
3777
 				GoodName:                    item.GoodName,
3848
 				GoodName:                    item.GoodName,
3778
 				SpecificationName:           item.SpecificationName,
3849
 				SpecificationName:           item.SpecificationName,
3804
 				PackingUnit:                 item.PackingUnit,
3875
 				PackingUnit:                 item.PackingUnit,
3805
 				PackingPrice:                item.RetailPrice,
3876
 				PackingPrice:                item.RetailPrice,
3806
 				IsWarehouse:                 1,
3877
 				IsWarehouse:                 1,
3878
+				DefaultCount:                item.DefaultCount,
3879
+				DefaultCountUnit:            item.DefaultCountUnit,
3880
+				FirstLetter:                 item.FirstLetter,
3807
 			}
3881
 			}
3808
 
3882
 
3809
 			//查询同种耗材名称同种类型同种规格的耗材是否存在
3883
 			//查询同种耗材名称同种类型同种规格的耗材是否存在
4231
 		var unit_id int64
4305
 		var unit_id int64
4232
 
4306
 
4233
 		drugDoseUnit := goodNameM["drug_dose_unit"].(string)
4307
 		drugDoseUnit := goodNameM["drug_dose_unit"].(string)
4308
+
4234
 		if len(drugDoseUnit) == 0 {
4309
 		if len(drugDoseUnit) == 0 {
4235
 			err_log := models.ExportErrLog{
4310
 			err_log := models.ExportErrLog{
4236
 				LogType:    4,
4311
 				LogType:    4,
4245
 			continue
4320
 			continue
4246
 		}
4321
 		}
4247
 
4322
 
4323
+		dataConfig, _ := service.GetDataConfigIsExist(0, units)
4324
+		if len(drugDoseUnit) != 0 {
4325
+			_, errcodedataconfig := service.GetChildeConfigIsExist(dataConfig.ID, drugDoseUnit, orgId)
4326
+			if errcodedataconfig == gorm.ErrRecordNotFound {
4327
+				childConfig, _ := service.GetLastChildeConfig(dataConfig.ID, orgId)
4328
+				dataconfig := models.Dataconfig{
4329
+					ParentId:       dataConfig.ID,
4330
+					Module:         "hemodialysis",
4331
+					OrgId:          orgId,
4332
+					Name:           drugDoseUnit,
4333
+					FieldName:      "",
4334
+					Value:          childConfig.Value + 1,
4335
+					CreatedTime:    "",
4336
+					UpdatedTime:    "",
4337
+					CreateUserId:   adminUser.AdminUser.Id,
4338
+					Status:         1,
4339
+					Remark:         "",
4340
+					DeleteIdSystem: 0,
4341
+					Title:          "",
4342
+					Content:        "",
4343
+					Order:          0,
4344
+					Code:           "",
4345
+					FieldType:      0,
4346
+				}
4347
+				service.CreateDataConfig(&dataconfig)
4348
+			}
4349
+		}
4350
+		list, _ := service.FindAllDataConfigList(orgId, dataConfig.ID)
4351
+		for _, it := range list {
4352
+			if drugDoseUnit == it.Name {
4353
+				unit_id = int64(it.Value)
4354
+			}
4355
+		}
4356
+		drug.DrugDoseUnit = unit_id
4357
+
4248
 		manufacturer := goodNameM["manufacturer"].(string)
4358
 		manufacturer := goodNameM["manufacturer"].(string)
4249
 		if len(manufacturer) == 0 { //名字为空则生成一条导入错误日志
4359
 		if len(manufacturer) == 0 { //名字为空则生成一条导入错误日志
4250
 			err_log := models.ExportErrLog{
4360
 			err_log := models.ExportErrLog{
4310
 		drug.Dealer = dealer_id
4420
 		drug.Dealer = dealer_id
4311
 
4421
 
4312
 		delivery_way := goodNameM["delivery_way"].(string)
4422
 		delivery_way := goodNameM["delivery_way"].(string)
4423
+		if len(delivery_way) == 0 {
4424
+			err_log := models.ExportErrLog{
4425
+				LogType:    4,
4426
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4427
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认给药途径不能为空",
4428
+				Status:     1,
4429
+				CreateTime: time.Now().Unix(),
4430
+				UpdateTime: time.Now().Unix(),
4431
+				ExportTime: time.Now().Unix(),
4432
+			}
4433
+			service.CreateExportErrLog(&err_log)
4434
+			continue
4435
+		}
4313
 
4436
 
4314
 		drug.DeliveryWay = delivery_way
4437
 		drug.DeliveryWay = delivery_way
4315
 
4438
 
4316
 		execution_frequency := goodNameM["execution_frequency"].(string)
4439
 		execution_frequency := goodNameM["execution_frequency"].(string)
4317
 
4440
 
4441
+		if len(execution_frequency) == 0 {
4442
+			err_log := models.ExportErrLog{
4443
+				LogType:    4,
4444
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4445
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
4446
+				Status:     1,
4447
+				CreateTime: time.Now().Unix(),
4448
+				UpdateTime: time.Now().Unix(),
4449
+				ExportTime: time.Now().Unix(),
4450
+			}
4451
+			service.CreateExportErrLog(&err_log)
4452
+			continue
4453
+		}
4454
+
4318
 		drug.ExecutionFrequency = execution_frequency
4455
 		drug.ExecutionFrequency = execution_frequency
4319
 
4456
 
4320
-		lmt_used_flags := int64(goodNameM["lmt_used_flag"].(float64))
4457
+		prescribing_number := goodNameM["prescribing_number"].(float64)
4321
 
4458
 
4322
-		drug.LmtUsedFlag = lmt_used_flags
4459
+		if prescribing_number == 0 {
4460
+			err_log := models.ExportErrLog{
4461
+				LogType:    4,
4462
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4463
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认开药数量不能为空",
4464
+				Status:     1,
4465
+				CreateTime: time.Now().Unix(),
4466
+				UpdateTime: time.Now().Unix(),
4467
+				ExportTime: time.Now().Unix(),
4468
+			}
4469
+			service.CreateExportErrLog(&err_log)
4470
+			continue
4471
+		}
4472
+		drug.PrescribingNumber = prescribing_number
4323
 
4473
 
4324
-		dataConfig, _ := service.GetDataConfigIsExist(0, units)
4325
-		if len(drugDoseUnit) != 0 {
4326
-			_, errcodedataconfig := service.GetChildeConfigIsExist(dataConfig.ID, drugDoseUnit, orgId)
4327
-			if errcodedataconfig == gorm.ErrRecordNotFound {
4328
-				childConfig, _ := service.GetLastChildeConfig(dataConfig.ID, orgId)
4329
-				dataconfig := models.Dataconfig{
4330
-					ParentId:       dataConfig.ID,
4331
-					Module:         "hemodialysis",
4332
-					OrgId:          orgId,
4333
-					Name:           drugDoseUnit,
4334
-					FieldName:      "",
4335
-					Value:          childConfig.Value + 1,
4336
-					CreatedTime:    "",
4337
-					UpdatedTime:    "",
4338
-					CreateUserId:   adminUser.AdminUser.Id,
4339
-					Status:         1,
4340
-					Remark:         "",
4341
-					DeleteIdSystem: 0,
4342
-					Title:          "",
4343
-					Content:        "",
4344
-					Order:          0,
4345
-					Code:           "",
4346
-					FieldType:      0,
4347
-				}
4348
-				service.CreateDataConfig(&dataconfig)
4474
+		prescribing_number_unit := goodNameM["prescribing_number_unit"].(string)
4475
+
4476
+		if len(prescribing_number_unit) == 0 {
4477
+			err_log := models.ExportErrLog{
4478
+				LogType:    4,
4479
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4480
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认开药数量单位不能为空",
4481
+				Status:     1,
4482
+				CreateTime: time.Now().Unix(),
4483
+				UpdateTime: time.Now().Unix(),
4484
+				ExportTime: time.Now().Unix(),
4349
 			}
4485
 			}
4486
+			service.CreateExportErrLog(&err_log)
4487
+			continue
4350
 		}
4488
 		}
4351
-		list, _ := service.FindAllDataConfigList(orgId, dataConfig.ID)
4352
-		for _, it := range list {
4353
-			if drugDoseUnit == it.Name {
4354
-				unit_id = int64(it.Value)
4489
+
4490
+		drug.PrescribingNumberUnit = prescribing_number_unit
4491
+
4492
+		drug_day := goodNameM["drug_day"].(string)
4493
+
4494
+		if len(drug_day) == 0 {
4495
+			err_log := models.ExportErrLog{
4496
+				LogType:    4,
4497
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
4498
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的天数不能为空",
4499
+				Status:     1,
4500
+				CreateTime: time.Now().Unix(),
4501
+				UpdateTime: time.Now().Unix(),
4502
+				ExportTime: time.Now().Unix(),
4355
 			}
4503
 			}
4504
+			service.CreateExportErrLog(&err_log)
4505
+			continue
4356
 		}
4506
 		}
4357
-		drug.DrugDoseUnit = unit_id
4507
+
4508
+		drug.DrugDay = drug_day
4509
+
4510
+		lmt_used_flags := int64(goodNameM["lmt_used_flag"].(float64))
4511
+
4512
+		drug.LmtUsedFlag = lmt_used_flags
4358
 
4513
 
4359
 		if goodNameM["drug_alias"] == nil || reflect.TypeOf(goodNameM["drug_alias"]).String() != "string" {
4514
 		if goodNameM["drug_alias"] == nil || reflect.TypeOf(goodNameM["drug_alias"]).String() != "string" {
4360
 			utils.ErrorLog("drug_alias")
4515
 			utils.ErrorLog("drug_alias")
4399
 		}
4554
 		}
4400
 
4555
 
4401
 		drugCategoryList, _ := service.GetParentDataConfig(drugCategoryConfig.ID, orgId)
4556
 		drugCategoryList, _ := service.GetParentDataConfig(drugCategoryConfig.ID, orgId)
4402
-		fmt.Println("drugCategoryList", drugCategoryList)
4403
 		for _, it := range drugCategoryList {
4557
 		for _, it := range drugCategoryList {
4404
 			if drug_category == it.Name {
4558
 			if drug_category == it.Name {
4405
 				drug_category_id = int64(it.Value)
4559
 				drug_category_id = int64(it.Value)
4557
 
4711
 
4558
 	if len(drugList) > 0 {
4712
 	if len(drugList) > 0 {
4559
 		for _, item := range drugList {
4713
 		for _, item := range drugList {
4714
+			hans := item.DrugName // 要转换的汉字字符串
4715
+			// 创建一个拼音转换器
4716
+			p := pinyin.NewArgs()
4717
+
4718
+			// 将汉字转为拼音
4719
+			pinyinSlice := pinyin.Pinyin(hans, p)
4720
+
4721
+			// 输出拼音
4722
+			fmt.Println("Pinyin:", pinyinSlice)
4723
+
4724
+			// 获取首字母
4725
+			firstLetter := ""
4726
+			for _, py := range pinyinSlice {
4727
+				if len(py) > 0 {
4728
+					firstLetter += string(py[0][0])
4729
+				}
4730
+			}
4731
+
4732
+			item.FirstLetter = firstLetter
4733
+			item.Pinyin = firstLetter
4560
 			goodInfo := models.BaseDrugLib{
4734
 			goodInfo := models.BaseDrugLib{
4561
 				DrugName:                    item.DrugName,
4735
 				DrugName:                    item.DrugName,
4562
 				DrugAlias:                   item.DrugAlias,
4736
 				DrugAlias:                   item.DrugAlias,
4608
 				MinNumber:                   item.MinNumber,
4782
 				MinNumber:                   item.MinNumber,
4609
 				IsUse:                       2,
4783
 				IsUse:                       2,
4610
 				MinPrice:                    item.MinPrice,
4784
 				MinPrice:                    item.MinPrice,
4785
+				PrescribingNumber:           item.PrescribingNumber,
4786
+				PrescribingNumberUnit:       item.PrescribingNumberUnit,
4787
+				FirstLetter:                 item.FirstLetter,
4611
 			}
4788
 			}
4612
 
4789
 
4613
 			//查询同种药品同种规格是否存在
4790
 			//查询同种药品同种规格是否存在
7998
 
8175
 
7999
 	}
8176
 	}
8000
 }
8177
 }
8178
+
8179
+func (this *StockManagerApiController) GetGoodPatientName() {
8180
+
8181
+	good_id, _ := this.GetInt64("good_id")
8182
+
8183
+	sys_record_time, _ := this.GetInt64("sys_record_time")
8184
+
8185
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8186
+
8187
+	projectList, _ := service.GetGoodProjectList(good_id, sys_record_time, orgId)
8188
+
8189
+	outList, _ := service.GetWarehouseOutListBySysrecordTime(good_id, sys_record_time, orgId)
8190
+
8191
+	this.ServeSuccessJSON(map[string]interface{}{
8192
+		"projectList": projectList,
8193
+		"outList":     outList,
8194
+	})
8195
+}

+ 1 - 0
models/dialysis.go View File

658
 	TransfusionVolume               string  `gorm:"column:transfusion_volume" json:"transfusion_volume" form:"transfusion_volume"`
658
 	TransfusionVolume               string  `gorm:"column:transfusion_volume" json:"transfusion_volume" form:"transfusion_volume"`
659
 	Condenser                       string  `gorm:"column:condenser" json:"condenser" form:"condenser"`
659
 	Condenser                       string  `gorm:"column:condenser" json:"condenser" form:"condenser"`
660
 	LastAfterWeight                 string  `gorm:"column:last_after_weight" json:"last_after_weight" form:"last_after_weight"`
660
 	LastAfterWeight                 string  `gorm:"column:last_after_weight" json:"last_after_weight" form:"last_after_weight"`
661
+	DisplaceLiquiValue              string  `gorm:"column:displace_liqui_value" json:"displace_liqui_value" form:"displace_liqui_value"`
661
 }
662
 }
662
 
663
 
663
 func (AssessmentAfterDislysis) TableName() string {
664
 func (AssessmentAfterDislysis) TableName() string {

+ 1 - 0
models/new_stock_models.go View File

172
 	Manufacturer           int64                  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
172
 	Manufacturer           int64                  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
173
 	Dealer                 int64                  `gorm:"column:dealer" json:"dealer" form:"dealer"`
173
 	Dealer                 int64                  `gorm:"column:dealer" json:"dealer" form:"dealer"`
174
 	MedicalInsuranceNumber string                 `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
174
 	MedicalInsuranceNumber string                 `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
175
+	DrugType               int64                  `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
175
 }
176
 }
176
 
177
 
177
 func (NewBaseDrugOne) TableName() string {
178
 func (NewBaseDrugOne) TableName() string {

+ 2 - 0
models/patient_models.go View File

231
 	AllergicHistory          string  `gorm:"column:allergic_history" json:"allergic_history" form:"allergic_history"`
231
 	AllergicHistory          string  `gorm:"column:allergic_history" json:"allergic_history" form:"allergic_history"`
232
 	PatientAddress           string  `gorm:"column:patient_address" json:"patient_address" form:"patient_address"`
232
 	PatientAddress           string  `gorm:"column:patient_address" json:"patient_address" form:"patient_address"`
233
 	FirstLetter              string  `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
233
 	FirstLetter              string  `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
234
+	PrintDate                int64   `gorm:"column:print_date" json:"print_date" form:"print_date"`
234
 }
235
 }
235
 
236
 
236
 func (Patients) TableName() string {
237
 func (Patients) TableName() string {
857
 	AllergicHistory              string  `gorm:"column:allergic_history" json:"allergic_history" form:"allergic_history"`
858
 	AllergicHistory              string  `gorm:"column:allergic_history" json:"allergic_history" form:"allergic_history"`
858
 	PatientAddress               string  `gorm:"column:patient_address" json:"patient_address" form:"patient_address"`
859
 	PatientAddress               string  `gorm:"column:patient_address" json:"patient_address" form:"patient_address"`
859
 	FirstLetter                  string  `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
860
 	FirstLetter                  string  `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
861
+	PrintDate                    int64   `gorm:"column:print_date" json:"print_date" form:"print_date"`
860
 }
862
 }
861
 
863
 
862
 func (XtPatientsNew) TableName() string {
864
 func (XtPatientsNew) TableName() string {

+ 5 - 5
models/smart_sch.go View File

14
 }
14
 }
15
 
15
 
16
 type SmartSchTemplatePatient struct {
16
 type SmartSchTemplatePatient struct {
17
-	ID         int64  `gorm:"column:id" json:"id" form:"id"`
18
-	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
19
-	Name       string `gorm:"column:name" json:"name" form:"name"`
20
-	DialysisNo string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
21
-
17
+	ID                          int64  `gorm:"column:id" json:"id" form:"id"`
18
+	UserOrgId                   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
19
+	Name                        string `gorm:"column:name" json:"name" form:"name"`
20
+	DialysisNo                  string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
21
+	Lapseto                     int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
22
 	XtPatientScheduleTemplateId []*XtPatientScheduleTemplateId
22
 	XtPatientScheduleTemplateId []*XtPatientScheduleTemplateId
23
 }
23
 }
24
 
24
 

+ 3 - 0
models/user_models.go View File

199
 	Epo                        string  `gorm:"column:epo" json:"epo" form:"epo"`
199
 	Epo                        string  `gorm:"column:epo" json:"epo" form:"epo"`
200
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
200
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
201
 	BloodAccessPartId          string  `gorm:"column:blood_access_part_id" json:"blood_access_part_id" form:"blood_access_part_id"`
201
 	BloodAccessPartId          string  `gorm:"column:blood_access_part_id" json:"blood_access_part_id" form:"blood_access_part_id"`
202
+	DialysisStrainer           string  `gorm:"column:dialysis_strainer" json:"dialysis_strainer" form:"dialysis_strainer"`
203
+	DialysisDialyszers         string  `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
204
+	DialysisIrrigation         string  `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
202
 }
205
 }
203
 
206
 
204
 func (XtDialysisPrescription) TableName() string {
207
 func (XtDialysisPrescription) TableName() string {

+ 11 - 2
service/dialysis_service.go View File

1
 package service
1
 package service
2
 
2
 
3
 import (
3
 import (
4
-	"XT_New/models"
5
 	"encoding/json"
4
 	"encoding/json"
6
 	"fmt"
5
 	"fmt"
7
-	"github.com/jinzhu/gorm"
8
 	"strconv"
6
 	"strconv"
9
 	"strings"
7
 	"strings"
10
 	"time"
8
 	"time"
9
+
10
+	"XT_New/models"
11
+	"github.com/jinzhu/gorm"
11
 )
12
 )
12
 
13
 
13
 // GetPatientList 返回患者的列表
14
 // GetPatientList 返回患者的列表
303
 	return err
304
 	return err
304
 }
305
 }
305
 
306
 
307
+func GetPredialysisEvaluation(patient_id int64, org_id int64) (models.PredialysisEvaluation, error) {
308
+
309
+	evaluation := models.PredialysisEvaluation{}
310
+
311
+	err := XTReadDB().Where("patient_id = ? and user_org_id = ? and status =1 and symptom_before_dialysis!=''", patient_id, org_id).Last(&evaluation).Error
312
+	return evaluation, err
313
+}
314
+
306
 // 修改透前评估
315
 // 修改透前评估
307
 func UpadatePredialysisEvaluation(predialysisEvaluation *models.PredialysisEvaluation) error {
316
 func UpadatePredialysisEvaluation(predialysisEvaluation *models.PredialysisEvaluation) error {
308
 	err := writeDb.Save(&predialysisEvaluation).Error
317
 	err := writeDb.Save(&predialysisEvaluation).Error

+ 14 - 4
service/mobile_dialysis_service.go View File

1
 package service
1
 package service
2
 
2
 
3
 import (
3
 import (
4
-	"XT_New/models"
5
 	"encoding/json"
4
 	"encoding/json"
6
 	"fmt"
5
 	"fmt"
7
-	"github.com/jinzhu/gorm"
8
 	"strconv"
6
 	"strconv"
9
 	"time"
7
 	"time"
8
+
9
+	"XT_New/models"
10
+	"github.com/jinzhu/gorm"
10
 )
11
 )
11
 
12
 
12
 // func GetSchedualPatients(orgID int64) ([]*MDialysisScheduleVM, error) {
13
 // func GetSchedualPatients(orgID int64) ([]*MDialysisScheduleVM, error) {
1139
 
1140
 
1140
 	// cur_date := time.Now().Format("2006-01-02")
1141
 	// cur_date := time.Now().Format("2006-01-02")
1141
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(maxDate, 10) + ":assessment_after_dislysis_last"
1142
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(maxDate, 10) + ":assessment_after_dislysis_last"
1143
+	redis.Set(key, "", time.Second)
1142
 	assessment_after_dislysis_last_str, _ := redis.Get(key).Result()
1144
 	assessment_after_dislysis_last_str, _ := redis.Get(key).Result()
1143
 
1145
 
1144
 	if len(assessment_after_dislysis_last_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1146
 	if len(assessment_after_dislysis_last_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2348
 
2350
 
2349
 	// cur_date := time.Now().Format("2006-01-02")
2351
 	// cur_date := time.Now().Format("2006-01-02")
2350
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
2352
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
2351
-
2352
 	dialysis_solution_str, _ := redis.Get(key).Result()
2353
 	dialysis_solution_str, _ := redis.Get(key).Result()
2353
 
2354
 
2354
 	if len(dialysis_solution_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2355
 	if len(dialysis_solution_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2355
-		err := readDb.Model(&models.DialysisSolution{}).Where("patient_id = ? and user_org_id = ? and status = 1 AND mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
2356
+		err := readDb.Model(&models.DialysisSolution{}).Where("patient_id = ? and user_org_id = ? and status = 1 AND mode_id = ? and solution_status=1", patientID, orgID, mode_id).Last(&record).Error
2356
 		if err != nil {
2357
 		if err != nil {
2357
 			if err == gorm.ErrRecordNotFound {
2358
 			if err == gorm.ErrRecordNotFound {
2358
 				if record.ID <= 0 {
2359
 				if record.ID <= 0 {
3170
 	return evaluation, err
3171
 	return evaluation, err
3171
 }
3172
 }
3172
 
3173
 
3174
+func GetAssessmentBeforFourty(orgid int64, patientid int64, recorddate int64) (models.XtAssessmentBeforeDislysis, error) {
3175
+
3176
+	evaluation := models.XtAssessmentBeforeDislysis{}
3177
+
3178
+	err := XTReadDB().Model(&evaluation).Where("user_org_id = ? and patient_id = ? and assessment_date = ? and status = 1", orgid, patientid, recorddate).Find(&evaluation).Error
3179
+
3180
+	return evaluation, err
3181
+}
3182
+
3173
 func GetAllHisDoctorAdvice(orgid int64, patientid int64, recorddate int64) (his []*models.HisDoctorAdviceInfo, err error) {
3183
 func GetAllHisDoctorAdvice(orgid int64, patientid int64, recorddate int64) (his []*models.HisDoctorAdviceInfo, err error) {
3174
 	redis := RedisClient()
3184
 	redis := RedisClient()
3175
 	defer redis.Close()
3185
 	defer redis.Close()

+ 8 - 5
service/new_warehouse_service.go View File

1
 package service
1
 package service
2
 
2
 
3
 import (
3
 import (
4
-	"XT_New/models"
5
-	"XT_New/utils"
6
 	"errors"
4
 	"errors"
7
 	"fmt"
5
 	"fmt"
8
-	"github.com/jinzhu/gorm"
9
 	"math"
6
 	"math"
10
 	"strconv"
7
 	"strconv"
11
 	"strings"
8
 	"strings"
12
 	"time"
9
 	"time"
10
+
11
+	"XT_New/models"
12
+	"XT_New/utils"
13
+	"github.com/jinzhu/gorm"
13
 )
14
 )
14
 
15
 
15
 // 耗材出库
16
 // 耗材出库
2631
 
2632
 
2632
 func UpdateDrugAutoReduceRecordInfo(patient_id int64, record_date int64, drug_id int64, detail *models.DrugAutomaticReduceDetail) error {
2633
 func UpdateDrugAutoReduceRecordInfo(patient_id int64, record_date int64, drug_id int64, detail *models.DrugAutomaticReduceDetail) error {
2633
 
2634
 
2634
-	err := XTWriteDB().Model(&models.DrugAutomaticReduceDetail{}).Where("patient_id = ? and record_date = ? and drug_id = ?", patient_id, record_date, drug_id).Update(map[string]interface{}{"patient_id": detail.PatientId, "record_time": detail.RecordTime, "drug_id": detail.DrugId, "count": detail.Count, "count_unit": detail.CountUnit, "warehouse_info_id": detail.WarehouseInfoId, "advice_id": detail.AdviceId, "storehouse_id": detail.StorehouseId}).Error
2635
+	err := XTWriteDB().Model(&models.DrugAutomaticReduceDetail{}).Where("patient_id = ? and record_time = ? and drug_id = ?", patient_id, record_date, drug_id).Update(map[string]interface{}{"patient_id": detail.PatientId, "record_time": detail.RecordTime, "drug_id": detail.DrugId, "count": detail.Count, "count_unit": detail.CountUnit, "warehouse_info_id": detail.WarehouseInfoId, "advice_id": detail.AdviceId, "storehouse_id": detail.StorehouseId}).Error
2635
 	return err
2636
 	return err
2636
 }
2637
 }
2637
 
2638
 
2638
 func UpdateNewDrugAutoReduceRecordInfo(patient_id int64, record_date int64, drug_id int64, detail *models.DrugAutomaticReduceDetail, tx *gorm.DB) error {
2639
 func UpdateNewDrugAutoReduceRecordInfo(patient_id int64, record_date int64, drug_id int64, detail *models.DrugAutomaticReduceDetail, tx *gorm.DB) error {
2639
 
2640
 
2640
-	err := tx.Model(&models.DrugAutomaticReduceDetail{}).Where("patient_id = ? and record_date = ? and drug_id = ?", patient_id, record_date, drug_id).Update(map[string]interface{}{"patient_id": detail.PatientId, "record_time": detail.RecordTime, "drug_id": detail.DrugId, "count": detail.Count, "count_unit": detail.CountUnit, "warehouse_info_id": detail.WarehouseInfoId, "advice_id": detail.AdviceId, "storehouse_id": detail.StorehouseId}).Error
2641
+	err := tx.Model(&models.DrugAutomaticReduceDetail{}).Where("patient_id = ? and record_time = ? and drug_id = ?", patient_id, record_date, drug_id).Update(map[string]interface{}{"patient_id": detail.PatientId, "record_time": detail.RecordTime, "drug_id": detail.DrugId, "count": detail.Count, "count_unit": detail.CountUnit, "warehouse_info_id": detail.WarehouseInfoId, "advice_id": detail.AdviceId, "storehouse_id": detail.StorehouseId}).Error
2641
 	if err != nil {
2642
 	if err != nil {
2642
 		tx.Rollback()
2643
 		tx.Rollback()
2643
 		return err
2644
 		return err
3910
 			lastDrugOutInfo, _ := GetNewNewDrugWarehouseOutInfoSix(advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId, advice.ID, warehouse.ID, tx)
3911
 			lastDrugOutInfo, _ := GetNewNewDrugWarehouseOutInfoSix(advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId, advice.ID, warehouse.ID, tx)
3911
 
3912
 
3912
 			if lastDrugOutInfo.ID == 0 {
3913
 			if lastDrugOutInfo.ID == 0 {
3914
+				//删除在新增
3915
+				UpdateNewDrugWarehouseOutInfoTen(lastDrugOutInfo.PatientId, lastDrugOutInfo.SysRecordTime, advice.ID, tx)
3913
 				AddNewSigleDrugWarehouseOutInfo(warehouseOutInfo, tx)
3916
 				AddNewSigleDrugWarehouseOutInfo(warehouseOutInfo, tx)
3914
 			}
3917
 			}
3915
 			if lastDrugOutInfo.ID > 0 {
3918
 			if lastDrugOutInfo.ID > 0 {

+ 18 - 3
service/patient_service.go View File

1
 package service
1
 package service
2
 
2
 
3
 import (
3
 import (
4
-	"XT_New/models"
5
-	"XT_New/utils"
6
 	"encoding/json"
4
 	"encoding/json"
7
 	"fmt"
5
 	"fmt"
8
 	"strconv"
6
 	"strconv"
9
 	"strings"
7
 	"strings"
10
 	"time"
8
 	"time"
11
 
9
 
10
+	"XT_New/models"
11
+	"XT_New/utils"
12
+
12
 	"github.com/jinzhu/gorm"
13
 	"github.com/jinzhu/gorm"
13
 )
14
 )
14
 
15
 
901
 func UpdatepatientTwo(patientsNew *models.XtPatientsNew, id int64) error {
902
 func UpdatepatientTwo(patientsNew *models.XtPatientsNew, id int64) error {
902
 
903
 
903
 	err := XTWriteDB().Model(&patientsNew).Where("blood_id = ?", id).Update(map[string]interface{}{"user_org_id": patientsNew.UserOrgId, "user_id": patientsNew.UserId, "avatar": patientsNew.Avatar, "patient_type": patientsNew.Avatar, "dialysis_no": patientsNew.DialysisNo, "admission_number": patientsNew.AdmissionNumber, "source": patientsNew.Source, "lapseto": patientsNew.Lapseto, "partition_id": patientsNew.PartitionId, "bed_id": patientsNew.BedId, "name": patientsNew.Name, "alias": patientsNew.Alias, "gender": patientsNew.Gender, "marital_status": patientsNew.MaritalStatus, "id_card_no": patientsNew.IdCardNo, "birthday": patientsNew.Birthday, "reimbursement_way_id": patientsNew.ReimbursementWayId, "health_care_type": patientsNew.HealthCareType, "health_care_no": patientsNew.HealthCareType, "health_care_due_date": patientsNew.HealthCareType, "height": patientsNew.Height, "blood_type": patientsNew.BloodType, "rh": patientsNew.Rh, "health_care_due_alert_date": patientsNew.HealthCareDueAlertDate, "education_level": patientsNew.EducationLevel, "profession": patientsNew.Profession, "phone": patientsNew.Phone, "home_telephone": patientsNew.HomeTelephone, "relative_phone": patientsNew.RelativePhone, "relative_relations": patientsNew.RelativeRelations, "home_address": patientsNew.HomeAddress, "work_unit": patientsNew.WorkUnit, "unit_address": patientsNew.UnitAddress, "children": patientsNew.Children, "receiving_date": patientsNew.ReceivingDate, "is_hospital_first_dialysis": patientsNew.IsHospitalFirstDialysis, "first_dialysis_date": patientsNew.FirstDialysisDate, "first_dialysis_hospital": patientsNew.FirstDialysisHospital, "predialysis_condition": patientsNew.PredialysisCondition, "pre_hospital_dialysis_frequency": patientsNew.PreHospitalDialysisFrequency, "pre_hospital_dialysis_times": patientsNew.PreHospitalDialysisFrequency, "hospital_first_dialysis_date": patientsNew.HospitalFirstDialysisDate, "induction_period": patientsNew.InductionPeriod, "initial_dialysis": patientsNew.InitialDialysis, "total_dialysis": patientsNew.TotalDialysis, "attending_doctor_id": patientsNew.AttendingDoctorId, "head_nurse_id": patientsNew.HeadNurseId, "evaluate": patientsNew.Evaluate, "diagnose": patientsNew.Diagnose, "remark": patientsNew.Remark, "registrars_id": patientsNew.RegistrarsId, "registrars": patientsNew.Registrars, "qr_code": patientsNew.QrCode, "binding_state": patientsNew.BindingState, "patient_complains": patientsNew.PatientComplains, "present_history": patientsNew.PresentHistory, "past_history": patientsNew.PastHistory, "temperature": patientsNew.Temperature,
904
 	err := XTWriteDB().Model(&patientsNew).Where("blood_id = ?", id).Update(map[string]interface{}{"user_org_id": patientsNew.UserOrgId, "user_id": patientsNew.UserId, "avatar": patientsNew.Avatar, "patient_type": patientsNew.Avatar, "dialysis_no": patientsNew.DialysisNo, "admission_number": patientsNew.AdmissionNumber, "source": patientsNew.Source, "lapseto": patientsNew.Lapseto, "partition_id": patientsNew.PartitionId, "bed_id": patientsNew.BedId, "name": patientsNew.Name, "alias": patientsNew.Alias, "gender": patientsNew.Gender, "marital_status": patientsNew.MaritalStatus, "id_card_no": patientsNew.IdCardNo, "birthday": patientsNew.Birthday, "reimbursement_way_id": patientsNew.ReimbursementWayId, "health_care_type": patientsNew.HealthCareType, "health_care_no": patientsNew.HealthCareType, "health_care_due_date": patientsNew.HealthCareType, "height": patientsNew.Height, "blood_type": patientsNew.BloodType, "rh": patientsNew.Rh, "health_care_due_alert_date": patientsNew.HealthCareDueAlertDate, "education_level": patientsNew.EducationLevel, "profession": patientsNew.Profession, "phone": patientsNew.Phone, "home_telephone": patientsNew.HomeTelephone, "relative_phone": patientsNew.RelativePhone, "relative_relations": patientsNew.RelativeRelations, "home_address": patientsNew.HomeAddress, "work_unit": patientsNew.WorkUnit, "unit_address": patientsNew.UnitAddress, "children": patientsNew.Children, "receiving_date": patientsNew.ReceivingDate, "is_hospital_first_dialysis": patientsNew.IsHospitalFirstDialysis, "first_dialysis_date": patientsNew.FirstDialysisDate, "first_dialysis_hospital": patientsNew.FirstDialysisHospital, "predialysis_condition": patientsNew.PredialysisCondition, "pre_hospital_dialysis_frequency": patientsNew.PreHospitalDialysisFrequency, "pre_hospital_dialysis_times": patientsNew.PreHospitalDialysisFrequency, "hospital_first_dialysis_date": patientsNew.HospitalFirstDialysisDate, "induction_period": patientsNew.InductionPeriod, "initial_dialysis": patientsNew.InitialDialysis, "total_dialysis": patientsNew.TotalDialysis, "attending_doctor_id": patientsNew.AttendingDoctorId, "head_nurse_id": patientsNew.HeadNurseId, "evaluate": patientsNew.Evaluate, "diagnose": patientsNew.Diagnose, "remark": patientsNew.Remark, "registrars_id": patientsNew.RegistrarsId, "registrars": patientsNew.Registrars, "qr_code": patientsNew.QrCode, "binding_state": patientsNew.BindingState, "patient_complains": patientsNew.PatientComplains, "present_history": patientsNew.PresentHistory, "past_history": patientsNew.PastHistory, "temperature": patientsNew.Temperature,
904
-		"pulse": patientsNew.Pulse, "respiratory": patientsNew.Respiratory, "sbp": patientsNew.Sbp, "dbp": patientsNew.Dbp, "nation": patientsNew.Nation, "native_place": patientsNew.NativePlace, "age": patientsNew.Age, "infectious_next_record_time": patientsNew.InfectiousNextRecordTime, "is_infectious": patientsNew.IsInfectious, "remind_cycle": patientsNew.RemindCycle, "response_result": patientsNew.ResponseResult, "is_open_remind": patientsNew.IsOpenRemind, "first_treatment_date": patientsNew.FirstTreatmentDate, "dialysis_age": patientsNew.DialysisAge, "expense_kind": patientsNew.ExpenseKind, "tell_phone": patientsNew.ExpenseKind, "contact_name": patientsNew.ContactName, "blood_patients": patientsNew.BloodPatients, "slow_patients": patientsNew.SlowPatients, "member_patients": patientsNew.MemberPatients, "ecommer_patients": patientsNew.EcommerPatients, "troble_shoot": patientsNew.TrobleShoot, "sch_remark": patientsNew.SchRemark, "treatment_plan": patientsNew.TreatmentPlan, "record_number": patientsNew.RecordNumber, "patient_start_time": patientsNew.PatientStartTime, "patient_end_time": patientsNew.PatientEndTime, "infectious_remark": patientsNew.InfectiousRemark, "allergic_history": patientsNew.AllergicHistory, "patient_address": patientsNew.PatientAddress}).Error
905
+		"pulse": patientsNew.Pulse, "respiratory": patientsNew.Respiratory, "sbp": patientsNew.Sbp, "dbp": patientsNew.Dbp, "nation": patientsNew.Nation, "native_place": patientsNew.NativePlace, "age": patientsNew.Age, "infectious_next_record_time": patientsNew.InfectiousNextRecordTime, "is_infectious": patientsNew.IsInfectious, "remind_cycle": patientsNew.RemindCycle, "response_result": patientsNew.ResponseResult, "is_open_remind": patientsNew.IsOpenRemind, "first_treatment_date": patientsNew.FirstTreatmentDate, "dialysis_age": patientsNew.DialysisAge, "expense_kind": patientsNew.ExpenseKind, "tell_phone": patientsNew.ExpenseKind, "contact_name": patientsNew.ContactName, "blood_patients": patientsNew.BloodPatients, "slow_patients": patientsNew.SlowPatients, "member_patients": patientsNew.MemberPatients, "ecommer_patients": patientsNew.EcommerPatients, "troble_shoot": patientsNew.TrobleShoot, "sch_remark": patientsNew.SchRemark, "treatment_plan": patientsNew.TreatmentPlan, "record_number": patientsNew.RecordNumber, "patient_start_time": patientsNew.PatientStartTime, "patient_end_time": patientsNew.PatientEndTime, "infectious_remark": patientsNew.InfectiousRemark, "allergic_history": patientsNew.AllergicHistory, "patient_address": patientsNew.PatientAddress, "print_date": patientsNew.PrintDate}).Error
905
 	return err
906
 	return err
906
 }
907
 }
907
 
908
 
4024
 
4025
 
4025
 	return solution, err
4026
 	return solution, err
4026
 }
4027
 }
4028
+
4029
+func GetPatientBeforRecordList(patient_id int64, user_org_id int64) (befor []*models.XtAssessmentBeforeDislysis, err error) {
4030
+
4031
+	err = XTReadDB().Where("patient_id = ? and user_org_id =? and status=1", patient_id, user_org_id).Order("id desc").Limit(5).Find(&befor).Error
4032
+
4033
+	return befor, err
4034
+}
4035
+
4036
+func GetPatientAfterRecordList(patient_id int64, user_org_id int64) (after []*models.XtAssessmentAfterDislysis, err error) {
4037
+
4038
+	err = XTReadDB().Where("patient_id = ? and user_org_id =? and status=1", patient_id, user_org_id).Order("id desc").Limit(5).Find(&after).Error
4039
+
4040
+	return after, err
4041
+}

+ 46 - 23
service/schedule_service.go View File

956
 	return list, err
956
 	return list, err
957
 }
957
 }
958
 
958
 
959
-func GetWeekDayScheduleByIdThee(orgid int64, scheduleDate int64, scheduleType int64, zone []string) (list []*models.VmSchedulesRemind, err error) {
959
+func GetWeekDayScheduleByIdThee(orgid int64, scheduleDate int64, scheduleType int64, zone []string, limit int64, page int64, ids []string) (list []*models.VmSchedulesRemind, total int64, err error) {
960
 
960
 
961
 	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
961
 	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
962
+	offset := (page - 1) * limit
962
 	if orgid > 0 {
963
 	if orgid > 0 {
963
 		db = db.Where("x.user_org_id = ?", orgid)
964
 		db = db.Where("x.user_org_id = ?", orgid)
964
 	}
965
 	}
972
 		db = db.Where("x.partition_id in (?)", zone)
973
 		db = db.Where("x.partition_id in (?)", zone)
973
 	}
974
 	}
974
 
975
 
975
-	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 {
976
-		return db.Where("status =1 and parent_id = 0 and advice_date = ?", scheduleDate).Preload("ChildDoctorAdvice", "status = 1")
977
-	}).Preload("DialysisPrescription", "status = 1 and record_date =? and user_org_id = ?", scheduleDate, orgid).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
978
-		return db.Where("status =1 and solution_status = 1").Order("id asc")
979
-	}).Preload("LastAfterWeight", func(db *gorm.DB) *gorm.DB {
980
-		return db.Where("user_org_id = ? and status = 1 and assessment_date < ?", orgid, scheduleDate).Limit(1)
981
-	}).Find(&list).Error
976
+	if len(ids) > 0 {
977
+		db = db.Where("x.patient_id in(?)", ids)
978
+	}
982
 
979
 
983
-	return list, err
980
+	err = db.Offset(offset).Limit(limit).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").Count(&total).Find(&list).Error
981
+
982
+	return list, total, err
984
 }
983
 }
985
 
984
 
986
-func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int64, startDate int64, zone []string) (list []*models.VmSchedulesRemind, err error) {
985
+func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int64, startDate int64, zone []string, limit int64, page int64, ids []string) (list []*models.VmSchedulesRemind, total int64, err error) {
987
 
986
 
988
 	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
987
 	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
988
+	offset := (page - 1) * limit
989
+
989
 	if orgid > 0 {
990
 	if orgid > 0 {
990
 		db = db.Where("x.user_org_id = ?", orgid)
991
 		db = db.Where("x.user_org_id = ?", orgid)
991
 	}
992
 	}
998
 	if len(zone) > 0 {
999
 	if len(zone) > 0 {
999
 		db = db.Where("x.partition_id in (?)", zone)
1000
 		db = db.Where("x.partition_id in (?)", zone)
1000
 	}
1001
 	}
1002
+	if len(ids) > 0 {
1003
+		db = db.Where("x.patient_id in(?)", ids)
1004
+	}
1001
 
1005
 
1002
-	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 {
1003
-		return db.Where("status =1 and parent_id = 0 and advice_date = ?", scheduleDate).Preload("ChildDoctorAdvice", "status = 1")
1004
-	}).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ?", scheduleDate).Preload("DialysisPrescription", "status = 1 and record_date = ?", scheduleDate).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
1005
-		return db.Where("status =1 and solution_status =1").Order("id asc")
1006
-	}).Preload("LastAfterWeight", func(db *gorm.DB) *gorm.DB {
1007
-		return db.Where("user_org_id = ? and status = 1 and assessment_date < ?", orgid, scheduleDate).Limit(1)
1008
-	}).Find(&list).Error
1006
+	err = db.Offset(offset).Limit(limit).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").Count(&total).Find(&list).Error
1009
 
1007
 
1010
-	return list, err
1008
+	return list, total, err
1011
 }
1009
 }
1012
 
1010
 
1013
 func RemoveRepeatedElement(arr []*models.DoctorAdvice) (newArr []*models.DoctorAdvice) {
1011
 func RemoveRepeatedElement(arr []*models.DoctorAdvice) (newArr []*models.DoctorAdvice) {
1167
 	return
1165
 	return
1168
 }
1166
 }
1169
 
1167
 
1170
-func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endtime int64, orgID int64, zone []string, record_date int64) (schedules []*models.WeekScheduleSix, err error) {
1168
+func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endtime int64, orgID int64, zone []string, record_date int64, ids []string) (schedules []*models.WeekScheduleSix, err error) {
1171
 
1169
 
1172
 	db := XTReadDB().Table("xt_schedule as s ").Where("s.status =1")
1170
 	db := XTReadDB().Table("xt_schedule as s ").Where("s.status =1")
1173
 	if orgID > 0 {
1171
 	if orgID > 0 {
1197
 	if len(zone) > 0 {
1195
 	if len(zone) > 0 {
1198
 		db = db.Where("s.partition_id in (?)", zone)
1196
 		db = db.Where("s.partition_id in (?)", zone)
1199
 	}
1197
 	}
1198
+	if len(ids) > 0 {
1199
+		db = db.Where("s.patient_id in (?)", ids)
1200
+	}
1200
 	err = db.
1201
 	err = db.
1201
 		Preload("DeviceZone", "status = 1 ").
1202
 		Preload("DeviceZone", "status = 1 ").
1202
 		Preload("DeviceNumber", "status = 1 ").Joins("JOIN xt_patients as p ON p.id = s.patient_id").
1203
 		Preload("DeviceNumber", "status = 1 ").Joins("JOIN xt_patients as p ON p.id = s.patient_id").
1365
 func GetNextWeekPanels(startime int64, endtime int64, orgid int64) (schedule []*models.XtSchedule, err error) {
1366
 func GetNextWeekPanels(startime int64, endtime int64, orgid int64) (schedule []*models.XtSchedule, err error) {
1366
 
1367
 
1367
 	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 {
1368
 	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 {
1368
-		return db.Where("user_org_id = ? and status = 1 and  assessment_date>=1672502400  and assessment_date < ?", orgid, endtime)
1369
+		return db.Where("user_org_id = ? and status = 1 and  assessment_date>=1704038400  and assessment_date < ?", orgid, endtime)
1369
 	}).Find(&schedule).Error
1370
 	}).Find(&schedule).Error
1370
 	return schedule, err
1371
 	return schedule, err
1371
 }
1372
 }
1514
 	return adviceInfo, err
1515
 	return adviceInfo, err
1515
 }
1516
 }
1516
 
1517
 
1517
-func GetLastDialysisSolution(org_id int64, patient_id int64, mode_id int64, schedule_date int64) (models.NewDialysisPrescription, error) {
1518
+func GetDoctorAdviceListSchedule(org_id int64, patient_id int64) (advices []*models.DoctorAdvice, err error) {
1519
+
1520
+	err = XTReadDB().Where("patient_id=? and user_org_id = ?  and status=1 and parent_id=0 and advice_type =1", patient_id, org_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advices).Error
1521
+	return advices, err
1522
+}
1523
+
1524
+func GetLastDialysisPrescriptionTwo(org_id int64, patient_id int64, mode_id int64, schedule_date int64) (models.NewDialysisPrescription, error) {
1518
 
1525
 
1519
 	dialysisprescription := models.NewDialysisPrescription{}
1526
 	dialysisprescription := models.NewDialysisPrescription{}
1520
-	err := XTReadDB().Where("user_org_id = ? and patient_id = ? and mode_id = ? and status = 1 and record_date>=1672502400 and record_date<?", org_id, patient_id, mode_id, schedule_date).Order("id desc").First(&dialysisprescription).Error
1527
+	err := XTReadDB().Where("user_org_id = ? and patient_id = ? and mode_id = ? and status = 1 and record_date>=1704038400 and record_date<?", org_id, patient_id, mode_id, schedule_date).Order("id desc").First(&dialysisprescription).Error
1521
 	return dialysisprescription, err
1528
 	return dialysisprescription, err
1522
 
1529
 
1523
 }
1530
 }
1524
 
1531
 
1532
+func GetLastDialysisSolution(org_id int64, patient_id int64, mode_id int64) (models.DialysisSolution, error) {
1533
+	dialysisSolution := models.DialysisSolution{}
1534
+	err := XTReadDB().Where("user_org_id =? and patient_id = ? and mode_id = ? and status=1 and solution_status=1", org_id, patient_id, mode_id).Find(&dialysisSolution).Error
1535
+	return dialysisSolution, err
1536
+}
1537
+
1538
+func GetLastDialysisAfter(org_id int64, patient_id int64, schedule_date int64) (models.AssessmentAfterDislysis, error) {
1539
+
1540
+	dislysis := models.AssessmentAfterDislysis{}
1541
+	err := XTReadDB().Where("user_org_id = ? and patient_id =? and assessment_date <= ? and status=1", org_id, patient_id, schedule_date).Order("id desc").Last(&dislysis).Error
1542
+	return dislysis, err
1543
+}
1544
+
1525
 func GetDoctorAdviceLastWeek(org_id int64, patient_id int64, schedule_date int64) (advice []*models.DoctorAdvice, err error) {
1545
 func GetDoctorAdviceLastWeek(org_id int64, patient_id int64, schedule_date int64) (advice []*models.DoctorAdvice, err error) {
1526
 
1546
 
1527
 	err = XTReadDB().Where("user_org_id = ? and patient_id = ? and status= 1 and parent_id = 0 and advice_date = ?", org_id, patient_id, schedule_date).Preload("ChildDoctorAdvice", "status = 1 and advice_date = ?", schedule_date).Find(&advice).Error
1547
 	err = XTReadDB().Where("user_org_id = ? and patient_id = ? and status= 1 and parent_id = 0 and advice_date = ?", org_id, patient_id, schedule_date).Preload("ChildDoctorAdvice", "status = 1 and advice_date = ?", schedule_date).Find(&advice).Error
1543
 	return solution, err
1563
 	return solution, err
1544
 }
1564
 }
1545
 
1565
 
1546
-func GetNextWeekDayScheduleSix(weektype int64, weektime int64, startime int64, endtime int64, orgID int64, zone []string, record_date int64) (schedules []*models.WeekScheduleSeven, err error) {
1566
+func GetNextWeekDayScheduleSix(weektype int64, weektime int64, startime int64, endtime int64, orgID int64, zone []string, record_date int64, ids []string) (schedules []*models.WeekScheduleSeven, err error) {
1547
 
1567
 
1548
 	db := XTReadDB().Table("xt_schedule as s ").Where("s.status =1")
1568
 	db := XTReadDB().Table("xt_schedule as s ").Where("s.status =1")
1549
 	if orgID > 0 {
1569
 	if orgID > 0 {
1574
 	if len(zone) > 0 {
1594
 	if len(zone) > 0 {
1575
 		db = db.Where("s.partition_id in (?)", zone)
1595
 		db = db.Where("s.partition_id in (?)", zone)
1576
 	}
1596
 	}
1597
+	if len(ids) > 0 {
1598
+		db = db.Where("s.patient_id in(?)", ids)
1599
+	}
1577
 	err = db.
1600
 	err = db.
1578
 		Preload("DeviceZone", "status = 1 ").
1601
 		Preload("DeviceZone", "status = 1 ").
1579
 		Preload("DeviceNumber", "status = 1 ").
1602
 		Preload("DeviceNumber", "status = 1 ").

+ 72 - 0
service/self_drug_service.go View File

3214
 	err = db.Find(&list).Error
3214
 	err = db.Find(&list).Error
3215
 	return list, err
3215
 	return list, err
3216
 }
3216
 }
3217
+
3218
+func GetHisAdviceGroupList(drug_id int64, user_org_id int64) (advicelist []*models.HisDoctorAdviceInfo, err error) {
3219
+
3220
+	if user_org_id == 10265 {
3221
+		err = XTReadDB().Where("drug_id = ? and user_org_id = ? and status=1 and execution_state =1", drug_id, user_org_id).Order("advice_date asc").Find(&advicelist).Error
3222
+
3223
+		return advicelist, err
3224
+	} else {
3225
+		err = XTReadDB().Where("drug_id = ? and user_org_id = ? and status=1", drug_id, user_org_id).Order("advice_date asc").Find(&advicelist).Error
3226
+
3227
+		return advicelist, err
3228
+	}
3229
+
3230
+}
3231
+
3232
+func GetDrugWarehousOutInfo(drug_id int64, org_id int64) (out []*models.XtDrugWarehouseOutInfo, err error) {
3233
+
3234
+	err = XTReadDB().Where("drug_id = ? and status=1 and org_id=? and is_sys=1", drug_id, org_id).Order("sys_record_time asc").Find(&out).Error
3235
+	return out, err
3236
+}
3237
+
3238
+func GetDrugWarehousOutInfoOne(drug_id int64, org_id int64) (out []*models.XtDrugWarehouseOutInfo, err error) {
3239
+
3240
+	err = XTReadDB().Where("drug_id = ? and status=1 and org_id=? and is_sys=0", drug_id, org_id).Order("sys_record_time asc").Find(&out).Error
3241
+	return out, err
3242
+}
3243
+
3244
+func GetCheckDrugFlow(drug_id int64, user_org_id int64) (drugflow []*models.DrugFlow, err error) {
3245
+
3246
+	err = XTReadDB().Where("drug_id =? and status=1 and (consumable_type =10 or consumable_type =11) and user_org_id = ?", drug_id, user_org_id).Order("system_time asc").Find(&drugflow).Error
3247
+	return drugflow, err
3248
+}
3249
+
3250
+func GetCheckGoodBatchList(good_id int64, user_org_id int64) (project []*models.HisPrescriptionProject, err error) {
3251
+
3252
+	err = XTReadDB().Where("project_id = ? and user_org_id = ? and status =1 and type =3", good_id, user_org_id).Order("record_date asc").Find(&project).Error
3253
+
3254
+	return project, err
3255
+}
3256
+
3257
+func GetCheckGoodWarehouseList(good_id int64, org_id int64) (info []*models.WarehouseOutInfo, err error) {
3258
+
3259
+	err = XTReadDB().Where("good_id = ? and org_id = ? and status=1 and is_sys=0", good_id, org_id).Order("sys_record_time").Find(&info).Error
3260
+	return info, err
3261
+}
3262
+
3263
+func GetHisAdviceListBySysRrecordTime(drug_id int64, sys_record_time int64, user_org_id int64) (info []*models.HisDoctorAdviceInfo, err error) {
3264
+
3265
+	err = XTReadDB().Where("drug_id=? and advice_date = ? and user_org_id = ? and status =1", drug_id, sys_record_time, user_org_id).Find(&info).Error
3266
+
3267
+	return info, err
3268
+}
3269
+
3270
+func GetDrugWarehouseOutInfoBySysRecordTime(drug_id int64, sys_record_time int64, user_org_id int64) (info []*models.DrugWarehouseOutInfo, err error) {
3271
+
3272
+	err = XTReadDB().Where("drug_id=? and sys_record_time =? and org_id = ? and status =1", drug_id, sys_record_time, user_org_id).Find(&info).Error
3273
+
3274
+	return info, err
3275
+}
3276
+
3277
+func GetGoodProjectList(good_id int64, sys_record_time int64, user_org_id int64) (project []*models.HisPrescriptionProject, err error) {
3278
+
3279
+	err = XTReadDB().Where("project_id = ? and status =1 and record_date = ? and user_org_id=? and type =3", good_id, sys_record_time, user_org_id).Find(&project).Error
3280
+
3281
+	return project, err
3282
+}
3283
+
3284
+func GetWarehouseOutListBySysrecordTime(good_id int64, sys_record_time int64, user_org_id int64) (out []*models.WarehouseOutInfo, err error) {
3285
+
3286
+	err = XTReadDB().Where("good_id = ? and sys_record_time =? and org_id = ? and status=1 and is_sys=1", good_id, sys_record_time, user_org_id).Find(&out).Error
3287
+	return out, err
3288
+}

+ 3 - 2
service/smart_sch.go View File

1
 package service
1
 package service
2
 
2
 
3
 import (
3
 import (
4
+	"time"
5
+
4
 	"XT_New/models"
6
 	"XT_New/models"
5
 	"github.com/jinzhu/gorm"
7
 	"github.com/jinzhu/gorm"
6
-	"time"
7
 )
8
 )
8
 
9
 
9
 func GetSmartSchPatientByKeyWord(orgID int64, keywords string) (patient []*models.SmartSchPatient, err error) {
10
 func GetSmartSchPatientByKeyWord(orgID int64, keywords string) (patient []*models.SmartSchPatient, err error) {
56
 }
57
 }
57
 
58
 
58
 func GetSmartSchTemplatePatientByKeyWord(orgID int64, keywords string) (patient []*models.SmartSchTemplatePatient, err error) {
59
 func GetSmartSchTemplatePatientByKeyWord(orgID int64, keywords string) (patient []*models.SmartSchTemplatePatient, err error) {
59
-	db := readDb.Model(&models.SmartSchTemplatePatient{}).Where("user_org_id=? and status=1", orgID)
60
+	db := readDb.Model(&models.SmartSchTemplatePatient{}).Where("user_org_id=? and status=1 and lapseto=1", orgID)
60
 	if len(keywords) > 0 {
61
 	if len(keywords) > 0 {
61
 		likekey := "%" + keywords + "%"
62
 		likekey := "%" + keywords + "%"
62
 		err = db.Where("name LIKE ? OR dialysis_no LIKE ? ", likekey, likekey).Find(&patient).Error
63
 		err = db.Where("name LIKE ? OR dialysis_no LIKE ? ", likekey, likekey).Find(&patient).Error

+ 14 - 6
service/stock_service.go View File

878
 
878
 
879
 func FindNewLastDrugWarehousingInfoByID(drug_id int64, storehouse_id int64, tx *gorm.DB) (info models.XtDrugWarehouseInfo, err error) {
879
 func FindNewLastDrugWarehousingInfoByID(drug_id int64, storehouse_id int64, tx *gorm.DB) (info models.XtDrugWarehouseInfo, err error) {
880
 	err = tx.Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ? AND status = 1 AND (stock_max_number > 0 or stock_min_number > 0) and storehouse_id = ? and is_check = 1", drug_id, storehouse_id).Order("ctime").First(&info).Error
880
 	err = tx.Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ? AND status = 1 AND (stock_max_number > 0 or stock_min_number > 0) and storehouse_id = ? and is_check = 1", drug_id, storehouse_id).Order("ctime").First(&info).Error
881
-	if err != nil {
882
-		tx.Rollback()
883
-		return info, err
881
+	if err != gorm.ErrRecordNotFound {
882
+		if err != nil {
883
+			tx.Rollback()
884
+			return info, err
885
+		}
884
 	}
886
 	}
887
+
885
 	return info, err
888
 	return info, err
886
 }
889
 }
887
 
890
 
2023
 func GetNewManufactureById(id int64, tx *gorm.DB) (models.Manufacturer, error) {
2026
 func GetNewManufactureById(id int64, tx *gorm.DB) (models.Manufacturer, error) {
2024
 	manufacturer := models.Manufacturer{}
2027
 	manufacturer := models.Manufacturer{}
2025
 	err := tx.Model(&manufacturer).Where("id = ? and status = 1", id).Find(&manufacturer).Error
2028
 	err := tx.Model(&manufacturer).Where("id = ? and status = 1", id).Find(&manufacturer).Error
2026
-	if err != nil {
2027
-		tx.Rollback()
2028
-		return manufacturer, err
2029
+	if err != gorm.ErrRecordNotFound {
2030
+		if err != nil {
2031
+			tx.Rollback()
2032
+			return manufacturer, err
2033
+		}
2029
 	}
2034
 	}
2035
+
2030
 	return manufacturer, err
2036
 	return manufacturer, err
2031
 }
2037
 }
2032
 
2038
 
2740
 
2746
 
2741
 func UpDateNewDrugWarehouseInfoByStock(info *models.XtDrugWarehouseInfo, tx *gorm.DB) (err error) {
2747
 func UpDateNewDrugWarehouseInfoByStock(info *models.XtDrugWarehouseInfo, tx *gorm.DB) (err error) {
2742
 	err = tx.Save(&info).Error
2748
 	err = tx.Save(&info).Error
2749
+
2743
 	if err != nil {
2750
 	if err != nil {
2744
 		tx.Rollback()
2751
 		tx.Rollback()
2745
 		return err
2752
 		return err
8912
 	err := tx.Where("good_id = ? and sys_record_time = ? and status = 1 and patient_id = ? and project_id = ? and warehouse_info_id = ?", good_id, record_time, patient_id, project_id, warehouse_info_id).Find(&info).Error
8919
 	err := tx.Where("good_id = ? and sys_record_time = ? and status = 1 and patient_id = ? and project_id = ? and warehouse_info_id = ?", good_id, record_time, patient_id, project_id, warehouse_info_id).Find(&info).Error
8913
 	if err != gorm.ErrRecordNotFound {
8920
 	if err != gorm.ErrRecordNotFound {
8914
 		if err != nil {
8921
 		if err != nil {
8922
+			tx.Rollback()
8915
 			return info, err
8923
 			return info, err
8916
 		}
8924
 		}
8917
 	}
8925
 	}

+ 9 - 7
service/warhouse_service.go View File

1
 package service
1
 package service
2
 
2
 
3
 import (
3
 import (
4
-	"XT_New/models"
5
-	"XT_New/utils"
6
 	"errors"
4
 	"errors"
7
 	"fmt"
5
 	"fmt"
8
 	_ "fmt"
6
 	_ "fmt"
9
-	"github.com/jinzhu/gorm"
10
 	"math"
7
 	"math"
11
 	"strconv"
8
 	"strconv"
12
 	"strings"
9
 	"strings"
13
 	"time"
10
 	"time"
11
+
12
+	"XT_New/models"
13
+	"XT_New/utils"
14
+	"github.com/jinzhu/gorm"
14
 )
15
 )
15
 
16
 
16
 // 药品出库
17
 // 药品出库
6022
 		CreateDrugFlowOne(drugflow)
6023
 		CreateDrugFlowOne(drugflow)
6023
 
6024
 
6024
 		//更新出库id
6025
 		//更新出库id
6025
-		UpdateDrugWarehouseOutInfo(advice.ID, warehouse.ID, advice.OrgId, over_count)
6026
+		UpdateDrugWarehouseOutInfo(advice.ID, warehouse.ID, advice.OrgId, over_count, drug_price)
6026
 
6027
 
6027
 		return nil
6028
 		return nil
6028
 
6029
 
6089
 
6090
 
6090
 		CreateDrugFlowOne(drugflow)
6091
 		CreateDrugFlowOne(drugflow)
6091
 		//更新出库id
6092
 		//更新出库id
6092
-		UpdateDrugWarehouseOutInfo(advice.ID, warehouse.ID, advice.OrgId, over_count)
6093
+		UpdateDrugWarehouseOutInfo(advice.ID, warehouse.ID, advice.OrgId, over_count, drug_price)
6093
 		// 出库完成后,要将该批次库存清零
6094
 		// 出库完成后,要将该批次库存清零
6094
 
6095
 
6095
 		prescribingNumber_two_temp := deliver_number - stock_number
6096
 		prescribingNumber_two_temp := deliver_number - stock_number
6102
 	return
6103
 	return
6103
 }
6104
 }
6104
 
6105
 
6105
-func UpdateDrugWarehouseOutInfo(id int64, warehouse_info_id int64, org_id int64, over_count int64) error {
6106
+func UpdateDrugWarehouseOutInfo(id int64, warehouse_info_id int64, org_id int64, over_count int64, drug_price float64) error {
6106
 	ut := XTWriteDB().Begin()
6107
 	ut := XTWriteDB().Begin()
6107
-	err = ut.Model(&models.DrugWarehouseOutInfo{}).Where("id = ? and org_id = ? and status = 1", id, org_id).Update(map[string]interface{}{"warehouse_info_id": warehouse_info_id, "over_count": over_count}).Error
6108
+	err = ut.Model(&models.DrugWarehouseOutInfo{}).Where("id = ? and org_id = ? and status = 1", id, org_id).Update(map[string]interface{}{"warehouse_info_id": warehouse_info_id, "over_count": over_count, "price": drug_price, "retail_price": drug_price}).Error
6108
 	if err != nil {
6109
 	if err != nil {
6109
 		ut.Rollback()
6110
 		ut.Rollback()
6110
 		return err
6111
 		return err
6194
 func FindNewLastDrugWarehouseOutInfo(orgid int64, tx *gorm.DB) (models.DrugWarehouseOutInfo, error) {
6195
 func FindNewLastDrugWarehouseOutInfo(orgid int64, tx *gorm.DB) (models.DrugWarehouseOutInfo, error) {
6195
 	info := models.DrugWarehouseOutInfo{}
6196
 	info := models.DrugWarehouseOutInfo{}
6196
 	err := tx.Where("org_id = ? and status = 1", orgid).Last(&info).Error
6197
 	err := tx.Where("org_id = ? and status = 1", orgid).Last(&info).Error
6198
+
6197
 	if err != gorm.ErrRecordNotFound {
6199
 	if err != gorm.ErrRecordNotFound {
6198
 		if err != nil {
6200
 		if err != nil {
6199
 			tx.Rollback()
6201
 			tx.Rollback()