Browse Source

库存调拨修改

28169 2 years ago
parent
commit
6f0d19cc63

+ 153 - 7
controllers/dialysis_api_controller.go View File

@@ -324,6 +324,11 @@ func (c *DialysisApiController) PostPrescription() {
324 324
 	add_amount, _ := c.GetFloat("add_amount")
325 325
 	reduce_amount, _ := c.GetFloat("reduce_amount")
326 326
 	dialysis_remark := c.GetString("dialysis_remark")
327
+	prescribing_number, _ := c.GetFloat("prescribing_number")
328
+	treatment_remark := c.GetString("treatment_remark")
329
+	prescription_sodium := c.GetString("prescription_sodium")
330
+	start_sodium := c.GetString("start_sodium")
331
+	sodium_curve := c.GetString("sodium_curve")
327 332
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
328 333
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
329 334
 
@@ -432,25 +437,31 @@ func (c *DialysisApiController) PostPrescription() {
432 437
 		AddAmount:                  add_amount,
433 438
 		ReduceAmount:               reduce_amount,
434 439
 		DialysisRemark:             dialysis_remark,
440
+		PrescribingNumber:          prescribing_number,
441
+		TreatmentRemark:            treatment_remark,
442
+		PrescriptionSodium:         prescription_sodium,
443
+		StartSodium:                start_sodium,
444
+		SodiumCurve:                sodium_curve,
435 445
 	}
436 446
 
437 447
 	//长沙南雅医院,自动生成抗凝剂的临时处方
438
-	if adminUserInfo.CurrentOrgId == 10340 {
448
+	if adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 9671 {
439 449
 		advice := models.DoctorAdvice{
440 450
 			UserOrgId:             adminUserInfo.CurrentOrgId,
441 451
 			PatientId:             patient,
442 452
 			GroupNo:               0,
443 453
 			AdviceType:            2,
454
+			RecordDate:            recordDate.Unix(),
444 455
 			AdviceDate:            recordDate.Unix(),
445 456
 			StartTime:             recordDate.Unix() + 7*60*60, // 根据排班班次,给默认时间
446 457
 			AdviceName:            "",                          // 根据抗凝剂转换为中文 + 首剂 + 维持 + 总量
447 458
 			AdviceDesc:            "",
448 459
 			ReminderDate:          0,
449
-			SingleDose:            0,
450
-			SingleDoseUnit:        "",
460
+			SingleDose:            5000,
461
+			SingleDoseUnit:        "iu",
451 462
 			DrugSpec:              0,
452 463
 			DrugSpecUnit:          "",
453
-			PrescribingNumber:     0, // 前端传过来的开药数量
464
+			PrescribingNumber:     prescribing_number, // 前端传过来的开药数量
454 465
 			PrescribingNumberUnit: "支",
455 466
 			DeliveryWay:           "静脉注射",
456 467
 			ExecutionFrequency:    "上机前",
@@ -517,14 +528,27 @@ func (c *DialysisApiController) PostPrescription() {
517 528
 
518 529
 		// 患者的临时医嘱里查找是否有抗凝剂临时医嘱
519 530
 		advicePrescription, _ := service.GetAdvicesByPrescription(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
520
-		if advicePrescription.ID > 0 {
531
+		if advicePrescription.ID > 0 && (anticoagulant == 3 || anticoagulant == 6 || anticoagulant == 7) {
532
+			advice.AdviceName = "低分子肝素钠注射液"
521 533
 			// 修改患者临时医嘱里的抗凝剂医嘱
522 534
 			advice.ID = advicePrescription.ID
523 535
 			service.UpdateDoctorAdvice(&advice)
524 536
 		} else {
525
-			// 新增患者临时医嘱里的抗凝剂医嘱
526
-			service.CreateDoctorAdvice(&advice)
537
+			if anticoagulant == 3 || anticoagulant == 6 || anticoagulant == 7 {
538
+				advice.AdviceName = "低分子肝素钠注射液"
539
+				// 新增患者临时医嘱里的抗凝剂医嘱
540
+				service.CreateDoctorAdvice(&advice)
541
+			}
542
+
527 543
 		}
544
+
545
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":doctor_advices"
546
+		redis := service.RedisClient()
547
+		//清空key 值
548
+		redis.Set(key, "", time.Second)
549
+		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":advice_list_all"
550
+		redis.Set(keyOne, "", time.Second)
551
+
528 552
 	}
529 553
 
530 554
 	if appRole.UserType == 2 || appRole.UserType == 1 {
@@ -773,6 +797,11 @@ func (c *DialysisApiController) PostSoulution() {
773 797
 	add_amount, _ := c.GetFloat("add_amount")
774 798
 	reduce_amount, _ := c.GetFloat("reduce_amount")
775 799
 	dialysis_remark := c.GetString("dialysis_remark")
800
+	prescribing_number, _ := c.GetFloat("prescribing_number")
801
+	treatment_remark := c.GetString("treatment_remark")
802
+	prescription_sodium := c.GetString("prescription_sodium")
803
+	start_sodium := c.GetString("start_sodium")
804
+	sodium_curve := c.GetString("sodium_curve")
776 805
 	var prescription_doctor int64
777 806
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
778 807
 
@@ -901,6 +930,11 @@ func (c *DialysisApiController) PostSoulution() {
901 930
 		AddAmount:                  add_amount,
902 931
 		ReduceAmount:               reduce_amount,
903 932
 		DialysisRemark:             dialysis_remark,
933
+		PrescribingNumber:          prescribing_number,
934
+		StartSodium:                start_sodium,
935
+		PrescriptionSodium:         prescription_sodium,
936
+		SodiumCurve:                sodium_curve,
937
+		TreatmentRemark:            treatment_remark,
904 938
 	}
905 939
 
906 940
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -1072,6 +1106,11 @@ func (c *DialysisApiController) PostSoulution() {
1072 1106
 		PreImpulse:                 preImpules,
1073 1107
 		SolutionStatus:             1,
1074 1108
 		DialysisRemark:             dialysis_remark,
1109
+		PrescribingNumber:          prescribing_number,
1110
+		StartSodium:                start_sodium,
1111
+		PrescriptionSodium:         prescription_sodium,
1112
+		SodiumCurve:                sodium_curve,
1113
+		TreatmentRemark:            treatment_remark,
1075 1114
 	}
1076 1115
 
1077 1116
 	//针对河间咸得
@@ -1101,6 +1140,113 @@ func (c *DialysisApiController) PostSoulution() {
1101 1140
 	//更新状态
1102 1141
 	service.UpdateDialysisSolutionStatusTwo(dialysisSolution.ID, dialysisSolution.ModeId, dialysisSolution.UserOrgId, dialysisSolution.PatientId)
1103 1142
 
1143
+	//长沙南雅医院,自动生成抗凝剂的临时处方
1144
+	if adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 9671 {
1145
+		advice := models.DoctorAdvice{
1146
+			UserOrgId:             adminUserInfo.CurrentOrgId,
1147
+			PatientId:             patient,
1148
+			GroupNo:               0,
1149
+			AdviceType:            2,
1150
+			RecordDate:            recordDate.Unix(),
1151
+			AdviceDate:            recordDate.Unix(),
1152
+			StartTime:             recordDate.Unix() + 7*60*60, // 根据排班班次,给默认时间
1153
+			AdviceName:            "",                          // 根据抗凝剂转换为中文 + 首剂 + 维持 + 总量
1154
+			AdviceDesc:            "",
1155
+			ReminderDate:          0,
1156
+			SingleDose:            5000,
1157
+			SingleDoseUnit:        "iu",
1158
+			DrugSpec:              0,
1159
+			DrugSpecUnit:          "",
1160
+			PrescribingNumber:     prescribing_number, // 前端传过来的开药数量
1161
+			PrescribingNumberUnit: "支",
1162
+			DeliveryWay:           "静脉注射",
1163
+			ExecutionFrequency:    "上机前",
1164
+			AdviceDoctor:          0,
1165
+			Status:                1,
1166
+			CreatedTime:           time.Now().Unix(),
1167
+			UpdatedTime:           time.Now().Unix(),
1168
+			IsPrescription:        1,
1169
+		}
1170
+		// 查询排班信息
1171
+		schedulePatient, _ := service.GetScheduleByPatient(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1172
+		if schedulePatient.ID > 0 {
1173
+			if schedulePatient.ScheduleType == 1 {
1174
+				advice.StartTime = recordDate.Unix() + 7*60*60
1175
+			}
1176
+
1177
+			if schedulePatient.ScheduleType == 2 {
1178
+				advice.StartTime = recordDate.Unix() + 11*60*60
1179
+			}
1180
+		}
1181
+		// 抗凝剂名称
1182
+		switch anticoagulant {
1183
+		case 1:
1184
+			advice.AdviceName = "无肝素"
1185
+			break
1186
+		case 2:
1187
+			advice.AdviceName = "普通肝素"
1188
+			break
1189
+		case 3:
1190
+			advice.AdviceName = "低分子肝素"
1191
+			break
1192
+		case 4:
1193
+			advice.AdviceName = "阿加曲班"
1194
+			break
1195
+		case 5:
1196
+			advice.AdviceName = "枸橼酸钠"
1197
+			break
1198
+		case 6:
1199
+			advice.AdviceName = "低分子肝素钙"
1200
+			break
1201
+		case 7:
1202
+			advice.AdviceName = "低分子肝素钠"
1203
+			break
1204
+		case 8:
1205
+			advice.AdviceName = "依诺肝素"
1206
+			break
1207
+		case 9:
1208
+			advice.AdviceName = "达肝素"
1209
+			break
1210
+		case 10:
1211
+			advice.AdviceName = "体外抗凝"
1212
+			break
1213
+		case 11:
1214
+			advice.AdviceName = "那曲肝素"
1215
+			break
1216
+		case 12:
1217
+			advice.AdviceName = "无抗凝剂"
1218
+			break
1219
+		}
1220
+		advice.AdviceDesc = "首剂" + strconv.FormatFloat(anticoagulant_shouji, 'f', -1, 64) + "维持" + strconv.FormatFloat(anticoagulant_weichi, 'f', -1, 64) + "总量" + strconv.FormatFloat(anticoagulant_zongliang, 'f', -1, 64)
1221
+		if appRole.UserType == 2 || appRole.UserType == 1 {
1222
+			advice.AdviceDoctor = appRole.AdminUserId
1223
+		}
1224
+
1225
+		// 患者的临时医嘱里查找是否有抗凝剂临时医嘱
1226
+		advicePrescription, _ := service.GetAdvicesByPrescription(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
1227
+
1228
+		if advicePrescription.ID > 0 && (anticoagulant == 3 || anticoagulant == 5 || anticoagulant == 7) {
1229
+			advice.AdviceName = "低分子肝素钙注射液"
1230
+			// 修改患者临时医嘱里的抗凝剂医嘱
1231
+			advice.ID = advicePrescription.ID
1232
+			service.UpdateDoctorAdvice(&advice)
1233
+		} else {
1234
+			// 新增患者临时医嘱里的抗凝剂医嘱
1235
+			if anticoagulant == 3 || anticoagulant == 5 || anticoagulant == 7 {
1236
+				advice.AdviceName = "低分子肝素钙注射液"
1237
+			}
1238
+			service.CreateDoctorAdvice(&advice)
1239
+		}
1240
+
1241
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":doctor_advices"
1242
+		redis := service.RedisClient()
1243
+		//清空key 值
1244
+		redis.Set(key, "", time.Second)
1245
+		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":advice_list_all"
1246
+		redis.Set(keyOne, "", time.Second)
1247
+
1248
+	}
1249
+
1104 1250
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
1105 1251
 	redis := service.RedisClient()
1106 1252
 

+ 241 - 3
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -1389,6 +1389,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1389 1389
 	admin_user_id, _ := c.GetInt64("admin_user_id")
1390 1390
 
1391 1391
 	is_water := c.GetString("is_water")
1392
+
1392 1393
 	var is_war int64
1393 1394
 	if is_water == "是" {
1394 1395
 		is_war = 1
@@ -1407,6 +1408,13 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1407 1408
 	add_amount, _ := c.GetFloat("add_amount")
1408 1409
 	reduce_amount, _ := c.GetFloat("reduce_amount")
1409 1410
 	dialysis_remark := c.GetString("dialysis_remark")
1411
+
1412
+	prescribing_number, _ := c.GetFloat("prescribing_number")
1413
+	prescription_sodium := c.GetString("prescription_sodium")
1414
+	start_sodium := c.GetString("start_sodium")
1415
+	sodium_curve := c.GetString("sodium_curve")
1416
+	treatment_remark := c.GetString("treatment_remark")
1417
+
1410 1418
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
1411 1419
 
1412 1420
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
@@ -1532,6 +1540,11 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1532 1540
 		AddAmount:                  add_amount,
1533 1541
 		ReduceAmount:               reduce_amount,
1534 1542
 		DialysisRemark:             dialysis_remark,
1543
+		PrescribingNumber:          prescribing_number,
1544
+		StartSodium:                start_sodium,
1545
+		SodiumCurve:                sodium_curve,
1546
+		TreatmentRemark:            treatment_remark,
1547
+		PrescriptionSodium:         prescription_sodium,
1535 1548
 	}
1536 1549
 
1537 1550
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -1620,6 +1633,113 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1620 1633
 
1621 1634
 		err := service.AddSigleRecord(&prescription)
1622 1635
 
1636
+		//长沙南雅医院,自动生成抗凝剂的临时处方
1637
+		if adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9671 {
1638
+			advice := models.DoctorAdvice{
1639
+				UserOrgId:             adminUserInfo.Org.Id,
1640
+				PatientId:             id,
1641
+				GroupNo:               0,
1642
+				AdviceType:            2,
1643
+				RecordDate:            recordDate.Unix(),
1644
+				AdviceDate:            recordDate.Unix(),
1645
+				StartTime:             recordDate.Unix() + 7*60*60, // 根据排班班次,给默认时间
1646
+				AdviceName:            "",                          // 根据抗凝剂转换为中文 + 首剂 + 维持 + 总量
1647
+				AdviceDesc:            "",
1648
+				ReminderDate:          0,
1649
+				SingleDose:            5000,
1650
+				SingleDoseUnit:        "iu",
1651
+				DrugSpec:              0,
1652
+				DrugSpecUnit:          "",
1653
+				PrescribingNumber:     prescribing_number, // 前端传过来的开药数量
1654
+				PrescribingNumberUnit: "支",
1655
+				DeliveryWay:           "静脉注射",
1656
+				ExecutionFrequency:    "上机前",
1657
+				AdviceDoctor:          0,
1658
+				Status:                1,
1659
+				CreatedTime:           time.Now().Unix(),
1660
+				UpdatedTime:           time.Now().Unix(),
1661
+				IsPrescription:        1,
1662
+			}
1663
+			// 查询排班信息
1664
+			schedulePatient, _ := service.GetScheduleByPatient(id, recordDate.Unix(), adminUserInfo.Org.Id)
1665
+			if schedulePatient.ID > 0 {
1666
+				if schedulePatient.ScheduleType == 1 {
1667
+					advice.StartTime = recordDate.Unix() + 7*60*60
1668
+				}
1669
+
1670
+				if schedulePatient.ScheduleType == 2 {
1671
+					advice.StartTime = recordDate.Unix() + 11*60*60
1672
+				}
1673
+			}
1674
+			// 抗凝剂名称
1675
+			switch anticoagulant {
1676
+			case 1:
1677
+				advice.AdviceName = "无肝素"
1678
+				break
1679
+			case 2:
1680
+				advice.AdviceName = "普通肝素"
1681
+				break
1682
+			case 3:
1683
+				advice.AdviceName = "低分子肝素"
1684
+				break
1685
+			case 4:
1686
+				advice.AdviceName = "阿加曲班"
1687
+				break
1688
+			case 5:
1689
+				advice.AdviceName = "枸橼酸钠"
1690
+				break
1691
+			case 6:
1692
+				advice.AdviceName = "低分子肝素钙"
1693
+				break
1694
+			case 7:
1695
+				advice.AdviceName = "低分子肝素钠"
1696
+				break
1697
+			case 8:
1698
+				advice.AdviceName = "依诺肝素"
1699
+				break
1700
+			case 9:
1701
+				advice.AdviceName = "达肝素"
1702
+				break
1703
+			case 10:
1704
+				advice.AdviceName = "体外抗凝"
1705
+				break
1706
+			case 11:
1707
+				advice.AdviceName = "那曲肝素"
1708
+				break
1709
+			case 12:
1710
+				advice.AdviceName = "无抗凝剂"
1711
+				break
1712
+			}
1713
+			advice.AdviceDesc = "首剂" + strconv.FormatFloat(anticoagulant_shouji, 'f', -1, 64) + "维持" + strconv.FormatFloat(anticoagulant_weichi, 'f', -1, 64) + "总量" + strconv.FormatFloat(anticoagulant_zongliang, 'f', -1, 64)
1714
+			if appRole.UserType == 2 || appRole.UserType == 1 {
1715
+				advice.AdviceDoctor = appRole.AdminUserId
1716
+			}
1717
+
1718
+			// 患者的临时医嘱里查找是否有抗凝剂临时医嘱
1719
+			advicePrescription, _ := service.GetAdvicesByPrescription(adminUserInfo.Org.Id, id, recordDate.Unix())
1720
+			if advicePrescription.ID > 0 && (anticoagulant == 3 || anticoagulant == 5 || anticoagulant == 7) {
1721
+				advice.AdviceName = "低分子肝素钠注射液"
1722
+				// 修改患者临时医嘱里的抗凝剂医嘱
1723
+				advice.ID = advicePrescription.ID
1724
+				service.UpdateDoctorAdvice(&advice)
1725
+			} else {
1726
+				if anticoagulant == 3 || anticoagulant == 5 || anticoagulant == 7 {
1727
+					advice.AdviceName = "低分子肝素钠注射液"
1728
+				}
1729
+				// 新增患者临时医嘱里的抗凝剂医嘱
1730
+				service.CreateDoctorAdvice(&advice)
1731
+			}
1732
+
1733
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":doctor_advices"
1734
+			redis := service.RedisClient()
1735
+			defer redis.Close()
1736
+			//清空key 值
1737
+			redis.Set(key, "", time.Second)
1738
+			keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":advice_list_all"
1739
+			redis.Set(keyOne, "", time.Second)
1740
+
1741
+		}
1742
+
1623 1743
 		//获取key,清空redis
1624 1744
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
1625 1745
 		redis := service.RedisClient()
@@ -2597,9 +2717,7 @@ func (this *DialysisAPIController) StartDialysis() {
2597 2717
 			record.SystolicBloodPressure = befor.SystolicBloodPressure
2598 2718
 			record.DiastolicBloodPressure = befor.DiastolicBloodPressure
2599 2719
 			record.BreathingRate = befor.BreathingRate
2600
-			if adminUserInfo.Org.Id != 10445 {
2601
-				record.PulseFrequency = befor.PulseFrequency
2602
-			}
2720
+			record.PulseFrequency = befor.PulseFrequency
2603 2721
 			record.Temperature = befor.Temperature
2604 2722
 		}
2605 2723
 	}
@@ -2794,6 +2912,12 @@ func (c *DialysisAPIController) PostSolution() {
2794 2912
 	is_water := c.GetString("is_water")
2795 2913
 	add_amount, _ := c.GetFloat("add_amount")
2796 2914
 	reduce_amount, _ := c.GetFloat("reduce_amount")
2915
+
2916
+	prescribing_number, _ := c.GetFloat("prescribing_number")
2917
+	treatment_remark := c.GetString("treatment_remark")
2918
+	prescription_sodium := c.GetString("prescription_sodium")
2919
+	start_sodium := c.GetString("start_sodium")
2920
+	sodium_curve := c.GetString("sodium_curve")
2797 2921
 	var is_war int64
2798 2922
 	if is_water == "是" {
2799 2923
 		is_war = 1
@@ -2931,6 +3055,11 @@ func (c *DialysisAPIController) PostSolution() {
2931 3055
 		AddAmount:                  add_amount,
2932 3056
 		ReduceAmount:               reduce_amount,
2933 3057
 		DialysisRemark:             dialysis_remark,
3058
+		PrescribingNumber:          prescribing_number,
3059
+		PrescriptionSodium:         prescription_sodium,
3060
+		StartSodium:                start_sodium,
3061
+		SodiumCurve:                sodium_curve,
3062
+		TreatmentRemark:            treatment_remark,
2934 3063
 	}
2935 3064
 
2936 3065
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
@@ -3030,6 +3159,11 @@ func (c *DialysisAPIController) PostSolution() {
3030 3159
 		PreImpulse:                 impulse,
3031 3160
 		SolutionStatus:             1,
3032 3161
 		DialysisRemark:             dialysis_remark,
3162
+		PrescribingNumber:          prescribing_number,
3163
+		PrescriptionSodium:         prescription_sodium,
3164
+		StartSodium:                start_sodium,
3165
+		SodiumCurve:                sodium_curve,
3166
+		TreatmentRemark:            treatment_remark,
3033 3167
 	}
3034 3168
 
3035 3169
 	//针对河间咸的
@@ -3052,6 +3186,110 @@ func (c *DialysisAPIController) PostSolution() {
3052 3186
 	//更新状态
3053 3187
 	service.UpdateDialysisSolutionStatusTwo(dialysisSolution.ID, dialysisSolution.ModeId, dialysisSolution.UserOrgId, dialysisSolution.PatientId)
3054 3188
 
3189
+	//长沙南雅医院,自动生成抗凝剂的临时处方
3190
+	if adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9671 {
3191
+		advice := models.DoctorAdvice{
3192
+			UserOrgId:             adminUserInfo.Org.Id,
3193
+			PatientId:             id,
3194
+			GroupNo:               0,
3195
+			AdviceType:            2,
3196
+			RecordDate:            recordDate.Unix(),
3197
+			AdviceDate:            recordDate.Unix(),
3198
+			StartTime:             recordDate.Unix() + 7*60*60, // 根据排班班次,给默认时间
3199
+			AdviceName:            "",                          // 根据抗凝剂转换为中文 + 首剂 + 维持 + 总量
3200
+			AdviceDesc:            "",
3201
+			ReminderDate:          0,
3202
+			SingleDose:            5000,
3203
+			SingleDoseUnit:        "iu",
3204
+			DrugSpec:              0,
3205
+			DrugSpecUnit:          "",
3206
+			PrescribingNumber:     prescribing_number, // 前端传过来的开药数量
3207
+			PrescribingNumberUnit: "支",
3208
+			DeliveryWay:           "静脉注射",
3209
+			ExecutionFrequency:    "上机前",
3210
+			AdviceDoctor:          0,
3211
+			Status:                1,
3212
+			CreatedTime:           time.Now().Unix(),
3213
+			UpdatedTime:           time.Now().Unix(),
3214
+			IsPrescription:        1,
3215
+		}
3216
+		// 查询排班信息
3217
+		schedulePatient, _ := service.GetScheduleByPatient(id, recordDate.Unix(), adminUserInfo.Org.Id)
3218
+		if schedulePatient.ID > 0 {
3219
+			if schedulePatient.ScheduleType == 1 {
3220
+				advice.StartTime = recordDate.Unix() + 7*60*60
3221
+			}
3222
+
3223
+			if schedulePatient.ScheduleType == 2 {
3224
+				advice.StartTime = recordDate.Unix() + 11*60*60
3225
+			}
3226
+		}
3227
+		// 抗凝剂名称
3228
+		switch anticoagulant {
3229
+		case 1:
3230
+			advice.AdviceName = "无肝素"
3231
+			break
3232
+		case 2:
3233
+			advice.AdviceName = "普通肝素"
3234
+			break
3235
+		case 3:
3236
+			advice.AdviceName = "低分子肝素"
3237
+			break
3238
+		case 4:
3239
+			advice.AdviceName = "阿加曲班"
3240
+			break
3241
+		case 5:
3242
+			advice.AdviceName = "枸橼酸钠"
3243
+			break
3244
+		case 6:
3245
+			advice.AdviceName = "低分子肝素钙"
3246
+			break
3247
+		case 7:
3248
+			advice.AdviceName = "低分子肝素钠"
3249
+			break
3250
+		case 8:
3251
+			advice.AdviceName = "依诺肝素"
3252
+			break
3253
+		case 9:
3254
+			advice.AdviceName = "达肝素"
3255
+			break
3256
+		case 10:
3257
+			advice.AdviceName = "体外抗凝"
3258
+			break
3259
+		case 11:
3260
+			advice.AdviceName = "那曲肝素"
3261
+			break
3262
+		case 12:
3263
+			advice.AdviceName = "无抗凝剂"
3264
+			break
3265
+		}
3266
+		advice.AdviceDesc = "首剂" + strconv.FormatFloat(anticoagulant_shouji, 'f', -1, 64) + "维持" + strconv.FormatFloat(anticoagulant_weichi, 'f', -1, 64) + "总量" + strconv.FormatFloat(anticoagulant_zongliang, 'f', -1, 64)
3267
+		if appRole.UserType == 2 || appRole.UserType == 1 {
3268
+			advice.AdviceDoctor = appRole.AdminUserId
3269
+		}
3270
+
3271
+		// 患者的临时医嘱里查找是否有抗凝剂临时医嘱
3272
+		advicePrescription, _ := service.GetAdvicesByPrescription(adminUserInfo.Org.Id, id, recordDate.Unix())
3273
+
3274
+		if advicePrescription.ID > 0 {
3275
+			// 修改患者临时医嘱里的抗凝剂医嘱
3276
+			advice.ID = advicePrescription.ID
3277
+			service.UpdateDoctorAdvice(&advice)
3278
+		} else {
3279
+			// 新增患者临时医嘱里的抗凝剂医嘱
3280
+			service.CreateDoctorAdvice(&advice)
3281
+		}
3282
+
3283
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":doctor_advices"
3284
+		redis := service.RedisClient()
3285
+		defer redis.Close()
3286
+		//清空key 值
3287
+		redis.Set(key, "", time.Second)
3288
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":advice_list_all"
3289
+		redis.Set(keyOne, "", time.Second)
3290
+
3291
+	}
3292
+
3055 3293
 	//获取key,清空redis
3056 3294
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
3057 3295
 	redis := service.RedisClient()

+ 10 - 0
models/patient_models.go View File

@@ -357,6 +357,11 @@ type DialysisPrescription struct {
357 357
 	AddAmount                  float64       `gorm:"column:add_amount" json:"add_amount" form:"add_amount"`
358 358
 	ReduceAmount               float64       `gorm:"column:reduce_amount" json:"reduce_amount" form:"reduce_amount"`
359 359
 	DialysisRemark             string        `gorm:"column:dialysis_remark" json:"dialysis_remark" form:"dialysis_remark"`
360
+	PrescribingNumber          float64       `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
361
+	TreatmentRemark            string        `gorm:"column:treatment_remark" json:"treatment_remark" form:"treatment_remark"`
362
+	PrescriptionSodium         string        `gorm:"column:prescription_sodium" json:"prescription_sodium" form:"prescription_sodium"`
363
+	StartSodium                string        `gorm:"column:start_sodium" json:"start_sodium" form:"start_sodium"`
364
+	SodiumCurve                string        `gorm:"column:sodium_curve" json:"sodium_curve" form:"sodium_curve"`
360 365
 }
361 366
 
362 367
 func (DialysisPrescription) TableName() string {
@@ -564,6 +569,11 @@ type DialysisSolution struct {
564 569
 	PreImpulse                 float64 `gorm:"column:pre_impulse" json:"pre_impulse" form:"pre_impulse"`
565 570
 	SolutionStatus             int64   `gorm:"column:solution_status" json:"solution_status" form:"solution_status"`
566 571
 	DialysisRemark             string  `gorm:"column:dialysis_remark" json:"dialysis_remark" form:"dialysis_remark"`
572
+	PrescribingNumber          float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
573
+	TreatmentRemark            string  `gorm:"column:treatment_remark" json:"treatment_remark" form:"treatment_remark"`
574
+	PrescriptionSodium         string  `gorm:"column:prescription_sodium" json:"prescription_sodium" form:"prescription_sodium"`
575
+	StartSodium                string  `gorm:"column:start_sodium" json:"start_sodium" form:"start_sodium"`
576
+	SodiumCurve                string  `gorm:"column:sodium_curve" json:"sodium_curve" form:"sodium_curve"`
567 577
 }
568 578
 
569 579
 func (DialysisSolution) TableName() string {

+ 4 - 3
service/inspection_service.go View File

@@ -33,9 +33,10 @@ func GetAdvices(orgid int64, patientid int64, recorddate int64) (advcie []*model
33 33
 	err = XTReadDB().Model(&models.DoctorAdvice{}).Where("patient_id = ? and user_org_id = ? and record_date = ? and status =1", patientid, orgid, recorddate).Find(&advcie).Error
34 34
 	return
35 35
 }
36
-func GetAdvicesByPrescription(orgid int64, patientid int64, recorddate int64) (advcie *models.DoctorAdvice, err error) {
37
-	err = XTReadDB().Model(&models.DoctorAdvice{}).Where("patient_id = ? and user_org_id = ? and record_date = ? and status =1 and is_prescription = 1", patientid, orgid, recorddate).Find(&advcie).Error
38
-	return
36
+func GetAdvicesByPrescription(orgid int64, patientid int64, recorddate int64) (models.DoctorAdvice, error) {
37
+	advice := models.DoctorAdvice{}
38
+	err = XTReadDB().Where("patient_id = ? and user_org_id = ? and record_date = ? and status =1 and is_prescription = 1", patientid, orgid, recorddate).Find(&advice).Error
39
+	return advice, err
39 40
 }
40 41
 
41 42
 func CreatePatientInspection(inspectins []models.Inspection) (err error) {

+ 1 - 1
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go View File

@@ -462,7 +462,7 @@ func GetHisBatchDoctorAdvice(orgid int64, patient_id int64, advice_date int64) (
462 462
 
463 463
 func GetHisBatchProject(orgid int64, patient_id int64, advice_date int64) (project []*models.HisPrescriptionProject, err error) {
464 464
 
465
-	err = p_service.XTReadDB().Where("user_org_id = ? and patient_id = ? and record_date = ? and status= 1", orgid, patient_id, advice_date).Find(&project).Error
465
+	err = p_service.XTReadDB().Where("user_org_id = ? and patient_id = ? and record_date = ? and status= 1", orgid, patient_id, advice_date).Preload("HisProject").Preload("GoodInfo", "status=1").Find(&project).Error
466 466
 	return project, err
467 467
 }
468 468