123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559 |
- package service
-
- import (
- "XT_New/models"
- "github.com/jinzhu/gorm"
- "time"
- )
-
- func GetAllPatientChargeDetails(org_id int64, start_time int64, end_time int64, keyword string, item_type int64) (patients []*models.ChargePatient, err error) {
- if len(keyword) == 0 {
- switch item_type {
- case 0:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
- Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 ")
- })
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
-
- break
- case 1:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
- Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id > 0 AND project_id = 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 ")
- })
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
-
- break
- case 2:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
- Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id = 0 AND project_id > 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Where("status = 1 ")
- })
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
-
- break
- case 3:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
- Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id = 0 AND project_id > 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 ")
- })
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
-
- break
-
- }
-
- } else {
- keyword := "%" + keyword + "%"
- switch item_type {
- case 0:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
- Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 ")
- })
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
-
- break
- case 1:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
- Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id > 0 AND project_id = 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 ")
- })
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
-
- break
- case 2:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
- Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id = 0 AND project_id > 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Where("status = 1 ")
- })
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
-
- break
- case 3:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id").
- Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("advice_id = 0 AND project_id > 0").Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 ")
- })
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
-
- break
-
- }
-
- }
-
- return
- }
-
- func GetAllPatientChargeSettle(org_id int64, start_time int64, end_time int64, keyword string, item_type int64) (patients []*models.SettlePatient, err error) {
- if len(keyword) == 0 {
- switch item_type {
- case 0:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
-
- break
- case 1:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 1 ", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
-
- break
- case 2:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 0", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
-
- break
- case 3:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 14", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
-
- break
- case 4:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 11", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
-
- break
- case 5:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 AND orders.insutype = 390", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 ", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
-
- break
- case 6:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 AND orders.insutype = 310 ", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ?", org_id).Group("id").Find(&patients).Error
-
- break
-
- }
-
- } else {
- keyword = "%" + keyword + "%"
- switch item_type {
- case 0:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
-
- break
- case 1:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 1 ", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
-
- break
- case 2:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND is_medicine_insurance = 0", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
-
- break
- case 3:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 14", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
-
- break
- case 4:
- err = readDb2.Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status,p.id_card_no").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1 AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2", start_time, end_time, org_id).Preload("HisChargeSettleOrder", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND med_type = 11", start_time, end_time, org_id)
- }).Where("p.status = 1 AND p.user_org_id = ? AND p.name LIKE ?", org_id, keyword).Group("id").Find(&patients).Error
-
- break
-
- }
- }
-
- return
- }
-
- func GetLabelPrintList(page int64, limit int64, user_org_id int64, record_time int64, is_print int64, keywors string) (labels []*models.HisLabelPrintInfo, total int64, err error) {
- offset := (page - 1) * limit
- db := readDb.Model(&models.HisLabelPrintInfo{})
- if is_print > 0 {
- db = db.Where("is_print = ?", is_print)
- }
- if len(keywors) > 0 {
- keywors = "%" + keywors + "%"
- db = db.Where("patient_name Like ?", keywors)
-
- }
- err = db.Where("user_org_id = ? AND record_date = ? AND status = 1 ", user_org_id, record_time).Count(&total).Offset(offset).Limit(limit).Find(&labels).Error
- return
- }
-
- func GetLabelPrintInfo(id int64) (labels models.HisLabelPrintInfo, err error) {
- db := readDb.Model(&models.HisLabelPrintInfo{})
- err = db.Where("id = ?", id).First(&labels).Error
- return
- }
-
- func AddSigleFapiaoRecord(dealer *models.HisFapiaoRecord) (err error, record *models.HisFapiaoRecord) {
- err = writeDb.Create(&dealer).Error
- return err, dealer
- }
-
- func ModifyFapiao(mesick *models.HisFapiaoRecord) error {
- err := writeDb.Save(&mesick).Error
-
- return err
- }
-
- func UpdateFapiaoIsUse(org_id int64) {
- writeDb.Model(&models.HisFapiaoRecord{}).Where("user_org_id = ?", org_id).Updates(map[string]interface{}{"mtime": time.Now().Unix(), "is_use": 0})
-
- }
-
- func FindAllFapiaoList(orgId int64, page int64, limit int64) (list []*models.HisFapiaoRecord, total int64, err error) {
- offset := (page - 1) * limit
- db := readDb.Model(&models.HisFapiaoRecord{})
- db = db.Where("user_org_id = ? AND status = 1", orgId)
- err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&list).Error
- return
- }
-
- func DeleteFapiaoById(id int64) error {
- err := writeDb.Model(&models.HisFapiaoRecord{}).Where("id = ? AND status = 1", id).Updates(map[string]interface{}{"mtime": time.Now().Unix(), "status": 0}).Error
- return err
- }
-
- func FindFapiaoById(id int64) (*models.HisFapiaoRecord, error) {
- dealer := &models.HisFapiaoRecord{}
- err := readDb.Model(&models.HisFapiaoRecord{}).Where("id = ? AND status = 1", id).First(&dealer).Error
- return dealer, err
- }
-
- func FindFapiaoByIsUse(org_id int64) (models.HisFapiaoRecord, error) {
- record := models.HisFapiaoRecord{}
- err := readDb.Model(&models.HisFapiaoRecord{}).Where("user_org_id = ? AND status = 1 AND is_use = 1", org_id).First(&record).Error
- return record, err
- }
-
- func FindHisYidiClearRecord(org_id int64) (records []*models.HisYidiClearRecord, err error) {
- err = readDb.Model(&models.HisYidiClearRecord{}).Where("user_org_id = ? AND status = 1", org_id).Find(&records).Error
- return
- }
-
- func GetHisYidiClearRecordById(org_id int64, id int64) (record models.HisYidiClearRecord, err error) {
- err = readDb.Model(&models.HisYidiClearRecord{}).Where("user_org_id = ? AND status = 1 AND id = ?", org_id, id).First(&record).Error
- return
- }
-
- func GetAllPatientTwo(org_id int64) (patients []*models.ChargePatientTwo, err error) {
- err = readDb.Model(&models.ChargePatientTwo{}).Where("user_org_id = ? AND status = 1", org_id).Find(&patients).Error
- return
- }
-
- func GetPatientChargeDetails(patient_id int64, org_id int64, start_time int64, end_time int64, keyword string, item_type int64, settle_type int64) (patients []*models.HisChargeOrderTwo, err error) {
- if len(keyword) == 0 {
- switch item_type {
- case 0:
- readDb2.Model(&models.HisChargeOrderTwo{}).Joins("join his_patient his on his.number = his_order.mdtrt_id AND his.patient_id = ").Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 ")
- })
- }).Where("status = 1 AND settle_accounts_date >= ? AND settle_accounts_date <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type=?", start_time, end_time, org_id, patient_id, settle_type)
- break
- case 1:
- readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).Where("status = 1 AND advice_id > 0 AND project_id = 0")
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type=?", start_time, end_time, org_id, patient_id, settle_type)
-
- break
- case 2:
- readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 AND advice_id = 0 AND project_id > 0 ")
- })
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type = ?", start_time, end_time, org_id, patient_id, settle_type)
-
- break
- case 3:
- readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 AND advice_id = 0 AND project_id > 0 ")
- })
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type = ?", start_time, end_time, org_id, patient_id, settle_type)
- break
- }
-
- } else {
- //keyword := "%" + keyword + "%"
- switch item_type {
- case 0:
- readDb2.Model(&models.HisChargeOrderTwo{}).Joins("join his_patient his on his.number = his_order.mdtrt_id AND his.patient_id = ").Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 ")
- })
- }).Where("status = 1 AND settle_accounts_date >= ? AND settle_accounts_date <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type=?", start_time, end_time, org_id, patient_id, settle_type)
- break
- case 1:
- readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).Where("status = 1 AND advice_id > 0 AND project_id = 0")
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type=?", start_time, end_time, org_id, patient_id, settle_type)
-
- break
- case 2:
- readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 AND advice_id = 0 AND project_id > 0 ")
- })
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type = ?", start_time, end_time, org_id, patient_id, settle_type)
-
- break
- case 3:
- readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 AND advice_id = 0 AND project_id > 0 ")
- })
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type = ?", start_time, end_time, org_id, patient_id, settle_type)
- break
- }
-
- }
- return
- }
-
- func GetPatientGather(patient_id int64, org_id int64, start_time int64, end_time int64, keyword string, item_type int64, settle_type int64) (patients []*models.HisChargeOrderTwo, err error) {
- if len(keyword) == 0 {
- switch item_type {
- case 0:
- readDb2.Model(&models.HisChargeOrderTwo{}).Joins("join his_patient his on his.number = his_order.mdtrt_id AND his.patient_id = ").Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 ")
- })
- }).Where("status = 1 AND settle_accounts_date >= ? AND settle_accounts_date <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type=?", start_time, end_time, org_id, patient_id, settle_type)
- break
- case 1:
- readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).Where("status = 1 AND advice_id > 0 AND project_id = 0")
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type=?", start_time, end_time, org_id, patient_id, settle_type)
-
- break
- case 2:
- readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 AND advice_id = 0 AND project_id > 0 ")
- })
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type = ?", start_time, end_time, org_id, patient_id, settle_type)
-
- break
- case 3:
- readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 AND advice_id = 0 AND project_id > 0 ")
- })
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type = ?", start_time, end_time, org_id, patient_id, settle_type)
- break
- }
-
- } else {
- //keyword := "%" + keyword + "%"
- switch item_type {
- case 0:
- readDb2.Model(&models.HisChargeOrderTwo{}).Joins("join his_patient his on his.number = his_order.mdtrt_id AND his.patient_id = ").Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 ")
- })
- }).Where("status = 1 AND settle_accounts_date >= ? AND settle_accounts_date <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type=?", start_time, end_time, org_id, patient_id, settle_type)
- break
- case 1:
- readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).Where("status = 1 AND advice_id > 0 AND project_id = 0")
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type=?", start_time, end_time, org_id, patient_id, settle_type)
-
- break
- case 2:
- readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 AND advice_id = 0 AND project_id > 0 ")
- })
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type = ?", start_time, end_time, org_id, patient_id, settle_type)
-
- break
- case 3:
- readDb2.Model(&models.HisChargeOrderTwo{}).Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 AND advice_id = 0 AND project_id > 0 ")
- })
- }).Where("status = 1 AND ctime >= ? AND ctime <= ? AND user_org_id = ? AND order_status = 2 AND patient_id = ? AND p_type = ?", start_time, end_time, org_id, patient_id, settle_type)
- break
- }
-
- }
- return
- }
-
- func GetAllChargeDetailsTwo(org_id int64, start_time int64, end_time int64) (patients []*models.HisChargeOrder, err error) {
- err = readDb2.Model(&models.HisChargeOrder{}).Preload("Patients", "status = 1").Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").
- Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Preload("Drug", "status = 1").Where("status = 1")
- }).
- Preload("HisChargePrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_id,user_org_id,status,patient_id,record_date,count,type").
- Preload("HisChargeProject", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,project_name,unit").Where("status = 1 ")
- }).
- Preload("HisChargeGoodInfo", func(db *gorm.DB) *gorm.DB {
- return db.Select("id,good_name,good_unit,specification_name").Where("status = 1 ")
- }).Where("status = 1 ")
- }).Where("status = 1")
- }).Where("status = 1 AND user_org_id = ? AND settle_accounts_date >= ? AND settle_accounts_date <= ? AND order_status = 2", org_id, start_time, end_time).Group("id").Find(&patients).Error
-
- return
- }
|