private void grdDataLocation_DoubleClick_1(object sender, EventArgs e)
        {
            OperationResult objOperationResult = new OperationResult();
            var             ServiceComponentId = grdDataLocation.Selected.Rows[0].Cells["v_ServiceComponentId"].Value.ToString();
            var             component          = grdDataLocation.Selected.Rows[0].Cells["v_ComponentName"].Value.ToString();
            var             componentId        = grdDataLocation.Selected.Rows[0].Cells["v_ComponentId"].Value.ToString();
            var             price = grdDataLocation.Selected.Rows[0].Cells["r_Price"].Value.ToString();

            FormPrecioComponente frm = new FormPrecioComponente(component, price, "Change");

            frm.ShowDialog();

            var oservicecomponentDto = new servicecomponentDto();

            var obj = _ServiceBL.GetServiceComponentsLiquidacion(ref objOperationResult, _serviceId);

            //var x = obj.Find(p => p.v_ComponentId == componentId);
            oservicecomponentDto.v_ServiceComponentId = ServiceComponentId;
            oservicecomponentDto.r_Price = frm.Precio;

            _ServiceBL.ActualizarPrecioComponente(oservicecomponentDto.r_Price.Value, oservicecomponentDto.v_ServiceComponentId);

            var dataListPc = _ServiceBL.GetServiceComponentsLiquidacion(ref objOperationResult, _serviceId);

            grdDataLocation.DataSource = dataListPc;

            float Total = 0;

            foreach (var item in dataListPc)
            {
                Total = Total + item.r_Price.Value;
            }
            lblCostoTotal.Text = Total.ToString();
        }
Exemplo n.º 2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (_auxiliaryExams == null)
            {
                _auxiliaryExams = new List <ServiceComponentList>();
            }

            // Save ListView / recorrer la lista de examenes seleccionados
            foreach (ListViewItem item in lvExamenesSeleccionados.Items)
            {
                var fields = item.SubItems;
                var serviceComponentConcatId = fields[1].Text.Split('|');
                var NombreComponente         = fields[0].Text.Split('|');

                foreach (var scid in serviceComponentConcatId)
                {
                    FormPrecioComponente frm = new FormPrecioComponente(NombreComponente[0].ToString());

                    frm.ShowDialog();

                    ServiceComponentList auxiliaryExam = new ServiceComponentList();
                    //auxiliaryExam.v_ServiceComponentId = scid;
                    //_auxiliaryExams.Add(auxiliaryExam);

                    servicecomponentDto objServiceComponentDto = new servicecomponentDto();
                    OperationResult     objOperationResult     = new OperationResult();
                    ServiceBL           _ObjServiceBL          = new ServiceBL();

                    objServiceComponentDto.v_ServiceId              = _serviceId;
                    objServiceComponentDto.i_ExternalInternalId     = (int)Common.ComponenteProcedencia.Interno;
                    objServiceComponentDto.i_ServiceComponentTypeId = 1;
                    objServiceComponentDto.i_IsVisibleId            = 1;
                    objServiceComponentDto.i_IsInheritedId          = (int)Common.SiNo.NO;
                    objServiceComponentDto.d_StartDate              = null;
                    objServiceComponentDto.d_EndDate                  = null;
                    objServiceComponentDto.i_index                    = 1;
                    objServiceComponentDto.r_Price                    = frm.Precio;
                    objServiceComponentDto.v_ComponentId              = scid;
                    objServiceComponentDto.i_IsInvoicedId             = (int)Common.SiNo.NO;
                    objServiceComponentDto.i_ServiceComponentStatusId = (int)Common.ServiceStatus.PorIniciar;
                    objServiceComponentDto.i_QueueStatusId            = (int)Common.QueueStatusId.LIBRE;
                    //objServiceComponentDto.i_IsRequiredId = (int)Common.SiNo.SI;
                    objServiceComponentDto.i_Iscalling = (int)Common.Flag_Call.NoseLlamo;
                    //objServiceComponentDto.i_Iscalling_1 = (int)Common.Flag_Call.NoseLlamo;
                    objServiceComponentDto.i_IsManuallyAddedId = (int)Common.SiNo.NO;
                    objServiceComponentDto.i_IsRequiredId      = (int)Common.SiNo.SI;


                    //_calendarBL.UpdateAdditionalExam(_auxiliaryExams, _serviceId, (int?)SiNo.SI, Globals.ClientSession.GetAsList());
                    _ObjServiceBL.AddServiceComponent(ref objOperationResult, objServiceComponentDto, Globals.ClientSession.GetAsList());
                }
            }

            MessageBox.Show("Se grabo correctamente", " ¡ INFORMACIÓN !", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.DialogResult = DialogResult.OK;
        }
Exemplo n.º 3
0
        private void AddAuxiliaryExam()
        {
            var findResult = lvExamenesSeleccionados.FindItemWithText(MedicalExamId);

            // El examen ya esta agregado
            if (findResult != null)
            {
                MessageBox.Show("Por favor seleccione otro examen.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var res = _ListaComponentes.Find(p => p == MedicalExamId);

            if (res != null)
            {
                var DialogResult = MessageBox.Show("El paciente ya cuenta con este examen, ¿Desea crear nuevo servicio?", "Error de Valicación", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (DialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    #region Agenda Automática
                    CalendarBL      calendarBl         = new CalendarBL();
                    OperationResult objOperationResult = new OperationResult();

                    var protocolId = Constants.Prot_Hospi_Adic;

                    var objCalendarDto = new calendarDto();
                    objCalendarDto.v_PersonId         = new PacientBL().GetPersonByNroDocument(ref objOperationResult, _dni).v_PersonId;// item.PersonId;
                    objCalendarDto.d_DateTimeCalendar = DateTime.Now;
                    objCalendarDto.d_CircuitStartDate = DateTime.Now;
                    objCalendarDto.d_EntryTimeCM      = DateTime.Now;
                    objCalendarDto.i_ServiceTypeId    = (int)ServiceType.Particular;
                    objCalendarDto.i_ServiceId        = (int)MasterService.Hospitalizacion;

                    objCalendarDto.i_CalendarStatusId  = (int)CalendarStatus.Agendado;
                    objCalendarDto.i_LineStatusId      = (int)LineStatus.EnCircuito;
                    objCalendarDto.v_ProtocolId        = protocolId;
                    objCalendarDto.i_NewContinuationId = 1;
                    objCalendarDto.i_LineStatusId      = (int)LineStatus.EnCircuito;
                    objCalendarDto.i_IsVipId           = (int)SiNo.NO;

                    var serviceId = calendarBl.AddShedule(ref objOperationResult, objCalendarDto, Globals.ClientSession.GetAsList(), protocolId, objCalendarDto.v_PersonId, (int)MasterService.Eso, "Nuevo");

                    serviceDto objServiceDto = new serviceDto();
                    objServiceDto = new ServiceBL().GetService(ref objOperationResult, serviceId);
                    objServiceDto.d_ServiceDate = DateTime.Now;

                    objServiceDto.i_ServiceStatusId = (int)Common.ServiceStatus.Iniciado;
                    new ServiceBL().UpdateService(ref objOperationResult, objServiceDto, Globals.ClientSession.GetAsList());


                    var servicesComponents = new ServiceBL().GetServiceComponents(ref objOperationResult, serviceId);

                    foreach (var servicesComponent in servicesComponents)
                    {
                        servicecomponentDto oservicecomponentDto = new servicecomponentDto();
                        oservicecomponentDto = new ServiceBL().GetServiceComponent(ref objOperationResult,
                                                                                   servicesComponent.v_ServiceComponentId);
                        oservicecomponentDto.i_MedicoTratanteId   = 11;
                        oservicecomponentDto.i_IsVisibleId        = 1;
                        oservicecomponentDto.v_ServiceComponentId = servicesComponent.v_ServiceComponentId;
                        new ServiceBL().UpdateServiceComponent(ref objOperationResult, oservicecomponentDto, Globals.ClientSession.GetAsList());
                    }



                    var oHospitalizacionserviceDto = new hospitalizacionserviceDto();

                    oHospitalizacionserviceDto.v_HopitalizacionId = _nroHospitalizacion;
                    oHospitalizacionserviceDto.v_ServiceId        = serviceId;

                    new HospitalizacionBL().AddHospitalizacionService(ref objOperationResult, oHospitalizacionserviceDto, Globals.ClientSession.GetAsList());
                    #endregion

                    MessageBox.Show("Se generó el servicio: " + serviceId, " ¡ INFORMACIÓN !", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //var DialogResult = DialogResult.OK;
                    //var frm = new frmCalendar(_nroHospitalizacion, _dni, _serviceId);
                    //frm.ShowDialog();
                }
                else
                {
                    return;
                }
            }


            var row = new ListViewItem(new[] { MedicalExamName, MedicalExamId, ServiceComponentConcatId });

            lvExamenesSeleccionados.Items.Add(row);

            gbExamenesSeleccionados.Text = string.Format("Examenes Seleccionados {0}", lvExamenesSeleccionados.Items.Count);
        }
Exemplo n.º 4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (cboMedico.SelectedValue.ToString() == "-1")
            {
                MessageBox.Show("Seleccionar un médico tratante", " ¡ VALIDACIÓN!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (_auxiliaryExams == null)
            {
                _auxiliaryExams = new List <ServiceComponentList>();
            }

            // Save ListView / recorrer la lista de examenes seleccionados
            foreach (ListViewItem item in lvExamenesSeleccionados.Items)
            {
                var fields           = item.SubItems;
                var ComponentId      = fields[1].Text.Split('|');
                var NombreComponente = fields[0].Text.Split('|');



                MedicalExamBL objComponentBL  = new MedicalExamBL();
                componentDto  objComponentDto = new componentDto();

                OperationResult objOperationResult = new OperationResult();
                foreach (var scid in ComponentId)
                {
                    var conCargoA = -1;
                    if (_type == "Hospi")
                    {
                        var oFrmType = new frmType();
                        oFrmType.ShowDialog();

                        if (oFrmType._conCargoA == "Médico")
                        {
                            conCargoA = 1;
                        }
                        else
                        {
                            conCargoA = 2;
                        }
                    }

                    objComponentDto = objComponentBL.GetMedicalExam(ref objOperationResult, scid);
                    SystemParameterBL oSp = new SystemParameterBL();
                    var o = oSp.GetSystemParameter(ref objOperationResult, 116, int.Parse(objComponentDto.i_CategoryId.ToString()));
                    //Lógica de Aumento de Precio Base

                    var porcentajes = o.v_Field.Split('-');

                    float p1 = porcentajes[0] == null ? 0 : float.Parse(porcentajes[0].ToString());

                    float p2 = porcentajes[1] == null ? 0 : float.Parse(porcentajes[1].ToString());

                    float pb          = objComponentDto.r_BasePrice.Value;
                    var   precio_base = pb + (pb * p1 / 100) + (pb * p2 / 100);
                    //FormPrecioComponente frm = new FormPrecioComponente("", "", "");
                    //frmConfigSeguros frm1 = new frmConfigSeguros(0, 0, 0, "", "");
                    ServiceComponentList auxiliaryExam          = new ServiceComponentList();
                    servicecomponentDto  objServiceComponentDto = new servicecomponentDto();
                    ServiceBL            _ObjServiceBL          = new ServiceBL();
                    TicketBL             oTicketBL = new TicketBL();
                    if (_modo == "ASEGU")
                    {
                        #region OLD Logica antigua
                        #region Conexion SAM
                        //ConexionSigesoft conectasam = new ConexionSigesoft();
                        //conectasam.opensigesoft();
                        #endregion
                        #region Query
                        //var componente = NombreComponente[0].ToString();
                        //var cadena1 = "select PL.i_EsDeducible, PL.i_EsCoaseguro, PL.d_Importe, PL.d_ImporteCo from [dbo].[plan] PL where PL.v_IdUnidadProductiva='" + lineId + "' and PL.v_ProtocoloId='" + _protocolId + "' ";
                        //SqlCommand comando = new SqlCommand(cadena1, connection: conectasam.conectarsigesoft);
                        //SqlDataReader lector = comando.ExecuteReader();
                        //int deducible = 0;
                        //int coaseguro = 0;
                        //decimal? importe = 0;
                        //decimal? importeCo = 0;
                        //while (lector.Read())
                        //{
                        //    deducible = int.Parse(lector.GetValue(0).ToString()); coaseguro = int.Parse(lector.GetValue(1).ToString()); importe = decimal.Parse(lector.GetValue(2).ToString()); importeCo = decimal.Parse(lector.GetValue(3).ToString());
                        //}
                        //lector.Close();
                        //string factores = ""; string aseguradoraName = ""; string organizationId = "";
                        //var factorGlobal = "";
                        //var cadena2 = "select PR.r_PriceFactor, OO.v_Name, PR.v_CustomerOrganizationId from Organization OO inner join protocol PR On PR.v_AseguradoraOrganizationId = OO.v_OrganizationId where PR.v_ProtocolId ='" + _protocolId + "'";
                        //comando = new SqlCommand(cadena2, connection: conectasam.conectarsigesoft);
                        //lector = comando.ExecuteReader();
                        //while (lector.Read())
                        //{
                        //    factores = lector.GetValue(0).ToString();
                        //    var factorArray = factores.Split('|');// factores[0].ToString().Split('|');
                        //    factorGlobal = factorArray[0];
                        //    aseguradoraName = lector.GetValue(1).ToString();
                        //    organizationId = lector.GetValue(2).ToString();
                        //}
                        //lector.Close();
                        //string empresa = "";
                        //var cadena3 = "select v_Name from Organization OO  where OO.v_OrganizationId ='" + organizationId + "'";
                        //comando = new SqlCommand(cadena3, connection: conectasam.conectarsigesoft);
                        //lector = comando.ExecuteReader();
                        //while (lector.Read())
                        //{
                        //    empresa = lector.GetValue(0).ToString();
                        //}
                        //lector.Close();
                        #endregion
                        #region Lógica PARA SABER SI ES DEDUCIBLE O COASEGURO
                        //if (rbNuevaConsulta.Checked)// QUIERE DECIR QUE ES UNA NUEVA ATENCION Y DEBE SER CONSIDERADO COMO DEDUCIBLE SIN FACTOR
                        //{
                        //    factorGlobal = "1";
                        //    coaseguro = 0;
                        //    importeCo = null;
                        //}
                        //else if (rbAdicional.Checked) // QUIERE DECIR QUE ES UN COMPONENTE ADICIONAL Y DEBE SER CONSIDERADO COMO COASEGURO CON FACTOR
                        //{
                        //    deducible = 0;
                        //    importe = null;
                        //}
                        #endregion
                        #region Formulario
                        //precio_base = (float)objComponentDto.r_PriceSegus;// se cambia el precio inicial por el SEGUS
                        //frmConfigSeguros frm1 = new frmConfigSeguros(deducible, coaseguro, importe, precio_base.ToString(), factorGlobal, importeCo);
                        //frm1.Text = aseguradoraName + " / " + empresa;
                        //frm1.ShowDialog();
                        #endregion
                        #endregion

                        #region Obteniendo los campos de la BD
                        ConexionSigesoft conectasam = new ConexionSigesoft();
                        conectasam.opensigesoft();
                        var           componente      = NombreComponente[0].ToString();
                        var           cadena          = "select i_KindOfService from  component where v_ComponentId='" + objComponentDto.v_ComponentId + "'";
                        SqlCommand    comando         = new SqlCommand(cadena, connection: conectasam.conectarsigesoft);
                        SqlDataReader lector          = comando.ExecuteReader();
                        int           i_KindOfService = 0;
                        while (lector.Read())
                        {
                            try
                            {
                                i_KindOfService = int.Parse(lector.GetValue(0).ToString());
                            }
                            catch (Exception exception)
                            {
                                MessageBox.Show(exception.Message, " ¡ ERROR !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        lector.Close();
                        var cadena1 = "select PL.i_PlanId, PL.i_EsCoaseguro, PL.d_Importe, PL.d_ImporteCo " +
                                      "from [dbo].[plan] PL " +
                                      "where PL.v_IdUnidadProductiva='" + lineId + "' and PL.v_ProtocoloId='" + _protocolId + "' ";
                        comando = new SqlCommand(cadena1, connection: conectasam.conectarsigesoft);
                        lector  = comando.ExecuteReader();
                        string PlanId = ""; int coaseguro = 0; decimal?importe = 0; decimal?importeCo = 0;
                        while (lector.Read())
                        {
                            try
                            {
                                PlanId    = lector.GetValue(0).ToString();
                                coaseguro = int.Parse(lector.GetValue(1).ToString());
                                importe   = decimal.Parse(lector.GetValue(2).ToString());
                                importeCo = decimal.Parse(lector.GetValue(3).ToString());
                            }
                            catch (Exception exception)
                            {
                                MessageBox.Show(exception.Message, " ¡ ERROR !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        lector.Close();
                        string factores = ""; string aseguradoraName = ""; string organizationId = ""; var factorGlobal = "";
                        var    cadena2 = "select PR.r_PriceFactor, OO.v_Name, PR.v_CustomerOrganizationId " +
                                         "from Organization OO " +
                                         "inner join protocol PR On PR.v_AseguradoraOrganizationId = OO.v_OrganizationId " +
                                         "where PR.v_ProtocolId ='" + _protocolId + "'";
                        comando = new SqlCommand(cadena2, connection: conectasam.conectarsigesoft);
                        lector  = comando.ExecuteReader();
                        while (lector.Read())
                        {
                            try
                            {
                                factores = lector.GetValue(0).ToString();
                                var factorArray = factores.Split('|');// factores[0].ToString().Split('|');
                                factorGlobal    = factorArray[0];
                                aseguradoraName = lector.GetValue(1).ToString();
                                organizationId  = lector.GetValue(2).ToString();
                            }
                            catch (Exception exception)
                            {
                                MessageBox.Show(exception.Message, " ¡ ERROR !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        lector.Close();
                        #endregion

                        #region Según el tipo de componente se hace el calculo
                        switch (i_KindOfService)
                        {
                        //CLINICA
                        case 1:
                        {
                            if (objComponentDto.r_PriceSegus != 0)
                            {
                                objServiceComponentDto.r_Price            = objComponentDto.r_PriceSegus;
                                objServiceComponentDto.d_SaldoPaciente    = importe;
                                objServiceComponentDto.d_SaldoAseguradora = (decimal)objComponentDto.r_PriceSegus - importe;
                            }
                            else
                            {
                                frmConfigSeguros frm1 = new frmConfigSeguros("1");
                                frm1.ShowDialog();
                                objServiceComponentDto.r_Price            = (float)frm1.nuevoPrecio;
                                objServiceComponentDto.d_SaldoPaciente    = importe;
                                objServiceComponentDto.d_SaldoAseguradora = frm1.nuevoPrecio - importe;
                            }
                        }
                        break;

                        //SERVICIOS AUXILIARES
                        case 2:
                        {
                            if (objComponentDto.r_PriceSegus != 0)
                            {
                                objServiceComponentDto.r_Price            = objComponentDto.r_PriceSegus * float.Parse(factorGlobal);
                                objServiceComponentDto.d_SaldoPaciente    = importeCo * (decimal)objServiceComponentDto.r_Price / 100;
                                objServiceComponentDto.d_SaldoAseguradora = (100 - importeCo) * (decimal)objServiceComponentDto.r_Price / 100;
                            }
                            else
                            {
                                frmConfigSeguros frm1 = new frmConfigSeguros(factorGlobal);
                                frm1.ShowDialog();
                                objServiceComponentDto.r_Price            = (float)frm1.nuevoPrecio;
                                objServiceComponentDto.d_SaldoPaciente    = importeCo * frm1.nuevoPrecio / 100;
                                objServiceComponentDto.d_SaldoAseguradora = (100 - importeCo) * frm1.nuevoPrecio / 100;
                            }
                        }
                        break;

                        //HONORARIOS MÉDICOS Y/O QUIRURGICOS
                        case 3:
                        {
                            if (objComponentDto.r_PriceSegus != 0)
                            {
                                objServiceComponentDto.r_Price            = objComponentDto.r_PriceSegus * float.Parse(factorGlobal);
                                objServiceComponentDto.d_SaldoPaciente    = importeCo * (decimal)objServiceComponentDto.r_Price / 100;
                                objServiceComponentDto.d_SaldoAseguradora = (100 - importeCo) * (decimal)objServiceComponentDto.r_Price / 100;
                            }
                            else
                            {
                                frmConfigSeguros frm1 = new frmConfigSeguros(factorGlobal);
                                frm1.ShowDialog();
                                objServiceComponentDto.r_Price            = (float)frm1.nuevoPrecio;
                                objServiceComponentDto.d_SaldoPaciente    = importeCo * frm1.nuevoPrecio / 100;
                                objServiceComponentDto.d_SaldoAseguradora = (100 - importeCo) * frm1.nuevoPrecio / 100;
                            }
                        }
                        break;
                        }
                        #endregion



                        objServiceComponentDto.v_ServiceId              = _serviceId;
                        objServiceComponentDto.i_ExternalInternalId     = (int)Common.ComponenteProcedencia.Interno;
                        objServiceComponentDto.i_ServiceComponentTypeId = 1;
                        objServiceComponentDto.i_IsVisibleId            = 1;
                        objServiceComponentDto.i_IsInheritedId          = (int)Common.SiNo.NO;
                        objServiceComponentDto.d_StartDate              = null;
                        objServiceComponentDto.d_EndDate                  = null;
                        objServiceComponentDto.i_index                    = 1;
                        objServiceComponentDto.v_ComponentId              = scid;
                        objServiceComponentDto.i_IsInvoicedId             = (int)Common.SiNo.NO;
                        objServiceComponentDto.i_ServiceComponentStatusId = (int)Common.ServiceStatus.PorIniciar;
                        objServiceComponentDto.i_QueueStatusId            = (int)Common.QueueStatusId.LIBRE;
                        objServiceComponentDto.i_Iscalling                = (int)Common.Flag_Call.NoseLlamo;
                        objServiceComponentDto.i_Iscalling_1              = (int)Common.Flag_Call.NoseLlamo;
                        objServiceComponentDto.i_IsManuallyAddedId        = (int)Common.SiNo.NO;
                        objServiceComponentDto.i_IsRequiredId             = (int)Common.SiNo.SI;
                        objServiceComponentDto.v_IdUnidadProductiva       = txtUnidProdId.Text;
                        objServiceComponentDto.i_MedicoTratanteId         = int.Parse(cboMedico.SelectedValue.ToString());
                        if (rbNuevaConsulta.Checked)
                        {
                            objServiceComponentDto.i_TipoDesc = 1;
                        }
                        else if (rbAdicional.Checked)
                        {
                            objServiceComponentDto.i_TipoDesc = 2;
                        }

                        _ObjServiceBL.AddServiceComponent(ref objOperationResult, objServiceComponentDto, Globals.ClientSession.GetAsList());
                        #region Update a service agrega el PlanId
                        cadena1 = "update service set " +
                                  "i_PlanId = '" + PlanId + "' " +
                                  "where v_ServiceId = '" + _serviceId + "' ";
                        comando = new SqlCommand(cadena1, connection: conectasam.conectarsigesoft);
                        lector  = comando.ExecuteReader();
                        lector.Close();
                        #endregion
                    }
                    else
                    {
                        FormPrecioComponente frm = new FormPrecioComponente(NombreComponente[0].ToString(), precio_base.ToString(), "");
                        frm.ShowDialog();
                        objServiceComponentDto.i_ConCargoA              = conCargoA;
                        objServiceComponentDto.v_ServiceId              = _serviceId;
                        objServiceComponentDto.i_ExternalInternalId     = (int)Common.ComponenteProcedencia.Interno;
                        objServiceComponentDto.i_ServiceComponentTypeId = 1;
                        objServiceComponentDto.i_IsVisibleId            = 1;
                        objServiceComponentDto.i_IsInheritedId          = (int)Common.SiNo.NO;
                        objServiceComponentDto.d_StartDate              = null;
                        objServiceComponentDto.d_EndDate                  = null;
                        objServiceComponentDto.i_index                    = 1;
                        objServiceComponentDto.r_Price                    = frm.Precio;
                        objServiceComponentDto.v_ComponentId              = scid;
                        objServiceComponentDto.i_IsInvoicedId             = (int)Common.SiNo.NO;
                        objServiceComponentDto.i_ServiceComponentStatusId = (int)Common.ServiceStatus.PorIniciar;
                        objServiceComponentDto.i_QueueStatusId            = (int)Common.QueueStatusId.LIBRE;
                        //objServiceComponentDto.i_IsRequiredId = (int)Common.SiNo.SI;
                        objServiceComponentDto.i_Iscalling          = (int)Common.Flag_Call.NoseLlamo;
                        objServiceComponentDto.i_Iscalling_1        = (int)Common.Flag_Call.NoseLlamo;
                        objServiceComponentDto.i_IsManuallyAddedId  = (int)Common.SiNo.NO;
                        objServiceComponentDto.i_IsRequiredId       = (int)Common.SiNo.SI;
                        objServiceComponentDto.v_IdUnidadProductiva = objComponentDto.v_IdUnidadProductiva;
                        objServiceComponentDto.i_MedicoTratanteId   = int.Parse(cboMedico.SelectedValue.ToString());
                        objServiceComponentDto.d_SaldoPaciente      = 0;
                        objServiceComponentDto.d_SaldoAseguradora   = 0;
                        _ObjServiceBL.AddServiceComponent(ref objOperationResult, objServiceComponentDto, Globals.ClientSession.GetAsList());
                    }
                }

                //Actualizo si son examenes adicionales
                if (_DataSource.Count > 0)
                {
                    new AdditionalExamBL().UpdateAdditionalExamByComponentIdAndServiceId(ComponentId[0], _serviceId,
                                                                                         Globals.ClientSession.i_SystemUserId);
                }
            }

            MessageBox.Show("Se grabo correctamente", " ¡ INFORMACIÓN !", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.DialogResult = DialogResult.OK;
        }
Exemplo n.º 5
0
        private void Llamar()
        {
            OperationResult             objOperationResult   = new OperationResult();
            List <ServiceComponentList> ListServiceComponent = new List <ServiceComponentList>();
            CalendarBL          objCalendarBL   = new CalendarBL();
            CalendarList        objCalendar     = new CalendarList();
            List <CalendarList> objCalendarList = new List <CalendarList>();
            ProtocolBL          oProtocolBL     = new ProtocolBL();

            ServiceBL           objServiceBL           = new ServiceBL();
            servicecomponentDto objservicecomponentDto = new servicecomponentDto();

            _ServiceComponentId = new List <string>();

            // Verificar si un componente está en la categoría
            MedicalExamBL oMedicalExamBL = new MedicalExamBL();

            Boolean Resultado = oMedicalExamBL.VerificarComponentePorCategoria(_categoriaId, Constants.ELECTROCARDIOGRAMA_ID);

            if (Resultado)
            {
                List <ServiceComponentFieldValuesList> Valores = objServiceBL.ValoresComponente(_serviceId, Constants.ANTROPOMETRIA_ID);
                decimal ValorIMCServicio  = decimal.Parse(Valores.Find(p => p.v_ComponentFieldId == Constants.ANTROPOMETRIA_IMC_ID).v_Value1.ToString());
                decimal ValorIMCProtocolo = decimal.Parse(oProtocolBL.GetProtocolComponentByProtocol(ref objOperationResult, _ProtocolId, Constants.ELECTROCARDIOGRAMA_ID).r_Imc.ToString());

                if (ValorIMCServicio < ValorIMCProtocolo)
                {
                    MessageBox.Show("El I.M.C. del paciente tiene valores normales, no aplica para este examen", "INFORMACIÓN!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }


            //Validación de Piso
            if (_Piso != "-1")
            {
                var ResultPiso = objServiceBL.PermitirLlamar(_serviceId, int.Parse(_Piso.ToString()));
                if (!ResultPiso)
                {
                    MessageBox.Show("El Paciente tiene consultorios por culminar, antes de ser llamado por este. Verifíquelo en unos minutos", "INFORMACIÓN!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            if (int.Parse(_serviceStatusId) == (int)ServiceStatus.EsperandoAptitud)
            {
                MessageBox.Show("Este paciente ya tiene el servicio en espera de Aptitud, no puede ser llamado.", "INFORMACIÓN!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                return;
            }

            if (_IsCall == "OcupadoLlamado")
            {
                DialogResult Result = MessageBox.Show("¿Está seguro de LLAMAR a este paciente que está ocupado?", "ADVERTENCIA!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (Result == DialogResult.No)
                {
                    return;
                }
            }

            objCalendar.v_Pacient            = grdListaLlamando.Selected.Rows[0].Cells["v_Pacient"].Value.ToString();
            objCalendar.v_OrganizationName   = grdListaLlamando.Selected.Rows[0].Cells["v_WorkingOrganizationName"].Value.ToString();
            objCalendar.v_ServiceComponentId = grdListaLlamando.Selected.Rows[0].Cells["v_ServiceComponentId"].Value.ToString();

            if (_categoryId == -1)
            {
                _ServiceComponentId.Add(grdListaLlamando.Selected.Rows[0].Cells["v_ServiceComponentId"].Value.ToString());
            }
            else
            {
                foreach (var item in objServiceBL.GetServiceComponentByCategoryId(ref objOperationResult, _categoryId, _serviceId))
                {
                    _ServiceComponentId.Add(item.v_ServiceComponentId);
                }
            }

            // Cargar grilla de llamando al paciente  ************
            objCalendarList.Add(objCalendar);
            grdLlamandoPaciente.DataSource = objCalendarList;

            if (grdLlamandoPaciente.Rows.Count > 0)
            {
                grdLlamandoPaciente.Rows[0].Selected = true;
            }

            //*******************************************************

            for (int i = 0; i < _ServiceComponentId.Count; i++)
            {
                objservicecomponentDto = new servicecomponentDto();
                objservicecomponentDto.v_ServiceComponentId = _ServiceComponentId[i];
                objservicecomponentDto.i_QueueStatusId      = (int)Common.QueueStatusId.LLAMANDO;
                objservicecomponentDto.v_NameOfice          = cbOficina.Text.ToString();
                objServiceBL.UpdateServiceComponentOfficeLlamando(objservicecomponentDto);
            }

            //Actualizar grdDataServiceComponent
            ListServiceComponent = objServiceBL.GetServiceComponents(ref objOperationResult, _serviceId);
            grdDataServiceComponent.DataSource = ListServiceComponent;

            grdListaLlamando.Enabled    = false;
            grdLlamandoPaciente.Enabled = true;
            btnRefresh.Enabled          = false;

            chkHability.Enabled = true;

            btnLlamar.Enabled = false;
        }
Exemplo n.º 6
0
        private void Liberar()
        {
            try
            {
                OperationResult objOperationResult = new OperationResult();
                ServiceBL       objServiceBL       = new ServiceBL();

                servicecomponentDto         objservicecomponentDto = null;
                List <ServiceComponentList> ListServiceComponent   = new List <ServiceComponentList>();

                if (_categoryId == -1)
                {
                    _ServiceComponentId.Add(grdLlamandoPaciente.Selected.Rows[0].Cells["v_ServiceComponentId"].Value.ToString());
                }
                else
                {
                    var servCompCat = objServiceBL.GetServiceComponentByCategoryId(ref objOperationResult, _categoryId, _serviceId);

                    foreach (var item in servCompCat)
                    {
                        _ServiceComponentId.Add(item.v_ServiceComponentId);
                    }
                }

                List <servicecomponentDto> list = new List <servicecomponentDto>();

                for (int i = 0; i < _ServiceComponentId.Count; i++)
                {
                    objservicecomponentDto = new servicecomponentDto();
                    objservicecomponentDto.v_ServiceComponentId = _ServiceComponentId[i];
                    objservicecomponentDto.i_QueueStatusId      = (int)Common.QueueStatusId.LIBRE;
                    objservicecomponentDto.i_Iscalling          = (int)SiNo.NO;
                    objservicecomponentDto.d_EndDate            = DateTime.Now;
                    list.Add(objservicecomponentDto);
                }

                // update
                objServiceBL.UpdateServiceComponentOffice(list);

                #region Check de salir de circuito

                if (chkHability.Checked == true) // finaliza el servicio y actualiza el estado del servicio
                {
                    if (ddlServiceStatusId.SelectedValue.ToString() == ((int)ServiceStatus.Iniciado).ToString())
                    {
                        MessageBox.Show("Debe elegir cualquier otro estado que no sea (Iniciado)\nSi desea Liberar y/o Finalizar Circuito.", "ADVERTENCIA!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    serviceDto objserviceDto = new serviceDto();

                    objserviceDto.v_ServiceId       = _serviceId;
                    objserviceDto.i_ServiceStatusId = int.Parse(ddlServiceStatusId.SelectedValue.ToString());
                    objserviceDto.v_Motive          = txtReason.Text;

                    objServiceBL.UpdateServiceOffice(ref objOperationResult, objserviceDto, Globals.ClientSession.GetAsList());

                    //Actualizamos el estado de la linea de la agenda como fuera de circuito
                    CalendarBL  objCalendarBL  = new CalendarBL();
                    calendarDto objcalendarDto = new calendarDto();
                    objcalendarDto = objCalendarBL.GetCalendar(ref objOperationResult, _CalendarId);
                    objcalendarDto.i_LineStatusId = 2;// int.Parse(Common.LineStatus.FueraCircuito.ToString());
                    objCalendarBL.UpdateCalendar(ref objOperationResult, objcalendarDto, Globals.ClientSession.GetAsList());
                }

                #endregion

                //Actualizar grdDataServiceComponent

                ListServiceComponent = objServiceBL.GetServiceComponents(ref objOperationResult, _serviceId);
                grdDataServiceComponent.DataSource = ListServiceComponent;

                btnRefresh_Click(null, null);

                txtReason.Text              = "";
                grdListaLlamando.Enabled    = true;
                grdLlamandoPaciente.Enabled = false;
                btnRefresh.Enabled          = true;
                chkHability.Enabled         = false;
                chkHability.Checked         = false;
                groupBox3.Enabled           = false;

                grdLlamandoPaciente.DataSource = new List <CalendarList>();
            }
            catch (Exception ex)
            {
                MessageBox.Show(Common.Utils.ExceptionFormatter(ex), "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 7
0
        private void Atender()
        {
            OperationResult             objOperationResult     = new OperationResult();
            ServiceBL                   objServiceBL           = new ServiceBL();
            servicecomponentDto         objservicecomponentDto = new servicecomponentDto();
            List <ServiceComponentList> ListServiceComponent   = new List <ServiceComponentList>();

            _ServiceComponentId = new List <string>();

            if (chkVerificarHuellaDigital.Checked)
            {
                var checkingFinger = new frmCheckingFinger();
                checkingFinger._PacientId = _personId;
                checkingFinger.ShowDialog();

                if (checkingFinger.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
            }

            DialogResult Result = MessageBox.Show("¿Está seguro de INICIAR ATENCIÓN este registro?", "ADVERTENCIA!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (_categoryId == -1)
            {
                _ServiceComponentId.Add(grdListaLlamando.Selected.Rows[0].Cells["v_ServiceComponentId"].Value.ToString());
            }
            else
            {
                foreach (var item in objServiceBL.GetServiceComponentByCategoryId(ref objOperationResult, _categoryId, _serviceId))
                {
                    _ServiceComponentId.Add(item.v_ServiceComponentId);
                }
            }

            if (Result == System.Windows.Forms.DialogResult.Yes)
            {
                for (int i = 0; i < _ServiceComponentId.Count(); i++)
                {
                    objservicecomponentDto = objServiceBL.GetServiceComponent(ref objOperationResult, _ServiceComponentId[i]);
                    objservicecomponentDto.i_QueueStatusId = (int)Common.QueueStatusId.OCUPADO;
                    objservicecomponentDto.d_StartDate     = DateTime.Now;
                    objServiceBL.UpdateServiceComponent(ref objOperationResult, objservicecomponentDto, Globals.ClientSession.GetAsList());
                }
                //Actualizar grdDataServiceComponent
                string strServicelId = grdListaLlamando.Selected.Rows[0].Cells[5].Value.ToString();
                ListServiceComponent = objServiceBL.GetServiceComponents(ref objOperationResult, strServicelId);
                grdDataServiceComponent.DataSource = ListServiceComponent;

                _Flag = 1;

                Form frm;
                if (_TserviceId == (int)MasterService.AtxMedicaParticular)
                {
                    frm = new Operations.frmMedicalConsult(_serviceId, string.Join("|", _componentIds.Select(p => p)), null);
                    frm.ShowDialog();
                }
                else
                {
                    this.Enabled = false;
                    frm          = new Operations.frmEso(_serviceId, string.Join("|", _componentIds.Select(p => p)), null);
                    frm.ShowDialog();
                    this.Enabled = true;
                    // Aviso automático de que se culminaron todos los examanes, se tendria que proceder
                    // a establecer el estado del servicio a (Culminado Esperando Aptitud)

                    var alert = objServiceBL.GetServiceComponentsCulminados(ref objOperationResult, _serviceId);

                    if (alert != null && alert.Count > 0)
                    {
                    }
                    else
                    {
                        MessageBox.Show("Todos los Examenes se encuentran concluidos.\nEl estado de la Atención es: En espera de Aptitud .", "INFORMACIÓN!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        serviceDto objserviceDto = new serviceDto();
                        objserviceDto = objServiceBL.GetService(ref objOperationResult, objservicecomponentDto.v_ServiceId);
                        objserviceDto.i_ServiceStatusId = (int)ServiceStatus.EsperandoAptitud;
                        objserviceDto.v_Motive          = "Esperando Aptitud";

                        objServiceBL.UpdateService(ref objOperationResult, objserviceDto, Globals.ClientSession.GetAsList());
                    }
                }

                // refrecar la grilla
                ListServiceComponent = objServiceBL.GetServiceComponents(ref objOperationResult, _serviceId);
                grdDataServiceComponent.DataSource = ListServiceComponent;
            }
        }
        protected void btnSaveRefresh_Click(object sender, EventArgs e)
        {
            OperationResult             objOperationResult    = new OperationResult();
            List <ServiceComponentList> lServiceComponentList = new List <ServiceComponentList>();
            ServiceBL     _ObjServiceBL = new ServiceBL();
            CheckBoxField field1        = (CheckBoxField)grdData.FindColumn("CheckBoxField2");

            for (int i = 0; i < grdData.Rows.Count; i++)
            {
                servicecomponentDto objServiceComponentDto = new servicecomponentDto();

                bool ChecAdicional = field1.GetCheckedState(i);
                var  Flag          = grdData.Rows[i].Values[4].ToString();

                if (ChecAdicional)
                {
                    objServiceComponentDto.v_ServiceId              = Session["SerId"].ToString();
                    objServiceComponentDto.i_ExternalInternalId     = 1;//interno
                    objServiceComponentDto.i_ServiceComponentTypeId = 1;
                    objServiceComponentDto.i_IsVisibleId            = 1;
                    objServiceComponentDto.i_IsInheritedId          = 0;
                    objServiceComponentDto.d_StartDate              = null;
                    objServiceComponentDto.d_EndDate                  = null;
                    objServiceComponentDto.i_index                    = 1;
                    objServiceComponentDto.r_Price                    = 10;
                    objServiceComponentDto.v_ComponentId              = grdData.Rows[i].Values[3];
                    objServiceComponentDto.i_IsInvoicedId             = 0;
                    objServiceComponentDto.i_ServiceComponentStatusId = 1; // (int)Common.ServiceStatus.PorIniciar;
                    objServiceComponentDto.i_QueueStatusId            = 1; // (int)Common.QueueStatusId.LIBRE;
                    objServiceComponentDto.i_Iscalling                = 0; // (int)Common.Flag_Call.NoseLlamo;
                    objServiceComponentDto.i_IsManuallyAddedId        = 0; // (int)Common.SiNo.NO;
                    objServiceComponentDto.i_IsRequiredId             = 1; // (int)Common.SiNo.SI;
                    if (Flag == "0")
                    {
                        _ObjServiceBL.AddServiceComponent(ref objOperationResult, objServiceComponentDto, ((ClientSession)Session["objClientSession"]).GetAsList());
                    }
                    else if (Flag == "1")
                    {
                        _ObjServiceBL.UpdateAdditionalExam(ref objOperationResult, grdData.Rows[i].Values[5].ToString(), 1, ((ClientSession)Session["objClientSession"]).GetAsList());
                    }
                }
                else if (ChecAdicional == false)
                {
                    //var Lista_OLD = (List<Categoria>)Session["lComponentes_OLD"];

                    //var Flag =   grdData.Rows[i].Values[4].ToString();
                    if (Flag == "1")
                    {
                        _ObjServiceBL.UpdateAdditionalExam(ref objOperationResult, grdData.Rows[i].Values[5].ToString(), 0, ((ClientSession)Session["objClientSession"]).GetAsList());
                    }
                    //Lista_OLD.Find(p => p.v_ComponentId == grdData.Rows[i].Values[3].ToString());
                }
            }

            //Analizar el resultado de la operación
            if (objOperationResult.Success == 1)  // Operación sin error
            {
                // Cerrar página actual y hacer postback en el padre para actualizar
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
            else  // Operación con error
            {
                Alert.ShowInTop("Error en operación:" + System.Environment.NewLine + objOperationResult.ExceptionMessage);
                // Se queda en el formulario.
            }
        }
Exemplo n.º 9
0
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            OperationResult     objOperationResult     = new OperationResult();
            CalendarBL          objCalendarBL          = new CalendarBL();
            ServiceBL           objServiceBL           = new ServiceBL();
            servicecomponentDto objservicecomponentDto = new servicecomponentDto();
            List <CalendarList> objCalendarList        = new List <CalendarList>();

            objCalendarList = objCalendarBL.GetCallPacientPagedAndFilteredGroupByCategoryId(ref objOperationResult, 0, null, "", "");

            if (objCalendarList == null)
            {
                return;
            }

            grdData.DataSource = objCalendarList;

            foreach (var item in objCalendarList)
            {
                if (item.i_QueueStatusId == (int)QueueStatusId.LLAMANDO && item.i_Iscalling == (int)SiNo.NO)
                {
                    string Repetitions = ConfigurationManager.AppSettings["Repetitions"];

                    for (int i = 0; i < int.Parse(Repetitions.ToString()); i++)
                    {
                        WindowsMediaPlayer wplayer = new WindowsMediaPlayer();

                        wplayer.URL = PathSound;

                        wplayer.controls.play();

                        string VTrabajador;

                        if (item.i_Gender == (int)Common.Gender.MASCULINO)
                        {
                            VTrabajador = "Trabajador";
                        }
                        else
                        {
                            VTrabajador = "Trabajadora";
                        }

                        if (item.v_NameOffice == "--Seleccionar--")
                        {
                            synth.SpeakAsync(string.Format(CallFormat, item.v_Pacient, item.v_OfficeNumber, item.v_CategoryName, VTrabajador));
                        }
                        else
                        {
                            synth.SpeakAsync(string.Format(CallFormat, item.v_Pacient, item.v_OfficeNumber + "," + item.v_NameOffice));
                        }
                    }
                }
            }

            List <CalendarList> x = objCalendarBL.GetCallPacientPagedAndFiltered(ref objOperationResult, 0, null, "", "");

            foreach (var item in x)
            {
                //Se actualiza el Flag de IsCalling para saber que el paciente ya ha sido llamado una vez
                string ServiceComponentId = item.v_ServiceComponentId;

                //if (NroTv =="1")
                //{
                objServiceBL.UpdateServiceComponentVisor(ref objOperationResult, ServiceComponentId, (int)SiNo.SI);
                //}
                //else if (NroTv == "2")
                //{
                //    objServiceBL.UpdateServiceComponentVisor_(ref objOperationResult, ServiceComponentId, (int)SiNo.SI);
                //}
            }
        }
Exemplo n.º 10
0
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            if (uvValidador.Validate(true, false).IsValid)
            {
                if (double.Parse(txtTalla.Text) < 0.5 || double.Parse(txtTalla.Text) > 2.5)
                {
                    MessageBox.Show("Talla: valor entre 0.5 y 2.5  ", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (double.Parse(txtPeso.Text) < 1 || double.Parse(txtPeso.Text) > 200)
                {
                    MessageBox.Show("Peso: valor entre 1 y 200  ", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (txtPerAbd.Text != "")
                {
                    if (double.Parse(txtPerAbd.Text) < 1 || double.Parse(txtPerAbd.Text) > 300)
                    {
                        MessageBox.Show("Perímetro Abdominal: valor entre 1 y 300  ", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
                if (txtPerCad.Text != "")
                {
                    if (double.Parse(txtPerCad.Text) < 1 || double.Parse(txtPerCad.Text) > 300)
                    {
                        MessageBox.Show("Perímetro Cadera: valor entre 1 y 300  ", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
                if (txtTemperatura.Text != "")
                {
                    if (double.Parse(txtTemperatura.Text) < 15 || double.Parse(txtTemperatura.Text) > 50)
                    {
                        MessageBox.Show("Temperatura: valor entre 15 y 50  ", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }

                if (int.Parse(txtPAS.Text) < 40 || int.Parse(txtPAS.Text) > 350)
                {
                    MessageBox.Show("PAS: valor entre 40 y 350  ", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (int.Parse(txtPAD.Text) < 40 || int.Parse(txtPAD.Text) > 350)
                {
                    MessageBox.Show("PAD: valor entre 40 y 350  ", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (txtFrecResp.Text != "")
                {
                    if (int.Parse(txtFrecResp.Text) < 0 || int.Parse(txtFrecResp.Text) > 60)
                    {
                        MessageBox.Show("Frecuencia Respiratoria: valor entre 0 y 60  ", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }

                if (txtFrecCard.Text != "")
                {
                    if (int.Parse(txtFrecCard.Text) < 0 || int.Parse(txtFrecCard.Text) > 250)
                    {
                        MessageBox.Show("Frecuencia Cardiaca: valor entre 0 y 250  ", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }

                OperationResult objOperationResult = new OperationResult();
                ServiceBL       _serviceBL         = new ServiceBL();
                ServiceComponentFieldValuesList        serviceComponentFieldValues      = null;
                ServiceComponentFieldsList             serviceComponentFields           = null;
                List <ServiceComponentFieldValuesList> _serviceComponentFieldValuesList = null;
                List <ServiceComponentFieldsList>      _serviceComponentFieldsList      = null;

                if (_serviceComponentFieldsList == null)
                {
                    _serviceComponentFieldsList = new List <ServiceComponentFieldsList>();
                }


                //Talla**-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-
                serviceComponentFields = new ServiceComponentFieldsList();

                serviceComponentFields.v_ComponentFieldsId  = Constants.ANTROPOMETRIA_TALLA_ID;
                serviceComponentFields.v_ServiceComponentId = _ServiceComponentId;

                _serviceComponentFieldValuesList = new List <ServiceComponentFieldValuesList>();
                serviceComponentFieldValues      = new ServiceComponentFieldValuesList();

                serviceComponentFieldValues.v_ComponentFieldValuesId = null;
                serviceComponentFieldValues.v_Value1 = txtTalla.Text;
                _serviceComponentFieldValuesList.Add(serviceComponentFieldValues);

                serviceComponentFields.ServiceComponentFieldValues = _serviceComponentFieldValuesList;

                // Agregar a mi lista
                _serviceComponentFieldsList.Add(serviceComponentFields);


                //Temperatura**-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-
                serviceComponentFields = new ServiceComponentFieldsList();

                serviceComponentFields.v_ComponentFieldsId  = Constants.FUNCIONES_VITALES_TEMPERATURA_ID;
                serviceComponentFields.v_ServiceComponentId = _ServiceComponentId;

                _serviceComponentFieldValuesList = new List <ServiceComponentFieldValuesList>();
                serviceComponentFieldValues      = new ServiceComponentFieldValuesList();

                serviceComponentFieldValues.v_ComponentFieldValuesId = null;
                serviceComponentFieldValues.v_Value1 = txtTemperatura.Text;
                _serviceComponentFieldValuesList.Add(serviceComponentFieldValues);

                serviceComponentFields.ServiceComponentFieldValues = _serviceComponentFieldValuesList;

                // Agregar a mi lista
                _serviceComponentFieldsList.Add(serviceComponentFields);

                //Peso**-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-
                serviceComponentFields = new ServiceComponentFieldsList();

                serviceComponentFields.v_ComponentFieldsId  = Constants.ANTROPOMETRIA_PESO_ID;
                serviceComponentFields.v_ServiceComponentId = _ServiceComponentId;

                _serviceComponentFieldValuesList = new List <ServiceComponentFieldValuesList>();
                serviceComponentFieldValues      = new ServiceComponentFieldValuesList();

                serviceComponentFieldValues.v_ComponentFieldValuesId = null;
                serviceComponentFieldValues.v_Value1 = txtPeso.Text;
                _serviceComponentFieldValuesList.Add(serviceComponentFieldValues);

                serviceComponentFields.ServiceComponentFieldValues = _serviceComponentFieldValuesList;

                // Agregar a mi lista
                _serviceComponentFieldsList.Add(serviceComponentFields);



                //PAS**-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-
                serviceComponentFields = new ServiceComponentFieldsList();

                serviceComponentFields.v_ComponentFieldsId  = Constants.FUNCIONES_VITALES_PAS_ID;
                serviceComponentFields.v_ServiceComponentId = _ServiceComponentId;

                _serviceComponentFieldValuesList = new List <ServiceComponentFieldValuesList>();
                serviceComponentFieldValues      = new ServiceComponentFieldValuesList();

                serviceComponentFieldValues.v_ComponentFieldValuesId = null;
                serviceComponentFieldValues.v_Value1 = txtPAS.Text;
                _serviceComponentFieldValuesList.Add(serviceComponentFieldValues);

                serviceComponentFields.ServiceComponentFieldValues = _serviceComponentFieldValuesList;

                // Agregar a mi lista
                _serviceComponentFieldsList.Add(serviceComponentFields);


                //IMC**-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-
                serviceComponentFields = new ServiceComponentFieldsList();

                serviceComponentFields.v_ComponentFieldsId  = Constants.ANTROPOMETRIA_IMC_ID;
                serviceComponentFields.v_ServiceComponentId = _ServiceComponentId;

                _serviceComponentFieldValuesList = new List <ServiceComponentFieldValuesList>();
                serviceComponentFieldValues      = new ServiceComponentFieldValuesList();

                serviceComponentFieldValues.v_ComponentFieldValuesId = null;
                serviceComponentFieldValues.v_Value1 = txtImc.Text;
                _serviceComponentFieldValuesList.Add(serviceComponentFieldValues);

                serviceComponentFields.ServiceComponentFieldValues = _serviceComponentFieldValuesList;

                // Agregar a mi lista
                _serviceComponentFieldsList.Add(serviceComponentFields);


                //PAD**-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-
                serviceComponentFields = new ServiceComponentFieldsList();

                serviceComponentFields.v_ComponentFieldsId  = Constants.FUNCIONES_VITALES_PAD_ID;
                serviceComponentFields.v_ServiceComponentId = _ServiceComponentId;

                _serviceComponentFieldValuesList = new List <ServiceComponentFieldValuesList>();
                serviceComponentFieldValues      = new ServiceComponentFieldValuesList();

                serviceComponentFieldValues.v_ComponentFieldValuesId = null;
                serviceComponentFieldValues.v_Value1 = txtPAD.Text;
                _serviceComponentFieldValuesList.Add(serviceComponentFieldValues);

                serviceComponentFields.ServiceComponentFieldValues = _serviceComponentFieldValuesList;

                // Agregar a mi lista
                _serviceComponentFieldsList.Add(serviceComponentFields);



                //Perímetro Abdomen**-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-
                serviceComponentFields = new ServiceComponentFieldsList();

                serviceComponentFields.v_ComponentFieldsId  = Constants.ANTROPOMETRIA_PERIMETRO_ABDOMINAL_ID;
                serviceComponentFields.v_ServiceComponentId = _ServiceComponentId;

                _serviceComponentFieldValuesList = new List <ServiceComponentFieldValuesList>();
                serviceComponentFieldValues      = new ServiceComponentFieldValuesList();

                serviceComponentFieldValues.v_ComponentFieldValuesId = null;
                serviceComponentFieldValues.v_Value1 = txtPerAbd.Text;
                _serviceComponentFieldValuesList.Add(serviceComponentFieldValues);

                serviceComponentFields.ServiceComponentFieldValues = _serviceComponentFieldValuesList;

                // Agregar a mi lista
                _serviceComponentFieldsList.Add(serviceComponentFields);

                //Frecuencia Cardiaca**-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-
                serviceComponentFields = new ServiceComponentFieldsList();

                serviceComponentFields.v_ComponentFieldsId  = Constants.FUNCIONES_VITALES_FREC_CARDIACA_ID;
                serviceComponentFields.v_ServiceComponentId = _ServiceComponentId;

                _serviceComponentFieldValuesList = new List <ServiceComponentFieldValuesList>();
                serviceComponentFieldValues      = new ServiceComponentFieldValuesList();

                serviceComponentFieldValues.v_ComponentFieldValuesId = null;
                serviceComponentFieldValues.v_Value1 = txtFrecCard.Text;
                _serviceComponentFieldValuesList.Add(serviceComponentFieldValues);

                serviceComponentFields.ServiceComponentFieldValues = _serviceComponentFieldValuesList;

                // Agregar a mi lista
                _serviceComponentFieldsList.Add(serviceComponentFields);

                //Perímetro Cadera**-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-
                serviceComponentFields = new ServiceComponentFieldsList();

                serviceComponentFields.v_ComponentFieldsId  = Constants.ANTROPOMETRIA_PERIMETRO_CADERA_ID;
                serviceComponentFields.v_ServiceComponentId = _ServiceComponentId;

                _serviceComponentFieldValuesList = new List <ServiceComponentFieldValuesList>();
                serviceComponentFieldValues      = new ServiceComponentFieldValuesList();

                serviceComponentFieldValues.v_ComponentFieldValuesId = null;
                serviceComponentFieldValues.v_Value1 = txtPerCad.Text;
                _serviceComponentFieldValuesList.Add(serviceComponentFieldValues);

                serviceComponentFields.ServiceComponentFieldValues = _serviceComponentFieldValuesList;

                // Agregar a mi lista
                _serviceComponentFieldsList.Add(serviceComponentFields);

                //Frecuencia Respiratoria**-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-
                serviceComponentFields = new ServiceComponentFieldsList();

                serviceComponentFields.v_ComponentFieldsId  = Constants.FUNCIONES_VITALES_FREC_RESPIRATORIA_ID;
                serviceComponentFields.v_ServiceComponentId = _ServiceComponentId;

                _serviceComponentFieldValuesList = new List <ServiceComponentFieldValuesList>();
                serviceComponentFieldValues      = new ServiceComponentFieldValuesList();

                serviceComponentFieldValues.v_ComponentFieldValuesId = null;
                serviceComponentFieldValues.v_Value1 = txtFrecResp.Text;
                _serviceComponentFieldValuesList.Add(serviceComponentFieldValues);

                serviceComponentFields.ServiceComponentFieldValues = _serviceComponentFieldValuesList;

                // Agregar a mi lista
                _serviceComponentFieldsList.Add(serviceComponentFields);


                //ICC**-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-
                serviceComponentFields = new ServiceComponentFieldsList();

                serviceComponentFields.v_ComponentFieldsId  = Constants.ANTROPOMETRIA_INDICE_CINTURA_ID;
                serviceComponentFields.v_ServiceComponentId = _ServiceComponentId;

                _serviceComponentFieldValuesList = new List <ServiceComponentFieldValuesList>();
                serviceComponentFieldValues      = new ServiceComponentFieldValuesList();

                serviceComponentFieldValues.v_ComponentFieldValuesId = null;
                serviceComponentFieldValues.v_Value1 = txtICC.Text;
                _serviceComponentFieldValuesList.Add(serviceComponentFieldValues);

                serviceComponentFields.ServiceComponentFieldValues = _serviceComponentFieldValuesList;

                // Agregar a mi lista
                _serviceComponentFieldsList.Add(serviceComponentFields);


                //Saturación Oxígeno**-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-
                serviceComponentFields = new ServiceComponentFieldsList();

                serviceComponentFields.v_ComponentFieldsId  = Constants.FUNCIONES_VITALES_SAT_O2_ID;
                serviceComponentFields.v_ServiceComponentId = _ServiceComponentId;

                _serviceComponentFieldValuesList = new List <ServiceComponentFieldValuesList>();
                serviceComponentFieldValues      = new ServiceComponentFieldValuesList();

                serviceComponentFieldValues.v_ComponentFieldValuesId = null;
                serviceComponentFieldValues.v_Value1 = txtSatOx.Text;
                _serviceComponentFieldValuesList.Add(serviceComponentFieldValues);

                serviceComponentFields.ServiceComponentFieldValues = _serviceComponentFieldValuesList;

                // Agregar a mi lista
                _serviceComponentFieldsList.Add(serviceComponentFields);



                var result = _serviceBL.AddServiceComponentValues(ref objOperationResult,
                                                                  _serviceComponentFieldsList,
                                                                  Globals.ClientSession.GetAsList(),
                                                                  _PersonId,
                                                                  _ServiceComponentId);

                //lIMPIAR LA LISTA DE DXS
                List <DiagnosticRepositoryList> ListaDxByComponent        = new List <DiagnosticRepositoryList>();
                MedicalExamFieldValuesBL        oMedicalExamFieldValuesBL = new MedicalExamFieldValuesBL();
                //Elminar los Dx antiguos
                _serviceBL.EliminarDxAniguosPorComponente(_ServiceId, Constants.FUNCIONES_VITALES_ID, Globals.ClientSession.GetAsList());
                _serviceBL.EliminarDxAniguosPorComponente(_ServiceId, Constants.ANTROPOMETRIA_ID, Globals.ClientSession.GetAsList());
                ListaDxByComponent = new List <DiagnosticRepositoryList>();

                if (txtImc.Text != "")
                {
                    double IMC = double.Parse(txtImc.Text.ToString());
                    DiagnosticRepositoryList DxByComponent = new DiagnosticRepositoryList();

                    List <RecomendationList> Recomendations = new List <RecomendationList>();
                    List <RestrictionList>   Restrictions   = new List <RestrictionList>();

                    DxByComponent.i_AutoManualId         = 1;
                    DxByComponent.i_FinalQualificationId = (int)FinalQualification.Definitivo;
                    DxByComponent.i_PreQualificationId   = 1;
                    DxByComponent.v_ComponentFieldsId    = Constants.ANTROPOMETRIA_IMC_ID;

                    //Obtener el Componente que está amarrado al DX
                    string ComponentDx = oMedicalExamFieldValuesBL.ObtenerComponentDx(Constants.ANTROPOMETRIA_IMC_ID);
                    string DiseasesId  = "";
                    if (IMC <= 18.49)
                    {
                        DiseasesId = "N009-DD000000300";
                    }
                    else if (IMC >= 18.5 && IMC <= 24.99)
                    {
                        DiseasesId = "N009-DD000000788";
                    }
                    else if (IMC >= 25 && IMC <= 29.99)
                    {
                        DiseasesId = "N009-DD000000601";
                    }
                    else if (IMC >= 30 && IMC <= 34.99)
                    {
                        DiseasesId = "N009-DD000000602";
                    }
                    else if (IMC >= 35 && IMC <= 39.99)
                    {
                        DiseasesId = "N009-DD000000603";
                    }
                    else if (IMC >= 40)
                    {
                        DiseasesId = "N009-DD000000604";
                    }
                    string ComponentFieldId = Constants.ANTROPOMETRIA_IMC_ID;

                    DiagnosticRepositoryList oDiagnosticRepositoryListOld = _serviceBL.VerificarDxExistente(_ServiceId, DiseasesId, ComponentDx, ComponentFieldId);
                    if (oDiagnosticRepositoryListOld != null)
                    {
                        oDiagnosticRepositoryListOld.v_DiagnosticRepositoryId = oDiagnosticRepositoryListOld.v_DiagnosticRepositoryId;
                        oDiagnosticRepositoryListOld.i_RecordType             = (int)RecordType.NoTemporal;
                        oDiagnosticRepositoryListOld.i_RecordStatus           = (int)RecordStatus.EliminadoLogico;
                        oDiagnosticRepositoryListOld.i_DiagnosticTypeId       = (int)TipoDx.Enfermedad_Comun;
                        ListaDxByComponent.Add(oDiagnosticRepositoryListOld);
                    }

                    DxByComponent.v_DiagnosticRepositoryId = Guid.NewGuid().ToString();
                    DxByComponent.i_RecordType             = (int)RecordType.Temporal;
                    DxByComponent.i_RecordStatus           = (int)RecordStatus.Agregado;
                    DxByComponent.i_DiagnosticTypeId       = (int)TipoDx.Enfermedad_Comun;



                    DxByComponent.d_ExpirationDateDiagnostic = DateTime.Now;

                    string ComponentFieldValuesId = oMedicalExamFieldValuesBL.ObtenerIdComponentFieldValues(ComponentFieldId, DiseasesId);
                    DxByComponent.v_ComponentFieldValuesId = ComponentFieldValuesId;


                    DxByComponent.v_ComponentId = ComponentDx;
                    DxByComponent.v_DiseasesId  = DiseasesId;
                    DxByComponent.v_ServiceId   = _ServiceId;


                    //Obtener las recomendaciones

                    DxByComponent.Recomendations = oMedicalExamFieldValuesBL.ObtenerListaRecomendaciones(ComponentFieldValuesId, _ServiceId, Constants.FUNCIONES_VITALES_ID);

                    ListaDxByComponent.Add(DxByComponent);



                    //Llenar entidad ServiceComponent
                    servicecomponentDto serviceComponentDto = new servicecomponentDto();
                    serviceComponentDto.v_ServiceComponentId       = _ServiceComponentId;
                    serviceComponentDto.v_Comment                  = "";
                    serviceComponentDto.i_ServiceComponentStatusId = (int)ServiceComponentStatus.Evaluado;
                    serviceComponentDto.i_ExternalInternalId       = (int)ComponenteProcedencia.Interno;
                    serviceComponentDto.i_IsApprovedId             = (int)SiNo.NO;
                    serviceComponentDto.v_ComponentId              = Constants.FUNCIONES_VITALES_ID;
                    serviceComponentDto.v_ServiceId                = _ServiceId;


                    _serviceBL.AddDiagnosticRepository(ref objOperationResult,
                                                       ListaDxByComponent,
                                                       serviceComponentDto,
                                                       Globals.ClientSession.GetAsList(),
                                                       true);
                }

                ListaDxByComponent = new List <DiagnosticRepositoryList>();

                if (txtPAS.Text != "")
                {
                    DiagnosticRepositoryList DxByComponent = new DiagnosticRepositoryList();

                    List <RecomendationList> Recomendations = new List <RecomendationList>();
                    List <RestrictionList>   Restrictions   = new List <RestrictionList>();
                    int PAS = int.Parse(txtPAS.Text.ToString());

                    DxByComponent.i_AutoManualId         = 1;
                    DxByComponent.i_FinalQualificationId = (int)FinalQualification.Definitivo;
                    DxByComponent.i_PreQualificationId   = 1;
                    DxByComponent.v_ComponentFieldsId    = Constants.FUNCIONES_VITALES_PAS_ID;
                    //Obtener el Componente que está amarrado al DX
                    string ComponentDx = oMedicalExamFieldValuesBL.ObtenerComponentDx(Constants.FUNCIONES_VITALES_PAS_ID);
                    string DiseasesId  = "";
                    if (PAS > 140)
                    {
                        DiseasesId = "N009-DD000000606";
                        string ComponentFieldId = Constants.FUNCIONES_VITALES_PAS_ID;

                        DiagnosticRepositoryList oDiagnosticRepositoryListOld = _serviceBL.VerificarDxExistente(_ServiceId, DiseasesId, ComponentDx, ComponentFieldId);
                        if (oDiagnosticRepositoryListOld != null)
                        {
                            oDiagnosticRepositoryListOld.v_DiagnosticRepositoryId = oDiagnosticRepositoryListOld.v_DiagnosticRepositoryId;
                            oDiagnosticRepositoryListOld.i_RecordType             = (int)RecordType.NoTemporal;
                            oDiagnosticRepositoryListOld.i_RecordStatus           = (int)RecordStatus.EliminadoLogico;
                            oDiagnosticRepositoryListOld.i_DiagnosticTypeId       = (int)TipoDx.Enfermedad_Comun;
                            ListaDxByComponent.Add(oDiagnosticRepositoryListOld);
                        }

                        DxByComponent.v_DiagnosticRepositoryId = Guid.NewGuid().ToString();
                        DxByComponent.i_RecordType             = (int)RecordType.Temporal;
                        DxByComponent.i_RecordStatus           = (int)RecordStatus.Agregado;
                        DxByComponent.i_DiagnosticTypeId       = (int)TipoDx.Enfermedad_Comun;



                        DxByComponent.d_ExpirationDateDiagnostic = DateTime.Now;

                        string ComponentFieldValuesId = oMedicalExamFieldValuesBL.ObtenerIdComponentFieldValues(ComponentFieldId, DiseasesId);
                        DxByComponent.v_ComponentFieldValuesId = ComponentFieldValuesId;


                        DxByComponent.v_ComponentId = ComponentDx;
                        DxByComponent.v_DiseasesId  = DiseasesId;
                        DxByComponent.v_ServiceId   = _ServiceId;


                        //Obtener las recomendaciones

                        DxByComponent.Recomendations = oMedicalExamFieldValuesBL.ObtenerListaRecomendaciones(ComponentFieldValuesId, _ServiceId, Constants.FUNCIONES_VITALES_ID);

                        ListaDxByComponent.Add(DxByComponent);

                        //Llenar entidad ServiceComponent
                        servicecomponentDto serviceComponentDto = new servicecomponentDto();
                        serviceComponentDto.v_ServiceComponentId       = _ServiceComponentId;
                        serviceComponentDto.v_Comment                  = "";
                        serviceComponentDto.i_ServiceComponentStatusId = (int)ServiceComponentStatus.Evaluado;
                        serviceComponentDto.i_ExternalInternalId       = (int)ComponenteProcedencia.Interno;
                        serviceComponentDto.i_IsApprovedId             = (int)SiNo.NO;
                        serviceComponentDto.v_ComponentId              = Constants.FUNCIONES_VITALES_ID;
                        serviceComponentDto.v_ServiceId                = _ServiceId;


                        _serviceBL.AddDiagnosticRepository(ref objOperationResult,
                                                           ListaDxByComponent,
                                                           serviceComponentDto,
                                                           Globals.ClientSession.GetAsList(),
                                                           true);
                    }
                }


                ListaDxByComponent = new List <DiagnosticRepositoryList>();
                if (txtICC.Text != "")
                {
                    DiagnosticRepositoryList DxByComponent = new DiagnosticRepositoryList();

                    List <RecomendationList> Recomendations = new List <RecomendationList>();
                    List <RestrictionList>   Restrictions   = new List <RestrictionList>();
                    double ICC = double.Parse(txtICC.Text.ToString());

                    DxByComponent.i_AutoManualId         = 1;
                    DxByComponent.i_FinalQualificationId = (int)FinalQualification.Definitivo;
                    DxByComponent.i_PreQualificationId   = 1;
                    DxByComponent.v_ComponentFieldsId    = Constants.ANTROPOMETRIA_INDICE_CINTURA_ID;
                    //Obtener el Componente que está amarrado al DX
                    string ComponentDx = oMedicalExamFieldValuesBL.ObtenerComponentDx(Constants.ANTROPOMETRIA_INDICE_CINTURA_ID);
                    string DiseasesId  = "";
                    if (ICC > 1)
                    {
                        DiseasesId = "N009-DD000000605";

                        string ComponentFieldId = Constants.ANTROPOMETRIA_INDICE_CINTURA_ID;

                        DiagnosticRepositoryList oDiagnosticRepositoryListOld = _serviceBL.VerificarDxExistente(_ServiceId, DiseasesId, ComponentDx, ComponentFieldId);
                        if (oDiagnosticRepositoryListOld != null)
                        {
                            oDiagnosticRepositoryListOld.v_DiagnosticRepositoryId = oDiagnosticRepositoryListOld.v_DiagnosticRepositoryId;
                            oDiagnosticRepositoryListOld.i_RecordType             = (int)RecordType.NoTemporal;
                            oDiagnosticRepositoryListOld.i_RecordStatus           = (int)RecordStatus.EliminadoLogico;
                            oDiagnosticRepositoryListOld.i_DiagnosticTypeId       = (int)TipoDx.Enfermedad_Comun;
                            ListaDxByComponent.Add(oDiagnosticRepositoryListOld);
                        }

                        DxByComponent.v_DiagnosticRepositoryId = Guid.NewGuid().ToString();
                        DxByComponent.i_RecordType             = (int)RecordType.Temporal;
                        DxByComponent.i_RecordStatus           = (int)RecordStatus.Agregado;
                        DxByComponent.i_DiagnosticTypeId       = (int)TipoDx.Enfermedad_Comun;



                        DxByComponent.d_ExpirationDateDiagnostic = DateTime.Now;

                        string ComponentFieldValuesId = oMedicalExamFieldValuesBL.ObtenerIdComponentFieldValues(ComponentFieldId, DiseasesId);
                        DxByComponent.v_ComponentFieldValuesId = ComponentFieldValuesId;


                        DxByComponent.v_ComponentId = ComponentDx;
                        DxByComponent.v_DiseasesId  = DiseasesId;
                        DxByComponent.v_ServiceId   = _ServiceId;


                        //Obtener las recomendaciones

                        DxByComponent.Recomendations = oMedicalExamFieldValuesBL.ObtenerListaRecomendaciones(ComponentFieldValuesId, _ServiceId, Constants.FUNCIONES_VITALES_ID);

                        ListaDxByComponent.Add(DxByComponent);

                        //Llenar entidad ServiceComponent
                        servicecomponentDto serviceComponentDto = new servicecomponentDto();
                        serviceComponentDto.v_ServiceComponentId       = _ServiceComponentId;
                        serviceComponentDto.v_Comment                  = "";
                        serviceComponentDto.i_ServiceComponentStatusId = (int)ServiceComponentStatus.Evaluado;
                        serviceComponentDto.i_ExternalInternalId       = (int)ComponenteProcedencia.Interno;
                        serviceComponentDto.i_IsApprovedId             = (int)SiNo.NO;
                        serviceComponentDto.v_ComponentId              = Constants.FUNCIONES_VITALES_ID;
                        serviceComponentDto.v_ServiceId                = _ServiceId;


                        _serviceBL.AddDiagnosticRepository(ref objOperationResult,
                                                           ListaDxByComponent,
                                                           serviceComponentDto,
                                                           Globals.ClientSession.GetAsList(),
                                                           true);
                    }
                }
                _serviceBL.ActualizarEstadoComponentesPorCategoria(ref objOperationResult, 10, _ServiceId, (int)ServiceComponentStatus.Evaluado, Globals.ClientSession.GetAsList());


                MessageBox.Show("Los datos se grabaron correctamente", "VALIDACIÓN!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Por favor corrija la información ingresada. Vea los indicadores de error.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 11
0
        private void Llamar()
        {
            OperationResult             objOperationResult   = new OperationResult();
            List <ServiceComponentList> ListServiceComponent = new List <ServiceComponentList>();
            CalendarBL          objCalendarBL   = new CalendarBL();
            CalendarList        objCalendar     = new CalendarList();
            List <CalendarList> objCalendarList = new List <CalendarList>();
            ProtocolBL          oProtocolBL     = new ProtocolBL();

            ServiceBL           objServiceBL           = new ServiceBL();
            servicecomponentDto objservicecomponentDto = new servicecomponentDto();

            _ServiceComponentId = new List <string>();
            // Verificar si un componente está en la categoría
            MedicalExamBL oMedicalExamBL = new MedicalExamBL();


            //Verificar si el paciente ya ha sido llamado en la BD y no en la temporal



            //var Resultado = objServiceBL.VerificarSiPacienteNoPuedeSerLlamado(grdListaLlamando.Selected.Rows[0].Cells["v_ServiceId"].Value.ToString());
            ////var Resultado = _objCalendarListAMC.Find(p => p.v_ServiceId == grdListaLlamando.Selected.Rows[0].Cells["v_ServiceId"].Value.ToString());
            //if (Resultado != null)
            //{
            //    MessageBox.Show("Usted ya llamó al paciente o el paciente está siendo llamdo por otro consultorio.", "ADVERTENCIA!", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            //    //grdListaLlamando.Enabled = false;
            //    grdLlamandoPaciente.Enabled = true;
            //    //btnRefresh.Enabled = false;

            //    chkHability.Enabled = true;

            //    btnLlamar.Enabled = false;
            //    btnRefresh_Click(null, null);

            //    if (grdLlamandoPaciente.Rows.Count > 0)
            //    {
            //        grdLlamandoPaciente.Rows[0].Selected = true;
            //        btnRellamar.Enabled = true;
            //        btnAtenderVerServicio.Enabled = true;
            //        btnLiberarFinalizarCircuito.Enabled = true;
            //    }
            //    return;
            //}


            Boolean Resultado1 = oMedicalExamBL.VerificarComponentePorCategoria(_categoriaId, Constants.ELECTROCARDIOGRAMA_ID);

            if (Resultado1)
            {
                List <ServiceComponentFieldValuesList> Valores = objServiceBL.ValoresComponente(_serviceId, Constants.ANTROPOMETRIA_ID);
                if (Valores.Count != 0)
                {
                    decimal ValorIMCServicio  = decimal.Parse(Valores.Find(p => p.v_ComponentFieldId == Constants.ANTROPOMETRIA_IMC_ID).v_Value1.ToString());
                    decimal ValorIMCProtocolo = decimal.Parse(oProtocolBL.GetProtocolComponentByProtocol(ref objOperationResult, _ProtocolId, Constants.ELECTROCARDIOGRAMA_ID).r_Imc.ToString());

                    if (ValorIMCServicio < ValorIMCProtocolo)
                    {
                        MessageBox.Show("El I.M.C. del paciente tiene valores normales, no aplica para este examen", "INFORMACIÓN!", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                        return;
                    }
                }
            }

            //Validación de Piso
            if (_Piso != "-1")
            {
                var ResultPiso = objServiceBL.PermitirLlamar(_serviceId, int.Parse(_Piso.ToString()));
                if (!ResultPiso)
                {
                    MessageBox.Show("El Paciente tiene consultorios por culminar, antes de ser llamado por este. Verifíquelo en unos minutos", "INFORMACIÓN!", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    return;
                }
            }

            if (int.Parse(_serviceStatusId) == (int)ServiceStatus.EsperandoAptitud)
            {
                MessageBox.Show("Este paciente ya tiene el servicio en espera de Aptitud, no puede ser llamado.", "INFORMACIÓN!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                return;
            }

            if (_IsCall == "OcupadoLlamado")
            {
                DialogResult Result = MessageBox.Show("Este paciente está ocupado en otro consultorio. Para llamarlo de todas formas seleccione SÍ", "ADVERTENCIA!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (Result == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
            }


            List <CalendarList> GrillaVacia = new List <CalendarList>();

            grdLlamandoPaciente.DataSource = GrillaVacia;
            grdLlamandoPaciente.ClearUndoHistory();
            // Cargar grilla de llamando al paciente  ************
            _objCalendarListAMC.Add(objCalendar);
            grdLlamandoPaciente.DataSource = _objCalendarListAMC;
            //*******************************************************

            objCalendar.v_Pacient                 = grdListaLlamando.Selected.Rows[0].Cells["v_Pacient"].Value.ToString();
            objCalendar.v_OrganizationName        = grdListaLlamando.Selected.Rows[0].Cells["v_WorkingOrganizationName"].Value.ToString();
            objCalendar.v_ServiceComponentId      = grdListaLlamando.Selected.Rows[0].Cells["v_ServiceComponentId"].Value.ToString();
            objCalendar.v_ServiceId               = grdListaLlamando.Selected.Rows[0].Cells["v_ServiceId"].Value.ToString();
            objCalendar.d_Birthdate               = DateTime.Parse(grdListaLlamando.Selected.Rows[0].Cells["d_Birthdate"].Value.ToString());
            objCalendar.v_DocNumber               = grdListaLlamando.Selected.Rows[0].Cells["v_DocNumber"].Value.ToString();
            objCalendar.v_WorkingOrganizationName = grdListaLlamando.Selected.Rows[0].Cells["v_WorkingOrganizationName"].Value.ToString();
            objCalendar.v_ProtocolName            = grdListaLlamando.Selected.Rows[0].Cells["v_ProtocolName"].Value.ToString();
            objCalendar.v_ProtocolId              = grdListaLlamando.Selected.Rows[0].Cells["v_ProtocolId"].Value.ToString();
            objCalendar.v_EsoTypeName             = grdListaLlamando.Selected.Rows[0].Cells["v_EsoTypeName"].Value.ToString();
            objCalendar.v_PersonId                = grdListaLlamando.Selected.Rows[0].Cells["v_PersonId"].Value.ToString();
            objCalendar.i_QueueStatusId           = (int)QueueStatusId.LLAMANDO;

            if (_categoryId == -1)
            {
                _ServiceComponentId.Add(grdListaLlamando.Selected.Rows[0].Cells["v_ServiceComponentId"].Value.ToString());
            }
            else
            {
                foreach (var item in objServiceBL.GetServiceComponentByCategoryId(ref objOperationResult, _categoryId, _serviceId))
                {
                    _ServiceComponentId.Add(item.v_ServiceComponentId);
                }
            }



            for (int i = 0; i < _ServiceComponentId.Count; i++)
            {
                objservicecomponentDto = new servicecomponentDto();
                objservicecomponentDto.v_ServiceComponentId = _ServiceComponentId[i];
                objservicecomponentDto.i_QueueStatusId      = (int)Common.QueueStatusId.LLAMANDO;
                objservicecomponentDto.v_NameOfice          = cbOficina.Text.ToString();
                objServiceBL.UpdateServiceComponentOfficeLlamando(objservicecomponentDto);
            }

            //Actualizar grdDataServiceComponent
            ListServiceComponent = objServiceBL.GetServiceComponents(ref objOperationResult, _serviceId);
            grdDataServiceComponent.DataSource = ListServiceComponent;

            //grdListaLlamando.Enabled = false;
            grdLlamandoPaciente.Enabled = true;
            //btnRefresh.Enabled = false;

            chkHability.Enabled = true;

            btnLlamar.Enabled = false;
        }
Exemplo n.º 12
0
        private void Liberar()
        {
            try
            {
                OperationResult objOperationResult = new OperationResult();
                ServiceBL       objServiceBL       = new ServiceBL();
                _ServiceComponentId = new List <string>();

                servicecomponentDto         objservicecomponentDto = null;
                List <ServiceComponentList> ListServiceComponent   = new List <ServiceComponentList>();


                if (grdDataServiceComponent.Rows.Count() == 0)
                {
                    MessageBox.Show("Debe seleccionar un paciente para poder LIBERARLO", "ADVERTENCIA!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (_categoryId == -1)
                {
                    _ServiceComponentId.Add(grdLlamandoPaciente.Selected.Rows[0].Cells["v_ServiceComponentId"].Value.ToString());
                }
                else
                {
                    var servCompCat = objServiceBL.GetServiceComponentByCategoryId(ref objOperationResult, _categoryId, _serviceId);

                    foreach (var item in servCompCat)
                    {
                        _ServiceComponentId.Add(item.v_ServiceComponentId);
                    }
                }

                List <servicecomponentDto> list = new List <servicecomponentDto>();

                for (int i = 0; i < _ServiceComponentId.Count; i++)
                {
                    objservicecomponentDto = new servicecomponentDto();
                    objservicecomponentDto.v_ServiceComponentId       = _ServiceComponentId[i];
                    objservicecomponentDto.i_QueueStatusId            = (int)Common.QueueStatusId.LIBRE;
                    objservicecomponentDto.i_Iscalling                = (int)SiNo.NO;
                    objservicecomponentDto.i_Iscalling_1              = (int)SiNo.NO;
                    objservicecomponentDto.d_EndDate                  = DateTime.Now;
                    objservicecomponentDto.i_ServiceComponentStatusId = (int)Common.ServiceComponentStatus.PorAprobacion;



                    list.Add(objservicecomponentDto);
                    //Buscar en la lista y reemplazar el i_QueueStatusId

                    foreach (var item in _objCalendarListAMC.Where(c => c.v_ServiceComponentId == _ServiceComponentId[i]))
                    {
                        item.i_QueueStatusId = (int)Common.QueueStatusId.LIBRE;
                    }
                }

                // update
                if (_componentName == "LABORATORIO")
                {
                    objServiceBL.UpdateServiceComponentOfficeLaboratorio(list);
                }
                else
                {
                    objServiceBL.UpdateServiceComponentOffice(list);
                }


                #region Check de salir de circuito

                if (chkHability.Checked == true) // finaliza el servicio y actualiza el estado del servicio
                {
                    if (ddlServiceStatusId.SelectedValue.ToString() == ((int)ServiceStatus.Iniciado).ToString())
                    {
                        MessageBox.Show("Debe elegir cualquier otro estado que no sea (Iniciado)\nSi desea Liberar y/o Finalizar Circuito.", "ADVERTENCIA!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    serviceDto objserviceDto = new serviceDto();

                    objserviceDto.v_ServiceId       = _serviceId;
                    objserviceDto.i_ServiceStatusId = int.Parse(ddlServiceStatusId.SelectedValue.ToString());
                    objserviceDto.v_Motive          = txtReason.Text;

                    objServiceBL.UpdateServiceOffice(ref objOperationResult, objserviceDto, Globals.ClientSession.GetAsList());

                    //Actualizamos el estado de la linea de la agenda como fuera de circuito
                    CalendarBL  objCalendarBL  = new CalendarBL();
                    calendarDto objcalendarDto = new calendarDto();
                    objcalendarDto = objCalendarBL.GetCalendar(ref objOperationResult, _CalendarId);
                    objcalendarDto.i_LineStatusId = 2;// int.Parse(Common.LineStatus.FueraCircuito.ToString());
                    objCalendarBL.UpdateCalendar(ref objOperationResult, objcalendarDto, Globals.ClientSession.GetAsList());
                }

                #endregion

                //Actualizar grdDataServiceComponent

                ListServiceComponent = objServiceBL.GetServiceComponents(ref objOperationResult, _serviceId);
                grdDataServiceComponent.DataSource = ListServiceComponent;

                btnRefresh_Click(null, null);

                txtReason.Text           = "";
                grdListaLlamando.Enabled = true;
                //grdLlamandoPaciente.Enabled = false;
                btnRefresh.Enabled  = true;
                chkHability.Enabled = false;
                chkHability.Checked = false;
                groupBox3.Enabled   = false;

                List <CalendarList> GrillaVacia = new List <CalendarList>();
                grdLlamandoPaciente.DataSource = GrillaVacia;

                _objCalendarListAMC.RemoveAll(x => x.i_QueueStatusId == 1);
                grdLlamandoPaciente.DataSource = _objCalendarListAMC;
                //grdLlamandoPaciente.DataSource = _objCalendarListAMC.FindAll(p => p.i_QueueStatusId != 1);

                //grdLlamandoPaciente.DataSource = new List<CalendarList>();

                if (_objCalendarListAMC.Count == 0)
                {
                    if (_objCalendarListAMC.Count > 0)
                    {
                        grdLlamandoPaciente.Rows[0].Selected = true;
                    }

                    btnRellamar.Enabled                 = false;
                    btnAtenderVerServicio.Enabled       = false;
                    btnLiberarFinalizarCircuito.Enabled = false;
                    grdLlamandoPaciente.Enabled         = false;
                    //grdLlamandoPaciente_Click(null, null);
                }

                else
                {
                    grdLlamandoPaciente.Rows[0].Selected = true;
                }

                //grdLlamandoPaciente.DataSource = new List<CalendarList>();
            }
            catch (Exception ex)
            {
                MessageBox.Show(Common.Utils.ExceptionFormatter(ex), "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }