|
|
|
|
2137
|
|
2137
|
|
2138
|
func GetNewAllUnChargeHisPatientList(org_id int64, keywords string, record_date int64, sch_type int64) (patients []*NewTempPatients, err error) {
|
2138
|
func GetNewAllUnChargeHisPatientList(org_id int64, keywords string, record_date int64, sch_type int64) (patients []*NewTempPatients, err error) {
|
2139
|
db := readDb.Model(&NewTempPatients{})
|
2139
|
db := readDb.Model(&NewTempPatients{})
|
2140
|
- //if sch_type > 0 {
|
|
|
2141
|
- // db = db.Joins("join xt_schedule as sch on sch.patient_id = xt_patients.id and sch.schedule_date = ? and sch.schedule_type = ?", record_date, sch_type)
|
|
|
2142
|
- //}
|
|
|
|
|
2140
|
+ if sch_type > 0 {
|
|
|
2141
|
+ db = db.Joins("join xt_schedule as sch on sch.patient_id = xt_patients.id and sch.schedule_date = ? and sch.schedule_type = ? and sch.status = 1", record_date, sch_type)
|
|
|
2142
|
+ }
|
2143
|
db = db.Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
|
2143
|
db = db.Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
|
2144
|
db = db.Preload("Schedule", "status = 1")
|
2144
|
db = db.Preload("Schedule", "status = 1")
|
2145
|
db = db.Preload("HisPatient", func(db *gorm.DB) *gorm.DB {
|
2145
|
db = db.Preload("HisPatient", func(db *gorm.DB) *gorm.DB {
|
2146
|
return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", org_id, record_date).Preload("VMHisOrders", "user_org_id = ? AND status = 1 AND settle_accounts_date = ?", org_id, record_date)
|
2146
|
return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", org_id, record_date).Preload("VMHisOrders", "user_org_id = ? AND status = 1 AND settle_accounts_date = ?", org_id, record_date)
|
2147
|
})
|
2147
|
})
|
2148
|
db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1 AND order_status <> 2 AND order_status <> 3", org_id, record_date)
|
2148
|
db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1 AND order_status <> 2 AND order_status <> 3", org_id, record_date)
|
2149
|
- err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1 AND prescription_status <> 3", org_id, record_date).Find(&patients).Error
|
|
|
|
|
2149
|
+ err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ? AND p_type <> 1 AND prescription_status <> 3", org_id, record_date).Find(&patients).Group("xt_patients.id").Error
|
2150
|
|
2150
|
|
2151
|
for _, item := range patients {
|
2151
|
for _, item := range patients {
|
2152
|
for _, sumItem := range item.HisPatient {
|
2152
|
for _, sumItem := range item.HisPatient {
|
|
|
|
|
2163
|
func GetNewAllChargeHisPatientList(org_id int64, keywords string, record_date int64, sch_type int64) (patients []*NewTempPatients, err error) {
|
2163
|
func GetNewAllChargeHisPatientList(org_id int64, keywords string, record_date int64, sch_type int64) (patients []*NewTempPatients, err error) {
|
2164
|
db := readDb.Model(&NewTempPatients{})
|
2164
|
db := readDb.Model(&NewTempPatients{})
|
2165
|
|
2165
|
|
2166
|
- //if sch_type > 0 {
|
|
|
2167
|
- // db = db.Joins("join xt_schedule as sch on sch.patient_id = xt_patients.id and sch.schedule_date = ? and sch.schedule_type = ?", record_date, sch_type)
|
|
|
2168
|
- //}
|
|
|
|
|
2166
|
+ fmt.Println("sch_type")
|
|
|
2167
|
+ fmt.Println(sch_type)
|
|
|
2168
|
+ if sch_type > 0 {
|
|
|
2169
|
+ db = db.Joins("join xt_schedule as sch on sch.patient_id = xt_patients.id and sch.schedule_date = ? and sch.schedule_type = ? and sch.status = 1", record_date, sch_type)
|
|
|
2170
|
+ }
|
2169
|
db = db.Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
|
2171
|
db = db.Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
|
2170
|
db = db.Preload("Schedule", "status = 1")
|
2172
|
db = db.Preload("Schedule", "status = 1")
|
2171
|
db = db.Preload("HisPatient", func(db *gorm.DB) *gorm.DB {
|
2173
|
db = db.Preload("HisPatient", func(db *gorm.DB) *gorm.DB {
|