function_service.go 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. package service
  2. import (
  3. "XT_Admin_Api/models/admin_models"
  4. "XT_Admin_Api/models/function_models"
  5. )
  6. // 病人管理
  7. func GetTodayInfo(to int64, ctime int64, page int64, limit int64, admin *admin_models.AdminAccount) (patientinfo []function_models.PatientInfo, total int64, err error) {
  8. //offset := (page - 1) * limit
  9. if admin.IsAdmin == 1 {
  10. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id AND f.status = 1 left JOIN sgj_user_district as d On d.id = u.city left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 left join sgj_xt.xt_patients as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  11. } else {
  12. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u join sgj_org_follow as f On f.org_id = u.id AND f.status = 1 AND f.admin_user_id = ? left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 left JOIN sgj_user_district as d On d.id = u.city left join sgj_xt.xt_patients as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", admin.ID, to, ctime).Scan(&patientinfo).Error
  13. }
  14. //rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_patients as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
  15. //fmt.Println("rows是什么", rows)
  16. //defer rows.Close()
  17. //if rows.Next() {
  18. // rows.Scan(&total)
  19. //}
  20. //fmt.Println("&total是什么", total)
  21. return patientinfo, total, err
  22. }
  23. // 透析处方
  24. func GetTodayDialysisPatientsInfo(to int64, ctime int64, page int64, limit int64, admin *admin_models.AdminAccount) (patientinfo []function_models.PatientInfo, total int64, err error) {
  25. //offset := (page - 1) * limit
  26. if admin.IsAdmin == 1 {
  27. err = readUserDb.Raw("select * , a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city left join sgj_org_follow as f On f.org_id = u.id AND f.status = 1 left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 left join sgj_xt.xt_dialysis_prescription as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  28. } else {
  29. err = readUserDb.Raw("select * , a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city join sgj_org_follow as f On f.org_id = u.id AND f.admin_user_id = ? AND f.status = 1 left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 left join sgj_xt.xt_dialysis_prescription as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", admin.ID, to, ctime).Scan(&patientinfo).Error
  30. }
  31. //rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_dialysis_prescription as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
  32. //defer rows.Close()
  33. //
  34. //if rows.Next() {
  35. // rows.Scan(&total)
  36. //}
  37. return patientinfo, total, err
  38. }
  39. // 接诊评估
  40. func GetTodayReceivePatientsInfo(to int64, ctime int64, page int64, limit int64, admin *admin_models.AdminAccount) (patientinfo []function_models.PatientInfo, total int64, err error) {
  41. //offset := (page - 1) * limit
  42. if admin.IsAdmin == 1 {
  43. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city left join sgj_org_follow as f On f.org_id = u.id AND f.status = 1 left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 left join sgj_xt.xt_receive_treatment_asses as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  44. } else {
  45. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city join sgj_org_follow as f On f.org_id = u.id AND f.status = 1 AND f.admin_user_id = ? left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 left join sgj_xt.xt_receive_treatment_asses as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", admin.ID, to, ctime).Scan(&patientinfo).Error
  46. }
  47. //rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_receive_treatment_asses as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
  48. //defer rows.Close()
  49. //
  50. //if rows.Next() {
  51. // rows.Scan(&total)
  52. //}
  53. return patientinfo, total, err
  54. }
  55. // 透前评估
  56. func GetTodayBeforDislysisInfo(to int64, ctime int64, page int64, limit int64, admin *admin_models.AdminAccount) (patientinfo []function_models.PatientInfo, total int64, err error) {
  57. //offset := (page - 1) * limit
  58. if admin.IsAdmin == 1 {
  59. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city left join sgj_org_follow as f On f.org_id = u.id left AND f.status = 1 JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 left join sgj_xt.xt_assessment_before_dislysis as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  60. } else {
  61. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city join sgj_org_follow as f On f.org_id = u.id AND f.admin_user_id = ? AND f.status = 1 left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 left join sgj_xt.xt_assessment_before_dislysis as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", admin.ID, to, ctime).Scan(&patientinfo).Error
  62. }
  63. //rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_assessment_before_dislysis as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
  64. //defer rows.Close()
  65. //
  66. //if rows.Next() {
  67. // rows.Scan(&total)
  68. //}
  69. return patientinfo, total, err
  70. }
  71. // 零食医嘱
  72. func GetTodayDoctorsOrderInfo(to int64, ctime int64, page int64, limit int64, admin *admin_models.AdminAccount) (patientinfo []function_models.PatientInfo, total int64, err error) {
  73. //offset := (page - 1) * limit
  74. if admin.IsAdmin == 1 {
  75. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city left join sgj_org_follow as f On f.org_id = u.id AND f.status = 1 left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 join sgj_xt.xt_doctor_advice as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  76. } else {
  77. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city join sgj_org_follow as f On f.org_id = u.id AND f.admin_user_id = ? AND f.status = 1 left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 join sgj_xt.xt_doctor_advice as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", admin.ID, to, ctime).Scan(&patientinfo).Error
  78. }
  79. //rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_doctor_advice as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
  80. //defer rows.Close()
  81. //
  82. //if rows.Next() {
  83. // rows.Scan(&total)
  84. //}
  85. return patientinfo, total, err
  86. }
  87. // 双人核对
  88. func GetTodayDoubleCheckInfo(to int64, ctime int64, page int64, limit int64, admin *admin_models.AdminAccount) (patientinfo []function_models.PatientInfo, total int64, err error) {
  89. //offset := (page - 1) * limit
  90. if admin.IsAdmin == 1 {
  91. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city left join sgj_org_follow as f On f.org_id = u.id AND f.status = 1 left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 join sgj_xt.xt_double_check as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  92. } else {
  93. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city join sgj_org_follow as f On f.org_id = u.id AND f.admin_user_id = ? AND f.status = 1 left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 join sgj_xt.xt_double_check as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", admin.ID, to, ctime).Scan(&patientinfo).Error
  94. }
  95. //rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_double_check as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
  96. //defer rows.Close()
  97. //
  98. //if rows.Next() {
  99. // rows.Scan(&total)
  100. //}
  101. return patientinfo, total, err
  102. }
  103. // 透析上机
  104. func GetTodayDialysisMachinek(to int64, ctime int64, page int64, limit int64, admin *admin_models.AdminAccount) (patientinfo []function_models.PatientInfo, total int64, err error) {
  105. //offset := (page - 1) * limit
  106. if admin.IsAdmin == 1 {
  107. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city left join sgj_org_follow as f On f.org_id = u.id AND f.status = 1 left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 left join sgj_xt.xt_dialysis_order as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  108. } else {
  109. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city join sgj_org_follow as f On f.org_id = u.id AND f.admin_user_id = ? AND f.status = 1 left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 left join sgj_xt.xt_dialysis_order as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", admin.ID, to, ctime).Scan(&patientinfo).Error
  110. }
  111. //rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_dialysis_order as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
  112. //defer rows.Close()
  113. //
  114. //if rows.Next() {
  115. // rows.Scan(&total)
  116. //}
  117. return patientinfo, total, err
  118. }
  119. // 透析检测
  120. func GetTodayDialysisExamination(to int64, ctime int64, page int64, limit int64, admin *admin_models.AdminAccount) (patientinfo []function_models.PatientInfo, total int64, err error) {
  121. //offset := (page - 1) * limit
  122. if admin.IsAdmin == 1 {
  123. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city left join sgj_org_follow as f On f.org_id = u.id AND f.status = 1 left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 join sgj_xt.xt_monitoring_record as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  124. } else {
  125. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city join sgj_org_follow as f On f.org_id = u.id AND f.admin_user_id = ? AND f.status = 1 left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 join sgj_xt.xt_monitoring_record as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", admin.ID, to, ctime).Scan(&patientinfo).Error
  126. }
  127. //rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_monitoring_record as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
  128. //defer rows.Close()
  129. //
  130. //if rows.Next() {
  131. // rows.Scan(&total)
  132. //}
  133. return patientinfo, total, err
  134. }
  135. // 透析下机
  136. func GetTodayBeforOrpenetration(to int64, ctime int64, page int64, limit int64, admin *admin_models.AdminAccount) (patientinfo []function_models.PatientInfo, total int64, err error) {
  137. //offset := (page - 1) * limit
  138. if admin.IsAdmin == 1 {
  139. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city left join sgj_org_follow as f On f.org_id = u.id AND f.status = 1 left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 join sgj_xt.xt_dialysis_order as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  140. } else {
  141. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city join sgj_org_follow as f On f.org_id = u.id AND f.admin_user_id = ? AND f.status = 1 left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 join sgj_xt.xt_dialysis_order as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", admin.ID, to, ctime).Scan(&patientinfo).Error
  142. }
  143. //rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_dialysis_order as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
  144. //defer rows.Close()
  145. //
  146. //if rows.Next() {
  147. // rows.Scan(&total)
  148. //}
  149. return patientinfo, total, err
  150. }
  151. // 透后评估
  152. func GetTodayPostAssessment(to int64, ctime int64, page int64, limit int64, admin *admin_models.AdminAccount) (patientinfo []function_models.PatientInfo, total int64, err error) {
  153. //offset := (page - 1) * limit
  154. if admin.IsAdmin == 1 {
  155. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city left join sgj_org_follow as f On f.org_id = u.id AND f.status = 1 left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 join sgj_xt.xt_assessment_after_dislysis as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  156. } else {
  157. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city join sgj_org_follow as f On f.org_id = u.id AND f.admin_user_id = ? AND f.status = 1 left JoIN sgj_admin as a On a.id = f.admin_user_id AND a.status = 1 join sgj_xt.xt_assessment_after_dislysis as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id where x.created_time >= ? AND x.created_time <= ? AND u.import <> 1 GROUP BY x.user_org_id", admin.ID, to, ctime).Scan(&patientinfo).Error
  158. }
  159. //rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_assessment_after_dislysis as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
  160. //defer rows.Close()
  161. //
  162. //if rows.Next() {
  163. // rows.Scan(&total)
  164. //}
  165. return patientinfo, total, err
  166. }
  167. func GetTodayEntrylist(to int64, ctime int64, limit int64, page int64, admin *admin_models.AdminAccount) (patientinfo []function_models.PatientInfo, total int64, err error) {
  168. //offset := (page - 1) * limit
  169. if admin.IsAdmin == 1 {
  170. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city join sgj_xt.xt_warehouse as x on x.org_id = u.id LEFT JOIN sgj_users.sgj_org_follow as f ON f.org_id = u.id AND f.status = 1 LEFT JOIN sgj_users.sgj_admin as a on a.id = f.admin_user_id AND a.status = 1 where x.ctime >= ? AND x.ctime<= ? AND u.import <> 1 GROUP BY x.org_id", to, ctime).Scan(&patientinfo).Error
  171. } else {
  172. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city join sgj_xt.xt_warehouse as x on x.org_id = u.id JOIN sgj_users.sgj_org_follow as f ON f.org_id = u.id AND f.admin_user_id = ? AND f.status = 1 LEFT JOIN sgj_users.sgj_admin as a on a.id = f.admin_user_id AND a.status = 1 where x.ctime >= ? AND x.ctime<= ? AND u.import <> 1 GROUP BY x.org_id", admin.ID, to, ctime).Scan(&patientinfo).Error
  173. }
  174. //rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_warehouse as x on x.org_id = u.id where x.ctime >= ? AND x.ctime <= ?", to, ctime).Rows()
  175. //defer rows.Close()
  176. //
  177. //if rows.Next() {
  178. // rows.Scan(&total)
  179. //}
  180. return patientinfo, total, err
  181. }
  182. func GetTodayExitlist(to int64, ctime int64, limit int64, page int64, admin *admin_models.AdminAccount) (patientinfo []function_models.PatientInfo, total int64, err error) {
  183. //offset := (page - 1) * limit
  184. if admin.IsAdmin == 1 {
  185. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city join sgj_xt.xt_warehouse_out as x on x.org_id = u.id LEFT JOIN sgj_users.sgj_org_follow as f ON f.org_id = u.id AND f.status = 1 LEFT JOIN sgj_users.sgj_admin as a on a.id = f.admin_user_id AND a.status = 1 where x.ctime >= ? AND x.ctime<= ? AND u.import <> 1 GROUP BY x.org_id", to, ctime).Scan(&patientinfo).Error
  186. } else {
  187. err = readUserDb.Raw("select *, a.name as admin_name, d.namepath as namepath from sgj_users.sgj_user_org as u left JOIN sgj_user_district as d On d.id = u.city join sgj_xt.xt_warehouse_out as x on x.org_id = u.id JOIN sgj_users.sgj_org_follow as f ON f.org_id = u.id AND f.admin_user_id = ? AND f.status = 1 LEFT JOIN sgj_users.sgj_admin as a on a.id = f.admin_user_id AND a.status = 1 where x.ctime >= ? AND x.ctime<= ? AND u.import <> 1 GROUP BY x.org_id", admin.ID, to, ctime).Scan(&patientinfo).Error
  188. }
  189. //rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_warehouse_out as x on x.org_id = u.id where x.ctime >= ? AND x.ctime <= ?", to, ctime).Rows()
  190. //defer rows.Close()
  191. //
  192. //if rows.Next() {
  193. // rows.Scan(&total)
  194. //}
  195. return patientinfo, total, err
  196. }