예제 #1
0
 public Doctor CheckDoctor(string ssn)
 {
     using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
     {
         return(repositoryDoctor.FirstWithExplicitLoad(I => I.Ssn == ssn));
     }
 }
예제 #2
0
 public int ChangePassword(Doctor doctor, string oldPassword, string newPassword, string newPasswordRepeat)
 {
     if (!string.IsNullOrEmpty(oldPassword) && !string.IsNullOrWhiteSpace(oldPassword) && !string.IsNullOrEmpty(newPassword) && !string.IsNullOrWhiteSpace(newPassword) && !string.IsNullOrEmpty(newPasswordRepeat) && !string.IsNullOrWhiteSpace(newPasswordRepeat) && doctor != null)
     {
         if (doctor.Password == PasswordCrypto.EncryptToSha512(oldPassword))
         {
             if (newPassword == newPasswordRepeat)
             {
                 using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
                 {
                     doctor.Password = PasswordCrypto.EncryptToSha512(newPassword);
                     repositoryDoctor.CUDOperation(doctor, EntityState.Modified);
                     return(repositoryDoctor.SaveChanges());
                 }
             }
             else
             {
                 return(-4);
             }
         }
         else
         {
             return(-3);
         }
     }
     else
     {
         return(-1);
     }
 }
예제 #3
0
 public List <Doctor> GetDeletedDoctor()
 {
     using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
     {
         return(repositoryDoctor.WhereWithExplicitLoad(I => I.IsActive == false).ToList());
     }
 }
예제 #4
0
        // GET: Turno
        public ActionResult Index()
        {
            RepositoryDoctor   repositoryDoctor   = new RepositoryDoctor();
            RepositoryAtencion repositoryatencion = new RepositoryAtencion();

            var turnos = db.Turnos.Include(t => t.Atencion).Include(t => t.Paciente);

            List <Turno> tur = new List <Turno>();

            tur = turnos.ToList();

            IEnumerable <Turno> lstordenada = tur.OrderBy(User => User.Fecha);

            foreach (var item in lstordenada)
            {
                foreach (var item2 in repositoryatencion.List())
                {
                    if (item.IdAtencion == item2.Id)
                    {
                        item.Atencion = item2;

                        foreach (var item3 in repositoryDoctor.List())
                        {
                            if (item.Atencion.IdDoctor == item3.Id)
                            {
                                item.Atencion.Doctor = item3;
                            }
                        }
                    }
                }
            }

            return(View(tur));
        }
예제 #5
0
 public Doctor DoctorLogIn(string userName, string password)
 {
     using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
     {
         string encryptedPassword = PasswordCrypto.EncryptToSha512(password);
         return(repositoryDoctor.FirstWithExplicitLoad(I => I.Ssn == userName && I.Password == encryptedPassword && I.IsActive == true));
     }
 }
예제 #6
0
 public int DoctorInfoUpdate(Doctor doctor, string picture)
 {
     using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
     {
         Image        image = Image.FromFile(picture);
         MemoryStream mem   = new MemoryStream();
         image.Save(mem, ImageFormat.Png);
         doctor.Picture = mem.ToArray();
         repositoryDoctor.CUDOperation(doctor, EntityState.Modified);
         return(repositoryDoctor.SaveChanges());
     }
 }
예제 #7
0
 public List <Doctor> GetActiveDoctors()
 {
     using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
     {
         List <Doctor> doctors = repositoryDoctor.WhereWithExplicitLoad(I => I.IsActive == true, paths: new string[] { "Hospital" }).ToList();
         foreach (var item in doctors)
         {
             item.Age = (DateTime.Now.Year - item.Birthday.Year);
         }
         return(doctors);
     }
 }
예제 #8
0
 public Doctor DoctorFind(string ssn)
 {
     using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
     {
         Doctor doctor = repositoryDoctor.FirstWithExplicitLoad(I => I.Ssn == ssn, paths: new string[] { "Hospital", "Appointments", "Appointments.Member", "Appointments.Medicines" });
         doctor.Age = (DateTime.Now.Year - doctor.Birthday.Year);
         foreach (var item in doctor.Appointments)
         {
             item.Member.Age = (DateTime.Now.Year - item.Member.Birthday.Year);
         }
         return(doctor);
     }
 }
예제 #9
0
 public int ResetDoctorPassword(Doctor doctor, string password)
 {
     if (doctor != null && !string.IsNullOrEmpty(password) && !string.IsNullOrWhiteSpace(password))
     {
         using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
         {
             doctor.Password = PasswordCrypto.EncryptToSha512(password);
             repositoryDoctor.CUDOperation(doctor, EntityState.Modified);
             return(repositoryDoctor.SaveChanges());
         }
     }
     else
     {
         return(-1);
     }
 }
예제 #10
0
 public int DoctorDeleteRecord(Doctor doctor)
 {
     if (doctor != null)
     {
         using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
         {
             doctor.DeleteTime = DateTime.Now;
             doctor.IsActive   = false;
             repositoryDoctor.CUDOperation(doctor, EntityState.Modified);
             return(repositoryDoctor.SaveChanges());
         }
     }
     else
     {
         return(-1);
     }
 }
예제 #11
0
        public ActionResult Create([Bind(Include = "Id,IdDoctor,IdSala,TipoEspecialidad,HorarioTurno,Dia")] Atencion atencion)
        {
            if (ModelState.IsValid)
            {
                RepositoryDoctor repositoryDoctor = new RepositoryDoctor();

                foreach (var item in repositoryDoctor.List())
                {
                    if (item.Id == atencion.IdDoctor)
                    {
                        atencion.TipoEspecialidad = item.TipoEspecialidad;
                    }
                }


                int valor = 0;
                RepositoryAtencion repository = new RepositoryAtencion();

                valor = atencion.verificardisponibilidadsala(repository, atencion);
                //foreach (var x in repository.List())
                //{
                //    if (x.Dia == atencion.Dia && x.HorarioTurno == atencion.HorarioTurno && x.IdSala == atencion.IdSala)
                //    {
                //        valor = 1;
                //    }
                //}

                if (valor == 1)
                {
                    string aviso = "Ya se encuentra un Empleado en ese dia, ese turno y esa sala.";
                    ViewBag.advertencia = aviso;
                }
                else
                {
                    db.Atenciones.Add(atencion);
                    db.SaveChanges();
                    log.Info("Creacion de atencion");
                    return(RedirectToAction("Index"));
                }
            }

            ViewBag.IdDoctor = new SelectList(db.Doctores, "Id", "Nombre", atencion.IdDoctor);
            ViewBag.IdSala   = new SelectList(db.Salas, "Id", "Nombre", atencion.IdSala);
            return(View(atencion));
        }
예제 #12
0
 public int ReactivateData <Entity>(Entity entity)
 {
     if (entity is Hospital)
     {
         using (RepositoryHospital repositoryHospital = new RepositoryHospital())
         {
             (entity as Hospital).IsActive = true;
             repositoryHospital.CUDOperation(entity as Hospital, EntityState.Modified);
             return(repositoryHospital.SaveChanges());
         }
     }
     else if (entity is Doctor)
     {
         using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
         {
             (entity as Doctor).IsActive = true;
             repositoryDoctor.CUDOperation(entity as Doctor, EntityState.Modified);
             return(repositoryDoctor.SaveChanges());
         }
     }
     else if (entity is Member)
     {
         using (RepositoryMember repositoryMember = new RepositoryMember())
         {
             (entity as Member).IsActive = true;
             repositoryMember.CUDOperation(entity as Member, EntityState.Modified);
             return(repositoryMember.SaveChanges());
         }
     }
     else if (entity is Medicine)
     {
         using (RepositoryMedicine repositoryMedicine = new RepositoryMedicine())
         {
             (entity as Medicine).IsActive = true;
             repositoryMedicine.CUDOperation(entity as Medicine, EntityState.Modified);
             return(repositoryMedicine.SaveChanges());
         }
     }
     else
     {
         return(-1);
     }
 }
예제 #13
0
 public DoctorController(RepositoryDoctor repo)
 {
     this.repo = repo;
 }
예제 #14
0
        public int DoctorInfoUpdate(Doctor doctor, string phone, string mail, string city, string county)
        {
            string tempPhone;
            string tempMail;
            string tempCity;
            string tempCounty;

            if (string.IsNullOrEmpty(phone.Trim()))
            {
                tempPhone = null;
            }
            else
            {
                tempPhone = phone;
            }
            if (string.IsNullOrEmpty(mail.Trim()))
            {
                tempMail = null;
            }
            else
            {
                tempMail = mail;
            }
            if (string.IsNullOrEmpty(city.Trim()))
            {
                tempCity = null;
            }
            else
            {
                tempCity = city;
            }
            if (string.IsNullOrEmpty(county.Trim()))
            {
                tempCounty = null;
            }
            else
            {
                tempCounty = county;
            }
            using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
            {
                if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Id != doctor.Id && I.Phone == phone))
                {
                    if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Id != doctor.Id && I.Mail == mail))
                    {
                        doctor.Phone  = tempPhone;
                        doctor.Mail   = tempMail;
                        doctor.City   = tempCity;
                        doctor.County = tempCounty;
                        repositoryDoctor.CUDOperation(doctor, EntityState.Modified);
                        return(repositoryDoctor.SaveChanges());
                    }
                    else
                    {
                        return(-112);
                    }
                }
                else
                {
                    return(-111);
                }
            }
        }
예제 #15
0
 public int DoctorNewRecord(Hospital hospital, string ssn, string appellation, string expertise, string ageRange, string name, string surname, DateTime birthday, string phone, string mail, string city, string county)
 {
     if (!string.IsNullOrEmpty(ssn) && !string.IsNullOrWhiteSpace(ssn) && ssn.Length == 11 && !string.IsNullOrEmpty(appellation) && !string.IsNullOrWhiteSpace(appellation) && !string.IsNullOrEmpty(expertise) && !string.IsNullOrWhiteSpace(expertise) && !string.IsNullOrEmpty(ageRange) && !string.IsNullOrWhiteSpace(ageRange) && !string.IsNullOrEmpty(surname) && !string.IsNullOrWhiteSpace(surname) && !string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name) && birthday != null && hospital != null)
     {
         string tempPhone;
         string tempMail;
         string tempCity;
         string tempCounty;
         if (string.IsNullOrEmpty(phone.Trim()))
         {
             tempPhone = null;
         }
         else
         {
             tempPhone = phone;
         }
         if (string.IsNullOrEmpty(mail.Trim()))
         {
             tempMail = null;
         }
         else
         {
             tempMail = mail;
         }
         if (string.IsNullOrEmpty(city.Trim()))
         {
             tempCity = null;
         }
         else
         {
             tempCity = city;
         }
         if (string.IsNullOrEmpty(county.Trim()))
         {
             tempCounty = null;
         }
         else
         {
             tempCounty = county;
         }
         using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
         {
             if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Ssn == ssn))
             {
                 if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Phone == phone))
                 {
                     if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Mail == mail))
                     {
                         Doctor doctor = new Doctor()
                         {
                             Id          = Guid.NewGuid(),
                             Ssn         = ssn,
                             Appellation = BLLHelper.GetEnumValueFromDescription <DoctorEnumAppellation>(appellation),
                             Expertise   = BLLHelper.GetEnumValueFromDescription <DoctorEnumExpertise>(expertise),
                             AgeRange    = BLLHelper.GetEnumValueFromDescription <DoctorEnumAgeRange>(ageRange),
                             Name        = BLLHelper.TrimName(name),
                             Surname     = BLLHelper.TrimSurname(surname),
                             Birthday    = birthday,
                             Phone       = tempPhone,
                             Mail        = tempMail,
                             City        = tempCity,
                             County      = tempCounty,
                             Picture     = BLLHelper.DefaultDoctorPic(),
                             Password    = PasswordCrypto.EncryptToSha512(ssn),
                             UpdateTime  = DateTime.Now,
                             HospitalId  = hospital.Id
                         };
                         repositoryDoctor.CUDOperation(doctor, EntityState.Added);
                         return(repositoryDoctor.SaveChanges());
                     }
                     else
                     {
                         return(-112);
                     }
                 }
                 else
                 {
                     return(-111);
                 }
             }
             else
             {
                 return(-110);
             }
         }
     }
     else
     {
         return(-1);
     }
 }
예제 #16
0
 public int DoctorUpdateRecord(Doctor doctor, Hospital hospital, string ssn, string appellation, string expertise, string ageRange, string name, string surname, DateTime birthday, string phone, string mail, string city, string county)
 {
     if (!string.IsNullOrEmpty(ssn) && !string.IsNullOrWhiteSpace(ssn) && ssn.Length == 11 && !string.IsNullOrEmpty(appellation) && !string.IsNullOrWhiteSpace(appellation) && !string.IsNullOrEmpty(expertise) && !string.IsNullOrWhiteSpace(expertise) && !string.IsNullOrEmpty(ageRange) && !string.IsNullOrWhiteSpace(ageRange) && !string.IsNullOrEmpty(surname) && !string.IsNullOrWhiteSpace(surname) && !string.IsNullOrEmpty(name) && !string.IsNullOrWhiteSpace(name) && birthday != null && doctor != null && hospital != null)
     {
         string tempPhone;
         string tempMail;
         string tempCity;
         string tempCounty;
         if (string.IsNullOrEmpty(phone.Trim()))
         {
             tempPhone = null;
         }
         else
         {
             tempPhone = phone;
         }
         if (string.IsNullOrEmpty(mail.Trim()))
         {
             tempMail = null;
         }
         else
         {
             tempMail = mail;
         }
         if (string.IsNullOrEmpty(city.Trim()))
         {
             tempCity = null;
         }
         else
         {
             tempCity = city;
         }
         if (string.IsNullOrEmpty(county.Trim()))
         {
             tempCounty = null;
         }
         else
         {
             tempCounty = county;
         }
         using (RepositoryDoctor repositoryDoctor = new RepositoryDoctor())
         {
             if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Id != doctor.Id && I.Ssn == ssn))
             {
                 if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Id != doctor.Id && I.Phone == phone))
                 {
                     if (!repositoryDoctor.AnyWithExplicitLoad(I => I.Id != doctor.Id && I.Mail == mail))
                     {
                         doctor.Ssn         = ssn;
                         doctor.Appellation = BLLHelper.GetEnumValueFromDescription <DoctorEnumAppellation>(appellation);
                         doctor.Expertise   = BLLHelper.GetEnumValueFromDescription <DoctorEnumExpertise>(expertise);
                         doctor.AgeRange    = BLLHelper.GetEnumValueFromDescription <DoctorEnumAgeRange>(ageRange);
                         doctor.Name        = BLLHelper.TrimName(name);
                         doctor.Surname     = BLLHelper.TrimSurname(surname);
                         doctor.Birthday    = birthday;
                         doctor.Phone       = tempPhone;
                         doctor.Mail        = tempMail;
                         doctor.City        = tempCity;
                         doctor.County      = tempCounty;
                         doctor.UpdateTime  = DateTime.Now;
                         doctor.HospitalId  = hospital.Id;
                         repositoryDoctor.CUDOperation(doctor, EntityState.Modified);
                         return(repositoryDoctor.SaveChanges());
                     }
                     else
                     {
                         return(-112);
                     }
                 }
                 else
                 {
                     return(-111);
                 }
             }
             else
             {
                 return(-110);
             }
         }
     }
     else
     {
         return(-1);
     }
 }
예제 #17
0
        public ActionResult Create([Bind(Include = "Id,TipoEspecialidad,Fecha,IdPaciente,IdAtencion,Hora,Abonado")] Turno turno)
        {
            RepositoryAtencion repositoryatencion = new RepositoryAtencion();
            RepositoryTurno    repositoryTurno    = new RepositoryTurno();
            RepositoryDoctor   repositoryDoctor   = new RepositoryDoctor();

            int    valoratencion = 1;
            string diaturno;

            diaturno = turno.Fecha.DayOfWeek.ToString();
            List <Atencion> lstatencionvalidas = new List <Atencion>();

            if (turno.IdAtencion == 0)
            {
                foreach (var item in repositoryatencion.List())
                {
                    turno.IdAtencion = item.Id;
                    valoratencion    = turno.verificarcoordinacionconatencion(repositoryatencion, turno);

                    if (valoratencion == 0)
                    {
                        if (turno.TipoEspecialidad == item.TipoEspecialidad)
                        {
                            if (turno.Atencion.Dia.ToString() == diaturno)
                            {
                                foreach (var item3 in repositoryDoctor.List())
                                {
                                    if (item.IdDoctor == item3.Id)
                                    {
                                        item.Doctor = item3;
                                    }
                                }

                                lstatencionvalidas.Add(item);
                            }

                            valoratencion = 1;
                        }
                    }
                }

                turno.IdAtencion = 0;
                //IEnumerable<Atencion> lst;
                //lst = lstatencionvalidas;
                if (lstatencionvalidas.Count > 0)
                {
                    //ViewBag.Atenciones = lstatencionvalidas.Select(m => new SelectListItem { Text = m.Id.ToString(), Value = m.Id.ToString() });
                    ViewBag.IdAtencion = new SelectList(lstatencionvalidas, "Id", "Doctor.Nombre");
                }

                ViewBag.IdPaciente = new SelectList(db.Pacientes, "Id", "Nombre", turno.IdPaciente);
                return(View(turno));
            }

            //List<Atencion> lstatencion = new List<Atencion>();

            //foreach (var item in repositoryatencion.List())
            //{
            //    if (item.TipoEspecialidad == turno.TipoEspecialidad)
            //    {
            //        lstatencion.Add(item);
            //    }
            //}
            //ViewBag.IdAtencion = new SelectList(lstatencion, "Id", "Id", turno.IdAtencion);
            if (ModelState.IsValid)
            {
                int valor2 = 0;

                valor2 = turno.validarhora(turno);



                Atencion natencion = new Atencion();
                natencion = repositoryatencion.GetById(turno.IdAtencion);
                int valor = 0;


                valor = turno.verificarrepeticion(repositoryTurno, turno);



                int valor3 = 1;

                //valor3 = turno.verificarcoordinacionconatencion(repositoryatencion, turno);


                valor3 = 0;

                if (valor3 == 1)
                {
                    ViewBag.advertencia4 = string.Format("El doctor no se encuentra en este horario, esta en el horario de {0} .", natencion.HorarioTurno);
                }

                if (valor == 1)
                {
                    ViewBag.advertencia = "Ya hay alguien asignado en este horario.";
                }

                if (valor2 == 1)
                {
                    ViewBag.advertencia3 = "La hora ingresada no es valida.";
                }

                if (valor == 1 || valor2 == 1 || valor3 == 1)
                {
                }
                else
                {
                    db.Turnos.Add(turno);
                    db.SaveChanges();
                    log.Info("Creacion de turno");
                    //int valor99 = 0;
                    //foreach (var item in repositoryatencion.List())
                    //{

                    //    if (valor99 < item.Id)
                    //    {
                    //        valor99 = item.Id;
                    //    }

                    //}
                    //repositoryatencion.Delete(valor99);
                    //valor99 = 0;
                    return(RedirectToAction("Index"));
                }
            }



            ViewBag.IdPaciente = new SelectList(db.Pacientes, "Id", "Nombre", turno.IdPaciente);
            return(View(turno));
        }