Beispiel #1
0
        public ActionResult PatientProfile(string UserId)
        {
            var a = System.Web.HttpContext.Current.User;

            if (UserId != null)
            {
                var patient = new PatientFormViewModels();
                var entity  = _context.PacientRepository.GetBy(x => x.UserId == UserId);
                if (entity != null)
                {
                    patient = Mapper.Map <Patient, PatientFormViewModels>(entity);
                    if (entity.Image != null)
                    {
                        patient.Image1 = entity.Image;
                    }
                    patient.Age = _userBll.CalculateAges(entity);


                    var genders  = _userBll.GetGenderTypes();
                    var analysis = _context.PatientAnalysisRepository.Find(x => x.PatientId == patient.Id);
                    var book     = _userBll.PatientBook(patient.Id).ToList();

                    patient.MedicalBook = new MedicalBookViewModel()
                    {
                        Id       = patient.Id,
                        Book     = Mapper.Map <List <Book>, List <BookViewModel> >(book),
                        Analysis = Mapper.Map <List <PatientAnalysis>, List <AnalysisViewModel> >(analysis),
                    };
                    foreach (var item in patient.MedicalBook.Book)
                    {
                        foreach (var type in _userBll.GetDiseaseTypes())
                        {
                            if (item.DiseaseType == type.Id)
                            {
                                item.DiseaseTypeName = type.Name;
                            }
                        }

                        var Doctor = _context.DoctorsRepository.GetBy(x => x.Id == item.DoctorId);
                        item.Doctor = Doctor.Name + " " + Doctor.Surname;
                    }

                    foreach (var item in genders)
                    {
                        if (item.Id == entity.Gender)
                        {
                            patient.Gender = item.Name;
                        }
                    }

                    patient.Diagnosis = new BookViewModel
                    {
                        DiseaseTypes = _userBll.GetDiseaseTypes()
                    };

                    return(View("PatientProfile", patient));
                }
                else
                {
                    patient.Genders = _userBll.GetGenderTypes();
                    return(View("RegisterPatientForm", patient));
                }
            }
            return(View("Error"));
        }