|
@@ -3197,7 +3197,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
3197
|
3197
|
var adviceList []models.HisDoctorAdviceInfo
|
3198
|
3198
|
var projectList []models.HisPrescriptionProject
|
3199
|
3199
|
|
3200
|
|
- if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10635 || adminInfo.CurrentOrgId == 10598 || adminInfo.CurrentOrgId == 10028 {
|
|
3200
|
+ if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10635 || adminInfo.CurrentOrgId == 10598 || adminInfo.CurrentOrgId == 10028 || adminInfo.CurrentOrgId == 10721 {
|
3201
|
3201
|
if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
3202
|
3202
|
prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
3203
|
3203
|
|
|
@@ -3824,7 +3824,445 @@ func (c *HisApiController) CreateHisPrescription() {
|
3824
|
3824
|
|
3825
|
3825
|
//查询保存耗材出库开关是否打开
|
3826
|
3826
|
if p.PatientId != 30038 {
|
3827
|
|
- if goodOutConfig.IsOpen == 1 {
|
|
3827
|
+
|
|
3828
|
+ //用机构ID区分
|
|
3829
|
+ if adminInfo.CurrentOrgId != 10721 && adminInfo.CurrentOrgId != 10164 {
|
|
3830
|
+ if goodOutConfig.IsOpen == 1 {
|
|
3831
|
+ //耗材出库
|
|
3832
|
+ if p.Type == 3 {
|
|
3833
|
+
|
|
3834
|
+ //对比当前数据和历史出库数据
|
|
3835
|
+
|
|
3836
|
+ historyProject, _ := service.GetHistoryProject(p.PatientId, p.UserOrgId, p.RecordDate, p.ID, p.ProjectId, tx)
|
|
3837
|
+
|
|
3838
|
+ historyCount, _ := strconv.ParseInt(historyProject.Count, 10, 64)
|
|
3839
|
+
|
|
3840
|
+ nowCount, _ := strconv.ParseInt(p.Count, 10, 64)
|
|
3841
|
+
|
|
3842
|
+ //如果当前处方数量大于历史数据,则需要出库
|
|
3843
|
+ if nowCount > historyCount {
|
|
3844
|
+
|
|
3845
|
+ var cha_count int64
|
|
3846
|
+ cha_count = nowCount - historyCount
|
|
3847
|
+
|
|
3848
|
+ timeStr := time.Now().Format("2006-01-02")
|
|
3849
|
+ timeArr := strings.Split(timeStr, "-")
|
|
3850
|
+ total, _ := service.FindAllWarehouseOut(adminInfo.CurrentOrgId)
|
|
3851
|
+
|
|
3852
|
+ total = total + 1
|
|
3853
|
+ warehousing_out_order := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
|
3854
|
+ number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
|
3855
|
+ number = number + total
|
|
3856
|
+ warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
|
|
3857
|
+
|
|
3858
|
+ operation_time := time.Now().Unix()
|
|
3859
|
+ creater := c.GetAdminUserInfo().AdminUser.Id
|
|
3860
|
+
|
|
3861
|
+ recordDateStr := time.Now().Format("2006-01-02")
|
|
3862
|
+ recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
|
|
3863
|
+ nowtime := recordDate.Unix()
|
|
3864
|
+ warehouseOut := models.WarehouseOut{
|
|
3865
|
+ WarehouseOutOrderNumber: warehousing_out_order,
|
|
3866
|
+ OperationTime: operation_time,
|
|
3867
|
+ OrgId: adminInfo.CurrentOrgId,
|
|
3868
|
+ Creater: creater,
|
|
3869
|
+ Ctime: time.Now().Unix(),
|
|
3870
|
+ Status: 1,
|
|
3871
|
+ WarehouseOutTime: nowtime,
|
|
3872
|
+ Type: 1,
|
|
3873
|
+ StorehouseId: storeConfig.StorehouseOutInfo,
|
|
3874
|
+ IsCheck: 1,
|
|
3875
|
+ IsSys: 1,
|
|
3876
|
+ }
|
|
3877
|
+ //查询是否生成出库单
|
|
3878
|
+ out, _ := service.FindNewPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
|
|
3879
|
+ if out.ID == 0 {
|
|
3880
|
+ service.AddNewSigleWarehouseOut(&warehouseOut, tx)
|
|
3881
|
+ }
|
|
3882
|
+
|
|
3883
|
+ lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
|
|
3884
|
+
|
|
3885
|
+ goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(p.ProjectId, tx)
|
|
3886
|
+ houseConfig, _ := service.GetNewAllStoreHouseConfig(p.UserOrgId, tx)
|
|
3887
|
+
|
|
3888
|
+ dialyPrepareOne := models.DialysisBeforePrepare{
|
|
3889
|
+ GoodTypeId: goodObj.GoodTypeId,
|
|
3890
|
+ GoodId: p.ProjectId,
|
|
3891
|
+ PatientId: p.PatientId,
|
|
3892
|
+ RecordDate: p.RecordDate,
|
|
3893
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
3894
|
+ Count: cha_count,
|
|
3895
|
+ Ctime: time.Now().Unix(),
|
|
3896
|
+ Creater: creater,
|
|
3897
|
+ Status: 1,
|
|
3898
|
+ StorehouseId: houseConfig.StorehouseOutInfo,
|
|
3899
|
+ ProjectId: p.ID,
|
|
3900
|
+ }
|
|
3901
|
+ //出库
|
|
3902
|
+ service.ConsumableNewHisPrescriptionDelivery(adminInfo.CurrentOrgId, p.PatientId, p.RecordDate, &dialyPrepareOne, &lastOut, creater, tx)
|
|
3903
|
+
|
|
3904
|
+ }
|
|
3905
|
+
|
|
3906
|
+ //如果当前处方数量小于历史数据,怎需要退库
|
|
3907
|
+ if nowCount < historyCount {
|
|
3908
|
+
|
|
3909
|
+ var cha_count int64
|
|
3910
|
+ cha_count = historyCount - nowCount
|
|
3911
|
+ goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(p.ProjectId, tx)
|
|
3912
|
+ creater := c.GetAdminUserInfo().AdminUser.Id
|
|
3913
|
+
|
|
3914
|
+ newPrescriptionProject := &models.HisPrescriptionProject{
|
|
3915
|
+ ID: p.ID,
|
|
3916
|
+ ProjectId: p.ProjectId,
|
|
3917
|
+ Price: p.Price,
|
|
3918
|
+ UserOrgId: p.UserOrgId,
|
|
3919
|
+ Status: 1,
|
|
3920
|
+ Ctime: time.Now().Unix(),
|
|
3921
|
+ Mtime: time.Now().Unix(),
|
|
3922
|
+ PatientId: p.PatientId,
|
|
3923
|
+ HisPatientId: p.HisPatientId,
|
|
3924
|
+ RecordDate: p.RecordDate,
|
|
3925
|
+ PrescriptionId: p.PrescriptionId,
|
|
3926
|
+ Count: p.Count,
|
|
3927
|
+ FeedetlSn: p.FeedetlSn,
|
|
3928
|
+ MedListCodg: p.MedListCodg,
|
|
3929
|
+ SingleDose: p.SingleDose,
|
|
3930
|
+ DeliveryWay: p.DeliveryWay,
|
|
3931
|
+ ExecutionFrequency: p.ExecutionFrequency,
|
|
3932
|
+ Day: p.Day,
|
|
3933
|
+ HisProject: models.HisProject{},
|
|
3934
|
+ GoodInfo: models.GoodInfo{},
|
|
3935
|
+ Remark: p.Remark,
|
|
3936
|
+ Unit: p.Unit,
|
|
3937
|
+ Type: p.Type,
|
|
3938
|
+ Doctor: p.Doctor,
|
|
3939
|
+ ExecutionTime: p.ExecutionTime,
|
|
3940
|
+ ExecutionStaff: p.ExecutionStaff,
|
|
3941
|
+ ExecutionState: p.ExecutionState,
|
|
3942
|
+ CheckTime: p.CheckTime,
|
|
3943
|
+ CheckState: p.CheckState,
|
|
3944
|
+ Checker: p.Checker,
|
|
3945
|
+ StartTime: p.StartTime,
|
|
3946
|
+ TeamId: p.TeamId,
|
|
3947
|
+ XtHisProjectTeam: models.XtHisProjectTeam{},
|
|
3948
|
+ FrequencyType: p.FrequencyType,
|
|
3949
|
+ DayCount: p.DayCount,
|
|
3950
|
+ WeekDay: p.WeekDay,
|
|
3951
|
+ IsCheckTeam: p.IsCheckTeam,
|
|
3952
|
+ HisOrderInfo: models.HisOrderInfo{},
|
|
3953
|
+ ExecutionFrequencyId: p.ExecutionFrequencyId,
|
|
3954
|
+ IsOut: p.IsOut,
|
|
3955
|
+ YbSyncStatus: p.YbSyncStatus,
|
|
3956
|
+ }
|
|
3957
|
+
|
|
3958
|
+ service.NewHisGoodCancelInfo(adminInfo.CurrentOrgId, creater, newPrescriptionProject, cha_count, goodObj, tx)
|
|
3959
|
+
|
|
3960
|
+ service.NewHisGoodAutoCancelInfo(adminInfo.CurrentOrgId, creater, newPrescriptionProject, cha_count, goodObj, tx)
|
|
3961
|
+
|
|
3962
|
+ }
|
|
3963
|
+
|
|
3964
|
+ if nowCount == historyCount {
|
|
3965
|
+ if historyCount == 0 {
|
|
3966
|
+ recordDateStr := time.Now().Format("2006-01-02")
|
|
3967
|
+ recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
|
|
3968
|
+ nowtime := recordDate.Unix()
|
|
3969
|
+ lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
|
|
3970
|
+ goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(p.ProjectId, tx)
|
|
3971
|
+ houseConfig, _ := service.GetNewAllStoreHouseConfig(p.UserOrgId, tx)
|
|
3972
|
+ creater := c.GetAdminUserInfo().AdminUser.Id
|
|
3973
|
+ dialyPrepareOne := models.DialysisBeforePrepare{
|
|
3974
|
+ GoodTypeId: goodObj.GoodTypeId,
|
|
3975
|
+ GoodId: p.ProjectId,
|
|
3976
|
+ PatientId: p.PatientId,
|
|
3977
|
+ RecordDate: p.RecordDate,
|
|
3978
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
3979
|
+ Count: nowCount,
|
|
3980
|
+ Ctime: time.Now().Unix(),
|
|
3981
|
+ Creater: creater,
|
|
3982
|
+ Status: 1,
|
|
3983
|
+ StorehouseId: houseConfig.StorehouseOutInfo,
|
|
3984
|
+ ProjectId: p.ID,
|
|
3985
|
+ }
|
|
3986
|
+ //出库
|
|
3987
|
+ service.ConsumableNewHisPrescriptionDelivery(adminInfo.CurrentOrgId, p.PatientId, p.RecordDate, &dialyPrepareOne, &lastOut, creater, tx)
|
|
3988
|
+ }
|
|
3989
|
+ }
|
|
3990
|
+
|
|
3991
|
+ lastHisProject, _ := service.GetLastHisProject(p.PatientId, p.UserOrgId, p.RecordDate, tx, p.ProjectId)
|
|
3992
|
+ //查询历史出库数据
|
|
3993
|
+ flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID)
|
|
3994
|
+
|
|
3995
|
+ var out_count_five int64
|
|
3996
|
+ for _, item := range flowGood {
|
|
3997
|
+ out_count_five += item.Count
|
|
3998
|
+ }
|
|
3999
|
+ parseIntCount, _ := strconv.ParseInt(p.Count, 10, 64)
|
|
4000
|
+
|
|
4001
|
+ //如果当前处方的出库数量和已经出库的数量不一致,需要进行退库或者出库
|
|
4002
|
+ if out_count_five != parseIntCount {
|
|
4003
|
+ service.UpdateNewAutomaticReduce(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID, tx)
|
|
4004
|
+ detail := models.AutomaticReduceDetail{
|
|
4005
|
+ WarehouseOutId: 0,
|
|
4006
|
+ WarehouseOutOrderNumber: "",
|
|
4007
|
+ PatientId: p.PatientId,
|
|
4008
|
+ Ctime: time.Now().Unix(),
|
|
4009
|
+ Mtime: 0,
|
|
4010
|
+ Status: 1,
|
|
4011
|
+ RecordTime: p.RecordDate,
|
|
4012
|
+ OrgId: p.UserOrgId,
|
|
4013
|
+ GoodId: p.ProjectId,
|
|
4014
|
+ GoodTypeId: 0,
|
|
4015
|
+ Count: parseIntCount,
|
|
4016
|
+ Type: 0,
|
|
4017
|
+ ProjectId: lastHisProject.ID,
|
|
4018
|
+ StorehouseId: 0,
|
|
4019
|
+ }
|
|
4020
|
+
|
|
4021
|
+ service.CreateNewAutoDetail(detail, tx)
|
|
4022
|
+ }
|
|
4023
|
+ // //查询耗材最后一次出库记录
|
|
4024
|
+ // wareOut, _ := service.GetLastGoodWarehouseOutInfoByProjectId(p.ProjectId, patient_id, recordDateTime, lastHisProject.ID)
|
|
4025
|
+ // //查询默认出库仓库库存
|
|
4026
|
+ // storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
|
|
4027
|
+ // if len(wareOut) > 0 {
|
|
4028
|
+ //
|
|
4029
|
+ // for _, it := range wareOut {
|
|
4030
|
+ // //回退库存
|
|
4031
|
+ // service.ModifyGoodWarehouseInfo(it.GoodId, it.WarehouseInfotId, it.OrgId, it.Count)
|
|
4032
|
+ //
|
|
4033
|
+ // //删除出库记录
|
|
4034
|
+ // service.DeleteGoodWarehouseOutInfo(it.GoodId, it.SysRecordTime, it.OrgId, it.ProjectId)
|
|
4035
|
+ //
|
|
4036
|
+ // }
|
|
4037
|
+ // }
|
|
4038
|
+ //
|
|
4039
|
+ // timeStr := time.Now().Format("2006-01-02")
|
|
4040
|
+ // timeArr := strings.Split(timeStr, "-")
|
|
4041
|
+ // total, _ := service.FindAllWarehouseOut(adminInfo.CurrentOrgId)
|
|
4042
|
+ //
|
|
4043
|
+ // total = total + 1
|
|
4044
|
+ // warehousing_out_order := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
|
4045
|
+ // number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
|
4046
|
+ // number = number + total
|
|
4047
|
+ // warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
|
|
4048
|
+ //
|
|
4049
|
+ // operation_time := time.Now().Unix()
|
|
4050
|
+ // creater := c.GetAdminUserInfo().AdminUser.Id
|
|
4051
|
+ //
|
|
4052
|
+ // recordDateStr := time.Now().Format("2006-01-02")
|
|
4053
|
+ // recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
|
|
4054
|
+ // nowtime := recordDate.Unix()
|
|
4055
|
+ // warehouseOut := models.WarehouseOut{
|
|
4056
|
+ // WarehouseOutOrderNumber: warehousing_out_order,
|
|
4057
|
+ // OperationTime: operation_time,
|
|
4058
|
+ // OrgId: adminInfo.CurrentOrgId,
|
|
4059
|
+ // Creater: creater,
|
|
4060
|
+ // Ctime: time.Now().Unix(),
|
|
4061
|
+ // Status: 1,
|
|
4062
|
+ // WarehouseOutTime: nowtime,
|
|
4063
|
+ // Type: 1,
|
|
4064
|
+ // StorehouseId: storeConfig.StorehouseOutInfo,
|
|
4065
|
+ // IsCheck: 1,
|
|
4066
|
+ // IsSys: 1,
|
|
4067
|
+ // }
|
|
4068
|
+ // //查询是否生成出库单
|
|
4069
|
+ // out, _ := service.FindNewPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
|
|
4070
|
+ // if out.ID == 0 {
|
|
4071
|
+ // service.AddNewSigleWarehouseOut(&warehouseOut, tx)
|
|
4072
|
+ // }
|
|
4073
|
+ //
|
|
4074
|
+ // lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
|
|
4075
|
+ //
|
|
4076
|
+ // goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(p.ProjectId, tx)
|
|
4077
|
+ // houseConfig, _ := service.GetNewAllStoreHouseConfig(p.UserOrgId, tx)
|
|
4078
|
+ //
|
|
4079
|
+ // dialyPrepareOne := models.DialysisBeforePrepare{
|
|
4080
|
+ // GoodTypeId: goodObj.GoodTypeId,
|
|
4081
|
+ // GoodId: p.ProjectId,
|
|
4082
|
+ // PatientId: p.PatientId,
|
|
4083
|
+ // RecordDate: p.RecordDate,
|
|
4084
|
+ // UserOrgId: adminInfo.CurrentOrgId,
|
|
4085
|
+ // Count: parseIntCount,
|
|
4086
|
+ // Ctime: time.Now().Unix(),
|
|
4087
|
+ // Creater: creater,
|
|
4088
|
+ // Status: 1,
|
|
4089
|
+ // StorehouseId: houseConfig.StorehouseOutInfo,
|
|
4090
|
+ // ProjectId: lastHisProject.ID,
|
|
4091
|
+ // }
|
|
4092
|
+ // //判断是否是零用耗材(非零用)
|
|
4093
|
+ // if goodObj.IsUse == 2 || goodObj.IsUse == 0 {
|
|
4094
|
+ //
|
|
4095
|
+ // //查询历史出库数据
|
|
4096
|
+ // flowGood, _ := service.GetNewStockFlowIsBatchNumberSeventy(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID, tx)
|
|
4097
|
+ // var out_count int64
|
|
4098
|
+ // for _, item := range flowGood {
|
|
4099
|
+ // out_count += item.Count
|
|
4100
|
+ // }
|
|
4101
|
+ // //如果历史数和当前数据不想等才进行退库出库
|
|
4102
|
+ // if out_count != parseIntCount {
|
|
4103
|
+ // service.ConsumableNewPrescriptionDelivery(adminInfo.CurrentOrgId, p.PatientId, p.RecordDate, &dialyPrepareOne, &lastOut, creater, parseIntCount, tx)
|
|
4104
|
+ //
|
|
4105
|
+ // service.UpdateNewAutomaticReduce(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID, tx)
|
|
4106
|
+ // detail := models.AutomaticReduceDetail{
|
|
4107
|
+ // WarehouseOutId: 0,
|
|
4108
|
+ // WarehouseOutOrderNumber: "",
|
|
4109
|
+ // PatientId: p.PatientId,
|
|
4110
|
+ // Ctime: time.Now().Unix(),
|
|
4111
|
+ // Mtime: 0,
|
|
4112
|
+ // Status: 1,
|
|
4113
|
+ // RecordTime: p.RecordDate,
|
|
4114
|
+ // OrgId: p.UserOrgId,
|
|
4115
|
+ // GoodId: p.ProjectId,
|
|
4116
|
+ // GoodTypeId: 0,
|
|
4117
|
+ // Count: parseIntCount,
|
|
4118
|
+ // Type: 0,
|
|
4119
|
+ // ProjectId: lastHisProject.ID,
|
|
4120
|
+ // StorehouseId: 0,
|
|
4121
|
+ // }
|
|
4122
|
+ //
|
|
4123
|
+ // service.CreateNewAutoDetail(detail, tx)
|
|
4124
|
+ //
|
|
4125
|
+ // //查询剩余库存
|
|
4126
|
+ // goodList, _ := service.GetNewAllGoodSumCount(p.ProjectId, adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, tx)
|
|
4127
|
+ // var sum_count int64
|
|
4128
|
+ // for _, item := range goodList {
|
|
4129
|
+ // sum_count += item.StockCount
|
|
4130
|
+ // }
|
|
4131
|
+ //
|
|
4132
|
+ // //更新剩余库存
|
|
4133
|
+ // service.UpdateNewGoodFlushCount(houseConfig.StorehouseOutInfo, p.ProjectId, adminInfo.CurrentOrgId, sum_count, tx)
|
|
4134
|
+ //
|
|
4135
|
+ // //耗材
|
|
4136
|
+ // service.UpdateNewGoodSumCountSeven(sum_count, p.ProjectId, adminInfo.CurrentOrgId, tx)
|
|
4137
|
+ //
|
|
4138
|
+ // }
|
|
4139
|
+ // //判断是否是零用耗材(零用但是是出库耗材)
|
|
4140
|
+ // if goodObj.IsUse == 1 && goodObj.IsWarehouse == 1 {
|
|
4141
|
+ //
|
|
4142
|
+ // //查询历史出库数据
|
|
4143
|
+ // flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID)
|
|
4144
|
+ // var out_count int64
|
|
4145
|
+ // for _, item := range flowGood {
|
|
4146
|
+ // out_count += item.Count
|
|
4147
|
+ // }
|
|
4148
|
+ // //如果历史数和当前数据不想等才进行退库出库
|
|
4149
|
+ // if out_count != parseIntCount {
|
|
4150
|
+ // service.ConsumableNewPrescriptionDelivery(adminInfo.CurrentOrgId, p.PatientId, p.RecordDate, &dialyPrepareOne, &lastOut, creater, parseIntCount, tx)
|
|
4151
|
+ //
|
|
4152
|
+ // service.UpdateNewAutomaticReduce(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID, tx)
|
|
4153
|
+ // detail := models.AutomaticReduceDetail{
|
|
4154
|
+ // WarehouseOutId: 0,
|
|
4155
|
+ // WarehouseOutOrderNumber: "",
|
|
4156
|
+ // PatientId: p.PatientId,
|
|
4157
|
+ // Ctime: time.Now().Unix(),
|
|
4158
|
+ // Mtime: 0,
|
|
4159
|
+ // Status: 1,
|
|
4160
|
+ // RecordTime: p.RecordDate,
|
|
4161
|
+ // OrgId: p.UserOrgId,
|
|
4162
|
+ // GoodId: p.ProjectId,
|
|
4163
|
+ // GoodTypeId: 0,
|
|
4164
|
+ // Count: parseIntCount,
|
|
4165
|
+ // Type: 0,
|
|
4166
|
+ // ProjectId: p.ID,
|
|
4167
|
+ // StorehouseId: 0,
|
|
4168
|
+ // }
|
|
4169
|
+ //
|
|
4170
|
+ // service.CreateNewAutoDetail(detail, tx)
|
|
4171
|
+ //
|
|
4172
|
+ // //查询剩余库存
|
|
4173
|
+ // goodList, _ := service.GetNewAllGoodSumCount(p.ProjectId, adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, tx)
|
|
4174
|
+ // var sum_count int64
|
|
4175
|
+ // for _, item := range goodList {
|
|
4176
|
+ // sum_count += item.StockCount
|
|
4177
|
+ // }
|
|
4178
|
+ //
|
|
4179
|
+ // //更新剩余库存
|
|
4180
|
+ // service.UpdateNewGoodFlushCount(houseConfig.StorehouseOutInfo, p.ProjectId, adminInfo.CurrentOrgId, sum_count, tx)
|
|
4181
|
+ //
|
|
4182
|
+ // //耗材
|
|
4183
|
+ // service.UpdateNewGoodSumCountSeven(sum_count, p.ProjectId, adminInfo.CurrentOrgId, tx)
|
|
4184
|
+ // }
|
|
4185
|
+ //
|
|
4186
|
+ // }
|
|
4187
|
+ //
|
|
4188
|
+ // }
|
|
4189
|
+ //
|
|
4190
|
+ //}
|
|
4191
|
+
|
|
4192
|
+ //记录日志
|
|
4193
|
+ byterequest, _ := json.Marshal(p)
|
|
4194
|
+ adviceLog := models.XtDoctorAdviceLog{
|
|
4195
|
+ UserOrgId: p.UserOrgId,
|
|
4196
|
+ PatientId: p.PatientId,
|
|
4197
|
+ AdminUserId: adminInfo.AdminUser.Id,
|
|
4198
|
+ Module: 1,
|
|
4199
|
+ ErrLog: string(byterequest),
|
|
4200
|
+ Status: 1,
|
|
4201
|
+ Ctime: time.Now().Unix(),
|
|
4202
|
+ Mtime: 0,
|
|
4203
|
+ Source: "电脑端新建his项目",
|
|
4204
|
+ RecordDate: p.RecordDate,
|
|
4205
|
+ }
|
|
4206
|
+ service.CreateDoctorAdviceLog(adviceLog)
|
|
4207
|
+
|
|
4208
|
+ projectList = append(projectList, p)
|
|
4209
|
+
|
|
4210
|
+ if p.Type == 2 { //因为项目和耗材的基础库存在id相同的情况,所以需要根据该字段来判断,type为2的话为从项目开出来的
|
|
4211
|
+ //新增或者编辑项目,修改对应的标签数据
|
|
4212
|
+ labelOrigin, _ := service.GetProjectById(p.UserOrgId, p.ID, patient_id, recordDateTime)
|
|
4213
|
+ if labelOrigin.ID == 0 { //当天某个人的处方中的项目不存在
|
|
4214
|
+ var label models.HisLabelPrintInfo
|
|
4215
|
+ project, _ := service.GetProjectDetail(p.ProjectId)
|
|
4216
|
+ if project.CostClassify == 3 { //类别为检验检查
|
|
4217
|
+ if p.TeamId > 0 { //检验检查组套
|
|
4218
|
+ tempLabel, _ := service.GetProjectByTeamId(p.UserOrgId, p.TeamId, patient_id, recordDateTime)
|
|
4219
|
+ if tempLabel.ID == 0 {
|
|
4220
|
+ team, _ := service.GetProjectTeamDetail(p.TeamId)
|
|
4221
|
+ label.Number = tempPrescription.PrescriptionNumber
|
|
4222
|
+ label.ProjectId = project.ID
|
|
4223
|
+ label.Status = 1
|
|
4224
|
+ label.IsPrint = 2
|
|
4225
|
+ label.DoctorId = info.DoctorId
|
|
4226
|
+ label.UserOrgId = p.UserOrgId
|
|
4227
|
+ label.PatientId = patient_id
|
|
4228
|
+ label.RecordDate = recordDateTime
|
|
4229
|
+ label.Ctime = time.Now().Unix()
|
|
4230
|
+ label.Mtime = time.Now().Unix()
|
|
4231
|
+ label.ItemId = p.TeamId
|
|
4232
|
+ label.FeedetlSn = p.FeedetlSn
|
|
4233
|
+ label.PProjectId = p.ID
|
|
4234
|
+ label.ProjectName = team.ProjectTeam
|
|
4235
|
+ label.PatientName = patient.Name
|
|
4236
|
+ service.CreateNewHisLabelRecord(&label, tx)
|
|
4237
|
+ }
|
|
4238
|
+ } else { //单条检验检查项目
|
|
4239
|
+ label.Number = tempPrescription.PrescriptionNumber
|
|
4240
|
+ label.ProjectId = project.ID
|
|
4241
|
+ label.Status = 1
|
|
4242
|
+ label.DoctorId = info.DoctorId
|
|
4243
|
+ label.UserOrgId = p.UserOrgId
|
|
4244
|
+ label.PatientId = patient_id
|
|
4245
|
+ label.RecordDate = recordDateTime
|
|
4246
|
+ label.IsPrint = 2
|
|
4247
|
+ label.Ctime = time.Now().Unix()
|
|
4248
|
+ label.Mtime = time.Now().Unix()
|
|
4249
|
+ label.FeedetlSn = p.FeedetlSn
|
|
4250
|
+ label.PProjectId = p.ID
|
|
4251
|
+ label.ItemId = p.TeamId
|
|
4252
|
+ label.ProjectName = project.ProjectName
|
|
4253
|
+ label.PatientName = patient.Name
|
|
4254
|
+ service.CreateNewHisLabelRecord(&label, tx)
|
|
4255
|
+ }
|
|
4256
|
+ }
|
|
4257
|
+ }
|
|
4258
|
+ }
|
|
4259
|
+
|
|
4260
|
+ }
|
|
4261
|
+ }
|
|
4262
|
+ }
|
|
4263
|
+
|
|
4264
|
+ if adminInfo.CurrentOrgId == 10721 || adminInfo.CurrentOrgId == 10164 {
|
|
4265
|
+
|
3828
|
4266
|
//耗材出库
|
3829
|
4267
|
if p.Type == 3 {
|
3830
|
4268
|
|
|
@@ -3836,9 +4274,6 @@ func (c *HisApiController) CreateHisPrescription() {
|
3836
|
4274
|
|
3837
|
4275
|
nowCount, _ := strconv.ParseInt(p.Count, 10, 64)
|
3838
|
4276
|
|
3839
|
|
- //fmt.Println("p----------------------------------------------------", p.ProjectId)
|
3840
|
|
- //fmt.Println("p----------------------------------------------------", nowCount)
|
3841
|
|
- //fmt.Println("p----------------------------------------------------", historyCount)
|
3842
|
4277
|
//如果当前处方数量大于历史数据,则需要出库
|
3843
|
4278
|
if nowCount > historyCount {
|
3844
|
4279
|
|
|
@@ -3998,9 +4433,6 @@ func (c *HisApiController) CreateHisPrescription() {
|
3998
|
4433
|
}
|
3999
|
4434
|
parseIntCount, _ := strconv.ParseInt(p.Count, 10, 64)
|
4000
|
4435
|
|
4001
|
|
- //fmt.Println("p.ProjectId-----------------", p.ProjectId)
|
4002
|
|
- //fmt.Println("out_count_five===============", out_count_five)
|
4003
|
|
- //fmt.Println("parseIntCount===============", parseIntCount)
|
4004
|
4436
|
//如果当前处方的出库数量和已经出库的数量不一致,需要进行退库或者出库
|
4005
|
4437
|
if out_count_five != parseIntCount {
|
4006
|
4438
|
service.UpdateNewAutomaticReduce(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID, tx)
|
|
@@ -4262,6 +4694,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
4262
|
4694
|
|
4263
|
4695
|
}
|
4264
|
4696
|
}
|
|
4697
|
+
|
4265
|
4698
|
}
|
4266
|
4699
|
|
4267
|
4700
|
//插入检验数据
|