{% extends 'base.html.twig' %}
{% block title %}HistoriaClinica index{% endblock %}
{% block body %}
<h3>Atención Médica</h3>
<div class="col-md-12">
{{ include('preparacion/buscar_pac.html.twig', {'button_label': 'Buscar'}) }}
</div>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>No</th>
<th>{{ knp_pagination_sortable(agendas, 'Hora', 'a.inicio') }}</th>
<th>{{ knp_pagination_sortable(agendas, 'Paciente', 'paciente') }}</th>
<th>{{ knp_pagination_sortable(agendas, 'Doctor/Enfer.', 'doctor') }}</th>
<th>{{ knp_pagination_sortable(agendas, 'Sala', 'sala') }}</th>
<th>{{ knp_pagination_sortable(agendas, 'Tipo', 'procedimiento') }}</th>
<th>Estado</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<tbody>{% set cont = 1 %}
{% for agenda in agendas %}
{% set pxs = agenda.agenda.getAgendaProcedimientos() %}
<tr>
<td>{{ page + cont }}</td>
<td>{{ agenda.inicio|date('Y-m-d') }}<br>{{ agenda.inicio|date('H:i:s') }}</td>
<td>{{ agenda.paciente}}<input type="hidden" id="pac{{ agenda.agenda.id }}" value="{{ agenda.paciente}}"></td>
<td>{{ agenda.doctor}} </td>
<td>{{ agenda.sala }}<br>{{ agenda.agenda.sala.unidad.nombre }}</td>
<td>{{ agenda.procedimiento }}<br>{% for px in pxs %} {{ px.procedimiento.nombre }}<br> {% endfor %}{{ agenda.agenda.especialidad.nombre }}</td>
<!--td>{{ agenda.procedimiento }}<br></td-->
<td>
{% if(agenda.agenda.preparacion==null)%}
<label class="badge bg-danger">PENDIENTE<br>PREPARACION</label>
{% else%}
{% if(agenda.agenda.preparacion.estado==1)%}
<label class="badge bg-danger">PASE<br>PREPARACION</label>
{% elseif(agenda.agenda.preparacion.estado==2)%}
{% if(agenda.agenda.historiaClinica==null)%}
<label class="badge bg-danger">ATENCION</label>
{% else %}
{% if(agenda.agenda.historiaClinica.estado==1)%}
<label class="badge bg-warning">PASAR<br></label>
{% else %}
<label class="badge bg-success">ATENDIDO</label>
{% endif %}
{% endif %}
{% endif%}
{% endif%}
</td>
<td>
{% if(agenda.agenda.preparacion==null)%}
{% else%}
{% if(agenda.agenda.preparacion.estado==2)%}
{% if(agenda.agenda.historiaclinica==null)%}
<a class="btn btn-outline-danger btn-fw btn-sm" href="javascript:pasar_doctor({{agenda.agenda.id}})">{{ agenda.agenda.procedimiento.nombre }}</a>
{% else %}
{% if(agenda.agenda.historiaclinica.estado>0)%}
{% if(agenda.agenda.sala.unidad.nombre == 'PROCEDIMIENTOS ENDOSCOPICOS') %}
<a class="btn btn-outline-warning btn-fw btn-sm" href="{{ path('estudio_nuevo_unico', {'id_historia': agenda.agenda.historiaClinica.id}) }}">{{ agenda.agenda.procedimiento.nombre }}</a>
{% else %}
<a class="btn btn-outline-warning btn-fw btn-sm" href="{{ path('historia_clinica_edit_new', {'id': agenda.agenda.historiaClinica.id}) }}">{{ agenda.agenda.procedimiento.nombre }}</a>
{% endif %}
{% endif %}
{% endif %}
{% endif%}
{% endif%}
</td>
</tr>{% set cont = cont + 1 %}
{% else %}
<tr>
<td colspan="16">no records found</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{# display navigation #}
<div class="navigation">
{{ knp_pagination_render(agendas,'', {'inicio': inicio, 'fin': fin}) }}
</div>
<script type="text/javascript">
function pasar_doctor(id){
var paciente = $('#pac'+id).val()
//var confirmar = confirm("Desea Pasar a Consulta al paciente: "+paciente);
var confirmar = true;
if(confirmar){
$.ajax({
url: '{{asset("index.php/historiaclinica/historiaclinica/new")}}/'+id,
type: 'GET',
dataType: 'json',
async: true,
success: function(data, status) {
if(data.estado == 'ok'){
location.href = '{{asset("index.php/historiaclinica")}}/'+data.historiaclinica+'/edit/new';
}else{
location.reload();
}
},
error : function(xhr, textStatus, errorThrown) {
console.log(xhr, textStatus, errorThrown);
alert('Ajax request failed.');
}
});
}
}
</script>
{% endblock %}