public List <PatientDataResponse> getPatientsForMP(int medicalProfessionalId) { using (var context = new HackathonEntities()) { var patientIdList = context.MpToPatients.Where(x => x.MPId == medicalProfessionalId).Select(x => x.PatientId).ToList(); var results = new List <PatientDataResponse>(); foreach (var patientId in patientIdList) { var patient = patientRepository.getPatientDataFromId(patientId); var user = userRepository.getUserInfoFromId(patient.UserId); var scripts = patientRepository.getPatientScripts(patientId); var result = new PatientDataResponse() { id = user.id, PatientId = patient.PatientId, firstName = user.first_name, lastName = user.last_name, email = user.email, AtRisk = patient.AtRisk.Value ? "Yes" : "No", DOB = patient.DOB.Value.ToString("MM-dd-yyyy"), Gender = patient.Gender, Scripts = scripts }; results.Add(result); } ; return(results); } }
public PatientDataResponse getAllPatientData(string userEmail) { var user = userRepository.getUserInfo(userEmail); var patientInfo = getPatientInfo(user.id); var patientScripts = getPatientScripts(patientInfo.PatientId); var response = new PatientDataResponse() { id = user.id, firstName = user.first_name, lastName = user.last_name, email = user.email, AtRisk = patientInfo.AtRisk.Value ? "Yes" : "No", DOB = patientInfo.DOB.Value.ToString("MM-dd-yyyy"), Gender = patientInfo.Gender, Scripts = patientScripts }; return(response); }