<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title><?= $titulo?></title>
	<?php
		$this->load->view('main/link');
		echo script_tag('js/modulos/xado.js?'.$_SESSION['app.gxc_sesion_version']);
		echo script_tag('js/modulos/xamo.js?'.$_SESSION['app.gxc_sesion_version']);
		echo script_tag('js/modulos/xaen.js?'.$_SESSION['app.gxc_sesion_version']);
		echo script_tag('js/modulos/xan.js?'.$_SESSION['app.gxc_sesion_version']);
	?>
	<style type="text/css">
		.tab-pane{
			padding-top: 10px;
		}
	</style>
	<script type="text/javascript">
		$(function () {
			var initl1 = 0;
			var initl2 = 0;
			var initl3 = 0;
			$('#txt_cantidad').numeric({allow:''});
			$('#txt_peso').numeric({allow:"."});
			$('#txt_talla').numeric({allow:"."});
			$('#txt_pabdominal').numeric({allow:"."});
			$('.date').datepicker({
                autoclose   : true,
                format      : 'dd/mm/yyyy'
            });
            $('#cbo_xdo').select2({
            	width				: '100%',
            	minimumInputLength 	: 3,
            	ajax 	: {
    				url 	: ruta + 'maestras/xdo/autocomplete',
    				dataType: 'json',
    				processResults: function (data) {
    					return {
                			results: data
            			};
    				}
  				}
            });
            $('#cbo_xmo').select2({
            	width				: '100%',
            	minimumInputLength 	: 3,
            	ajax 	: {
    				url 	: ruta + 'maestras/xmo/autocomplete',
    				dataType: 'json',
    				processResults: function (data) {
    					return {
                			results: data
            			};
    				}
  				}
            });
            $('#cbo_xen').select2({
            	width				: '100%',
            	minimumInputLength 	: 3
            });
            $('#myTab a').click(function (e) {
  				e.preventDefault();
  				$(this).tab('show');
  				if($(this).attr('href')=='#xado'){
  					//if(initl1==0){
  					//	initl1 = 1;
					//	fn_xado_pdiario_insertar_listar(1);
					//}
  				}else if($(this).attr('href')=='#xamo'){
  					if(initl2==0){
  						initl2 = 1;
  						fn_xamo_pdiario_insertar_listar(1);
  					}
  				}else if($(this).attr('href')=='#xaen'){
  					//if(initl3==0){
  					//	initl3 = 1;
  					//	fn_xaen_pdiario_insertar_listar(1);
  					//}
  				}
			});
            //fn_xado_pdiario_insertar_listar(1);
            //fn_xamo_pdiario_listar();
            //fn_xaen_pdiario_listar();
		});
	</script>
</head>
<body>
	<div class="container">
		<div class="panel panel-primary">
			<?= $cabecera?>
			<?= $menu?>
			<div class="panel-body" style="text-align: center;">
				<h3><b>NUEVA ATENCIÓN PARA [<?= $ds->hc_apenombres?>]</b></h3>
				<div class="btn-group">
  					<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  						<span class="glyphicon glyphicon-th-list"></span>
  					  	<b>H/C [ <?= str_pad($ds->hc_id, 6, '0', STR_PAD_LEFT)?> ]</b>
  					</button>
  					<ul class="dropdown-menu">
  					  	<li>
				  			<a href="javascript:fn_xhan_listar(1);"><b>Historial de Atenciones</b></a>
				  		</li>
  					  	<li role="separator" class="divider"></li>
  					  	<li>
				  			<a href="javascript:fn_xhan_listar(2);"><b>Historial de Atenciones (V1)</b></a>
				  		</li>
  					</ul>
				</div>
			</div>
			<div class="panel-body">
				<form id="form_xan" method="post" action="javascript:fn_xan_insertar();">
					<ul class="nav nav-tabs" id="myTab">
  						<li class="active"><a href="#datos" data-toggle="tab"><b>Datos generales</b></a></li>
  						<li><a href="#xado" data-toggle="tab"><b>Diagnósticos</b></a></li>
  						<li><a href="#xamo" data-toggle="tab"><b>Medicamentos</b></a></li>
  						<li><a href="#xaen" data-toggle="tab"><b>Exámenes</b></a></li>
					</ul>
					<!-- Tab panes -->
					<div class="tab-content">
					  	<div class="tab-pane active" id="datos" style="margin-top: 10px;">
					  		<div class="row">
								<div class="col-md-2">
									<div class="form-group">
										<label for="txt_fecha">Fecha: </label>
										<div class="input-group date">
											<input type="text" id="txt_fecha" name="txt_fecha" value="<?= date('d/m/Y')?>" readonly class="form-control" autocomplete="off">
											<span class="input-group-addon">
												<span class="glyphicon glyphicon-calendar"></span>
											</span>
										</div>
									</div>
								</div>
								<div class="col-md-2">
									<div class="form-group">
										<label for="txt_edad">Edad: </label>
										<input type="text" name="txt_edad" id="txt_edad" value="<?= $this->util->calcular_edad($ds->hc_fecha_nac)?>" class="form-control" readonly style="text-align: center;">
										<input type="hidden" name="txt_id" id="txt_id" value="0">
										<input type="hidden" name="txt_horai" id="txt_horai" value="<?= date('H:i:s')?>">
										<input type="hidden" name="txt_xhc" id="txt_xhc" value="<?= $ds->hc_id?>">
										<input type="hidden" name="txt_xca" id="txt_xca" value="<?= $ds->cit_id?>">
										<input type="hidden" name="txt_xpn" id="txt_xpn" value="<?= $ds->prog_id?>">
									</div>
								</div>
								<div class="col-md-2">
									<div class="form-group">
										<label for="txt_peso">Peso: </label>
										<input type="text" name="txt_peso" id="txt_peso" value="<?= $ds->hc_peso?>" onblur="fn_calcular_imc();" class="form-control" autocomplete="off" style="text-align: center;">
									</div>
								</div>
								<div class="col-md-2">
									<div class="form-group">
										<label for="txt_talla">Talla: </label>
										<input type="text" name="txt_talla" id="txt_talla" value="<?= $ds->hc_talla?>" onblur="fn_calcular_imc();" class="form-control" autocomplete="off" style="text-align: center;">
									</div>
								</div>
								<div class="col-md-2">
									<div class="form-group">
										<label for="txt_imc">IMC: </label>
										<input type="text" name="txt_imc" id="txt_imc" value="<?= $ds->hc_imc?>" class="form-control" style="text-align: center;" readonly>
									</div>
								</div>
								<div class="col-md-2">
									<div class="form-group">
										<label for="txt_pabdominal">Perimetro Abdominal: </label>
										<input type="text" name="txt_pabdominal" id="txt_pabdominal" value="<?= $ds->hc_pabdominal?>" class="form-control" style="text-align: center;" autocomplete="off">
									</div>
								</div>
					  		</div>
					  		<div class="row">
								<div class="col-sm-6">
									<label for="txt_anamnesis">Anamnesis: </label>
									<textarea name="txt_anamnesis" id="txt_anamnesis" class="form-control" style="height: 75px;"></textarea>
								</div>
								<div class="col-sm-6">
									<label for="txt_efisico">Exámen Físico: </label>
									<textarea name="txt_efisico" id="txt_efisico" class="form-control" style="height: 75px;"></textarea>
								</div>
							</div>
					  	</div>
					  	<div class="tab-pane" id="xado">
					  		<div class="row">
								<div class="col-md-12">
									<div class="form-group">
										<select name="cbo_xdo" id="cbo_xdo" class="form-control">
											<option value="0"> - BUSCAR DIAGNÓSTICO - </option>
										</select>
									</div>
									<button type="button" onclick="fn_xado_pdiario_insertar_listar(2);" class="btn btn-primary btn-xs">
										<span class="glyphicon glyphicon-plus"></span> <b>Agregar</b>
									</button>
								</div>
								<div class="col-md-12" style="margin-top: 10px;">
									<table id="xado_data" class="display table table-hover table-bordered table-condensed table-stripped responsive nowrap">
										<thead>
											<tr>
												<th>Códigos</th>
												<th>Descripción</th>
												<th>Acción</th>
											</tr>
										</thead>
										<tbody></tbody>
									</table>
								</div>
							</div>
					  	</div>
					  	<div class="tab-pane" id="xamo">
							<div class="row">
								<div class="col-md-12">
									<div class="form-group">
										<select name="cbo_xmo" id="cbo_xmo" class="form-control">
											<option value="0"> - BUSCAR MEDICAMENTO - </option>
										</select>
									</div>
								</div>
								<div class="col-md-12">
									<div class="row">
										<div class="col-md-2">
											<div class="form-group">
												<label for="txt_cantidad">Cantidad</label>
												<input type="text" name="txt_cantidad" id="txt_cantidad" class="form-control" autocomplete="off">
											</div>
										</div>
										<div class="col-md-6">
											<div class="form-group">
												<label for="txt_indicacion">Indicaciones</label>
												<textarea id="txt_indicacion" name="txt_indicacion" class="form-control" placeholder="Indicaciones"></textarea>
											</div>
										</div>
									</div>
								</div>
								<div class="col-md-12" style="margin-top: 10px;">
									<button type="button" onclick="fn_xamo_pdiario_insertar_listar(2);" class="btn btn-primary btn-xs">
										<span class="glyphicon glyphicon-plus"></span> <b>Agregar</b>
									</button>
									<br><br>
									<table id="xamo_data" class="display table table-hover table-bordered table-condensed table-stripped responsive nowrap">
										<thead>
											<tr>
												<th>Descripción</th>
												<th>Cantidad</th>
												<th>Indicación</th>
												<th>Acción</th>
											</tr>
										</thead>
										<tbody></tbody>
									</table>
								</div>
							</div>
					  	</div>
					  	<div class="tab-pane" id="xaen">
					  		<div class="row">
								<div class="col-md-12">
									<div class="form-group">
										<select name="cbo_xen" id="cbo_xen" class="form-control">
											<?= $xen?>
										</select>
									</div>
									<div class="form-group">
										<label for="txt_indicacione">Indicaciones</label>
										<textarea id="txt_indicacione" name="txt_indicacione" class="form-control" placeholder="Indicaciones"></textarea>
									</div>
									<button type="button" onclick="fn_xaen_pdiario_insertar_listar(2);" class="btn btn-primary btn-xs">
										<span class="glyphicon glyphicon-plus"></span> <b>Agregar</b>
									</button>
								</div>
								<div class="col-md-12" style="margin-top: 10px;">
									<table id="xaen_data" class="display table table-hover table-bordered table-condensed table-stripped responsive nowrap">
										<thead>
											<tr>
												<th>Descripción</th>
												<th>Indicación</th>
												<th>Acción</th>
											</tr>
										</thead>
										<tbody></tbody>
									</table>
								</div>
							</div>
					  	</div>
					</div>
					<br>
					<button type="submit" class="btn btn-primary">
						<span class="glyphicon glyphicon-floppy-disk"></span>
						 <b>Grabar</b>
      				</button>
      				<a href="<?= base_url('movimientos/xan/pdiario')?>" class="btn btn-default">
      					<span class="glyphicon glyphicon-remove"></span>
      					 <b>Cancelar</b>
      				</a>
				</form>
			</div>
			<div class="panel-body">
				<table id="xpn_data" class="display table table-bordered table-hover table-stripped responsive nowrap">
				</table>
			</div>
			<?= $pie?>
		</div>
	</div>
</body>
</html>
<div id="histo" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
	
</div>