Browse Source

历史排班

28169 1 year ago
parent
commit
4eb9de4006

+ 106 - 41
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -5260,9 +5260,12 @@ func (c *DialysisAPIController) CreateRemindDoctorAdvice() {
5260 5260
 	for _, adviceNameMap := range adviceNames {
5261 5261
 		adviceNameM := adviceNameMap.(map[string]interface{})
5262 5262
 		var advice models.GroupAdvice
5263
+
5263 5264
 		advice.Remark = Remark
5264 5265
 		advice.AdviceType = adviceType
5266
+
5265 5267
 		advice.StartTime = StartTime
5268
+
5266 5269
 		advice.AdviceDate = AdviceDate
5267 5270
 
5268 5271
 		advice.RecordDate = RecordDate
@@ -5372,6 +5375,11 @@ func (c *DialysisAPIController) CreateRemindDoctorAdvice() {
5372 5375
 			advice.DrugNameId = drug_name_id
5373 5376
 		}
5374 5377
 
5378
+		if adviceNameM["groupno"] != nil || reflect.TypeOf(adviceNameM["groupno"]).String() == "float64" {
5379
+			groupno := int64(adviceNameM["groupno"].(float64))
5380
+			advice.GroupNo = groupno
5381
+		}
5382
+
5375 5383
 		if adviceNameM["template_id"] != nil && reflect.TypeOf(adviceNameM["template_id"]).String() == "string" {
5376 5384
 			template_id, _ := adviceNameM["template_id"].(string)
5377 5385
 			advice.TemplateId = template_id
@@ -5448,6 +5456,11 @@ func (c *DialysisAPIController) CreateRemindDoctorAdvice() {
5448 5456
 						child.PrescribingNumberUnit = childPrescribingNumberUnit
5449 5457
 					}
5450 5458
 
5459
+					if childMap["groupno"] != nil || reflect.TypeOf(childMap["groupno"]).String() == "float64" {
5460
+						groupno := int64(childMap["groupno"].(float64))
5461
+						advice.GroupNo = groupno
5462
+					}
5463
+
5451 5464
 					child.DeliveryWay = advice.DeliveryWay
5452 5465
 					child.ExecutionFrequency = advice.ExecutionFrequency
5453 5466
 					advice.Children = append(advice.Children, &child)
@@ -5475,51 +5488,92 @@ func (c *DialysisAPIController) CreateRemindDoctorAdvice() {
5475 5488
 			PatientId:  patient,
5476 5489
 		}
5477 5490
 
5478
-		dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.Org.Id, AdviceDate, 4, patient)
5491
+		dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.Org.Id, AdviceDate, 4, patient)
5479 5492
 		if dialysisFinish.ID == 0 {
5480 5493
 			service.CreateDialysisFinish(finish)
5481 5494
 		}
5482 5495
 
5483
-		list, err := service.CreateMGroupAdvice(adminUserInfo.Org.Id, advices, groupNo)
5496
+		if adminUserInfo.Org.Id == 10597 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10164 {
5497
+			list, err := service.CreateMGroupAdviceOne(adminUserInfo.Org.Id, advices, groupNo)
5498
+			for _, item := range advices {
5499
+				byterequest, _ := json.Marshal(item)
5500
+				adviceLog := models.XtDoctorAdviceLog{
5501
+					UserOrgId:   adminUserInfo.Org.Id,
5502
+					PatientId:   patient,
5503
+					AdminUserId: adminUserInfo.AdminUser.Id,
5504
+					Module:      1,
5505
+					ErrLog:      string(byterequest),
5506
+					Status:      1,
5507
+					Ctime:       time.Now().Unix(),
5508
+					Mtime:       0,
5509
+					Source:      "手机端医嘱推送",
5510
+					RecordDate:  item.AdviceDate,
5511
+				}
5484 5512
 
5485
-		for _, item := range advices {
5486
-			byterequest, _ := json.Marshal(item)
5487
-			adviceLog := models.XtDoctorAdviceLog{
5488
-				UserOrgId:   adminUserInfo.Org.Id,
5489
-				PatientId:   patient,
5490
-				AdminUserId: adminUserInfo.AdminUser.Id,
5491
-				Module:      1,
5492
-				ErrLog:      string(byterequest),
5493
-				Status:      1,
5494
-				Ctime:       time.Now().Unix(),
5495
-				Mtime:       0,
5496
-				Source:      "手机端医嘱推送",
5497
-				RecordDate:  item.AdviceDate,
5513
+				service.CreateDoctorAdviceLog(adviceLog)
5498 5514
 			}
5499 5515
 
5500
-			service.CreateDoctorAdviceLog(adviceLog)
5501
-		}
5516
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(RecordDate, 10) + ":doctor_advices"
5517
+			redis := service.RedisClient()
5518
+			//清空key 值
5519
+			redis.Set(key, "", time.Second)
5502 5520
 
5503
-		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(RecordDate, 10) + ":doctor_advices"
5504
-		redis := service.RedisClient()
5505
-		//清空key 值
5506
-		redis.Set(key, "", time.Second)
5521
+			keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":advice_list_all"
5522
+			redis.Set(keyOne, "", time.Second)
5507 5523
 
5508
-		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":advice_list_all"
5509
-		redis.Set(keyOne, "", time.Second)
5524
+			keyThree := "scheduals_" + adviceDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
5525
+			defer redis.Close()
5526
+			redis.Set(keyThree, "", time.Second)
5527
+			if err != nil {
5528
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
5529
+				return
5530
+			}
5510 5531
 
5511
-		keyThree := "scheduals_" + adviceDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
5512
-		defer redis.Close()
5513
-		redis.Set(keyThree, "", time.Second)
5514
-		if err != nil {
5515
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
5516
-			return
5517
-		}
5532
+			c.ServeSuccessJSON(map[string]interface{}{
5533
+				"msg":     "ok",
5534
+				"advices": list,
5535
+			})
5536
+		} else {
5537
+			list, err := service.CreateMGroupAdvice(adminUserInfo.Org.Id, advices, groupNo)
5538
+			for _, item := range advices {
5539
+				byterequest, _ := json.Marshal(item)
5540
+				adviceLog := models.XtDoctorAdviceLog{
5541
+					UserOrgId:   adminUserInfo.Org.Id,
5542
+					PatientId:   patient,
5543
+					AdminUserId: adminUserInfo.AdminUser.Id,
5544
+					Module:      1,
5545
+					ErrLog:      string(byterequest),
5546
+					Status:      1,
5547
+					Ctime:       time.Now().Unix(),
5548
+					Mtime:       0,
5549
+					Source:      "手机端医嘱推送",
5550
+					RecordDate:  item.AdviceDate,
5551
+				}
5518 5552
 
5519
-		c.ServeSuccessJSON(map[string]interface{}{
5520
-			"msg":     "ok",
5521
-			"advices": list,
5522
-		})
5553
+				service.CreateDoctorAdviceLog(adviceLog)
5554
+			}
5555
+
5556
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(RecordDate, 10) + ":doctor_advices"
5557
+			redis := service.RedisClient()
5558
+			//清空key 值
5559
+			redis.Set(key, "", time.Second)
5560
+
5561
+			keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":advice_list_all"
5562
+			redis.Set(keyOne, "", time.Second)
5563
+
5564
+			keyThree := "scheduals_" + adviceDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
5565
+			defer redis.Close()
5566
+			redis.Set(keyThree, "", time.Second)
5567
+			if err != nil {
5568
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
5569
+				return
5570
+			}
5571
+
5572
+			c.ServeSuccessJSON(map[string]interface{}{
5573
+				"msg":     "ok",
5574
+				"advices": list,
5575
+			})
5576
+		}
5523 5577
 
5524 5578
 	} else {
5525 5579
 		c.ServeSuccessJSON(map[string]interface{}{
@@ -8157,12 +8211,9 @@ func (c *DialysisAPIController) GetPatientDialysisRecordList() {
8157 8211
 
8158 8212
 	end_time := c.GetString("end_time")
8159 8213
 
8160
-	fmt.Println("start_timeo2o2o2o2o2o", start_time)
8161
-	fmt.Println("end_Time2o2o2o2ooo22", end_time)
8162 8214
 	var startdateunix int64
8163 8215
 	if len(start_time) > 0 {
8164 8216
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
8165
-		fmt.Println("theTim3333333333333333333333e", theTime)
8166 8217
 		if err != nil {
8167 8218
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8168 8219
 			return
@@ -8190,20 +8241,34 @@ func (c *DialysisAPIController) GetPatientDialysisRecordList() {
8190 8241
 
8191 8242
 	org_id := c.GetMobileAdminUserInfo().Org.Id
8192 8243
 
8193
-	if org_id == 10579 {
8194
-		list, _ := service.GetPatientDialysisRecordListOne(id, startdateunix, enddateunix)
8244
+	//if org_id == 10579 {
8245
+	//	list, _ := service.GetPatientDialysisRecordListOne(id, startdateunix, enddateunix)
8246
+	//	c.ServeSuccessJSON(map[string]interface{}{
8247
+	//		"list": list,
8248
+	//	})
8249
+	//	return
8250
+	//} else {
8251
+	//	list, _ := service.GetPatientDialysisRecordList(id, startdateunix, enddateunix)
8252
+	//	c.ServeSuccessJSON(map[string]interface{}{
8253
+	//		"list": list,
8254
+	//	})
8255
+	//	return
8256
+	//}
8257
+	if org_id == 9538 || org_id == 10101 {
8258
+		list, _ := service.GetPatientDialysisRecordList(id, startdateunix, enddateunix)
8195 8259
 		c.ServeSuccessJSON(map[string]interface{}{
8196 8260
 			"list": list,
8197 8261
 		})
8198 8262
 		return
8199 8263
 	} else {
8200
-		list, _ := service.GetPatientDialysisRecordList(id, startdateunix, enddateunix)
8264
+		list, _ := service.GetPatientDialysisRecordListOne(id, startdateunix, enddateunix)
8201 8265
 		c.ServeSuccessJSON(map[string]interface{}{
8202 8266
 			"list": list,
8203 8267
 		})
8204
-		return
8205 8268
 	}
8206 8269
 
8270
+	return
8271
+
8207 8272
 }
8208 8273
 
8209 8274
 func (c *DialysisAPIController) BathDeleteAdviceList() {

+ 29 - 1
controllers/sign_api_controller.go View File

@@ -91,6 +91,9 @@ func SignApiRegistRouters() {
91 91
 
92 92
 	beego.Router("/api/device/toautodiagnose", &SignApiController{}, "Get:ToAutoDiagnose")
93 93
 
94
+	//加油
95
+	beego.Router("/api/device/toautojiayou", &SignApiController{}, "Get:ToAutoJiaYou")
96
+
94 97
 }
95 98
 
96 99
 // 短信服务接口
@@ -662,7 +665,7 @@ func (this *SignApiController) GetEnterPriseDetail() {
662 665
 
663 666
 func (this *SignApiController) UploadPrintOrder() {
664 667
 
665
-	list, _ := service.GetAllPatientNew(10567)
668
+	list, _ := service.GetAllPatientNew(10440)
666 669
 	for _, item := range list {
667 670
 
668 671
 		hans := item.Name // 要转换的汉字字符串
@@ -1228,3 +1231,28 @@ func (this *SignApiController) ToAutoDiagnose() {
1228 1231
 	//})
1229 1232
 
1230 1233
 }
1234
+
1235
+func (this *SignApiController) ToAutoJiaYou() {
1236
+
1237
+	list, _ := service.GetPrescriptionListOne(10579)
1238
+
1239
+	for _, item := range list {
1240
+
1241
+		schedule, _ := service.GetPatientScheduleById(item.PatientId, item.RecordDate)
1242
+		var DialysisMachineName string
1243
+		if len(item.DialysisDialyszers) > 0 {
1244
+			DialysisMachineName = item.DialysisDialyszers
1245
+		}
1246
+
1247
+		if len(item.DialysisIrrigation) > 0 {
1248
+			DialysisMachineName = DialysisMachineName + "," + item.DialysisIrrigation
1249
+		}
1250
+
1251
+		if len(item.DialysisStrainer) > 0 {
1252
+			DialysisMachineName = DialysisMachineName + "," + item.DialysisStrainer
1253
+		}
1254
+		DialysisMachineName = DialysisMachineName
1255
+
1256
+		service.UpdateDialysisScheduleOne(schedule.ID, item.ModeId, DialysisMachineName)
1257
+	}
1258
+}

+ 1 - 0
models/dialysis_parameter_models.go View File

@@ -136,6 +136,7 @@ type DialysisPrescriptionParameter struct {
136 136
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
137 137
 	DialysisDialyszers         string  `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
138 138
 	DialysisIrrigation         string  `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
139
+	DialysisStrainer           string  `gorm:"column:dialysis_strainer" json:"dialysis_strainer" form:"dialysis_strainer"`
139 140
 }
140 141
 
141 142
 func (DialysisPrescriptionParameter) TableName() string {

+ 13 - 11
models/patient_models.go View File

@@ -1632,6 +1632,7 @@ type VmDialysisSolution struct {
1632 1632
 	ModeId                     int64                 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1633 1633
 	Anticoagulant              int64                 `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
1634 1634
 	DialysisSolution           VmDialysisSolutionOne `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"solution"`
1635
+	SolutionStatus             int64                 `gorm:"column:solution_status" json:"solution_status" form:"solution_status"`
1635 1636
 }
1636 1637
 
1637 1638
 func (VmDialysisSolution) TableName() string {
@@ -1670,17 +1671,18 @@ func (VmDialysisPrescription) TableName() string {
1670 1671
 }
1671 1672
 
1672 1673
 type XtScheduleList struct {
1673
-	UserOrgId        int64              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1674
-	PartitionId      int64              `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1675
-	BedId            int64              `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1676
-	PatientId        int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1677
-	ScheduleDate     int64              `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1678
-	ScheduleType     int64              `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1679
-	ScheduleWeek     int64              `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1680
-	ModeId           int64              `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1681
-	IsExport         int64              `gorm:"column:is_export" json:"is_export" form:"is_export"`
1682
-	DialysisSolution VmDialysisSolution `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"vmsolution"`
1683
-	Status           int64              `gorm:"column:status" json:"status" form:"status"`
1674
+	UserOrgId            int64                `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1675
+	PartitionId          int64                `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1676
+	BedId                int64                `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1677
+	PatientId            int64                `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1678
+	ScheduleDate         int64                `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1679
+	ScheduleType         int64                `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1680
+	ScheduleWeek         int64                `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1681
+	ModeId               int64                `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1682
+	IsExport             int64                `gorm:"column:is_export" json:"is_export" form:"is_export"`
1683
+	DialysisSolution     VmDialysisSolution   `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"vmsolution"`
1684
+	DialysisPrescription DialysisPrescription `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"prescription"`
1685
+	Status               int64                `gorm:"column:status" json:"status" form:"status"`
1684 1686
 }
1685 1687
 
1686 1688
 func (XtScheduleList) TableName() string {

+ 1 - 0
models/schedule_models.go View File

@@ -392,6 +392,7 @@ type VmBloodSchedule struct {
392 392
 	ReceiveTreatmentAsses      ReceiveTreatmentAsses      `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"xt_receive_treatment_asses"`
393 393
 	XtAssessmentAfterDislysis  XtAssessmentAfterDislysis  `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate" json:"xt_assesment_after_dislysis"`
394 394
 	LastAfterWeight            AssessmentAfterDislysis    `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
395
+	DialysisMachineName        string                     `gorm:"column:dialysis_machine_name" json:"dialysis_machine_name" form:"dialysis_machine_name"`
395 396
 }
396 397
 
397 398
 func (VmBloodSchedule) TableName() string {

+ 1 - 1
service/gobal_config_service.go View File

@@ -519,7 +519,7 @@ func GetMobileScheduleListOne(start_time int64, end_time int64, org_id int64) (s
519 519
 	if end_time > 0 {
520 520
 		db = db.Where("schedule_date<=?", end_time)
521 521
 	}
522
-	err = db.Preload("DialysisSolution", "status=1 and user_org_id =?", org_id).Find(&schedulelist).Error
522
+	err = db.Preload("DialysisSolution", "status=1 and user_org_id =? and solution_status =1", org_id).Preload("DialysisPrescription", "status=1 and user_org_id =?", org_id).Find(&schedulelist).Error
523 523
 
524 524
 	return schedulelist, err
525 525
 

+ 1 - 0
service/mobile_dialysis_service.go View File

@@ -2340,6 +2340,7 @@ func MobileGetDialysisSolutionByModeId(orgID int64, patientID int64, mode_id int
2340 2340
 
2341 2341
 	// cur_date := time.Now().Format("2006-01-02")
2342 2342
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
2343
+
2343 2344
 	dialysis_solution_str, _ := redis.Get(key).Result()
2344 2345
 
2345 2346
 	if len(dialysis_solution_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis

+ 38 - 2
service/patient_service.go View File

@@ -79,11 +79,11 @@ func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bind
79 79
 
80 80
 	}
81 81
 	if lapseto != 2 && lapseto != 3 {
82
-		if orgID != 10579 {
82
+		if orgID != 10579 && orgID != 10600 {
83 83
 			err = db.Order("p.id desc").Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time,p.user_sys_before_count,p.out_reason,p.death_time,p.is_infectious").Group("p.id").Count(&total).Offset(offset).Limit(limit).Find(&patients).Error
84 84
 		}
85 85
 
86
-		if orgID == 10579 {
86
+		if orgID == 10579 || orgID == 10600 {
87 87
 			err = db.Order("p.dialysis_no asc").Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time,p.user_sys_before_count,p.out_reason,p.death_time,p.is_infectious").Group("p.id").Count(&total).Offset(offset).Limit(limit).Find(&patients).Error
88 88
 		}
89 89
 
@@ -1114,6 +1114,42 @@ func CreateMGroupAdvice(orgId int64, advices []*models.GroupAdvice, groupNo int6
1114 1114
 	return
1115 1115
 }
1116 1116
 
1117
+func CreateMGroupAdviceOne(orgId int64, advices []*models.GroupAdvice, groupNo int64) (list []*models.GroupAdvice, err error) {
1118
+	if groupNo <= 0 {
1119
+		group := GetMaxAdviceGroupID(orgId)
1120
+		groupNo = group + 1
1121
+	}
1122
+	tx := writeDb.Begin()
1123
+	defer func() {
1124
+		if r := recover(); r != nil {
1125
+			tx.Rollback()
1126
+		}
1127
+	}()
1128
+	for _, advice := range advices {
1129
+		advice.GroupNo = advice.GroupNo
1130
+		if err = tx.Create(advice).Error; err != nil {
1131
+			tx.Rollback()
1132
+			return
1133
+		}
1134
+		list = append(list, advice)
1135
+		if len(advice.Children) > 0 {
1136
+			for _, child := range advice.Children {
1137
+				child.GroupNo = child.GroupNo
1138
+				child.ParentId = advice.ID
1139
+				fmt.Println(child)
1140
+				if err = tx.Create(&child).Error; err != nil {
1141
+					tx.Rollback()
1142
+					return
1143
+				}
1144
+				list = append(list, child)
1145
+			}
1146
+		}
1147
+
1148
+	}
1149
+	tx.Commit()
1150
+	return
1151
+}
1152
+
1117 1153
 func UpdateDoctorAdvice(m *models.DoctorAdvice) (err error) {
1118 1154
 	return writeDb.Save(m).Error
1119 1155
 }

+ 22 - 1
service/sign_service.go View File

@@ -2099,7 +2099,7 @@ func UpdateSchPatient(patient_id int64, schedule_date int64, user_org_id int64,
2099 2099
 
2100 2100
 func GetNewAllpatient(org_id int64) (list []*models.XtPatientsNew, err error) {
2101 2101
 
2102
-	err = XTReadDB().Where("status =1 and user_org_id =9990").Find(&list).Error
2102
+	err = XTReadDB().Where("status =1 and user_org_id =10551").Find(&list).Error
2103 2103
 
2104 2104
 	return list, err
2105 2105
 }
@@ -2141,3 +2141,24 @@ func UpdateDialysisSchedule(id int64, dialysis_machine_name string) error {
2141 2141
 	err := XTWriteDB().Model(models.XtSchedule{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"dialysis_machine_name": dialysis_machine_name}).Error
2142 2142
 	return err
2143 2143
 }
2144
+
2145
+func GetPrescriptionListOne(user_org_id int64) (prescription []*models.DialysisPrescription, err error) {
2146
+
2147
+	err = XTReadDB().Model(&prescription).Where("user_org_id = ? and status= 1 and record_date =? and status=1", 10579, 1701360000).Find(&prescription).Error
2148
+	return prescription, err
2149
+}
2150
+
2151
+func GetPatientScheduleById(patient_id int64, schedule_date int64) (models.XtSchedule, error) {
2152
+
2153
+	schedule := models.XtSchedule{}
2154
+
2155
+	err := XTReadDB().Where("patient_id= ? and schedule_date = ? and status =1 and user_org_id =10579", patient_id, schedule_date).First(&schedule).Error
2156
+
2157
+	return schedule, err
2158
+}
2159
+
2160
+func UpdateDialysisScheduleOne(id int64, mode_id int64, dialysis_machine_name string) error {
2161
+
2162
+	err := XTWriteDB().Model(models.XtSchedule{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"dialysis_machine_name": dialysis_machine_name, "mode_id": mode_id}).Error
2163
+	return err
2164
+}