his_print_service.go 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package service
  2. import (
  3. "XT_New/models"
  4. "github.com/jinzhu/gorm"
  5. )
  6. func GetBatchDrugHisPrescription(ids []string, record_time int64, user_org_id int64) (patients []*models.PrintPatient, err error) {
  7. readDb.Model(&models.PrintPatient{}).Preload("HisPrintPatient", "status = 1 AND record_date = ?", record_time).
  8. Preload("HisPrintPrescription", func(db *gorm.DB) *gorm.DB {
  9. return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND type = 1 AND p_type = 2", user_org_id, record_time).
  10. Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  11. return db.Where("status = 1 AND user_org_id = ?", user_org_id).Preload("Drug", "status=1")
  12. })
  13. }).
  14. Preload("HisPrescriptionInfoTwo", "status = 1 AND record_date = ?", record_time).
  15. Where("id in (?) AND user_org_id = ?", ids, user_org_id).Find(&patients)
  16. return
  17. }
  18. func GetBatchProjectHisPrescription(ids []string, record_time int64, user_org_id int64) (patients []*models.PrintPatient, err error) {
  19. readDb.Model(&models.PrintPatient{}).Preload("HisPrintPatient", "status = 1 AND record_date = ?", record_time).
  20. Preload("HisPrintPrescription", func(db *gorm.DB) *gorm.DB {
  21. return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND type <> 1 AND p_type = 2", user_org_id, record_time).
  22. Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  23. return db.Where("his_prescription_project.status = 1 AND his_prescription_project.user_org_id = ?", user_org_id).Where("his_prescription_project.status = 1 ").Preload("HisProject", "status = 1").Preload("GoodInfo", "status=1")
  24. })
  25. }).
  26. Preload("HisPrescriptionInfoTwo", "status = 1 AND record_date = ?", record_time).
  27. Where("id in (?) AND user_org_id = ? ", ids, user_org_id).Find(&patients)
  28. return
  29. }
  30. func GetBatchInspectionProjectHisPrescription(ids []string, record_time int64, user_org_id int64) (patients []*models.PrintPatient, err error) {
  31. readDb.Model(&models.PrintPatient{}).Preload("HisPrintPatient", "status = 1 AND record_date = ?", record_time).
  32. Preload("HisPrintPrescription", func(db *gorm.DB) *gorm.DB {
  33. return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND type <> 1 AND p_type = 2", user_org_id, record_time).
  34. Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  35. return db.Joins("Join xt_his_project p On p.id = his_prescription_project.project_id AND p.cost_classify = 3").Where("his_prescription_project.status = 1 ").Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1")
  36. })
  37. }).
  38. Preload("HisPrescriptionInfoTwo", "status = 1 AND record_date = ?", record_time).
  39. Where("id in (?) AND user_org_id = ? ", ids, user_org_id).Find(&patients)
  40. return
  41. }