<html>
 <head><meta http-equiv="Content-Type" content="text/html; charset=gb18030">
   <style>
      input[type="checkbox"]{
      border: 5px solid #3498db;
      width: 13px;
      height: 13px;
      margin: 0 2px 0 0;
    }
    label {
      width: 25%;
       float: left;
       font-famyli:Arial;
       font-size:12px;
       color:#3498db;
    }
   </style>

   <script type="text/javascript">
    function confirmation() {
      if(confirm("Esta seguro de eliminar el Diagnostico?"))
      {
         return true;
      }
      return false;
     }

    function confirmation1() {
      if(confirm("Esta seguro de eliminar el Procedimiento?"))
      {
         return true;
      }
      return false;
     }

    function Suma(isChecked, myValue)
    {
      tot = parseInt(document.form1.numSupPlaca.value);
      //alert (tot);
      myValue = parseInt(myValue);
       //alert (myValue);
      if (isChecked.checked) document.form1.numSupPlaca.value = tot + myValue;
      else document.form1.numSupPlaca.value = tot - myValue;

      tot1 = document.form1.numSupPlaca.value / 128;
      document.form1.indicePlaca.value = tot1*100;
    }
   </script>

   <script src="js/ajax.js"></script> 
   <script src="js/cups.js"></script>  
   <script src="js/cups1.js"></script>   

   <script>
     function check1(box) {
       if (box.checked) {
         document.getElementById("chkDgs").checked=false
       }
      }
      function check2(box) {
        if (box.checked) {
           document.getElementById("chkCups").checked=false 
         }
      }
    </script>
 </head>

<?php

 function cuantosRe($tabla, $consulta, $historia)
 { 
   //conexion a la base de datos
   include("conexionOdo.php");
   $query = " SELECT COUNT(*) as cuantos FROM $tabla WHERE numTratamiento = $consulta ";//numConsulta = $consulta AND tipoHistoria='$historia' "; 
    //echo $query;
   $result = mysql_query($query) or die('Consulta de cantidad $tabla: ' . mysql_error());
   $line = mysql_fetch_array($result, MYSQL_ASSOC);
          
   $ct = $line["cuantos"];
          
   // Liberar resultados
   mysql_free_result($result);
   // Cerrar la conexion
   //mysql_close($link);
            
   return $ct;  
 } 

 include("header.php");
 include("select.php");
 include("conexionOdo.php");  

  $activeBoton = "S";
 
  session_start();    
  $s_nitEmpresa = $_SESSION['nitEmpresa']; 
  $s_codSede    = $_SESSION['codSede'];
  $s_usuario    = $_SESSION['nombreUsuario'];
  $s_empresa    = $_SESSION['empresaUsuario'];
  $s_cargo      = $_SESSION['cargoUsuario'];
  $s_idUsuario  = $_SESSION['idUsuario']; 
  
  // tipo Consulta
  $s_tipoCon    = $_SESSION['s_tipoCon']; 
  // causa de consulta
  $s_codCausa   =  $_SESSION['s_codCausa'];
  //Tipo Entidad
  $s_codEntidad = $_SESSION['s_codEntidad'];
 
  //paciente
  $e_tipoId     = $_SESSION['e_tipoId'];
  $e_idPaciente = $_SESSION['e_identifica'];
   
  $w_fecha          = date("Y-m-d",time()); 
  
  //Definicion de variables de entrada
  $par    =  $_GET['lin'];
  $par1   =  base64_decode($par);
  $partir = explode("/",$par1);
   
  $s_tipoHistoria   = $partir[0];

  $viene            = $partir[1];
  //$s_yaGrabo      = $partir[2];
  //$_SESSION['s_pc'] = $partir[3];
  $pc               = $_SESSION['s_pc'];
  $e_tratamiento    = $partir[4];
  
  $s_numSupPlaca =0;
  $s_indicePlaca=0;

  session_start();
  $pc               = $_SESSION['s_pc'];
  $e_tratamiento    = $_SESSION['s_tra'];
  
 ///// TRAE NUMERO DE CONSULTA Y DE TRATAMIENTO
 if ($e_tratamiento>0)

 {
   $query = "SELECT *  FROM SIO_TRAT_CON WHERE tratamiento=$e_tratamiento ";
   $result = mysql_query($query) or die('Consulta de tratamiento consulta fallida: ' . mysql_error());
   $line = mysql_fetch_array($result, MYSQL_ASSOC);
   
   $t_numConsulta   = $line['numConsulta'];


   $t_numConsulta = $pc;

   $nConsulta       = $t_numConsulta;
   $e_nvoNroCon     = $t_numConsulta;
   $t_estado        = $line['estado'];
   $t_fechaCreacion = $line['fechaCreacion'];

   if ($t_numConsulta>0)
   {
      $s_yaGrabo="S";
   } 
 }//pc>0 

 //$nConsulta=999;
 //$e_nvoNroCon=999; 
 //$s_yaGrabo=="S";
  $s_tipoHistoria="TRATAMIENTO";


 // TRAE DATOS DEL PACIENTE
 $query = "SELECT * FROM SIME_BAS_PACIENTE WHERE tipoId='$e_tipoId ' AND idPaciente=$e_idPaciente ";
 $result = mysql_query($query) or die('Consulta de paciente fallida: ' . mysql_error());
 $line = mysql_fetch_array($result, MYSQL_ASSOC);
  
 $s_sexo            = $line["sexoPaciente"];
 $s_apell1Paciente  = $line["apell1Paciente"];   
 $s_apell2Paciente  = $line["apell2Paciente"]; 
 $s_nomPaciente     = $line["nomPaciente"];  
 $s_nomPaciente2    = $line["nomPaciente2"]; 
 $s_edadPaciente    = $line["edadPaciente"];
 $w_rhPac           = $line["RH"];

 $w_nomPac = $s_nomPaciente . ' ' . $s_nomPaciente2 . ' ' . $s_apell1Paciente . ' ' .  $s_apell2Paciente;

  $s_apell1Paciente   = $line["apell1Paciente"]; 
  $s_apell2Paciente   = $line["apell2Paciente"]; 
  $s_nomPaciente      = $line["nomPaciente"]; 
  $s_nomPaciente2     = $line["nomPaciente2"]; 
  $s_fecNacimiento    = $line["fecNacimiento"]; 
  $fecha_de_nacimiento = $line["fecNacimiento"]; 
  $s_lugarNacimiento  = $line["lugarNacimiento"]; 
  $s_edadPaciente     = $line["edadPaciente"]; 
  $s_sexoPaciente     = $line["sexoPaciente"]; 
  $s_estCivil         = $line["estCivil"]; 
  $s_escolaridad      = $line["escolaridad"]; 
  $s_tipoVinculacion  = $line["tipoVinculacion"]; 
  $s_depResidencia    = $line["depResidencia"]; 
  $s_ciuResidencia    = $line["ciuResidencia"]; 
  $s_dirResidencia    = $line["dirResidencia"]; 
  $s_telResidencia    = $line["telResidencia"]; 
  $s_email            = $line["email"]; 
  $s_famResponsable   = $line["famResponsable"]; 
  $s_rh               = $line["RH"]; 
      
  $s_UNO = str_replace(" ","%20",$s_famResponsable);
  $s_DOS = urlencode($s_famResponsable);
  $s_TRES = urldecode($s_DOS);
  $s_CUATRO = str_replace(" ","%20",$s_famResponsable);
       
  $s_parentesco       = $line["parentesco"]; 
  $s_telPariente      = $line["telPariente"]; 
  $s_ubicacion        = $line["ubicacion"];
     
  $s_rango            = $line["rango"];
  $s_tipoUsuario      = $line["tipoUsuario"];
   
  if ($i == 0)
  {
   $existe="N";
   $menPac = "EL PACIENTE NO EXISTE, DEBE CREARLO ANTES DE REALIZAR CUALQUIER TRANSACCION";
  }
  else
  {
    $menPac = "PARA MODIFICAR LOS DATOS DEL PACIENTE  TOQUE LA OPCION 'GRABAR'";
  }
  
  // Liberar resultados
  mysql_free_result($result);
  
  //tipo de identificacion
   if ($s_tipoId == "CC"){$iDcc="selected";}
   if ($s_tipoId == "TI"){$iDti="selected";}
   if ($s_tipoId == "PP"){$iDpp="selected";}
   if ($s_tipoId == "CE"){$iDce="selected";}
   if ($s_tipoId == "RC"){$iDrc="selected";}
 
   //sexo paciente
   if ($s_sexoPaciente == "M")
   {$sxM = "selected";}
   if ($s_sexoPaciente == "F"){$sxF = "selected";}
   if ($s_sexoPaciente == "N"){$sxN = "selected";}//NI&ntilde;O
   if ($s_sexoPaciente == "A"){$sxN = "selected";}//NI&ntilde;A
   
   //estado civil
   if ($s_estCivil== "S"){$ecS="selected";}
   if ($s_estCivil== "C"){$ecC="selected";}
   if ($s_estCivil== "U"){$ecU="selected";}
   if ($s_estCivil== "D"){$ecD="selected";} 
   if ($s_estCivil== "V"){$ecV="selected";}
  
   //vinculacion   
   if ($s_tipoVinculacion == "C"){$tvC ="selected";}
   if ($s_tipoVinculacion == "B"){$tvB ="selected";}
   if ($s_tipoVinculacion == "P"){$tvP ="selected";}
   if ($s_tipoVinculacion == "O"){$tvO ="selected";}
  
   //rango
   if ($s_rango == 1){$rangoU ="selected";}
   if ($s_rango == 2){$rangoD ="selected";}
   if ($s_rango == 3){$rangoT ="selected";}

   //tipoUsuario
   if ($s_tipoUsuario == 1){$tipoUc ="selected";}
   if ($s_tipoUsuario == 2){$tipoUs ="selected";}
   if ($s_tipoUsuario == 3){$tipoUv ="selected";}
   if ($s_tipoUsuario == 4){$tipoUp ="selected";}
   if ($s_tipoUsuario == 5){$tipoUo ="selected";}

   //escolaridad 
   if ($s_escolaridad == "P"){$esP ="selected";}
   if ($s_escolaridad == "B"){$esB ="selected";}
   if ($s_escolaridad == "T"){$esT ="selected";}
   if ($s_escolaridad == "G"){$esG ="selected";}
   if ($s_escolaridad == "U"){$esU ="selected";}
   if ($s_escolaridad == "E"){$esE ="selected";}

   //ubicacion
   if ($s_ubicacion == "U"){$ubU ="selected";}
   if ($s_ubicacion == "R"){$ubR ="selected";}


/////////// calcula la edad del paciente
if ($fecha_de_nacimiento!="")
{ 
  $fecha_actual = date ("Y-m-d"); 

  //echo "<br>Hoy es $fecha_actual"; 
  //echo "<br>Naciste el $fecha_de_nacimiento"; 

  // separamos en partes las fechas 
  $array_nacimiento = explode ( "-", $fecha_de_nacimiento ); 
  $array_actual = explode ( "-", $fecha_actual ); 

  $anos =  $array_actual[0] - $array_nacimiento[0]; // calculamos años 
  $meses = $array_actual[1] - $array_nacimiento[1]; // calculamos meses 
  $dias =  $array_actual[2] - $array_nacimiento[2]; // calculamos días 

  //ajuste de posible negativo en $días 
  if ($dias < 0) 
  { 
    --$meses; 
    
    //ahora hay que sumar a $dias los dias que tiene el mes anterior de la fecha actual 
    switch ($array_actual[1]) { 
           case 1:     $dias_mes_anterior=31; break; 
           case 2:     $dias_mes_anterior=31; break; 
           case 3:  
                if (bisiesto($array_actual[0])) 
                { 
                    $dias_mes_anterior=29; break; 
                } else { 
                    $dias_mes_anterior=28; break; 
                } 
           case 4:     $dias_mes_anterior=31; break; 
           case 5:     $dias_mes_anterior=30; break; 
           case 6:     $dias_mes_anterior=31; break; 
           case 7:     $dias_mes_anterior=30; break; 
           case 8:     $dias_mes_anterior=31; break; 
           case 9:     $dias_mes_anterior=31; break; 
           case 10:    $dias_mes_anterior=30; break; 
           case 11:    $dias_mes_anterior=31; break; 
           case 12:    $dias_mes_anterior=30; break; 
    } 

    $dias=$dias + $dias_mes_anterior; 
  } 

  //ajuste de posible negativo en $meses 
  if ($meses < 0) 
  { 
    --$anos; 
    $meses=$meses + 12; 
  } 

  if ($meses == 1) 
  { 
    $txtMes = 'mes'; 
  } 
  else
  {
     $txtMes = 'meses';  
  }

}//fecha diferente de vacio
//echo "<br>Tu edad es: $anos años con $meses $txtMes y $dias días"; 

function bisiesto($anio_actual){ 
    $bisiesto=false; 
    //probamos si el mes de febrero del año actual tiene 29 días 
      if (checkdate(2,29,$anio_actual)) 
      { 
        $bisiesto=true; 
    } 
    return $bisiesto; 
} 
   


 
   

 
 /*-----ALERGIAS----*/
 $queryAlerg="SELECT alergias FROM SIO_ALERGIAS WHERE tipoId= '$e_tipoId ' AND numeroId=$e_idPaciente ";
 $resultAlerg = mysql_query($queryAlerg) or die('Consulta de existencia de alergias fallida: ' . mysql_error());   
 $lineAlerg = mysql_fetch_array($resultAlerg, MYSQL_ASSOC);
 $s_alergias = $lineAlerg['alergias'];
 // Liberar resultados
 mysql_free_result($resultAlerg);
 /*-----FIN ALERGIAS----*/   

 //CARGA VARIABLES DE  LAS TABLAS CUANDO YA S HA CREADO LA HISTORIA -- GENERAL --
 /* ============================================================================================================================
 ============================================================================================================================*/

 if ($nConsulta>0)
 { 
   
  // VARIABLES SITUACION ACTUAL
  $query = "SELECT * FROM SIO_SIT_ACTUAL WHERE numtratamiento = $e_tratamiento";//numConsulta= $nConsulta" ;

  $result = mysql_query($query) or die('Consulta  de Situacion Actual fallida: ' . mysql_error());
  $line = mysql_fetch_array($result, MYSQL_ASSOC);

  $s_motConsulta = $line['motivoConsulta'];
  $s_enfActual   = $line['enfermedadActual']; 
  $s_antFam      = $line['antFamiliares'];

  //VARIABLES ANTECEDENTES ODONTOLOGICOS
  ////////////////////////////////////////////////////////////
  $query = "SELECT * FROM SIO_ANT_ODYMED WHERE numtratamiento = $e_tratamiento";//numConsulta= $nConsulta" ;
  $result = mysql_query($query) or die('Consulta  de Antecedentes fallida: ' . mysql_error());
  $line = mysql_fetch_array($result, MYSQL_ASSOC);
   /*
    $s_alergias          = $line['alergias'];
    if ($s_alergias =="" OR $s_alergias =="N")
    {
      $s_alergias = "N";
    }
    else
    {    
      $chkAlergia = "checked";
    }
    $s_obsAlergia       = $line['obsAlergias'];*/

    //-------------------------------------------------------//
    $s_discrasiasSang    = $line['discrasiasSang'];
    if ($s_discrasiasSang =="N" OR $s_discrasiasSang =="")
    {
      $s_discrasiasSang = "N";
    }
    else
    {    
      $chkDiscrasias = "checked";
    }
    $s_obsDiscrasiasSang= $line['obsDiscrasiasSang'];
    //-------------------------------------------------------//
    $s_cardiopatias      = $line['cardiopatias'];
    if ($s_cardiopatias =="N" OR $s_cardiopatias =="")
    {
      $s_cardiopatias = "N";
    }
    else
    {    
      $chkCardio = "checked";
    }
    $s_obsCardiopatias  = $line['obsCardiopatias'];
    //-------------------------------------------------------//
    $s_embarazo          = $line['embarazo'];
    if ($s_embarazo =="N" OR $s_embarazo =="")
    {
      $s_embarazo = "N";
    }
    else
    {    
      $chkEmbarazo = "checked";
    }
    $s_obsEmbarazo = $line['obsEmbarazo'];
    //-------------------------------------------------------//
    $s_altPresArterial   = $line['altPresArterial'];
    if ($s_altPresArterial =="N" OR $s_altPresArterial =="")
    {
      $s_altPresArterial = "N";
    }
    else
    {
      $chkPresArt = "checked";
    }
    $s_obsAltPresArterial = $line['obsAltPresArterial'];
    //-------------------------------------------------------//
    $s_tomaMedicamentos  = $line['tomaMedicamentos'];
    if ($s_tomaMedicamentos =="N" OR $s_tomaMedicamentos =="")
    {
      $s_tomaMedicamentos = "N";
    }
    else
    {    
      $chkTomaMedicamentos = "checked";
    }
    $s_obsTomaMedicamentos = $line['obsTomaMedicamentos'];
    //-------------------------------------------------------//
    $s_tratMedActual     = $line['tratMedActual'];
    if ($s_tratMedActual =="N" OR $s_tratMedActual =="")
    {
      $s_tratMedActual = "N";
    }
    else
    {    
      $chkTratMedActual = "checked";
    }
    $s_obsTratMedActual= $line['obsTratMedActual'];
    //-------------------------------------------------------//
    $s_hepatitis         = $line['hepatitis'];
    if ($s_hepatitis =="N" OR $s_hepatitis =="")
    {
      $s_hepatitis = "N";
    }
    else
    {    
      $chkHepatitis = "checked";
    }
    $s_obsHepatitis = $line['obsHepatitis'];
    //-------------------------------------------------------//
    $s_diabetes          = $line['diabetes'];
    if ($s_diabetes =="N" OR $s_diabetes =="")
    {
      $s_diabetes = "N";
    }
    else
    {    
      $chkDiabetes = "checked";
    }
    $s_obsDiabetes = $line['obsDiabetes'];
    //-------------------------------------------------------//
    $s_fiebreReum        = $line['fiebreReum'];
    if ($s_fiebreReum =="N" OR $s_fiebreReum =="")
    {
      $s_fiebreReum = "N";
    }
    else
    {    
     $chkFiebreReum = "checked";
    }
    $s_obsFiebreReum = $line['obsFiebreReum'];
    //-------------------------------------------------------//
    $s_sida              = $line['sida'];
    if ($s_sida =="N" OR $s_sida =="")
    {
      $s_sida = "N";
    }
    else
    {    
      $chkSida = "checked";
    }
    $s_obsSida = $line['obsSida'];
    //-------------------------------------------------------//
    $s_inmunosupresion   = $line['inmunosupresion'];
    if ($s_inmunosupresion =="N" OR $s_inmunosupresion =="")
    {
      $s_inmunosupresion = "N";
    }
    else
    {    
      $chkInmuno = "checked";
    }
    $s_obsInmunosupresion = $line['obsInmunosupresion'];
    //-------------------------------------------------------//
    $s_patologiasRenales = $line['patologiasRenales'];
    if ($s_patologiasRenales =="N" OR $s_patologiasRenales =="")
    {
      $s_patologiasRenales = "N";
    }
    else
    {    
      $chkPatRenal = "checked";
    }
    $s_obsPatologiasRenales = $line['obsPatologiasRenales'];
    //-------------------------------------------------------//
    $s_patRespiratoria   = $line['patRespiratoria'];
    if ($s_patRespiratoria =="N" OR $s_patRespiratoria =="")
    {
      $s_patRespiratoria = "N";
    }
    else
    {    
      $chkPatResp = "checked";
    }
    $s_obsPatRespiratoria = $line['obsPatRespiratoria'];
    //-------------------------------------------------------//
    $s_trasGastricos     = $line['trasGastricos'];
    if ($s_trasGastricos =="N" OR $s_trasGastricos =="")
    {
     $s_trasGastricos = "N";
    }
    else
    {    
     $chkTrasGastricos = "checked";
    }
    $s_obsTrasGastricos = $line['obsTrasGastricos'];
    //-------------------------------------------------------//
    $s_trasEmocional     = $line['trasEmocional'];
    if ($s_trasEmocional =="N" OR $s_trasEmocional =="")
    {
      $s_trasEmocional = "N";
    }
    else
    {    
      $chktTrasEmocional = "checked";
    }
    $s_obsTrasEmocional = $line['obsTrasEmocional'];
    //-------------------------------------------------------//
    $s_sinusitis         = $line['sinusitis'];
    if ($s_sinusitis =="N" OR $s_sinusitis =="")
    {
      $s_sinusitis = "N";
    }
    else
    {    
      $chkSinusitis = "checked";
    }
    $s_obsSinusitis= $line['obsSinusitis'];
    //-------------------------------------------------------//
    $s_cirugias          = $line['cirugias'];
    if ($s_cirugias =="N" OR $s_cirugias =="")
    {
      $s_cirugias = "N";
    }
    else
    {    
      $chkCirugias = "checked";
    }
    $s_obsCirugias = $line['obsCirugias'];
    //-------------------------------------------------------//
    $s_exodoncias        = $line['exodoncias'];
    if ($s_exodoncias =="N" OR $s_exodoncias =="")
    {
      $s_exodoncias = "N";
    }
    else
    {    
      $chkExodoncias = "checked";
    }
    $s_obsExodoncias = $line['obsExodoncias'];
    //-------------------------------------------------------//
    $s_enfOrales         = $line['enfOrales'];
    if ($s_enfOrales =="N" OR $s_enfOrales =="")
    {
      $s_enfOrales = "N";
    }
    else
    {    
      $chkEnfOrales = "checked";
    }
    $s_obsEnfOrales = $line['obsenfOrales'];
    //-------------------------------------------------------//
    $s_usoProtesis       = $line['usoProtesis'];
    if ($s_usoProtesis =="N" OR $s_usoProtesis =="")
    {
      $s_usoProtesis = "N";
    }
    else
    {    
      $chkUsoProtesis = "checked";
    }
    $s_obsUsoProtesis = $line['obsUsoProtesis'];
    //-------------------------------------------------------//
    $s_habitos           = $line['habitos'];

    /////////////////////////////////////////////////////////// 
    //VARIABLES EXAMEN ESTOMATOLOGICO
    ////////////////////////////////////////////////////////////
     $query = "SELECT * FROM SIO_EXA_ESTOMATOLOGICO WHERE numtratamiento = $e_tratamiento";//numConsulta= $nConsulta" ;
     $result = mysql_query($query) or die('Consulta  de Examen estomatologico fallida: ' . mysql_error());
     $line = mysql_fetch_array($result, MYSQL_ASSOC);
  
     $s_labioInferior    = $line['labioInferior'];
     if ($s_labioInferior == "Normal")
     {
       $labioInferiorNormal ="selected";
     }
     if ($s_labioInferior == "Anormal")
     {
       $labioInferiorAnormal ="selected";
     }
     $s_obsLabioInferior = $line['obsLabioInferior'];
     //-------------------------------------------------------//
     $s_labioSuperior    = $line['labioSuperior'];
     if ($s_labioSuperior == "Normal")
     {
       $labioSuperiorNormal ="selected";
     }
     if ($s_labioSuperior == "Anormal")
     {
       $labioSuperiorAnormal ="selected";
     }
     $s_obsLabioSuperior = $line['obsLabioSuperior'];
     //-------------------------------------------------------//
     $s_comisuras= $line['comisuras'];
     if ($s_comisuras == "Normal")
     {
      $comisurasNormal ="selected";
     }
     if ($s_comisuras == "Anormal")
     {
         $comisurasAnormal ="selected";
     }
     $s_obsComisuras= $line['obsComisuras'];
     //-------------------------------------------------------//
     $s_mucosaOral= $line['mucosaOral'];
     if ($s_mucosaOral == "Normal")
     {
      $mucosaOralNormal ="selected";
     }
     if ($s_mucosaOral == "Anormal")
     {
       $mucosaOralAnormal ="selected";
     }
     $s_obsMucosaOral= $line['obsMucosaOral'];
     //-------------------------------------------------------//
     $s_surcosYugales= $line['surcosYugales'];
     if ($s_surcosYugales == "Normal")
     {
      $surcosYugalesNormal ="selected";
     }
     if ($s_surcosYugales == "Anormal")
     {
      $surcosYugalesAnormal ="selected";
     }
     $s_obsSurcosYugales = $line['obsSurcosYugales'];
     //-------------------------------------------------------//
     $s_frenillos = $line['frenillos'];
     if ($s_frenillos == "Normal")
     {
       $frenillosNormal ="selected";
     }
     if ($s_frenillos == "Anormal")
     {
       $frenillosAnormal ="selected";
     }
     $s_obsFrenillos= $line['obsFrenillos'];
     //-------------------------------------------------------//
     $s_oroFaringe= $line['oroFaringe'];
     if ($s_oroFaringe == "Normal")
     {
       $oroFaringeNormal ="selected";
     }
     if ($s_oroFaringe == "Anormal")
     {
       $oroFaringeAnormal ="selected";
     }
     $s_obsOrofaringe= $line['obsOrofaringe'];
     //-------------------------------------------------------//
     $s_paladar= $line['paladar'];
     if ($s_paladar == "Normal")
     {
       $paladarNormal ="selected";
     }
     if ($s_paladar == "Anormal")
     {
       $paladarAnormal ="selected";
     }
     $s_obsPaladar= $line['obsPaladar'];
     //-------------------------------------------------------//
     $s_glandSalivales= $line['glandSalivales'];
     if ($s_glandSalivales == "Normal")
     {
       $glandSalivalesNormal ="selected";
     }
     if ($s_glandSalivales == "Anormal")
     {
       $glandSalivalesAnormal ="selected";
     }
     $s_obsGlandSalivales = $line['obsGlandSalivales'];
     //-------------------------------------------------------//
     $s_pisoBoca    = $line['pisoBoca'];
     if ($s_pisoBoca == "Normal")
     {
       $pisoBocaNormal ="selected";
     }
     if ($s_pisoBoca == "Anormal")
     {
       $pisoBocaAnormal ="selected";
     }
     $s_obsPisoBoca  = $line['obsPisoBoca'];
     //-------------------------------------------------------//
     $s_dorsoLengua= $line['dorsoLengua'];
     if ($s_dorsoLengua == "Normal")
     {
       $dorsoLenguaNormal ="selected";
     }
     if ($s_dorsoLengua == "Anormal")
     {
      $dorsoLenguaAnormal ="selected";
     }
     $s_obsDorsoLengua= $line['obsDorsoLengua'];
     //-------------------------------------------------------//
     $s_vientreLengua= $line['vientreLengua'];
     if ($s_vientreLengua == "Normal")
     {
       $vientreLenguaNormal ="selected";
     }
     if ($s_vientreLengua == "Anormal")
     {
       $vientreLenguaAnormal ="selected";
     }
     $s_obsVientreLengua= $line['obsVientreLengua'];

     /////////////////////////////////////////////////////////// 
    //VARIABLES ARTICULACION TEMPORO MANDIBULAR
    ////////////////////////////////////////////////////////////
    $query = "SELECT * FROM SIO_ART_TEMPORO WHERE numtratamiento = $e_tratamiento";//numConsulta= $nConsulta" ;
    $result = mysql_query($query) or die('Consulta  de Examen estomatologico fallida: ' . mysql_error());
    $line = mysql_fetch_array($result, MYSQL_ASSOC);

    $s_ruidos= $line['ruidos'];
    if ($s_ruidos == "Normal")
    {
      $ruidosNormal ="selected";
    }
    if ($s_ruidos == "Anormal")
    {
      $ruidosAnormal ="selected";
    }
    $s_obsRuidos= $line['obsRuidos'];
    //-------------------------------------------------------//
    $s_desviacion= $line['desviacion'];
    if ($s_desviacion == "Normal")
    {
        $desviacionNormal ="selected";
    }
    if ($s_desviacion == "Anormal")
    {
      $desviacionAnormal ="selected";
    }
    $s_obsDesviacion= $line['obsDesviacion'];
    //-------------------------------------------------------//
    $s_cambioVolumen= $line['cambioVolumen'];
    if ($s_cambioVolumen == "Normal")
    {
      $cambioVolumenNormal ="selected";
    }
    if ($s_cambioVolumen == "Anormal")
    {
      $cambioVolumenAnormal ="selected";
    }
    $s_obsCambioVolumen= $line['obsCambioVolumen'];
    //-------------------------------------------------------//
    $s_bloqueoMand= $line['bloqueoMand'];
    if ($s_bloqueoMand == "Normal")
    {
     $bloqueoMandNormal ="selected";
    }
    if ($s_bloqueoMand == "Anormal")
    {
     $bloqueoMandAnormal ="selected";
    }
    $s_obsBloqueMand= $line['obsBloqueMand'];
    //-------------------------------------------------------//
    $s_limitApertura= $line['limitApertura'];
    if ($s_limitApertura == "Normal")
    {
      $limitAperturaNormal ="selected";
    }
    if ($s_limitApertura == "Anormal")
    {
      $limitAperturaAnormal ="selected";
    }
    $s_obsLimitApertura= $line['obsLimitApertura'];
    //-------------------------------------------------------//
    $s_dolorArticular= $line['dolorArticular'];
    if ($s_dolorArticular == "Normal")
    {
      $dolorArticularNormal ="selected";
    }
    if ($s_dolorArticular == "Anormal")
    {
      $dolorArticularAnormal ="selected";
    }
    $s_obsDolorArticular= $line['obsDolorArticular'];
    //-------------------------------------------------------//
    $s_dolorMuscular= $line['dolorMuscular'];
    if ($s_dolorMuscular == "Normal")
    {
     $dolorMuscularNormal ="selected";
    }
    if ($s_dolorMuscular == "Anormal")
    {
     $dolorMuscularAnormal ="selected";
    }
    $s_obsDolorMuscular= $line['obsDolorMuscular'];

    ///////////////////////////////////////////////////////////  
    //VARIABLES CONSENTIMIENTOS INFORMADOS
    ///////////////////////////////////////////////////////////  
    $query = "SELECT * FROM SIO_CON_INFORMADOS WHERE numtratamiento = $e_tratamiento";//numConsulta= $nConsulta" ;
    $result = mysql_query($query) or die('Consulta  de Consentimiento Informados fallida: ' . mysql_error());
    $line = mysql_fetch_array($result, MYSQL_ASSOC);
 
    $s_conInformado = $line['conInformado'];
    if ($s_conInformado =="N" OR $s_conInformado =="")
    {
      $s_conInformado = "N";
    }
    else
    {    
      $chkConInformado = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfOpera = $line['conInfOpera'];
    if ($s_conInfOpera =="N" OR $s_conInfOpera =="")
    {
      $s_conInfOpera = "N";
    }
    else
    {    
      $chkConInfOpera = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfAneLoc = $line['conInfAneLoc'];
    if ($s_conInfAneLoc =="N" OR $s_conInfAneLoc =="")
    {
      $s_conInfAneLoc = "N";
    }
    else
    {    
      $chkConInfAneLoc = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfEndo = $line['conInfEndo'];
    if ($s_conInfEndo =="N" OR $s_conInfEndo =="")
    {
      $s_conInfEndo = "N";
    }
    else
    {    
      $chkConInfEndo = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfEndSim = $line['conInfEndSim'];
    if ($s_conInfEndSim =="N" OR $s_conInfEndSim =="")
    {
      $s_conInfEndSim = "N";
    }
    else
    {    
      $chkConInfEndSim = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfExoSim = $line['conInfExoSim'];
    if ($s_conInfExoSim =="N" OR $s_conInfExoSim =="")
    {
      $s_conInfExoSim = "N";
    }
    else
    {    
      $chkConInExoSim = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfExoCor = $line['conInfExoCor'];
    if ($s_conInfExoCor =="N" OR $s_conInfExoCor =="")
    {
      $s_conInfExoCor = "N";
    }
    else
    {    
      $chkConInfExoCor = "checked";
    } 
    //-------------------------------------------------------//
    $s_conInfCirApi = $line['conInfCirApi'];
    if ($s_conInfCirApi =="N" OR $s_conInfCirApi =="")
    {
      $s_conInfCirApi = "N";
    }
    else
    {    
      $chkConInfCirApi = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfTerNeu = $line['conInfTerNeu'];
    if ($s_conInfTerNeu =="N" OR $s_conInfTerNeu =="")
    {
      $s_conInfTerNeu = "N";
    }
    else
    {    
      $chkConInfTerNeu = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfRevoc = $line['conInfRevoc'];
    if ($s_conInfRevoc =="N" OR $s_conInfRevoc =="")
    {
      $s_conInfRevoc = "N";
    }
    else
    {    
      $chkConInfRevoc = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfNegacion = $line['conInfNegacion'];
    if ($s_conInfNegacion =="N" OR $s_conInfNegacion =="")
    {
      $s_conInfNegacion = "N";
    }
    else
    {    
      $chkConInfNegacion = "checked";
    }
     
    ///////////////////////////////////////////////////////////  
    //VARIABLES PROTESIS   
    ///////////////////////////////////////////////////////////  
    $query = "SELECT * FROM SIO_PRE_PROTESIS WHERE numtratamiento = $e_tratamiento";//numConsulta= $nConsulta" ;
    $result = mysql_query($query) or die('Consulta  de Protesis fallida: ' . mysql_error());
    $line = mysql_fetch_array($result, MYSQL_ASSOC);

    $s_protesis = $line['protesis'];
    if ($s_protesis =="N" OR $s_protesis =="")
    {
      $s_protesis = "N";
    }
    else
    {    
     $chkProtesis = "checked";
    }
    $s_obsProtesis = $line['obsProtesis'];

    /////////////////////////////////////////////////////////// 
    //VARIABLES HIGIENE ORAL
    ////////////////////////////////////////////////////////////
    $query = "SELECT * FROM SIO_HIG_ORAL WHERE numtratamiento = $e_tratamiento";//numConsulta= $nConsulta" ;
    $result = mysql_query($query) or die('Consulta  de HIGIENE ORAL fallida: ' . mysql_error());
    $line = mysql_fetch_array($result, MYSQL_ASSOC);

    $s_higiene= $line['higiene'];
    if ($s_higiene == "Buena")
    {
     $hBuena="selected";
    }
    if ($s_higiene == "Regular")
    {
     $hRegular="selected";
    }
    if ($s_higiene == "Mala")
    {
     $hMala="selected";
    }
    //-------------------------------------------------------//
    $s_freCepillado= $line['freCepillado'];
    if ($s_freCepillado == "Tres Veces")
    {
      $fCtres="selected";
    }
    if ($s_freCepillado == "Dos Veces")
    {
      $fCdos="selected";
    }
    if ($s_freCepillado == "Una Vez")
    {
      $fCuno="selected";
    }
    //-------------------------------------------------------//
    $s_sedaDental= $line['sedaDental'];
    if ($s_sedaDental =="N" OR $s_sedaDental =="")
    {
     $s_sedaDental = "N";
     $chkSedaDental = "";
    }
    else
    {    
       $chkSedaDental = "checked";
    }
    //-------------------------------------------------------//
    $s_pigmentacion= $line['pigmentacion'];
    if ($s_pigmentacion =="" OR $s_pigmentacion =="N")
    {
      $s_pigmentacion = "N";
       $chkPigmentacion = "";
    }
    else
    {    
      $chkPigmentacion = "checked";
    }
    //-------------------------------------------------------//
    $s_gradoRiesgo= $line['gradoRiesgo'];
    if ($s_gradoRiesgo == "Bajo")
    {
      $grBajo="selected";
    }
    if ($s_gradoRiesgo == "Medio")
    {
      $grMedio="selected";
    }
    if ($s_gradoRiesgo == "Alto")
    {
     $grAlto="selected";
    }
    //-------------------------------------------------------//
    $s_obsHigiene= $line['obsHigiene'];
   
    ///////////////////////////////////////////////////////////  
    //VARIABLES EXAMEN PULPAR 
    /////////////////////////////////////////////////////////// 
    $query = "SELECT * FROM SIO_EXA_PULPAR WHERE numtratamiento = $e_tratamiento";//numConsulta= $nConsulta" ;
    $result = mysql_query($query) or die('Consulta  de Examen estomatologico fallida: ' . mysql_error());
    $line = mysql_fetch_array($result, MYSQL_ASSOC);
    
    $s_cuelloSencible= $line['cuelloSencible'];
    if ($s_cuelloSencible =="N" OR $s_cuelloSencible =="")
    {
      $s_cuelloSencible = "N";
    }
    else
    {    
     $chkCuelloSencible = "checked";
    }
    $s_obsCuelloSencible= $line['obsCuelloSencible'];
    //-------------------------------------------------------//
    $s_abscesos= $line['abscesos'];
    if ($s_abscesos =="N" OR $s_abscesos =="")
    {
     $s_abscesos = "N";
    }
    else
    {    
     $chkAbscesos= "checked";
    }
    $s_obsAbscesos= $line['obsAbscesos'];
    //-------------------------------------------------------//
    $s_exposicionPulpar= $line['exposicionPulpar'];
    if ($s_exposicionPulpar =="N" OR $s_exposicionPulpar =="")
    {
      $s_exposicionPulpar = "N";
    }
    else
    {    
      $chkExposicionPulpar= "checked";
    }
    $s_obsExposicionPulpar= $line['obsExposicionPulpar'];
    //-------------------------------------------------------//
    $s_cambioColor= $line['cambioColor'];
    if ($s_cambioColor =="N" OR $s_cambioColor =="")
    {
      $s_cambioColor = "N";
    }
    else
    {    
      $chkCambioColor= "checked";
    }
    $s_obsCambioColor= $line['obsCambioColor'];    

    ///////////////////////////////////////////////////////////  
    //VARIABLES TEJIDOS DENTARIOS Y OCLUSION
    ///////////////////////////////////////////////////////////  
    $query = "SELECT * FROM SIO_TEJ_DENTARIOS WHERE numtratamiento = $e_tratamiento";//numConsulta= $nConsulta" ;
    $result = mysql_query($query) or die('Consulta  de Tabla: SIO_TEJ_DENTARIOS fallida: ' . mysql_error());
    $line = mysql_fetch_array($result, MYSQL_ASSOC);

    $s_supernumerarios= $line['supernumerarios'];
    if ($s_supernumerarios =="N" OR $s_supernumerarios =="")
    {
     $s_supernumerarios = "N";
    }
    else
    {    
      $chkSupernumerarios= "checked";
    }
    $s_obsSupernumerarios= $line['obsSupernumerarios'];
    //-------------------------------------------------------//
    $s_decoloracion= $line['decoloracion'];
    if ($s_decoloracion =="N" OR $s_decoloracion =="")
    {
     $s_decoloracion = "N";
    }
    else
    {    
     $chkDecoloracion= "checked";
    }
    $s_obsDecoloracion= $line['obsDecoloracion'];
    //-------------------------------------------------------//
    $s_descalsificacion= $line['descalsificacion'];
    if ($s_descalsificacion =="N" OR $s_descalsificacion =="")
    {
     $s_descalsificacion = "N";
    }
    else
    {    
      $chkDescalsificacion= "checked";
    }
    $s_obsDescalsificacion= $line['obsDescalsificacion'];
    //-------------------------------------------------------//
    $s_facetaDesgaste= $line['facetaDesgaste'];
    if ($s_facetaDesgaste =="N" OR $s_facetaDesgaste =="")
    {
      $s_facetaDesgaste = "N";
    }
    else
    {    
     $chkFacetaDesgaste= "checked";
    }
    $s_obsFacetaDesgaste= $line['obsFacetaDesgaste'];
    //-------------------------------------------------------//
    $s_abrasion= $line['abrasion'];
    if ($s_abrasion =="N" OR $s_abrasion =="")
    {
     $s_abrasion = "N";
    }
    else
    {    
     $chkAbrasion= "checked";
    }
    $s_obsAbrasion= $line['obsAbrasion'];
    //-------------------------------------------------------//
    $s_fluorosis= $line['fluorosis'];
    if ($s_fluorosis =="N" OR $s_fluorosis =="")
    {
      $s_fluorosis = "N";
    }
    else
    {    
     $chkFluorosis= "checked";
    }
    $s_obsFluorosis= $line['obsFluorosis'];     

    ///////////////////////////////////////////////////////////  
    //VARIABLES ALTERACIONES PERIODENTALES  
    /////////////////////////////////////////////////////////// 
    $query = "SELECT * FROM SIO_ALT_PERIODONTALES WHERE numtratamiento = $e_tratamiento";//numConsulta= $nConsulta" ;
    $result = mysql_query($query) or die('Consulta  de Antecedentes fallida: ' . mysql_error());
    $line = mysql_fetch_array($result, MYSQL_ASSOC);

    $s_sangrado= $line['sangrado'];
    if ($s_sangrado =="N" OR $s_sangrado =="")
    {
      $s_sangrado = "N";
    }
    else
    {    
      $chkSangrado = "checked";
    }
    $s_obsSangrado= $line['obsSangrado'];
    //---------------------------------------//
    $s_exudado = $line['exudado'];
    if ($s_exudado=="N" OR $s_exudado=="")
    {
      $s_exudado = "N";
    }
    else
    {    
     $chkExudado = "checked";
    }
    $s_obsExudado = $line['obsExudado'];
    //---------------------------------------//
    $s_supuracion = $line['supuracion'];
    if ($s_supuracion =="N" OR $s_supuracion =="")
    {
      $s_supuracion = "N";
    }
    else
    {    
     $chkSupuracion = "checked";
    }
    $s_obsSupuracion = $line['obsSupuracion'];
    //---------------------------------------// 
    $s_calculos= $line['calculos'];
    if ($s_calculos =="N" OR $s_calculos =="")
    {
       $s_calculos = "N";
    }
    else
    {    
       $chkCalculos = "checked";
    }
    $s_obsCalculos= $line['obsCalculos'];
    //-------------------------------------------------------//
    $s_inflamacion= $line['inflamacion'];
    if ($s_inflamacion =="N" OR $s_inflamacion =="")
    {
       $s_inflamacion = "N";
    }
    else
    {    
       $chkInflamacion = "checked";
    }
    $s_obsInflamacion= $line['obsInflamacion'];
    //-------------------------------------------------------//
    $s_retracciones= $line['retracciones'];
    if ($s_retracciones =="N" OR $s_retracciones =="")
    {
     $s_retracciones = "N";
    }
    else
    {    
     $chkRetracciones = "checked";
    }
    $s_obsRetracciones= $line['obsRetracciones'];
    //-------------------------------------------------------//
    $s_presenciaBolsas= $line['presenciaBolsas'];
    if ($s_presenciaBolsas =="N" OR $s_presenciaBolsas =="")
    {
      $s_presenciaBolsas = "N";
    }
    else
    {    
      $chkPresenciaBolsas = "checked";
    }
    $s_obsPresenciaBolsas= $line['obsPresenciaBolsas'];
    //-------------------------------------------------------//
    $s_tipOclusion= $line['tipOclusion'];
    if ($s_tipOclusion =="N" OR $s_tipOclusion =="")
    {
      $s_tipOclusion = "N";
    }
    else
    {    
      $chkTipOclusion = "checked";
    }
    $s_obsTipOclusion= $line['obsTipOclusion'];
    //-------------------------------------------------------// 
    ///////////////////////////////////////////////////////////  
    //OBSERVACION ODONTOGRAMA
    /////////////////////////////////////////////////////////// 
    $query = "SELECT * FROM SIO_OBS_ODONTOGRAMA WHERE numtratamiento = $e_tratamiento";//numConsulta= $nConsulta" ;
    $result = mysql_query($query) or die('Consulta  de Observaciones de Odontograma fallida: ' . mysql_error());
    $line = mysql_fetch_array($result, MYSQL_ASSOC);
    $s_obsOdontograma =  $line['obsOdontograma'];



     ///////////////////////////////////////////////////////////  
    //VARIABLES REGISTRO DE PLACA
    ///////////////////////////////////////////////////////////   
   
   
    //////////////////////////////////////////////////////////////////////////////////////
    /////////////////// INICIO REGISTRO DE PLACA    //////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////
    $query = "SELECT * FROM SIO_REG_PLACA WHERE numtratamiento = $e_tratamiento";//numConsulta= $nConsulta" ;
    $result = mysql_query($query) or die('Consulta  de Registro de Placa fallida: ' . mysql_error());
    $line = mysql_fetch_array($result, MYSQL_ASSOC);
    
    $s_P551 =  $line['P551'];
    if ($s_P551 ==0)
    {
      $s_P551 = 0;
    }
    else
    {
      $chkP551  = "checked";
    }

    $s_P554 =  $line['P554'];
    if ($s_P554 ==0)
    {
      $s_P554 = 0;
    }
    else
    {
      $chkP554  = "checked";
    }  
    
    $s_P552 =  $line['P552'];
    if ($s_P552 ==0)
    {
      $s_P552 = 0;
    }
    else
    {
      $chkP552  = "checked";
    }      
    
    $s_P555 =  $line['P555'];
    if ($s_P555 ==0)
    {
      $s_P555 = 0;
    }
    else
    {
      $chkP555  = "checked";
    }    
    $s_P541 =  $line['P541'];
    if ($s_P541 ==0)
    {
      $s_P541 = 0;
    }
    else
    {
      $chkP541  = "checked";
    }

    $s_P544 =  $line['P544'];
    if ($s_P544 ==0)
    {
      $s_P544 = 0;
    }
    else
    {
      $chkP544  = "checked";
    }  
    
    $s_P542 =  $line['P542'];
    if ($s_P542 ==0)
    {
      $s_P542 = 0;
    }
    else
    {
      $chkP542  = "checked";
    }      
    
    $s_P545 =  $line['P545'];
    if ($s_P545 ==0)
    {
      $s_P545 = 0;
    }
    else
    {
      $chkP545  = "checked";
    }
    $s_P531 =  $line['P531'];
    if ($s_P531 ==0)
    {
      $s_P531 = 0;
    }
    else
    {
      $chkP531  = "checked";
    }

    $s_P534 =  $line['P534'];
    if ($s_P534 ==0)
    {
      $s_P534 = 0;
    }
    else
    {
      $chkP534  = "checked";
    }  
    
    $s_P532 =  $line['P532'];
    if ($s_P532 ==0)
    {
      $s_P532 = 0;
    }
    else
    {
      $chkP532  = "checked";
    }      
    
    $s_P535 =  $line['P535'];
    if ($s_P535 ==0)
    {
      $s_P535 = 0;
    }
    else
    {
      $chkP535  = "checked";
    }
    $s_P521 =  $line['P521'];
    if ($s_P521 ==0)
    {
      $s_P521 = 0;
    }
    else
    {
      $chkP521  = "checked";
    }

    $s_P524 =  $line['P524'];
    if ($s_P524 ==0)
    {
      $s_P524 = 0;
    }
    else
    {
      $chkP524  = "checked";
    }  
    
    $s_P522 =  $line['P522'];
    if ($s_P522 ==0)
    {
      $s_P522 = 0;
    }
    else
    {
      $chkP522  = "checked";
    }      
    
    $s_P525 =  $line['P525'];
    if ($s_P525 ==0)
    {
      $s_P525 = 0;
    }
    else
    {
      $chkP525  = "checked";
    }   
    $s_P511 =  $line['P511'];
    if ($s_P511 ==0)
    {
      $s_P511 = 0;
    }
    else
    {
      $chkP511  = "checked";
    }

    $s_P514 =  $line['P514'];
    if ($s_P514 ==0)
    {
      $s_P514 = 0;
    }
    else
    {
      $chkP514  = "checked";
    }  
    
    $s_P512 =  $line['P512'];
    if ($s_P512 ==0)
    {
      $s_P512 = 0;
    }
    else
    {
      $chkP512  = "checked";
    }      
    
    $s_P515 =  $line['P515'];
    if ($s_P515 ==0)
    {
      $s_P515 = 0;
    }
    else
    {
      $chkP515  = "checked";
    }  
    $s_P611 =  $line['P611'];
    if ($s_P611 ==0)
    {
      $s_P611 = 0;
    }
    else
    {
      $chkP611  = "checked";
    }

    $s_P614 =  $line['P614'];
    if ($s_P614 ==0)
    {
      $s_P614 = 0;
    }
    else
    {
      $chkP614  = "checked";
    }  
    
    $s_P612 =  $line['P612'];
    if ($s_P612 ==0)
    {
      $s_P612 = 0;
    }
    else
    {
      $chkP612  = "checked";
    }      
    
    $s_P615 =  $line['P615'];
    if ($s_P615 ==0)
    {
      $s_P615 = 0;
    }
    else
    {
      $chkP615  = "checked";
    }  
    $s_P621 =  $line['P621'];
    if ($s_P621 ==0)
    {
      $s_P621 = 0;
    }
    else
    {
      $chkP621  = "checked";
    }

    $s_P624 =  $line['P624'];
    if ($s_P624 ==0)
    {
      $s_P624 = 0;
    }
    else
    {
      $chkP624  = "checked";
    }  
    
    $s_P622 =  $line['P622'];
    if ($s_P622 ==0)
    {
      $s_P622 = 0;
    }
    else
    {
      $chkP622  = "checked";
    }      
    
    $s_P625 =  $line['P625'];
    if ($s_P625 ==0)
    {
      $s_P625 = 0;
    }
    else
    {
      $chkP625  = "checked";
    }  
    $s_P631 =  $line['P631'];
    if ($s_P631 ==0)
    {
      $s_P631 = 0;
    }
    else
    {
      $chkP631  = "checked";
    }

    $s_P634 =  $line['P634'];
    if ($s_P634 ==0)
    {
      $s_P634 = 0;
    }
    else
    {
      $chkP634  = "checked";
    }  
    
    $s_P632 =  $line['P632'];
    if ($s_P632 ==0)
    {
      $s_P632 = 0;
    }
    else
    {
      $chkP632  = "checked";
    }      
    
    $s_P635 =  $line['P635'];
    if ($s_P635 ==0)
    {
      $s_P635 = 0;
    }
    else
    {
      $chkP635  = "checked";
    }    
        $s_P641 =  $line['P641'];
    if ($s_P641 ==0)
    {
      $s_P641 = 0;
    }
    else
    {
      $chkP641  = "checked";
    }

    $s_P644 =  $line['P644'];
    if ($s_P644 ==0)
    {
      $s_P644 = 0;
    }
    else
    {
      $chkP644  = "checked";
    }  
    
    $s_P642 =  $line['P642'];
    if ($s_P642 ==0)
    {
      $s_P642 = 0;
    }
    else
    {
      $chkP642  = "checked";
    }      
    
    $s_P645 =  $line['P645'];
    if ($s_P645 ==0)
    {
      $s_P645 = 0;
    }
    else
    {
      $chkP645  = "checked";
    }  
    $s_P651 =  $line['P651'];
    if ($s_P651 ==0)
    {
      $s_P651 = 0;
    }
    else
    {
      $chkP651  = "checked";
    }

    $s_P654 =  $line['P654'];
    if ($s_P654 ==0)
    {
      $s_P654 = 0;
    }
    else
    {
      $chkP654  = "checked";
    }  
    
    $s_P652 =  $line['P652'];
    if ($s_P652 ==0)
    {
      $s_P652 = 0;
    }
    else
    {
      $chkP652  = "checked";
    }      
    
    $s_P655 =  $line['P655'];
    if ($s_P655 ==0)
    {
      $s_P655 = 0;
    }
    else
    {
      $chkP655  = "checked";
    }  
    $s_P857 =  $line['P857'];
    if ($s_P857 ==0)
    {
      $s_P857 = 0;
    }
    else
    {
      $chkP857  = "checked";
    }

    $s_P854 =  $line['P854'];
    if ($s_P854 ==0)
    {
      $s_P854 = 0;
    }
    else
    {
      $chkP854  = "checked";
    }  
    
    $s_P852 =  $line['P852'];
    if ($s_P852 ==0)
    {
      $s_P852 = 0;
    }
    else
    {
      $chkP852  = "checked";
    }      
    
    $s_P851 =  $line['P851'];
    if ($s_P851 ==0)
    {
      $s_P851 = 0;
    }
    else
    {
      $chkP851  = "checked";
    }  
    $s_P847 =  $line['P847'];
    if ($s_P847 ==0)
    {
      $s_P847 = 0;
    }
    else
    {
      $chkP847  = "checked";
    }

    $s_P844 =  $line['P844'];
    if ($s_P844 ==0)
    {
      $s_P844 = 0;
    }
    else
    {
      $chkP844  = "checked";
    }  
    
    $s_P842 =  $line['P842'];
    if ($s_P842 ==0)
    {
      $s_P842 = 0;
    }
    else
    {
      $chkP842  = "checked";
    }      
    
    $s_P841 =  $line['P841'];
    if ($s_P841 ==0)
    {
      $s_P841 = 0;
    }
    else
    {
      $chkP841  = "checked";
    }    
    $s_P837 =  $line['P837'];
    if ($s_P837 ==0)
    {
      $s_P837 = 0;
    }
    else
    {
      $chkP837  = "checked";
    }

    $s_P834 =  $line['P834'];
    if ($s_P834 ==0)
    {
      $s_P834 = 0;
    }
    else
    {
      $chkP834  = "checked";
    }  
    
    $s_P832 =  $line['P832'];
    if ($s_P832 ==0)
    {
      $s_P832 = 0;
    }
    else
    {
      $chkP832  = "checked";
    }      
    
    $s_P831 =  $line['P831'];
    if ($s_P831 ==0)
    {
      $s_P831 = 0;
    }
    else
    {
      $chkP831  = "checked";
    }  
    $s_P827 =  $line['P827'];
    if ($s_P827 ==0)
    {
      $s_P827 = 0;
    }
    else
    {
      $chkP827  = "checked";
    }

    $s_P824 =  $line['P824'];
    if ($s_P824 ==0)
    {
      $s_P824 = 0;
    }
    else
    {
      $chkP824  = "checked";
    }  
    
    $s_P822 =  $line['P822'];
    if ($s_P822 ==0)
    {
      $s_P822 = 0;
    }
    else
    {
      $chkP822  = "checked";
    }      
    
    $s_P821 =  $line['P821'];
    if ($s_P821 ==0)
    {
      $s_P821 = 0;
    }
    else
    {
      $chkP821  = "checked";
    }  
    $s_P817 =  $line['P817'];
    if ($s_P817 ==0)
    {
      $s_P817 = 0;
    }
    else
    {
      $chkP817  = "checked";
    }

    $s_P814 =  $line['P814'];
    if ($s_P814 ==0)
    {
      $s_P814 = 0;
    }
    else
    {
      $chkP814  = "checked";
    }  
    
    $s_P812 =  $line['P812'];
    if ($s_P812 ==0)
    {
      $s_P812 = 0;
    }
    else
    {
      $chkP812  = "checked";
    }      
    
    $s_P811 =  $line['P811'];
    if ($s_P811 ==0)
    {
      $s_P811 = 0;
    }
    else
    {
      $chkP811  = "checked";
    }  
    $s_P717 =  $line['P717'];
    if ($s_P717 ==0)
    {
      $s_P717 = 0;
    }
    else
    {
      $chkP717  = "checked";
    }

    $s_P714 =  $line['P714'];
    if ($s_P714 ==0)
    {
      $s_P714 = 0;
    }
    else
    {
      $chkP714  = "checked";
    }  
    
    $s_P712 =  $line['P712'];
    if ($s_P712 ==0)
    {
      $s_P712 = 0;
    }
    else
    {
      $chkP712  = "checked";
    }      
    
    $s_P711 =  $line['P711'];
    if ($s_P711 ==0)
    {
      $s_P711 = 0;
    }
    else
    {
      $chkP711  = "checked";
    }  
    $s_P727 =  $line['P727'];
    if ($s_P727 ==0)
    {
      $s_P727 = 0;
    }
    else
    {
      $chkP727  = "checked";
    }

    $s_P724 =  $line['P724'];
    if ($s_P724 ==0)
    {
      $s_P724 = 0;
    }
    else
    {
      $chkP724  = "checked";
    }  
    
    $s_P722 =  $line['P722'];
    if ($s_P722 ==0)
    {
      $s_P722 = 0;
    }
    else
    {
      $chkP722  = "checked";
    }      
    
    $s_P721 =  $line['P721'];
    if ($s_P721 ==0)
    {
      $s_P721 = 0;
    }
    else
    {
      $chkP721  = "checked";
    }   
    $s_P737 =  $line['P737'];
    if ($s_P737 ==0)
    {
      $s_P737 = 0;
    }
    else
    {
      $chkP737  = "checked";
    }

    $s_P734 =  $line['P734'];
    if ($s_P734 ==0)
    {
      $s_P734 = 0;
    }
    else
    {
      $chkP734  = "checked";
    }  
    
    $s_P732 =  $line['P732'];
    if ($s_P732 ==0)
    {
      $s_P732 = 0;
    }
    else
    {
      $chkP732  = "checked";
    }      
    
    $s_P731 =  $line['P731'];
    if ($s_P731 ==0)
    {
      $s_P731 = 0;
    }
    else
    {
      $chkP731  = "checked";
    } 
    $s_P747 =  $line['P747'];
    if ($s_P747 ==0)
    {
      $s_P747 = 0;
    }
    else
    {
      $chkP747  = "checked";
    }

    $s_P744 =  $line['P744'];
    if ($s_P744 ==0)
    {
      $s_P744 = 0;
    }
    else
    {
      $chkP744  = "checked";
    }  
    
    $s_P742 =  $line['P742'];
    if ($s_P742 ==0)
    {
      $s_P742 = 0;
    }
    else
    {
      $chkP742  = "checked";
    }      
    
    $s_P741 =  $line['P741'];
    if ($s_P741 ==0)
    {
      $s_P741 = 0;
    }
    else
    {
      $chkP741  = "checked";
    } 
    $s_P757 =  $line['P757'];
    if ($s_P757 ==0)
    {
      $s_P757 = 0;
    }
    else
    {
      $chkP757  = "checked";
    }

    $s_P754 =  $line['P754'];
    if ($s_P754 ==0)
    {
      $s_P754 = 0;
    }
    else
    {
      $chkP754  = "checked";
    }  
    
    $s_P752 =  $line['P752'];
    if ($s_P752 ==0)
    {
      $s_P752 = 0;
    }
    else
    {
      $chkP752  = "checked";
    }      
    
    $s_P751 =  $line['P751'];
    if ($s_P751 ==0)
    {
      $s_P751 = 0;
    }
    else
    {
      $chkP751  = "checked";
    }   

    ///////////REGISTRO DE PLACA NUEVOS 
        $s_P161 =  $line['P161'];
    if ($s_P161 ==0)
    {
      $s_P161 = 0;
    }
    else
    {
      $chkP161  = "checked";
    }    
    $s_P164 =  $line['P164'];
    if ($s_P164 ==0)
    {
      $s_P164 = 0;
    }
    else
    {
      $chkP164  = "checked";
    }
    $s_P166 =  $line['P166'];
    if ($s_P166 ==0)
    {
      $s_P166 = 0;
    }
    else
    {
      $chkP166  = "checked";
    }
    $s_P162 =  $line['P162'];
    if ($s_P162 ==0)
    {
      $s_P162 = 0;
    }
    else
    {
      $chkP162  = "checked";
    }
    $s_P165 =  $line['P165'];
    if ($s_P165 ==0)
    {
      $s_P165 = 0;
    }
    else
    {
      $chkP165  = "checked";
    }

    $s_P171 =  $line['P171'];
    if ($s_P171 ==0)
    {
      $s_P171 = 0;
    }
    else
    {
      $chkP171  = "checked";
    }    
    $s_P174 =  $line['P174'];
    if ($s_P174 ==0)
    {
      $s_P174 = 0;
    }
    else
    {
      $chkP174  = "checked";
    }
    $s_P176 =  $line['P176'];
    if ($s_P176 ==0)
    {
      $s_P176 = 0;
    }
    else
    {
      $chkP176  = "checked";
    }
    $s_P172 =  $line['P172'];
    if ($s_P172 ==0)
    {
      $s_P172 = 0;
    }
    else
    {
      $chkP172  = "checked";
    }
    $s_P175 =  $line['P175'];
    if ($s_P175 ==0)
    {
      $s_P175 = 0;
    }
    else
    {
      $chkP175  = "checked";
    }
    $s_P181 =  $line['P181'];
    if ($s_P181 ==0)
    {
      $s_P181 = 0;
    }
    else
    {
      $chkP181  = "checked";
    }    
    $s_P184 =  $line['P184'];
    if ($s_P184 ==0)
    {
      $s_P184 = 0;
    }
    else
    {
      $chkP184  = "checked";
    }
    $s_P186 =  $line['P186'];
    if ($s_P186 ==0)
    {
      $s_P186 = 0;
    }
    else
    {
      $chkP186  = "checked";
    }
    $s_P182 =  $line['P182'];
    if ($s_P182 ==0)
    {
      $s_P182 = 0;
    }
    else
    {
      $chkP182  = "checked";
    }
    $s_P185 =  $line['P185'];
    if ($s_P185 ==0)
    {
      $s_P185 = 0;
    }
    else
    {
      $chkP185  = "checked";
    }

$s_P261 =  $line['P261'];
    if ($s_P261 ==0)
    {
      $s_P261 = 0;
    }
    else
    {
      $chkP261  = "checked";
    }
    $s_P262 =  $line['P262'];
    if ($s_P262 ==0)
    {
      $s_P262 = 0;
    }
    else
    {
      $chkP262  = "checked";
    }
    $s_P266 =  $line['P266'];
    if ($s_P266 ==0)
    {
      $s_P266 = 0;
    }
    else
    {
      $chkP266  = "checked";
    }
    $s_P264 =  $line['P264'];
    if ($s_P264 ==0)
    {
      $s_P264 = 0;
    }
    else
    {
      $chkP264  = "checked";
    }
    $s_P265 =  $line['P265'];
    if ($s_P265 ==0)
    {
      $s_P265 = 0;
    }
    else
    {
      $chkP265  = "checked";
    }

    $s_P271 =  $line['P271'];
    if ($s_P271 ==0)
    {
      $s_P271 = 0;
    }
    else
    {
      $chkP271  = "checked";
    }
    $s_P272 =  $line['P272'];
    if ($s_P272 ==0)
    {
      $s_P272 = 0;
    }
    else
    {
      $chkP272  = "checked";
    }
    $s_P276 =  $line['P276'];
    if ($s_P276 ==0)
    {
      $s_P276 = 0;
    }
    else
    {
      $chkP276  = "checked";
    }
    $s_P274 =  $line['P274'];
    if ($s_P274 ==0)
    {
      $s_P274 = 0;
    }
    else
    {
      $chkP274  = "checked";
    }
    $s_P275 =  $line['P275'];
    if ($s_P275 ==0)
    {
      $s_P275 = 0;
    }
    else
    {
      $chkP275  = "checked";
    }

    $s_P281 =  $line['P281'];
    if ($s_P281 ==0)
    {
      $s_P281 = 0;
    }
    else
    {
      $chkP281  = "checked";
    }
    $s_P282 =  $line['P282'];
    if ($s_P282 ==0)
    {
      $s_P282 = 0;
    }
    else
    {
      $chkP282  = "checked";
    }
    $s_P286 =  $line['P286'];
    if ($s_P286 ==0)
    {
      $s_P286 = 0;
    }
    else
    {
      $chkP286  = "checked";
    }
    $s_P284 =  $line['P284'];
    if ($s_P284 ==0)
    {
      $s_P284 = 0;
    }
    else
    {
      $chkP284  = "checked";
    }
    $s_P285 =  $line['P285'];
    if ($s_P285 ==0)
    {
      $s_P285 = 0;
    }
    else
    {
      $chkP285  = "checked";
    }

    $s_P467 =  $line['P467'];
    if ($s_P467 ==0)
    {
      $s_P467 = 0;
    }
    else
    {
      $chkP467  = "checked";
    }
    $s_P464 =  $line['P464'];
    if ($s_P464 ==0)
    {
      $s_P464 = 0;
    }
    else
    {
      $chkP464  = "checked";
    }
    $s_P466 =  $line['P466'];
    if ($s_P466 ==0)
    {
      $s_P466 = 0;
    }
    else
    {
      $chkP466  = "checked";
    }
    $s_P462 =  $line['P462'];
    if ($s_P462 ==0)
    {
      $s_P462 = 0;
    }
    else
    {
      $chkP462  = "checked";
    }
    $s_P461 =  $line['P461'];
    if ($s_P461 ==0)
    {
      $s_P461 = 0;
    }
    else
    {
      $chkP461  = "checked";
    }
   
    $s_P477 =  $line['P477'];
    if ($s_P477 ==0)
    {
      $s_P477 = 0;
    }
    else
    {
      $chkP477  = "checked";
    }
    $s_P474 =  $line['P474'];
    if ($s_P474 ==0)
    {
      $s_P474 = 0;
    }
    else
    {
      $chkP474  = "checked";
    }
    $s_P476 =  $line['P476'];
    if ($s_P476 ==0)
    {
      $s_P476 = 0;
    }
    else
    {
      $chkP476  = "checked";
    }
    $s_P472 =  $line['P472'];
    if ($s_P472 ==0)
    {
      $s_P472 = 0;
    }
    else
    {
      $chkP472  = "checked";
    }
    $s_P471 =  $line['P471'];
    if ($s_P471 ==0)
    {
      $s_P471 = 0;
    }
    else
    {
      $chkP471  = "checked";
    }

///////

    $s_P487 =  $line['P487'];
    if ($s_P487 ==0)
    {
      $s_P487 = 0;
    }
    else
    {
      $chkP487  = "checked";
    }

    $s_P484 =  $line['P484'];
    if ($s_P484 ==0)
    {
      $s_P484 = 0;
    }
    else
    {
      $chkP484  = "checked";
    }

    $s_P486 =  $line['P486'];
    if ($s_P486 ==0)
    {
      $s_P486 = 0;
    }
    else
    {
      $chkP486  = "checked";
    }

    $s_P482 =  $line['P482'];
    if ($s_P482 ==0)
    {
      $s_P482 = 0;
    }
    else
    {
      $chkP482  = "checked";
    }

    $s_P481 =  $line['P481'];
    if ($s_P481 ==0)
    {
      $s_P481 = 0;
    }
    else
    {
      $chkP481  = "checked";
    }
////////
    $s_P367 =  $line['P367'];
    if ($s_P367 ==0)
    {
      $s_P367 = 0;
    }
    else
    {
      $chkP367  = "checked";
    }
    $s_P362 =  $line['P362'];
    if ($s_P362 ==0)
    {
      $s_P362 = 0;
    }
    else
    {
      $chkP362  = "checked";
    }
    $s_P366 =  $line['P366'];
    if ($s_P366 ==0)
    {
      $s_P366 = 0;
    }
    else
    {
      $chkP366  = "checked";
    }
    $s_P364 =  $line['P364'];
    if ($s_P364 ==0)
    {
      $s_P364 = 0;
    }
    else
    {
      $chkP364  = "checked";
    }
    $s_P361 =  $line['P361'];
    if ($s_P361 ==0)
    {
      $s_P361 = 0;
    }
    else
    {
      $chkP361  = "checked";
    }

    $s_P377 =  $line['P377'];
    if ($s_P377 ==0)
    {
      $s_P377 = 0;
    }
    else
    {
      $chkP377  = "checked";
    }
    $s_P372 =  $line['P372'];
    if ($s_P372 ==0)
    {
      $s_P372 = 0;
    }
    else
    {
      $chkP372  = "checked";
    }
    $s_P376 =  $line['P376'];
    if ($s_P376 ==0)
    {
      $s_P376 = 0;
    }
    else
    {
      $chkP376  = "checked";
    }
    $s_P374 =  $line['P374'];
    if ($s_P374 ==0)
    {
      $s_P374 = 0;
    }
    else
    {
      $chkP374  = "checked";
    }
    $s_P371 =  $line['P371'];
    if ($s_P371 ==0)
    {
      $s_P371 = 0;
    }
    else
    {
      $chkP371  = "checked";
    }

    $s_P387 =  $line['P387'];
    if ($s_P387 ==0)
    {
      $s_P387 = 0;
    }
    else
    {
      $chkP387  = "checked";
    }
    $s_P382 =  $line['P382'];
    if ($s_P382 ==0)
    {
      $s_P382 = 0;
    }
    else
    {
      $chkP382  = "checked";
    }
    $s_P386 =  $line['P386'];
    if ($s_P386 ==0)
    {
      $s_P386 = 0;
    }
    else
    {
      $chkP386  = "checked";
    }
    $s_P384 =  $line['P384'];
    if ($s_P384 ==0)
    {
      $s_P384 = 0;
    }
    else
    {
      $chkP384  = "checked";
    }
    $s_P381 =  $line['P381'];
    if ($s_P381 ==0)
    {
      $s_P381 = 0;
    }
    else
    {
      $chkP381  = "checked";
    } 
    ///////////////indices de placa
    $s_numSupPlaca=$line['numSupPlaca'];
    $s_indicePlaca=$line['indicePlaca'];

    IF ($s_numSupPlaca==""){$s_numSupPlaca=0;}
    IF ($s_indicePlaca==""){$s_indicePlaca=0;}
 
  
    $s_regPlaNoApl = $line['noAplica'];
    if ($s_regPlaNoApl =="N" OR $s_regPlaNoApl =="")
    {
      $s_regPlaNoApl = "N";
    }
    else
    {    
      $chkRegPlaNoApl = "checked";
    }
    $s_obsRegPlaNoApl =  $line['obsNoAplica'];

  }//>0  


 /*===================================================================================
   =============================LISTAS DE DIAGNOSTICOS ===============================
   =================================================================================== */
    
  //consulta lista de odontograma de diagnosticos
  $query="SELECT * from SIO_LIS_ODONTOGRAMA WHERE tipOdo='DG' order by descripcion";
  $result = mysql_query($query) or die('Consulta de lista odontograma de diagnostico fallida: ' . mysql_error());
  //$line = mysql_fetch_array($result, MYSQL_ASSOC);  
    
  $comboLisOd="";
  while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) 
  {
   $comboLisOd .=" <option value='".$line['codigo']."'>".$line['descripcion']."</option>"; 
  }
  // Liberar resultados
  mysql_free_result($result);

  //consulta lista de odontograma de tratamiento
  $query="SELECT * from SIO_LIS_ODONTOGRAMA WHERE tipOdo='TR' order by descripcion";
  $result = mysql_query($query) or die('Consulta de lista odontograma de tratamiento fallida: ' . mysql_error());
  //$line = mysql_fetch_array($result, MYSQL_ASSOC);  
    
  $comboLisTr="";
  while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) 
  {
   $comboLisTr .=" <option value='".$line['codigo']."'>".$line['descripcion']."</option>"; 
  }
  // Liberar resultados
  mysql_free_result($result);


  //========================== ========================== 
  $query="SELECT * FROM SIO_GRUPO_CIE10";
  $result = mysql_query($query) or die('Consulta de grupos para cie10: ' . mysql_error());
  $i=0;
  while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
  {
    if ($i==0)
      {
        $comboGrCie10 .=" <option value=''>".'Grupo Diagnostico'."</option>";
      }
    //  else
    //  {  
        $comboGrCie10 .=" <option value='".$line['codGrupo']."'>".$line['nomGrupo']."</option>"; 
    //  }
    $i++; 
  }
  // Liberar resultados
  mysql_free_result($result); 
  //========================== ========================== 

 //========================== ========================== 
  $query="SELECT * FROM SIO_GRUPO_CUPS";
  $result = mysql_query($query) or die('Consulta de grupos para cups: ' . mysql_error());
  $i=0;
  while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
  {
    if ($i==0)
      {
        $comboGrCups .=" <option value=''>".'Grupo Cups'."</option>";
      }
    //  else
    //  {  
        $comboGrCups .=" <option value='".$line['codGrCups']."'>".$line['nomGrCups']."</option>"; 
    //  }
    $i++; 
  }
  // Liberar resultados
  mysql_free_result($result); 
  //========================== ========================== 

 //========================== ========================== 
  $query="SELECT * FROM SIO_GRUPO_CUPS";
  $result = mysql_query($query) or die('Consulta de grupos para cups 1: ' . mysql_error());
  $i=0;
  while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
  {
    if ($i==0)
      {
        $comboGrCups1 .=" <option value=''>".'Grupo Cups'."</option>";
      }
    //  else
    //  {  
        $comboGrCups1 .=" <option value='".$line['codGrCups']."'>".$line['nomGrCups']."</option>"; 
    //  }
    $i++; 
  }
  // Liberar resultados
  mysql_free_result($result); 
  //========================== ========================== 

  //GRABA DATOS DEL ODONTOGRAMA
  /* ============================================================================================================================
  ============================================================================================================================*/
 
  if(isset($_POST['grabarOd']))
  {
    //TOMA DIAGNOSTICO
    $s_grDg        = $_POST['grDg'];  
    $s_chkDgs      = $_POST['chkDgs']; 
    $s_chkCups     = $_POST['chkCups'];

    /*echo "dgs.." . $s_chkDgs;
    echo '<br>';
    echo "cups.." . $s_chkCups;
    echo '<br>';*/

    if ($s_chkDgs==on)
    {
      $tipoDeDiagnostico = "DG";
      $odonto            = $_POST['odonto'];      
      //TRAE UBICACION DEL DIAGNOSTICO
      $queryUbica  = "SELECT ubica FROM SIO_CIE10 WHERE codCie10 = '$odonto'";
      $result      = mysql_query($queryUbica) or die('Consulta de ubicacion Diagnostico fallida: ' . mysql_error()); 
      $line        = mysql_fetch_array($result, MYSQL_ASSOC);
      $s_ubicacion = $line['ubica']; 
    }
    if ($s_chkCups==on)
    {
      $tipoDeDiagnostico = "TR";
      $odonto            = $_POST['codCup'];      
      //TRAE UBICACION DEL DIAGNOSTICO
      $queryUbica  = "SELECT ubica FROM SIO_PROC_POS WHERE cups = '$odonto'";
      $result      = mysql_query($queryUbica) or die('Consulta de ubicacion Proceso fallida: ' . mysql_error()); 
      $line        = mysql_fetch_array($result, MYSQL_ASSOC);
      $s_ubicacion = $line['ubica'];
    }

   /* echo '<br>';
    echo "ubicacion.." . $s_ubicacion;
    echo '<br>';
    echo "tipo.." .  $tipoDeDiagnostico;
    echo '<br>';
    echo "diente.." .  $odonto;
    echo '<br>';*/

    //$odonto        = $_POST['odonto'];
    $caries        = $_POST['icCarNoCav'];
    $tOdo          = $_POST['tipOdo'];  
    $e_nvoNroCon   = $_POST['nroCta'];
    $nConsulta     = $e_nvoNroCon;
    $s_yaGrabo     = $_POST['yaGrabo'];

    /*echo "odonto.." . $odonto;
    echo '<br>';
    echo "caries.." . $caries;
    echo '<br>';
    echo "tOdo.." . $tOdo;*/

    ///GRABA CUANDO LA UBICACION DEL DIAGNOSTICO ES EN EL DIENTE
    if ($s_ubicacion=='DI')
    { 

//tipo="TR"

    if ($tipoDeDiagnostico=="DG")
    {
      echo '<br>';
      echo "entra a diente diagnostico.. ";
      echo '<br>';

      for ( $diente = 11 ; $diente <= 85 ; $diente ++ ) { //DIENTES
        for ( $cara = 0 ; $cara <= 7 ; $cara ++ ) { //CARAS
    
           $diCara = "C".$diente.$cara;
           $caraSel = $_POST[$diCara];
           
           if ($caraSel=="S" AND $odonto!="") 
           {
             //pone nombre a las caras
             if ($cara == 0)
             {
              $caraD = "TODO";
             }
             if ($cara == 1)
             {
              $caraD = "VESTIBULAR";
             }
             if ($cara == 2)
             {
              $caraD = "MESIAL";
             }
             if ($cara == 3)
             {
              $caraD = "INCISAL";
             }
             if ($cara == 4)
             {
              $caraD = "DISTAL";
             }
             if ($cara == 5)
             {
              $caraD = "PALATINO";
             }
             if ($cara == 6)
             {
              $caraD= "OCLUSAL";
             }
             if ($cara == 7)
             {
              $caraD = "LINGUAL";
             }

             //if($tOdo=="DG")
             //{
               // VERIFICA EXISTENCIA DE DATOS EN ODONTOGRAMA DE DIAGNOSTICOS
               //$query = "SELECT count(*) AS numC1 FROM SIO_DIA_ODONTOGRAMA where numConsulta=$nConsulta AND codDiag='$odonto' AND ".
               //         " numDiente=$diente AND caraDiente='$caraD' ";

               $query = "SELECT count(*) AS numC1 FROM SIO_DIA_ODONTOGRAMA where tipoId='$e_tipoId' AND idPaciente=$e_idPaciente AND codDiag='$odonto' AND ".
                        " numDiente=$diente AND caraDiente='$caraD' ";      
               $result = mysql_query($query) or die('Consulta numero de odontograma fallida: ' . mysql_error());
               $line = mysql_fetch_array($result, MYSQL_ASSOC);
               $odontos = $line["numC1"];
                

               if ($odontos==0) 
               {    
                 // INSERTAR ODONTOGRAMA DE DIAGNOSTICOS
                 $query = "INSERT INTO SIO_DIA_ODONTOGRAMA " .
                         "(nitEmpresa, " . 
                         "codSede, " . 
                         "tipoId, " .
                         "idPaciente, ".
                         "numConsulta, ".
                         "tipoHistoria, ".
                         "numDiente, ".
                         "caraDiente, ".
                         "codDiag,".
                         "observaciones,".
                         "medConsulta ) ".
                 " VALUES ($s_nitEmpresa, " . 
                         "$s_codSede, " .
                         "'$e_tipoId', ".
                         "$e_idPaciente, ".
                         "$nConsulta, ".
                         "'GENERAL', ".
                         "$diente, ".
                         "'$caraD', ".
                         "'$odonto',". 
                        "'$odontObserva',".
                        "$s_idUsuario)";    
                $result = mysql_query($query) or die('Insercion de odontograma de diagnosticos fallida: ' . mysql_error());
               }//if caraSel   
               else
               {
                 $query ="UPDATE SIO_DIA_ODONTOGRAMA SET observaciones='$odontObserva', medConsulta=$s_idUsuario WHERE numConsulta=$nConsulta AND codDiag='$odonto'AND ".
                       " numDiente=$diente AND caraDiente='$cara' ";
                 //$result = mysql_query($query) or die('Modificaci&oacute;n de odontograma  de diagnosticos fallida: ' . mysql_error());
               }
              //}//FIN DG

             //if($tOdo=="TR") 
             //{
               // VERIFICA EXISTENCIA DE DATOS ODONTOGRAMA DE TRATAMIENTO  
               //$query = "SELECT count(*) AS numC1 FROM SIO_TRA_ODONTOGRAMA where numConsulta=$nConsulta AND codDiag='$odonto' AND ".
               //         " numDiente=$diente AND caraDiente='$caraD' ";

               $query = "SELECT count(*) AS numC1 FROM SIO_TRA_ODONTOGRAMA where tipoId='$e_tipoId' AND idPaciente=$e_idPaciente AND codDiag='$odonto' AND ".
                        " numDiente=$diente AND caraDiente='$caraD' ";
               $result = mysql_query($query) or die('Consulta numero de odontograma  de tratramiento fallida: ' . mysql_error());
               $line = mysql_fetch_array($result, MYSQL_ASSOC);
               $odontosTr = $line["numC1"];
           
               if ($odontosTr==0) 
               {    
                 // INSERTAR ODONTOGRAMA DE TRATAMIENTO
                 $query = "INSERT INTO SIO_TRA_ODONTOGRAMA " .
                         "(nitEmpresa, " . 
                         "codSede, " . 
                         "tipoId, " .
                         "idPaciente, ".
                         "numConsulta, ".
                         "tipoHistoria, ".
                         "numDiente, ".
                         "caraDiente, ".
                         "codDiag,".
                         "observaciones,".
                         "medConsulta ) ".
                 " VALUES ($s_nitEmpresa, " . 
                         "$s_codSede, " .
                         "'$e_tipoId', ".
                         "$e_idPaciente, ".
                         "$nConsulta, ".
                         "'GENERAL', ".
                         "$diente, ".
                         "'$caraD', ".
                         "'$odonto',". 
                        "'$odontObserva',".
                        " $s_idUsuario)";      

                $result = mysql_query($query) or die('Insercion de odontograma de tratamiento fallida: ' . mysql_error());
               }//if caraSel   
               else
               {
                 $query ="UPDATE SIO_TRA_ODONTOGRAMA SET observaciones='$odontObserva', medConsulta=$s_idUsuario WHERE numConsulta=$nConsulta AND codDiag='$odonto'AND ".
                       " numDiente=$diente AND caraDiente='$cara' ";
                 //$result = mysql_query($query) or die('Modificaci&oacute;n de odontograma de tratamiento fallida: ' . mysql_error());
               }
             
             //}//FIN TR
    
           }//caraSel      
        }//FIN for CARAS         
      }//FIN for DIENTES
    }//FIN cuado es diagnostico DG

    ///// AQUI PARA TRATAMIENTOS

    if ($tipoDeDiagnostico=="TR")
    {
      echo '<br>';
      echo "entra a diente Tratamiento .. ";
      echo '<br>';

      for ( $diente = 11 ; $diente <= 85 ; $diente ++ ) { //DIENTES
        for ( $cara = 0 ; $cara <= 7 ; $cara ++ ) { //CARAS
    
           $diCara = "C".$diente.$cara;
           $caraSel = $_POST[$diCara];
           
           if ($caraSel=="S" AND $odonto!="") 
           {
             //pone nombre a las caras
             if ($cara == 0)
             {
              $caraD = "TODO";
             }
             if ($cara == 1)
             {
              $caraD = "VESTIBULAR";
             }
             if ($cara == 2)
             {
              $caraD = "MESIAL";
             }
             if ($cara == 3)
             {
              $caraD = "INCISAL";
             }
             if ($cara == 4)
             {
              $caraD = "DISTAL";
             }
             if ($cara == 5)
             {
              $caraD = "PALATINO";
             }
             if ($cara == 6)
             {
              $caraD= "OCLUSAL";
             }
             if ($cara == 7)
             {
              $caraD = "LINGUAL";
             }

             
            /////// GRABA EN LECTURA DE BOCA
            $query = "SELECT count(*) AS numC2 FROM SIO_DIA_ODONBOCA where tipoId='$e_tipoId' AND idPaciente=$e_idPaciente AND codDiag='$odonto' AND ".
                        " numDiente=$diente AND caraDiente='$caraD' ";
            $result = mysql_query($query) or die('Consulta numero de odontograma  de tratramiento fallida: ' . mysql_error());
            $line = mysql_fetch_array($result, MYSQL_ASSOC);
            $odontosB = $line["numC2"];

            if ($odontosB==0) 
            {    
               //INSERTAR ODONTOGRAMA DE DIAGNOSTICOS PARA TODA LA BOCA
               $query = "INSERT INTO SIO_DIA_ODONBOCA " .
                       "(nitEmpresa, " . 
                       "codSede, " . 
                       "tipoId, " .
                       "idPaciente, ".
                       "numConsulta, ".
                       "tipoHistoria, ".
                       "numDiente, ".
                       "caraDiente, ".
                       "codDiag,".
                       "tipo,".
                       "observaciones,".
                       "medConsulta ) ".
               " VALUES ($s_nitEmpresa, " . 
                       "$s_codSede, " .
                       "'$e_tipoId', ".
                       "$e_idPaciente, ".
                       "$nConsulta, ".
                       "'GENERAL', ".
                       "$diente, ".
                       "'$caraD', ".
                       "'$odonto',". 
                       "'$tipoDeDiagnostico',".  
                      "'$odontObserva',".
                      "$s_idUsuario)";  
               ECHO $query;
                      $result = mysql_query($query) or die('Insercion de odontograma de toda la boca fallida: ' . mysql_error());
             }               
             
             //}//FIN TR
    
           }//caraSel      
        }//FIN for CARAS         
      }//FIN for DIENTES
    }//FIN cuado es diagnostico TR



   }//IF GRABA CUANDO LA UBICACION DEL DIAGNOSTICO ES EN EL DIENTE
  
   //AQUI DEBE IR EL IF DE LA BOCA

   if ($s_ubicacion=='BO')
   {

     echo '<br>';
    echo "enta a boca.. ";
    echo '<br>';
    
     $query = "SELECT count(*) AS numC2 FROM SIO_DIA_ODONBOCA where tipoId='$e_tipoId' AND idPaciente=$e_idPaciente AND codDiag='$odonto'" ;
     $result = mysql_query($query) or die('Consulta numero de odontograma  de tratramiento fallida: ' . mysql_error());
     $line = mysql_fetch_array($result, MYSQL_ASSOC);
     $odontosB = $line["numC2"];

     if ($odontosB==0) 
     {    

     //INSERTAR ODONTOGRAMA DE DIAGNOSTICOS PARA TODA LA BOCA
               $query = "INSERT INTO SIO_DIA_ODONBOCA " .
                       "(nitEmpresa, " . 
                       "codSede, " . 
                       "tipoId, " .
                       "idPaciente, ".
                       "numConsulta, ".
                       "tipoHistoria, ".
                       "numDiente, ".
                       "caraDiente, ".
                       "codDiag,".
                       "tipo,".
                       "observaciones,".
                       "medConsulta ) ".
               " VALUES ($s_nitEmpresa, " . 
                       "$s_codSede, " .
                       "'$e_tipoId', ".
                       "$e_idPaciente, ".
                       "$nConsulta, ".
                       "'GENERAL', ".
                       "99, ".
                       "'TODO', ".
                       "'$odonto',". 
                       "'$tipoDeDiagnostico',".  
                      "'$odontObserva',".
                      "$s_idUsuario)";  
                      $result = mysql_query($query) or die('Insercion de odontograma de toda la boca fallida: ' . mysql_error());
     }                 
 
   }
  //FIN EL IF DE LA BOCA


  }//FIN GRABAR ODONTOGRAMA


 //FINNNN   GRABA DATOS DEL ODONTOGRAMA DE DIAGNOSTICO
 /* ============================================================================================================================
  ============================================================================================================================*/

 if(isset($_POST['BorrarOd']))
 {
   $e_nvoNroCon   = $_POST['nroCta'];
   $nConsulta     = $e_nvoNroCon;
   $s_yaGrabo     = $_POST['yaGrabo'];
   $id          = $_POST['BorrarOd']; 
    
   $fp   = explode("-", $id);
           $dg   = $fp[0];
           $dte  = $fp[1];
           $car  = $fp[2];

   //verifica si se puede borrar el diagnostico
   $queryCon = " SELECT codTra FROM SIO_TRA_MOVODONTO ". 
               " WHERE codDiag='$dg' AND numDiente=$dte AND caraDiente='$car' AND tipoId='$e_tipoId' AND idPaciente=$e_idPaciente";   
   
   $resultCON = mysql_query($queryCon) or die('Consulta de tratamiento de diagnostico fallida: ' . mysql_error());   
   while ($line = mysql_fetch_array($resultCON, MYSQL_ASSOC)) 
   {
     $tratamiento    = $line["codTra"];
   }

   if ($tratamiento=="")
   {
     //////////////////////////////////////////BORRA EN DIAGNOSTICOS 
     //$query = "DELETE FROM SIO_DIA_ODONTOGRAMA WHERE codDiag='$dg' AND numDiente=$dte AND caraDiente='$car' AND numConsulta=$nConsulta";
     $query = "DELETE FROM SIO_DIA_ODONTOGRAMA WHERE codDiag='$dg' AND numDiente=$dte AND caraDiente='$car' AND tipoId='$e_tipoId' AND idPaciente=$e_idPaciente";
     $result = mysql_query($query) or die('Eliminacion de Odontograma de diagnostico fallida: ' . mysql_error());

     //////////////////////////////////////////BORRA EN TRATAMIENTO
     $query = "DELETE FROM SIO_TRA_ODONTOGRAMA WHERE codDiag='$dg' AND numDiente=$dte AND caraDiente='$car' AND tipoId='$e_tipoId' AND idPaciente=$e_idPaciente";
     $result = mysql_query($query) or die('Eliminacion de Odontograma de tratamiento fallida: ' . mysql_error());

     //////////////////////////////////////////BORRA EN EVOLUCION 
     $query = "DELETE FROM SIO_EVO_ODONTOGRAMA WHERE codDiag='$dg' AND numDiente=$dte AND caraDiente='$car' AND tipoId='$e_tipoId' AND idPaciente=$e_idPaciente";
     $result = mysql_query($query) or die('Eliminacion de Odontograma de evolucion fallida: ' . mysql_error());
   }
   else
   {
    ?>
     <script> 
       alert("No se puede eliminar el diagnostico\nYa se esta realizando tratamiento");
     </script>
   <?php  
   }

 }//FIN BORRA ODONTOGRAMA DIAGNOSTICO  

 //MODIFIC DATOS DEL ODONTOGRAMA DE TRATAMIENTO
 /* ============================================================================================================================
  ============================================================================================================================*/

 if(isset($_POST['modificarTr']))
 {
   $e_nvoNroCon   = $_POST['nroCta'];
   $nConsulta     = $e_nvoNroCon;
   $s_yaGrabo     = $_POST['yaGrabo'];
   $id            = $_POST['modificarTr']; 

    $fp   = explode("-", $id);
            $dg   = $fp[0];
            $dte  = $fp[1];
            $car  = $fp[2];

    $s_enTrat       = $_POST['enTrat'];
    $s_realizado    = $_POST['realizado'];

      if ($s_realizado=="")
      {
        $s_estado = "EN-TRATAMIENTO";
        $s_trata ="S";   
        $s_terminado = "";            
      }
      else
      {
        $s_estado = "TERMINADO";
        $s_trata ="T";   
        $s_terminado = "S";            

      }

      $s_obsTr     = $_POST['obsTratamiento'];
      $s_odontoTr  = $_POST['odontoTr'];

      if($s_odontoTr!="")
      {
        //$query = "UPDATE SIO_TRA_ODONTOGRAMA SET observaciones='$s_obsTr', realizado='$s_terminado', tratamiento='$s_enTrat' WHERE codDiag='$dg' AND numDiente=$dte AND caraDiente='$car' AND numConsulta=$nConsulta";
 
        //$query = "UPDATE SIO_TRA_ODONTOGRAMA SET observaciones='$s_obsTr', realizado='$s_realizado', tratamiento='$s_enTrat', codTra='$s_odontoTr', medConsulta=$s_idUsuario WHERE codDiag='$dg' AND numDiente=$dte AND caraDiente='$car' AND tipoId='$e_tipoId' AND idPaciente=$e_idPaciente";
        //$result = mysql_query($query) or die('Modificacion de Odontograma de tratamiento fallida: ' . mysql_error());

        $queryCont = "select count(*) as cuantas  from SIO_TRA_MOVODONTO WHERE codDiag='$dg' AND codTra='$s_odontoTr' AND numDiente=$dte AND caraDiente='$car' AND tipoId='$e_tipoId' AND idPaciente=$e_idPaciente AND numConsulta= $nConsulta" ; 
        $resultCont = mysql_query($queryCont) or die('Consulta de cantidad de movimientos fallida: ' . mysql_error());
        $line = mysql_fetch_array($resultCont, MYSQL_ASSOC);
        $s_cuantas = $line["cuantas"];

        if ($s_cuantas==0)
        {  
         // INSERTAR MOVIMIENTOS DEL TRATAMIENTO
           $query = "INSERT INTO SIO_TRA_MOVODONTO " .
                       "(nitEmpresa, " . 
                       "codSede, " .
                       "numConsulta, ".
                       "tipoId, " .
                       "idPaciente, ".
                       "tipoHistoria, ".
                       "numDiente, ".
                       "caraDiente, ".
                       "codDiag,".
                       "codTra,".
                       "observaciones, ".
                       "estado,".
                       "medConsulta ) ".
               " VALUES ($s_nitEmpresa, " . 
                       "$s_codSede, " .
                       "$nConsulta, ".
                       "'$e_tipoId', ".
                       "$e_idPaciente, ".
                       "'GENERAL', ".
                       "$dte, ".
                       "'$car', ".
                       "'$dg',". 
                       "'$s_odontoTr',". 
                       "'$s_obsTr',".
                       "'$s_estado',". 
                       " $s_idUsuario)";  
              $result = mysql_query($query) or die('Insercion de movimiento de odontograma de tratamiento fallida: ' . mysql_error());
        }
        else
        {  
          // MODIFICA MOVIMIENTOS DEL TRATAMIENTO
          $query = "UPDATE SIO_TRA_MOVODONTO SET observaciones='$s_obsTr', estado='$s_estado', codTra='$s_odontoTr', medConsulta=$s_idUsuario WHERE codDiag='$dg' AND codTra='$s_odontoTr' AND numDiente=$dte AND caraDiente='$car' AND tipoId='$e_tipoId' AND idPaciente=$e_idPaciente AND numConsulta= $nConsulta" ; 
        $result = mysql_query($query) or die('Modificacion de Odontograma de movimiento de tratamiento fallida: ' . mysql_error());
        }

        // MODIFICA EL ESTADO DE EVOLUCION DEL DIENTE EN EL ENCABEZADO DEL TRATAMIENTO        
        //$queryEst = "UPDATE SIO_TRA_ODONTOGRAMA SET codTra='$s_odontoTr', tratamiento='$s_enQva' ".
        //            "WHERE codDiag='$dg' AND numDiente=$dte AND caraDiente='$car' AND ".
                    "tipoId='$e_tipoId' AND idPaciente=$e_idPaciente AND numConsulta= $nConsulta" ; 
        //$result = mysql_query($queryEst) or die('Modificacion de estado de tratamiento fallida: ' . mysql_error());       


$query = "UPDATE SIO_TRA_ODONTOGRAMA SET observaciones='$s_obsTr', realizado='$s_terminado', tratamiento='$s_trata', codTra='$s_odontoTr', medConsulta=$s_idUsuario WHERE codDiag='$dg' AND numDiente=$dte AND caraDiente='$car' AND tipoId='$e_tipoId' AND idPaciente=$e_idPaciente";
        $result = mysql_query($query) or die('Modificacion de Odontograma de tratamiento fallida: ' . mysql_error());


    }//SE SELECCIONO TRATAMIENTO
    else
     {

       echo "<script type=\"text/javascript\">alert(\"Debe Seleccionar un procedimiento\");</script>";  
       header("location: datosOdontograma.php#selTratamiento" );



     }//NO SE SELECCIONO TRATAMIENTO
   }//FIN MODIFICAR ODONTOGRAMA TRATAMIENTO

  //BORRA DATOS DEL ODONTOGRAMA DE TRATAMIENTO
  /* ============================================================================================================================
  ============================================================================================================================*/
  if(isset($_POST['BorrarTr']))
  {
   $e_nvoNroCon   = $_POST['nroCta'];
   
   $nConsulta     = $e_nvoNroCon;
   $s_yaGrabo     = $_POST['yaGrabo'];
   $id            = $_POST['BorrarTr']; 
    
   $fp   = explode("-", $id);
           $diagno = $fp[0];
           $diente = $fp[1];
           $cara   = $fp[2];
           $trata  = $fp[3];


   //////////////////// OJOOOOOOOOOOOOOOOOOO   verifica si se puede borrar el tratamiento
   //////////////////// CONSULTANDO EN LOS TRATAMIENTOS EVOLUCIONADOS SIO_EVO_ODONTOGRAMA
  
    //////////////////////////////////////////BORRA EN TRATAMIENTO
    $query = "DELETE FROM SIO_TRA_MOVODONTO WHERE codDiag='$diagno' AND codTra='$trata' AND numDiente=$diente AND caraDiente='$cara' AND tipoId='$e_tipoId' AND idPaciente=$e_idPaciente "; //AND numConsulta= $nConsulta" ; 
     $result = mysql_query($query) or die('Eliminacion de Odontograma de tratamiento fallida: ' . mysql_error());

  
  } //FIN BORRAR DATOS DEL ODONTOGRAMA TRATAMIENTO

  
  //BORRA DATOS DEL ODONTOGRAMA DE DIAGNOSTICOS BOCA
  /* ============================================================================================================================
  ============================================================================================================================*/
  if(isset($_POST['BorrarTrBoca']))
  {
   $e_nvoNroCon   = $_POST['nroCta'];
   
   $nConsulta     = $e_nvoNroCon;
   $s_yaGrabo     = $_POST['yaGrabo'];
   $id            = $_POST['BorrarTrBoca']; 
    
   /*$fp   = explode("-", $id);
           $diagN = $fp[0];
           $tipoD = $fp[1];*/

    $fp   = explode("-", $id);
           $diagN   = $fp[0];
           $dienteD = $fp[1];  
           $caraD   = $fp[2];       

   //////////////////////////////////////////BORRA EN SIO_DIA_ODONBOCA
   //$query = "DELETE FROM SIO_DIA_ODONBOCA WHERE codDiag='$diagN' AND tipo = '$tipoD' AND tipoId='$e_tipoId' AND idPaciente=$e_idPaciente" ;// AND numConsulta= $nConsulta" ; 
   $query = "DELETE FROM SIO_DIA_ODONBOCA WHERE " .
            " codDiag='$diagN' AND numDiente=$dienteD AND caraDiente='$caraD' AND tipoId='$e_tipoId' AND idPaciente=$e_idPaciente" ;
   $result = mysql_query($query) or die('Eliminacion de  diagnostico boca fallida: ' . mysql_error());

           
  } //FIN BORRAR ODONTOGRAMA DE DIAGNOSTICOS BOCA


  //VARIABLES PARA  TABLAS DE LA HISTORIA DE TRATAMIENTO -- GENERAL --
  /* ============================================================================================================================
  ============================================================================================================================*/
   
  if(isset($_POST['submit']))
  {
    $s_tipoId      = $_POST['e_tipoId']; 
    $s_identifica  = $_POST['e_identifica'];
    $s_yaGrabo     = $_POST['yaGrabo'];
    $e_nvoNroCon   = $_POST['nroCta'];

   /* echo '<br>';
    ECHO "LA CUENTA " . $e_nvoNroCon;
    echo '<br>';*/

    $nConsulta =$e_nvoNroCon;
    $s_tipoHistoria = $_POST['s_tipoHistoria'];
    $viene          = $_POST['viD'];
    $pc            = $_POST['pc'];
    //$activeBoton  = $_POST['activeBoton'];
    $e_tratamiento  = $_POST['trat'];
    
    //DEFAULT HORA EN BOGOTA;
    date_default_timezone_set("America/Bogota");
    $w_fecha =  date("Y/m/d H:i:s");
    //$w_fecha          = date("Y-m-d",time());

    //////////////////////////////////////////////////////////// 
    //Controla el numero de consulta
    //////////////////////////////////////////////////////////// 

    echo '<br>';
    //ECHO "YA GRABO " . $s_yaGrabo;
    echo '<br>';

    if ($s_yaGrabo=="")
    {
       // conexion a la base de datos
       //include("conexion.php");
       // Realiza consulta del numero de consulta a asignar MySQL
       $query = "SELECT numConsulta AS nroCon FROM SIO_CON_CONSULTAS";// WHERE nitEmpresa=$s_nitEmpresa";
            
       //$result = mysql_query($query) or die('Consulta de Numero Consulta fallida: ' . mysql_error());
       $line = mysql_fetch_array($result, MYSQL_ASSOC);
       //asigna valores a variables de trabajo
       $nvoNroCon = $line["nroCon"];
       $nvoNroCon = $nvoNroCon+1;
       $e_nvoNroCon = $nvoNroCon; 
       $s_yaGrabo="S";
       // Liberar resultados
       mysql_free_result($result);
                     
       //<!---------------- Realiza insercion de datos de movimiento de consultas de pacientes ---------------->
       // MOVIMIENTO DE CONSULTAS
       $query  = "INSERT INTO SIO_CON_PACIENTE " .
                 "(nitEmpresa, codSede, tipoId, idPaciente, numConsulta, tipoHistoria, causaConsulta, ".
                 "codEntidad, codTipoConsulta, fechaConsulta, medConsulta) " .                    
                  //" VALUES($s_nitEmpresa, $s_codSede, '$e_tipoId', $e_idPaciente, $e_nvoNroCon, '$s_tipoHistoria', ".
                 " VALUES($s_nitEmpresa, $s_codSede, '$e_tipoId', $e_idPaciente, $pc, '$s_tipoHistoria', ".
                 " '$s_codCausa', '$s_codEntidad', $s_tipoCon, '$w_fecha ', $s_idUsuario)";
       $result = mysql_query($query) or die('Adicion de movimiento en  SIO_CON_PACIENTE: ' . mysql_error());  
       // Liberar resultados
       mysql_free_result($result); 
             
       //<!---------------- Realiza actualizacion de consecutivo de consultas ---------------->
       // NUMERO DE CONSULTA
       $query = "UPDATE SIO_CON_CONSULTAS SET numConsulta = $e_nvoNroCon "; //WHERE nitEmpresa=$s_nitEmpresa";
       //$result = mysql_query($query) or die('Modificacion numero de consulta  fallida: ' . mysql_error());
       // Liberar resultados
       mysql_free_result($result);
            
       $activeBoton = "S";
            
       //<!---------------- Realiza insercion de datos en movimiento de citas y actualiza estado de citas ----------------> 
      

       if ($pc>0)
       {
          $w_fecha = date("Y-m-d",time()); 
          date_default_timezone_set("America/Bogota");
          $fecha =  date("Y/m/d H:i:s");
          $queryU=" UPDATE SIO_O_CITAS set estado='ATENDIDA', fechaAtencion='$w_fecha', horaIniAtencion='$fecha', numConsulta=$nvoNroCon, tipoHistoria='$s_tipoHistoria',  medConsulta = $s_idUsuario ".  
                  "WHERE preconsulta=$pc";                  
          $result = mysql_query($queryU) or die('Modificacion estado de preconsulta fallida: ' . mysql_error()); 
          // Liberar resultados
          mysql_free_result($result);
      
          $query = " INSERT INTO `SIO_O_CITAS_MOV` (`preConsulta`, `nitEmpresa`, `codSede`, `tipoId`, `idPaciente`, `estado`, `usuario`, `fechaEstado`, horaIniAtencion) ".
                   " VALUES ($pc, $s_nitEmpresa, $s_codSede, '$e_tipoId', $e_idPaciente, 'ATENDIDA',$s_idUsuario,'$w_fecha', '$fecha')";
          $result = mysql_query($query) or die('Insercion de movimiento de cita fallida: ' . mysql_error());  
          // Liberar resultados
          mysql_free_result($result); 

          //inserta en tratamiento consultas sio_trat_con
          $queryIn = " INSERT INTO SIO_TRAT_CON " .
                     "(tratamiento, numConsulta, estado, fechaCreacion)".
               "values($e_tratamiento, $pc, 'A', '$fecha')";
          $result = mysql_query($queryIn) or die('Insercion de tratamiento y consulta fallidas: ' . mysql_error());  
          // Liberar resultados
          mysql_free_result($result);      


       }
    } //ya grabo


    ////////////////////////////////////////////////////////////
      ////GRABA DATOS DE QUIEN ATIENDE LAS CITAS
    ////////////////////////////////////////////////////////////

    $queryExCon  = "SELECT COUNT(*) AS CTS FROM SIO_CIT_ATENDIDAS WHERE numTratamiento=$e_tratamiento AND numConsulta=$pc "; 
    $resultExCon = mysql_query($queryExCon) or die('Consulta de cita atendida fallida: ' . mysql_error());
    $lineExCon   = mysql_fetch_array($resultExCon, MYSQL_ASSOC); 
    $cts = $lineExCon['CTS'];

    if ($cts==0)
    {
     $queryInsExCon = " INSERT INTO SIO_CIT_ATENDIDAS ( " .
                      " numTratamiento, numConsulta, fechaConsulta, medConsulta )".
                      " VALUES ($e_tratamiento, $pc, '$w_fecha ', $s_idUsuario ) " ;
     $resultInExCon = mysql_query($queryInsExCon) or die('Adicion de cita atendida fallida: ' . mysql_error());                  
    }
    else
    {
     $queryUpdExCon = " UPDATE SIO_CIT_ATENDIDAS " .
                      " SET fechaConsulta='$w_fecha', medConsulta=$s_idUsuario ".
                      " WHERE numTratamiento=$e_tratamiento AND numConsulta=$pc ";
     $resultUpdCon = mysql_query($queryUpdExCon) or die('Modificacion de cita atendida fallida: ' . mysql_error()); 

    }


    //////////////////////////////////////////////////////////// 
    // VARIABLES SITUACION ACTUAL
    //////////////////////////////////////////////////////////// 
    $s_motConsulta = $_POST['motivoConsulta'];
    $s_enfActual   = $_POST['enfermedadActual']; 
    $s_antFam      = $_POST['antecedentesFam'];
    
    //////////////////////////////////////////////////////////// 
    //VARIABLES ANTECEDENTES ODONTOLOGICOS
    ////////////////////////////////////////////////////////////
    $s_alergias          = $_POST['alergias'];
    if ($s_alergias =="")
    {
      $s_alergias = "N";
    }
    else
    {    
      $chkAlergia = "checked";
    }
    $s_obsAlergia       = $_POST['obsAlergia'];

    //-------------------------------------------------------//
    $s_discrasiasSang    = $_POST['discrasiasSang'];
    if ($s_discrasiasSang =="")
    {
      $s_discrasiasSang = "N";
    }
    else
    {    
      $chkDiscrasias = "checked";
    }
    $s_obsDiscrasiasSang= $_POST['obsDiscrasiasSang'];
    //-------------------------------------------------------//
    $s_cardiopatias      = $_POST['cardiopatias'];
    if ($s_cardiopatias =="")
    {
      $s_cardiopatias = "N";
    }
    else
    {    
      $chkCardio = "checked";
    }
    $s_obsCardiopatias  = $_POST['obsCardiopatias'];
    //-------------------------------------------------------//
    $s_embarazo          = $_POST['embarazo'];
    if ($s_embarazo =="")
    {
      $s_embarazo = "N";
    }
    else
    {    
      $chkEmbarazo = "checked";
    }
    $s_obsEmbarazo = $_POST['obsEmbarazo'];
    //-------------------------------------------------------//
    $s_altPresArterial   = $_POST['altPresArterial'];
    if ($s_altPresArterial =="")
    {
      $s_altPresArterial = "N";
    }
    else
    {
      $chkPresArt = "checked";
    }
    $s_obsAltPresArterial = $_POST['obsAltPresArterial'];
    //-------------------------------------------------------//
    $s_tomaMedicamentos  = $_POST['tomaMedicamentos'];
    if ($s_tomaMedicamentos =="")
    {
      $s_tomaMedicamentos = "N";
    }
    else
    {    
      $chkTomaMedicamentos = "checked";
    }
    $s_obsTomaMedicamentos = $_POST['obsTomaMedicamentos'];
    //-------------------------------------------------------//
    $s_tratMedActual     = $_POST['tratMedActual'];
    if ($s_tratMedActual =="")
    {
      $s_tratMedActual = "N";
    }
    else
    {    
      $chkTratMedActual = "checked";
    }
    $s_obsTratMedActual= $_POST['obsTratMedActual'];
    //-------------------------------------------------------//
    $s_hepatitis         = $_POST['hepatitis'];
    if ($s_hepatitis =="")
    {
      $s_hepatitis = "N";
    }
    else
    {    
      $chkHepatitis = "checked";
    }
    $s_obsHepatitis = $_POST['obsHepatitis'];
    //-------------------------------------------------------//
    $s_diabetes          = $_POST['diabetes'];
    if ($s_diabetes =="")
    {
      $s_diabetes = "N";
    }
    else
    {    
      $chkDiabetes = "checked";
    }
    $s_obsDiabetes = $_POST['obsDiabetes'];
    //-------------------------------------------------------//
    $s_fiebreReum        = $_POST['fiebreReum'];
    if ($s_fiebreReum =="")
    {
      $s_fiebreReum = "N";
    }
    else
    {    
     $chkFiebreReum = "checked";
    }
    $s_obsFiebreReum = $_POST['obsFiebreReum'];
    //-------------------------------------------------------//
    $s_sida              = $_POST['sida'];
    if ($s_sida =="")
    {
      $s_sida = "N";
    }
    else
    {    
      $chkSida = "checked";
    }
    $s_obsSida = $_POST['obsSida'];
    //-------------------------------------------------------//
    $s_inmunosupresion   = $_POST['inmunosupresion'];
    if ($s_inmunosupresion =="")
    {
      $s_inmunosupresion = "N";
    }
    else
    {    
      $chkInmuno = "checked";
    }
    $s_obsInmunosupresion = $_POST['obsInmunosupresion'];
    //-------------------------------------------------------//
    $s_patologiasRenales = $_POST['patologiasRenales'];
    if ($s_patologiasRenales =="")
    {
      $s_patologiasRenales = "N";
    }
    else
    {    
      $chkPatRenal = "checked";
    }
    $s_obsPatologiasRenales = $_POST['obsPatologiasRenales'];
    //-------------------------------------------------------//
    $s_patRespiratoria   = $_POST['patRespiratoria'];
    if ($s_patRespiratoria =="")
    {
      $s_patRespiratoria = "N";
    }
    else
    {    
      $chkPatResp = "checked";
    }
    $s_obsPatRespiratoria = $_POST['obsPatRespiratoria'];
    //-------------------------------------------------------//
    $s_trasGastricos     = $_POST['trasGastricos'];
    if ($s_trasGastricos =="")
    {
     $s_trasGastricos = "N";
    }
    else
    {    
     $chkTrasGastricos = "checked";
    }
    $s_obsTrasGastricos = $_POST['obsTrasGastricos'];
    //-------------------------------------------------------//
    $s_trasEmocional     = $_POST['trasEmocional'];
    if ($s_trasEmocional =="")
    {
      $s_trasEmocional = "N";
    }
    else
    {    
      $chktTrasEmocional = "checked";
    }
    $s_obsTrasEmocional = $_POST['obsTrasEmocional'];
    //-------------------------------------------------------//
    $s_sinusitis         = $_POST['sinusitis'];
    if ($s_sinusitis =="")
    {
      $s_sinusitis = "N";
    }
    else
    {    
      $chkSinusitis = "checked";
    }
    $s_obsSinusitis= $_POST['obsSinusitis'];
    //-------------------------------------------------------//
    $s_cirugias          = $_POST['cirugias'];
    if ($s_cirugias =="")
    {
      $s_cirugias = "N";
    }
    else
    {    
      $chkCirugias = "checked";
    }
    $s_obsCirugias = $_POST['obsCirugias'];
    //-------------------------------------------------------//
    $s_exodoncias        = $_POST['exodoncias'];
    if ($s_exodoncias =="")
    {
      $s_exodoncias = "N";
    }
    else
    {    
      $chkExodoncias = "checked";
    }
    $s_obsExodoncias = $_POST['obsExodoncias'];
    //-------------------------------------------------------//
    $s_enfOrales         = $_POST['enfOrales'];
    if ($s_enfOrales =="")
    {
      $s_enfOrales = "N";
    }
    else
    {    
      $chkEnfOrales = "checked";
    }
    $s_obsEnfOrales = $_POST['obsEnfOrales'];
    //-------------------------------------------------------//
    $s_usoProtesis       = $_POST['usoProtesis'];
    if ($s_usoProtesis =="")
    {
      $s_usoProtesis = "N";
    }
    else
    {    
      $chkUsoProtesis = "checked";
    }
    $s_obsUsoProtesis = $_POST['obsUsoProtesis'];
    //-------------------------------------------------------//
    $s_habitos           = $_POST['habitos'];
    

    /////////////////////////////////////////////////////////// 
    //VARIABLES EXAMEN ESTOMATOLOGICO
    ////////////////////////////////////////////////////////////
    
     $s_labioInferior    = $_POST['labioInferior'];
     if ($s_labioInferior == "Normal")
     {
       $labioInferiorNormal ="selected";
     }
     if ($s_labioInferior == "Anormal")
     {
       $labioInferiorAnormal ="selected";
     }
     $s_obsLabioInferior = $_POST['obsLabioInferior'];
     //-------------------------------------------------------//
     $s_labioSuperior    = $_POST['labioSuperior'];
     if ($s_labioSuperior == "Normal")
     {
       $labioSuperiorNormal ="selected";
     }
     if ($s_labioSuperior == "Anormal")
     {
       $labioSuperiorAnormal ="selected";
     }
     $s_obsLabioSuperior = $_POST['obsLabioSuperior'];
     //-------------------------------------------------------//
     $s_comisuras= $_POST['comisuras'];
     if ($s_comisuras == "Normal")
     {
      $comisurasNormal ="selected";
     }
     if ($s_comisuras == "Anormal")
     {
               $comisurasAnormal ="selected";
     }
     $s_obsComisuras= $_POST['obsComisuras'];
     //-------------------------------------------------------//
     $s_mucosaOral= $_POST['mucosaOral'];
     if ($s_mucosaOral == "Normal")
     {
      $mucosaOralNormal ="selected";
     }
     if ($s_mucosaOral == "Anormal")
     {
       $mucosaOralAnormal ="selected";
     }
     $s_obsMucosaOral= $_POST['obsMucosaOral'];
     //-------------------------------------------------------//
     $s_surcosYugales= $_POST['surcosYugales'];
     if ($s_surcosYugales == "Normal")
     {
      $surcosYugalesNormal ="selected";
     }
     if ($s_surcosYugales == "Anormal")
     {
      $surcosYugalesAnormal ="selected";
     }
     $s_obsSurcosYugales = $_POST['obsSurcosYugales'];
     //-------------------------------------------------------//
     $s_frenillos = $_POST['frenillos'];
     if ($s_frenillos == "Normal")
     {
       $frenillosNormal ="selected";
     }
     if ($s_frenillos == "Anormal")
     {
       $frenillosAnormal ="selected";
     }
     $s_obsFrenillos= $_POST['obsFrenillos'];
     //-------------------------------------------------------//
     $s_oroFaringe= $_POST['oroFaringe'];
     if ($s_oroFaringe == "Normal")
     {
       $oroFaringeNormal ="selected";
     }
     if ($s_oroFaringe == "Anormal")
     {
       $oroFaringeAnormal ="selected";
     }
     $s_obsOrofaringe= $_POST['obsOrofaringe'];
     //-------------------------------------------------------//
     $s_paladar= $_POST['paladar'];
     if ($s_paladar == "Normal")
     {
       $paladarNormal ="selected";
     }
     if ($s_paladar == "Anormal")
     {
       $paladarAnormal ="selected";
     }
     $s_obsPaladar= $_POST['obsPaladar'];
     //-------------------------------------------------------//
     $s_glandSalivales= $_POST['glandSalivales'];
     if ($s_glandSalivales == "Normal")
     {
       $glandSalivalesNormal ="selected";
     }
     if ($s_glandSalivales == "Anormal")
     {
       $glandSalivalesAnormal ="selected";
     }
     $s_obsGlandSalivales = $_POST['obsGlandSalivales'];
     //-------------------------------------------------------//
     $s_pisoBoca    = $_POST['pisoBoca'];
     if ($s_pisoBoca == "Normal")
     {
       $pisoBocaNormal ="selected";
     }
     if ($s_pisoBoca == "Anormal")
     {
       $pisoBocaAnormal ="selected";
     }
     $s_obsPisoBoca  = $_POST['obsPisoBoca'];
     //-------------------------------------------------------//
     $s_dorsoLengua= $_POST['dorsoLengua'];
     if ($s_dorsoLengua == "Normal")
     {
       $dorsoLenguaNormal ="selected";
     }
     if ($s_dorsoLengua == "Anormal")
     {
      $dorsoLenguaAnormal ="selected";
     }
     $s_obsDorsoLengua= $_POST['obsDorsoLengua'];
     //-------------------------------------------------------//
     $s_vientreLengua= $_POST['vientreLengua'];
     if ($s_vientreLengua == "Normal")
     {
       $vientreLenguaNormal ="selected";
     }
     if ($s_vientreLengua == "Anormal")
     {
       $vientreLenguaAnormal ="selected";
     }
     $s_obsVientreLengua= $_POST['obsVientreLengua'];
     
     /////////////////////////////////////////////////////////// 
    //VARIABLES ARTICULACION TEMPORO MANDIBULAR
    ////////////////////////////////////////////////////////////
    $s_ruidos= $_POST['ruidos'];
    if ($s_ruidos == "Normal")
    {
      $ruidosNormal ="selected";
    }
    if ($s_ruidos == "Anormal")
    {
      $ruidosAnormal ="selected";
    }
    $s_obsRuidos= $_POST['obsRuidos'];
    //-------------------------------------------------------//
    $s_desviacion= $_POST['desviacion'];
    if ($s_desviacion == "Normal")
    {
        $desviacionNormal ="selected";
    }
    if ($s_desviacion == "Anormal")
    {
      $desviacionAnormal ="selected";
    }
    $s_obsDesviacion= $_POST['obsDesviacion'];
    //-------------------------------------------------------//
    $s_cambioVolumen= $_POST['cambioVolumen'];
    if ($s_cambioVolumen == "Normal")
    {
      $cambioVolumenNormal ="selected";
    }
    if ($s_cambioVolumen == "Anormal")
    {
      $cambioVolumenAnormal ="selected";
    }
    $s_obsCambioVolumen= $_POST['obsCambioVolumen'];
    //-------------------------------------------------------//
    $s_bloqueoMand= $_POST['bloqueoMand'];
    if ($s_bloqueoMand == "Normal")
    {
     $bloqueoMandNormal ="selected";
    }
    if ($s_bloqueoMand == "Anormal")
    {
     $bloqueoMandAnormal ="selected";
    }
    $s_obsBloqueMand= $_POST['obsBloqueMand'];
    //-------------------------------------------------------//
    $s_limitApertura= $_POST['limitApertura'];
    if ($s_limitApertura == "Normal")
    {
      $limitAperturaNormal ="selected";
    }
    if ($s_limitApertura == "Anormal")
    {
      $limitAperturaAnormal ="selected";
    }
    $s_obsLimitApertura= $_POST['obsLimitApertura'];
    //-------------------------------------------------------//
    $s_dolorArticular= $_POST['dolorArticular'];
    if ($s_dolorArticular == "Normal")
    {
      $dolorArticularNormal ="selected";
    }
    if ($s_dolorArticular == "Anormal")
    {
      $dolorArticularAnormal ="selected";
    }
    $s_obsDolorArticular= $_POST['obsDolorArticular'];
    //-------------------------------------------------------//
    $s_dolorMuscular= $_POST['dolorMuscular'];
    if ($s_dolorMuscular == "Normal")
    {
     $dolorMuscularNormal ="selected";
    }
    if ($s_dolorMuscular == "Anormal")
    {
     $dolorMuscularAnormal ="selected";
    }
    $s_obsDolorMuscular= $_POST['obsDolorMuscular'];
    
    /////////////////////////////////////////////////////////// 
    //VARIABLES HIGIENE ORAL
    ////////////////////////////////////////////////////////////
    $s_higiene= $_POST['higiene'];
    if ($s_higiene == "Buena")
    {
     $hBuena="selected";
    }
    if ($s_higiene == "Regular")
    {
     $hRegular="selected";
    }
    if ($s_higiene == "Mala")
    {
     $hMala="selected";
    }
    //-------------------------------------------------------//
    $s_freCepillado= $_POST['freCepillado'];
    if ($s_freCepillado == "Tres Veces")
    {
      $fCtres="selected";
    }
    if ($s_freCepillado == "Dos Veces")
    {
      $fCdos="selected";
    }
    if ($s_freCepillado == "Una Vez")
    {
      $fCuno="selected";
    }
    //-------------------------------------------------------//
    $s_sedaDental= $_POST['sedaDental'];
    if ($s_sedaDental =="" OR $s_sedaDental =="N")
    {
     $s_sedaDental = "N";
     $chkSedaDental = "";
    }
    else
    {    
       $chkSedaDental = "checked";
    }
    //-------------------------------------------------------//
    $s_pigmentacion= $_POST['pigmentacion'];
    if ($s_pigmentacion =="" OR $s_pigmentacion =="N")
    {
      $s_pigmentacion = "N";
      $chkPigmentacion="";
    }
    else
    {    
      $chkPigmentacion = "checked";
    }
    //-------------------------------------------------------//
    $s_gradoRiesgo= $_POST['gradoRiesgo'];
    if ($s_gradoRiesgo == "Bajo")
    {
      $grBajo="selected";
    }
    if ($s_gradoRiesgo == "Medio")
    {
      $grMedio="selected";
    }
    if ($s_gradoRiesgo == "Alto")
    {
     $grAlto="selected";
    }
    //-------------------------------------------------------//
    $s_obsHigiene= $_POST['obsHigiene'];
   
    //VARIABLES EXAMEN PULPAR
    $s_cuelloSencible= $_POST['cuelloSencible'];
    if ($s_cuelloSencible =="")
    {
      $s_cuelloSencible = "N";
    }
    else
    {    
     $chkCuelloSencible = "checked";
    }
    $s_obsCuelloSencible= $_POST['obsCuelloSencible'];
    //-------------------------------------------------------//
    $s_abscesos= $_POST['abscesos'];
    if ($s_abscesos =="")
    {
      $s_abscesos = "N";
    }
    else
    {    
      $chkAbscesos= "checked";
    }
    $s_obsAbscesos= $_POST['obsAbscesos'];
    //-------------------------------------------------------//
    $s_exposicionPulpar= $_POST['exposicionPulpar'];
    if ($s_exposicionPulpar =="")
    {
      $s_exposicionPulpar = "N";
    }
    else
    {    
      $chkExposicionPulpar= "checked";
    }
    $s_obsExposicionPulpar= $_POST['obsExposicionPulpar'];
    //-------------------------------------------------------//
    $s_cambioColor= $_GET['cambioColor'];
    if ($s_cambioColor =="")
    {
     $s_cambioColor = "N";
    }
    else
    {    
      $chkCambioColor= "checked";
    }
    $s_obsCambioColor= $_POST['obsCambioColor'];
    //-------------------------------------------------------//

    ///////////////////////////////////////////////////////////  
    //VARIABLES PROTESIS   
    ///////////////////////////////////////////////////////////  
    $s_protesis = $_POST['protesis'];
    if ($s_protesis =="")
    {
      $s_protesis = "N";
    }
    else
    {    
     $chkProtesis = "checked";
    }
    $s_obsProtesis = $_POST['obsProtesis'];
   
    ///////////////////////////////////////////////////////////  
    //VARIABLES EXAMEN PULPAR 
    /////////////////////////////////////////////////////////// 
    $s_cuelloSencible= $_POST['cuelloSencible'];
    if ($s_cuelloSencible =="")
    {
      $s_cuelloSencible = "N";
    }
    else
    {    
     $chkCuelloSencible = "checked";
    }
    $s_obsCuelloSencible= $_POST['obsCuelloSencible'];
    //-------------------------------------------------------//
    $s_abscesos= $_POST['abscesos'];
    if ($s_abscesos =="")
    {
     $s_abscesos = "N";
    }
    else
    {    
     $chkAbscesos= "checked";
    }
    $s_obsAbscesos= $_POST['obsAbscesos'];
    //-------------------------------------------------------//
    $s_exposicionPulpar= $_POST['exposicionPulpar'];
    if ($s_exposicionPulpar =="")
    {
      $s_exposicionPulpar = "N";
    }
    else
    {    
      $chkExposicionPulpar= "checked";
    }
    $s_obsExposicionPulpar= $_POST['obsExposicionPulpar'];
    //-------------------------------------------------------//
    $s_cambioColor= $_POST['cambioColor'];
    if ($s_cambioColor =="")
    {
      $s_cambioColor = "N";
    }
    else
    {    
      $chkCambioColor= "checked";
    }
    $s_obsCambioColor= $_POST['obsCambioColor'];
    
    ///////////////////////////////////////////////////////////  
    //VARIABLES TEJIDOS DENTARIOS Y OCLUSION
    ///////////////////////////////////////////////////////////  
    
    $s_supernumerarios= $_POST['supernumerarios'];
    if ($s_supernumerarios =="")
    {
     $s_supernumerarios = "N";
    }
    else
    {    
      $chkSupernumerarios= "checked";
    }
    $s_obsSupernumerarios= $_POST['obsSupernumerarios'];
    //-------------------------------------------------------//
    $s_decoloracion= $_POST['decoloracion'];
    if ($s_decoloracion =="")
    {
     $s_decoloracion = "N";
    }
    else
    {    
     $chkDecoloracion= "checked";
    }
    $s_obsDecoloracion= $_POST['obsDecoloracion'];
    //-------------------------------------------------------//
    $s_descalsificacion= $_POST['descalsificacion'];
    if ($s_descalsificacion =="")
    {
     $s_descalsificacion = "N";
    }
    else
    {    
      $chkDescalsificacion= "checked";
    }
    $s_obsDescalsificacion= $_POST['obsDescalsificacion'];
    //-------------------------------------------------------//
    $s_facetaDesgaste= $_POST['facetaDesgaste'];
    if ($s_facetaDesgaste =="")
    {
      $s_facetaDesgaste = "N";
    }
    else
    {    
     $chkFacetaDesgaste= "checked";
    }
    $s_obsFacetaDesgaste= $_POST['obsFacetaDesgaste'];
    //-------------------------------------------------------//
    $s_abrasion= $_POST['abrasion'];
    if ($s_abrasion =="")
    {
     $s_abrasion = "N";
    }
    else
    {    
     $chkAbrasion= "checked";
    }
    $s_obsAbrasion= $_POST['obsAbrasion'];
    //-------------------------------------------------------//
    $s_fluorosis= $_POST['fluorosis'];
    if ($s_fluorosis =="")
    {
      $s_fluorosis = "N";
    }
    else
    {    
     $chkFluorosis= "checked";
    }
    $s_obsFluorosis= $_POST['obsFluorosis'];
    
    ///////////////////////////////////////////////////////////  
    //VARIABLES ALTERACIONES PERIODENTALES  
    /////////////////////////////////////////////////////////// 
    $s_sangrado= $_POST['sangrado'];
    if ($s_sangrado =="")
    {
      $s_sangrado = "N";
    }
    else
    {    
      $chkSangrado = "checked";
    }
    $s_obsSangrado= $_POST['obsSangrado'];
    //---------------------------------------//
    $s_exudado = $_POST['exudado'];
    if ($s_exudado=="")
    {
      $s_exudado = "N";
    }
    else
    {    
     $chkExudado = "checked";
    }
    $s_obsExudado = $_POST['obsExudado'];
    //---------------------------------------//
    $s_supuracion = $_POST['supuracion'];
    if ($s_supuracion =="")
    {
      $s_supuracion = "N";
    }
    else
    {    
     $chkSupuracion = "checked";
    }
    $s_obsSupuracion = $_POST['obsSupuracion'];
    //---------------------------------------// 
    $s_calculos= $_POST['calculos'];
    if ($s_calculos =="")
    {
       $s_calculos = "N";
    }
    else
    {    
       $chkCalculos = "checked";
    }
    $s_obsCalculos= $_POST['obsCalculos'];
    //-------------------------------------------------------//
    $s_inflamacion= $_POST['inflamacion'];
    if ($s_inflamacion =="")
    {
       $s_inflamacion = "N";
    }
    else
    {    
       $chkInflamacion = "checked";
    }
    $s_obsInflamacion= $_POST['obsInflamacion'];
    //-------------------------------------------------------//
    $s_retracciones= $_POST['retracciones'];
    if ($s_retracciones =="")
    {
     $s_retracciones = "N";
    }
    else
    {    
     $chkRetracciones = "checked";
    }
    $s_obsRetracciones= $_POST['obsRetracciones'];
    //-------------------------------------------------------//
    $s_presenciaBolsas= $_POST['presenciaBolsas'];
    if ($s_presenciaBolsas =="")
    {
      $s_presenciaBolsas = "N";
    }
    else
    {    
      $chkPresenciaBolsas = "checked";
    }
    $s_obsPresenciaBolsas= $_POST['obsPresenciaBolsas'];
    //-------------------------------------------------------//
    $s_tipOclusion= $_POST['tipOclusion'];
    if ($s_tipOclusion =="")
    {
      $s_tipOclusion = "N";
    }
    else
    {    
      $chkTipOclusion = "checked";
    }
    $s_obsTipOclusion= $_POST['obsTipOclusion'];
    //-------------------------------------------------------//

    ///////////////////////////////////////////////////////////  
    //VARIABLES CONSENTIMIENTOS INFORMADOS
    ///////////////////////////////////////////////////////////  
     
    $s_conInformado = $_POST['conInformado'];
    if ($s_conInformado =="")
    {
      $s_conInformado = "N";
    }
    else
    {    
      $chkConInformado = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfOpera = $_POST['conInfOpera'];
    if ($s_conInfOpera =="")
    {
      $s_conInfOpera = "N";
    }
    else
    {    
      $chkConInfOpera = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfAneLoc = $_POST['conInfAneLoc'];
    if ($s_conInfAneLoc =="")
    {
      $s_conInfAneLoc = "N";
    }
    else
    {    
      $chkConInfAneLoc = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfEndo = $_POST['conInfEndo'];
    if ($s_conInfEndo =="")
    {
      $s_conInfEndo = "N";
    }
    else
    {    
      $chkConInfEndo = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfEndSim = $_POST['conInfEndSim'];
    if ($s_conInfEndSim =="")
    {
      $s_conInfEndSim = "N";
    }
    else
    {    
      $chkConInfEndSim = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfExoSim = $_POST['conInfExoSim'];
    if ($s_conInfExoSim =="")
    {
      $s_conInfExoSim = "N";
    }
    else
    {    
      $chkConInExoSim = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfExoCor = $_POST['conInfExoCor'];
    if ($s_conInfExoCor =="")
    {
      $s_conInfExoCor = "N";
    }
    else
    {    
      $chkConInfExoCor = "checked";
    } 
    //-------------------------------------------------------//
    $s_conInfCirApi = $_POST['conInfCirApi'];
    if ($s_conInfCirApi =="")
    {
      $s_conInfCirApi = "N";
    }
    else
    {    
      $chkConInfCirApi = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfTerNeu = $_POST['conInfTerNeu'];
    if ($s_conInfTerNeu =="")
    {
      $s_conInfTerNeu = "N";
    }
    else
    {    
      $chkConInfTerNeu = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfRevoc = $_POST['conInfRevoc'];
    if ($s_conInfRevoc =="")
    {
      $s_conInfRevoc = "N";
    }
    else
    {    
      $chkConInfRevoc = "checked";
    }
    //-------------------------------------------------------//
    $s_conInfNegacion = $_POST['conInfNegacion'];
    if ($s_conInfNegacion =="")
    {
      $s_conInfNegacion = "N";
    }
    else
    {    
      $chkConInfNegacion = "checked";
    }

    ///////////////////////////////////////////////////////////  
    //VARIABLES REGISTRO DE PLACA
    ///////////////////////////////////////////////////////////   
   
    $s_numSupPlaca = $_POST['numSupPlaca'];
    $s_indicePlaca = $_POST['indicePlaca'];
    
    $s_regPlaNoApl = $_POST['regPlaNoApl'];
    if ($s_regPlaNoApl =="")
    {
      $s_regPlaNoApl = "N";
    }
    else
    {    
      $chkRegPlaNoApl = "checked";
    }
    $s_obsRegPlaNoApl =  $_POST['obsRegPlaNoApl'];

    //////////////////////////////////////////////////////////////////////////////////////
    /////////////////// INICIO REGISTRO DE PLACA    //////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////

    $s_P551 =  $_POST['P551'];
    if ($s_P551 ==0)
    {
      $s_P551 = 0;
    }
    else
    {
      $chkP551  = "checked";
    }

    $s_P554 =  $_POST['P554'];
    if ($s_P554 ==0)
    {
      $s_P554 = 0;
    }
    else
    {
      $chkP554  = "checked";
    }  
    
    $s_P552 =  $_POST['P552'];
    if ($s_P552 ==0)
    {
      $s_P552 = 0;
    }
    else
    {
      $chkP552  = "checked";
    }      
    
    $s_P555 =  $_POST['P555'];
    if ($s_P555 ==0)
    {
      $s_P555 = 0;
    }
    else
    {
      $chkP555  = "checked";
    }    
    $s_P541 =  $_POST['P541'];
    if ($s_P541 =="")
    {
      $s_P541 = 0;
    }
    else
    {
      $chkP541  = "checked";
    }

    $s_P544 =  $_POST['P544'];
    if ($s_P544 =="")
    {
      $s_P544 = 0;
    }
    else
    {
      $chkP544  = "checked";
    }  
    
    $s_P542 =  $_POST['P542'];
    if ($s_P542 =="")
    {
      $s_P542 = 0;
    }
    else
    {
      $chkP542  = "checked";
    }      
    
    $s_P545 =  $_POST['P545'];
    if ($s_P545 =="")
    {
      $s_P545 = 0;
    }
    else
    {
      $chkP545  = "checked";
    }
    $s_P531 =  $_POST['P531'];
    if ($s_P531 =="")
    {
      $s_P531 = 0;
    }
    else
    {
      $chkP531  = "checked";
    }

    $s_P534 =  $_POST['P534'];
    if ($s_P534 =="")
    {
      $s_P534 = 0;
    }
    else
    {
      $chkP534  = "checked";
    }  
    
    $s_P532 =  $_POST['P532'];
    if ($s_P532 =="")
    {
      $s_P532 = 0;
    }
    else
    {
      $chkP532  = "checked";
    }      
    
    $s_P535 =  $_POST['P535'];
    if ($s_P535 =="")
    {
      $s_P535 = 0;
    }
    else
    {
      $chkP535  = "checked";
    }
    $s_P521 =  $_POST['P521'];
    if ($s_P521 =="")
    {
      $s_P521 = 0;
    }
    else
    {
      $chkP521  = "checked";
    }

    $s_P524 =  $_POST['P524'];
    if ($s_P524 =="")
    {
      $s_P524 = 0;
    }
    else
    {
      $chkP524  = "checked";
    }  
    
    $s_P522 =  $_POST['P522'];
    if ($s_P522 =="")
    {
      $s_P522 = 0;
    }
    else
    {
      $chkP522  = "checked";
    }      
    
    $s_P525 =  $_POST['P525'];
    if ($s_P525 =="")
    {
      $s_P525 = 0;
    }
    else
    {
      $chkP525  = "checked";
    }   
    $s_P511 =  $_POST['P511'];
    if ($s_P511 =="")
    {
      $s_P511 = 0;
    }
    else
    {
      $chkP511  = "checked";
    }

    $s_P514 =  $_POST['P514'];
    if ($s_P514 =="")
    {
      $s_P514 = 0;
    }
    else
    {
      $chkP514  = "checked";
    }  
    
    $s_P512 =  $_POST['P512'];
    if ($s_P512 =="")
    {
      $s_P512 = 0;
    }
    else
    {
      $chkP512  = "checked";
    }      
    
    $s_P515 =  $_POST['P515'];
    if ($s_P515 =="")
    {
      $s_P515 = 0;
    }
    else
    {
      $chkP515  = "checked";
    }  
    $s_P611 =  $_POST['P611'];
    if ($s_P611 =="")
    {
      $s_P611 = 0;
    }
    else
    {
      $chkP611  = "checked";
    }

    $s_P614 =  $_POST['P614'];
    if ($s_P614 =="")
    {
      $s_P614 = 0;
    }
    else
    {
      $chkP614  = "checked";
    }  
    
    $s_P612 =  $_POST['P612'];
    if ($s_P612 =="")
    {
      $s_P612 = 0;
    }
    else
    {
      $chkP612  = "checked";
    }      
    
    $s_P615 =  $_POST['P615'];
    if ($s_P615 =="")
    {
      $s_P615 = 0;
    }
    else
    {
      $chkP615  = "checked";
    }  
    $s_P621 =  $_POST['P621'];
    if ($s_P621 =="")
    {
      $s_P621 = 0;
    }
    else
    {
      $chkP621  = "checked";
    }

    $s_P624 =  $_POST['P624'];
    if ($s_P624 =="")
    {
      $s_P624 = 0;
    }
    else
    {
      $chkP624  = "checked";
    }  
    
    $s_P622 =  $_POST['P622'];
    if ($s_P622 =="")
    {
      $s_P622 = 0;
    }
    else
    {
      $chkP622  = "checked";
    }      
    
    $s_P625 =  $_POST['P625'];
    if ($s_P625 =="")
    {
      $s_P625 = 0;
    }
    else
    {
      $chkP625  = "checked";
    }  
    $s_P631 =  $_POST['P631'];
    if ($s_P631 =="")
    {
      $s_P631 = 0;
    }
    else
    {
      $chkP631  = "checked";
    }

    $s_P634 =  $_POST['P634'];
    if ($s_P634 =="")
    {
      $s_P634 = 0;
    }
    else
    {
      $chkP634  = "checked";
    }  
    
    $s_P632 =  $_POST['P632'];
    if ($s_P632 =="")
    {
      $s_P632 = 0;
    }
    else
    {
      $chkP632  = "checked";
    }      
    
    $s_P635 =  $_POST['P635'];
    if ($s_P635 =="")
    {
      $s_P635 = 0;
    }
    else
    {
      $chkP635  = "checked";
    }    
        $s_P641 =  $_POST['P641'];
    if ($s_P641 =="")
    {
      $s_P641 = 0;
    }
    else
    {
      $chkP641  = "checked";
    }

    $s_P644 =  $_POST['P644'];
    if ($s_P644 =="")
    {
      $s_P644 = 0;
    }
    else
    {
      $chkP644  = "checked";
    }  
    
    $s_P642 =  $_POST['P642'];
    if ($s_P642 =="")
    {
      $s_P642 = 0;
    }
    else
    {
      $chkP642  = "checked";
    }      
    
    $s_P645 =  $_POST['P645'];
    if ($s_P645 =="")
    {
      $s_P645 = 0;
    }
    else
    {
      $chkP645  = "checked";
    }  
    $s_P651 =  $_POST['P651'];
    if ($s_P651 =="")
    {
      $s_P651 = 0;
    }
    else
    {
      $chkP651  = "checked";
    }

    $s_P654 =  $_POST['P654'];
    if ($s_P654 =="")
    {
      $s_P654 = 0;
    }
    else
    {
      $chkP654  = "checked";
    }  
    
    $s_P652 =  $_POST['P652'];
    if ($s_P652 =="")
    {
      $s_P652 = 0;
    }
    else
    {
      $chkP652  = "checked";
    }      
    
    $s_P655 =  $_POST['P655'];
    if ($s_P655 =="")
    {
      $s_P655 = 0;
    }
    else
    {
      $chkP655  = "checked";
    }  
    $s_P857 =  $_POST['P857'];
    if ($s_P857 =="")
    {
      $s_P857 = 0;
    }
    else
    {
      $chkP857  = "checked";
    }

    $s_P854 =  $_POST['P854'];
    if ($s_P854 =="")
    {
      $s_P854 = 0;
    }
    else
    {
      $chkP854  = "checked";
    }  
    
    $s_P852 =  $_POST['P852'];
    if ($s_P852 =="")
    {
      $s_P852 = 0;
    }
    else
    {
      $chkP852  = "checked";
    }      
    
    $s_P851 =  $_POST['P851'];
    if ($s_P851 =="")
    {
      $s_P851 = 0;
    }
    else
    {
      $chkP851  = "checked";
    }  
    $s_P847 =  $_POST['P847'];
    if ($s_P847 =="")
    {
      $s_P847 = 0;
    }
    else
    {
      $chkP847  = "checked";
    }

    $s_P844 =  $_POST['P844'];
    if ($s_P844 =="")
    {
      $s_P844 = 0;
    }
    else
    {
      $chkP844  = "checked";
    }  
    
    $s_P842 =  $_POST['P842'];
    if ($s_P842 =="")
    {
      $s_P842 = 0;
    }
    else
    {
      $chkP842  = "checked";
    }      
    
    $s_P841 =  $_POST['P841'];
    if ($s_P841 =="")
    {
      $s_P841 = 0;
    }
    else
    {
      $chkP841  = "checked";
    }    
    $s_P837 =  $_POST['P837'];
    if ($s_P837 =="")
    {
      $s_P837 = 0;
    }
    else
    {
      $chkP837  = "checked";
    }

    $s_P834 =  $_POST['P834'];
    if ($s_P834 =="")
    {
      $s_P834 = 0;
    }
    else
    {
      $chkP834  = "checked";
    }  
    
    $s_P832 =  $_POST['P832'];
    if ($s_P832 =="")
    {
      $s_P832 = 0;
    }
    else
    {
      $chkP832  = "checked";
    }      
    
    $s_P831 =  $_POST['P831'];
    if ($s_P831 =="")
    {
      $s_P831 = 0;
    }
    else
    {
      $chkP831  = "checked";
    }  
    $s_P827 =  $_POST['P827'];
    if ($s_P827 =="")
    {
      $s_P827 = 0;
    }
    else
    {
      $chkP827  = "checked";
    }

    $s_P824 =  $_POST['P824'];
    if ($s_P824 =="")
    {
      $s_P824 = 0;
    }
    else
    {
      $chkP824  = "checked";
    }  
    
    $s_P822 =  $_POST['P822'];
    if ($s_P822 =="")
    {
      $s_P822 = 0;
    }
    else
    {
      $chkP822  = "checked";
    }      
    
    $s_P821 =  $_POST['P821'];
    if ($s_P821 =="")
    {
      $s_P821 = 0;
    }
    else
    {
      $chkP821  = "checked";
    }  
    $s_P817 =  $_POST['P817'];
    if ($s_P817 =="")
    {
      $s_P817 = 0;
    }
    else
    {
      $chkP817  = "checked";
    }

    $s_P814 =  $_POST['P814'];
    if ($s_P814 =="")
    {
      $s_P814 = 0;
    }
    else
    {
      $chkP814  = "checked";
    }  
    
    $s_P812 =  $_POST['P812'];
    if ($s_P812 =="")
    {
      $s_P812 = 0;
    }
    else
    {
      $chkP812  = "checked";
    }      
    
    $s_P811 =  $_POST['P811'];
    if ($s_P811 =="")
    {
      $s_P811 = 0;
    }
    else
    {
      $chkP811  = "checked";
    }  
    $s_P717 =  $_POST['P717'];
    if ($s_P717 =="")
    {
      $s_P717 = 0;
    }
    else
    {
      $chkP717  = "checked";
    }

    $s_P714 =  $_POST['P714'];
    if ($s_P714 =="")
    {
      $s_P714 = 0;
    }
    else
    {
      $chkP714  = "checked";
    }  
    
    $s_P712 =  $_POST['P712'];
    if ($s_P712 =="")
    {
      $s_P712 = 0;
    }
    else
    {
      $chkP712  = "checked";
    }      
    
    $s_P711 =  $_POST['P711'];
    if ($s_P711 =="")
    {
      $s_P711 = 0;
    }
    else
    {
      $chkP711  = "checked";
    }  
    $s_P727 =  $_POST['P727'];
    if ($s_P727 =="")
    {
      $s_P727 = 0;
    }
    else
    {
      $chkP727  = "checked";
    }

    $s_P724 =  $_POST['P724'];
    if ($s_P724 =="")
    {
      $s_P724 = 0;
    }
    else
    {
      $chkP724  = "checked";
    }  
    
    $s_P722 =  $_POST['P722'];
    if ($s_P722 =="")
    {
      $s_P722 = 0;
    }
    else
    {
      $chkP722  = "checked";
    }      
    
    $s_P721 =  $_POST['P721'];
    if ($s_P721 =="")
    {
      $s_P721 = 0;
    }
    else
    {
      $chkP721  = "checked";
    }   
    $s_P737 =  $_POST['P737'];
    if ($s_P737 =="")
    {
      $s_P737 = 0;
    }
    else
    {
      $chkP737  = "checked";
    }

    $s_P734 =  $_POST['P734'];
    if ($s_P734 =="")
    {
      $s_P734 = 0;
    }
    else
    {
      $chkP734  = "checked";
    }  
    
    $s_P732 =  $_POST['P732'];
    if ($s_P732 =="")
    {
      $s_P732 = 0;
    }
    else
    {
      $chkP732  = "checked";
    }      
    
    $s_P731 =  $_POST['P731'];
    if ($s_P731 =="")
    {
      $s_P731 = 0;
    }
    else
    {
      $chkP731  = "checked";
    } 
    $s_P747 =  $_POST['P747'];
    if ($s_P747 =="")
    {
      $s_P747 = 0;
    }
    else
    {
      $chkP747  = "checked";
    }

    $s_P744 =  $_POST['P744'];
    if ($s_P744 =="")
    {
      $s_P744 = 0;
    }
    else
    {
      $chkP744  = "checked";
    }  
    
    $s_P742 =  $_POST['P742'];
    if ($s_P742 =="")
    {
      $s_P742 = 0;
    }
    else
    {
      $chkP742  = "checked";
    }      
    
    $s_P741 =  $_POST['P741'];
    if ($s_P741 =="")
    {
      $s_P741 = 0;
    }
    else
    {
      $chkP741  = "checked";
    } 
    $s_P757 =  $_POST['P757'];
    if ($s_P757 =="")
    {
      $s_P757 = 0;
    }
    else
    {
      $chkP757  = "checked";
    }

    $s_P754 =  $_POST['P754'];
    if ($s_P754 =="")
    {
      $s_P754 = 0;
    }
    else
    {
      $chkP754  = "checked";
    }  
    
    $s_P752 =  $_POST['P752'];
    if ($s_P752 =="")
    {
      $s_P752 = 0;
    }
    else
    {
      $chkP752  = "checked";
    }      
    
    $s_P751 =  $_POST['P751'];
    if ($s_P751 =="")
    {
      $s_P751 = 0;
    }
    else
    {
      $chkP751  = "checked";
    }    

    ///////////REGISTRO DE PLACA NUEVOS 
        $s_P161 =  $_POST['P161'];
    if ($s_P161 =="")
    {
      $s_P161 = 0;
    }
    else
    {
      $chkP161  = "checked";
    }    
    $s_P164 =  $_POST['P164'];
    if ($s_P164 =="")
    {
      $s_P164 = 0;
    }
    else
    {
      $chkP164  = "checked";
    }
    $s_P166 =  $_POST['P166'];
    if ($s_P166 =="")
    {
      $s_P166 = 0;
    }
    else
    {
      $chkP166  = "checked";
    }
    $s_P162 =  $_POST['P162'];
    if ($s_P162 =="")
    {
      $s_P162 = 0;
    }
    else
    {
      $chkP162  = "checked";
    }
    $s_P165 =  $_POST['P165'];
    if ($s_P165 =="")
    {
      $s_P165 = 0;
    }
    else
    {
      $chkP165  = "checked";
    }

    $s_P171 =  $_POST['P171'];
    if ($s_P171 =="")
    {
      $s_P171 = 0;
    }
    else
    {
      $chkP171  = "checked";
    }    
    $s_P174 =  $_POST['P174'];
    if ($s_P174 =="")
    {
      $s_P174 = 0;
    }
    else
    {
      $chkP174  = "checked";
    }
    $s_P176 =  $_POST['P176'];
    if ($s_P176 =="")
    {
      $s_P176 = 0;
    }
    else
    {
      $chkP176  = "checked";
    }
    $s_P172 =  $_POST['P172'];
    if ($s_P172 =="")
    {
      $s_P172 = 0;
    }
    else
    {
      $chkP172  = "checked";
    }
    $s_P175 =  $_POST['P175'];
    if ($s_P175 =="")
    {
      $s_P175 = 0;
    }
    else
    {
      $chkP175  = "checked";
    }
    $s_P181 =  $_POST['P181'];
    if ($s_P181 =="")
    {
      $s_P181 = 0;
    }
    else
    {
      $chkP181  = "checked";
    }    
    $s_P184 =  $_POST['P184'];
    if ($s_P184 =="")
    {
      $s_P184 = 0;
    }
    else
    {
      $chkP184 = "checked";
    }

    $s_P186 =  $_POST['P186'];
    if ($s_P186 =="")
    {
      $s_P186 = 0;
    }
    else
    {
      $chkP186  = "checked";
    }

    $s_P182 =  $_POST['P182'];
    if ($s_P182 =="")
    {
      $s_P182 = 0;
    }
    else
    {
      $chkP182  = "checked";
    }
    $s_P185 =  $_POST['P185'];
    if ($s_P185 =="")
    {
      $s_P185 = 0;
    }
    else
    {
      $chkP185  = "checked";
    }

$s_P261 =  $_POST['P261'];
    if ($s_P261 =="")
    {
      $s_P261 = 0;
    }
    else
    {
      $chkP261  = "checked";
    }
    $s_P262 =  $_POST['P262'];
    if ($s_P262 =="")
    {
      $s_P262 = 0;
    }
    else
    {
      $chkP262  = "checked";
    }
    $s_P266 =  $_POST['P266'];
    if ($s_P266 =="")
    {
      $s_P266 = 0;
    }
    else
    {
      $chkP266  = "checked";
    }
    $s_P264 =  $_POST['P264'];
    if ($s_P264 =="")
    {
      $s_P264 = 0;
    }
    else
    {
      $chkP264  = "checked";
    }
    $s_P265 =  $_POST['P265'];
    if ($s_P265 =="")
    {
      $s_P265 = 0;
    }
    else
    {
      $chkP265  = "checked";
    }

    $s_P271 =  $_POST['P271'];
    if ($s_P271 =="")
    {
      $s_P271 = 0;
    }
    else
    {
      $chkP271  = "checked";
    }
    $s_P272 =  $_POST['P272'];
    if ($s_P272 =="")
    {
      $s_P272 = 0;
    }
    else
    {
      $chkP272  = "checked";
    }
    $s_P276 =  $_POST['P276'];
    if ($s_P276 =="")
    {
      $s_P276 = 0;
    }
    else
    {
      $chkP276  = "checked";
    }
    $s_P274 =  $_POST['P274'];
    if ($s_P274 =="")
    {
      $s_P274 = 0;
    }
    else
    {
      $chkP274  = "checked";
    }
    $s_P275 =  $_POST['P275'];
    if ($s_P275 =="")
    {
      $s_P275 = 0;
    }
    else
    {
      $chkP275  = "checked";
    }

    $s_P281 =  $_POST['P281'];
    if ($s_P281 =="")
    {
      $s_P281 = 0;
    }
    else
    {
      $chkP281  = "checked";
    }
    $s_P282 =  $_POST['P282'];
    if ($s_P282 =="")
    {
      $s_P282 = 0;
    }
    else
    {
      $chkP282  = "checked";
    }
    $s_P286 =  $_POST['P286'];
    if ($s_P286 =="")
    {
      $s_P286 = 0;
    }
    else
    {
      $chkP286  = "checked";
    }
    $s_P284 =  $_POST['P284'];
    if ($s_P284 =="")
    {
      $s_P284 = 0;
    }
    else
    {
      $chkP284  = "checked";
    }
    $s_P285 =  $_POST['P285'];
    if ($s_P285 =="")
    {
      $s_P285 = 0;
    }
    else
    {
      $chkP285  = "checked";
    }

    $s_P467 =  $_POST['P467'];
    if ($s_P467 =="")
    {
      $s_P467 = 0;
    }
    else
    {
      $chkP467  = "checked";
    }
    $s_P464 =  $_POST['P464'];
    if ($s_P464 =="")
    {
      $s_P464 = 0;
    }
    else
    {
      $chkP464  = "checked";
    }
    $s_P466 =  $_POST['P466'];
    if ($s_P466 =="")
    {
      $s_P466 = 0;
    }
    else
    {
      $chkP466  = "checked";
    }
    $s_P462 =  $_POST['P462'];
    if ($s_P462 =="")
    {
      $s_P462 = 0;
    }
    else
    {
      $chkP462  = "checked";
    }
    $s_P461 =  $_POST['P461'];
    if ($s_P461 =="")
    {
      $s_P461 = 0;
    }
    else
    {
      $chkP461  = "checked";
    }
   
    $s_P477 =  $_POST['P477'];
    if ($s_P477 =="")
    {
      $s_P477 = 0;
    }
    else
    {
      $chkP477  = "checked";
    }
    $s_P474 =  $_POST['P474'];
    if ($s_P474 =="")
    {
      $s_P474 = 0;
    }
    else
    {
      $chkP474  = "checked";
    }
    $s_P476 =  $_POST['P476'];
    if ($s_P476 =="")
    {
      $s_P476 = 0;
    }
    else
    {
      $chkP476  = "checked";
    }
    $s_P472 =  $_POST['P472'];
    if ($s_P472 =="")
    {
      $s_P472 = 0;
    }
    else
    {
      $chkP472  = "checked";
    }
    $s_P471 =  $_POST['P471'];
    if ($s_P471 =="")
    {
      $s_P471 = 0;
    }
    else
    {
      $chkP471  = "checked";
    }

    $s_P487 =  $_POST['P487'];
    if ($s_P487 =="")
    {
      $s_P487 = 0;
    }
    else
    {
      $chkP487  = "checked";
    }
    $s_P484 =  $_POST['P484'];
    if ($s_P484 =="")
    {
      $s_P484 = 0;
    }
    else
    {
      $chkP484  = "checked";
    }
    $s_P486 =  $_POST['P486'];
    if ($s_P486 =="")
    {
      $s_P486 = 0;
    }
    else
    {
      $chkP486  = "checked";
    }
    $s_P482 =  $_POST['P482'];
    if ($s_P482 =="")
    {
      $s_P482 = 0;
    }
    else
    {
      $chkP482  = "checked";
    }
    $s_P481 =  $_POST['P481'];
    if ($s_P481 =="")
    {
      $s_P481 = 0;
    }
    else
    {
      $chkP481  = "checked";
    }

    $s_P367 =  $_POST['P367'];
    if ($s_P367 =="")
    {
      $s_P367 = 0;
    }
    else
    {
      $chkP367  = "checked";
    }
    $s_P362 =  $_POST['P362'];
    if ($s_P362 =="")
    {
      $s_P362 = 0;
    }
    else
    {
      $chkP362  = "checked";
    }
    $s_P366 =  $_POST['P366'];
    if ($s_P366 =="")
    {
      $s_P366 = 0;
    }
    else
    {
      $chkP366  = "checked";
    }
    $s_P364 =  $_POST['P364'];
    if ($s_P364 =="")
    {
      $s_P364 = 0;
    }
    else
    {
      $chkP364  = "checked";
    }
    $s_P361 =  $_POST['P361'];
    if ($s_P361 =="")
    {
      $s_P361 = 0;
    }
    else
    {
      $chkP361  = "checked";
    }

    $s_P377 =  $_POST['P377'];
    if ($s_P377 =="")
    {
      $s_P377 = 0;
    }
    else
    {
      $chkP377  = "checked";
    }
    $s_P372 =  $_POST['P372'];
    if ($s_P372 =="")
    {
      $s_P372 = 0;
    }
    else
    {
      $chkP372  = "checked";
    }
    $s_P376 =  $_POST['P376'];
    if ($s_P376 =="")
    {
      $s_P376 = 0;
    }
    else
    {
      $chkP376  = "checked";
    }
    $s_P374 =  $_POST['P374'];
    if ($s_P374 =="")
    {
      $s_P374 = 0;
    }
    else
    {
      $chkP374  = "checked";
    }
    $s_P371 =  $_POST['P371'];
    if ($s_P371 =="")
    {
      $s_P371 = 0;
    }
    else
    {
      $chkP371  = "checked";
    }

    $s_P387 =  $_POST['P387'];
    if ($s_P387 =="")
    {
      $s_P387 = 0;
    }
    else
    {
      $chkP387  = "checked";
    }
    $s_P382 =  $_POST['P382'];
    if ($s_P382 =="")
    {
      $s_P382 = 0;
    }
    else
    {
      $chkP382  = "checked";
    }
    $s_P386 =  $_POST['P386'];
    if ($s_P386 =="")
    {
      $s_P386 = 0;
    }
    else
    {
      $chkP386  = "checked";
    }
    $s_P384 =  $_POST['P384'];
    if ($s_P384 =="")
    {
      $s_P384 = 0;
    }
    else
    {
      $chkP384  = "checked";
    }
    $s_P381 =  $_POST['P381'];
    if ($s_P381 =="")
    {
      $s_P381 = 0;
    }
    else
    {
      $chkP381  = "checked";
    }

    ///////////////indices de placa
    $s_numSupPlaca=$_POST['numSupPlaca'];
    $s_indicePlaca=$_POST['indicePlaca'];

    $s_regPlaNoApl = $_POST['regPlaNoApl'];
    if ($s_regPlaNoApl =="")
    {
      $s_regPlaNoApl = "N";
    }
    else
    {    
      $chkRegPlaNoApl = "checked";
    }
    $s_obsRegPlaNoApl =  $_POST['obsRegPlaNoApl'];


  //GRABA TABLAS DE LA HISTORIA DE TRATAMIENTO -- GENERAL --
  /* ============================================================================================================================
  ============================================================================================================================*/
  
    //<!---------------- Inicio Situacion Actual ---------------->    
    //Verifica existencia del registro en la tabla SIO_SIT_ACTUAL   
    $ct = cuantosRe("SIO_SIT_ACTUAL", $e_tratamiento, $s_tipoHistoria, $e_tipoId );
         
    if ($ct==0)//Insertar datos en SIO_SIT_ACTUAL
    {
      $query = " INSERT INTO SIO_SIT_ACTUAL " .
               " (nitEmpresa, codSede, numConsulta, numTratamiento, idPaciente, tipoHistoria,  " .
               " motivoConsulta, enfermedadActual, antFamiliares, fechaConsulta, medConsulta) " .
               " VALUES($s_nitEmpresa, $s_codSede, $pc, $e_tratamiento, $e_idPaciente, '$s_tipoHistoria', ".
               "        '$s_motConsulta', '$s_enfActual', '$s_antFam', '$w_fecha', $s_idUsuario)";
      $result = mysql_query($query) or die('Error en Insercion de SIO_SIT_ACTUAL: ' . mysql_error());          
      // Liberar resultados
      mysql_free_result($result);
    }
    if ($ct==1)//Actualizar datos en SIO_SIT_ACTUAL
    {
      $query = " UPDATE SIO_SIT_ACTUAL ".
               " SET motivoConsulta='$s_motConsulta', EnfermedadActual='$s_enfActual', antFamiliares='$s_antFam', fechaConsulta='$w_fecha' ".
               //" WHERE numConsulta=$e_nvoNroCon "; 
               " WHERE numTratamiento = $e_tratamiento";
      $result = mysql_query($query) or die('Error en Actualizacion de SIO_SIT_ACTUAL: ' . mysql_error());
      // Liberar resultados
      mysql_free_result($result);
    }

    //Verifica existencia del registro en la tabla SIO_ANT_ODYMED
          $ct = cuantosRe("SIO_ANT_ODYMED", $e_tratamiento, $s_tipoHistoria, $s_tipoId );
          if ($ct==0)//Insertar datos en SIO_ANT_ODYMED
          {
 //ECHO "1";
//ECHO '<BR>';
            $query = " INSERT INTO SIO_ANT_ODYMED(nitEmpresa, codSede, numConsulta, numTratamiento, idPaciente, tipoHistoria, " .
                     " alergias, obsAlergias, altPresArterial, obsAltPresArterial, cardiopatias, obsCardiopatias, ".
                     " cirugias, obsCirugias, diabetes, obsDiabetes, discrasiasSang, obsDiscrasiasSang, ".
                     " embarazo, obsEmbarazo, enfOrales, obsEnfOrales, exodoncias, obsExodoncias, ".
                     " fiebreReum, obsFiebreReum, hepatitis, obsHepatitis, inmunosupresion, obsInmunosupresion, ". 
                     " patologiasRenales, obsPatologiasRenales, patRespiratoria, obsPatRespiratoria, sida, obsSida, ". 
                     " tomaMedicamentos, obsTomaMedicamentos, sinusitis, obsSinusitis, trasEmocional, obsTrasEmocional, ".
                     " trasGastricos, obsTrasGastricos, tratMedActual, obsTratMedActual, ".
                     " usoProtesis, obsUsoProtesis, habitos, fechaConsulta, medConsulta) ".
                     " VALUES($s_nitEmpresa, $s_codSede, $pc, $e_tratamiento, $e_idPaciente, '$s_tipoHistoria', ". 
                     " '$s_alergias', '$s_obsAlergia', '$s_altPresArterial', '$s_obsAltPresArterial', '$s_cardiopatias', '$s_obsCardiopatias', ".
                     " '$s_cirugias', '$s_obsCirugias','$s_diabetes','$s_obsDiabetes', '$s_discrasiasSang', '$s_obsDiscrasiasSang', ".
                     " '$s_embarazo', '$s_obsEmbarazo', '$s_enfOrales', '$s_obsEnfOrales', '$s_exodoncias', '$s_obsExodoncias', ".              
                     " '$s_fiebreReum', '$s_obsFiebreReum', '$s_hepatitis', '$s_obsHepatitis', '$s_inmunosupresion', '$s_obsInmunosupresion', ".
                     " '$s_patologiasRenales', '$s_obsPatologiasRenales', '$s_patRespiratoria', '$s_obsPatRespiratoria', '$s_sida', '$s_obsSida', ". 
                     " '$s_tomaMedicamentos', '$s_obsTomaMedicamentos', '$s_sinusitis', '$s_obsSinusitis', '$s_trasEmocional', '$s_obsTrasEmocional', ".
                     " '$s_trasGastricos', '$s_obsTrasGastricos', '$s_tratMedActual', '$s_obsTratMedActual', ".  
                     " '$s_usoProtesis', '$s_obsUsoProtesis', '$s_habitos', '$w_fecha', $s_idUsuario) ";
            $result = mysql_query($query) or die('Error en adicion de SIO_ANT_ODYMED: ' . mysql_error());
            // Liberar resultados
            mysql_free_result($result);        
          }
          if ($ct==1)//Actualizar datos en SIO_ANT_ODYMED
          {
//ECHO '<BR>';
            $query = " UPDATE SIO_ANT_ODYMED ".
                     " SET alergias='$s_alergias', obsAlergias='$s_obsAlergia', altPresArterial='$s_altPresArterial', obsAltPresArterial='$s_obsAltPresArterial', ".
                     " cardiopatias='$s_cardiopatias', obsCardiopatias='$s_obsCardiopatias', cirugias='$s_cirugias', obsCirugias='$s_obsCirugias', ".
                     " diabetes='$s_diabetes', obsDiabetes='$s_obsDiabetes', discrasiasSang='$s_discrasiasSang', obsDiscrasiasSang='$s_obsDiscrasiasSang', ".
                     " embarazo='$s_embarazo', obsEmbarazo='$s_obsEmbarazo', enfOrales='$s_enfOrales', obsEnfOrales='$s_obsEnfOrales', ".
                     " exodoncias='$s_exodoncias', obsExodoncias='$s_obsExodoncias', fiebreReum='$s_fiebreReum', obsFiebreReum='$s_obsFiebreReum',".
                     " hepatitis='$s_hepatitis', obsHepatitis='$s_obsHepatitis', inmunosupresion='$s_inmunosupresion', obsInmunosupresion='$s_obsInmunosupresion', ".
                     " patologiasRenales='$s_patologiasRenales', obsPatologiasRenales='$s_obsPatologiasRenales', patRespiratoria='$s_patRespiratoria', ".
                     " obsPatRespiratoria='$s_obsPatRespiratoria', sida='$s_sida', obsSida='$s_obsSida',tomaMedicamentos='$s_tomaMedicamentos', ".
                     " obsTomaMedicamentos='$s_obsTomaMedicamentos', sinusitis='$s_sinusitis', obsSinusitis='$s_obsSinusitis', trasEmocional='$s_trasEmocional', ".
                     " obsTrasEmocional='$s_obsTrasEmocional', trasGastricos='$s_trasGastricos', obsTrasGastricos='$s_obsTrasGastricos', tratMedActual='$s_tratMedActual',".
                     " obsTratMedActual='$s_obsTratMedActual', usoProtesis='$s_usoProtesis', obsUsoProtesis='$s_obsUsoProtesis', habitos='$s_habitos', fechaConsulta='$w_fecha' ".
                     //" WHERE numConsulta=$e_nvoNroCon "; 
               " WHERE numTratamiento = $e_tratamiento";
                     
            $result = mysql_query($query) or die('Error en modificacion de SIO_ANT_ODYMED: ' . mysql_error());
            // Liberar resultados
            mysql_free_result($result);
          } 

          //Verifica existencia del registro en la tabla SIO_EXA_ESTOMATOLOGICO
          $ct = cuantosRe("SIO_EXA_ESTOMATOLOGICO", $e_tratamiento, $s_tipoHistoria, $s_tipoId );
          if ($ct==0)//Insertar datos en SIO_EXA_ESTOMATOLOGICO
          {
            // conexion a la base de datos
            //include("conexion.php");
            $query = " INSERT INTO SIO_EXA_ESTOMATOLOGICO(nitEmpresa, codSede, numConsulta, numTratamiento,idPaciente, tipoHistoria, ". 
                     " labioInferior, obsLabioInferior, labioSuperior, obsLabioSuperior, comisuras, obsComisuras, mucosaOral, obsMucosaOral, ". 
                     " surcosYugales, obsSurcosYugales, frenillos, obsFrenillos, oroFaringe, obsOrofaringe, ".
                     " paladar, obsPaladar, glandSalivales, obsGlandSalivales, pisoBoca, obsPisoBoca, ".
                     " dorsoLengua, obsDorsoLengua, vientreLengua, obsVientreLengua, fechaConsulta, medConsulta )".
                     " VALUES ($s_nitEmpresa, $s_codSede, $pc, $e_tratamiento,$e_idPaciente, '$s_tipoHistoria', ".
                     " '$s_labioInferior', '$s_obsLabioInferior', '$s_labioSuperior', '$s_obsLabioSuperior', '$s_comisuras', '$s_obsComisuras', '$s_mucosaOral', ".
                     " '$s_obsMucosaOral', ".
                     " '$s_surcosYugales', '$s_obsSurcosYugales', '$s_frenillos', '$s_obsFrenillos', '$s_oroFaringe', '$s_obsOrofaringe', ".
                     " '$s_paladar', '$s_obsPaladar', '$s_glandSalivales', '$s_obsGlandSalivales', '$s_pisoBoca', '$s_obsPisoBoca', ".
                     " '$s_dorsoLengua', '$s_obsDorsoLengua', '$s_vientreLengua', '$s_obsVientreLengua', '$w_fecha', $s_idUsuario)";
            $result = mysql_query($query) or die('Error en adicion de SIO_EXA_ESTOMATOLOGICO: ' . mysql_error());
            // Liberar resultados  
            mysql_free_result($result);         
          }
          if ($ct==1)//Actualizar datos en SIO_EXA_ESTOMATOLOGICO
          {
            // conexion a la base de datos
            //include("conexion.php");
            $query = " UPDATE SIO_EXA_ESTOMATOLOGICO " .
                     " SET labioInferior='$s_labioInferior', obsLabioInferior='$s_obsLabioInferior', labioSuperior='$s_labioSuperior', ".
                     " obsLabioSuperior='$s_obsLabioSuperior', comisuras='$s_comisuras', obsComisuras='$s_obsComisuras', mucosaOral='$s_mucosaOral', ".
                     " obsMucosaOral='$s_obsMucosaOral', surcosYugales='$s_surcosYugales', obsSurcosYugales='$s_obsSurcosYugales', frenillos='$s_frenillos',".
                     " obsFrenillos='$s_obsFrenillos', oroFaringe='$s_oroFaringe', obsOrofaringe='$s_obsOrofaringe',  paladar='$s_paladar', obsPaladar='$s_obsPaladar',".
                     " glandSalivales='$s_glandSalivales', obsGlandSalivales='$s_obsGlandSalivales', pisoBoca='$s_pisoBoca', obsPisoBoca='$s_obsPisoBoca', ".
                     " dorsoLengua='$s_dorsoLengua', obsDorsoLengua='$s_obsDorsoLengua', vientreLengua='$s_vientreLengua', obsVientreLengua='$s_obsVientreLengua', fechaConsulta='$w_fecha'".
                     //" WHERE numConsulta=$e_nvoNroCon "; 
               " WHERE numTratamiento = $e_tratamiento";         
            $result = mysql_query($query) or die('Error en modificacion de SIO_EXA_ESTOMATOLOGICO: ' . mysql_error());
            // Liberar resultados
            mysql_free_result($result);
          } 

          //Verifica existencia del registro en la tabla SIO_ART_TEMPORO
          $ct = cuantosRe("SIO_ART_TEMPORO", $e_tratamiento, $s_tipoHistoria, $s_tipoId );
          if ($ct==0)//Insertar datos en SIO_ART_TEMPORO
          {
            // conexion a la base de datos
            //include("conexion.php");
            $query = " INSERT INTO SIO_ART_TEMPORO(nitEmpresa, codSede, numConsulta, numTratamiento, idPaciente, tipoHistoria, ".
                     " ruidos, obsRuidos, desviacion, obsDesviacion, cambioVolumen, obsCambioVolumen, bloqueoMand, obsBloqueMand, ".
                     " limitApertura, obsLimitApertura, dolorArticular, obsDolorArticular, dolorMuscular, obsDolorMuscular, fechaConsulta, medConsulta) ".
                     " VALUES ($s_nitEmpresa, $s_codSede, $pc, $e_tratamiento,$e_idPaciente, '$s_tipoHistoria', ".
                     " '$s_ruidos','$s_obsRuidos','$s_desviacion','$s_obsDesviacion','$s_cambioVolumen','$s_obsCambioVolumen','$s_bloqueoMand', ".
                     " '$s_obsBloqueMand','$s_limitApertura','$s_obsLimitApertura','$s_dolorArticular','$s_obsDolorArticular','$s_dolorMuscular',".
                     " '$s_obsDolorMuscular', '$w_fecha', $s_idUsuario)";
            $result = mysql_query($query) or die('Error en ADICION de SIO_ART_TEMPORO: ' . mysql_error());      
            // Liberar resultados
            mysql_free_result($result);        
          }
          if ($ct==1)//Actualizar datos en SIO_ART_TEMPORO
          {
            // conexion a la base de datos
            //include("conexion.php");
            $query = " UPDATE SIO_ART_TEMPORO ".
                     " SET ruidos='$s_ruidos', obsRuidos='$s_obsRuidos', desviacion='$s_desviacion', obsDesviacion='$s_obsDesviacion', ".
                     " cambioVolumen='$s_cambioVolumen', obsCambioVolumen='$s_obsCambioVolumen', bloqueoMand='$s_bloqueoMand',obsBloqueMand='$s_obsBloqueMand',".
                     " limitApertura='$s_limitApertura', obsLimitApertura='$s_obsLimitApertura', dolorArticular='$s_dolorArticular', ".
                     " obsDolorArticular='$s_obsDolorArticular', dolorMuscular='$s_dolorMuscular', obsDolorMuscular='$s_obsDolorMuscular', fechaConsulta='$w_fecha'".
            //" WHERE numConsulta=$e_nvoNroCon "; 
               " WHERE numTratamiento = $e_tratamiento";   
            $result = mysql_query($query) or die('Error en modificacion de SIO_ART_TEMPORO: ' . mysql_error());         
            // Liberar resultados
            mysql_free_result($result);
          } 

          //Verifica existencia del registro en la tabla SIO_PRE_PROTESIS
          $ct = cuantosRe("SIO_PRE_PROTESIS", $e_tratamiento, $s_tipoHistoria, $s_tipoId );
          if ($ct==0)//Insertar datos en SIO_PRE_PROTESIS
          {
            $query = " INSERT INTO SIO_PRE_PROTESIS(nitEmpresa, codSede, numConsulta, numTratamiento, idPaciente, tipoHistoria, ".
                     " protesis, obsProtesis, fechaConsulta, medConsulta)".
                     " VALUES ($s_nitEmpresa, $s_codSede, $pc, $e_tratamiento, $e_idPaciente, '$s_tipoHistoria', ".
                     " '$s_protesis', '$s_obsProtesis', '$w_fecha', $s_idUsuario)"; 
            $result = mysql_query($query) or die('Error en adicion de SIO_PRE_PROTESIS: ' . mysql_error());
             // Liberar resultados
             mysql_free_result($result);         
          }
          if ($ct==1)//Actualizar datos en SIO_PRE_PROTESIS;
          {
            $query = " UPDATE SIO_PRE_PROTESIS ".    
                     " SET protesis='$s_protesis', obsProtesis='$s_obsProtesis', fechaConsulta='$w_fecha'".
                     //" WHERE numConsulta=$e_nvoNroCon ";
               " WHERE numTratamiento = $e_tratamiento";                        
            $result = mysql_query($query) or die('Error en modificacion de SIO_PRE_PROTESIS: ' . mysql_error());
            // Liberar resultados
            mysql_free_result($result);         
          }   

          //Verifica existencia del registro en la tabla SIO_HIG_ORAL
          $ct = cuantosRe("SIO_HIG_ORAL", $e_tratamiento, $s_tipoHistoria, $s_tipoId );
          if ($ct==0)//Insertar datos en SIO_HIG_ORAL
          {
            $query = " INSERT INTO SIO_HIG_ORAL(nitEmpresa, codSede, numConsulta, numTratamiento, idPaciente, tipoHistoria, ".
                     " higiene, freCepillado, sedaDental, pigmentacion, gradoRiesgo, obsHigiene, fechaConsulta, medConsulta) ".
                     " VALUES ($s_nitEmpresa, $s_codSede, $pc, $e_tratamiento, $e_idPaciente, '$s_tipoHistoria', ".
                     " '$s_higiene', '$s_freCepillado', '$s_sedaDental', '$s_pigmentacion', '$s_gradoRiesgo', '$s_obsHigiene', '$w_fecha', $s_idUsuario)";
            $result = mysql_query($query) or die('Error en adicion de SIO_HIG_ORAL: ' . mysql_error());
            // Liberar resultados
            mysql_free_result($result);         
          }
          if ($ct==1)//Actualizar datos en SIO_HIG_ORAL
          {
            $query = " UPDATE SIO_HIG_ORAL " .         
                     " SET higiene='$s_higiene', freCepillado='$s_freCepillado', sedaDental='$s_sedaDental', pigmentacion='$s_pigmentacion', ".
                     " gradoRiesgo='$s_gradoRiesgo', obsHigiene='$s_obsHigiene', fechaConsulta='$w_fecha' ".
           // " WHERE numConsulta=$e_nvoNroCon ";   
               " WHERE numTratamiento = $e_tratamiento";   

            $result = mysql_query($query) or die('Error en modificacion de SIO_HIG_ORAL: ' . mysql_error());         
            // Liberar resultados
            mysql_free_result($result);
          }   

          //Verifica existencia del registro en la tabla SIO_EXA_PULPAR
          $ct = cuantosRe("SIO_EXA_PULPAR", $e_tratamiento, $s_tipoHistoria, $s_tipoId );
          if ($ct==0)//Insertar datos en SIO_EXA_PULPAR
          {
            $query = " INSERT INTO SIO_EXA_PULPAR(nitEmpresa, codSede, numConsulta, numTratamiento,idPaciente, tipoHistoria, ".
                     " cuelloSencible, obsCuelloSencible, abscesos, obsAbscesos, exposicionPulpar, ".
                     " obsExposicionPulpar, cambioColor, obsCambioColor, fechaConsulta, medConsulta)". 
                     " VALUES ($s_nitEmpresa, $s_codSede, $pc, $e_tratamiento, $e_idPaciente, '$s_tipoHistoria', ".   
                     " '$s_cuelloSencible', '$s_obsCuelloSencible', '$s_abscesos','$s_obsAbscesos', '$s_exposicionPulpar',".
                     " '$s_obsExposicionPulpar','$s_cambioColor', '$s_obsCambioColor', '$w_fecha', $s_idUsuario)";
            $result = mysql_query($query) or die('Error en adicion de SIO_HIG_ORAL: ' . mysql_error());
            // Liberar resultados
            mysql_free_result($result);         
          }
          if ($ct==1)//Actualizar datos en SIO_EXA_PULPAR
          {
            // conexion a la base de datos
            //include("conexion.php");
            $query = " UPDATE SIO_EXA_PULPAR ".
                     " SET cuelloSencible='$s_cuelloSencible', obsCuelloSencible='$s_obsCuelloSencible', abscesos='$s_abscesos', obsAbscesos='$s_obsAbscesos', ".
                     " exposicionPulpar='$s_exposicionPulpar', obsExposicionPulpar='$s_obsExposicionPulpar', cambioColor='$s_cambioColor', ".
                     " obsCambioColor='$s_obsCambioColor', fechaConsulta='$w_fecha'  ".
            //" WHERE numConsulta=$e_nvoNroCon ";
               " WHERE numTratamiento = $e_tratamiento";                        

            $result = mysql_query($query) or die('Error en modificacion de SIO_EXA_PULPAR: ' . mysql_error());
            // Liberar resultados
            mysql_free_result($result);         
          }  
     
          //Verifica existencia del registro en la tabla SIO_TEJ_DENTARIOS
          $ct = cuantosRe("SIO_TEJ_DENTARIOS", $e_tratamiento, $s_tipoHistoria, $s_tipoId );
          if ($ct==0)//Insertar datos en SIO_TEJ_DENTARIOS
          {
            $query = " INSERT INTO SIO_TEJ_DENTARIOS(nitEmpresa, codSede, numConsulta, numTratamiento, idPaciente, tipoHistoria, ".
                     " Supernumerarios, obsSupernumerarios, decoloracion ,obsDecoloracion, Descalsificacion, obsDescalsificacion, ".
                     " facetaDesgaste, obsFacetaDesgaste, abrasion, obsAbrasion, fluorosis, obsFluorosis, fechaConsulta, medConsulta)".
                     " VALUES ($s_nitEmpresa, $s_codSede, $pc, $e_tratamiento, $e_idPaciente, '$s_tipoHistoria', ".
                     " '$s_supernumerarios', '$s_obsSupernumerarios', '$s_decoloracion', '$s_obsDecoloracion', '$s_descalsificacion', ".
                     " '$s_obsDescalsificacion', '$s_facetaDesgaste', '$s_obsFacetaDesgaste', '$s_abrasion', '$s_obsAbrasion', '$s_fluorosis', '$s_obsFluorosis', '$w_fecha', $s_idUsuario)";
             $result = mysql_query($query) or die('Error en adicion de SIO_TEJ_DENTARIOS: ' . mysql_error());
             // Liberar resultados
             mysql_free_result($result);         
          }
          if ($ct==1)//Actualizar datos en SIO_TEJ_DENTARIOS
          {
            // conexion a la base de datos
            //include("conexion.php");
            $query = " UPDATE SIO_TEJ_DENTARIOS ".    
                     " SET supernumerarios='$s_supernumerarios',obsSupernumerarios='$s_obsSupernumerarios',decoloracion='$s_decoloracion',".
                     " obsDecoloracion='$s_obsDecoloracion', descalsificacion='$s_descalsificacion',obsDescalsificacion='$s_obsDescalsificacion', ".
                     " facetaDesgaste='$s_facetaDesgaste',obsFacetaDesgaste='$s_obsFacetaDesgaste',abrasion='$s_abrasion',obsAbrasion='$s_obsAbrasion', fluorosis='$s_fluorosis', obsFluorosis='$s_obsFluorosis', fechaConsulta='$w_fecha' ".    
                     //" WHERE numConsulta=$e_nvoNroCon ";
               " WHERE numTratamiento = $e_tratamiento";                        

            $result = mysql_query($query) or die('Error en modificacion de SIO_TEJ_DENTARIOS: ' . mysql_error());
            // Liberar resultados
            mysql_free_result($result);         
          }  

          //Verifica existencia del registro en la tabla SIO_ALT_PERIODONTALESS
          $ct = cuantosRe("SIO_ALT_PERIODONTALES", $e_tratamiento, $s_tipoHistoria, $s_tipoId );
          if ($ct==0)//Insertar datos en SIO_ALT_PERIODONTALESS
          {
           $query = " INSERT INTO SIO_ALT_PERIODONTALES(nitEmpresa, codSede, numConsulta, numTratamiento, idPaciente, tipoHistoria, ".
                     " sangrado, obsSangrado, exudado, obsExudado, supuracion, obsSupuracion,calculos, obsCalculos , inflamacion, ".
                     " obsInflamacion, retracciones, obsRetracciones, presenciaBolsas, obsPresenciaBolsas, tipOclusion, obsTipOclusion, fechaConsulta, medConsulta)". 
                     " VALUES ($s_nitEmpresa, $s_codSede, $pc, $e_tratamiento, $e_idPaciente, '$s_tipoHistoria', ".
                     " '$s_sangrado', '$s_obsSangrado', '$s_exudado', '$s_obsExudado', '$s_supuracion', '$s_obsSupuracion', '$s_calculos', '$s_obsCalculos',". 
                     " '$s_inflamacion', '$s_obsInflamacion', '$s_retracciones', '$s_obsRetracciones', '$s_presenciaBolsas', '$s_obsPresenciaBolsas', ".   
                     " '$s_tipOclusion', '$s_obsTipOclusion', '$w_fecha', $s_idUsuario)"; 
                          
             $result = mysql_query($query) or die('Error en adicion de SIO_ALT_PERIODONTALES: ' . mysql_error());
             // Liberar resultados
             mysql_free_result($result);         
          }
          if ($ct==1)//Actualizar datos en SIO_ALT_PERIODENTALESS
          {
            $query = " UPDATE SIO_ALT_PERIODONTALES ".
                     " SET sangrado='$s_sangrado', obsSangrado='$s_obsSangrado', exudado='$s_exudado', obsExudado='$s_obsExudado', supuracion='$s_supuracion',".
                     " obsSupuracion='$s_obsSupuracion', calculos='$s_calculos', obsCalculos='$s_obsCalculos', inflamacion='$s_inflamacion', ".
                     " obsInflamacion='$s_obsInflamacion', retracciones='$s_retracciones', obsRetracciones='$s_obsRetracciones', ".
                     " presenciaBolsas='$s_presenciaBolsas',  obsPresenciaBolsas='$s_obsPresenciaBolsas', tipOclusion='$s_tipOclusion', obsTipOclusion='$s_obsTipOclusion', fechaConsulta='$w_fecha'  ". 
                     //" WHERE numConsulta=$e_nvoNroCon ";
               " WHERE numTratamiento = $e_tratamiento";                        

            $result = mysql_query($query) or die('Error en modificacion de SIO_ALT_PERIODONTALES: ' . mysql_error());
            // Liberar resultados
            mysql_free_result($result);         
          }            

     //<!---------------- Inicio Consentimientos Informados ---------------->    
     //Verifica existencia del registro en la tabla SIO_CON_INFORMADOS   
     $ct = cuantosRe("SIO_CON_INFORMADOS", $e_tratamiento, $s_tipoHistoria, $e_tipoId );
         
     if ($ct==0)//Insertar datos en Tabla: SIO_CON_INFORMADOS
     {
       $query = " INSERT INTO SIO_CON_INFORMADOS " .
               " (nitEmpresa, codSede, numConsulta, numTratamiento, idPaciente, tipoHistoria,  " .
               " conInformado, conInfOpera, conInfAneLoc, conInfEndo, conInfEndSim, ".
               " conInfExoSim, conInfExoCor, conInfCirApi, conInfTerNeu, conInfRevoc, ".
               " conInfNegacion, fechaConsulta, medConsulta) " .
               " VALUES($s_nitEmpresa, $s_codSede, $pc, $e_tratamiento, $e_idPaciente, '$s_tipoHistoria', ".
               "       '$s_conInformado', '$s_conInfOpera', '$s_conInfAneLoc', '$s_conInfEndo', '$s_conInfEndSim', ".
               "       '$s_conInfExoSim', '$s_conInfExoCor', '$s_conInfCirApi', '$s_conInfTerNeu', '$s_conInfRevoc',".
               "       '$s_conInfNegacion', '$w_fecha', $s_idUsuario)";
       $result = mysql_query($query) or die('Error en Insercion de SIO_CON_INFORMADOS: ' . mysql_error());          
       // Liberar resultados
       mysql_free_result($result);
     }
     if ($ct==1)//Actualizar datos en SIO_CON_INFORMADOS
     {
       $query = " UPDATE SIO_CON_INFORMADOS ".
               " SET conInformado='$s_conInformado', conInfOpera='$s_conInfOpera', conInfAneLoc='$s_conInfAneLoc', ".
               "     conInfEndo='$s_conInfEndo', conInfEndSim='$s_conInfEndSim', conInfExoSim='$s_conInfExoSim', ".
               "     conInfExoCor='$s_conInfExoCor', conInfCirApi='$s_conInfCirApi', conInfTerNeu='$s_conInfTerNeu', ".
               "     conInfRevoc='$s_conInfRevoc', conInfNegacion='$s_conInfNegacion', fechaConsulta='$w_fecha' ".
               //" WHERE numConsulta=$e_nvoNroCon ";
               " WHERE numTratamiento = $e_tratamiento";                        

       $result = mysql_query($query) or die('Error en Actualizacion de SIO_CON_INFORMADOS: ' . mysql_error());
       // Liberar resultados
       mysql_free_result($result);
     } 

     //<!---------------- Inicio Registro de placa ---------------->    
     //Verifica existencia del registro en la tabla SIO_REG_PLACA
     $ct = cuantosRe("SIO_REG_PLACA", $e_tratamiento, $s_tipoHistoria, $s_tipoId );
     if ($ct==0)//Insertar datos en SIO_REG_PLACA
     {
        $query=" INSERT INTO SIO_REG_PLACA ".
                     " (nitEmpresa, codSede, numConsulta, numTratamiento, idPaciente, tipoHistoria," .           
                     " P551, P554, P552, P555, P541, P544, P542, P545, ".
                     " P531, P534, P532, P535, P521, P524, P522, P525, ".
                     " P511, P514, P512, P515, P611, P614, P612, P615, ".
                     " P621, P624, P622, P625, P631, P634, P632, P635, ".
                     " P641, P644, P642, P645, P651, P654, P652, P655, ".
                     " P857, P854, P852, P851, P847, P844, P842, P841, ".
                     " P837, P834, P832, P831, P827, P824, P822, P821, ".
                     " P817, P814, P812, P811, P717, P714, P712, P711, ".
                     " P727, P724, P722, P721, P737, P734, P732, P731, ".
                     " P747, P744, P742, P741, P757, P754, P752, P751, ".

" P161, P164, P166, P162, P165, ".
" P171, P174, P176, P172, P175, ".
" P181, P184, P186, P182, P185, ".

" P261, P262, P266, P264, P265, ".
" P271, P272, P276, P274, P275, ".
" P281, P282, P286, P284, P285, ".

" P467, P464, P466, P462, P461, ".
" P477, P474, P476, P472, P471, ".
" P487, P484, P486, P482, P481, ".

" P367, P362, P366, P364, P361, ".
" P377, P372, P376, P374, P371, ".
" P387, P382, P386, P384, P381, ".

                     " numSupPlaca, indicePlaca, noAplica, obsNoAplica, fechaConsulta )". 
              "VALUES($s_nitEmpresa, $s_codSede, $pc, $e_tratamiento, $e_idPaciente, '$s_tipoHistoria', ".
                     "$s_P551, $s_P554, $s_P552, $s_P555, $s_P541, $s_P544, $s_P542, $s_P545, ".
                     "$s_P531, $s_P534, $s_P532, $s_P535, $s_P521, $s_P524, $s_P522, $s_P525, ".
                     "$s_P511, $s_P514, $s_P512, $s_P515, $s_P611, $s_P614, $s_P612, $s_P615, ".
                     "$s_P621, $s_P624, $s_P622, $s_P625, $s_P631, $s_P634, $s_P632, $s_P635, ".
                     "$s_P641, $s_P644, $s_P642, $s_P645, $s_P651, $s_P654, $s_P652, $s_P655, ".
                     "$s_P857, $s_P854, $s_P852, $s_P851, $s_P847, $s_P844, $s_P842, $s_P841, ".
                     "$s_P837, $s_P834, $s_P832, $s_P831, $s_P827, $s_P824, $s_P822, $s_P821, ".
                     "$s_P817, $s_P814, $s_P812, $s_P811, $s_P717, $s_P714, $s_P712, $s_P711, ".
                     "$s_P727, $s_P724, $s_P722, $s_P721, $s_P737, $s_P734, $s_P732, $s_P731, ".
                     "$s_P747, $s_P744, $s_P742, $s_P741, $s_P757, $s_P754, $s_P752, $s_P751, ".

" $s_P161, $s_P164, $s_P166, $s_P162, $s_P165, ".
" $s_P171, $s_P174, $s_P176, $s_P172, $s_P175, ".
" $s_P181, $s_P184, $s_P186, $s_P182, $s_P185, ".

" $s_P261, $s_P262, $s_P266, $s_P264, $s_P265, ".
" $s_P271, $s_P272, $s_P276, $s_P274, $s_P275, ".
" $s_P281, $s_P282, $s_P286, $s_P284, $s_P285, ".

" $s_P467, $s_P464, $s_P466, $s_P462, $s_P461, ".
" $s_P477, $s_P474, $s_P476, $s_P472, $s_P471, ".
" $s_P487, $s_P484, $s_P486, $s_P482, $s_P481, ".

" $s_P367, $s_P362, $s_P366, $s_P364, $s_P361, ".
" $s_P377, $s_P372, $s_P376, $s_P374, $s_P371, ".
" $s_P387, $s_P382, $s_P386, $s_P384, $s_P381, ".


                     "$s_numSupPlaca, $s_indicePlaca, '$s_regPlaNoApl', '$s_obsRegPlaNoApl', '$w_fecha' )";  
          $result = mysql_query($query) or die('Error en adicion de SIO_REG_PLACA: ' . mysql_error());

          // Liberar resultados
          mysql_free_result($result);               
      }
      if ($ct==1)//Actualizar datos en SIO_REG_PLACA
      {
         $query=" UPDATE SIO_REG_PLACA SET ".
                " P551=$s_P551, P554=$s_P554, P552=$s_P552, P555=$s_P555, P541=$s_P541, P544=$s_P544, P542=$s_P542, P545=$s_P545, ".
                " P531=$s_P531, P534=$s_P534, P532=$s_P532, P535=$s_P535, P521=$s_P521, P524=$s_P524, P522=$s_P522, P525=$s_P525, ".
                " P511=$s_P511, P514=$s_P514, P512=$s_P512, P515=$s_P515, P611=$s_P611, P614=$s_P614, P612=$s_P612, P615=$s_P615, ".
                " P621=$s_P621, P624=$s_P624, P622=$s_P622, P625=$s_P625, P631=$s_P631, P634=$s_P634, P632=$s_P632, P635=$s_P635, ".
                " P641=$s_P641, P644=$s_P644, P642=$s_P642, P645=$s_P645, P651=$s_P651, P654=$s_P654, P652=$s_P652, P655=$s_P655, ".
                " P857=$s_P857, P854=$s_P854, P852=$s_P852, P851=$s_P851, P847=$s_P847, P844=$s_P844, P842=$s_P842, P841=$s_P841, ".
                " P837=$s_P837, P834=$s_P834, P832=$s_P832, P831=$s_P831, P827=$s_P827, P824=$s_P824, P822=$s_P822, P821=$s_P821, ".
                " P817=$s_P817, P814=$s_P814, P812=$s_P812, P811=$s_P811, P717=$s_P717, P714=$s_P714, P712=$s_P712, P711=$s_P711, ".
                " P727=$s_P727, P724=$s_P724, P722=$s_P722, P721=$s_P721, P737=$s_P737, P734=$s_P734, P732=$s_P732, P731=$s_P731, ".
                " P747=$s_P747, P744=$s_P744, P742=$s_P742, P741=$s_P741, P757=$s_P757, P754=$s_P754, P752=$s_P752, P751=$s_P751, ".

" P161=$s_P161, P164=$s_P164, P166=$s_P166, P162=$s_P162, P165=$s_P165, ".
" P171=$s_P171, P174=$s_P174, P176=$s_P176, P172=$s_P172, P175=$s_P175, ".
" P181=$s_P181, P184=$s_P184, P186=$s_P186, P182=$s_P182, P185=$s_P185, ".

" P261=$s_P261, P262=$s_P262, P266=$s_P266, P264=$s_P264, P265=$s_P265, ".
" P271=$s_P271, P272=$s_P272, P276=$s_P276, P274=$s_P274, P275=$s_P275, ".
" P281=$s_P281, P282=$s_P282, P286=$s_P286, P284=$s_P284, P285=$s_P285, ".

" P467=$s_P467, P464=$s_P464, P466=$s_P466, P462=$s_P462, P461=$s_P461, ".
" P477=$s_P477, P474=$s_P474, P476=$s_P476, P472=$s_P472, P471=$s_P471, ".
" P487=$s_P487, P484=$s_P484, P486=$s_P486, P482=$s_P482, P481=$s_P481, ".

" P367=$s_P367, P362=$s_P362, P366=$s_P366, P364=$s_P364, P361=$s_P361, ".
" P377=$s_P377, P372=$s_P372, P376=$s_P376, P374=$s_P374, P371=$s_P371, ".
" P387=$s_P387, P382=$s_P382, P386=$s_P386, P384=$s_P384, P381=$s_P381, ".



                " numSupPlaca=$s_numSupPlaca, indicePlaca=$s_indicePlaca, noAplica='$s_regPlaNoApl', obsNoAplica='$s_obsRegPlaNoApl', ".
                " fechaConsulta='$w_fecha' ".
                //" WHERE numConsulta=$e_nvoNroCon ";
               " WHERE numTratamiento = $e_tratamiento";  
//echo $query;
                      

          $result = mysql_query($query) or die('Error en modificacion de SIO_REG_PLACA: ' . mysql_error());
          // Liberar resultados
          mysql_free_result($result);        
      }

     //<!---------------- Inicio Observaciones del Odontograma  ---------------->  
     $s_obsOdontograma = $_POST['obsOdontograma'];
     //Verifica existencia del registro en la tabla SIO_OBS_ODONTOGRAMA
     $ct = cuantosRe("SIO_OBS_ODONTOGRAMA", $e_tratamiento, $s_tipoHistoria, $s_tipoId );
     if ($ct==0)//Insertar datos en SIO_OBS_ODONTOGRAMA
     {
        $query=" INSERT INTO SIO_OBS_ODONTOGRAMA ".
                      " (nitEmpresa, codSede, numConsulta, numTratamiento, idPaciente, tipoHistoria," .
                      " obsOdontograma, fechaConsulta, medConsulta)".
               "VALUES($s_nitEmpresa, $s_codSede, $pc, $e_tratamiento, $e_idPaciente, '$s_tipoHistoria', ".
                      " '$s_obsOdontograma', '$w_fecha', $s_idUsuario)";
          $result = mysql_query($query) or die('Error en adicion de SIO_OBS_ODONTOGRAMA: ' . mysql_error());

          // Liberar resultados
          mysql_free_result($result);   
     }
     if ($ct==1)//Actualizar datos en SIO_OBS_ODONTOGRAMA
     {
         $query=" UPDATE SIO_OBS_ODONTOGRAMA SET ".
                "obsOdontograma='$s_obsOdontograma', fechaConsulta='$w_fecha', medConsulta=$s_idUsuario ".    
               " WHERE numTratamiento = $e_tratamiento";                        

          $result = mysql_query($query) or die('Error en modificacion de SIO_OBS_ODONTOGRAMA: ' . mysql_error());
          // Liberar resultados
          mysql_free_result($result);  
     }

     /*-----ALERGIAS----*/
     if ($s_alergias!=""){
          $queryAlerg="SELECT COUNT(*) AS cuantos FROM SIO_ALERGIAS WHERE tipoId= '$e_tipoId ' AND numeroId=$e_idPaciente ";
          $resultAlerg = mysql_query($queryAlerg) or die('Consulta de existencia de alergias fallida: ' . mysql_error());   
          $lineAlerg = mysql_fetch_array($resultAlerg, MYSQL_ASSOC);

          //asigna valores a variables de trabajo
          $cuantos = $lineAlerg["cuantos"];
  
          if ($cuantos==0){
           //inserta en alergias
           $queryA = "INSERT INTO SIO_ALERGIAS(tipoId, numeroId, alergias) VALUES('$e_tipoId', $e_idPaciente, '$s_alergias')";
           $resultAlerg = mysql_query($queryA) or die('Adicion de alergias fallida: ' . mysql_error());   
          }
          else
          {
            //modifica en alergias
            $queryA = "UPDATE SIO_ALERGIAS SET alergias = '$s_alergias' WHERE tipoId= '$e_tipoId ' AND numeroId=$e_idPaciente ";
            $resultAlerg = mysql_query($queryA) or die('Modificacion de alergias fallida: ' . mysql_error());
          }
     }//if alergias
     /*-----FIN ALERGIAS----*/

     /*-----FAMILIAR----*/
     if($s_familiar!="")
     {
       //Verifica existencia del registro en la tabla SIO_FAMILIAR   
       $query  = " SELECT COUNT(*) as cuantos FROM SIO_FAMILIAR WHERE numConsulta = $e_nvoNroCon";
       $result = mysql_query($query) or die('Consulta de cantidad familiar $tabla: ' . mysql_error());
       $line   = mysql_fetch_array($result, MYSQL_ASSOC);
       $ct     = $line["cuantos"];

       if($ct==0)
       {
          $queryFam = "INSERT INTO SIO_FAMILIAR(tipoId, idPaciente,numConsulta, familiar, parentesco, telPariente)".
          " VALUES ('$e_tipoId', $e_idPaciente,  $e_nvoNroCon, '$s_familiar', '$s_parentesco', '$s_telPariente')";  
          $resultFam = mysql_query($queryFam) or die('Adicion de familiares fallida: ' . mysql_error());  
       }
     } 
     /*-----FIN FAMILIAR----*/ 

  } //fin if _post

  //FINNNNNN    GRABA TABLAS DE LA HISTORIA DE TRATAMIENTO -- GENERAL --
  /* ============================================================================================================================
  ============================================================================================================================*/
?>
 <table align="center" width="960">
     <br>
     <tr class="camposLista">
       <td width="100%"  align="center"><span class="icon-checkbox-checked" style="font-size:20px; color:rgba(41, 128, 185, 1);"> <span style="font-size:20px; font-family:Arial; color:#e67e22;"> HISTORIA CLINICA ODONTOLOGICA DE TRATAMIENTO </span> </span></td> 
      </tr>
   </table>


       <table align="center" width="960">
          <tr class="camposLista">
            <td width="100%"  align="center"><span class="icon-user" style="font-size:20px; color:#34495e;"> <span style="font-size:20px; font-family:Arial; color:#34495e;"> DATOS GENERALES DEL PACIENTE</span> </span></td> 
            
          </tr>  
        </table>
        
        
        <table align="center" border="1" width="950">
          <!--<tr>
             <td width ="50%" class="titulosTabla" align ="center">DATOS GENERALES DEL PACIENTE</td>    
          </tr>-->
          <tr>
            <table align="center" border="1"  width="950">
              <tr> 
                <td width ="50%">
                 <table>
                   <tr>
                     <td class = "negrita" align="left">Tipo de documento</td>
                     <td class = "negrita" align="left">N&uacute;mero de documento</label></td>
                     <td class = "negrita" align="left">F.nacimiento</td>
                     <td class = "negrita" align="left">Edad</td>
                   </tr>
                   <tr>
                      <td class="camposTabla" ><?=$e_tipoId?></td>
                      <td class="camposTabla" ><?=$e_idPaciente?></td>
                      <td class = "camposTabla"><?=$s_fecNacimiento?>
                      </td>
                      <td>
                         
                         <input  readonly class="style-1" type="text" size=2 id="edadPaciente" name="edadPaciente" readonly="readonly" value=<?=$anos?>>
                      </td>
                   </tr>
                   <?php
                     if($meses!="")
                     {
                   ?>
                   <tr>
                     <td colspan="4" align="right"><small>Edad <?=$anos?> a&ntilde;os con <?=$meses?> <?=$txtMes?> y <?=$dias?> d&iacute;as</small></td>
                   </tr>
                   <?php
                     }
                   ?>  
                   <tr>
                     <td class = "negrita" align="left">Nombres</td>   
                   </tr>
                   <tr>
                     <td class="camposTabla" colspan="2"><?=$s_nomPaciente?></td>
                     <td class="camposTabla" colspan="2"><?=$s_nomPaciente2?></td>
                   </tr>
                   <tr>
                     <td class = "negrita" align="left">Apellidos</td>   
                   </tr>
                   <tr>
                     <td class="camposTabla" colspan="2"><?=$s_apell1Paciente?></td>
                     <td  class="camposTabla" colspan="2"><?=$s_apell2Paciente?></td>
                   </tr>
                   <tr>
                     <td class = "negrita">RH</td>
                   </tr>
                   <tr>  
                     <td class="camposTabla" align="left"><?=$s_rh?></td>  
                   </tr>
                 </table>
                </td>
                <td width ="50%">
                 <table align="center">
                   <tr>
                      <td class = "negrita" align="left">Ciudad de Nacimiento</td>
                   </tr> 
                   <tr>
                     <td class="camposTabla" colspan = "2" ><?=$s_lugarNacimiento?></td>
                   </tr>
                   <tr>
                     <td class = "negrita" align="left">Sexo</td>                     
                   <tr>     
                     <td align="left">
                       <select name="sexoPaciente" id="sexoPaciente" style="width:200; height:23px;">
                         <option <?=$sxM?> value="M">Masculino</option>
                         <option <?=$sxF?> value="F">Femenino</option>
                         <option <?=$sxN?> value="N">Ni&ntilde;o</option>
                         <option <?=$sxA?> value="A">Ni&ntilde;a</option>
                      </select>
                     </td> 
                    </tr>
                    <tr>
                       <td class = "negrita" align="left">Estado civil</td>
                   </tr>
                    <tr> 
                     <td align="left">
                      <select name="estCivil" id="estCivil" style="width:200; height:23px;">
                         <option <?=$ecS?> value="S">Soltero</option>
                         <option <?=$ecC?> value="C">Casado</option>
                         <option <?=$ecU?> value="U">Uni&oacute;n libre</option>
                         <option <?=$ecD?> value="D">Divorciado</option>                          
                         <option <?=$ecV?> value="V">Viudo</option>                          
                      </select>                        
                     </td>
                   </tr>
                   <tr>
                     <td class = "negrita" align="left">Escolaridad</td>
                   </tr>
                   <tr>  
                     <td align="left">
                      <select readonly name="escolaridad" id="escolaridad" style="width:200; height:23px;">
                         <option <?=$esS?> value="S">Sin escolaridad</option>
                         <option <?=$esP?> value="P">Primaria</option>
                         <option <?=$esB?> value="B">Bachillerato</option>
                         <option <?=$esT?> value="T">T&eacute;cnico</option>
                         <option <?=$esG?> value="G">Tecnol&oacute;gico</option>
                         <option <?=$esU?> value="U">Universitario</option>
                         <option <?=$esE?> value="E">Especializaci&oacute;n</option>
                      </select>
                     </td> 
                     
                   </tr>
                 </table>
                </td>
              </tr>
            </table>
          </tr>
        </table> 
    
        
        <table align="center" border="1"  width="950">
          <tr> 
            <td width ="50%">
              <table>
                <tr>
                  <td class="titulosTabla" align ="center" colspan="4">UBICACION DEL PACIENTE</td>
                </tr>
                <tr>
                   <td colspan="2" class="negrita" align="left">Ciudad</td>
                   <td colspan="2" class="negrita" align="left">Ubicaci&oacute;n</td>
                </tr>
                <tr>
                   <td class="camposTabla" colspan="2"><?=$s_ciuResidencia?></td>
                   <td colspan="2">
                     <select name="ubicacion" id="ubicacion" style="width:200; height:23px;" required>
                       <option  value=""></option>
                       <option <?=$ubU?> value="U">Urbana</option>                            
                       <option <?=$ubR?> value="R">Rural</option>
                     </select>
                   </td>
                </tr>
                <tr>
                   <td colspan="4" class="negrita" align="left">Direcci&oacute;n</td>
                </tr>
                <tr>
                   <td class="camposTabla" colspan="4"><?=$s_dirResidencia?></td>
                </tr>
                <tr>
                   <td colspan="2" class="negrita" align="left">Tel&eacute;fonos</td>
                   <td colspan="2" class="negrita" align="left">E Mail</td>
                </tr> 
                <tr>
                   <td class="camposTabla" colspan="2" align="left"><?=$s_telResidencia?></td> 
                   <td class="camposTabla" colspan="2" align="left"><?=$s_email?></td>
                </tr>
                    
              </table>
            </td>
            <td align="center" width ="50%">
              <table  width ="100%" align="center">
                <tr>
                  <td class="titulosTabla" align ="center" colspan="4">DATOS DE VINCULACION</td>
                </tr>
                <tr>
                   <td class="negrita" align="left">Tipo de vinculaci&oacute;n</td> 
                </tr>
                <tr>
                   <td align="left">
                      <select name="tipoVinculacion" id="tipoVinculacion" style="width:250; height:23px;">
                        <option <?=$tvC?> value="C">Cotizante</option>                            
                        <option <?=$tvB?> value="B">Beneficiario</option>
                        <option <?=$tvP?> value="P">Particular</option>
                         <option <?=$tvO?> value="O">Otro</option>                          
                      </select>
                   </td>  
                </tr> 
                <tr>
                   <td class="negrita" align="left">Rango</td> 
                </tr>
                <tr>
                   <td align="left">
                      <select name="rango" id="rango" style="width:250; height:23px;">
                        <option <?=$rangoU?> value=1>Uno</option>                            
                        <option <?=$rangoD?> value=2>Dos</option>
                        <option <?=$rangoT?> value=3>Tres</option>                         
                      </select>
                    </td>      
                </tr>
                <tr>
                   <td class="negrita" align="left">Tipo de Usuario</td> 
                </tr>
                <tr>
                   <td align="left">
                      <select name="tipUsu" id="tipUsu" style="width:250; height:23px;">
                        <option <?=$tipoUc?> value=1>Contributivo</option>                            
                        <option <?=$tipoUs?> value=2>Subsidiado</option>
                        <option <?=$tipoUv?> value=3>Vinculado</option>
                        <option <?=$tipoUp?> value=4>Particular</option>
                        <option <?=$tipoUo?> value=5>Otro</option>                         
                      </select>
                    </td>      
                </tr>
              </table>
            </td>  
          </tr>
        </table>
 <form name="form1" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">   
  
    <table align="center" border="0" width="960" > 
     <tr>
       <td class="negrita" colspan="2" align="center">En las descripciones no incluir caracteres especiales como las comillas dobles o las comillas simples (" o ')</td>
     </tr>
   </table>    

   <table align="center" border="1" width="960"> 
    <tr>
       <td align="center"><span class="icon-volume-high" style="font-size:16px; color:#e74c3c;"></span> <span style="font-size:16px; color:#e74c3c; font-family:Arial;"> ALERTAS:Alergias - Medicamentos </span></td>
     </tr>
     <tr>
       <td align="center"> 
         <textarea style="font-size:14px; color:#e74c3c; font-family:Arial;" rows="3" cols="120" wrap="soft" name="alergias" id="alergias"><?=$s_alergias?></textarea>
       </td>
     </tr> 
    
   </table> 

   <!--- ///////////////////////////////////////////////////////////////////////////////
         /////////////////////////// MOTIVO DE CONSULTA ////////////////////////////////
         ///////////////////////////////////////////////////////////////////////////////-->

   <table width="960" border="1" align="center" cellpadding="0">
     <tr></td><br></td></tr> 
     <tr class="titulosTabla">
       <td align="left">Motivo Consulta</td>
     </tr>
                
     <tr> 
       <td align="center">
          <textarea rows="4" cols="110" wrap="soft" name="motivoConsulta" id="motivoConsulta" required><?=$s_motConsulta?></textarea>
       </td>
     </tr> 
     <tr class="titulosTabla">
         <td align="left">Enfermedad Actual</td>
     </tr> 
     <tr>
       <td align="center">
         <textarea rows="4" cols="110" wrap="soft" name="enfermedadActual" id="enfermedadActual" required><?=$s_enfActual?></textarea>   
       </td>
     </tr>  
     <tr class="titulosTabla">
        <td align="left">
          Antecedentes Familiares                        
        </td>
     </tr> 
     <tr>
       <td align="center">
         <textarea rows="4" cols="110" wrap="soft" name="antecedentesFam" id="antecedentesFam"><?=$s_antFam?></textarea>   
       </td>
     </tr>  
     <tr>
       <td align="center">
         <input type="submit" name="submit" value="Grabar Situaci&oacute;n Actual"><br>   
       </td>
     </tr>        
   </table>

   <!--- ///////////////////////////////////////////////////////////////////////////////
         //////////////ANTECEDENTES ODONTOLOGICOS Y MEDICOS GENERALES//////////////////
         ///////////////////////////////////////////////////////////////////////////////-->

     <table width="960" border="0" align="center" cellpadding="0">
        <tr></td><br></td></tr> 
                <tr class="titulosTabla" align="center">
                  <td colspan="3">ANTECEDENTES ODONTOLOGICOS Y MEDICOS GENERALES</td>
                <tr>  
                <tr class="subtutulosTabla" align="center">
                  <td width="60%">Antecedente</td>
                  <td width="5%">SI</td>
                  <td width="35%">Observaciones(Si contesta afirmativamente, debe diligenciar las observaciones)</td>
                </tr>
                <!--<tr class="camposTabla">
                  <td>Alergias</td>
                  <td align="center"><input <?=$chkAlergia?> id="alergias" name="alergias" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsAlergia" id="obsAlergia"><?=$s_obsAlergia?></textarea></td>
                </tr>-->
                <tr class="camposTabla">
                  <td>Discracias Sanguineas</td>
                  <td align="center"><input <?=$chkDiscrasias?> id="discrasiasSang" name="discrasiasSang" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsDiscrasiasSang" id="obsDiscrasiasSang"><?=$s_obsDiscrasiasSang?></textarea></td>
                </tr> 
                <tr class="camposTabla">
                  <td>Cardiopatias</td>
                  <td align="center"><input <?=$chkCardio?> id="cardiopatias" name="cardiopatias" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsCardiopatias" id="obsCardiopatias"><?=$s_obsCardiopatias?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Embarazo</td>
                  <td align="center"><input <?=$chkEmbarazo?> id="embarazo" name="embarazo" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsEmbarazo" id="obsEmbarazo"><?=$s_obsEmbarazo?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Alteracion presion arterial</td>
                  <td align="center"><input <?=$chkPresArt?> id="altPresArterial" name="altPresArterial" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsAltPresArterial" id="obsAltPresArterial"><?=$s_obsAltPresArterial?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Toma Medicamentos</td>
                  <td align="center"><input <?=$chkTomaMedicamentos?> id="tomaMedicamentos" name="tomaMedicamentos" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsTomaMedicamentos" id="obsTomaMedicamentos"><?=$s_obsTomaMedicamentos?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Tratamiento Medico Actual</td>
                  <td align="center"><input <?=$chkTratMedActual?> id="tratMedActual" name="tratMedActual" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsTratMedActual" id="obsTratMedActual"><?=$s_obsTratMedActual?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Hepatitis</td>
                  <td align="center"><input <?=$chkHepatitis?> id="hepatitis" name="hepatitis" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsHepatitis" id="obsHepatitis"><?=$s_obsHepatitis?></textarea></td>
                </tr> 
                <tr class="camposTabla">
                  <td>Diabetes</td>
                  <td align="center"><input <?=$chkDiabetes?> id="diabetes" name="diabetes" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsDiabetes" id="obsDiabetes"><?=$s_obsDiabetes?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Fiebre Reumatica</td>
                  <td align="center"><input <?=$chkFiebreReum?> id="fiebreReum" name="fiebreReum" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsFiebreReum" id="obsFiebreReum"><?=$s_obsFiebreReum?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>HIV-Sida</td>
                  <td align="center"><input <?=$chkSida?> id="sida" name="sida" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsSida" id="obsSida"><?=$s_obsSida?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Inmunosupresion</td>
                  <td align="center"><input <?=$chkInmuno?> id="inmunosupresion" name="inmunosupresion" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsInmunosupresion" id="obsInmunosupresion"><?=$s_obsInmunosupresion?></textarea></td>
                </tr>
                <tr class="camposTabla">
                 <td>Patologias Renales</td>
                 <td align="center"><input <?=$chkPatRenal?> id="patologiasRenales" name="patologiasRenales" type="checkbox" value="S" /></td>
                 <td><textarea rows="2" cols="80" wrap="soft" name="obsPatologiasRenales" id="obsPatologiasRenales"><?=$s_obsPatologiasRenales?></textarea></td>
                </tr>  
                <tr class="camposTabla">
                  <td>Patologias Respiratoria</td>
                  <td align="center"><input <?=$chkPatResp?> id="patRespiratoria" name="patRespiratoria" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsPatRespiratoria" id="obsPatRespiratoria"><?=$s_obsPatRespiratoria?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Trastornos Gastricos</td>
                  <td align="center"><input <?=$chkTrasGastricos?> id="trasGastricos" name="trasGastricos" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsTrasGastricos" id="obsTrasGastricos"><?=$s_obsTrasGastricos?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Trastornos Emocionales</td>
                  <td align="center"><input <?=$chktTrasEmocional?> id="trasEmocional" name="trasEmocional" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsTrasEmocional" id="obsTrasEmocional"><?=$s_obsTrasEmocional?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Sinusitis</td>
                  <td align="center"><input <?=$chkSinusitis?> id="sinusitis" name="sinusitis" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsSinusitis" id="obsSinusitis"><?=$s_obsSinusitis?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Cirugias (Incluson Orales)</td>
                  <td align="center"><input <?=$chkCirugias?> id="cirugias" name="cirugias" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsCirugias" id="obsCirugias"><?=$s_obsCirugias?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Exodoncias</td>
                  <td align="center"><input <?=$chkExodoncias?> id="exodoncias" name="exodoncias" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsExodoncias" id="obsExodoncias"><?=$s_obsExodoncias?></textarea></td>
                </tr>
                 <tr class="camposTabla">
                  <td>Enfermedades Orales</td>
                  <td align="center"><input <?=$chkEnfOrales?> id="enfOrales" name="enfOrales" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsEnfOrales" id="obsEnfOrales"><?=$s_obsEnfOrales?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Uso de protesis o aparatologia oral</td>
                  <td align="center"><input <?=$chkUsoProtesis?> id="usoProtesis" name="usoProtesis" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsUsoProtesis" id="obsUsoProtesis"><?=$s_obsUsoProtesis?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Habitos y otras patologias o antecedentes odont&oacute;logicos o m&eacute;dicos </td>
                  <td colspan="2"><textarea rows="2" cols="90" wrap="soft" name="habitos" id="habitos"><?=$s_habitos?></textarea></td>
                </tr>
                <tr>
                  <td colspan="3" align="center">
                  <input type="submit" name="submit" value="Grabar Antecedentes"><br>   
                  </td>
                </tr> 
    </table>  
    
    <!--- ///////////////////////////////////////////////////////////////////////////////
         ///////////////////////////EXAMEN ESTOMATOLOGICO ///////////////////////////////
         ///////////////////////////////////////////////////////////////////////////////-->   

    <table width="960" border="0" align="center" cellpadding="0">
            <tr></td><br></td></tr> 
               <tr class="titulosTabla" align="center">
                  <td colspan="3">EXAMEN ESTOMATOLOGICO</td>
                <tr>
                <tr class="subtutulosTabla" align="center">
                  <td width="30%">Estructura</td>
                  <td width="5%">Estado</td>
                  <td width="70%">Observaciones</td>
                </tr>
                <tr class="camposTabla">
                  <td>Labio Inferior</td>
                  <td> 
                     <select name="labioInferior" id="labioInferior">
                         <option <?=$labioInferiorNormal?> value="Normal">Normal</option>
                         <option <?=$labioInferiorAnormal?> value="Anormal">Sintomatico</option>
                     </select>
                  </td>   
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsLabioInferior" id="obsLabioInferior"><?=$s_obsLabioInferior?></textarea></td>
                </tr>
                <tr class="camposTabla">
                   <td>Labio Superior</td>
                   <td align="center">
                      <select name="labioSuperior" id="labioSuperior">
                           <option <?=$labioSuperiorNormal?> value="Normal">Normal</option>
                           <option <?=$labioSuperiorAnormal?> value="Anormal">Sintomatico</option>
                       </select>
                    </td>
                    <td><textarea rows="2" cols="80" wrap="soft" name="obsLabioSuperior" id="obsLabioSuperior"><?=$s_obsLabioSuperior?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Comisuras</td>
                  <td align="center">
                       <select name="comisuras" id="comisuras">
                           <option <?=$comisurasNormal?> value="Normal">Normal</option>
                           <option <?=$comisurasAnormal?> value="Anormal">Sintomatico</option>
                       </select>
                  </td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsComisuras" id="obsComisuras"><?=$s_obsComisuras?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Mucosa Oral</td>
                  <td align="center">
                       <select name="mucosaOral" id="mucosaOral">
                           <option <?=$mucosaOralNormal?> value="Normal">Normal</option>
                           <option <?=$mucosaOralAnormal?> value="Anormal">Sintomatico</option>
                       </select>
                  </td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsMucosaOral" id="obsmucosaOral"><?=$s_obsMucosaOral?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Surcos Yugales</td>
                  <td align="center">
                       <select name="surcosYugales" id="surcosYugales">
                           <option <?=$surcosYugalesNormal?> value="Normal">Normal</option>
                           <option <?=$surcosYugalesAnormal?> value="Anormal">Sintomatico</option>
                       </select>
                  </td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsSurcosYugales" id="obsSurcosYugales"><?=$s_obsSurcosYugales?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Frenillos</td>
                  <td align="center">
                       <select name="frenillos" id="frenillos">
                           <option <?=$frenillosNormal?> value="Normal">Normal</option>
                           <option <?=$frenillosAnormal?> value="Anormal">Sintomatico</option>
                       </select>
                  </td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsFrenillos" id="obsFrenillos"><?=$s_obsFrenillos?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>OroFaringe</td>
                  <td align="center">
                       <select name="oroFaringe" id="oroFaringe">
                           <option <?=$oroFaringeNormal?> value="Normal">Normal</option>
                           <option <?=$oroFaringeAnormal?> value="Anormal">Sintomatico</option>
                       </select> 
                  </td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsOrofaringe" id="obsOrofaringe"><?=$s_obsOrofaringe?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Paladar</td>
                  <td align="center">
                       <select name="paladar" id="paladar">
                           <option <?=$paladarNormal?> value="Normal">Normal</option>
                           <option <?=$paladarAnormal?> value="Anormal">Sintomatico</option>
                       </select>
                  </td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsPaladar" id="obsPaladar"><?=$s_obsPaladar?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Glandulas Salivales</td>
                  <td align="center">
                        <select name="glandSalivales" id="glandSalivales">
                           <option <?=$glandSalivalesNormal?> value="Normal">Normal</option>
                           <option <?=$glandSalivalesAnormal?> value="Anormal">Sintomatico</option>
                       </select>
                  </td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsGlandSalivales" id="obsGlandSalivales"><?=$s_obsGlandSalivales?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Piso de Boca</td>
                  <td align="center">
                        <select name="pisoBoca" id="pisoBoca">
                           <option <?=$pisoBocaNormal?> value="Normal">Normal</option>
                           <option <?=$pisoBocaAnormal?> value="Anormal">Sintomatico</option>
                       </select>
                  </td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsPisoBoca" id="obsPisoBoca"><?=$s_obsPisoBoca?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Dorso de Lengua</td>
                  <td align="center">
                        <select name="dorsoLengua" id="dorsoLengua">
                           <option <?=$dorsoLenguaNormal?> value="Normal">Normal</option>
                           <option <?=$dorsoLenguaAnormal?> value="Anormal">Sintomatico</option>
                       </select>
                  </td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsDorsoLengua" id="obsDorsoLengua"><?=$s_obsDorsoLengua?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Vientre de Lengua</td>
                  <td align="center">
                        <select name="vientreLengua" id="vientreLengua">
                           <option <?=$vientreLenguaNormal?> value="Normal">Normal</option>
                           <option <?=$vientreLenguaAnormal?> value="Anormal">Sintomatico</option>
                       </select>
                  </td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsVientreLengua" id="obsVientreLengua"><?=$s_obsVientreLengua?></textarea></td>
                </tr>
                <tr>
                  <td colspan="3" align="center">
                  <input type="submit" name="submit" value="Grabar Examen Estomatologico"><br>   
                  </td>
                </tr> 
    </table>  

   <!--- ///////////////////////////////////////////////////////////////////////////////
         /////////////////////////// ARTICULACION TEMPOROMANDIBULAR /////////////////////
         ///////////////////////////////////////////////////////////////////////////////-->  

   <table width="960" border="0" align="center" cellpadding="0">
              <tr></td><br></td></tr>  
               <tr class="titulosTabla" align="center">
                  <td colspan="3">ARTICULACION TEMPOROMANDIBULAR</td>
                <tr>
                <tr class="subtutulosTabla" align="center">
                  <td width="30%">Hallazgos Cl&iacute;nicos</td>
                  <td width="5%">Estado</td>
                  <td width="70%">Observaciones</td>
                </tr>
                <tr class="camposTabla">
                  <td>Ruidos</td>
                  <td align="center">
                       <select name="ruidos" id="ruidos">
                            <option <?=$ruidosNormal?> value="Normal">No Presente</option>
                            <option <?=$ruidosAnormal?> value="Anormal">Presente</option>
                       </select>
                  </td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsRuidos" id="obsRuidos"><?=$s_obsRuidos?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Desviacion</td>
                  <td align="center">
                         <select name="desviacion" id="desviacion">
                            <option <?=$desviacionNormal?> value="Normal">No Presente</option>
                            <option <?=$desviacionAnormal?> value="Anormal">Presente</option>
                       </select>
                  </td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsDesviacion" id="obsDesviacion"><?=$s_obsDesviacion?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Cambio de Volumen</td>
                  <td align="center">
                        <select name="cambioVolumen" id="cambioVolumen">
                            <option <?=$cambioVolumenNormal?> value="Normal">No Presente</option>
                            <option <?=$cambioVolumenAnormal?> value="Anormal">Presente</option>
                       </select>
                  </td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsCambioVolumen" id="obsCambioVolumen"><?=$s_obsCambioVolumen?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Bloqueo Mandibular</td>
                  <td align="center">
                         <select name="bloqueoMand" id="bloqueoMand">
                            <option <?=$bloqueoMandNormal?> value="Normal">No Presente</option>
                            <option <?=$bloqueoMandAnormal?> value="Anormal">Presente</option>
                       </select>
                  </td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsBloqueMand" id="obsBloqueMand"><?=$s_obsBloqueMand?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Limite de Apertura</td>
                  <td align="center">
                         <select name="limitApertura" id="limitApertura">
                            <option <?=$limitAperturaNormal?> value="Normal">No Presente</option>
                            <option <?=$limitAperturaAnormal?> value="Anormal">Presente</option>
                       </select>
                  </td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsLimitApertura" id="obsLimitApertura"><?=$s_obsLimitApertura?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Dolor Articular</td>
                  <td align="center">
                        <select name="dolorArticular" id="dolorArticular">
                            <option <?=$dolorArticularNormal?> value="Normal">No Presente</option>
                            <option <?=$dolorArticularAnormal?> value="Anormal">Presente</option>
                       </select>
                  </td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsDolorArticular" id="obsDolorArticular"><?=$s_obsDolorArticular?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Dolor Muscular</td>
                  <td align="center">
                        <select name="dolorMuscular" id="dolorMuscular">
                            <option <?=$dolorMuscularNormal?> value="Normal">No Presente</option>
                            <option <?=$dolorMuscularAnormal?> value="Anormal">Presente</option>
                       </select>
                  </td>
                 <td><textarea rows="2" cols="80" wrap="soft" name="obsDolorMuscular" id="obsDolorMuscular"><?=$s_obsDolorMuscular?></textarea></td>
                </tr>
                <tr>
                  <td colspan="3" align="center">
                  <input type="submit" name="submit" value="Grabar Articuluacion Temporomandibular"><br>   
                  </td>
                </tr> 
    </table>  


    <!--- ///////////////////////////////////////////////////////////////////////////////
         /////////////////////////// DATOS DE ODONTOGRAMA ///////////////////////////////
         ///////////////////////////////////////////////////////////////////////////////-->  

   <table align='center' border="0" width="960">
       <!--
       <tr>
        <td colspan="2" class="subtutulosTabla" align="left" style='height:40' >Seleccione el Odontograma a trabajar</td>
        <td>
          <select name="tipOdo" id="tipOdo" style='height:25; width:350'>
            <?php echo $comboTipOdo; ?>
          </select>
        </td> 
       </tr>
       -->
       <tr></td><br></td></tr>  
       <tr class="titulosTabla" align="center">
          <td colspan="3">PLAN DE TRATAMIENTO</td>
       <tr>

       <tr>
          <td colspan="3" class="subtutulosTabla" align="left" >SELECCIONE EL DIAGNOSTICO O PROCEDIMIENTO ENCONTRADO Y MARQUE LOS DIENTES CORRESPONDIENTES</td> 
       </tr>
       <tr>  
          <td>
             <input id="chkDgs" name="chkDgs" type="checkbox" onclick="check2(this)" />
          </td> 
          <td>
            <select name="grDg" id="grDg"  onchange="load(this.value)" style='height:25; width:350'>
               <?php echo $comboGrCie10; ?>
            </select>
          </td>
            <td>
              <div id="myDiv"></div>
            </td>
        </tr>  

        <tr>  
          <td>
             <input id="chkCups" name="chkCups" type="checkbox" onclick="check1(this)" />
          </td> 
          <td>
            <select name="grCups" id="grCups"  onchange="load1(this.value)" style='height:25; width:350'>
               <?php echo $comboGrCups; ?>
            </select>
          </td>
            <td>
              <div id="myDiv1"></div>
            </td>
        </tr> 
       <!--     
       <tr>    
          <td class="subtutulosTabla" align="left" >SELECCIONE EL DIAGNOSTICO Y MARQUE LOS DIENTES CORRESPONDIENTES</td>
          <td align="left" class="camposTabla"> Diagn&oacute;stico: 
           <select name="odonto" id="odonto"style='height:25; width:350'>
             <?php echo $comboLisOd; ?>
           </select>
          </td>
       </tr>    
       -->
       <tr>
         <td><br></td>
       </tr>
   </table>
   
   <!--===================================================================================
       =============================LISTAS DE DIENTES  FILA 1=============================
       =================================================================================== -->
   
   <table align="center" border="0">
       <tr class="negrita">  <!--FILA 1-->
         <td colspan="3" align="center">  <!--diente 18-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center' colspan="3"><label>18</label><input id="C180" name="C180" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C181" name="C181" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C184" name="C184" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C186" name="C186" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C182" name="C182" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C185" name="C185" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 18-->
         
         <td colspan="3" align="center">  <!--diente 17-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center' colspan="3"><label>17</label><input id="C170" name="C170" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C171" name="C171" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C174" name="C174" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C176" name="C176" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C172" name="C172" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C175" name="C175" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 17  -->       

         <td colspan="3" align="center">  <!--diente 16-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center' colspan="3"><label>16</label><input id="C160" name="C160" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C161" name="C161" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C164" name="C164" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C166" name="C166" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C162" name="C162" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C165" name="C165" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 16  -->           

         <td colspan="3" align="center">  <!--diente 15-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align = "center" colspan="3"><label>15</label><input id="C150" name="C150" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C151" name="C151" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C154" name="C154" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C156" name="C156" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C152" name="C152" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C155" name="C155" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 15  -->  
         
         <td colspan="3" align="center">  <!--diente 14-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>14</label><input id="C140" name="C140" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C141" name="C141" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C144" name="C144" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C146" name="C146" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C142" name="C142" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C145" name="C145" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 14  -->   
         
         <td colspan="3" align="center">  <!--diente 13-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>13</label><input id="C130" name="C130" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C131" name="C131" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C134" name="C134" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C133" name="C133" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C132" name="C132" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C135" name="C135" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 13  -->          

         <td colspan="3" align="center">  <!--diente 12-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>12</label><input id="C120" name="C120" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C121" name="C121" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C124" name="C124" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C123" name="C123" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C122" name="C122" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C125" name="C125" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 12  -->
         
         <td colspan="3" align="center">  <!--diente 11-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>11</label><input id="C110" name="C110" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C111" name="C111" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C114" name="C114" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C113" name="C113" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C112" name="C112" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C115" name="C115" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 11  -->    
         
         <td colspan="3" align="center">  <!--diente 21-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>21</label><input id="C210" name="C210" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C211" name="C211" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C212" name="C212" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C213" name="C213" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C214" name="C214" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C215" name="C215" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 21  -->            

         <td colspan="3" align="center">  <!--diente 22-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>22</label><input id="C220" name="C220" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C221" name="C221" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C222" name="C222" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C223" name="C223" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C224" name="C224" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C225" name="C225" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 22  -->    
         
         <td colspan="3" align="center">  <!--diente 23-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>23</label><input id="C230" name="C230" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C231" name="C231" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C232" name="C232" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C233" name="C233" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C234" name="C234" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C235" name="C235" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 23  -->                             
         
         <td colspan="3" align="center">  <!--diente 24-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>24</label><input id="C240" name="C240" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C241" name="C241" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C242" name="C242" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C246" name="C246" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C244" name="C244" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C245" name="C245" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 24  --> 
         
         <td colspan="3" align="center">  <!--diente 25-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>25</label><input id="C250" name="C250" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C251" name="C251" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C252" name="C252" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C256" name="C256" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C254" name="C254" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C255" name="C255" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 25  -->          
         
         <td colspan="3" align="center">  <!--diente 26-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>26</label><input id="C260" name="C260" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C261" name="C261" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C262" name="C262" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C266" name="C266" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C264" name="C264" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C265" name="C265" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 26  --> 
         
         <td colspan="3" align="center">  <!--diente 27-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>27</label><input id="C270" name="C270" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C271" name="C271" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C272" name="C272" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C276" name="C276" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C274" name="C274" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C275" name="C275" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 27  --> 
         
         <td colspan="3" align="center">  <!--diente 28-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>28</label><input id="C280" name="C280" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C281" name="C281" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C282" name="C282" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C286" name="C286" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C284" name="C284" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C285" name="C285" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 28  -->                                    
       <tr>  <!--FIN FILA 1 -->
       <tr>
         <td><br></td>
       </tr> 
     </table>
     
     <!--  ============================= FILA 2 =================================== -->

     <table align="center">            
       <tr class="negrita">  <!--FILA 2-->
       
         <td></td>

         <td colspan="3" align="center">  <!--diente 55-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>55</label><input id="C550" name="C550" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C551" name="C551" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C554" name="C554" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C556" name="C556" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C552" name="C552" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C555" name="C555" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 55  -->          

         <td colspan="3" align="center">  <!--diente 54-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>54</label><input id="C540" name="C540" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C541" name="C541" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C544" name="C544" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C546" name="C546" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C542" name="C542" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C545" name="C545" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 54  -->  
            
         <td colspan="3" align="center">  <!--diente 53-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>53</label><input id="C530" name="C530" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C531" name="C531" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C534" name="C534" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C533" name="C533" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C532" name="C532" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C535" name="C535" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>            
            
         <td colspan="3" align="center">  <!--diente 52-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>52</label><input id="C520" name="C520" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C521" name="C521" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C524" name="C524" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C523" name="C523" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C522" name="C522" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C525" name="C525" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 52  -->      
     
         <td colspan="3" align="center">  <!--diente 51-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>51</label><input id="C510" name="C510" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C511" name="C511" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C514" name="C514" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C513" name="C513" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C512" name="C512" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C515" name="C515" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 51  -->      
     
         <td colspan="3" align="center">  <!--diente 61-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>61</label><input id="C610" name="C610" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C611" name="C611" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C612" name="C612" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C613" name="C613" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C614" name="C614" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C615" name="C615" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 61  --> 
              
         <td colspan="3" align="center">  <!--diente 62-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>62</label><input id="C620" name="C620" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C621" name="C621" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C622" name="C622" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C623" name="C623" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C624" name="C624" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C625" name="C625" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 62  -->      
     
         <td colspan="3" align="center">  <!--diente 63-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>63</label><input id="C630" name="C630" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C631" name="C631" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C632" name="C632" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C633" name="C633" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C634" name="C634" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C635" name="C635" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 63  --> 

         <td colspan="3" align="center">  <!--diente 64-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>64</label><input id="C640" name="C640" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C641" name="C641" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C642" name="C642" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C646" name="C646" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C644" name="C644" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C645" name="C645" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 64  --> 
         
         <td colspan="3" align="center">  <!--diente 65-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>65</label><input id="C650" name="C650" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C651" name="C651" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input id="C652" name="C652" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C656" name="C656" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C654" name="C654" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C655" name="C655" type="checkbox" value="S" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 65  -->          
       </tr> <!--FILA 2 -->
       <tr>
         <td><br></td>
       </tr>
     </table>

     <!--  ============================= FILA 3 =================================== -->

     <table align="center">            
       <tr class="negrita">  <!--FILA 3-->
       
         <td></td>
                
         <td colspan="3" align="center">  <!--diente 85-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>85</label><input id="C850" name="C850" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C857" name="C857" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C854" name="C854" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C856" name="C856" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C852" name="C852" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C851" name="C851" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 85  -->   
         
         <td colspan="3" align="center">  <!--diente 84-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>84</label><input id="C840" name="C840" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C847" name="C847" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C844" name="C844" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C846" name="C846" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C842" name="C842" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C841" name="C841" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 84  -->          

         <td colspan="3" align="center">  <!--diente 83-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>83</label><input id="C830" name="C830" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C837" name="C837" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C834" name="C834" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C833" name="C833" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C832" name="C832" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C831" name="C831" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 83  --> 

         <td colspan="3" align="center">  <!--diente 82-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>82</label><input id="C820" name="C820" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C827" name="C827" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C824" name="C824" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C823" name="C823" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C822" name="C822" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C821" name="C821" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 82  --> 

         <td colspan="3" align="center">  <!--diente 81-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>81</label><input id="C810" name="C810" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C817" name="C817" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C814" name="C814" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C813" name="C813" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C812" name="C812" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C811" name="C811" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 81  -->          

         <td colspan="3" align="center">  <!--diente 71-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>71</label><input id="C710" name="C710" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C717" name="C717" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C712" name="C712" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C713" name="C713" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C714" name="C714" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C711" name="C711" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 71  --> 

         <td colspan="3" align="center">  <!--diente 72-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>72</label><input id="C720" name="C720" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C727" name="C727" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C722" name="C722" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C723" name="C723" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C724" name="C724" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C721" name="C721" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 72  --> 

         <td colspan="3" align="center">  <!--diente 73-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>73</label><input id="C730" name="C730" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C737" name="C737" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C732" name="C732" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C733" name="C733" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C734" name="C734" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C731" name="C731" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 73  --> 

         <td colspan="3" align="center">  <!--diente 74-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>74</label><input id="C740" name="C740" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C747" name="C747" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C742" name="C742" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C746" name="C746" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C744" name="C744" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C741" name="C741" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 74  --> 

         <td colspan="3" align="center">  <!--diente 75-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>75</label><input id="C750" name="C750" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C757" name="C757" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C752" name="C752" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C756" name="C756" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C754" name="C754" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C751" name="C751" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 75  --> 
       </tr> <!--FILA 3 -->
       <tr>
         <td><br></td>
       </tr>
      <table> 
 
      <!--  ============================= FILA 4 =================================== -->

      <table align="center">            
       <tr class="negrita">  <!--FILA 4-->     
         <td colspan="3" align="center">  <!--diente 48-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>48</label><input id="C480" name="C480" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C487" name="C487" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C484" name="C484" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C486" name="C486" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C482" name="C482" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C481" name="C481" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 48  --> 
         
         <td colspan="3" align="center">  <!--diente 47-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>47</label><input id="C470" name="C470" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C477" name="C477" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C474" name="C474" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C476" name="C476" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C472" name="C472" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C471" name="C471" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 47  -->          
   
         <td colspan="3" align="center">  <!--diente 46-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>46</label><input id="C460" name="C460" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C467" name="C467" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C464" name="C464" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C466" name="C466" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C462" name="C462" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C461" name="C461" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 46  -->    
   
         <td colspan="3" align="center">  <!--diente 45-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>45</label><input id="C450" name="C450" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C457" name="C457" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C454" name="C454" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C456" name="C456" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C452" name="C452" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C451" name="C451" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 45  -->    
   
         <td colspan="3" align="center">  <!--diente 44-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>44</label><input id="C440" name="C440" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C447" name="C447" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C444" name="C444" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C446" name="C446" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C442" name="C442" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C441" name="C441" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 44  -->    
   
         <td colspan="3" align="center">  <!--diente 43-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>43</label><input id="C430" name="C430" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C437" name="C437" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C434" name="C434" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C433" name="C433" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C432" name="C432" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C431" name="C431" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 43  -->    
   
         <td colspan="3" align="center">  <!--diente 42-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>42</label><input id="C420" name="C420" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C427" name="C427" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C424" name="C424" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C423" name="C423" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C422" name="C422" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C421" name="C421" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 42  -->    
   
         <td colspan="3" align="center">  <!--diente 41-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>41</label><input id="C410" name="C410" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C417" name="C417" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C414" name="C414" type="checkbox" value="S" /></td> <!--Distal-->
               <td align="center"><input id="C413" name="C413" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C412" name="C412" type="checkbox" value="S" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C411" name="C411" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 41  -->    
   
         <td colspan="3" align="center">  <!--diente 31-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>31</label><input id="C310" name="C310" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C317" name="C317" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C312" name="C312" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C313" name="C313" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C314" name="C314" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C311" name="C311" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 31  -->    
   
         <td colspan="3" align="center">  <!--diente 32-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>32</label><input id="C320" name="C320" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C327" name="C327" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C322" name="C322" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C323" name="C323" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C324" name="C324" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C321" name="C321" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 32  -->    
   
         <td colspan="3" align="center">  <!--diente 33-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>33</label><input id="C330" name="C330" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C337" name="C337" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C332" name="C332" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C333" name="C333" type="checkbox" value="S" /></td> <!--Incisal-->
               <td align="center"><input id="C334" name="C334" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C331" name="C331" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 33  -->    
 
         <td colspan="3" align="center">  <!--diente 34-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>34</label><input id="C340" name="C340" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C347" name="C347" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C342" name="C342" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C346" name="C346" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C344" name="C344" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C341" name="C341" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 34  -->  
 
         <td colspan="3" align="center">  <!--diente 35-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>35</label><input id="C350" name="C350" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C357" name="C357" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C352" name="C352" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C356" name="C356" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C354" name="C354" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C351" name="C351" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 35  -->  
 
         <td colspan="3" align="center">  <!--diente 36-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>36</label><input id="C360" name="C360" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C367" name="C367" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C362" name="C362" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C366" name="C366" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C364" name="C364" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C361" name="C361" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 36  -->  
 
         <td colspan="3" align="center">  <!--diente 37-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>37</label><input id="C370" name="C370" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C377" name="C377" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C372" name="C372" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C376" name="C376" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C374" name="C374" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C371" name="C371" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 37  -->  
 
         <td colspan="3" align="center">  <!--diente 38-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align='center'colspan="3"><label>38</label><input id="C380" name="C380" type="checkbox" value="S" /></td> <!--Todo-->
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input id="C387" name="C387" type="checkbox" value="S" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input id="C382" name="C382" type="checkbox" value="S" /></td> <!--Mesial-->
               <td align="center"><input id="C386" name="C386" type="checkbox" value="S" /></td> <!--Oclusal-->
               <td align="center"><input id="C384" name="C384" type="checkbox" value="S" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input id="C381" name="C381" type="checkbox" value="S" /></td> <!--Vestibular-->
             </tr> 
           </table>
         <td>  <!--FIN diente 38  -->        
        </tr> <!--FILA 4 -->
        <tr>
         <td><br></td>
        </tr>
      <table> 

      <!--  ============================= BOTON DE GRABAR =================================== -->   

      <table align='center' border="0" width="100%">
        <tr> 
          <td class='negrita' align='center'>
            <input type='submit' id='grabarOd' name='grabarOd' value='Grabar Datos del Odontograma' style='height:40; width:960' >
          </td>
        </tr>  
      </table>

     <!--//////////////////////////////////////////////////////////////////////////////////////
         ///////////////////INICIO DE  ODONTOGRAMA DE DIAGNOSTICO ////////////////////////////
         //////////////////////////////////////////////////////////////////////////////////////-->

     <div id="TabbedPanels1" class="TabbedPanels">
      <ul class="TabbedPanelsTabGroup">
        <li class="TabbedPanelsTab" tabindex="0">DIAGNOSTICO</li>
        <li class="TabbedPanelsTab" tabindex="0">TRATAMIENTO</li>
        <!--<li class="TabbedPanelsTab" tabindex="0">EVOLUCION</li>-->
      </ul>
      <div class="TabbedPanelsContentGroup">
        <div class="TabbedPanelsContent">
         <table bgcolor="#FFF" width='960' align="center">
          <tr>
            <td>  
              <?php
                //arma tabla de odontograma de diagnosticos elegidos
                $query = " SELECT B.*, A.codCie10, A.nomCie10, A.grupo " .
                         " FROM SIO_CIE10 A, SIO_DIA_ODONTOGRAMA B ".
                         " WHERE A.codCie10 = B.codDiag AND ". 
                         "       B.tipoId = '$e_tipoId' AND B.idPaciente = $e_idPaciente";
                         //"     B.numConsulta = '$nConsulta' ";
                $result = mysql_query($query) or die('Consulta de odontograma de diagnosticofallida: ' . mysql_error());
        
                $num_total_registros = mysql_num_rows($result); 
                //echo $num_total_registros;
        
                $s_icCarNoCav = 0; 
                $i=0;
                while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) 
                {
                  $diente    = $line["numDiente"];
                  $cara      = $line["caraDiente"]; 
                  $codigo    = $line["codCie10"];
                  $nombre    = $line["nomCie10"];
                  $odoObs    = $line["observaciones"];
                  $consulta  = $line["numConsulta"];
                  $fecha     = $line["fechaConsulta"];
                  $s_grDg    = $line["grupo"];

                  $matriz = explode(" ", $fecha);
                  $fecha = $matriz[0]; 

                  //$fecha = date("d-m-Y", strtotime($fecha));

                  /////// SUMA VALORES PARA INDICE COPS 
                  $s_icSignos = $s_icSignos + 1;
                  if ($s_grDg=='GD002')
                  {
                    
                    $s_icCarNoCav = $s_icCarNoCav + 1;
                    
                    /*$s_icCarCav
                    $s_icObturados
                    $s_icPerCaries
                    $s_icPerOtra
                    $s_icTotDiePre
                    $s_icCop
                    $s_icCopMod*/
                  }
                  /////// FIN SUMA VALORES PARA INDICE COPS


                  echo("<table class='camposTabla' align='center' width='960' border='1' cellpading='0'>\n");
                  //echo ("<form method='post' action='historiaClinica.php'>\n");
                  if ($i==0)
                  {// para mostrar titulos 
                     echo ("<tr>\n");
                        echo   ("<td class='titulosTabla' align='center' colspan='4'>LISTA DE DIAGNOSTICOS</td>\n");
                     echo("</tr>\n");
                     echo("<tr>\n");
                        echo("<td width='25%' class='negrita'align='center'>Toque para eliminar</td>\n");
                        echo("<td width='50%' class='negrita'>Diagnostico</td>\n");
                        echo("<td width='25%' class='negrita'>Fecha</td>\n");
                        //echo("<td width='25%' class='negrita'>No. Consulta / Fecha</td>\n");
                     echo("</tr>\n");
                  }
                  echo("<tr>\n");
                    echo("<td width='25%' align='center'><input type='submit' id='BorrarOd' name='BorrarOd' value='$codigo-$diente-$cara' style='width:150' onclick='return confirmation()'></td>\n");
                    echo("<td width='50%' align='center' class='camposTabla'>$nombre</td>\n");
                    //echo("<td width='25%' class='camposTabla' align='center'> $consulta del $fecha</td>\n");
                    echo("<td width='25%' class='camposTabla' align='center'> $fecha</td>\n"); 
                  echo("</tr>\n");
          
                  $i = $i+1;
                }//while 
        
                 $activeDg="N";
                 if ($i>0)
                 {
                  $activeDg="S";      
                 }
                 echo("</table>\n");
                 // Liberar resultados
                 mysql_free_result($result);
               ?>
              </td>
            </tr>
            
            <?php
             if($activeDg=="S")
             {
            ?>
             <tr> 


               <td colspan="4"  align="CENTER"> 
                <a href=sioOdontogramaDiag.php?s_tipoHistoria=<?=$s_tipoCon?>&nroCta=<?=$nConsulta?>&tipoId=<?=$e_tipoId?>&idPaciente=<?=$e_idPaciente?> target='_blank' ><img src="../SIME/imagenes/verOdont.jpg"></a>
              </td
            </tr>
          <?php  
           }
          ?>  
         </table>    
       </div>
      


      <div class="TabbedPanelsContent">

         <table>







           <tr>               
             <td class='negrita'>SELECCIONE EL TRATAMIENTO
               <select name="grCups1" id="grCups1"  onchange="load3(this.value)" style='height:25; width:350'>
                  <?php echo $comboGrCups1; ?>
                </select>
              </td>
           </tr>
           <tr>         
              <td>
                <div id="myDiv3"></div>
              </td>
            </tr> 

             <!--<tr>
              <td class='negrita' colspan="3" align="left" class="camposTabla">SELECCIONE EL TRATAMIENTO
                <select name="odontoTr" id="odontoTr" style='height:25; width:470'>
                   <?php echo $comboLisTr; ?>
                </select>
              </td>
             </tr>-->






 
             <tr>
                <td class='negrita'>INGRESE INFORMACION ADICIONAL PARA EL TRATAMIENTO A SEGUIR Y TOQUE EL DIENTE CORRESPONDIENTE 
                 <textarea rows="3" cols="85" wrap="soft" name="obsTratamiento" id="obsTratamiento"></textarea> 
               </td>
               <td clas="camposTabla">
                 <table>
                   <!-- 
                   <tr>
                     <td><input type="checkbox" name="enTrat" id="enTrat" onclick='cambiarTr()'></td>
                     <td>Tratamiemto </td> 
                   </tr>
                   -->
                   <tr>
                     <td clas="camposTabla">
                        <input type="checkbox" name="realizado" id="realizado" onclick='cambiarRe()'> 
                     </td>
                     <td>Terminado? </td>  
                   </tr> 
                 </table>
               </td> 
             </tr>
             <tr> 
             <?php
             if($activeTr=="S")
             {
            ?>  


               <td colspan="4"  align="right"> 
                <a href=sioOdontogramaTra.php?s_tipoHistoria=<?=$s_tipoCon?>&nroCta=<?=$nConsulta?>&tipoId=<?=$e_tipoId?>&idPaciente=<?=$e_idPaciente?> target='_blank' ><img src="../SIME/imagenes/verOdont.jpg"></a>
              </td
            </tr>
          <?php  
           }
          ?>  
          </table>  

          <table bgcolor="#FFF" width='960'>
            <tr>
              <td>
               <?php
              //////////////////////////////////////////////////////////////////////////////////////
              ///////////////////INICIO DE  ODONTOGRAMA DE TRATAMIENTO
              //////////////////////////////////////////////////////////////////////////////////////

                //arma tabla de odontograma de tratamientos elegidos
                $query = " SELECT B.*, A.codCie10, A.nomCie10, A.grupo " .
                         " FROM SIO_CIE10 A, SIO_TRA_ODONTOGRAMA B ".
                         " WHERE A.codCie10 = B.codDiag AND ". 
                         "       B.tipoId = '$e_tipoId' AND B.idPaciente = $e_idPaciente";
                         //"     B.numConsulta = '$nConsulta' ";
                $result = mysql_query($query) or die('Consulta de odontograma de tratamiento fallida: ' . mysql_error());
        
                $num_total_registros = mysql_num_rows($result); 
                //echo $num_total_registros;
        
                $i=0;
                while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) 
                {
                  $trat="GGGG";
                  $diente    = $line["numDiente"];
                  $cara      = $line["caraDiente"]; 
                  $codigo    = $line["codCie10"];
                  $nombre    = $line["nomCie10"];
                  $odoObs    = $line["observaciones"];
                  $trat      = $line["tratamiento"];
                  $real      = $line["realizado"];
                  $codTr     = $line["codTra"];
                  $consulta  = $line["numConsulta"];
                  $fecha     = $line["fechaConsulta"];

                  $matriz = explode(" ", $fecha);
                  $fecha = $matriz[0]; 


                  if ($trat=="S"){
                    $estado="EN-TRATAMIENTO";
                   }
                  else{
                    if ($real=="S"){
                       $estado="----TERMINADO----";
                     }
                     else{ 
                      $estado="EN-DIAGNOSTICO";
                     }
                   } 
                  $queryT  = "SELECT descripcion FROM SIO_PROC_POS WHERE cups='$codTr'";
                  $resultT = mysql_query($queryT) or die('Consulta de descripcion de tratamiento fallida: ' . mysql_error()); 
                  $lineT   = mysql_fetch_array($resultT, MYSQL_ASSOC);
                  $nomT    = $lineT["descripcion"];

                  echo("<table class='camposTabla' align='center' width='100%' border='1' cellpading='0'>\n");
                  //echo ("<form method='post' action='historiaClinica.php'>\n");
                  if ($i==0)
                  {// para mostrar titulos 
                     echo ("<tr>\n");
                        echo   ("<td class='subtutulosTabla' align='center' colspan='7'>EVOLUCION</td>\n");
                     echo("</tr>\n");
                     echo("<tr>\n");
                        echo("<td  colspan='2' class='negrita'align='center'>Diagn&oacute;stico y Diente a Tratar</td>\n");
                        echo("<td  colspan='2' class='negrita' align='center'>Ultimo tratamiento realizado</td>\n");
                        echo("<td  class='negrita'>Estado</td>\n");
                        //echo("<td  class='negrita'>No. Consulta / Fecha</td>\n");
                        echo("<td  class='negrita'>Fecha</td>\n");
                        //echo("<td  class='negrita'>Ver detalles</td>\n");
                     echo("</tr>\n");
                  }

                  if ($estado!="----TERMINADO----")
                  {
                  echo("<tr>\n");
                    echo("<td width='15%' align='center'><input type='submit' id='modificarTr' name='modificarTr' value='$codigo-$diente-$cara' style='width:150'></td>\n");
                  }                                 
                  else
                  {
                    echo("<td width='15%' align='center'><b>$codigo-$diente-$cara</b></td>\n");
                  }

                    echo("<td width='20%' align='center' class='camposTabla'>$nombre</td>\n");
                    echo("<td width='15%' align='center'>$codTr</td>\n");
                    echo("<td width='20%' align='left' class='camposTabla'>$nomT</td>\n");
                    echo("<td width='5%' align='left' class='camposTabla'>$estado</td>\n");
                    //echo("<td width='15%' class='camposTabla' align='center'> $consulta del $fecha</td>\n");
                    echo("<td width='15%' class='camposTabla' align='center'>$fecha</td>\n");
                    //echo("<td width='15%' class='camposTabla' align='center'><input onclick='abrirHijo();' type=image src='imagenes/lupa.jpg' width='35' height='22'></td>\n");
                  echo("</tr>\n");
          
                  $i = $i+1;
                }//while 
        
                 $activeTr="N";
                 if ($i>0)
                 {
                  $activeTr="S";      
                 }
                 echo("</table>\n");
                 // Liberar resultados
                 mysql_free_result($result);
               ?>
              </td>           
             </tr>
             </table>
             
             <table> 
               <tr> 
                <?php
                 if($activeTr=="S")
                 {
                ?>  


                  <td colspan="4"  align="right"> 
                    <a href=sioOdontogramaTra.php?s_tipoHistoria=<?=$s_tipoCon?>&nroCta=<?=$nConsulta?>&tipoId=<?=$e_tipoId?>&idPaciente=<?=$e_idPaciente?> target='_blank' ><img src="../SIME/imagenes/verOdont.jpg"></a>
                 </td
               </tr>
             <?php  
              }
             ?>  
            </table> 
        </div>


      </div>
     </div>


<!--- ///////////////////////////////////////////////////////////////////////////////
         ////////////////DIAGNOSTICOS PARA TODA LA BOCA////////////////////
         ///////////////////////////////////////////////////////////////////////////////-->  


          <table align='center' border="0" width="960">
             <?php
                //arma tabla de dg y tr para toda la boca elegidos
                $query = " SELECT *" .
                         " FROM SIO_DIA_ODONBOCA ".
                         " WHERE tipoId = '$e_tipoId' AND idPaciente = $e_idPaciente";

                $result = mysql_query($query) or die('Consulta de odontograma de tratamiento fallida: ' . mysql_error());

                $i=0;
                while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) 
                {
                  $s_numConsulta   = $line["numConsulta"];
                  $s_tipoHistoria  = $line["tipoHistoria"];
                  $s_codDiag       = $line["codDiag"];
                  $s_tipo          = $line["tipo"];
                  $s_numDiente     = $line["numDiente"];
                  $s_caraDiente    = $line["caraDiente"]; 
                  $s_observaciones = $line["observaciones"];
                  $s_medConsulta   = $line["medConsulta"];   


                  if ($s_tipo=="DG"){
                    $queryName = "SELECT nomCie10 AS NOMBRE FROM SIO_CIE10 WHERE codCie10 = '$s_codDiag' ";
                    $resultName = mysql_query($queryName) or die('Consulta de nombre cie10 123 fallida: ' . mysql_error());
                    $lineName = mysql_fetch_array($resultName, MYSQL_ASSOC);
                  }
                  if ($s_tipo=="TR"){
                    $queryName = "SELECT descripcion AS NOMBRE FROM SIO_PROC_POS WHERE cups = '$s_codDiag' "; 
                    $resultName = mysql_query($queryName) or die('Consulta de nombre procedimiento 123 fallida: ' . mysql_error());
                    $lineName = mysql_fetch_array($resultName, MYSQL_ASSOC);
                  }

                  $nombrePrDg = $lineName["NOMBRE"];

                  if ($i==0)
                  {// para mostrar titulos 
                     echo ("<tr>\n");
                        echo   ("<td class='titulosTabla' align='center' colspan='3'>OTROS PROCEDIMIENTOS</td>\n");
                     echo("</tr>\n");
                     echo("<tr>\n");                        
                        echo("<td  class='negrita'>Tipo (Toque para eliminar)</td>\n");
                        //echo("<td  class='negrita'>Diag. / Trata</td>\n");
                        echo("<td  class='negrita'>Nombre</td>\n");
                     echo("</tr>\n");
                  }
                  echo("<tr class='camposTabla'>\n"); 
                     echo("<td width='150' align='LEFT'>
                       <input type='submit' id='BorrarTrBoca' name='BorrarTrBoca' value='$s_codDiag-$s_numDiente-$s_caraDiente' style='width:150' onclick='return confirmation()'></td>\n");

                     //echo("<td width='150' align='LEFT'>
                  //<input type='submit' id='BorrarTrBoca' name='BorrarTrBoca' value='$s_codDiag-$s_tipo' style='width:150' onclick='return confirmation()'></td>\n");

                    echo("<td width='250' align='left'>$nombrePrDg</td>\n");
                  echo("</tr>\n");

                  $i=$i+1;
                }

             ?>
          </table>

<!--- ///////////////////////////////////////////////////////////////////////////////
         /////////////////////////// OSERVACIONES DEL ODONTOGRAMA////////////////////
         ///////////////////////////////////////////////////////////////////////////////-->  

    <table align='center' border="0" width="960">      
      <tr>
        <td class="negrita" align="center">
          <HR width=100% align="right">
       </td>
      </tr>
      <tr>
        <td class="negrita" align="center">OBSERVACIONES PARA EL ODONTOGRAMA</td>
      </tr>
      <tr>
        <td class="negrita" align="center">
          <HR width=100% align="right">
       </td>
      </tr>
      <tr>
        <td ALIGN="center">
          <textarea  class="style-1" rows="4" cols="160" wrap="soft" name="obsOdontograma" id="obsOdontograma"><?=$s_obsOdontograma?></textarea>
        </td>
      </tr>   
      <tr>
         <td colspan="3" align="center">
           <input type="submit" name="submit" value="Grabar Observaciones par el Odontograma"><br>   
         </td>
      </tr>     
    </table>  

<!--- ///////////////////////////////////////////////////////////////////////////////
         /////////////////////////// INDICE COPS ///////////////////////////////////////
         ///////////////////////////////////////////////////////////////////////////////-->  

    <table align='center' border="0" width="960">
       <tr><td><br></td></tr>
       <tr>
        <td colspan="9" class="titulosTabla" align="center" align="left">INDICE COPS 1</td>
       </tr>
       <tr class="negrita" align="center"> 
          <td>Signos</td> <td>Cariados No<br>Cavitacional(C1)</td> <td>Cariados <br>Cavitacional(C2)</td> <td>Obturados(O)</td>
          <td>Perdidos Por<br>Caries(P)</td><td>Perdidos Otra<br>Raz&oacute;n(K)</td><td>Total Dientes<br>Presentes</td><td>COP<br>(C2+O+P)</td>
          <td>COP Modificado<br>(C1+C2+O+P)</td>
       </tr>
       <tr align="center">
           <td>
              <input type="text" id="icSignos" name="icSignos" readOnly="readonly" size="10" value=<?=$s_icSignos?>>
           </td>
           <td>
              <input type="text" id="icCarNoCav" name="icCarNoCav" readOnly="readonly" size="10" value=<?=$s_icCarNoCav?>>
           </td> 
           <td>
              <input type="text" id="icCarCav" name="icCarCav" readOnly="readonly" size="10" value=<?=$s_icCarCav?>>
           </td>
           <td>
              <input type="text" id="icObturados" name="icObturados" readOnly="readonly" size="10" value=<?=$s_icObturados?>>
           </td> 
           <td>
              <input type="text" id="icPerCaries" name="icPerCaries" readOnly="readonly" size="10" value=<?=$s_icPerCaries?>>
           </td>
       
           <td>
              <input type="text" id="icPerOtra" name="icPerOtra" readOnly="readonly" size="10" value=<?=$s_icPerOtra?>>
           </td> 
           <td>
              <input type="text" id="icTotDiePre" name="icTotDiePre" readOnly="readonly" size="10" value=<?=$s_icTotDiePre?>>
           </td>
           <td>
              <input type="text" id="icCop" name="icCop" readOnly="readonly" size="10" value=<?=$s_icCop?>>
           </td>  
           <td>
              <input type="text" id="icCopMod" name="icCopMod" readOnly="readonly" size="10" value=<?=$s_icCopMod?>>
           </td>  
       </tr> 
    </table>

    <!--//////////////////////////////////////////////////////////////////////////////////////
         ///////////////////INICIO CONSENTIMIENTOS INFORMADOS ////////////////////////////////////////
         //////////////////////////////////////////////////////////////////////////////////////--> 

    <table width="960" border="0" align="center" cellpadding="0">
      <tr></td><br></td></tr>  
      <tr class="titulosTabla" align="center">
        <td colspan="2">CONSENTIMIENTOS INFORMADOS</td>
      <tr>
      <tr class="negrita" align="center">
        <td colspan="2">Por favor seleccione los consentimientos informados de este tratamiento</td>
      <tr>
      <tr class="subtutulosTabla" align="center">
        <td align="left" width="50%">Consentimiento</td>
        <td align="left" width="50%">SI</td>
      </tr>
      <tr class="camposTabla">
         <td>Consentimiento Informado</td>
         <td align="left"><input <?=$chkConInformado?> id="conInformado" name="conInformado" type="checkbox" value="S" /></td>
      </tr>
      <tr class="camposTabla">
         <td>Formulario de Consentimiento Informado para Operatoria</td>
         <td align="left"><input <?=$chkConInfOpera?> id="conInfOpera" name="conInfOpera" type="checkbox" value="S" /></td>
      </tr>
      <tr class="camposTabla">
         <td>Formulario de Consentimiento Informado para Anestesia Local</td>
         <td align="left"><input <?=$chkConInfAneLoc?> id="conInfAneLoc" name="conInfAneLoc" type="checkbox" value="S" /></td>
      </tr>
      <tr class="camposTabla">
         <td>Formulario de Consentimiento Informado para Endodoncia</td>
         <td align="left"><input <?=$chkConInfEndo?> id="conInfEndo" name="conInfEndo" type="checkbox" value="S" /></td>
      </tr>
      <tr class="camposTabla">
         <td>Formulario de Consentimiento Informado para Endodoncia Simple</td>
         <td align="left"><input <?=$chkConInfEndSim?> id="conInfEndSim" name="conInfEndSim" type="checkbox" value="S" /></td>
      </tr>
      <tr class="camposTabla">
         <td>Formulario de Consentimiento Informado para Exodoncia Simple</td>
         <td align="left"><input <?=$chkConInExoSim?> id="conInfExoSim" name="conInfExoSim" type="checkbox" value="S" /></td>
      </tr>
      <tr class="camposTabla">
         <td>Formulario de Consentimiento Informado para Exodoncia de Cordales e Incluidos</td>
         <td align="left"><input <?=$chkConInfExoCor?> id="conInfExoCor" name="conInfExoCor" type="checkbox" value="S" /></td>
      </tr>
      <tr class="camposTabla">
         <td>Formulario de  Consentimiento Informado para Cirug&iacute;a Apical</td>
         <td align="left"><input <?=$chkConInfCirApi?> id="conInfCirApi" name="conInfCirApi" type="checkbox" value="S" /></td>
      </tr>
      <tr class="camposTabla">
         <td>Formulario de Consentimiento Informado para Terapia Neural</td>
         <td align="left"><input <?=$chkConInfTerNeu?> id="conInfTerNeu" name="conInfTerNeu" type="checkbox" value="S" /></td>
      </tr>
      <tr class="camposTabla">
         <td>Revocaci&oacute;n</td>
         <td align="left"><input <?=$chkConInfRevoc?> id="conInfRevoc" name="conInfRevoc" type="checkbox" value="S" /></td>
      </tr>
      <tr class="camposTabla">
         <td>Formulario de Negaci&oacute;n del Consentimiento Informado</td>
         <td align="left"><input <?=$chkConInfNegacion?> id="conInfNegacion" name="conInfNegacion" type="checkbox" value="S" /></td>
      </tr>
      <tr>
         <td colspan="3" align="center">
           <input type="submit" name="submit" value="Grabar Consentimientos Informados"><br>   
         </td>
      </tr>       
    </table> 

     <!--//////////////////////////////////////////////////////////////////////////////////////
         ///////////////////INICIO PLAN DE TRATAMIENTO ////////////////////////////////////////
         //////////////////////////////////////////////////////////////////////////////////////-->

     <?php
               //arma tabla de odontograma de tratamientos elegidos
                $query = " SELECT B.*, A.codCie10, A.nomCie10, A.grupo " .
                         " FROM SIO_CIE10 A, SIO_TRA_MOVODONTO B ".
                         " WHERE A.codCie10 = B.codDiag AND ". 
                         "       B.tipoId = '$e_tipoId' AND B.idPaciente = $e_idPaciente";
                         //"     B.numConsulta = '$nConsulta' ";   
                $result = mysql_query($query) or die('Consulta de odontograma de movimientos de tratamiento fallida: ' . mysql_error());
        
                $num_total_registros = mysql_num_rows($result); 
                //echo $num_total_registros;
        
                $i=0;
                echo("<table class='camposTabla' align='center' width='960' border='1' cellpading='0'>\n"); 
                while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) 
                {
                  $diente    = $line["numDiente"];
                  $cara      = $line["caraDiente"]; 
                  $codigo    = $line["codDiag"];
                  $nombre    = $line["descripcion"];
                  $codTr     = $line["codTra"];
                  $odoObs    = $line["observaciones"];                 
                  $consulta  = $line["numConsulta"];
                  $fecha     = $line["fechaConsulta"];
                  $s_estado  = $line["estado"];
                  $s_medConsulta = $line["medConsulta"];

                  //trae nombre del medico 
                  $queryMed = "select nomUsuario, apell1usuario, apell2usuario FROM SIME_BAS_N_USUARIOS WHERE idusuario=$s_medConsulta"; 
                  $resultM = mysql_query($queryMed) or die('Consulta de medico tratante fallida: ' . mysql_error()); 
                  $lineM   = mysql_fetch_array($resultM, MYSQL_ASSOC);
                  $nomM    = $lineM["nomUsuario"] . " " . $lineM["apell1usuario"] . " " . $lineM["apell2usuario"];
  
                  $matriz = explode(" ", $fecha);
                  $fecha = $matriz[0]; 

                  //$queryT  = "SELECT descripcion FROM SIO_LIS_ODONTOGRAMA WHERE codigo='$codTr'";
                  $queryT  = "SELECT descripcion FROM SIO_PROC_POS WHERE cups='$codTr'";     

                  $resultT = mysql_query($queryT) or die('Consulta de descripcion de tratamiento fallida: ' . mysql_error()); 
                  $lineT   = mysql_fetch_array($resultT, MYSQL_ASSOC);
                  $nomT    = $lineT["descripcion"];

                  if ($i==0)
                  {// para mostrar titulos      
                    echo ("<tr></td><br></td></tr>\n");                 
                     echo ("<tr>\n");
                        echo   ("<td class='titulosTabla' align='center' colspan='9'>PLAN DE TRATAMIENTO</td>\n");
                     echo("</tr>\n");
                     echo("<tr class='subtutulosTabla'>\n");
                        echo("<td class='negrita'align='left'>Diagn&oacute;sticos/Diente/Cara/Procedimiento Realizado</td>\n");
                        echo("<td class='negrita' align='center'>Observaciones</td>\n"); 
                        echo("<td class='negrita'>Estado</td>\n");
                        //echo("<td  class='negrita'>No.Cons./Fecha</td>\n");
                        echo("<td class='negrita'>Fecha</td>\n");
                        //echo("<td class='negrita'>Evolucionar</td>\n");
                     echo("</tr>\n");
                  }
                   echo("<tr>\n");
                    if ($s_estado=="EN-TRATAMIENTO")
                    {
                      echo("<td 'align='left'><input type='submit' id='BorrarTr' name='BorrarTr' value='$codigo-$diente-$cara-$codTr' onclick='return confirmation1()'>$nombre / $nomT   <br>  <b>$nomM</b></td>\n");
                   echo("</td>\n");
                    }
                    else
                    {
                      echo("<td 'align='left'><b>$codigo-$diente-$cara-$codTr</b>  $nombre / $nomT   <br>  <b>$nomM</b></td>\n");
                   echo("</td>\n");                      
                    }
 
                    echo("<td class='camposTabla1' align='left'>$odoObs</td>\n");
                    echo("<td class='camposTabla1' align='left'>$s_estado</td>\n");
                    echo("<td class='camposTabla1' align='center'>$fecha</td>\n");
                    //echo("<td class='camposTabla1' width='10%' align='center'> $consulta del $fecha</td>\n");
                    //echo("<td class='negrita'>Evolucionar</td>\n");
                  echo("</tr>\n"); 
                  $i = $i+1;
                }//while 
        
                $activeTr="N";
                if ($i>0)
                {
                  $activeTr="S";      
                }
                echo("</table>\n");
                // Liberar resultados
                mysql_free_result($result);
              ?>

     <!--//////////////////////////////////////////////////////////////////////////////////////
         ///////////////////INICIO PROTESIS E HIGIENE ORAL//////////////////////////////////////
         //////////////////////////////////////////////////////////////////////////////////////-->

     <table width="960" border="0" align="center" cellpadding="0">
        <tr></td><br></td></tr>
             <tr class="titulosTabla" align="center">
              <td colspan="3">PROTESIS</td>
             <tr>
             <tr class="subtutulosTabla" align="center">
               <td width="30%"></td>
               <td width="5%">SI</td>
               <td width="70%">Observaciones</td>
             </tr>
             <tr class="camposTabla">
               <td>Presenta alg&uacute;n Tipo de Protesis</td>
               <td align="center"><input <?=$chkProtesis?> id="protesis" name="protesis" type="checkbox" value="S" /></td>
               <td><textarea rows="2" cols="80" wrap="soft" name="obsProtesis" id="obsProtesis"><?=$s_obsProtesis?></textarea></td>
             </tr>
     </table>
     
     <table width="960" border="0" align="center" cellpadding="0">
           <tr></td><br></td></tr>
             <tr class="titulosTabla" align="center">
              <td colspan="4">HIGIENE ORAL</td>
             </tr>
                <tr class="camposTabla">
                  <td>Higiene
                    <select name="higiene" id="higiene">
                         <option <?=$hBuena?> value="Buena">Buena</option>
                         <option <?=$hRegular?> value="Regular">Regular</option>
                         <option <?=$hMala?> value="Mala">Mala</option>
                    </select>
                  </td>
                  <td>Frecuancia Cepillado
                    <select name="freCepillado" id="freCepillado">
                         <option <?=$fCtres?> value="Tres Veces">Tres Veces</option>
                         <option <?=$fCdos?> value="Dos Veces">Dos Veces</option>
                         <option <?=$fCuno?> value="Una Vez">Una Vez</option>
                    </select>
                  </td>
                </tr>
                <tr class="camposTabla">
                  <td>Seda Dental <input <?=$chkSedaDental?> id="sedaDental" name="sedaDental" type="checkbox" value="S" /></td>  
                  <td>Pigmentaciones <input <?=$chkPigmentacion?> id="pigmentacion" name="pigmentacion" type="checkbox" value="S" /></td>
                </tr>  
                <tr class="camposTabla">
                   <td>Grado de Riesgo
                     <select name="gradoRiesgo" id="gradoRiesgo">
                         <option <?=$grBajo?> value="Bajo">Bajo</option>
                         <option <?=$grMedio?> value="Medio">Medio</option>
                         <option <?=$grAlto?> value="Alto">Alto</option>
                     </select>
                   </td> 
                </tr>
                <tr class="negrita">
                   <td colspan="4">Observaciones</td> 
                </tr>
                <tr align="center">
                   <td colspan="2"><textarea rows="4" cols="110" wrap="soft" name="obsHigiene" id="obsHigiene"><?=$s_obsHigiene?></textarea></td> 
                </tr>
                <tr>
                  <td colspan="3" align="center">
                     <input type="submit" name="submit" value="Grabar Pr&oacute;tesis e Higiene Oral"><br>   
                  </td>
                </tr> 
    </table>   
    
    <!--//////////////////////////////////////////////////////////////////////////////////////
         ///////////////////INICIO REGISTRO DE PLACA    //////////////////////////////////////
         //////////////////////////////////////////////////////////////////////////////////////-->     
       
     <table width="960" border="0" align="center" cellpadding="0">
       <tr></td><br></td></tr>
       <tr class="titulosTabla" align="center">
           <td>REGISTRO DE PLACA</td>
       </tr>
     </table>

<!--  ============================= FILA 2 PARA EL REGISRO DE PLACA =================================== -->

     <table align="center">            
       <tr class="negrita">  <!--FILA 2-->

         <td colspan="3" align="center">  <!--diente 18-->
           <table align='center' border="0" cellpadding="0" width="10">             
             <tr>
               <td align="center"></td>
               <td align="center"><label>.</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>18</label></td>
               <td align="center"></td>
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP181?> id="P181" name="P181" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP184?> id="P184" name="P184" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
               <td align="center"><input id="P186" name="P186" type="checkbox" value="0" onclick="return false;"/></td> <!--Oclusal-->
               <td align="center"><input <?=$chkP182?> id="P182" name="P182" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP185?> id="P185" name="P185" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 18  -->            
       
         <td colspan="3" align="center">  <!--diente 17-->
           <table align='center' border="0" cellpadding="0" width="10">             
             <tr>
               <td align="center"></td>
               <td align="center"><label>.</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>17</label></td>
               <td align="center"></td>
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP171?> id="P171" name="P171" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP174?> id="P174" name="P174" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
               <td align="center"><input id="P176" name="P176" type="checkbox" value="0" onclick="return false;"/></td> <!--Oclusal-->
               <td align="center"><input <?=$chkP172?> id="P172" name="P172" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP175?> id="P175" name="P175" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 17  -->            

         <td colspan="3" align="center">  <!--diente 16-->
           <table align='center' border="0" cellpadding="0" width="10">             
             <tr>
               <td align="center"></td>
               <td align="center"><label>.</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>16</label></td>
               <td align="center"></td>
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP161?> id="P161" name="P161" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP164?> id="P164" name="P164" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
               <td align="center"><input id="P166" name="P166" type="checkbox" value="0" onclick="return false;"/></td> <!--Oclusal-->
               <td align="center"><input <?=$chkP162?> id="P162" name="P162" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP165?> id="P165" name="P165" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 16  -->            

         <td colspan="3" align="center">  <!--diente 55-->
           <table align='center' border="0" cellpadding="0" width="10">
             
             <tr>
               <td align="center"></td>
               <td align="center"><label>55</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>15</label></td>
               <td align="center"></td>
             </tr>     
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP551?> id="P551" name="P551" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP554?> id="P554" name="P554" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
               <td align="center"><input id="P556" name="P556" type="checkbox" value="0" onclick="return false;"/></td> <!--Oclusal-->
               <td align="center"><input <?=$chkP552?> id="P552" name="P552" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP555?> id="P555" name="P555" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 55  -->          

         <td colspan="3" align="center">  <!--diente 54-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align="center"></td>
               <td align="center"><label>54</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>14</label></td>
               <td align="center"></td>
             </tr>      
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP541?> id="P541" name="P541" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP544?> id="P544" name="P544" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
               <td align="center"><input id="P546" name="P546" type="checkbox" value="0" onclick="return false;" /></td> <!--Oclusal-->
               <td align="center"><input <?=$chkP542?> id="P542" name="P542" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP545?> id="P545" name="P545" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 54  -->  
            
         <td colspan="3" align="center">  <!--diente 53-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align="center"></td>
               <td align="center"><label>53</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>13</label></td>
               <td align="center"></td>
             </tr>       
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP531?> id="P531" name="P531" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP534?> id="P534" name="P534" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
               <td align="center"><input id="P533" name="P533" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP532?> id="P532" name="P532" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP535?> id="P535" name="P535" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Palatino-->
             </tr> 
           </table>            
            
         <td colspan="3" align="center">  <!--diente 52-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align="center"></td>
               <td align="center"><label>52</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>12</label></td>
               <td align="center"></td>
             </tr>       
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP521?> id="P521" name="P521" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP524?>  id="P524" name="P524" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
               <td align="center"><input id="P523" name="P523" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP522?> id="P522" name="P522" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP525?> id="P525" name="P525" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 52  -->      
     
         <td colspan="3" align="center">  <!--diente 51-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align="center"></td>
               <td align="center"><label>51</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>11</label></td>
               <td align="center"></td>
             </tr>        
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP511?> id="P511" name="P511" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP514?> id="P514" name="P514" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
               <td align="center"><input id="P513" name="P513" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP512?> id="P512" name="P512" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP515?> id="P515" name="P515" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 51  -->      
     
         <td colspan="3" align="center">  <!--diente 61-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align="center"></td>
               <td align="center"><label>61</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>21</label></td>
               <td align="center"></td>
             </tr>      
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP611?> id="P611" name="P611" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP612?> id="P612" name="P612" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
               <td align="center"><input id="P613" name="P613" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP614?>  id="P614" name="P614" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP615?> id="P615" name="P615" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 61  --> 
              
         <td colspan="3" align="center">  <!--diente 62-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align="center"></td>
               <td align="center"><label>62</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>22</label></td>
               <td align="center"></td>
             </tr>       
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP621?> id="P621" name="P621" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP622?> id="P622" name="P622" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
               <td align="center"><input id="P623" name="P623" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP624?> id="P624" name="P624" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP625?> id="P625" name="P625" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 62  -->      
     
         <td colspan="3" align="center">  <!--diente 63-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align="center"></td>
               <td align="center"><label>63</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>23</label></td>
               <td align="center"></td>
             </tr>       
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP631?> id="P631" name="P631" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP632?> id="P632" name="P632" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
               <td align="center"><input id="P633" name="P633" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP634?> id="P634" name="P634" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP635?> id="P635" name="P635" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 63  --> 

         <td colspan="3" align="center">  <!--diente 64-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align="center"></td>
               <td align="center"><label>64</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>24</label></td>
               <td align="center"></td>
             </tr>       
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP641?> id="P641" name="P641" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP642?> id="P642" name="P642" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
               <td align="center"><input id="P646" name="P646" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP644?> id="P644" name="P644" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP645?> id="P645" name="P645" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 64  --> 
         
         <td colspan="3" align="center">  <!--diente 65-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align="center"></td>
               <td align="center"><label>65</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>25</label></td>
               <td align="center"></td>
             </tr>       
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP651?> id="P651" name="P651" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP652?> id="P652" name="P652" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
               <td align="center"><input id="P656" name="P656" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP654?> id="P654" name="P654" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP655?> id="P655" name="P655" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 65  -->       

         <td colspan="3" align="center">  <!--diente 26-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align="center"></td>
               <td align="center"><label>.</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>26</label></td>
               <td align="center"></td>
             </tr>       
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP261?> id="P261" name="P261" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP262?> id="P262" name="P262" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
               <td align="center"><input id="P266" name="P266" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP264?> id="P264" name="P264" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP265?> id="P265" name="P265" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 26  -->    

         <td colspan="3" align="center">  <!--diente 27-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align="center"></td>
               <td align="center"><label>.</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>27</label></td>
               <td align="center"></td>
             </tr>       
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP271?> id="P271" name="P271" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP272?> id="P272" name="P272" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
               <td align="center"><input id="P276" name="P276" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP274?> id="P274" name="P274" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP275?> id="P275" name="P275" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 27  -->    

         <td colspan="3" align="center">  <!--diente 28-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td align="center"></td>
               <td align="center"><label>.</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>28</label></td>
               <td align="center"></td>
             </tr>       
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP281?> id="P281" name="P281" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP282?> id="P282" name="P282" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
               <td align="center"><input id="P286" name="P286" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP284?> id="P284" name="P284" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP285?> id="P285" name="P285" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Palatino-->
             </tr> 
           </table>
         <td>  <!--FIN diente 28  -->    


   
       </tr> <!--FILA 2 -->
       <tr>
         <td colspan="60"><HR width=100% align="center"></td>
       </tr>
     </table>
  
     <!--  ============================= FILA 3 PARA EL REGISRO DE PLACA=================================== -->

     <table align="center">            
       <tr class="negrita">  <!--FILA 3-->

         <td colspan="3" align="center">  <!--diente 48-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP487?> id="P487" name="P487" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP484?> id="P484" name="P484" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
               <td align="center"><input id="P486" name="P486" type="checkbox" value="0" onclick="return false;" /></td> <!--Oclusal-->
               <td align="center"><input <?=$chkP482?> id="P482" name="P482" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP481?> id="P481" name="P481" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"></td>
               <td align="center"><label>48</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>.</label></td>
               <td align="center"></td>
             </tr>   
           </table>
         <td>  <!--FIN diente 48  --> 

         <td colspan="3" align="center">  <!--diente 47-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP477?> id="P477" name="P477" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP474?> id="P474" name="P474" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
               <td align="center"><input id="P476" name="P476" type="checkbox" value="0" onclick="return false;" /></td> <!--Oclusal-->
               <td align="center"><input <?=$chkP472?> id="P472" name="P472" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP471?> id="P471" name="P471" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"></td>
               <td align="center"><label>47</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>.</label></td>
               <td align="center"></td>
             </tr>   
           </table>
         <td>  <!--FIN diente 47  -->   

       
         <td colspan="3" align="center">  <!--diente 46-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP467?> id="P467" name="P467" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP464?> id="P464" name="P464" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
               <td align="center"><input id="P466" name="P466" type="checkbox" value="0" onclick="return false;" /></td> <!--Oclusal-->
               <td align="center"><input <?=$chkP462?> id="P462" name="P462" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP461?> id="P461" name="P461" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"></td>
               <td align="center"><label>46</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>.</label></td>
               <td align="center"></td>
             </tr>   
           </table>
         <td>  <!--FIN diente 46  -->   
                
         <td colspan="3" align="center">  <!--diente 85-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP857?> id="P857" name="P857" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP854?> id="P854" name="P854" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
               <td align="center"><input id="P856" name="P856" type="checkbox" value="0" onclick="return false;" /></td> <!--Oclusal-->
               <td align="center"><input <?=$chkP852?> id="P852" name="P852" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP851?> id="P851" name="P851" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"></td>
               <td align="center"><label>45</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>85</label></td>
               <td align="center"></td>
             </tr>   
           </table>
         <td>  <!--FIN diente 85  -->   
         
         <td colspan="3" align="center">  <!--diente 84-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP847?> id="P847" name="P847" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP844?> id="P844" name="P844" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
               <td align="center"><input id="P846" name="P846" type="checkbox" value="0" onclick="return false;" /></td> <!--Oclusal-->
               <td align="center"><input <?=$chkP842?> id="P842" name="P842" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP841?> id="P841" name="P841" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"></td>
               <td align="center"><label>44</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>84</label></td>
               <td align="center"></td>
             </tr>  
           </table>
         <td>  <!--FIN diente 84  -->          

         <td colspan="3" align="center">  <!--diente 83-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP837?> id="P837" name="P837" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP834?> id="P834" name="P834" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
               <td align="center"><input id="P833" name="P833" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP832?> id="P832" name="P832" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP831?> id="P831" name="P831" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"></td>
               <td align="center"><label>43</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>83</label></td>
               <td align="center"></td>
             </tr>  
           </table>
         <td>  <!--FIN diente 83  --> 

         <td colspan="3" align="center">  <!--diente 82-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP827?> id="P827" name="P827" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP824?> id="P824" name="P824" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
               <td align="center"><input id="P823" name="P823" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP822?> id="P822" name="P822" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP821?> id="P821" name="P821" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"></td>
               <td align="center"><label>42</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>82</label></td>
               <td align="center"></td>
             </tr>  
           </table>
         <td>  <!--FIN diente 82  --> 

         <td colspan="3" align="center">  <!--diente 81-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP817?> id="P817" name="P817" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP814?> id="P814" name="P814" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
               <td align="center"><input id="P813" name="P813" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP812?> id="P812" name="P812" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP811?> id="P811" name="P811" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"></td>
               <td align="center"><label>41</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>81</label></td>
               <td align="center"></td>
             </tr>  
           </table>
         <td>  <!--FIN diente 81  -->          

         <td colspan="3" align="center">  <!--diente 71-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP717?> id="P717" name="P717" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP712?> id="P712" name="P712" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
               <td align="center"><input id="P713" name="P713" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP714?> id="P714" name="P714" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP711?> id="P711" name="P711" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"></td>
               <td align="center"><label>31</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>71</label></td>
               <td align="center"></td>
             </tr>  
           </table>
         <td>  <!--FIN diente 71  --> 

         <td colspan="3" align="center">  <!--diente 72-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP727?> id="P727" name="P727" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP722?> id="P722" name="P722" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
               <td align="center"><input id="P723" name="P723" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP724?> id="P724" name="P724" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP721?> id="P721" name="P721" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"></td>
               <td align="center"><label>32</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>72</label></td>
               <td align="center"></td>
             </tr>  
           </table>
         <td>  <!--FIN diente 72  --> 

         <td colspan="3" align="center">  <!--diente 73-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP737?> id="P737" name="P737" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP732?> id="P732" name="P732" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
               <td align="center"><input id="P733" name="P733" type="checkbox" value="0" onclick="return false;" /></td> <!--Incisal-->
               <td align="center"><input <?=$chkP734?> id="P734" name="P734" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP734?> id="P731" name="P731" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"></td>
               <td align="center"><label>33</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>73</label></td>
               <td align="center"></td>
             </tr>  
           </table>
         <td>  <!--FIN diente 73  --> 

         <td colspan="3" align="center">  <!--diente 74-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP747?> id="P747" name="P747" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP742?> id="P742" name="P742" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
               <td align="center"><input id="P746" name="P746" type="checkbox" value="0" onclick="return false;" /></td> <!--Oclusal-->
               <td align="center"><input <?=$chkP744?> id="P744" name="P744" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP741?> id="P741" name="P741" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"></td>
               <td align="center"><label>34</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>74</label></td>
               <td align="center"></td>
             </tr>  
           </table>
         <td>  <!--FIN diente 74  --> 

         <td colspan="3" align="center">  <!--diente 75-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP757?> id="P757" name="P757" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP752?> id="P752" name="P752" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
               <td align="center"><input id="P756" name="P756" type="checkbox" value="0" onclick="return false;" /></td> <!--Oclusal-->
               <td align="center"><input <?=$chkP754?> id="P754" name="P754" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP751?> id="P751" name="P751" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"></td>
               <td align="center"><label>35</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>75</label></td>
               <td align="center"></td>
             </tr>  
           </table>
         <td>  <!--FIN diente 75  --> 

         <td colspan="3" align="center">  <!--diente 36-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP367?> id="P367" name="P367" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP362?> id="P362" name="P362" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
               <td align="center"><input id="P366" name="P366" type="checkbox" value="0" onclick="return false;" /></td> <!--Oclusal-->
               <td align="center"><input <?=$chkP364?> id="P364" name="P364" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP361?> id="P361" name="P361" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"></td>
               <td align="center"><label>36</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>.</label></td>
               <td align="center"></td>
             </tr>  
           </table>
         <td>  <!--FIN diente 36  --> 

         <td colspan="3" align="center">  <!--diente 37-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP377?> id="P377" name="P377" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP372?> id="P372" name="P372" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
               <td align="center"><input id="P376" name="P376" type="checkbox" value="0" onclick="return false;" /></td> <!--Oclusal-->
               <td align="center"><input <?=$chkP374?> id="P374" name="P374" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP371?> id="P371" name="P371" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"></td>
               <td align="center"><label>37</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>.</label></td>
               <td align="center"></td>
             </tr>  
           </table>
         <td>  <!--FIN diente 37  --> 

         <td colspan="3" align="center">  <!--diente 38-->
           <table align='center' border="0" cellpadding="0" width="10">
             <tr>
               <td></td> 
               <td align="center"><input <?=$chkP387?> id="P387" name="P387" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Lingual-->
             </tr> 
             <tr>
               <td align="center"><input <?=$chkP382?> id="P382" name="P382" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Mesial-->
               <td align="center"><input id="P386" name="P386" type="checkbox" value="0" onclick="return false;" /></td> <!--Oclusal-->
               <td align="center"><input <?=$chkP384?> id="P384" name="P384" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Distal-->
             </tr>
             <tr>
               <td></td>
               <td align="center"><input <?=$chkP381?> id="P381" name="P381" type="checkbox" value="1" onclick="Suma(this,this.value)" /></td> <!--Vestibular-->
             </tr> 
             <tr>
               <td align="center"></td>
               <td align="center"><label>38</label></td>
               <td align="center"></td>
             </tr>  
             <tr>
               <td align="center"></td>
               <td align="center"><label>.</label></td>
               <td align="center"></td>
             </tr>  
           </table>
         <td>  <!--FIN diente 38  --> 
       </tr> <!--FILA 3 -->
       <tr>
         <td><br></td>
       </tr>
      </table> 
      <table width="960" border="0" align="center" cellpadding="0">
        <tr>
         <td>
           <table>  
             <tr>
               <td class="camposTabla" width="200" align="left">
                 No. de superficies con Placa
               </td>
             </tr>
             <tr>  
               <td width="100">
                 <input type="number" id="numSupPlaca" name="numSupPlaca" value=<?=$s_numSupPlaca?> readOnly="readonly"/>
               </td>  
             </tr>
             <tr>  
               <td class="camposTabla" width="200" align="left">
                 Indice de Placa
               </td>
             </tr>
             <tr>  
               <td  width="100">
                 <input readOnly="readonly" type="number" id="indicePlaca" name="indicePlaca"  value=<?=$s_indicePlaca?> > %
               </td>
             </tr> 
           </table>
         </td>
         <td>       
            <table>
              <tr class="camposTabla">
                <td align="left"><input <?=$chkRegPlaNoApl?> id="regPlaNoApl" name="regPlaNoApl" type="checkbox" value="S" /> Registro de placa no aplica (por favor explicar en las observaciones)</td>
              </tr> 
              <tr class="camposTabla">
                  <td align="center">Observaciones y/o Indicaciones </td>
              </tr> 
              <tr class="camposTabla"> 
                  <td colspan="2"><textarea rows="3" cols="90" wrap="soft" name="obsRegPlaNoApl" id="obsRegPlaNoApl"><?=$s_obsRegPlaNoApl?></textarea></td>
              </tr>
            </table>
         </td> 
        </tr>
        <tr>
          <td colspan="3" align="center">
            <input type="submit" name="submit" value="Grabar Registro de Placa"><br>   
          </td>
        </tr> 
      </table>

     <!--//////////////////////////////////////////////////////////////////////////////////////
         ///////////////////INICIO EXAMEN PULPAR //////////////////////////////////////
         //////////////////////////////////////////////////////////////////////////////////////--> 
 
      <table width="960" border="0" align="center" cellpadding="0">
               <tr></td><br></td></tr>
                <tr class="titulosTabla" align="center">
                  <td colspan="3" >EXAMEN PULPAR</td>
                </tr>
                <tr class="subtutulosTabla" align="center">
                  <td width="30%">Criterio</td>
                  <td width="5%">SI</td>
                  <td width="70%">Observaciones</td>
                </tr>
                <tr class="camposTabla">
                  <td>Cuello Sensible</td>
                  <td align="center"><input <?=$chkCuelloSencible?> id="cuelloSencible" name="cuelloSencible" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsCuelloSencible" id="obsCuelloSencible"><?=$s_obsCuelloSencible?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Abscesos</td>
                  <td align="center"><input <?=$chkAbscesos?> id="abscesos" name="abscesos" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsAbscesos" id="obsAbscesos"><?=$s_obsAbscesos?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Exposicion Pulpar</td>
                  <td align="center"><input <?=$chkExposicionPulpar?> id="exposicionPulpar" name="exposicionPulpar" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsExposicionPulpar" id="obsExposicionPulpar"><?=$s_obsExposicionPulpar?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Cambio de Color</td>
                  <td align="center"><input <?=$chkCambioColor?> id="cambioColor" name="cambioColor" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsCambioColor" id="obsCambioColor"><?=$s_obsCambioColor?></textarea></td>
                </tr>
                <tr>
                  <td colspan="3" align="center">
                     <input type="submit" name="submit" value="Grabar Examen Pulpar"><br>   
                  </td>
                </tr> 
    </table>  
      
    <!--//////////////////////////////////////////////////////////////////////////////////////
         ///////////////////INICIO TEJIDOS DENTARIOS Y OCLUSION    ///////////////////////////
         //////////////////////////////////////////////////////////////////////////////////////--> 

    <table width="960" border="0" align="center" cellpadding="0">
                <tr></td><br></td></tr>
                <tr class="titulosTabla" align="center">
                  <td colspan="3" >TEJIDOS DENTARIOS Y OCLUSION</td>
                </tr>
                <tr class="subtutulosTabla" align="center">
                  <td width="30%">Criterio</td>
                  <td width="5%">SI</td>
                  <td width="70%">Observaciones</td>
                </tr>
                <tr class="camposTabla">
                  <td>Supernumerarios</td>
                  <td align="center"><input <?=$chkSupernumerarios?> id="supernumerarios" name="supernumerarios" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsSupernumerarios" id="obsSupernumerarios"><?=$s_obsSupernumerarios?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Decoloracion</td>
                  <td align="center"><input <?=$chkDecoloracion?> id="decoloracion" name="decoloracion" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsDecoloracion" id="obsDecoloracion"><?=$s_obsDecoloracion?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Descalsificacion</td>
                  <td align="center"><input <?=$chkDescalsificacion?> id="descalsificacion" name="descalsificacion" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsDescalsificacion" id="obsDescalsificacion"><?=$s_obsDescalsificacion?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Facetas de Desgaste</td>
                  <td align="center"><input <?=$chkFacetaDesgaste?> id="facetaDesgaste" name="facetaDesgaste" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsFacetaDesgaste" id="obsFacetaDesgaste"><?=$s_obsFacetaDesgaste?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Abrasi&oacute;n y/o erosi&oacute;n</td>
                  <td align="center"><input <?=$chkAbrasion?> id="abrasion" name="abrasion" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsAbrasion" id="obsAbrasion"><?=$s_obsAbrasion?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Fluorosis</td>
                  <td align="center"><input <?=$chkFluorosis?> id="fluorosis" name="fluorosis" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsFluorosis" id="obsFluorosis"><?=$s_obsFluorosis?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Tipo Oclusion </td>
                  <td align="center"><input <?=$chkTipOclusion?> id="tipOclusion" name="tipOclusion" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsTipOclusion" id="obsTipOclusion"><?=$s_obsTipOclusion?></textarea></td>
                </tr>
                <tr>
                  <td colspan="3" align="center">
                     <input type="submit" name="submit" value="Grabar Tejidos Dentarios"><br>   
                  </td>
                </tr> 
     </table>    

      <!--//////////////////////////////////////////////////////////////////////////////////////
         ///////////////////    INICIO ALTERACIONES PERIODONTALES    ///////////////////////////
         //////////////////////////////////////////////////////////////////////////////////////--> 

       <table width="960" border="0" align="center" cellpadding="0">
                <tr></td><br></td></tr>
                <tr class="titulosTabla" align="center">
                  <td colspan="3" >ALTERACIONES PERIODONTALES</td>
                </tr>
                <tr class="subtutulosTabla" align="center">
                  <td width="30%">Criterio</td>
                  <td width="5%">SI</td>
                  <td width="70%">Observaciones</td>
                </tr>
                <tr class="camposTabla">
                  <td>Sangrado </td>
                  <td align="center"><input <?=$chkSangrado?> id="sangrado" name="sangrado" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsSangrado" id="obsSangrado"><?=$s_obsSangrado?></textarea></td>
                </tr>
                 <tr class="camposTabla">
                  <td>Exudado </td>
                  <td align="center"><input <?=$chkExudado?> id="exudado" name="exudado" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsExudado" id="obsExudado"><?=$s_obsExudado?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Supuracion</td>
                  <td align="center"><input <?=$chkSupuracion?> id="supuracion" name="supuracion" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsSupuracion" id="obsSupuracion"><?=$s_obsSupuracion?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Calculos</td>
                  <td align="center"><input <?=$chkCalculos?> id="calculos" name="calculos" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsCalculos" id="obsCalculos"><?=$s_obsCalculos?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Inflamacion </td>
                  <td align="center"><input <?=$chkInflamacion?> id="inflamacion" name="inflamacion" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsInflamacion" id="obsInflamacion"><?=$s_obsInflamacion?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Retracciones </td>
                  <td align="center"><input <?=$chkRetracciones?> id="retracciones" name="retracciones" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsRetracciones" id="obsRetracciones"><?=$s_obsRetracciones?></textarea></td>
                </tr>
                <tr class="camposTabla">
                  <td>Presencia Bolsas </td>
                  <td align="center"><input <?=$chkPresenciaBolsas?> id="presenciaBolsas" name="presenciaBolsas" type="checkbox" value="S" /></td>
                  <td><textarea rows="2" cols="80" wrap="soft" name="obsPresenciaBolsas" id="obsPresenciaBolsas"><?=$s_obsPresenciaBolsas?></textarea></td>
                </tr>

                <tr>
                  <td colspan="3" align="center">
                     <input type="submit" name="submit" value="Grabar Alteraciones Periodontales"><br>   
                  </td>
                </tr>                
     </table> 

     

     <!--VARIABLES PARA RECARGAR-->
     <div style=display:none;>

     <input style="visibility:hidden" name="yaGrabo" id="yaGrabo" value="<?=$s_yaGrabo?>"/>
       <input style="visibility:hidden" name="nroCta" id="nroCta" value="<?=$e_nvoNroCon?>"/>
       
      <input style="visibility:hidden" name="s_tipoHistoria" id="s_tipoHistoria" value="<?=$s_tipoHistoria?>"/>
      <!--<input style="visibility:hidden" name="nroCta" id="nroCta" value="<?=$nConsulta?>"/>-->
      <input style="visibility:hidden" name="tipoId" id="tipoId" value="<?=$e_tipoId?>"/>
      <input style="visibility:hidden" name="idPaciente" id="idPaciente" value="<?=$e_idPaciente?>"/>
      <input style="visibility:hidden" name="nom" id="nom" value="<?=$nombre?>"/>

      <input style="visibility:hidden" name="s_nitEmpresa" id="s_nitEmpresa"value="<?=$s_nitEmpresa?>"/>
      <input style="visibility:hidden" name="s_codSede" id="s_codSede"value="<?=$s_codSede?>"/>
      <input style="visibility:hidden" name="s_idUsuario" id="s_idUsuario"value="<?=$s_idUsuario?>"/>
      <input style="visibility:hidden" name="s_usuario" id="s_usuario"value="<?=$s_usuario?>"/>
      <input style="visibility:hidden" name="s_empresa" id="s_empresa"value="<?=$s_empresa?>"/>
      <input style="visibility:hidden" name="s_cargo" id="s_cargo" value="<?=$s_cargo?>"/> 
      
      <input style="visibility:hidden" name="nDiente" id="nDiente" value="<?=$nDiente?>"/> 
      <input style="visibility:hidden" name="caraDiente" id="caraDiente" value="<?=$caraDiente?>"/> 
      
      <input style="visibility:hidden" name="s_codEntidad" id="s_codEntidad" value="<?=$s_codEntidad?>"/>
      <input style="visibility:hidden" name="s_tipoCon" id="s_tipoCon" value="<?=$s_tipoCon?>"/>
      <input style="visibility:hidden" name="pc"        id="pc"        value="<?=$pc?>"/>
      <input style="visibility:hidden" name="trat"      id="trat"      value="<?=$e_tratamiento?>"/>
      <input style="visibility:hidden" name="viD"       id="viD"       value="<?=$viene?>"/>
   </div>
 </form>     
</table>

 <table align="center" border="0" width="960">
   <tr><td><hr width="100%"></td></tr>
 </table>

 <table align="center" border="0" width="960">
       <tr>
         <td align="right"> 
           <a href=sioBarraOdo0.php><img src="imagenes/btnVol.jpg"</a>
         </td>
      
        <?php
         if ($activeBoton == "S")
         {
            //envio a ordenamientos
            //$lu  ="$e_nvoNroCon/TRATAMIENTO";
            $lu  ="$pc/TRATAMIENTO";  
            $leHnP = base64_encode($lu);
          ?>
           
           <td align="left"> 
            <a href=sioSelCie10.php?lin=<?=$leHnP?>><img src="imagenes/btnCont.jpg"></a>
           </td>
           
           <?php
           }        
           ?>                        
        </tr>
        
        <tr>
           <td align="center" class="negrita" colspan="2">Para ingresar los ordenamientos y terminar la consulta toque Seguir</td> 
        </tr> 
  </table> 

 <table align="center" border="0" width="960">
   <tr><td><hr width="100%"></td></tr>
 </table>


   <script type="text/javascript">
      var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1");
    </script>

    <script type="text/javascript">
     function cambiarTr(){
        document.getElementById('realizado').checked=false;
     }
    </script>

    <script type="text/javascript">
     function abrirHijo() {
       
       var valor1 = document.getElementById("tipoId").value;  
       var valor2 = document.getElementById("idPaciente").value;
       
       alert(valor2);
       alert(valor1);
       //window.open("simeLstDg.php?v1="+valor1+"&v2="+valor2+" location=no,menubar=no,titlebar=no,resizable=no,toolbar=no, menubar=no,width=500,height=500");

        open("sioDetalleTrat.php?v1="+valor1+"&v2="+valor2+"",'','location=no,menubar=no,titlebar=no,resizable=no,toolbar=no, menubar=no, top=300,left=300,width=1200,height=300') ;
     }
    </script> 
   
  </body>
</html>    