123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- package service
-
- import (
- "XT_New/models"
- "github.com/jinzhu/gorm"
- )
-
- func GetNewAllUnHisZuoBiaoPatientList(org_id int64, record_date int64) (patients []*NewTempPatients, err error) {
- db := readDb.Model(&NewTempPatients{})
- db = db.Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
- db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date <= ? AND order_status <> 2 AND order_status <> 3 AND order_status <> 5", org_id, record_date)
- err = db.Find(&patients).Error
- return
- }
-
- func GetNewAllChargeHisZuoBiaoPatientList(org_id int64, record_date int64) (patients []*NewTempPatients, err error) {
- db := readDb.Model(&NewTempPatients{})
- db = db.Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
- db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ? AND order_status = 5", org_id, record_date)
- err = db.Find(&patients).Error
- return
- }
-
- func GetUploadHisZuoBiaoPatientList(org_id int64, record_date int64) (patients []*models.HisZuobiaoAdvice, err error) {
- db := readDb.Model(&models.HisZuobiaoAdvice{})
- db = db.Where("status = 1 and record_date = ? and user_org_id = ?", record_date, org_id)
- db = db.Preload("Patient", "status = 1")
- err = db.Find(&patients).Error
- return
- }
-
- func GetUnUploadHisZuoBiaoPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).
- Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
- }).
- Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
- }).
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND order_status <> 3 AND order_status<> 4 AND order_status<> 5", org_id, record_date, patient_id).
- Find(&prescription).Error
- return
- }
-
- func GetUploadHisZuoBiaoPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).
- Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
- }).
- Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
- }).
- Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status = 5 ", org_id, record_date, patient_id).
- Find(&prescription).Error
- return
- }
-
- func GetMonthUnUploadHisZuoBiaoPrescription(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).
- Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
- }).
- Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
- }).
- Where("user_org_id = ? AND status = 1 AND patient_id = ? AND record_date <= ? AND record_date >= ? AND order_status <> 2 AND order_status <> 3 AND order_status<> 4 AND order_status<> 5 ", org_id, patient_id, end_time, start_time).
- Find(&prescription).Error
- return
- }
-
- func GetMonthUploadHisZuoBiaoPrescription(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).
- Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ? ", org_id).Preload("XtHisAddtionConfig", "status=1")
- }).
- Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ? and is_self_drug <> 1 ", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
- }).
- Where("user_org_id = ? AND status = 1 AND patient_id = ? AND record_date <= ? AND record_date >= ? AND order_status = 5", org_id, patient_id, end_time, start_time).
- Find(&prescription).Error
- return
- }
-
- func GetAllMonthHisZuoBiaoPrescription(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
- err = readDb.Model(&models.HisPrescription{}).
- Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
- }).
- Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
- }).
- Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
- return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
- }).
- Where("user_org_id = ? AND status = 1 AND patient_id = ? AND record_date <= ? AND record_date >= ? ", org_id, patient_id, end_time, start_time).
- Find(&prescription).Error
- return
- }
-
- func GetZuobiaoInfoById(id int64) (err error, zuobiao models.HisZuobiaoAdvice) {
- err = readDb.Model(&models.HisZuobiaoAdvice{}).Where("id = ? and status = 1", id).First(&zuobiao).Error
- return
- }
-
- func GetZuoBiaoPrescriptionInfo(user_org_id int64, patient_id int64) (models.HisPrescriptionInfo, error) {
- info := models.HisPrescriptionInfo{}
- err := XTReadDB().Where("user_org_id = ? and patient_id =? and status=1", user_org_id, patient_id).Last(&info).Error
- return info, err
- }
|