function_service.go 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. package service
  2. import (
  3. "XT_Admin_Api/models/function_models"
  4. "fmt"
  5. )
  6. //病人管理
  7. func GetTodayInfo(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
  8. offset := (page - 1) * limit
  9. err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id left join sgj_xt.xt_patients as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  10. 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()
  11. if rows.Next() {
  12. rows.Scan(&total)
  13. }
  14. fmt.Println("&total是什么", total)
  15. return patientinfo, total, err
  16. }
  17. //透析处方
  18. func GetTodayDialysisPatientsInfo(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
  19. offset := (page - 1) * limit
  20. err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id 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 <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  21. 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()
  22. if rows.Next() {
  23. rows.Scan(&total)
  24. }
  25. return patientinfo, total, err
  26. }
  27. //接诊评估
  28. func GetTodayReceivePatientsInfo(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
  29. offset := (page - 1) * limit
  30. err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id 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 <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  31. 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()
  32. if rows.Next() {
  33. rows.Scan(&total)
  34. }
  35. return patientinfo, total, err
  36. }
  37. // 透前评估
  38. func GetTodayBeforDislysisInfo(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
  39. offset := (page - 1) * limit
  40. err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id 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 <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  41. 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()
  42. if rows.Next() {
  43. rows.Scan(&total)
  44. }
  45. return patientinfo, total, err
  46. }
  47. //零食医嘱
  48. func GetTodayDoctorsOrderInfo(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
  49. offset := (page - 1) * limit
  50. err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id 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 <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  51. 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()
  52. if rows.Next() {
  53. rows.Scan(&total)
  54. }
  55. return patientinfo, total, err
  56. }
  57. //双人核对
  58. func GetTodayDoubleCheckInfo(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
  59. offset := (page - 1) * limit
  60. err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id 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 <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  61. 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()
  62. if rows.Next() {
  63. rows.Scan(&total)
  64. }
  65. return patientinfo, total, err
  66. }
  67. //透析上机
  68. func GetTodayDialysisMachinek(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
  69. offset := (page - 1) * limit
  70. err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id 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 <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  71. 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()
  72. if rows.Next() {
  73. rows.Scan(&total)
  74. }
  75. return patientinfo, total, err
  76. }
  77. //透析检测
  78. func GetTodayDialysisExamination(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
  79. offset := (page - 1) * limit
  80. err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id 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 <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  81. 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()
  82. if rows.Next() {
  83. rows.Scan(&total)
  84. }
  85. return patientinfo, total, err
  86. }
  87. //透析下机
  88. func GetTodayBeforOrpenetration(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
  89. offset := (page - 1) * limit
  90. err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id 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 <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  91. 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()
  92. if rows.Next() {
  93. rows.Scan(&total)
  94. }
  95. return patientinfo, total, err
  96. }
  97. //透后评估
  98. func GetTodayPostAssessment(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
  99. offset := (page - 1) * limit
  100. err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id 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 <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
  101. 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()
  102. if rows.Next() {
  103. rows.Scan(&total)
  104. }
  105. return patientinfo, total, err
  106. }
  107. func GetTodayEntrylist(to int64, ctime int64, limit int64, page int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
  108. offset := (page - 1) * limit
  109. err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u 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 LEFT JOIN sgj_users.sgj_admin as a on a.id = f.admin_user_id where x.ctime >= ? AND x.ctime<= ? GROUP BY x.org_id", to, ctime).Scan(&patientinfo).Error
  110. 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()
  111. if rows.Next() {
  112. rows.Scan(&total)
  113. }
  114. return patientinfo, total, err
  115. }
  116. func GetTodayExitlist(to int64, ctime int64, limit int64, page int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
  117. offset := (page - 1) * limit
  118. err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u 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 LEFT JOIN sgj_users.sgj_admin as a on a.id = f.admin_user_id where x.ctime >= ? AND x.ctime<= ? GROUP BY x.org_id", to, ctime).Scan(&patientinfo).Error
  119. 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()
  120. if rows.Next() {
  121. rows.Scan(&total)
  122. }
  123. return patientinfo, total, err
  124. }