private SqlCommand CargarParametrosStore(Triaje pTriaje_BE) { SqlCommand ocomando = new SqlCommand(); try { ocomando.Parameters.Add("@IdTriaje", SqlDbType.Int).Value = pTriaje_BE.IdTriaje; ocomando.Parameters.Add("@Nombre", SqlDbType.VarChar, 250).Value = pTriaje_BE.Nombres; ocomando.Parameters.Add("@Nacionalidad", SqlDbType.VarChar, 250).Value = pTriaje_BE.Nacionalidad; ocomando.Parameters.Add("@Departamento", SqlDbType.VarChar, 250).Value = pTriaje_BE.Departamento; ocomando.Parameters.Add("@TipoDocumento", SqlDbType.VarChar, 250).Value = pTriaje_BE.TipoDocumento; ocomando.Parameters.Add("@NumeroDocumento", SqlDbType.VarChar, 250).Value = pTriaje_BE.NumeroDocumento; ocomando.Parameters.Add("@Respuesta1", SqlDbType.VarChar, 250).Value = pTriaje_BE.Respuesta1; ocomando.Parameters.Add("@Respuesta2", SqlDbType.VarChar, 250).Value = pTriaje_BE.Respuesta2; ocomando.Parameters.Add("@Respuesta3", SqlDbType.VarChar, 250).Value = pTriaje_BE.Respuesta3; ocomando.Parameters.Add("@Respuesta4", SqlDbType.VarChar, 250).Value = pTriaje_BE.Respuesta4; ocomando.Parameters.Add("@Respuesta5", SqlDbType.VarChar, 250).Value = pTriaje_BE.Respuesta5; ocomando.Parameters.Add("@Respuesta6", SqlDbType.VarChar, 250).Value = pTriaje_BE.Respuesta6; ocomando.Parameters.Add("@FechaTriaje", SqlDbType.VarChar, 250).Value = pTriaje_BE.FechaTriaje; ocomando.Parameters.Add("@Estado", SqlDbType.VarChar, 250).Value = pTriaje_BE.Estado; ocomando.Parameters.Add("@IdMapa ", SqlDbType.VarChar, 250).Value = pTriaje_BE.IdMapa; } catch (Exception e) { throw new Exception("CargarParametrosStore():" + e.Message); } finally { } return(ocomando); }
public JsonResult RegistraModifica(Triaje pBETriaje_BE, string pTipoTransaccion) { try { Triaje oTriaje_BE = new Triaje(); oTriaje_BE.MensajeError = ""; oTriaje_BE.CodigoError = 0; if (!pBETriaje_BE.NumeroDocumento.Equals("")) { pBETriaje_BE.NumeroDocumento = Convert.ToString(oTriaje_SD.RegistraModifica(pBETriaje_BE, pTipoTransaccion)); return(Json(pBETriaje_BE, JsonRequestBehavior.AllowGet)); } else { return(Json(null)); } } catch (Exception ex) { Triaje oTriaje_BE = new Triaje(); oTriaje_BE.CodigoError = ex.GetHashCode(); oTriaje_BE.MensajeError = ex.Message; return(Json(oTriaje_BE, JsonRequestBehavior.AllowGet)); } }
public Triaje ListarKey(System.Int32 pCodigoTriaje) { SqlConnection oconexion = new SqlConnection(this.CadenaConexion()); SqlCommand ocomando = new SqlCommand("[" + this.EsquemaBaseDatos() + "].[uspTriaje_ListarKey]", oconexion); ocomando.CommandType = CommandType.StoredProcedure; Triaje ObeTriaje = new Triaje(); ocomando.Parameters.Add("@IdTriaje", SqlDbType.Int).Value = pCodigoTriaje; try { oconexion.Open(); SqlDataReader oDataReader = ocomando.ExecuteReader(); while (oDataReader.Read()) { ObeTriaje = CargarDatosEntidad(oDataReader); break; } } catch (Exception e) { throw new Exception("ListarKey():" + e.Message); } finally { if (oconexion.State == ConnectionState.Open) { oconexion.Close(); } ocomando.Dispose(); oconexion.Dispose(); } return(ObeTriaje); }
public DataTable Lista(Triaje pTriaje_BE) { SqlConnection oconexion = new SqlConnection(this.CadenaConexion()); SqlCommand ocomando = CargarParametrosStore(pTriaje_BE); ocomando.CommandText = "[" + this.EsquemaBaseDatos() + "].[uspTriaje_Listar]"; ocomando.Connection = oconexion; ocomando.CommandType = CommandType.StoredProcedure; DataTable oDt = new DataTable("Triaje"); try { oconexion.Open(); oDt.Load(ocomando.ExecuteReader()); } catch (Exception e) { throw new Exception("Lista():" + e.Message); } finally { if (oconexion.State == ConnectionState.Open) { oconexion.Close(); } ocomando.Dispose(); oconexion.Dispose(); } return(oDt); }
public List <Triaje> ListarTriajeFallecido() { SqlConnection oconexion = new SqlConnection(this.CadenaConexion()); SqlCommand ocomando = new SqlCommand("[" + this.EsquemaBaseDatos() + "].[uspTriaje_ListarFallecido]", oconexion); ocomando.CommandType = CommandType.StoredProcedure; List <Triaje> oLista = new List <Triaje>(); try { oconexion.Open(); SqlDataReader oDataReader = ocomando.ExecuteReader(); while (oDataReader.Read()) { Triaje obeTriaje = new Triaje(); obeTriaje = CargarDatosEntidad(oDataReader); oLista.Add(obeTriaje); obeTriaje = null; } } catch (Exception e) { throw new Exception("ListarTriajeFallecido():" + e.Message); } finally { if (oconexion.State == ConnectionState.Open) { oconexion.Close(); } ocomando.Dispose(); oconexion.Dispose(); } return(oLista); }
public string RegistraModifica(Triaje pTriaje_BE, string pTipoTransaccion) { SqlConnection oconexion = new SqlConnection(this.CadenaConexion()); SqlCommand ocomando = new SqlCommand("[" + this.EsquemaBaseDatos() + "].[uspTriaje_RegistraModifica]", oconexion); ocomando.CommandType = CommandType.StoredProcedure; ocomando.Parameters.Add("@TipoTransaccion", SqlDbType.Char, 1).Value = pTipoTransaccion; ocomando.Parameters.Add("@Nombre", SqlDbType.VarChar, 250).Value = pTriaje_BE.Nombres; ocomando.Parameters.Add("@Nacionalidad", SqlDbType.VarChar, 250).Value = pTriaje_BE.Nacionalidad; ocomando.Parameters.Add("@Departamento", SqlDbType.VarChar, 250).Value = pTriaje_BE.Departamento; ocomando.Parameters.Add("@TipoDocumento", SqlDbType.VarChar, 250).Value = pTriaje_BE.TipoDocumento; ocomando.Parameters.Add("@NumeroDocumento", SqlDbType.VarChar, 250).Value = pTriaje_BE.NumeroDocumento; // ocomando.Parameters.Add("@PreguntaTriaje", SqlDbType.VarChar, 250).Value = pTriaje_BE.PreguntaTriaje; ocomando.Parameters.Add("@Respuesta1", SqlDbType.VarChar, 250).Value = pTriaje_BE.Respuesta1; ocomando.Parameters.Add("@Respuesta2", SqlDbType.VarChar, 250).Value = pTriaje_BE.Respuesta2; ocomando.Parameters.Add("@Respuesta3", SqlDbType.VarChar, 250).Value = pTriaje_BE.Respuesta3; ocomando.Parameters.Add("@Respuesta4", SqlDbType.VarChar, 250).Value = pTriaje_BE.Respuesta4; ocomando.Parameters.Add("@Respuesta5", SqlDbType.VarChar, 250).Value = pTriaje_BE.Respuesta5; ocomando.Parameters.Add("@Respuesta6", SqlDbType.VarChar, 250).Value = pTriaje_BE.Respuesta6; //ocomando.Parameters.Add("@Latitud", SqlDbType.VarChar, 250).Value = pTriaje_BE.Latitud; //ocomando.Parameters.Add("@Longitud", SqlDbType.VarChar, 250).Value = pTriaje_BE.Longitud; ////ocomando.Parameters.Add("@IdMapa", SqlDbType.VarChar, 250).Value = pTriaje_BE.IdMapa; //ocomando.Parameters["@IdTriaje"].Direction = ParameterDirection.InputOutput; string StrResultado = ""; try { oconexion.Open(); ocomando.ExecuteNonQuery(); StrResultado = ocomando.Parameters["@NumeroDocumento"].Value.ToString(); } catch (Exception e) { throw new Exception("RegistraModifica():" + e.Message); } finally { if (oconexion.State == ConnectionState.Open) { oconexion.Close(); } ocomando.Dispose(); oconexion.Dispose(); } return(StrResultado); }
public JsonResult ListarTriajeConfirmado() { Triaje pTriaje = new Triaje(); try { oREspuesta.ObjListaTriaje = oTriaje_SD.ListarTriajeConfirmado(); } catch (Exception ex) { pTriaje.CodigoError = 5; pTriaje.DescripcionError = ex.Message; oREspuesta.ObjTriaje = pTriaje; } return(Json(oREspuesta, JsonRequestBehavior.AllowGet)); }
public JsonResult ListaTriaje() { try { oREspuesta.ObjListaTriaje = oTriaje_SD.ListarTriaje(); return(Json(oREspuesta, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Triaje oTriaje_BE = new Triaje(); oTriaje_BE.CodigoError = ex.GetHashCode(); oTriaje_BE.MensajeError = ex.Message; oREspuesta.ObjTriaje = oTriaje_BE; return(Json(oREspuesta, JsonRequestBehavior.AllowGet)); } }
public JsonResult BuscarTriajePorNroDocumento(System.String pDocumento) { Triaje pTriaje = new Triaje(); try { pTriaje.NumeroDocumento = pDocumento; oREspuesta.ObjListaTriaje = oTriaje_SD.ListarDocumento(pDocumento); } catch (Exception ex) { pTriaje.CodigoError = 5; pTriaje.DescripcionError = ex.Message; oREspuesta.ObjTriaje = pTriaje; } return(Json(oREspuesta, JsonRequestBehavior.AllowGet)); }
public JsonResult Elimina(System.Int32 pCodigoTriaje) { try { Triaje oTriaje_BE = new Triaje(); oTriaje_BE.CodigoError = 0; oTriaje_BE.MensajeError = ""; oTriaje_BE.Eliminado = oTriaje_SD.Elimina(pCodigoTriaje); return(Json(oTriaje_BE, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Triaje oTriaje_BE = new Triaje(); oTriaje_BE.CodigoError = ex.GetHashCode(); oTriaje_BE.MensajeError = ex.Message; return(Json(oTriaje_BE, JsonRequestBehavior.AllowGet)); } }
public Triaje CargarDatosEntidad(SqlDataReader oDataReader) { Triaje ObeTriaje = new Triaje(); try { ObeTriaje = new Triaje( oDataReader.GetInt32((int)Triaje.CAMPOS.IdTriaje), oDataReader.GetString((int)Triaje.CAMPOS.Nombres), oDataReader.GetString((int)Triaje.CAMPOS.Nacionalidad), oDataReader.GetString((int)Triaje.CAMPOS.TipoDocumento), oDataReader.GetString((int)Triaje.CAMPOS.Departamento), oDataReader.GetString((int)Triaje.CAMPOS.NumeroDocumento), oDataReader.GetString((int)Triaje.CAMPOS.Respuesta1), oDataReader.GetString((int)Triaje.CAMPOS.Respuesta2), oDataReader.GetString((int)Triaje.CAMPOS.Respuesta3), oDataReader.GetString((int)Triaje.CAMPOS.Respuesta4), oDataReader.GetString((int)Triaje.CAMPOS.Respuesta5), oDataReader.GetString((int)Triaje.CAMPOS.Respuesta6), oDataReader.GetString((int)Triaje.CAMPOS.FechaTriaje), oDataReader.GetString((int)Triaje.CAMPOS.Estado), oDataReader.GetInt32((int)Triaje.CAMPOS.IdMapa) //oDataReader.GetString((int)Triaje.CAMPOS.Address) ); } catch (Exception e) { ObeTriaje = null; throw new Exception("CargarDatosEntidad():" + e.Message); } finally { } return(ObeTriaje); }
public List <Triaje> ListarDocumentoConRiego(System.String pNumeroDocumento) { SqlConnection oconexion = new SqlConnection(this.CadenaConexion()); SqlCommand ocomando = new SqlCommand("[" + this.EsquemaBaseDatos() + "].[uspTriaje_ListarEstadoConRiesgo]", oconexion); ocomando.CommandType = CommandType.StoredProcedure; List <Triaje> oLista = new List <Triaje>(); ocomando.Parameters.Add("@NumeroDocumento", SqlDbType.VarChar, 250).Value = pNumeroDocumento; try { oconexion.Open(); SqlDataReader oDataReader = ocomando.ExecuteReader(); while (oDataReader.Read()) { Triaje obeTriaje = new Triaje(); obeTriaje = CargarDatosEntidad(oDataReader); oLista.Add(obeTriaje); obeTriaje = null; } } catch (Exception e) { throw new Exception("ListarDocumentoConRiego():" + e.Message); } finally { if (oconexion.State == ConnectionState.Open) { oconexion.Close(); } ocomando.Dispose(); oconexion.Dispose(); } return(oLista); }
public List <BEReporteTriaje> GuardarTriaje(int dni, string sintoma, bool esViolencia) { Paciente bPaciente = new Paciente(); List <BEReporteTriaje> reporteFinal = new List <BEReporteTriaje>(); int idticketemergencia = 0; bool EsTrauma = false; string sala = string.Empty; int iddestino; int countTrauma, countObservacion, countPrioridad, countNoPrioridad; int[] arrSintoma; try { //sintoma = sintoma + ","; arrSintoma = sintoma.Split(',').Select(f => Int32.Parse(f.ToString())).ToArray(); using (ConnectionRicardoPalma bdRicardo = new ConnectionRicardoPalma()) { using (TransactionScope scope = new TransactionScope()) { TicketEmergencia ticket = new TicketEmergencia(); TicketTraumaShockTopico trauma = new TicketTraumaShockTopico(); TicketSalaObservacion observacion = new TicketSalaObservacion(); ticket.IdPaciente = bdRicardo.Paciente.Where(g => g.dni == dni).First().IdPaciente; ticket.EsViolencia = esViolencia; bdRicardo.TicketEmergencia.Add(ticket); bdRicardo.SaveChanges(); idticketemergencia = ticket.IdTicketEmergencia; foreach (string sintomaitem in sintoma.Split(',')) { int sint = Convert.ToInt32(sintomaitem); Triaje triaje = new Triaje(); triaje.IdSintoma = Convert.ToInt32(sintomaitem); triaje.IdTicketEmergencia = idticketemergencia; triaje.IdPrioridad = bdRicardo.Protocolo.Where(g => g.IdSintoma == sint).First().IdPrioridad; bdRicardo.Triaje.Add(triaje); } bdRicardo.SaveChanges(); //countTrauma = bdRicardo.Protocolo.Where(d => arrSintoma.Contains(d.IdSintoma) && d.Sala == "Trauma").Count(); //countObservacion = bdRicardo.Protocolo.Where(d => arrSintoma.Contains(d.IdSintoma) && d.Sala == "Topico").Count(); countPrioridad = bdRicardo.Protocolo.Where(d => arrSintoma.Contains(d.IdSintoma) && d.Sala == "Trauma" && d.IdPrioridad == 1).Count(); countNoPrioridad = bdRicardo.Protocolo.Where(d => arrSintoma.Contains(d.IdSintoma) && d.Sala == "Trauma" && (d.IdPrioridad == 2 || d.IdPrioridad == 3 || d.IdPrioridad == 4)).Count(); //------------------------------------------- if (countPrioridad > 0) { EsTrauma = true; } else if (countNoPrioridad > 0) { EsTrauma = false; } //else if (countObservacion > countTrauma) //{ // EsTrauma = true; //} //else if (countTrauma >= 2 && countPrioridad == 0) //{ // EsTrauma = true; //} //else if (countObservacion < countTrauma) //{ // EsTrauma = true; //} else { EsTrauma = false; } //------------------------------------------- if (EsTrauma) { int dias = Convert.ToInt32(Math.Ceiling(bdRicardo.Protocolo.Where(d => arrSintoma.Contains(d.IdSintoma)).Average(f => f.DiasAtencion))); string diagnostico = bdRicardo.Protocolo.Where(d => arrSintoma.Contains(d.IdSintoma)).OrderByDescending(h => h.IdPrioridad).First().Diagnostico; iddestino = bdRicardo.Protocolo.Where(d => arrSintoma.Contains(d.IdSintoma)).OrderByDescending(h => h.IdPrioridad).First().IdDestino; trauma.Ingreso = DateTime.Now; trauma.Egreso = DateTime.Now.AddDays(dias); trauma.Diagnostico = diagnostico; trauma.EsTraumaShock = EsTrauma; bdRicardo.TicketTraumaShockTopico.Add(trauma); } else { int dias = Convert.ToInt32(Math.Ceiling(bdRicardo.Protocolo.Where(d => arrSintoma.Contains(d.IdSintoma)).Average(f => f.DiasAtencion))); string diagnostico = bdRicardo.Protocolo.Where(d => arrSintoma.Contains(d.IdSintoma)).OrderByDescending(h => h.IdPrioridad).First().Diagnostico; string condicioningreso = bdRicardo.Protocolo.Where(d => arrSintoma.Contains(d.IdSintoma)).OrderByDescending(h => h.IdPrioridad).First().CondicionIngreso; string condicionegreso = bdRicardo.Protocolo.Where(d => arrSintoma.Contains(d.IdSintoma)).OrderByDescending(h => h.IdPrioridad).First().CondicionEgreso; iddestino = bdRicardo.Protocolo.Where(d => arrSintoma.Contains(d.IdSintoma)).OrderByDescending(h => h.IdPrioridad).First().IdDestino; observacion.Ingreso = DateTime.Now; observacion.Egreso = DateTime.Now.AddDays(dias); observacion.Diagnostico = diagnostico; observacion.CondicionIngreso = condicioningreso; observacion.CondicionEgreso = condicionegreso; bdRicardo.TicketSalaObservacion.Add(observacion); } bdRicardo.SaveChanges(); //------------------------------------------- ticket.IdDestino = iddestino; if (EsTrauma) { ticket.IdTicketTrauma = trauma.IdTicketTrauma; } else { ticket.IdTicketSala = observacion.IdTicketSala; } observacion.Ingreso = DateTime.Now; if (EsTrauma) { ticket.Ingreso = trauma.Ingreso; ticket.Egreso = trauma.Egreso; } else { ticket.Ingreso = observacion.Ingreso; ticket.Egreso = observacion.Egreso; } bdRicardo.SaveChanges(); scope.Complete(); } reporteFinal = bdRicardo.Triaje.Where(m => m.IdTicketEmergencia == idticketemergencia).Select(d => new BEReporteTriaje() { NombrePaciente = d.TicketEmergencia.Paciente.Nombre + " " + d.TicketEmergencia.Paciente.ApellidoPaterno + " " + d.TicketEmergencia.Paciente.ApellidoMaterno, DNI = d.TicketEmergencia.Paciente.dni, TipoPaciente = d.TicketEmergencia.Paciente.TipoPaciente.Descripcion, Sintoma = d.Sintoma.Descripcion, Prioridad = d.Prioridad.Descripcion, Destino = (d.TicketEmergencia.IdTicketSala == null && d.TicketEmergencia.IdTicketTrauma != null ? "Unidad Trauma" : "Sala Observación") }).ToList(); } } catch (EntityException exx) { if (exx.InnerException != null && (exx.InnerException.Message.Contains("A network-related") || exx.InnerException.Message.Contains("Error relacionado con la red"))) { throw new TimeoutException(ConfigurationManager.AppSettings["strErrorTimeout"]); } else { throw exx; } } catch (Exception ex) { throw ex; } return(reporteFinal); }