|
@@ -8,6 +8,7 @@ import (
|
8
|
8
|
"encoding/json"
|
9
|
9
|
"fmt"
|
10
|
10
|
"github.com/astaxie/beego"
|
|
11
|
+ "github.com/jinzhu/gorm"
|
11
|
12
|
"reflect"
|
12
|
13
|
"strconv"
|
13
|
14
|
"time"
|
|
@@ -295,73 +296,139 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
|
295
|
296
|
|
296
|
297
|
err := service.UpdateBaseDrugLib(drugLib)
|
297
|
298
|
|
298
|
|
- //修改xt_drug_name 表
|
299
|
|
- drugName := models.XtDrugName{
|
300
|
|
- DrugName: drug_name,
|
|
299
|
+ //查询是否存在
|
|
300
|
+ _, errOne := service.GetDrugNameIsExist(id, adminInfo.CurrentOrgId)
|
|
301
|
+ if errOne == gorm.ErrRecordNotFound {
|
|
302
|
+ fmt.Println("进来了吗")
|
|
303
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
304
|
+ "msg": "修改成功",
|
|
305
|
+ })
|
|
306
|
+ return
|
|
307
|
+ } else if errOne == nil {
|
|
308
|
+ //修改xt_drug_name 表
|
|
309
|
+ drugName := models.XtDrugName{
|
|
310
|
+ DrugName: drug_name,
|
|
311
|
+ }
|
|
312
|
+ service.UpdatedDrugName(id, adminInfo.CurrentOrgId, &drugName)
|
301
|
313
|
}
|
302
|
|
- service.UpdatedDrugName(id, adminInfo.CurrentOrgId, &drugName)
|
303
|
314
|
|
304
|
|
- //修改规格xt_stand_name表
|
305
|
|
- standName := models.XtStandName{
|
306
|
|
- DrugName: drug_name,
|
307
|
|
- DrugSpec: drug_spec,
|
308
|
|
- DrugStockLimit: drug_stock_limit,
|
309
|
|
- MinUnit: min_unit,
|
310
|
|
- }
|
|
315
|
+ //查询是否存在
|
|
316
|
+ _, errTwo := service.GetStandNameIsExist(id, adminInfo.CurrentOrgId)
|
|
317
|
+ if errTwo == gorm.ErrRecordNotFound {
|
|
318
|
+ fmt.Println("进来了吗1")
|
|
319
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
320
|
+ "msg": "修改成功",
|
|
321
|
+ })
|
|
322
|
+ return
|
|
323
|
+ } else if errTwo == nil {
|
|
324
|
+ //修改规格xt_stand_name表
|
|
325
|
+ standName := models.XtStandName{
|
|
326
|
+ DrugName: drug_name,
|
|
327
|
+ DrugSpec: drug_spec,
|
|
328
|
+ DrugStockLimit: drug_stock_limit,
|
|
329
|
+ MinUnit: min_unit,
|
|
330
|
+ }
|
311
|
331
|
|
312
|
|
- service.UpdateStandName(id, adminInfo.CurrentOrgId, &standName)
|
313
|
|
- //修改药品表
|
314
|
|
- medical := models.XtSelfMedical{
|
315
|
|
- DrugName: drug_name,
|
316
|
|
- DrugSpec: drug_spec,
|
317
|
|
- ExecutionFrequency: execution_frequency,
|
318
|
|
- PrescribingNumber: prescribing_number,
|
319
|
|
- DeliveryWay: delivery_way,
|
320
|
|
- SingleDose: single_dose,
|
321
|
|
- MinUnit: min_unit,
|
|
332
|
+ service.UpdateStandName(id, adminInfo.CurrentOrgId, &standName)
|
322
|
333
|
}
|
323
|
334
|
|
324
|
|
- service.UpdateSelfMedical(id, adminInfo.CurrentOrgId, &medical)
|
|
335
|
+ _, errThree := service.GetSelfMedicalIsExist(id, adminInfo.CurrentOrgId)
|
|
336
|
+
|
|
337
|
+ if errThree == gorm.ErrRecordNotFound {
|
|
338
|
+ fmt.Println("进来了吗2")
|
|
339
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
340
|
+ "msg": "修改成功",
|
|
341
|
+ })
|
|
342
|
+ return
|
|
343
|
+ } else if errThree == nil {
|
|
344
|
+ //修改药品表
|
|
345
|
+ medical := models.XtSelfMedical{
|
|
346
|
+ DrugName: drug_name,
|
|
347
|
+ DrugSpec: drug_spec,
|
|
348
|
+ ExecutionFrequency: execution_frequency,
|
|
349
|
+ PrescribingNumber: prescribing_number,
|
|
350
|
+ DeliveryWay: delivery_way,
|
|
351
|
+ SingleDose: single_dose,
|
|
352
|
+ MinUnit: min_unit,
|
|
353
|
+ }
|
325
|
354
|
|
326
|
|
- //修改入库表
|
327
|
|
- //nameId, err := service.GetDrugNameId(id, adminInfo.CurrentOrgId)
|
|
355
|
+ service.UpdateSelfMedical(id, adminInfo.CurrentOrgId, &medical)
|
|
356
|
+ }
|
328
|
357
|
|
329
|
|
- stock := models.XtSelfStock{
|
330
|
|
- DrugSpec: drug_spec,
|
331
|
|
- DrugName: drug_name,
|
332
|
|
- MinUnit: min_unit,
|
|
358
|
+ _, errFour := service.GetSelfStosckIsExist(id, adminInfo.CurrentOrgId)
|
|
359
|
+ if errFour == gorm.ErrRecordNotFound {
|
|
360
|
+ fmt.Println("进来了吗3")
|
|
361
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
362
|
+ "msg": "修改成功",
|
|
363
|
+ })
|
|
364
|
+ return
|
|
365
|
+ } else if errFour == nil {
|
|
366
|
+ stock := models.XtSelfStock{
|
|
367
|
+ DrugSpec: drug_spec,
|
|
368
|
+ DrugName: drug_name,
|
|
369
|
+ MinUnit: min_unit,
|
|
370
|
+ }
|
|
371
|
+ service.UpdatedSelfStock(&stock, id, adminInfo.CurrentOrgId)
|
333
|
372
|
}
|
334
|
373
|
|
335
|
|
- service.UpdatedSelfStock(&stock, id, adminInfo.CurrentOrgId)
|
336
|
|
- outStock := models.XtSelfOutStock{
|
337
|
|
- DrugName: drug_name,
|
338
|
|
- DrugSpec: drug_spec,
|
|
374
|
+ _, errFive := service.GetOutSelfOutStockIsExist(id, adminInfo.CurrentOrgId)
|
|
375
|
+ if errFive == gorm.ErrRecordNotFound {
|
|
376
|
+ fmt.Println("进来了吗4")
|
|
377
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
378
|
+ "msg": "修改成功",
|
|
379
|
+ })
|
|
380
|
+ return
|
|
381
|
+ } else if errFive == nil {
|
|
382
|
+ outStock := models.XtSelfOutStock{
|
|
383
|
+ DrugName: drug_name,
|
|
384
|
+ DrugSpec: drug_spec,
|
|
385
|
+ }
|
|
386
|
+ //修改出库表
|
|
387
|
+ service.UpdatedOutSelfStock(&outStock, id, adminInfo.CurrentOrgId)
|
339
|
388
|
}
|
340
|
|
- //修改出库表
|
341
|
|
- service.UpdatedOutSelfStock(&outStock, id, adminInfo.CurrentOrgId)
|
342
|
389
|
|
343
|
|
- //查询未执行的医嘱
|
344
|
|
- advice := models.DoctorAdvice{
|
345
|
|
- AdviceName: drug_name,
|
346
|
|
- AdviceDesc: drug_spec,
|
347
|
|
- DeliveryWay: delivery_way,
|
348
|
|
- ExecutionFrequency: execution_frequency,
|
349
|
|
- SingleDose: single_dose,
|
350
|
|
- SingleDoseUnit: min_unit,
|
|
390
|
+ _, errSix := service.GetDoctorAdviceIsExist(id, adminInfo.CurrentOrgId)
|
|
391
|
+ if errSix == gorm.ErrRecordNotFound {
|
|
392
|
+ fmt.Println("进来了吗5")
|
|
393
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
394
|
+ "msg": "修改成功",
|
|
395
|
+ })
|
|
396
|
+ return
|
|
397
|
+ } else if errSix == nil {
|
|
398
|
+ //查询未执行的医嘱
|
|
399
|
+ advice := models.DoctorAdvice{
|
|
400
|
+ AdviceName: drug_name,
|
|
401
|
+ AdviceDesc: drug_spec,
|
|
402
|
+ DeliveryWay: delivery_way,
|
|
403
|
+ ExecutionFrequency: execution_frequency,
|
|
404
|
+ SingleDose: single_dose,
|
|
405
|
+ SingleDoseUnit: min_unit,
|
|
406
|
+ }
|
|
407
|
+
|
|
408
|
+ service.UpdateNoExcuteDoctorAdvice(id, adminInfo.CurrentOrgId, &advice)
|
351
|
409
|
}
|
352
|
410
|
|
353
|
|
- service.UpdateNoExcuteDoctorAdvice(id, adminInfo.CurrentOrgId, &advice)
|
|
411
|
+ _, errSeven := service.GetDoctorAdviceTemplateIsExist(id, adminInfo.CurrentOrgId)
|
|
412
|
+
|
|
413
|
+ if errSeven == gorm.ErrRecordNotFound {
|
|
414
|
+ fmt.Println("进来了吗6")
|
|
415
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
416
|
+ "msg": "修改成功",
|
|
417
|
+ })
|
|
418
|
+ return
|
|
419
|
+ } else if errSeven == nil {
|
|
420
|
+ //修改医嘱模板
|
|
421
|
+ template := models.DoctorAdviceTemplate{
|
|
422
|
+ AdviceName: drug_name,
|
|
423
|
+ AdviceDesc: drug_spec,
|
|
424
|
+ DeliveryWay: delivery_way,
|
|
425
|
+ ExecutionFrequency: execution_frequency,
|
|
426
|
+ SingleDose: single_dose,
|
|
427
|
+ SingleDoseUnit: min_unit,
|
|
428
|
+ }
|
|
429
|
+ service.UpdatedDoctorAdviceTemplate(id, adminInfo.CurrentOrgId, &template)
|
354
|
430
|
|
355
|
|
- //修改医嘱模板
|
356
|
|
- template := models.DoctorAdviceTemplate{
|
357
|
|
- AdviceName: drug_name,
|
358
|
|
- AdviceDesc: drug_spec,
|
359
|
|
- DeliveryWay: delivery_way,
|
360
|
|
- ExecutionFrequency: execution_frequency,
|
361
|
|
- SingleDose: single_dose,
|
362
|
|
- SingleDoseUnit: min_unit,
|
363
|
431
|
}
|
364
|
|
- service.UpdatedDoctorAdviceTemplate(id, adminInfo.CurrentOrgId, &template)
|
365
|
432
|
|
366
|
433
|
if err == nil {
|
367
|
434
|
c.ServeSuccessJSON(map[string]interface{}{
|