templates/historia_clinica/edit_new.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}Edit HistoriaClinica{% endblock %}
  3. {% block body %}
  4.     
  5.     <style type="text/css">
  6.         p {
  7.             margin-bottom: 0px;
  8.             margin-top: 5px;
  9.         }    
  10.     </style>    
  11.     <div id="modal_ante" class="modal fade" role="dialog">
  12.         <div class="modal-dialog modal-lg" >
  13.             <div class="modal-content" id="div_ante">
  14.                    
  15.             </div>     
  16.         </div>
  17.     </div>
  18.      
  19.     <div class="row">
  20.         <div class="col-md-4">
  21.             <br>
  22.             <div class="position-fixed" id="div_fade" style="display: none;z-index: 9999;">
  23.                 <div class="alert success">
  24.                   <span class="closebtn">×</span>  
  25.                   <strong>Guardado con Exito!</strong>
  26.                 </div>
  27.             </div>
  28.             <div class="position-fixed" id="div_fade_error" style="display: none;z-index: 9999;">
  29.                 <div class="alert danger">
  30.                   <span class="closebtn">×</span>  
  31.                   <strong>Error al Guardar Informar!</strong>
  32.                 </div>
  33.             </div>
  34.             <div class="position-fixed" id="div_fade_sesion" style="display: none;z-index: 9999;">
  35.                 <div class="alert danger">
  36.                   <span class="closebtn">×</span>  
  37.                   <strong>Se cerro la sesion!</strong>
  38.                 </div>
  39.             </div>
  40.         </div>
  41.         
  42.         <div class="col-md-8">
  43.             <div class="position-fixed d-flex gap-2 flex-wrap" style="z-index:9999">
  44.                 {# ===== ACCIONES PRINCIPALES ===== #}
  45.                 
  46.                     <a class="btn btn-warning btn-sm"
  47.                     href="{{ path('paciente_edit',{'id': historia_clinica.paciente.id}) }}"
  48.                     target="_blank">
  49.                         <i class="bi bi-person"></i> Paciente
  50.                     </a>
  51.                     <a class="btn btn-info btn-sm"
  52.                     href="{{ path('receta_index',{'id_historia': historia_clinica.id}) }}">
  53.                         <i class="bi bi-journal-medical"></i> Nueva Receta
  54.                     </a>
  55.                 
  56.                 {% if historia_clinica.estado != 2 %}
  57.                     <button class="btn btn-danger btn-sm" onclick="atendido()">
  58.                         <i class="bi bi-check-circle"></i> Atendido
  59.                     </button>
  60.                     <button class="btn btn-warning btn-sm" onclick="suspender_agenda_form()">
  61.                         <i class="bi bi-x-circle"></i> No asistió
  62.                     </button>
  63.                 {% endif %}
  64.                 {# ===== DROPDOWN DE MÁS ACCIONES ===== #}
  65.                 <div class="dropdown">
  66.                     <button class="btn btn-dark btn-sm dropdown-toggle"
  67.                             type="button"
  68.                             data-bs-toggle="dropdown">
  69.                         <i class="bi bi-three-dots-vertical"></i> Más acciones
  70.                     </button>
  71.                     <ul class="dropdown-menu">
  72.                         
  73.                             <li>
  74.                                 <a class="dropdown-item"
  75.                                 href="{{ path('examen_orden_index',{'id_historia': historia_clinica.id}) }}">
  76.                                     🧪 Orden Laboratorio
  77.                                 </a>
  78.                             </li>
  79.                             <li>
  80.                                 <a class="dropdown-item"
  81.                                 href="{{ path('orden_procedimiento_index',{'id': historia_clinica.agenda.id}) }}">
  82.                                     🩺 Orden Procedimiento
  83.                                 </a>
  84.                             </li>
  85.                             <li>
  86.                                 <a class="dropdown-item"
  87.                                 href="{{ path('historia_clinica_index_paciente',{'id_paciente': historia_clinica.paciente.id}) }}"
  88.                                 target="_blank">
  89.                                     📄 Historia Clínica
  90.                                 </a>
  91.                             </li>
  92.                         
  93.                         {% if historia_clinica.agenda.especialidad.dependencia
  94.                         and historia_clinica.agenda.especialidad.dependencia.id == 3 %}
  95.                             <li>
  96.                                 <a class="dropdown-item"
  97.                                 href="{{ path('odontograma_index',{'id': historia_clinica.agenda.id}) }}"
  98.                                 target="_blank">
  99.                                     🦷 Odontograma
  100.                                 </a>
  101.                             </li>
  102.                         {% endif %}
  103.                         <li><hr class="dropdown-divider"></li>
  104.                         <li>
  105.                             <a class="dropdown-item text-success"
  106.                             href="{{ path('listado_paciente_resultados',{'id_paciente': historia_clinica.paciente.id}) }}"
  107.                             target="_blank">
  108.                                 📊 Resultados
  109.                             </a>
  110.                         </li>
  111.                         {% for receta in historia_clinica.recetas %}
  112.                             <li>
  113.                                 <a class="dropdown-item"
  114.                                 href="{{ path('receta_edit',{'id': receta.id}) }}">
  115.                                     💊 Receta Nº {{ receta.id }}
  116.                                 </a>
  117.                             </li>
  118.                         {% endfor %}
  119.                     </ul>
  120.                 </div>
  121.             </div>
  122.         </div>
  123.         {% set pxs = historia_clinica.agenda.getAgendaProcedimientos() %}
  124.         <div class="col-md-6">
  125.             <H3>{{ historia_clinica.agenda.procedimiento.nombre }}<br>{% for px in pxs %} {{ px.procedimiento.nombre }}<br> {% endfor %}</H3>
  126.             <p style="font-size: 10px;">*** Dando Click en cualquier parte de la pantalla se grabará el contenido</p>
  127.         </div>
  128.         <div class="col-md-6">
  129.             
  130.         </div>    
  131.         {% if(historia_clinica.agenda.procedimiento.id > 1) %}
  132.         <!--div class="col-md-5">
  133.             {% if (app.user.tipousuario != 'ENFERMERIA') %}
  134.             <a class="btn btn-primary" href="{{path('estudio_index',{'id_historia': historia_clinica.id})}}">Estudio</a>
  135.             {% endif %}
  136.         </div-->    
  137.         {% endif %}
  138.         {{ include('historia_clinica/_form_archivo.html.twig', {'button_label': 'Subir Estudio'}) }}
  139.         {% set estudios = historia_clinica.estudios %}
  140.         
  141.     </div>
  142.     <div class="row">
  143.         {% for estudio in estudios %}
  144.             <div class="col-md-3">
  145.             {% if(estudio.procedimiento != null) %}
  146.             <a class="btn btn-success btn-sm" href="{{path('estudio_edit',{'id': estudio.id})}}" target="_blank">{{ estudio.procedimiento.nombre }}</a>
  147.             {% endif %}
  148.             </div>
  149.         {% endfor %}
  150.     </div>
  151.     <div class="row">
  152.         <div class="col-md-12">
  153.             <p class="text-light bg-dark pl-1">Datos del Paciente: </p>    
  154.         </div>
  155.     </div>
  156.     <table class="table">
  157.         <tbody>
  158.             <tr>
  159.                 <th>Nombres</th>
  160.                 <td colspan="2" style="color: red;font-size: 18px"><b>{{ historia_clinica.paciente.apellido1 }} {{ historia_clinica.paciente.apellido2 }} {{ historia_clinica.paciente.nombre1 }} {{ historia_clinica.paciente.nombre2 }}</b></td>
  161.                 <td style="background-color: #0AB3F7 !important;"><b>Alias:</b>{{ historia_clinica.paciente.alias }}</td>
  162.                 <th>Fecha Nacimiento</th>
  163.                 <td>{{ historia_clinica.paciente.fechaNacimiento|date('Y-m-d')  }}</td>
  164.                 <th>Edad</th>
  165.                 <td>{{ historia_clinica.paciente.calculaedad() }}</td>
  166.             </tr>
  167.             <tr>
  168.                 <th>Cédula</th>
  169.                 <td>{{ historia_clinica.paciente.cedula  }}</td>
  170.                 <th>Estado Civil</th>
  171.                 <td>{{ historia_clinica.paciente.estadoCivil }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Hijos:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ historia_clinica.paciente.hijos }}</td>
  172.                 <th>Ocupación</th>
  173.                 <td>{{ historia_clinica.paciente.ocupacion  }}</td>
  174.                 <th>Residencia</th>
  175.                 <td>{{ historia_clinica.paciente.ciudad }}</td>
  176.             </tr>
  177.             <tr>
  178.                 <th>Teléfonos</th>
  179.                 <td>{{ historia_clinica.paciente.telefono  }} - {{ historia_clinica.paciente.celular  }}</td>
  180.                 <th>Seguro</th>
  181.                 <td>{{ historia_clinica.agenda.seguro.nombre }}</td>
  182.                 <th>Recomendacion</th>
  183.                 <td >{{ historia_clinica.paciente.recomendacion }}</td>
  184.                 <th>Derivacion</th>
  185.                 <td >{% if(historia_clinica.agenda.recomendado != null) %}{{ historia_clinica.agenda.recomendado.apellido1 }}{% endif %}
  186.                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Red Social </b>{% if(historia_clinica.agenda.redsocial != null) %} {{ historia_clinica.agenda.redsocial.nombre }}{% endif %}</td>
  187.             </tr>
  188.         </tbody>
  189.     </table>
  190.     <div class="row">
  191.         <div class="col-md-12">
  192.             <p class="text-light bg-dark pl-1">Signos Vitales: </p>    
  193.         </div>
  194.     </div>
  195.     <table class="table">
  196.         <tbody>
  197.             <tr>
  198.                 <th>Motivo Consulta</th>
  199.                 <td colspan="2" >{{ historia_clinica.agenda.validacion }}</td>
  200.                 <th>Observacion Paciente</th>
  201.                 <td colspan="2" >{{ historia_clinica.paciente.observacion }}</td>
  202.             </tr>
  203.             <tr>
  204.                 <th>Temperatura (C)</th>
  205.                 <td>{{ preparacion.temperatura }}</td>
  206.                 <th>Presion arterial (mmHg)</th>
  207.                 <td>{{ preparacion.presion }}</td>
  208.                 <th>Frecuencia Cardiaca (l/m)</th>
  209.                 <td>{{ preparacion.pulso }}</td>
  210.             </tr>
  211.             <tr>
  212.                 <th>Frecuencia Respiratoria (r/m)</th>
  213.                 <td>{{ preparacion.frecuenciarespiratoria }}</td>
  214.                 <th>SPO (%)</th>
  215.                 <td>{{ preparacion.saturaciondeoxigeno }}</td>
  216.                 <th>Observacion Signos Vitales</th>
  217.                 <td>{{ preparacion.observacion }}</td>
  218.             </tr>
  219.         </tbody>
  220.     </table>
  221.     <div class ="row" >
  222.         <div class="col-md-12">
  223.             
  224.             {% if(historia_clinica.paciente.copiacedula != null) %}
  225.                 <a class="btn btn-success btn-sm" target="_blank" href="{{ asset('uploads/copia_cedula/' ~ historia_clinica.paciente.copiacedula) }}"><i class="mdi mdi-printer"> Historia Clinica Subida</i></a>
  226.             {% endif %}
  227.             {% if(historia_clinica.agenda.archivo053 != null) %}
  228.                 <a class="btn btn-success btn-sm" target="_blank" href="{{ asset('uploads/laboratorio_externo/' ~ historia_clinica.agenda.archivo053) }}"><i class="mdi mdi-printer"> Examenes Laboratorio Subido</i></a>
  229.             {% endif %}
  230.         </div> 
  231.     </div> 
  232.     
  233.     {{ include('historia_clinica/_form_new.html.twig', {'button_label': 'Update'}) }}
  234.     
  235.     
  236.     {{ include('diagnosticos_historia_clinica/form_dx.html.twig') }}
  237.     <div id="div_lista_cie10">
  238.         
  239.     </div>
  240.     
  241.     <div class="row">
  242.         <div class="col-md-12"><h4>Imagenes del Examen</h4></div>
  243.         {% if(estudio != null) %}    
  244.             {% set imagenes = estudio.imagenesEstudios %}
  245.             {% for imagen in imagenes %}
  246.             <div class="col-md-6" style="padding: 20px;">
  247.                 <!--img src="{{ asset('uploads/estudios') }}/{{ imagen.nombre}}" width="40%">    
  248.                 <button onclick="eliminar_imagen('{{imagen.id}}')" class="btn btn-danger btn-rounded btn-sm">Eliminar</button-->
  249.                 {% set ext = imagen.nombre|split('.')|last|lower %}
  250.                 {% if ext == 'pdf' %}
  251.                     <a 
  252.                         href="{{ asset('uploads/estudios') }}/{{ imagen.nombre }}" 
  253.                         target="_blank"
  254.                         class="btn btn-outline-primary"
  255.                     >
  256.                         📄 Ver PDF
  257.                     </a>
  258.                 {% else %}
  259.                     <img 
  260.                         src="{{ asset('uploads/estudios') }}/{{ imagen.nombre }}" 
  261.                         width="40%"
  262.                     >
  263.                 {% endif %}
  264.                 <button 
  265.                     onclick="eliminar_imagen('{{ imagen.id }}')" 
  266.                     class="btn btn-danger btn-rounded btn-sm"
  267.                 >
  268.                     Eliminar
  269.                 </button>
  270.             </div>
  271.             {% endfor %}
  272.         {% endif %}    
  273.     </div>
  274.     {{ include('imagenes_estudio/_form.html.twig', {'button_label': 'Update'}) }}
  275.     <div class="col-md-12 pc" style="display: none;" id="div_upload">
  276.         <img src="{{ asset('assets/images/upload.gif') }}" width="50" height="50">Subiendo Archivo
  277.     </div>  
  278.     <div class="col-md-12 pc" id="certificados">
  279.     </div>
  280.     {% endblock %}
  281.     {% block javascripts %}
  282.     
  283.     <script type="text/javascript">
  284.     
  285.         $(document).ready(function() {
  286.             
  287.             bsCustomFileInput.init();
  288.             
  289.             //const intervalID = setInterval (() => {
  290.             
  291.                 //guardar();
  292.                 //console.log ('Beeeeep!');
  293.             
  294.             //}, 60000)
  295.             var estatura = $( "#historia_clinica_new_estatura" ).val();
  296.             if(estatura != 0 && estatura != ''){
  297.                 var peso = $( "#historia_clinica_new_peso" ).val();
  298.                 if(peso != 0 && peso != ''){
  299.                     calcular_imc(peso,estatura);   
  300.                 }
  301.                 
  302.             }
  303.         });
  304.         
  305.         function subir_estudio(){
  306.             
  307.             
  308.             var formData2 = new FormData($('#estudio_form')[0]);
  309.             
  310.             $.ajax({  
  311.                 url:        '{{path("historia_edit_archivo_storage",{ 'id': historia_clinica.id })}}',  
  312.                 type:       'POST', 
  313.                 //data:       $('#estudio_form').serialize(),
  314.                 data:       formData2,
  315.                 //dataType:   'json',  
  316.                 //async:      true,  
  317.                 processData: false,
  318.                 contentType: false,
  319.                 cache: false,
  320.                 
  321.                 success: function(data, status) { 
  322.                     
  323.                     if(data.estado=='err'){
  324.                         alert(data.mensaje);
  325.                         
  326.                     }
  327.                     //console.log(data.recargar);
  328.                     if(data.recargar){
  329.                         location.reload();
  330.                     }
  331.                     $('#div_fade').fadeIn(1000);
  332.                     $('#div_fade').fadeOut(1000);
  333.                     
  334.                 },  
  335.                 error : function(xhr, textStatus, errorThrown) { 
  336.                     //console.log(xhr);
  337.                     alert('Ajax request failed.');  
  338.                 }  
  339.             });
  340.             
  341.            
  342.                    
  343.         }
  344.         
  345.         {% if(historia_clinica.paciente.sexo) %}
  346.             $('#historia_clinica_new_fum').hide();
  347.             $('#historia_clinica_new_ago').hide();
  348.             $('#historia_clinica_new_gesta').hide();
  349.             $('#historia_clinica_new_abo').hide();
  350.             $('#historia_clinica_new_para').hide();
  351.             $('#historia_clinica_new_cesa').hide();    
  352.         {% else %}
  353.             $('#historia_clinica_new_fum').show();
  354.             $('#historia_clinica_new_ago').show();
  355.             $('#historia_clinica_new_gesta').show();
  356.             $('#historia_clinica_new_abo').show();
  357.             $('#historia_clinica_new_para').show();
  358.             $('#historia_clinica_new_cesa').show();
  359.         {% endif %}
  360.         
  361.         $(document).ready(function(){
  362.             $('#modal_ante').on('hidden.bs.modal', function(e) {
  363.                 recarga_ante(); 
  364.                 
  365.             });
  366.             $('#div_evol').html($('#historia_clinica_evolucion').val());
  367.             certificados();
  368.         });    
  369.         function certificados(){
  370.             
  371.             $.ajax({  
  372.                 url:        "{{path('asistencia_formulario',{'id': historia_clinica.id})}}",  
  373.                 type:       'GET',   
  374.                 //dataType:   'json',  
  375.                 async:      true,  
  376.                
  377.                 success: function(data, status) { 
  378.                     //console.log(data); 
  379.                     $('#certificados').empty().html(data);
  380.                     
  381.                     
  382.                 },  
  383.                 error : function(xhr, textStatus, errorThrown) { 
  384.                     //console.log(xhr);
  385.                     alert('Ajax request failed.');  
  386.                 }  
  387.             });
  388.             
  389.         }
  390.         function cp_signos() {
  391.           var imc = document.getElementById('imc_val').innerText;    
  392.           var signos =     '{{ preparacion.temperatura }}\n{{ preparacion.presion }}\n{{ preparacion.pulso }}\n{{ preparacion.frecuenciarespiratoria }}\n{{ preparacion.peso }}\n{{ preparacion.estatura }}\n{{ preparacion.perimetrocefalico }}\n{{ preparacion.perimetrotoraxico }}\n'+imc+'\n{{ preparacion.cambiodepeso }}\n\n\n{{ preparacion.saturaciondeoxigeno}}';
  393.           var texto = document.createTextNode(signos);            
  394.           var aux   = document.createElement("textarea")
  395.           //console.log(aux);
  396.           //var texto = document.getElementById(id_elemento).innerHTML + '\nhola';
  397.           //var aux = document.getElementById(id_elemento);
  398.           aux.appendChild(texto);
  399.           //aux.setAttribute("text", texto);
  400.           document.body.appendChild(aux);
  401.           aux.select();
  402.           document.execCommand("copy");
  403.           //document.body.removeChild(aux);
  404.         }
  405.         function recarga_ante() {
  406.             $.ajax({  
  407.                 url:        "{{path('paciente_antecedente_ajax', {'id': historia_clinica.paciente.id})}}",  
  408.                 type:       'GET', 
  409.                 //dataType:   'json',  
  410.                 async:      true, 
  411.                 beforeSend: function (){
  412.               
  413.                 }, 
  414.                 success: function(data, status) { 
  415.                     //console.log(data);
  416.                     var ant_per = '<p style="margin-bottom: 1px;">'+data.antecedentes_personales+'</p>';
  417.                     ant_per = ant_per + '<p style="margin-bottom: 1px;">Habitos:  Alcohol: '+ data.alcohol +' Tabaco: '+ data.tabaco +' Drogas: '+ data.drogas +'</p>';
  418.                     ant_per     = ant_per + '<p style="margin-bottom: 1px;">Alergias: ' + data.alergias + '</p>'; 
  419.                       ant_per     = ant_per + '<p style="margin-bottom: 1px;">Antecedentes Quirurgicos: ' + data.antecedentes_quirurgicos + '</p>';
  420.                       {% if(historia_clinica.paciente.sexo==0) %}
  421.                           ant_per     = ant_per + '<p style="margin-bottom: 1px;">Ago: ' + data.ago + '</p><p style="margin-bottom: 1px;"> Fum: ' + data.fum + '</p>';
  422.                           ant_per     = ant_per + '<p style="margin-bottom: 1px;">Gesta: ' + data.gesta + '</p><p style="margin-bottom: 1px;"> Abo: ' + data.abo + '</p>';
  423.                           ant_per     = ant_per + '<p style="margin-bottom: 1px;">Para: ' + data.para + '</p><p style="margin-bottom: 1px;"> Cesa: ' + data.cesa + '</p>';
  424.                       {% endif %}
  425.                       ant_per     = ant_per + '<p style="margin-bottom: 1px;">Medicación: ' + data.medicacion + '</p>';
  426.                       $('#ante_div_aj').html(ant_per);
  427.                       var fam = '<p style="margin-bottom: 1px;">'+data.antecedentes_familiares+'</p>';
  428.                       $('#fam_div_aj').html(fam);
  429.                       
  430.                 },  
  431.                 error : function(xhr, textStatus, errorThrown) { 
  432.                     //console.log(xhr);
  433.                     alert('Ajax request failed.');  
  434.                 }  
  435.             });
  436.              
  437.         }
  438.         function cp_antecedentes_per() {
  439.             $.ajax({  
  440.                 url:        "{{path('paciente_antecedente_ajax', {'id': historia_clinica.paciente.id})}}",  
  441.                 type:       'GET', 
  442.                 //dataType:   'json',  
  443.                 async:      true, 
  444.                 beforeSend: function (){
  445.               
  446.                 }, 
  447.                 success: function(data, status) { 
  448.                     //console.log(data);
  449.                     var ant_per = data.antecedentes_personales+'\n';
  450.                     ant_per = ant_per + 'Habitos:  Alcohol: '+ data.alcohol +'Tabaco: '+ data.tabaco +' Drogas: '+ data.drogas +'\n';
  451.                     ant_per     = ant_per + 'Alergias: ' + data.alergias + '\n'; 
  452.                       ant_per     = ant_per + 'Antecedentes Quirurgicos: ' + data.antecedentes_quirurgicos + '\n';
  453.                       {% if(historia_clinica.paciente.sexo==0) %}
  454.                           ant_per     = ant_per + 'Ago: ' + data.ago + ' Fum: ' + data.fum + '\n';
  455.                           ant_per     = ant_per + 'Gesta: ' + data.gesta + ' Abo: ' + data.abo + '\n';
  456.                           ant_per     = ant_per + 'Para: ' + data.para + ' Cesa: ' + data.cesa + '\n';
  457.                       {% endif %}
  458.                       ant_per     = ant_per + 'Medicación: ' + data.medicacion;
  459.                       var texto2 = document.createTextNode(ant_per);            
  460.                     var aux2   = document.createElement("textarea")
  461.                     console.log(aux2);
  462.                     aux2.appendChild(texto2);
  463.                     document.body.appendChild(aux2);
  464.                     aux2.select();
  465.                     document.execCommand("copy");
  466.                      
  467.                 },  
  468.                 error : function(xhr, textStatus, errorThrown) { 
  469.                     //console.log(xhr);
  470.                     alert('Ajax request failed.');  
  471.                 }  
  472.             });
  473.              
  474.         }
  475.         function cp_antecedentes_fam() {
  476.             $.ajax({  
  477.                 url:        "{{path('paciente_antecedente_ajax', {'id': historia_clinica.paciente.id})}}",  
  478.                 type:       'GET', 
  479.                 //dataType:   'json',  
  480.                 async:      true, 
  481.                 beforeSend: function (){
  482.               
  483.                 }, 
  484.                 success: function(data, status) { 
  485.                     var ant_fam = data.antecedentes_familiares;
  486.                     var texto2 = document.createTextNode(ant_fam);            
  487.                     var aux2   = document.createElement("textarea");
  488.                     //console.log(aux2);
  489.                     aux2.appendChild(texto2);
  490.                     document.body.appendChild(aux2);
  491.                     aux2.select();
  492.                     document.execCommand("copy");
  493.                     
  494.                 },  
  495.                 error : function(xhr, textStatus, errorThrown) { 
  496.                     //console.log(xhr);
  497.                     alert('Ajax request failed.');  
  498.                 }  
  499.             });    
  500.                     
  501.         }
  502.         
  503.         function cp_campo_motivo(){
  504.             $.ajax({  
  505.                 url:        "{{path('historia_clinica_obtener_ajax', {'id': historia_clinica.getId()})}}",  
  506.                 type:       'GET', 
  507.                 //dataType:   'json',  
  508.                 async:      true, 
  509.                 beforeSend: function (){
  510.                     guardar();
  511.                 }, 
  512.                 success: function(data, status) { 
  513.                     cp_campo(data.motivo);
  514.                 },  
  515.                 error : function(xhr, textStatus, errorThrown) { 
  516.                     //console.log(xhr);
  517.                     alert('Ajax request failed.');  
  518.                 }  
  519.             });
  520.         }
  521.         function cp_campo_en_act(){
  522.             $.ajax({  
  523.                 url:        "{{path('historia_clinica_obtener_ajax', {'id': historia_clinica.getId()})}}",  
  524.                 type:       'GET', 
  525.                 //dataType:   'json',  
  526.                 async:      true, 
  527.                 beforeSend: function (){
  528.                     guardar();
  529.                 }, 
  530.                 success: function(data, status) { 
  531.                     cp_campo(data.evolucion);
  532.                 },  
  533.                 error : function(xhr, textStatus, errorThrown) { 
  534.                     //console.log(xhr);
  535.                     alert('Ajax request failed.');  
  536.                 }  
  537.             });
  538.         }
  539.         function cp_campo_revision(){
  540.             $.ajax({  
  541.                 url:        "{{path('historia_clinica_obtener_ajax', {'id': historia_clinica.getId()})}}",  
  542.                 type:       'GET', 
  543.                 //dataType:   'json',  
  544.                 async:      true, 
  545.                 beforeSend: function (){
  546.                     guardar();
  547.                 }, 
  548.                 success: function(data, status) {
  549.                     //console.log(data); 
  550.                     cp_campo(data.revision_actual_organos_y_sistemas);
  551.                 },  
  552.                 error : function(xhr, textStatus, errorThrown) { 
  553.                     //console.log(xhr);
  554.                     alert('Ajax request failed.');  
  555.                 }  
  556.             });
  557.         }
  558.         function cp_campo_examen_fisico(){
  559.             $.ajax({  
  560.                 url:        "{{path('historia_clinica_obtener_ajax', {'id': historia_clinica.getId()})}}",  
  561.                 type:       'GET', 
  562.                 //dataType:   'json',  
  563.                 async:      true, 
  564.                 beforeSend: function (){
  565.                     guardar();
  566.                 }, 
  567.                 success: function(data, status) {
  568.                     //console.log(data); 
  569.                     var cadena=data.examen_fisico;
  570.                     //Cadena sin saltos de linea
  571.                     //var sin_salto = cadena.split("\r\n").join(" ");
  572.                     //console.log(sin_salto);
  573.                     //cp_campo(sin_salto);
  574.                     cp_campo2(cadena);
  575.                 },  
  576.                 error : function(xhr, textStatus, errorThrown) { 
  577.                     //console.log(xhr);
  578.                     alert('Ajax request failed.');  
  579.                 }  
  580.             });
  581.         }
  582.         function cp_campo_indicacion(){
  583.             $.ajax({  
  584.                 url:        "{{path('historia_clinica_obtener_ajax', {'id': historia_clinica.getId()})}}",  
  585.                 type:       'GET', 
  586.                 //dataType:   'json',  
  587.                 async:      true, 
  588.                 beforeSend: function (){
  589.                     guardar();
  590.                 }, 
  591.                 success: function(data, status) {
  592.                     var receta='Prescripcion:\n';
  593.                     {% set receta = historia_clinica.recetas.first %}
  594.                     {% if(receta!=null) %}gu
  595.                         {% for detalle in receta.recetaDetalles %}
  596.                             receta1 = '{{ detalle.nombre }} - {{ detalle.cantidad | number_format }} ('+ NumeroALetras('{{ detalle.cantidad }}','{{ detalle.id }}') +') {{ detalle.indicacion }}';
  597.                             receta1 = agregar_salto(receta1) ;
  598.                             receta = receta + receta1;
  599.                         {% endfor %}    
  600.                     {% endif %}
  601.                     receta2 = agregar_salto(data.receta_observacion);
  602.                     //console.log(data.receta_observacion);
  603.                     receta = receta + receta2 + '\n';
  604.                     var cadena = receta + 'Medidas Generales\n' + data.indicaciones;
  605.                     var orden  = '\nExamenes Complementarios\n';
  606.                     {% set examen = historia_clinica.examenOrdens.first %}
  607.                     {% if(examen!=null) %}
  608.                         {% for detalle in examen.examenDetalles %}
  609.                             orden1 = '{{ detalle.nombre }}'; 
  610.                             orden1 = agregar_salto(orden1) + '\n';
  611.                             orden  = orden + orden1;
  612.                         {% endfor %}
  613.                     {% endif %}
  614.                     
  615.                     {% set orden = historia_clinica.getOrden012s.first %}
  616.                     {% if(orden!=null) %}
  617.                         {% for detalle in orden.orden012Detalles %}
  618.                             proc = '{{ detalle.descripcion }}';
  619.                             proc = agregar_salto(proc) + '\n';
  620.                             orden = orden + proc;     
  621.                         {% endfor %}
  622.                     {% endif %}
  623.                     cadena = cadena + orden;
  624.                     cp_campo2(cadena);
  625.                     //Cadena sin saltos de linea
  626.                     //var sin_salto = cadena.split("\r\n").join(" ");
  627.                     
  628.                     //cp_campo(sin_salto);
  629.                 },  
  630.                 error : function(xhr, textStatus, errorThrown) { 
  631.                     //console.log(xhr);
  632.                     alert('Ajax request failed.');  
  633.                 }  
  634.             });
  635.         }
  636.         function cp_campo_pres(){
  637.             $.ajax({  
  638.                 url:        "{{path('historia_clinica_obtener_ajax', {'id': historia_clinica.getId()})}}",  
  639.                 type:       'GET', 
  640.                 //dataType:   'json',  
  641.                 async:      true, 
  642.                 beforeSend: function (){
  643.                     guardar();
  644.                 }, 
  645.                 success: function(data, status) {
  646.                     var receta='';
  647.                     {% set receta = historia_clinica.recetas.first %}
  648.                     {% if(receta!=null) %}
  649.                         {% for detalle in receta.recetaDetalles %}
  650.                             receta1 = '{{ detalle.nombre }} - {{ detalle.cantidad | number_format }} ('+ NumeroALetras('{{ detalle.cantidad }}','{{ detalle.id }}') +') {{ detalle.indicacion }}';
  651.                             receta1 = agregar_salto(receta1) ;
  652.                             receta = receta + receta1;
  653.                         {% endfor %}    
  654.                     {% endif %}
  655.                     receta2 = agregar_salto(data.receta_observacion);
  656.                     //console.log(data.receta_observacion);
  657.                     receta = receta + receta2 + '\n';
  658.                     cp_campo2(receta);
  659.                 },  
  660.                 error : function(xhr, textStatus, errorThrown) { 
  661.                     //console.log(xhr);
  662.                     alert('Ajax request failed.');  
  663.                 }  
  664.             });    
  665.         }
  666.         
  667.         
  668.         function cp_campo(texto){
  669.             //console.log(texto);
  670.             var cantidad = texto.length;
  671.             var cociente = cantidad / 78;
  672.             cociente     = Math.trunc(cociente);
  673.             var tas400 = []; 
  674.             var i;
  675.             for (i = 0; i < cociente ; i ++) {
  676.                 var t   = i * 78;
  677.                 var x   = 78 + t;
  678.                 var sub = texto.substring( t, x);
  679.                 tas400.push(sub);
  680.             }
  681.             var sub = texto.substring(x);
  682.             tas400.push(sub);
  683.             var cantidad2 = tas400.length;
  684.             var as400 = '';
  685.             for (i = 0; i < cantidad2 ; i ++) {
  686.                 as400 = as400 + tas400[i] + '\n';
  687.                 //console.log(as400);
  688.             }    
  689.             var texto = document.createTextNode(as400);            
  690.               var aux   = document.createElement("textarea");
  691.               aux.appendChild(texto);
  692.               document.body.appendChild(aux);
  693.               aux.select();
  694.               document.execCommand("copy");
  695.         }
  696.         function agregar_salto(texto){
  697.             if(texto == null){
  698.                 return ' ';
  699.             }
  700.             var cantidad = texto.length;
  701.             var cociente = cantidad / 78;
  702.             cociente     = Math.trunc(cociente);
  703.             var tas400 = []; 
  704.             var i;
  705.             for (i = 0; i < cociente ; i ++) {
  706.                 var t   = i * 78;
  707.                 var x   = 78 + t;
  708.                 var sub = texto.substring( t, x);
  709.                 tas400.push(sub);
  710.             }
  711.             var sub = texto.substring(x);
  712.             tas400.push(sub);
  713.             var cantidad2 = tas400.length;
  714.             var as400 = '';
  715.             for (i = 0; i < cantidad2 ; i ++) {
  716.                 as400 = as400 + tas400[i] + '\n';
  717.                 //console.log(as400);
  718.             }    
  719.             
  720.             return as400;
  721.         }
  722.         function cp_campo2(texto){
  723.             
  724.             var texto = document.createTextNode(texto);            
  725.               var aux   = document.createElement("textarea");
  726.               aux.appendChild(texto);
  727.               document.body.appendChild(aux);
  728.               aux.select();
  729.               document.execCommand("copy");
  730.         }
  731.         cargar_default();
  732.         
  733.         cargar_lista_cie10();
  734.         carga_letras(); 
  735.         
  736.         /*$( "#historia_clinica_new_evolucion" ).change(function() {
  737.             guardar();  
  738.         });
  739.         
  740.         $( "#historia_clinica_new_antecedentes_familiares" ).change(function() {
  741.             guardar();  
  742.         });
  743.         
  744.         
  745.         $( "#historia_clinica_new_presion" ).change(function() {
  746.             guardar();  
  747.         });*/
  748.         
  749.         $( "#historia_clinica_new_estatura" ).change(function() {
  750.             if(this.value != 0 && this.value != ''){
  751.                 var peso = $( "#historia_clinica_new_peso" ).val();
  752.                 if(peso != 0 && peso != ''){
  753.                     calcular_imc(peso,this.value);   
  754.                 }
  755.                 
  756.             }
  757.             //guardar();  
  758.             
  759.         });
  760.         
  761.         $( "#historia_clinica_new_peso" ).change(function() {
  762.             if(this.value != 0 && this.value != ''){
  763.                 var estatura = $( "#historia_clinica_new_estatura" ).val();
  764.                 if(estatura != 0 && estatura != ''){
  765.                     calcular_imc(this.value, estatura);   
  766.                 }
  767.                 
  768.             }
  769.             //guardar();  
  770.         });
  771.         
  772.         /*$( "#historia_clinica_new_mas_antecedentes_familiares" ).change(function() {
  773.             guardar();  
  774.         });
  775.         
  776.         $( "#historia_clinica_new_mas_antecedentes_personales" ).change(function() {
  777.             guardar();  
  778.         });
  779.         
  780.         
  781.         $( "#historia_clinica_new_antecedentes_quirurgicos" ).change(function() {
  782.             guardar();  
  783.         });
  784.         
  785.         $( "#historia_clinica_new_medicacion" ).change(function() {
  786.             guardar();  
  787.         });
  788.         
  789.         $( "#historia_clinica_new_alergias" ).change(function() {
  790.             guardar();  
  791.         });
  792.         
  793.         $( "#historia_clinica_new_alcohol" ).change(function() {
  794.             guardar();  
  795.         });
  796.         
  797.         $( "#historia_clinica_new_tabaco" ).change(function() {
  798.             guardar();  
  799.         });
  800.         
  801.         $( "#historia_clinica_new_drogas" ).change(function() {
  802.             guardar();  
  803.         });
  804.         
  805.         $( "#historia_clinica_new_examen_fisico" ).change(function() {
  806.             guardar();  
  807.         });
  808.         
  809.         $( "#historia_clinica_new_indicaciones" ).change(function() {
  810.             guardar();  
  811.         });
  812.         
  813.         $( "#historia_clinica_new_motivo" ).change(function() {
  814.             guardar();  
  815.         });
  816.         
  817.         $( "#historia_clinica_new_revision_actual_organos_y_sistemas" ).change(function() {
  818.             guardar();  
  819.         });
  820.         
  821.         $( "#historia_clinica_new_observacion_paciente" ).change(function() {
  822.             guardar();  
  823.         });*/
  824.         $('#historia_form').on('change', 'input, textarea, select', function () {
  825.             guardar();
  826.         });
  827.         
  828.         function guardar(){
  829.             $.ajax({  
  830.                 url:        '{{path("historia_clinica_edit_ajax_new",{"id": historia_clinica.getId()})}}',  
  831.                 type:       'POST', 
  832.                 data:       $('#historia_form').serialize(),   
  833.                 //dataType:   'json',  
  834.                 async:      true,  
  835.                 success: function(data, status, xhr) {
  836.                     console.log(data);
  837.                     console.log(xhr);
  838.                     console.log(status);
  839.                     if(data.estado == 'ok'){
  840.                         $('#div_fade').fadeIn(1000);
  841.                         $('#div_fade').fadeOut(1000);    
  842.                     }else{
  843.                         //alert("No guardo, informar");
  844.                         $('#div_fade_error').fadeIn(1000).fadeOut(10000, function() {
  845.                             location.reload();
  846.                         });
  847.                         
  848.                     }
  849.                     
  850.                 },  
  851.                 error : function(xhr, textStatus, errorThrown) { 
  852.                     console.log(xhr);
  853.                     console.log(textStatus);
  854.                     console.log(errorThrown);
  855.                     if (xhr.status === 302) {
  856.                         // Obtener la URL de la redirección (generalmente es la página de login)
  857.                         $('#div_fade_sesion').fadeIn(1000);
  858.                         $('#div_fade_sesion').fadeOut(10000);
  859.                         
  860.                         // Redirigir manualmente al login
  861.                         //window.location.href = redirectUrl;
  862.                     }
  863.                     
  864.                     //alert('Ajax request failed.');  
  865.                 }  
  866.             });     
  867.         }
  868.         $( "#historia_clinica_cardio_ritmo" ).change(function() {
  869.             cardio_store();  
  870.         });
  871.         $( "#historia_clinica_cardio_frecuencia" ).change(function() {
  872.             cardio_store();  
  873.         });
  874.         $( "#historia_clinica_cardio_intervalos" ).change(function() {
  875.             cardio_store();  
  876.         });
  877.         $( "#historia_clinica_cardio_segmento_st" ).change(function() {
  878.             cardio_store();  
  879.         });
  880.         $( "#historia_clinica_cardio_eje_electrico" ).change(function() {
  881.             cardio_store();  
  882.         });
  883.         $( "#historia_clinica_cardio_imp_diagnostica_ekg" ).change(function() {
  884.             cardio_store();  
  885.         });
  886.         $( "#historia_clinica_cardio_conclusion" ).change(function() {
  887.             cardio_store();  
  888.         });
  889.         $( "#historia_clinica_cardio_riesgo" ).change(function() {
  890.             cardio_store();  
  891.         });
  892.         $( "#historia_clinica_cardio_recomendaciones" ).change(function() {
  893.             cardio_store();  
  894.         });
  895.         function cardio_store(){
  896.             $.ajax({  
  897.                 url:        '{{path("historia_clinica_store_cardio",{"id": historia_clinica.getId()})}}',  
  898.                 type:       'POST', 
  899.                 data:       $('#cardio_form').serialize(),   
  900.                 //dataType:   'json',  
  901.                 async:      true,  
  902.                 success: function(data, status) { 
  903.                     $('#div_fade').fadeIn(1000);
  904.                     $('#div_fade').fadeOut(1000);
  905.                 },  
  906.                 error : function(xhr, textStatus, errorThrown) { 
  907.                     console.log(xhr);
  908.                     alert('Ajax request failed.');  
  909.                 }  
  910.             });     
  911.         }
  912.     
  913.         function calcular_imc(peso, estatura){
  914.             var estatura = estatura / 100 ;
  915.             var imc = peso / ( estatura * estatura );
  916.             //console.log(peso,estatura,imc);
  917.             imc = Math.round(imc * 100)/100;
  918.             var txt_imc = tabla_imc(imc);
  919.             $('#imc').text(imc + ': ' + txt_imc);
  920.         }
  921.         function tabla_imc(imc){
  922.             
  923.             if(imc < 18.5){
  924.                 return "Bajo Peso";
  925.             }else if(imc < 24.99){
  926.                 return "Normal";
  927.             }else if(imc < 29.99){
  928.                 return "Sobrepeso";
  929.             }else if(imc < 34.99){
  930.                 return "Obesidad Tipo I";
  931.             }else if(imc < 39.99){
  932.                 return "Obesidad Tipo II";
  933.             }else {
  934.                 return "Obesidad Tipo III";
  935.             }
  936.         }
  937.         function atendido(){
  938.             var confirmar = confirm("Desea marcar como atendido al paciente");
  939.             
  940.             
  941.             if(confirmar){
  942.                 
  943.                 location.href = '{{path('historia_clinica_atendido',{id: historia_clinica.id})}}';
  944.                   
  945.             }
  946.         }
  947.         function antecedentes(){
  948.             $('#modal_ante').modal();
  949.             $.ajax({  
  950.                 url:        "{{path('historia_clinica_antecedente_edit',{'id': historia_clinica.getId()})}}",  
  951.                 type:       'GET', 
  952.                 //dataType:   'json',  
  953.                 async:      true,  
  954.                 success: function(data, status) { 
  955.                     $('#div_ante').empty().html(data);
  956.                     //$('#div_fade').fadeOut(1000);
  957.                 },  
  958.                 error : function(xhr, textStatus, errorThrown) { 
  959.                     console.log(xhr);
  960.                     alert('Ajax request failed.');  
  961.                 }  
  962.             });
  963.             
  964.         }
  965.         $('#diagnosticos_historia_clinica_cie10').autocomplete({
  966.             // serviceUrl: '/autosuggest/service/url',
  967.             serviceUrl: '{{ path('cie10_buscar_codigo') }}',
  968.             //lookup: countriesArray,
  969.             onSearchComplete: function (query, suggestions) {
  970.                 //console.log(suggestions);
  971.             }, 
  972.             onSelect: function(suggestion) {
  973.                 //console.log(suggestion);
  974.                 $('#diagnosticos_historia_clinica_descripcion').val(suggestion.data.trim());
  975.                 $('#diagnosticos_historia_clinica_cie10_id').val(suggestion.id);
  976.                 
  977.                 //alert(suggestion.data);  
  978.             },
  979.             
  980.         });
  981.         
  982.         $('#diagnosticos_historia_clinica_descripcion').autocomplete({
  983.             // serviceUrl: '/autosuggest/service/url',
  984.             serviceUrl: '{{ path('cie10_buscar_texto') }}',
  985.             //lookup: countriesArray,
  986.             onSearchComplete: function (query, suggestions) {
  987.                 //console.log(suggestions);
  988.             }, 
  989.             onSelect: function(suggestion) {
  990.                 //console.log(suggestion);
  991.                 $('#diagnosticos_historia_clinica_cie10').val(suggestion.data.trim());
  992.                 $('#diagnosticos_historia_clinica_cie10_id').val(suggestion.id);
  993.                 
  994.                 //alert(suggestion.data);  
  995.             },
  996.             
  997.         });
  998.         $( "#agregar_cie10" ).click(function() {
  999.             var cie10_id = $('#diagnosticos_historia_clinica_cie10_id').val()
  1000.             if(cie10_id!=''){
  1001.                 $.ajax({  
  1002.                     url:        '{{path("diagnosticos_historia_clinica_new_ajax",{'historiaclinica_id': historia_clinica.getId()})}}',  
  1003.                     type:       'POST', 
  1004.                     data:       $('#dx_form').serialize(),   
  1005.                     //dataType:   'json',  
  1006.                     async:      true,  
  1007.                     success: function(data, status) { 
  1008.                         cargar_lista_cie10();
  1009.                         $('#diagnosticos_historia_clinica_descripcion').val('');
  1010.                         $('#diagnosticos_historia_clinica_cie10_id').val('');
  1011.                         $('#diagnosticos_historia_clinica_cie10').val('');
  1012.                         //$('#div_fade').fadeIn(1000);
  1013.                         //$('#div_fade').fadeOut(1000);
  1014.                     },  
  1015.                     error : function(xhr, textStatus, errorThrown) { 
  1016.                         console.log(xhr);
  1017.                         alert('Ajax request failed.');  
  1018.                     }  
  1019.                 });     
  1020.             }else{
  1021.                 alert("Por favor ingresar diagnostico");
  1022.             }
  1023.         });
  1024.         function cargar_lista_cie10(){
  1025.             $.ajax({  
  1026.                 url:        '{{path("diagnosticos_historia_clinica_index_aj",{'historiaclinica_id': historia_clinica.getId()})}}',  
  1027.                 type:       'GET', 
  1028.                 //dataType:   'json',  
  1029.                 async:      true,  
  1030.                 success: function(data, status) { 
  1031.                     $('#div_lista_cie10').empty().html(data);
  1032.                     //$('#div_fade').fadeOut(1000);
  1033.                 },  
  1034.                 error : function(xhr, textStatus, errorThrown) { 
  1035.                     console.log(xhr);
  1036.                     alert('Ajax request failed.');  
  1037.                 }  
  1038.             });     
  1039.         }
  1040.         function eliminar(id){
  1041.             $.ajax({  
  1042.                 url:        '{{asset("index.php/diagnosticos_historia_clinica/eliminar")}}/'+id,  
  1043.                 type:       'GET', 
  1044.                 //dataType:   'json',  
  1045.                 async:      true,  
  1046.                 success: function(data, status) {
  1047.                     cargar_lista_cie10() 
  1048.                     //$('#div_lista_cie10').empty().html(data);
  1049.                     //$('#div_fade').fadeOut(1000);
  1050.                 },  
  1051.                 error : function(xhr, textStatus, errorThrown) { 
  1052.                     console.log(xhr);
  1053.                     alert('Ajax request failed.');  
  1054.                 }  
  1055.             });     
  1056.         }
  1057.         function cargar_default(){
  1058.             var txt_motivo = $('#historia_clinica_enfermedad_actual').text();
  1059.             {% if(historia_clinica.paciente.sexo) %}
  1060.             var sexo = 'MASCULINO';
  1061.             {% else %}
  1062.             var sexo = 'FEMENINO';
  1063.             {% endif %}
  1064.             if(txt_motivo==''){
  1065.                 txt_motivo = 'Paciente de sexo '+sexo+' de '+'{{historia_clinica.paciente.calculaedad()}} que acude al centro medico {{ empresa.nombrecorto }} por';
  1066.                 $('#historia_clinica_enfermedad_actual').text(txt_motivo);
  1067.             }
  1068.             
  1069.             /*var txt_examen = $('#historia_clinica_examen_fisico').text();
  1070.             if(txt_examen==''){
  1071.                 txt_examen = 'Cabeza: normocefalo, cabello de implantaciòn normal, mucosas hidratadas.\nFaringe: normal\nCuello: simetrico, no adenopatìas ni masas tiroideas.\nTorax: mecanica ventilatoria conservada, cs ps claros, rs cs normofoneticos\n y normoritmicos\nAbdomen: blando depresible, no doloroso a la palpacion en, ruidos hidroaereos\n conservados\nMiembros: simetricos, no edema.\nGenitales: normal.\nOtros:';
  1072.                 $('#historia_clinica_examen_fisico').text(txt_examen);
  1073.             }*/
  1074.             var txt_examen = $('#historia_clinica_new_examen_fisico').text();
  1075.             if(txt_examen==''){
  1076.                 //txt_examen = 'Otoscopia: \n\nRinoscopia: \n\nCavidad Oral: \n';
  1077.                 txt_examen = '';
  1078.                 $('#historia_clinica_new_examen_fisico').text(txt_examen);
  1079.             }
  1080.             
  1081.             /*var txtrevision = $('#historia_clinica_revision_actual_organos_y_sistemas').text();
  1082.             if(txtrevision==''){
  1083.                 txtrevision = 'Al momento paciente hemodinamicamente estable, orientado en tiempo y espacio, colaborador con el  interrogatorio de forma  activa, neurologico conservado, cardiorespiratorio  suficiente, glasgow 15/15. saturando 98% al ambiente, afebril.'
  1084.                 $('#historia_clinica_revision_actual_organos_y_sistemas').text(txtrevision);
  1085.             }*/
  1086.             /*var txtindicacion = $('#historia_clinica_indicaciones').text();
  1087.             if(txtindicacion==''){
  1088.                 txtindicacion = 'Medidas de bioseguridad e higiene personal.\nEjercicios fisicos.\nAsesoria nutricional.\nAnte cualquier alarma de sintomatologia de covid acudir al centro medico mas cercano y no automedicarse.\nSeguir el tratamiento establecido.';
  1089.                 $('#historia_clinica_indicaciones').text(txtindicacion);
  1090.             }*/
  1091.             
  1092.             var txt_motivo2 = $('#historia_clinica_evolucion').text();
  1093.             
  1094.             if(txt_motivo2==''){
  1095.                 txt_motivo2 = 'Paciente de sexo '+sexo+' de '+'{{historia_clinica.paciente.calculaedad()}} que acude al centro medico {{ empresa.nombrecorto }} por';
  1096.                 $('#historia_clinica_evolucion').text(txt_motivo2);
  1097.             }
  1098.             
  1099.         }
  1100.             
  1101.         $('#historia_clinica_enfermedad_actual').change(function(){
  1102.            //console.log(this);
  1103.         });
  1104.         function carga_letras(){
  1105.             
  1106.             {% set receta = historia_clinica.recetas.first %}
  1107.             {% if(receta!=null) %}
  1108.                 {% for detalle in receta.recetaDetalles %}
  1109.                     var letras = NumeroALetras('{{ detalle.cantidad }}','{{ detalle.id }}');
  1110.                     $('#rd{{ detalle.id }}').text(letras);
  1111.                     $('#rd1{{ detalle.id }}').text(letras);    
  1112.                 {% endfor %}    
  1113.             {% endif %}
  1114.         }
  1115.         
  1116.         function suspender_agenda_form(){
  1117.             var confirmar = confirm("Desea Suspender esta agenda");
  1118.             if(confirmar){
  1119.                 var observacion = $('#agenda_type_edit_observacion').val();
  1120.                 if(observacion==''){
  1121.                     alert("Por favor ingrese motivo");
  1122.                 }else{
  1123.                     
  1124.                     $.ajax({  
  1125.                         url:        '{{path("historia_suspender",{'id': historia_clinica.agenda.id})}}',  
  1126.                         type:       'POST', 
  1127.                         data:       { },   
  1128.                         //dataType:   'json',  
  1129.                         //async:      true,  
  1130.                         processData: false,
  1131.                         contentType: false,
  1132.                         cache: false,
  1133.                        
  1134.                         success: function(data, status) { 
  1135.                             
  1136.                             alert("Agenda suspendida con Exito");
  1137.                             location.href = '{{path('historia_clinica_index')}}';
  1138.                             
  1139.                             
  1140.                             
  1141.                         },  
  1142.                         error : function(xhr, textStatus, errorThrown) { 
  1143.                             console.log(xhr);
  1144.                             alert('Ajax request failed.');  
  1145.                         }  
  1146.                     });     
  1147.                 }
  1148.             }
  1149.             
  1150.             
  1151.         }
  1152.         
  1153.         function guardar_imagen(){
  1154.             
  1155.             var form_data = new FormData();
  1156.            // Read selected files
  1157.            var totalfiles = document.getElementById('imagenes_estudio_imagen_jpg').files.length;
  1158.            //alert(totalfiles);
  1159.            for (var index = 0; index < totalfiles; index++) {
  1160.               form_data.append("files[]", document.getElementById('imagenes_estudio_imagen_jpg').files[index]);
  1161.            }
  1162.            console.log(form_data);
  1163.             
  1164.             //var archivo = $('#imagenes_estudio_imagen_jpg');
  1165.             //console.log(archivo.length);
  1166.                 $('#div_upload').show();
  1167.             /*if(archivo !=''){
  1168.                 $('#div_upload').show();
  1169.             }
  1170.            
  1171.             var formData = new FormData($('#imagen_form'));
  1172.             console.log(formData);*/
  1173.     
  1174.             $.ajax({  
  1175.                 url:        '{{path("hc_imagenes_estudio_new_ajax",{'id': historia_clinica.id})}}',  
  1176.                 type:       'POST', 
  1177.                 data:       form_data,   
  1178.                 //dataType:   'json',  
  1179.                 //async:      true,  
  1180.                 processData: false,
  1181.               contentType: false,
  1182.               cache: false,
  1183.                
  1184.                 success: function(data, status) { 
  1185.                     //console.log(data); 
  1186.                     $('#div_upload').hide();
  1187.                     $('#div_fade').fadeIn(1000);
  1188.                     $('#div_fade').fadeOut(1000);
  1189.                     //alert("Imagen Guardada con Exito");
  1190.                     location.reload();
  1191.                     
  1192.                     
  1193.                 },  
  1194.                 error : function(xhr, textStatus, errorThrown) { 
  1195.                     console.log(xhr);
  1196.                     alert('Ajax request failed.');  
  1197.                 }  
  1198.             }); 
  1199.         }
  1200.         
  1201.         function eliminar_imagen( id ){
  1202.             var confirmar = confirm("Desea eliminar la imagen");
  1203.             if(confirmar){
  1204.                 $.ajax({  
  1205.                     url:        '{{asset("index.php/imagenes_estudio/eliminar")}}/'+id,  
  1206.                     type:       'GET', 
  1207.                     //dataType:   'json',  
  1208.                     async:      true,  
  1209.                     success: function(data, status) {
  1210.                         
  1211.                         location.reload();
  1212.                     },  
  1213.                     error : function(xhr, textStatus, errorThrown) { 
  1214.                         console.log(xhr);
  1215.                         alert('Ajax request failed.');  
  1216.                     }  
  1217.                 });
  1218.             }
  1219.         }
  1220.         
  1221.         function eliminar_estudio(){
  1222.             {% if(estudio != null) %}
  1223.             var confirmar = confirm("Desea eliminar estudios");
  1224.             if(confirmar){
  1225.                 $.ajax({  
  1226.                     url:        '{{ asset("index.php/estudio/archivo/eliminar") }}/{{ estudio.id }}',  
  1227.                     type:       'GET', 
  1228.                     //dataType:   'json',  
  1229.                     async:      true,  
  1230.                     success: function(data, status) {
  1231.                         
  1232.                         location.reload();
  1233.                     },  
  1234.                     error : function(xhr, textStatus, errorThrown) { 
  1235.                         console.log(xhr);
  1236.                         alert('Ajax request failed.');  
  1237.                     }  
  1238.                 });
  1239.             }
  1240.             {% endif %}
  1241.         }
  1242.         
  1243.         function mostrar_tabla_imc(){
  1244.             $('#tabla_imc').show();
  1245.             $('#id_boton_minus').show();
  1246.             $('#id_boton_plus').hide();
  1247.         }
  1248.         function ocultar_tabla_imc(){
  1249.             $('#tabla_imc').hide();
  1250.             $('#id_boton_minus').hide();
  1251.             $('#id_boton_plus').show();
  1252.         }
  1253.         
  1254.         
  1255.         
  1256.     </script>
  1257. {% endblock %}