|
@@ -1127,7 +1127,7 @@ func FindDrugWarehousingInfoByIdOne(id []string, org_id int64) (list []*models.S
|
1127
|
1127
|
if org_id > 0 {
|
1128
|
1128
|
db = db.Where("x.org_id = ?", org_id)
|
1129
|
1129
|
}
|
1130
|
|
- err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehouseing_unit,x.stock_max_number,x.stock_min_number,x.price,x.remark,x.batch_number,x.batch_number,t.manufacturer,t.dealer,t.drug_name,t.last_price,t.dose_unit,t.dose,t.min_number,t.min_unit,t.max_unit,t.drug_type").Joins("left join xt_base_drug as t on t.id = x.drug_id").Scan(&list).Error
|
|
1130
|
+ err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehouseing_unit,x.stock_max_number,x.stock_min_number,x.price,x.remark,x.batch_number,x.batch_number,x.manufacturer,x.dealer,t.drug_name,t.last_price,t.dose_unit,t.dose,t.min_number,t.min_unit,t.max_unit,t.drug_type").Joins("left join xt_base_drug as t on t.id = x.drug_id").Scan(&list).Error
|
1131
|
1131
|
return list, err
|
1132
|
1132
|
}
|
1133
|
1133
|
|
|
@@ -6345,7 +6345,7 @@ func GetDrugDetailSummary(startime int64, endtime int64, keyword string, limit i
|
6345
|
6345
|
|
6346
|
6346
|
if len(keyword) > 0 {
|
6347
|
6347
|
likeKey := "%" + keyword + "%"
|
6348
|
|
- db = db.Select("x.patient_id,x.user_org_id,x.id,x.advice_date,x.advice_date,x.prescribing_number_unit,x.drug_id").Joins("left join sgj_xt.xt_base_drug as d on d.id = x.drug_id").Where("d.drug_name like ?", likeKey)
|
|
6348
|
+ db = db.Select("x.patient_id,x.user_org_id,x.id,x.advice_date,x.advice_date,x.prescribing_number_unit,x.drug_id,x.prescribing_number").Joins("left join sgj_xt.xt_base_drug as d on d.id = x.drug_id").Where("d.drug_name like ?", likeKey)
|
6349
|
6349
|
}
|
6350
|
6350
|
|
6351
|
6351
|
offset := (page - 1) * limit
|
|
@@ -6372,7 +6372,7 @@ func GetDrugDetailSummaryOne(startime int64, endtime int64, keyword string, limi
|
6372
|
6372
|
|
6373
|
6373
|
if len(keyword) > 0 {
|
6374
|
6374
|
likeKey := "%" + keyword + "%"
|
6375
|
|
- db = db.Select("x.patient_id,x.user_org_id,x.id,x.advice_date,x.advice_date,x.prescribing_number_unit,x.drug_id").Joins("left join sgj_xt.xt_base_drug as d on d.id = x.drug_id").Where("d.drug_name like ?", likeKey)
|
|
6375
|
+ db = db.Select("x.patient_id,x.user_org_id,x.id,x.advice_date,x.advice_date,x.prescribing_number_unit,x.drug_id,x.prescribing_number").Joins("left join sgj_xt.xt_base_drug as d on d.id = x.drug_id").Where("d.drug_name like ?", likeKey)
|
6376
|
6376
|
}
|
6377
|
6377
|
|
6378
|
6378
|
err = db.Order("x.created_time desc").Scan(&adviceinfo).Error
|
|
@@ -6403,7 +6403,7 @@ func GetGoodDetailSummary(startime int64, endtime int64, keyword string, limit i
|
6403
|
6403
|
|
6404
|
6404
|
if len(keyword) > 0 {
|
6405
|
6405
|
likeKey := "%" + keyword + "%"
|
6406
|
|
- db = db.Select("x.id,x.project_id,x.user_org_id,x.patient_id,x.record_date").Joins("left join xt_good_information as d on d.id = x.project_id").Where("d.good_name like ?", likeKey).Group("d.id")
|
|
6406
|
+ db = db.Select("x.id,x.project_id,x.user_org_id,x.patient_id,x.record_date,x.count").Joins("left join xt_good_information as d on d.id = x.project_id").Where("d.good_name like ?", likeKey).Group("d.id")
|
6407
|
6407
|
}
|
6408
|
6408
|
|
6409
|
6409
|
offset := (page - 1) * limit
|
|
@@ -6429,7 +6429,7 @@ func GetGoodDetailSummaryOne(startime int64, endtime int64, keyword string, limi
|
6429
|
6429
|
|
6430
|
6430
|
if len(keyword) > 0 {
|
6431
|
6431
|
likeKey := "%" + keyword + "%"
|
6432
|
|
- db = db.Select("x.id,x.project_id,x.user_org_id,x.patient_id,x.record_date").Joins("left join xt_good_information as d on d.id = x.project_id").Where("d.good_name like ? ", likeKey).Group("d.id")
|
|
6432
|
+ db = db.Select("x.id,x.project_id,x.user_org_id,x.patient_id,x.record_date,x.count").Joins("left join xt_good_information as d on d.id = x.project_id").Where("d.good_name like ? ", likeKey).Group("d.id")
|
6433
|
6433
|
}
|
6434
|
6434
|
|
6435
|
6435
|
err = db.Order("x.ctime desc").Group("x.id").Scan(&project).Error
|
|
@@ -6481,3 +6481,34 @@ func GetAutoStockOutById(good_id, record_date int64, orgid int64, patient_id int
|
6481
|
6481
|
err := XTReadDB().Where("good_id = ? and record_time = ? and org_id = ? and status = 1 and patient_id = ?", good_id, record_date, orgid, patient_id).Find(&detail).Error
|
6482
|
6482
|
return detail, err
|
6483
|
6483
|
}
|
|
6484
|
+
|
|
6485
|
+func GetAdviceConfig(orgid int64) (*models.XtAdviceSetting, error) {
|
|
6486
|
+
|
|
6487
|
+ setting := models.XtAdviceSetting{}
|
|
6488
|
+ err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&setting).Error
|
|
6489
|
+ if err == gorm.ErrRecordNotFound {
|
|
6490
|
+ return nil, err
|
|
6491
|
+ }
|
|
6492
|
+ if err != nil {
|
|
6493
|
+ return nil, err
|
|
6494
|
+ }
|
|
6495
|
+ return &setting, nil
|
|
6496
|
+}
|
|
6497
|
+
|
|
6498
|
+func CreateAdviceSetting(setting models.XtAdviceSetting) error {
|
|
6499
|
+
|
|
6500
|
+ err := XTWriteDB().Create(&setting).Error
|
|
6501
|
+ return err
|
|
6502
|
+}
|
|
6503
|
+
|
|
6504
|
+func UpdateAdviceSetting(orgid int64, setting models.XtAdviceSetting) error {
|
|
6505
|
+
|
|
6506
|
+ err := XTWriteDB().Model(&setting).Where("user_org_id = ? and status = 1", orgid).Update(map[string]interface{}{"is_advice_open": setting.IsAdviceOpen, "mtime": time.Now().Unix()}).Error
|
|
6507
|
+ return err
|
|
6508
|
+}
|
|
6509
|
+
|
|
6510
|
+func FindAdviceSettingById(orgid int64) (models.XtAdviceSetting, error) {
|
|
6511
|
+ setting := models.XtAdviceSetting{}
|
|
6512
|
+ err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&setting).Error
|
|
6513
|
+ return setting, err
|
|
6514
|
+}
|