Ejemplo n.º 1
0
        protected void btnSaveRefresh_Click(object sender, EventArgs e)
        {
            OperationResult objOperationResult = new OperationResult();
            diseasesDto     objDiseaseDto      = new diseasesDto();
            diseasesDto     objDiseaseDto1     = new diseasesDto();
            List <dxfrecuentedetalleDto> ListadxfrecuentedetalleDto = new List <dxfrecuentedetalleDto>();

            if (ddlExamen.SelectedValue == null || ddlExamen.SelectedValue == "-1")
            {
                Alert.Show("Por favor seleccione un examen.");
                return;
            }

            if (Session["v_DxFrecuenteId"] != null) // Grabar un Dx frecuente
            {
                //Grabar el Dx en el servicio
                Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList        _diagnosticRepository      = new Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList();
                List <Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList> _ListadiagnosticRepository = new List <Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList>();

                List <Sigesoft.Node.WinClient.BE.RecomendationList> Recomendaciones = new List <Node.WinClient.BE.RecomendationList>();
                Sigesoft.Node.WinClient.BE.RecomendationList        Recomendacion   = null;


                List <Sigesoft.Node.WinClient.BE.RestrictionList> Restricciones = new List <Node.WinClient.BE.RestrictionList>();
                Sigesoft.Node.WinClient.BE.RestrictionList        Restriccion   = null;



                _diagnosticRepository.v_DiagnosticRepositoryId = Guid.NewGuid().ToString();
                _diagnosticRepository.v_DiseasesId             = Session["DiseasesId"].ToString();
                _diagnosticRepository.i_AutoManualId           = 1;
                _diagnosticRepository.i_PreQualificationId     = 1;
                _diagnosticRepository.i_FinalQualificationId   = (int)FinalQualification.Definitivo;
                _diagnosticRepository.i_DiagnosticTypeId       = (int)TipoDx.Enfermedad_Comun;

                _diagnosticRepository.v_ServiceId    = Session["ServiceId"].ToString();
                _diagnosticRepository.v_ComponentId  = ddlExamen.SelectedValue.ToString(); //_componentId;
                _diagnosticRepository.i_RecordStatus = (int)RecordStatus.Agregado;
                _diagnosticRepository.i_RecordType   = (int)RecordType.Temporal;

                #region Recomendación
                if (txtRecomendacion1.Text.Trim() != "")
                {
                    //Verficiar si la recomendación se encuentra en la bd
                    MasterRecommendationRestricctionBL oMasterRecommendationRestricctionBL = new MasterRecommendationRestricctionBL();
                    var masterrecommendation = oMasterRecommendationRestricctionBL.GetMasterRecommendationRestricctionByName(txtRecomendacion1.Text.Trim());

                    if (masterrecommendation == null)
                    {
                        masterrecommendationrestricctionDto omasterrecommendationrestricctionDto = new masterrecommendationrestricctionDto();
                        omasterrecommendationrestricctionDto.v_Name        = txtRecomendacion1.Text.Trim();
                        omasterrecommendationrestricctionDto.i_TypifyingId = 1;
                        //Crear Recomendación
                        var MasterRecommendationId = oMasterRecommendationRestricctionBL.AddMasterRecommendationRestricction(ref objOperationResult, omasterrecommendationrestricctionDto, ((ClientSession)Session["objClientSession"]).GetAsList());

                        Recomendacion = new Node.WinClient.BE.RecomendationList();

                        Recomendacion.v_ServiceId              = Session["ServiceId"].ToString();
                        Recomendacion.v_ComponentId            = ddlExamen.SelectedValue.ToString();
                        Recomendacion.v_MasterRecommendationId = MasterRecommendationId;
                        Recomendacion.i_RecordType             = (int)RecordType.Temporal;
                        Recomendacion.i_RecordStatus           = (int)RecordStatus.Agregado;
                        Recomendaciones.Add(Recomendacion);
                    }
                    else
                    {
                        var ListaReco = oServiceBL.ObtenerListaRecomendacionesPorDxFrecuente(Session["v_DxFrecuenteId"].ToString(), 1);

                        foreach (var item in ListaReco)
                        {
                            Recomendacion = new Node.WinClient.BE.RecomendationList();

                            Recomendacion.v_ServiceId              = Session["ServiceId"].ToString();
                            Recomendacion.v_ComponentId            = ddlExamen.SelectedValue.ToString();
                            Recomendacion.v_MasterRecommendationId = item.v_MasterRecommendationRestricctionId;
                            Recomendacion.i_RecordType             = (int)RecordType.Temporal;
                            Recomendacion.i_RecordStatus           = (int)RecordStatus.Agregado;
                            Recomendaciones.Add(Recomendacion);
                        }
                    }
                }

                #endregion

                #region Restricciones

                if (txtRestriccion1.Text.Trim() != "")
                {
                    //Verficiar si la recomendación se encuentra en la bd
                    MasterRecommendationRestricctionBL oMasterRecommendationRestricctionBL = new MasterRecommendationRestricctionBL();
                    var masterrestriccion = oMasterRecommendationRestricctionBL.GetMasterRecommendationRestricctionByName(txtRestriccion1.Text.Trim());
                    if (masterrestriccion == null)
                    {
                        masterrecommendationrestricctionDto omasterrecommendationrestricctionDto = new masterrecommendationrestricctionDto();
                        omasterrecommendationrestricctionDto.v_Name        = txtRestriccion1.Text.Trim();
                        omasterrecommendationrestricctionDto.i_TypifyingId = 2;
                        //Crear Restricción
                        var MasterRestriccionId = oMasterRecommendationRestricctionBL.AddMasterRecommendationRestricction(ref objOperationResult, omasterrecommendationrestricctionDto, ((ClientSession)Session["objClientSession"]).GetAsList());

                        Restriccion = new Node.WinClient.BE.RestrictionList();

                        Restriccion.v_ServiceId           = Session["ServiceId"].ToString();
                        Restriccion.v_ComponentId         = ddlExamen.SelectedValue.ToString();
                        Restriccion.v_MasterRestrictionId = MasterRestriccionId;
                        Restriccion.i_RecordType          = (int)RecordType.Temporal;
                        Restriccion.i_RecordStatus        = (int)RecordStatus.Agregado;
                        Restricciones.Add(Restriccion);
                    }
                    else
                    {
                        var ListaRestri = oServiceBL.ObtenerListaRecomendacionesPorDxFrecuente(Session["v_DxFrecuenteId"].ToString(), 2);

                        foreach (var item1 in ListaRestri)
                        {
                            Restriccion = new Node.WinClient.BE.RestrictionList();

                            Restriccion.v_ServiceId           = Session["ServiceId"].ToString();
                            Restriccion.v_ComponentId         = ddlExamen.SelectedValue.ToString();
                            Restriccion.v_MasterRestrictionId = item1.v_MasterRecommendationRestricctionId;
                            Restriccion.i_RecordType          = (int)RecordType.Temporal;
                            Restriccion.i_RecordStatus        = (int)RecordStatus.Agregado;
                            Restricciones.Add(Restriccion);
                        }
                    }
                }

                #endregion

                _diagnosticRepository.Restrictions   = Restricciones;
                _diagnosticRepository.Recomendations = Recomendaciones;

                _ListadiagnosticRepository.Add(_diagnosticRepository);

                oServiceBL.AddDiagnosticRepository(ref objOperationResult, _ListadiagnosticRepository, null, ((ClientSession)Session["objClientSession"]).GetAsList(), true);

                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.
                }
            }
            else if (Session["DiseasesId"] == null)
            {
                #region Crear el Dx Frecuente

                objDiseaseDto.v_CIE10Id = Session["Cie10Id"].ToString();
                objDiseaseDto.v_Name    = txtDxActualizado.Text;

                objDiseaseDto1 = oServiceBL.GetIsValidateDiseases(ref objOperationResult, objDiseaseDto.v_Name);
                string DxFrecuneteId = null;
                if (objDiseaseDto1 == null)
                {
                    //Creo el Diseases
                    objDiseaseDto.v_DiseasesId = oServiceBL.AddDiseases(ref objOperationResult, objDiseaseDto, ((ClientSession)Session["objClientSession"]).GetAsList());

                    //Crear nuevo Dx Frecuente y lo amarro al diseasesId creado
                    DxFrecuenteBL  oDxFrecuenteBL  = new DxFrecuenteBL();
                    dxfrecuenteDto odxfrecuenteDto = new dxfrecuenteDto();
                    odxfrecuenteDto.v_DiseasesId = objDiseaseDto.v_DiseasesId;
                    odxfrecuenteDto.v_CIE10Id    = Session["Cie10Id"].ToString();
                    DxFrecuneteId = oDxFrecuenteBL.AddDxFrecuente(ref objOperationResult, odxfrecuenteDto, ((ClientSession)Session["objClientSession"]).GetAsList());

                    //Agregar Recomendaciones a Dx Frecuente
                    dxfrecuentedetalleDto odxfrecuentedetalleDto = new dxfrecuentedetalleDto();

                    //Verficiar si la recomendación se encuentra en la bd
                    MasterRecommendationRestricctionBL oMasterRecommendationRestricctionBL = new MasterRecommendationRestricctionBL();
                    var masterrecommendation   = oMasterRecommendationRestricctionBL.GetMasterRecommendationRestricctionByName(txtRecomendacion1.Text.Trim());
                    var MasterRecommendationId = "";
                    if (masterrecommendation == null)
                    {
                        masterrecommendationrestricctionDto omasterrecommendationrestricctionDto = new masterrecommendationrestricctionDto();
                        omasterrecommendationrestricctionDto.v_Name        = txtRecomendacion1.Text.Trim();
                        omasterrecommendationrestricctionDto.i_TypifyingId = 1;
                        //Crear Recomendación
                        MasterRecommendationId = oMasterRecommendationRestricctionBL.AddMasterRecommendationRestricction(ref objOperationResult, omasterrecommendationrestricctionDto, ((ClientSession)Session["objClientSession"]).GetAsList());
                    }
                    odxfrecuentedetalleDto.v_DxFrecuenteId = DxFrecuneteId;
                    odxfrecuentedetalleDto.v_MasterRecommendationRestricctionId = MasterRecommendationId;
                    ListadxfrecuentedetalleDto.Add(odxfrecuentedetalleDto);


                    odxfrecuentedetalleDto = new dxfrecuentedetalleDto();
                    //Agregar Restricciones a Dx Frecuente
                    var masterrestriccion   = oMasterRecommendationRestricctionBL.GetMasterRecommendationRestricctionByName(txtRestriccion1.Text.Trim());
                    var MasterRestriccionId = "";
                    if (masterrestriccion == null)
                    {
                        masterrecommendationrestricctionDto omasterrecommendationrestricctionDto = new masterrecommendationrestricctionDto();
                        omasterrecommendationrestricctionDto.v_Name        = txtRestriccion1.Text.Trim();
                        omasterrecommendationrestricctionDto.i_TypifyingId = 2;
                        //Crear Restricción
                        MasterRestriccionId = oMasterRecommendationRestricctionBL.AddMasterRecommendationRestricction(ref objOperationResult, omasterrecommendationrestricctionDto, ((ClientSession)Session["objClientSession"]).GetAsList());
                    }
                    odxfrecuentedetalleDto.v_DxFrecuenteId = DxFrecuneteId;
                    odxfrecuentedetalleDto.v_MasterRecommendationRestricctionId = MasterRestriccionId;
                    ListadxfrecuentedetalleDto.Add(odxfrecuentedetalleDto);
                    //Agrego el detalle de los dxfrecuentes creados
                    foreach (var item in ListadxfrecuentedetalleDto)
                    {
                        oDxFrecuenteBL.AddDxFrecuenteDetalle(ref objOperationResult, item, ((ClientSession)Session["objClientSession"]).GetAsList());
                    }
                }
                else
                {
                    Alert.Show("Escoja uno que tenga código interno", "Error de validación", MessageBoxIcon.Warning);
                    return;
                }

                #endregion

                #region Grabo el dx al servicio

                //Grabar el Dx en el servicio
                Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList        _diagnosticRepository      = new Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList();
                List <Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList> _ListadiagnosticRepository = new List <Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList>();

                List <Sigesoft.Node.WinClient.BE.RecomendationList> Recomendaciones = new List <Node.WinClient.BE.RecomendationList>();
                Sigesoft.Node.WinClient.BE.RecomendationList        Recomendacion   = null;


                List <Sigesoft.Node.WinClient.BE.RestrictionList> Restricciones = new List <Node.WinClient.BE.RestrictionList>();
                Sigesoft.Node.WinClient.BE.RestrictionList        Restriccion   = null;



                _diagnosticRepository.v_DiagnosticRepositoryId = Guid.NewGuid().ToString();
                _diagnosticRepository.v_DiseasesId             = objDiseaseDto.v_DiseasesId;
                _diagnosticRepository.i_AutoManualId           = 1;
                _diagnosticRepository.i_PreQualificationId     = 1;
                _diagnosticRepository.i_FinalQualificationId   = (int)FinalQualification.Definitivo;
                _diagnosticRepository.i_DiagnosticTypeId       = (int)TipoDx.Enfermedad_Comun;

                _diagnosticRepository.v_ServiceId    = Session["ServiceId"].ToString();
                _diagnosticRepository.v_ComponentId  = ddlExamen.SelectedValue.ToString(); //_componentId;
                _diagnosticRepository.i_RecordStatus = (int)RecordStatus.Agregado;
                _diagnosticRepository.i_RecordType   = (int)RecordType.Temporal;

                #region Recomendación
                if (txtRecomendacion1.Text.Trim() != "")
                {
                    //Verficiar si la recomendación se encuentra en la bd
                    MasterRecommendationRestricctionBL oMasterRecommendationRestricctionBL = new MasterRecommendationRestricctionBL();
                    var masterrecommendation = oMasterRecommendationRestricctionBL.GetMasterRecommendationRestricctionByName(txtRecomendacion1.Text.Trim());

                    if (masterrecommendation == null)
                    {
                        masterrecommendationrestricctionDto omasterrecommendationrestricctionDto = new masterrecommendationrestricctionDto();
                        omasterrecommendationrestricctionDto.v_Name        = txtRecomendacion1.Text.Trim();
                        omasterrecommendationrestricctionDto.i_TypifyingId = 1;
                        //Crear Recomendación
                        var MasterRecommendationId = oMasterRecommendationRestricctionBL.AddMasterRecommendationRestricction(ref objOperationResult, omasterrecommendationrestricctionDto, ((ClientSession)Session["objClientSession"]).GetAsList());

                        Recomendacion = new Node.WinClient.BE.RecomendationList();

                        Recomendacion.v_ServiceId              = Session["ServiceId"].ToString();
                        Recomendacion.v_ComponentId            = ddlExamen.SelectedValue.ToString();
                        Recomendacion.v_MasterRecommendationId = MasterRecommendationId;
                        Recomendacion.i_RecordType             = (int)RecordType.Temporal;
                        Recomendacion.i_RecordStatus           = (int)RecordStatus.Agregado;
                        Recomendaciones.Add(Recomendacion);
                    }
                    else
                    {
                        var ListaReco = oServiceBL.ObtenerListaRecomendacionesPorDxFrecuente(DxFrecuneteId, 1);

                        foreach (var item in ListaReco)
                        {
                            Recomendacion = new Node.WinClient.BE.RecomendationList();

                            Recomendacion.v_ServiceId              = Session["ServiceId"].ToString();
                            Recomendacion.v_ComponentId            = ddlExamen.SelectedValue.ToString();
                            Recomendacion.v_MasterRecommendationId = item.v_MasterRecommendationRestricctionId;
                            Recomendacion.i_RecordType             = (int)RecordType.Temporal;
                            Recomendacion.i_RecordStatus           = (int)RecordStatus.Agregado;
                            Recomendaciones.Add(Recomendacion);
                        }
                    }
                }

                #endregion

                #region Restricciones

                if (txtRestriccion1.Text.Trim() != "")
                {
                    //Verficiar si la recomendación se encuentra en la bd
                    MasterRecommendationRestricctionBL oMasterRecommendationRestricctionBL = new MasterRecommendationRestricctionBL();
                    var masterrestriccion = oMasterRecommendationRestricctionBL.GetMasterRecommendationRestricctionByName(txtRestriccion1.Text.Trim());
                    if (masterrestriccion == null)
                    {
                        masterrecommendationrestricctionDto omasterrecommendationrestricctionDto = new masterrecommendationrestricctionDto();
                        omasterrecommendationrestricctionDto.v_Name        = txtRestriccion1.Text.Trim();
                        omasterrecommendationrestricctionDto.i_TypifyingId = 2;
                        //Crear Restricción
                        var MasterRestriccionId = oMasterRecommendationRestricctionBL.AddMasterRecommendationRestricction(ref objOperationResult, omasterrecommendationrestricctionDto, ((ClientSession)Session["objClientSession"]).GetAsList());

                        Restriccion = new Node.WinClient.BE.RestrictionList();

                        Restriccion.v_ServiceId           = Session["ServiceId"].ToString();
                        Restriccion.v_ComponentId         = ddlExamen.SelectedValue.ToString();
                        Restriccion.v_MasterRestrictionId = MasterRestriccionId;
                        Restriccion.i_RecordType          = (int)RecordType.Temporal;
                        Restriccion.i_RecordStatus        = (int)RecordStatus.Agregado;
                        Restricciones.Add(Restriccion);
                    }
                    else
                    {
                        var ListaRestri = oServiceBL.ObtenerListaRecomendacionesPorDxFrecuente(DxFrecuneteId, 2);

                        foreach (var item1 in ListaRestri)
                        {
                            Restriccion = new Node.WinClient.BE.RestrictionList();

                            Restriccion.v_ServiceId           = Session["ServiceId"].ToString();
                            Restriccion.v_ComponentId         = ddlExamen.SelectedValue.ToString();
                            Restriccion.v_MasterRestrictionId = item1.v_MasterRecommendationRestricctionId;
                            Restriccion.i_RecordType          = (int)RecordType.Temporal;
                            Restriccion.i_RecordStatus        = (int)RecordStatus.Agregado;
                            Restricciones.Add(Restriccion);
                        }
                    }
                }

                #endregion

                _diagnosticRepository.Restrictions   = Restricciones;
                _diagnosticRepository.Recomendations = Recomendaciones;

                _ListadiagnosticRepository.Add(_diagnosticRepository);

                oServiceBL.AddDiagnosticRepository(ref objOperationResult, _ListadiagnosticRepository, null, ((ClientSession)Session["objClientSession"]).GetAsList(), true);

                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.
                }
                #endregion
            }
            else if (Session["DiseasesId"] != null)
            {
                string DxFrecuneteId = null;
                objDiseaseDto = oServiceBL.GetDiseases(ref objOperationResult, Session["DiseasesId"].ToString());

                objDiseaseDto.v_CIE10Id = Session["Cie10Id"].ToString();
                objDiseaseDto.v_Name    = txtDxActualizado.Text;
                oServiceBL.UpdateDiseases(ref objOperationResult, objDiseaseDto, ((ClientSession)Session["objClientSession"]).GetAsList());

                #region Crear el Dx Frecuente
                //Crear nuevo Dx Frecuente y lo amarro al diseasesId creado
                DxFrecuenteBL  oDxFrecuenteBL  = new DxFrecuenteBL();
                dxfrecuenteDto odxfrecuenteDto = new dxfrecuenteDto();
                odxfrecuenteDto.v_DiseasesId = objDiseaseDto.v_DiseasesId;
                odxfrecuenteDto.v_CIE10Id    = Session["Cie10Id"].ToString();
                DxFrecuneteId = oDxFrecuenteBL.AddDxFrecuente(ref objOperationResult, odxfrecuenteDto, ((ClientSession)Session["objClientSession"]).GetAsList());

                //Agregar Recomendaciones a Dx Frecuente
                dxfrecuentedetalleDto odxfrecuentedetalleDto = new dxfrecuentedetalleDto();

                //Verficiar si la recomendación se encuentra en la bd
                MasterRecommendationRestricctionBL oMasterRecommendationRestricctionBL = new MasterRecommendationRestricctionBL();
                var masterrecommendation   = oMasterRecommendationRestricctionBL.GetMasterRecommendationRestricctionByName(txtRecomendacion1.Text.Trim());
                var MasterRecommendationId = "";
                if (masterrecommendation == null)
                {
                    masterrecommendationrestricctionDto omasterrecommendationrestricctionDto = new masterrecommendationrestricctionDto();
                    omasterrecommendationrestricctionDto.v_Name        = txtRecomendacion1.Text.Trim();
                    omasterrecommendationrestricctionDto.i_TypifyingId = 1;
                    //Crear Recomendación
                    MasterRecommendationId = oMasterRecommendationRestricctionBL.AddMasterRecommendationRestricction(ref objOperationResult, omasterrecommendationrestricctionDto, ((ClientSession)Session["objClientSession"]).GetAsList());
                }
                odxfrecuentedetalleDto.v_DxFrecuenteId = DxFrecuneteId;
                odxfrecuentedetalleDto.v_MasterRecommendationRestricctionId = MasterRecommendationId;
                ListadxfrecuentedetalleDto.Add(odxfrecuentedetalleDto);


                odxfrecuentedetalleDto = new dxfrecuentedetalleDto();
                //Agregar Restricciones a Dx Frecuente
                var masterrestriccion   = oMasterRecommendationRestricctionBL.GetMasterRecommendationRestricctionByName(txtRestriccion1.Text.Trim());
                var MasterRestriccionId = "";
                if (masterrestriccion == null)
                {
                    masterrecommendationrestricctionDto omasterrecommendationrestricctionDto = new masterrecommendationrestricctionDto();
                    omasterrecommendationrestricctionDto.v_Name        = txtRestriccion1.Text.Trim();
                    omasterrecommendationrestricctionDto.i_TypifyingId = 2;
                    //Crear Restricción
                    MasterRestriccionId = oMasterRecommendationRestricctionBL.AddMasterRecommendationRestricction(ref objOperationResult, omasterrecommendationrestricctionDto, ((ClientSession)Session["objClientSession"]).GetAsList());
                }
                odxfrecuentedetalleDto.v_DxFrecuenteId = DxFrecuneteId;
                odxfrecuentedetalleDto.v_MasterRecommendationRestricctionId = MasterRestriccionId;
                ListadxfrecuentedetalleDto.Add(odxfrecuentedetalleDto);
                //Agrego el detalle de los dxfrecuentes creados
                foreach (var item in ListadxfrecuentedetalleDto)
                {
                    oDxFrecuenteBL.AddDxFrecuenteDetalle(ref objOperationResult, item, ((ClientSession)Session["objClientSession"]).GetAsList());
                }
                #endregion

                #region Grabo el dx al servicio

                //Grabar el Dx en el servicio
                Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList        _diagnosticRepository      = new Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList();
                List <Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList> _ListadiagnosticRepository = new List <Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList>();

                List <Sigesoft.Node.WinClient.BE.RecomendationList> Recomendaciones = new List <Node.WinClient.BE.RecomendationList>();
                Sigesoft.Node.WinClient.BE.RecomendationList        Recomendacion   = null;


                List <Sigesoft.Node.WinClient.BE.RestrictionList> Restricciones = new List <Node.WinClient.BE.RestrictionList>();
                Sigesoft.Node.WinClient.BE.RestrictionList        Restriccion   = null;



                _diagnosticRepository.v_DiagnosticRepositoryId = Guid.NewGuid().ToString();
                _diagnosticRepository.v_DiseasesId             = objDiseaseDto.v_DiseasesId;
                _diagnosticRepository.i_AutoManualId           = 1;
                _diagnosticRepository.i_PreQualificationId     = 1;
                _diagnosticRepository.i_FinalQualificationId   = (int)FinalQualification.Definitivo;
                _diagnosticRepository.i_DiagnosticTypeId       = (int)TipoDx.Enfermedad_Comun;

                _diagnosticRepository.v_ServiceId    = Session["ServiceId"].ToString();
                _diagnosticRepository.v_ComponentId  = ddlExamen.SelectedValue.ToString(); //_componentId;
                _diagnosticRepository.i_RecordStatus = (int)RecordStatus.Agregado;
                _diagnosticRepository.i_RecordType   = (int)RecordType.Temporal;

                #region Recomendación
                if (txtRecomendacion1.Text.Trim() != "")
                {
                    //Verficiar si la recomendación se encuentra en la bd
                    masterrecommendation = oMasterRecommendationRestricctionBL.GetMasterRecommendationRestricctionByName(txtRecomendacion1.Text.Trim());

                    if (masterrecommendation == null)
                    {
                        masterrecommendationrestricctionDto omasterrecommendationrestricctionDto = new masterrecommendationrestricctionDto();
                        omasterrecommendationrestricctionDto.v_Name        = txtRecomendacion1.Text.Trim();
                        omasterrecommendationrestricctionDto.i_TypifyingId = 1;
                        //Crear Recomendación
                        MasterRecommendationId = oMasterRecommendationRestricctionBL.AddMasterRecommendationRestricction(ref objOperationResult, omasterrecommendationrestricctionDto, ((ClientSession)Session["objClientSession"]).GetAsList());

                        Recomendacion = new Node.WinClient.BE.RecomendationList();

                        Recomendacion.v_ServiceId              = Session["ServiceId"].ToString();
                        Recomendacion.v_ComponentId            = ddlExamen.SelectedValue.ToString();
                        Recomendacion.v_MasterRecommendationId = MasterRecommendationId;
                        Recomendacion.i_RecordType             = (int)RecordType.Temporal;
                        Recomendacion.i_RecordStatus           = (int)RecordStatus.Agregado;
                        Recomendaciones.Add(Recomendacion);
                    }
                    else
                    {
                        var ListaReco = oServiceBL.ObtenerListaRecomendacionesPorDxFrecuente(DxFrecuneteId, 1);

                        foreach (var item in ListaReco)
                        {
                            Recomendacion = new Node.WinClient.BE.RecomendationList();

                            Recomendacion.v_ServiceId              = Session["ServiceId"].ToString();
                            Recomendacion.v_ComponentId            = ddlExamen.SelectedValue.ToString();
                            Recomendacion.v_MasterRecommendationId = item.v_MasterRecommendationRestricctionId;
                            Recomendacion.i_RecordType             = (int)RecordType.Temporal;
                            Recomendacion.i_RecordStatus           = (int)RecordStatus.Agregado;
                            Recomendaciones.Add(Recomendacion);
                        }
                    }
                }

                #endregion

                #region Restricciones

                if (txtRestriccion1.Text.Trim() != "")
                {
                    //Verficiar si la recomendación se encuentra en la bd

                    masterrestriccion = oMasterRecommendationRestricctionBL.GetMasterRecommendationRestricctionByName(txtRestriccion1.Text.Trim());
                    if (masterrestriccion == null)
                    {
                        masterrecommendationrestricctionDto omasterrecommendationrestricctionDto = new masterrecommendationrestricctionDto();
                        omasterrecommendationrestricctionDto.v_Name        = txtRestriccion1.Text.Trim();
                        omasterrecommendationrestricctionDto.i_TypifyingId = 2;
                        //Crear Restricción
                        MasterRestriccionId = oMasterRecommendationRestricctionBL.AddMasterRecommendationRestricction(ref objOperationResult, omasterrecommendationrestricctionDto, ((ClientSession)Session["objClientSession"]).GetAsList());

                        Restriccion = new Node.WinClient.BE.RestrictionList();

                        Restriccion.v_ServiceId           = Session["ServiceId"].ToString();
                        Restriccion.v_ComponentId         = ddlExamen.SelectedValue.ToString();
                        Restriccion.v_MasterRestrictionId = MasterRestriccionId;
                        Restriccion.i_RecordType          = (int)RecordType.Temporal;
                        Restriccion.i_RecordStatus        = (int)RecordStatus.Agregado;
                        Restricciones.Add(Restriccion);
                    }
                    else
                    {
                        var ListaRestri = oServiceBL.ObtenerListaRecomendacionesPorDxFrecuente(DxFrecuneteId, 2);

                        foreach (var item1 in ListaRestri)
                        {
                            Restriccion = new Node.WinClient.BE.RestrictionList();

                            Restriccion.v_ServiceId           = Session["ServiceId"].ToString();
                            Restriccion.v_ComponentId         = ddlExamen.SelectedValue.ToString();
                            Restriccion.v_MasterRestrictionId = item1.v_MasterRecommendationRestricctionId;
                            Restriccion.i_RecordType          = (int)RecordType.Temporal;
                            Restriccion.i_RecordStatus        = (int)RecordStatus.Agregado;
                            Restricciones.Add(Restriccion);
                        }
                    }
                }

                #endregion

                _diagnosticRepository.Restrictions   = Restricciones;
                _diagnosticRepository.Recomendations = Recomendaciones;

                _ListadiagnosticRepository.Add(_diagnosticRepository);

                oServiceBL.AddDiagnosticRepository(ref objOperationResult, _ListadiagnosticRepository, null, ((ClientSession)Session["objClientSession"]).GetAsList(), true);

                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.
                }
                #endregion
            }
        }
        protected void btnSaveRefresh_Click(object sender, EventArgs e)
        {
            OperationResult objOperationResult = new OperationResult();
            ServiceBL       oServiceBL         = new ServiceBL();
            List <Sigesoft.Node.WinClient.BE.RecomendationList>        Recomendaciones            = new List <Node.WinClient.BE.RecomendationList>();
            List <Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList> _ListadiagnosticRepository = new List <Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList>();

            Sigesoft.Node.WinClient.BE.RecomendationList        Recomendacion        = null;
            Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList diagnosticRepository = new Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList();

            string Mode = Request.QueryString["Mode"].ToString();

            if (Mode == "New")
            {
                //Verificar si el hábito ya existe en la grilla
                var Result = _objHistoryBL.ListarGrillaNocivos(Session["PersonId"].ToString()).Find(p => p.i_TypeHabitsId == int.Parse(ddlTipoHabito.SelectedValue.ToString()));

                if (Result != null)
                {
                    Alert.ShowInTop("Este hábito nocivo ya se encuentra registrado, revíselo y edítelo.");
                    return;
                }
                noxioushabitsDto onoxioushabitsDto = new noxioushabitsDto();
                onoxioushabitsDto.i_TypeHabitsId = int.Parse(ddlTipoHabito.SelectedValue.ToString());
                onoxioushabitsDto.v_Frequency    = ddlFrecuencia.SelectedText.ToString();
                onoxioushabitsDto.v_PersonId     = Session["PersonId"].ToString();
                onoxioushabitsDto.v_Comment      = txtComentario.Text;

                _objHistoryBL.AddNocivo(ref objOperationResult, onoxioushabitsDto, ((ClientSession)Session["objClientSession"]).GetAsList());

                if (ddlFrecuencia.SelectedText.ToString() == "FUMADOR")
                {
                    diagnosticRepository.v_DiagnosticRepositoryId = Guid.NewGuid().ToString();
                    diagnosticRepository.v_DiseasesId             = "N009-DD000000519";
                    diagnosticRepository.i_AutoManualId           = 1;
                    diagnosticRepository.i_PreQualificationId     = 1;
                    diagnosticRepository.i_FinalQualificationId   = (int)FinalQualification.Definitivo;
                    diagnosticRepository.i_DiagnosticTypeId       = (int)TipoDx.Enfermedad_Comun;

                    diagnosticRepository.v_ServiceId    = Session["ServiceId"].ToString();
                    diagnosticRepository.v_ComponentId  = "N002-ME000000022"; //_componentId;
                    diagnosticRepository.i_RecordStatus = (int)RecordStatus.Agregado;
                    diagnosticRepository.i_RecordType   = (int)RecordType.Temporal;

                    var ListaReco = oServiceBL.ObtenerListaRecomendacionesPorDxFrecuente("N002-HG000000229", 1);

                    foreach (var item in ListaReco)
                    {
                        Recomendacion = new Node.WinClient.BE.RecomendationList();

                        Recomendacion.v_ServiceId              = Session["ServiceId"].ToString();
                        Recomendacion.v_ComponentId            = "N002-ME000000022";
                        Recomendacion.v_MasterRecommendationId = item.v_MasterRecommendationRestricctionId;
                        Recomendacion.i_RecordType             = (int)RecordType.Temporal;
                        Recomendacion.i_RecordStatus           = (int)RecordStatus.Agregado;
                        Recomendaciones.Add(Recomendacion);
                    }

                    diagnosticRepository.Recomendations = Recomendaciones;
                    _ListadiagnosticRepository.Add(diagnosticRepository);
                    oServiceBL.AddDiagnosticRepository(ref objOperationResult, _ListadiagnosticRepository, null, ((ClientSession)Session["objClientSession"]).GetAsList(), true);
                }
            }
            else if (Mode == "Edit")
            {
                noxioushabitsDto onoxioushabitsDto = (noxioushabitsDto)Session["objEntity"];

                onoxioushabitsDto.i_TypeHabitsId = int.Parse(ddlTipoHabito.SelectedValue.ToString());
                onoxioushabitsDto.v_Frequency    = ddlFrecuencia.SelectedText.ToString();
                onoxioushabitsDto.v_Comment      = txtComentario.Text;

                _objHistoryBL.UpdateNocivo(ref objOperationResult, onoxioushabitsDto, ((ClientSession)Session["objClientSession"]).GetAsList());

                if (ddlFrecuencia.SelectedText.ToString() == "FUMADOR")
                {
                    diagnosticRepository.v_DiagnosticRepositoryId = Guid.NewGuid().ToString();
                    diagnosticRepository.v_DiseasesId             = "N009-DD000000519";
                    diagnosticRepository.i_AutoManualId           = 1;
                    diagnosticRepository.i_PreQualificationId     = 1;
                    diagnosticRepository.i_FinalQualificationId   = (int)FinalQualification.Definitivo;
                    diagnosticRepository.i_DiagnosticTypeId       = (int)TipoDx.Enfermedad_Comun;

                    diagnosticRepository.v_ServiceId    = Session["ServiceId"].ToString();
                    diagnosticRepository.v_ComponentId  = "N002-ME000000022"; //_componentId;
                    diagnosticRepository.i_RecordStatus = (int)RecordStatus.Agregado;
                    diagnosticRepository.i_RecordType   = (int)RecordType.Temporal;

                    var ListaReco = oServiceBL.ObtenerListaRecomendacionesPorDxFrecuente("N002-HG000000229", 1);

                    foreach (var item in ListaReco)
                    {
                        Recomendacion = new Node.WinClient.BE.RecomendationList();

                        Recomendacion.v_ServiceId              = Session["ServiceId"].ToString();
                        Recomendacion.v_ComponentId            = "N002-ME000000022";
                        Recomendacion.v_MasterRecommendationId = item.v_MasterRecommendationRestricctionId;
                        Recomendacion.i_RecordType             = (int)RecordType.Temporal;
                        Recomendacion.i_RecordStatus           = (int)RecordStatus.Agregado;
                        Recomendaciones.Add(Recomendacion);
                    }

                    diagnosticRepository.Recomendations = Recomendaciones;
                    _ListadiagnosticRepository.Add(diagnosticRepository);
                    oServiceBL.AddDiagnosticRepository(ref objOperationResult, _ListadiagnosticRepository, null, ((ClientSession)Session["objClientSession"]).GetAsList(), true);
                }
            }
            //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.
            }
        }
Ejemplo n.º 3
0
        protected void btnSaveRefresh_Click(object sender, EventArgs e)
        {
            if (ddlExamen.SelectedValue == null || ddlExamen.SelectedValue == "-1")
            {
                Alert.Show("Por favor seleccione un examen.");
                return;
            }
            OperationResult objOperationResult = new OperationResult();

            //Grabar el Dx en el servicio
            Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList        _diagnosticRepository      = new Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList();
            List <Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList> _ListadiagnosticRepository = new List <Sigesoft.Node.WinClient.BE.DiagnosticRepositoryList>();

            List <Sigesoft.Node.WinClient.BE.RecomendationList> Recomendaciones = new List <Node.WinClient.BE.RecomendationList>();

            Sigesoft.Node.WinClient.BE.RecomendationList Recomendacion = null;


            List <Sigesoft.Node.WinClient.BE.RestrictionList> Restricciones = new List <Node.WinClient.BE.RestrictionList>();

            Sigesoft.Node.WinClient.BE.RestrictionList Restriccion = null;



            _diagnosticRepository.v_DiagnosticRepositoryId = Guid.NewGuid().ToString();
            _diagnosticRepository.v_DiseasesId             = Session["DiseasesId"].ToString();
            _diagnosticRepository.i_AutoManualId           = 1;
            _diagnosticRepository.i_PreQualificationId     = 1;
            _diagnosticRepository.i_FinalQualificationId   = (int)FinalQualification.Definitivo;
            _diagnosticRepository.i_DiagnosticTypeId       = (int)TipoDx.Enfermedad_Comun;

            _diagnosticRepository.v_ServiceId    = Session["ServiceId"].ToString();
            _diagnosticRepository.v_ComponentId  = ddlExamen.SelectedValue.ToString(); //_componentId;
            _diagnosticRepository.i_RecordStatus = (int)RecordStatus.Agregado;
            _diagnosticRepository.i_RecordType   = (int)RecordType.Temporal;


            var ListaReco = oServiceBL.ObtenerListaRecomendacionesPorDxFrecuente(Session["v_DxFrecuenteId"].ToString(), 1);

            foreach (var item in ListaReco)
            {
                Recomendacion = new Node.WinClient.BE.RecomendationList();

                Recomendacion.v_ServiceId              = Session["ServiceId"].ToString();
                Recomendacion.v_ComponentId            = ddlExamen.SelectedValue.ToString();
                Recomendacion.v_MasterRecommendationId = item.v_MasterRecommendationRestricctionId;
                Recomendacion.i_RecordType             = (int)RecordType.Temporal;
                Recomendacion.i_RecordStatus           = (int)RecordStatus.Agregado;
                Recomendaciones.Add(Recomendacion);
            }

            var ListaRestri = oServiceBL.ObtenerListaRecomendacionesPorDxFrecuente(Session["v_DxFrecuenteId"].ToString(), 2);

            foreach (var item1 in ListaRestri)
            {
                Restriccion = new Node.WinClient.BE.RestrictionList();

                Restriccion.v_ServiceId           = Session["ServiceId"].ToString();
                Restriccion.v_ComponentId         = ddlExamen.SelectedValue.ToString();
                Restriccion.v_MasterRestrictionId = item1.v_MasterRecommendationRestricctionId;
                Restriccion.i_RecordType          = (int)RecordType.Temporal;
                Restriccion.i_RecordStatus        = (int)RecordStatus.Agregado;
                Restricciones.Add(Restriccion);
            }



            _diagnosticRepository.Restrictions   = Restricciones;
            _diagnosticRepository.Recomendations = Recomendaciones;

            _ListadiagnosticRepository.Add(_diagnosticRepository);

            oServiceBL.AddDiagnosticRepository(ref objOperationResult, _ListadiagnosticRepository, null, ((ClientSession)Session["objClientSession"]).GetAsList(), true);

            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.
            }
        }