@php
 
    use App\Libraries\ejLib;
    $var = ejLib::getInstance();
    $soapclient = $var->getWs();
    $wsClave = $var->get_wsClave();

    function recuperaCadena($cadena_entrante){       
        $cadena = $cadena_entrante;
        $cadena = utf8_decode($cadena);
        $cadena = str_replace('.*-*.br .*-*.', '<br>', $cadena);
        $cadena = str_replace('.*-*.b .*-*.', '<b>', $cadena);
        return trim(utf8_decode($cadena));
    }

    function cifrar($string, $key) {
	   $result = '';
	   for($i=0; $i<strlen($string); $i++) {
	      $char = substr($string, $i, 1);
	      $keychar = substr($key, ($i % strlen($key))-1, 1);
	      $char = chr(ord($char)+ord($keychar));
	      $result.=$char;
	   }
	   return base64_encode($result);
	}


    $data = $soapclient->ConsultaExterna_getLstNotas_xPaciente($_GET['id_paciente'], '1', $wsClave);
    $data = new SimpleXMLElement($data);
    $notas = $data->respuesta;

 
    $data = $soapclient->Archivo_getLstPacientesFull('', $_GET['id_paciente'], $wsClave);
      $data = new SimpleXMLElement(utf8_encode($data));
      $paciente = $data->respuesta;
    
 
      $f_nac = explode('/',$paciente->f_nac); 
      $FNac = new DateTime($f_nac[2]."-".$f_nac[1]."-".$f_nac[0]);
      $hoy = new DateTime();
      $edad = $hoy->diff($FNac); 

@endphp

<link rel="stylesheet" href="css/bootstrap.css">
<script src="js/jquery-3.1.0.min.js"></script>
<script src="js/notify.js"></script>

<style type="text/css">
	.page-headerL { font-size: 1.1em; font-weight: bold; border-bottom: 1px solid #3c8cbc; width: 100%; text-align: left;}

	.margenSuperior { margin-top: 5px; }
	.input-group{ margin-top: 5px; }

	.td{ border: 1px solid; border-color: #d2d6de; height: 30px; padding: 5px 10px; line-height: 1.3;}
	    
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<div class="box box-primary">

			<div class="box-body" id="espAgenda" name="espAgenda" style="width: 95%; margin: 0px auto; margin-top: 40px;">
				<div class="row alinear_centrado">
                    <div class="page-headerL" id="espacioAgenda" name="espacioAgenda">

                      <div>
    <div style="float:left;width: 30%;"> <img src="{{asset('img/insabi.png')}}" width="60%"></div>
    <div style="float:left;width: 40%;"><p align="center">SECRETAR&#205;A DE SALUD <BR><BR>Hoja Frontal</p>
                   </div>    
    <div style="float:right;width: 30%;">  <img src="{{asset('img/salud.png')}}" width="60%" align="right"></div>    
</div>
<div style="clear:both"></div>
                     <div style="width: 97%;">
                        <div style="position: relative; text-align: right; font-weight: 600; margin-top: 5px;">Fecha: {{ date("d") . "/" . date("m") . "/" . date("Y"). ' ' . date("H") . ':' . date("i") }}</div>                          
                      </div>
                          
                    </div>
                    <div class="row margenSuperior">

                      <div class="row">
                        <div class="col-sm-4">                                                    	
                          	<table width="103%">                         		
                          		<tr><td class="input-group-addon" style="background: #eee;">Nombre del Paciente:</td><td class="td">   <?php echo $paciente->nombre." ".$paciente->primer_apellido." ".$paciente->segundo_apellido; ?> </td></tr>                          		
                          	</table>

                          	<table width="103%">
                          	<tr>
                          		<td class="input-group-addon" style="background: #eee;">Edad</td><td class="td" style="width: 15%;">{{  $edad->y }} a&ntilde;os
                                </td>
                          		<td class="input-group-addon" style="background: #eee;">Fecha de Nacimiento</td><td class="td" style="width:35%;"><?php echo $paciente->f_nac; ?></td>
                          		 
                          	</tr></table>

                          	<table width="103%">
                          	<tr>
                          		<td class="input-group-addon" style="background: #eee; width: 10%;">CURP</td><td class="td"> <?php echo $paciente->curp; ?></td>
                          		<td class="input-group-addon" style="background: #eee; width: 20%;">Derecho Habiencia</td><td class="td"><?php echo $paciente->afil_descripcion; ?> </td>

                          	</tr></table>

                          	<table width="103%">
                          		<td class="input-group-addon" style="background: #eee; width: 25%;">Sexo</td><td class="td"> <?php echo $paciente->sex_nombre; ?></td>
                              <td class="input-group-addon" style="background: #eee; width: 25%;">Folio</td><td class="td"><?php echo $paciente->folio_afil; ?> </td>

                          	</table>
                            <br>
                              <table width="100%">                            
                              <tr>
                                <td   style="background: #eee;padding:6px 12px;font-size:14px;font-weight:400;line-height:1;color:#555;text-align:center;background-color:#eee;border:1px solid #ccc;border-radius:4px" width="70">FECHA</td>
                                <td   style="background: #eee;padding:6px 12px;font-size:14px;font-weight:400;line-height:1;color:#555;text-align:center;background-color:#eee;border:1px solid #ccc;border-radius:4px" width="230">DIAGNOSTICO</td>
                                <td class="input-group-addon" style="background: #eee;">TIPO DE NOTA</td>
                                <td   style="background: #eee;padding:6px 12px;font-size:14px;font-weight:400;line-height:1;color:#555;text-align:center;background-color:#eee;border:1px solid #ccc;border-radius:4px" width="60">ESTADO </td>
                              </tr> 
                            <?php foreach ($notas as $key => $value) {
                              
                            ?>
                              <tr>
                                <td class="td"  ><?php echo $value->fecha; ?> </td>
                                <td class="td"  ><?php echo (utf8_decode($value->diagnosticos)); ?> </td>
                                <td class="td"  ><?php echo (utf8_decode($value->titulonota)); ?> </td>
                                <td class="td"  ><?php echo $value->estadosalud; ?> </td>
                              </tr>    
                              <?php } ?>                              
                            </table>

                            

                        </div>
                      </div>

                      
                      <div style="width: 97%;">
                      	<div style="position: relative; text-align: center; margin-top: 5px;"> </div>
                      </div>

                      

                    </div>
                </div>
            </div>
		</div>

