public ViewModelPatientTherapist GetPatientsTherapist(string NPINumber) { // List<tblPatient> patients = _unitOfWork.PatientEntityRepo.Get().ToList(); List <PatientEntity> patients = GetPatientsbyNPINumber(NPINumber); ViewModelPatientTherapist patTher = new ViewModelPatientTherapist(); List <PatientEntity> patientsEntity = new List <PatientEntity>(); Team.Rehab.DataModel.RehabEntities rehab = new RehabEntities(); List <TherapistEntity> therapistEntity = new List <TherapistEntity>(); //therapistEntity = (from therapist in rehab.tblTherapists // select new TherapistEntity // { // FirstName = therapist.FirstName, // LastName = therapist.LastName // //PhoneNumber = therapist.LastName, // //Email = therapist.LastName // } //).ToList(); string ReferralSource = null; tblReferrer referrer = _unitOfWork.ReferrerRepo.Get(o => o.NPINumber == NPINumber).FirstOrDefault(); if (referrer != null) { ReferralSource = Convert.ToString(referrer.Rrowid); } therapistEntity = (from therapist in rehab.tblTherapists join docs in rehab.tblDocMasters on therapist.TherapistID equals docs.TreatingTherapistId join patient in rehab.tblPatients.Where(a => a.ReferralSource == ReferralSource) on docs.PTrowid equals patient.Prowid //join referrer in rehab.tblReferrers on ptint.ReferralSource equals referrer.Rrowid //where referrer.NPINumber = NPINumber select new TherapistEntity { FirstName = therapist.FirstName, LastName = therapist.LastName //PhoneNumber = therapist.LastName, //Email = therapist.LastName } ).Distinct().ToList(); if (patients.Count() > 0) { patTher.PatientList = patients; } if (therapistEntity.Count() > 0) { patTher.Therapist = therapistEntity; } return(patTher); }
public IHttpActionResult GetPatientsTherapists(string NPINumber) { // string NPINumber = string.Empty; ViewModelPatientTherapist patientsTherapists = _patientRepository.GetPatientsTherapist(NPINumber); if (patientsTherapists.PatientList == null && patientsTherapists.Therapist == null) { throw new ApiDataException(1002, "No patient/Therapist found .", HttpStatusCode.InternalServerError); } else if (patientsTherapists.PatientList.Count < 1 && patientsTherapists.Therapist.Count < 0) { throw new ApiDataException(1002, "No patient/Therapist found .", HttpStatusCode.InternalServerError); } return(Ok(patientsTherapists)); }