<?php
class grid_fiche_prof_sante_semep_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_sexe_nm_fk(&$conteudo , $sexe_nm_fk) 
   {   
      static $save_conteudo = "" ; 
      static $save_conteudo1 = "" ; 
      $tst_cache = $sexe_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($sexe_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_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_statut_maladie(&$statut_maladie) 
   {
      $conteudo = "" ; 
      if ($statut_maladie == "S")
      { 
          $conteudo = "Cas suspect";
      } 
      if ($statut_maladie == "C")
      { 
          $conteudo = "Cas confirmé";
      } 
      if ($statut_maladie == "I")
      { 
          $conteudo = "Cas infirmé";
      } 
      if (!empty($conteudo)) 
      { 
          $statut_maladie = $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_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_stat1_statut_maladie(&$statut_maladie) 
   {
      $conteudo = "" ; 
      if ($statut_maladie == "S")
      { 
          $conteudo = "Cas suspect";
      } 
      if ($statut_maladie == "C")
      { 
          $conteudo = "Cas confirmé";
      } 
      if ($statut_maladie == "I")
      { 
          $conteudo = "Cas infirmé";
      } 
      if (!empty($conteudo)) 
      { 
          $statut_maladie = $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,     code_fiche,     date_declaration,     wilaya,     commune,     \"structure\",     nom_rapporteur,     tel_rapporteur,     email_rapporteur,     maladie_suspectee_nm_fk,     nom_malade,     prenom_malade,     date_naissance_malade,     age_malade,     sexe_nm_fk,     profession_malade,     adresse_malade,     wilaya_malade,     commune_malade,     lieu_travail,     tel_malade,     email_malade,     lieux_frequentes,     date_apparition_symptomes,     autres_symptomes,     hospitalisation,     date_hospitalisation,     evacuation,     date_evacuation,     structure_evacuation,     antecedent_medicaux,     commentaires,     longitude,     latitude,     envoie,     envoie_ack,     valide,     descr_invalidite,     user_fk,     validator_fk,     mobile,     evolution_nm_fk,     symptomes,     device_id,     maladie_suspectee_by_ia,     date_validation,     user_labo_fk,     date_confirmation_labo,     maladie_confirmee_labo,     statut_maladie,     date_sortie,     date_deces,     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 (structure = '" . $_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_semep_stat']['where_res_lookup']))
       {
           $nm_comando .= " " .  $_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_semep_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_semep_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,     code_fiche,     date_declaration,     wilaya,     commune,     \"structure\",     nom_rapporteur,     tel_rapporteur,     email_rapporteur,     maladie_suspectee_nm_fk,     nom_malade,     prenom_malade,     date_naissance_malade,     age_malade,     sexe_nm_fk,     profession_malade,     adresse_malade,     wilaya_malade,     commune_malade,     lieu_travail,     tel_malade,     email_malade,     lieux_frequentes,     date_apparition_symptomes,     autres_symptomes,     hospitalisation,     date_hospitalisation,     evacuation,     date_evacuation,     structure_evacuation,     antecedent_medicaux,     commentaires,     longitude,     latitude,     envoie,     envoie_ack,     valide,     descr_invalidite,     user_fk,     validator_fk,     mobile,     evolution_nm_fk,     symptomes,     device_id,     maladie_suspectee_by_ia,     date_validation,     user_labo_fk,     date_confirmation_labo,     maladie_confirmee_labo,     statut_maladie,     date_sortie,     date_deces,     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 (structure = '" . $_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_semep_stat']['where_res_lookup']))
       {
           $nm_comando .= " " .  $_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_semep_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_semep_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,     code_fiche,     date_declaration,     wilaya,     commune,     \"structure\",     nom_rapporteur,     tel_rapporteur,     email_rapporteur,     maladie_suspectee_nm_fk,     nom_malade,     prenom_malade,     date_naissance_malade,     age_malade,     sexe_nm_fk,     profession_malade,     adresse_malade,     wilaya_malade,     commune_malade,     lieu_travail,     tel_malade,     email_malade,     lieux_frequentes,     date_apparition_symptomes,     autres_symptomes,     hospitalisation,     date_hospitalisation,     evacuation,     date_evacuation,     structure_evacuation,     antecedent_medicaux,     commentaires,     longitude,     latitude,     envoie,     envoie_ack,     valide,     descr_invalidite,     user_fk,     validator_fk,     mobile,     evolution_nm_fk,     symptomes,     device_id,     maladie_suspectee_by_ia,     date_validation,     user_labo_fk,     date_confirmation_labo,     maladie_confirmee_labo,     statut_maladie,     date_sortie,     date_deces,     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 (structure = '" . $_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_semep_stat']['where_res_lookup']))
       {
           $nm_comando .= " " .  $_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_semep_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_semep_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_semep_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_valide_SC_1()
   {
       $result = array();
       $ind_count     = 1;
       $campos_select = "valide";
       $nm_comando = "select " . $campos_select . ", COUNT(*) from (SELECT     id_fiche_ps,     code_fiche,     date_declaration,     wilaya,     commune,     \"structure\",     nom_rapporteur,     tel_rapporteur,     email_rapporteur,     maladie_suspectee_nm_fk,     nom_malade,     prenom_malade,     date_naissance_malade,     age_malade,     sexe_nm_fk,     profession_malade,     adresse_malade,     wilaya_malade,     commune_malade,     lieu_travail,     tel_malade,     email_malade,     lieux_frequentes,     date_apparition_symptomes,     autres_symptomes,     hospitalisation,     date_hospitalisation,     evacuation,     date_evacuation,     structure_evacuation,     antecedent_medicaux,     commentaires,     longitude,     latitude,     envoie,     envoie_ack,     valide,     descr_invalidite,     user_fk,     validator_fk,     mobile,     evolution_nm_fk,     symptomes,     device_id,     maladie_suspectee_by_ia,     date_validation,     user_labo_fk,     date_confirmation_labo,     maladie_confirmee_labo,     statut_maladie,     date_sortie,     date_deces,     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 (structure = '" . $_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_semep_stat']['where_res_lookup']))
       {
           $nm_comando .= " " .  $_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_semep_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_semep_stat']['ajax_nav'])
           {
               $result['set_option'][] = array('field' => 'valide_SC_1', 'opt' => '__NM__', 'value' => $this->Ini->Nm_lang['lang_search_select_summary'], "UTF-8", $_SESSION['scriptcase']['charset']);
           }
           else
           {
               $result['set_option'][] = array('field' => 'valide_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_valide_SC_1($val_format);
               if ($_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_semep_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' => 'valide_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_valide_SC_1(&$valide_SC_1) 
   {
      $conteudo = "" ; 
      $valide_SC_1_1 = explode(";", $valide_SC_1) ;
      if (in_array("O", $valide_SC_1_1))
      { 
          $conteudo .= "Oui" . " ";
      } 
      if (in_array("N", $valide_SC_1_1))
      { 
          $conteudo .= "Non" . " ";
      } 
      if (!empty($conteudo)) 
      { 
          $valide_SC_1 = $conteudo; 
      } 
   }  
   function lookup_res_evolution_nm_fk_SC_1()
   {
       $result = array();
       $ind_count     = 1;
       $campos_select = "evolution_nm_fk";
       $nm_comando = "select " . $campos_select . ", COUNT(*) from (SELECT     id_fiche_ps,     code_fiche,     date_declaration,     wilaya,     commune,     \"structure\",     nom_rapporteur,     tel_rapporteur,     email_rapporteur,     maladie_suspectee_nm_fk,     nom_malade,     prenom_malade,     date_naissance_malade,     age_malade,     sexe_nm_fk,     profession_malade,     adresse_malade,     wilaya_malade,     commune_malade,     lieu_travail,     tel_malade,     email_malade,     lieux_frequentes,     date_apparition_symptomes,     autres_symptomes,     hospitalisation,     date_hospitalisation,     evacuation,     date_evacuation,     structure_evacuation,     antecedent_medicaux,     commentaires,     longitude,     latitude,     envoie,     envoie_ack,     valide,     descr_invalidite,     user_fk,     validator_fk,     mobile,     evolution_nm_fk,     symptomes,     device_id,     maladie_suspectee_by_ia,     date_validation,     user_labo_fk,     date_confirmation_labo,     maladie_confirmee_labo,     statut_maladie,     date_sortie,     date_deces,     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 (structure = '" . $_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_semep_stat']['where_res_lookup']))
       {
           $nm_comando .= " " .  $_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_semep_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_evolution_nm_fk_SC_1($val_format, $val_orig);
               if ($_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_semep_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' => 'evolution_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_evolution_nm_fk_SC_1(&$conteudo , $evolution_nm_fk) 
   {   
      static $save_conteudo = "" ; 
      static $save_conteudo1 = "" ; 
      $tst_cache = $evolution_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($evolution_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,     code_fiche,     date_declaration,     wilaya,     commune,     \"structure\",     nom_rapporteur,     tel_rapporteur,     email_rapporteur,     maladie_suspectee_nm_fk,     nom_malade,     prenom_malade,     date_naissance_malade,     age_malade,     sexe_nm_fk,     profession_malade,     adresse_malade,     wilaya_malade,     commune_malade,     lieu_travail,     tel_malade,     email_malade,     lieux_frequentes,     date_apparition_symptomes,     autres_symptomes,     hospitalisation,     date_hospitalisation,     evacuation,     date_evacuation,     structure_evacuation,     antecedent_medicaux,     commentaires,     longitude,     latitude,     envoie,     envoie_ack,     valide,     descr_invalidite,     user_fk,     validator_fk,     mobile,     evolution_nm_fk,     symptomes,     device_id,     maladie_suspectee_by_ia,     date_validation,     user_labo_fk,     date_confirmation_labo,     maladie_confirmee_labo,     statut_maladie,     date_sortie,     date_deces,     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 (structure = '" . $_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_semep_stat']['where_res_lookup']))
       {
           $nm_comando .= " " .  $_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_semep_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_semep_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,     code_fiche,     date_declaration,     wilaya,     commune,     \"structure\",     nom_rapporteur,     tel_rapporteur,     email_rapporteur,     maladie_suspectee_nm_fk,     nom_malade,     prenom_malade,     date_naissance_malade,     age_malade,     sexe_nm_fk,     profession_malade,     adresse_malade,     wilaya_malade,     commune_malade,     lieu_travail,     tel_malade,     email_malade,     lieux_frequentes,     date_apparition_symptomes,     autres_symptomes,     hospitalisation,     date_hospitalisation,     evacuation,     date_evacuation,     structure_evacuation,     antecedent_medicaux,     commentaires,     longitude,     latitude,     envoie,     envoie_ack,     valide,     descr_invalidite,     user_fk,     validator_fk,     mobile,     evolution_nm_fk,     symptomes,     device_id,     maladie_suspectee_by_ia,     date_validation,     user_labo_fk,     date_confirmation_labo,     maladie_confirmee_labo,     statut_maladie,     date_sortie,     date_deces,     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 (structure = '" . $_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_semep_stat']['where_res_lookup']))
       {
           $nm_comando .= " " .  $_SESSION['sc_session'][$this->Ini->sc_page]['grid_fiche_prof_sante_semep_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_semep_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; 
      } 
   }  
}
?>
