public async Task <IActionResult> Post([FromBody] Evolucion model)
        {
            try
            {
                var currentUser = await userManager.FindByNameAsync(User.Identity.Name);

                var newModel = new Evolucion()
                {
                    Id            = model.Id,
                    pacienteId    = model.pacienteId,
                    Fecharegistro = DateTime.Now,
                    Resultadolab  = model.Resultadolab,
                    Analisis      = model.Analisis,
                    Observaciones = model.Observaciones,
                    user          = currentUser
                };
                clinicaRepositorio.AddEvolucion(newModel);
                if (clinicaRepositorio.SaveAll())
                {
                    /*   return Created($"/api/order/{Newmodel.Id}", Newmodel);*/
                    var results = new
                    {
                        ruta = $"{newModel.Id}"
                    };
                    return(Created("", results));
                }
            }
            catch (Exception ex)
            {
                logger.LogError($"Fallo al Guardar Paciente:{ex}");
            }

            return(BadRequest("Fallo al Guardar Paciente"));
        }
        public void saveByIdPaciente(Evolucion entity, int IdPaciente)
        {
            try{
                var tratamiento = context.Tratamientos.FirstOrDefault(x => x.Id == entity.TratamientoId);                                 //id unico

                var solicitudTratamiento = context.SolicitudTratamientos.FirstOrDefault(x => x.Id == tratamiento.SolicitudTratamientoId); //id unico
                //var evolucionAnteriores = context.Evoluciones.LastOrDefault(x => x.Tratamiento.TipoTratamiento == entity.TratamientoId);
                var evolucionAnteriores = context.Evoluciones
                                          .OrderByDescending(x => x.Id)
                                          .FirstOrDefault(x => x.Tratamiento.SolicitudTratamiento.PacienteId == IdPaciente &&
                                                          x.TipoTratamiento == entity.TipoTratamiento);

                if (evolucionAnteriores != null)
                {
                    entity.Sesion = evolucionAnteriores.Sesion + 1;
                }
                else
                {
                    entity.Sesion = 1;
                }

                tratamiento.Estado = "Completado";
                context.Evoluciones.Add(entity);
                context.SaveChanges();
            }catch {
                throw;
            }
        }
        public async Task <IActionResult> Create(int?id, [Bind("DescripcionAtencion")] Evolucion evolucion)
        {
            if (ModelState.IsValid)
            {
                evolucion.Medico        = User.Identity.Name;
                evolucion.FechaYHora    = DateTime.Now;
                evolucion.EstadoAbierto = true;
                evolucion.EpisodioId    = (int)id;

                Episodio e = _context.Episodios.Where(e => e.Id == id).FirstOrDefault();
                evolucion.Episodio = e;
                evolucion.Notas    = new List <Nota>();

                if (e.Evoluciones == null)
                {
                    e.Evoluciones = new List <Evolucion>();
                }
                e.Evoluciones.Add(evolucion);

                _context.Add(evolucion);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", new { id }));
            }
            return(View(evolucion));
        }
        public void Save(Evolucion entity)
        {
            try{
                var tratamiento = context.Tratamientos.FirstOrDefault(x => x.Id == entity.TratamientoId);


                context.Evoluciones.Add(entity);
                context.SaveChanges();
            }catch {
                throw;
            }
        }
 public IActionResult PostByIdPatient([FromBody] Evolucion evolucion, int IdPaciente)
 {
     evolucionService.saveByIdPaciente(evolucion, IdPaciente);
     if (evolucion.Id != 0)
     {
         return(Ok(evolucion));
     }
     else
     {
         return(BadRequest(new { message = "error en el registro, vuelva a intentar" }));
     }
 }
Beispiel #6
0
        public void alistarDt(Evolucion evolucionMedica)
        {
            evolucionMedica.dtDiagnostico.AcceptChanges();

            this.evolucionMedica.dtAlistar = evolucionMedica.dtDiagnostico.Copy();
            this.evolucionMedica.dtAlistar.Columns.Remove("Código");
            if (this.evolucionMedica.dtAlistar.Rows.Count > 0)
            {
                this.evolucionMedica.dtAlistar.Rows.RemoveAt(this.evolucionMedica.dtAlistar.Rows.Count - 1);
                evolucionMedica.dtDiagnostico.Rows.RemoveAt(evolucionMedica.dtDiagnostico.Rows.Count - 1);
            }
        }
Beispiel #7
0
 public static void cargarDatos(Evolucion evolucionMedica)
 {
     try
     {
         List <String> list = new List <String>();
         list.Add(Convert.ToString(evolucionMedica.idEvolucion));
         evolucionMedica.dsDatos = GeneralC.llenarDataset(Sentencias.CARGAR_EVOLUCION_MEDICA, list);
     }catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #8
0
        public void saveByIdPaciente(Evolucion entity, int IdPaciente)
        {
            evolucionRepository.saveByIdPaciente(entity, IdPaciente);

            if (entity.Id > 0)
            {
                var notificacion = new Notificacion();

                var emisor = pacienteRepository.FindById(IdPaciente);

                notificacion.EmisorId         = emisor.UsuarioId;
                notificacion.ReceptorId       = 1;
                notificacion.TipoNotificacion = "REGISTRARFORMULARIOEVOLUCION";

                notificacionRepository.saveNotificacion(notificacion, entity.TipoTratamiento);
            }
        }
Beispiel #9
0
 public static void borrarEvolucion(Evolucion evolucionMedica)
 {
     try
     {
         using (SqlCommand comando = new SqlCommand())
         {
             comando.Connection  = PrincipalUI.Cnxion;
             comando.CommandType = System.Data.CommandType.StoredProcedure;
             comando.CommandText = Sentencias.ANULAR_EVOLUCION_MEDICA;
             comando.Parameters.Add(new SqlParameter("@idEvolucion", System.Data.SqlDbType.Int)).Value = evolucionMedica.idEvolucion;
             comando.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #10
0
        public void GrabarEvolucion(Evolucion X)
        {
            conexion = null;
            try
            {
                conexion = new AccesoDatos();
                string consulta = "insert into Evoluciones (IdPaciente, IdAdmin, IdProfesional, IdEspecialidad, IdHistoriaClinica, IdTurno, Evolucion, FechaAlta, Estado) values (" + X.IdPaciente + ", ";

                if (X.IdAdministrativo == 0)
                {
                    consulta = consulta + "null, ";
                }
                else
                {
                    consulta = consulta + X.IdAdministrativo + ", ";
                }

                if (X.IdProfesional == 0)
                {
                    consulta = consulta + "null, null, ";
                }
                else
                {
                    consulta = consulta + X.IdProfesional + ", " + X.IdEspecialidad + ", ";
                }

                consulta = consulta + X.IdHC + ", " + X.IdTurno + ", '" + X.evolucion + "', getdate(), 1)";
                conexion.setearConsulta(consulta);
                conexion.abrirConexion();
                conexion.ejecutarAccion();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conexion != null)
                {
                    conexion.cerrarConexion();
                }
            }
        }
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            try
            {
                Evolucion ev = new Evolucion();
                ev.IdPaciente       = turn.IdPaciente;
                ev.IdAdministrativo = 0;
                ev.IdProfesional    = turn.IdProfesional;
                ev.IdEspecialidad   = turn.IdEspecialidad;
                ev.IdHC             = turn.IdHC;
                ev.IdTurno          = turn.IdTurno;
                ev.evolucion        = txtEvolucion.Text;

                evNeg.GrabarEvolucion(ev);
                turnNeg.realizado(turn.IdTurno);
                MessageBox.Show("Se grabo correctamente");
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #12
0
        public static void guardarEvolucion(Evolucion evolucionMedica)
        {
            try
            {
                using (System.Data.SqlClient.SqlCommand comando = new SqlCommand())
                {
                    comando.Connection  = PrincipalUI.Cnxion;
                    comando.CommandType = System.Data.CommandType.StoredProcedure;
                    comando.CommandText = Sentencias.CREAR_EVOLUCION_MEDICA;
                    comando.Parameters.Add(new SqlParameter("@IdAtencion", System.Data.SqlDbType.Int)).Value            = evolucionMedica.IdAtencion;
                    comando.Parameters.Add(new SqlParameter("@IdEvolucion", System.Data.SqlDbType.Int)).Value           = evolucionMedica.idEvolucion;
                    comando.Parameters.Add(new SqlParameter("@Fecha", System.Data.SqlDbType.DateTime)).Value            = evolucionMedica.fechaEvolucion;
                    comando.Parameters.Add(new SqlParameter("@Subjetivos", System.Data.SqlDbType.NVarChar)).Value       = evolucionMedica.Subjetivos;
                    comando.Parameters.Add(new SqlParameter("@Generales", System.Data.SqlDbType.NVarChar)).Value        = evolucionMedica.Generales;
                    comando.Parameters.Add(new SqlParameter("@SignosVitales", System.Data.SqlDbType.NVarChar)).Value    = evolucionMedica.SignosVitales;
                    comando.Parameters.Add(new SqlParameter("@GenitoUrinario", System.Data.SqlDbType.NVarChar)).Value   = evolucionMedica.GenitalUrinario;
                    comando.Parameters.Add(new SqlParameter("@Torax", System.Data.SqlDbType.NVarChar)).Value            = evolucionMedica.Torax;
                    comando.Parameters.Add(new SqlParameter("@SistemaNervioso", System.Data.SqlDbType.NVarChar)).Value  = evolucionMedica.SistemaNervioso;
                    comando.Parameters.Add(new SqlParameter("@Abdomen", System.Data.SqlDbType.NVarChar)).Value          = evolucionMedica.Abdomen;
                    comando.Parameters.Add(new SqlParameter("@PielFanera", System.Data.SqlDbType.NVarChar)).Value       = evolucionMedica.PielFanera;
                    comando.Parameters.Add(new SqlParameter("@Extremidades", System.Data.SqlDbType.NVarChar)).Value     = evolucionMedica.Extremidades;
                    comando.Parameters.Add(new SqlParameter("@CabezaCuello", System.Data.SqlDbType.NVarChar)).Value     = evolucionMedica.CabezaCuello;
                    comando.Parameters.Add(new SqlParameter("@CardioPulmonar", System.Data.SqlDbType.NVarChar)).Value   = evolucionMedica.CardioPulmonar;
                    comando.Parameters.Add(new SqlParameter("@Analisis", System.Data.SqlDbType.NVarChar)).Value         = evolucionMedica.Analisis;
                    comando.Parameters.Add(new SqlParameter("@Plan", System.Data.SqlDbType.NVarChar)).Value             = evolucionMedica.Plan;
                    comando.Parameters.Add(new SqlParameter("@idUsuario", System.Data.SqlDbType.Int)).Value             = Sesion.IdUsuario;
                    comando.Parameters.Add(new SqlParameter("@tblDiagnostico", System.Data.SqlDbType.Structured)).Value = evolucionMedica.dtAlistar;

                    evolucionMedica.idEvolucion = (int)comando.ExecuteScalar();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #13
0
        public IList <Evolucion> Buscar(int ModoEstado, int ModoBuscar, int idPte, int idHC, int idAdm, int idProf, int idEvol)
        {
            conexion = null;
            IList <Evolucion> lista = new List <Evolucion>();

            try
            {
                conexion = new AccesoDatos();
                string consulta = "select e.IdEvolucion, e.IdPaciente, (select pers.Apellido + ', ' + pers.Nombre from personas as pers where e.IdPaciente = pers.idpersona), e.IdAdmin, (select pers.Apellido + ', ' + pers.Nombre from personas as pers where e.IdAdmin = pers.idpersona), e.IdProfesional, (select pers.Apellido + ', ' + pers.Nombre from personas as pers where e.IdProfesional = pers.idpersona), e.IdEspecialidad, esp.Especialidad, e.IdHistoriaClinica, e.IdTurno, e.Evolucion, e.FechaAlta, e.FechaModif, e.IdAdminModif, (select pers.Apellido + ', ' + pers.Nombre from personas as pers where e.IdAdminModif = pers.idpersona), e.FechaBaja, e.IdAdminBaja, (select pers.Apellido + ', ' + pers.Nombre from personas as pers where e.IdAdminBaja = pers.idpersona), e.Estado from Evoluciones as e inner join Especialidades as esp on e.IdEspecialidad=esp.IdEspecialidad where";

                if (ModoBuscar == 1)
                {
                    consulta = consulta + " e.IdPaciente=" + idPte;
                }
                else if (ModoBuscar == 2)
                {
                    consulta = consulta + " e.IdHistoriaClinica=" + idHC;
                }
                else if (ModoBuscar == 3)
                {
                    consulta = consulta + " e.IdAdmin=" + idAdm;
                }
                else if (ModoBuscar == 4)
                {
                    consulta = consulta + " e.IdProfesional=" + idProf;
                }
                else if (ModoBuscar == 5)
                {
                    consulta = consulta + " e.IdEvolucion=" + idEvol;
                }


                if (ModoBuscar > 0 & ModoEstado < 2)
                {
                    consulta += " and";
                }


                if (ModoEstado == 0)
                {
                    consulta = consulta + " e.Estado=0";
                }
                else if (ModoEstado == 1)
                {
                    consulta = consulta + " e.Estado=1";
                }

                conexion.setearConsulta(consulta);
                conexion.abrirConexion();
                conexion.ejecutarConsulta();

                while (conexion.Lector.Read())
                {
                    aux             = new Evolucion();
                    aux.IdEvolucion = (Int32)conexion.Lector[0];
                    aux.IdPaciente  = (Int32)conexion.Lector[1];
                    aux.Paciente    = conexion.Lector.GetString(2);
                    if (!conexion.Lector.IsDBNull(3))
                    {
                        aux.IdAdministrativo = (Int32)conexion.Lector[3];
                    }
                    if (!conexion.Lector.IsDBNull(4))
                    {
                        aux.Administrativo = conexion.Lector.GetString(4);
                    }
                    if (!conexion.Lector.IsDBNull(5))
                    {
                        aux.IdProfesional = (Int32)conexion.Lector[5];
                    }
                    if (!conexion.Lector.IsDBNull(6))
                    {
                        aux.Profesional = conexion.Lector.GetString(6);
                    }
                    if (!conexion.Lector.IsDBNull(7))
                    {
                        aux.IdEspecialidad = (Int32)conexion.Lector[7];
                    }
                    if (!conexion.Lector.IsDBNull(8))
                    {
                        aux.Especialidad = conexion.Lector.GetString(8);
                    }
                    aux.IdHC        = (Int32)conexion.Lector[9];
                    aux.IdTurno     = (Int32)conexion.Lector[10];
                    aux.evolucion   = conexion.Lector.GetString(11);
                    aux.FechaHrAlta = (DateTime)conexion.Lector[12];
                    if (!conexion.Lector.IsDBNull(13))
                    {
                        aux.FechaHrModif = (DateTime)conexion.Lector[13];
                    }
                    if (!conexion.Lector.IsDBNull(14))
                    {
                        aux.IdAdminModif = (Int32)conexion.Lector[14];
                    }
                    if (!conexion.Lector.IsDBNull(15))
                    {
                        aux.AdminModif = conexion.Lector.GetString(15);
                    }
                    if (!conexion.Lector.IsDBNull(16))
                    {
                        aux.FechaHrBaja = (DateTime)conexion.Lector[16];
                    }
                    if (!conexion.Lector.IsDBNull(17))
                    {
                        aux.IdAdminBaja = (Int32)conexion.Lector[17];
                    }
                    if (!conexion.Lector.IsDBNull(18))
                    {
                        aux.AdminBaja = conexion.Lector.GetString(18);
                    }
                    aux.Estado = (bool)conexion.Lector[19];

                    lista.Add(aux);
                }

                return(lista);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (conexion != null)
                {
                    conexion.cerrarConexion();
                }
            }
        }
Beispiel #14
0
 public void AddEvolucion(Evolucion newModel)
 {
     AddEntity(newModel);
 }
Beispiel #15
0
 public void Save(Evolucion entity)
 {
     throw new System.NotImplementedException();
 }