Kaynağa Gözat

库存流水展示

XMLWAN 1 yıl önce
ebeveyn
işleme
694aaa59e9

+ 1 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go Dosyayı Görüntüle

@@ -674,7 +674,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
674 674
 				evaluation.Phinholing = lastPredialysisEvaluation.Phinholing                   //针眼
675 675
 				evaluation.Remark = lastPredialysisEvaluation.Remark
676 676
 				if adminUserInfo.Org.Id == 10318 {
677
-					evaluation.Remark = "患者已确认无发热,无流行病学接触史"
677
+					evaluation.Remark = ""
678 678
 				}
679 679
 				if adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10447 {
680 680
 					evaluation.BreathingRate = "20"

+ 28 - 6
controllers/mobile_api_controllers/dialysis_api_controller.go Dosyayı Görüntüle

@@ -1772,7 +1772,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1772 1772
 				}
1773 1773
 
1774 1774
 				if schedulePatient.ScheduleType == 2 {
1775
-					advice.StartTime = recordDate.Unix() + 11*60*60
1775
+					advice.StartTime = recordDate.Unix() + 10*60*60
1776 1776
 				}
1777 1777
 			}
1778 1778
 			// 抗凝剂名称
@@ -2818,6 +2818,13 @@ func (this *DialysisAPIController) StartDialysis() {
2818 2818
 				value, _ := strconv.ParseFloat(fmt.Sprintf("%.3f", prescription.TargetUltrafiltration/float64(totalMin)*60), 6)
2819 2819
 				ultrafiltration_rate = value
2820 2820
 			}
2821
+
2822
+			//针对
2823
+			if adminUserInfo.Org.Id == 10471 || adminUserInfo.Org.Id == 3877 {
2824
+
2825
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
2826
+				ultrafiltration_rate = ultrafiltration_rate / 1000
2827
+			}
2821 2828
 		}
2822 2829
 	}
2823 2830
 
@@ -3402,7 +3409,7 @@ func (c *DialysisAPIController) PostSolution() {
3402 3409
 			}
3403 3410
 
3404 3411
 			if schedulePatient.ScheduleType == 2 {
3405
-				advice.StartTime = recordDate.Unix() + 11*60*60
3412
+				advice.StartTime = recordDate.Unix() + 10*60*60
3406 3413
 			}
3407 3414
 		}
3408 3415
 		// 抗凝剂名称
@@ -3683,11 +3690,18 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
3683 3690
 				record.UltrafiltrationRate = ultrafiltration_rate
3684 3691
 			}
3685 3692
 
3686
-			if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10340 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 9829 || adminInfo.Org.Id == 10440 || adminInfo.Org.Id == 10469 || adminInfo.Org.Id == 10471 {
3693
+			if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10340 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 9829 || adminInfo.Org.Id == 10440 || adminInfo.Org.Id == 10469 {
3687 3694
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / 1000 / float64(totalMin) * 1000)
3688 3695
 
3689 3696
 				record.UltrafiltrationRate = ultrafiltration_rate
3690 3697
 			}
3698
+
3699
+			if adminInfo.Org.Id == 10471 {
3700
+
3701
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3702
+				record.UltrafiltrationRate = ultrafiltration_rate / 1000
3703
+
3704
+			}
3691 3705
 			//if template.TemplateId == 47 {
3692 3706
 			//	ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
3693 3707
 			//	record.UltrafiltrationRate = ultrafiltration_rate
@@ -3714,15 +3728,22 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
3714 3728
 	}
3715 3729
 
3716 3730
 	//长沙南雅
3717
-	if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 10469 || adminInfo.Org.Id == 10471 {
3731
+	if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 10469 {
3718 3732
 
3719 3733
 		if ultrafiltration_rate > 0 {
3720 3734
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
3721
-
3735
+			fmt.Println("ultrafiltration_volume", ultrafiltration_volume)
3722 3736
 			record.UltrafiltrationVolume = ultrafiltration_volume
3723 3737
 		}
3724 3738
 
3725 3739
 	}
3740
+
3741
+	if adminInfo.Org.Id == 10471 {
3742
+
3743
+		ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
3744
+		fmt.Println("ultrafiltration_volume", ultrafiltration_volume)
3745
+		record.UltrafiltrationVolume = ultrafiltration_volume / 1000
3746
+	}
3726 3747
 	//长沙南雅累计血容量自动计算
3727 3748
 	//if adminInfo.Org.Id == 10340 || adminInfo.Org.Id == 9671 ||  adminInfo.Org.Id == 3877{
3728 3749
 	//	record.AccumulatedBloodVolume = (record.BloodFlowVolume - 25) * (math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime)/3600) * 60) / 1000
@@ -4265,9 +4286,10 @@ func (c *DialysisAPIController) GetLongAdviceOne() {
4265 4286
 		//开启推送提醒逻辑    提交长期处方的时候,弹起长期医嘱推送
4266 4287
 		var advice_three []*models.DoctorAdvice
4267 4288
 
4268
-		//fmt.Println("theStartTime23434343433434433443434343434334", theStartTime)
4269 4289
 		advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.Org.Id, patient_id, theStartTime)
4290
+
4270 4291
 		advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.Org.Id, patient_id, theStartTime)
4292
+
4271 4293
 		for _, advice := range advices {
4272 4294
 			if advice.FrequencyType == 3 {
4273 4295
 				t := time.Now()

+ 35 - 2
controllers/mobile_api_controllers/patient_api_controller.go Dosyayı Görüntüle

@@ -701,7 +701,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
701 701
 				if isHasWay {
702 702
 					var total int64
703 703
 					var prescribing_number_total int64
704
-					fmt.Println("advicesssssssssssssssss", len(advices))
704
+
705 705
 					for _, item := range advices {
706 706
 						if item.Way == 1 {
707 707
 							houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
@@ -1132,6 +1132,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1132 1132
 						}
1133 1133
 					}
1134 1134
 					if total_count == drug_count {
1135
+
1135 1136
 						advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
1136 1137
 						c.ServeSuccessJSON(map[string]interface{}{
1137 1138
 							"msg":    "1",
@@ -1170,7 +1171,17 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1170 1171
 						}
1171 1172
 
1172 1173
 						if medical.IsUse == 1 {
1173
-
1174
+							drugError := models.XtDrugError{
1175
+								UserOrgId:  adminInfo.Org.Id,
1176
+								DrugId:     item.DrugId,
1177
+								RecordDate: item.AdviceDate,
1178
+								PatientId:  item.PatientId,
1179
+								Remark:     "零用药品",
1180
+								Status:     1,
1181
+								Ctime:      time.Now().Unix(),
1182
+								Mtime:      0,
1183
+							}
1184
+							service.CreateDrugError(drugError)
1174 1185
 							if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
1175 1186
 								c.ServeSuccessJSON(map[string]interface{}{
1176 1187
 									"msg":    "1",
@@ -1181,6 +1192,17 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1181 1192
 							}
1182 1193
 						}
1183 1194
 						if medical.IsUse != 1 {
1195
+							drugError := models.XtDrugError{
1196
+								UserOrgId:  adminInfo.Org.Id,
1197
+								DrugId:     item.DrugId,
1198
+								RecordDate: item.AdviceDate,
1199
+								PatientId:  item.PatientId,
1200
+								Remark:     "药品库存不足",
1201
+								Status:     1,
1202
+								Ctime:      time.Now().Unix(),
1203
+								Mtime:      0,
1204
+							}
1205
+							service.CreateDrugError(drugError)
1184 1206
 							if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
1185 1207
 								c.ServeSuccessJSON(map[string]interface{}{
1186 1208
 									"msg":    "3",
@@ -1190,6 +1212,17 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1190 1212
 								return
1191 1213
 							}
1192 1214
 							if prescribing_number_total > total {
1215
+								drugError := models.XtDrugError{
1216
+									UserOrgId:  adminInfo.Org.Id,
1217
+									DrugId:     item.DrugId,
1218
+									RecordDate: item.AdviceDate,
1219
+									PatientId:  item.PatientId,
1220
+									Remark:     "出库数量大于库存",
1221
+									Status:     1,
1222
+									Ctime:      time.Now().Unix(),
1223
+									Mtime:      0,
1224
+								}
1225
+								service.CreateDrugError(drugError)
1193 1226
 								c.ServeSuccessJSON(map[string]interface{}{
1194 1227
 									"msg":    "2",
1195 1228
 									"advice": advice,

+ 50 - 30
controllers/pharmacy_controller.go Dosyayı Görüntüle

@@ -165,7 +165,7 @@ func (this *PharmacyController) IssuedDrug() {
165 165
 		etime = stime + 86399
166 166
 	}
167 167
 
168
-	if orgid == 10164 || orgid == 3877 || orgid == 10188 || orgid == 10217 || orgid == 9671 {
168
+	if orgid == 10164 || orgid == 3877 || orgid == 10188 || orgid == 10217 || orgid == 9671 || orgid == 10387 {
169 169
 
170 170
 		//获取排班班次
171 171
 		schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
@@ -189,7 +189,7 @@ func (this *PharmacyController) IssuedDrug() {
189 189
 		})
190 190
 	}
191 191
 
192
-	if orgid != 10164 && orgid == 3877 && orgid != 10188 && orgid != 10217 && orgid != 9671 {
192
+	if orgid != 10164 && orgid == 3877 && orgid != 10188 && orgid != 10217 && orgid != 9671 && orgid != 10387 {
193 193
 		//查询表里当天的数据
194 194
 		var flist []*models.TmpPatient
195 195
 		flist, err = service.GetTodayDrug(stime, etime, orgid, 1, keyword)
@@ -245,7 +245,7 @@ func (this *PharmacyController) WaitingDrug() {
245 245
 		etime = stime + 86399
246 246
 	}
247 247
 
248
-	if orgid != 9671 && orgid != 10188 && orgid != 10217 && orgid != 3877 && orgid != 10164 {
248
+	if orgid != 9671 && orgid != 10188 && orgid != 10217 && orgid != 3877 && orgid != 10164 && orgid != 10387 {
249 249
 		//查询表里当天的数据
250 250
 		var flist []*models.TmpPatient
251 251
 		flist, err = service.GetTodayDrug(stime, etime, orgid, 0, keyword)
@@ -269,7 +269,7 @@ func (this *PharmacyController) WaitingDrug() {
269 269
 	}
270 270
 
271 271
 	//当天已发药的人数
272
-	if orgid == 9671 || orgid == 10188 || orgid == 10217 || orgid == 3877 || orgid == 10164 {
272
+	if orgid == 9671 || orgid == 10188 || orgid == 10217 || orgid == 3877 || orgid == 10164 || orgid == 10387 {
273 273
 
274 274
 		//获取排班班次
275 275
 		schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
@@ -368,35 +368,37 @@ func (this *PharmacyController) DispensingMedicine() {
368 368
 		var total int64
369 369
 		var prescribing_number_total int64
370 370
 		for _, item := range advicelist {
371
-			houseConfig, _ := service.GetAllStoreHouseConfig(orgid)
372
-			//查询该药品是否有库存
373
-			list, _ := service.GetDrugTotalCountTwenty(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
374
-
375 371
 			//查询改药品信息
376 372
 			medical, _ := service.GetBaseDrugMedical(item.DrugId)
377
-			//判断单位是否相等
378
-			if medical.MaxUnit == item.PrescribingNumberUnit {
379
-				prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
380
-				count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
381
-				//转化为最小单位
382
-				total = list.Count*medical.MinNumber + list.StockMinNumber
383
-				prescribing_number_total = count * medical.MinNumber
384
-			}
385
-			if medical.MinUnit == item.PrescribingNumberUnit {
386
-				prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
387
-				count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
388
-				total = list.Count*medical.MinNumber + list.StockMinNumber
389
-				prescribing_number_total = count
390
-			}
373
+			if medical.IsPharmacy == 1 {
374
+				houseConfig, _ := service.GetAllStoreHouseConfig(orgid)
375
+				//查询该药品是否有库存
376
+				list, _ := service.GetDrugTotalCountTwenty(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
377
+
378
+				//判断单位是否相等
379
+				if medical.MaxUnit == item.PrescribingNumberUnit {
380
+					prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
381
+					count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
382
+					//转化为最小单位
383
+					total = list.Count*medical.MinNumber + list.StockMinNumber
384
+					prescribing_number_total = count * medical.MinNumber
385
+				}
386
+				if medical.MinUnit == item.PrescribingNumberUnit {
387
+					prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
388
+					count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
389
+					total = list.Count*medical.MinNumber + list.StockMinNumber
390
+					prescribing_number_total = count
391
+				}
391 392
 
392
-			if medical.IsUse != 1 {
393
-				//如果出库数量大于库存数量
394
-				if prescribing_number_total > total {
395
-					err := fmt.Errorf(service.FindDrugsName(item.DrugId) + "库存不足")
396
-					if err != nil {
397
-						utils.ErrorLog(err.Error())
398
-						this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
399
-						return
393
+				if medical.IsUse != 1 {
394
+					//如果出库数量大于库存数量
395
+					if prescribing_number_total > total {
396
+						err := fmt.Errorf(service.FindDrugsName(item.DrugId) + "库存不足")
397
+						if err != nil {
398
+							utils.ErrorLog(err.Error())
399
+							this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
400
+							return
401
+						}
400 402
 					}
401 403
 				}
402 404
 			}
@@ -405,11 +407,29 @@ func (this *PharmacyController) DispensingMedicine() {
405 407
 	}
406 408
 
407 409
 	err = service.DispensingMedicine(orgid, patient_id, stime, etime, creater)
410
+
411
+	if orgid == 10387 || orgid == 3877 {
412
+		advicelist, _ := service.FindeHisAdviceDocAdvice(orgid, patient_id, stime, etime)
413
+		if len(advicelist) > 0 {
414
+			for _, item := range advicelist {
415
+				//查询改药品信息
416
+				medical, _ := service.GetBaseDrugMedical(item.DrugId)
417
+				if medical.IsPharmacy == 1 {
418
+					flow, _ := service.GetFlow(item.DrugId, item.AdviceDate, orgid, item.PatientId)
419
+					if len(flow) > 0 {
420
+						service.UpdateAdviceFlow(item.ID)
421
+					}
422
+				}
423
+			}
424
+
425
+		}
426
+	}
408 427
 	if err != nil {
409 428
 		utils.ErrorLog(err.Error())
410 429
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
411 430
 		return
412 431
 	}
432
+
413 433
 	this.ServeSuccessJSON(map[string]interface{}{
414 434
 		"list": "操作成功",
415 435
 	})

+ 16 - 0
models/drug_stock.go Dosyayı Görüntüle

@@ -709,3 +709,19 @@ type DrugWarehouseOutInfoNight struct {
709 709
 func (DrugWarehouseOutInfoNight) TableName() string {
710 710
 	return "xt_drug_warehouse_out_info"
711 711
 }
712
+
713
+type XtDrugError struct {
714
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
715
+	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
716
+	DrugId     int64  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
717
+	RecordDate int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
718
+	PatientId  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
719
+	Remark     string `gorm:"column:remark" json:"remark" form:"remark"`
720
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
721
+	Ctime      int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
722
+	Mtime      int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
723
+}
724
+
725
+func (XtDrugError) TableName() string {
726
+	return "xt_drug_error"
727
+}

+ 7 - 0
service/drug_pharmacy_management_service.go Dosyayı Görüntüle

@@ -1647,3 +1647,10 @@ func GetPharmacyConfig(orgid int64) (models.PharmacyConfig, error) {
1647 1647
 
1648 1648
 	return config, err
1649 1649
 }
1650
+
1651
+func CreateDrugError(drugError models.XtDrugError) error {
1652
+
1653
+	err := XTWriteDB().Create(&drugError).Error
1654
+
1655
+	return err
1656
+}

+ 11 - 0
service/pharmacy_service.go Dosyayı Görüntüle

@@ -2019,3 +2019,14 @@ func FindeHisAdviceDocAdvice(orgid int64, patient_id int64, stime int64, etime i
2019 2019
 
2020 2020
 	return advice, err
2021 2021
 }
2022
+
2023
+func GetFlow(drug_id int64, system_time int64, org_id int64, patient_id int64) (flow []*models.DrugFlow, err error) {
2024
+
2025
+	err = XTWriteDB().Where("drug_id = ? and system_time =? and user_org_id = ? and status = 1 and patient_id =?", drug_id, system_time, org_id, patient_id).Find(&flow).Error
2026
+	return flow, err
2027
+}
2028
+
2029
+func UpdateAdviceFlow(id int64) error {
2030
+	err := XTWriteDB().Model(&models.HisDoctorAdviceInfo{}).Where("id = ? and status = 1 and is_medicine =0", id).Update(map[string]interface{}{"is_medicine": 1}).Error
2031
+	return err
2032
+}