Example #1
0
        //Es el metodo que se encarga de insertar a los pacientes en las estructuras de datos : Tabla Hash, Arboles de busqueda AVL (nombre,apellido, dpi)

        public void Agregar(PacientModel newPacient)
        {
            //genera una llave de tipo long la cual se usara como indice en la insercion a la tabla hash
            long newkey = keyGen(newPacient.DPI);

            //se inserta en la Tabla Hash que contiene los datos de todos los municipios y departamentos
            Database.Add(newPacient, newkey);

            //se inserta en la tabla hash que nada mas se utiliza por cada inicio de sesion
            Data.Add(newPacient, newkey);

            //se realiza la insercion de un PacientModel nada mas con la informacion de DPI
            DpiTree.Root = DpiTree.Insert(new SearchCriteria <long> {
                value = newPacient.DPI, key = newPacient.DPI
            }, DpiTree.Root);

            //se realiza la insercion de un PacientModel nada mas con la informacion de Nombre
            NameTree.Root = NameTree.Insert(new SearchCriteria <string> {
                value = newPacient.Name, key = newPacient.DPI
            }, NameTree.Root);

            //se realiza la insercion de un PacientModel nada mas con la informacion de Apellido
            LastNameTree.Root = LastNameTree.Insert(new SearchCriteria <string> {
                value = newPacient.LastName, key = newPacient.DPI
            }, LastNameTree.Root);

            //Se inserta el pacientModel al heap para que luego la informacion sea capturada en las demas interfaces de la aplicacion
            HeapPacient.insertKey(newPacient);
        }
        public IHttpActionResult PostPacientModel(PacientModel pacientmodel)
        {
            //HEAD
            //User-Agent: Fiddler
            //Host: localhost:1678
            //Content-Length: 194
            //Content-Type: application/json

            //BODY
            //{"Id":"00000000-0000-0000-0000-000000000000","Email":"*****@*****.**","FirstName":"Douglas","LastName":"Costa","BornDate":"1985-08-26T00:00:00","Weight":"71.0","Height":"1.71","Version":null}
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //try
            //{
            Save(pacientmodel);
            //}
            //catch (DbUpdateException)
            //{
            //    //if (PacientModelExists(pacientmodel.Id))
            //    //    return Conflict();
            //    //else
            //        throw;
            //}

            return(CreatedAtRoute("DefaultApi", new { id = pacientmodel.Id }, pacientmodel));
        }
        // GET api/Pacient/5
        //[ResponseType(typeof(PacientModel))]
        //public IHttpActionResult GetPacientModel(Guid id)
        //{
        //    PacientModel pacientmodel = db.PacientModels.Find(id);
        //    if (pacientmodel == null)
        //    {
        //        return NotFound();
        //    }

        //    return Ok(pacientmodel);
        //}

        // PUT api/Pacient/5
        public IHttpActionResult PutPacientModel(Guid id, PacientModel pacientmodel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != pacientmodel.Id)
            {
                return(BadRequest());
            }

            try
            {
                Save(pacientmodel);
            }
            catch (DbUpdateConcurrencyException)
            {
                //if (!PacientModelExists(id))
                //    return NotFound();
                //else
                throw;
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #4
0
        //Método que reasigna la fecha de vacunación de un registro
        public ActionResult SReschedule(PacientModel pacient)
        {
            var x = Singleton.Instance.HeapPacient.extractMin();

            x.schedule = Singleton.Instance.NextDate(Singleton.Instance.HeapPacient.Length() - 1);
            Singleton.Instance.HeapPacient.insertKey(x);
            return(RedirectToAction(nameof(Simulation)));
        }
Example #5
0
        public ActionResult WorkArea(IFormCollection collection)
        {
            //Obtiene los datos indicados por el usuario, asigna una prioridad en base a estos y lo añade a la lista de espera
            long dpi     = long.Parse(collection["dpi"]);
            var  pacient = new PacientModel
            {
                Name         = collection["name"],
                LastName     = collection["lastname"],
                DPI          = dpi,
                Department   = collection["department"],
                municipality = collection["municipality"],
                schedule     = new DateTime(),
                vaccinated   = false,
            };
            string q1 = collection["q1"];
            string q2 = collection["q2"];
            string q3 = collection["q3"];

            if (q1 == "Si")
            {
                pacient.priority = "1a";
            }
            else if (q2 == "Si")
            {
                pacient.priority = "1c";
            }
            else if (q3 == "Si")
            {
                pacient.priority = "1f";
            }
            else
            {
                pacient.priority = "1b";
            }
            Singleton.Instance.Agregar(pacient);
            Data();
            return(RedirectToAction(nameof(Index)));
        }
Example #6
0
        //Get de la view Configuration
        public IActionResult Configuration()
        {
            //Este método aplica las configuraciones básicas del programa, si hay unas previamente indicadas
            //las cargará al programa, de lo contrario mostrará la vista para que el usuario pueda asignarlas
            if (System.IO.File.Exists("./Database.txt"))
            {
                var      lectorlinea = new StreamReader("./Database.txt");
                string   line        = lectorlinea.ReadToEnd();
                string[] obj         = line.Split("\n");
                //Recorre todo el archivo de texto y asigna las propiedades al programa
                for (int i = 0; i < obj.Length; i++)
                {
                    int spacer = obj[i].IndexOf(":");
                    //Asigna la propiedad heapCapacity
                    if (obj[i].Substring(0, spacer) == "heapCapacity")
                    {
                        Singleton.Instance.heapCapacity = Convert.ToInt32(obj[i].Substring(spacer + 1));
                        Singleton.Instance.HeapPacient  = new Heap <PacientModel>(Singleton.Instance.heapCapacity);
                    }
                    //Asigna la propiedad hashCapacity
                    if (obj[i].Substring(0, spacer) == "hashCapacity")
                    {
                        Singleton.Instance.hashCapacity = Convert.ToInt32(obj[i].Substring(spacer + 1));
                        Singleton.Instance.Data         = new HashTable <PacientModel, long>(Singleton.Instance.hashCapacity);
                    }
                    //Carga todos los datos guardados previamente
                    if (obj[i].Substring(0, spacer) == "pacients")
                    {
                        string[] tasks = obj[i].Substring(spacer + 1).Split(";");

                        for (int j = 0; j < tasks.Length; j++)
                        {
                            string[] obj2 = tasks[j].Split(",");
                            if (obj2.Length == 8)
                            {
                                //Crea los objetos de tipo PacientModel
                                var newPacient = new PacientModel
                                {
                                    Name         = obj2[0],
                                    LastName     = obj2[1],
                                    DPI          = Convert.ToInt64(obj2[2]),
                                    Department   = obj2[3],
                                    municipality = obj2[4],
                                    priority     = obj2[5],
                                    vaccinated   = bool.Parse(obj2[7])
                                };
                                string   d    = obj2[6];
                                string[] date = d.Split("/");
                                newPacient.schedule = newPacient.schedule.AddYears(int.Parse(date[2].Substring(0, 4)) - 1);
                                newPacient.schedule = newPacient.schedule.AddMonths(int.Parse(date[1]) - 1);
                                newPacient.schedule = newPacient.schedule.AddDays(int.Parse(date[0]) - 1);
                                newPacient.schedule = newPacient.schedule.AddHours(int.Parse(date[2].Substring(5, 2)));
                                int separator = date[2].IndexOf(":");
                                newPacient.schedule = newPacient.schedule.AddMinutes(int.Parse(date[2].Substring(separator + 1, 2)));
                                if (newPacient.schedule.CompareTo(new DateTime()) != 0)
                                {
                                    if (Singleton.Instance.startingDate.CompareTo(newPacient.schedule) < 0)
                                    {
                                        Singleton.Instance.startingDate = newPacient.schedule;
                                    }
                                }
                                //Carga el dato a el programa
                                Singleton.Instance.AddDataBase(newPacient);
                            }
                        }
                    }
                }
                lectorlinea.Close();

                return(RedirectToAction(nameof(Login)));
            }
            else
            {
                return(View());
            }
        }
Example #7
0
 //Get de la view WorkArea
 public ActionResult WorkArea(PacientModel pacient)
 {
     //Manda los valores del nuevo registro
     return(View(pacient));
 }
Example #8
0
        public ActionResult Create(IFormCollection collection)
        {
            //Crea un nuevo Registro y le asigna una prioridad según los datos indicados, también
            //valida si el dpi indicado es válido, de lo contrario mostrará un mensaje de error
            string pr  = collection["priority"];
            int    age = int.Parse(collection["age"]);
            long   dpi = Convert.ToInt64(collection["DPI"]);

            if (Singleton.Instance.cuiValid(dpi))
            {
                var newPacient = new PacientModel
                {
                    Name         = collection["Name"],
                    LastName     = collection["LastName"],
                    DPI          = dpi,
                    Department   = HttpContext.Session.GetString(SessionDepartment),
                    municipality = HttpContext.Session.GetString(SessionMunicipality),
                    schedule     = new DateTime(),
                    vaccinated   = false
                };
                if (pr == "Area de salud")
                {
                    //Si es del area de salud pasará a otra vista que pregunta mas datos para determinar la prioridad
                    return(RedirectToAction(nameof(WorkArea), newPacient));
                }
                else if (pr == "Trabajador de funeraria o de institucion del adulto mayor" || pr == "Cuerpo de socorro")
                {
                    newPacient.priority = "1d";
                }
                else if (pr == "Persona internada en hogar o institucion del adulto mayor")
                {
                    newPacient.priority = "1e";
                }
                else
                {
                    if (collection["q3"] == "No" && age < 70)
                    {
                        switch (pr)
                        {
                        case "Otros":
                            if (age < 40)
                            {
                                newPacient.priority = "4b";
                            }
                            else if (age < 50)
                            {
                                newPacient.priority = "4a";
                            }
                            break;

                        case "Area educativa":
                            newPacient.priority = "3c";
                            break;

                        case "Area de justicia":
                            newPacient.priority = "3d";
                            break;

                        case "Entidad de servivios esenciales":
                            newPacient.priority = "3b";
                            break;

                        case "Area de seguridad nacional":
                            newPacient.priority = "3a";
                            break;
                        }
                    }
                    else
                    {
                        newPacient.priority = "2a";
                    }
                }
                Singleton.Instance.Agregar(newPacient);
                Data();
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                TempData["testmsg"] = "DPI no valido, intentelo de nuevo";
                return(View());
            }
        }
Example #9
0
        //Metodo que es llamado en el HomeController para obtener todos los datos en un archivo de texto que contiene todos los pacientes y su respectiva informacion
        public void AddDataBase(PacientModel newPacient)
        {
            long newkey = keyGen(newPacient.DPI);

            Database.Add(newPacient, newkey);
        }
        // DELETE api/Pacient/5
        //[ResponseType(typeof(PacientModel))]
        //public IHttpActionResult DeletePacientModel(Guid id)
        //{
        //    PacientModel pacientmodel = db.PacientModels.Find(id);
        //    if (pacientmodel == null)
        //    {
        //        return NotFound();
        //    }

        //    db.PacientModels.Remove(pacientmodel);
        //    db.SaveChanges();

        //    return Ok(pacientmodel);
        //}

        //protected override void Dispose(bool disposing)
        //{
        //    if (disposing)
        //    {
        //        db.Dispose();
        //    }
        //    base.Dispose(disposing);
        //}

        //private bool PacientModelExists(Guid id)
        //{
        //    return db.PacientModels.Count(e => e.Id == id) > 0;
        //}

        private void Save(PacientModel pacientmodel)
        {
            Entities.Pacient pacient = MapperHelper.Map <PacientModel, Entities.Pacient>(pacientmodel);
            _business.Save(pacient);
        }