package service import "XT_New/models" func GetAllPatients(org_id int64) (ps []models.KyyPatients) { readDb.Model(&models.KyyPatients{}).Where("user_org_id = ? and status = 1 and lapseto = 1", org_id).Find(&ps) return } func GetAllPatientLaspse(org_id int64) (ps []models.XtPatientLaspseRecord) { readDb.Model(&models.XtPatientLaspseRecord{}).Where("user_org_id = ? and status = 1", org_id).Find(&ps) return } func GetAllPatientPre(org_id int64) (ps []models.KYYPrescriptionVM) { readDb.Model(&models.KYYPrescriptionVM{}).Where("user_org_id = ? and status = 1", org_id).Find(&ps) return } func GetAllPatientSch(org_id int64) (ps []models.KyySchedule) { readDb.Model(&models.KyySchedule{}).Where("user_org_id = ? and status = 1", org_id).Find(&ps) return } func GetAllPatientDialysisRecord(org_id int64, record_date int64, patient_id int64) (ps models.KYYDialysisOrder) { 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) return } func GetAllDialysisRecord(org_id int64, time int64) (ps []models.KYYDialysisOrderTwo) { readDb.Model(&models.KYYDialysisOrderTwo{}).Where("user_org_id = ? and status = 1 and dialysis_date >= ?", org_id, time).Find(&ps) return } func GetSyncTimeByOrgId(org_id int64, sync_type int64) (sync_info models.YHDataUpload, err error) { err = readDb.Model(&models.YHDataUpload{}).Where("org_id = ? and sync_type = ? ", org_id, sync_type).Last(&sync_info).Error return } func GetAdminUserRoleTwo(id string, orgid int64) (models.SgjUserAdminRole, error) { role := models.SgjUserAdminRole{} err := UserReadDB().Where("admin_user_id = ? and org_id = ? and status = 1", id, orgid).Find(&role).Error return role, err }