<?php
class grid_fiche_prof_sante_labo_stat_lookup
{
//  
   function lookup_sc_free_group_by_wilaya(&$conteudo , $wilaya) 
   {   
      static $save_conteudo = "" ; 
      static $save_conteudo1 = "" ; 
      $tst_cache = $wilaya; 
      if ($tst_cache === $save_conteudo && $conteudo != "&nbsp;") 
      { 
          $conteudo = $save_conteudo1 ; 
          return ; 
      } 
      $save_conteudo = $tst_cache ; 
      $nm_comando = "select concat(code_wilaya, ' - ', nom_wilaya) from \"public\".wilaya where code_wilaya = '" . substr($this->Db->qstr($wilaya), 1 , -1) . "' order by code_wilaya" ; 
      $conteudo = "" ; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($rx = $this->Db->Execute($nm_comando)) 
      { 
          if (isset($rx->fields[0]))  
          { 
              $conteudo = $rx->fields[0]; 
          } 
          $save_conteudo1 = $conteudo ; 
          $rx->Close(); 
      } 
      elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
          exit; 
      } 
      if ($conteudo === "") 
      { 
          $conteudo = "&nbsp;";
          $save_conteudo1 = $conteudo ; 
      } 
   }  
//  
   function lookup_sc_free_group_by_commune(&$conteudo , $commune) 
   {   
      static $save_conteudo = "" ; 
      static $save_conteudo1 = "" ; 
      $tst_cache = $commune; 
      if ($tst_cache === $save_conteudo && $conteudo != "&nbsp;") 
      { 
          $conteudo = $save_conteudo1 ; 
          return ; 
      } 
      $save_conteudo = $tst_cache ; 
      $nm_comando = "select concat(code_commune, ' - ' , nom_commune) from \"public\".commune where code_commune = '" . substr($this->Db->qstr($commune), 1 , -1) . "' order by code_commune" ; 
      $conteudo = "" ; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($rx = $this->Db->Execute($nm_comando)) 
      { 
          if (isset($rx->fields[0]))  
          { 
              $conteudo = $rx->fields[0]; 
          } 
          $save_conteudo1 = $conteudo ; 
          $rx->Close(); 
      } 
      elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
          exit; 
      } 
      if ($conteudo === "") 
      { 
          $conteudo = "&nbsp;";
          $save_conteudo1 = $conteudo ; 
      } 
   }  
//  
   function lookup_sc_free_group_by_maladie_confirmee_labo(&$conteudo , $maladie_confirmee_labo) 
   {   
      static $save_conteudo = "" ; 
      static $save_conteudo1 = "" ; 
      $tst_cache = $maladie_confirmee_labo; 
      if ($tst_cache === $save_conteudo && $conteudo != "&nbsp;") 
      { 
          $conteudo = $save_conteudo1 ; 
          return ; 
      } 
      $save_conteudo = $tst_cache ; 
      $nm_comando = "select nomenclature_item from \"public\".ref_nomenclature_items where nomenclature_item_code = '" . substr($this->Db->qstr($maladie_confirmee_labo), 1 , -1) . "' order by nomenclature_item" ; 
      $conteudo = "" ; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($rx = $this->Db->Execute($nm_comando)) 
      { 
          if (isset($rx->fields[0]))  
          { 
              $conteudo = $rx->fields[0]; 
          } 
          $save_conteudo1 = $conteudo ; 
          $rx->Close(); 
      } 
      elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
          exit; 
      } 
      if ($conteudo === "") 
      { 
          $conteudo = "&nbsp;";
          $save_conteudo1 = $conteudo ; 
      } 
   }  
//  
   function lookup_sc_free_group_by_type_prelevement_nm_fk(&$conteudo , $type_prelevement_nm_fk) 
   {   
      static $save_conteudo = "" ; 
      static $save_conteudo1 = "" ; 
      $tst_cache = $type_prelevement_nm_fk; 
      if ($tst_cache === $save_conteudo && $conteudo != "&nbsp;") 
      { 
          $conteudo = $save_conteudo1 ; 
          return ; 
      } 
      $save_conteudo = $tst_cache ; 
      $verif_cmp_mult = explode(";", $conteudo);
      $conteudo = "";
      foreach ($verif_cmp_mult as $cada_ocorr)
      {
          if (!empty($conteudo))
          {
              $conteudo .= "','";
          }
          $conteudo .= $cada_ocorr;
      }
      $type_prelevement_nm_fk = $conteudo;
      $nm_comando = "select nomenclature_item from \"public\".ref_nomenclature_items where nomenclature_item_code  IN ('$type_prelevement_nm_fk') order by nomenclature_item" ; 
      $conteudo = "" ; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($rx = $this->Db->Execute($nm_comando)) 
      { 
          $y = 0; 
          $nm_count = $rx->FieldCount();
          while (!$rx->EOF) 
          { 
                 if ($y != 0)
                 { 
                     $conteudo .= "<br>";
                 } 
                 $y++; 
                 for ($x = 0; $x < $nm_count; $x++)
                 { 
                        if ($x != 0)
                        { 
                            $conteudo .= "";
                        } 
                        $conteudo .= $rx->fields[$x]; 
                 }
                 $rx->MoveNext() ;
          }  
          $save_conteudo1 = $conteudo ; 
          $rx->Close(); 
      } 
      elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
          exit; 
      } 
      if ($conteudo === "") 
      { 
          $conteudo = "&nbsp;";
          $save_conteudo1 = $conteudo ; 
      } 
   }  
//  
   function lookup_sc_free_group_by_pays_origine(&$conteudo , $pays_origine) 
   {   
      static $save_conteudo = "" ; 
      static $save_conteudo1 = "" ; 
      $tst_cache = $pays_origine; 
      if ($tst_cache === $save_conteudo && $conteudo != "&nbsp;") 
      { 
          $conteudo = $save_conteudo1 ; 
          return ; 
      } 
      $save_conteudo = $tst_cache ; 
      $nm_comando = "select nomenclature_item from \"public\".ref_nomenclature_items where nomenclature_item_code = '" . substr($this->Db->qstr($pays_origine), 1 , -1) . "' order by nomenclature_item" ; 
      $conteudo = "" ; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($rx = $this->Db->Execute($nm_comando)) 
      { 
          if (isset($rx->fields[0]))  
          { 
              $conteudo = $rx->fields[0]; 
          } 
          $save_conteudo1 = $conteudo ; 
          $rx->Close(); 
      } 
      elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
          exit; 
      } 
      if ($conteudo === "") 
      { 
          $conteudo = "&nbsp;";
          $save_conteudo1 = $conteudo ; 
      } 
   }  
//  
   function lookup_sc_free_group_by_nationalite_nm_fk(&$nationalite_nm_fk) 
   {
      $conteudo = "" ; 
      if ($nationalite_nm_fk == "A")
      { 
          $conteudo = "Algérien(ne)";
      } 
      if ($nationalite_nm_fk == "E")
      { 
          $conteudo = "Étranger(e)";
      } 
      if (!empty($conteudo)) 
      { 
          $nationalite_nm_fk = $conteudo; 
      } 
   }  
//  
   function lookup_stat1_wilaya_malade(&$conteudo , $wilaya_malade) 
   {   
      static $save_conteudo = "" ; 
      static $save_conteudo1 = "" ; 
      $tst_cache = $wilaya_malade; 
      if ($tst_cache === $save_conteudo && $conteudo != "&nbsp;") 
      { 
          $conteudo = $save_conteudo1 ; 
          return ; 
      } 
      $save_conteudo = $tst_cache ; 
      $nm_comando = "select concat(code_wilaya, ' - ', nom_wilaya) from \"public\".wilaya where code_wilaya = '" . substr($this->Db->qstr($wilaya_malade), 1 , -1) . "' order by code_wilaya" ; 
      $conteudo = "" ; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($rx = $this->Db->Execute($nm_comando)) 
      { 
          if (isset($rx->fields[0]))  
          { 
              $conteudo = $rx->fields[0]; 
          } 
          $save_conteudo1 = $conteudo ; 
          $rx->Close(); 
      } 
      elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
          exit; 
      } 
      if ($conteudo === "") 
      { 
          $conteudo = "&nbsp;";
          $save_conteudo1 = $conteudo ; 
      } 
   }  
//  
   function lookup_stat1_maladie_confirmee_labo(&$conteudo , $maladie_confirmee_labo) 
   {   
      static $save_conteudo = "" ; 
      static $save_conteudo1 = "" ; 
      $tst_cache = $maladie_confirmee_labo; 
      if ($tst_cache === $save_conteudo && $conteudo != "&nbsp;") 
      { 
          $conteudo = $save_conteudo1 ; 
          return ; 
      } 
      $save_conteudo = $tst_cache ; 
      $nm_comando = "select nomenclature_item from \"public\".ref_nomenclature_items where nomenclature_item_code = '" . substr($this->Db->qstr($maladie_confirmee_labo), 1 , -1) . "' order by nomenclature_item" ; 
      $conteudo = "" ; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($rx = $this->Db->Execute($nm_comando)) 
      { 
          if (isset($rx->fields[0]))  
          { 
              $conteudo = $rx->fields[0]; 
          } 
          $save_conteudo1 = $conteudo ; 
          $rx->Close(); 
      } 
      elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
          exit; 
      } 
      if ($conteudo === "") 
      { 
          $conteudo = "&nbsp;";
          $save_conteudo1 = $conteudo ; 
      } 
   }  
   function lookup_res_wilaya_SC_1()
   {
       $result = array();
       $ind_count     = 1;
       $campos_select = "wilaya";
       $nm_comando = "select " . $campos_select . ", COUNT(*) from (SELECT     id_fiche_ps,          date_declaration,     wilaya,     commune,     \"structure\",          maladie_suspectee_nm_fk,         date_naissance_malade,     age_malade,     sexe_nm_fk,         wilaya_malade,     commune_malade,             user_fk,     validator_fk,         evolution_nm_fk,     symptomes,        maladie_suspectee_by_ia,     date_validation,     user_labo_fk,     date_confirmation_labo,     maladie_confirmee_labo,     statut_maladie,         date_prelevements,     date_reception_prelevement,     date_resultats_labo,     type_prelevement_nm_fk,     resultats_labo,     labo_destination,     nin,     commentaires_labo,     commentaires_semep,     statut_fiche,     pays_origine,     nationalite_nm_fk FROM     \"public\".fiche_prof_sante  WHERE (labo_destination= '" . $_SESSION['usr_fac'] . "')  and  (((fiche_prof_sante.date_declaration)::date >= (('now'::text)::date - (concat(( SELECT sec_settings.set_value                    FROM sec_settings                   WHERE ((sec_settings.set_name)::text = 'stat_observation_period'::text)), ' days'))::interval))  AND (fiche_prof_sante.deleted IS DISTINCT FROM 'O'::bpchar)) ) SC ";
       if (!empty($_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['where_res_lookup']))
       {
           $nm_comando .= " " .  $_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['where_res_lookup'];
       }
       $nm_comando .= " GROUP BY " .$campos_select . "";
       $nm_comando .= " order by " . $campos_select . "";
       $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando;
       $_SESSION['scriptcase']['sc_sql_ult_conexao'] = '';
       if ($RSI = $this->Db->Execute($nm_comando))
       {
           while (!$RSI->EOF) 
           {
               $val_orig   = $RSI->fields[0];
               $val_format = $val_orig;
               $this->lookup_wilaya_SC_1($val_format, $val_orig);
               if ($_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['opcao'] == "ajax_res_fill_combo")
               {
                   $val_orig   = sc_convert_encoding($val_orig, "UTF-8", $_SESSION['scriptcase']['charset']);
                   $val_format = sc_convert_encoding($val_format, "UTF-8", $_SESSION['scriptcase']['charset']);
               }
               $result['set_option'][] = array('field' => 'wilaya_SC_1', 'opt' => $val_orig, 'value' => $val_format);
               $RSI->MoveNext() ;
           }
           $RSI->Close(); 
       }
       elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
       { 
           $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
           exit; 
       } 
       return $result;
   }
//  
   function lookup_wilaya_SC_1(&$conteudo , $wilaya) 
   {   
      static $save_conteudo = "" ; 
      static $save_conteudo1 = "" ; 
      $tst_cache = $wilaya; 
      if ($tst_cache === $save_conteudo && $conteudo != "&nbsp;") 
      { 
          $conteudo = $save_conteudo1 ; 
          return ; 
      } 
      $save_conteudo = $tst_cache ; 
      $nm_comando = "select nom_wilaya from \"public\".wilaya where code_wilaya = '" . substr($this->Db->qstr($wilaya), 1 , -1) . "' order by nom_wilaya" ; 
      $conteudo = "" ; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($rx = $this->Db->Execute($nm_comando)) 
      { 
          if (isset($rx->fields[0]))  
          { 
              $conteudo = $rx->fields[0]; 
          } 
          $save_conteudo1 = $conteudo ; 
          $rx->Close(); 
      } 
      elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
          exit; 
      } 
      if ($conteudo === "") 
      { 
          $conteudo = "&nbsp;";
          $save_conteudo1 = $conteudo ; 
      } 
   }  
   function lookup_res_commune_SC_1()
   {
       $result = array();
       $ind_count     = 1;
       $campos_select = "commune";
       $nm_comando = "select " . $campos_select . ", COUNT(*) from (SELECT     id_fiche_ps,          date_declaration,     wilaya,     commune,     \"structure\",          maladie_suspectee_nm_fk,         date_naissance_malade,     age_malade,     sexe_nm_fk,         wilaya_malade,     commune_malade,             user_fk,     validator_fk,         evolution_nm_fk,     symptomes,        maladie_suspectee_by_ia,     date_validation,     user_labo_fk,     date_confirmation_labo,     maladie_confirmee_labo,     statut_maladie,         date_prelevements,     date_reception_prelevement,     date_resultats_labo,     type_prelevement_nm_fk,     resultats_labo,     labo_destination,     nin,     commentaires_labo,     commentaires_semep,     statut_fiche,     pays_origine,     nationalite_nm_fk FROM     \"public\".fiche_prof_sante  WHERE (labo_destination= '" . $_SESSION['usr_fac'] . "')  and  (((fiche_prof_sante.date_declaration)::date >= (('now'::text)::date - (concat(( SELECT sec_settings.set_value                    FROM sec_settings                   WHERE ((sec_settings.set_name)::text = 'stat_observation_period'::text)), ' days'))::interval))  AND (fiche_prof_sante.deleted IS DISTINCT FROM 'O'::bpchar)) ) SC ";
       if (!empty($_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['where_res_lookup']))
       {
           $nm_comando .= " " .  $_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['where_res_lookup'];
       }
       $nm_comando .= " GROUP BY " .$campos_select . "";
       $nm_comando .= " order by " . $campos_select . "";
       $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando;
       $_SESSION['scriptcase']['sc_sql_ult_conexao'] = '';
       if ($RSI = $this->Db->Execute($nm_comando))
       {
           while (!$RSI->EOF) 
           {
               $val_orig   = $RSI->fields[0];
               $val_format = $val_orig;
               $this->lookup_commune_SC_1($val_format, $val_orig);
               if ($_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['opcao'] == "ajax_res_fill_combo")
               {
                   $val_orig   = sc_convert_encoding($val_orig, "UTF-8", $_SESSION['scriptcase']['charset']);
                   $val_format = sc_convert_encoding($val_format, "UTF-8", $_SESSION['scriptcase']['charset']);
               }
               $result['set_option'][] = array('field' => 'commune_SC_1', 'opt' => $val_orig, 'value' => $val_format);
               $RSI->MoveNext() ;
           }
           $RSI->Close(); 
       }
       elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
       { 
           $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
           exit; 
       } 
       return $result;
   }
//  
   function lookup_commune_SC_1(&$conteudo , $commune) 
   {   
      static $save_conteudo = "" ; 
      static $save_conteudo1 = "" ; 
      $tst_cache = $commune; 
      if ($tst_cache === $save_conteudo && $conteudo != "&nbsp;") 
      { 
          $conteudo = $save_conteudo1 ; 
          return ; 
      } 
      $save_conteudo = $tst_cache ; 
      $nm_comando = "select nom_commune from \"public\".commune where code_commune = '" . substr($this->Db->qstr($commune), 1 , -1) . "' order by nom_commune" ; 
      $conteudo = "" ; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($rx = $this->Db->Execute($nm_comando)) 
      { 
          if (isset($rx->fields[0]))  
          { 
              $conteudo = $rx->fields[0]; 
          } 
          $save_conteudo1 = $conteudo ; 
          $rx->Close(); 
      } 
      elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
          exit; 
      } 
      if ($conteudo === "") 
      { 
          $conteudo = "&nbsp;";
          $save_conteudo1 = $conteudo ; 
      } 
   }  
   function lookup_res_maladie_suspectee_nm_fk_SC_1()
   {
       $result = array();
       $ind_count     = 1;
       $campos_select = "maladie_suspectee_nm_fk";
       $nm_comando = "select " . $campos_select . ", COUNT(*) from (SELECT     id_fiche_ps,          date_declaration,     wilaya,     commune,     \"structure\",          maladie_suspectee_nm_fk,         date_naissance_malade,     age_malade,     sexe_nm_fk,         wilaya_malade,     commune_malade,             user_fk,     validator_fk,         evolution_nm_fk,     symptomes,        maladie_suspectee_by_ia,     date_validation,     user_labo_fk,     date_confirmation_labo,     maladie_confirmee_labo,     statut_maladie,         date_prelevements,     date_reception_prelevement,     date_resultats_labo,     type_prelevement_nm_fk,     resultats_labo,     labo_destination,     nin,     commentaires_labo,     commentaires_semep,     statut_fiche,     pays_origine,     nationalite_nm_fk FROM     \"public\".fiche_prof_sante  WHERE (labo_destination= '" . $_SESSION['usr_fac'] . "')  and  (((fiche_prof_sante.date_declaration)::date >= (('now'::text)::date - (concat(( SELECT sec_settings.set_value                    FROM sec_settings                   WHERE ((sec_settings.set_name)::text = 'stat_observation_period'::text)), ' days'))::interval))  AND (fiche_prof_sante.deleted IS DISTINCT FROM 'O'::bpchar)) ) SC ";
       if (!empty($_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['where_res_lookup']))
       {
           $nm_comando .= " " .  $_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['where_res_lookup'];
       }
       $nm_comando .= " GROUP BY " .$campos_select . "";
       $nm_comando .= " order by " . $campos_select . "";
       $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando;
       $_SESSION['scriptcase']['sc_sql_ult_conexao'] = '';
       if ($RSI = $this->Db->Execute($nm_comando))
       {
           if ($_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['ajax_nav'])
           {
               $result['set_option'][] = array('field' => 'maladie_suspectee_nm_fk_SC_1', 'opt' => '__NM__', 'value' => $this->Ini->Nm_lang['lang_search_select_summary'], "UTF-8", $_SESSION['scriptcase']['charset']);
           }
           else
           {
               $result['set_option'][] = array('field' => 'maladie_suspectee_nm_fk_SC_1', 'opt' => '__NM__', 'value' => sc_convert_encoding($this->Ini->Nm_lang['lang_search_select_summary'], "UTF-8", $_SESSION['scriptcase']['charset']));
           }
           while (!$RSI->EOF) 
           {
               $val_orig   = $RSI->fields[0];
               $val_format = $val_orig;
               $this->lookup_maladie_suspectee_nm_fk_SC_1($val_format, $val_orig);
               if ($_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['opcao'] == "ajax_res_fill_combo")
               {
                   $val_orig   = sc_convert_encoding($val_orig, "UTF-8", $_SESSION['scriptcase']['charset']);
                   $val_format = sc_convert_encoding($val_format, "UTF-8", $_SESSION['scriptcase']['charset']);
               }
               $result['set_option'][] = array('field' => 'maladie_suspectee_nm_fk_SC_1', 'opt' => $val_orig, 'value' => $val_format);
               $RSI->MoveNext() ;
           }
           $RSI->Close(); 
       }
       elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
       { 
           $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
           exit; 
       } 
       return $result;
   }
//  
   function lookup_maladie_suspectee_nm_fk_SC_1(&$conteudo , $maladie_suspectee_nm_fk) 
   {   
      static $save_conteudo = "" ; 
      static $save_conteudo1 = "" ; 
      $tst_cache = $maladie_suspectee_nm_fk; 
      if ($tst_cache === $save_conteudo && $conteudo != "&nbsp;") 
      { 
          $conteudo = $save_conteudo1 ; 
          return ; 
      } 
      $save_conteudo = $tst_cache ; 
      $nm_comando = "select nomenclature_item from \"public\".ref_nomenclature_items where nomenclature_item_code = '" . substr($this->Db->qstr($maladie_suspectee_nm_fk), 1 , -1) . "' order by nomenclature_item" ; 
      $conteudo = "" ; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($rx = $this->Db->Execute($nm_comando)) 
      { 
          if (isset($rx->fields[0]))  
          { 
              $conteudo = $rx->fields[0]; 
          } 
          $save_conteudo1 = $conteudo ; 
          $rx->Close(); 
      } 
      elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
          exit; 
      } 
      if ($conteudo === "") 
      { 
          $conteudo = "&nbsp;";
          $save_conteudo1 = $conteudo ; 
      } 
   }  
   function lookup_res_maladie_confirmee_labo_SC_1()
   {
       $result = array();
       $ind_count     = 1;
       $campos_select = "maladie_confirmee_labo";
       $nm_comando = "select " . $campos_select . ", COUNT(*) from (SELECT     id_fiche_ps,          date_declaration,     wilaya,     commune,     \"structure\",          maladie_suspectee_nm_fk,         date_naissance_malade,     age_malade,     sexe_nm_fk,         wilaya_malade,     commune_malade,             user_fk,     validator_fk,         evolution_nm_fk,     symptomes,        maladie_suspectee_by_ia,     date_validation,     user_labo_fk,     date_confirmation_labo,     maladie_confirmee_labo,     statut_maladie,         date_prelevements,     date_reception_prelevement,     date_resultats_labo,     type_prelevement_nm_fk,     resultats_labo,     labo_destination,     nin,     commentaires_labo,     commentaires_semep,     statut_fiche,     pays_origine,     nationalite_nm_fk FROM     \"public\".fiche_prof_sante  WHERE (labo_destination= '" . $_SESSION['usr_fac'] . "')  and  (((fiche_prof_sante.date_declaration)::date >= (('now'::text)::date - (concat(( SELECT sec_settings.set_value                    FROM sec_settings                   WHERE ((sec_settings.set_name)::text = 'stat_observation_period'::text)), ' days'))::interval))  AND (fiche_prof_sante.deleted IS DISTINCT FROM 'O'::bpchar)) ) SC ";
       if (!empty($_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['where_res_lookup']))
       {
           $nm_comando .= " " .  $_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['where_res_lookup'];
       }
       $nm_comando .= " GROUP BY " .$campos_select . "";
       $nm_comando .= " order by " . $campos_select . "";
       $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando;
       $_SESSION['scriptcase']['sc_sql_ult_conexao'] = '';
       if ($RSI = $this->Db->Execute($nm_comando))
       {
           while (!$RSI->EOF) 
           {
               $val_orig   = $RSI->fields[0];
               $val_format = $val_orig;
               $this->lookup_maladie_confirmee_labo_SC_1($val_format, $val_orig);
               if ($_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['opcao'] == "ajax_res_fill_combo")
               {
                   $val_orig   = sc_convert_encoding($val_orig, "UTF-8", $_SESSION['scriptcase']['charset']);
                   $val_format = sc_convert_encoding($val_format, "UTF-8", $_SESSION['scriptcase']['charset']);
               }
               $result['set_option'][] = array('field' => 'maladie_confirmee_labo_SC_1', 'opt' => $val_orig, 'value' => $val_format);
               $RSI->MoveNext() ;
           }
           $RSI->Close(); 
       }
       elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
       { 
           $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
           exit; 
       } 
       return $result;
   }
//  
   function lookup_maladie_confirmee_labo_SC_1(&$conteudo , $maladie_confirmee_labo) 
   {   
      static $save_conteudo = "" ; 
      static $save_conteudo1 = "" ; 
      $tst_cache = $maladie_confirmee_labo; 
      if ($tst_cache === $save_conteudo && $conteudo != "&nbsp;") 
      { 
          $conteudo = $save_conteudo1 ; 
          return ; 
      } 
      $save_conteudo = $tst_cache ; 
      $nm_comando = "select nomenclature_item from \"public\".ref_nomenclature_items where nomenclature_item_code = '" . substr($this->Db->qstr($maladie_confirmee_labo), 1 , -1) . "' order by nomenclature_item" ; 
      $conteudo = "" ; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($rx = $this->Db->Execute($nm_comando)) 
      { 
          if (isset($rx->fields[0]))  
          { 
              $conteudo = $rx->fields[0]; 
          } 
          $save_conteudo1 = $conteudo ; 
          $rx->Close(); 
      } 
      elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
          exit; 
      } 
      if ($conteudo === "") 
      { 
          $conteudo = "&nbsp;";
          $save_conteudo1 = $conteudo ; 
      } 
   }  
   function lookup_res_statut_maladie_SC_1()
   {
       $result = array();
       $ind_count     = 1;
       $campos_select = "statut_maladie";
       $nm_comando = "select " . $campos_select . ", COUNT(*) from (SELECT     id_fiche_ps,          date_declaration,     wilaya,     commune,     \"structure\",          maladie_suspectee_nm_fk,         date_naissance_malade,     age_malade,     sexe_nm_fk,         wilaya_malade,     commune_malade,             user_fk,     validator_fk,         evolution_nm_fk,     symptomes,        maladie_suspectee_by_ia,     date_validation,     user_labo_fk,     date_confirmation_labo,     maladie_confirmee_labo,     statut_maladie,         date_prelevements,     date_reception_prelevement,     date_resultats_labo,     type_prelevement_nm_fk,     resultats_labo,     labo_destination,     nin,     commentaires_labo,     commentaires_semep,     statut_fiche,     pays_origine,     nationalite_nm_fk FROM     \"public\".fiche_prof_sante  WHERE (labo_destination= '" . $_SESSION['usr_fac'] . "')  and  (((fiche_prof_sante.date_declaration)::date >= (('now'::text)::date - (concat(( SELECT sec_settings.set_value                    FROM sec_settings                   WHERE ((sec_settings.set_name)::text = 'stat_observation_period'::text)), ' days'))::interval))  AND (fiche_prof_sante.deleted IS DISTINCT FROM 'O'::bpchar)) ) SC ";
       if (!empty($_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['where_res_lookup']))
       {
           $nm_comando .= " " .  $_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['where_res_lookup'];
       }
       $nm_comando .= " GROUP BY " .$campos_select . "";
       $nm_comando .= " order by " . $campos_select . "";
       $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando;
       $_SESSION['scriptcase']['sc_sql_ult_conexao'] = '';
       if ($RSI = $this->Db->Execute($nm_comando))
       {
           while (!$RSI->EOF) 
           {
               $val_orig   = $RSI->fields[0];
               $val_format = $val_orig;
               $this->lookup_statut_maladie_SC_1($val_format);
               if ($_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['opcao'] == "ajax_res_fill_combo")
               {
                   $val_orig   = sc_convert_encoding($val_orig, "UTF-8", $_SESSION['scriptcase']['charset']);
                   $val_format = sc_convert_encoding($val_format, "UTF-8", $_SESSION['scriptcase']['charset']);
               }
               $result['set_option'][] = array('field' => 'statut_maladie_SC_1', 'opt' => $val_orig, 'value' => $val_format);
               $RSI->MoveNext() ;
           }
           $RSI->Close(); 
       }
       elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
       { 
           $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
           exit; 
       } 
       return $result;
   }
//  
   function lookup_statut_maladie_SC_1(&$statut_maladie_SC_1) 
   {
      $conteudo = "" ; 
      $statut_maladie_SC_1_1 = explode(";", $statut_maladie_SC_1) ;
      if (in_array("S", $statut_maladie_SC_1_1))
      { 
          $conteudo .= "Cas suspect" . " ";
      } 
      if (in_array("C", $statut_maladie_SC_1_1))
      { 
          $conteudo .= "Cas confirmé" . " ";
      } 
      if (in_array("I", $statut_maladie_SC_1_1))
      { 
          $conteudo .= "Cas infirmé" . " ";
      } 
      if (!empty($conteudo)) 
      { 
          $statut_maladie_SC_1 = $conteudo; 
      } 
   }  
   function lookup_res_type_prelevement_nm_fk_SC_1()
   {
       $result = array();
       $ind_count     = 1;
       $campos_select = "type_prelevement_nm_fk";
       $nm_comando = "select " . $campos_select . ", COUNT(*) from (SELECT     id_fiche_ps,          date_declaration,     wilaya,     commune,     \"structure\",          maladie_suspectee_nm_fk,         date_naissance_malade,     age_malade,     sexe_nm_fk,         wilaya_malade,     commune_malade,             user_fk,     validator_fk,         evolution_nm_fk,     symptomes,        maladie_suspectee_by_ia,     date_validation,     user_labo_fk,     date_confirmation_labo,     maladie_confirmee_labo,     statut_maladie,         date_prelevements,     date_reception_prelevement,     date_resultats_labo,     type_prelevement_nm_fk,     resultats_labo,     labo_destination,     nin,     commentaires_labo,     commentaires_semep,     statut_fiche,     pays_origine,     nationalite_nm_fk FROM     \"public\".fiche_prof_sante  WHERE (labo_destination= '" . $_SESSION['usr_fac'] . "')  and  (((fiche_prof_sante.date_declaration)::date >= (('now'::text)::date - (concat(( SELECT sec_settings.set_value                    FROM sec_settings                   WHERE ((sec_settings.set_name)::text = 'stat_observation_period'::text)), ' days'))::interval))  AND (fiche_prof_sante.deleted IS DISTINCT FROM 'O'::bpchar)) ) SC ";
       if (!empty($_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['where_res_lookup']))
       {
           $nm_comando .= " " .  $_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['where_res_lookup'];
       }
       $nm_comando .= " GROUP BY " .$campos_select . "";
       $nm_comando .= " order by " . $campos_select . "";
       $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando;
       $_SESSION['scriptcase']['sc_sql_ult_conexao'] = '';
       if ($RSI = $this->Db->Execute($nm_comando))
       {
           while (!$RSI->EOF) 
           {
               $val_orig   = $RSI->fields[0];
               $val_format = $val_orig;
               $this->lookup_type_prelevement_nm_fk_SC_1($val_format, $val_orig);
               if ($_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_labo_stat']['opcao'] == "ajax_res_fill_combo")
               {
                   $val_orig   = sc_convert_encoding($val_orig, "UTF-8", $_SESSION['scriptcase']['charset']);
                   $val_format = sc_convert_encoding($val_format, "UTF-8", $_SESSION['scriptcase']['charset']);
               }
               $result['set_option'][] = array('field' => 'type_prelevement_nm_fk_SC_1', 'opt' => $val_orig, 'value' => $val_format);
               $RSI->MoveNext() ;
           }
           $RSI->Close(); 
       }
       elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
       { 
           $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
           exit; 
       } 
       return $result;
   }
//  
   function lookup_type_prelevement_nm_fk_SC_1(&$conteudo , $type_prelevement_nm_fk) 
   {   
      static $save_conteudo = "" ; 
      static $save_conteudo1 = "" ; 
      $tst_cache = $type_prelevement_nm_fk; 
      if ($tst_cache === $save_conteudo && $conteudo != "&nbsp;") 
      { 
          $conteudo = $save_conteudo1 ; 
          return ; 
      } 
      $save_conteudo = $tst_cache ; 
      $verif_cmp_mult = explode(";", $conteudo);
      $conteudo = "";
      foreach ($verif_cmp_mult as $cada_ocorr)
      {
          if (!empty($conteudo))
          {
              $conteudo .= "','";
          }
          $conteudo .= $cada_ocorr;
      }
      $type_prelevement_nm_fk_SC_1 = $conteudo;
      $nm_comando = "select nomenclature_item from \"public\".ref_nomenclature_items where nomenclature_item_code  = '$type_prelevement_nm_fk' order by nomenclature_item" ; 
      $conteudo = "" ; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($rx = $this->Db->Execute($nm_comando)) 
      { 
          $y = 0; 
          $nm_count = $rx->FieldCount();
          while (!$rx->EOF) 
          { 
                 if ($y != 0)
                 { 
                     $conteudo .= "<br>";
                 } 
                 $y++; 
                 for ($x = 0; $x < $nm_count; $x++)
                 { 
                        if ($x != 0)
                        { 
                            $conteudo .= "";
                        } 
                        $conteudo .= $rx->fields[$x]; 
                 }
                 $rx->MoveNext() ;
          }  
          $save_conteudo1 = $conteudo ; 
          $rx->Close(); 
      } 
      elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
          exit; 
      } 
      if ($conteudo === "") 
      { 
          $conteudo = "&nbsp;";
          $save_conteudo1 = $conteudo ; 
      } 
   }  
}
?>
