|
@@ -2,10 +2,13 @@ package controllers
|
2
|
2
|
|
3
|
3
|
import (
|
4
|
4
|
"XT_New/enums"
|
|
5
|
+ "XT_New/models"
|
5
|
6
|
"XT_New/service"
|
6
|
7
|
"XT_New/utils"
|
7
|
8
|
"fmt"
|
8
|
9
|
"github.com/astaxie/beego"
|
|
10
|
+ "math"
|
|
11
|
+ "strconv"
|
9
|
12
|
"strings"
|
10
|
13
|
"time"
|
11
|
14
|
)
|
|
@@ -16,9 +19,18 @@ type PharmacyApiController struct {
|
16
|
19
|
|
17
|
20
|
func PharmacyApiControllersRegisterRouters() {
|
18
|
21
|
|
|
22
|
+ //获取设置为药房发药的药品数据
|
19
|
23
|
beego.Router("/api/advice/gettodayadvicelist", &PharmacyApiController{}, "Get:GetTodayAdviceList")
|
|
24
|
+ //获取今日未发药的数据
|
20
|
25
|
beego.Router("api/advice/getpharmacybasedrug", &PharmacyApiController{}, "Get:GetPharyMacyBaseDrug")
|
|
26
|
+ //发药
|
21
|
27
|
beego.Router("/api/advice/updatepharmacybasedrug", &PharmacyApiController{}, "Get:UpdatePharmacyBaseDrug")
|
|
28
|
+
|
|
29
|
+ //获取今日已发药的数据
|
|
30
|
+ beego.Router("api/advice/getpharmacybasedruglist", &PharmacyApiController{}, "Get:GetPharmacyBaseDrugList")
|
|
31
|
+ //退药流程
|
|
32
|
+ beego.Router("/api/advice/getreturnpharmacybasedrug", &PharmacyApiController{}, "Get:GetReturnPharmacyBaseDrug")
|
|
33
|
+
|
22
|
34
|
}
|
23
|
35
|
|
24
|
36
|
func (this *PharmacyApiController) GetTodayAdviceList() {
|
|
@@ -105,139 +117,348 @@ func (this *PharmacyApiController) UpdatePharmacyBaseDrug() {
|
105
|
117
|
adviceList, _ := service.GetPharmacyAdviceList(idArray, orgId)
|
106
|
118
|
|
107
|
119
|
hisAdviceList, _ := service.GetPharmacyHisAdviceList(idArray, orgId)
|
108
|
|
- fmt.Print(hisAdviceList)
|
|
120
|
+
|
109
|
121
|
//查询是否通过药房出库
|
110
|
122
|
pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
|
111
|
|
-
|
112
|
|
- medical, _ := service.GetBaseDrugMedical(orgId)
|
113
|
|
- fmt.Print(medical)
|
|
123
|
+ creater := this.GetAdminUserInfo().AdminUser.Id
|
114
|
124
|
if pharmacyConfig.IsOpen == 1 {
|
|
125
|
+ var total int64
|
|
126
|
+ var prescribing_number_total int64
|
|
127
|
+ //创建流水
|
|
128
|
+ timeStr := time.Now().Format("2006-01-02")
|
|
129
|
+ timeArr := strings.Split(timeStr, "-")
|
|
130
|
+ totals, _ := service.FindAllPharmacyDrugWarehouseOut(orgId)
|
|
131
|
+ totals = totals + 1
|
|
132
|
+ warehousing_out_order := strconv.FormatInt(orgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
|
133
|
+ number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
|
134
|
+ number = number + totals
|
|
135
|
+ warehousing_out_order = "FY" + strconv.FormatInt(number, 10)
|
115
|
136
|
|
|
137
|
+ //血透
|
116
|
138
|
for _, item := range adviceList {
|
117
|
|
- fmt.Print(item)
|
118
|
|
- //houseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
|
|
139
|
+
|
|
140
|
+ pharmacy := models.Pharmacy{
|
|
141
|
+ UserOrgId: item.UserOrgId,
|
|
142
|
+ PatientId: item.PatientId,
|
|
143
|
+ HisPrescriptionId: 0,
|
|
144
|
+ XtAdviceId: item.ID,
|
|
145
|
+ HisOrXt: 1,
|
|
146
|
+ Ctime: time.Now().Unix(),
|
|
147
|
+ Mtime: 0,
|
|
148
|
+ Status: 1,
|
|
149
|
+ HisAdviceId: 0,
|
|
150
|
+ DrugId: item.DrugId,
|
|
151
|
+ RecordDate: item.AdviceDate,
|
|
152
|
+ OrdreNumber: warehousing_out_order,
|
|
153
|
+ Creater: creater,
|
|
154
|
+ }
|
|
155
|
+
|
|
156
|
+ service.CreatePharmacy(pharmacy)
|
|
157
|
+
|
|
158
|
+ lastPharmacy, _ := service.GetLastPharmary(item.UserOrgId, item.ID, item.AdviceDate)
|
|
159
|
+
|
|
160
|
+ houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
|
119
|
161
|
////查询该药品是否有库存
|
120
|
|
- //list, _ := service.GetDrugTotalCountTwenty(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
|
|
162
|
+ list, _ := service.GetDrugTotalCountTwenty(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
|
121
|
163
|
//
|
122
|
164
|
////查询改药品信息
|
123
|
|
- //medical, _ := service.GetBaseDrugMedical(item.DrugId)
|
|
165
|
+ medical, _ := service.GetBaseDrugMedical(item.DrugId)
|
124
|
166
|
////判断单位是否相等
|
125
|
|
- //if medical.MaxUnit == item.PrescribingNumberUnit {
|
126
|
|
- // prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
127
|
|
- // count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
128
|
|
- // //转化为最小单位
|
129
|
|
- // total = list.Count*medical.MinNumber + list.StockMinNumber
|
130
|
|
- // prescribing_number_total = count * medical.MinNumber
|
131
|
|
- //}
|
132
|
|
- //if medical.MinUnit == item.PrescribingNumberUnit {
|
133
|
|
- // prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
|
134
|
|
- // count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
135
|
|
- // total = list.Count*medical.MinNumber + list.StockMinNumber
|
136
|
|
- // prescribing_number_total = count
|
137
|
|
- //}
|
138
|
|
- //
|
139
|
|
- //if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
|
140
|
|
- // c.ServeSuccessJSON(map[string]interface{}{
|
141
|
|
- // "msg": "3",
|
142
|
|
- // "advice": advice,
|
143
|
|
- // })
|
144
|
|
- // return
|
145
|
|
- //}
|
146
|
|
- //if prescribing_number_total > total {
|
147
|
|
- // c.ServeSuccessJSON(map[string]interface{}{
|
148
|
|
- // "msg": "2",
|
149
|
|
- // "advice": advice,
|
150
|
|
- // })
|
151
|
|
- // return
|
152
|
|
- //}
|
153
|
|
- //if prescribing_number_total <= total {
|
154
|
|
- //
|
155
|
|
- // //查询是否门诊处方和临时医嘱同步到透析医嘱的开关是否开启
|
156
|
|
- //
|
157
|
|
- // adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
|
158
|
|
- // if adviceSetting.IsAdviceOpen == 1 {
|
159
|
|
- //
|
160
|
|
- // //查询是否出库按钮开启
|
161
|
|
- // prescriptionConfig, _ := service.FindPrescriptionConfigById(item.UserOrgId)
|
162
|
|
- // if prescriptionConfig.IsOpen == 1 {
|
163
|
|
- // if medical.IsUse == 2 {
|
164
|
|
- // service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
|
165
|
|
- // //查询默认仓库
|
166
|
|
- // houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
|
167
|
|
- // //查询默认仓库剩余多少库存
|
168
|
|
- // list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
169
|
|
- // var sum_count int64
|
170
|
|
- // var sum_in_count int64
|
171
|
|
- // for _, it := range list {
|
172
|
|
- // baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
|
173
|
|
- // if it.MaxUnit == baseDrug.MaxUnit {
|
174
|
|
- // it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
|
175
|
|
- // it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
|
176
|
|
- // }
|
177
|
|
- // sum_count += it.StockMaxNumber + it.StockMinNumber
|
178
|
|
- // sum_in_count += it.WarehousingCount
|
179
|
|
- // }
|
180
|
|
- // service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
|
181
|
|
- // break
|
182
|
|
- // c.ServeSuccessJSON(map[string]interface{}{
|
183
|
|
- // "msg": "1",
|
184
|
|
- // "advice": advice,
|
185
|
|
- // })
|
186
|
|
- // return
|
187
|
|
- // }
|
188
|
|
- // if medical.IsUse == 1 {
|
189
|
|
- // c.ServeSuccessJSON(map[string]interface{}{
|
190
|
|
- // "msg": "1",
|
191
|
|
- // "advice": advice,
|
192
|
|
- // })
|
193
|
|
- // return
|
194
|
|
- // }
|
195
|
|
- // } else {
|
196
|
|
- // if medical.IsUse == 1 {
|
197
|
|
- // c.ServeSuccessJSON(map[string]interface{}{
|
198
|
|
- // "msg": "1",
|
199
|
|
- // "advice": advice,
|
200
|
|
- // })
|
201
|
|
- // return
|
202
|
|
- // }
|
203
|
|
- // }
|
|
167
|
+ if medical.MaxUnit == item.PrescribingNumberUnit {
|
|
168
|
+ prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
|
169
|
+ count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
|
170
|
+ //转化为最小单位
|
|
171
|
+ total = list.Count*medical.MinNumber + list.StockMinNumber
|
|
172
|
+ prescribing_number_total = count * medical.MinNumber
|
|
173
|
+ }
|
|
174
|
+ if medical.MinUnit == item.PrescribingNumberUnit {
|
|
175
|
+ prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
|
176
|
+ count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
|
177
|
+ total = list.Count*medical.MinNumber + list.StockMinNumber
|
|
178
|
+ prescribing_number_total = count
|
|
179
|
+ }
|
|
180
|
+
|
|
181
|
+ if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
|
|
182
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
183
|
+ "msg": "3",
|
|
184
|
+ "medical": medical,
|
|
185
|
+ })
|
|
186
|
+ return
|
|
187
|
+ }
|
|
188
|
+ if prescribing_number_total > total {
|
|
189
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
190
|
+ "msg": "2",
|
|
191
|
+ "medical": medical,
|
|
192
|
+ })
|
|
193
|
+ return
|
|
194
|
+ }
|
|
195
|
+
|
|
196
|
+ if prescribing_number_total <= total {
|
|
197
|
+
|
|
198
|
+ //查询是否门诊处方和临时医嘱同步到透析医嘱的开关是否开启
|
|
199
|
+ adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
|
|
200
|
+ if adviceSetting.IsAdviceOpen == 1 {
|
|
201
|
+ if medical.IsUse == 2 {
|
|
202
|
+ service.PharmacyDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item, lastPharmacy.ID)
|
|
203
|
+ //查询默认仓库
|
|
204
|
+ houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
|
|
205
|
+ //查询默认仓库剩余多少库存
|
|
206
|
+ list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
|
207
|
+ var sum_count int64
|
|
208
|
+ var sum_in_count int64
|
|
209
|
+ for _, it := range list {
|
|
210
|
+ baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
|
|
211
|
+ if it.MaxUnit == baseDrug.MaxUnit {
|
|
212
|
+ it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
|
|
213
|
+ it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
|
|
214
|
+ }
|
|
215
|
+ sum_count += it.StockMaxNumber + it.StockMinNumber
|
|
216
|
+ sum_in_count += it.WarehousingCount
|
|
217
|
+ }
|
|
218
|
+ service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
|
|
219
|
+ break
|
|
220
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
221
|
+ "msg": "1",
|
|
222
|
+ "medical": medical,
|
|
223
|
+ })
|
|
224
|
+ return
|
|
225
|
+ }
|
|
226
|
+ if medical.IsUse == 1 {
|
|
227
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
228
|
+ "msg": "1",
|
|
229
|
+ })
|
|
230
|
+ return
|
|
231
|
+ }
|
|
232
|
+
|
|
233
|
+ } else {
|
|
234
|
+ if medical.IsUse == 2 {
|
|
235
|
+ service.PharmacyDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item, lastPharmacy.ID)
|
|
236
|
+ //查询默认仓库
|
|
237
|
+ houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
|
|
238
|
+ //查询默认仓库剩余多少库存
|
|
239
|
+ list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
|
240
|
+ var sum_count int64
|
|
241
|
+ var sum_in_count int64
|
|
242
|
+ for _, it := range list {
|
|
243
|
+ baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
|
|
244
|
+ if it.MaxUnit == baseDrug.MaxUnit {
|
|
245
|
+ it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
|
|
246
|
+ it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
|
|
247
|
+ }
|
|
248
|
+ sum_count += it.StockMaxNumber + it.StockMinNumber
|
|
249
|
+ sum_in_count += it.WarehousingCount
|
|
250
|
+ }
|
|
251
|
+ service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
|
|
252
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
253
|
+ "msg": "1",
|
|
254
|
+ "medical": medical,
|
|
255
|
+ })
|
|
256
|
+ return
|
|
257
|
+ }
|
|
258
|
+ if medical.IsUse == 1 {
|
|
259
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
260
|
+ "msg": "1",
|
|
261
|
+ "medical": medical,
|
|
262
|
+ })
|
|
263
|
+ return
|
|
264
|
+ }
|
|
265
|
+ }
|
|
266
|
+ }
|
|
267
|
+ }
|
|
268
|
+
|
|
269
|
+ //血透
|
|
270
|
+ for _, item := range hisAdviceList {
|
|
271
|
+
|
|
272
|
+ pharmacy := models.Pharmacy{
|
|
273
|
+ UserOrgId: item.UserOrgId,
|
|
274
|
+ PatientId: item.PatientId,
|
|
275
|
+ HisPrescriptionId: 0,
|
|
276
|
+ XtAdviceId: 0,
|
|
277
|
+ HisOrXt: 2,
|
|
278
|
+ Ctime: time.Now().Unix(),
|
|
279
|
+ Mtime: 0,
|
|
280
|
+ Status: 1,
|
|
281
|
+ HisAdviceId: item.ID,
|
|
282
|
+ DrugId: item.DrugId,
|
|
283
|
+ RecordDate: item.AdviceDate,
|
|
284
|
+ OrdreNumber: warehousing_out_order,
|
|
285
|
+ Creater: creater,
|
|
286
|
+ }
|
|
287
|
+
|
|
288
|
+ service.CreatePharmacy(pharmacy)
|
|
289
|
+
|
|
290
|
+ lastPharmary, _ := service.GetLastHisPharmary(item.UserOrgId, item.ID, item.AdviceDate)
|
|
291
|
+
|
|
292
|
+ houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
|
|
293
|
+ ////查询该药品是否有库存
|
|
294
|
+ list, _ := service.GetDrugTotalCountTwenty(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
|
204
|
295
|
//
|
205
|
|
- // } else {
|
206
|
|
- // if medical.IsUse == 2 {
|
207
|
|
- // service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
|
208
|
|
- // //查询默认仓库
|
209
|
|
- // houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
|
210
|
|
- // //查询默认仓库剩余多少库存
|
211
|
|
- // list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
212
|
|
- // var sum_count int64
|
213
|
|
- // var sum_in_count int64
|
214
|
|
- // for _, it := range list {
|
215
|
|
- // baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
|
216
|
|
- // if it.MaxUnit == baseDrug.MaxUnit {
|
217
|
|
- // it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
|
218
|
|
- // it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
|
219
|
|
- // }
|
220
|
|
- // sum_count += it.StockMaxNumber + it.StockMinNumber
|
221
|
|
- // sum_in_count += it.WarehousingCount
|
222
|
|
- // }
|
223
|
|
- // service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
|
224
|
|
- // break
|
225
|
|
- // c.ServeSuccessJSON(map[string]interface{}{
|
226
|
|
- // "msg": "1",
|
227
|
|
- // "advice": advice,
|
228
|
|
- // })
|
229
|
|
- // return
|
230
|
|
- // }
|
231
|
|
- // if medical.IsUse == 1 {
|
232
|
|
- // c.ServeSuccessJSON(map[string]interface{}{
|
233
|
|
- // "msg": "1",
|
234
|
|
- // "advice": advice,
|
235
|
|
- // })
|
236
|
|
- // return
|
237
|
|
- // }
|
238
|
|
- // }
|
239
|
|
- //}
|
|
296
|
+ ////查询改药品信息
|
|
297
|
+ medical, _ := service.GetBaseDrugMedical(item.DrugId)
|
|
298
|
+ ////判断单位是否相等
|
|
299
|
+ if medical.MaxUnit == item.PrescribingNumberUnit {
|
|
300
|
+ prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
|
301
|
+ count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
|
302
|
+ //转化为最小单位
|
|
303
|
+ total = list.Count*medical.MinNumber + list.StockMinNumber
|
|
304
|
+ prescribing_number_total = count * medical.MinNumber
|
|
305
|
+ }
|
|
306
|
+ if medical.MinUnit == item.PrescribingNumberUnit {
|
|
307
|
+ prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
|
308
|
+ count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
|
309
|
+ total = list.Count*medical.MinNumber + list.StockMinNumber
|
|
310
|
+ prescribing_number_total = count
|
|
311
|
+ }
|
|
312
|
+
|
|
313
|
+ if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
|
|
314
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
315
|
+ "msg": "3",
|
|
316
|
+ "medical": medical,
|
|
317
|
+ })
|
|
318
|
+ return
|
|
319
|
+ }
|
|
320
|
+ if prescribing_number_total > total {
|
|
321
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
322
|
+ "msg": "2",
|
|
323
|
+ "medical": medical,
|
|
324
|
+ })
|
|
325
|
+ return
|
|
326
|
+ }
|
|
327
|
+
|
|
328
|
+ if prescribing_number_total <= total {
|
|
329
|
+
|
|
330
|
+ //查询是否门诊处方和临时医嘱同步到透析医嘱的开关是否开启
|
|
331
|
+ adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
|
|
332
|
+ if adviceSetting.IsAdviceOpen == 1 {
|
|
333
|
+ if medical.IsUse == 2 {
|
|
334
|
+ service.PharmacyHisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item, lastPharmary.ID)
|
|
335
|
+ //查询默认仓库
|
|
336
|
+ houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
|
|
337
|
+ //查询默认仓库剩余多少库存
|
|
338
|
+ list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
|
339
|
+ var sum_count int64
|
|
340
|
+ var sum_in_count int64
|
|
341
|
+ for _, it := range list {
|
|
342
|
+ baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
|
|
343
|
+ if it.MaxUnit == baseDrug.MaxUnit {
|
|
344
|
+ it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
|
|
345
|
+ it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
|
|
346
|
+ }
|
|
347
|
+ sum_count += it.StockMaxNumber + it.StockMinNumber
|
|
348
|
+ sum_in_count += it.WarehousingCount
|
|
349
|
+ }
|
|
350
|
+ service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
|
|
351
|
+ break
|
|
352
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
353
|
+ "msg": "1",
|
|
354
|
+ "medical": medical,
|
|
355
|
+ })
|
|
356
|
+ return
|
|
357
|
+ }
|
|
358
|
+ if medical.IsUse == 1 {
|
|
359
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
360
|
+ "msg": "1",
|
|
361
|
+ })
|
|
362
|
+ return
|
|
363
|
+ }
|
|
364
|
+
|
|
365
|
+ } else {
|
|
366
|
+ if medical.IsUse == 2 {
|
|
367
|
+ service.PharmacyHisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item, lastPharmary.ID)
|
|
368
|
+ //查询默认仓库
|
|
369
|
+ houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
|
|
370
|
+ //查询默认仓库剩余多少库存
|
|
371
|
+ list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
|
372
|
+ var sum_count int64
|
|
373
|
+ var sum_in_count int64
|
|
374
|
+ for _, it := range list {
|
|
375
|
+ baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
|
|
376
|
+ if it.MaxUnit == baseDrug.MaxUnit {
|
|
377
|
+ it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
|
|
378
|
+ it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
|
|
379
|
+ }
|
|
380
|
+ sum_count += it.StockMaxNumber + it.StockMinNumber
|
|
381
|
+ sum_in_count += it.WarehousingCount
|
|
382
|
+ }
|
|
383
|
+ service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
|
|
384
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
385
|
+ "msg": "1",
|
|
386
|
+ "medical": medical,
|
|
387
|
+ })
|
|
388
|
+ return
|
|
389
|
+ }
|
|
390
|
+ if medical.IsUse == 1 {
|
|
391
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
392
|
+ "msg": "1",
|
|
393
|
+ "medical": medical,
|
|
394
|
+ })
|
|
395
|
+ return
|
|
396
|
+ }
|
|
397
|
+ }
|
|
398
|
+ }
|
240
|
399
|
}
|
241
|
400
|
}
|
|
401
|
+}
|
|
402
|
+
|
|
403
|
+func (this *PharmacyApiController) GetPharmacyBaseDrugList() {
|
|
404
|
+
|
|
405
|
+ start_time := this.GetString("start_time")
|
|
406
|
+ timeLayout := "2006-01-02"
|
|
407
|
+ loc, _ := time.LoadLocation("Local")
|
|
408
|
+ var theStartTime int64
|
|
409
|
+ if len(start_time) > 0 {
|
|
410
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
411
|
+ if err != nil {
|
|
412
|
+ utils.ErrorLog(err.Error())
|
|
413
|
+ }
|
|
414
|
+ theStartTime = theTime.Unix()
|
|
415
|
+ }
|
242
|
416
|
|
|
417
|
+ drug_id, _ := this.GetInt64("drug_id")
|
|
418
|
+
|
|
419
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
420
|
+ //获取血透医嘱
|
|
421
|
+ advicelist, _ := service.GetUseredBloodAdviceList(theStartTime, drug_id, orgId)
|
|
422
|
+
|
|
423
|
+ //获取医保医嘱
|
|
424
|
+ hisAdviceList, err := service.GetUseredHisAdviceList(theStartTime, drug_id, orgId)
|
|
425
|
+
|
|
426
|
+ patient, _ := service.GetAllPatientListSix(orgId)
|
|
427
|
+ if err == nil {
|
|
428
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
429
|
+ "advicelist": advicelist,
|
|
430
|
+ "hisAdviceList": hisAdviceList,
|
|
431
|
+ "patient": patient,
|
|
432
|
+ })
|
|
433
|
+ } else {
|
|
434
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
435
|
+ }
|
|
436
|
+}
|
|
437
|
+
|
|
438
|
+func (this *PharmacyApiController) GetReturnPharmacyBaseDrug() {
|
|
439
|
+
|
|
440
|
+ bloodStr := this.GetString("bloodStr")
|
|
441
|
+
|
|
442
|
+ hisStr := this.GetString("hisStr")
|
|
443
|
+
|
|
444
|
+ if len(bloodStr) == 0 {
|
|
445
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
446
|
+ return
|
|
447
|
+ }
|
|
448
|
+
|
|
449
|
+ idArray := strings.Split(bloodStr, ",")
|
|
450
|
+
|
|
451
|
+ if len(hisStr) == 0 {
|
|
452
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
453
|
+ return
|
|
454
|
+ }
|
|
455
|
+
|
|
456
|
+ idArrayOne := strings.Split(hisStr, ",")
|
|
457
|
+
|
|
458
|
+ fmt.Println("idArray23332233223", idArray)
|
|
459
|
+ fmt.Println("idArrayOne23332233223", idArrayOne)
|
|
460
|
+
|
|
461
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
462
|
+ service.UpdateReturnPharmacyAdviceBaseDrug(idArray, orgId)
|
|
463
|
+ service.UpdateReturnPharmacyHisAdviceBaseDrug(idArray, orgId)
|
243
|
464
|
}
|