public frmOccupationalHistory(string pstrMode, string pstrHistoryId, string pstrPacientId, bool Validation)
        {
            OperationResult objOperationResult = new OperationResult();

            PacientBL   objPacientBL = new PacientBL();
            PacientList objpersonDto = new PacientList();

            InitializeComponent();

            objpersonDto = objPacientBL.GetPacient(ref objOperationResult, pstrPacientId, null);
            this.Text    = this.Text + "  (" + objpersonDto.v_FirstName + " " + objpersonDto.v_FirstLastName + " " + objpersonDto.v_SecondLastName + ")";

            _Mode      = pstrMode;
            _HistoryId = pstrHistoryId;
            _PacientId = pstrPacientId;

            Utils.LoadDropDownList(ddlTypeOperationId, "Value1", "Id", BLL.Utils.GetSystemParameterForCombo(ref objOperationResult, 204, null), DropDownListAction.Select);

            //frmHistory frm = new frmHistory(_PacientId);
            //bool ResultValidation = false;
            //ResultValidation = frm._Validation;

            //if (Validation)
            //{
            //    btnSave.Enabled = true;
            //}
            //else
            //{
            //    btnSave.Enabled = false;
            //}
        }
Beispiel #2
0
        private void frmPacientEdiccion_Load(object sender, EventArgs e)
        {
            OperationResult objOperationResult = new OperationResult();

            dtpBirthdate.CustomFormat = "dd/MM/yyyy";
            //Llenado de combos
            Utils.LoadDropDownList(ddlMaritalStatusId, "Value1", "Id", BLL.Utils.GetSystemParameterForCombo(ref objOperationResult, 101, null), DropDownListAction.Select);
            Utils.LoadDropDownList(ddlDocTypeId, "Value1", "Id", BLL.Utils.GetDataHierarchyForCombo(ref objOperationResult, 106, null), DropDownListAction.Select);
            Utils.LoadDropDownList(ddlSexTypeId, "Value1", "Id", BLL.Utils.GetSystemParameterForCombo(ref objOperationResult, 100, null), DropDownListAction.Select);
            Utils.LoadDropDownList(ddlLevelOfId, "Value1", "Id", BLL.Utils.GetDataHierarchyForCombo(ref objOperationResult, 108, null), DropDownListAction.Select);
            Utils.LoadDropDownList(ddlBloodGroupId, "Value1", "Id", BLL.Utils.GetSystemParameterForCombo(ref objOperationResult, 154, null), DropDownListAction.Select);
            Utils.LoadDropDownList(ddlBloodFactorId, "Value1", "Id", BLL.Utils.GetSystemParameterForCombo(ref objOperationResult, 155, null), DropDownListAction.Select);

            Utils.LoadDropDownList(ddlRelationshipId, "Value1", "Id", BLL.Utils.GetSystemParameterForCombo(ref objOperationResult, 207, null), DropDownListAction.Select);
            Utils.LoadDropDownList(ddlAltitudeWorkId, "Value1", "Id", BLL.Utils.GetSystemParameterForCombo(ref objOperationResult, 208, null), DropDownListAction.Select);
            Utils.LoadDropDownList(ddlPlaceWorkId, "Value1", "Id", BLL.Utils.GetSystemParameterForCombo(ref objOperationResult, 204, null), DropDownListAction.Select);

            if (Mode == "New")
            {
                // Additional logic here.
                dtpBirthdate.Checked = false;
            }
            else if (Mode == "Edit")
            {
                PacientList objpacientDto = new PacientList();
                objpacientDto = _objPacientBL.GetPacient(ref objOperationResult, PacientId, null);


                ddlRelationshipId.SelectedValue = objpacientDto.i_Relationship == null ? "-1" : objpacientDto.i_Relationship.ToString();
                ddlAltitudeWorkId.SelectedValue = objpacientDto.i_AltitudeWorkId == null ? "-1" : objpacientDto.i_AltitudeWorkId.ToString();
                ddlPlaceWorkId.SelectedValue    = objpacientDto.i_PlaceWorkId == null ? "-1" : objpacientDto.i_PlaceWorkId.ToString();
                txtExploitedMineral.Text        = objpacientDto.v_ExploitedMineral;

                txtName.Text                     = objpacientDto.v_FirstName;
                txtFirstLastName.Text            = objpacientDto.v_FirstLastName;
                txtSecondLastName.Text           = objpacientDto.v_SecondLastName;
                ddlDocTypeId.SelectedValue       = objpacientDto.i_DocTypeId.ToString();
                ddlSexTypeId.SelectedValue       = objpacientDto.i_SexTypeId.ToString();
                ddlMaritalStatusId.SelectedValue = objpacientDto.i_MaritalStatusId.ToString();
                ddlLevelOfId.SelectedValue       = objpacientDto.i_LevelOfId.ToString();
                txtDocNumber.Text                = objpacientDto.v_DocNumber;
                NumberDocument                   = txtDocNumber.Text;
                dtpBirthdate.Value               = (DateTime)objpacientDto.d_Birthdate;
                txtBirthPlace.Text               = objpacientDto.v_BirthPlace;
                txtTelephoneNumber.Text          = objpacientDto.v_TelephoneNumber;
                txtAdressLocation.Text           = objpacientDto.v_AdressLocation;
                txtMail.Text                     = objpacientDto.v_Mail;
                ddlBloodGroupId.SelectedValue    = objpacientDto.i_BloodGroupId == 0 ? "-1" : objpacientDto.i_BloodGroupId.ToString();
                ddlBloodFactorId.SelectedValue   = objpacientDto.i_BloodFactorId == 0 ? "-1" : objpacientDto.i_BloodFactorId.ToString();
                txtCurrentOccupation.Text        = objpacientDto.v_CurrentOccupation;

                FingerPrintTemplate = objpacientDto.b_FingerPrintTemplate;
                FingerPrintImage    = objpacientDto.b_FingerPrintImage;
                RubricImage         = objpacientDto.b_RubricImage;
                RubricImageText     = objpacientDto.t_RubricImageText;

                pbPersonImage.Image = Common.Utils.BytesArrayToImage(objpacientDto.b_Photo, pbPersonImage);
            }
        }
Beispiel #3
0
        private void BindGrid()
        {
            CalendarBL  objCalendarBL  = new CalendarBL();
            calendarDto objcalendarDto = new calendarDto();
            PacientBL   objPacientBL   = new PacientBL();
            PacientList objPacientDto  = new PacientList();

            OperationResult objOperationResult = new OperationResult();

            var objData = GetData(0, null, "", strFilterExpression);

            //Validar que el trabajador exista en el sistema
            objPacientDto = objPacientBL.GetPacient(ref objOperationResult, null, txtDocNumber.Text.Trim());
            //_CalendarId = objData[0].v_CalendarId;
            if (objPacientDto == null)
            {
                MessageBox.Show("Este Trabajador no está ingresado en el sistema SIGESOFT.", "NO SE ENCONTRÓ TRABAJADOR!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string Pacient = objPacientDto.v_FirstName + " " + objPacientDto.v_FirstLastName + " " + objPacientDto.v_SecondLastName;

            if (objData.Count == 0)
            {
                MessageBox.Show("El trabajado " + Pacient + " no está agendado. Comuníquese con el área de Recepción.", "NO SE ENCONTRÓ CITA!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (objData[0].i_CalendarStatusId == (int)CalendarStatus.Cancelado)
                {
                    MessageBox.Show("La cita del trabajor " + Pacient + " ha sido cancelada. Comuníquese con el área de recepción.", "¡INFORMACIÓN!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (objData[0].i_CalendarStatusId != (int)CalendarStatus.Agendado)
                {
                    MessageBox.Show("El trabajor " + Pacient + " ya está dentro del Centro Médico.", "¡INFORMACIÓN!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                DialogResult Result = MessageBox.Show("¿Desea registar el ingreso de " + Pacient + " al centro médico?", "TRABAJADOR AGENDADO!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (Result == System.Windows.Forms.DialogResult.Yes)
                {
                    foreach (var item in objData)
                    {
                        objcalendarDto = objCalendarBL.GetCalendar(ref objOperationResult, item.v_CalendarId);
                        objcalendarDto.d_EntryTimeCM = DateTime.Now;

                        objcalendarDto.i_CalendarStatusId = (int)CalendarStatus.Ingreso;
                        objCalendarBL.UpdateCalendar(ref objOperationResult, objcalendarDto, Globals.ClientSession.GetAsList());
                    }
                }
                _objLista                    = _objCalendarBL.GetCalendarsPagedAndFiltered1(ref objOperationResult, 0, null, "i_CalendarStatusId ASC , d_EntryTimeCM ASC", null, DateTime.Now.Date, DateTime.Now.Date.AddDays(1));
                grdData.DataSource           = _objLista;
                lblRecordCountTotal.Text     = "Total : " + _objLista.Count.ToString();
                lblRecordCountPendiente.Text = "Pendientes : " + _objLista.FindAll(p => p.i_CalendarStatusId == (int)CalendarStatus.Agendado).Count();
            }
        }
        private void LoadPerson()
        {
            PacientList     objpacientDto      = new PacientList();
            PacientBL       _objPacientBL      = new PacientBL();
            OperationResult objOperationResult = new OperationResult();

            objpacientDto                    = _objPacientBL.GetPacient(ref objOperationResult, _PersonId, null);
            NumberDocument                   = objpacientDto.v_DocNumber;
            txtName.Text                     = objpacientDto.v_FirstName;
            txtFirstLastName.Text            = objpacientDto.v_FirstLastName;
            txtSecondLastName.Text           = objpacientDto.v_SecondLastName;
            ddlDocTypeId.SelectedValue       = objpacientDto.i_DocTypeId.ToString();
            ddlSexTypeId.SelectedValue       = objpacientDto.i_SexTypeId.ToString();
            ddlMaritalStatusId.SelectedValue = objpacientDto.i_MaritalStatusId.ToString();
            ddlLevelOfId.SelectedValue       = objpacientDto.i_LevelOfId.ToString();
            txtDocNumber.Text                = objpacientDto.v_DocNumber;
            txtTelephoneNumber.Text          = objpacientDto.v_TelephoneNumber;
            txtMail.Text                     = objpacientDto.v_Mail;
        }
        public static void CreateAnexo3_Exoneracion_ResponsabilidadYanacocha(ServiceList DataService, string filePDF,
                                                                             PacientList datosPac,
                                                                             organizationDto infoEmpresaPropietaria, PacientList filiationData,
                                                                             List <ServiceComponentList> serviceComponent)
        {
            Document document = new Document(PageSize.A4, 40f, 40f, 80f, 50f);


            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include      = string.Empty;
            List <PdfPCell> cells        = null;
            float[]         columnWidths = null;
            PdfPTable       header2      = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 13, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresaPropietaria.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);


            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("ANEXO 3", fontTitle1))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("EXONERACION DE RESPONSABILIDAD", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 20f, 60f, 20f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            var    tamaño_celda = 25f;
            string tipodoc      = "";
            if (datosPac.i_DocTypeId == 1)
            {
                tipodoc = "DNI";
            }
            else if (datosPac.i_DocTypeId == 2)
            {
                tipodoc = "Pasaporte";
            }
            else if (datosPac.i_DocTypeId == 3)
            {
                tipodoc = "Licencia de Conducir";
            }
            else if (datosPac.i_DocTypeId == 4)
            {
                tipodoc = "Carnet de Extranjeria";
            }

            #region Contenido
            string empresageneral     = DataService.v_CustomerOrganizationName;
            string empresacontrata    = DataService.EmpresaEmpleadora;
            string empresasubcontrata = DataService.EmpresaTrabajo;

            string empr_Conct = "";
            if (empresageneral != empresasubcontrata)
            {
                empr_Conct = empresacontrata + " / " + empresasubcontrata;
            }
            else
            {
                empr_Conct = empresacontrata;
            }

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n YO, ", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n" + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName, fontColumnValue))
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n VISITANTE, perteneciente", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\na  la  Empresa   ", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n " + empr_Conct, fontColumnValue))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\nIdentificado (a) con " + tipodoc + " N°  ", fontColumnValue))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n" + datosPac.v_DocNumber, fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\ndeclaro haber sido", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\ndebida y ampliamente informado(a), de los riesgos de mi salud que se pueden presentar", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\ndurante mi visita a las instalaciones de MINERA YANACOCHA S.R.L.", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \nAsimismo eximo de cualquier responsabilidad legal a MINERA YANACOCHA S.R.L., de lo ", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \nque pueda derivar de mi viaje a su área de operaciones.", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            string[] fechaServicio = datosPac.FechaServicio.ToString().Split('/', ' ');
            string   mes           = "";
            if (fechaServicio[1] == "01")
            {
                mes = "Enero";
            }
            else if (fechaServicio[1] == "02")
            {
                mes = "Febrero";
            }
            else if (fechaServicio[1] == "03")
            {
                mes = "Marzo";
            }
            else if (fechaServicio[1] == "04")
            {
                mes = "Abril";
            }
            else if (fechaServicio[1] == "05")
            {
                mes = "Mayo";
            }
            else if (fechaServicio[1] == "06")
            {
                mes = "Junio";
            }
            else if (fechaServicio[1] == "07")
            {
                mes = "Julio";
            }
            else if (fechaServicio[1] == "08")
            {
                mes = "Agosto";
            }
            else if (fechaServicio[1] == "09")
            {
                mes = "Setiembre";
            }
            else if (fechaServicio[1] == "10")
            {
                mes = "Octubre";
            }
            else if (fechaServicio[1] == "11")
            {
                mes = "Noviembre";
            }
            else if (fechaServicio[1] == "12")
            {
                mes = "Diciembre";
            }

            PdfPCell cellFirmaTrabajador = null;

            PdfPCell cellHuellaTrabajador = null;

            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 100, 35));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 60, 80));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            #region Fecha / Firmma
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\n \n \n \n Lugar y Fecha:     " + infoEmpresaPropietaria.v_SectorName + ", " + fechaServicio[0] + " de " + mes + " del " + fechaServicio[2], fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(cellFirmaTrabajador)
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, FixedHeight = 180, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(cellHuellaTrabajador)
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, FixedHeight = 180, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("_____________________________________", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("           Firma y Post Firma        ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
        }
Beispiel #6
0
        public static void CreateFichaPsicologicaGoldfields(PacientList filiationData,
                                                            List <ServiceComponentList> serviceComponent,
                                                            organizationDto infoEmpresa,
                                                            PacientList datosPac,
                                                            string filePDF, UsuarioGrabo DatosGrabo)
        {
            Document document = new Document(PageSize.A4, 30f, 30f, 42f, 41f);

            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include       = string.Empty;
            List <PdfPCell> cells         = null;
            float[]         columnWidths  = null;
            string[]        columnValues  = null;
            string[]        columnHeaders = null;
            PdfPTable       header2       = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            PdfPCell  cell            = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            var tamaño_celda = 11f;
            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresa.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresa.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("FICHA PSICOLÓGICA OCUPACIONAL", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f
                },
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region DATOS GENERALES
            string preOcp = "", Ocup = "", postOcup = "";
            if (filiationData.i_EsoTypeId == 1)
            {
                preOcp = "X";
            }
            else if (filiationData.i_EsoTypeId == 2)
            {
                Ocup = "X";
            }
            else if (filiationData.i_EsoTypeId == 3)
            {
                postOcup = "X";
            }


            string[] fechaServicio = datosPac.FechaServicio.ToString().Split(' ');

            string empresageneral     = filiationData.empresa_;
            string empresacontrata    = filiationData.contrata;
            string empresasubcontrata = filiationData.subcontrata;

            string empr_Conct = "";
            if (empresageneral != empresasubcontrata)
            {
                empr_Conct = empresacontrata + " / " + empresasubcontrata;
            }
            else
            {
                empr_Conct = empresacontrata;
            }

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("CLÍNICA:", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(infoEmpresa.v_Name, fontColumnValue))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Fecha de Entrevista", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(fechaServicio[0], fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("I. Datos Generales:", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BackgroundColor = BaseColor.GRAY
                },

                new PdfPCell(new Phrase("Apellidos Y Nombres", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName, fontColumnValue))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Edad", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.Edad.ToString(), fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Fecha de Nacimiento:", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.d_Birthdate.ToString().Split(' ')[0], fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Estado Civil:", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_MaritalStatus, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Empresa", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(empr_Conct, fontColumnValue))
                {
                    Colspan = 7, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Cargo", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_CurrentOccupation, fontColumnValue))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Tipo de Evaluación", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Pre Ocupacional", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(preOcp, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Ocupacional", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(Ocup, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Post Ocupacional", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(postOcup, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            ServiceComponentList ficha_psico_goldfields = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_OCUPACIONAL_GOLDFIELDS);

            #region DATOS OCUPACIONALES
            //var empresa_Actual = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_EMPRESA_ACTUAL) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_EMPRESA_ACTUAL).v_Value1;
            var area_trabajo     = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_AREA_LUGAR) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_AREA_LUGAR).v_Value1;
            var provincia_depart = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_PROVINCIA_DEPARTAMENTO) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_PROVINCIA_DEPARTAMENTO).v_Value1;
            var tiempo_laborando = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_TIEMPO_TOTAL_LAB) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_TIEMPO_TOTAL_LAB).v_Value1;
            var experiencia      = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_EXPERIENCIA_PUESTO) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_EXPERIENCIA_PUESTO).v_Value1;
            var riesgos          = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_PRINCIPALES_RIESGOS) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_PRINCIPALES_RIESGOS).v_Value1;
            var medidasSeguridad = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_MEDIDAS_SEGURIDAD) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_MEDIDAS_SEGURIDAD).v_Value1;

            var ingreso1   = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_FECHA_INGRESO1) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_FECHA_INGRESO1).v_Value1;
            var empresa1   = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_NOMBRE_EMPRESA1) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_NOMBRE_EMPRESA1).v_Value1;
            var actividad1 = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_ACTIVIDAD_EMPRESA1) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_ACTIVIDAD_EMPRESA1).v_Value1;
            var puesto1    = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_PUESTO_EMPRESA1) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_PUESTO_EMPRESA1).v_Value1;
            var tiempo1    = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_PERMANENCIA_TIEMPO1) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_PERMANENCIA_TIEMPO1).v_Value1;
            var salida1    = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_PERMANENCIA_FECHA_SALIDA1) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_PERMANENCIA_FECHA_SALIDA1).v_Value1;
            var cese1      = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_CAUSA_CESE1) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_CAUSA_CESE1).v_Value1;

            var ingreso2   = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_FECHA_INGRESO2) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_FECHA_INGRESO2).v_Value1;
            var empresa2   = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_NOMBRE_EMPRESA2) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_NOMBRE_EMPRESA2).v_Value1;
            var actividad2 = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_ACTIVIDAD_EMPRESA2) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_ACTIVIDAD_EMPRESA2).v_Value1;
            var puesto2    = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_PUESTO_EMPRESA2) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_PUESTO_EMPRESA2).v_Value1;
            var tiempo2    = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_PERMANENCIA_TIEMPO2) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_PERMANENCIA_TIEMPO2).v_Value1;
            var salida2    = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_PERMANENCIA_FECHA_SALIDA2) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_PERMANENCIA_FECHA_SALIDA2).v_Value1;
            var cese2      = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_CAUSA_CESE2) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_CAUSA_CESE2).v_Value1;


            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("II. Datos Ocupacionale:", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BackgroundColor = BaseColor.GRAY
                },

                new PdfPCell(new Phrase("2.1 Empresa Actual", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("Área, lugar de trabajo", fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(area_trabajo, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Provincia, departamento", fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(provincia_depart, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Tiempo total laborando", fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(tiempo_laborando, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Experiencia en el puesto", fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(experiencia, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Principales riesgos", fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(riesgos, fontColumnValue))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Medidas de seguridad", fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(medidasSeguridad, fontColumnValue))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("2.2 Anteriores Empresas (Experiencia Laboral): ", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE, FixedHeight = 1f
                },

                new PdfPCell(new Phrase("Fecha de ingreso", fontColumnValue))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Nombre de la Empresa", fontColumnValue))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Actividad de la Empresa", fontColumnValue))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Puesto", fontColumnValue))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Permanencia", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Causa de cese", fontColumnValue))
                {
                    Colspan = 4, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Tiempo", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Fecha salida", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase(ingreso1, fontColumnValue))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(empresa1, fontColumnValue))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(actividad1, fontColumnValue))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(puesto1, fontColumnValue))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(tiempo1, fontColumnValue))
                {
                    Colspan = 2, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(salida1, fontColumnValue))
                {
                    Colspan = 2, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(cese1, fontColumnValue))
                {
                    Colspan = 4, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase(ingreso2, fontColumnValue))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(empresa2, fontColumnValue))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(actividad2, fontColumnValue))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(puesto2, fontColumnValue))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(tiempo2, fontColumnValue))
                {
                    Colspan = 2, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(salida2, fontColumnValue))
                {
                    Colspan = 2, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(cese2, fontColumnValue))
                {
                    Colspan = 4, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region HISTORIA FAMILIAR
            var historia_familiar = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_HISTORIA_FAMILIAR) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_HISTORIA_FAMILIAR).v_Value1;
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("III. Historia Familiar (Con quien vive actualmente, pasatiempos, actividades fuera del trabajo", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BackgroundColor = BaseColor.GRAY
                },
                new PdfPCell(new Phrase(historia_familiar, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 20
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region HISTORIA FAMILIAR
            var enfermedades_accidentes = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_ENFERMEDADES_ACCIDENTES) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_ENFERMEDADES_ACCIDENTES).v_Value1;
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("IV Enfermedades y accidentes (Durante el tiempo del trabajo)", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BackgroundColor = BaseColor.GRAY
                },
                new PdfPCell(new Phrase(enfermedades_accidentes, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 20
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region ENFERMEDADES Y ACCIDENTES
            var    enfermedad_salud_mental     = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_ENFERMEDAD_SALUD_MENTAL) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_ENFERMEDAD_SALUD_MENTAL).v_Value1;
            string enfermedad_salud_mentalSINO = "";
            if (enfermedad_salud_mental == "1")
            {
                enfermedad_salud_mentalSINO = "SI";
            }
            if (enfermedad_salud_mental == "0")
            {
                enfermedad_salud_mentalSINO = "NO";
            }
            var descripcion_salud_mental      = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_DESCRIPCION_SALUD_MENTAL) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_DESCRIPCION_SALUD_MENTAL).v_Value1;
            var otras_enfermedades_accidentes = ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_OTRAS_ENFEREMDADES) == null ? "" : ficha_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FICHA_PSICOLOGICA_GOLDFIELDS_OTRAS_ENFEREMDADES).v_Value1;

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("V. Antecedentes personales", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BackgroundColor = BaseColor.GRAY
                },

                new PdfPCell(new Phrase("a) Para ser llenado por el trabajador", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Yo, " + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName + "con DNI: " + datosPac.v_DocNumber + " manifiesto que " + enfermedad_salud_mentalSINO + " se me ha identificado una", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("enfermedad de salud mental, o psiquiátrica.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n En el caso de marcar SI, describir en breve palabras el diagnostico de la enfermedad mental, y si recibió tratamiento;", fontColumnValueApendice))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("b) Otras enfermedades de salud, y/o accidentes:", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase(otras_enfermedades_accidentes, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region ENFERMEDADES Y ACCIDENTES

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("VI. Antecedentes personales", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BackgroundColor = BaseColor.GRAY
                },

                new PdfPCell(new Phrase("Con la firma del presente documento, confirmo y doy fe que la información brindada sobre mi salud es completa y verdadera, haciéndome", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("\nresponsable de cualquier omisión o dato incorrecto; así mismo quedo obligado a informar toda circunstancia nueva que pueda influir", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\no alterar esta información.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            //var psico = serviceComponent.Find(p => p.i_CategoryId == (int)Sigesoft.Common.Consultorio.Psicología);

            #region Firma

            #region Creando celdas de tipo Imagen y validando nulls
            PdfPCell cellFirmaTrabajador  = null;
            PdfPCell cellHuellaTrabajador = null;
            PdfPCell cellFirma            = null;

            // Firma del trabajador ***************************************************


            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 80, 40));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirmaTrabajador.FixedHeight         = 50F;
            // Huella del trabajador **************************************************

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 30, 45));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellHuellaTrabajador.FixedHeight         = 50F;
            // Firma del doctor Auditor **************************************************
            if (DatosGrabo.Firma != null)
            {
                cellFirma = new PdfPCell(HandlingItextSharp.GetImage(DatosGrabo.Firma, null, null, 120, 50))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                }
            }
            ;
            else
            {
                cellFirma = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirma.FixedHeight         = 50F;
            #endregion

            cells = new List <PdfPCell>()
            {
                new PdfPCell(cellFirmaTrabajador)
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
                new PdfPCell(cellHuellaTrabajador)
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("FIRMA Y SELLO DEL PSICÓLOGO", fontColumnValueBold))
                {
                    Rowspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(cellFirma)
                {
                    Rowspan = 3, HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },

                new PdfPCell(new Phrase("FIRMA DEL EXAMINADO", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 12f
                },
                new PdfPCell(new Phrase("HUELLA DEL EXAMINADO", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 12f
                },

                new PdfPCell(new Phrase("CON LA CUAL DECLARA QUE LA INFORMACIÓN DECLARADA ES VERAZ", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
            };
            columnWidths = new float[] { 25f, 25f, 25f, 25f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);

            document.Add(filiationWorker);

            #endregion

            document.Close();
            writer.Close();
            writer.Dispose();
        }
Beispiel #7
0
        public static void CreateCertificadoMedicoOcupacional_Cosapi(ServiceList DataService,
                                                                     PacientList filiationData,
                                                                     List <DiagnosticRepositoryList> Diagnosticos,
                                                                     List <ServiceComponentList> serviceComponent,
                                                                     organizationDto infoEmpresa,
                                                                     PacientList datosPac,
                                                                     string filePDF
                                                                     )
        {
            Document document = new Document(PageSize.A4, 30f, 30f, 45f, 41f);

            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include       = string.Empty;
            List <PdfPCell> cells         = null;
            float[]         columnWidths  = null;
            string[]        columnValues  = null;
            string[]        columnHeaders = null;
            PdfPTable       header2       = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            PdfPCell  cell            = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            var tamaño_celda = 14f;
            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresa.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresa.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 785);
                document.Add(imagenEmpresa);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("CERTIFICADO DE APTITUD MÉDICO OCUPACIONAL", fontTitle1))
                {
                    Colspan = 2, BackgroundColor = BaseColor.GRAY, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f
                },
            };
            columnWidths = new float[] { 80f, 20f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            #region DATOS GENERALES
            string sexM = " ", sexF = " ";
            if (datosPac.i_SexTypeId == 1)
            {
                sexM = "X";
            }
            else if (datosPac.i_SexTypeId == 2)
            {
                sexF = "X";
            }

            string PreOcupacional = "", Periodica = "", Retiro = "", Otros = "";
            if (DataService != null)
            {
                if (DataService.i_EsoTypeId == (int)Sigesoft.Common.TypeESO.PreOcupacional)
                {
                    PreOcupacional = "X";
                }
                else if (DataService.i_EsoTypeId == (int)Sigesoft.Common.TypeESO.PeriodicoAnual)
                {
                    Periodica = "X";
                }
                else if (DataService.i_EsoTypeId == (int)Sigesoft.Common.TypeESO.Retiro)
                {
                    Retiro = "X";
                }
                else
                {
                    Otros = "X";
                }
            }
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    BackgroundColor = BaseColor.GRAY, Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f
                },
                new PdfPCell(new Phrase("Código", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f
                },
                new PdfPCell(new Phrase(datosPac.v_IdService, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f
                },

                new PdfPCell(new Phrase("Certifica que el Sr.(a)", fontColumnValue))
                {
                    Colspan = 15, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Grupo Sanguineo y Factor", fontColumnValue))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_BloodGroupName, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_BloodFactorName, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Nombres y Apellidos", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Documento de identidad (DNI ó C.E):", fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_DocNumber, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Edad", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.Edad.ToString(), fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Género:", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("M", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(sexM, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("F", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(sexF, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Tipo de examen", fontColumnValue))
                {
                    Colspan = 4, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Preocupacional", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(PreOcupacional, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Periódico", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(Periodica, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Retiro", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(Retiro, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Otro(Especifique)", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(Otros, fontColumnValue))
                {
                    Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Empresa", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(filiationData.v_FullWorkingOrganizationName, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Proyecto/Sede - Cliente", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(filiationData.v_NombreProtocolo, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Puesto de trabajo", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_CurrentOccupation, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("N° de Historia Clínica", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_DocNumber, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase(null, fontColumnValue))
                {
                    BackgroundColor = BaseColor.GRAY, Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 2
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region Hallazgos y recomendaciones
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("Recomendaciones", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },
            };
            columnWidths    = new float[] { 20.6f, 40.6f };
            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);
            document.Add(filiationWorker);
            cells = new List <PdfPCell>();

            var filterDiagnosticRepository = Diagnosticos.FindAll(p => p.i_FinalQualificationId != (int)Sigesoft.Common.FinalQualification.Descartado);

            if (filterDiagnosticRepository != null && filterDiagnosticRepository.Count > 0)
            {
                columnWidths = new float[] { 100f };
                include      = "Valor1";

                foreach (var item in filterDiagnosticRepository)
                {
                    ListaComun        oListaComun = null;
                    List <ListaComun> Listacomun  = new List <ListaComun>();

                    foreach (var Reco in item.Recomendations)
                    {
                        oListaComun        = new ListaComun();
                        oListaComun.Valor1 = Reco.v_RecommendationName;
                        Listacomun.Add(oListaComun);
                    }

                    table = HandlingItextSharp.GenerateTableFromList(Listacomun, columnWidths, include, fontColumnValue);
                    cell  = new PdfPCell(table);

                    cells.Add(cell);
                }
                columnWidths = new float[] { 100f };
            }
            else
            {
                cells.Add(new PdfPCell(new Phrase("NO SE HAN REGISTRADO DATOS.", fontColumnValue)));
                columnWidths = new float[] { 100f };
            }
            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, null);
            document.Add(table);
            /////

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("Restricciones", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },
            };
            columnWidths    = new float[] { 20.6f, 40.6f };
            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);
            document.Add(filiationWorker);
            cells = new List <PdfPCell>();

            var filterDiagnosticRepository_1 = Diagnosticos.FindAll(p => p.i_FinalQualificationId != (int)Sigesoft.Common.FinalQualification.Descartado);

            if (filterDiagnosticRepository_1 != null && filterDiagnosticRepository_1.Count > 0)
            {
                columnWidths = new float[] { 100f };
                include      = "Valor1";

                //var desc = Diagnosticos.Find(p => p.Restrictions != (int)Sigesoft.Common.FinalQualification.Descartado);
                foreach (var item_1 in filterDiagnosticRepository_1)
                {
                    ListaComun        oListaComun = null;
                    List <ListaComun> Listacomun  = new List <ListaComun>();

                    foreach (var Rest_1 in item_1.Restrictions)
                    {
                        oListaComun        = new ListaComun();
                        oListaComun.Valor1 = Rest_1.v_RestrictionName;
                        Listacomun.Add(oListaComun);
                    }
                    table = HandlingItextSharp.GenerateTableFromList(Listacomun, columnWidths, include, fontColumnValue);
                    cell  = new PdfPCell(table);
                    cells.Add(cell);
                }
                columnWidths = new float[] { 100f };
            }
            else
            {
                cells.Add(new PdfPCell(new Phrase("NO SE HAN REGISTRADO DATOS.", fontColumnValue)));
                columnWidths = new float[] { 100 };
            }

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, null);
            document.Add(table);
            #endregion

            #region RESULTADO DE APROBACION / FECHAS
            string Apto = "", NoApto = "", AptoConRestricciones = "", AptoObs = "";

            if (DataService.i_AptitudeStatusId == (int)Sigesoft.Common.AptitudeStatus.Apto)
            {
                Apto = "X";
            }
            else if (DataService.i_AptitudeStatusId == (int)Sigesoft.Common.AptitudeStatus.NoApto)
            {
                NoApto = "X";
            }
            else if (DataService.i_AptitudeStatusId == (int)Sigesoft.Common.AptitudeStatus.AptRestriccion)
            {
                AptoConRestricciones = "X";
            }
            else if (DataService.i_AptitudeStatusId == (int)Sigesoft.Common.AptitudeStatus.AptoObs)
            {
                AptoObs = "X";
            }

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("Resultado para Trabajar", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = PdfPCell.ALIGN_LEFT, BackgroundColor = BaseColor.GRAY, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("APTO", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = PdfPCell.ALIGN_LEFT, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(Apto, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("APTO CON RESTRICCIONES", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = PdfPCell.ALIGN_LEFT, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(AptoConRestricciones, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("NO APTO", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = PdfPCell.ALIGN_LEFT, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(NoApto, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
            };
            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

            document.Add(filiationWorker);
            #endregion
            #region APTITUDES ESPECÍFICAS

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("APTITUDES ESPECÍFICAS:", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },
            };
            columnWidths    = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);
            document.Add(filiationWorker);

            ServiceComponentList geografico  = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.ALTURA_GEOGRAFICA_ID);
            if (geografico != null)
            {
                var    alt_geograf = geografico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.ALTURA_GEOGRAFICA_APTO_ID) == null ? "" : geografico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.ALTURA_GEOGRAFICA_APTO_ID).v_Value1;
                string alt_geograf_1 = "", alt_geograf_2 = "", alt_geograf_3 = "", alt_geograf_4 = "";
                if (alt_geograf == "1")
                {
                    alt_geograf_1 = "X";
                }
                else if (alt_geograf == "2")
                {
                    alt_geograf_2 = "X";
                }
                else if (alt_geograf == "3")
                {
                    alt_geograf_3 = "X";
                }
                else if (alt_geograf == "4")
                {
                    alt_geograf_4 = "X";
                }


                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("Trabajador en altura geográfica mayor a 2500 m.s.n.m.", fontColumnValue))
                    {
                        Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("APTO", fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase(alt_geograf_1, fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("NO APTO", fontColumnValue))
                    {
                        Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase(alt_geograf_2, fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("APTO CON RESTRIC.", fontColumnValue))
                    {
                        Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase(alt_geograf_3, fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("OBSERVADO", fontColumnValue))
                    {
                        Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase(alt_geograf_4, fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                };
                columnWidths    = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
                filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);
                document.Add(filiationWorker);
            }
            else
            {
                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("Trabajador en altura geográfica mayor a 2500 m.s.n.m.", fontColumnValue))
                    {
                        Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("NO APLICA", fontColumnValue))
                    {
                        Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                };
                columnWidths    = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
                filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);
                document.Add(filiationWorker);
            }

            ServiceComponentList estructural = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.ALTURA_ESTRUCTURAL_ID);
            if (estructural != null)
            {
                var    alt_estruc = estructural.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.ALTURA_ESTRUCTURAL_APTO_ID) == null ? "" : estructural.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.ALTURA_ESTRUCTURAL_APTO_ID).v_Value1;
                string alt_estruc_1 = "", alt_estruc_2 = "", alt_estruc_3 = "", alt_estruc_4 = "";
                if (alt_estruc == "1")
                {
                    alt_estruc_1 = "X";
                }
                else if (alt_estruc == "2")
                {
                    alt_estruc_2 = "X";
                }
                else if (alt_estruc == "3")
                {
                    alt_estruc_3 = "X";
                }
                else if (alt_estruc == "4")
                {
                    alt_estruc_4 = "X";
                }
                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("Trabajos en altura estructural mayor a 1.8m:", fontColumnValue))
                    {
                        Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("APTO", fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase(alt_estruc_1, fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("NO APTO", fontColumnValue))
                    {
                        Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase(alt_estruc_2, fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("APTO CON RESTRIC.", fontColumnValue))
                    {
                        Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase(alt_estruc_3, fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("OBSERVADO", fontColumnValue))
                    {
                        Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase(alt_estruc_4, fontColumnValue))
                    {
                        Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                };
                columnWidths    = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
                filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);
                document.Add(filiationWorker);
            }
            else
            {
                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("Trabajos en altura estructural mayor a 1.8m:", fontColumnValue))
                    {
                        Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                    new PdfPCell(new Phrase("NO APLICA", fontColumnValue))
                    {
                        Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                    },
                };
                columnWidths    = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
                filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);
                document.Add(filiationWorker);
            }
            #endregion
            #region FECHA  NOMBRE DE MEDICO
            string[] fechaServicio           = datosPac.FechaServicio.ToString().Split(' ');
            string[] fechacaducidad          = datosPac.FechaCaducidad.ToString().Split(' ');
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("FECHA DE EXAMEN", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = PdfPCell.ALIGN_LEFT, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(fechaServicio[0], fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("FECHA DE CADUCIDAD", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = PdfPCell.ALIGN_LEFT, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(fechacaducidad[0], fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("MÉDICO: ", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = PdfPCell.ALIGN_LEFT, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(DataService.NombreDoctor, fontColumnValue))
                {
                    Colspan = 9, HorizontalAlignment = PdfPCell.ALIGN_CENTER, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Número de CMP:", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = PdfPCell.ALIGN_LEFT, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(DataService.CMP, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = PdfPCell.ALIGN_CENTER, MinimumHeight = tamaño_celda
                },
            };
            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

            document.Add(filiationWorker);
            #endregion
            #region Firma

            #region Creando celdas de tipo Imagen y validando nulls

            // Firma del trabajador ***************************************************
            PdfPCell cellFirmaTrabajador = null;
            //DirectoryInfo rutaFirma = null;
            //rutaFirma = new DirectoryInfo(WebConfigurationManager.AppSettings["FirmaHuella"].ToString());
            //iTextSharp.text.Image Firmajpg = iTextSharp.text.Image.GetInstance(rutaFirma +DataService.v_DocNumber + "_Firma.jpg");


            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 70, 30));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }
            //cellFirmaTrabajador = new PdfPCell(Firmajpg);

            // Huella del trabajador **************************************************
            PdfPCell cellHuellaTrabajador = null;

            //DirectoryInfo rutaHuella = null;
            //rutaHuella = new DirectoryInfo(WebConfigurationManager.AppSettings["FirmaHuella"].ToString());
            //iTextSharp.text.Image Huellajpg = iTextSharp.text.Image.GetInstance(rutaHuella + DataService.v_DocNumber + "_Huella.jpg");

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 30, 30));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }
            //cellHuellaTrabajador = new PdfPCell(Huellajpg);

            // Firma del doctor Auditor **************************************************

            PdfPCell cellFirma = null;

            if (DataService.FirmaMedicoMedicina != null)
            {
                cellFirma = new PdfPCell(HandlingItextSharp.GetImage(DataService.FirmaMedicoMedicina, null, null, 120, 50))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                }
            }
            ;
            else
            {
                cellFirma = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            #endregion

            #region Crear tablas en duro (para la Firma y huella del trabajador)

            cells = new List <PdfPCell>();

            cellFirmaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirmaTrabajador.Border      = PdfPCell.NO_BORDER;
            cellFirmaTrabajador.FixedHeight = 40F;
            cells.Add(cellFirmaTrabajador);
            cells.Add(new PdfPCell(new Phrase("FIRMA DEL EXAMINADO", fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
            });

            columnWidths = new float[] { 100f };

            var tableFirmaTrabajador = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

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

            cells = new List <PdfPCell>();

            cellHuellaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirmaTrabajador.Border       = PdfPCell.NO_BORDER;
            cellHuellaTrabajador.FixedHeight = 40F;
            cells.Add(cellHuellaTrabajador);
            cells.Add(new PdfPCell(new Phrase("HUELLA DEL EXAMINADO", fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
            });

            columnWidths = new float[] { 100f };

            var tableHuellaTrabajador = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

            #endregion

            cells = new List <PdfPCell>();

            // 1 celda vacia
            cells.Add(new PdfPCell(tableFirmaTrabajador));

            // 1 celda vacia
            cells.Add(new PdfPCell(tableHuellaTrabajador));

            // 2 celda
            cell = new PdfPCell(new Phrase("FIRMA Y SELLO MÉDICO", fontColumnValue))
            {
                Rowspan = 2
            };
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cells.Add(cell);

            // 3 celda (Imagen)
            cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirma.FixedHeight         = 40F;
            cells.Add(cellFirma);

            cells.Add(new PdfPCell(new Phrase("CON LA CUAL DECLARA QUE LA INFORMACIÓN DECLARADA ES VERAZ", fontColumnValue))
            {
                Colspan = 2, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE
            });
            cells.Add(new PdfPCell(new Phrase("", fontColumnValue))
            {
                Colspan = 2, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
            });

            columnWidths = new float[] { 35f, 35f, 30f, 40F };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);

            document.Add(table);

            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
        }
        public static void CreateFichaMedicaTrabajador3(PacientList filiationData, ServiceList doctoPhisicalExam, List <DiagnosticRepositoryList> diagnosticRepository, organizationDto infoEmpresaPropietaria, string pstrExamenesConcatenados, string pstrExamenesLabConcatenados, List <ServiceComponentList> serviceComponent, string pstrRestriciones, string filePDF)
        {
            Document document = new Document();

            document.SetPageSize(iTextSharp.text.PageSize.A4);

            //try
            //{NO_BORDER
            // step 2: we create aPA writer that listens to the document
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));

            //create an instance of your PDFpage class. This is the class we generated above.
            pdfPage page = new pdfPage();

            page.Dato = "FMT3/" + filiationData.v_FirstName + " " + filiationData.v_FirstLastName + " " + filiationData.v_SecondLastName;
            //set the PageEvent of the pdfWriter instance to the instance of our PDFPage class
            writer.PageEvent = page;

            // step 3: we open the document
            document.Open();
            // step 4: we Add content to the document
            // we define some fonts
            #region Declaration Tables

            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.White);
            string          include      = string.Empty;
            List <PdfPCell> cells        = null;
            float[]         columnWidths = null;
            //string[] columnValues = null;
            string[] columnHeaders = null;


            PdfPTable filiationWorker = new PdfPTable(8);

            PdfPTable table = null;

            PdfPCell cell = null;

            #endregion

            #region Fonts

            Font fontTitle1               = FontFactory.GetFont("Arial", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Arial", 9, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableAntecedentesOcupacionales  = FontFactory.GetFont("Arial", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueAntecedentesOcupacionales = FontFactory.GetFont("Arial", 6, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueNegrita = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontAptitud = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            //Font fontTitleTableNegro = FontFactory.GetFont("Arial", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            #endregion


            //#region Logo
            PdfPCell CellLogo = null;


            #region Title

            CellLogo = null;
            cells    = new List <PdfPCell>();
            PdfPCell cellPhoto1 = null;

            if (filiationData.b_Photo != null)
            {
                cellPhoto1 = new PdfPCell(HandlingItextSharp.GetImage(filiationData.b_Photo, 23F))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_RIGHT
                }
            }
            ;
            else
            {
                cellPhoto1 = new PdfPCell(new Phrase(" ", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_RIGHT
                }
            };

            if (infoEmpresaPropietaria.b_Image != null)
            {
                CellLogo = new PdfPCell(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image, 30F))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                };
            }
            else
            {
                CellLogo = new PdfPCell(new Phrase(" ", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                };
            }

            columnWidths = new float[] { 100f };

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("RESUMEN DE EXAMEN MÉDICO", fontTitle1))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
            };

            table = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);

            cells.Add(CellLogo);
            cells.Add(new PdfPCell(table));
            cells.Add(cellPhoto1);

            columnWidths = new float[] { 20f, 60f, 20f };

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);
            document.Add(table);

            #endregion

            #region Datos del examen

            cells = new List <PdfPCell>()
            {
                //fila
                new PdfPCell(new Phrase("NRO DE HCL:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.v_IdService, fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("TIPO DE EXAMEN: ", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.v_TipoExamen, fontColumnValue)),
                new PdfPCell(new Phrase("FECHA EXAMEN:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.d_ServiceDate.Value.ToShortDateString(), fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },


                //fila
                new PdfPCell(new Phrase("PROVEEDOR:", fontColumnValue)),
                new PdfPCell(new Phrase(infoEmpresaPropietaria.v_Name, fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("EMPRESA:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.v_OrganitationName, fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("GRUPO DE RIESGO:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.GESO, fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },

                //fila
                new PdfPCell(new Phrase("EXÁMENES REALIZADOS:", fontColumnValue)),
                new PdfPCell(new Phrase(pstrExamenesConcatenados, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },

                //fila
                new PdfPCell(new Phrase("LABORATORIO: ", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase(pstrExamenesLabConcatenados, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
            };
            columnWidths = new float[] { 25f, 20f, 20f, 20f, 20f, 20f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "DATOS DEL EXAMEN", fontTitleTable);

            document.Add(filiationWorker);



            #endregion

            #region Datos del trabajador

            cells = new List <PdfPCell>()
            {
                //fila
                new PdfPCell(new Phrase("APELLIDOS Y NOMBRES:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.v_FirstLastName + " " + filiationData.v_SecondLastName + " " + filiationData.v_FirstName, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },

                //fila
                new PdfPCell(new Phrase("DNI:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.v_DocNumber, fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("EDAD:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.i_Age.Value.ToString(), fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("PUESTO:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.v_CurrentOccupation, fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
            };
            columnWidths = new float[] { 25f, 20f, 10f, 10f, 10f, 50f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "DATOS DEL TRABAJADOR", fontTitleTable);

            document.Add(filiationWorker);



            #endregion

            #region Resultados del examen médico
            cells = new List <PdfPCell>();

            if (diagnosticRepository != null && diagnosticRepository.Count > 0)
            {
                //PdfPCell cellDx = null;

                columnWidths = new float[] { 50f };
                include      = "v_RecommendationName";

                var ListaFinal = diagnosticRepository.FindAll(p => p.i_CategoryId != 1 && p.i_CategoryId != 10);
                foreach (var item in ListaFinal)
                {
                    if (item.v_DiseasesId == "N009-DD000000029")
                    {
                        cell = new PdfPCell(new Phrase(""))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }
                    else
                    {
                        cell = new PdfPCell(new Phrase(item.Categoria + " - " + item.v_DiseasesName, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }

                    // Crear tabla de recomendaciones para insertarla en la celda que corresponde
                    var tableDx = HandlingItextSharp.GenerateTableFromList(item.Recomendations, columnWidths, include, fontColumnValue);
                    cell = new PdfPCell(tableDx);
                    cells.Add(cell);
                }
                columnWidths = new float[] { 50f, 54f };
            }
            else
            {
                cells.Add(new PdfPCell(new Phrase("No se han registrado datos.", fontColumnValue)));
                columnWidths = new float[] { 100f };
            }

            var GrillaDx = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "RESULTADOS DEL EXAMEN MÉDICO", fontTitleTableNegro);
            document.Add(GrillaDx);
            #endregion

            #region Nutrición
            cells = new List <PdfPCell>();
            var xNutricion = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.ANTROPOMETRIA_ID);
            if (xNutricion != null)
            {
                // Subtitulo  ******************
                cell = new PdfPCell(new Phrase("NUTRICIÓN", fontSubTitleNegroNegrita))
                {
                    Colspan             = 4,
                    BackgroundColor     = subTitleBackGroundColor,
                    HorizontalAlignment = Element.ALIGN_CENTER,
                };

                cells.Add(cell);
                //*****************************************
                // titulo
                var valorPeso  = xNutricion.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.ANTROPOMETRIA_PESO_ID);
                var valorTalla = xNutricion.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.ANTROPOMETRIA_TALLA_ID);
                cells.Add(new PdfPCell(new Phrase("PESO(Kg):", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(valorPeso == null ? string.Empty : valorPeso.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("TALLA(m):", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(valorTalla == null ? string.Empty : valorTalla.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });

                // titulo
                cells.Add(new PdfPCell(new Phrase("EXAMEN", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("VALOR HALLADO", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("DIAGNÓSTICO", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("RECOMENDACIONES", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });

                var valorIMC = xNutricion.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.ANTROPOMETRIA_IMC_ID);

                var dxIMC   = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.ANTROPOMETRIA_IMC_ID);
                var RecoIMC = dxIMC.Recomendations.FindAll(p => p.v_ComponentId == Sigesoft.Common.Constants.ANTROPOMETRIA_ID);
                // 1era fila
                cells.Add(new PdfPCell(new Phrase("IMC", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(valorIMC == null ? string.Empty : valorIMC.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxIMC == null ? "NORMAL" : dxIMC.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(string.Join(", ", RecoIMC.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });

                columnWidths = new float[] { 25f, 25f, 25f, 25f };

                table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths);
                document.Add(table);
            }

            #endregion

            #region Presión Arterial
            cells = new List <PdfPCell>();
            var xPresionArterial = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.FUNCIONES_VITALES_ID);
            if (xPresionArterial != null)
            {
                // Subtitulo  ******************
                cell = new PdfPCell(new Phrase("PRESIÓN ARTERIAL", fontSubTitleNegroNegrita))
                {
                    Colspan             = 4,
                    BackgroundColor     = subTitleBackGroundColor,
                    HorizontalAlignment = Element.ALIGN_CENTER,
                };

                cells.Add(cell);
                //*****************************************

                // titulo
                cells.Add(new PdfPCell(new Phrase("EXAMEN", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("VALOR HALLADO", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("DIAGNÓSTICO", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("RECOMENDACIONES", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });

                var valorPA1 = xPresionArterial.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_PAS_ID) == null ? "" : xPresionArterial.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_PAS_ID).v_Value1;
                var valorPA2 = xPresionArterial.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_PAD_ID) == null ? "" : xPresionArterial.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_PAD_ID).v_Value1;

                var dxPA   = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_PAS_ID);
                var RecoPA = dxPA == null?null: dxPA.Recomendations;
                // 1era fila
                cells.Add(new PdfPCell(new Phrase("PRESIÓN ARTERIAL", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(valorPA1 + " / " + valorPA2, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxPA == null ? "NORMAL" : dxPA.v_Name, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoPA == null ?"CONTROL ANUAL":string.Join(", ", RecoPA.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });

                columnWidths = new float[] { 25f, 25f, 25f, 25f };

                table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths);
                document.Add(table);
            }
            #endregion

            #region Laboratorio
            cells = new List <PdfPCell>();
            // Subtitulo  ******************
            cell = new PdfPCell(new Phrase("LABORATORIO", fontSubTitleNegroNegrita))
            {
                Colspan             = 4,
                BackgroundColor     = subTitleBackGroundColor,
                HorizontalAlignment = Element.ALIGN_CENTER,
            };

            cells.Add(cell);
            //*****************************************

            // titulo
            cells.Add(new PdfPCell(new Phrase("EXAMEN", fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_CENTER
            });
            cells.Add(new PdfPCell(new Phrase("VALOR HALLADO", fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_CENTER
            });
            cells.Add(new PdfPCell(new Phrase("DIAGNÓSTICO", fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_CENTER
            });
            cells.Add(new PdfPCell(new Phrase("RECOMENDACIONES", fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_CENTER
            });

            var xHB = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.HEMOGRAMA_COMPLETO_ID);

            var xHTO            = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.HEMOGRAMA_COMPLETO_ID);
            var xColesterol     = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.COLESTEROL_ID);
            var xTrigli         = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.TRIGLICERIDOS_ID);
            var xGlucosa        = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.GLUCOSA_ID);
            var xUrea           = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.UREA_ID);
            var xCreatina       = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.CREATININA_ID);
            var xColesterol_1   = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.PERFIL_LIPIDICO);
            var xTrigli_1       = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.PERFIL_LIPIDICO);
            var xOrina          = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.EXAMEN_COMPLETO_DE_ORINA_ID);
            var xGrupoSanguineo = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.GRUPO_Y_FACTOR_SANGUINEO_ID);
            if (xHB != null)
            {
                var hbValor = xHB.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.HEMOGRAMA_COMPLETO_HEMOGLOBINA);
                var dxHB    = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.HEMOGRAMA_COMPLETO_HEMOGLOBINA);
                var RecoHB  = dxHB == null ? null : dxHB.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("HB", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxHB == null ? "NORMAL" : dxHB.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }

            if (xHTO != null)
            {
                var hbValor = xHTO.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.HEMOGRAMA_COMPLETO_HEMATOCRITO);
                var dxHTO   = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.HEMOGRAMA_COMPLETO_HEMATOCRITO);
                var RecoHB  = dxHTO == null ? null : dxHTO.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("HTO", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxHTO == null ? "NORMAL" : dxHTO.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }
            if (xColesterol != null)
            {
                var hbValor      = xColesterol.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.COLESTEROL_COLESTEROL_TOTAL_ID);
                var dxColesterol = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.COLESTEROL_COLESTEROL_TOTAL_ID);
                var RecoHB       = dxColesterol == null ? null : dxColesterol.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("COLESTEROL", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxColesterol == null ? "NORMAL" : dxColesterol.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }
            if (xTrigli != null)
            {
                var hbValor  = xTrigli.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.TRIGLICERIDOS_BIOQUIMICA_TRIGLICERIDOS);
                var dxTrigli = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.TRIGLICERIDOS_BIOQUIMICA_TRIGLICERIDOS);
                var RecoHB   = dxTrigli == null ? null : dxTrigli.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("TRIGLICÉRIDOS", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxTrigli == null ? "NORMAL" : dxTrigli.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }
            if (xGlucosa != null)
            {
                var hbValor   = xGlucosa.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.OFTALMOLOGIA_DESCRIPCION);
                var dxGlucosa = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.OFTALMOLOGIA_DESCRIPCION);
                var RecoHB    = dxGlucosa == null ? null : dxGlucosa.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("GLUCOSA", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxGlucosa == null ? "NORMAL" : dxGlucosa.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }
            if (xUrea != null)
            {
                var hbValor = xUrea.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.UREA_BIOQUIMICA_UREA);
                var dxUrea  = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.UREA_BIOQUIMICA_UREA);
                var RecoHB  = dxUrea == null ? null : dxUrea.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("ÚREA", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxUrea == null ? "NORMAL" : dxUrea.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }
            if (xCreatina != null)
            {
                var hbValor    = xCreatina.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CREATININA_BIOQUIMICA_CREATININA);
                var dxCreatina = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CREATININA_BIOQUIMICA_CREATININA);
                var RecoHB     = dxCreatina == null ? null : dxCreatina.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("CREATINA", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxCreatina == null ? "NORMAL" : dxCreatina.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }
            if (xColesterol_1 != null)
            {
                var hbValor        = xColesterol_1.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.COLESTEROL_TOTAL);
                var dxColesterol_1 = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.COLESTEROL_TOTAL);
                var RecoHB         = dxColesterol_1 == null ? null : dxColesterol_1.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("COLESTEROL", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxColesterol_1 == null ? "NORMAL" : dxColesterol_1.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }
            if (xTrigli_1 != null)
            {
                var hbValor    = xTrigli_1.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.TRIGLICERIDOS);
                var dxTrigli_1 = diagnosticRepository.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.TRIGLICERIDOS);
                var RecoHB     = dxTrigli_1 == null ? null : dxTrigli_1.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("TRIGLICÉRIDOS", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase(hbValor == null ? string.Empty : hbValor.v_Value1, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxTrigli_1 == null ? "NORMAL" : dxTrigli_1.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }

            if (xOrina != null)
            {
                var dxOrina = diagnosticRepository.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.EXAMEN_COMPLETO_DE_ORINA_ID);
                var RecoHB  = dxOrina == null ? null : dxOrina.Recomendations;

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("EXAMEN ORINA", fontColumnValue)));
                cells.Add(new PdfPCell(new Phrase("---", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(dxOrina == null ? "NORMAL" : dxOrina.v_DiseasesName, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase(RecoHB == null ? "CONTROL ANUAL" : string.Join(", ", RecoHB.Select(p => p.v_RecommendationName)), fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }

            if (xGrupoSanguineo != null)
            {
                var GSValor = xGrupoSanguineo.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.GRUPO_SANGUINEO_ID);
                var FSValor = xGrupoSanguineo.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FACTOR_SANGUINEO_ID);

                // 1era fila
                cells.Add(new PdfPCell(new Phrase("GRUPO SANGUÍNEO", fontSubTitleNegroNegrita)));
                cells.Add(new PdfPCell(new Phrase(GSValor == null ? string.Empty : GSValor.v_Value1Name, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("---", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("---", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });

                cells.Add(new PdfPCell(new Phrase("FACTOR RH", fontSubTitleNegroNegrita)));
                cells.Add(new PdfPCell(new Phrase(FSValor == null ? string.Empty : FSValor.v_Value1Name, fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("---", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
                cells.Add(new PdfPCell(new Phrase("---", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                });
            }

            columnWidths = new float[] { 25f, 25f, 25f, 25f };

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths);
            document.Add(table);



            #endregion

            #region GrupoSanguineo

            #endregion

            #region Aptitud
            cells = new List <PdfPCell>()
            {
                //fila
                new PdfPCell(new Phrase("APTO:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.i_AptitudeStatusId == (int)Sigesoft.Common.AptitudeStatus.Apto ? "X" :"", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("APTO CON RESTRICCIÓN: ", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.i_AptitudeStatusId == (int)Sigesoft.Common.AptitudeStatus.AptRestriccion ? "X" :"", fontColumnValue)),
                new PdfPCell(new Phrase("NO APTO:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.i_AptitudeStatusId == (int)Sigesoft.Common.AptitudeStatus.NoApto ? "X" :"", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("OBSERVADO:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.i_AptitudeStatusId == (int)Sigesoft.Common.AptitudeStatus.AptoObs ? "X" :"", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },

                //fila
                new PdfPCell(new Phrase("COMENTARIOS:", fontColumnValue)),
                new PdfPCell(new Phrase(filiationData.v_ObsStatusService == "" ? "NINGUNO":filiationData.v_ObsStatusService, fontColumnValue))
                {
                    Colspan = 7, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },

                //fila
                new PdfPCell(new Phrase("RESTRICCIONES:", fontColumnValue)),
                new PdfPCell(new Phrase(pstrRestriciones == "" ? "NINGUNA" : pstrRestriciones, fontColumnValue))
                {
                    Colspan = 7, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
            };
            columnWidths = new float[] { 20f, 10f, 20f, 10f, 20f, 10f, 20f, 10f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "APTITUD", fontTitleTable);

            document.Add(filiationWorker);

            #endregion

            #region Firma y sello Médico

            table = new PdfPTable(2);
            table.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.WidthPercentage     = 40;

            columnWidths = new float[] { 15f, 25f };
            table.SetWidths(columnWidths);

            PdfPCell cellFirma = null;

            if (filiationData.FirmaDoctorAuditor != null)
            {
                cellFirma = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaDoctorAuditor, null, null, 120, 45));
            }
            else
            {
                cellFirma = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirma.FixedHeight         = 50F;

            cell = new PdfPCell(new Phrase("FIRMA Y SELLO MÉDICO", fontColumnValue));
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;

            table.AddCell(cell);
            table.AddCell(cellFirma);

            document.Add(table);

            #endregion



            document.Close();
            writer.Close();
            writer.Dispose();
        }
    }
        public static void CreateExamen_Oftalmologico_Simple(PacientList filiationData, ServiceList DataService,
                                                             List <ServiceComponentList> serviceComponent,
                                                             organizationDto infoEmpresa,
                                                             PacientList datosPac,
                                                             string filePDF, UsuarioGrabo DatosGrabo, List <DiagnosticRepositoryList> Diagnosticos)
        {
            Document document = new Document(PageSize.A4, 30f, 30f, 42f, 41f);

            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include       = string.Empty;
            List <PdfPCell> cells         = null;
            float[]         columnWidths  = null;
            string[]        columnValues  = null;
            string[]        columnHeaders = null;
            PdfPTable       header2       = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            PdfPCell  cell            = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1       = FontFactory.GetFont("Calibri", 12, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValue2 = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue  = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValue1 = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            var tamaño_celda = 15f;
            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresa.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresa.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);
            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("N° DE FICHA", fontColumnValue2))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_IdService, fontColumnValue2))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("INFORME OFTALMOLÓGICO", fontTitle1))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 75f, 25f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            #region DATOS GENERALES
            string[] fechaServicio = datosPac.FechaServicio.ToString().Split(' ');

            string empresageneral     = filiationData.empresa_;
            string empresacontrata    = filiationData.contrata;
            string empresasubcontrata = filiationData.subcontrata;

            string empr_Conct = "";
            if (empresageneral != empresasubcontrata)
            {
                empr_Conct = empresacontrata + " / " + empresasubcontrata;
            }
            else
            {
                empr_Conct = empresacontrata;
            }

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\nDATOS PERSONALES: ", fontColumnValue2))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("NOMBRES: ", fontColumnValue2))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_FirstName, fontColumnValue1))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("APELLIDOS: ", fontColumnValue2))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName, fontColumnValue1))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("EDAD: ", fontColumnValue2))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.Edad.ToString() + " AÑOS", fontColumnValue1))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("TELEFONO: ", fontColumnValue2))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_TelephoneNumber, fontColumnValue1))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("DOMICILIO: ", fontColumnValue2))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_AdressLocation, fontColumnValue1))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("CONTRATA: ", fontColumnValue2))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(empr_Conct, fontColumnValue1))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("FECHA: ", fontColumnValue2))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(fechaServicio[0], fontColumnValue1))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            ServiceComponentList informeOftalmoSimple = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_ID);

            #region ANTECEDENTES LABORALES
            var antecedentes_laborales = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_DESCRIPCION_LAB) == null ? "NO REFIERE ANTECEDENTES PERSONALES" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_DESCRIPCION_LAB).v_Value1;

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("ANTECEDENTES LABORALES: ", fontColumnValue2))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase(antecedentes_laborales, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20F, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region ANTECEDENTES PATOLÓGICOS
            var antecedentes_patologicos = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_DESCRIPCION_PAT) == null ? "NO REFIERE ANTECEDENTES PATOLÓGICOS" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_DESCRIPCION_PAT).v_Value1;

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("ANTECEDENTES PATOLÓGICOS: ", fontColumnValue2))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase(antecedentes_patologicos, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20F, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue2))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 2F, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region OJOS

            var vcscod = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VCSCOD) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VCSCOD).v_Value1Name;
            var vcscoi = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VCSCOI) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VCSCOI).v_Value1Name;
            var vcccod = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VCCCOD) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VCCCOD).v_Value1Name;
            var vcccoi = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VCCCOI) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VCCCOI).v_Value1Name;

            var vlscod = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VLSCOD) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VLSCOD).v_Value1Name;
            var vlscoi = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VLSCOI) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VLSCOI).v_Value1Name;
            var vlccod = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VLCCOD) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VLCCOD).v_Value1Name;
            var vlccoi = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VLCCOI) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VLCCOI).v_Value1Name;

            var    visioncolores         = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VISION_COLORES) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_VISION_COLORES).v_Value1Name;
            var    enfermedadesOculares  = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_ENFERMEDADES_OCULARES) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_ENFERMEDADES_OCULARES).v_Value1;
            var    reflejosPupilares     = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_REFLEJOS_PUPILARES) == null ? "FALTA LLENAR" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_REFLEJOS_PUPILARES).v_Value1Name;
            var    vision_estereoscopica = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_TEST_VISION_ESTEREOSCOPICA) == null ? "NO APLICA" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_TEST_VISION_ESTEREOSCOPICA).v_Value1;
            string stereocopica          = "";
            if (vision_estereoscopica == "-1")
            {
                stereocopica = "NO APLICA";
            }
            else if (vision_estereoscopica == "1")
            {
                stereocopica = "ANORMAL";
            }
            else if (vision_estereoscopica == "2")
            {
                stereocopica = "NORMAL";
            }


            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("OJOS", fontColumnValueBold))
                {
                    Colspan = 4, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("SIN CORREGIR", fontColumnValueBold))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("CORREGIDA", fontColumnValueBold))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("OJO DERECHO", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("OJO IZQUIERDO", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("OJO DERECHO", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("OJO IZQUIERDO", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("VISIÓN DE CERCA", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vcscod, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vcscoi, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vcccod, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vcccoi, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("VISIÓN DE LEJOS", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vlscod, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vlscoi, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vlccod, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vlccoi, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("VISIÓN DE COLORES", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(visioncolores, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },

                new PdfPCell(new Phrase("ENFERMEDADES OCULARES", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(enfermedadesOculares == null?"- - -":enfermedadesOculares == ""?"- - -":enfermedadesOculares, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },

                new PdfPCell(new Phrase("REFLEJOS PUPILARES", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(reflejosPupilares, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },

                new PdfPCell(new Phrase("TEST DE VISIÓN ESTEREOSCÓPICA", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(stereocopica, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 2F, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region  APTITUD OFTALMOLOGO
            //var aptitud = informe_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_GOLDFIELDS_APTITUD_PSICO) == null ? "" : informe_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_GOLDFIELDS_APTITUD_PSICO).v_Value1;
            //var conclusion_desc = informe_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_GOLDFIELDS_APTITUD_PSICO_DESC) == null ? "" : informe_psico_goldfields.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_GOLDFIELDS_APTITUD_PSICO_DESC).v_Value1;
            var    aptoSi = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_APTITUD_SI) == null ? "" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_APTITUD_SI).v_Value1;
            var    aptoNo = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_APTITUD_NO) == null ? "" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_APTITUD_NO).v_Value1;
            string nombreDoc = "", cmp = "";
            if (DataService != null)
            {
                nombreDoc = DataService.NombreDoctor;
                cmp       = DataService.CMP;
            }
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("APTO PARA TRABAJAR", fontColumnValueBold))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("NOMBRES Y APELLIDOS DEL MÉDICO", fontColumnValueBold))
                {
                    Colspan = 9, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("CMP/RNE", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("SI", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(aptoSi == "1"?"X":aptoSi == "0"?"":aptoSi, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("NO", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(aptoNo == "1"?"X":aptoNo == "0"?"":aptoNo, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase(nombreDoc, fontColumnValueBold))
                {
                    Colspan = 9, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(cmp, fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            //var psico = serviceComponent.Find(p => p.i_CategoryId == (int)Sigesoft.Common.Consultorio.Psicología);

            #region Firma

            #region Creando celdas de tipo Imagen y validando nulls
            PdfPCell cellFirmaTrabajador  = null;
            PdfPCell cellHuellaTrabajador = null;
            PdfPCell cellFirma            = null;

            // Firma del trabajador ***************************************************


            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 80, 40));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirmaTrabajador.FixedHeight         = 50F;
            // Huella del trabajador **************************************************

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 30, 45));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellHuellaTrabajador.FixedHeight         = 50F;
            // Firma del doctor Auditor **************************************************
            if (DatosGrabo != null)
            {
                if (DatosGrabo.Firma != null)
                {
                    cellFirma = new PdfPCell(HandlingItextSharp.GetImage(DatosGrabo.Firma, null, null, 120, 50))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_CENTER
                    }
                }
                ;
                else
                {
                    cellFirma = new PdfPCell(new Phrase(" ", fontColumnValue));
                }

                cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
                cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cellFirma.FixedHeight         = 50F;
            }

            #endregion

            cells = new List <PdfPCell>()
            {
                new PdfPCell(cellFirmaTrabajador)
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
                new PdfPCell(cellHuellaTrabajador)
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("FIRMA Y SELLO DEL MÉDICO", fontColumnValueBold))
                {
                    Rowspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(cellFirma)
                {
                    Rowspan = 3, HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },

                new PdfPCell(new Phrase("FIRMA DEL EXAMINADO", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 12f
                },
                new PdfPCell(new Phrase("HUELLA DEL EXAMINADO", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 12f
                },

                new PdfPCell(new Phrase("CON LA CUAL DECLARA QUE LA INFORMACIÓN DECLARADA ES VERAZ", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
            };
            columnWidths = new float[] { 25f, 25f, 25f, 25f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);

            document.Add(filiationWorker);

            #endregion

            #region EXAMENES AUXILIARES COMPLEMENTARIOS
            //var examenesAuxiliares = informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_EXAMENES_AUXILIARES) == null ? "NO REFIERE EXAMENES AUXILIARES" : informeOftalmoSimple.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_EXAMENES_AUXILIARES).v_Value1;

            //cells = new List<PdfPCell>()
            //{

            //    new PdfPCell(new Phrase("EXAMENES AUXILIARES COMPLEMENTARIOS: ", fontColumnValue2)) {Colspan = 20,HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders=true, BorderColorLeft=BaseColor.BLACK,  BorderColorRight=BaseColor.BLACK,  BorderColorBottom=BaseColor.WHITE, BorderColorTop=BaseColor.BLACK  },

            //    new PdfPCell(new Phrase(examenesAuxiliares, fontColumnValue)) {Colspan = 20,HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20F, UseVariableBorders=true, BorderColorLeft=BaseColor.BLACK,  BorderColorRight=BaseColor.BLACK,  BorderColorBottom=BaseColor.BLACK, BorderColorTop=BaseColor.WHITE  },

            //    //new PdfPCell(new Phrase("", fontTitle3)) {Colspan = 20,HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 2F, UseVariableBorders=true, BorderColorLeft=BaseColor.WHITE,  BorderColorRight=BaseColor.WHITE,  BorderColorBottom=BaseColor.WHITE, BorderColorTop=BaseColor.BLACK  },

            //};

            //columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            //table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            //document.Add(table);
            #endregion

            #region Hallazgos y recomendaciones
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("HALLAZGOS Y EXAMENES AUXILIARES COMPLEMENTARIOS ", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },

                new PdfPCell(new Phrase("CIE 10", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },
                new PdfPCell(new Phrase("ESPECIFICACIONES", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },
            };
            columnWidths    = new float[] { 20.6f, 40.6f };
            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);
            document.Add(filiationWorker);
            cells = new List <PdfPCell>();

            var filterDiagnosticRepository = Diagnosticos.FindAll(p => p.v_ComponentId == Sigesoft.Common.Constants.EXAMEN_OFTALMOLOGICO_SIMPLE_ID);

            if (filterDiagnosticRepository != null && filterDiagnosticRepository.Count > 0)
            {
                columnWidths = new float[] { 0.7f, 23.6f };
                include      = "i_Item,Valor1";

                foreach (var item in filterDiagnosticRepository)
                {
                    if (item.v_DiseasesId == "N009-DD000000029")
                    {
                        cell = new PdfPCell(new Phrase(""))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }
                    else
                    {
                        cell = new PdfPCell(new Phrase(item.v_DiseasesName, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }

                    ListaComun        oListaComun = null;
                    List <ListaComun> Listacomun  = new List <ListaComun>();

                    if (item.Recomendations.Count > 0)
                    {
                        oListaComun        = new ListaComun();
                        oListaComun.Valor1 = "RECOMENDACIONES";
                        oListaComun.i_Item = "#";
                        Listacomun.Add(oListaComun);
                    }


                    int Contador = 1;
                    foreach (var Reco in item.Recomendations)
                    {
                        oListaComun = new ListaComun();

                        oListaComun.Valor1 = Reco.v_RecommendationName;
                        oListaComun.i_Item = Contador.ToString();
                        Listacomun.Add(oListaComun);
                        Contador++;
                    }

                    if (item.Restrictions.Count > 0)
                    {
                        oListaComun        = new ListaComun();
                        oListaComun.Valor1 = "RESTRICCIONES";
                        oListaComun.i_Item = "#";
                        Listacomun.Add(oListaComun);
                    }
                    int Contador1 = 1;
                    foreach (var Rest in item.Restrictions)
                    {
                        oListaComun        = new ListaComun();
                        oListaComun.Valor1 = Rest.v_RestrictionName;
                        oListaComun.i_Item = Contador1.ToString();
                        Listacomun.Add(oListaComun);
                        Contador1++;
                    }

                    // Crear tabla de recomendaciones para insertarla en la celda que corresponde
                    table = HandlingItextSharp.GenerateTableFromList(Listacomun, columnWidths, include, fontColumnValue);
                    cell  = new PdfPCell(table);

                    cells.Add(cell);
                }

                columnWidths = new float[] { 20.6f, 40.6f };
            }
            else
            {
                cells.Add(new PdfPCell(new Phrase("NO SE HAN REGISTRADO DATOS.", fontColumnValue)));
                columnWidths = new float[] { 100 };
            }

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, null);
            document.Add(table);
            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
        }
        private void btnImportExcel_Click(object sender, EventArgs e)
        {
            int           Value        = 0;
            bool          Imported     = true;
            int           ErrorCounter = 0;
            DateTime      ValueDateTime;
            StringBuilder sbMensaje = new StringBuilder();

            //if (_TempPacientList == null) return;
            if (_TempPacientList != null)
            {
                if (MessageBox.Show("Ya existe una lista de pacientes por agendar; ¿Desea reemplazarla?.", "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    return;
                }
            }
            openFileDialog1.FileName = string.Empty;
            openFileDialog1.Filter   = "Image Files (*.xls;*.xlsx)|*.xls;*.xlsx";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                _TempPacientList = new List <PacientList>();

                var Ext = Path.GetExtension(openFileDialog1.FileName).ToUpper();

                //try
                //{
                if (Ext == ".XLSX" || Ext == ".XLS")
                {
                    Infragistics.Documents.Excel.Workbook workbook1 = Infragistics.Documents.Excel.Workbook.Load(openFileDialog1.FileName);

                    Infragistics.Documents.Excel.Worksheet worksheet1 = workbook1.Worksheets["PLANTILLA"];

                    PacientList TempPacient;

                    int i  = 4;
                    int ii = 4;
                    //Validar que el excel no esta vacio
                    while (worksheet1.Rows[ii].Cells[0].Value != null)
                    {
                        if (worksheet1.Rows[ii].Cells[0].Value == null || worksheet1.Rows[ii].Cells[1].Value == null || worksheet1.Rows[ii].Cells[2].Value == null || worksheet1.Rows[ii].Cells[3].Value == null || worksheet1.Rows[ii].Cells[4].Value == null || worksheet1.Rows[ii].Cells[5].Value == null || worksheet1.Rows[ii].Cells[6].Value == null || worksheet1.Rows[ii].Cells[7].Value == null || worksheet1.Rows[ii].Cells[8].Value == null || worksheet1.Rows[ii].Cells[9].Value == null || worksheet1.Rows[ii].Cells[10].Value == null || worksheet1.Rows[ii].Cells[11].Value == null || worksheet1.Rows[ii].Cells[12].Value == null)
                        {
                            for (int y = 0; y <= 12; y++)
                            {
                                if (worksheet1.Rows[ii].Cells[y].Value == null)
                                {
                                    Imported = false;
                                    sbMensaje.Append("Registro número : ");
                                    sbMensaje.Append(worksheet1.Rows[ii].Cells[0].Value);
                                    sbMensaje.Append(". El campo " + worksheet1.Rows[3].Cells[y].Value.ToString() + " no puede estar vacio");
                                    sbMensaje.Append("\n");
                                }
                            }
                        }
                        ii++;
                    }
                    if (Imported == false)
                    {
                        MessageBox.Show(sbMensaje.ToString(), "Corregir registros en blanco", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }


                    while (worksheet1.Rows[i].Cells[0].Value != null)
                    {
                        TempPacient = new PacientList();

                        if (worksheet1.Rows[i].Cells[0].Value != null)
                        {
                            TempPacient.i_Correlative = int.Parse(worksheet1.Rows[i].Cells[0].Value.ToString());
                            Imported = true;
                        }
                        //Nombres
                        if (worksheet1.Rows[i].Cells[1].Value != null)
                        {
                            TempPacient.v_FirstName = worksheet1.Rows[i].Cells[1].Value.ToString();
                            Imported = true;
                        }
                        else
                        {
                            ErrorCounter++;
                            Imported = false;
                            sbMensaje.Append("Registro número : ");
                            sbMensaje.Append(worksheet1.Rows[i].Cells[0].Value);
                            sbMensaje.Append(". El campo Nombres es inválido");
                            sbMensaje.Append("\n");
                            i++;
                            continue;
                        }
                        //Apellido Paterno
                        if (worksheet1.Rows[i].Cells[2].Value != null)
                        {
                            TempPacient.v_FirstLastName = worksheet1.Rows[i].Cells[2].Value.ToString();
                            Imported = true;
                        }
                        else
                        {
                            ErrorCounter++;
                            Imported = false;
                            sbMensaje.Append("Registro número : ");
                            sbMensaje.Append(worksheet1.Rows[i].Cells[0].Value);
                            sbMensaje.Append(". El campo Apellido Paterno es inválido");
                            sbMensaje.Append("\n");
                            i++;
                            continue;
                        }
                        //Apellido Materno
                        if (worksheet1.Rows[i].Cells[3].Value != null)
                        {
                            TempPacient.v_SecondLastName = worksheet1.Rows[i].Cells[3].Value.ToString();
                            Imported = true;
                        }
                        else
                        {
                            ErrorCounter++;
                            Imported = false;
                            sbMensaje.Append("Registro número : ");
                            sbMensaje.Append(worksheet1.Rows[i].Cells[0].Value);
                            sbMensaje.Append(". El campo Apellido Materno es inválido");
                            sbMensaje.Append("\n");
                            i++;
                            continue;
                        }
                        //ID Tipo Documento
                        if (worksheet1.Rows[i].Cells[4].Value == null)
                        {
                            ErrorCounter++;
                            Imported = false;
                            sbMensaje.Append("Registro número : ");
                            sbMensaje.Append(worksheet1.Rows[i].Cells[0].Value);
                            sbMensaje.Append(". El campo ID Tipo Documento es inválido");
                            sbMensaje.Append("\n");
                            i++;
                            continue;
                        }
                        if (int.TryParse(worksheet1.Rows[i].Cells[4].Value.ToString(), out Value) == false)
                        {
                            ErrorCounter++;
                            Imported = false;
                            sbMensaje.Append("Registro número : ");
                            sbMensaje.Append(worksheet1.Rows[i].Cells[0].Value);
                            sbMensaje.Append(". El campo ID Tipo Documento es inválido");
                            sbMensaje.Append("\n");
                            i++;
                            continue;
                        }
                        else
                        {
                            Imported = true;
                            TempPacient.i_DocTypeId = int.Parse(worksheet1.Rows[i].Cells[4].Value.ToString());
                        }
                        //Nombre Tipo Documento
                        if (worksheet1.Rows[i].Cells[5].Value != null)
                        {
                            TempPacient.v_DocTypeName = worksheet1.Rows[i].Cells[5].Value.ToString();
                            Imported = true;
                        }
                        else
                        {
                            ErrorCounter++;
                            Imported = false;
                            sbMensaje.Append("Registro número : ");
                            sbMensaje.Append(worksheet1.Rows[i].Cells[0].Value);
                            sbMensaje.Append(". El campo Nombre Tipo Documento es inválido");
                            sbMensaje.Append("\n");
                            i++;
                            continue;
                        }
                        //Número Documento
                        if (worksheet1.Rows[i].Cells[6].Value != null)
                        {
                            if (worksheet1.Rows[i].Cells[4].Value.ToString() == "1") // DNI
                            {
                                if (worksheet1.Rows[i].Cells[6].Value.ToString().Length != 8)
                                {
                                    ErrorCounter++;
                                    Imported = false;
                                    sbMensaje.Append("Registro número : ");
                                    sbMensaje.Append(worksheet1.Rows[i].Cells[0].Value);
                                    sbMensaje.Append(". El campo Número de DNI debe tener 8 dígitos");
                                    sbMensaje.Append("\n");
                                    i++;
                                    continue;
                                }
                                else
                                {
                                    Imported = true;
                                    TempPacient.v_DocNumber = worksheet1.Rows[i].Cells[6].Value.ToString();
                                }
                            }
                            else if (worksheet1.Rows[i].Cells[4].Value.ToString() == "2") // PASAPORTE
                            {
                                if (worksheet1.Rows[i].Cells[6].Value.ToString().Length != 9)
                                {
                                    ErrorCounter++;
                                    Imported = false;
                                    sbMensaje.Append("Registro número : ");
                                    sbMensaje.Append(worksheet1.Rows[i].Cells[0].Value);
                                    sbMensaje.Append(". El Número PASAPORTE debe tener 9 dígitos");
                                    sbMensaje.Append("\n");
                                    i++;
                                    continue;
                                }
                                else
                                {
                                    Imported = true;
                                    TempPacient.v_DocNumber = worksheet1.Rows[i].Cells[6].Value.ToString();
                                }
                            }
                            else if (worksheet1.Rows[i].Cells[4].Value.ToString() == "3") // LICENCIA DE CONDUCIR
                            {
                                if (worksheet1.Rows[i].Cells[6].Value.ToString().Length != 10)
                                {
                                    ErrorCounter++;
                                    Imported = false;
                                    sbMensaje.Append("Registro número : ");
                                    sbMensaje.Append(worksheet1.Rows[i].Cells[0].Value);
                                    sbMensaje.Append(". El Número LICENCIA DE CONDUCIR debe tener 10 dígitos");
                                    sbMensaje.Append("\n");
                                    i++;
                                    continue;
                                }
                                else
                                {
                                    Imported = true;
                                    TempPacient.v_DocNumber = worksheet1.Rows[i].Cells[6].Value.ToString();
                                }
                            }
                            else if (worksheet1.Rows[i].Cells[4].Value.ToString() == "4")// CARNET DE EXTRANJERIA
                            {
                                if (worksheet1.Rows[i].Cells[6].Value.ToString().Length != 11)
                                {
                                    ErrorCounter++;
                                    Imported = false;
                                    sbMensaje.Append("Registro número : ");
                                    sbMensaje.Append(worksheet1.Rows[i].Cells[0].Value);
                                    sbMensaje.Append(". El Número CARNET DE EXTRANJERIA debe tener 11 dígitos");
                                    sbMensaje.Append("\n");
                                    i++;
                                    continue;
                                }
                                else
                                {
                                    Imported = true;
                                    TempPacient.v_DocNumber = worksheet1.Rows[i].Cells[6].Value.ToString();
                                }
                            }
                        }
                        else
                        {
                            ErrorCounter++;
                            Imported = false;
                            sbMensaje.Append("Registro número : ");
                            sbMensaje.Append(worksheet1.Rows[i].Cells[0].Value);
                            sbMensaje.Append(". El campo Número Documento es inválido");
                            sbMensaje.Append("\n");
                            i++;
                            continue;
                        }
                        //ID Género
                        if (int.TryParse(worksheet1.Rows[i].Cells[7].Value.ToString(), out Value))
                        {
                            Imported = true;
                            TempPacient.i_SexTypeId = int.Parse(worksheet1.Rows[i].Cells[7].Value.ToString());
                        }
                        else
                        {
                            ErrorCounter++;
                            Imported = false;
                            sbMensaje.Append("Registro número : ");
                            sbMensaje.Append(worksheet1.Rows[i].Cells[0].Value);
                            sbMensaje.Append(". El campo ID Género es inválido");
                            sbMensaje.Append("\n");
                            i++;
                            continue;
                        }
                        // Nombre Género
                        if (worksheet1.Rows[i].Cells[8].Value != null)
                        {
                            Imported = true;
                            TempPacient.v_SexTypeName = worksheet1.Rows[i].Cells[8].Value.ToString();
                        }
                        else
                        {
                            ErrorCounter++;
                            Imported = false;
                            sbMensaje.Append("Registro número : ");
                            sbMensaje.Append(worksheet1.Rows[i].Cells[0].Value);
                            sbMensaje.Append(". El campo Nombre Género es inválido");
                            sbMensaje.Append("\n");
                            i++;
                            continue;
                        }
                        //Fecha Nacimiento
                        if (worksheet1.Rows[i].Cells[12].Value == null)
                        {
                            ErrorCounter++;
                            Imported = false;
                            sbMensaje.Append("Registro número : ");
                            sbMensaje.Append(worksheet1.Rows[i].Cells[0].Value);
                            sbMensaje.Append(". El campo Fecha Nacimiento es inválido");
                            sbMensaje.Append("\n");
                            i++;
                            continue;
                        }
                        if (DateTime.TryParseExact(worksheet1.Rows[i].Cells[12].Value.ToString(), "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out ValueDateTime) == false)
                        {
                            ErrorCounter++;
                            Imported = false;
                            sbMensaje.Append("Registro número : ");
                            sbMensaje.Append(worksheet1.Rows[i].Cells[0].Value);
                            sbMensaje.Append(". El campo Fecha Nacimiento es inválido");
                            sbMensaje.Append("\n");
                            i++;
                            continue;
                        }
                        else
                        {
                            Imported = true;
                            TempPacient.d_Birthdate = DateTime.ParseExact(worksheet1.Rows[i].Cells[12].Value.ToString(), "yyyyMMdd", CultureInfo.InvariantCulture);
                        }


                        //Puesto de Trabajo
                        if (worksheet1.Rows[i].Cells[13].Value != null)
                        {
                            TempPacient.v_CurrentOccupation = worksheet1.Rows[i].Cells[13].Value.ToString();
                            Imported = true;
                        }
                        else
                        {
                            //ErrorCounter++;
                            //Imported = false;
                            //sbMensaje.Append("Registro número : ");
                            //sbMensaje.Append(worksheet1.Rows[i].Cells[10].Value);
                            //sbMensaje.Append(". El campo Nombres es inválido");
                            //sbMensaje.Append("\n");
                            //i++;
                            //continue;
                            TempPacient.v_CurrentOccupation = string.Empty;
                        }

                        //PROTOCOLO ID
                        if (worksheet1.Rows[i].Cells[14].Value != null)
                        {
                            TempPacient.v_ProtocoloId = worksheet1.Rows[i].Cells[14].Value.ToString();
                            Imported = true;
                        }
                        else
                        {
                            //ErrorCounter++;
                            //Imported = false;
                            //sbMensaje.Append("Registro número : ");
                            //sbMensaje.Append(worksheet1.Rows[i].Cells[10].Value);
                            //sbMensaje.Append(". El campo Nombres es inválido");
                            //sbMensaje.Append("\n");
                            //i++;
                            //continue;
                            TempPacient.v_ProtocoloId = string.Empty;
                        }
                        _TempPacientList.Add(TempPacient);

                        var Result = _TempPacientList.FindAll(p => p.v_DocNumber == TempPacient.v_DocNumber && p.i_DocTypeId == TempPacient.i_DocTypeId);
                        if (Result.Count > 1)
                        {
                            MessageBox.Show("El correlativo " + Result[0].i_Correlative + " tiene el mismo Número Documento que el correlativo " + Result[1].i_Correlative + " .Revise el Excel y corriga la duplicidad", "Error al cargar Excel", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        i++;
                    }

                    lblRecordCountPacients.Text = string.Format("Se encontraron {0} registros.", _TempPacientList.Count());

                    if (ErrorCounter > 0)
                    {
                        _TempPacientList         = new List <PacientList>();
                        grdDataPeople.DataSource = new List <PacientList>();
                        MessageBox.Show(sbMensaje.ToString(), "Registros no importados", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        sbMensaje = null;
                    }
                    else if (ErrorCounter == 0)
                    {
                        grdDataPeople.DataSource = _TempPacientList;
                        MessageBox.Show("Se importaron " + _TempPacientList.Count() + " registros.", "Importación correcta", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        _TempPacientList         = new List <PacientList>();
                        grdDataPeople.DataSource = new List <PacientList>();
                        MessageBox.Show(sbMensaje.ToString(), "Registros no importados", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        sbMensaje = null;
                    }
                }
                else
                {
                    grdDataPeople.DataSource = new List <PacientList>();
                    MessageBox.Show("Seleccione un formato correcto (.xlsx)", "INFORMACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                //}
                //catch (Exception )
                //{
                //    MessageBox.Show("El archivo está en uso. Por favor cierra el documento.", "INFORMACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                //}
            }
        }
        public static void CreateExoneracionPlacaTorax(PacientList filiationData, string filePDF,
                                                       PacientList datosPac,
                                                       organizationDto infoEmpresaPropietaria,
                                                       List <ServiceComponentList> exams,
                                                       List <DiagnosticRepositoryList> Diagnosticos,
                                                       List <ServiceComponentList> serviceComponent)
        {
            Document document = new Document(PageSize.A4, 40f, 40f, 80f, 50f);


            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include      = string.Empty;
            List <PdfPCell> cells        = null;
            float[]         columnWidths = null;
            PdfPTable       header2      = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 15, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 12, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresaPropietaria.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);


            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("EXONERACIÓN DE EXAMENES DE PLACA DE TORAX P-A", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, BorderColor = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            var    tamaño_celda = 24f;
            string tipodoc      = "";
            if (datosPac.i_DocTypeId == 1)
            {
                tipodoc = "DNI";
            }
            else if (datosPac.i_DocTypeId == 2)
            {
                tipodoc = "Pasaporte";
            }
            else if (datosPac.i_DocTypeId == 3)
            {
                tipodoc = "Licencia de Conducir";
            }
            else if (datosPac.i_DocTypeId == 4)
            {
                tipodoc = "Carnet de Extranjeria";
            }
            #region Contenido
            ServiceComponentList exoneracion_rx = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.EXCEPCIONES_RX_ID);
            var motivo = exoneracion_rx.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXCEPCIONES_RX_EXO_MOTIVO) == null ? "" : exoneracion_rx.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXCEPCIONES_RX_EXO_MOTIVO).v_Value1;

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\n \nYO :                  " + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\nIdentificado (a) con " + tipodoc + " N° " + datosPac.v_DocNumber + " solicito la exoneración", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase("del procedimiento de Radiología (Radiografía de Torax P-A) por motivos de: ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase(motivo, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase("por lo cual exonero de toda responsabilidad médico legal al personal de :" + infoEmpresaPropietaria.v_Name.Split(' ')[0] + " " + infoEmpresaPropietaria.v_Name.Split(' ')[1], fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase(infoEmpresaPropietaria.v_Name.Split(' ')[2] + " " + infoEmpresaPropietaria.v_Name.Split(' ')[3] + ", como la propia institución por mi decisión de no realizarme dicho", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase("procedimiento.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            string[] fechaServicio = datosPac.FechaServicio.ToString().Split('/', ' ');
            string   mes           = "";
            if (fechaServicio[1] == "01")
            {
                mes = "Enero";
            }
            else if (fechaServicio[1] == "02")
            {
                mes = "Febrero";
            }
            else if (fechaServicio[1] == "03")
            {
                mes = "Marzo";
            }
            else if (fechaServicio[1] == "04")
            {
                mes = "Abril";
            }
            else if (fechaServicio[1] == "05")
            {
                mes = "Mayo";
            }
            else if (fechaServicio[1] == "06")
            {
                mes = "Junio";
            }
            else if (fechaServicio[1] == "07")
            {
                mes = "Julio";
            }
            else if (fechaServicio[1] == "08")
            {
                mes = "Agosto";
            }
            else if (fechaServicio[1] == "09")
            {
                mes = "Setiembre";
            }
            else if (fechaServicio[1] == "10")
            {
                mes = "Octubre";
            }
            else if (fechaServicio[1] == "11")
            {
                mes = "Noviembre";
            }
            else if (fechaServicio[1] == "12")
            {
                mes = "Diciembre";
            }

            PdfPCell cellFirmaTrabajador = null;

            PdfPCell cellHuellaTrabajador = null;

            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 120, 45));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 60, 80));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            #region Fecha / Firmmal
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\n \n \n \n " + infoEmpresaPropietaria.v_SectorName + ", " + fechaServicio[0] + " de " + mes + " del " + fechaServicio[2], fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(cellFirmaTrabajador)
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, FixedHeight = 180, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(cellHuellaTrabajador)
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, FixedHeight = 180, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("_____________________________________", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("           Firma del Paciente        ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
        }
        public static void CreateTicket(string filePDF,
                                        organizationDto infoEmpresaPropietaria, List <TicketDetalleList> detalleTicket,
                                        PacientList datosPac, hospitalizacionDto hospit,
                                        hospitalizacionhabitacionDto hospitHabit, MedicoTratanteAtenciones medico, ticketDto ticket, protocolDto protocolo)
        {
            Document document = new Document(PageSize.A4, 30f, 30f, 45f, 41f);

            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include       = string.Empty;
            List <PdfPCell> cells         = null;
            float[]         columnWidths  = null;
            string[]        columnValues  = null;
            string[]        columnHeaders = null;
            PdfPTable       header2       = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            PdfPCell  cell            = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValue1        = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold1    = FontFactory.GetFont("Calibri", 9, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresaPropietaria.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);
            var tamaño_celda = 15f;
            var cellsTit     = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("TICKET " + ticket.v_TicketId, fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            #region DATOS
            string titular = "";
            if (datosPac.v_OwnerName == "")
            {
                titular = datosPac.v_FirstName + " " + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName;
            }
            else
            {
                titular = datosPac.v_OwnerName;
            }
            string n_habitac = "";
            if (hospitHabit.i_HabitacionId == 1)
            {
                n_habitac = "201";
            }
            else if (hospitHabit.i_HabitacionId == 2)
            {
                n_habitac = "202";
            }
            else if (hospitHabit.i_HabitacionId == 3)
            {
                n_habitac = "203";
            }
            else if (hospitHabit.i_HabitacionId == 4)
            {
                n_habitac = "204";
            }
            else if (hospitHabit.i_HabitacionId == 5)
            {
                n_habitac = "205";
            }
            else if (hospitHabit.i_HabitacionId == 6)
            {
                n_habitac = "206";
            }
            else if (hospitHabit.i_HabitacionId == 7)
            {
                n_habitac = "207";
            }
            else if (hospitHabit.i_HabitacionId == 8)
            {
                n_habitac = "208";
            }
            else if (hospitHabit.i_HabitacionId == 9)
            {
                n_habitac = "301";
            }
            else if (hospitHabit.i_HabitacionId == 10)
            {
                n_habitac = "302";
            }
            else if (hospitHabit.i_HabitacionId == 11)
            {
                n_habitac = "303";
            }
            else if (hospitHabit.i_HabitacionId == 12)
            {
                n_habitac = "304";
            }
            else if (hospitHabit.i_HabitacionId == 13)
            {
                n_habitac = "305";
            }
            else if (hospitHabit.i_HabitacionId == 14)
            {
                n_habitac = "306";
            }
            else if (hospitHabit.i_HabitacionId == 15)
            {
                n_habitac = "307";
            }
            else if (hospitHabit.i_HabitacionId == 16)
            {
                n_habitac = "308";
            }
            else
            {
                n_habitac = "- - -";
            }
            string med = "";

            if (medico != null)
            {
                med = medico.Nombre;
            }
            else
            {
                med = "CLINICA SAN LORENZO";
            }
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("SERViCIO: ", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase(protocolo.v_Name, fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("CÓDIGO INTERNO: ", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase(hospitHabit.v_HopitalizacionId, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("PACIENTE: ", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_FirstName + " " + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("TITULAR: ", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(titular, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("HIST. CLINICA : ", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_DocNumber, fontColumnValueBold1))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("CAMA : ", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(n_habitac, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("EMPRESA: ", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_Employer, fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("INGRESO :", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(hospit.d_FechaIngreso.ToString() == null?"":hospit.d_FechaIngreso.ToString().Split(' ')[0], fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },


                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("MEDICO A CARGO: ", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(med, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 5f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 15f, 30f, 15f, 15f, 10F, 15F };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            #region DATOS
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("DETALLE", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("FECHA", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("TICKET", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("NOMBRE", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("CANT", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
            };
            columnWidths = new float[] { 12f, 12f, 66f, 10f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion


            #region Parte Dinámica
            cells = new List <PdfPCell>();
            int    tamañoTickets = 0;
            string enfermera     = "";
            if (detalleTicket != null)
            {
                var detalletickets = detalleTicket.FindAll(p => p.d_Cantidad != 0);
                tamañoTickets = detalletickets.Count();

                cell = new PdfPCell(new Phrase(ticket.d_Fecha.ToString().Split(' ')[0], fontColumnValue))
                {
                    Rowspan = tamañoTickets, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE, MinimumHeight = 15f
                };
                cells.Add(cell);

                cell = new PdfPCell(new Phrase(ticket.i_TipoCuentaId.ToString() == "1" ? "\nSOP" : ticket.i_TipoCuentaId.ToString() == "2" ? "\nPROC - SOP" : ticket.i_TipoCuentaId.ToString() == "3" ? "\nHOSP" : ticket.i_TipoCuentaId.ToString() == "4" ? "\nI. SERV." : string.Empty, fontColumnValue))
                {
                    Rowspan = tamañoTickets, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE, MinimumHeight = 15f
                };
                cells.Add(cell);

                foreach (var item in detalleTicket)
                {
                    cell = new PdfPCell(new Phrase(item.v_Descripcion, fontColumnValue))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_LEFT, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE, MinimumHeight = 15f
                    };
                    cells.Add(cell);
                    int cantidad = (int)item.d_Cantidad;
                    cell = new PdfPCell(new Phrase(cantidad.ToString(), fontColumnValue))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_CENTER, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE, MinimumHeight = 15f
                    };
                    cells.Add(cell);
                    enfermera = item.UsuarioCrea;
                }
            }
            columnWidths = new float[] { 12f, 12f, 66f, 10f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

            document.Add(filiationWorker);
            #endregion

            #region Enfermera
            cells = new List <PdfPCell>();

            cell = new PdfPCell(new Phrase("Enfermera: ", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 25f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase(enfermera, fontColumnValueBold))
            {
                Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 25f
            };
            cells.Add(cell);


            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 50f
            };
            cells.Add(cell);


            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("_______________________________________", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("_______________________________________", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);

            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("FARMACIA", fontColumnValue1))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("PACIENTE: " + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + ", " + datosPac.v_FirstName + "\nDNI: " + datosPac.v_DocNumber, fontColumnValue1))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);
            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 13f
            };
            cells.Add(cell);



            cell = new PdfPCell(new Phrase("", fontColumnValue))
            {
                Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, MinimumHeight = 30f
            };
            cells.Add(cell);

            columnWidths = new float[] { 10f, 34f, 12f, 34f, 10f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

            document.Add(filiationWorker);
            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
            RunFile(filePDF);
        }
        public static void CreateAutorizacionLiberacionInformacionMedicaSanMartin(string filePDF,
                                                                                  PacientList datosPac,
                                                                                  organizationDto infoEmpresaPropietaria, PacientList filiationData)
        {
            Document document = new Document(PageSize.A4, 40f, 40f, 80f, 50f);


            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include      = string.Empty;
            List <PdfPCell> cells        = null;
            float[]         columnWidths = null;
            PdfPTable       header2      = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 14, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 9, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValue1        = FontFactory.GetFont("Calibri", 9, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 11, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresaPropietaria.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            string[] fechaServicio = datosPac.FechaServicio.ToString().Split('/', ' ');

            var tamaño_celda = 20f;

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("AUTORIZACION DE LIBERACION DE INFORMACION MÉDICA", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, BorderColor = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region Contenido
            string empresageneral     = filiationData.empresa_;
            string empresacontrata    = filiationData.contrata;
            string empresasubcontrata = filiationData.subcontrata;

            string empr_Conct = "";
            if (empresageneral != empresasubcontrata)
            {
                empr_Conct = empresageneral + " / " + empresacontrata + " / " + empresasubcontrata;
            }
            else
            {
                empr_Conct = empresageneral + " / " + empresacontrata;
            }

            string[] clinica = infoEmpresaPropietaria.v_Name.Split(' ');
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \nYO :  ", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n" + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName, fontColumnValue))
                {
                    Colspan = 17, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\nIdentificado (a) con DNI / PASAPORTE / CARNE DE EXTRANJERIA N° ", fontColumnValue))
                {
                    Colspan = 14, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
                new PdfPCell(new Phrase("\n" + datosPac.v_DocNumber, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\ncon domicilio ubicado en ", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
                new PdfPCell(new Phrase("\n" + datosPac.v_AdressLocation, fontColumnValue))
                {
                    Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\nDECLARO ", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
                new PdfPCell(new Phrase("\nque en forma libre y espontanea ", fontColumnValue))
                {
                    Colspan = 7, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
                new PdfPCell(new Phrase("\nAUTORIZO ", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
                new PdfPCell(new Phrase("\na la ", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
                new PdfPCell(new Phrase("\n" + clinica[0] + " " + clinica[1], fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n" + clinica[2] + " " + clinica[3], fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
                new PdfPCell(new Phrase("\na proporcionar información con respecto a mi estado de salud, resultados ", fontColumnValue))
                {
                    Colspan = 14, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n de examenes auziliares, mis resultados de evaluaciones medicas ocupacionales, contenidas ", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\nen mi Historia Clínica, al responsable del Área de Salud Ocupacional de la Empresa", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },


                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n" + empr_Conct, fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \nLa presente autorización se ampara en lo dispuesto en los Artículos 5° segundo párrafo, Artículos 13°,", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n25°, 27° y 29° tercer párrafo de la Ley General de Salud N° 26842.", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },


                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \nFECHA: " + fechaServicio[0] + "/" + fechaServicio[1] + "/" + fechaServicio[2], fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion



            PdfPCell cellFirmaTrabajador = null;

            PdfPCell cellHuellaTrabajador = null;

            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 125, 50));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 55, 75));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;


            #region Fecha / Firmmal
            cells = new List <PdfPCell>()
            {
                new PdfPCell(cellFirmaTrabajador)
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, FixedHeight = 160, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(cellHuellaTrabajador)
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, FixedHeight = 160, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("_____________________________________", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Firma del Paciente", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("N° de DNI: " + datosPac.v_DocNumber, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
        }
        public static void CreateDeclaracion_Jurada_EMPO_YANACOCHA(ServiceList DataService, string filePDF,
                                                                   PacientList datosPac,
                                                                   organizationDto infoEmpresaPropietaria, PacientList filiationData,
                                                                   List <ServiceComponentList> serviceComponent,
                                                                   byte[] CuadroVacio,
                                                                   byte[] CuadroCheck)
        {
            Document document = new Document(PageSize.A4, 40f, 40f, 40f, 50f);


            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include      = string.Empty;
            List <PdfPCell> cells        = null;
            float[]         columnWidths = null;
            PdfPTable       header2      = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 13, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 11, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 11, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue1     = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold1 = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            #endregion

            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresaPropietaria.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);


            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("DECLARACIÓN JURADA PARA EXAMENES MÉDICOS \nPRE OCUPACIONALES", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 5f, 90f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            var    tamaño_celda = 25f;
            string tipodoc1 = "", tipodoc2 = "", tipodoc3 = "", tipodoc4 = "";
            if (datosPac.i_DocTypeId == 1)
            {
                tipodoc1 = "";
            }
            else if (datosPac.i_DocTypeId == 2)
            {
                tipodoc2 = "";
            }
            else if (datosPac.i_DocTypeId == 3)
            {
                tipodoc3 = "";
            }
            else if (datosPac.i_DocTypeId == 4)
            {
                tipodoc4 = "";
            }

            #region Contenido
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n      YO, ", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n identificado con", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                //+ datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("DNI( " + tipodoc1 + " )/ Pasaporte( " + tipodoc2 + " )/CARNET DE EXTRANJERÍA( " + tipodoc4 + " ) N°", fontColumnValue))
                {
                    Colspan = 11, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("representante legal", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("de la empresa ", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("mediante la presente declaro que la información presentada ante la Oficina de", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Proceso de Admisión de Minera Yanacocha SRL, respecto a los exámenes médicos", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("para la visita de mis trabajadores , es fidedigna, veraz y autorizo a comprobarla, ", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("entendiendo que la omisión o distorsión de la misma es motivo suficiente para la ", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase(" ", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("invalidez de mi tramite.", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            string[] fechaServicio = datosPac.FechaServicio.ToString().Split('/', ' ');
            string   mes           = "";
            if (fechaServicio[1] == "01")
            {
                mes = "Enero";
            }
            else if (fechaServicio[1] == "02")
            {
                mes = "Febrero";
            }
            else if (fechaServicio[1] == "03")
            {
                mes = "Marzo";
            }
            else if (fechaServicio[1] == "04")
            {
                mes = "Abril";
            }
            else if (fechaServicio[1] == "05")
            {
                mes = "Mayo";
            }
            else if (fechaServicio[1] == "06")
            {
                mes = "Junio";
            }
            else if (fechaServicio[1] == "07")
            {
                mes = "Julio";
            }
            else if (fechaServicio[1] == "08")
            {
                mes = "Agosto";
            }
            else if (fechaServicio[1] == "09")
            {
                mes = "Setiembre";
            }
            else if (fechaServicio[1] == "10")
            {
                mes = "Octubre";
            }
            else if (fechaServicio[1] == "11")
            {
                mes = "Noviembre";
            }
            else if (fechaServicio[1] == "12")
            {
                mes = "Diciembre";
            }

            PdfPCell cellFirmaTrabajador = null;

            PdfPCell cellHuellaTrabajador = null;

            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 100, 35));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 60, 80));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            #region Fecha / Firmma
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\n \n \n \n ........................, " + "....... de .....................del 20.....", fontColumnValue))
                {
                    Colspan = 19, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell()
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, FixedHeight = 100, BorderColor = BaseColor.WHITE
                },
                new PdfPCell()
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, FixedHeight = 100, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("_____________________________________", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Firma", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },


                new PdfPCell(new Phrase("\n \n \n", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 50f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region Title

            PdfPCell CellLogo   = null;
            PdfPCell cellPhoto1 = null;

            if (filiationData.b_Photo != null)
            {
                cellPhoto1 = new PdfPCell(HandlingItextSharp.GetImage(filiationData.b_Photo, null, null, 80, 60))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_RIGHT
                }
            }
            ;
            else
            {
                cellPhoto1 = new PdfPCell(new Phrase(" ", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_RIGHT
                }
            };

            if (infoEmpresaPropietaria.b_Image != null)
            {
                CellLogo = new PdfPCell(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image, 20F))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                };
            }
            else
            {
                CellLogo = new PdfPCell(new Phrase(" ", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                };
            }

            PdfPCell cellConCheck = null;
            cellConCheck = new PdfPCell(HandlingItextSharp.GetImage(CuadroCheck));

            PdfPCell cellSinCheck = null;
            cellSinCheck = new PdfPCell(HandlingItextSharp.GetImage(CuadroVacio));


            PdfPCell PreOcupacional = cellSinCheck, Periodica = cellSinCheck, Retiro = cellSinCheck, Otros = cellSinCheck, Empresa = cellSinCheck, Contratista = cellSinCheck;

            if (DataService != null)
            {
                if (DataService.i_EsoTypeId == (int)Sigesoft.Common.TypeESO.PreOcupacional)
                {
                    PreOcupacional = cellConCheck;
                }
                else if (DataService.i_EsoTypeId == (int)Sigesoft.Common.TypeESO.PeriodicoAnual)
                {
                    Periodica = cellConCheck;
                }
                else if (DataService.i_EsoTypeId == (int)Sigesoft.Common.TypeESO.Retiro)
                {
                    Retiro = cellConCheck;
                }
                else
                {
                    Otros = cellConCheck;
                }

                if (DataService.i_ServiceTypeId == (int)Sigesoft.Common.ServiceType.Empresarial)
                {
                    Empresa = cellConCheck;
                }
                else
                {
                    Contratista = cellConCheck;
                }
            }
            float  tamaño_celda1      = 12f;
            string empresageneral     = filiationData.empresa_;
            string empresacontrata    = filiationData.contrata;
            string empresasubcontrata = filiationData.subcontrata;

            string empr_Conct = "";
            if (empresageneral != empresasubcontrata)
            {
                empr_Conct = empresacontrata + " / " + empresasubcontrata;
            }
            else
            {
                empr_Conct = empresacontrata;
            }
            cells = new List <PdfPCell>()
            {
                //fila
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Rowspan = 2, Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_CENTER, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("ANEXO N° 16", fontTitle2))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_CENTER, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("EXAMEN MÉDICO", fontColumnValueBold1))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    UseVariableBorders = true, MinimumHeight = tamaño_celda1, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                //fila
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("FICHA MÉDICA OCUPACIONAL", fontTitle2))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_CENTER, UseVariableBorders = true, MinimumHeight = tamaño_celda1, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("PRE-OCUPACIONAL", fontColumnValue1))
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(PreOcupacional)
                {
                    Border = PdfPCell.RIGHT_BORDER, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_BOTTOM
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                ////fila
                //  new PdfPCell(new Phrase("", fontColumnValue1)){ Colspan =1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders=true, BorderColorLeft=BaseColor.WHITE,  BorderColorRight=BaseColor.WHITE,  BorderColorBottom=BaseColor.WHITE, BorderColorTop=BaseColor.WHITE},
                // new PdfPCell(new Phrase(" ", fontColumnValue1)) {Colspan =4 ,MinimumHeight = tamaño_celda1, UseVariableBorders=true, BorderColorLeft=BaseColor.BLACK,  BorderColorRight=BaseColor.BLACK,  BorderColorBottom=BaseColor.WHITE, BorderColorTop=BaseColor.WHITE},
                // //new PdfPCell(new Phrase(" ", fontColumnValue1)){Rowspan = 4, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_RIGHT},
                // new PdfPCell(new Phrase("ANUAL", fontColumnValue1)){ Border = PdfPCell.NO_BORDER ,HorizontalAlignment=PdfPCell.ALIGN_LEFT},
                // new PdfPCell(Periodica){Border = PdfPCell.RIGHT_BORDER, HorizontalAlignment=PdfPCell.ALIGN_CENTER, VerticalAlignment=PdfPCell.ALIGN_CENTER },
                //  new PdfPCell(new Phrase("", fontColumnValue1)){ Colspan =1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda1, UseVariableBorders=true, BorderColorLeft=BaseColor.WHITE,  BorderColorRight=BaseColor.WHITE,  BorderColorBottom=BaseColor.WHITE, BorderColorTop=BaseColor.WHITE},

                //fila
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Border = PdfPCell.LEFT_BORDER
                },
                new PdfPCell()
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_BOTTOM
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Border = PdfPCell.NO_BORDER
                },
                new PdfPCell(new Phrase(" ", fontColumnValue1))
                {
                    Border = PdfPCell.NO_BORDER, Colspan = 1, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("ANUAL", fontColumnValue1))
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(Periodica)
                {
                    Border = PdfPCell.RIGHT_BORDER, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },


                //fila
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("EMPRESA:", fontColumnValue1))
                {
                    Border = PdfPCell.LEFT_BORDER
                },
                new PdfPCell(Empresa)
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_BOTTOM
                },
                new PdfPCell(new Phrase(empresageneral, fontColumnValue1))
                {
                    Border = PdfPCell.NO_BORDER
                },
                new PdfPCell(new Phrase(" ", fontColumnValue1))
                {
                    Border = PdfPCell.NO_BORDER, Colspan = 1, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("RETIRO", fontColumnValue1))
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(Retiro)
                {
                    Border = PdfPCell.RIGHT_BORDER, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                //fila
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("CONTRATISTA:", fontColumnValue1))
                {
                    Border = PdfPCell.LEFT_BORDER
                },
                new PdfPCell(Contratista)
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_BOTTOM
                },
                new PdfPCell(new Phrase(empresacontrata, fontColumnValue1))
                {
                    Border = PdfPCell.NO_BORDER
                },
                new PdfPCell(new Phrase(" ", fontColumnValue1))
                {
                    Border = PdfPCell.NO_BORDER, Colspan = 1, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("REUBICACIÓN", fontColumnValue1))
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(Otros)
                {
                    Border = PdfPCell.RIGHT_BORDER, HorizontalAlignment = PdfPCell.ALIGN_CENTER, VerticalAlignment = PdfPCell.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                //fila
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("APELLIDOS Y NOMBRES: ", fontColumnValue1))
                {
                    Colspan = 1, Border = PdfPCell.LEFT_BORDER
                },
                new PdfPCell(new Phrase(datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName, fontColumnValue1))
                {
                    Colspan = 2, Border = PdfPCell.NO_BORDER
                },
                new PdfPCell(new Phrase(" ", fontColumnValue1))
                {
                    Border = PdfPCell.NO_BORDER, Colspan = 1, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("N° DE FICHA: " + datosPac.v_IdService, fontColumnValue1))
                {
                    Colspan = 2, Border = PdfPCell.RIGHT_BORDER
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("FECHA DEL EXAMEN", fontColumnValue1))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_LEFT, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase(datosPac.FechaServicio.ToString().Split(' ')[0], fontColumnValue1))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                // fila
                new PdfPCell(new Phrase("MINERALES EXPLOTADOS O PROCESADOS", fontColumnValue1))
                {
                    Colspan = 1, HorizontalAlignment = PdfPCell.ALIGN_LEFT, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase(datosPac.v_ExploitedMineral, fontColumnValue1))
                {
                    Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_LEFT, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValue1))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda1, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 15f, 5f, 25f, 20f, 20f, 5f, 5f };

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);

            #endregion

            document.Close();
            writer.Close();
            writer.Dispose();
        }
    }
        public static void CreateApendiceN2_Evaluacion_Oftalmologica_Yanacocha(PacientList filiationData,
                                                                               List <ServiceComponentList> serviceComponent,
                                                                               organizationDto infoEmpresa,
                                                                               PacientList datosPac,
                                                                               string filePDF, UsuarioGrabo DatosGrabo, List <ServiceComponentList> ExamenesServicio, List <DiagnosticRepositoryList> Diagnosticos)
        {
            Document document = new Document(PageSize.A4, 30f, 30f, 42f, 41f);

            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include       = string.Empty;
            List <PdfPCell> cells         = null;
            float[]         columnWidths  = null;
            string[]        columnValues  = null;
            string[]        columnHeaders = null;
            PdfPTable       header2       = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            PdfPCell  cell            = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue  = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValue1 = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            var tamaño_celda = 20f;
            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresa.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresa.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("APÉNDICE N° 02: EVALUACIÓN OFTALMOLÓGICA", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f
                },
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);
            document.Add(table);
            #endregion
            #region DATOS GENERALES
            string[] fechaServicio = datosPac.FechaServicio.ToString().Split(' ');
            string   preOcp = "", Ocup = "", postOcup = "";
            if (filiationData.i_EsoTypeId == 1)
            {
                preOcp = "X";
            }
            else if (filiationData.i_EsoTypeId == 2)
            {
                Ocup = "X";
            }
            else if (filiationData.i_EsoTypeId == 3)
            {
                postOcup = "X";
            }

            string empresageneral     = filiationData.empresa_;
            string empresacontrata    = filiationData.contrata;
            string empresasubcontrata = filiationData.subcontrata;

            string empr_Conct = "";
            if (empresageneral != empresasubcontrata)
            {
                empr_Conct = empresacontrata + " / " + empresasubcontrata;
            }
            else
            {
                empr_Conct = empresacontrata;
            }

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("\nApellidos Y Nombres", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + ", " + datosPac.v_FirstName, fontColumnValue))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Edad", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.Edad.ToString() + " Años", fontColumnValue))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Evaluación:", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Pre Ocupacional", fontColumnValue1))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("( " + preOcp + " )", fontColumnValue1))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Ocupacional", fontColumnValue1))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("( " + Ocup + " )", fontColumnValue1))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Post Ocupacional", fontColumnValue1))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("( " + postOcup + " )", fontColumnValue1))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Empresa", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(empr_Conct, fontColumnValue))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);
            document.Add(table);
            #endregion
            ServiceComponentList apendice2Yanacocha = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.APENDICE_N_2_EVALUACION_OFTALMOLOGICA_YANACOCHA_ID);

            #region EXAMENES

            var vcscod = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VCSCOD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VCSCOD).v_Value1Name;
            var vcscoi = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VCSCOI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VCSCOI).v_Value1Name;
            var vcccod = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VCCCOD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VCCCOD).v_Value1Name;
            var vcccoi = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VCCCOI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VCCCOI).v_Value1Name;

            var vlscod = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VLSCOD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VLSCOD).v_Value1Name;
            var vlscoi = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VLSCOI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VLSCOI).v_Value1Name;
            var vlccod = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VLCCOD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VLCCOD).v_Value1Name;
            var vlccoi = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VLCCOI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_VLCCOI).v_Value1Name;

            var enfermedadesOculares = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_ENFERMEDADES_OCULARES) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_ENFERMEDADES_OCULARES).v_Value1;

            var testIshihara      = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_TEST_ISHIHARA) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_TEST_ISHIHARA).v_Value1Name;
            var reflejosPupilares = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_REFLEJOS_PUPILARES) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_REFLEJOS_PUPILARES).v_Value1Name;

            var maculaOD       = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_MACULA_OD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_MACULA_OD).v_Value1Name;
            var maculaOI       = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_MACULA_OI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_MACULA_OI).v_Value1Name;
            var nervioOpticoOD = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_NERVIO_OPTICO_OD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_NERVIO_OPTICO_OD).v_Value1Name;
            var nervioOpticoOI = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_NERVIO_OPTICO_OI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_NERVIO_OPTICO_OI).v_Value1Name;
            var retinaOD       = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_RETINA_OD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_RETINA_OD).v_Value1Name;
            var retinaOI       = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_RETINA_OI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_RETINA_OI).v_Value1Name;

            var presionIntraOcOD     = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_PRESION_INTRAOCULAR_OD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_PRESION_INTRAOCULAR_OD).v_Value1;
            var presionIntraOcOI     = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_PRESION_INTRAOCULAR_OI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_PRESION_INTRAOCULAR_OI).v_Value1;
            var npresionIntraOcODMed = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_PRESION_INTRAOCULAR_OD) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_PRESION_INTRAOCULAR_OD).v_MeasurementUnitName;
            var presionIntraOcOIMed  = apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_PRESION_INTRAOCULAR_OI) == null ? "FALTA LLENAR" : apendice2Yanacocha.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EVALUACION_OFTALMOLOGICA_APENDICE_N_2_YANACOCHA_PRESION_INTRAOCULAR_OI).v_MeasurementUnitName;

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 15, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("OJOS", fontColumnValueBold))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("SIN CORREGIR", fontColumnValueBold))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("CORREGIDA", fontColumnValueBold))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("ENFERMEDADES OCULARES", fontColumnValueBold))
                {
                    Colspan = 5, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("OJO DERECHO", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("OJO IZQUIERDO", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("OJO DERECHO", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("OJO IZQUIERDO", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("VISIÓN DE CERCA", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vcscod, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vcscoi, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vcccod, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vcccoi, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(enfermedadesOculares, fontColumnValue))
                {
                    Colspan = 5, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("VISIÓN DE LEJOS", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vlscod, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vlscoi, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vlccod, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vlccoi, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("VISIÓN DE COLORES \n (TEST DE ISHIHARA)", fontColumnValueBold))
                {
                    Colspan = 3, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(testIshihara, fontColumnValue1))
                {
                    Colspan = 12, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase("REFLEJOS PUPILARES", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(reflejosPupilares, fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },

                new PdfPCell(new Phrase("FONDO DE OJO \n (FUNDOSCOPIA)", fontColumnValueBold))
                {
                    Colspan = 3, Rowspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("MÁCULA OD", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase(maculaOD, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase("MÁCULA OI", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase(maculaOI, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase("PRESIÓN INTRAOCULAR", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("NERVIO ÓPT OD", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase(nervioOpticoOD, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase("NERVIO ÓPT OI", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase(nervioOpticoOI, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase("OD", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(presionIntraOcOD + " " + npresionIntraOcODMed, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("RETINA OD", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase(retinaOD, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase("RETINA OI", fontColumnValueBold))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase(retinaOI, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase("OI", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(presionIntraOcOI + " " + presionIntraOcOIMed, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("NOMBRES Y APELLIDOS DEL MÉDICO", fontColumnValueBold))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("CMP/RNE", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase(DatosGrabo.Nombre, fontColumnValueBold))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(DatosGrabo.CMP, fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region Firma

            #region Creando celdas de tipo Imagen y validando nulls
            PdfPCell cellFirmaTrabajador  = null;
            PdfPCell cellHuellaTrabajador = null;
            PdfPCell cellFirma            = null;

            // Firma del trabajador ***************************************************


            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 80, 40));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirmaTrabajador.FixedHeight         = 50F;
            // Huella del trabajador **************************************************

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 30, 45));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellHuellaTrabajador.FixedHeight         = 50F;
            // Firma del doctor Auditor **************************************************

            if (DatosGrabo.Firma != null)
            {
                cellFirma = new PdfPCell(HandlingItextSharp.GetImage(DatosGrabo.Firma, null, null, 120, 50))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                };
            }
            else
            {
                cellFirma = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirma.FixedHeight         = 50F;
            #endregion

            cells = new List <PdfPCell>()
            {
                new PdfPCell(cellFirmaTrabajador)
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
                new PdfPCell(cellHuellaTrabajador)
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("FIRMA Y SELLO DEL MÉDICO", fontColumnValueBold))
                {
                    Rowspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(cellFirma)
                {
                    Rowspan = 3, HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },

                new PdfPCell(new Phrase("FIRMA DEL EXAMINADO", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 12f
                },
                new PdfPCell(new Phrase("HUELLA DEL EXAMINADO", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 12f
                },

                new PdfPCell(new Phrase("CON LA CUAL DECLARA QUE LA INFORMACIÓN DECLARADA ES VERAZ", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
            };
            columnWidths = new float[] { 25f, 25f, 25f, 25f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);

            document.Add(filiationWorker);

            #endregion

            #region OBSERVACIONES
            //var diagnosticosYanacocha = Diagnosticos.FindAll(p => p.v_ComponentId == Sigesoft.Common.Constants.APENDICE_N_2_EVALUACION_OFTALMOLOGICA_YANACOCHA_ID);
            //cells = new List<PdfPCell>()
            //{
            //    new PdfPCell(new Phrase("Observaciones: ", fontColumnValueBold)) {Colspan = 20,HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders=true, BorderColorLeft=BaseColor.BLACK,  BorderColorRight=BaseColor.BLACK,  BorderColorBottom=BaseColor.WHITE, BorderColorTop=BaseColor.BLACK  },
            //    //new PdfPCell(new Phrase(observaciones, fontColumnValue)) {Colspan = 20,HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20F, UseVariableBorders=true, BorderColorLeft=BaseColor.BLACK,  BorderColorRight=BaseColor.BLACK,  BorderColorBottom=BaseColor.BLACK, BorderColorTop=BaseColor.WHITE  },
            //};

            //if (diagnosticosYanacocha.Count != 0)
            //{
            //    foreach (var item in diagnosticosYanacocha)
            //    {
            //        cells.Add(new PdfPCell(new Phrase(item.v_DiseasesName, fontColumnValue)) { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20F, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE });
            //        //cells.Add(new PdfPCell(new Phrase(item.Recomendations, fontColumnValue)) { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20F, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE });
            //        foreach (var item2 in item.Recomendations)
            //        {
            //            cells.Add(new PdfPCell(new Phrase(item2.v_RecommendationName, fontColumnValue)) { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20F, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE });
            //        }
            //    }
            //}

            //columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            //table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            //document.Add(table);
            #endregion
            #region Hallazgos y recomendaciones
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("HALLAZGOS", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },

                new PdfPCell(new Phrase("CIE 10", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },
                new PdfPCell(new Phrase("ESPECIFICACIONES", fontColumnValueBold))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 13, BackgroundColor = BaseColor.GRAY
                },
            };
            columnWidths    = new float[] { 20.6f, 40.6f };
            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);
            document.Add(filiationWorker);
            cells = new List <PdfPCell>();

            var filterDiagnosticRepository = Diagnosticos.FindAll(p => p.v_ComponentId == Sigesoft.Common.Constants.APENDICE_N_2_EVALUACION_OFTALMOLOGICA_YANACOCHA_ID);

            if (filterDiagnosticRepository != null && filterDiagnosticRepository.Count > 0)
            {
                columnWidths = new float[] { 0.7f, 23.6f };
                include      = "i_Item,Valor1";

                foreach (var item in filterDiagnosticRepository)
                {
                    if (item.v_DiseasesId == "N009-DD000000029")
                    {
                        cell = new PdfPCell(new Phrase(""))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }
                    else
                    {
                        cell = new PdfPCell(new Phrase(item.v_DiseasesName, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }

                    ListaComun        oListaComun = null;
                    List <ListaComun> Listacomun  = new List <ListaComun>();

                    if (item.Recomendations.Count > 0)
                    {
                        oListaComun        = new ListaComun();
                        oListaComun.Valor1 = "RECOMENDACIONES";
                        oListaComun.i_Item = "#";
                        Listacomun.Add(oListaComun);
                    }


                    int Contador = 1;
                    foreach (var Reco in item.Recomendations)
                    {
                        oListaComun = new ListaComun();

                        oListaComun.Valor1 = Reco.v_RecommendationName;
                        oListaComun.i_Item = Contador.ToString();
                        Listacomun.Add(oListaComun);
                        Contador++;
                    }

                    if (item.Restrictions.Count > 0)
                    {
                        oListaComun        = new ListaComun();
                        oListaComun.Valor1 = "RESTRICCIONES";
                        oListaComun.i_Item = "#";
                        Listacomun.Add(oListaComun);
                    }
                    int Contador1 = 1;
                    foreach (var Rest in item.Restrictions)
                    {
                        oListaComun        = new ListaComun();
                        oListaComun.Valor1 = Rest.v_RestrictionName;
                        oListaComun.i_Item = Contador1.ToString();
                        Listacomun.Add(oListaComun);
                        Contador1++;
                    }

                    // Crear tabla de recomendaciones para insertarla en la celda que corresponde
                    table = HandlingItextSharp.GenerateTableFromList(Listacomun, columnWidths, include, fontColumnValue);
                    cell  = new PdfPCell(table);

                    cells.Add(cell);
                }

                columnWidths = new float[] { 20.6f, 40.6f };
            }
            else
            {
                cells.Add(new PdfPCell(new Phrase("NO SE HAN REGISTRADO DATOS.", fontColumnValue)));
                columnWidths = new float[] { 100 };
            }

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, null);
            document.Add(table);
            #endregion


            document.Close();
            writer.Close();
            writer.Dispose();
        }
Beispiel #16
0
        public static void CreateDeclaracionJuradaCoimolacheLaZanja(PacientList filiationData,
                                                                    List <ServiceComponentList> serviceComponent,
                                                                    organizationDto infoEmpresa,
                                                                    PacientList datosPac,
                                                                    string filePDF)
        {
            Document document = new Document(PageSize.A4, 30f, 30f, 42f, 41f);

            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include       = string.Empty;
            List <PdfPCell> cells         = null;
            float[]         columnWidths  = null;
            string[]        columnValues  = null;
            string[]        columnHeaders = null;
            PdfPTable       header2       = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            PdfPCell  cell            = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue      = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold  = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold1 = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            var tamaño_celda = 20f;
            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresa.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresa.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("DECLARACIÓN JURADA", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 5f, 90f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region DATOS GENERALES
            //string preOcp = "", Ocup = "", postOcup = "";
            //if (DataService.i_EsoTypeId == 1)
            //{
            //    preOcp = "X";
            //}
            //else if (DataService.i_EsoTypeId == 2)
            //{
            //    Ocup = "X";
            //}
            //else if (filiationData.i_EsoTypeId == 3)
            //{
            //    postOcup = "X";
            //}

            //string[] fechaServicio = datosPac.FechaServicio.ToString().Split(' ');
            //cells = new List<PdfPCell>()
            //{
            //    new PdfPCell(new Phrase("CLÍNICA:", fontColumnValueBold)) { Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //    new PdfPCell(new Phrase(infoEmpresa.v_Name, fontColumnValue)) { Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //    new PdfPCell(new Phrase("Fecha de Entrevista", fontColumnValueBold)) { Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //    new PdfPCell(new Phrase(fechaServicio[0], fontColumnValue)) { Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },

            //    new PdfPCell(new Phrase("I. Datos Generales:", fontColumnValueBold)) { Colspan = 20,HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BackgroundColor = BaseColor.GRAY },

            //    new PdfPCell(new Phrase("Apellidos Y Nombres", fontColumnValueBold)) { Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //    new PdfPCell(new Phrase(datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName, fontColumnValue)) { Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },

            //    new PdfPCell(new Phrase("Edad", fontColumnValueBold)) { Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda},
            //    new PdfPCell(new Phrase(datosPac.Edad.ToString() , fontColumnValue)) { Colspan = 2,HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //    new PdfPCell(new Phrase("Fecha de Nacimiento:", fontColumnValueBold)) { Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //    new PdfPCell(new Phrase(datosPac.d_Birthdate.ToString().Split(' ')[0], fontColumnValue)) { Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //    new PdfPCell(new Phrase("Estado Civil:", fontColumnValueBold)) { Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda },
            //    new PdfPCell(new Phrase(datosPac.v_MaritalStatus, fontColumnValue)) { Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda },

            //    new PdfPCell(new Phrase("Empresa", fontColumnValueBold)) { Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //    new PdfPCell(new Phrase(filiationData.v_FullWorkingOrganizationName, fontColumnValue)) { Colspan = 7, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //    new PdfPCell(new Phrase("Cargo", fontColumnValueBold)) { Colspan = 2,HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //    new PdfPCell(new Phrase(datosPac.v_CurrentOccupation, fontColumnValue)) { Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda},

            //    new PdfPCell(new Phrase("Tipo de Evaluación", fontColumnValueBold)) { Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //    new PdfPCell(new Phrase("Pre Ocupacional" , fontColumnValueBold)) { Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //    new PdfPCell(new Phrase(preOcp , fontColumnValue)) { Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //    new PdfPCell(new Phrase("Ocupacional", fontColumnValueBold)) { Colspan = 3,HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //    new PdfPCell(new Phrase(Ocup, fontColumnValue)) { Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //    new PdfPCell(new Phrase("Post Ocupacional" , fontColumnValueBold)) { Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //    new PdfPCell(new Phrase(postOcup , fontColumnValue)) { Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda },
            //};

            //columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            //table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            //document.Add(table);
            #endregion
            ServiceComponentList declaracion_jurada_coimo_zanja = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.D_J_PSICOLOGIA_COIMOLACHE_LA_ZANJA_ID);

            #region ENFERMEDADES Y ACCIDENTES
            var    enfermedad_salud_mental     = declaracion_jurada_coimo_zanja.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.D_J_P_COIMOLACHE_LA_ZANJA_ENFERMEDAD_MENTAL) == null ? "" : declaracion_jurada_coimo_zanja.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.D_J_P_COIMOLACHE_LA_ZANJA_ENFERMEDAD_MENTAL).v_Value1;
            string enfermedad_salud_mentalSINO = "";
            if (enfermedad_salud_mental == "1")
            {
                enfermedad_salud_mentalSINO = "SI";
            }
            if (enfermedad_salud_mental == "0")
            {
                enfermedad_salud_mentalSINO = "NO";
            }
            var descripcion_salud_mental      = declaracion_jurada_coimo_zanja.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.D_J_P_COIMOLACHE_LA_ZANJA_SI_DESCRIPCION) == null ? "" : declaracion_jurada_coimo_zanja.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.D_J_P_COIMOLACHE_LA_ZANJA_SI_DESCRIPCION).v_Value1;
            var otras_enfermedades_accidentes = declaracion_jurada_coimo_zanja.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.D_J_P_COIMOLACHE_LA_ZANJA_OTRAS_ENFERMEDADES) == null ? "" : declaracion_jurada_coimo_zanja.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.D_J_P_COIMOLACHE_LA_ZANJA_OTRAS_ENFERMEDADES).v_Value1;

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Antecedentes personales", fontColumnValueBold))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BackgroundColor = BaseColor.GRAY
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("a) Para ser llenado por el trabajador", fontColumnValueBold))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Yo, " + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName + " con DNI : " + datosPac.v_DocNumber + " manifiesto que " + enfermedad_salud_mentalSINO + " se me", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("ha identificadouna enfermedad de salud mental, o psiquiátrica.", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n En el caso de marcar SI, describir en breve palabras el diagnostico de la enfermedad mental, y si recibió tratamiento;", fontColumnValueApendice))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(descripcion_salud_mental, fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("b) Otras enfermedades de salud, y/o accidentes:", fontColumnValueBold))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(otras_enfermedades_accidentes, fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region ENFERMEDADES Y ACCIDENTES

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("VI. Antecedentes personales", fontColumnValueBold))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BackgroundColor = BaseColor.GRAY
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\nCon la firma del presente documento, confirmo y doy fe que la información brindada sobre mi salud es ", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\ncompleta y verdadera, haciéndome responsable de cualquier omisión o dato incorrecto; así mismo ", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\nquedo obligado a informar toda circunstancia nueva que pueda influir no alterar esta información.", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 10f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            var psico = serviceComponent.Find(p => p.i_CategoryId == (int)Sigesoft.Common.Consultorio.Psicología);

            #region Firma

            #region Creando celdas de tipo Imagen y validando nulls
            PdfPCell cellFirmaTrabajador  = null;
            PdfPCell cellHuellaTrabajador = null;
            PdfPCell cellFirma            = null;

            // Firma del trabajador ***************************************************


            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 80, 40));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirmaTrabajador.FixedHeight         = 50F;
            // Huella del trabajador **************************************************

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 30, 45));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellHuellaTrabajador.FixedHeight         = 50F;
            // Firma del doctor Auditor **************************************************

            if (psico.FirmaMedico != null)
            {
                cellFirma = new PdfPCell(HandlingItextSharp.GetImage(psico.FirmaMedico, null, null, 120, 50))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                };
            }
            else
            {
                cellFirma = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirma.FixedHeight         = 50F;
            #endregion

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(cellFirmaTrabajador)
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
                new PdfPCell(cellHuellaTrabajador)
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("FIRMA Y SELLO DEL PSICÓLOGO", fontColumnValueBold1))
                {
                    Rowspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(cellFirma)
                {
                    Rowspan = 3, HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Rowspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("FIRMA DEL EXAMINADO \nN° DNI: " + datosPac.v_DocNumber, fontColumnValueBold1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 12f
                },
                new PdfPCell(new Phrase("HUELLA DEL EXAMINADO", fontColumnValueBold1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 12f
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("CON LA CUAL DECLARA QUE LA INFORMACIÓN DECLARADA ES VERAZ", fontColumnValueBold1))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
            };
            columnWidths = new float[] { 5f, 25f, 20f, 20f, 25f, 5f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);

            document.Add(filiationWorker);

            #endregion

            document.Close();
            writer.Close();
            writer.Dispose();
        }
Beispiel #17
0
        public static void CreateEntregaExamenMedicoOcipacional(PacientList filiationData, ServiceList DataService,
                                                                List <ServiceComponentList> serviceComponent,
                                                                organizationDto infoEmpresa,
                                                                PacientList datosPac,
                                                                string filePDF)
        {
            Document document = new Document(PageSize.A4, 30f, 30f, 45f, 38f);

            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include       = string.Empty;
            List <PdfPCell> cells         = null;
            float[]         columnWidths  = null;
            string[]        columnValues  = null;
            string[]        columnHeaders = null;
            PdfPTable       header2       = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            PdfPCell  cell            = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 13, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue  = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValue1 = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValue2 = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresa.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresa.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(45, 718);
                document.Add(imagenEmpresa);
            }

            //if (filiationData.logoCliente != null)
            //{
            //    iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(filiationData.logoCliente));
            //    imagenEmpresa.ScalePercent(20);
            //    imagenEmpresa.SetAbsolutePosition(40, 795);
            //    document.Add(imagenEmpresa);
            //}
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 60f
                },
                new PdfPCell(new Phrase("ENTREGA DE EXAMEN MEDICO OCUPACIONAL", fontTitle2))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 60f
                },
                new PdfPCell(new Phrase("", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 60f
                },

                new PdfPCell(new Phrase("", fontTitle1))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f
                },
                new PdfPCell(new Phrase("", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f
                },
                new PdfPCell(new Phrase("", fontTitle2))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f
                },
                new PdfPCell(new Phrase("Página 1 de 1", fontColumnValue1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f
                },
            };
            columnWidths = new float[] { 25f, 15f, 30f, 15f, 25f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            var tamaño_cuerpo = 25f;

            #region Contenido
            string preOcp = "", Ocup = "", postOcup = "";
            if (filiationData.i_EsoTypeId == 1)
            {
                preOcp = "X";
            }
            else if (filiationData.i_EsoTypeId == 2)
            {
                Ocup = "X";
            }
            else if (filiationData.i_EsoTypeId == 3)
            {
                postOcup = "X";
            }

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontTitle1))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },


                new PdfPCell(new Phrase("ENTREGA E INFORME DE EXAMEN MEDICO OCUPACIONAL", fontTitle1))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\nLA EMPRESA,", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n" + filiationData.v_FullWorkingOrganizationName, fontColumnValue))
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n; por medio del presente documento,", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("deja constancia que el área  de Salud Ocupacional, ha hecho entrega del informe del Examen Médico", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Ocupacional en Físico, Pre ocupacional ( " + preOcp + " ), Periódico ( " + Ocup + " ) Retiro (" + postOcup + " ) ", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Al Señor (a):   ", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName, fontColumnValue))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Identificado con DNI N°    ", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_DocNumber, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(", Puesto de Trabajo  ", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_CurrentOccupation, fontColumnValue))
                {
                    Colspan = 7, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("destinado al Proyecto: ", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(filiationData.v_NombreProtocolo, fontColumnValue))
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("  CR:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("; así mismo se ha informado detalladamente los resultados obtenidos en el examen médico ocupacional", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("realizado el día: ", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.FechaServicio.ToString().Split(' ')[0], fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("; indicando al trabajador que cumpla con las recomendaciones", fontColumnValue))
                {
                    Colspan = 11, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("médicas respectivas y se compromete a cumplirlas de acuerdo a las indicaciones respectivas.", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("El trabajador firma en señal de conformidad de todo lo escrito previamente.", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 2f, 6f, 5f, 5f, 6f, 5f, 6f, 5f, 5f, 5f, 5f, 5f, 6f, 5f, 6f, 5f, 6f, 5f, 5f, 2f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            string[] fechaImpresion = DateTime.Now.ToString().Split('/', ' ');
            string   mes            = "";
            if (fechaImpresion[1] == "01")
            {
                mes = "Enero";
            }
            else if (fechaImpresion[1] == "02")
            {
                mes = "Febrero";
            }
            else if (fechaImpresion[1] == "03")
            {
                mes = "Marzo";
            }
            else if (fechaImpresion[1] == "04")
            {
                mes = "Abril";
            }
            else if (fechaImpresion[1] == "05")
            {
                mes = "Mayo";
            }
            else if (fechaImpresion[1] == "06")
            {
                mes = "Junio";
            }
            else if (fechaImpresion[1] == "07")
            {
                mes = "Julio";
            }
            else if (fechaImpresion[1] == "08")
            {
                mes = "Agosto";
            }
            else if (fechaImpresion[1] == "09")
            {
                mes = "Setiembre";
            }
            else if (fechaImpresion[1] == "10")
            {
                mes = "Octubre";
            }
            else if (fechaImpresion[1] == "11")
            {
                mes = "Noviembre";
            }
            else if (fechaImpresion[1] == "12")
            {
                mes = "Diciembre";
            }

            PdfPCell cellFirmaTrabajador = null;

            PdfPCell cellHuellaTrabajador = null;
            PdfPCell cellFirmaMedico      = null;

            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 100, 40));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 40, 60));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            if (DataService.FirmaMedicoMedicina != null)
            {
                cellFirmaMedico = new PdfPCell(HandlingItextSharp.GetImage(DataService.FirmaMedicoMedicina, null, null, 100, 40));
            }
            else
            {
                cellFirmaMedico = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaMedico.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellFirmaMedico.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            #region Fecha / Firmmal
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\n \n \n \n  " + infoEmpresa.v_SectorName + ", " + fechaImpresion[0] + " de " + mes + " del " + fechaImpresion[2], fontColumnValue2))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue2))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 50f, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(cellFirmaMedico)
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, FixedHeight = 80, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(cellFirmaTrabajador)
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, FixedHeight = 80, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(cellHuellaTrabajador)
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, FixedHeight = 80, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("___________________________________", fontColumnValue2))
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("___________________________________", fontColumnValue2))
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("PERSONAL MEDICO RESPONSABLE ", fontColumnValue2))
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("FIRMA DEL TRABAJADOR", fontColumnValue2))
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_cuerpo, BorderColor = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
        }
        protected void btnSubir_Click(object sender, EventArgs e)
        {
            OperationResult objOperationResult = new OperationResult();
            CalendarBL      objCalendarBL      = new CalendarBL();
            calendarDto     objCalendarDto     = new calendarDto();
            PacientBL       objPacientBL       = new PacientBL();
            pacientDto      objPacientDto      = new pacientDto();
            PacientList     PacientList        = new PacientList();

            if (dpFechaInicio.SelectedDate.Value < DateTime.Now.Date)
            {
                Alert.ShowInTop("No se permite agendar con una fecha anterior a la actual.", "Error de validación");
                return;
            }

            string CalendarId;
            string PacientId = "";

            StringBuilder sbDatos = new StringBuilder();

            var ListaGrilla = (List <Sigesoft.Node.WinClient.BE.PacientList>)Session["_TempPacientList"];

            foreach (var item in ListaGrilla)
            {
                personDto objPersonDto = new personDto();
                //Validar si el trabajador existe
                objPersonDto = objPacientBL.GetPersonByNroDocument(ref objOperationResult, item.v_DocNumber);
                if (objPersonDto != null)
                {
                    objPersonDto.v_FirstName       = item.v_FirstName.Trim();
                    objPersonDto.v_FirstLastName   = item.v_FirstLastName.Trim();
                    objPersonDto.v_SecondLastName  = item.v_SecondLastName.Trim();
                    objPersonDto.i_DocTypeId       = item.i_DocTypeId;
                    objPersonDto.v_DocNumber       = item.v_DocNumber;
                    objPersonDto.i_SexTypeId       = item.i_SexTypeId;
                    objPersonDto.d_Birthdate       = item.d_Birthdate;
                    objPersonDto.i_LevelOfId       = -1;
                    objPersonDto.i_MaritalStatusId = -1;

                    objPersonDto.i_BloodGroupId           = -1;
                    objPersonDto.i_BloodFactorId          = -1;
                    objPersonDto.i_DepartmentId           = -1;
                    objPersonDto.i_ProvinceId             = -1;
                    objPersonDto.i_DistrictId             = -1;
                    objPersonDto.i_ResidenceInWorkplaceId = -1;
                    objPersonDto.i_TypeOfInsuranceId      = -1;
                    objPersonDto.i_OccupationTypeId       = -1;
                    objPersonDto.i_AltitudeWorkId         = -1;
                    objPersonDto.i_PlaceWorkId            = -1;
                    objPersonDto.i_Relationship           = -1;

                    objPersonDto.v_CurrentOccupation = item.v_CurrentOccupation;
                    objPacientBL.UpdatePacient(ref objOperationResult, objPersonDto, ((ClientSession)Session["objClientSession"]).GetAsList(), objPersonDto.v_DocNumber, objPersonDto.v_DocNumber);
                    PacientId = objPersonDto.v_PersonId;
                }
                else
                {
                    objPersonDto                          = new personDto();
                    objPersonDto.v_FirstName              = item.v_FirstName.Trim();
                    objPersonDto.v_FirstLastName          = item.v_FirstLastName.Trim();
                    objPersonDto.v_SecondLastName         = item.v_SecondLastName.Trim();
                    objPersonDto.i_DocTypeId              = item.i_DocTypeId;
                    objPersonDto.v_DocNumber              = item.v_DocNumber;
                    objPersonDto.i_SexTypeId              = item.i_SexTypeId;
                    objPersonDto.d_Birthdate              = item.d_Birthdate;
                    objPersonDto.i_LevelOfId              = -1;
                    objPersonDto.i_MaritalStatusId        = -1;
                    objPersonDto.i_BloodGroupId           = -1;
                    objPersonDto.i_BloodFactorId          = -1;
                    objPersonDto.i_DepartmentId           = -1;
                    objPersonDto.i_ProvinceId             = -1;
                    objPersonDto.i_DistrictId             = -1;
                    objPersonDto.i_ResidenceInWorkplaceId = -1;
                    objPersonDto.i_TypeOfInsuranceId      = -1;
                    objPersonDto.i_OccupationTypeId       = -1;
                    objPersonDto.i_AltitudeWorkId         = -1;
                    objPersonDto.i_PlaceWorkId            = -1;
                    objPersonDto.i_Relationship           = -1;
                    objPersonDto.v_Deducible              = 0;
                    //objPersonDto.v_Password = item.v_DocNumber;
                    objPersonDto.v_CurrentOccupation = item.v_CurrentOccupation;

                    PacientId = objPacientBL.AddPacient(ref objOperationResult, objPersonDto, ((ClientSession)Session["objClientSession"]).GetAsList());
                }

                var Verificar = objPacientBL.GetBlackList(ref objOperationResult, objPersonDto.v_PersonId);


                if (PacientId != null && Verificar == null)      // Se grabo el paciente y se lo agenda
                {
                    objCalendarDto.v_PersonId         = PacientId;
                    objCalendarDto.d_DateTimeCalendar = dpFechaInicio.SelectedDate.Value;
                    objCalendarDto.i_ServiceTypeId    = (int)ServiceType.Empresarial;
                    objCalendarDto.i_CalendarStatusId = (int)CalendarStatus.Agendado;
                    objCalendarDto.i_ServiceId        = (int)MasterService.Eso;
                    //objCalendarDto.v_ProtocolId = _ProtocolId;
                    //Obtener Id de Protocolo por medio del código del protocolo
                    var ProtocolId = oProtocolBL.ObtenerProtocoloIdPorCodigoProtocolo(ddlProtocoloId.SelectedText);
                    if (ProtocolId == null)
                    {
                        Alert.ShowInTop("El protocolo no existe en el sistema.", "ERRROR!");
                        return;
                    }
                    objCalendarDto.v_ProtocolId        = ProtocolId;
                    objCalendarDto.i_NewContinuationId = (int)modality.NuevoServicio;
                    objCalendarDto.i_LineStatusId      = (int)LineStatus.FueraCircuito;
                    objCalendarDto.i_IsVipId           = (int)SiNo.NO;

                    CalendarId = objPacientBL.AddShedule(ref objOperationResult, objCalendarDto, ((ClientSession)Session["objClientSession"]).GetAsList(), ProtocolId, PacientId, (int)MasterService.Eso, "Nuevo");
                }
                else      // no se grabro el paciente
                {
                    sbDatos.Append("PACIENTE :  ");
                    sbDatos.Append(objPersonDto.v_FirstName + " " + objPersonDto.v_FirstLastName + " " + objPersonDto.v_SecondLastName);
                    sbDatos.Append("  DOCUMENTO :  ");
                    sbDatos.Append(objPersonDto.v_DocNumber);
                    sbDatos.Append("\n");
                }
            }

            //iniciar circuitos


            if (objOperationResult.Success == 1)      // Operación sin error
            {
                Alert.Show("Se agendó correctamente.");
            }
            else    // Operación con error
            {
                Alert.ShowInTop("Error al agendar, por favor comuníquese con su proveedor", "ERROR!");
            }
        }
        public static void CreateHistoriaClinica(PacientList filiationData, List <ServiceComponentList> serviceComponent, organizationDto infoEmpresaPropietaria, List <PersonMedicalHistoryList> listMedicoPersonales, List <FamilyMedicalAntecedentsList> listaPatologicosFamiliares, List <NoxiousHabitsList> listaHabitoNocivos, List <DiagnosticRepositoryList> ListDiagnosticRepository, List <MedicationList> ListMedicamentos, string Recomendaciones, string filePDF)
        {
            //
            // step 1: creation of a document-object
            Document document = new Document();

            //Document document = new Document(new Rectangle(500f, 300f), 10, 10, 10, 10);
            //document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
            document.SetPageSize(iTextSharp.text.PageSize.A4);
            //Document document = new Document(PageSize.A4, 0, 0, 20, 20);
            //
            try
            {
                // step 2: we create a writer that listens to the document
                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
                //
                //create an instance of your PDFpage class. This is the class we generated above.
                pdfPage page = new pdfPage();
                //set the PageEvent of the pdfWriter instance to the instance of our PDFPage class
                writer.PageEvent = page;

                // step 3: we open the document
                document.Open();
                // step 4: we Add content to the document
                // we define some fonts

                #region Fonts

                Font fontTitle1               = FontFactory.GetFont(FontFactory.HELVETICA, 18, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
                Font fontTitle2               = FontFactory.GetFont(FontFactory.HELVETICA, 12, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
                Font fontTitleTable           = FontFactory.GetFont(FontFactory.HELVETICA, 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
                Font fontTitleTableNegro      = FontFactory.GetFont(FontFactory.HELVETICA, 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
                Font fontSubTitle             = FontFactory.GetFont(FontFactory.HELVETICA, 9, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
                Font fontSubTitleNegroNegrita = FontFactory.GetFont(FontFactory.HELVETICA, 9, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

                Font fontColumnValue = FontFactory.GetFont(FontFactory.HELVETICA, 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));


                #endregion

                #region Logo

                Image     logo      = HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image, 30F);
                PdfPTable headerTbl = new PdfPTable(1);
                headerTbl.TotalWidth = writer.PageSize.Width;
                PdfPCell cellLogo = new PdfPCell(logo);

                cellLogo.VerticalAlignment   = Element.ALIGN_TOP;
                cellLogo.HorizontalAlignment = Element.ALIGN_CENTER;

                cellLogo.Border = PdfPCell.NO_BORDER;
                headerTbl.AddCell(cellLogo);
                document.Add(headerTbl);

                #endregion

                #region Title

                Paragraph cTitle = new Paragraph("HISTORIA CLÍNICA", fontTitle2);
                //Paragraph cTitle2 = new Paragraph(customerOrganizationName, fontTitle2);
                cTitle.Alignment = Element.ALIGN_CENTER;
                //cTitle2.Alignment = Element.ALIGN_CENTER;

                document.Add(cTitle);
                //document.Add(cTitle2);

                #endregion

                #region Declaration Tables
                var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.White);
                string          include       = string.Empty;
                List <PdfPCell> cells         = null;
                float[]         columnWidths  = null;
                string[]        columnValues  = null;
                string[]        columnHeaders = null;

                //PdfPTable header1 = new PdfPTable(2);
                //header1.HorizontalAlignment = Element.ALIGN_CENTER;
                //header1.WidthPercentage = 100;
                ////header1.TotalWidth = 500;
                ////header1.LockedWidth = true;    // Esto funciona con TotalWidth
                //float[] widths = new float[] { 150f, 200f};
                //header1.SetWidths(widths);


                //Rectangle rec = document.PageSize;
                PdfPTable header2 = new PdfPTable(6);
                header2.HorizontalAlignment = Element.ALIGN_CENTER;
                header2.WidthPercentage     = 100;
                //header1.TotalWidth = 500;
                //header1.LockedWidth = true;    // Esto funciona con TotalWidth
                float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
                header2.SetWidths(widths1);
                //header2.SetWidthPercentage(widths1, rec);

                PdfPTable companyData = new PdfPTable(6);
                companyData.HorizontalAlignment = Element.ALIGN_CENTER;
                companyData.WidthPercentage     = 100;
                //header1.TotalWidth = 500;
                //header1.LockedWidth = true;    // Esto funciona con TotalWidth
                float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
                companyData.SetWidths(widthscolumnsCompanyData);

                PdfPTable filiationWorker = new PdfPTable(4);

                PdfPTable table = null;

                PdfPCell cell = null;

                #endregion

                // Salto de linea
                document.Add(new Paragraph("\r\n"));


                #region Datos Empresa Propietaria

                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("Dirección: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(infoEmpresaPropietaria.v_Address, fontColumnValue)),
                    new PdfPCell(new Phrase("Teléfono: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(infoEmpresaPropietaria.v_PhoneNumber, fontColumnValue)),
                    new PdfPCell(new Phrase("Email: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(infoEmpresaPropietaria.v_Mail, fontColumnValue)),
                };

                columnWidths = new float[] { 17f, 17f, 17f, 17f, 17f, 17f };

                filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTableNegro, null);

                document.Add(filiationWorker);

                #endregion

                // Salto de linea
                document.Add(new Paragraph("\r\n"));
                #region Cabecera del Reporte

                var xFuncionesVitales = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.FUNCIONES_VITALES_ID);
                var FrecCar           = "";
                var FrecResp          = "";
                var PResionArterial   = "";
                var PResionDias       = "";
                var Temperatura       = "";
                if (xFuncionesVitales != null || xFuncionesVitales.ServiceComponentFields.Count == 0)
                {
                    PResionArterial = xFuncionesVitales.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_PAS_ID) == null ? "" : xFuncionesVitales.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_PAS_ID).v_Value1;
                    PResionDias     = xFuncionesVitales.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_PAD_ID) == null ? "" : xFuncionesVitales.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_PAD_ID).v_Value1;

                    FrecCar  = xFuncionesVitales.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_FREC_CARDIACA_ID) == null ? "" : xFuncionesVitales.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_FREC_CARDIACA_ID).v_Value1;
                    FrecResp = xFuncionesVitales.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_FREC_RESPIRATORIA_ID) == null ? "" : xFuncionesVitales.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_FREC_RESPIRATORIA_ID).v_Value1;

                    Temperatura = xFuncionesVitales.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_TEMPERATURA_ID) == null ? "" : xFuncionesVitales.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.FUNCIONES_VITALES_TEMPERATURA_ID).v_Value1;
                }
                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("Código: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(filiationData.v_IdService, fontColumnValue)),
                    new PdfPCell(new Phrase("Fecha: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(filiationData.d_ServiceDate.Value.ToShortDateString(), fontColumnValue)),
                    new PdfPCell(new Phrase("Emp. Seguro: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(filiationData.v_DocNumber, fontColumnValue))
                    {
                        Colspan = 3
                    },


                    new PdfPCell(new Phrase("Paciente: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(filiationData.v_FirstName + " " + filiationData.v_FirstLastName + " " + filiationData.v_SecondLastName, fontColumnValue))
                    {
                        Colspan = 7
                    },
                    new PdfPCell(new Phrase("Dirección: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(filiationData.v_AdressLocation, fontColumnValue))
                    {
                        Colspan = 7
                    },

                    new PdfPCell(new Phrase("Sexo: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(filiationData.v_SexTypeName, fontColumnValue)),
                    new PdfPCell(new Phrase("Teléfono: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(filiationData.v_TelephoneNumber, fontColumnValue)),
                    new PdfPCell(new Phrase("DNI: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(filiationData.v_DocNumber, fontColumnValue)),
                    new PdfPCell(new Phrase("Edad: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(filiationData.i_Age.ToString() + "años", fontColumnValue)),


                    new PdfPCell(new Phrase("F.C: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(FrecCar + " (Lat/min)", fontColumnValue)),
                    new PdfPCell(new Phrase("F.R: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(FrecResp + " (Resp/min)", fontColumnValue)),
                    new PdfPCell(new Phrase("P.A: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(PResionArterial + " (mmHg)", fontColumnValue)),
                    new PdfPCell(new Phrase("T.: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(Temperatura + " C°", fontColumnValue)),


                    new PdfPCell(new Phrase("T. Emfermedad: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(filiationData.TiempoEnfermedad, fontColumnValue)),
                    new PdfPCell(new Phrase("Inicio: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(filiationData.InicioEnfermedad, fontColumnValue)),
                    new PdfPCell(new Phrase("curso: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(filiationData.CursoEnfermedad, fontColumnValue))
                    {
                        Colspan = 3
                    },

                    new PdfPCell(new Phrase("Signos y Síntomas: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(filiationData.v_MainSymptom, fontColumnValue))
                    {
                        Colspan = 7
                    },
                    new PdfPCell(new Phrase("Enfermedad Actual(Motivo): ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(filiationData.v_Story, fontColumnValue))
                    {
                        Colspan = 7
                    },
                };

                columnWidths = new float[] { 12.5f, 12.5f, 12.5f, 12.5f, 12.5f, 12.5f, 12.5f, 12.5f };

                filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTableNegro, null);

                document.Add(filiationWorker);

                #endregion


                #region  Antecedentes Personales
                cells = new List <PdfPCell>();

                if (listMedicoPersonales != null && listMedicoPersonales.Count > 0)
                {
                    foreach (var item in listMedicoPersonales)
                    {
                        //Columna DX
                        cell = new PdfPCell(new Phrase(item.v_DiseasesName, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);

                        //Columna FECHA INICIO
                        cell = new PdfPCell(new Phrase(item.d_StartDate.Value.ToShortDateString(), fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);

                        //Columna DETALLE
                        cell = new PdfPCell(new Phrase(item.v_TreatmentSite, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }

                    columnWidths = new float[] { 33f, 33f, 33f };
                }
                else
                {
                    cells.Add(new PdfPCell(new Phrase("No se han registrado datos.", fontColumnValue))
                    {
                        Colspan = 8, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                    });
                    columnWidths = new float[] { 33f, 33f, 33f };
                }

                columnHeaders = new string[] { "Diagnóstico", "Fecha Inicio", "Detalle" };

                table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "ANTECEDENTES PERSONALES", fontTitleTableNegro, columnHeaders);

                document.Add(table);

                #endregion

                #region  Antecedentes Familiares
                cells = new List <PdfPCell>();

                if (listaPatologicosFamiliares != null && listaPatologicosFamiliares.Count > 0)
                {
                    foreach (var item in listaPatologicosFamiliares)
                    {
                        //Columna Grupo Familiar
                        cell = new PdfPCell(new Phrase(item.v_TypeFamilyName, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);

                        //Columna DX
                        cell = new PdfPCell(new Phrase(item.v_DiseaseName, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);


                        //Columna DETALLE
                        cell = new PdfPCell(new Phrase(item.v_Comment, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }
                    columnWidths = new float[] { 33f, 33f, 33f };
                }

                else
                {
                    cells.Add(new PdfPCell(new Phrase("No se han registrado datos.", fontColumnValue))
                    {
                        Colspan = 8, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                    });
                    columnWidths = new float[] { 33f, 33f, 33f };
                }

                columnHeaders = new string[] { "Grupo Familiar", "Diagnostico", "Detalle" };

                table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "ANTECEDENTES FAMILIARES", fontTitleTableNegro, columnHeaders);

                document.Add(table);

                #endregion

                #region  Antecedentes Habitos Noscivos
                cells = new List <PdfPCell>();

                if (listaHabitoNocivos != null && listaHabitoNocivos.Count > 0)
                {
                    foreach (var item in listaHabitoNocivos)
                    {
                        //Columna Hábito
                        cell = new PdfPCell(new Phrase(item.v_NoxiousHabitsName, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);

                        //Columna Frecuencia
                        cell = new PdfPCell(new Phrase(item.v_FrecuenciaHabito, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);


                        //Columna Comentario
                        cell = new PdfPCell(new Phrase(item.v_Comment, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }
                    columnWidths = new float[] { 33f, 33f, 33f };
                }

                else
                {
                    cells.Add(new PdfPCell(new Phrase("No se han registrado datos.", fontColumnValue))
                    {
                        Colspan = 8, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                    });
                    columnWidths = new float[] { 33f, 33f, 33f };
                }

                columnHeaders = new string[] { "Hábito", "Frecuencia", "Comentartio" };

                table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "HÁBITOS NOSCIVOS", fontTitleTableNegro, columnHeaders);

                document.Add(table);

                #endregion


                var    xExamenFisico     = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.EXAMEN_FISICO_ID);
                string ValorExamenFisico = "";
                if (xExamenFisico != null)
                {
                    ValorExamenFisico = xExamenFisico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_FISICO_HALLAZGOS_ID).v_Value1;
                }
                else
                {
                    ValorExamenFisico = "";
                }

                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("Examen Físico: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(ValorExamenFisico, fontColumnValue)),
                };

                columnWidths = new float[] { 12.5f, 88.5f };

                filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, null, fontTitleTableNegro, null);

                document.Add(filiationWorker);

                #region  Diagnósticos
                cells = new List <PdfPCell>();

                if (ListDiagnosticRepository != null && ListDiagnosticRepository.Count > 0)
                {
                    foreach (var item in ListDiagnosticRepository)
                    {
                        //Columna DX
                        cell = new PdfPCell(new Phrase(item.v_DiseasesName, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);

                        //Columna XIE10
                        cell = new PdfPCell(new Phrase(item.v_Cie10, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }
                    columnWidths = new float[] { 66f, 33f };
                }

                else
                {
                    cells.Add(new PdfPCell(new Phrase("No se han registrado datos.", fontColumnValue))
                    {
                        Colspan = 8, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                    });
                    columnWidths = new float[] { 66f, 33f };
                }

                columnHeaders = new string[] { "Diagnósticos", "CIE10" };

                table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "DIAGNÓSTICOS", fontTitleTableNegro, columnHeaders);

                document.Add(table);

                #endregion

                #region Resultados

                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("Resultados: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(filiationData.v_ExaAuxResult, fontColumnValue)),
                };

                columnWidths = new float[] { 12.5f, 88.5f };

                filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, null, fontTitleTableNegro, null);

                document.Add(filiationWorker);

                #endregion


                #region  Medicación
                cells = new List <PdfPCell>();

                if (ListMedicamentos != null && ListMedicamentos.Count > 0)
                {
                    foreach (var item in ListMedicamentos)
                    {
                        cell = new PdfPCell(new Phrase(item.v_GenericName, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);


                        cell = new PdfPCell(new Phrase(item.v_PresentationName, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);


                        cell = new PdfPCell(new Phrase(item.v_Doses, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);


                        cell = new PdfPCell(new Phrase(item.v_ViaName, fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);
                    }

                    columnWidths = new float[] { 25f, 25f, 25f, 25f };
                }
                else
                {
                    cells.Add(new PdfPCell(new Phrase("No se han registrado datos.", fontColumnValue))
                    {
                        Colspan = 8, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                    });
                    columnWidths = new float[] { 25f, 25f, 25f, 25f };
                }

                columnHeaders = new string[] { "Fármaco", "Presentación", "Dosis", "Vía" };

                table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "MEDICACIÓN Y RECETA", fontTitleTableNegro, columnHeaders);

                document.Add(table);

                #endregion

                #region Reomendaciones

                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("Recomendaciones: ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT
                    }, new PdfPCell(new Phrase(Recomendaciones, fontColumnValue)),
                };

                columnWidths = new float[] { 20f, 80f };

                filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, null, fontTitleTableNegro, null);

                document.Add(filiationWorker);

                #endregion


                #region Firma


                #region Creando celdas de tipo Imagen y validando nulls

                // Firma del trabajador ***************************************************
                PdfPCell cellFirmaTrabajador = null;

                if (filiationData.FirmaTrabajador != null)
                {
                    cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, 20, 20));
                }
                else
                {
                    cellFirmaTrabajador = new PdfPCell(new Phrase("Sin Firma Trabajador", fontColumnValue));
                }

                // Huella del trabajador **************************************************
                PdfPCell cellHuellaTrabajador = null;

                if (filiationData.HuellaTrabajador != null)
                {
                    cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, 15, 15));
                }
                else
                {
                    cellHuellaTrabajador = new PdfPCell(new Phrase("Sin Huella", fontColumnValue));
                }

                // Firma del doctor Auditor **************************************************

                PdfPCell cellFirma = null;

                if (filiationData.FirmaMedico != null)
                {
                    cellFirma = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaMedico, 25, 25));
                }
                else
                {
                    cellFirma = new PdfPCell(new Phrase("Sin Firma", fontColumnValue));
                }

                #endregion

                #region Crear tablas en duro (para la Firma y huella del trabajador)

                cells = new List <PdfPCell>();

                cellFirmaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
                cellFirmaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cellFirmaTrabajador.FixedHeight         = 70F;
                cells.Add(cellFirmaTrabajador);
                cells.Add(new PdfPCell(new Phrase("Firma del Examinado", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                });

                columnWidths = new float[] { 100f };

                var tableFirmaTrabajador = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

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

                cells = new List <PdfPCell>();

                cellHuellaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
                cellHuellaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cellHuellaTrabajador.FixedHeight         = 70F;
                cells.Add(cellHuellaTrabajador);
                cells.Add(new PdfPCell(new Phrase("Huella del Examinado", fontColumnValue))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                });

                columnWidths = new float[] { 100f };

                var tableHuellaTrabajador = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

                #endregion

                cells = new List <PdfPCell>();

                // 1 celda vacia
                cells.Add(new PdfPCell(tableFirmaTrabajador));

                // 1 celda vacia
                cells.Add(new PdfPCell(tableHuellaTrabajador));

                // 2 celda
                cell = new PdfPCell(new Phrase("Firma y Sello Médico", fontColumnValue))
                {
                    Rowspan = 2
                };
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cells.Add(cell);

                // 3 celda (Imagen)
                cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
                cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cellFirma.FixedHeight         = 70F;
                cells.Add(cellFirma);

                cells.Add(new PdfPCell(new Phrase("Con la cual declara que la información declarada es veraz", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE
                });
                cells.Add(new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 2
                });

                columnWidths = new float[] { 25f, 25f, 20f, 30F };
                table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, " ", fontTitleTable);

                document.Add(table);

                #endregion



                // step 5: we close the document
                document.Close();
                writer.Close();
                writer.Dispose();
                //RunFile(filePDF);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public static void CreateInformeResultadosAutorizacionCoimolache(PacientList filiationData, string filePDF,
                                                                         PacientList datosPac,
                                                                         organizationDto infoEmpresaPropietaria)
        {
            Document document = new Document(PageSize.A4, 40f, 40f, 80f, 50f);


            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include      = string.Empty;
            List <PdfPCell> cells        = null;
            float[]         columnWidths = null;
            PdfPTable       header2      = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 12, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValue1        = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresaPropietaria.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);
            string[] fechaServicio = datosPac.FechaServicio.ToString().Split('/', ' ');
            string   mes           = "";
            var      tamaño_celda  = 18f;
            if (fechaServicio[1] == "01")
            {
                mes = "Enero";
            }
            else if (fechaServicio[1] == "02")
            {
                mes = "Febrero";
            }
            else if (fechaServicio[1] == "03")
            {
                mes = "Marzo";
            }
            else if (fechaServicio[1] == "04")
            {
                mes = "Abril";
            }
            else if (fechaServicio[1] == "05")
            {
                mes = "Mayo";
            }
            else if (fechaServicio[1] == "06")
            {
                mes = "Junio";
            }
            else if (fechaServicio[1] == "07")
            {
                mes = "Julio";
            }
            else if (fechaServicio[1] == "08")
            {
                mes = "Agosto";
            }
            else if (fechaServicio[1] == "09")
            {
                mes = "Setiembre";
            }
            else if (fechaServicio[1] == "10")
            {
                mes = "Octubre";
            }
            else if (fechaServicio[1] == "11")
            {
                mes = "Noviembre";
            }
            else if (fechaServicio[1] == "12")
            {
                mes = "Diciembre";
            }

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("CONSENTIMIENTO INFORMADO DE EXAMEN MEDICO Y AUTORIZACIÓN DE ENTREGA DE RESULTADOS", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n \n  " + infoEmpresaPropietaria.v_SectorName + ", " + fechaServicio[0] + " de " + mes + " del " + fechaServicio[2], fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            string tipodoc = "";
            if (datosPac.i_DocTypeId == 1)
            {
                tipodoc = "DNI";
            }
            else if (datosPac.i_DocTypeId == 2)
            {
                tipodoc = "Pasaporte";
            }
            else if (datosPac.i_DocTypeId == 3)
            {
                tipodoc = "Licencia de Conducir";
            }
            else if (datosPac.i_DocTypeId == 4)
            {
                tipodoc = "Carnet de Extranjeria";
            }

            #region Contenido
            string empresageneral     = filiationData.empresa_;
            string empresacontrata    = filiationData.contrata;
            string empresasubcontrata = filiationData.subcontrata;

            string empr_Conct = "";
            if (empresageneral != empresasubcontrata)
            {
                empr_Conct = empresacontrata + " / " + empresasubcontrata;
            }
            else
            {
                empr_Conct = empresacontrata;
            }
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\n \nYO,  ", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n \n" + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName, fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\nIdentificado (a) con " + tipodoc + " N° " + datosPac.v_DocNumber + ", con ocupación laboral de", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase(datosPac.v_CurrentOccupation + ", certifico que he sido inforamdo acerca de la naturaleza y propósito", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase("de los exámenes ocupacionales y pruebas complementarias de la empresa", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase("\n" + empresacontrata, fontColumnValue1))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },


                new PdfPCell(new Phrase("Unidad :", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase(empresageneral, fontColumnValue1))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase(" solicita, :", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },


                new PdfPCell(new Phrase("y que todas mis dudas y preguntas al respecto han sido absueltas; así mismo, autorizo que los", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase("resultados sean entregados al departamento médico de la empresa la cual soy trabajador.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },


                //new PdfPCell(new Phrase("\nTrabajador de la empresa :    ", fontColumnValue))
                //{ Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda , BorderColor=BaseColor.WHITE, ExtraParagraphSpace = 5.0f},
                //new PdfPCell(new Phrase("\n"+empr_Conct, fontColumnValue))
                //{ Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda , BorderColor=BaseColor.WHITE, ExtraParagraphSpace = 5.0f},


                new PdfPCell(new Phrase("\nPor tanto, en forma consciente y voluntaria doy mi consentimiento expreso, de acuerdo a lo establecido en el", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase("item 6.6.2 el Documento Técnico: Protocolos de Exámenes Médicos Ocupacionales y Guías de diagnóstico de", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase("los Exámenes Médicos Obligatorios por Actividad aprobado por la Resolución Ministerial N° 312-2011/MINSA,", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase("para que el Centro Médico que " + empresacontrata + " designe, proceda a efectuar", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase("los exámenes que correspondan en relación a los riesgos laborales propios del puesto de trabajo de", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase("desempeño en la empresa; asimismo, autorizo la utilización de los resultados conforme al artículo 102° del ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase("Decreto Supremo N° 002-2012-TR, Reglamento de la ley de Seguridad y Salud en el Trabajo.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },


                new PdfPCell(new Phrase("\nDe igual manera, autorizo que el Médico Ocupacional de " + empresacontrata, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase("obtenga la información de mi historia clínica presente o anterior, aurotizando a que la pueda solicitar", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase("directamente a la institución que corresponda, conforme al inciso a) del Artículo 25° de la Ley N° 26842,", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },

                new PdfPCell(new Phrase("Ley General de Salud.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion



            PdfPCell cellFirmaTrabajador = null;

            PdfPCell cellHuellaTrabajador = null;

            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 125, 50));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 55, 75));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;


            #region Fecha / Firmmal
            cells = new List <PdfPCell>()
            {
                new PdfPCell(cellFirmaTrabajador)
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, FixedHeight = 120, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(cellHuellaTrabajador)
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, FixedHeight = 120, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("_____________________________________", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Firma del Paciente", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("N° DNI/ Carne de Extranjería y Pasaporte: " + datosPac.v_DocNumber, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("...................", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Ley N° 26842 Art. 4 y Art.25", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
        }
        private void btnschedule_Click(object sender, EventArgs e)
        {
            OperationResult objOperationResult = new OperationResult();
            CalendarBL      objCalendarBL      = new CalendarBL();
            calendarDto     objCalendarDto     = new calendarDto();
            PacientBL       objPacientBL       = new PacientBL();
            pacientDto      objPacientDto      = new pacientDto();
            PacientList     PacientList        = new PacientList();
            BlackListBL     objBlackListBL     = new BlackListBL();

            if (dtpDateTimeCalendar.Value < DateTime.Now.Date)
            {
                MessageBox.Show("No se permite agendar con una fecha anterior a la actual.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string CalendarId;
            string PacientId   = "";
            string ProtocoloId = "";

            StringBuilder sbDatos = new StringBuilder();

            if (uvschedule.Validate(true, false).IsValid)
            {
                foreach (var item in _TempPacientList)
                {
                    personDto objPersonDto = new personDto();
                    //Validar si el trabajador existe
                    objPersonDto = objPacientBL.GetPersonByNroDocument(ref objOperationResult, item.v_DocNumber);
                    if (objPersonDto != null)
                    {
                        objPersonDto.v_FirstName       = item.v_FirstName.Trim();
                        objPersonDto.v_FirstLastName   = item.v_FirstLastName.Trim();
                        objPersonDto.v_SecondLastName  = item.v_SecondLastName.Trim();
                        objPersonDto.i_DocTypeId       = item.i_DocTypeId;
                        objPersonDto.v_DocNumber       = item.v_DocNumber;
                        objPersonDto.i_SexTypeId       = item.i_SexTypeId;
                        objPersonDto.d_Birthdate       = item.d_Birthdate;
                        objPersonDto.i_LevelOfId       = -1;
                        objPersonDto.i_MaritalStatusId = -1;

                        objPersonDto.i_BloodGroupId           = -1;
                        objPersonDto.i_BloodFactorId          = -1;
                        objPersonDto.i_DepartmentId           = -1;
                        objPersonDto.i_ProvinceId             = -1;
                        objPersonDto.i_DistrictId             = -1;
                        objPersonDto.i_ResidenceInWorkplaceId = -1;
                        objPersonDto.i_TypeOfInsuranceId      = -1;
                        objPersonDto.i_OccupationTypeId       = -1;
                        objPersonDto.i_AltitudeWorkId         = -1;
                        objPersonDto.i_PlaceWorkId            = -1;
                        objPersonDto.i_Relationship           = -1;

                        objPersonDto.v_CurrentOccupation = item.v_CurrentOccupation;
                        objPacientBL.UpdatePacient(ref objOperationResult, objPersonDto, Globals.ClientSession.GetAsList(), objPersonDto.v_DocNumber, "");
                        PacientId = objPersonDto.v_PersonId;
                    }
                    else
                    {
                        objPersonDto                          = new personDto();
                        objPersonDto.v_FirstName              = item.v_FirstName.Trim();
                        objPersonDto.v_FirstLastName          = item.v_FirstLastName.Trim();
                        objPersonDto.v_SecondLastName         = item.v_SecondLastName.Trim();
                        objPersonDto.i_DocTypeId              = item.i_DocTypeId;
                        objPersonDto.v_DocNumber              = item.v_DocNumber;
                        objPersonDto.i_SexTypeId              = item.i_SexTypeId;
                        objPersonDto.d_Birthdate              = item.d_Birthdate;
                        objPersonDto.i_LevelOfId              = -1;
                        objPersonDto.i_MaritalStatusId        = -1;
                        objPersonDto.i_BloodGroupId           = -1;
                        objPersonDto.i_BloodFactorId          = -1;
                        objPersonDto.i_DepartmentId           = -1;
                        objPersonDto.i_ProvinceId             = -1;
                        objPersonDto.i_DistrictId             = -1;
                        objPersonDto.i_ResidenceInWorkplaceId = -1;
                        objPersonDto.i_TypeOfInsuranceId      = -1;
                        objPersonDto.i_OccupationTypeId       = -1;
                        objPersonDto.i_AltitudeWorkId         = -1;
                        objPersonDto.i_PlaceWorkId            = -1;
                        objPersonDto.i_Relationship           = -1;
                        objPersonDto.v_Password               = item.v_DocNumber;
                        objPersonDto.v_CurrentOccupation      = item.v_CurrentOccupation;

                        PacientId = objPacientBL.AddPacient(ref objOperationResult, objPersonDto, Globals.ClientSession.GetAsList());
                    }

                    var Verificar = objBlackListBL.GetBlackList(ref objOperationResult, objPersonDto.v_PersonId);


                    if (PacientId != null && Verificar == null)  // Se grabo el paciente y se lo agenda
                    {
                        objCalendarDto.v_PersonId         = PacientId;
                        objCalendarDto.d_DateTimeCalendar = dtpDateTimeCalendar.Value;
                        objCalendarDto.i_ServiceTypeId    = Int32.Parse(ddlServiceTypeId.SelectedValue.ToString());
                        objCalendarDto.i_CalendarStatusId = Int32.Parse(ddlCalendarStatusId.SelectedValue.ToString());
                        objCalendarDto.i_ServiceId        = Int32.Parse(ddlMasterServiceId.SelectedValue.ToString());
                        //objCalendarDto.v_ProtocolId = _ProtocolId;
                        objCalendarDto.v_ProtocolId        = item.v_ProtocoloId;
                        objCalendarDto.i_NewContinuationId = Int32.Parse(ddlNewContinuationId.SelectedValue.ToString());
                        objCalendarDto.i_LineStatusId      = Int32.Parse(ddlLineStatusId.SelectedValue.ToString());
                        objCalendarDto.i_IsVipId           = Int32.Parse(ddlVipId.SelectedValue.ToString());

                        CalendarId = objCalendarBL.AddShedule(ref objOperationResult, objCalendarDto, Globals.ClientSession.GetAsList(), item.v_ProtocoloId, PacientId, Int32.Parse(ddlMasterServiceId.SelectedValue.ToString()), "Nuevo", chkIsCampania.Checked ? 1 : 0);
                    }
                    else  // no se grabro el paciente
                    {
                        sbDatos.Append("PACIENTE :  ");
                        sbDatos.Append(objPersonDto.v_FirstName + " " + objPersonDto.v_FirstLastName + " " + objPersonDto.v_SecondLastName);
                        sbDatos.Append("  DOCUMENTO :  ");
                        sbDatos.Append(objPersonDto.v_DocNumber);
                        sbDatos.Append("\n");
                    }
                }
                if (objOperationResult.Success == 1)  // Operación sin error
                {
                    if (sbDatos.ToString() != "")
                    {
                        MessageBox.Show(sbDatos.ToString(), "Estos pacientes no fueron agendados", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        this.Close();
                    }
                }
                else// Operación con error
                {
                    if (objOperationResult.ErrorMessage != null)
                    {
                        MessageBox.Show(objOperationResult.ErrorMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show(sbDatos.ToString(), "Estos pacientes no fueron agendados", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        // Se queda en el formulario.
                    }
                }
            }
        }
        public static void CreateInforme_Otorrinolaringologico(string filePDF,
                                                               PacientList datosPac,
                                                               organizationDto infoEmpresaPropietaria, PacientList filiationData,
                                                               List <ServiceComponentList> serviceComponent, List <DiagnosticRepositoryList> Diagnosticos, UsuarioGrabo DatosGrabo)
        {
            Document document = new Document(PageSize.A4, 40f, 40f, 40f, 50f);


            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include      = string.Empty;
            List <PdfPCell> cells        = null;
            float[]         columnWidths = null;
            PdfPTable       header2      = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            document.Add(new Paragraph("\r\n"));
            PdfPCell cell = null;
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresaPropietaria.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontTitle1))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("INFORME RADIOLÓGICO", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 25f, 50, 25f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            var    tamaño_celda = 25f;
            string tipodoc      = "";
            if (datosPac.i_DocTypeId == 1)
            {
                tipodoc = "DNI";
            }
            else if (datosPac.i_DocTypeId == 2)
            {
                tipodoc = "Pasaporte";
            }
            else if (datosPac.i_DocTypeId == 3)
            {
                tipodoc = "Licencia de Conducir";
            }
            else if (datosPac.i_DocTypeId == 4)
            {
                tipodoc = "Carnet de Extranjeria";
            }
            ServiceComponentList informe_radiologico = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.INFORME_RADIOLOGICO_ID);
            var n_Placa      = informe_radiologico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_RADIOLOGICO_N_PLACA) == null ? "- - -" : informe_radiologico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_RADIOLOGICO_N_PLACA).v_Value1;
            var informe      = informe_radiologico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_RADIOLOGICO_DESCRIPCION) == null ? "- - -" : informe_radiologico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_RADIOLOGICO_DESCRIPCION).v_Value1;
            var conclusiones = informe_radiologico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_RADIOLOGICO_CONCLUSIONES) == null ? "- - -" : informe_radiologico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_RADIOLOGICO_CONCLUSIONES).v_Value1;

            #region Contenido
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \nNÚMERO DE PLACA: ", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n" + n_Placa.ToString(), fontColumnValue))
                {
                    Colspan = 9, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("APELLIDOS Y NOMBRES: ", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_FirstName + " " + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName, fontColumnValue))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("EDAD: ", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.Edad.ToString() + " años.", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 11, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("SEXO: ", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.Genero, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 11, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("COMPAÑIA", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_FirstName + " " + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName, fontColumnValue))
                {
                    Colspan = 15, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("FECHA: ", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.FechaServicio.ToString().Split(' ')[0], fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },


                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("1. ANAMNESIS: ", fontColumnValueBold))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("2. ANTECEDENTES: ", fontColumnValueBold))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("4. DIAGNÓSTICOS: ", fontColumnValueBold))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region conclusiones
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("5. CONCLUSIONES: ", fontColumnValueBold))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(conclusiones, fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("6. RECOMENDACIONES: ", fontColumnValueBold))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion


            //#region RECOMENDACIONES

            //cells = new List<PdfPCell>()
            //    {
            //        new PdfPCell(new Phrase("", fontColumnValue)){ Colspan =1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 12f, UseVariableBorders=true, BorderColorLeft=BaseColor.WHITE,  BorderColorRight=BaseColor.WHITE,  BorderColorBottom=BaseColor.WHITE, BorderColorTop=BaseColor.WHITE},
            //        new PdfPCell(new Phrase("N°", fontSubTitleNegroNegrita)){HorizontalAlignment = Element.ALIGN_CENTER,  UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK , MinimumHeight = 12f,},
            //        new PdfPCell(new Phrase("DESCRIPCIÓN", fontSubTitleNegroNegrita)){HorizontalAlignment = Element.ALIGN_CENTER, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK, MinimumHeight = 12f, },
            //        new PdfPCell(new Phrase("", fontColumnValue)){ Colspan =1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 12f, UseVariableBorders=true, BorderColorLeft=BaseColor.WHITE,  BorderColorRight=BaseColor.WHITE,  BorderColorBottom=BaseColor.WHITE, BorderColorTop=BaseColor.WHITE},

            //    };

            //columnWidths = new float[] { 5f, 5f, 85f, 5f };

            //filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);

            //document.Add(filiationWorker);


            //cells = new List<PdfPCell>();

            //int nroreco = 1;
            //if (dx != null && dx.Count > 0)
            //{
            //    foreach (var item in dx)
            //    {
            //        columnWidths = new float[] { 95f };
            //        include = "v_RecommendationName";
            //        cell = new PdfPCell(new Phrase("", fontColumnValue)) { HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE };
            //        cells.Add(cell);

            //        cell = new PdfPCell(new Phrase(nroreco.ToString() + ". ", fontColumnValue)) { HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE };
            //        cells.Add(cell);

            //        table = HandlingItextSharp.GenerateTableFromList(item.Recomendations, columnWidths, include, fontColumnValue, PdfPCell.NO_BORDER, null, null);
            //        cell = new PdfPCell(table);
            //        cells.Add(cell);

            //        cell = new PdfPCell(new Phrase("", fontColumnValue)) { HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE };
            //        cells.Add(cell);

            //        nroreco++;
            //    }

            //    columnWidths = new float[] { 5f, 5f, 85f, 5f };
            //}
            //else
            //{
            //    cells.Add(new PdfPCell(new Phrase("", fontColumnValue)));
            //    cells.Add(new PdfPCell(new Phrase("SIN RECOMENDACIONES", fontColumnValue)));
            //    cells.Add(new PdfPCell(new Phrase("", fontColumnValue)));

            //    columnWidths = new float[] { 5f, 90f, 5f };
            //}

            //table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTableNegro, null);

            //document.Add(table);


            //#endregion
            #region Firma

            #region Creando celdas de tipo Imagen y validando nulls
            PdfPCell cellFirmaTrabajador  = null;
            PdfPCell cellHuellaTrabajador = null;
            PdfPCell cellFirma            = null;

            // Firma del trabajador ***************************************************


            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 80, 40));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirmaTrabajador.FixedHeight         = 50F;
            // Huella del trabajador **************************************************

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 30, 45));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellHuellaTrabajador.FixedHeight         = 50F;
            // Firma del doctor Auditor **************************************************
            if (DatosGrabo != null)
            {
                if (DatosGrabo.Firma != null)
                {
                    cellFirma = new PdfPCell(HandlingItextSharp.GetImage(DatosGrabo.Firma, null, null, 120, 50))
                    {
                        HorizontalAlignment = PdfPCell.ALIGN_CENTER
                    }
                }
                ;
                else
                {
                    cellFirma = new PdfPCell(new Phrase(" ", fontColumnValue));
                }

                cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
                cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cellFirma.FixedHeight         = 50F;
            }

            #endregion

            cells = new List <PdfPCell>()
            {
                //new PdfPCell(cellFirmaTrabajador){HorizontalAlignment = PdfPCell.ALIGN_CENTER},
                //new PdfPCell(cellHuellaTrabajador){HorizontalAlignment = PdfPCell.ALIGN_CENTER},
                //new PdfPCell(new Phrase("FIRMA Y SELLO DEL MÉDICO", fontColumnValueBold)) {Rowspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda},
                //new PdfPCell(cellFirma){Rowspan=3, HorizontalAlignment = PdfPCell.ALIGN_CENTER},

                //new PdfPCell(new Phrase("FIRMA DEL EXAMINADO", fontColumnValueBold)) { HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 12f},
                //new PdfPCell(new Phrase("HUELLA DEL EXAMINADO", fontColumnValueBold)) { HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 12f},

                //new PdfPCell(new Phrase("CON LA CUAL DECLARA QUE LA INFORMACIÓN DECLARADA ES VERAZ", fontColumnValueBold)) {Colspan=2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda},
                new PdfPCell(new Phrase("\n \n \n", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(cellFirma)
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 25f, 25f, 25f, 25f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);

            document.Add(filiationWorker);

            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
        }
Beispiel #23
0
        public void GenerateAdditionalexam(string filePDF, OrganizationDto MedicalCenter, PacientList DatosPaciente, UsuarioGrabo usuarioGraba, string MotivoComentario, List <Categoria> DataSource, List <AdditionalExamCustom> ListAdditional)
        {
            Document document = new Document(PageSize.A5, 20f, 20f, 20f, 20f);

            document.SetPageSize(iTextSharp.text.PageSize.A5);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include      = string.Empty;
            List <PdfPCell> cells        = null;
            float[]         columnWidths = null;
            PdfPTable       header2      = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            PdfPCell  cell            = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2_              = FontFactory.GetFont("Calibri", 6, Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.UNDERLINE, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontTitleTableAntecedentesOcupacionales  = FontFactory.GetFont("Arial", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueAntecedentesOcupacionales = FontFactory.GetFont("Arial", 5, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            #endregion


            #region CABECERA
            cells = new List <PdfPCell>();
            var pdfCell = new PdfPCell();

            if (MedicalCenter.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(MedicalCenter.b_Image));
                imagenEmpresa.ScalePercent(25);

                //imagenEmpresa.SetAbsolutePosition(40, 790);
                //document.Add(imagenEmpresa);
                pdfCell = new PdfPCell(imagenEmpresa)
                {
                    Colspan = 1, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColor = BaseColor.WHITE
                };
            }
            else
            {
                pdfCell = new PdfPCell(new Phrase("SIN LOGOTIPO", fontTitle2_))
                {
                    Colspan = 1, Rowspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, BorderColor = BaseColor.WHITE
                };
            }

            var names = new List <PdfPCell>()
            {
                pdfCell,
                new PdfPCell(new Phrase(MedicalCenter.v_Name, fontTitle2_))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(MedicalCenter.v_Address, fontTitle2_))
                {
                    Colspan = 2, HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColor = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 30f, 70f };
            table        = HandlingItextSharp.GenerateTableFromCells(names, columnWidths, null, fontTitleTable);
            document.Add(table);

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\nORDEN DE EXÁMENES MÉDICOS \nADICIONALES", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, BorderColor = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);

            string PacientFullName = "", Edad = "", FechaNac = "", TipoDoc = "", DocNumber = "", Direccion = "", Cargo = "", nHistoria = "---", Celular = "";

            if (DatosPaciente != null)
            {
                PacientFullName = DatosPaciente.v_FirstLastName + " " + DatosPaciente.v_SecondLastName + " " + DatosPaciente.v_FirstName;
                Edad            = DatosPaciente.Edad.ToString();
                FechaNac        = DatosPaciente.d_Birthdate.Value.ToShortDateString();
                DocNumber       = DatosPaciente.v_DocNumber == null ? "---" : DatosPaciente.v_DocNumber;
                Direccion       = string.IsNullOrEmpty(DatosPaciente.v_AdressLocation) ? "---" : DatosPaciente.v_AdressLocation;
                Cargo           = string.IsNullOrEmpty(DatosPaciente.v_CurrentOccupation) ? "---" : DatosPaciente.v_CurrentOccupation;
                Celular         = string.IsNullOrEmpty(DatosPaciente.v_TelephoneNumber) ? "---" : DatosPaciente.v_TelephoneNumber;
                if (DatosPaciente.i_DocTypeId == 1)
                {
                    TipoDoc = "DNI";
                }
                else if (DatosPaciente.i_DocTypeId == 2)
                {
                    TipoDoc = "Pasaporte";
                }
                else if (DatosPaciente.i_DocTypeId == 3)
                {
                    TipoDoc = "Licencia de Conducir";
                }
                else if (DatosPaciente.i_DocTypeId == 4)
                {
                    TipoDoc = "Carnet de Extranjeria";
                }
            }

            //Datos del paciente
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("NOMBRES:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(PacientFullName, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("EDAD:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(Edad, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("F. NAC:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(FechaNac, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase(TipoDoc + ":", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(DocNumber, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("DIRECCIÓN:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(Direccion, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("CARGO:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(Cargo, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("N° HISTORIA:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("CSL-" + DocNumber, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("CELULAR:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(Celular, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 12f, 27f, 15f, 23f, 12f, 11f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);


            #endregion

            #region CUERPO
            //resumen

            var pdfCellComentario = new PdfPCell();
            if (MotivoComentario.Length > 0)
            {
                pdfCellComentario = new PdfPCell(new Phrase(MotivoComentario, fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT,
                    VerticalAlignment   = iTextSharp.text.Element.ALIGN_MIDDLE,
                    MinimumHeight       = 30f,
                    BorderColor         = BaseColor.WHITE
                };
            }
            else
            {
                pdfCellComentario = new PdfPCell(new Phrase("........................................................................................................................................................................ \n........................................................................................................................................................................", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, BorderColor = BaseColor.WHITE
                };
            }
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("RESUMEN", fontTitleTableNegro))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
                pdfCellComentario,
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);


            //exámenes
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("EXÁMENES", fontTitleTableNegro))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);

            foreach (var category in DataSource)
            {
                //exámenes
                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("* ", fontTitleTable))
                    {
                        HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                    },
                    new PdfPCell(new Phrase(category.v_CategoryName, fontTitleTable))
                    {
                        HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                    },
                };
                columnWidths = new float[] { 10f, 90f };
                table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
                document.Add(table);

                foreach (var component in category.Componentes)
                {
                    string estado = "";
                    var    obj    = ListAdditional.Find(x => x.ComponentId == component.v_ComponentId);
                    if (obj != null)
                    {
                        if (obj.IsProcessed == 1)
                        {
                            estado = " ( AGENDADO)";
                        }
                        else
                        {
                            estado = " ( POR AGENDAR )";
                        }
                    }

                    cells = new List <PdfPCell>()
                    {
                        new PdfPCell(new Phrase("- ", fontColumnValue))
                        {
                            HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                        },
                        new PdfPCell(new Phrase(component.v_ComponentName + estado, fontColumnValue))
                        {
                            HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.WHITE
                        },
                    };
                    columnWidths = new float[] { 15f, 85f };
                    table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
                    document.Add(table);
                }
            }



            //datos medicos
            var    cellFirma = new PdfPCell();
            string NombreMedico = "---", CMP = "---";
            if (usuarioGraba != null)
            {
                NombreMedico = usuarioGraba.Nombre == null ? "---" : usuarioGraba.Nombre;
                CMP          = usuarioGraba == null ? "---" : usuarioGraba.CMP;

                if (usuarioGraba.Firma != null)
                {
                    cellFirma = new PdfPCell(HandlingItextSharp.GetImage(usuarioGraba.Firma, null, null, 110, 40))
                    {
                        Colspan = 1, Rowspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColor = BaseColor.BLACK
                    };
                }
            }
            else
            {
                cellFirma = new PdfPCell(new Phrase("FIRMA", fontTitle2_))
                {
                    Colspan = 1, Rowspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.BLACK
                };
            }


            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("DATOS MÉDICOS", fontTitle2))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.BLACK
                },
                cellFirma,
                new PdfPCell(new Phrase("NOMBRE:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.BLACK
                },
                new PdfPCell(new Phrase(NombreMedico, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("CMP:", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.BLACK
                },
                new PdfPCell(new Phrase(CMP, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, BorderColor = BaseColor.BLACK
                },
            };
            columnWidths = new float[] { 15f, 35f, 50f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion


            document.Close();
            writer.Close();
            writer.Dispose();
        }
        public static void CreateInformeMedicoAptitudOcupacionalEmpresa(ServiceList DataService, string filePDF,
                                                                        PacientList datosPac,
                                                                        organizationDto infoEmpresaPropietaria,
                                                                        List <ServiceComponentList> exams,
                                                                        List <DiagnosticRepositoryList> Diagnosticos,
                                                                        List <ServiceComponentList> serviceComponent)
        {
            Document document = new Document(PageSize.A4, 40f, 40f, 10f, 0f);

            //
            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include      = string.Empty;
            List <PdfPCell> cells        = null;
            float[]         columnWidths = null;
            PdfPTable       header2      = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 12, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 11, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            #region TÍTULO

            cells = new List <PdfPCell>();

            iTextSharp.text.Image hudbay = iTextSharp.text.Image.GetInstance("C:/Banner/HUDBAY.png");
            hudbay.ScalePercent(50);
            hudbay.SetAbsolutePosition(45, 760);
            document.Add(hudbay);

            iTextSharp.text.Image banner4 = iTextSharp.text.Image.GetInstance("C:/Banner/Imagen2.png");
            banner4.ScalePercent(50);
            banner4.SetAbsolutePosition(-10, 0);
            document.Add(banner4);


            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80f
                },
                new PdfPCell(new Phrase("INFORME MÉDICO DE APTITUD \n OCUPACIONAL PARA LA EMPRESA", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80f
                },
                new PdfPCell(new Phrase("Formato \n\nDocumento ID   : \nVersión     : \nFecha       : ", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80f
                },
            };
            columnWidths = new float[] { 20f, 50f, 30f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            var tamaño_celda = 20f;


            ServiceComponentList declaracion_jurada = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.EXCEPCIONES_RX_ID);
            //var fecha_regla = declaracion_jurada.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXCEPCIONES_RX_FECHA_ULTIMA_REGLA) == null ? "" : declaracion_jurada.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXCEPCIONES_RX_FECHA_ULTIMA_REGLA).v_Value1;
            string[] fechaServicio = datosPac.FechaServicio.ToString().Split(' ');
            #region Contenido
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("Fecha Examen : " + fechaServicio [0], fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("\nEstimados Señores \nEmpresa:  " + DataService.v_CustomerOrganizationName + " / " + DataService.EmpresaEmpleadora, fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\nLa presente es para saludarles y a la vez informarles acerca de la Aptitud Laboral de su trabajador que paso", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("su Examen de Salud Ocupacional en nuestro Centro Médico Autorizado por Hudbay Perú SAC (indicar nombre del ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("CMA autorizado por HBP)" + infoEmpresaPropietaria.v_Name, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\nDatos del trabajador: ", fontColumnValueBold))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Nombre y Apellidos del Trabajador:", fontColumnValue))
                {
                    Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_FirstName + " " + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Área y Puesto Laboral (específico) donde labora o al que postula", fontColumnValue))
                {
                    Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_CurrentOccupation, fontColumnValue))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\nSiendo los resultados los siguientes (marca con una X donde corresponda): ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("APTO", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("NO APTO", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("APTO CON RESTRICCIONES", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("Examen Médico Pre Ocupacional", fontColumnValue))
                {
                    Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },


                //    new PdfPCell(new Phrase("consentimiento. ", fontColumnValue))
                //    { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda , BorderColor=BaseColor.WHITE},

                //    new PdfPCell(new Phrase("\nEl informe médico que se entregará a su Empresa contiene información relacionada únicamente a la ", fontColumnValue))
                //    { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda , BorderColor=BaseColor.WHITE},
                //    new PdfPCell(new Phrase("aptitud laboral y enfermedad (es) relacionada (s) al trabajo diagnosticado(s), u otras condiciones", fontColumnValue))
                //    { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda , BorderColor=BaseColor.WHITE},
                //    new PdfPCell(new Phrase("médicas que puedan afectar la seguridad en el trabajo y/o aquellas condiciones médicas que puedan", fontColumnValue))
                //    { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda , BorderColor=BaseColor.WHITE},
                //    new PdfPCell(new Phrase("confundir la  exposición a riesgos ocupacionales (Embarazo y/o Riesgos de Salud Reproductiva),", fontColumnValue))
                //    { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda , BorderColor=BaseColor.WHITE},
                //    new PdfPCell(new Phrase("asimismo se indicará las recomendaciones y restricciones del caso. Por otro lado Usted recibirá un", fontColumnValue))
                //    { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda , BorderColor=BaseColor.WHITE},
                //    new PdfPCell(new Phrase("Informe Médico Ocupacional resumido de lo más importante de su evaluación realizada.", fontColumnValue))
                //    { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda , BorderColor=BaseColor.WHITE},

                //    new PdfPCell(new Phrase("\nSu información médica será protegida y no será revelada sin su consentimiento por escrito. Usted puede ", fontColumnValue))
                //    { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda , BorderColor=BaseColor.WHITE},
                //    new PdfPCell(new Phrase("invalidar cualquier consentimiento oral y/o escrito, enviando un documento a la Gerencia de Seguridad y ", fontColumnValue))
                //    { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda , BorderColor=BaseColor.WHITE},
                //    new PdfPCell(new Phrase("Salud Ocupacional.", fontColumnValue))
                //    { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda , BorderColor=BaseColor.WHITE},

                //    new PdfPCell(new Phrase("\nHabiendo leído y comprendido lo anteriormente descrito, acepto el acceso a la historia clínica para los ", fontColumnValue))
                //    { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda , BorderColor=BaseColor.WHITE},
                //    new PdfPCell(new Phrase("fines detallados en este documento al Área de Salud Ocupacional de Hudbay.", fontColumnValue))
                //    { Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda , BorderColor=BaseColor.WHITE},
                //
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion



            string tipodoc = "";
            if (datosPac.i_DocTypeId == 1)
            {
                tipodoc = "DNI";
            }
            else if (datosPac.i_DocTypeId == 2)
            {
                tipodoc = "Pasaporte";
            }
            else if (datosPac.i_DocTypeId == 3)
            {
                tipodoc = "Licencia de Conducir";
            }
            else if (datosPac.i_DocTypeId == 4)
            {
                tipodoc = "Carnet de Extranjeria";
            }
            PdfPCell cellFirmaTrabajador = null;

            PdfPCell cellHuellaTrabajador = null;

            if (DataService.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(DataService.FirmaTrabajador, null, null, 100, 35));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            if (DataService.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(DataService.HuellaTrabajador, null, null, 50, 70));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            #region Fecha / Firmma
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("APELLIDOS Y NOMBRES: ", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName, fontColumnValue))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("FIRMA: ", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(cellFirmaTrabajador)
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(cellHuellaTrabajador)
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80, BorderColor = BaseColor.WHITE
                },


                new PdfPCell(new Phrase(tipodoc + " :", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_DocNumber, fontColumnValue))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("FECHA: ", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(fechaServicio[0], fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("EMPRESA: ", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(DataService.v_CustomerOrganizationName, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
        }
        public static void CreateFichaMedicaTrabajador2(PacientList filiationData, ServiceList doctoPhisicalExam, List <DiagnosticRepositoryList> diagnosticRepository, organizationDto infoEmpresaPropietaria, string filePDF)
        {
            Document document = new Document();

            document.SetPageSize(iTextSharp.text.PageSize.A4);

            //try
            //{NO_BORDER
            // step 2: we create aPA writer that listens to the document
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));

            //create an instance of your PDFpage class. This is the class we generated above.
            pdfPage page = new pdfPage();

            page.Dato = "FMT2/" + filiationData.v_FirstName + " " + filiationData.v_FirstLastName + " " + filiationData.v_SecondLastName;
            //set the PageEvent of the pdfWriter instance to the instance of our PDFPage class
            writer.PageEvent = page;

            // step 3: we open the document
            document.Open();
            // step 4: we Add content to the document
            // we define some fonts
            #region Declaration Tables

            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.White);
            string          include      = string.Empty;
            List <PdfPCell> cells        = null;
            float[]         columnWidths = null;
            //string[] columnValues = null;
            string[] columnHeaders = null;


            PdfPTable filiationWorker = new PdfPTable(8);

            PdfPTable table = null;

            PdfPCell cell = null;

            #endregion

            #region Fonts

            Font fontTitle1               = FontFactory.GetFont("Arial", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Arial", 9, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableAntecedentesOcupacionales  = FontFactory.GetFont("Arial", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueAntecedentesOcupacionales = FontFactory.GetFont("Arial", 6, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueNegrita = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontAptitud = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            //Font fontTitleTableNegro = FontFactory.GetFont("Arial", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            #endregion


            //#region Logo
            PdfPCell CellLogo = null;
            //if (infoEmpresaPropietaria.b_Image != null)
            //{
            //    CellLogo = new PdfPCell(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image, 30F));
            //}
            //else
            //{
            //    CellLogo = new PdfPCell(new Phrase(" ", fontColumnValue));
            //}
            //Image logo = HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image, 20F);
            //PdfPTable headerTbl = new PdfPTable(1);
            //headerTbl.TotalWidth = writer.PageSize.Width;
            //PdfPCell cellLogo = new PdfPCell(CellLogo);

            //cellLogo.VerticalAlignment = Element.ALIGN_TOP;
            //cellLogo.HorizontalAlignment = Element.ALIGN_CENTER;

            //cellLogo.Border = PdfPCell.NO_BORDER;
            //headerTbl.AddCell(cellLogo);
            //document.Add(headerTbl);

            //#endregion

            //document.Add(new Paragraph("\r\n"));

            //#region Title
            //Paragraph cTitle = new Paragraph("CARTA DE COMPROMISO", fontTitle1);
            //cTitle.Alignment = Element.ALIGN_CENTER;
            //document.Add(cTitle);
            //#endregion

            #region Title

            CellLogo = null;
            cells    = new List <PdfPCell>();
            PdfPCell cellPhoto1 = null;

            if (filiationData.b_Photo != null)
            {
                cellPhoto1 = new PdfPCell(HandlingItextSharp.GetImage(filiationData.b_Photo, 23F))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_RIGHT
                }
            }
            ;
            else
            {
                cellPhoto1 = new PdfPCell(new Phrase(" ", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_RIGHT
                }
            };

            if (infoEmpresaPropietaria.b_Image != null)
            {
                CellLogo = new PdfPCell(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image, 30F))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                };
            }
            else
            {
                CellLogo = new PdfPCell(new Phrase(" ", fontColumnValue))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_LEFT
                };
            }

            columnWidths = new float[] { 100f };

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("CARTA DE COMPROMISO", fontTitle1))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                },
            };

            table = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);

            cells.Add(CellLogo);
            cells.Add(new PdfPCell(table));
            cells.Add(cellPhoto1);

            columnWidths = new float[] { 20f, 60f, 20f };

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);
            document.Add(table);

            #endregion
            #region Cabecera
            string XPreocupacional = "( )";
            string PeriodicoAnual  = "( )";
            string Retiro          = "( )";
            if (filiationData.i_EsoTypeId == (int)Sigesoft.Common.TypeESO.PreOcupacional)
            {
                XPreocupacional = "( X )";
            }
            else if (filiationData.i_EsoTypeId == (int)Sigesoft.Common.TypeESO.PeriodicoAnual)
            {
                PeriodicoAnual = "( X )";
            }
            else if (filiationData.i_EsoTypeId == (int)Sigesoft.Common.TypeESO.Retiro)
            {
                Retiro = "( X )";
            }
            string Linea1 = "YO,        " + filiationData.v_OwnerName.ToUpper();

            string Linea2 = "IDENTIFICADO CON DNI/CE/PASAPORTE       " + filiationData.v_DocNumber + ",         CON EL CARGO / PUESTO " + filiationData.v_CurrentOccupation == null ? "" : filiationData.v_CurrentOccupation;

            string Linea3 = "PERTENECIENTE A LA EMPRESA        " + filiationData.v_FullWorkingOrganizationName.ToUpper();

            string Linea4 = "EN EL CENTRO MÉDICO:        " + infoEmpresaPropietaria.v_Name.ToUpper() + ",         EN LA FECHA:" + filiationData.d_ServiceDate.Value.ToShortDateString();

            cells = new List <PdfPCell>()
            {
                //fila
                new PdfPCell(new Phrase(Linea1, fontColumnValue))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_JUSTIFIED
                },

                //fila
                new PdfPCell(new Phrase(Linea2, fontColumnValue))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_JUSTIFIED
                },

                //fila
                new PdfPCell(new Phrase(Linea3, fontColumnValue))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_JUSTIFIED
                },

                //fila
                new PdfPCell(new Phrase("HABIENDO PASADO LA EVALUACIÓN MÉDICA:", fontTitleTable))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },

                //fila
                new PdfPCell(new Phrase(XPreocupacional, fontColumnValue))
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("PRE OCUPACIONAL", fontColumnValue))
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase(PeriodicoAnual, fontColumnValue))
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("ANUAL", fontColumnValue))
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase(Retiro, fontColumnValue))
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                new PdfPCell(new Phrase("DE RETIRO", fontColumnValue))
                {
                    Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },

                //fila
                new PdfPCell(new Phrase(Linea4, fontColumnValue))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },

                //fila
                new PdfPCell(new Phrase("HE SIDO DEBIDAMENTE INFORMADO DE LOS RESULTADOS OBTENIDOS EN EL EXAMEN MÉDICO, SIENDO LOS DIAGNÓSTICOS ENCONTRADOS:", fontColumnValue))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
            };

            columnWidths = new float[] { 5f, 20f, 5f, 20f, 5f, 20f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);

            document.Add(filiationWorker);

            #endregion


            #region DETALLE CONCLUSIONES
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("ÍTEM", fontSubTitleNegroNegrita))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("DIAGNÓSTICOS", fontSubTitleNegroNegrita))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("CIE10", fontSubTitleNegroNegrita))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                },
            };

            columnWidths = new float[] { 5f, 80f, 15f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);

            document.Add(filiationWorker);

            #endregion

            #region Hallazgos y recomendaciones

            cells = new List <PdfPCell>();

            int nro = 1;
            var dx  = diagnosticRepository.FindAll(p => p.i_DiagnosticTypeId != (int)Sigesoft.Common.TipoDx.Normal);
            if (dx != null && dx.Count > 0)
            {
                //columnWidths = new float[] { 0.7f, 23.6f };
                //include = "i_Item,v_RecommendationName";

                foreach (var item in dx)
                {
                    cell = new PdfPCell(new Phrase(nro.ToString() + ".- ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                    };
                    cells.Add(cell);

                    cell = new PdfPCell(new Phrase(item.v_DiseasesName, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE
                    };
                    cells.Add(cell);
                    cell = new PdfPCell(new Phrase(item.i_DiagnosticTypeId == (int)Sigesoft.Common.TipoDx.Normal ? "---" : item.v_Dx_CIE10, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                    };
                    cells.Add(cell);
                    //// Crear tabla de recomendaciones para insertarla en la celda que corresponde
                    //table = HandlingItextSharp.GenerateTableFromList(item.Recomendations, columnWidths, include, fontColumnValue);
                    //cell = new PdfPCell(table);
                    //cells.Add(cell);
                    nro++;
                }

                columnWidths = new float[] { 5f, 80f, 15f };
            }
            else
            {
                cells.Add(new PdfPCell(new Phrase("No se han registrado datos.", fontColumnValue)));
                columnWidths = new float[] { 100 };
            }

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro);

            document.Add(table);

            #endregion

            #region Texto
            cells = new List <PdfPCell>()
            {
                //fila
                new PdfPCell(new Phrase("LOS MISMOS QUE ACEPTO Y POR LO TANTO ME COMPROMETO A SEGUIR LAS SIGUIENTES RECOMENDACIONES CLÍNICAS Y DE SALUD OCUPACIONAL QUE EL MÉDICO CONSIDERE.", fontColumnValue))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
            };

            columnWidths = new float[] { 100f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

            document.Add(filiationWorker);
            #endregion

            #region Recomendaciones

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("ÍTEM", fontSubTitleNegroNegrita))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("RECOMENDACIONES", fontSubTitleNegroNegrita))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                },
            };

            columnWidths = new float[] { 5f, 95f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);

            document.Add(filiationWorker);


            cells = new List <PdfPCell>();

            int nroreco = 1;
            if (dx != null && dx.Count > 0)
            {
                foreach (var item in dx)
                {
                    columnWidths = new float[] { 95f };
                    include      = "v_RecommendationName";

                    cell = new PdfPCell(new Phrase(nroreco.ToString() + ".- ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                    };
                    cells.Add(cell);

                    table = HandlingItextSharp.GenerateTableFromList(item.Recomendations, columnWidths, include, fontColumnValue);
                    cell  = new PdfPCell(table);
                    cells.Add(cell);
                    nroreco++;
                }

                columnWidths = new float[] { 5f, 95f };
            }
            else
            {
                cells.Add(new PdfPCell(new Phrase("No se han registrado datos.", fontColumnValue)));
                columnWidths = new float[] { 100 };
            }

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro);

            document.Add(table);


            #endregion

            #region Restricciones

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("ÍTEM", fontSubTitleNegroNegrita))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                },
                new PdfPCell(new Phrase("RESTRICCIONES", fontSubTitleNegroNegrita))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER
                },
            };

            columnWidths = new float[] { 5f, 95f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro, null);

            document.Add(filiationWorker);


            cells = new List <PdfPCell>();

            int nroreco1 = 1;
            if (dx != null && dx.Count > 0)
            {
                foreach (var item in dx)
                {
                    if (item.Restrictions.Count > 0)
                    {
                        columnWidths = new float[] { 95f };
                        include      = "v_RestrictionName";

                        cell = new PdfPCell(new Phrase(nroreco1.ToString() + ".- ", fontColumnValue))
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
                        };
                        cells.Add(cell);

                        //cell = new PdfPCell(new Phrase(item.v_DiseasesName, fontColumnValue)) { HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE };
                        //cells.Add(cell);
                        //cell = new PdfPCell(new Phrase(item.i_DiagnosticTypeId == (int)Sigesoft.Common.TipoDx.Normal ? "---" : item.v_Dx_CIE10, fontColumnValue)) { HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE };
                        //cells.Add(cell);


                        // Crear tabla de recomendaciones para insertarla en la celda que corresponde

                        table = HandlingItextSharp.GenerateTableFromList(item.Restrictions, columnWidths, include, fontColumnValue);
                        cell  = new PdfPCell(table);
                        cells.Add(cell);
                        nroreco1++;
                    }
                }

                columnWidths = new float[] { 5f, 95f };
            }
            else
            {
                cells.Add(new PdfPCell(new Phrase("No se han registrado datos.", fontColumnValue)));
                columnWidths = new float[] { 100 };
            }

            table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTableNegro);

            document.Add(table);


            #endregion

            #region Texto
            cells = new List <PdfPCell>()
            {
                //fila
                new PdfPCell(new Phrase("LAS QUE CUMPLIRÉ ESTRICTAMENTE CON LA FINALIDAD DE PREVENIR LA SEVERIDAD O EMPEORAMIENTO DE LOS PRESENTES CUADROS DIAGNOSTICADOS,  ASÍ MISMO  ME COMPROMETO A CUMPLIR CON LOS CHEQUEOS Y CONTROLES MÉDICOS OCUPACIONALES QUE EL  MÉDICO DE LA CLÍNICA MENCIONADA  INDIQUE.", fontColumnValue))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
                //fila
                new PdfPCell(new Phrase("FIRMO EN CONFORMIDAD CON LO ANTES EXPUESTO.", fontColumnValue))
                {
                    Colspan = 6, Border = PdfPCell.NO_BORDER, HorizontalAlignment = PdfPCell.ALIGN_LEFT
                },
            };

            columnWidths = new float[] { 100f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

            document.Add(filiationWorker);
            #endregion

            document.Add(new Paragraph("\r\n"));
            #region Firma

            #region Creando celdas de tipo Imagen y validando nulls

            // Firma del trabajador ***************************************************
            PdfPCell cellFirmaTrabajador = null;

            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, 20, 10));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase("Sin Firma Trabajador", fontColumnValue));
            }

            // Huella del trabajador **************************************************
            PdfPCell cellHuellaTrabajador = null;

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, 20, 30));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase("Sin Huella", fontColumnValue));
            }

            // Firma del doctor EXAMEN FISICO **************************************************

            PdfPCell cellFirma = null;

            if (filiationData == null)
            {
                cellFirma = new PdfPCell(new Phrase("Sin Firma", fontColumnValue));
            }
            else if (filiationData.FirmaDoctorAuditor != null)
            {
                cellFirma = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaDoctorAuditor, null, null, 120, 45));
            }
            else
            {
                cellFirma = new PdfPCell(new Phrase("Sin Firma", fontColumnValue));
            }
            #endregion

            #region Crear tablas en duro (para la Firma y huella del trabajador)

            cells = new List <PdfPCell>();

            cellFirmaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirmaTrabajador.FixedHeight         = 80F;
            cells.Add(cellFirmaTrabajador);
            cells.Add(new PdfPCell(new Phrase("NOMBRE: " + filiationData.v_OwnerName, fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE
            });
            cells.Add(new PdfPCell(new Phrase("D.N.I: " + filiationData.v_DocNumber, fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE
            });
            cells.Add(new PdfPCell(new Phrase("PUESTO: " + filiationData.v_CurrentOccupation, fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE
            });
            columnWidths = new float[] { 100f };

            var tableFirmaTrabajador = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

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

            cells = new List <PdfPCell>();

            cellHuellaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellHuellaTrabajador.FixedHeight         = 80F;
            cells.Add(cellHuellaTrabajador);
            cells.Add(new PdfPCell(new Phrase("HUELLA DEL EXAMINADO", fontColumnValue))
            {
                HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE
            });

            columnWidths = new float[] { 100f };

            var tableHuellaTrabajador = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, "", fontTitleTable);

            #endregion

            cells = new List <PdfPCell>();

            // 1 celda vacia
            cells.Add(new PdfPCell(tableFirmaTrabajador));

            // 1 celda vacia
            cells.Add(new PdfPCell(tableHuellaTrabajador));

            // 2 celda
            cell = new PdfPCell(new Phrase("FIRMA Y SELLO MÉDICO", fontColumnValue));
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cells.Add(cell);

            // 3 celda (Imagen)
            cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirma.FixedHeight         = 30F;
            cells.Add(cellFirma);

            columnWidths = new float[] { 25f, 25f, 20f, 30F };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, " ", fontTitleTable);

            document.Add(table);

            #endregion


            document.Close();
            writer.Close();
            writer.Dispose();
        }
    }
Beispiel #26
0
        public static void CreateDeclaracionJurada(string filePDF,
                                                   PacientList datosPac,
                                                   organizationDto infoEmpresaPropietaria, PacientList filiationData,
                                                   List <ServiceComponentList> serviceComponent)
        {
            Document document = new Document(PageSize.A4, 40f, 40f, 40f, 50f);


            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include      = string.Empty;
            List <PdfPCell> cells        = null;
            float[]         columnWidths = null;
            PdfPTable       header2      = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 13, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresaPropietaria.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);


            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("DECLARACION JURADA", fontTitle1))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 30f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 20f, 60f, 20f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            var    tamaño_celda = 25f;
            string tipodoc      = "";
            if (datosPac.i_DocTypeId == 1)
            {
                tipodoc = "DNI";
            }
            else if (datosPac.i_DocTypeId == 2)
            {
                tipodoc = "Pasaporte";
            }
            else if (datosPac.i_DocTypeId == 3)
            {
                tipodoc = "Licencia de Conducir";
            }
            else if (datosPac.i_DocTypeId == 4)
            {
                tipodoc = "Carnet de Extranjeria";
            }

            #region Contenido
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n YO, ", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n" + datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n \n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\nIdentificado (a) con " + tipodoc + " N°  ", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n" + datosPac.v_DocNumber, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\ndeclaro por medio de este documento", fontColumnValue))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\nmédico legal que me encuentro en buen estado de salud física y mental y que toda la", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\ninformación proporcionada al médico o funcionario responsable es de carácter verídico,", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\n ", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\npara el cargo correspondiente.", fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            string[] fechaServicio = datosPac.FechaServicio.ToString().Split('/', ' ');
            string   mes           = "";
            if (fechaServicio[1] == "01")
            {
                mes = "Enero";
            }
            else if (fechaServicio[1] == "02")
            {
                mes = "Febrero";
            }
            else if (fechaServicio[1] == "03")
            {
                mes = "Marzo";
            }
            else if (fechaServicio[1] == "04")
            {
                mes = "Abril";
            }
            else if (fechaServicio[1] == "05")
            {
                mes = "Mayo";
            }
            else if (fechaServicio[1] == "06")
            {
                mes = "Junio";
            }
            else if (fechaServicio[1] == "07")
            {
                mes = "Julio";
            }
            else if (fechaServicio[1] == "08")
            {
                mes = "Agosto";
            }
            else if (fechaServicio[1] == "09")
            {
                mes = "Setiembre";
            }
            else if (fechaServicio[1] == "10")
            {
                mes = "Octubre";
            }
            else if (fechaServicio[1] == "11")
            {
                mes = "Noviembre";
            }
            else if (fechaServicio[1] == "12")
            {
                mes = "Diciembre";
            }

            PdfPCell cellFirmaTrabajador = null;

            PdfPCell cellHuellaTrabajador = null;

            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 100, 35));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 60, 80));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            #region Fecha / Firmma
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("\n \n \n \n" + infoEmpresaPropietaria.v_SectorName + ", " + fechaServicio[0] + " de " + mes + " del " + fechaServicio[2], fontColumnValue))
                {
                    Colspan = 19, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("\n", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(cellFirmaTrabajador)
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, FixedHeight = 180, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(cellHuellaTrabajador)
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, FixedHeight = 180, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("_____________________________________", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("       Firma y Post Firma        ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("N° de " + tipodoc + ": " + datosPac.v_DocNumber, fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
        }
        public static void CreateConsentimientoInformadoAccesoHistoriClinica(ServiceList DataService, string filePDF,
                                                                             PacientList datosPac,
                                                                             List <DiagnosticRepositoryList> Diagnosticos,
                                                                             List <ServiceComponentList> serviceComponent)
        {
            Document document = new Document(PageSize.A4, 40f, 40f, 10f, 0f);

            //
            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include      = string.Empty;
            List <PdfPCell> cells        = null;
            float[]         columnWidths = null;
            PdfPTable       header2      = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 12, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 11, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            #region TÍTULO

            cells = new List <PdfPCell>();

            iTextSharp.text.Image hudbay = iTextSharp.text.Image.GetInstance("C:/Banner/HUDBAY.png");
            hudbay.ScalePercent(50);
            hudbay.SetAbsolutePosition(45, 760);
            document.Add(hudbay);

            iTextSharp.text.Image banner4 = iTextSharp.text.Image.GetInstance("C:/Banner/Imagen2.png");
            banner4.ScalePercent(50);
            banner4.SetAbsolutePosition(-10, 0);
            document.Add(banner4);


            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80f
                },
                new PdfPCell(new Phrase("CONSENTIMIENTO INFORMADO PARA \n ACCESO A LA HISTORIA CLÍNICA", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80f
                },
                new PdfPCell(new Phrase("Formato \n\nDocumento ID   : \nVersión     : \nFecha       : ", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80f
                },
            };
            columnWidths = new float[] { 20f, 50f, 30f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            var tamaño_celda = 20f;


            ServiceComponentList declaracion_jurada = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.EXCEPCIONES_RX_ID);
            var fecha_regla = declaracion_jurada.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXCEPCIONES_RX_FECHA_ULTIMA_REGLA) == null ? "" : declaracion_jurada.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXCEPCIONES_RX_FECHA_ULTIMA_REGLA).v_Value1;

            #region Contenido
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("La historia clínica es el único documento válido desde el punto de vista clínico y legal.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("\nLa Ley General de Salud del Perú menciona que toda persona usuaria de los servicios de salud tiene ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("derecho a exigir la reserva de la información relacionada con el acto médico y su historia clínica, con las ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("excepciones que la ley establece.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\nEl artículo 77° del Código de Ética y Deontología del Colegio Médico del Perú señala que la elaboración, ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("diagnóstico, terapéutica y pronóstico contenidos en la historia clínica pueden ser utilizados por el médico ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("tratante para fines de investigación, docencia, mejora continua de la calidad, médico legal, gestión y ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("administración de los servicios médicos. El médico está obligado, en este caso, a mantener en reserva", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("aquellos datos que permitan la identificación del paciente. La mencionada norma establece que la ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("violación de esta disposición constituye falta ética.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\nLa Gerencia de Seguridad y Salud Ocupacional de Hudbay y los Centros Médicos Autorizados de HBP,", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("mantendrán confidencial su información médica privada obtenida al proporcionarle servicios a usted a ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("menos que se autorice por ley, su información médica protegida no será utilizada ni revelada sin su ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("consentimiento. ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\nEl informe médico que se entregará a su Empresa contiene información relacionada únicamente a la ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("aptitud laboral y enfermedad (es) relacionada (s) al trabajo diagnosticado(s), u otras condiciones", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("médicas que puedan afectar la seguridad en el trabajo y/o aquellas condiciones médicas que puedan", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("confundir la  exposición a riesgos ocupacionales (Embarazo y/o Riesgos de Salud Reproductiva),", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("asimismo se indicará las recomendaciones y restricciones del caso. Por otro lado Usted recibirá un", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Informe Médico Ocupacional resumido de lo más importante de su evaluación realizada.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\nSu información médica será protegida y no será revelada sin su consentimiento por escrito. Usted puede ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("invalidar cualquier consentimiento oral y/o escrito, enviando un documento a la Gerencia de Seguridad y ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Salud Ocupacional.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("\nHabiendo leído y comprendido lo anteriormente descrito, acepto el acceso a la historia clínica para los ", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED_ALL, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("fines detallados en este documento al Área de Salud Ocupacional de Hudbay.", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_JUSTIFIED, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, BorderColor = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            string[] fechaServicio = datosPac.FechaServicio.ToString().Split(' ');

            string tipodoc = "";
            if (datosPac.i_DocTypeId == 1)
            {
                tipodoc = "DNI";
            }
            else if (datosPac.i_DocTypeId == 2)
            {
                tipodoc = "Pasaporte";
            }
            else if (datosPac.i_DocTypeId == 3)
            {
                tipodoc = "Licencia de Conducir";
            }
            else if (datosPac.i_DocTypeId == 4)
            {
                tipodoc = "Carnet de Extranjeria";
            }
            PdfPCell cellFirmaTrabajador = null;

            PdfPCell cellHuellaTrabajador = null;

            if (DataService.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(DataService.FirmaTrabajador, null, null, 100, 35));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            if (DataService.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(DataService.HuellaTrabajador, null, null, 50, 70));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            #region Fecha / Firmma
            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("APELLIDOS Y NOMBRES: ", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName, fontColumnValue))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("FIRMA: ", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(cellFirmaTrabajador)
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(cellHuellaTrabajador)
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80, BorderColor = BaseColor.WHITE
                },


                new PdfPCell(new Phrase(tipodoc + " :", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_DocNumber, fontColumnValue))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("FECHA: ", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(fechaServicio[0], fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20, BorderColor = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("EMPRESA: ", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20, BorderColor = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(DataService.v_CustomerOrganizationName, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20, BorderColor = BaseColor.WHITE, ExtraParagraphSpace = 5.0f
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
        }
Beispiel #28
0
        public static void CreateInforme_Psicologico_Resumen(PacientList filiationData, ServiceList DataService,
                                                             List <ServiceComponentList> serviceComponent,
                                                             organizationDto infoEmpresa,
                                                             PacientList datosPac,
                                                             string filePDF)
        {
            Document document = new Document(PageSize.A4, 30f, 30f, 42f, 41f);

            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include       = string.Empty;
            List <PdfPCell> cells         = null;
            float[]         columnWidths  = null;
            string[]        columnValues  = null;
            string[]        columnHeaders = null;
            PdfPTable       header2       = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            PdfPCell  cell            = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 12, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 8, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            var tamaño_celda = 18f;
            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresa.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresa.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }
            //iTextSharp.text.Image imagenMinsa = iTextSharp.text.Image.GetInstance("C:/Banner/Minsa.png");
            //imagenMinsa.ScalePercent(10);
            //imagenMinsa.SetAbsolutePosition(400, 785);
            //document.Add(imagenMinsa);

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("INFORME PSICOLÓGICO", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f
                },
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, PdfPCell.NO_BORDER, null, fontTitleTable);
            document.Add(table);
            #endregion
            ServiceComponentList informe_psico_resumen = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_RESUMEN_ID);

            #region DATOS GENERALES
            string masc = "", fem = "";
            if (datosPac.Genero == "FEMENINO")
            {
                fem = "X";
            }
            else if (datosPac.Genero == "MASCULINO")
            {
                masc = "X";
            }

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 5f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Apellidos Y Nombres: ", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName, fontColumnValue))
                {
                    Colspan = 13, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 8f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Lugar y Fecha de Nacimiento:", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_BirthPlace, fontColumnValue))
                {
                    Colspan = 10, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase(datosPac.d_Birthdate.ToString().Split(' ')[0], fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 8f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Edad: ", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.Edad.ToString(), fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Sexo: ", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("M", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(masc, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("F", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(fem, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 8f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Grado de Instrucción: ", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.GradoInstruccion, fontColumnValue))
                {
                    Colspan = 13, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 8f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Dirección: ", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.v_AdressLocation, fontColumnValue))
                {
                    Colspan = 13, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 8f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("Fecha de Evaluación: ", fontColumnValueBold))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(datosPac.FechaServicio.ToString().Split(' ')[0], fontColumnValue))
                {
                    Colspan = 13, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 8f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region MOTIVO DE CONSULTA

            var motivo            = informe_psico_resumen.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_RESUMEN_EVALUACION) == null ? "" : informe_psico_resumen.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_RESUMEN_EVALUACION).v_Value1;
            var pruebas_aplicadas = informe_psico_resumen.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_RESUMEN_PRUEBAS_APLICADAS) == null ? "" : informe_psico_resumen.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_RESUMEN_PRUEBAS_APLICADAS).v_Value1;

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 10f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("MOTIVO DE EVALUACIÓN:", fontTitle2))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase(motivo, fontColumnValue))
                {
                    Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("PRUEBAS APLICADAS:", fontTitle2))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 50f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(pruebas_aplicadas, fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 50f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 50f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 8f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion


            #region RESULTADOS

            var resultados   = informe_psico_resumen.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_RESUMEN_RESULTADOS) == null ? "" : informe_psico_resumen.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_RESUMEN_RESULTADOS).v_Value1;
            var conclusiones = informe_psico_resumen.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_RESUMEN_CONCLUSIONES) == null ? "" : informe_psico_resumen.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_RESUMEN_CONCLUSIONES).v_Value1;
            var apto         = informe_psico_resumen.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_RESUMEN_APTO) == null ? "" : informe_psico_resumen.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_RESUMEN_APTO).v_Value1;
            var noapto       = informe_psico_resumen.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_RESUMEN_NOAPTO) == null ? "" : informe_psico_resumen.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_RESUMEN_NOAPTO).v_Value1;
            var observado    = informe_psico_resumen.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_RESUMEN_OBSERVADO) == null ? "" : informe_psico_resumen.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.INFORME_PSICOLOGICO_RESUMEN_OBSERVADO).v_Value1;

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 10f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("RESULTADOS", fontTitle2))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.BLACK
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(resultados, fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 80f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 5f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("CONCLUSIONES", fontTitle2))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 60f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(conclusiones, fontColumnValue))
                {
                    Colspan = 18, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 60f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 60f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 10f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("APTO", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(apto == "1" ?"X":apto == "0"?"":apto, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontTitle1))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("NO APTO", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(noapto == "1" ?"X":noapto == "0"?"":noapto, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontTitle1))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("OBSERVADO", fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase(observado == "1" ?"X":observado == "0"?"":observado, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 15f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontColumnValueBold))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 20f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            var psico = serviceComponent.Find(p => p.i_CategoryId == (int)Sigesoft.Common.Consultorio.Psicología);

            #region Firma

            #region Creando celdas de tipo Imagen y validando nulls
            PdfPCell cellFirmaTrabajador  = null;
            PdfPCell cellHuellaTrabajador = null;
            PdfPCell cellFirma            = null;

            // Firma del trabajador ***************************************************


            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 80, 40));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirmaTrabajador.FixedHeight         = 50F;
            // Huella del trabajador **************************************************

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 30, 45));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = Element.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellHuellaTrabajador.FixedHeight         = 50F;
            // Firma del doctor Auditor **************************************************
            if (psico.FirmaMedico != null)
            {
                cellFirma = new PdfPCell(HandlingItextSharp.GetImage(psico.FirmaMedico, null, null, 120, 50))
                {
                    HorizontalAlignment = PdfPCell.ALIGN_CENTER
                }
            }
            ;
            else
            {
                cellFirma = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
            cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cellFirma.FixedHeight         = 50F;
            #endregion

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(cellFirma)
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_BOTTOM, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 13f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("______________________________", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 13f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },

                new PdfPCell(new Phrase("", fontTitle1))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_RIGHT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 13f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
                new PdfPCell(new Phrase("FIRMA DEL PSICÓLOGO", fontColumnValue))
                {
                    HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 13f, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorTop = BaseColor.WHITE
                },
            };
            columnWidths = new float[] { 60f, 30f };

            filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);

            document.Add(filiationWorker);

            #endregion

            document.Close();
            writer.Close();
            writer.Dispose();
        }
        public static void CreateLaboratorioReport(PacientList filiationData, List <ServiceComponentList> serviceComponent, organizationDto infoEmpresaPropietaria, string filePDF)
        {
            //
            // step 1: creation of a document-object
            Document document = new Document();

            //Document document = new Document(new Rectangle(500f, 300f), 10, 10, 10, 10);
            //document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
            document.SetPageSize(iTextSharp.text.PageSize.A4);
            //Document document = new Document(PageSize.A4, 0, 0, 20, 20);
            //
            try
            {
                // step 2: we create a writer that listens to the document
                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
                //
                //create an instance of your PDFpage class. This is the class we generated above.
                pdfPage page = new pdfPage();
                //set the PageEvent of the pdfWriter instance to the instance of our PDFPage class
                writer.PageEvent = page;

                // step 3: we open the document
                document.Open();
                // step 4: we Add content to the document
                // we define some fonts

                #region Fonts

                Font fontTitle1               = FontFactory.GetFont(FontFactory.HELVETICA, 18, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
                Font fontTitle2               = FontFactory.GetFont(FontFactory.HELVETICA, 12, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
                Font fontTitleTable           = FontFactory.GetFont(FontFactory.HELVETICA, 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
                Font fontTitleTableNegro      = FontFactory.GetFont(FontFactory.HELVETICA, 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
                Font fontSubTitle             = FontFactory.GetFont(FontFactory.HELVETICA, 9, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
                Font fontSubTitleNegroNegrita = FontFactory.GetFont(FontFactory.HELVETICA, 9, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

                Font fontColumnValue = FontFactory.GetFont(FontFactory.HELVETICA, 8, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));


                #endregion

                #region Logo

                Image     logo      = HandlingItextSharp.GetImage(infoEmpresaPropietaria.b_Image, 20F);
                PdfPTable headerTbl = new PdfPTable(1);
                headerTbl.TotalWidth = writer.PageSize.Width;
                PdfPCell cellLogo = new PdfPCell(logo);

                cellLogo.VerticalAlignment   = Element.ALIGN_TOP;
                cellLogo.HorizontalAlignment = Element.ALIGN_CENTER;

                cellLogo.Border = PdfPCell.NO_BORDER;
                headerTbl.AddCell(cellLogo);
                document.Add(headerTbl);

                #endregion

                #region Title

                Paragraph cTitle = new Paragraph("EXAMENES ESPECIALES", fontTitle2);
                //Paragraph cTitle2 = new Paragraph(customerOrganizationName, fontTitle2);
                cTitle.Alignment = Element.ALIGN_CENTER;
                //cTitle2.Alignment = Element.ALIGN_CENTER;

                document.Add(cTitle);
                //document.Add(cTitle2);

                #endregion

                #region Declaration Tables
                var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.White);
                string          include       = string.Empty;
                List <PdfPCell> cells         = null;
                float[]         columnWidths  = null;
                string[]        columnValues  = null;
                string[]        columnHeaders = null;

                //PdfPTable header1 = new PdfPTable(2);
                //header1.HorizontalAlignment = Element.ALIGN_CENTER;
                //header1.WidthPercentage = 100;
                ////header1.TotalWidth = 500;
                ////header1.LockedWidth = true;    // Esto funciona con TotalWidth
                //float[] widths = new float[] { 150f, 200f};
                //header1.SetWidths(widths);


                //Rectangle rec = document.PageSize;
                PdfPTable header2 = new PdfPTable(6);
                header2.HorizontalAlignment = Element.ALIGN_CENTER;
                header2.WidthPercentage     = 100;
                //header1.TotalWidth = 500;
                //header1.LockedWidth = true;    // Esto funciona con TotalWidth
                float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
                header2.SetWidths(widths1);
                //header2.SetWidthPercentage(widths1, rec);

                PdfPTable companyData = new PdfPTable(6);
                companyData.HorizontalAlignment = Element.ALIGN_CENTER;
                companyData.WidthPercentage     = 100;
                //header1.TotalWidth = 500;
                //header1.LockedWidth = true;    // Esto funciona con TotalWidth
                float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
                companyData.SetWidths(widthscolumnsCompanyData);

                PdfPTable filiationWorker = new PdfPTable(4);

                PdfPTable table = null;

                PdfPCell cell = null;

                #endregion

                // Salto de linea
                document.Add(new Paragraph("\r\n"));

                #region Datos personales del trabajador

                cells = new List <PdfPCell>()
                {
                    new PdfPCell(new Phrase("Paciente: ", fontColumnValue)), new PdfPCell(new Phrase(filiationData.v_FirstName + " " + filiationData.v_FirstLastName + " " + filiationData.v_SecondLastName, fontColumnValue)),
                    new PdfPCell(new Phrase("Empresa: ", fontColumnValue)), new PdfPCell(new Phrase(filiationData.v_FullWorkingOrganizationName, fontColumnValue)),
                    new PdfPCell(new Phrase("Puesto: ", fontColumnValue)), new PdfPCell(new Phrase(filiationData.v_CurrentOccupation, fontColumnValue)),
                    new PdfPCell(new Phrase("Fecha Atención: ", fontColumnValue)), new PdfPCell(new Phrase(filiationData.d_ServiceDate.Value.ToShortDateString(), fontColumnValue)),
                };

                columnWidths = new float[] { 20f, 70f };

                filiationWorker = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, PdfPCell.NO_BORDER, "I. DATOS PERSONALES", fontTitleTableNegro, null);

                document.Add(filiationWorker);

                #endregion

                #region EXAMENES ESPECIALES

                cells = new List <PdfPCell>();

                // Subtitulo  ******************
                cell = new PdfPCell(new Phrase("EXAMENES ESPECIALES", fontSubTitleNegroNegrita))
                {
                    Colspan             = 5,
                    BackgroundColor     = subTitleBackGroundColor,
                    HorizontalAlignment = Element.ALIGN_CENTER,
                };

                cells.Add(cell);
                //*****************************************

                var xBKDirecto   = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.BK_DIRECTO_ID);
                var xExamenElisa = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.EXAMEN_ELISA_ID);
                var xHepatitisA  = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.HEPATITIS_A_ID);
                var xHepatitisC  = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.HEPATITIS_C_ID);
                var xVdrl        = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.VDRL_ID);
                var xSubUnidad   = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.SUB_UNIDAD_BETA_CUALITATIVO_ID);


                if (xBKDirecto != null)
                {
                    var MuestraBKDirecto    = xBKDirecto.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.BK_DIRECTO_MICROBIOLOGICO_MUESTRA);
                    var ColoracionBKDirecto = xBKDirecto.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.BK_DIRECTO_MICROBIOLOGICO_COLORACION);
                    var ResultadosBKDirecto = xBKDirecto.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.BK_DIRECTO_MICROBIOLOGICO_RESULTADOS);

                    // 1era fila
                    cells.Add(new PdfPCell(new Phrase("BK - DIRECTO", fontTitleTableNegro)));
                    cells.Add(new PdfPCell(new Phrase(" ", fontColumnValue))
                    {
                        Colspan = 4, HorizontalAlignment = Element.ALIGN_CENTER
                    });

                    cells.Add(new PdfPCell(new Phrase(" ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase("MUSTRA", fontTitleTableNegro))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase(MuestraBKDirecto.v_Value1, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase("COLORACIÓN", fontTitleTableNegro))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase(ColoracionBKDirecto.v_Value1, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });

                    cells.Add(new PdfPCell(new Phrase("RESULTADOS", fontTitleTableNegro)));
                    cells.Add(new PdfPCell(new Phrase(ResultadosBKDirecto.v_Value1, fontColumnValue))
                    {
                        Colspan = 4, HorizontalAlignment = Element.ALIGN_LEFT
                    });
                }


                if (xExamenElisa != null)
                {
                    var ResultadoExamenElisa = xExamenElisa.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_ELISA_REACTIVOS_EXAMEN_ELISA);
                    var DeseableExamenElisa  = xExamenElisa.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_ELISA__REACTIVOS_EXAMEN_ELISA_DESEABLE);
                    var ObsExamenElisa       = xExamenElisa.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.EXAMEN_ELISA__REACTIVOS_EXAMEN_ELISA_OBSERVACION);

                    // 1era fila
                    cells.Add(new PdfPCell(new Phrase("EXAMEN DE ELISA", fontTitleTableNegro)));
                    cells.Add(new PdfPCell(new Phrase(" ", fontColumnValue))
                    {
                        Colspan = 4, HorizontalAlignment = Element.ALIGN_CENTER
                    });

                    cells.Add(new PdfPCell(new Phrase(" ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase("RESULTADO", fontTitleTableNegro))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase(ResultadoExamenElisa.v_Value1Name, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase("DESEABLE", fontTitleTableNegro))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase(DeseableExamenElisa.v_Value1, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });

                    cells.Add(new PdfPCell(new Phrase("OBSERVACIÓN", fontTitleTableNegro)));
                    cells.Add(new PdfPCell(new Phrase(ObsExamenElisa.v_Value1, fontColumnValue))
                    {
                        Colspan = 4, HorizontalAlignment = Element.ALIGN_LEFT
                    });
                }

                if (xHepatitisA != null)
                {
                    var ResultadoHepatitisA = xHepatitisA.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.HEPATITIS_A_REACTIVOS_HEPATITIS_A);
                    var DeseableHepatitisA  = xHepatitisA.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.HEPATITIS_A_REACTIVOS_HEPATITIS_A_DESEABLE);
                    var ObsHepatitisA       = xHepatitisA.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.HEPATITIS_A_REACTIVOS_HEPATITIS_A_OBSERVACION);

                    // 1era fila
                    cells.Add(new PdfPCell(new Phrase("HEPATITIS A", fontTitleTableNegro)));
                    cells.Add(new PdfPCell(new Phrase(" ", fontColumnValue))
                    {
                        Colspan = 4, HorizontalAlignment = Element.ALIGN_CENTER
                    });

                    cells.Add(new PdfPCell(new Phrase(" ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase("RESULTADO", fontTitleTableNegro))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase(ResultadoHepatitisA.v_Value1Name, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase("DESEABLE", fontTitleTableNegro))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase(DeseableHepatitisA.v_Value1, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });

                    cells.Add(new PdfPCell(new Phrase("OBSERVACIÓN", fontTitleTableNegro)));
                    cells.Add(new PdfPCell(new Phrase(ObsHepatitisA.v_Value1, fontColumnValue))
                    {
                        Colspan = 4, HorizontalAlignment = Element.ALIGN_LEFT
                    });
                }

                if (xHepatitisC != null)
                {
                    var ResultadoHepatitisC = xHepatitisC.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.HEPATITIS_C_REACTIVOS_HEPATITIS_C);
                    var DesableHepatitisC   = xHepatitisC.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.HEPATITIS_C_REACTIVOS_HEPATITIS_C_DESEABLE);
                    var ObsHepatitisC       = xHepatitisC.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.HEPATITIS_C_REACTIVOS_HEPATITIS_C_OBSERVACION);


                    // 1era fila
                    cells.Add(new PdfPCell(new Phrase("HEPATITIS C", fontTitleTableNegro)));
                    cells.Add(new PdfPCell(new Phrase(" ", fontColumnValue))
                    {
                        Colspan = 4, HorizontalAlignment = Element.ALIGN_CENTER
                    });

                    cells.Add(new PdfPCell(new Phrase(" ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase("RESULTADO", fontTitleTableNegro))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase(ResultadoHepatitisC.v_Value1Name, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase("DESEABLE", fontTitleTableNegro))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase(DesableHepatitisC.v_Value1, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });

                    cells.Add(new PdfPCell(new Phrase("OBSERVACIÓN", fontColumnValue)));
                    cells.Add(new PdfPCell(new Phrase(ObsHepatitisC.v_Value1, fontColumnValue))
                    {
                        Colspan = 4, HorizontalAlignment = Element.ALIGN_LEFT
                    });
                }

                if (xSubUnidad != null)
                {
                    var ResultadoSubUnidad = xHepatitisC.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.SUB_UNIDAD_BETA_CUALITATIVO_RESULTADO);
                    var DesableSubUnidad   = xHepatitisC.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.SUB_UNIDAD_BETA_CUALITATIVO_DESEABLE);
                    var ObsSubUnidad       = xHepatitisC.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.SUB_UNIDAD_BETA_CUALITATIVO_OBSERVACION);

                    // 1era fila
                    cells.Add(new PdfPCell(new Phrase("Sub Unidad Beta Culaitativo", fontTitleTableNegro)));
                    cells.Add(new PdfPCell(new Phrase(" ", fontColumnValue))
                    {
                        Colspan = 4, HorizontalAlignment = Element.ALIGN_CENTER
                    });

                    cells.Add(new PdfPCell(new Phrase(" ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase("RESULTADO", fontTitleTableNegro))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase(ResultadoSubUnidad.v_Value1Name, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase("DESEABLE", fontTitleTableNegro))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase(ResultadoSubUnidad.v_Value1, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });

                    cells.Add(new PdfPCell(new Phrase("OBSERVACIÓN", fontTitleTableNegro)));
                    cells.Add(new PdfPCell(new Phrase(ResultadoSubUnidad.v_Value1, fontColumnValue))
                    {
                        Colspan = 4, HorizontalAlignment = Element.ALIGN_LEFT
                    });
                }

                if (xVdrl != null)
                {
                    var ResultadoVdrl   = xVdrl.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.VDRL_REACTIVOS_VDRL);
                    var DeseableVdrl    = xVdrl.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.VDRL_REACTIVOS_VDRL_DESEABLE);
                    var ObservacionVdrl = xVdrl.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.VDRL_REACTIVOS_VDRL);


                    // 1era fila
                    cells.Add(new PdfPCell(new Phrase("VDRL", fontTitleTableNegro)));
                    cells.Add(new PdfPCell(new Phrase(" ", fontColumnValue))
                    {
                        Colspan = 4, HorizontalAlignment = Element.ALIGN_CENTER
                    });

                    cells.Add(new PdfPCell(new Phrase(" ", fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase("RESULTADO", fontTitleTableNegro))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase(ResultadoVdrl.v_Value1Name, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase("DESEABLE", fontTitleTableNegro))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                    cells.Add(new PdfPCell(new Phrase(DeseableVdrl.v_Value1, fontColumnValue))
                    {
                        HorizontalAlignment = Element.ALIGN_CENTER
                    });
                }
                columnWidths = new float[] { 20f, 20f, 20f, 20f, 20f };

                table = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths);
                document.Add(table);

                #endregion

                #region Imprimir todos los examenes de laboratorio

                string[] orderPrint = new string[]
                {
                    Sigesoft.Common.Constants.HEMOGRAMA_COMPLETO_ID,
                    Sigesoft.Common.Constants.EXAMEN_COMPLETO_DE_ORINA_ID,
                    Sigesoft.Common.Constants.GRUPO_Y_FACTOR_SANGUINEO_ID,
                    Sigesoft.Common.Constants.GLUCOSA_ID,
                    Sigesoft.Common.Constants.COLESTEROL_ID,
                    Sigesoft.Common.Constants.COLESTEROL_HDL_ID,
                    Sigesoft.Common.Constants.COLESTEROL_LDL_ID,
                    Sigesoft.Common.Constants.COLESTEROL_VLDL_ID,
                    Sigesoft.Common.Constants.CREATININA_ID,
                    Sigesoft.Common.Constants.ACIDO_URICO_ID,
                    Sigesoft.Common.Constants.ANTIGENO_PROSTATICO_ID,
                    Sigesoft.Common.Constants.PLOMO_SANGRE_ID,
                    Sigesoft.Common.Constants.TGO_ID,
                    Sigesoft.Common.Constants.TGP_ID,
                    Sigesoft.Common.Constants.UREA_ID,
                    Sigesoft.Common.Constants.AGLUTINACIONES_LAMINA_ID,
                    Sigesoft.Common.Constants.EXAMEN_ELISA_ID,
                    Sigesoft.Common.Constants.HEPATITIS_A_ID,
                    Sigesoft.Common.Constants.HEPATITIS_C_ID,
                    Sigesoft.Common.Constants.VDRL_ID,
                    Sigesoft.Common.Constants.PARASITOLOGICO_SIMPLE_ID,
                    Sigesoft.Common.Constants.PARASITOLOGICO_SERIADO_ID,
                    Sigesoft.Common.Constants.BK_DIRECTO_ID,
                    Sigesoft.Common.Constants.TOXICOLOGICO_COCAINA_MARIHUANA_ID,
                };

                #endregion

                //Capturar la firma del medico que grabo en laboratorio
                var lab = serviceComponent.Find(p => p.i_CategoryId == (int)Sigesoft.Common.Consultorio.Laboratorio);

                ReportBuilderReportForLaboratorioReport(serviceComponent, orderPrint, fontTitleTable, fontSubTitleNegroNegrita, fontColumnValue, subTitleBackGroundColor, document);

                // Salto de linea
                document.Add(new Paragraph("\r\n"));

                #region Firma y sello Médico

                table = new PdfPTable(2);
                table.HorizontalAlignment = Element.ALIGN_RIGHT;
                table.WidthPercentage     = 40;

                columnWidths = new float[] { 15f, 25f };
                table.SetWidths(columnWidths);

                PdfPCell cellFirma = null;

                if (lab != null)
                {
                    if (lab.FirmaMedico != null)
                    {
                        cellFirma = new PdfPCell(HandlingItextSharp.GetImage(lab.FirmaMedico, 25, 25));
                    }
                    else
                    {
                        cellFirma = new PdfPCell(new Phrase("Sin Foto", fontColumnValue));
                    }
                }
                else
                {
                    cellFirma = new PdfPCell();
                }

                cellFirma.HorizontalAlignment = Element.ALIGN_CENTER;
                cellFirma.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cellFirma.FixedHeight         = 70F;

                cell = new PdfPCell(new Phrase("Firma y Sello Médico", fontColumnValue));
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;

                table.AddCell(cell);
                table.AddCell(cellFirma);

                document.Add(table);

                #endregion

                // step 5: we close the document
                document.Close();
                writer.Close();
                writer.Dispose();
                //RunFile(filePDF);
            }
            catch (DocumentException)
            {
                throw;
            }
            catch (IOException)
            {
                throw;
            }
        }
Beispiel #30
0
        public static void CreateCertificadoPsicosensometricoDatos(PacientList filiationData,
                                                                   List <ServiceComponentList> serviceComponent,
                                                                   organizationDto infoEmpresa,
                                                                   PacientList datosPac,
                                                                   string filePDF, UsuarioGrabo usuariograbo)
        {
            Document document = new Document(PageSize.A4, 50f, 30f, 45f, 41f);

            document.SetPageSize(iTextSharp.text.PageSize.A4);

            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filePDF, FileMode.Create));
            pdfPage   page   = new pdfPage();

            writer.PageEvent = page;
            document.Open();

            #region Declaration Tables
            var             subTitleBackGroundColor = new BaseColor(System.Drawing.Color.Gray);
            string          include       = string.Empty;
            List <PdfPCell> cells         = null;
            float[]         columnWidths  = null;
            string[]        columnValues  = null;
            string[]        columnHeaders = null;
            PdfPTable       header2       = new PdfPTable(6);
            header2.HorizontalAlignment = Element.ALIGN_CENTER;
            header2.WidthPercentage     = 100;
            float[] widths1 = new float[] { 16.6f, 18.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            header2.SetWidths(widths1);
            PdfPTable companyData = new PdfPTable(6);
            companyData.HorizontalAlignment = Element.ALIGN_CENTER;
            companyData.WidthPercentage     = 100;
            float[] widthscolumnsCompanyData = new float[] { 16.6f, 16.6f, 16.6f, 16.6f, 16.6f, 16.6f };
            companyData.SetWidths(widthscolumnsCompanyData);
            PdfPTable filiationWorker = new PdfPTable(4);
            PdfPTable table           = null;
            PdfPCell  cell            = null;
            document.Add(new Paragraph("\r\n"));
            #endregion

            #region Fonts
            Font fontTitle1               = FontFactory.GetFont("Calibri", 10, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitle2               = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTable           = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontTitleTableNegro      = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontSubTitle             = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.White));
            Font fontSubTitleNegroNegrita = FontFactory.GetFont("Calibri", 6, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));

            Font fontColumnValue         = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueBold     = FontFactory.GetFont("Calibri", 7, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            Font fontColumnValueApendice = FontFactory.GetFont("Calibri", 5, iTextSharp.text.Font.BOLD, new BaseColor(System.Drawing.Color.Black));
            #endregion

            var tamaño_celda = 20f;
            #region TÍTULO

            cells = new List <PdfPCell>();

            if (infoEmpresa.b_Image != null)
            {
                iTextSharp.text.Image imagenEmpresa = iTextSharp.text.Image.GetInstance(HandlingItextSharp.GetImage(infoEmpresa.b_Image));
                imagenEmpresa.ScalePercent(25);
                imagenEmpresa.SetAbsolutePosition(40, 790);
                document.Add(imagenEmpresa);
            }

            var cellsTit = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("CERTIFICADO DE APTITUD DE EVALUACIÓN PSICOSENSOMETRICO", fontTitle1))
                {
                    BackgroundColor = BaseColor.ORANGE, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = 25f
                },
            };
            columnWidths = new float[] { 100f };
            table        = HandlingItextSharp.GenerateTableFromCells(cellsTit, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region DATOS Generales

            string[] fechaServicio = datosPac.FechaServicio.ToString().Split(' ');
            string[] fechaInforme  = datosPac.FechaActualizacion.ToString().Split(' ');
            string[] fechanac      = datosPac.d_Birthdate.ToString().Split(' ');

            ServiceComponentList psicosensometrico = serviceComponent.Find(p => p.v_ComponentId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_ID);
            var nLicencia = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_N_LICENCIA) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_N_LICENCIA).v_Value1;
            var clase     = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_LICENCIA_CLASE_CATEGORIA) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_LICENCIA_CLASE_CATEGORIA).v_Value1;
            var vehiculo  = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_EQUIPO_VEHICULO) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_EQUIPO_VEHICULO).v_Value1;

            var    primer_Ev   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_1_EVALUACION) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_1_EVALUACION).v_Value1;
            string primer_Ev_1 = "";
            if (primer_Ev == "1")
            {
                primer_Ev_1 = "X";
            }
            var    primer_ReEv   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_1_RE_EVALUACION) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_1_RE_EVALUACION).v_Value1;
            string primer_ReEv_1 = "";
            if (primer_ReEv == "1")
            {
                primer_ReEv_1 = "X";
            }
            var    segunda_ReEv   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_2_RE_EVALUACION) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_2_RE_EVALUACION).v_Value1;
            string segunda_ReEv_1 = "";
            if (segunda_ReEv == "1")
            {
                segunda_ReEv_1 = "X";
            }

            string empresageneral     = filiationData.empresa_;
            string empresacontrata    = filiationData.contrata;
            string empresasubcontrata = filiationData.subcontrata;

            string empr_Conct = "";
            if (empresageneral != empresasubcontrata)
            {
                empr_Conct = empresacontrata + " / " + empresasubcontrata;
            }
            else
            {
                empr_Conct = empresacontrata;
            }

            cells = new List <PdfPCell>()
            {
                new PdfPCell(new Phrase("N° de Informe", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.N_Informe, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Fecha de Evaluación:", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(fechaServicio[0], fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Fecha de Informe:", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(fechaInforme[0], fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Empresa", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(empresageneral, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Contrata", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(empr_Conct, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Apellidos Y Nombres", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Edad", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.Edad.ToString(), fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Fecha de nacimiento: ", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(fechanac[0], fontColumnValue))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Genero", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.Genero, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("N° Licencia de Conducir", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(nLicencia, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Telefono:", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_TelephoneNumber, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Clase y Categoría de Licencia", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(clase, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Equipo/Vehículo a operar (*):", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vehiculo, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Documento de Identidad (DNI)", fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_DocNumber, fontColumnValue))
                {
                    Colspan = 16, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("1ER Evaluación", fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(primer_Ev_1, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("1ER Re-Evaluación", fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(primer_ReEv_1, fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("2DA Re-Evaluación", fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(segunda_ReEv_1, fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region RESULTADOS


            var    agudeza_visual   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_AGUDEZA_VISUAL) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_AGUDEZA_VISUAL).v_Value1;
            string agudeza_visual_1 = "";
            if (agudeza_visual == "1")
            {
                agudeza_visual_1 = "EVALUADO";
            }
            else if (agudeza_visual == "2")
            {
                agudeza_visual_1 = "APROBADO";
            }
            else if (agudeza_visual == "3")
            {
                agudeza_visual_1 = "REPROBADO";
            }

            var    test_palancas   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_PALANCAS) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_PALANCAS).v_Value1;
            string test_palancas_1 = "";
            if (test_palancas == "1")
            {
                test_palancas_1 = "EVALUADO";
            }
            else if (test_palancas == "2")
            {
                test_palancas_1 = "APROBADO";
            }
            else if (test_palancas == "3")
            {
                test_palancas_1 = "REPROBADO";
            }

            var    vision_profundidad   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_VISION_PROFUNDIDAD) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_VISION_PROFUNDIDAD).v_Value1;
            string vision_profundidad_1 = "";
            if (vision_profundidad == "1")
            {
                vision_profundidad_1 = "EVALUADO";
            }
            else if (vision_profundidad == "2")
            {
                vision_profundidad_1 = "APROBADO";
            }
            else if (vision_profundidad == "3")
            {
                vision_profundidad_1 = "REPROBADO";
            }

            var    test_punteo   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_PUNTEO) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_PUNTEO).v_Value1;
            string test_punteo_1 = "";
            if (test_punteo == "1")
            {
                test_punteo_1 = "EVALUADO";
            }
            else if (test_punteo == "2")
            {
                test_punteo_1 = "APROBADO";
            }
            else if (test_punteo == "3")
            {
                test_punteo_1 = "REPROBADO";
            }

            var    discriminacion_colores   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_DISCRIMINACION_COLORES) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_DISCRIMINACION_COLORES).v_Value1;
            string discriminacion_colores_1 = "";
            if (discriminacion_colores == "1")
            {
                discriminacion_colores_1 = "DISCROMATOPSIA";
            }
            else if (discriminacion_colores == "2")
            {
                discriminacion_colores_1 = "APROBADO";
            }
            else if (discriminacion_colores == "3")
            {
                discriminacion_colores_1 = "REPROBADO";
            }

            var    test_reaccion_simple   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_REACCION_SIMPLE) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_REACCION_SIMPLE).v_Value1;
            string test_reaccion_simple_1 = "";
            if (test_reaccion_simple == "1")
            {
                test_reaccion_simple_1 = "EVALUADO";
            }
            else if (test_reaccion_simple == "2")
            {
                test_reaccion_simple_1 = "APROBADO";
            }
            else if (test_reaccion_simple == "3")
            {
                test_reaccion_simple_1 = "REPROBADO";
            }

            var    test_foria   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_FORIA) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_FORIA).v_Value1;
            string test_foria_1 = "";
            if (test_foria == "1")
            {
                test_foria_1 = "EVALUADO";
            }
            else if (test_foria == "2")
            {
                test_foria_1 = "APROBADO";
            }
            else if (test_foria == "3")
            {
                test_foria_1 = "REPROBADO";
            }

            var    test_anticipacion   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_ANTICIPACION) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_ANTICIPACION).v_Value1;
            string test_anticipacion_1 = "";
            if (test_anticipacion == "1")
            {
                test_anticipacion_1 = "EVALUADO";
            }
            else if (test_anticipacion == "2")
            {
                test_anticipacion_1 = "APROBADO";
            }
            else if (test_anticipacion == "3")
            {
                test_anticipacion_1 = "REPROBADO";
            }

            var    vision_nocturna   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_VISION_NOCTURNA) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_VISION_NOCTURNA).v_Value1;
            string vision_nocturna_1 = "";
            if (vision_nocturna == "1")
            {
                vision_nocturna_1 = "EVALUADO";
            }
            else if (vision_nocturna == "2")
            {
                vision_nocturna_1 = "APROBADO";
            }
            else if (vision_nocturna == "3")
            {
                vision_nocturna_1 = "REPROBADO";
            }

            var    test_reacciones_multiples   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_REACCIONES_MULTIPLES) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_REACCIONES_MULTIPLES).v_Value1;
            string test_reacciones_multiples_1 = "";
            if (test_reacciones_multiples == "1")
            {
                test_reacciones_multiples_1 = "EVALUADO";
            }
            else if (test_reacciones_multiples == "2")
            {
                test_reacciones_multiples_1 = "APROBADO";
            }
            else if (test_reacciones_multiples == "3")
            {
                test_reacciones_multiples_1 = "REPROBADO";
            }

            var    encandilamiento   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_ENCANDILAMIENTO) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_ENCANDILAMIENTO).v_Value1;
            string encandilamiento_1 = "";
            if (encandilamiento == "1")
            {
                encandilamiento_1 = "EVALUADO";
            }
            else if (encandilamiento == "2")
            {
                encandilamiento_1 = "APROBADO";
            }
            else if (encandilamiento == "3")
            {
                encandilamiento_1 = "REPROBADO";
            }

            var    monotonia   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_REACCION_MONOTONIA_CANSANCIO) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_REACCION_MONOTONIA_CANSANCIO).v_Value1;
            string monotonia_1 = "";
            if (monotonia == "1")
            {
                monotonia_1 = "EVALUADO";
            }
            else if (monotonia == "2")
            {
                monotonia_1 = "APROBADO";
            }
            else if (monotonia == "3")
            {
                monotonia_1 = "REPROBADO";
            }

            var    perimetria   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_PERIMETRIA) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_PERIMETRIA).v_Value1;
            string perimetria_1 = "";
            if (perimetria == "1")
            {
                perimetria_1 = "EVALUADO";
            }
            else if (perimetria == "2")
            {
                perimetria_1 = "APROBADO";
            }
            else if (perimetria == "3")
            {
                perimetria_1 = "REPROBADO";
            }

            var    coordinacion   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_COORDINACION_BIMANUAL) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_TEST_COORDINACION_BIMANUAL).v_Value1;
            string coordinacion_1 = "";
            if (coordinacion == "1")
            {
                coordinacion_1 = "EVALUADO";
            }
            else if (coordinacion == "2")
            {
                coordinacion_1 = "APROBADO";
            }
            else if (coordinacion == "3")
            {
                coordinacion_1 = "REPROBADO";
            }

            var    oido_derecho   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_OIDO_DERECHO) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_OIDO_DERECHO).v_Value1;
            string oido_derecho_1 = "";
            if (oido_derecho == "1")
            {
                oido_derecho_1 = "EVALUADO";
            }
            else if (oido_derecho == "2")
            {
                oido_derecho_1 = "APROBADO";
            }
            else if (oido_derecho == "3")
            {
                oido_derecho_1 = "REPROBADO";
            }

            var    oido_izquierdo   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_OIDO_IZQUIERDO) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_OIDO_IZQUIERDO).v_Value1;
            string oido_izquierdo_1 = "";
            if (oido_izquierdo == "1")
            {
                oido_izquierdo_1 = "EVALUADO";
            }
            else if (oido_izquierdo == "2")
            {
                oido_izquierdo_1 = "APROBADO";
            }
            else if (oido_izquierdo == "3")
            {
                oido_izquierdo_1 = "REPROBADO";
            }

            var    resultado_final   = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_RESULTADO_FINAL) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_RESULTADO_FINAL).v_Value1;
            string resultado_final_1 = "";
            if (resultado_final == "1")
            {
                resultado_final_1 = "EVALUADO";
            }
            else if (resultado_final == "2")
            {
                resultado_final_1 = "APROBADO";
            }
            else if (resultado_final == "3")
            {
                resultado_final_1 = "REPROBADO";
            }

            var restricciones = psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_RESTRICCIONES) == null ? "" : psicosensometrico.ServiceComponentFields.Find(p => p.v_ComponentFieldsId == Sigesoft.Common.Constants.CERTIFICADO_PSICOSENSOMETRICO_DATOS_RESTRICCIONES).v_Value1;

            cells = new List <PdfPCell>
            {
                new PdfPCell(new Phrase("Agudeza Visual", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(agudeza_visual_1, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Test de Palancas", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(test_palancas_1, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Visión de Profundidad", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vision_profundidad_1, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Test de punteo", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(test_punteo_1, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Discriminación de Colores", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(discriminacion_colores_1, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Test de reacción simple", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(test_reaccion_simple_1, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Test de Foria", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(test_foria_1, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Test de anticipación", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(test_anticipacion_1, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Visión Nocturna", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(vision_nocturna_1, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Test de reacciones múltiples", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(test_reacciones_multiples_1, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Test de Encandilamiento", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(encandilamiento_1, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Test de reacción a la monotonía y cansancio", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(monotonia_1, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Test de Perimetría o Test de campo visual", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(perimetria_1, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Test de coordinación bimanual", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(coordinacion_1, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Audición", fontColumnValue))
                {
                    Colspan = 2, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Oído Derecho", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(oido_derecho_1, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Oído Izquierdo", fontColumnValue))
                {
                    Colspan = 6, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(oido_izquierdo_1, fontColumnValue))
                {
                    Colspan = 3, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("", fontColumnValue))
                {
                    Colspan = 20, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 3, BackgroundColor = BaseColor.GRAY
                },
                new PdfPCell(new Phrase("Resultado Final", fontColumnValue))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(resultado_final_1, fontColumnValue))
                {
                    Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Restricciones", fontColumnValue))
                {
                    Colspan = 8, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(restricciones, fontColumnValue))
                {
                    Colspan = 12, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, MinimumHeight = tamaño_celda
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion

            #region Firma y sello Médico
            PdfPCell cellFirmaTrabajador  = null;
            PdfPCell cellHuellaTrabajador = null;
            PdfPCell cellFirmaDoctor      = null;

            if (filiationData.FirmaTrabajador != null)
            {
                cellFirmaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.FirmaTrabajador, null, null, 100, 35));
            }
            else
            {
                cellFirmaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellFirmaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

            if (filiationData.HuellaTrabajador != null)
            {
                cellHuellaTrabajador = new PdfPCell(HandlingItextSharp.GetImage(filiationData.HuellaTrabajador, null, null, 45, 60));
            }
            else
            {
                cellHuellaTrabajador = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellHuellaTrabajador.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellHuellaTrabajador.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;


            if (usuariograbo.Firma != null)
            {
                cellFirmaDoctor = new PdfPCell(HandlingItextSharp.GetImage(usuariograbo.Firma, null, null, 120, 55));
            }
            else
            {
                cellFirmaDoctor = new PdfPCell(new Phrase(" ", fontColumnValue));
            }

            cellFirmaDoctor.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellFirmaDoctor.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;


            cells = new List <PdfPCell>
            {
                //Linea

                new PdfPCell(cellFirmaDoctor)
                {
                    Rowspan = 8, Colspan = 5, HorizontalAlignment = PdfPCell.ALIGN_CENTER, FixedHeight = 100
                },
                new PdfPCell(cellFirmaTrabajador)
                {
                    Rowspan = 8, Colspan = 3, HorizontalAlignment = PdfPCell.ALIGN_CENTER, FixedHeight = 100, UseVariableBorders = true, BorderColorLeft = BaseColor.BLACK, BorderColorRight = BaseColor.WHITE, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(cellHuellaTrabajador)
                {
                    Rowspan = 8, Colspan = 2, HorizontalAlignment = PdfPCell.ALIGN_CENTER, FixedHeight = 100, UseVariableBorders = true, BorderColorLeft = BaseColor.WHITE, BorderColorRight = BaseColor.BLACK, BorderColorBottom = BaseColor.BLACK, BorderColorTop = BaseColor.BLACK
                },
                new PdfPCell(new Phrase("Firma del Evaluador", fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Firma del Evaluado", fontColumnValue))
                {
                    Colspan = 5, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Nombre", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(usuariograbo.Nombre, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase("Nombre", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(datosPac.v_FirstLastName + " " + datosPac.v_SecondLastName + " " + datosPac.v_FirstName, fontColumnValue))
                {
                    Colspan = 4, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },

                new PdfPCell(new Phrase("Registro", fontColumnValue))
                {
                    Colspan = 1, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_LEFT, FixedHeight = tamaño_celda
                },
                new PdfPCell(new Phrase(usuariograbo.CMP, fontColumnValue))
                {
                    Colspan = 9, HorizontalAlignment = iTextSharp.text.Element.ALIGN_CENTER, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = tamaño_celda
                },
            };

            columnWidths = new float[] { 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion


            #region NOTA
            cells = new List <PdfPCell>
            {
                new PdfPCell(new Phrase("(*) Definirá la categoría que obliga al reglamento en MTC, para los casos de los equipos fuera de carretera, como tractores, rodillos, etc., los parámetros de aplicar será los correspondientes a la licencia AIIIC", fontColumnValue))
                {
                    Colspan = 30, HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT, VerticalAlignment = iTextSharp.text.Element.ALIGN_MIDDLE, FixedHeight = 30
                },
            };

            columnWidths = new float[] { 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f, 5f };
            table        = HandlingItextSharp.GenerateTableFromCells(cells, columnWidths, null, fontTitleTable);
            document.Add(table);
            #endregion
            document.Close();
            writer.Close();
            writer.Dispose();
        }