diff --git a/.github/workflows/label02_has_conflicts.yaml b/.github/workflows/label02_has_conflicts.yaml new file mode 100644 index 00000000..5f08c0d3 --- /dev/null +++ b/.github/workflows/label02_has_conflicts.yaml @@ -0,0 +1,84 @@ +name: PR conflict label + +on: + pull_request: + types: [opened, synchronize, reopened] + push: + branches: [master] + +permissions: + pull-requests: write + issues: write + contents: read + +jobs: + conflicts: + runs-on: ubuntu-latest + steps: + - name: Check conflicts + uses: actions/github-script@v7 + with: + script: | + const { owner, repo } = context.repo; + + async function checkPR(pr) { + let data; + let retries = 5; + const issue_number = pr.number; + + while (retries > 0) { + const response = await github.rest.pulls.get({ + owner, + repo, + pull_number: issue_number + }); + data = response.data; + console.log(`PR #${issue_number} - mergeable: ${data.mergeable}, state: ${data.mergeable_state}`); + + // Si mergeable es null, GitHub aún está calculando + if (data.mergeable !== null) break; + + await new Promise(r => setTimeout(r, 5000)); + retries--; + } + + // Usamos mergeable === false para detectar conflictos reales + if (data.mergeable === false) { + console.log(`Adding "Conflictos" label to PR #${issue_number}`); + await github.rest.issues.addLabels({ + owner, + repo, + issue_number, + labels: ['Conflictos'] + }); + } else if (data.mergeable === true) { + console.log(`Removing "Conflictos" label from PR #${issue_number} (if exists)`); + try { + await github.rest.issues.removeLabel({ + owner, + repo, + issue_number, + name: 'Conflictos' + }); + } catch (e) { + // label no existía + } + } + } + + if (context.eventName === 'pull_request') { + await checkPR(context.payload.pull_request); + } + + if (context.eventName === 'push') { + const { data: prs } = await github.rest.pulls.list({ + owner, + repo, + state: 'open', + base: 'master' + }); + + for (const pr of prs) { + await checkPR(pr); + } + } 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/AuditoriaUsuario.cs b/Business/Data/Laboratorio/AuditoriaUsuario.cs index 9ee61111..e72e6451 100644 --- a/Business/Data/Laboratorio/AuditoriaUsuario.cs +++ b/Business/Data/Laboratorio/AuditoriaUsuario.cs @@ -24,7 +24,9 @@ public sealed class AuditoriaUsuario : Business.BaseDataAccess private string m_accion; private string m_username; - private int m_idusuarioregistro; + private int m_idusuarioregistro; + private string m_valorNuevo; + private string m_valorAnterior; #endregion #region Default ( Empty ) Class Constuctor @@ -193,7 +195,29 @@ public bool IsChanged { get { return m_isChanged; } } - - #endregion + public string ValorNuevo + { + get { return m_valorNuevo; } + set + { + if (value != null && value.Length > 500) + throw new ArgumentOutOfRangeException("Invalid value for Valor Nuevo", value, value.ToString()); + + m_isChanged |= (m_valorNuevo != value); m_valorNuevo = value; + } + } + + public string ValorAnterior + { + get { return m_valorAnterior; } + set + { + if (value != null && value.Length > 500) + throw new ArgumentOutOfRangeException("Invalid value for Valor Anterior", value, value.ToString()); + + m_isChanged |= (m_valorAnterior != value); m_valorAnterior = value; + } + } + #endregion } } diff --git a/Business/Data/Laboratorio/AuditoriaUsuario.hbm.xml b/Business/Data/Laboratorio/AuditoriaUsuario.hbm.xml index c14ac5fb..4e1e1b0c 100644 --- a/Business/Data/Laboratorio/AuditoriaUsuario.hbm.xml +++ b/Business/Data/Laboratorio/AuditoriaUsuario.hbm.xml @@ -12,6 +12,7 @@ - + + 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/Business/Data/Usuario.cs b/Business/Data/Usuario.cs index 1982d0a8..e017fcbc 100644 --- a/Business/Data/Usuario.cs +++ b/Business/Data/Usuario.cs @@ -4,6 +4,7 @@ insert license info here using Business.Data.Laboratorio; using System; using System.Collections; +using System.Data.SqlClient; namespace Business.Data { @@ -225,8 +226,9 @@ public string Nombre m_isChanged |= (m_nombre != value); m_nombre = value; } } + - public void GrabaAuditoria(string accion, int iduser, string username) + public void GrabaAuditoria(string accion, int iduser, string username, string valorAnterior="", string valorNuevo="") { AuditoriaUsuario oRegistro = new AuditoriaUsuario(); oRegistro.IdUsuario = iduser; // usuario afectado que esta modificando, consultando , etc. @@ -236,8 +238,10 @@ public void GrabaAuditoria(string accion, int iduser, string username) oRegistro.Hora = DateTime.Now.ToLongTimeString(); oRegistro.IdUsuarioRegistro = this.IdUsuario; //usuario que realiza la accion + oRegistro.ValorAnterior = valorAnterior; + oRegistro.ValorNuevo = valorNuevo; oRegistro.Save(); - + } @@ -474,5 +478,6 @@ public DateTime FechaAceptaTerminosCondiciones { } } + } } 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/Estadisticas/Reporte.aspx.cs b/WebLab/Estadisticas/Reporte.aspx.cs index fd7a9b2c..40b5dc3b 100644 --- a/WebLab/Estadisticas/Reporte.aspx.cs +++ b/WebLab/Estadisticas/Reporte.aspx.cs @@ -201,7 +201,7 @@ private void CalcularPromedio() int prom = 0; - if (Session["Agrupado"].ToString() == "0") columnas = 4; + if (Session["Agrupado"].ToString() == "0") columnas = 6; if (Session["Agrupado"].ToString() == "1") columnas = 2; for (int j=1; j"; 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/AuditoriaUser.cs b/WebLab/Informes/AuditoriaUser.cs new file mode 100644 index 00000000..011b0ace --- /dev/null +++ b/WebLab/Informes/AuditoriaUser.cs @@ -0,0 +1,176 @@ +//------------------------------------------------------------------------------ +// +// 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 { + using System; + using System.ComponentModel; + using CrystalDecisions.Shared; + using CrystalDecisions.ReportSource; + using CrystalDecisions.CrystalReports.Engine; + + + public class AuditoriaUser : ReportClass { + + public AuditoriaUser() { + } + + public override string ResourceName { + get { + return "AuditoriaUser.rpt"; + } + set { + // Do nothing + } + } + + public override bool NewGenerator { + get { + return true; + } + set { + // Do nothing + } + } + + public override string FullResourceName { + get { + return "WebLab.Informes.AuditoriaUser.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 Section3 { + get { + return this.ReportDefinition.Sections[2]; + } + } + + [Browsable(false)] + [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)] + 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.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]; + } + } + } + + [System.Drawing.ToolboxBitmapAttribute(typeof(CrystalDecisions.Shared.ExportOptions), "report.bmp")] + public class CachedAuditoriaUser : Component, ICachedReport { + + public CachedAuditoriaUser() { + } + + [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() { + AuditoriaUser rpt = new AuditoriaUser(); + 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/AuditoriaUser.rpt b/WebLab/Informes/AuditoriaUser.rpt new file mode 100644 index 00000000..1e957ad7 Binary files /dev/null and b/WebLab/Informes/AuditoriaUser.rpt differ 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/Pacientes/PacienteEdit2.aspx.cs b/WebLab/Pacientes/PacienteEdit2.aspx.cs index 7fc1495e..bfb7f930 100644 --- a/WebLab/Pacientes/PacienteEdit2.aspx.cs +++ b/WebLab/Pacientes/PacienteEdit2.aspx.cs @@ -80,13 +80,7 @@ protected void Page_Load(object sender, EventArgs e) { try { - //IntAutenticacion.AutenticacionClient cliente = - // new IntAutenticacion.AutenticacionClient(); - - //TicketUsuario = cliente.LoginPecas(SistemaCliente, PasswordSistemaCliente); - - //if (TicketUsuario != "") - //{ + if (oCon.ConectaRenaper) { 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 b/WebLab/Protocolos/ProtocoloEdit2.aspx index d633a85c..cb97b304 100644 --- a/WebLab/Protocolos/ProtocoloEdit2.aspx +++ b/WebLab/Protocolos/ProtocoloEdit2.aspx @@ -303,15 +303,9 @@ : + - - - - diff --git a/WebLab/Protocolos/ProtocoloEdit2.aspx.cs b/WebLab/Protocolos/ProtocoloEdit2.aspx.cs index e3942200..cc2c6513 100644 --- a/WebLab/Protocolos/ProtocoloEdit2.aspx.cs +++ b/WebLab/Protocolos/ProtocoloEdit2.aspx.cs @@ -1593,6 +1593,7 @@ inner join lab_item P with (nolock) on dp.idsubitem = p.iditem ddlOrigen.SelectedValue = oC.IdOrigenUrgencia.ToString(); //Origen: Guardia ddlSectorServicio.SelectedValue = oC.IdSectorUrgencia.ToString(); // sector de urgencia ddlPrioridad.SelectedValue = "2"; // Prioridad: Urgencia + chkRecordarPractica.Visible = false; } else { @@ -3649,71 +3650,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 +3796,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 +4544,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 +4582,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 +4657,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/ResultadoNoPacienteView.aspx.cs b/WebLab/Resultados/ResultadoNoPacienteView.aspx.cs index 70b78d97..98dbfe20 100644 --- a/WebLab/Resultados/ResultadoNoPacienteView.aspx.cs +++ b/WebLab/Resultados/ResultadoNoPacienteView.aspx.cs @@ -28,9 +28,9 @@ public partial class ResultadoNoPacienteView : System.Web.UI.Page { CrystalReportSource oCr = new CrystalReportSource(); - bool hayAntecedente = false; + Configuracion oCon = new Configuracion(); - DataTable dtProtocolo; + public Usuario oUser = new Usuario(); @@ -85,21 +85,12 @@ protected void Page_Unload(object sender, EventArgs e) } private void Inicializar() { - //CargarGrilla(); + - pnlAntecedentes.Visible = false; - - pnlHC.Visible = true; - //if (Request["validado"].ToString() == "1") - // lblTitulo.Text = "HISTORIAL DE RESULTADOS"; - //else - // lblTitulo.Text = "CONSULTA DE RESULTADOS"; - + pnlAntecedentes.Visible = false; + pnlHC.Visible = true; pnlReferencia.Visible = true; - MuestraDatos(Request["idProtocolo"].ToString()); - - if (Request["desde"] == "Urgencia") hypRegresar.NavigateUrl = "../Urgencia/UrgenciaList.aspx"; else @@ -187,12 +178,7 @@ private void MuestraDatos(string p) oConservacion = (Conservacion)oConservacion.Get(typeof(Conservacion), oRegistro.IdConservacion); lblConservacion.Text = oConservacion.Descripcion; } - //lblServicio.Text = oRegistro.IdTipoServicio.Nombre.ToUpper(); - - - - - //Master.FindControl("ContentPlaceHolder1").FindControl("Panel1").Controls.Add(tContenido); + Control control1 = Master.FindControl("ContentPlaceHolder1").FindControl("Panel1").FindControl("tContenido"); Table tablaContenido = (Table)control1; int cantidadFilas =0; @@ -222,83 +208,14 @@ private void MuestraDatos(string p) lblFecha.Text = oRegistro.Fecha.ToShortDateString(); lblProtocolo.Text = oRegistro.GetNumero().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; - //else - // lblOrigen.Text = oRegistro.IdEfectorSolicitante.Nombre; - - //if ((oRegistro.IdEspecialistaSolicitante > 0) && (oRegistro.IdEfectorSolicitante == oRegistro.IdEfector)) - //{ - // try - // { - // Profesional oMedico = new Profesional(); - // oMedico = (Profesional)oMedico.Get(typeof(Profesional), oRegistro.IdEspecialistaSolicitante); - // if (oMedico != null) - // lblMedico.Text = oMedico.Apellido + " " + oMedico.Nombre; - // } - // catch (Exception ex) - // { - // lblMedico.Text = ""; string exception = ""; - // //while (ex != null) - // //{ - // // exception = ex.Message + "
"; - - // //} - // } - //} - //else - // lblMedico.Text = ""; - //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 != "") lblSector.Text += " Sala: " + oRegistro.Sala; if (oRegistro.Cama != "") lblSector.Text += " Cama: " + oRegistro.Cama; - //HFIdPaciente.Value = oRegistro.IdPaciente.IdPaciente.ToString(); - - ///Datos del Paciente - //if (oRegistro.IdPaciente.IdEstado == 2) lblDni.Text = "(Sin DU Temporal)"; - //else lblDni.Text = oRegistro.IdPaciente.NumeroDocumento.ToString(); - //lblPaciente.Text = oRegistro.IdPaciente.Apellido.ToUpper() + " " + oRegistro.IdPaciente.Nombre.ToUpper(); - //lblSexo.Text = oRegistro.IdPaciente.getSexo(); - //lblFechaNacimiento.Text = oRegistro.IdPaciente.FechaNacimiento.ToShortDateString(); - //lblEdad.Text = oRegistro.Edad.ToString(); - //switch (oRegistro.UnidadEdad) - //{ - // case 0: lblEdad.Text += " años"; break; - // case 1: lblEdad.Text += " meses"; break; - // case 2: lblEdad.Text += " días"; break; - //} lblNumeroOrigen.Text = oRegistro.NumeroOrigen; - - //////////////////////////////////////// - //string embarazada=""; - //ISession m_session = NHibernateHttpModule.CurrentSession; - //ICriteria crit = m_session.CreateCriteria(typeof(ProtocoloDiagnostico)); - //crit.Add(Expression.Eq("IdProtocolo", oRegistro)); - //IList lista = crit.List(); - //if (lista.Count > 0) - //{ - // foreach (ProtocoloDiagnostico oDiag in lista) - // { - // Cie10 oD = new Cie10(); - // oD = (Cie10)oD.Get(typeof(Cie10), oDiag.IdDiagnostico); - // if ( lblDiagnostico.Text=="") lblDiagnostico.Text = oD.Nombre; - // else lblDiagnostico.Text += " - " + oD.Nombre; - // if (oD.Codigo=="Z32.1") embarazada="E"; - - // } - //} - - //lblCodigoPaciente.Text = oRegistro.getCodificaHiv(embarazada); // lblSexo.Text.Substring(0, 1) + oRegistro.IdPaciente.Nombre.Substring(0, 2) + oRegistro.IdPaciente.Apellido.Substring(0, 2) + lblFechaNacimiento.Text.Replace("/", "") + embarazada; lblPedidoOriginal.Text = oRegistro.GetPracticasPedidas(); @@ -324,11 +241,7 @@ private void LlenarTabla(string p) da.Fill(Ds); - - //int cantidadResultadosValidados = Ds.Tables[0].Rows.Count; - //if (cantidadResultadosValidados > 0) - - //{ + string s = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator; @@ -391,31 +304,15 @@ private void LlenarTabla(string p) objCellValida_TITULO.Controls.Add(lblValida); Label lblCargadoPor = new Label(); - if ((Request["Operacion"].ToString() == "HC") && (Request["validado"].ToString() == "1")) - { - lblCargadoPor.Text = "VALIDADO POR"; - // Panel1.ScrollBars = ScrollBars.None; - } + if ((Request["Operacion"].ToString() == "HC") && (Request["validado"].ToString() == "1")) + lblCargadoPor.Text = "VALIDADO POR"; 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); @@ -432,6 +329,34 @@ 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 for (int i = 0; i < Ds.Tables[0].Rows.Count; i++) { //decimal m_minimoReferencia=-1; @@ -465,12 +390,7 @@ private void LlenarTabla(string p) string m_estadoObservacion = Ds.Tables[0].Rows[i].ItemArray[29].ToString(); string m_area = 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[1].ToString(); m_titulo = Ds.Tables[0].Rows[i].ItemArray[0].ToString(); @@ -494,24 +414,20 @@ private void LlenarTabla(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"; + tContenido.Controls.Add(objRow); pivot_Area = m_area; @@ -539,10 +455,16 @@ private void LlenarTabla(string p) tContenido.Controls.Add(objRow); m_nombre = m_titulo; + if (m_trajoMuestra == "No") + { + Label lblSinMuestra = new Label(); + 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.Controls.Add(lblSinMuestra); + } } - - - Label lbl1 = new Label(); if (m_hijo == m_titulo) lbl1.Text = m_hijo; else lbl1.Text = "   " + m_hijo; @@ -562,60 +484,27 @@ private void LlenarTabla(string p) objCellAnalisis.Controls.Add(lbl1); - Item oItem = new Item(); - oItem = (Item)oItem.Get(typeof(Item), m_idItem); - - //DetalleProtocolo oDetalle = new DetalleProtocolo(); - //oDetalle = (DetalleProtocolo)oDetalle.Get(typeof(DetalleProtocolo), i_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); - // bool es_Bacteriologia = false; - string observacionesDetalle = ""; + ///Antes de mostrar el control verifica si está derivado - if (oItem.IdEfectorDerivacion != oItem.IdEfector) //es derivado + if (oDeriva != null) /// esta pendiente { Label lblDerivacion = new Label(); lblDerivacion.Font.Italic = true; - lblDerivacion.TabIndex = short.Parse("500"); - //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; - - 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 = "Derivado: " + oItem.IdEfectorDerivacion.Nombre; - //if (oDeriva.Estado == 2) /// no enviado - // estadoDerivacion = " No Derivado. " + oDeriva.Observacion; - - lblDerivacion.Font.Bold = true; - estadoDerivacion = oDetalle.ResultadoCar; //Para todos los estados - if (oDeriva.Resultado != "") - estadoDerivacion += " - Resultado Informado: " + oDeriva.Resultado; - - } - - } - lblDerivacion.Text = estadoDerivacion; - + lblDerivacion.TabIndex = short.Parse("500"); + string estadoDerivacion = ""; + estadoDerivacion = oDetalle.ResultadoCar; + if (oDeriva.Resultado != "") + estadoDerivacion += " - Resultado Informado: " + oDeriva.Resultado; + lblDerivacion.Text = estadoDerivacion; objCellResultado.ColumnSpan = 1; objCellResultado.Controls.Add(lblDerivacion); } @@ -658,13 +547,10 @@ private void LlenarTabla(string p) else olbl.Text = x.ToString(System.Globalization.CultureInfo.InvariantCulture) + " " + unMedida; - if (i_iddetalleProtocolo != 0) + if (oDetalle != null) { - if (i_iddetalleProtocolo != 9999999) - { - DetalleProtocolo oDetalle = new DetalleProtocolo(); - oDetalle = (DetalleProtocolo)oDetalle.Get(typeof(DetalleProtocolo), i_iddetalleProtocolo); - + + m_usuariovalida += " " + oDetalle.FechaValida.ToShortDateString(); if (Observaciones != "") { if (m_conResultado == "False") @@ -674,7 +560,10 @@ private void LlenarTabla(string p) { Usuario oUser = new Usuario(); oUser = (Usuario)oUser.Get(typeof(Usuario), oDetalle.IdUsuarioValidaObservacion); - if (oUser.FirmaValidacion == "") m_usuariovalida = oUser.Apellido + " " + oUser.Nombre; else m_usuariovalida = oUser.FirmaValidacion; + if (oUser.FirmaValidacion == "") m_usuariovalida = oUser.Apellido + " " + oUser.Nombre; + else m_usuariovalida = oUser.FirmaValidacion; + + m_usuariovalida +=" " + oDetalle.FechaValida.ToShortDateString(); } } else @@ -684,31 +573,26 @@ private void LlenarTabla(string p) if (oDetalle.IdProtocolo.IdTipoServicio.IdTipoServicio!=5) { - string resultadoAnterior = oDetalle.BuscarResultadoAnterior(oDetalle.IdSubItem, oDetalle.IdItem, false); - 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,440); return false"); - olblResultadoAnterior.ToolTip = "Haga clic aqui para ver gráfico de evolución"; - //olblResultadoAnterior.ForeColor = Color.Green; - olblResultadoAnterior.Width = Unit.Pixel(20); - olblResultadoAnterior.Text = resultadoAnterior; + string resultadoAnterior = oDetalle.BuscarResultadoAnterior(oDetalle.IdSubItem, oDetalle.IdItem, false); + 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,440); return false"); + olblResultadoAnterior.ToolTip = "Haga clic aqui para ver gráfico de evolución"; + olblResultadoAnterior.Width = Unit.Pixel(20); + olblResultadoAnterior.Text = resultadoAnterior; - objCellResultadoAnterior.Controls.Add(olblResultadoAnterior); + 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 @@ -721,48 +605,28 @@ private void LlenarTabla(string p) lblValorCritico.TabIndex = short.Parse("500"); lblValorCritico.Text = " VALOR CRITICO"; lblValorCritico.Font.Bold = true; - lblValorCritico.ForeColor = Color.OrangeRed; - // objCellResultado.ColumnSpan = 5; + lblValorCritico.ForeColor = Color.OrangeRed; - } - - ///IMAGENES ADJUNTAS - - - + } if (oDetalle.tieneAdjuntoVisible())//tiene observaciones { 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"); - } else - btnImagen.Visible = false; - - // fin de imagenes adjuntas - } + btnImagen.Visible = false; } objCellResultado.Controls.Add(olbl); objCellResultado.Controls.Add(btnImagen); ///etiqueta de unidad de medida Label olblUM = new Label(); - - - // olblUM.ID = "UM" + m_idItem.ToString(); olblUM.Font.Size = FontUnit.Point(7); - olblUM.Text = unMedida; - - - - + olblUM.Text = unMedida; objCellResultado.Controls.Add(olblUM); olblUM.Visible = false; @@ -791,33 +655,25 @@ private void LlenarTabla(string p) } objCellResultado.Controls.Add(olbl); - if ((i_iddetalleProtocolo != 0) ) + if (oDetalle != null) { - 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); if (resultadoAnterior != "") { - hayAntecedente = true; + // hayAntecedente = true; Label olblResultadoAnterior = new Label(); olblResultadoAnterior.TabIndex = short.Parse("500"); - olblResultadoAnterior.Font.Size = FontUnit.Point(8); - //olblResultadoAnterior.CssClass = "myLink"; + olblResultadoAnterior.Font.Size = FontUnit.Point(8); olblResultadoAnterior.Attributes.Add("onClick", "javascript: AntecedenteView (" + oDetalle.IdSubItem.IdItem.ToString() + "," + oDetalle.IdProtocolo.IdPaciente.IdPaciente.ToString() + ",790,300); return false"); - olblResultadoAnterior.ToolTip = "Haga clic aqui para ver más datos."; - //olblResultadoAnterior.ForeColor = Color.Green; + olblResultadoAnterior.ToolTip = "Haga clic aqui para ver más datos."; olblResultadoAnterior.Width = Unit.Pixel(20); 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); + } } @@ -835,47 +691,31 @@ private void LlenarTabla(string p) objCellResultado.Controls.Add(btnImagen); } } - } + } // fin case 1 break; - - }//fin swicth - - 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(); - - - - /// 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); } @@ -885,27 +725,19 @@ private void LlenarTabla(string p) ///Definir los anchos de las columnas objCellAnalisis.Width = Unit.Percentage(30); objCellResultado.Width = Unit.Percentage(30); - objCellValoresReferencia.Width = Unit.Percentage(20); - // objCellValida.Width = Unit.Percentage(5); + objCellValoresReferencia.Width = Unit.Percentage(20); objCellPersona.Width = Unit.Percentage(20); - - - /////////////////////// ///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); + objFila.Cells.Add(objCellResultado); - //if ((Request["Operacion"].ToString() == "Valida") || (Request["Operacion"].ToString() == "Control")) objFila.Cells.Add(objCellValida); + 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); @@ -1076,48 +908,7 @@ private void Imprimir(Protocolo oProtocolo, string tipo) } - //protected void gvLista_RowCommand(object sender, GridViewCommandEventArgs e) - //{ - // if (e.CommandName == "Ingresar") - // { - // dtProtocolo = (System.Data.DataTable)(Session["Tabla1"]); - // if (dtProtocolo != null) - // { - // for (int i = 0; i < dtProtocolo.Rows.Count; i++) - // { - // // dtProtocolo.Rows[i].Delete(); - // if (dtProtocolo.Rows[i][0].ToString() == e.CommandArgument.ToString()) CurrentIndexGrilla = i; - // } - // CurrentPageIndex = int.Parse( e.CommandArgument.ToString()); - // Response.Redirect("ResultadoView.aspx?idServicio=" + Request["idServicio"].ToString() + "&Operacion=" + Request["Operacion"].ToString() + "&idProtocolo=" + e.CommandArgument + "&Index=" + CurrentIndexGrilla + "&idArea=" + Request["idArea"].ToString() + "&validado=" + Request["validado"].ToString() + "&modo=" + Request["modo"].ToString(), false); - // } - // else - // Response.Redirect("../FinSesion.aspx", false); - // } - - //} - - //protected void gvLista_RowDataBound(object sender, GridViewRowEventArgs e) - //{ - // if (e.Row.RowType == DataControlRowType.DataRow) - // { - // ImageButton CmdModificar = (ImageButton)e.Row.Cells[2].Controls[1]; - // CmdModificar.CommandArgument = gvLista.DataKeys[e.Row.RowIndex].Value.ToString(); - // CmdModificar.CommandName = "Ingresar"; - - - // string idProtocolo= this.gvLista.DataKeys[e.Row.RowIndex].Value.ToString(); - // string s_detalle = e.Row.Cells[0].Text + ": " + getDetalleProtocolo(idProtocolo); - - // e.Row.Cells[0].ToolTip = s_detalle; - // e.Row.Cells[1].ToolTip = s_detalle; - - // CmdModificar.ToolTip = s_detalle; - // } - - - //} - + protected void cvValidaControles_ServerValidate(object source, ServerValidateEventArgs args) { //if ( (ValidaControlesSuperior()) && (ValidaControlesInferior()) ) @@ -1153,65 +944,7 @@ private bool estaVisibleControl(string idarea) - protected void btnSiguiente_Click(object sender, EventArgs e) - { - - } - - //private void Avanzar(int avance) - //{ - // //try - // //{ - - // if (Session["Tabla1"] != null) - // { - // if (CurrentIndexGrilla <= UltimaPageIndex) - // { - // if (avance == 1) - // { - // if (CurrentIndexGrilla < UltimaPageIndex) CurrentIndexGrilla += 1; //avanza - // } - // else //retrocede - // CurrentIndexGrilla = CurrentIndexGrilla - 1; //retrocede - - // if (CurrentIndexGrilla > -1) - // { - // dtProtocolo = (System.Data.DataTable)(Session["Tabla1"]); - // CurrentPageIndex = int.Parse(dtProtocolo.Rows[CurrentIndexGrilla][0].ToString()); - - // Response.Redirect("ResultadoView.aspx?idServicio=" + Request["idServicio"].ToString() + "&Operacion=" + Request["Operacion"].ToString() + "&idProtocolo=" + CurrentPageIndex + "&Index=" + CurrentIndexGrilla + "&idArea=" + Request["idArea"].ToString() + "&validado=" + Request["validado"].ToString() + "&modo=" + Request["modo"].ToString(), false); - // } - // } - // else - // if (Request["Operacion"].ToString() == "HC") - // Response.Redirect("../Informes/HistoriaClinicaFiltro.aspx?Tipo=Paciente", false); - // else - // Response.Redirect("ResultadoBusqueda.aspx?idServicio=" + Request["idServicio"].ToString() + "&Operacion=" + Request["Operacion"].ToString() + "&modo=" + Request["modo"].ToString(), false); - - // } - // else Response.Redirect("../FinSesion.aspx", false); - - - - //} - - protected void lnkPosterior_Click(object sender, EventArgs e) - { - //Avanzar(1); - } - - protected void lnkAnterior_Click(object sender, EventArgs e) - { - //Avanzar(-1); - } - - - protected void lnkAuditoria_Click(object sender, EventArgs e) - { - - } - - + protected void imgPdf_Click(object sender, ImageClickEventArgs e) { @@ -1226,75 +959,7 @@ protected void imgPdf_Click(object sender, ImageClickEventArgs 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") @@ -1330,34 +995,7 @@ 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; - } - protected void btnArchivos_Click(object sender, EventArgs e) - { - Response.Redirect("../Protocolos/ProtocoloAdjuntar.aspx?idProtocolo=" + Request["idProtocolo"].ToString() + "&desde=resultado"); - } + protected void imgPdf_Click1(object sender, EventArgs e) { if (Session["idUsuario"] != null) 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/Site1.Master b/WebLab/Site1.Master index 0b042a64..8ab1782a 100644 --- a/WebLab/Site1.Master +++ b/WebLab/Site1.Master @@ -222,7 +222,7 @@ document.onkeydown=checkKeyCode; font-weight: normal; font-size: 14px; font-family: Arial; - text-align:center;">Versión MultiEfector Abril 2026-22." target="_blank" >Ver Cambios Version

+ text-align:center;">Versión MultiEfector Mayo 2026-11." target="_blank" >Ver Cambios Version

diff --git a/WebLab/SiteTurnos.Master b/WebLab/SiteTurnos.Master index b5002364..3a4ee6a7 100644 --- a/WebLab/SiteTurnos.Master +++ b/WebLab/SiteTurnos.Master @@ -222,7 +222,7 @@ document.onkeydown=checkKeyCode; font-weight: normal; font-size: 14px; font-family: Arial; - text-align:center;">Versión MultiEfector Abril 2026-22." target="_blank" >Ver Cambios Version

+ text-align:center;">Versión MultiEfector Mayo 2026-11." target="_blank" >Ver Cambios Version

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..1461ef87 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 A.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..94ce4b1a 100644 --- a/WebLab/Turnos/TurnosEdit2.aspx.cs +++ b/WebLab/Turnos/TurnosEdit2.aspx.cs @@ -500,14 +500,13 @@ 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"; - oUtil.CargarCombo(ddlSectorServicio, m_ssql, "idSectorServicio", "nombre"); - ddlSectorServicio.Items.Insert(0, new ListItem("-SIN IDENTIFICAR-", "0")); - + //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")); - //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")); + 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() + ")) "; //Carga del combo de determinaciones string s_idEfector = oUser.IdEfector.IdEfector.ToString(); @@ -517,6 +516,20 @@ private void CargarListas() s_idEfector = oUser.IdEfectorDestino.IdEfector.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="+ s_idEfector + @" )" + str_condicion + @" order by nombre"; + + oUtil.CargarCombo(ddlSectorServicio, m_ssql, "idSectorServicio", "nombre"); + ddlSectorServicio.Items.Insert(0, new ListItem("Seleccione", "0")); + + + //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")); + + + m_ssql = @"SELECT I.idItem as idItem, I.codigo as codigo, I.nombre as nombre, I.nombre + ' - ' + I.codigo as nombreLargo FROM Lab_item I with (nolock) inner join lab_ItemEfector as IE with (nolock) on IE.idItem= I.iditem and IE.idEfector= " + s_idEfector +//MultiEfector 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/Usuarios/PasswordEdit2.aspx.cs b/WebLab/Usuarios/PasswordEdit2.aspx.cs index 9182eaed..3c7c4a5c 100644 --- a/WebLab/Usuarios/PasswordEdit2.aspx.cs +++ b/WebLab/Usuarios/PasswordEdit2.aspx.cs @@ -139,7 +139,7 @@ protected void btnContinuar_Click(object sender, EventArgs e) { Usuario oRegistro = new Usuario(); oRegistro = (Usuario)oRegistro.Get(typeof(Usuario), int.Parse(Session["idUsuario"].ToString())); - if (oRegistro.Externo) + if (oRegistro.Externo) Response.Redirect("~/Consulta/Historiaclinicafiltro.aspx", false); else diff --git a/WebLab/Usuarios/UsuarioEdit.aspx b/WebLab/Usuarios/UsuarioEdit.aspx index 7c745b4c..1a892ea0 100644 --- a/WebLab/Usuarios/UsuarioEdit.aspx +++ b/WebLab/Usuarios/UsuarioEdit.aspx @@ -204,7 +204,7 @@ +
- Contraseña: diff --git a/WebLab/Usuarios/UsuarioEdit.aspx.cs b/WebLab/Usuarios/UsuarioEdit.aspx.cs index 83c732a3..3f09ffc4 100644 --- a/WebLab/Usuarios/UsuarioEdit.aspx.cs +++ b/WebLab/Usuarios/UsuarioEdit.aspx.cs @@ -34,25 +34,42 @@ public partial class UsuarioEdit : System.Web.UI.Page protected void Page_PreInit(object sender, EventArgs e) { - oCr.CacheDuration = 0; - oCr.EnableCaching = false; - oC = (Configuracion)oC.Get(typeof(Configuracion), 1); // "IdEfector", oUser.IdEfector); + if (Session["idUsuario"] != null) + { + oCr.CacheDuration = 0; + oCr.EnableCaching = false; + oC = (Configuracion)oC.Get(typeof(Configuracion), 1); // "IdEfector", oUser.IdEfector); + } + else Response.Redirect("../FinSesion.aspx", false); } protected void Page_Load(object sender, EventArgs e) { - if (!Page.IsPostBack) - { - if (Session["idUsuario"] != null) + if (Session["idUsuario"] != null) + { + if (!Page.IsPostBack) { VerificaPermisos("Usuarios"); CargarListas(); if (Request["id"] != null) MostrarDatos(); else + { MostrarEfectores(); - + btnAuditoria.Visible = false; + } + } - else Response.Redirect("../FinSesion.aspx", false); + } + else Response.Redirect("../FinSesion.aspx", false); + + } + + protected void Page_Unload(object sender, EventArgs e) + { + if (this.oCr.ReportDocument != null) + { + this.oCr.ReportDocument.Close(); + this.oCr.ReportDocument.Dispose(); } } @@ -87,14 +104,6 @@ private void CargarListas() m_ssql = @" SELECT idArea, nombre FROM LAB_Area (nolock) where baja=0 ORDER BY nombre "; oUtil.CargarCombo(ddlArea, m_ssql, "idArea", "nombre"); ddlArea.Items.Insert(0, new ListItem("Todas", "0")); - - if (ConfigurationManager.AppSettings["tipoAutenticacion"].ToString() == "SSO") - { - chkRequiereContrasenia.Checked = false; - chkRequiereContrasenia.Visible = false; - } - - } #region Datos Generales @@ -108,7 +117,10 @@ private void MostrarDatos() //txtMatricula.Text = oRegistro.Matricula; txtUsername.Text = oRegistro.Username; chkRequiereContrasenia.Checked = oRegistro.RequiereCambioPass; + //En modificacion no se puede editar contraseña, la ocultamos: txtPassword.Enabled = false; + txtPassword.Visible = false; + lblPassword.Visible = false; chkActivo.Checked = oRegistro.Activo; ddlPerfil.SelectedValue = oRegistro.IdPerfil.IdPerfil.ToString(); //ddlEfector.SelectedValue = oRegistro.IdEfector.IdEfector.ToString(); @@ -130,7 +142,7 @@ private void MostrarDatos() habilitarAdministrador(); Usuario oAuditor = new Usuario(); oAuditor = (Usuario)oAuditor.Get(typeof(Usuario), int.Parse(Session["idUsuario"].ToString())); - oAuditor.GrabaAuditoria("Consulta", oRegistro.IdUsuario, oRegistro.Username); + ViewState["idAuditoriaConsulta"] = oAuditor.GrabaAuditoria("Consulta", oRegistro.IdUsuario, oRegistro.Username); MostrarEfectores(); ddlTipoAutenticacion.SelectedValue = oRegistro.TipoAutenticacion.Trim(); @@ -149,6 +161,7 @@ private void habilitarAdministrador() lblMensajeEfector.Visible = false; lblMensajeEfector.UpdateAfterCallBack = true; ddlEfector3.ClearSelection(); agregarEfectorAdmin(); + ddlPerfil_SelectedIndexChanged(null,null); //si antes era Admin externo queda visible } else @@ -156,6 +169,7 @@ private void habilitarAdministrador() ddlArea.Enabled = true; ddlPerfil.Enabled = true; btnAgregarEfector.Enabled = true; + ddlPerfil_SelectedIndexChanged(null, null); } ddlArea.UpdateAfterCallBack = true; @@ -181,11 +195,8 @@ private void agregarEfectorAdmin() private void Guardar(Usuario oRegistro) { - string accion = "Crea"; - if (Request["id"] != null) //oRegistro nunca es null - accion = "Modifica"; - - + guardarAuditoria(oRegistro); + Perfil oPerfil = new Perfil(); oPerfil = (Perfil)oPerfil.Get(typeof(Perfil), int.Parse(ddlPerfil.SelectedValue)); @@ -200,13 +211,10 @@ private void Guardar(Usuario oRegistro) else oEfectorDestino = oEfector; - - oRegistro.IdEfector = oEfector; oRegistro.IdEfectorDestino = oEfectorDestino; oRegistro.IdPerfil = oPerfil; oRegistro.IdArea = int.Parse(ddlArea.SelectedValue); - oRegistro.Apellido = txtApellido.Text; oRegistro.Nombre = txtNombre.Text; oRegistro.Legajo = ""; @@ -214,7 +222,6 @@ private void Guardar(Usuario oRegistro) //oRegistro.Matricula=txtMatricula.Text; oRegistro.Administrador = chkAdministrador.Checked; oRegistro.Username = txtUsername.Text; - oRegistro.Email = email.Value; oRegistro.Telefono = txtTelefono.Text; @@ -232,39 +239,14 @@ private void Guardar(Usuario oRegistro) oRegistro.Password = m_password; } - - - if (Request["id"] != null) //oRegistro nunca es null - { - if ((oRegistro.Activo == true) && (chkActivo.Checked == false)) - accion = "Inhabilita"; - if ((oRegistro.Activo == false) && (chkActivo.Checked == true)) - accion = "Habilita"; - - if (oRegistro.IdPerfil != oPerfil) - accion = "Cambia Perfil"; - - if (oRegistro.TipoAutenticacion.Trim() != ddlTipoAutenticacion.SelectedValue) - accion = "Cambia Autenticacion: " + ddlTipoAutenticacion.SelectedValue.Trim(); - - } - oRegistro.Activo = chkActivo.Checked; oRegistro.Externo = chkExterno.Checked; oRegistro.RequiereCambioPass = chkRequiereContrasenia.Checked; oRegistro.IdUsuarioActualizacion = int.Parse(Session["idUsuario"].ToString()); oRegistro.FechaActualizacion = DateTime.Now; - - oRegistro.TipoAutenticacion = ddlTipoAutenticacion.SelectedValue; oRegistro.Save(); - - Usuario oAuditor = new Usuario(); - oAuditor = (Usuario)oAuditor.Get(typeof(Usuario), int.Parse(Session["idUsuario"].ToString())); - - oAuditor.GrabaAuditoria(accion, oRegistro.IdUsuario, oRegistro.Username); - if (Request["id"] == null) //en el alta se guardan los efectores luego de crear el usuario //en modificacion no los guardamos desde aca, ya que se guardan en el evento "Agregar Efector" GuardarEfectores(oRegistro); @@ -294,10 +276,6 @@ protected void btnGuardar_Click1(object sender, EventArgs e) Guardar(oRegistro); - //if (Request["id"] != null) - // Response.Redirect("UsuarioList.aspx", false); - //else - // Response.Redirect("UsuarioEdit.aspx", false); string parametros = this.parametros(); Response.Redirect("UsuarioList.aspx?" + parametros, false); } @@ -361,7 +339,7 @@ protected void btnAuditoria_Click(object sender, EventArgs e) encabezado3.Value = "Auditoria de Usuario"; - oCr.Report.FileName = "../Informes/AuditoriaProtocolo.rpt"; + oCr.Report.FileName = "../Informes/AuditoriaUser.rpt"; oCr.ReportDocument.SetDataSource(dtAuditoria); oCr.ReportDocument.ParameterFields[0].CurrentValues.Add(encabezado1); oCr.ReportDocument.ParameterFields[1].CurrentValues.Add(encabezado2); @@ -378,7 +356,7 @@ protected void btnAuditoria_Click(object sender, EventArgs e) } else { - string popupScript = ""; + string popupScript = ""; Page.RegisterStartupScript("PopupScript", popupScript); } } @@ -388,21 +366,26 @@ private DataTable GetDataSetAuditoria() { string m_strSQL = ""; - string m_strCondicion = ""; - SqlConnection conn = (SqlConnection)NHibernateHttpModule.CurrentSession.Connection; SqlDataAdapter adapter = new SqlDataAdapter(); - //if (!oUser.Administrador) - //{ - // m_strCondicion = " and P.idefector=" + oUser.IdEfector.IdEfector.ToString(); - //} - - - m_strSQL = @" SELECT A.username AS numero, P.apellido as username, A.fecha AS fecha, A.hora, A.accion, '' as analisis, '' as valor, '' as valorAnterior - FROM LAB_Auditoriausuario AS A (nolock) - inner join sys_usuario P (nolock) on P.idusuario= A.idusuarioregistro - where A.idusuario= " + Request["id"].ToString() + @" ORDER BY A.idAuditoriausuario"; + //Agregamos la auditoria de aceptacion de terminos y condiciones + + m_strSQL = @" SELECT U.username + ' - '+ U.apellido + ' ' + U.nombre as numero , + P.nombre + ' ' + P.apellido as username,A.fecha AS fecha, A.accion, + isnull(valorNuevo,'') as valor, isnull(valorAnterior,'') as valorAnterior + FROM LAB_Auditoriausuario AS A (nolock) + inner join sys_usuario P (nolock) on P.idusuario= A.idusuarioregistro + inner join Sys_Usuario U (nolock) on U.idusuario= A.idUsuario + where A.idusuario= " + Request["id"].ToString() + + @" union + SELECT U.username + ' - '+ U.apellido + ' ' + U.nombre as numero, + P.nombre + ' ' + P.apellido as username, L.fecha AS fecha, + 'Acepto Terminos y Condiciones', '' as valor, '' as valorAnterior + FROM LAB_LogAccesoTerminosCondiciones AS L (nolock) + inner join sys_usuario P (nolock) on P.idusuario= L.idUsuario + inner join Sys_Usuario U (nolock) on U.idusuario= P.idUsuario + where P.idusuario=" + Request["id"].ToString() + " ORDER BY fecha desc"; DataSet Ds1 = new DataSet(); adapter.SelectCommand = new SqlCommand(m_strSQL, conn); @@ -435,7 +418,7 @@ protected void btnBlanquear_Click(object sender, EventArgs e) protected void customValidacionGeneral_ServerValidate(object source, ServerValidateEventArgs args) { - if (Request["id"] == null) // alta + //if (Request["id"] == null) // Validar tambien en modificacion { Usuario oRegistro = new Usuario(); @@ -443,7 +426,9 @@ protected void customValidacionGeneral_ServerValidate(object source, ServerValid oRegistro = (Usuario)oRegistro.Get(typeof(Usuario), "Username", txtUsername.Text.Trim()); if (oRegistro != null) { - args.IsValid = false; + if (Request["id"] != null) + if (oRegistro.IdUsuario != int.Parse(Request["id"])) //que no compare el username del que estoy modificando + args.IsValid = false; return; @@ -542,12 +527,13 @@ private void habilitarPorAutenticacion() //Por defecto la contraseña es el username txtPassword.Enabled = false; rfvPassword.Enabled = false; + btnBlanquear.Visible = false; } else { chkRequiereContrasenia.Enabled = true; chkExterno.Enabled = true; - + btnBlanquear.Visible = true; //Se puede poner una contraseña if (Request["id"] == null){ txtPassword.Enabled = true; rfvPassword.Enabled = true; } else @@ -584,6 +570,76 @@ protected void customValidatorEfector_ServerValidate(object source, ServerValida } } + private void guardarAuditoria(Usuario oRegistro) + { + Usuario oAuditor = new Usuario(); + oAuditor = (Usuario)oAuditor.Get(typeof(Usuario), int.Parse(Session["idUsuario"].ToString())); + + if (Request["id"] == null) + { + oAuditor.GrabaAuditoria("Crea", oRegistro.IdUsuario, oRegistro.Username); + } + else //Auditoria cambio de valores del usuario + { + + if (oRegistro.Nombre != txtNombre.Text) + { oAuditor.GrabaAuditoria("Modifica Nombre", oRegistro.IdUsuario, oRegistro.Username, oRegistro.Nombre, txtNombre.Text); } + + if (oRegistro.Apellido != txtApellido.Text) + { oAuditor.GrabaAuditoria("Modifica Apellido", oRegistro.IdUsuario, oRegistro.Username, oRegistro.Apellido, txtApellido.Text); } + + + if (oRegistro.FirmaValidacion != txtFirmaValidacion.Text) + { oAuditor.GrabaAuditoria("Modifica Firma Validacion", oRegistro.IdUsuario, oRegistro.Username, oRegistro.FirmaValidacion, txtFirmaValidacion.Text); } + + if (oRegistro.Email != email.Value.ToString()) + { oAuditor.GrabaAuditoria("Modifica Email", oRegistro.IdUsuario, oRegistro.Username, oRegistro.Email, email.Value); } + + if (oRegistro.Telefono != txtTelefono.Text) + { oAuditor.GrabaAuditoria("Modifica Telefono", oRegistro.IdUsuario, oRegistro.Username, oRegistro.Telefono, txtTelefono.Text); } + + if (oRegistro.TipoAutenticacion.Trim() != ddlTipoAutenticacion.SelectedValue) + { oAuditor.GrabaAuditoria("Modifica Tipo Autenticacion", oRegistro.IdUsuario, oRegistro.Username, oRegistro.TipoAutenticacion, ddlTipoAutenticacion.SelectedValue); } + + if (oRegistro.Username != txtUsername.Text) + { oAuditor.GrabaAuditoria("Modifica Username", oRegistro.IdUsuario, oRegistro.Username, oRegistro.Username, txtUsername.Text); } + + if (oRegistro.Administrador != chkAdministrador.Checked) + { oAuditor.GrabaAuditoria("Modifica Administrador", oRegistro.IdUsuario, oRegistro.Username, oRegistro.Administrador ? "Si" : "No", chkAdministrador.Checked ? "Si" : "No"); } + + if (oRegistro.IdArea.ToString() != ddlArea.SelectedValue) + { + string nombreArea = ""; + if (oRegistro.IdArea != 0) + { + Area oArea = new Area(); + oArea = (Area)oArea.Get(typeof(Area), oRegistro.IdArea); + nombreArea = oArea.Nombre; + } + else nombreArea = "Todas"; + + oAuditor.GrabaAuditoria("Modifica Area", oRegistro.IdUsuario, oRegistro.Username, nombreArea, ddlArea.SelectedItem.Text); + + + } + + if (oRegistro.IdPerfil.IdPerfil.ToString() != ddlPerfil.SelectedValue) + { oAuditor.GrabaAuditoria("Modifica Perfil", oRegistro.IdUsuario, oRegistro.Username, oRegistro.IdPerfil.Nombre, ddlPerfil.SelectedItem.Text); } + + if (ddlEfectorDestino.SelectedValue != "" && oRegistro.IdEfectorDestino.IdEfector.ToString() != ddlEfectorDestino.SelectedValue) + { oAuditor.GrabaAuditoria("Modifica Laboratorio Destino", oRegistro.IdUsuario, oRegistro.Username, oRegistro.IdEfectorDestino.Nombre, ddlEfectorDestino.SelectedItem.Text); } + + if (oRegistro.Activo != chkActivo.Checked) + { oAuditor.GrabaAuditoria("Modifica Activo", oRegistro.IdUsuario, oRegistro.Username, oRegistro.Activo ? "Si" : "No", chkActivo.Checked ? "Si" : "No"); } + + if (oRegistro.Externo != chkExterno.Checked) + { oAuditor.GrabaAuditoria("Modifica Externo", oRegistro.IdUsuario, oRegistro.Username, oRegistro.Externo ? "Si" : "No", chkExterno.Checked ? "Si" : "No"); } + + if (oRegistro.RequiereCambioPass != chkRequiereContrasenia.Checked) + { oAuditor.GrabaAuditoria("Modifica Requiere Contraseña", oRegistro.IdUsuario, oRegistro.Username, oRegistro.RequiereCambioPass ? "Si" : "No", chkRequiereContrasenia.Checked ? "Si" : "No"); } + + } + } #endregion #region Efectores diff --git a/WebLab/Usuarios/UsuarioEdit.aspx.designer.cs b/WebLab/Usuarios/UsuarioEdit.aspx.designer.cs index d8c0b814..fcde6f90 100644 --- a/WebLab/Usuarios/UsuarioEdit.aspx.designer.cs +++ b/WebLab/Usuarios/UsuarioEdit.aspx.designer.cs @@ -140,6 +140,15 @@ public partial class UsuarioEdit /// protected global::System.Web.UI.WebControls.CustomValidator customValidacionGeneral1; + /// + /// Control lblPassword. + /// + /// + /// 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 lblPassword; + /// /// Control txtPassword. /// diff --git a/WebLab/Usuarios/UsuarioList.aspx.cs b/WebLab/Usuarios/UsuarioList.aspx.cs index 1ca5239f..2a796ad7 100644 --- a/WebLab/Usuarios/UsuarioList.aspx.cs +++ b/WebLab/Usuarios/UsuarioList.aspx.cs @@ -118,9 +118,38 @@ private void CargarListas() oUtil.CargarCombo(ddlEfector, m_ssql, "idEfector", "nombre"); if (nivelcentral) - ddlEfector.Items.Insert(0, new ListItem("Todos", "0")); + ddlEfector.Items.Insert(0, new ListItem("--Seleccione un efector--", "0")); - m_ssql = @"SELECT idPerfil, nombre FROM Sys_Perfil with (nolock) ORDER BY nombre"; + if (nivelcentral) + m_ssql = @"SELECT idPerfil, nombre FROM Sys_Perfil with (nolock) ORDER BY nombre"; + else + m_ssql = @"SELECT DISTINCT + U.idPerfil, + P.nombre + FROM Sys_Usuario U + INNER JOIN Sys_Perfil P ON P.idPerfil = U.idPerfil + WHERE U.idUsuario IN ( + SELECT idUsuario + FROM Sys_UsuarioEfector + WHERE idEfector = " + oUser.IdEfector.IdEfector.ToString() + @" + ) + UNION + + SELECT + P.idPerfil, + P.nombre + FROM Sys_Perfil P WITH (NOLOCK) + WHERE P.idPerfil = 15 + AND EXISTS ( + SELECT 1 + FROM Sys_Usuario U WITH (NOLOCK) + WHERE U.idEfector <> " + oUser.IdEfector.IdEfector.ToString() + @" + AND U.idEfectorDestino = " + oUser.IdEfector.IdEfector.ToString() + @" + AND U.activo = 1 + AND U.idPerfil = 15 + ) + + ORDER BY P.nombre"; oUtil.CargarCombo(ddlPerfil, m_ssql, "idPerfil", "nombre"); ddlPerfil.Items.Insert(0, new ListItem("Todos", "0")); diff --git a/WebLab/WebLab.csproj b/WebLab/WebLab.csproj index f06aebe9..27e8e4d5 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 @@ -4902,6 +4894,12 @@ Component True + + AuditoriaUser.rpt + True + Component + True + True True @@ -4947,6 +4945,12 @@ HistorialPorUsuario.aspx + + True + True + HTrabajoProtocolo2Horizontal.rpt + Component + PacientesList.aspx ASPXCodeBehind @@ -6809,6 +6813,10 @@ CrystalDecisions.VSDesigner.CodeGen.ReportCodeGenerator AuditoriaLote.cs + + CrystalDecisions.VSDesigner.CodeGen.ReportCodeGenerator + AuditoriaUser.cs + CrystalDecisions.VSDesigner.CodeGen.ReportCodeGenerator AuditoriaProtocolo.cs diff --git a/WebLab/controldecambios.html b/WebLab/controldecambios.html index 43b85394..acb9cc3a 100644 --- a/WebLab/controldecambios.html +++ b/WebLab/controldecambios.html @@ -1,1199 +1,1521 @@ - - - - - - Lista de cambios - + + + +

Lista de cambios en SIL2

+ +
+ +
+ + + + + + + + + + + + +
FechaModuloDetalleTipo
+ + 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..1b6a2c74 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) @@ -380,6 +340,13 @@ private void CrearLogAcceso(Usuario oUser) private bool MostrarTerminosCondiciones(Usuario oUser) { + /* + PARAMETRIZACION: + Cantidad X de dias + > 0 --> Muestra "Terminos y Condiciones" dado X dias + == 0 --> Muestra Siempre "Terminos y Condiciones" + < 0 --> NO muestra "Terminos y Condiciones" + */ int dias = Convert.ToInt32(ConfigurationManager.AppSettings["DiasTerminosCondiciones"]); if(dias > 0) { @@ -396,8 +363,8 @@ private bool MostrarTerminosCondiciones(Usuario oUser) } else { - // ScriptManager.RegisterStartupScript(this, this.GetType(), "error", "alert('❌ No hay dias definidos para los terminos y condiciones');", true); - return true; + if(dias == 0) return true; + else return false; }