|
@@ -259,7 +259,7 @@ func ModifyGoodInfo(goodInfo *models.GoodInfo) (error, *models.GoodInfo) {
|
259
|
259
|
|
260
|
260
|
}
|
261
|
261
|
|
262
|
|
-func FindGoodInfoList(orgId int64, page int64, limit int64, keyword string, is_use int64, is_charge int64, good_kind int64, is_mark int64, manufacturer int64) (list []*models.GoodInfo, total int64, err error) {
|
|
262
|
+func FindGoodInfoList(orgId int64, page int64, limit int64, keyword string, is_use int64, is_charge int64, good_kind int64, is_mark int64, manufacturer int64, is_type int64) (list []*models.GoodInfo, total int64, err error) {
|
263
|
263
|
offset := (page - 1) * limit
|
264
|
264
|
db := readDb.Model(&models.GoodInfo{})
|
265
|
265
|
db = db.Where("org_id = ? AND status = 1", orgId)
|
|
@@ -291,6 +291,9 @@ func FindGoodInfoList(orgId int64, page int64, limit int64, keyword string, is_u
|
291
|
291
|
if manufacturer > 0 {
|
292
|
292
|
db = db.Where("manufacturer = ?", manufacturer)
|
293
|
293
|
}
|
|
294
|
+ if is_type > 0 {
|
|
295
|
+ db = db.Where("good_type_id = ?", is_type)
|
|
296
|
+ }
|
294
|
297
|
} else {
|
295
|
298
|
if is_use > 0 {
|
296
|
299
|
if is_use == 1 {
|
|
@@ -316,6 +319,9 @@ func FindGoodInfoList(orgId int64, page int64, limit int64, keyword string, is_u
|
316
|
319
|
if manufacturer > 0 {
|
317
|
320
|
db = db.Where("manufacturer = ?", manufacturer)
|
318
|
321
|
}
|
|
322
|
+ if is_type > 0 {
|
|
323
|
+ db = db.Where("good_type_id = ?", is_type)
|
|
324
|
+ }
|
319
|
325
|
}
|
320
|
326
|
|
321
|
327
|
err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&list).Error
|
|
@@ -3483,6 +3489,12 @@ func DeleteAutoRedeceDetailTwo(orgid int64, patient_id int64, recordtime int64,
|
3483
|
3489
|
return err
|
3484
|
3490
|
}
|
3485
|
3491
|
|
|
3492
|
+func GetWarehosueOutByStockFlow(patient_id int64, recrod_date int64, goodid int64) (stockflow []*models.VmStockFlow, err error) {
|
|
3493
|
+
|
|
3494
|
+ err = XTReadDB().Where("patient_id = ? and system_time = ? and good_id = ? and consumable_type = 3 and status = 1", patient_id, recrod_date, goodid).Find(&stockflow).Error
|
|
3495
|
+ return stockflow, err
|
|
3496
|
+}
|
|
3497
|
+
|
3486
|
3498
|
func DeleteAutoRedeceDetailTen(orgid int64, patient_id int64, recordtime int64, goodid int64) error {
|
3487
|
3499
|
|
3488
|
3500
|
detail := models.BloodAutomaticReduceDetail{}
|
|
@@ -3491,15 +3503,30 @@ func DeleteAutoRedeceDetailTen(orgid int64, patient_id int64, recordtime int64,
|
3491
|
3503
|
err = XTWriteDB().Model(&info).Where("org_id = ? and patient_id = ? and sys_record_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
|
3492
|
3504
|
prepare := models.DialysisBeforePrepare{}
|
3493
|
3505
|
err = XTWriteDB().Model(&prepare).Where("user_org_id = ? and patient_id = ? and record_date = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
|
|
3506
|
+ flow := models.VmStockFlow{}
|
|
3507
|
+ err = XTWriteDB().Model(&flow).Where("user_org_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
|
3494
|
3508
|
return err
|
3495
|
3509
|
|
3496
|
3510
|
}
|
3497
|
3511
|
|
3498
|
3512
|
func UpDateWarehouseInfoByStockDelete(id int64, count int64) (err error) {
|
|
3513
|
+
|
3499
|
3514
|
err = writeDb.Model(&models.WarehousingInfo{}).Where("id = ?", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
|
3500
|
3515
|
return err
|
3501
|
3516
|
}
|
3502
|
3517
|
|
|
3518
|
+func GetCancelStockInfoByPatientId(patientid int64, goodid int64, record_date int64) (info []*models.CancelStockInfo, err error) {
|
|
3519
|
+
|
|
3520
|
+ err = XTReadDB().Where("patient_id = ? and good_id = ? and record_date = ? and status = 1", patientid, goodid, record_date).Find(&info).Error
|
|
3521
|
+ return info, err
|
|
3522
|
+}
|
|
3523
|
+
|
|
3524
|
+func GetHisPrepscritionByPatientId(patientid int64, goodid int64, record_date int64) (list []*models.HisPrescriptionProject, err error) {
|
|
3525
|
+
|
|
3526
|
+ err = XTReadDB().Where("patient_id = ? and project_id = ? and record_date = ? and status = 1", patientid, goodid, record_date).Find(&list).Error
|
|
3527
|
+ return list, err
|
|
3528
|
+}
|
|
3529
|
+
|
3503
|
3530
|
func UpDateWarehouStockFlowByStockDelete(id int64, recordtime int64, good_id int64, count int64, patient_id int64) (err error) {
|
3504
|
3531
|
|
3505
|
3532
|
err = writeDb.Model(&models.VmStockFlow{}).Where("warehousing_id = ? and system_time = ? and good_id = ? and patient_id = ?", id, recordtime, good_id, patient_id).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
|
|
@@ -3525,15 +3552,14 @@ func GetAutoDialysisBefor(goodid int64, goodtypeid int64, patientid int64, orgid
|
3525
|
3552
|
return &autoreduece, nil
|
3526
|
3553
|
}
|
3527
|
3554
|
|
3528
|
|
-func GetAutoRecordByGoodId(goodid int64, patientid int64, recorddate int64) (models.WarehouseOutInfo, error) {
|
3529
|
|
- detail := models.WarehouseOutInfo{}
|
3530
|
|
- err := XTReadDB().Model(&detail).Where("good_id = ? and patient_id = ? and sys_record_time = ? and status = 1", goodid, patientid, recorddate).Find(&detail).Error
|
|
3555
|
+func GetAutoRecordByGoodIdSeven(goodid int64, patientid int64, recorddate int64) (models.WarehouseOutInfoSeven, error) {
|
|
3556
|
+ detail := models.WarehouseOutInfoSeven{}
|
|
3557
|
+ err := XTReadDB().Select("id,count").Where(" good_id = ? and sys_record_time = ? and patient_id = ? and status = 1", goodid, recorddate, patientid).Find(&detail).Error
|
3531
|
3558
|
return detail, err
|
3532
|
3559
|
}
|
3533
|
3560
|
|
3534
|
|
-func GetAutoRecordByGoodIdSeven(goodid int64, patientid int64, recorddate int64) (models.WarehouseOutInfoSeven, error) {
|
3535
|
|
- detail := models.WarehouseOutInfoSeven{}
|
3536
|
|
- err := XTReadDB().Model(&detail).Where("sys_record_time = ? and good_id = ? and patient_id = ? and status = 1", recorddate, goodid, patientid).Find(&detail).Error
|
|
3561
|
+func GetAutoRecordByGoodIdSevenEight(goodid int64, patientid int64, recorddate int64) (detail []*models.WarehouseOutInfoSeven, err error) {
|
|
3562
|
+ err = XTReadDB().Select("id,count").Where("good_id = ? and sys_record_time = ? and patient_id = ? and status = 1", goodid, recorddate, patientid).Find(&detail).Error
|
3537
|
3563
|
return detail, err
|
3538
|
3564
|
}
|
3539
|
3565
|
|
|
@@ -4706,9 +4732,9 @@ func GetHisAdviceListByDrugIdEight(drugid int64, patient_id int64, advice_date i
|
4706
|
4732
|
return info, err
|
4707
|
4733
|
}
|
4708
|
4734
|
|
4709
|
|
-func GetLastDrugWarehouseOutByDrugId(drugid int64, patient_id int64, advice_date int64) (models.DrugAutomaticReduceDetail, error) {
|
|
4735
|
+func GetLastDrugWarehouseOutByDrugId(drugid int64, patient_id int64, advice_date int64, advice_id int64) (models.DrugAutomaticReduceDetail, error) {
|
4710
|
4736
|
detail := models.DrugAutomaticReduceDetail{}
|
4711
|
|
- err := XTReadDB().Model(&detail).Where("drug_id = ? and patient_id = ? and record_time = ? and status = 1", drugid, patient_id, advice_date).Last(&detail).Error
|
|
4737
|
+ err := XTReadDB().Model(&detail).Where("drug_id = ? and patient_id = ? and record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, advice_date, advice_id).Last(&detail).Error
|
4712
|
4738
|
return detail, err
|
4713
|
4739
|
}
|
4714
|
4740
|
|