yh_service.go 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package service
  2. import "XT_New/models"
  3. func GetAllPatients(org_id int64) (ps []models.KyyPatients) {
  4. readDb.Model(&models.KyyPatients{}).Where("user_org_id = ? and status = 1 and lapseto = 1", org_id).Find(&ps)
  5. return
  6. }
  7. func GetAllPatientLaspse(org_id int64) (ps []models.XtPatientLaspseRecord) {
  8. readDb.Model(&models.XtPatientLaspseRecord{}).Where("user_org_id = ? and status = 1", org_id).Find(&ps)
  9. return
  10. }
  11. func GetAllPatientPre(org_id int64) (ps []models.KYYPrescriptionVM) {
  12. readDb.Model(&models.KYYPrescriptionVM{}).Where("user_org_id = ? and status = 1", org_id).Find(&ps)
  13. return
  14. }
  15. func GetAllPatientSch(org_id int64) (ps []models.KyySchedule) {
  16. readDb.Model(&models.KyySchedule{}).Where("user_org_id = ? and status = 1", org_id).Find(&ps)
  17. return
  18. }
  19. func GetAllPatientDialysisRecord(org_id int64, record_date int64, patient_id int64) (ps models.KYYDialysisOrder) {
  20. readDb.Model(&models.KYYDialysisOrder{}).Preload("KYYPrescriptionVM", "status = 1").Preload("DeviceNumber", "status = 1").Preload("UserAdminRole", "status = 1").Preload("KyyPredialysisEvaluation", "status = 1 and user_org_id = ? and assessment_date = ?", org_id, record_date).Preload("KyyAssessmentAfterDislysis", "status = 1 and user_org_id = ? and assessment_date = ?", org_id, record_date).Preload("KyyTreatmentSummary", "status = 1 and user_org_id = ? and assessment_date = ?", org_id, record_date).Preload("KyyMonitoringRecord", "status = 1 and user_org_id = ? and monitoring_date = ?", org_id, record_date).Preload("KyyDoctorAdvice", "status = 1 and user_org_id = ? and advice_date = ?", org_id, record_date).Where("user_org_id = ? and status = 1 and dialysis_date = ? and patient_id = ?", org_id, record_date, patient_id).Find(&ps)
  21. return
  22. }
  23. func GetAllDialysisRecord(org_id int64, time int64) (ps []models.KYYDialysisOrderTwo) {
  24. readDb.Model(&models.KYYDialysisOrderTwo{}).Where("user_org_id = ? and status = 1 and dialysis_date >= ?", org_id, time).Find(&ps)
  25. return
  26. }
  27. func GetSyncTimeByOrgId(org_id int64, sync_type int64) (sync_info models.YHDataUpload, err error) {
  28. err = readDb.Model(&models.YHDataUpload{}).Where("org_id = ? and sync_type = ? ", org_id, sync_type).Last(&sync_info).Error
  29. return
  30. }
  31. func GetAdminUserRoleTwo(id string, orgid int64) (models.SgjUserAdminRole, error) {
  32. role := models.SgjUserAdminRole{}
  33. err := UserReadDB().Where("admin_user_id = ? and org_id = ? and status = 1", id, orgid).Find(&role).Error
  34. return role, err
  35. }