public async Task <CurrentTreatmentOutputModel> GetCurrentTreatment(string patientId) { var activeDiagnoseId = await _diagnoseContext.Patients .Where(p => p.UserId == patientId) .Select(x => x.ActiveDiagnoseId) .SingleOrDefaultAsync(); var treatment = await _diagnoseContext.Diagnoses .Where(d => d.Treatment.DiagnoseId == activeDiagnoseId) .Include(d => d.Treatment) .Include(d => d.Doctor) .Include(d => d.Patient) .SingleOrDefaultAsync(); if (treatment == null) { return(null); } var doctor = await _userManager.FindByIdAsync(treatment.Doctor.UserId); var patient = await _userManager.FindByIdAsync(treatment.Patient.UserId); var model = new CurrentTreatmentOutputModel() { DoctorName = doctor.FirstName + " " + doctor.LastName, PatientName = patient.FirstName + " " + patient.LastName, AddedOn = treatment.Treatment.Beginning.ToShortDateString(), Treatment = StateTranslator.GetTreatmentDisplayName(treatment.Treatment.Surgery, treatment.Treatment.Radiation, treatment.Treatment.Chemeotherapy, treatment.Treatment.EndocrineTreatment), Description = StateTranslator.GetTreatmentDescription(treatment.Treatment.Surgery, treatment.Treatment.Radiation, treatment.Treatment.Chemeotherapy, treatment.Treatment.EndocrineTreatment) }; return(model); }
public async Task <CurrentDiagnoseOutputModel> GetActiveDiagnose(string patientId) { var p = await _diagnoseContext.Patients .Where(x => x.UserId == patientId) .SingleOrDefaultAsync(); var diagnose = await _diagnoseContext.Diagnoses .Where(d => d.Id == p.ActiveDiagnoseId) .Include(d => d.Doctor) .Include(d => d.Patient) .SingleOrDefaultAsync(); if (diagnose == null) { return(null); } var doctor = await _userManager.FindByIdAsync(diagnose.Doctor.UserId); var patient = await _userManager.FindByIdAsync(diagnose.Patient.UserId); var tumorState = StateTranslator.TranslateTumorState(diagnose.PrimaryTumor); var distantMetastasisState = StateTranslator.TranslateMetastatsisState(diagnose.DistantMetastasis); var regionalLymphNodesState = StateTranslator.TranslateRegionalLymphNodesState(diagnose.RegionalLymphNodes); var outputModel = new CurrentDiagnoseOutputModel() { DoctorName = doctor.FirstName + " " + doctor.LastName, PatientName = patient.FirstName + " " + patient.LastName, Stage = diagnose.Stage.ToString(), PrimaryTumorState = tumorState, DistantMetastasisState = distantMetastasisState, RegionalLymphNodesState = regionalLymphNodesState }; return(outputModel); }