diff --git a/Business/Data/AutoAnalizador/RealItem.cs b/Business/Data/AutoAnalizador/RealItem.cs new file mode 100644 index 00000000..0615d231 --- /dev/null +++ b/Business/Data/AutoAnalizador/RealItem.cs @@ -0,0 +1,127 @@ +/* +insert license info here +*/ +using System; +using System.Collections; + +namespace Business.Data.AutoAnalizador +{ + /// + /// Generated by MyGeneration using the NHibernate Object Mapping template + /// + [Serializable] + public sealed class RealItem: Business.BaseDataAccess + { + + #region Private Members + private bool m_isChanged; + + private int m_idrealitem; + private string m_idreal; + private int m_iditem; + private bool m_habilitado; + #endregion + + #region Default ( Empty ) Class Constuctor + /// + /// default constructor + /// + public RealItem() + { + m_idrealitem = 0; + m_idreal = String.Empty; + m_iditem = 0; + m_habilitado = false; + } + #endregion // End of Default ( Empty ) Class Constuctor + + #region Required Fields Only Constructor + /// + /// required (not null) fields only constructor + /// + public RealItem( + string idreal, + int iditem, + bool habilitado) + : this() + { + m_idreal = idreal; + m_iditem = iditem; + m_habilitado = habilitado; + } + #endregion // End Required Fields Only Constructor + + #region Public Properties + + /// + /// + /// + public int IdRealItem + { + get { return m_idrealitem; } + set + { + m_isChanged |= (m_idrealitem != value ); + m_idrealitem = value; + } + + } + + /// + /// + /// + public string IdReal + { + get { return m_idreal; } + + set + { + if( value == null ) + throw new ArgumentOutOfRangeException("Null value not allowed for IdReal", value, "null"); + + if( value.Length > 50) + throw new ArgumentOutOfRangeException("Invalid value for IdReal", value, value.ToString()); + + m_isChanged |= (m_idreal != value); m_idreal = value; + } + } + + /// + /// + /// + public int IdItem + { + get { return m_iditem; } + set + { + m_isChanged |= ( m_iditem != value ); + m_iditem = value; + } + + } + + /// + /// + /// + public bool Habilitado + { + get { return m_habilitado; } + set + { + m_isChanged |= ( m_habilitado != value ); + m_habilitado = value; + } + + } + + /// + /// Returns whether or not the object has changed it's values. + /// + public bool IsChanged + { + get { return m_isChanged; } + } + + #endregion + } +} diff --git a/Business/Data/AutoAnalizador/RealItem.hbm.xml b/Business/Data/AutoAnalizador/RealItem.hbm.xml new file mode 100644 index 00000000..dc314397 --- /dev/null +++ b/Business/Data/AutoAnalizador/RealItem.hbm.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Business/Data/Laboratorio/Protocolo.cs b/Business/Data/Laboratorio/Protocolo.cs index 4ab840ca..2f88115e 100644 --- a/Business/Data/Laboratorio/Protocolo.cs +++ b/Business/Data/Laboratorio/Protocolo.cs @@ -11,6 +11,8 @@ insert license info here using System.IO; using System.Drawing; using QRCoder; +using System.Collections.Generic; +using System.Linq; namespace Business.Data.Laboratorio { @@ -1116,6 +1118,120 @@ public DateTime FechaTomaMuestra } } + public class ResultadoAnteriorDTO + { + public int IdSubItem { get; set; } + public string Resultado { get; set; } + } + + public Dictionary ObtenerResultadosAnteriores(string conexion) + { + int idPaciente = this.IdPaciente.IdPaciente; + int idProtocoloActual = this.IdProtocolo; + Dictionary diccionario = + new Dictionary(); + + string sql = @" + SELECT + dp.IdSubItem, + dp.ResultadoCar, + dp.ResultadoNum, + dp.FormatoValida, + dp.UnidadMedida + FROM LAB_DetalleProtocolo dp + INNER JOIN LAB_Protocolo p + ON p.IdProtocolo = dp.IdProtocolo + INNER JOIN + ( + SELECT + dp2.IdSubItem, + MAX(dp2.IdDetalleProtocolo) IdDetalle + FROM LAB_DetalleProtocolo dp2 + INNER JOIN LAB_Protocolo p2 + ON p2.IdProtocolo = dp2.IdProtocolo + WHERE p2.IdPaciente = @idPaciente + AND p2.Baja = 0 + AND p2.Estado > 0 + AND p2.IdProtocolo < @idProtocoloActual + AND dp2.IdUsuarioValida > 0 + GROUP BY dp2.IdSubItem + ) ult + ON ult.IdDetalle = dp.IdDetalleProtocolo + "; + + Utility oUtil = new Utility(); + + using (SqlConnection conn = + new SqlConnection(conexion + )) + { + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + cmd.Parameters.AddWithValue("@idPaciente", idPaciente); + cmd.Parameters.AddWithValue("@idProtocoloActual", idProtocoloActual); + + conn.Open(); + + using (SqlDataReader dr = cmd.ExecuteReader()) + { + while (dr.Read()) + { + int idSubItem = + Convert.ToInt32(dr["IdSubItem"]); + + string resultado = ""; + + string resultadoCar = + dr["ResultadoCar"] != DBNull.Value + ? dr["ResultadoCar"].ToString().Trim() + : ""; + + if (resultadoCar == "") + { + decimal resultadoNum = + dr["ResultadoNum"] != DBNull.Value + ? Convert.ToDecimal(dr["ResultadoNum"]) + : 0; + + string formatoValida = + dr["FormatoValida"] != DBNull.Value + ? dr["FormatoValida"].ToString() + : "0"; + + string unidadMedida = + dr["UnidadMedida"] != DBNull.Value + ? dr["UnidadMedida"].ToString() + : ""; + + string formato = + oUtil.Formato(formatoValida); + + resultado = + resultadoNum.ToString( + formato, + System.Globalization.CultureInfo.InvariantCulture); + + if (unidadMedida != "") + resultado += " " + unidadMedida; + } + else + { + resultado = + resultadoCar.Length > 10 + ? resultadoCar.Substring(0, 10) + : resultadoCar; + } + + if (!diccionario.ContainsKey(idSubItem)) + diccionario.Add(idSubItem, resultado); + } + } + } + } + + return diccionario; + } + /// /// Returns whether or not the object has changed it's values. /// @@ -1252,13 +1368,11 @@ public int GenerarNumeroMultiEfector(int idEfector) } public bool tieneAdjuntoProtocolo() { - ICriteria crit = m_session.CreateCriteria(typeof(ProtocoloAnexo)); - + ICriteria crit = m_session.CreateCriteria(typeof(ProtocoloAnexo)); crit.Add(Expression.Eq("IdProtocolo", this)); crit.Add(Expression.Eq("IdDetalleProtocolo", 0)); IList lista = crit.List(); if (lista.Count > 0) - return true; else @@ -2161,8 +2275,9 @@ public void CalcularFormulas(string s_operacion, int i_idusuario, bool solovacio { crit.Add(Expression.Eq("ConResultado",false)); } + - IList lista = crit.List(); + IList lista = crit.List(); //if (lista.Count > 0) //{ @@ -2176,7 +2291,8 @@ public void CalcularFormulas(string s_operacion, int i_idusuario, bool solovacio if (oItem.SinInsumo) continue; /*fin control insumo */ - ICriteria critFormula = m_session.CreateCriteria(typeof(Formula)); + + ICriteria critFormula = m_session.CreateCriteria(typeof(Formula)); critFormula.Add(Expression.Eq("IdItem", oDet.IdSubItem)); critFormula.Add(Expression.Eq("IdTipoFormula", 1)); critFormula.Add(Expression.Eq("Baja", false)); @@ -2751,33 +2867,57 @@ FROM LAB_AuditoriaProtocolo AS A INNER JOIN public string GetPracticasPedidas() { - string s_practicas = ""; - DetalleProtocolo oDetalle = new DetalleProtocolo(); - ISession m_session = NHibernateHttpModule.CurrentSession; - ICriteria crit = m_session.CreateCriteria(typeof(DetalleProtocolo)); - crit.Add(Expression.Eq("IdProtocolo", this)); - crit.Add(Expression.Eq("Informable", true)); - crit.AddOrder(Order.Asc("IdDetalleProtocolo")); - - IList items = crit.List(); - string pivot = ""; - string sDatos = ""; - foreach (DetalleProtocolo oDet in items) - { - if (pivot != oDet.IdItem.Nombre) - { - if (sDatos == "") - sDatos = oDet.IdItem.Nombre; - else - sDatos += " - " + oDet.IdItem.Nombre; - //sDatos += "#" + oDet.IdItem.Codigo + "#" + oDet.IdItem.Nombre + "#" + oDet.TrajoMuestra + "@"; - pivot = oDet.IdItem.Nombre; - } - + /* string s_practicas = ""; + DetalleProtocolo oDetalle = new DetalleProtocolo(); + ISession m_session = NHibernateHttpModule.CurrentSession; + ICriteria crit = m_session.CreateCriteria(typeof(DetalleProtocolo)); + crit.Add(Expression.Eq("IdProtocolo", this)); + crit.Add(Expression.Eq("Informable", true)); + crit.AddOrder(Order.Asc("IdDetalleProtocolo")); + + IList items = crit.List(); + string pivot = ""; + string sDatos = ""; + foreach (DetalleProtocolo oDet in items) + { + if (pivot != oDet.IdItem.Nombre) + { + if (sDatos == "") + sDatos = oDet.IdItem.Nombre; + else + sDatos += " - " + oDet.IdItem.Nombre; + //sDatos += "#" + oDet.IdItem.Codigo + "#" + oDet.IdItem.Nombre + "#" + oDet.TrajoMuestra + "@"; + pivot = oDet.IdItem.Nombre; + } + + } + + s_practicas = sDatos; + return s_practicas; + */ + ISession session = NHibernateHttpModule.CurrentSession; + + IList practicas = session.CreateQuery(@" + select distinct i.Nombre + from DetalleProtocolo dp + inner join dp.IdItem i + where dp.IdProtocolo = :protocolo + and dp.Informable = 1 + order by i.Nombre") + .SetEntity("protocolo", this) + .List(); + + string resultado = ""; + + foreach (object item in practicas) + { + if (resultado == "") + resultado = item.ToString(); + else + resultado += " - " + item.ToString(); } - s_practicas = sDatos; - return s_practicas; + return resultado; } public void ActualizarNumeroDesdeID() diff --git a/WebLab/Agendas/AgendaEdit.aspx.cs b/WebLab/Agendas/AgendaEdit.aspx.cs index a6d152d1..dfae347f 100644 --- a/WebLab/Agendas/AgendaEdit.aspx.cs +++ b/WebLab/Agendas/AgendaEdit.aspx.cs @@ -1,7 +1,14 @@ -using System; +using Business; +using Business.Data; +using Business.Data.Laboratorio; +using NHibernate; +using NHibernate.Expression; +using System; using System.Collections; +using System.Collections.Generic; using System.Configuration; using System.Data; +using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.Security; @@ -10,12 +17,6 @@ using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; -using Business; -using Business.Data.Laboratorio; -using Business.Data; -using NHibernate; -using NHibernate.Expression; -using System.Data.SqlClient; namespace WebLab.Agendas { @@ -72,8 +73,16 @@ private void MostrarDatos() { ddlEfector.SelectedValue = oRegistro.IdEfectorSolicitante.IdEfector.ToString(); cboTipoServicio.SelectedValue = oRegistro.IdTipoServicio.IdTipoServicio.ToString(); + txtFechaDesde.Value = oRegistro.FechaDesde.ToShortDateString(); txtFechaHasta.Value = oRegistro.FechaHasta.ToShortDateString(); + + //Por defecto los items se los carga con cboTipoServicio.SelectedValue = 1 + //Por eso cuando el item no es LABORATORIO no trae la Practica porque no es de tipo 1 + if (cboTipoServicio.SelectedValue != "1") + { + CargarItems(); //Lo recargo con el cboTipoServicio de la agenda + } ddlItem.SelectedValue = oRegistro.IdItem.ToString(); AgendaDia oItem = new AgendaDia(); @@ -306,6 +315,23 @@ protected void customValidadorGeneral_ServerValidate(object source, ServerValida if (Request["id"] != null) //Sacar el id de la agenda si es modificacion crit.Add(Expression.Not(Expression.Eq("IdAgenda", int.Parse(Request["id"])))); + // validar días seleccionados + List diasSeleccionados = new List(); + for (int i=0; i 0) diff --git a/WebLab/Agendas/AgendaList.aspx b/WebLab/Agendas/AgendaList.aspx index ad8fdad1..6e7092f4 100644 --- a/WebLab/Agendas/AgendaList.aspx +++ b/WebLab/Agendas/AgendaList.aspx @@ -24,12 +24,20 @@ + onselectedindexchanged="ddlTipoServicio_SelectedIndexChanged" tabindex="1"> + + + + Efector Solicitante: + + + Text="Agregar" Font-Size="10pt" CssClass="btn btn-primary" Width="100px" tabindex="3"/> @@ -60,6 +68,12 @@ + + + + + + diff --git a/WebLab/Agendas/AgendaList.aspx.cs b/WebLab/Agendas/AgendaList.aspx.cs index 6f71fc18..c828c19a 100644 --- a/WebLab/Agendas/AgendaList.aspx.cs +++ b/WebLab/Agendas/AgendaList.aspx.cs @@ -41,7 +41,10 @@ protected void Page_Load(object sender, EventArgs e) CargarListas(); CargarGrilla(); - + if (oUser.IdEfector.IdEfector == 227) + btnAgregar.Visible = false; + + } } private int Permiso /*el permiso */ @@ -79,18 +82,51 @@ private object LeerDatos() { //Usuario oUser = new Usuario(); //oUser = (Usuario)oUser.Get(typeof(Usuario), int.Parse(Session["idUsuario"].ToString())); - - string m_condicion = " and A.idEfector = " + oUser.IdEfector.IdEfector.ToString(); + + string m_condicion=""; + + if (oUser.IdEfector.IdEfector != 227) + m_condicion = " and A.idEfector = " + oUser.IdEfector.IdEfector.ToString(); if (ddlTipoServicio.SelectedValue != "0") m_condicion += " and A.idTipoServicio=" + ddlTipoServicio.SelectedValue; + if (ddlEfectorSolicitante.SelectedValue != "0") m_condicion += " and A.idEfectorSolicitante=" + ddlEfectorSolicitante.SelectedValue; - string m_strSQL = @" select top 20 A.idAgenda, T.nombre, I.nombre as item, convert(varchar(10),A.fechaDesde,103) as fechaDesde, - convert(varchar(10),A.fechaHasta,103) as fechaHasta ,E.nombre as efector, U.apellido as usuario, A.fechaRegistro + string m_strSQL = @" select top 20 A.idAgenda, T.nombre, (I.codigo +'-' +I.nombre) as item, convert(varchar(10),A.fechaDesde,103) as fechaDesde, + convert(varchar(10),A.fechaHasta,103) as fechaHasta ,E.nombre as efector, U.apellido as usuario, + A.fechaRegistro,D.dias, D.limiteTurnos from Lab_TipoServicio T (nolock) - INNER JOIN lAB_aGENDA A (nolock) on A.idTipoServicio= T.idTipoServicio - LEFT JOIN lab_item I (nolock) on A.iditem=i.iditem - inner join sys_Efector E (nolock) on E.idEfector=A.idEfectorSolicitante - inner join sys_usuario U (nolock) on U.idUsuario= A.idUsuarioRegistro - where A.baja=0 " + m_condicion +" order by A.idAgenda desc "; + INNER JOIN lAB_aGENDA A (nolock) on A.idTipoServicio= T.idTipoServicio + LEFT JOIN lab_item I (nolock) on A.iditem=i.iditem + inner join sys_Efector E (nolock) on E.idEfector=A.idEfectorSolicitante + inner join sys_usuario U (nolock) on U.idUsuario= A.idUsuarioRegistro + INNER JOIN ( + SELECT + D1.idAgenda, + + STUFF(( + SELECT ', ' + + case + when D2.dia = 1 then 'Lunes' + when D2.dia = 2 then 'Martes' + when D2.dia = 3 then 'Miercoles' + when D2.dia = 4 then 'Jueves' + when D2.dia = 5 then 'Viernes' + when D2.dia = 6 then 'Sabado' + when D2.dia = 7 then 'Domingo' + + end + FROM LAB_AgendaDia D2 (NOLOCK) + WHERE D2.idAgenda = D1.idAgenda + ORDER BY D2.dia + FOR XML PATH('') + ), 1, 1, '') AS dias, + + MAX(D1.limiteTurnos) AS limiteTurnos + + FROM LAB_AgendaDia D1 (NOLOCK) + GROUP BY D1.idAgenda + ) D + ON D.idAgenda = A.idAgenda + where A.baja=0 " + m_condicion +" order by A.idAgenda desc "; DataSet Ds = new DataSet(); SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SIL_ReadOnly"].ConnectionString); ///Performance: conexion de solo lectura @@ -109,10 +145,30 @@ inner join sys_usuario U (nolock) on U.idUsuario= A.idUsuarioRegistro private void CargarListas() { Utility oUtil = new Utility(); ///Carga de combos de Areas + string connReady = ConfigurationManager.ConnectionStrings["SIL_ReadOnly"].ConnectionString; ///Performance: conexion de solo lectura + string m_ssql = "select idTipoServicio, nombre from Lab_TipoServicio WHERE idtipoServicio<4 and (baja = 0)"; oUtil.CargarCombo(ddlTipoServicio, m_ssql, "idTipoServicio", "nombre"); ddlTipoServicio.Items.Insert(0, new ListItem("Todos", "0")); + ////////////Carga de combos de Efector + if (oUser.IdEfector.IdEfector == 227) + { + m_ssql = @"SELECT idEfector, nombre FROM sys_Efector E (nolock) + where idEfector in (select distinct D.idEfectorSolicitante from LAB_Agenda D (nolock) + where D.baja =0) + order by nombre "; + } + else + m_ssql = @"SELECT idEfector, nombre FROM sys_Efector E (nolock) + where idEfector in (select distinct R.idefectorRel from LAB_EfectorRelacionado R (nolock) + inner join LAB_Agenda D (nolock) ON D.idEfectorSolicitante=R.idefectorRel and D.idEfector=R.idEfector + where D.baja =0 and R.idefector = " + oUser.IdEfector.IdEfector.ToString() + + ") or (E.idEfector= " + oUser.IdEfector.IdEfector.ToString() + @") order by nombre "; + + oUtil.CargarCombo(ddlEfectorSolicitante, m_ssql, "idEfector", "nombre"); + if(ddlEfectorSolicitante.Items.Count > 1) + ddlEfectorSolicitante.Items.Insert(0, new ListItem("Todos", "0")); m_ssql = null; oUtil = null; @@ -133,12 +189,12 @@ protected void gvLista_RowDataBound(object sender, GridViewRowEventArgs e) if (e.Row.RowType == DataControlRowType.DataRow) { - ImageButton CmdModificar = (ImageButton)e.Row.Cells[7].Controls[1]; + ImageButton CmdModificar = (ImageButton)e.Row.Cells[9].Controls[1]; CmdModificar.CommandArgument = this.gvLista.DataKeys[e.Row.RowIndex].Value.ToString(); CmdModificar.CommandName = "Modificar"; CmdModificar.ToolTip="Modifica"; - ImageButton CmdEliminar = (ImageButton)e.Row.Cells[8].Controls[1]; + ImageButton CmdEliminar = (ImageButton)e.Row.Cells[10].Controls[1]; CmdEliminar.CommandArgument = this.gvLista.DataKeys[e.Row.RowIndex].Value.ToString(); if (Permiso == 1) { @@ -192,5 +248,9 @@ protected void ddlTipoServicio_SelectedIndexChanged(object sender, EventArgs e) CargarGrilla(); } + protected void ddlEfectorSolicitante_SelectedIndexChanged(object sender, EventArgs e) + { + CargarGrilla(); + } } } diff --git a/WebLab/Agendas/AgendaList.aspx.designer.cs b/WebLab/Agendas/AgendaList.aspx.designer.cs index 24ed57e8..eae8585f 100644 --- a/WebLab/Agendas/AgendaList.aspx.designer.cs +++ b/WebLab/Agendas/AgendaList.aspx.designer.cs @@ -1,41 +1,52 @@ //------------------------------------------------------------------------------ -// -// This code was generated by a tool. +// +// Este código fue generado por una herramienta. // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// +// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si +// se vuelve a generar el código. +// //------------------------------------------------------------------------------ -namespace WebLab.Agendas { - - - public partial class AgendaList { - +namespace WebLab.Agendas +{ + + + public partial class AgendaList + { + /// - /// ddlTipoServicio control. + /// Control ddlTipoServicio. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.DropDownList ddlTipoServicio; - + + /// + /// Control ddlEfectorSolicitante. + /// + /// + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. + /// + protected global::System.Web.UI.WebControls.DropDownList ddlEfectorSolicitante; + /// - /// btnAgregar control. + /// Control btnAgregar. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.Button btnAgregar; - + /// - /// gvLista control. + /// Control gvLista. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.GridView gvLista; } diff --git a/WebLab/AutoAnalizador/REAL/ConfiguracionEdit.aspx b/WebLab/AutoAnalizador/REAL/ConfiguracionEdit.aspx new file mode 100644 index 00000000..0221967d --- /dev/null +++ b/WebLab/AutoAnalizador/REAL/ConfiguracionEdit.aspx @@ -0,0 +1,144 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ConfiguracionEdit.aspx.cs" Inherits="WebLab.AutoAnalizador.REAL.ConfiguracionEdit" MasterPageFile="~/Site1.Master" %> +<%@ Register assembly="Anthem" namespace="Anthem" tagprefix="anthem" %> + + + + + + + + + +
+
+
+

Configuración SIL - REAL

+
+ +
+ + + + + + + + + + + + + + + + + + + <%-- + --%> + + + + + + + + + + + + + + + + + +
+ Area: + + +
+ Análisis del LIS: + + + + + + +
+ ID en Equipo: + + + +
+   + +
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+
+
+ + + +
diff --git a/WebLab/AutoAnalizador/REAL/ConfiguracionEdit.aspx.cs b/WebLab/AutoAnalizador/REAL/ConfiguracionEdit.aspx.cs new file mode 100644 index 00000000..f8bf8818 --- /dev/null +++ b/WebLab/AutoAnalizador/REAL/ConfiguracionEdit.aspx.cs @@ -0,0 +1,297 @@ +using System; +using System.Collections; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.HtmlControls; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using System.Xml.Linq; +using System.Data.SqlClient; +using Business; +using Business.Data.AutoAnalizador; +using NHibernate; +using NHibernate.Expression; +using System.Text; +using System.IO; +using Business.Data; + +namespace WebLab.AutoAnalizador.REAL +{ + public partial class ConfiguracionEdit : System.Web.UI.Page + { + Usuario oUser = new Usuario(); + + protected void Page_PreInit(object sender, EventArgs e) + { + if (Session["idUsuario"] != null) + oUser = (Usuario)oUser.Get(typeof(Usuario), int.Parse(Session["idUsuario"].ToString())); + // oC = (Configuracion)oC.Get(typeof(Configuracion), "IdConfiguracion", 1, "IdEfector", oEfector); + else + Response.Redirect("../FinSesion.aspx", false); + + } + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + VerificaPermisos("Config. REAL"); + CargarCombos(); + CargarGrilla(); + } + } + private void VerificaPermisos(string sObjeto) + { + if (Session["s_permiso"] != null) + { + Utility oUtil = new Utility(); + int i_permiso = oUtil.VerificaPermisos((ArrayList)Session["s_permiso"], sObjeto); + switch (i_permiso) + { + case 0: Response.Redirect("../AccesoDenegado.aspx", false); break; + //case 1: btn .Visible = false; break; + } + } + else Response.Redirect("../FinSesion.aspx", false); + } + private void CargarGrilla() + { + gvLista.DataSource = LeerDatos(); + gvLista.DataBind(); + } + + private DataTable LeerDatos() + { + string m_strSQL = @" SELECT M.idrealitem, I.codigo, I.nombre, M.idreal, M.habilitado as Habilitado + FROM lab_realitem AS M + INNER JOIN LAB_Item AS I ON M.idItem = I.idItem Order by I.nombre "; + + DataSet Ds = new DataSet(); + SqlConnection conn = (SqlConnection)NHibernateHttpModule.CurrentSession.Connection; + SqlDataAdapter adapter = new SqlDataAdapter(); + adapter.SelectCommand = new SqlCommand(m_strSQL, conn); + adapter.Fill(Ds); + + // CantidadRegistros.Text = Ds.Tables[0].Rows.Count.ToString() + " registros encontrados"; + + return Ds.Tables[0]; + } + private DataTable LeerDatosExcel() + { + string m_strSQL = @" SELECT I.codigo as [Codigo SIL], I.nombre as [Descripcion], M.idreal as [Codigo Real], M.habilitado as Habilitado + FROM lab_realitem AS M + INNER JOIN LAB_Item AS I ON M.idItem = I.idItem Order by I.nombre "; + + DataSet Ds = new DataSet(); + SqlConnection conn = (SqlConnection)NHibernateHttpModule.CurrentSession.Connection; + SqlDataAdapter adapter = new SqlDataAdapter(); + adapter.SelectCommand = new SqlCommand(m_strSQL, conn); + adapter.Fill(Ds); + + // CantidadRegistros.Text = Ds.Tables[0].Rows.Count.ToString() + " registros encontrados"; + + return Ds.Tables[0]; + } + + private void CargarCombos() + { + + Utility oUtil = new Utility(); + string connReady = ConfigurationManager.ConnectionStrings["SIL_ReadOnly"].ConnectionString; ///Performance: conexion de solo lectura + + string m_ssql = "select idArea, nombre from Lab_Area where baja=0 and idtiposervicio=3 order by nombre"; + oUtil.CargarCombo(ddlArea, m_ssql, "idArea", "nombre", connReady); + + + + CargarItem(); + //ddlArea.Items.Insert(0, new ListItem("Seleccione Area", "0")); + + + m_ssql = null; + oUtil = null; + } + + + + + + + private void GuardarDetalleConfiguracion() + { + RealItem oDetalle = new RealItem(); + oDetalle.IdReal = txtIDEquipo.Text; + oDetalle.IdItem = int.Parse(ddlItem.SelectedValue); + oDetalle.Habilitado = true; + oDetalle.Save(); + + + + } + + + protected void btnGuardar_Click2(object sender, EventArgs e) + { + if (Page.IsValid) + { + string validacion = existe(); + if (validacion == "") + { + lblMensajeValidacion.Text = ""; + GuardarDetalleConfiguracion(); + CargarGrilla(); + } + else + lblMensajeValidacion.Text = validacion; + } + } + + private string existe() + { + ////////////////////////////////////////////////////////////////////////////////////////// + ///Verifica de que no exista un item para la combincacion orden y tipo de muestra + ////////////////////////////////////////////////////////////////////////////////////////// + string hay = ""; + + RealItem oItem = new RealItem(); + oItem = (RealItem)oItem.Get(typeof(RealItem), "IdItem", int.Parse(ddlItem.SelectedValue)); + if (oItem == null) + { + + ISession m_session = NHibernateHttpModule.CurrentSession; + ICriteria crit = m_session.CreateCriteria(typeof(RealItem)); + crit.Add(Expression.Eq("IdReal", txtIDEquipo.Text)); + IList detalle = crit.List(); + if (detalle.Count > 0) + hay = "Ya existe una vinculación para el ID de muestra seleccionado. Verifique."; + } + else + hay = "Ya existe una configuración para el análisis seleccionado"; + + return hay; + } + + protected void gvLista_RowDataBound(object sender, GridViewRowEventArgs e) + { + if (e.Row.RowType == DataControlRowType.DataRow) + { + + ImageButton CmdEliminar = (ImageButton)e.Row.Cells[4].Controls[1]; + CmdEliminar.CommandArgument = this.gvLista.DataKeys[e.Row.RowIndex].Value.ToString(); + CmdEliminar.CommandName = "Eliminar"; + CmdEliminar.ToolTip = "Eliminar"; + + + CheckBox chkStatus = (CheckBox)e.Row.Cells[3].Controls[1]; + if (oUser.IdEfector.IdEfector == 227) + { + CmdEliminar.Visible = true; + chkStatus.Visible = true; + + } + else + { + CmdEliminar.Visible = false; + chkStatus.Enabled = false; + } + + + } + } + + protected void gvLista_RowCommand(object sender, GridViewCommandEventArgs e) + { + if (e.CommandName == "Eliminar") + { + RealItem oRegistro = new RealItem(); + oRegistro = (RealItem)oRegistro.Get(typeof(RealItem), int.Parse(e.CommandArgument.ToString())); + oRegistro.Delete(); + + CargarGrilla(); + + } + + } + protected void chkStatus_OnCheckedChanged(object sender, EventArgs e) + { + CheckBox chkStatus = (CheckBox)sender; + GridViewRow row = (GridViewRow)chkStatus.NamingContainer; + + int i_id = int.Parse(gvLista.DataKeys[row.RowIndex].Value.ToString()); + + RealItem oRegistro = new RealItem(); + oRegistro = (RealItem)oRegistro.Get(typeof(RealItem), i_id); + oRegistro.Habilitado = chkStatus.Checked; + oRegistro.Save(); + + + } + protected void lnkRegresar_Click(object sender, EventArgs e) + { + // Response.Redirect("../PrincipalSysmex.aspx", false); + } + + protected void ddlArea_SelectedIndexChanged(object sender, EventArgs e) + { + CargarItem(); + } + + private void CargarItem() + { + + + + + Utility oUtil = new Utility(); + string connReady = ConfigurationManager.ConnectionStrings["SIL_ReadOnly"].ConnectionString; ///Performance: conexion de solo lectura + + ///Carga de combos de Item sin el item que se está configurando y solo las determinaciones simples + string m_ssql = @"select idItem, nombre + ' - ' + codigo as nombre from Lab_Item I + where baja=0 AND idArea=" + ddlArea.SelectedValue + + " order by nombre"; + + oUtil.CargarCombo(ddlItem, m_ssql, "idItem", "nombre", connReady); + ddlItem.Items.Insert(0, new ListItem("Seleccione Item", "0")); + ddlItem.UpdateAfterCallBack = true; + } + + protected void btnExcel_Click(object sender, EventArgs e) + { + if (Page.IsValid) + dataTableAExcel(LeerDatosExcel(), "REAL_SIL"); + } + + + private void dataTableAExcel(DataTable tabla, string nombreArchivo) + { + if (tabla.Rows.Count > 0) + { + StringBuilder sb = new StringBuilder(); + StringWriter sw = new StringWriter(sb); + HtmlTextWriter htw = new HtmlTextWriter(sw); + Page pagina = new Page(); + HtmlForm form = new HtmlForm(); + GridView dg = new GridView(); + dg.EnableViewState = false; + dg.DataSource = tabla; + dg.DataBind(); + pagina.EnableEventValidation = false; + pagina.DesignerInitialize(); + pagina.Controls.Add(form); + form.Controls.Add(dg); + pagina.RenderControl(htw); + Response.Clear(); + Response.Buffer = true; + Response.ContentType = "application/vnd.ms-excel"; + Response.AddHeader("Content-Disposition", "attachment;filename=" + nombreArchivo + ".xls"); + Response.Charset = "UTF-8"; + Response.ContentEncoding = Encoding.Default; + Response.Write(sb.ToString()); + Response.End(); + } + } + } +} diff --git a/WebLab/AutoAnalizador/REAL/ConfiguracionEdit.aspx.designer.cs b/WebLab/AutoAnalizador/REAL/ConfiguracionEdit.aspx.designer.cs new file mode 100644 index 00000000..ce56935f --- /dev/null +++ b/WebLab/AutoAnalizador/REAL/ConfiguracionEdit.aspx.designer.cs @@ -0,0 +1,96 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WebLab.AutoAnalizador.REAL { + + + public partial class ConfiguracionEdit { + + /// + /// ddlArea control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::Anthem.DropDownList ddlArea; + + /// + /// ddlItem control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::Anthem.DropDownList ddlItem; + + /// + /// RangeValidator1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RangeValidator RangeValidator1; + + /// + /// txtIDEquipo control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtIDEquipo; + + /// + /// RequiredFieldValidator1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1; + + /// + /// btnGuardar control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnGuardar; + + /// + /// lblMensajeValidacion control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblMensajeValidacion; + + /// + /// btnExcel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnExcel; + + /// + /// gvLista control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.GridView gvLista; + } +} diff --git a/WebLab/ControlResultados/ControlPlanilla.aspx.cs b/WebLab/ControlResultados/ControlPlanilla.aspx.cs index 983127e8..52f6059c 100644 --- a/WebLab/ControlResultados/ControlPlanilla.aspx.cs +++ b/WebLab/ControlResultados/ControlPlanilla.aspx.cs @@ -188,46 +188,20 @@ protected void btnBuscar_Click(object sender, EventArgs e) string m_parametro = " P.idTipoServicio=" + ddlServicio.SelectedValue; m_parametro += " AND P.Fecha>='" + fecha1.ToString("yyyyMMdd") + "' AND P.fecha<='" + fecha2.ToString("yyyyMMdd") + "'"; m_parametro += " and P.idEfector =" + oUser.IdEfector.IdEfector.ToString(); - //if (ddlArea.SelectedValue != "0") m_parametro += " AND i.idArea=" + ddlArea.SelectedValue; - - - //Configuracion oCon = new Configuracion(); oCon = (Configuracion)oCon.Get(typeof(Configuracion), 1); - //switch (oCon.TipoNumeracionProtocolo)// busqueda con autonumerico - //{ - // case 0: - // { + if (txtProtocoloDesde.Value != "") m_parametro += " And P.numero>=" + int.Parse(txtProtocoloDesde.Value); if (txtProtocoloHasta.Value != "") m_parametro += " AND P.numero<=" + int.Parse(txtProtocoloHasta.Value); - // } break; - // case 1: - // { - // if (txtProtocoloDesde.Value != "") m_parametro += " And P.numeroDiario>=" + int.Parse(txtProtocoloDesde.Value); - // if (txtProtocoloHasta.Value != "") m_parametro += " AND P.numeroDiario<=" + int.Parse(txtProtocoloHasta.Value); - // } break; - // case 2: - // { - // if (txtProtocoloDesde.Value != "") m_parametro += " And P.numeroSector>=" + int.Parse(txtProtocoloDesde.Value); - // if (txtProtocoloHasta.Value != "") m_parametro += " AND P.numeroSector<=" + int.Parse(txtProtocoloHasta.Value); - // } break; - - // case 3: - // { - // if (txtProtocoloDesde.Value != "") m_parametro += " And P.numeroTipoServicio>=" + int.Parse(txtProtocoloDesde.Value); - // if (txtProtocoloHasta.Value != "") m_parametro += " AND P.numeroTipoServicio<=" + int.Parse(txtProtocoloHasta.Value); - // } break; - //} + if (ddlEfector.SelectedValue != "0") m_parametro += " AND P.idEfectorSolicitante=" + ddlEfector.SelectedValue; if (ddlOrigen.SelectedValue != "0") m_parametro += " AND P.idOrigen=" + ddlOrigen.SelectedValue; if (ddlPrioridad.SelectedValue != "0") m_parametro += " AND P.idPrioridad=" + ddlPrioridad.SelectedValue; - // if (ddlSectorServicio.SelectedValue != "0") m_parametro += " AND P.idSector = " + ddlSectorServicio.SelectedValue; - + m_parametro += " AND P.idSector in (" + getListaSectores() + ")"; string m_orden = " order by P.numero "; - //string operacion = "Carga"; - // string modoCarga = "HT"; + if (chkRecordarFiltro.Checked) AlmacenarSesion(); diff --git a/WebLab/Informes/Auditoria.aspx.cs b/WebLab/Informes/Auditoria.aspx.cs index b1e2c999..e7f53358 100644 --- a/WebLab/Informes/Auditoria.aspx.cs +++ b/WebLab/Informes/Auditoria.aspx.cs @@ -124,11 +124,11 @@ private void CargarListas() string m_ssql = @" select idusuario, apellido + ' ' +nombre as nombre from sys_usuario u with (nolock) - where activo = 1 + where activo = 1 and username <>'adminapi' and exists (select 1 from sys_usuarioefector e (nolock) where e.idusuario = u.idusuario and e.idEfector = " + oUser.IdEfector.IdEfector.ToString() + @") order by apellido, nombre"; if (oUser.Administrador) { - m_ssql = @" select idusuario, apellido + ' ' +nombre as nombre from sys_usuario u with (nolock) where activo = 1 order by apellido, nombre"; + m_ssql = @" select idusuario, apellido + ' ' +nombre as nombre from sys_usuario u with (nolock) where activo = 1 and username <>'adminapi' order by apellido, nombre"; } oUtil.CargarCombo(ddlUsuario, m_ssql, "idusuario", "nombre", connReady); oUtil.CargarCombo(ddlUsuario2, m_ssql, "idusuario", "nombre", connReady); diff --git a/WebLab/Informes/AuditoriaUsuario.aspx.cs b/WebLab/Informes/AuditoriaUsuario.aspx.cs index afb4eff7..225967c0 100644 --- a/WebLab/Informes/AuditoriaUsuario.aspx.cs +++ b/WebLab/Informes/AuditoriaUsuario.aspx.cs @@ -68,7 +68,7 @@ private void CargarListas() { Utility oUtil = new Utility(); ///Carga de combos de tipos de servicios - string m_ssql = "select idusuario, apellido + ' ' +nombre as nombre from sys_usuario order by apellido, nombre"; + string m_ssql = "select idusuario, apellido + ' ' +nombre as nombre from sys_usuario where username<>'adminapi' order by apellido, nombre"; oUtil.CargarCombo(ddlUsuarioModificado, m_ssql, "idusuario", "nombre"); oUtil.CargarCombo(ddlUsuarioABM, m_ssql, "idusuario", "nombre"); diff --git a/WebLab/Informes/HistoriaClinica.aspx.cs b/WebLab/Informes/HistoriaClinica.aspx.cs index d1f36f04..ad26db10 100644 --- a/WebLab/Informes/HistoriaClinica.aspx.cs +++ b/WebLab/Informes/HistoriaClinica.aspx.cs @@ -24,17 +24,26 @@ namespace WebLab.Informes public partial class HistoriaClinica : System.Web.UI.Page { Paciente oPaciente = new Paciente(); - + Configuracion oCon = new Configuracion(); public CrystalReportSource oCr = new CrystalReportSource(); - + public Usuario oUser = new Usuario(); protected void Page_PreInit(object sender, EventArgs e) { oCr.Report.FileName = ""; oCr.CacheDuration = 0; oCr.EnableCaching = false; + if (Session["idUsuario"] != null) + { + + oUser = (Usuario)oUser.Get(typeof(Usuario), int.Parse(Session["idUsuario"].ToString())); + oCon = (Configuracion)oCon.Get(typeof(Configuracion), "IdEfector", oUser.IdEfector); - } + } + else + Response.Redirect("SinDatos.aspx", false); + + } protected void Page_Load(object sender, EventArgs e) { @@ -131,7 +140,8 @@ private void MostrarPaciente() private DataTable LlenarDatos() { DataSet Ds = new DataSet(); - SqlConnection conn = (SqlConnection)NHibernateHttpModule.CurrentSession.Connection; + string conexion = ConfigurationManager.ConnectionStrings["SIL_ReadOnly"].ConnectionString; + SqlConnection conn = new SqlConnection(conexion); ///Performance: conexion de solo lectura SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; @@ -186,16 +196,25 @@ private void ExportarPDF() dt =LlenarDatos(); if (dt.Rows.Count > 0) { - Configuracion oCon = new Configuracion(); oCon = (Configuracion)oCon.Get(typeof(Configuracion), 1); + /// Configuracion oCon = new Configuracion(); oCon = (Configuracion)oCon.Get(typeof(Configuracion), 1); + string enc1 = "SUBSECRETARIA DE SALUD"; + string enc2 = "SISTEMA INFORMATICO PROVINCIAL DE LABORATORIO"; + string enc3 = ""; + if (oUser.IdEfector.IdEfector != 227) + { + enc1= oCon.EncabezadoLinea1; + enc2 = oCon.EncabezadoLinea2; + enc3 = oCon.EncabezadoLinea3; + } ParameterDiscreteValue encabezado1 = new ParameterDiscreteValue(); - encabezado1.Value = oCon.EncabezadoLinea1; + encabezado1.Value = enc1;// oCon.EncabezadoLinea1; ParameterDiscreteValue encabezado2 = new ParameterDiscreteValue(); - encabezado2.Value = oCon.EncabezadoLinea2; + encabezado2.Value = enc2; // oCon.EncabezadoLinea2; ParameterDiscreteValue encabezado3 = new ParameterDiscreteValue(); - encabezado3.Value = oCon.EncabezadoLinea3; + encabezado3.Value = enc3;// oCon.EncabezadoLinea3; ParameterDiscreteValue encabezado4 = new ParameterDiscreteValue(); encabezado4.Value = lblAnalisis.Text; @@ -244,15 +263,7 @@ private void ExportarPDF() oCr.DataBind(); oCr.ReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "Historial_Resultados.pdf"); - //MemoryStream oStream; // using System.IO - //oStream = (MemoryStream)oCr.ReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); - //Response.Clear(); - //Response.Buffer = true; - //Response.ContentType = "application/pdf"; - //Response.AddHeader("Content-Disposition", "attachment;filename=Historial_Resultados.pdf"); - - //Response.BinaryWrite(oStream.ToArray()); - //Response.End(); + } else Response.Redirect("SinDatos.aspx", false); diff --git a/WebLab/Informes/HojasdeTrabajo/HTrabajoProtocolo2Horizontal.cs b/WebLab/Informes/HojasdeTrabajo/HTrabajoProtocolo2Horizontal.cs new file mode 100644 index 00000000..da616cbc --- /dev/null +++ b/WebLab/Informes/HojasdeTrabajo/HTrabajoProtocolo2Horizontal.cs @@ -0,0 +1,217 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WebLab.Informes.HojasdeTrabajo { + using System; + using System.ComponentModel; + using CrystalDecisions.Shared; + using CrystalDecisions.ReportSource; + using CrystalDecisions.CrystalReports.Engine; + + + public class HTrabajoProtocolo2Horizontal : ReportClass { + + public HTrabajoProtocolo2Horizontal() { + } + + public override string ResourceName { + get { + return "HTrabajoProtocolo2Horizontal.rpt"; + } + set { + // Do nothing + } + } + + public override bool NewGenerator { + get { + return true; + } + set { + // Do nothing + } + } + + public override string FullResourceName { + get { + return "WebLab.Informes.HojasdeTrabajo.HTrabajoProtocolo2Horizontal.rpt"; + } + set { + // Do nothing + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public CrystalDecisions.CrystalReports.Engine.Section Section1 { + get { + return this.ReportDefinition.Sections[0]; + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public CrystalDecisions.CrystalReports.Engine.Section Section2 { + get { + return this.ReportDefinition.Sections[1]; + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public CrystalDecisions.CrystalReports.Engine.Section GroupHeaderSection1 { + get { + return this.ReportDefinition.Sections[2]; + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public CrystalDecisions.CrystalReports.Engine.Section GroupHeaderSection2 { + get { + return this.ReportDefinition.Sections[3]; + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public CrystalDecisions.CrystalReports.Engine.Section Section3 { + get { + return this.ReportDefinition.Sections[4]; + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public CrystalDecisions.CrystalReports.Engine.Section GroupFooterSection2 { + get { + return this.ReportDefinition.Sections[5]; + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public CrystalDecisions.CrystalReports.Engine.Section GroupFooterSection1 { + get { + return this.ReportDefinition.Sections[6]; + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public CrystalDecisions.CrystalReports.Engine.Section Section4 { + get { + return this.ReportDefinition.Sections[7]; + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public CrystalDecisions.CrystalReports.Engine.Section Section5 { + get { + return this.ReportDefinition.Sections[8]; + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public CrystalDecisions.Shared.IParameterField Parameter_encabezado1 { + get { + return this.DataDefinition.ParameterFields[0]; + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public CrystalDecisions.Shared.IParameterField Parameter_encabezado2 { + get { + return this.DataDefinition.ParameterFields[1]; + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public CrystalDecisions.Shared.IParameterField Parameter_encabezado3 { + get { + return this.DataDefinition.ParameterFields[2]; + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public CrystalDecisions.Shared.IParameterField Parameter_imprimirFechaHora { + get { + return this.DataDefinition.ParameterFields[3]; + } + } + } + + [System.Drawing.ToolboxBitmapAttribute(typeof(CrystalDecisions.Shared.ExportOptions), "report.bmp")] + public class CachedHTrabajoProtocolo2Horizontal : Component, ICachedReport { + + public CachedHTrabajoProtocolo2Horizontal() { + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public virtual bool IsCacheable { + get { + return true; + } + set { + // + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public virtual bool ShareDBLogonInfo { + get { + return false; + } + set { + // + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + public virtual System.TimeSpan CacheTimeOut { + get { + return CachedReportConstants.DEFAULT_TIMEOUT; + } + set { + // + } + } + + public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { + HTrabajoProtocolo2Horizontal rpt = new HTrabajoProtocolo2Horizontal(); + rpt.Site = this.Site; + return rpt; + } + + public virtual string GetCustomizedCacheKey(RequestContext request) { + String key = null; + // // The following is the code used to generate the default + // // cache key for caching report jobs in the ASP.NET Cache. + // // Feel free to modify this code to suit your needs. + // // Returning key == null causes the default cache key to + // // be generated. + // + // key = RequestContext.BuildCompleteCacheKey( + // request, + // null, // sReportFilename + // this.GetType(), + // this.ShareDBLogonInfo ); + return key; + } + } +} diff --git a/WebLab/Informes/HojasdeTrabajo/HTrabajoProtocolo2Horizontal.rpt b/WebLab/Informes/HojasdeTrabajo/HTrabajoProtocolo2Horizontal.rpt index 61d55423..5beb3223 100644 Binary files a/WebLab/Informes/HojasdeTrabajo/HTrabajoProtocolo2Horizontal.rpt and b/WebLab/Informes/HojasdeTrabajo/HTrabajoProtocolo2Horizontal.rpt differ diff --git a/WebLab/Informes/Informe.aspx b/WebLab/Informes/Informe.aspx index 9cf9458a..a6c55f61 100644 --- a/WebLab/Informes/Informe.aspx +++ b/WebLab/Informes/Informe.aspx @@ -271,7 +271,7 @@
-

+

diff --git a/WebLab/Informes/Informe.aspx.cs b/WebLab/Informes/Informe.aspx.cs index 45443b99..de25e7f7 100644 --- a/WebLab/Informes/Informe.aspx.cs +++ b/WebLab/Informes/Informe.aspx.cs @@ -628,12 +628,7 @@ private void VistaPreeliminar(object p, string accion) } if (accion == "PDF") { - - oCr.ReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, nombrePDF); - - //oCr.ReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, nombrePDF+".pdf"); - - + oCr.ReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, nombrePDF); } else { diff --git a/WebLab/Protocolos/ProcesaRenaper.aspx.cs b/WebLab/Protocolos/ProcesaRenaper.aspx.cs index ca2083d8..b9031bc8 100644 --- a/WebLab/Protocolos/ProcesaRenaper.aspx.cs +++ b/WebLab/Protocolos/ProcesaRenaper.aspx.cs @@ -12,7 +12,7 @@ using System.Web.Script.Serialization; using Business.Data; using NHibernate; -using Business.Data.Laboratorio; +using Business.Data.Laboratorio; using NHibernate.Expression; using System.Collections; using System.Data; @@ -24,6 +24,7 @@ using System.Net.Http; using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography; +using Newtonsoft.Json; namespace WebLab.Protocolos { @@ -280,7 +281,8 @@ protected void Page_Load(object sender, EventArgs e) if (!conOK)// si no funcionó la conexion con renaper se fija se está activado MPI if (oCon.ConectaMPI) { - conOK = SolicitarServicioMPI(); + // conOK = SolicitarServicioMPI(); + conOK = ConectarMPIXRoad(); if (!conOK) HabilitaCargaManual(); } @@ -289,7 +291,8 @@ protected void Page_Load(object sender, EventArgs e) { if (oCon.ConectaMPI) { - conOK = SolicitarServicioMPI(); + conOK = ConectarMPIXRoad(); + ///conOK = SolicitarServicioMPI(); if (!conOK) HabilitaCargaManual(); } @@ -767,6 +770,158 @@ private bool SolicitarServicio() return ok; } + private bool ConectarMPIXRoad() + { + bool ok = false; + try + { + string tipo = "MPI"; + imgAndes.Visible = false; + imgRenaper.Visible = false; lblFechaDomicilio.Visible = false; + GrabarLogAcceso(tipo, Request["dni"].ToString()); + + long nrodocumento = long.Parse(Request["dni"].ToString()); + // string sexo = Request["sexo"].ToString(); + + string rutaCert = ConfigurationManager.AppSettings["RutaCert"].ToString(); + string BaseUrl = "https://xroadss.andes.gob.ar/r1/OPTIC/GOB/GOB00008/GP-SALUD/MPI";///ConfigurationManager.AppSettings["BaseUrlXroad"].ToString(); + string Serv = "?identifier=http://www.renaper.gob.ar;";// GP-RENAPER/WS_RENAPER_DOCUMENTO/"; + string clie = "OPTIC/GOB/GOB00008/GP-SALUD";//ConfigurationManager.AppSettings["ClienteXroad"].ToString();//"OPTIC/GOB/GOB00008/GP-SALUD/MPI";// + string param = nrodocumento.ToString(); ///+ "/" + sexo.ToUpper(); + string host = BaseUrl + Serv + param; + + ServicePointManager.Expect100Continue = true; + ServicePointManager.ServerCertificateValidationCallback = (snder, cert, chain, error) => true; + // ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(host); + + //certificado + X509Certificate certificate = new X509Certificate(rutaCert, "", X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet + | X509KeyStorageFlags.PersistKeySet); + + req.ClientCertificates = new X509CertificateCollection() { certificate }; + req.ContentType = "application/json"; + req.AllowAutoRedirect = true; + req.Timeout = 10 * 1000; + req.Method = "GET"; + req.Headers.Add("X-Road-Client", clie); + + + + + using (WebResponse response = req.GetResponse()) + { + JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); + + using (Stream strReader = response.GetResponseStream()) + { + + using (StreamReader objReader = new StreamReader(strReader)) + { + + string responseBody = objReader.ReadToEnd(); + + var lista = JsonConvert.DeserializeObject>(responseBody); + var resultado2 = lista?.FirstOrDefault(); + + if (resultado2 != null) + { + lblValidador.Visible = true; + lblValidador.Text = "Paciente VALIDADO POR " + tipo; + ok = true; + + txtDNI.Text = Request["dni"]?.ToString(); + + // Nombre y apellido + var nombreData = resultado2.Name?.FirstOrDefault(); + txtApellido.Text = nombreData?.Family?.FirstOrDefault()?.ToUpper() ?? ""; + txtNombre.Text = string.Join(" ", nombreData?.Given ?? new List()).ToUpper(); + + // Fecha nacimiento + txtFechaNacimiento.Value = resultado2.BirthDate.ToString("dd/MM/yyyy"); + + // Domicilio (toma el primero) + var direccion = resultado2.Address?.FirstOrDefault(); + + txtCalle.Value = direccion?.Line?.FirstOrDefault() ?? "SIN DATOS"; + txtCiudad.Value = string.IsNullOrEmpty(direccion?.City) ? "SIN DATOS" : direccion.City; + txtProvincia.Value = string.IsNullOrEmpty(direccion?.State) ? "SIN DATOS" : direccion.State; + txtPais.Value = string.IsNullOrEmpty(direccion?.Country) ? "SIN DATOS" : direccion.Country; + txtCodigoPostal.Value = string.IsNullOrEmpty(direccion?.PostalCode) ? "SIN DATOS" : direccion.PostalCode; + + // CUIL + txtCuil.Value = resultado2.Identifier? + .FirstOrDefault(x => x.System.Contains("cuil"))?.Value ?? ""; + + // Campos que ya no existen en este JSON + txtBarrio.Value = "SIN DATOS"; + fallecimiento.Text = ""; + fechaDomicilio.Text = ""; + + txtTelefono.Value = resultado2.Telecom? + .Where(x => x.System == "phone") + .OrderBy(x => x.Rank) + .FirstOrDefault() + ?.Value ?? "SIN DATOS"; + + var sexo = resultado2.Gender?.ToLower(); + + if (sexo == "female") + { + txtSexo.Value = "FEMENINO"; + ddlSexo.SelectedValue = "2"; + } + else if (sexo == "male") + { + txtSexo.Value = "MASCULINO"; + ddlSexo.SelectedValue = "3"; + } + else if (sexo == "other") + { + txtSexo.Value = "X"; + ddlSexo.SelectedValue = "0"; + } + else + { + txtSexo.Value = "SIN DATOS"; + ddlSexo.SelectedValue = "0"; + } + /// traer al paciente si no es nuevo, es modificacion + int id = Convert.ToInt32(Request.QueryString["id"]); + //datos del Paciente + Paciente pac = new Paciente(); + if (id != 0) pac = (Paciente)pac.Get(typeof(Paciente), id); + txtTelefono.Value = pac.InformacionContacto; + + + } + else + ok = false; + + + + } + response.Close(); + } + + } + + + } + catch (WebException ex) + { + ok = false; + string mensaje = ex.ToString(); + + } + + + return ok; + + } + public void GrabarLogAcceso(string servicio, string dni) { try @@ -792,6 +947,83 @@ INSERT INTO LAB_LogAccesoServicio { } } + public class ResultadoMPIModel + { + [JsonProperty("resourceType")] + public string ResourceType { get; set; } + + [JsonProperty("identifier")] + public List Identifier { get; set; } + + [JsonProperty("active")] + public bool Active { get; set; } + + [JsonProperty("name")] + public List Name { get; set; } + + [JsonProperty("telecom")] + public List Telecom { get; set; } + + [JsonProperty("gender")] + public string Gender { get; set; } + + [JsonProperty("birthDate")] + public DateTime BirthDate { get; set; } + + [JsonProperty("address")] + public List Address { get; set; } + } + public class IdentifierRenaper + { + [JsonProperty("system")] + public string System { get; set; } + + [JsonProperty("value")] + public string Value { get; set; } + } + public class NameRenaper + { + [JsonProperty("use")] + public string Use { get; set; } + + [JsonProperty("text")] + public string Text { get; set; } + + [JsonProperty("family")] + public List Family { get; set; } + + [JsonProperty("given")] + public List Given { get; set; } + } + public class TelecomRenaper + { + [JsonProperty("system")] + public string System { get; set; } // phone, email + + [JsonProperty("value")] + public string Value { get; set; } + + [JsonProperty("rank")] + public int Rank { get; set; } + } + public class AddressRenaper + { + [JsonProperty("line")] + public List Line { get; set; } + + [JsonProperty("city")] + public string City { get; set; } + + [JsonProperty("state")] + public string State { get; set; } + + [JsonProperty("postalCode")] + public string PostalCode { get; set; } + + [JsonProperty("country")] + public string Country { get; set; } + } + protected void btnConfirmar_Click(object sender, EventArgs e) { if (validadatos()) @@ -799,15 +1031,10 @@ protected void btnConfirmar_Click(object sender, EventArgs e) { if (validamail()) { - //Configuracion oC = new Configuracion(); - - //oC = (Configuracion)oC.Get(typeof(Configuracion), 1); // "IdEfector", oUser.IdEfector); - + Utility oUtil = new Utility(); - ////instancio el usuario - //Usuario us = new Usuario(); - //us = (Usuario)us.Get(typeof(Usuario), int.Parse(Session["idUsuario"].ToString())); + int id = Convert.ToInt32(Request.QueryString["id"]); //datos del Paciente diff --git a/WebLab/Protocolos/ProtocoloEdit2.aspx.cs b/WebLab/Protocolos/ProtocoloEdit2.aspx.cs index e3942200..26e0d81c 100644 --- a/WebLab/Protocolos/ProtocoloEdit2.aspx.cs +++ b/WebLab/Protocolos/ProtocoloEdit2.aspx.cs @@ -3649,71 +3649,7 @@ private void SelectedEfector() } - //private void CargarSolicitantesInternos() - //{ - // Utility oUtil = new Utility(); - // ///Carga de combos de Medicos Solicitantes - // string m_ssql = "SELECT idProfesional, apellido + ' ' + nombre AS nombre FROM Sys_Profesional ORDER BY apellido, nombre "; - // oUtil.CargarCombo(ddlEspecialista, m_ssql, "idProfesional", "nombre"); - // ddlEspecialista.Items.Insert(0, new ListItem("No identificado", "0")); - // ddlEspecialista.UpdateAfterCallBack = true; - // //imgCrearSolicitante.Visible = false; - // //imgCrearSolicitante.UpdateAfterCallBack = true; - //} - - //private void CargarSolicitantesExternos(string m_solicitante) - //{ - // Utility oUtil = new Utility(); - - // ///Carga de combos de solicitantes expertos - // string m_ssql = "select idSolicitanteExterno, apellido + ', ' + nombre as nombre from Lab_SolicitanteExterno where baja=0 order by apellido, nombre"; - // oUtil.CargarCombo(ddlEspecialista, m_ssql, "idSolicitanteExterno", "nombre"); - // ddlEspecialista.Items.Insert(0, new ListItem("No identificado", "0")); - // if (m_solicitante != "") ddlEspecialista.SelectedValue = m_solicitante; - // ddlEspecialista.UpdateAfterCallBack = true; - // //imgCrearSolicitante.Visible = true; - // //imgCrearSolicitante.UpdateAfterCallBack = true; - //} - - //protected void btnGuardarSolicitante_Click(object sender, EventArgs e) - //{ - // if (Page.IsValid) - // { - // GuardarSolicitanteExterno(); - - // LimpiarDatosSolicitante(); - // //Panel1.Visible = false; - // //Panel1.UpdateAfterCallBack = true; - // } - //} - - //private void GuardarSolicitanteExterno() - //{ - // Usuario oUser = new Usuario(); - // SolicitanteExterno oRegistro = new SolicitanteExterno(); - // Configuracion oC = new Configuracion(); oC = (Configuracion)oC.Get(typeof(Configuracion), "IdConfiguracion", 1); - // oRegistro.IdEfector = oC.IdEfector; - // oRegistro.Matricula = txtMatricula.Text; - // oRegistro.Apellido = txtApellidoSolicitante.Text; - // oRegistro.Nombre = txtNombreSolicitante.Text; - // oRegistro.IdUsuarioRegistro = (Usuario)oUser.Get(typeof(Usuario), int.Parse(Session["idUsuario"].ToString())); - // oRegistro.FechaRegistro = DateTime.Now; - // oRegistro.Save(); - // CargarSolicitantesExternos(oRegistro.IdSolicitanteExterno.ToString()); - //} - - //protected void btnCancelarSolicitante_Click(object sender, EventArgs e) - //{ - // LimpiarDatosSolicitante(); - - //} - - //private void LimpiarDatosSolicitante() - //{ - // txtMatricula.Text = ""; - // txtApellidoSolicitante.Text = ""; - // txtNombreSolicitante.Text = ""; - //} + protected void gvLista_SelectedIndexChanged(object sender, EventArgs e) { @@ -3859,18 +3795,7 @@ private void BuscarNombreDiagnostico() ISession m_session = NHibernateHttpModule.CurrentSession; if (oC.NomencladorDiagnostico == 0) { - //ICriteria crit = m_session.CreateCriteria(typeof(Cie10)); - //crit.Add(Expression.Sql(" Nombre like '%" + txtNombreDiagnostico.Text + "%' order by Nombre")); - - //IList items = crit.List(); - - //foreach (Cie10 oDiagnostico in items) - //{ - // ListItem oDia = new ListItem(); - // oDia.Text = oDiagnostico.Codigo + " - " + oDiagnostico.Nombre; - // oDia.Value = oDiagnostico.Id.ToString(); - // lstDiagnosticos.Items.Add(oDia); - //} + string m_strSQL = @"select id, codigo + ' -' + nombre from sys_cie10 (nolock) where tipo='DIAG' and Nombre like '%" + txtNombreDiagnostico.Text.Trim() + "%' order by Nombre"; @@ -4618,17 +4543,7 @@ private bool VerificaObligatoriedadFIS() } - //private bool VerificarFechaPacienteMuestra() - //{ - // Paciente oPaciente = new Paciente(); - // oPaciente = (Paciente)oPaciente.Get(typeof(Paciente), int.Parse(HFIdPaciente.Value)); - - // string tieneingreso = oPaciente.GetFechaProtocolosReciente(Request["idServicio"].ToString(),ddlMuestra.SelectedValue); - // if (tieneingreso==txtFecha.Value) return false; - // else return true; - //} - - + private bool VerificarAnalisisComplejosContenidos(string listaCodigo) @@ -4666,17 +4581,6 @@ private bool VerificarAnalisisComplejosContenidos(string listaCodigo) - //protected void lnkReimprimirComprobante_Click(object sender, EventArgs e) - //{ - // Business.Data.Laboratorio.Protocolo oRegistro = new Business.Data.Laboratorio.Protocolo(); - // oRegistro = (Business.Data.Laboratorio.Protocolo)oRegistro.Get(typeof(Business.Data.Laboratorio.Protocolo), int.Parse(Request["idProtocolo"].ToString())); - - // ////Imprimir Comprobante para el paciente - // Imprimir(oRegistro); - - - - //} protected void lnkReimprimirCodigoBarras_Click(object sender, EventArgs e) { @@ -4752,15 +4656,7 @@ private void Avanzar(int avance) } } - } - //if (avance == 1) - //{ - // ProtocoloNuevo = ProtocoloActual+1; - //} - //else //retrocede - // ProtocoloNuevo = ProtocoloActual - 1; - - + } ISession m_session = NHibernateHttpModule.CurrentSession; ICriteria crit = m_session.CreateCriteria(typeof(Protocolo)); diff --git a/WebLab/Resultados/ResultadoBusqueda.aspx b/WebLab/Resultados/ResultadoBusqueda.aspx index 06d8bd7a..4bb0fd69 100644 --- a/WebLab/Resultados/ResultadoBusqueda.aspx +++ b/WebLab/Resultados/ResultadoBusqueda.aspx @@ -349,7 +349,7 @@ -

+


diff --git a/WebLab/Resultados/ResultadoEdit2.aspx b/WebLab/Resultados/ResultadoEdit2.aspx index 63d0c042..dbeda29e 100644 --- a/WebLab/Resultados/ResultadoEdit2.aspx +++ b/WebLab/Resultados/ResultadoEdit2.aspx @@ -728,7 +728,7 @@ - + diff --git a/WebLab/Resultados/ResultadoView.aspx b/WebLab/Resultados/ResultadoView.aspx index d9fb1dce..80b242d0 100644 --- a/WebLab/Resultados/ResultadoView.aspx +++ b/WebLab/Resultados/ResultadoView.aspx @@ -336,8 +336,11 @@ - - + + +
 
+ + @@ -354,6 +357,8 @@ > + + @@ -368,10 +373,10 @@
- + <%-- - + --%> @@ -380,7 +385,7 @@ -

 

+

@@ -448,8 +453,8 @@ - + <%-- --%> diff --git a/WebLab/Resultados/ResultadoView.aspx.cs b/WebLab/Resultados/ResultadoView.aspx.cs index 1f0eb12c..f0884e4e 100644 --- a/WebLab/Resultados/ResultadoView.aspx.cs +++ b/WebLab/Resultados/ResultadoView.aspx.cs @@ -88,11 +88,7 @@ protected void Page_PreInit(object sender, EventArgs e) } } - //protected void Page_UnLoad(object sender, EventArgs e) - //{ - // oCr.Dispose(); - //} - + protected void Page_Load(object sender, EventArgs e) { @@ -115,7 +111,7 @@ private void Inicializar() pnlAntecedentes.Visible = false; - pnlHC.Visible = true; + // pnlHC.Visible = true; if (Session["validado"].ToString() == "1") lblTitulo.Text = "HISTORIAL DE RESULTADOS"; else @@ -206,14 +202,9 @@ private void CargarGrilla() if (Request["Operacion"].ToString() == "HC") m_strSQL += " order by idProtocolo desc "; // desde el mas reciente al mas antiguo. - else - { - // Configuracion oC = new Configuracion(); oC = (Configuracion)oC.Get(typeof(Configuracion), "IdConfiguracion", 1); - //if (oC.TipoNumeracionProtocolo == 0) - m_strSQL += " order by idProtocolo "; - //if (oC.TipoNumeracionProtocolo == 1) m_strSQL += " order by numerodiario "; - //if (oC.TipoNumeracionProtocolo == 2) m_strSQL += " order by prefijosector, numerosector "; - } + else + m_strSQL += " order by idProtocolo "; + DataSet Ds = new DataSet(); @@ -273,18 +264,16 @@ private void MuestraDatos(string p) if (oRegistro != null) { - //Configuracion oCon = new Configuracion(); - //oCon = (Configuracion)oCon.Get(typeof(Configuracion), "IdEfector", oRegistro.IdEfector); - //Image1.= oRegistro.getQRResultados(oCon); - + HFIdProtocolo.Value = p; //Actualiza los datos de los objetos : alta o modificacion . lblEfector.Text = oRegistro.IdEfector.Nombre; oRegistro.GrabarAuditoriaProtocolo("Consulta", int.Parse(Session["idUsuario"].ToString())); - if (oRegistro.tieneAdjuntoProtocoloVisible()) - { imgAdjunto.Visible = true; spanadjunto.Visible = true; } - else - { imgAdjunto.Visible = false; spanadjunto.Visible = false; } + + + bool tieneAdjunto = oRegistro.tieneAdjuntoProtocoloVisible(); + imgAdjunto.Visible = tieneAdjunto; + spanadjunto.Visible = tieneAdjunto; if ((oRegistro.IdTipoServicio.IdTipoServicio == 3) || (oRegistro.IdTipoServicio.IdTipoServicio == 5)) //Microbiologia @@ -313,7 +302,7 @@ private void MuestraDatos(string p) lblCovid.Visible = true; Caracter oCaracter = new Caracter(); oCaracter = (Caracter)oCaracter.Get(typeof(Caracter), oRegistro.IdCaracter); - lblCovid.Text = "Clasificación Covid-19: " + oCaracter.Nombre; + lblCovid.Text = "Clasificación SNVS: " + oCaracter.Nombre; if (oRegistro.FechaInicioSintomas.Year != 1900) lblCovid.Text = lblCovid.Text + " - F. Inicio Síntomas: " + oRegistro.FechaInicioSintomas.ToShortDateString(); @@ -368,28 +357,17 @@ private void MuestraDatos(string p) lblUsuario.Text = oRegistro.IdUsuarioRegistro.Apellido; lblFechaRegistro.Text = oRegistro.FechaRegistro.ToShortDateString() + " " + oRegistro.FechaRegistro.ToShortTimeString(); - //int len = oRegistro.FechaRegistro.ToString().Length - 11; - //lblHoraRegistro.Text = oRegistro.FechaRegistro.ToString().Substring(11, oRegistro.FechaRegistro.ToString().Length - 11); + lblFecha.Text = oRegistro.Fecha.ToShortDateString(); lblProtocolo.Text = oRegistro.Numero.ToString(); - //hplProtocolo.NavigateUrl = "../Protocolos/ProtocoloEdit2.aspx?idServicio=" + oRegistro.IdTipoServicio.IdTipoServicio.ToString()+ "&Operacion=Modifica&idProtocolo=" +oRegistro.IdProtocolo.ToString(); - - //if (oRegistro.IdEfector == oRegistro.IdEfectorSolicitante) - lblOrigen.Text = oRegistro.IdOrigen.Nombre; + lblOrigen.Text = oRegistro.IdOrigen.Nombre; //else lblSolicitante.Text = oRegistro.IdEfectorSolicitante.Nombre; if (oRegistro.MatriculaEspecialista != "-1") lblMedico.Text = oRegistro.Especialista + " MP:" + oRegistro.MatriculaEspecialista; - - //lblPrioridad.Text = oRegistro.IdPrioridad.Nombre; - // if (oRegistro.IdPrioridad.Nombre == "URGENTE") - // { - // lblPrioridad.ForeColor = Color.Red; - // lblPrioridad.Font.Bold = true; - // } - - //lblSector.Text = oRegistro.IdSector.Nombre; + + if (oRegistro.Sala != "") lblOrigen.Text += " Sala: " + oRegistro.Sala; if (oRegistro.Cama != "") lblOrigen.Text += " Cama: " + oRegistro.Cama; @@ -448,14 +426,12 @@ private void MuestraDatos(string p) } - - - + private void LlenarTabla(string p) { - // SqlConnection conn = (SqlConnection)NHibernateHttpModule.CurrentSession.Connection; - SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SIL_ReadOnly"].ConnectionString); ///Performance: conexion de solo lectura + string conexion = ConfigurationManager.ConnectionStrings["SIL_ReadOnly"].ConnectionString; + SqlConnection conn = new SqlConnection(conexion); ///Performance: conexion de solo lectura DataSet Ds = new DataSet(); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; @@ -467,13 +443,8 @@ private void LlenarTabla(string p) SqlDataAdapter da = new SqlDataAdapter(cmd); - da.Fill(Ds); - - - //int cantidadResultadosValidados = Ds.Tables[0].Rows.Count; - //if (cantidadResultadosValidados > 0) - - //{ + da.Fill(Ds); + string s = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator; @@ -544,26 +515,12 @@ private void LlenarTabla(string p) else lblCargadoPor.Text = "ESTADO"; - objCellPersona_TITULO.Controls.Add(lblCargadoPor); - - - /////observaciones - //if (Request["Operacion"].ToString() == "Valida") - //{ - - + objCellPersona_TITULO.Controls.Add(lblCargadoPor); objFila_TITULO.Cells.Add(objCellAnalisis_TITULO); - objFila_TITULO.Cells.Add(objCellResultado_TITULO); - - - - - objFila_TITULO.Cells.Add(objCellValoresReferencia_TITULO); - - + objFila_TITULO.Cells.Add(objCellResultado_TITULO); + objFila_TITULO.Cells.Add(objCellValoresReferencia_TITULO); objFila_TITULO.Cells.Add(objCellPersona_TITULO); objFila_TITULO.Cells.Add(objCellResultadoAnterior_TITULO); - objFila_TITULO.CssClass = "myLabelIzquierda"; objFila_TITULO.BackColor = Color.Gainsboro; @@ -576,7 +533,41 @@ private void LlenarTabla(string p) int tablas = Ds.Tables.Count; if (tablas > 0) - { + { + + ////Caro PF: Cache de resultado item + + ISession session = NHibernateHttpModule.CurrentSession; + ///CARO PF: traer detalleprotocolos y derivaciones antes del for para no ir a la base N veces + var idsDetallesList = Ds.Tables[0].AsEnumerable() + .Select(r => r.Field("idDetalleProtocolo")) + .ToList(); + + var detallesList = session.CreateCriteria(typeof(DetalleProtocolo)) + .Add(Expression.In("IdDetalleProtocolo", idsDetallesList.ToArray())) + .List() + .Cast() + .ToList(); + + var detallesDict = detallesList + .ToDictionary(d => d.IdDetalleProtocolo); + + // Traer todas las Derivaciones juntas + var derivacionesList = session.CreateCriteria(typeof(Derivacion)) + .CreateAlias("IdDetalleProtocolo", "dp") + .Add(Expression.In("dp.IdDetalleProtocolo", idsDetallesList.ToArray())) + .List() + .Cast() + .ToList(); + + var derivacionesDict = derivacionesList + .ToDictionary(d => d.IdDetalleProtocolo.IdDetalleProtocolo); + /// CARO PF : fin + + Protocolo oRegistro = new Protocolo(); + oRegistro = (Protocolo)oRegistro.Get(typeof(Business.Data.Laboratorio.Protocolo), int.Parse(p)); + var resultadosAnteriores = oRegistro.ObtenerResultadosAnteriores(conexion); + for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { //decimal m_minimoReferencia=-1; @@ -630,35 +621,24 @@ private void LlenarTabla(string p) TableCell objCellPersona = new TableCell(); TableCell objCellObservaciones = new TableCell(); - decimal x = 0; - - if (m_area != pivot_Area) ///poner titulo del area { TableRow objRow = new TableRow(); TableCell objCell = new TableCell(); - Label lbl0 = new Label(); - //lbl0.ForeColor = Color + Label lbl0 = new Label(); lbl0.Text = m_area.ToUpper(); lbl0.TabIndex = short.Parse("500"); lbl0.Font.Bold = true; - Master.FindControl("ContentPlaceHolder1").FindControl("Panel1").Controls.Add(lbl0); objCell.Controls.Add(lbl0); - //if (Request["Operacion"].ToString() == "HC") - // objCell.ColumnSpan = 8; - //else objCell.ColumnSpan = 8; - objRow.BackColor = Color.Beige; objRow.HorizontalAlign = HorizontalAlign.Center; - objRow.Cells.Add(objCell); - // objRow.CssClass = "myLabelIzquierda"; + objRow.Cells.Add(objCell); tContenido.Controls.Add(objRow); - pivot_Area = m_area; } @@ -691,20 +671,14 @@ private void LlenarTabla(string p) lblSinMuestra.TabIndex = short.Parse("500"); lblSinMuestra.Text = "Sin Muestra";// +oItem.IdEfectorDerivacion.Nombre; /// Ds.Tables[0].Rows[i].ItemArray[1].ToString(); lblSinMuestra.Font.Italic = true; - lblSinMuestra.ForeColor = Color.Blue; - // objCellResultado.ColumnSpan = 5; + lblSinMuestra.ForeColor = Color.Blue; objCellResultado.Controls.Add(lblSinMuestra); } } - - - Label lbl1 = new Label(); if (m_hijo == m_titulo) lbl1.Text = m_hijo; else lbl1.Text = "   " + m_hijo; - - - + lbl1.TabIndex = short.Parse("500"); lbl1.ForeColor = Color.Black; lbl1.Font.Size = FontUnit.Point(9); @@ -717,6 +691,21 @@ private void LlenarTabla(string p) objCellAnalisis.Controls.Add(lbl1); + + /* var row = Ds.Tables[0].Rows[i]; + int idDetalle = Convert.ToInt32(row["idDetalleProtocolo"]); + */ + DetalleProtocolo oDetalle; + detallesDict.TryGetValue(i_iddetalleProtocolo, out oDetalle); + + Derivacion oDeriva; + derivacionesDict.TryGetValue(i_iddetalleProtocolo, out oDeriva); + //fin + Item oItem = new Item(); + oItem = oDetalle.IdSubItem; // (Item)oItem.Get(typeof(Item), m_idItem); + + + /*antes / DetalleProtocolo oDetalle = new DetalleProtocolo(); oDetalle = (DetalleProtocolo)oDetalle.Get(typeof(DetalleProtocolo), i_iddetalleProtocolo); @@ -725,7 +714,7 @@ private void LlenarTabla(string p) //DetalleProtocolo oDetalle = new DetalleProtocolo(); //oDetalle = (DetalleProtocolo)oDetalle.Get(typeof(DetalleProtocolo), i_iddetalleProtocolo); - + fin antes*/ // bool es_Bacteriologia = false; string observacionesDetalle = ""; @@ -733,11 +722,12 @@ private void LlenarTabla(string p) /// observacionesDetalle = oDetalle.Observaciones; // m_usuariovalida += " " + oDetalle.FechaValida.ToShortDateString(); + + /*antes Derivacion oDeriva = new Derivacion(); oDeriva = (Derivacion)oDeriva.Get(typeof(Derivacion), "IdDetalleProtocolo", oDetalle); - if (oDeriva != null) /// esta pendiente - - //if (oItem.IdEfectorDerivacion != oItem.IdEfector) //es derivado + fin antes*/ + if (oDeriva != null) /// esta pendiente { Label lblDerivacion = new Label(); lblDerivacion.Font.Italic = true; @@ -745,41 +735,11 @@ private void LlenarTabla(string p) //Verifica el estado de la derivacion string estadoDerivacion = ""; - //if (i_iddetalleProtocolo != 0) - //{ - // DetalleProtocolo oDetalle = new DetalleProtocolo(); - // oDetalle = (DetalleProtocolo)oDetalle.Get(typeof(DetalleProtocolo), i_iddetalleProtocolo); - - - - // observacionesDetalle = oDetalle.Observaciones; - // m_usuariovalida += " " + oDetalle.FechaValida.ToShortDateString(); - // Derivacion oDeriva = new Derivacion(); - // oDeriva = (Derivacion)oDeriva.Get(typeof(Derivacion), "IdDetalleProtocolo", oDetalle); - // if (oDeriva == null) /// esta pendiente - // { - // estadoDerivacion = "Pendiente de Derivacion"; - // lblDerivacion.ForeColor = Color.Red; - // } - // else - // { - /* if (oDeriva.Estado == 0) /// pendiente - { - estadoDerivacion = "Pendiente de Derivacion"; - lblDerivacion.ForeColor = Color.Red; - } - if (oDeriva.Estado == 1) /// enviado - estadoDerivacion = oDetalle.ResultadoCar; // "Derivado: " + oItem.GetEfectorDerivacion(oCon.IdEfector); - if (oDeriva.Estado == 2) /// no enviado - estadoDerivacion = oDetalle.ResultadoCar; //" No Derivado. " + oDeriva.Observacion; - lblDerivacion.Font.Bold = true;*/ + estadoDerivacion = oDetalle.ResultadoCar; if (oDeriva.Resultado != "") estadoDerivacion += " - Resultado Informado: " + oDeriva.Resultado; - - //} - - //} + lblDerivacion.Text = estadoDerivacion; objCellResultado.ColumnSpan = 1; @@ -810,9 +770,7 @@ private void LlenarTabla(string p) //if (Request["Operacion"].ToString() != "HC") if (m_conResultado!= "False") { - // DetalleProtocolo oDetalle = new DetalleProtocolo(); - // oDetalle = (DetalleProtocolo)oDetalle.Get(typeof(DetalleProtocolo), i_iddetalleProtocolo); - + Anthem.GridView Gd1 = new Anthem.GridView(); Gd1.ID = m_idItem.ToString(); ProtocoloLuminex oFusion = new ProtocoloLuminex(); @@ -846,11 +804,8 @@ private void LlenarTabla(string p) if (i_iddetalleProtocolo != 0) { - if (i_iddetalleProtocolo != 9999999) - { - //DetalleProtocolo oDetalle = new DetalleProtocolo(); - //oDetalle = (DetalleProtocolo)oDetalle.Get(typeof(DetalleProtocolo), i_iddetalleProtocolo); - + //if (i_iddetalleProtocolo != 9999999) + //{ m_usuariovalida += " " + oDetalle.FechaValida.ToShortDateString(); if (Observaciones != "") { @@ -874,31 +829,32 @@ private void LlenarTabla(string p) if (oDetalle.IdProtocolo.IdTipoServicio.IdTipoServicio!=5) { - string resultadoAnterior = oDetalle.BuscarResultadoAnterior(oDetalle.IdSubItem, oDetalle.IdItem, false); - if (resultadoAnterior != "") - { + //string resultadoAnterior = oDetalle.BuscarResultadoAnterior(oDetalle.IdSubItem, oDetalle.IdItem, false); + + string resultadoAnterior = ""; + + if (resultadosAnteriores.ContainsKey(oDetalle.IdSubItem.IdItem)) + { + resultadoAnterior = resultadosAnteriores[oDetalle.IdSubItem.IdItem]; + } + + if (resultadoAnterior != "") + { hayAntecedente = true; Label olblResultadoAnterior = new Label(); olblResultadoAnterior.TabIndex = short.Parse("500"); olblResultadoAnterior.Font.Size = FontUnit.Point(8); olblResultadoAnterior.CssClass = "myLittleLink"; olblResultadoAnterior.Attributes.Add("onClick", "javascript: AntecedenteView (" + oDetalle.IdSubItem.IdItem.ToString() + "," + oDetalle.IdProtocolo.IdPaciente.IdPaciente.ToString() + ",790,540); return false"); - olblResultadoAnterior.ToolTip = "Haga clic aqui para ver gráfico de evolución"; - //olblResultadoAnterior.ForeColor = Color.Green; - olblResultadoAnterior.Width = Unit.Pixel(20); + olblResultadoAnterior.ToolTip = "Haga clic aqui para ver gráfico de evolución"; + olblResultadoAnterior.Width = Unit.Pixel(30); olblResultadoAnterior.Text = resultadoAnterior; - objCellResultadoAnterior.Controls.Add(olblResultadoAnterior); - //Button oB = new Button(); - //oB.Text = "R.ANT"; - //oB.OnClientClick = "javascript: AntecedenteView (" + oDetalle.IdSubItem.IdItem.ToString() + "," + oDetalle.IdProtocolo.IdPaciente.IdPaciente.ToString() + "); return false"; - //objCellResultadoAnterior.Controls.Add(oB); - } + } - } - // if (VerificaValorReferencia(m_minimoReferencia, m_maximoReferencia, x, m_tipoValorReferencia)) + } if (oDetalle.VerificaValorReferencia(x)) olbl.ForeColor = Color.Black; else @@ -924,7 +880,7 @@ private void LlenarTabla(string p) - if (oDetalle.tieneAdjuntoVisible())//tiene observaciones + if (oDetalle.tieneAdjuntoVisible())//Caro: falta mejorar esto { imgAdj = true; btnImagen.TabIndex = short.Parse("500"); @@ -942,22 +898,15 @@ private void LlenarTabla(string p) - } + //} } objCellResultado.Controls.Add(olbl); if (imgAdj)objCellResultado.Controls.Add(btnImagen); ///etiqueta de unidad de medida - Label olblUM = new Label(); - - - // olblUM.ID = "UM" + m_idItem.ToString(); + Label olblUM = new Label(); olblUM.Font.Size = FontUnit.Point(7); - olblUM.Text = unMedida; - - - - + olblUM.Text = unMedida; objCellResultado.Controls.Add(olblUM); olblUM.Visible = false; @@ -986,11 +935,7 @@ private void LlenarTabla(string p) } - ///IMAGENES ADJUNTAS - - - - + ///IMAGENES ADJUNTAS // fin de imagenes adjuntas @@ -998,15 +943,22 @@ private void LlenarTabla(string p) if ((i_iddetalleProtocolo != 0) ) { - if (i_iddetalleProtocolo != 9999999) - { + //if (i_iddetalleProtocolo != 9999999) + //{ //DetalleProtocolo oDetalle = new DetalleProtocolo(); //oDetalle = (DetalleProtocolo)oDetalle.Get(typeof(DetalleProtocolo), i_iddetalleProtocolo); m_usuariovalida += " " + oDetalle.FechaValida.ToShortDateString(); if (oDetalle.IdProtocolo.IdTipoServicio.IdTipoServicio != 5) { - string resultadoAnterior = oDetalle.BuscarResultadoAnterior(oDetalle.IdSubItem, oDetalle.IdItem, false); + //string resultadoAnterior = oDetalle.BuscarResultadoAnterior(oDetalle.IdSubItem, oDetalle.IdItem, false); + string resultadoAnterior = ""; + + if (resultadosAnteriores.ContainsKey(oDetalle.IdSubItem.IdItem)) + { + resultadoAnterior = resultadosAnteriores[oDetalle.IdSubItem.IdItem]; + } + if (resultadoAnterior != "") { hayAntecedente = true; @@ -1017,32 +969,25 @@ private void LlenarTabla(string p) olblResultadoAnterior.Attributes.Add("onClick", "javascript: AntecedenteView (" + oDetalle.IdSubItem.IdItem.ToString() + "," + oDetalle.IdProtocolo.IdPaciente.IdPaciente.ToString() + ",790,450); return false"); olblResultadoAnterior.ToolTip = "Haga clic aqui para ver más datos."; //olblResultadoAnterior.ForeColor = Color.Green; - olblResultadoAnterior.Width = Unit.Pixel(20); + olblResultadoAnterior.Width = Unit.Pixel(30); olblResultadoAnterior.Text = resultadoAnterior; - objCellResultadoAnterior.Controls.Add(olblResultadoAnterior); - //Button oB = new Button(); - //oB.Text = "R.ANT"; - //oB.OnClientClick = "javascript: AntecedenteView (" + oDetalle.IdSubItem.IdItem.ToString() + "," + oDetalle.IdProtocolo.IdPaciente.IdPaciente.ToString() + "); return false"; - //objCellResultadoAnterior.Controls.Add(oB); + } } if (oDetalle.tieneAdjuntoVisible())//tiene observaciones - { - // ImageButton btnImagen = new ImageButton(); + { btnImagen.TabIndex = short.Parse("500"); btnImagen.ID = "IMG" + oDetalle.IdDetalleProtocolo.ToString(); btnImagen.ImageUrl = "~/App_Themes/default/images/obs_validado.png"; - btnImagen.ToolTip = "Adjunto imprimible para " + lbl1.Text.Replace(" ", ""); - btnImagen.Attributes.Add("onClick", "javascript: AdjuntoEdit (" + oDetalle.IdDetalleProtocolo.ToString() + "," + oDetalle.IdProtocolo.IdTipoServicio.IdTipoServicio.ToString() + ",'" + Request["Operacion"].ToString() + "'); return false"); objCellResultado.Controls.Add(btnImagen); } } - } + //} } // fin case 1 break; @@ -1050,39 +995,26 @@ private void LlenarTabla(string p) }//fin swicth - - - Label lblPersona = new Label(); - // lblPersona.TabIndex = short.Parse("500"); - lblPersona.Text = m_usuariovalida; /// Ds.Tables[0].Rows[i].ItemArray[1].ToString(); - - + Label lblPersona = new Label(); + lblPersona.Text = m_usuariovalida; /// lblPersona.Font.Size = FontUnit.Point(7); lblPersona.Font.Italic = true; lblPersona.Text = m_usuariovalida ; - - objCellPersona.Controls.Add(lblPersona); - - + objCellPersona.Controls.Add(lblPersona); } - Label lblValoresReferencia = new Label(); - - // lblValoresReferencia.ID = "VR" + m_idItem.ToString(); + Label lblValoresReferencia = new Label(); lblValoresReferencia.Font.Italic = true; lblValoresReferencia.Font.Size = FontUnit.Point(8); if (valorReferencia != "") {// muestra el valor guardado lblValoresReferencia.Text = valorReferencia; - if (m_metodo != "") - // lblValoresReferencia.Text += " |Método:" + m_metodo; + if (m_metodo != "") lblValoresReferencia.Text += Environment.NewLine + m_metodo; - } - //else - // lblValoresReferencia.Text = oDetalle.CalcularValoresReferencia(); + } objCellValoresReferencia.Controls.Add(lblValoresReferencia); } @@ -1091,30 +1023,21 @@ private void LlenarTabla(string p) ///Definir los anchos de las columnas objCellAnalisis.Width = Unit.Percentage(30); - objCellResultado.Width = Unit.Percentage(30); + objCellResultado.Width = Unit.Percentage(25); objCellValoresReferencia.Width = Unit.Percentage(20); // objCellValida.Width = Unit.Percentage(5); - objCellPersona.Width = Unit.Percentage(20); - + objCellPersona.Width = Unit.Percentage(15); + objCellResultadoAnterior.Width = Unit.Percentage(10); /////////////////////// ///agrega a la fila cada una de las celdas objFila.Cells.Add(objCellAnalisis); - objFila.Cells.Add(objCellResultado); - - //if (Request["Operacion"].ToString() != "HC") objFila.Cells.Add(objCellUnMedida); - - objFila.Cells.Add(objCellValoresReferencia); - - //if ((Request["Operacion"].ToString() == "Valida") || (Request["Operacion"].ToString() == "Control")) objFila.Cells.Add(objCellValida); - + objFila.Cells.Add(objCellResultado); + objFila.Cells.Add(objCellValoresReferencia); objFila.Cells.Add(objCellPersona); - objFila.Cells.Add(objCellResultadoAnterior); - //if (Request["Operacion"].ToString() != "HC") objFila.Cells.Add(objCellObservaciones); - - ////// + ////// Master.FindControl("ContentPlaceHolder1").FindControl("Panel1").Controls.Add(tContenido); //'añadimos la fila a la tabla @@ -1142,11 +1065,7 @@ private void LlenarTablaATB(string p) da.Fill(Ds); - - //int cantidadResultadosValidados = Ds.Tables[0].Rows.Count; - //if (cantidadResultadosValidados > 0) - - //{ + string s = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator; @@ -1196,43 +1115,13 @@ private void LlenarTablaATB(string p) for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { - //decimal m_minimoReferencia=-1; - //decimal m_maximoReferencia=-1; - // string valorReferencia = Ds.Tables[0].Rows[i].ItemArray[11].ToString(); - // int m_idItem = int.Parse(Ds.Tables[0].Rows[i].ItemArray[2].ToString()); - // int m_idMecanismo = int.Parse(Ds.Tables[0].Rows[i].ItemArray[3].ToString()); - // string unMedida = Ds.Tables[0].Rows[i].ItemArray[8].ToString(); - // string Observaciones = Ds.Tables[0].Rows[i].ItemArray[5].ToString(); + int tiporesultado = (int.Parse(Ds.Tables[0].Rows[i].ItemArray[4].ToString())); - // int tipodeterminacion = int.Parse(Ds.Tables[0].Rows[i].ItemArray[6].ToString()); - // int estado = int.Parse(Ds.Tables[0].Rows[i].ItemArray[9].ToString()); - // string m_metodo = Ds.Tables[0].Rows[i].ItemArray[10].ToString(); - - // string m_observacionReferencia = Ds.Tables[0].Rows[i].ItemArray[13].ToString(); - // string m_usuarioCarga = Ds.Tables[0].Rows[i].ItemArray[14].ToString(); - // string m_trajoMuestra = Ds.Tables[0].Rows[i].ItemArray[15].ToString(); - // string m_tipoValorReferencia = Ds.Tables[0].Rows[i].ItemArray[16].ToString(); - // string m_conResultado = Ds.Tables[0].Rows[i].ItemArray[17].ToString(); - // string m_formatoDecimal = Ds.Tables[0].Rows[i].ItemArray[18].ToString(); - //string m_formato0 = Ds.Tables[0].Rows[i].ItemArray[19].ToString(); - //string m_formato1 = Ds.Tables[0].Rows[i].ItemArray[20].ToString(); - //string m_formato2 = Ds.Tables[0].Rows[i].ItemArray[21].ToString(); - //string m_formato3 = Ds.Tables[0].Rows[i].ItemArray[22].ToString(); - //string m_formato4 = Ds.Tables[0].Rows[i].ItemArray[23].ToString(); - //string m_resultadoDefecto = Ds.Tables[0].Rows[i].ItemArray[24].ToString(); - // string m_usuariocontrol = Ds.Tables[0].Rows[i].ItemArray[25].ToString(); + string m_usuariovalida = Ds.Tables[0].Rows[i].ItemArray[5].ToString(); - // int i_iddetalleProtocolo = int.Parse(Ds.Tables[0].Rows[i].ItemArray[26].ToString()); - //string m_codificaPaciente = Ds.Tables[0].Rows[i].ItemArray[27].ToString(); - - // string m_estadoObservacion = Ds.Tables[0].Rows[i].ItemArray[29].ToString(); + string m_area = "ATB";//Ds.Tables[0].Rows[i].ItemArray[30].ToString(); - - //if (m_codificaPaciente == "True") - //{ - // lblPaciente.Visible = false; - // lblCodigoPaciente.Visible = true; - //} + m_hijo = Ds.Tables[0].Rows[i].ItemArray[2].ToString(); @@ -1257,24 +1146,19 @@ private void LlenarTablaATB(string p) { TableRow objRow = new TableRow(); TableCell objCell = new TableCell(); - Label lbl0 = new Label(); - //lbl0.ForeColor = Color + Label lbl0 = new Label(); lbl0.Text = m_area.ToUpper(); lbl0.TabIndex = short.Parse("500"); lbl0.Font.Bold = true; Master.FindControl("ContentPlaceHolder1").FindControl("Panel1").Controls.Add(lbl0); - objCell.Controls.Add(lbl0); - //if (Request["Operacion"].ToString() == "HC") - // objCell.ColumnSpan = 8; - //else + objCell.Controls.Add(lbl0); objCell.ColumnSpan = 8; objRow.BackColor = Color.Beige; objRow.HorizontalAlign = HorizontalAlign.Center; - objRow.Cells.Add(objCell); - // objRow.CssClass = "myLabelIzquierda"; + objRow.Cells.Add(objCell); tContenido.Controls.Add(objRow); pivot_Area = m_area; @@ -1317,45 +1201,26 @@ private void LlenarTablaATB(string p) lbl1.TabIndex = short.Parse("500"); lbl1.ForeColor = Color.Black; lbl1.Font.Size = FontUnit.Point(9); - //if (tipodeterminacion != 0) - //{ + lbl1.Font.Bold = true; lbl1.Font.Italic = true; objCellAnalisis.ColumnSpan = 1; - //} + objCellAnalisis.Controls.Add(lbl1); - - //if (tipodeterminacion == 0) // si es una determinacion simple - //{ Label olbl = new Label(); olbl.Font.Bold = true; olbl.Font.Size = FontUnit.Point(9); - //if (m_conResultado == "0") - // olbl.Text = ""; - //else olbl.Text = Ds.Tables[0].Rows[i].ItemArray[3].ToString(); - //if (Observaciones != "") - //{ - // if (olbl.Text == "") - // olbl.Text += Observaciones; - // else - // olbl.Text += Environment.NewLine + " " + Observaciones; - - //} - objCellResultado.Controls.Add(olbl); - - //DetalleProtocolo oDetalle = new DetalleProtocolo(); - //oDetalle = (DetalleProtocolo)oDetalle.Get(typeof(DetalleProtocolo), i_iddetalleProtocolo); - + m_usuariovalida += " "; //+ fefecha validad @@ -1364,8 +1229,7 @@ private void LlenarTablaATB(string p) - Label lblPersona = new Label(); - // lblPersona.TabIndex = short.Parse("500"); + Label lblPersona = new Label(); lblPersona.Text = m_usuariovalida; /// Ds.Tables[0].Rows[i].ItemArray[1].ToString(); @@ -1378,27 +1242,7 @@ private void LlenarTablaATB(string p) objCellPersona.Controls.Add(lblPersona); - - - ///no se usa valor referencia con los ATB - //Label lblValoresReferencia = new Label(); - - //// lblValoresReferencia.ID = "VR" + m_idItem.ToString(); - //lblValoresReferencia.Font.Italic = true; - //lblValoresReferencia.Font.Size = FontUnit.Point(8); - //if (valorReferencia != "") - //{// muestra el valor guardado - // lblValoresReferencia.Text = valorReferencia; - // if (m_metodo != "") - // // lblValoresReferencia.Text += " |Método:" + m_metodo; - // lblValoresReferencia.Text += Environment.NewLine + m_metodo; - //} - ////else - //// lblValoresReferencia.Text = oDetalle.CalcularValoresReferencia(); - - //objCellValoresReferencia.Controls.Add(lblValoresReferencia); - //} - + ///Definir los anchos de las columnas @@ -1447,10 +1291,6 @@ private void Imprimir(Protocolo oProtocolo, string tipo) Configuracion oCon = new Configuracion(); oCon = (Configuracion)oCon.Get(typeof(Configuracion),"IdEfector", oProtocolo.IdEfector); - // CrystalReportSource oCr = new CrystalReportSource(); - //oCr.Report.FileName = ""; - //oCr.CacheDuration =10000; - //oCr.EnableCaching = true; string parametroPaciente = ""; string parametroProtocolo = ""; @@ -1672,7 +1512,7 @@ protected void gvLista_RowDataBound(object sender, GridViewRowEventArgs e) string idProtocolo= this.gvLista.DataKeys[e.Row.RowIndex].Value.ToString(); - string s_detalle = e.Row.Cells[0].Text + ": " + getDetalleProtocolo(idProtocolo); + string s_detalle = e.Row.Cells[0].Text;// + ": " + getDetalleProtocolo(idProtocolo); e.Row.Cells[0].ToolTip = s_detalle; e.Row.Cells[1].ToolTip = s_detalle; @@ -1699,22 +1539,7 @@ private bool AnalizarLimites(string p) throw new NotImplementedException(); } - private bool estaVisibleControl(string idarea) - { - bool visible=true; - //if (HidArea.Value == "0") - // visible = true; - //else - //{ - // if (idarea == HidArea.Value) - // visible = true; - // else - // visible = false; - //} - return visible; - - } - + @@ -1784,84 +1609,8 @@ protected void lnkAuditoria_Click(object sender, EventArgs e) - protected void lnkMarcar_Click(object sender, EventArgs e) - { - - Marcar(true); - - } - - private void Marcar(bool p) - { - - CheckBox chk; - - - if (Page.Master != null) - { - foreach (Control control in Page.Master.Controls) - { - if (control is HtmlForm) - { - foreach (Control controlform in control.Controls) - { - if (controlform is ContentPlaceHolder) - { - foreach (Control control1 in controlform.Controls) - { - if (control1 is Panel) - foreach (Control control2 in control1.Controls) - { - if (control2 is Table) - foreach (Control control3 in control2.Controls) - { - - if (control3 is TableRow) - foreach (Control control4 in control3.Controls) - { - - if (control4 is TableCell) - foreach (Control control5 in control4.Controls) - { - - if (control5 is CheckBox) - { - chk = (CheckBox)control5; - chk.Checked = p; - - - - } - - - } - } - } - } - } - } - } - } - } - } - - } - - protected void lnkDesmarcar_Click(object sender, EventArgs e) - { - Marcar(false); - } - - protected void btnVerAntecendente_Click(object sender, EventArgs e) - { - //if (ddlItem.SelectedValue != "0") - //{ - // Protocolo oProtocolo = new Protocolo(); - // oProtocolo = (Protocolo)oProtocolo.Get(typeof(Protocolo), CurrentPageIndex);//int.Parse(Request["idProtocolo"].ToString()));r(); - // CargarGrillaAntecedentes(oProtocolo); - // SetSelectedTab(TabIndex.THREE); - //} - } + + @@ -1887,35 +1636,35 @@ protected void btnPeticion_Click(object sender, EventArgs e) } - private string getDetalleProtocolo(string idProtocolo) - { - string dev = ""; int i = 0; - Protocolo oRegistro = new Protocolo(); - oRegistro = (Protocolo)oRegistro.Get(typeof(Protocolo), int.Parse(idProtocolo)); - - ISession m_session = NHibernateHttpModule.CurrentSession; - ICriteria crit = m_session.CreateCriteria(typeof(DetalleProtocolo)); - crit.Add(Expression.Eq("IdProtocolo", oRegistro)); - IList items = crit.List(); - foreach (DetalleProtocolo oDet in items) - { - i += 1; - if (dev == "") - dev = oDet.IdItem.Nombre; - else - { - if (dev.IndexOf(oDet.IdItem.Nombre) == -1) - dev = dev + " - " + oDet.IdItem.Nombre; - } - } - //return i.ToString() + ": " + dev; - return dev; - } + //private string getDetalleProtocolo(string idProtocolo) + //{ + // string dev = ""; int i = 0; + // Protocolo oRegistro = new Protocolo(); + // oRegistro = (Protocolo)oRegistro.Get(typeof(Protocolo), int.Parse(idProtocolo)); + + // ISession m_session = NHibernateHttpModule.CurrentSession; + // ICriteria crit = m_session.CreateCriteria(typeof(DetalleProtocolo)); + // crit.Add(Expression.Eq("IdProtocolo", oRegistro)); + // IList items = crit.List(); + // foreach (DetalleProtocolo oDet in items) + // { + // i += 1; + // if (dev == "") + // dev = oDet.IdItem.Nombre; + // else + // { + // if (dev.IndexOf(oDet.IdItem.Nombre) == -1) + // dev = dev + " - " + oDet.IdItem.Nombre; + // } + // } + // //return i.ToString() + ": " + dev; + // return dev; + //} - protected void btnArchivos_Click(object sender, EventArgs e) - { - Response.Redirect("../Protocolos/ProtocoloAdjuntar.aspx?idProtocolo=" + Session["idProtocolo"].ToString()+"&desde=resultado"); - } + //protected void btnArchivos_Click(object sender, EventArgs e) + //{ + // Response.Redirect("../Protocolos/ProtocoloAdjuntar.aspx?idProtocolo=" + Session["idProtocolo"].ToString()+"&desde=resultado"); + //} protected void imgPdf_Click(object sender, EventArgs e) { diff --git a/WebLab/Resultados/ResultadoView.aspx.designer.cs b/WebLab/Resultados/ResultadoView.aspx.designer.cs index 2bcb64d5..091f5509 100644 --- a/WebLab/Resultados/ResultadoView.aspx.designer.cs +++ b/WebLab/Resultados/ResultadoView.aspx.designer.cs @@ -283,49 +283,40 @@ public partial class ResultadoView { protected global::System.Web.UI.WebControls.Label lblDiagnostico; /// - /// lblNroSISA control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Label lblNroSISA; - - /// - /// lblPedidoOriginal control. + /// lblCovid control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.Label lblPedidoOriginal; + protected global::System.Web.UI.WebControls.Label lblCovid; /// - /// HFCurrTabIndex control. + /// lblNroSISA control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.HiddenField HFCurrTabIndex; + protected global::System.Web.UI.WebControls.Label lblNroSISA; /// - /// pnlHC control. + /// lblPedidoOriginal control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.Panel pnlHC; + protected global::System.Web.UI.WebControls.Label lblPedidoOriginal; /// - /// lblCovid control. + /// HFCurrTabIndex control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.Label lblCovid; + protected global::System.Web.UI.WebControls.HiddenField HFCurrTabIndex; /// /// lblMuestra control. @@ -435,15 +426,6 @@ public partial class ResultadoView { /// protected global::System.Web.UI.WebControls.DropDownList ddlItem; - /// - /// btnVerAntecendente control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Button btnVerAntecendente; - /// /// gvAntecedente control. /// diff --git a/WebLab/Turnos/TurnoList.aspx b/WebLab/Turnos/TurnoList.aspx index a830b6bd..2fe56064 100644 --- a/WebLab/Turnos/TurnoList.aspx +++ b/WebLab/Turnos/TurnoList.aspx @@ -149,7 +149,9 @@ + + diff --git a/WebLab/Turnos/TurnoList.aspx.cs b/WebLab/Turnos/TurnoList.aspx.cs index 0c40d791..21786305 100644 --- a/WebLab/Turnos/TurnoList.aspx.cs +++ b/WebLab/Turnos/TurnoList.aspx.cs @@ -1,7 +1,19 @@ -using System; +using Business; +using Business.Data; +using Business.Data.Laboratorio; +using CrystalDecisions.Shared; +using CrystalDecisions.Web; +using NHibernate; +using NHibernate.Collection; +using NHibernate.Expression; +using System; using System.Collections; using System.Configuration; using System.Data; +using System.Data.SqlClient; +using System.Data.SqlTypes; +using System.Drawing; +using System.IO; using System.Linq; using System.Web; using System.Web.Security; @@ -10,26 +22,15 @@ using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; -using Business; -using System.Data.SqlClient; -using NHibernate; -using Business.Data.Laboratorio; -using NHibernate.Expression; -using System.Data.SqlTypes; -using CrystalDecisions.Shared; -using System.IO; -using System.Drawing; -using NHibernate.Collection; -using CrystalDecisions.Web; -using Business.Data; +using static System.Net.WebRequestMethods; namespace WebLab.Turnos { public partial class TurnoList : System.Web.UI.Page { protected string DiasNoHabiles = ""; - protected DateTime fechaDesde= new DateTime(); - protected DateTime fechaHasta = new DateTime(); + //protected DateTime fechaDesde= new DateTime(); //Vane: No se esta usando mas + //protected DateTime fechaHasta = new DateTime(); public Configuracion oCon = new Configuracion(); public Usuario oUser = new Usuario(); @@ -237,10 +238,10 @@ private bool noEsFeriado() private bool VerificarAgenda() { - bool result = false; + bool result = false; lblMensajeSolicitante.Visible = false; if (ddlTipoServicio.SelectedValue != "") { - string s_item = ""; string m_ssqlItem = ""; + string s_item = ""; string m_ssqlItem = "", m_ssqlDia =""; if (ddlItem.SelectedValue != "0") s_item = " - " + ddlItem.SelectedItem.Text; m_ssqlItem = " AND A.IdItem=" + ddlItem.SelectedValue; @@ -248,69 +249,109 @@ private bool VerificarAgenda() lblFecha.Text = cldTurno.SelectedDate.ToLongDateString().ToUpper();//.ToShortDateString(); int dia = (int)cldTurno.SelectedDate.DayOfWeek; - + m_ssqlDia = " AND AD.Dia=" + dia.ToString(); DateTime fecha = DateTime.Parse(cldTurno.SelectedDate.ToShortDateString()); - ISession m_session = NHibernateHttpModule.CurrentSession; - string m_ssql = ""; - if (oUser.IdPerfil.IdPerfil == 15) - m_ssql = " FROM Agenda A WHERE A.Baja=0 AND A.IdTipoServicio=" + ddlTipoServicio.SelectedValue + - " and IdEfectorSolicitante = " + oUser.IdEfector.IdEfector.ToString()+ - " AND A.FechaDesde<='" + fecha.ToString("yyyyMMdd") + "'" + - " AND A.FechaHasta>='" + fecha.ToString("yyyyMMdd") + "'" + m_ssqlItem; - - else - m_ssql = " FROM Agenda A WHERE A.Baja=0 AND A.IdTipoServicio=" + ddlTipoServicio.SelectedValue + - " and IdEfector = " + oCon.IdEfector.IdEfector.ToString() + - " and IdEfectorSolicitante = " + oCon.IdEfector.IdEfector.ToString() + - " AND A.FechaDesde<='" + fecha.ToString("yyyyMMdd") + "'" + - " AND A.FechaHasta>='" + fecha.ToString("yyyyMMdd") + "'" + m_ssqlItem; + // ISession m_session = NHibernateHttpModule.CurrentSession; + string m_ssql = @"Select AD.HoraDesde, AD.HoraHasta, AD.TipoTurno, AD.Frecuencia, AD.LimiteTurnos, A.IdEfectorSolicitante, + ISNULL(Turnos.TurnosDados, 0) as TurnosDados + FROM LAB_Agenda A with (nolock) + inner join LAB_AgendaDia AD with (nolock) on AD.idAgenda = A.idAgenda + LEFT JOIN ( + SELECT + idEfector, + idEfectorSolicitante, + idTipoServicio, + IdItem, + COUNT(idTurno) as TurnosDados + FROM LAB_Turno WITH (NOLOCK) + WHERE baja = 0 AND fecha = '" + fecha.ToString("yyyyMMdd")+ @"' + GROUP BY idEfector, idEfectorSolicitante, idTipoServicio, IdItem + ) Turnos ON + Turnos.idEfector = A.IdEfector AND + Turnos.idEfectorSolicitante = A.IdEfectorSolicitante AND + Turnos.idTipoServicio = A.IdTipoServicio AND + Turnos.IdItem = A.IdItem + WHERE A.Baja=0 + AND A.IdTipoServicio=" + ddlTipoServicio.SelectedValue + + " AND A.FechaDesde<='" + fecha.ToString("yyyyMMdd") + "'" + + " AND A.FechaHasta>='" + fecha.ToString("yyyyMMdd") + "'" + m_ssqlItem + m_ssqlDia; - IQuery q = m_session.CreateQuery(m_ssql); + if (oUser.IdPerfil.IdPerfil == 15) + m_ssql += " and IdEfectorSolicitante = " + oUser.IdEfector.IdEfector.ToString(); + else //Traigo el labo y sus relacionados + m_ssql += " and A.IdEfector = " + oCon.IdEfector.IdEfector.ToString(); + + + DataSet Ds = new DataSet(); + SqlConnection conn = (SqlConnection)NHibernateHttpModule.CurrentSession.Connection; + SqlDataAdapter adapter = new SqlDataAdapter(); + adapter.SelectCommand = new SqlCommand(m_ssql, conn); + adapter.Fill(Ds); + if (Ds.Tables[0].Rows.Count > 0) + { + result = true; + //Me traigo la fila con la que completo los horarios + DataRow[] array = Ds.Tables[0].Select("idEfectorSolicitante = " + oUser.IdEfector.IdEfector); + if (array != null && array.Length > 0) + { + DataRow fila = array[0]; + string horaDesde = fila[0].ToString(); + string horaHasta = fila[1].ToString(); + int tipoTurno = int.Parse(fila[2].ToString()); + int frecuencia = int.Parse(fila[3].ToString()); + lblHorario.Text = "Horario de Atención: " + horaDesde + " - " + horaHasta; + lblHoraTurno.Text = CalcularHorarioDisponible(tipoTurno, frecuencia, horaDesde); + } + else //no hay agenda del efector logueado + { + result = false; + } + //Me traigo la fila con la que completo los turnos disponibles, dependiendo del efector solicitante elegido + string idEfectorSolicitante = "0"; + if (ddlEfectorSolicitante.SelectedValue != "0") idEfectorSolicitante = ddlEfectorSolicitante.SelectedValue; + else idEfectorSolicitante = oUser.IdEfector.IdEfector.ToString(); - IList lista = q.List(); - if (lista.Count > 0) - { - foreach (Agenda oAgenda in lista) + DataRow[] arraySol = Ds.Tables[0].Select("idEfectorSolicitante = " + idEfectorSolicitante); + if(arraySol != null && arraySol.Length >0 ) //Tiene agenda el efector solicitante seleccionado { - fechaDesde = oAgenda.FechaDesde; - fechaHasta = oAgenda.FechaHasta; - ICriteria crit = m_session.CreateCriteria(typeof(AgendaDia)); - crit.Add(Expression.Eq("IdAgenda", oAgenda)); - crit.Add(Expression.Eq("Dia", dia)); - - IList listaDias = crit.List(); - if (listaDias.Count > 0) + DataRow filaSol = arraySol[0]; + int limiteTurnos = int.Parse(filaSol[4].ToString()); + if (limiteTurnos == 0) { - foreach (AgendaDia oAgendaDia in listaDias) - { - result = true; - lblHorario.Text = "Horario de Atención: " + oAgendaDia.HoraDesde + " - " + oAgendaDia.HoraHasta; - lblHoraTurno.Text = CalcularHorarioDisponible(oAgendaDia.TipoTurno, oAgendaDia.Frecuencia, oAgendaDia.HoraDesde); - if (oAgendaDia.LimiteTurnos == 0) - { - lblLimiteTurnos.Text = "Sin límite de turnos"; - lblTurnosDisponibles.Text = "0"; - } - else - { - lblLimiteTurnos.Text = oAgendaDia.LimiteTurnos.ToString(); - int turnos_dados = int.Parse(lblTurnosDados.Text); - lblTurnosDisponibles.Text = (oAgendaDia.LimiteTurnos - turnos_dados).ToString(); - } - - } - break; + lblLimiteTurnos.Text = "Sin límite de turnos"; + lblTurnosDisponibles.Text = "0"; } else - result = false; + { + lblLimiteTurnos.Text = limiteTurnos.ToString(); + int turnos_dados = int.Parse(filaSol[6].ToString()); + lblTurnosDisponibles.Text = (limiteTurnos - turnos_dados).ToString(); + lblTurnosDados.Text = turnos_dados.ToString(); + } + + + } + else + { + if(idEfectorSolicitante.ToString() != oUser.IdEfector.IdEfector.ToString()) + { + lblLimiteTurnos.Text = "0"; + lblTurnosDisponibles.Text = "0"; + lblTurnosDados.Text = "0"; + lblMensajeSolicitante.Text = "No existe agenda para el Efector Solicitante"; + lblMensajeSolicitante.Visible = true; + } + } + } else result = false; + } - else result = false; + return result; } @@ -319,25 +360,25 @@ private string CalcularHorarioDisponible(int tipo, int f, string horadesde) { DateTime fecha = DateTime.Parse(cldTurno.SelectedDate.ToShortDateString()); string m_strSQL = ""; - if (oUser.IdPerfil.IdPerfil==15) + if (oUser.IdPerfil.IdPerfil == 15) m_strSQL = " SELECT idTurno AS idturno, hora FROM LAB_Turno AS T (nolock) " + " WHERE (T.baja = 0) AND T.fecha='" + fecha.ToString("yyyyMMdd") + "'" + " and T.idEfectorSolicitante= " + oUser.IdEfector.IdEfector.ToString() + " AND T.idTipoServicio=" + ddlTipoServicio.SelectedValue + " AND T.IdItem=" + ddlItem.SelectedValue + " ORDER BY idturno DESC "; else - m_strSQL = @" SELECT idTurno AS idturno, hora + m_strSQL = @" SELECT idTurno AS idturno, hora FROM LAB_Turno AS T (nolock) WHERE (T.baja = 0) AND T.fecha='" + fecha.ToString("yyyyMMdd") + @"' and T.idEfector= " + oCon.IdEfector.IdEfector.ToString() + - @" and T.idEfectorSolicitante= " + oCon.IdEfector.IdEfector.ToString() + - @" AND T.idTipoServicio=" + ddlTipoServicio.SelectedValue + " AND T.IdItem=" + ddlItem.SelectedValue + " ORDER BY idturno DESC "; + @" and T.idEfectorSolicitante= " + oCon.IdEfector.IdEfector.ToString() + + @" AND T.idTipoServicio=" + ddlTipoServicio.SelectedValue + " AND T.IdItem=" + ddlItem.SelectedValue + " ORDER BY idturno DESC "; DataSet Ds = new DataSet(); SqlConnection conn = (SqlConnection)NHibernateHttpModule.CurrentSession.Connection; SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = new SqlCommand(m_strSQL, conn); adapter.Fill(Ds); - string m_Hora=horadesde; + string m_Hora = horadesde; lblTurnosDados.Text = Ds.Tables[0].Rows.Count.ToString(); if (tipo == 1) @@ -350,7 +391,7 @@ FROM LAB_Turno AS T (nolock) } } - return m_Hora; + return m_Hora; @@ -500,7 +541,7 @@ protected void btnNuevo_Click(object sender, EventArgs e) Session["Turno_Fecha"] = cldTurno.SelectedDate; Session["Turno_IdTipoServicio"] = ddlTipoServicio.SelectedValue; Session["idServicio"] = ddlTipoServicio.SelectedValue; - Session["Turno_Hora"] = lblHoraTurno.Text; + Session["Turno_Hora"] = lblHoraTurno.Text; Session["idItem"] = ddlItem.SelectedValue; Response.Redirect("Default.aspx", false); } diff --git a/WebLab/Turnos/TurnoList.aspx.designer.cs b/WebLab/Turnos/TurnoList.aspx.designer.cs index f4b76aae..f2ee3d25 100644 --- a/WebLab/Turnos/TurnoList.aspx.designer.cs +++ b/WebLab/Turnos/TurnoList.aspx.designer.cs @@ -1,275 +1,286 @@ //------------------------------------------------------------------------------ -// -// This code was generated by a tool. +// +// Este código fue generado por una herramienta. // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// +// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si +// se vuelve a generar el código. +// //------------------------------------------------------------------------------ -namespace WebLab.Turnos { - - - public partial class TurnoList { - +namespace WebLab.Turnos +{ + + + public partial class TurnoList + { + /// - /// lblTitulo control. + /// Control lblTitulo. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.Label lblTitulo; - + /// - /// lblSubTitulo control. + /// Control lblSubTitulo. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.Label lblSubTitulo; - + /// - /// pnlDerecho control. + /// Control pnlDerecho. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl pnlDerecho; - + /// - /// ddlTipoServicio control. + /// Control ddlTipoServicio. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.DropDownList ddlTipoServicio; - + /// - /// imgServicioView control. + /// Control imgServicioView. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.ImageButton imgServicioView; - + /// - /// ddlItem control. + /// Control ddlItem. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.DropDownList ddlItem; - + /// - /// imgCalendarioView control. + /// Control imgCalendarioView. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.ImageButton imgCalendarioView; - + /// - /// btnActualizar control. + /// Control btnActualizar. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.Button btnActualizar; - + /// - /// cldTurno control. + /// Control cldTurno. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.Calendar cldTurno; - + /// - /// btnNuevo control. + /// Control btnNuevo. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.Button btnNuevo; - + /// - /// lnkProtocolo control. + /// Control lnkProtocolo. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.LinkButton lnkProtocolo; - + /// - /// lblMensaje control. + /// Control lblMensaje. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.Label lblMensaje; - + + /// + /// Control lblMensajeSolicitante. + /// + /// + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. + /// + protected global::System.Web.UI.WebControls.Label lblMensajeSolicitante; + /// - /// lblHoraTurno control. + /// Control lblHoraTurno. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.Label lblHoraTurno; - + /// - /// lblTipoServicio control. + /// Control lblTipoServicio. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.Label lblTipoServicio; - + /// - /// lblFecha control. + /// Control lblFecha. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.Label lblFecha; - + /// - /// lblHorario control. + /// Control lblHorario. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.Label lblHorario; - + /// - /// lblLimiteTurnos control. + /// Control lblLimiteTurnos. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.Label lblLimiteTurnos; - + /// - /// lblTurnosDados control. + /// Control lblTurnosDados. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.Label lblTurnosDados; - + /// - /// lblTurnosDisponibles control. + /// Control lblTurnosDisponibles. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.Label lblTurnosDisponibles; - + /// - /// ddlEfectorSolicitante control. + /// Control ddlEfectorSolicitante. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.DropDownList ddlEfectorSolicitante; - + /// - /// ddlEstadoTurno control. + /// Control ddlEstadoTurno. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.DropDownList ddlEstadoTurno; - + /// - /// txtPaciente control. + /// Control txtPaciente. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.TextBox txtPaciente; - + /// - /// rdbBusqueda control. + /// Control rdbBusqueda. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.RadioButtonList rdbBusqueda; - + /// - /// btnBuscar control. + /// Control btnBuscar. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.LinkButton btnBuscar; - + /// - /// cvNumeroDesde control. + /// Control cvNumeroDesde. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.CustomValidator cvNumeroDesde; - + /// - /// lblUltimoProtocolo control. + /// Control lblUltimoProtocolo. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.Label lblUltimoProtocolo; - + /// - /// gvLista control. + /// Control gvLista. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.GridView gvLista; - + /// - /// lnkPlanilla control. + /// Control lnkPlanilla. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.LinkButton lnkPlanilla; - + /// - /// lnkPlanillaDetallada control. + /// Control lnkPlanillaDetallada. /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. + /// Campo generado automáticamente. + /// Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente. /// protected global::System.Web.UI.WebControls.LinkButton lnkPlanillaDetallada; } diff --git a/WebLab/Turnos/TurnosEdit2.aspx.cs b/WebLab/Turnos/TurnosEdit2.aspx.cs index a3abde8d..0a785f81 100644 --- a/WebLab/Turnos/TurnosEdit2.aspx.cs +++ b/WebLab/Turnos/TurnosEdit2.aspx.cs @@ -500,9 +500,22 @@ private void CargarListas() //oUtil.CargarCombo(ddlDiagnostico, m_ssql, "id", "nombre"); //ddlDiagnostico.Items.Insert(0, new ListItem("", "0")); - string m_ssql = "SELECT idSectorServicio, prefijo + ' - ' + nombre as nombre FROM LAB_SectorServicio with (nolock) WHERE (baja = 0) order by nombre"; + //string m_ssql = "SELECT idSectorServicio, prefijo + ' - ' + nombre as nombre FROM LAB_SectorServicio with (nolock) WHERE (baja = 0) order by nombre"; + // oUtil.CargarCombo(ddlSectorServicio, m_ssql, "idSectorServicio", "nombre"); + // ddlSectorServicio.Items.Insert(0, new ListItem("-SIN IDENTIFICAR-", "0")); + + string str_condicion = ")"; + if ( (Request["Modifica"].ToString() == "1") && (Request["idTurno"] != null)) + str_condicion = " or exists (select 1 from LAB_Turno p WHERE p.idsector = s.idSectorServicio and idTurno = " + Request["idTurno"].ToString() + ")) "; + + + + string m_ssql = @"SELECT s.idSectorServicio, s.prefijo + ' - ' + s.nombre as nombre FROM LAB_SectorServicio S with (nolock) + WHERE (baja = 0) + and ( exists (select 1 from Lab_SectorServicioEfector SE where SE.idSectorServicio=S.idSectorServicio and se.idefector=" + oUser.IdEfector.IdEfector.ToString() + @" )" + str_condicion + @" order by nombre"; + oUtil.CargarCombo(ddlSectorServicio, m_ssql, "idSectorServicio", "nombre"); - ddlSectorServicio.Items.Insert(0, new ListItem("-SIN IDENTIFICAR-", "0")); + ddlSectorServicio.Items.Insert(0, new ListItem("Seleccione", "0")); //m_ssql = "SELECT idProfesional, apellido + ' ' + nombre AS nombre FROM Sys_Profesional ORDER BY apellido, nombre "; diff --git a/WebLab/Usuarios/PasswordEdit.aspx.cs b/WebLab/Usuarios/PasswordEdit.aspx.cs index ccddad53..e0597de9 100644 --- a/WebLab/Usuarios/PasswordEdit.aspx.cs +++ b/WebLab/Usuarios/PasswordEdit.aspx.cs @@ -18,15 +18,19 @@ public partial class PasswordEdit : System.Web.UI.Page protected void Page_PreInit(object sender, EventArgs e) { Usuario oUser = new Usuario(); + if (Session["idUsuario"]!= null) oUser = (Usuario)oUser.Get(typeof(Usuario), int.Parse(Session["idUsuario"].ToString())); + else Response.Redirect("../FinSesion.aspx", false); + /* //Caro: Adaptacion multiefector - correccion que no estaba funcionando el cambio de clave de validacion. Configuracion oC = new Configuracion(); - oC = (Configuracion)oC.Get(typeof(Configuracion), "IdConfiguracion", 1); - if (oUser.IdEfector != oC.IdEfector) // es externo - { - this.MasterPageFile = "~/PeticionElectronica/SitePE.master"; + oC = (Configuracion)oC.Get(typeof(Configuracion), "IdConfiguracion", 1); + if (oUser.IdEfector != oC.IdEfector) // es externo + { + this.MasterPageFile = "~/PeticionElectronica/SitePE.master"; - } + } + */ } protected void Page_Load(object sender, EventArgs e) @@ -35,13 +39,13 @@ protected void Page_Load(object sender, EventArgs e) { Usuario oUser = new Usuario(); oUser = (Usuario)oUser.Get(typeof(Usuario), int.Parse(Session["idUsuario"].ToString())); - - Configuracion oC = new Configuracion(); + //Caro: Adaptacion multiefector - correccion que no estaba funcionando el cambio de clave de validacion. + /* Configuracion oC = new Configuracion(); oC = (Configuracion)oC.Get(typeof(Configuracion), "IdConfiguracion", 1); if (oUser.IdEfector != oC.IdEfector) // es externo VerificaPermisos("Validacion Externo"); - else + else*/ VerificaPermisos("Validacion"); if (Request["id"] != null) diff --git a/WebLab/WebLab.csproj b/WebLab/WebLab.csproj index f06aebe9..690222be 100644 --- a/WebLab/WebLab.csproj +++ b/WebLab/WebLab.csproj @@ -2124,7 +2124,6 @@ - @@ -4854,13 +4853,6 @@ ResultadoDefault.aspx - - ResultadosaSisa.aspx - ASPXCodeBehind - - - ResultadosaSisa.aspx - SinDatos.aspx ASPXCodeBehind @@ -4947,6 +4939,12 @@ HistorialPorUsuario.aspx + + True + True + HTrabajoProtocolo2Horizontal.rpt + Component + PacientesList.aspx ASPXCodeBehind diff --git a/WebLab/login.ascx.cs b/WebLab/login.ascx.cs index e51634c3..8f08deaa 100644 --- a/WebLab/login.ascx.cs +++ b/WebLab/login.ascx.cs @@ -44,10 +44,10 @@ protected void Page_Load(object sender, EventArgs e) else { - if (ConfigurationManager.AppSettings["tipoAutenticacion"].ToString() == "SSO") + //if (ConfigurationManager.AppSettings["tipoAutenticacion"].ToString() == "SSO") - Salud.Security.SSO.SSOHelper.RedirectToSSOPage("Logout.aspx?relogin=1", "login.aspx"); + // Salud.Security.SSO.SSOHelper.RedirectToSSOPage("Logout.aspx?relogin=1", "login.aspx"); } } //} @@ -199,30 +199,28 @@ protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) } - - + + private bool VerificarSiTienePermisodeValidar(string user, string m_url) { - bool b_permiso = false; + string m_strSQL = @" SELECT P.permiso, M.objeto, M.url, U.username FROM Sys_Menu AS M INNER JOIN Sys_Permiso AS P ON M.idMenu = P.idMenu INNER JOIN Sys_Usuario AS U ON P.idPerfil = U.idPerfil - WHERE (M.url = '" + m_url + "') AND (U.username = '" + user + "') AND (P.permiso = 2) and (U.activo=1 ) "; + WHERE (M.url = @url) AND (U.username = @username) AND (P.permiso = 2) and (U.activo=1 ) "; - using (SqlConnection conn = (SqlConnection)NHibernateHttpModule.CurrentSession.Connection) + SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SIL_ReadOnly"].ConnectionString); ///Performance: conexion de solo lectura + using (SqlCommand cmd = new SqlCommand(m_strSQL, conn)) { - DataSet Ds = new DataSet(); + cmd.Parameters.AddWithValue("@url", m_url); + cmd.Parameters.AddWithValue("@username", user); - SqlDataAdapter adapter = new SqlDataAdapter(); - adapter.SelectCommand = new SqlCommand(m_strSQL, conn); - adapter.Fill(Ds); + conn.Open(); - DataTable dtPermisos = Ds.Tables[0]; + var result = cmd.ExecuteScalar(); - if (dtPermisos.Rows.Count > 0) b_permiso = true; - conn.Close(); - return b_permiso; + return result != null; } } } diff --git a/WebLab/loginSIL.ascx.cs b/WebLab/loginSIL.ascx.cs index 90f1de21..e7dd1d0f 100644 --- a/WebLab/loginSIL.ascx.cs +++ b/WebLab/loginSIL.ascx.cs @@ -35,53 +35,55 @@ protected void Page_Load(object sender, EventArgs e) Session["idUsuarioValida"] = null; Session["idUsuario"] = null; Session.Clear(); - if (ConfigurationManager.AppSettings["tipoAutenticacion"].ToString() == "SSO") + /* Caro: en miultiefector, no se autentica con SSO + if (ConfigurationManager.AppSettings["tipoAutenticacion"].ToString() == "SSO") Salud.Security.SSO.SSOHelper.RedirectToSSOPage("Logout.aspx?relogin=1", "login.aspx"); + */ } } } protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) - { - Utility oUtil = new Utility(); - string m_password = oUtil.Encrypt(Login1.Password); - - - int i_idusuario = 0; - string m_strSQL = @" SELECT top 1 idUsuario FROM Sys_usuario with (nolock) WHERE (username = '" + Login1.UserName + "') AND ([password] = '" + m_password + "') "; - - DataSet Ds = new DataSet(); - SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SIL_ReadOnly"].ConnectionString); ///Performance: conexion de solo lectura - SqlDataAdapter adapter = new SqlDataAdapter(); - adapter.SelectCommand = new SqlCommand(m_strSQL, conn); - adapter.Fill(Ds); - DataTable dtPermisos = Ds.Tables[0]; - - if (dtPermisos.Rows.Count > 0) { - i_idusuario = int.Parse(dtPermisos.Rows[0][0].ToString()); - } - + { Usuario oUser = new Usuario(); - //oUser = (Usuario)oUser.Get(typeof(Usuario), "Username", Login1.UserName, "Password", m_password); - if (i_idusuario > 0) - { - - oUser = (Usuario)oUser.Get(typeof(Usuario), i_idusuario); - if (MostrarTerminosCondiciones(oUser)) + oUser = (Usuario)oUser.Get(typeof(Usuario), "Username", Login1.UserName); + if (oUser!= null) //(i_idusuario > 0) + { + if ((oUser.Activo) && (oUser.IdPerfil.Activo)) { - Session["usuarioPendienteAceptacion"] = i_idusuario; - ScriptManager.RegisterStartupScript(this, this.GetType(), "mostrarModal", "$('#modalTerminosCondiciones').modal('show');", true); + if (VerificarTipoAutenticacion(oUser)) + { + if (MostrarTerminosCondiciones(oUser)) + { + Session["usuarioPendienteAceptacion"] = oUser.IdUsuario;// i_idusuario; + ScriptManager.RegisterStartupScript(this, this.GetType(), "mostrarModal", "$('#modalTerminosCondiciones').modal('show');", true); + return; + } + } + else + { + oUser = null; + e.Authenticated = false; + Login1.FailureText = "Usuario y/o contraseña incorrecta."; + return; + } + } + else + { + oUser = null; + e.Authenticated = false; + Login1.FailureText = "El usuario inválido."; return; } - + } else { oUser = null; e.Authenticated = false; - Login1.FailureText = "El usuario y/o contraseña no son correctos."; + Login1.FailureText = "El usuario inválido."; return; } @@ -89,153 +91,38 @@ protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) } - private void AutenticarUsuarioLdap(string username, string key) - - { - //// string path = @"LDAP://ldap.neuquen.gov.ar:389"; - ////string path = "LDAP://OU=People,O=integrabilidad,O=neuquen, DC=ldap.neuquen.gov.ar"; - //string path = @"LDAP://ldap.neuquen.gov.ar:389/OU=People,O=integrabilidad,O=neuquen"; - - - //DirectoryEntry ds = new DirectoryEntry(path, "26982063", "bc*123456", AuthenticationTypes.Secure); - //DirectorySearcher dssearch = new DirectorySearcher(ds); - //SearchResult result = dssearch.FindOne(); - - try - { - // Create the new LDAP connection - LdapDirectoryIdentifier ldi = new LdapDirectoryIdentifier("ldap.neuquen.gov.ar", 389); - System.DirectoryServices.Protocols.LdapConnection ldapConnection = - new System.DirectoryServices.Protocols.LdapConnection(ldi); - Console.WriteLine("LdapConnection is created successfully."); - ldapConnection.AuthType = AuthType.Basic; - ldapConnection.SessionOptions.ProtocolVersion = 3; - NetworkCredential nc = new NetworkCredential("uid=" + username + ",ou=people,O=integrabilidad,O=neuquen", - key); // "bc*1213456"); //password - ldapConnection.Bind(nc); - // ldapConnection.pr - - VerificarMatriculacion(username, key); - Console.WriteLine("LdapConnection authentication success"); - ldapConnection.Dispose(); - } - catch (LdapException e) - { - Console.WriteLine("\r\nUnable to login:\r\n\t" + e.Message); - VerificarMatriculacion(username, key); - } - catch (Exception e) - { - Console.WriteLine("\r\nUnexpected exception occured:\r\n\t" + e.GetType() + ":" + e.Message); - } - - } - - public void VerificarMatriculacion(string username, string contra) - { - //HttpContext CurrContext = HttpContext.Current; - //CurrContext.Items.Add("Documento", "20321008"); - //CurrContext.Items.Add("Clave", "20321008"); - //CurrContext.Items.Add("Apellido", "RESCHIA"); - //CurrContext.Items.Add("Nombre", "SANDRA CEFERINA"); - //CurrContext.Items.Add("Titulo", "MEDICA CIRUJANA"); - //Server.Transfer("DatosPersona.aspx"); - - - Session["Documento"] = "20321008"; - Session["Clave"] = "20321008"; - Session["Apellido"] = "RESCHIA"; - Session["Nombre"] = "SANDRA CEFERINA"; - Session["Titulo"] = "MEDICA CIRUJANA"; - - Response.Redirect("DatosPersona.aspx", false); - - - /* Configuracion oC = new Configuracion(); - - - oC = (Configuracion)oC.Get(typeof(Configuracion), 1);// "IdEfector", oEfector); - - string s_urlWFC = oC.UrlMatriculacion; - string s_url = s_urlWFC + "documento=" + username; // + "&codigoProfesion in (1,23)"; - - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(s_url); - HttpWebResponse ws1 = (HttpWebResponse)request.GetResponse(); - JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); - Stream st = ws1.GetResponseStream(); - StreamReader sr = new StreamReader(st); - - string s = sr.ReadToEnd(); - if (s != "0") - { - - List pro = jsonSerializer.Deserialize>(s); - string espe; - if (pro.Count > 0) - { - - for (int i = 0; i < pro.Count; i++) - { - espe = pro[i].apellido + " " + pro[i].nombre + " - " + pro[i].profesiones[0].titulo; - HttpContext CurrContext = HttpContext.Current; - CurrContext.Items.Add("Documento", username); - CurrContext.Items.Add("Clave", contra); - CurrContext.Items.Add("Apellido", pro[i].apellido); - CurrContext.Items.Add("Nombre", pro[i].nombre); - CurrContext.Items.Add("Titulo", pro[i].profesiones[0].titulo); - Server.Transfer("DatosPersona.aspx"); - - - } - - - - - } - else - { //error no encontrado} - - - - } // procount - }//s!=0 - */ - } + + private bool VerificarSiTienePermisodeValidar(string user, string m_url) { - bool b_permiso = false; + string m_strSQL = @" SELECT P.permiso, M.objeto, M.url, U.username FROM Sys_Menu AS M INNER JOIN Sys_Permiso AS P ON M.idMenu = P.idMenu INNER JOIN Sys_Usuario AS U ON P.idPerfil = U.idPerfil - WHERE (M.url = '" + m_url + "') AND (U.username = '" + user + "') AND (P.permiso = 2) and (U.activo=1 ) "; - - using (SqlConnection conn = (SqlConnection)NHibernateHttpModule.CurrentSession.Connection) + WHERE (M.url = @url) AND (U.username = @username) AND (P.permiso = 2) and (U.activo=1 ) "; + + SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SIL_ReadOnly"].ConnectionString); ///Performance: conexion de solo lectura + using (SqlCommand cmd = new SqlCommand(m_strSQL, conn)) { - DataSet Ds = new DataSet(); + cmd.Parameters.AddWithValue("@url", m_url); + cmd.Parameters.AddWithValue("@username", user); - SqlDataAdapter adapter = new SqlDataAdapter(); - adapter.SelectCommand = new SqlCommand(m_strSQL, conn); - adapter.Fill(Ds); + conn.Open(); - DataTable dtPermisos = Ds.Tables[0]; + var result = cmd.ExecuteScalar(); - if (dtPermisos.Rows.Count > 0) b_permiso = true; - conn.Close(); - return b_permiso; + return result != null; } } private void IngresoSistema(Usuario oUser, AuthenticateEventArgs e) - { - - /* Habilitar cuando se quiera autogestion de usuarios medicos - if (oUser == null) - AutenticarUsuarioLdap(Login1.UserName, Login1.Password); - */ + { + if (oUser != null) { + if ((oUser.Activo) && (oUser.IdPerfil.Activo)) { if ((oUser.Activo) && (oUser.Externo)) @@ -341,6 +228,79 @@ private void IngresoSistema(Usuario oUser, AuthenticateEventArgs e) lblMensajeError.Text = Login1.FailureText; Login1.FailureText = ""; //Muestro solo lblMensajeError, ya que Login1.FailureText solo sirve para Login1_Authenticate y no para btn_aceptarTerminosCondiciones_Click } + + private bool VerificarTipoAutenticacion(Usuario oUser) + { /* + Caro: autenticacion diferencias con SIL /ONLOGIN + */ + // Utility oUtil = new Utility(); + bool autentica = false; + + if (oUser != null) + { //verifica el tipo de autenticacion + + string tipoAutenticacion = oUser.TipoAutenticacion.ToUpper().Trim(); + if (tipoAutenticacion == "SIL") + { + + Utility oUtil = new Utility(); + string m_password = oUtil.Encrypt(Login1.Password); + + string query = @" SELECT 1 FROM Sys_usuario + WHERE activo = 1 + AND username = @username + AND [password] = @password"; + + using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SIL_ReadOnly"].ConnectionString)) + using (SqlCommand cmd = new SqlCommand(query, conn)) + { + cmd.Parameters.AddWithValue("@username", Login1.UserName); + cmd.Parameters.AddWithValue("@password", m_password); + + conn.Open(); + var result = cmd.ExecuteScalar(); + + autentica= result != null; + } + } + + else if (tipoAutenticacion == "ONELOGIN") + { + try + { + // Create the new LDAP connection + LdapDirectoryIdentifier ldi = new LdapDirectoryIdentifier("ldap.neuquen.gov.ar", 389); + System.DirectoryServices.Protocols.LdapConnection ldapConnection = + new System.DirectoryServices.Protocols.LdapConnection(ldi); + ldapConnection.AuthType = AuthType.Basic; + ldapConnection.SessionOptions.ProtocolVersion = 3; + NetworkCredential nc = new NetworkCredential("uid=" + Login1.UserName + ",ou=people,O=integrabilidad,O=neuquen", Login1.Password); + ldapConnection.Bind(nc); + ldapConnection.Dispose(); + autentica = true; + + } + catch (LdapException ex) + { + ////"Servicio LDAP no disponible" + autentica = false; + } + catch (Exception ex) + { + autentica = false; + } + } + else //ni sil no onlogin + { + + /// "Tipo de autenticación no soportado."; + autentica = false; + } + } + return autentica; + /*fin Caro: validacion por tipo de autenticacion*/ + } + protected void btn_aceptarTerminosCondiciones_Click(object sender, EventArgs e) { if(Session["usuarioPendienteAceptacion"] == null)