|
@@ -3176,6 +3176,175 @@ func GetNowTime() (int64, int64) {
|
3176
|
3176
|
// })
|
3177
|
3177
|
// }
|
3178
|
3178
|
//}
|
|
3179
|
+func (c *HisApiController) ChangeDrugfour() {
|
|
3180
|
+ patient_id, _ := c.GetInt64("patient_id")
|
|
3181
|
+ admin_user_id, _ := c.GetInt64("admin_user_id")
|
|
3182
|
+ //id_arr := strings.Split(ids, ",")
|
|
3183
|
+ times := c.GetString("time", "")
|
|
3184
|
+ timeLayout := "2006-01-02"
|
|
3185
|
+ loc, _ := time.LoadLocation("Local")
|
|
3186
|
+ var stime, etime int64
|
|
3187
|
+ if times == "" {
|
|
3188
|
+ stime, etime = GetNowTime()
|
|
3189
|
+ } else {
|
|
3190
|
+ stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
|
|
3191
|
+ stime = stmp.Unix()
|
|
3192
|
+ etime = stime + 86399
|
|
3193
|
+ }
|
|
3194
|
+ advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
|
|
3195
|
+ var flows []*models.DrugFlow
|
|
3196
|
+ for _, item := range advicelist {
|
|
3197
|
+ flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
|
|
3198
|
+ flows = append(flows, flow...)
|
|
3199
|
+ }
|
|
3200
|
+ roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
|
|
3201
|
+ miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
|
|
3202
|
+ var err []string
|
|
3203
|
+
|
|
3204
|
+ for _, item := range flows {
|
|
3205
|
+ var res3 ResultSix
|
|
3206
|
+ if item.ConsumableType == 3 { //3为自动出库 7为自动退库
|
|
3207
|
+ prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
|
|
3208
|
+ if prescription.OrderStatus == 2 {
|
|
3209
|
+ //已经结算
|
|
3210
|
+ //判断是否已经销售
|
|
3211
|
+ if item.IsSale == 1 { //是否已经销售,1是 0否
|
|
3212
|
+ //是否已经变更 1是 0否
|
|
3213
|
+ if item.IsChange == 0 { //没变更,进行变更操作
|
|
3214
|
+ bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
|
|
3215
|
+
|
|
3216
|
+ result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
|
|
3217
|
+ saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
|
|
3218
|
+ var respJSON3 map[string]interface{}
|
|
3219
|
+ if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
|
|
3220
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
3221
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
3222
|
+ return
|
|
3223
|
+ }
|
|
3224
|
+ userJSONBytes3, _ := json.Marshal(respJSON3)
|
|
3225
|
+ if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
|
|
3226
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
3227
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
3228
|
+ return
|
|
3229
|
+ }
|
|
3230
|
+ if res3.Infcode == 0 {
|
|
3231
|
+ item.IsChange = 1
|
|
3232
|
+ item.BgBchno = bg_number
|
|
3233
|
+ service.SaveDF2(item)
|
|
3234
|
+ } else {
|
|
3235
|
+
|
|
3236
|
+ err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
|
|
3237
|
+ }
|
|
3238
|
+ }
|
|
3239
|
+ } else { //没销售,
|
|
3240
|
+ var res FJ3507Result
|
|
3241
|
+ var res3507for10188 FJ3507ResultFor10188
|
|
3242
|
+ number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
|
|
3243
|
+
|
|
3244
|
+ //进行商品销售接口
|
|
3245
|
+ result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
|
|
3246
|
+ saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
|
|
3247
|
+ var respJSON3 map[string]interface{}
|
|
3248
|
+ if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
|
|
3249
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
3250
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
3251
|
+ return
|
|
3252
|
+ }
|
|
3253
|
+ userJSONBytes3, _ := json.Marshal(respJSON3)
|
|
3254
|
+ if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
|
|
3255
|
+ if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
|
|
3256
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
3257
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
3258
|
+ return
|
|
3259
|
+ }
|
|
3260
|
+ //if res3507for10188.Infcode
|
|
3261
|
+ res.InfRefmsgid = res3507for10188.InfRefmsgid
|
|
3262
|
+ //res.Output = resSix10265.Output
|
|
3263
|
+ res.ErrMsg = res3507for10188.ErrMsg
|
|
3264
|
+ res.Cainfo = res3507for10188.Cainfo
|
|
3265
|
+ res.WarnMsg = res3507for10188.WarnMsg
|
|
3266
|
+ infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
|
|
3267
|
+ res.Infcode = infocode
|
|
3268
|
+ } else {
|
|
3269
|
+ if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
|
|
3270
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
3271
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
3272
|
+ return
|
|
3273
|
+ }
|
|
3274
|
+
|
|
3275
|
+ }
|
|
3276
|
+ if res.Infcode == 0 {
|
|
3277
|
+ item.IsSale = 1
|
|
3278
|
+ item.Bchno = number
|
|
3279
|
+ item.SaleDate = time.Now().Format("2006-01-02")
|
|
3280
|
+
|
|
3281
|
+ err5 := service.SaveDF(item)
|
|
3282
|
+ if err5 == nil {
|
|
3283
|
+ if item.IsChange == 0 { //没变更,进行变更操作
|
|
3284
|
+ bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
|
|
3285
|
+
|
|
3286
|
+ result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
|
|
3287
|
+ saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
|
|
3288
|
+
|
|
3289
|
+ var respJSON3 map[string]interface{}
|
|
3290
|
+ if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
|
|
3291
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
3292
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
3293
|
+ return
|
|
3294
|
+ }
|
|
3295
|
+ if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
|
|
3296
|
+ if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
|
|
3297
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
3298
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
3299
|
+ return
|
|
3300
|
+ }
|
|
3301
|
+ //if res3507for10188.Infcode
|
|
3302
|
+ res3.InfRefmsgid = res3507for10188.InfRefmsgid
|
|
3303
|
+ //res.Output = resSix10265.Output
|
|
3304
|
+ res3.ErrMsg = res3507for10188.ErrMsg
|
|
3305
|
+ res3.Cainfo = res3507for10188.Cainfo
|
|
3306
|
+ res3.WarnMsg = res3507for10188.WarnMsg
|
|
3307
|
+ infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
|
|
3308
|
+ res3.Infcode = infocode
|
|
3309
|
+ } else {
|
|
3310
|
+ if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
|
|
3311
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
3312
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
3313
|
+ return
|
|
3314
|
+ }
|
|
3315
|
+ }
|
|
3316
|
+ if res3.Infcode == 0 {
|
|
3317
|
+ item.IsChange = 1
|
|
3318
|
+ item.BgBchno = bg_number
|
|
3319
|
+ service.SaveDF2(item)
|
|
3320
|
+ } else {
|
|
3321
|
+
|
|
3322
|
+ err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
|
|
3323
|
+ }
|
|
3324
|
+ }
|
|
3325
|
+ }
|
|
3326
|
+ } else {
|
|
3327
|
+
|
|
3328
|
+ err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
|
|
3329
|
+ }
|
|
3330
|
+ }
|
|
3331
|
+
|
|
3332
|
+ } else { //还没结,提示用户去结算,并药品追溯上传
|
|
3333
|
+ err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
|
|
3334
|
+ }
|
|
3335
|
+ }
|
|
3336
|
+ }
|
|
3337
|
+ if len(err) == 0 {
|
|
3338
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
3339
|
+ "msg": "销售变更成功",
|
|
3340
|
+ })
|
|
3341
|
+ } else {
|
|
3342
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
3343
|
+ "failed_code": -10,
|
|
3344
|
+ "msg": err,
|
|
3345
|
+ })
|
|
3346
|
+ }
|
|
3347
|
+}
|
3179
|
3348
|
|
3180
|
3349
|
func (c *HisApiController) ChangeDrug() {
|
3181
|
3350
|
ids := c.GetString("ids")
|
|
@@ -4445,7 +4614,9 @@ func (c *HisApiController) ChangeDrugTen() {
|
4445
|
4614
|
|
4446
|
4615
|
//ids := c.GetString("ids")
|
4447
|
4616
|
//id_arr := strings.Split(ids, ",")
|
4448
|
|
- flows, _ := service.GetNewDrugFlowInforTen()
|
|
4617
|
+ now := time.Now()
|
|
4618
|
+ timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
|
|
4619
|
+ flows, _ := service.GetNewDrugFlowInforTen(timestamp)
|
4449
|
4620
|
admin_user_id, _ := c.GetInt64("admin_user_id")
|
4450
|
4621
|
roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
|
4451
|
4622
|
miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
|