<?php
require_once("../../base/php/startSession.php");
require_once("../../base/php/classDatabase.php");
require_once("../../base/php/Functions.php");
require_once("../../base/php/Environnement.php");
require_once("../../base/php/WebAppLog.php");

global $database;
global $getOption;
global $getParam;


$tableName = getPOST("tableName");
$getOption = getPOST("getOption");
$getParam = getPOST("getParam");
$refPrefix = getPOST("refPrefix");


//WebAppLog("","",print_r($_POST,true));


$database = new Database("iCTI");

//echo $softCode;

$httpString = "";
$httpString = $httpString . "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
$httpString = $httpString . "\n<HTTP_SERVICE>";

switch($tableName) {
	case "t_fiche5_enquete" :
		$httpString = $httpString . getRecords_fiche5_enquete();
		break;
	case "p_fiche5_rss" :
		$httpString = $httpString . getRecords_fiche5_rss();
		break;
}

$httpString = $httpString . "\n</HTTP_SERVICE>";
 

//$httpString = compress64($httpString);

echo "<CTICONTENT>$httpString</CTICONTENT>";


// fiche5_enquete
function getRecords_fiche5_enquete() {

global $database;

	$httpString = "";

	$sqlcmd = "SELECT 
					t_fiche5_enquete.oid ,
					t_fiche5_enquete.code,
					t_fiche5_enquete.texte,
					t_fiche5_enquete.annee,
					t_fiche5_enquete.data,
					nb_ogc,
					nb_rss_ok,
					nb_rss_ko
				FROM pmsi.t_fiche5_enquete 
				WHERE t_fiche5_enquete.oid > 0";
	
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
	
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecordInto();
										

			if ($record != FALSE) {
				$ok = TRUE;

				$oid = $record[0];
				$code = toHTML(trim($record[1]));
				$texte = toHTML(trim($record[2]));
				$annee = toHTML(trim($record[3]));
				$data = toHTML(trim($record[4]));
				$nb_ogc = floatval($record[5]);
				$nb_rss_ok = floatval($record[6]);
				$nb_rss_ko = floatval($record[7]);
				
				$httpString = $httpString . 
					"\r\n<RECORD 
						oid=\"$oid\" 
						code=\"$code\" 
						texte=\"$texte\" 
						annee=\"$annee\" 
						data=\"$data\" 
						nb_ogc=\"+$nb_ogc\" 
						nb_rss_ok=\"+$nb_rss_ok\" 
						nb_rss_ko=\"+$nb_rss_ko\" 
					/>";
				

			}
		}

	
	}
	
	return $httpString . getCombo_annee();
	
	

}


// fiche5_rss
function getRecords_fiche5_rss() {

global $database;

	$httpString = "";

	$sqlcmd = "SELECT 
				p_fiche5_rss.oid,
				t_fiche5_enquete.texte || '. OGC '::text || p_fiche5_rss.no_ogc::text || ' RSS '::text || p_fiche5_rss.no_rss::text AS texte,
				p_fiche5_rss.enquete_id,
				p_fiche5_rss.champ_id,
				COALESCE(t_fiche5_champ.code,'') AS champ_code,
				COALESCE(t_fiche5_champ.texte,'') AS champ_texte,
				p_fiche5_rss.no_ogc,
				p_fiche5_rss.no_rss,
				p_fiche5_rss.rss_id,
				p_fiche5_rss.matricule_assure,
				p_fiche5_rss.cle_matricule_assure,
				p_fiche5_rss.no_sejour_administratif,
				p_fiche5_rss.no_patient,
				p_fiche5_rss.nom,
				p_fiche5_rss.nom_naissance,
				p_fiche5_rss.prenom,
				p_fiche5_rss.nom || ' ' || p_fiche5_rss.prenom || CASE WHEN p_fiche5_rss.nom_naissance != '' THEN ' (née ' || p_fiche5_rss.nom_naissance || ')' ELSE '' END AS nom_complet,
				to_char(p_fiche5_rss.date_naissance,'DD/MM/YYYY') AS date_naissance,
				p_fiche5_rss.no_facture,
				p_fiche5_rss.regime_code,
				p_fiche5_rss.caisse_gestionnaire_code,
				p_fiche5_rss.caisse_gestionnaire_texte,
				p_fiche5_rss.regime_code || caisse_gestionnaire_code || ' ' || p_fiche5_rss.caisse_gestionnaire_texte AS regime_caisse_texte,
				to_char(p_fiche5_rss.date_entree,'DD/MM/YYYY') AS date_entree,
				to_char(p_fiche5_rss.date_sortie,'DD/MM/YYYY') AS date_sortie,
				p_fiche5_rss.duree_sejour,
				to_char(p_fiche5_rss.taux_remboursement,'FM990') AS taux_remboursement,
				to_char(p_fiche5_rss.taux_remboursement_vidhosp,'FM990') AS taux_remboursement_vidhosp,
				to_char(p_fiche5_rss.montant_majoration_parcours_soins,'FM990D00') AS montant_majoration_parcours_soins,
				to_char(p_fiche5_rss.montant_ticket_moderateur,'FM9999990D00') AS montant_ticket_moderateur,
				to_char(p_fiche5_rss.montant_forfait_journalier,'FM9999990') AS montant_forfait_journalier,
				to_char(p_fiche5_rss.nombre_forfait_journalier,'FM9999990') AS nombre_forfait_journalier,
				
				p_fiche5_rss.status,
				CASE p_fiche5_rss.status
				WHEN 'P9' THEN 'Préparé'
				WHEN 'C8' THEN 'Contesté'
				WHEN 'C9' THEN 'Accepté'
				ELSE '' END AS status_texte,
				
				p_fiche5_rss.facture_dp_code,
				p_fiche5_rss.facture_dp_code || ' ' || COALESCE(facture_t_dp.texte,'') AS facture_dp_texte,
				p_fiche5_rss.facture_ghs_code,
				p_fiche5_rss.facture_ghm_code,
				p_fiche5_rss.facture_ghm_code || ' ' || COALESCE(facture_t_ghm.texte,'') AS facture_ghm_texte,
				p_fiche5_rss.facture_ghs_montant_total,
				p_fiche5_rss.facture_exb_montant_total,
				p_fiche5_rss.facture_exh_montant_total,
				
				p_fiche5_rss.initial_dp_code,
				p_fiche5_rss.initial_dp_code || ' ' || COALESCE(initial_t_dp.texte,'') AS initial_dp_texte,
				p_fiche5_rss.initial_ghs_code,
				p_fiche5_rss.initial_ghm_code,
				p_fiche5_rss.initial_ghm_code || ' ' || COALESCE(initial_t_ghm.texte,'') AS initial_ghm_texte,
				p_fiche5_rss.initial_rum_um_code[01] AS initial_rum_um_code_01,
				p_fiche5_rss.initial_rum_um_code[02] AS initial_rum_um_code_02,
				p_fiche5_rss.initial_rum_um_code[03] AS initial_rum_um_code_03,
				p_fiche5_rss.initial_rum_um_code[04] AS initial_rum_um_code_04,
				p_fiche5_rss.initial_rum_um_code[05] AS initial_rum_um_code_05,
				p_fiche5_rss.initial_rum_um_code[06] AS initial_rum_um_code_06,
				p_fiche5_rss.initial_rum_um_code[07] AS initial_rum_um_code_07,
				p_fiche5_rss.initial_rum_um_code[08] AS initial_rum_um_code_08,
				p_fiche5_rss.initial_rum_um_code[09] AS initial_rum_um_code_09,
				p_fiche5_rss.initial_rum_um_code[10] AS initial_rum_um_code_10,
				p_fiche5_rss.initial_rum_dp_code[01] AS initial_rum_dp_code_01,
				p_fiche5_rss.initial_rum_dp_code[02] AS initial_rum_dp_code_02,
				p_fiche5_rss.initial_rum_dp_code[03] AS initial_rum_dp_code_03,
				p_fiche5_rss.initial_rum_dp_code[04] AS initial_rum_dp_code_04,
				p_fiche5_rss.initial_rum_dp_code[05] AS initial_rum_dp_code_05,
				p_fiche5_rss.initial_rum_dp_code[06] AS initial_rum_dp_code_06,
				p_fiche5_rss.initial_rum_dp_code[07] AS initial_rum_dp_code_07,
				p_fiche5_rss.initial_rum_dp_code[08] AS initial_rum_dp_code_08,
				p_fiche5_rss.initial_rum_dp_code[09] AS initial_rum_dp_code_09,
				p_fiche5_rss.initial_rum_dp_code[10] AS initial_rum_dp_code_10,
				p_fiche5_rss.initial_rum_dr_code[01] AS initial_rum_dr_code_01,
				p_fiche5_rss.initial_rum_dr_code[02] AS initial_rum_dr_code_02,
				p_fiche5_rss.initial_rum_dr_code[03] AS initial_rum_dr_code_03,
				p_fiche5_rss.initial_rum_dr_code[04] AS initial_rum_dr_code_04,
				p_fiche5_rss.initial_rum_dr_code[05] AS initial_rum_dr_code_05,
				p_fiche5_rss.initial_rum_dr_code[06] AS initial_rum_dr_code_06,
				p_fiche5_rss.initial_rum_dr_code[07] AS initial_rum_dr_code_07,
				p_fiche5_rss.initial_rum_dr_code[08] AS initial_rum_dr_code_08,
				p_fiche5_rss.initial_rum_dr_code[09] AS initial_rum_dr_code_09,
				p_fiche5_rss.initial_rum_dr_code[10] AS initial_rum_dr_code_10,
				p_fiche5_rss.initial_rum_da_code[01] AS initial_rum_da_code_01,
				p_fiche5_rss.initial_rum_da_code[02] AS initial_rum_da_code_02,
				p_fiche5_rss.initial_rum_da_code[03] AS initial_rum_da_code_03,
				p_fiche5_rss.initial_rum_da_code[04] AS initial_rum_da_code_04,
				p_fiche5_rss.initial_rum_da_code[05] AS initial_rum_da_code_05,
				p_fiche5_rss.initial_rum_da_code[06] AS initial_rum_da_code_06,
				p_fiche5_rss.initial_rum_da_code[07] AS initial_rum_da_code_07,
				p_fiche5_rss.initial_rum_da_code[08] AS initial_rum_da_code_08,
				p_fiche5_rss.initial_rum_da_code[09] AS initial_rum_da_code_09,
				p_fiche5_rss.initial_rum_da_code[10] AS initial_rum_da_code_10,
				p_fiche5_rss.initial_rum_ccam_code[01] AS initial_rum_ccam_code_01,
				p_fiche5_rss.initial_rum_ccam_code[02] AS initial_rum_ccam_code_02,
				p_fiche5_rss.initial_rum_ccam_code[03] AS initial_rum_ccam_code_03,
				p_fiche5_rss.initial_rum_ccam_code[04] AS initial_rum_ccam_code_04,
				p_fiche5_rss.initial_rum_ccam_code[05] AS initial_rum_ccam_code_05,
				p_fiche5_rss.initial_rum_ccam_code[06] AS initial_rum_ccam_code_06,
				p_fiche5_rss.initial_rum_ccam_code[07] AS initial_rum_ccam_code_07,
				p_fiche5_rss.initial_rum_ccam_code[08] AS initial_rum_ccam_code_08,
				p_fiche5_rss.initial_rum_ccam_code[09] AS initial_rum_ccam_code_09,
				p_fiche5_rss.initial_rum_ccam_code[10] AS initial_rum_ccam_code_10,
				p_fiche5_rss.initial_ghs_montant_total,
				p_fiche5_rss.initial_exb_montant_total,
				p_fiche5_rss.initial_exh_montant_total,
				
				p_fiche5_rss.scenar1_rule,
				p_fiche5_rss.scenar1_comment,
				p_fiche5_rss.scenar1_dp_code,
				p_fiche5_rss.scenar1_dp_code || ' ' || COALESCE(scenar1_t_dp.texte,'') AS scenar1_dp_texte,
				p_fiche5_rss.scenar1_ghs_code,
				p_fiche5_rss.scenar1_ghm_code,
				p_fiche5_rss.scenar1_ghm_code || ' ' || COALESCE(scenar1_t_ghm.texte,'') AS scenar1_ghm_texte,
				p_fiche5_rss.scenar1_rum_um_code[01] AS scenar1_rum_um_code_01,
				p_fiche5_rss.scenar1_rum_um_code[02] AS scenar1_rum_um_code_02,
				p_fiche5_rss.scenar1_rum_um_code[03] AS scenar1_rum_um_code_03,
				p_fiche5_rss.scenar1_rum_um_code[04] AS scenar1_rum_um_code_04,
				p_fiche5_rss.scenar1_rum_um_code[05] AS scenar1_rum_um_code_05,
				p_fiche5_rss.scenar1_rum_um_code[06] AS scenar1_rum_um_code_06,
				p_fiche5_rss.scenar1_rum_um_code[07] AS scenar1_rum_um_code_07,
				p_fiche5_rss.scenar1_rum_um_code[08] AS scenar1_rum_um_code_08,
				p_fiche5_rss.scenar1_rum_um_code[09] AS scenar1_rum_um_code_09,
				p_fiche5_rss.scenar1_rum_um_code[10] AS scenar1_rum_um_code_10,
				p_fiche5_rss.scenar1_rum_dp_code[01] AS scenar1_rum_dp_code_01,
				p_fiche5_rss.scenar1_rum_dp_code[02] AS scenar1_rum_dp_code_02,
				p_fiche5_rss.scenar1_rum_dp_code[03] AS scenar1_rum_dp_code_03,
				p_fiche5_rss.scenar1_rum_dp_code[04] AS scenar1_rum_dp_code_04,
				p_fiche5_rss.scenar1_rum_dp_code[05] AS scenar1_rum_dp_code_05,
				p_fiche5_rss.scenar1_rum_dp_code[06] AS scenar1_rum_dp_code_06,
				p_fiche5_rss.scenar1_rum_dp_code[07] AS scenar1_rum_dp_code_07,
				p_fiche5_rss.scenar1_rum_dp_code[08] AS scenar1_rum_dp_code_08,
				p_fiche5_rss.scenar1_rum_dp_code[09] AS scenar1_rum_dp_code_09,
				p_fiche5_rss.scenar1_rum_dp_code[10] AS scenar1_rum_dp_code_10,
				p_fiche5_rss.scenar1_rum_dr_code[01] AS scenar1_rum_dr_code_01,
				p_fiche5_rss.scenar1_rum_dr_code[02] AS scenar1_rum_dr_code_02,
				p_fiche5_rss.scenar1_rum_dr_code[03] AS scenar1_rum_dr_code_03,
				p_fiche5_rss.scenar1_rum_dr_code[04] AS scenar1_rum_dr_code_04,
				p_fiche5_rss.scenar1_rum_dr_code[05] AS scenar1_rum_dr_code_05,
				p_fiche5_rss.scenar1_rum_dr_code[06] AS scenar1_rum_dr_code_06,
				p_fiche5_rss.scenar1_rum_dr_code[07] AS scenar1_rum_dr_code_07,
				p_fiche5_rss.scenar1_rum_dr_code[08] AS scenar1_rum_dr_code_08,
				p_fiche5_rss.scenar1_rum_dr_code[09] AS scenar1_rum_dr_code_09,
				p_fiche5_rss.scenar1_rum_dr_code[10] AS scenar1_rum_dr_code_10,
				p_fiche5_rss.scenar1_rum_da_code[01] AS scenar1_rum_da_code_01,
				p_fiche5_rss.scenar1_rum_da_code[02] AS scenar1_rum_da_code_02,
				p_fiche5_rss.scenar1_rum_da_code[03] AS scenar1_rum_da_code_03,
				p_fiche5_rss.scenar1_rum_da_code[04] AS scenar1_rum_da_code_04,
				p_fiche5_rss.scenar1_rum_da_code[05] AS scenar1_rum_da_code_05,
				p_fiche5_rss.scenar1_rum_da_code[06] AS scenar1_rum_da_code_06,
				p_fiche5_rss.scenar1_rum_da_code[07] AS scenar1_rum_da_code_07,
				p_fiche5_rss.scenar1_rum_da_code[08] AS scenar1_rum_da_code_08,
				p_fiche5_rss.scenar1_rum_da_code[09] AS scenar1_rum_da_code_09,
				p_fiche5_rss.scenar1_rum_da_code[10] AS scenar1_rum_da_code_10,
				p_fiche5_rss.scenar1_rum_ccam_code[01] AS scenar1_rum_ccam_code_01,
				p_fiche5_rss.scenar1_rum_ccam_code[02] AS scenar1_rum_ccam_code_02,
				p_fiche5_rss.scenar1_rum_ccam_code[03] AS scenar1_rum_ccam_code_03,
				p_fiche5_rss.scenar1_rum_ccam_code[04] AS scenar1_rum_ccam_code_04,
				p_fiche5_rss.scenar1_rum_ccam_code[05] AS scenar1_rum_ccam_code_05,
				p_fiche5_rss.scenar1_rum_ccam_code[06] AS scenar1_rum_ccam_code_06,
				p_fiche5_rss.scenar1_rum_ccam_code[07] AS scenar1_rum_ccam_code_07,
				p_fiche5_rss.scenar1_rum_ccam_code[08] AS scenar1_rum_ccam_code_08,
				p_fiche5_rss.scenar1_rum_ccam_code[09] AS scenar1_rum_ccam_code_09,
				p_fiche5_rss.scenar1_rum_ccam_code[10] AS scenar1_rum_ccam_code_10,
				p_fiche5_rss.scenar1_ghs_montant_total,
				p_fiche5_rss.scenar1_exb_montant_total,
				p_fiche5_rss.scenar1_exh_montant_total,
				
				p_fiche5_rss.scenar2_rule,
				p_fiche5_rss.scenar2_comment,
				p_fiche5_rss.scenar2_dp_code,
				p_fiche5_rss.scenar2_dp_code || ' ' || COALESCE(scenar2_t_dp.texte,'') AS scenar2_dp_texte,
				p_fiche5_rss.scenar2_ghs_code,
				p_fiche5_rss.scenar2_ghm_code,
				p_fiche5_rss.scenar2_ghm_code || ' ' || COALESCE(scenar2_t_ghm.texte,'') AS scenar2_ghm_texte,
				p_fiche5_rss.scenar2_rum_um_code[01] AS scenar2_rum_um_code_01,
				p_fiche5_rss.scenar2_rum_um_code[02] AS scenar2_rum_um_code_02,
				p_fiche5_rss.scenar2_rum_um_code[03] AS scenar2_rum_um_code_03,
				p_fiche5_rss.scenar2_rum_um_code[04] AS scenar2_rum_um_code_04,
				p_fiche5_rss.scenar2_rum_um_code[05] AS scenar2_rum_um_code_05,
				p_fiche5_rss.scenar2_rum_um_code[06] AS scenar2_rum_um_code_06,
				p_fiche5_rss.scenar2_rum_um_code[07] AS scenar2_rum_um_code_07,
				p_fiche5_rss.scenar2_rum_um_code[08] AS scenar2_rum_um_code_08,
				p_fiche5_rss.scenar2_rum_um_code[09] AS scenar2_rum_um_code_09,
				p_fiche5_rss.scenar2_rum_um_code[10] AS scenar2_rum_um_code_10,
				p_fiche5_rss.scenar2_rum_dp_code[01] AS scenar2_rum_dp_code_01,
				p_fiche5_rss.scenar2_rum_dp_code[02] AS scenar2_rum_dp_code_02,
				p_fiche5_rss.scenar2_rum_dp_code[03] AS scenar2_rum_dp_code_03,
				p_fiche5_rss.scenar2_rum_dp_code[04] AS scenar2_rum_dp_code_04,
				p_fiche5_rss.scenar2_rum_dp_code[05] AS scenar2_rum_dp_code_05,
				p_fiche5_rss.scenar2_rum_dp_code[06] AS scenar2_rum_dp_code_06,
				p_fiche5_rss.scenar2_rum_dp_code[07] AS scenar2_rum_dp_code_07,
				p_fiche5_rss.scenar2_rum_dp_code[08] AS scenar2_rum_dp_code_08,
				p_fiche5_rss.scenar2_rum_dp_code[09] AS scenar2_rum_dp_code_09,
				p_fiche5_rss.scenar2_rum_dp_code[10] AS scenar2_rum_dp_code_10,
				p_fiche5_rss.scenar2_rum_dr_code[01] AS scenar2_rum_dr_code_01,
				p_fiche5_rss.scenar2_rum_dr_code[02] AS scenar2_rum_dr_code_02,
				p_fiche5_rss.scenar2_rum_dr_code[03] AS scenar2_rum_dr_code_03,
				p_fiche5_rss.scenar2_rum_dr_code[04] AS scenar2_rum_dr_code_04,
				p_fiche5_rss.scenar2_rum_dr_code[05] AS scenar2_rum_dr_code_05,
				p_fiche5_rss.scenar2_rum_dr_code[06] AS scenar2_rum_dr_code_06,
				p_fiche5_rss.scenar2_rum_dr_code[07] AS scenar2_rum_dr_code_07,
				p_fiche5_rss.scenar2_rum_dr_code[08] AS scenar2_rum_dr_code_08,
				p_fiche5_rss.scenar2_rum_dr_code[09] AS scenar2_rum_dr_code_09,
				p_fiche5_rss.scenar2_rum_dr_code[10] AS scenar2_rum_dr_code_10,
				p_fiche5_rss.scenar2_rum_da_code[01] AS scenar2_rum_da_code_01,
				p_fiche5_rss.scenar2_rum_da_code[02] AS scenar2_rum_da_code_02,
				p_fiche5_rss.scenar2_rum_da_code[03] AS scenar2_rum_da_code_03,
				p_fiche5_rss.scenar2_rum_da_code[04] AS scenar2_rum_da_code_04,
				p_fiche5_rss.scenar2_rum_da_code[05] AS scenar2_rum_da_code_05,
				p_fiche5_rss.scenar2_rum_da_code[06] AS scenar2_rum_da_code_06,
				p_fiche5_rss.scenar2_rum_da_code[07] AS scenar2_rum_da_code_07,
				p_fiche5_rss.scenar2_rum_da_code[08] AS scenar2_rum_da_code_08,
				p_fiche5_rss.scenar2_rum_da_code[09] AS scenar2_rum_da_code_09,
				p_fiche5_rss.scenar2_rum_da_code[10] AS scenar2_rum_da_code_10,
				p_fiche5_rss.scenar2_rum_ccam_code[01] AS scenar2_rum_ccam_code_01,
				p_fiche5_rss.scenar2_rum_ccam_code[02] AS scenar2_rum_ccam_code_02,
				p_fiche5_rss.scenar2_rum_ccam_code[03] AS scenar2_rum_ccam_code_03,
				p_fiche5_rss.scenar2_rum_ccam_code[04] AS scenar2_rum_ccam_code_04,
				p_fiche5_rss.scenar2_rum_ccam_code[05] AS scenar2_rum_ccam_code_05,
				p_fiche5_rss.scenar2_rum_ccam_code[06] AS scenar2_rum_ccam_code_06,
				p_fiche5_rss.scenar2_rum_ccam_code[07] AS scenar2_rum_ccam_code_07,
				p_fiche5_rss.scenar2_rum_ccam_code[08] AS scenar2_rum_ccam_code_08,
				p_fiche5_rss.scenar2_rum_ccam_code[09] AS scenar2_rum_ccam_code_09,
				p_fiche5_rss.scenar2_rum_ccam_code[10] AS scenar2_rum_ccam_code_10,
				p_fiche5_rss.scenar2_ghs_montant_total,
				p_fiche5_rss.scenar2_exb_montant_total,
				p_fiche5_rss.scenar2_exh_montant_total,
				
				p_fiche5_rss.control_rule,
				p_fiche5_rss.control_comment,
				p_fiche5_rss.control_dp_code,
				p_fiche5_rss.control_dp_code || ' ' || COALESCE(control_t_dp.texte,'') AS control_dp_texte,
				p_fiche5_rss.control_ghs_code,
				p_fiche5_rss.control_ghm_code,
				p_fiche5_rss.control_ghm_code || ' ' || COALESCE(control_t_ghm.texte,'') AS control_ghm_texte,
				p_fiche5_rss.control_rum_um_code[01] AS control_rum_um_code_01,
				p_fiche5_rss.control_rum_um_code[02] AS control_rum_um_code_02,
				p_fiche5_rss.control_rum_um_code[03] AS control_rum_um_code_03,
				p_fiche5_rss.control_rum_um_code[04] AS control_rum_um_code_04,
				p_fiche5_rss.control_rum_um_code[05] AS control_rum_um_code_05,
				p_fiche5_rss.control_rum_um_code[06] AS control_rum_um_code_06,
				p_fiche5_rss.control_rum_um_code[07] AS control_rum_um_code_07,
				p_fiche5_rss.control_rum_um_code[08] AS control_rum_um_code_08,
				p_fiche5_rss.control_rum_um_code[09] AS control_rum_um_code_09,
				p_fiche5_rss.control_rum_um_code[10] AS control_rum_um_code_10,
				p_fiche5_rss.control_rum_dp_code[01] AS control_rum_dp_code_01,
				p_fiche5_rss.control_rum_dp_code[02] AS control_rum_dp_code_02,
				p_fiche5_rss.control_rum_dp_code[03] AS control_rum_dp_code_03,
				p_fiche5_rss.control_rum_dp_code[04] AS control_rum_dp_code_04,
				p_fiche5_rss.control_rum_dp_code[05] AS control_rum_dp_code_05,
				p_fiche5_rss.control_rum_dp_code[06] AS control_rum_dp_code_06,
				p_fiche5_rss.control_rum_dp_code[07] AS control_rum_dp_code_07,
				p_fiche5_rss.control_rum_dp_code[08] AS control_rum_dp_code_08,
				p_fiche5_rss.control_rum_dp_code[09] AS control_rum_dp_code_09,
				p_fiche5_rss.control_rum_dp_code[10] AS control_rum_dp_code_10,
				p_fiche5_rss.control_rum_dr_code[01] AS control_rum_dr_code_01,
				p_fiche5_rss.control_rum_dr_code[02] AS control_rum_dr_code_02,
				p_fiche5_rss.control_rum_dr_code[03] AS control_rum_dr_code_03,
				p_fiche5_rss.control_rum_dr_code[04] AS control_rum_dr_code_04,
				p_fiche5_rss.control_rum_dr_code[05] AS control_rum_dr_code_05,
				p_fiche5_rss.control_rum_dr_code[06] AS control_rum_dr_code_06,
				p_fiche5_rss.control_rum_dr_code[07] AS control_rum_dr_code_07,
				p_fiche5_rss.control_rum_dr_code[08] AS control_rum_dr_code_08,
				p_fiche5_rss.control_rum_dr_code[09] AS control_rum_dr_code_09,
				p_fiche5_rss.control_rum_dr_code[10] AS control_rum_dr_code_10,
				p_fiche5_rss.control_rum_da_code[01] AS control_rum_da_code_01,
				p_fiche5_rss.control_rum_da_code[02] AS control_rum_da_code_02,
				p_fiche5_rss.control_rum_da_code[03] AS control_rum_da_code_03,
				p_fiche5_rss.control_rum_da_code[04] AS control_rum_da_code_04,
				p_fiche5_rss.control_rum_da_code[05] AS control_rum_da_code_05,
				p_fiche5_rss.control_rum_da_code[06] AS control_rum_da_code_06,
				p_fiche5_rss.control_rum_da_code[07] AS control_rum_da_code_07,
				p_fiche5_rss.control_rum_da_code[08] AS control_rum_da_code_08,
				p_fiche5_rss.control_rum_da_code[09] AS control_rum_da_code_09,
				p_fiche5_rss.control_rum_da_code[10] AS control_rum_da_code_10,
				p_fiche5_rss.control_rum_ccam_code[01] AS control_rum_ccam_code_01,
				p_fiche5_rss.control_rum_ccam_code[02] AS control_rum_ccam_code_02,
				p_fiche5_rss.control_rum_ccam_code[03] AS control_rum_ccam_code_03,
				p_fiche5_rss.control_rum_ccam_code[04] AS control_rum_ccam_code_04,
				p_fiche5_rss.control_rum_ccam_code[05] AS control_rum_ccam_code_05,
				p_fiche5_rss.control_rum_ccam_code[06] AS control_rum_ccam_code_06,
				p_fiche5_rss.control_rum_ccam_code[07] AS control_rum_ccam_code_07,
				p_fiche5_rss.control_rum_ccam_code[08] AS control_rum_ccam_code_08,
				p_fiche5_rss.control_rum_ccam_code[09] AS control_rum_ccam_code_09,
				p_fiche5_rss.control_rum_ccam_code[10] AS control_rum_ccam_code_10,
				p_fiche5_rss.control_ghs_montant_total,
				p_fiche5_rss.control_exb_montant_total,
				p_fiche5_rss.control_exh_montant_total,
				
				p_fiche5_rss.retenu_rule,
				p_fiche5_rss.retenu_comment,
				p_fiche5_rss.retenu_dp_code,
				p_fiche5_rss.retenu_dp_code || ' ' || COALESCE(retenu_t_dp.texte,'') AS retenu_dp_texte,
				p_fiche5_rss.retenu_ghs_code,
				p_fiche5_rss.retenu_ghm_code,
				p_fiche5_rss.retenu_ghm_code || ' ' || COALESCE(retenu_t_ghm.texte,'') AS retenu_ghm_texte,
				p_fiche5_rss.retenu_rum_um_code[01] AS retenu_rum_um_code_01,
				p_fiche5_rss.retenu_rum_um_code[02] AS retenu_rum_um_code_02,
				p_fiche5_rss.retenu_rum_um_code[03] AS retenu_rum_um_code_03,
				p_fiche5_rss.retenu_rum_um_code[04] AS retenu_rum_um_code_04,
				p_fiche5_rss.retenu_rum_um_code[05] AS retenu_rum_um_code_05,
				p_fiche5_rss.retenu_rum_um_code[06] AS retenu_rum_um_code_06,
				p_fiche5_rss.retenu_rum_um_code[07] AS retenu_rum_um_code_07,
				p_fiche5_rss.retenu_rum_um_code[08] AS retenu_rum_um_code_08,
				p_fiche5_rss.retenu_rum_um_code[09] AS retenu_rum_um_code_09,
				p_fiche5_rss.retenu_rum_um_code[10] AS retenu_rum_um_code_10,
				p_fiche5_rss.retenu_rum_dp_code[01] AS retenu_rum_dp_code_01,
				p_fiche5_rss.retenu_rum_dp_code[02] AS retenu_rum_dp_code_02,
				p_fiche5_rss.retenu_rum_dp_code[03] AS retenu_rum_dp_code_03,
				p_fiche5_rss.retenu_rum_dp_code[04] AS retenu_rum_dp_code_04,
				p_fiche5_rss.retenu_rum_dp_code[05] AS retenu_rum_dp_code_05,
				p_fiche5_rss.retenu_rum_dp_code[06] AS retenu_rum_dp_code_06,
				p_fiche5_rss.retenu_rum_dp_code[07] AS retenu_rum_dp_code_07,
				p_fiche5_rss.retenu_rum_dp_code[08] AS retenu_rum_dp_code_08,
				p_fiche5_rss.retenu_rum_dp_code[09] AS retenu_rum_dp_code_09,
				p_fiche5_rss.retenu_rum_dp_code[10] AS retenu_rum_dp_code_10,
				p_fiche5_rss.retenu_rum_dr_code[01] AS retenu_rum_dr_code_01,
				p_fiche5_rss.retenu_rum_dr_code[02] AS retenu_rum_dr_code_02,
				p_fiche5_rss.retenu_rum_dr_code[03] AS retenu_rum_dr_code_03,
				p_fiche5_rss.retenu_rum_dr_code[04] AS retenu_rum_dr_code_04,
				p_fiche5_rss.retenu_rum_dr_code[05] AS retenu_rum_dr_code_05,
				p_fiche5_rss.retenu_rum_dr_code[06] AS retenu_rum_dr_code_06,
				p_fiche5_rss.retenu_rum_dr_code[07] AS retenu_rum_dr_code_07,
				p_fiche5_rss.retenu_rum_dr_code[08] AS retenu_rum_dr_code_08,
				p_fiche5_rss.retenu_rum_dr_code[09] AS retenu_rum_dr_code_09,
				p_fiche5_rss.retenu_rum_dr_code[10] AS retenu_rum_dr_code_10,
				p_fiche5_rss.retenu_rum_da_code[01] AS retenu_rum_da_code_01,
				p_fiche5_rss.retenu_rum_da_code[02] AS retenu_rum_da_code_02,
				p_fiche5_rss.retenu_rum_da_code[03] AS retenu_rum_da_code_03,
				p_fiche5_rss.retenu_rum_da_code[04] AS retenu_rum_da_code_04,
				p_fiche5_rss.retenu_rum_da_code[05] AS retenu_rum_da_code_05,
				p_fiche5_rss.retenu_rum_da_code[06] AS retenu_rum_da_code_06,
				p_fiche5_rss.retenu_rum_da_code[07] AS retenu_rum_da_code_07,
				p_fiche5_rss.retenu_rum_da_code[08] AS retenu_rum_da_code_08,
				p_fiche5_rss.retenu_rum_da_code[09] AS retenu_rum_da_code_09,
				p_fiche5_rss.retenu_rum_da_code[10] AS retenu_rum_da_code_10,
				p_fiche5_rss.retenu_rum_ccam_code[01] AS retenu_rum_ccam_code_01,
				p_fiche5_rss.retenu_rum_ccam_code[02] AS retenu_rum_ccam_code_02,
				p_fiche5_rss.retenu_rum_ccam_code[03] AS retenu_rum_ccam_code_03,
				p_fiche5_rss.retenu_rum_ccam_code[04] AS retenu_rum_ccam_code_04,
				p_fiche5_rss.retenu_rum_ccam_code[05] AS retenu_rum_ccam_code_05,
				p_fiche5_rss.retenu_rum_ccam_code[06] AS retenu_rum_ccam_code_06,
				p_fiche5_rss.retenu_rum_ccam_code[07] AS retenu_rum_ccam_code_07,
				p_fiche5_rss.retenu_rum_ccam_code[08] AS retenu_rum_ccam_code_08,
				p_fiche5_rss.retenu_rum_ccam_code[09] AS retenu_rum_ccam_code_09,
				p_fiche5_rss.retenu_rum_ccam_code[10] AS retenu_rum_ccam_code_10,
				p_fiche5_rss.retenu_ghs_montant_total,
				p_fiche5_rss.retenu_exb_montant_total,
				p_fiche5_rss.retenu_exh_montant_total
				
			FROM pmsi.p_fiche5_rss
			JOIN pmsi.t_fiche5_enquete ON enquete_id = t_fiche5_enquete.oid
			LEFT JOIN pmsi.t_fiche5_champ ON champ_id = t_fiche5_champ.oid
			LEFT JOIN pmsi.t_diagnostics facture_t_dp ON facture_dp_id = facture_t_dp.oid AND facture_t_dp.oid <> 0
			LEFT JOIN pmsi.t_diagnostics initial_t_dp ON initial_dp_id = initial_t_dp.oid AND initial_t_dp.oid <> 0
			LEFT JOIN pmsi.t_diagnostics scenar1_t_dp ON scenar1_dp_id = scenar1_t_dp.oid AND scenar1_t_dp.oid <> 0
			LEFT JOIN pmsi.t_diagnostics scenar2_t_dp ON scenar2_dp_id = scenar2_t_dp.oid AND scenar2_t_dp.oid <> 0
			LEFT JOIN pmsi.t_diagnostics control_t_dp ON control_dp_id = control_t_dp.oid AND control_t_dp.oid <> 0
			LEFT JOIN pmsi.t_diagnostics  retenu_t_dp ON  retenu_dp_id =  retenu_t_dp.oid AND  retenu_t_dp.oid <> 0
			LEFT JOIN pmsi.t_ghm facture_t_ghm ON facture_ghm_id = facture_t_ghm.oid AND facture_t_ghm.oid <> 0
			LEFT JOIN pmsi.t_ghm initial_t_ghm ON initial_ghm_id = initial_t_ghm.oid AND initial_t_ghm.oid <> 0
			LEFT JOIN pmsi.t_ghm scenar1_t_ghm ON scenar1_ghm_id = scenar1_t_ghm.oid AND scenar1_t_ghm.oid <> 0
			LEFT JOIN pmsi.t_ghm scenar2_t_ghm ON scenar2_ghm_id = scenar2_t_ghm.oid AND scenar2_t_ghm.oid <> 0
			LEFT JOIN pmsi.t_ghm control_t_ghm ON control_ghm_id = control_t_ghm.oid AND control_t_ghm.oid <> 0
			LEFT JOIN pmsi.t_ghm  retenu_t_ghm ON  retenu_ghm_id =  retenu_t_ghm.oid AND  retenu_t_ghm.oid <> 0
			ORDER BY enquete_id, no_ogc";
	
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
	
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecordAssoc();
										

			if ($record != FALSE) {
				$ok = TRUE;

				$oid 								= $record['oid'];
				$texte 								= toHTML(trim($record['texte']));
				$enquete_id 						= toHTML(trim($record['enquete_id']));
				$champ_id 							= toHTML(trim($record['champ_id']));
				$champ_code 						= toHTML(trim($record['champ_code']));
				$champ_texte 						= toHTML(trim($record['champ_texte']));
				$no_ogc								= toHTML(trim($record['no_ogc']));
				$no_rss                             = toHTML(trim($record['no_rss']));
				$rss_id                             = toHTML(trim($record['rss_id']));
				$matricule_assure                   = toHTML(trim($record['matricule_assure']));
				$cle_matricule_assure               = toHTML(trim($record['cle_matricule_assure']));
				$no_sejour_administratif            = toHTML(trim($record['no_sejour_administratif']));
				$no_patient                         = toHTML(trim($record['no_patient']));
				$nom_complet                      	= toHTML(trim($record['nom_complet']));
				$date_naissance                     = toHTML(trim($record['date_naissance']));
				$no_facture                         = toHTML(trim($record['no_facture']));
				$regime_caisse_texte          		= toHTML(trim($record['regime_caisse_texte']));
				$date_entree                        = toHTML(trim($record['date_entree']));
				$date_sortie                        = toHTML(trim($record['date_sortie']));
				$duree_sejour                       = toHTML(trim($record['duree_sejour']));
				$taux_remboursement                 = toHTML(trim($record['taux_remboursement']));
				$taux_remboursement_vidhosp         = toHTML(trim($record['taux_remboursement_vidhosp']));
				$montant_majoration_parcours_soins  = toHTML(trim($record['montant_majoration_parcours_soins']));
				$montant_ticket_moderateur          = toHTML(trim($record['montant_ticket_moderateur']));
				$montant_forfait_journalier         = toHTML(trim($record['montant_forfait_journalier']));
				$nombre_forfait_journalier         	= toHTML(trim($record['nombre_forfait_journalier']));
				
				$status         					= toHTML(trim($record['status']));
				$status_texte      					= toHTML(trim($record['status_texte']));
				
				$facture_dp_code          			= toHTML(trim($record['facture_dp_code']));
				$facture_dp_texte          			= toHTML(trim($record['facture_dp_texte']));
				$facture_ghs_code                   = toHTML(trim($record['facture_ghs_code']));
				$facture_ghm_code                   = toHTML(trim($record['facture_ghm_code']));
				$facture_ghm_texte                  = toHTML(trim($record['facture_ghm_texte']));
				$facture_ghs_montant_total 			= floatval($record['facture_ghs_montant_total']);
				$facture_exb_montant_total          = floatval($record['facture_exb_montant_total']);
				$facture_exh_montant_total          = floatval($record['facture_exh_montant_total']);
				
				$initial_dp_code          			= toHTML(trim($record['initial_dp_code']));
				$initial_dp_texte          			= toHTML(trim($record['initial_dp_texte']));
				$initial_ghs_code                   = toHTML(trim($record['initial_ghs_code']));
				$initial_ghm_code                   = toHTML(trim($record['initial_ghm_code']));
				$initial_ghm_texte                  = toHTML(trim($record['initial_ghm_texte']));
				$initial_rum_um_code_01				= toHTML(trim($record['initial_rum_um_code_01']));
				$initial_rum_um_code_02				= toHTML(trim($record['initial_rum_um_code_02']));
				$initial_rum_um_code_03				= toHTML(trim($record['initial_rum_um_code_03']));
				$initial_rum_um_code_04				= toHTML(trim($record['initial_rum_um_code_04']));
				$initial_rum_um_code_05				= toHTML(trim($record['initial_rum_um_code_05']));
				$initial_rum_um_code_06				= toHTML(trim($record['initial_rum_um_code_06']));
				$initial_rum_um_code_07				= toHTML(trim($record['initial_rum_um_code_07']));
				$initial_rum_um_code_08				= toHTML(trim($record['initial_rum_um_code_08']));
				$initial_rum_um_code_09				= toHTML(trim($record['initial_rum_um_code_09']));
				$initial_rum_um_code_10				= toHTML(trim($record['initial_rum_um_code_10']));
				$initial_rum_dp_code_01				= toHTML(trim($record['initial_rum_dp_code_01']));
				$initial_rum_dp_code_02				= toHTML(trim($record['initial_rum_dp_code_02']));
				$initial_rum_dp_code_03				= toHTML(trim($record['initial_rum_dp_code_03']));
				$initial_rum_dp_code_04				= toHTML(trim($record['initial_rum_dp_code_04']));
				$initial_rum_dp_code_05				= toHTML(trim($record['initial_rum_dp_code_05']));
				$initial_rum_dp_code_06				= toHTML(trim($record['initial_rum_dp_code_06']));
				$initial_rum_dp_code_07				= toHTML(trim($record['initial_rum_dp_code_07']));
				$initial_rum_dp_code_08				= toHTML(trim($record['initial_rum_dp_code_08']));
				$initial_rum_dp_code_09				= toHTML(trim($record['initial_rum_dp_code_09']));
				$initial_rum_dp_code_10				= toHTML(trim($record['initial_rum_dp_code_10']));
				$initial_rum_dr_code_01				= toHTML(trim($record['initial_rum_dr_code_01']));
				$initial_rum_dr_code_02				= toHTML(trim($record['initial_rum_dr_code_02']));
				$initial_rum_dr_code_03				= toHTML(trim($record['initial_rum_dr_code_03']));
				$initial_rum_dr_code_04				= toHTML(trim($record['initial_rum_dr_code_04']));
				$initial_rum_dr_code_05				= toHTML(trim($record['initial_rum_dr_code_05']));
				$initial_rum_dr_code_06				= toHTML(trim($record['initial_rum_dr_code_06']));
				$initial_rum_dr_code_07				= toHTML(trim($record['initial_rum_dr_code_07']));
				$initial_rum_dr_code_08				= toHTML(trim($record['initial_rum_dr_code_08']));
				$initial_rum_dr_code_09				= toHTML(trim($record['initial_rum_dr_code_09']));
				$initial_rum_dr_code_10				= toHTML(trim($record['initial_rum_dr_code_10']));
				$initial_rum_da_code_01				= toHTML(trim($record['initial_rum_da_code_01']));
				$initial_rum_da_code_02				= toHTML(trim($record['initial_rum_da_code_02']));
				$initial_rum_da_code_03				= toHTML(trim($record['initial_rum_da_code_03']));
				$initial_rum_da_code_04				= toHTML(trim($record['initial_rum_da_code_04']));
				$initial_rum_da_code_05				= toHTML(trim($record['initial_rum_da_code_05']));
				$initial_rum_da_code_06				= toHTML(trim($record['initial_rum_da_code_06']));
				$initial_rum_da_code_07				= toHTML(trim($record['initial_rum_da_code_07']));
				$initial_rum_da_code_08				= toHTML(trim($record['initial_rum_da_code_08']));
				$initial_rum_da_code_09				= toHTML(trim($record['initial_rum_da_code_09']));
				$initial_rum_da_code_10				= toHTML(trim($record['initial_rum_da_code_10']));
				$initial_rum_ccam_code_01			= toHTML(trim($record['initial_rum_ccam_code_01']));
				$initial_rum_ccam_code_02			= toHTML(trim($record['initial_rum_ccam_code_02']));
				$initial_rum_ccam_code_03			= toHTML(trim($record['initial_rum_ccam_code_03']));
				$initial_rum_ccam_code_04			= toHTML(trim($record['initial_rum_ccam_code_04']));
				$initial_rum_ccam_code_05			= toHTML(trim($record['initial_rum_ccam_code_05']));
				$initial_rum_ccam_code_06			= toHTML(trim($record['initial_rum_ccam_code_06']));
				$initial_rum_ccam_code_07			= toHTML(trim($record['initial_rum_ccam_code_07']));
				$initial_rum_ccam_code_08			= toHTML(trim($record['initial_rum_ccam_code_08']));
				$initial_rum_ccam_code_09			= toHTML(trim($record['initial_rum_ccam_code_09']));
				$initial_rum_ccam_code_10			= toHTML(trim($record['initial_rum_ccam_code_10']));
				$initial_ghs_montant_total			= floatval($record['initial_ghs_montant_total']);
				$initial_exb_montant_total	        = floatval($record['initial_exb_montant_total']);
				$initial_exh_montant_total	        = floatval($record['initial_exh_montant_total']);
				
				$scenar1_rule          				= toHTML(trim($record['scenar1_rule']));
				$scenar1_comment          			= toHTML(trim($record['scenar1_comment']));
				$scenar1_dp_code          			= toHTML(trim($record['scenar1_dp_code']));
				$scenar1_dp_texte          			= toHTML(trim($record['scenar1_dp_texte']));
				$scenar1_ghs_code                   = toHTML(trim($record['scenar1_ghs_code']));
				$scenar1_ghm_code                   = toHTML(trim($record['scenar1_ghm_code']));
				$scenar1_ghm_texte                  = toHTML(trim($record['scenar1_ghm_texte']));
				$scenar1_rum_um_code_01				= toHTML(trim($record['scenar1_rum_um_code_01']));
				$scenar1_rum_um_code_02				= toHTML(trim($record['scenar1_rum_um_code_02']));
				$scenar1_rum_um_code_03				= toHTML(trim($record['scenar1_rum_um_code_03']));
				$scenar1_rum_um_code_04				= toHTML(trim($record['scenar1_rum_um_code_04']));
				$scenar1_rum_um_code_05				= toHTML(trim($record['scenar1_rum_um_code_05']));
				$scenar1_rum_um_code_06				= toHTML(trim($record['scenar1_rum_um_code_06']));
				$scenar1_rum_um_code_07				= toHTML(trim($record['scenar1_rum_um_code_07']));
				$scenar1_rum_um_code_08				= toHTML(trim($record['scenar1_rum_um_code_08']));
				$scenar1_rum_um_code_09				= toHTML(trim($record['scenar1_rum_um_code_09']));
				$scenar1_rum_um_code_10				= toHTML(trim($record['scenar1_rum_um_code_10']));
				$scenar1_rum_dp_code_01				= toHTML(trim($record['scenar1_rum_dp_code_01']));
				$scenar1_rum_dp_code_02				= toHTML(trim($record['scenar1_rum_dp_code_02']));
				$scenar1_rum_dp_code_03				= toHTML(trim($record['scenar1_rum_dp_code_03']));
				$scenar1_rum_dp_code_04				= toHTML(trim($record['scenar1_rum_dp_code_04']));
				$scenar1_rum_dp_code_05				= toHTML(trim($record['scenar1_rum_dp_code_05']));
				$scenar1_rum_dp_code_06				= toHTML(trim($record['scenar1_rum_dp_code_06']));
				$scenar1_rum_dp_code_07				= toHTML(trim($record['scenar1_rum_dp_code_07']));
				$scenar1_rum_dp_code_08				= toHTML(trim($record['scenar1_rum_dp_code_08']));
				$scenar1_rum_dp_code_09				= toHTML(trim($record['scenar1_rum_dp_code_09']));
				$scenar1_rum_dp_code_10				= toHTML(trim($record['scenar1_rum_dp_code_10']));
				$scenar1_rum_dr_code_01				= toHTML(trim($record['scenar1_rum_dr_code_01']));
				$scenar1_rum_dr_code_02				= toHTML(trim($record['scenar1_rum_dr_code_02']));
				$scenar1_rum_dr_code_03				= toHTML(trim($record['scenar1_rum_dr_code_03']));
				$scenar1_rum_dr_code_04				= toHTML(trim($record['scenar1_rum_dr_code_04']));
				$scenar1_rum_dr_code_05				= toHTML(trim($record['scenar1_rum_dr_code_05']));
				$scenar1_rum_dr_code_06				= toHTML(trim($record['scenar1_rum_dr_code_06']));
				$scenar1_rum_dr_code_07				= toHTML(trim($record['scenar1_rum_dr_code_07']));
				$scenar1_rum_dr_code_08				= toHTML(trim($record['scenar1_rum_dr_code_08']));
				$scenar1_rum_dr_code_09				= toHTML(trim($record['scenar1_rum_dr_code_09']));
				$scenar1_rum_dr_code_10				= toHTML(trim($record['scenar1_rum_dr_code_10']));
				$scenar1_rum_da_code_01				= toHTML(trim($record['scenar1_rum_da_code_01']));
				$scenar1_rum_da_code_02				= toHTML(trim($record['scenar1_rum_da_code_02']));
				$scenar1_rum_da_code_03				= toHTML(trim($record['scenar1_rum_da_code_03']));
				$scenar1_rum_da_code_04				= toHTML(trim($record['scenar1_rum_da_code_04']));
				$scenar1_rum_da_code_05				= toHTML(trim($record['scenar1_rum_da_code_05']));
				$scenar1_rum_da_code_06				= toHTML(trim($record['scenar1_rum_da_code_06']));
				$scenar1_rum_da_code_07				= toHTML(trim($record['scenar1_rum_da_code_07']));
				$scenar1_rum_da_code_08				= toHTML(trim($record['scenar1_rum_da_code_08']));
				$scenar1_rum_da_code_09				= toHTML(trim($record['scenar1_rum_da_code_09']));
				$scenar1_rum_da_code_10				= toHTML(trim($record['scenar1_rum_da_code_10']));
				$scenar1_rum_ccam_code_01			= toHTML(trim($record['scenar1_rum_ccam_code_01']));
				$scenar1_rum_ccam_code_02			= toHTML(trim($record['scenar1_rum_ccam_code_02']));
				$scenar1_rum_ccam_code_03			= toHTML(trim($record['scenar1_rum_ccam_code_03']));
				$scenar1_rum_ccam_code_04			= toHTML(trim($record['scenar1_rum_ccam_code_04']));
				$scenar1_rum_ccam_code_05			= toHTML(trim($record['scenar1_rum_ccam_code_05']));
				$scenar1_rum_ccam_code_06			= toHTML(trim($record['scenar1_rum_ccam_code_06']));
				$scenar1_rum_ccam_code_07			= toHTML(trim($record['scenar1_rum_ccam_code_07']));
				$scenar1_rum_ccam_code_08			= toHTML(trim($record['scenar1_rum_ccam_code_08']));
				$scenar1_rum_ccam_code_09			= toHTML(trim($record['scenar1_rum_ccam_code_09']));
				$scenar1_rum_ccam_code_10			= toHTML(trim($record['scenar1_rum_ccam_code_10']));
				$scenar1_ghs_montant_total 			= floatval($record['scenar1_ghs_montant_total']);
				$scenar1_exb_montant_total          = floatval($record['scenar1_exb_montant_total']);
				$scenar1_exh_montant_total          = floatval($record['scenar1_exh_montant_total']);
				
				$scenar2_rule          				= toHTML(trim($record['scenar2_rule']));
				$scenar2_comment          			= toHTML(trim($record['scenar2_comment']));
				$scenar2_dp_code          			= toHTML(trim($record['scenar2_dp_code']));
				$scenar2_dp_texte          			= toHTML(trim($record['scenar2_dp_texte']));
				$scenar2_ghs_code                   = toHTML(trim($record['scenar2_ghs_code']));
				$scenar2_ghm_code                   = toHTML(trim($record['scenar2_ghm_code']));
				$scenar2_ghm_texte                  = toHTML(trim($record['scenar2_ghm_texte']));
				$scenar2_rum_um_code_01				= toHTML(trim($record['scenar2_rum_um_code_01']));
				$scenar2_rum_um_code_02				= toHTML(trim($record['scenar2_rum_um_code_02']));
				$scenar2_rum_um_code_03				= toHTML(trim($record['scenar2_rum_um_code_03']));
				$scenar2_rum_um_code_04				= toHTML(trim($record['scenar2_rum_um_code_04']));
				$scenar2_rum_um_code_05				= toHTML(trim($record['scenar2_rum_um_code_05']));
				$scenar2_rum_um_code_06				= toHTML(trim($record['scenar2_rum_um_code_06']));
				$scenar2_rum_um_code_07				= toHTML(trim($record['scenar2_rum_um_code_07']));
				$scenar2_rum_um_code_08				= toHTML(trim($record['scenar2_rum_um_code_08']));
				$scenar2_rum_um_code_09				= toHTML(trim($record['scenar2_rum_um_code_09']));
				$scenar2_rum_um_code_10				= toHTML(trim($record['scenar2_rum_um_code_10']));
				$scenar2_rum_dp_code_01				= toHTML(trim($record['scenar2_rum_dp_code_01']));
				$scenar2_rum_dp_code_02				= toHTML(trim($record['scenar2_rum_dp_code_02']));
				$scenar2_rum_dp_code_03				= toHTML(trim($record['scenar2_rum_dp_code_03']));
				$scenar2_rum_dp_code_04				= toHTML(trim($record['scenar2_rum_dp_code_04']));
				$scenar2_rum_dp_code_05				= toHTML(trim($record['scenar2_rum_dp_code_05']));
				$scenar2_rum_dp_code_06				= toHTML(trim($record['scenar2_rum_dp_code_06']));
				$scenar2_rum_dp_code_07				= toHTML(trim($record['scenar2_rum_dp_code_07']));
				$scenar2_rum_dp_code_08				= toHTML(trim($record['scenar2_rum_dp_code_08']));
				$scenar2_rum_dp_code_09				= toHTML(trim($record['scenar2_rum_dp_code_09']));
				$scenar2_rum_dp_code_10				= toHTML(trim($record['scenar2_rum_dp_code_10']));
				$scenar2_rum_dr_code_01				= toHTML(trim($record['scenar2_rum_dr_code_01']));
				$scenar2_rum_dr_code_02				= toHTML(trim($record['scenar2_rum_dr_code_02']));
				$scenar2_rum_dr_code_03				= toHTML(trim($record['scenar2_rum_dr_code_03']));
				$scenar2_rum_dr_code_04				= toHTML(trim($record['scenar2_rum_dr_code_04']));
				$scenar2_rum_dr_code_05				= toHTML(trim($record['scenar2_rum_dr_code_05']));
				$scenar2_rum_dr_code_06				= toHTML(trim($record['scenar2_rum_dr_code_06']));
				$scenar2_rum_dr_code_07				= toHTML(trim($record['scenar2_rum_dr_code_07']));
				$scenar2_rum_dr_code_08				= toHTML(trim($record['scenar2_rum_dr_code_08']));
				$scenar2_rum_dr_code_09				= toHTML(trim($record['scenar2_rum_dr_code_09']));
				$scenar2_rum_dr_code_10				= toHTML(trim($record['scenar2_rum_dr_code_10']));
				$scenar2_rum_da_code_01				= toHTML(trim($record['scenar2_rum_da_code_01']));
				$scenar2_rum_da_code_02				= toHTML(trim($record['scenar2_rum_da_code_02']));
				$scenar2_rum_da_code_03				= toHTML(trim($record['scenar2_rum_da_code_03']));
				$scenar2_rum_da_code_04				= toHTML(trim($record['scenar2_rum_da_code_04']));
				$scenar2_rum_da_code_05				= toHTML(trim($record['scenar2_rum_da_code_05']));
				$scenar2_rum_da_code_06				= toHTML(trim($record['scenar2_rum_da_code_06']));
				$scenar2_rum_da_code_07				= toHTML(trim($record['scenar2_rum_da_code_07']));
				$scenar2_rum_da_code_08				= toHTML(trim($record['scenar2_rum_da_code_08']));
				$scenar2_rum_da_code_09				= toHTML(trim($record['scenar2_rum_da_code_09']));
				$scenar2_rum_da_code_10				= toHTML(trim($record['scenar2_rum_da_code_10']));
				$scenar2_rum_ccam_code_01			= toHTML(trim($record['scenar2_rum_ccam_code_01']));
				$scenar2_rum_ccam_code_02			= toHTML(trim($record['scenar2_rum_ccam_code_02']));
				$scenar2_rum_ccam_code_03			= toHTML(trim($record['scenar2_rum_ccam_code_03']));
				$scenar2_rum_ccam_code_04			= toHTML(trim($record['scenar2_rum_ccam_code_04']));
				$scenar2_rum_ccam_code_05			= toHTML(trim($record['scenar2_rum_ccam_code_05']));
				$scenar2_rum_ccam_code_06			= toHTML(trim($record['scenar2_rum_ccam_code_06']));
				$scenar2_rum_ccam_code_07			= toHTML(trim($record['scenar2_rum_ccam_code_07']));
				$scenar2_rum_ccam_code_08			= toHTML(trim($record['scenar2_rum_ccam_code_08']));
				$scenar2_rum_ccam_code_09			= toHTML(trim($record['scenar2_rum_ccam_code_09']));
				$scenar2_rum_ccam_code_10			= toHTML(trim($record['scenar2_rum_ccam_code_10']));
				$scenar2_ghs_montant_total 			= floatval($record['scenar2_ghs_montant_total']);
				$scenar2_exb_montant_total          = floatval($record['scenar2_exb_montant_total']);
				$scenar2_exh_montant_total          = floatval($record['scenar2_exh_montant_total']);
				
				$control_rule          				= toHTML(trim($record['control_rule']));
				$control_comment          			= toHTML(trim($record['control_comment']));
				$control_dp_code          			= toHTML(trim($record['control_dp_code']));
				$control_dp_texte          			= toHTML(trim($record['control_dp_texte']));
				$control_ghs_code                   = toHTML(trim($record['control_ghs_code']));
				$control_ghm_code                   = toHTML(trim($record['control_ghm_code']));
				$control_ghm_texte                  = toHTML(trim($record['control_ghm_texte']));
				$control_rum_um_code_01				= toHTML(trim($record['control_rum_um_code_01']));
				$control_rum_um_code_02				= toHTML(trim($record['control_rum_um_code_02']));
				$control_rum_um_code_03				= toHTML(trim($record['control_rum_um_code_03']));
				$control_rum_um_code_04				= toHTML(trim($record['control_rum_um_code_04']));
				$control_rum_um_code_05				= toHTML(trim($record['control_rum_um_code_05']));
				$control_rum_um_code_06				= toHTML(trim($record['control_rum_um_code_06']));
				$control_rum_um_code_07				= toHTML(trim($record['control_rum_um_code_07']));
				$control_rum_um_code_08				= toHTML(trim($record['control_rum_um_code_08']));
				$control_rum_um_code_09				= toHTML(trim($record['control_rum_um_code_09']));
				$control_rum_um_code_10				= toHTML(trim($record['control_rum_um_code_10']));
				$control_rum_dp_code_01				= toHTML(trim($record['control_rum_dp_code_01']));
				$control_rum_dp_code_02				= toHTML(trim($record['control_rum_dp_code_02']));
				$control_rum_dp_code_03				= toHTML(trim($record['control_rum_dp_code_03']));
				$control_rum_dp_code_04				= toHTML(trim($record['control_rum_dp_code_04']));
				$control_rum_dp_code_05				= toHTML(trim($record['control_rum_dp_code_05']));
				$control_rum_dp_code_06				= toHTML(trim($record['control_rum_dp_code_06']));
				$control_rum_dp_code_07				= toHTML(trim($record['control_rum_dp_code_07']));
				$control_rum_dp_code_08				= toHTML(trim($record['control_rum_dp_code_08']));
				$control_rum_dp_code_09				= toHTML(trim($record['control_rum_dp_code_09']));
				$control_rum_dp_code_10				= toHTML(trim($record['control_rum_dp_code_10']));
				$control_rum_dr_code_01				= toHTML(trim($record['control_rum_dr_code_01']));
				$control_rum_dr_code_02				= toHTML(trim($record['control_rum_dr_code_02']));
				$control_rum_dr_code_03				= toHTML(trim($record['control_rum_dr_code_03']));
				$control_rum_dr_code_04				= toHTML(trim($record['control_rum_dr_code_04']));
				$control_rum_dr_code_05				= toHTML(trim($record['control_rum_dr_code_05']));
				$control_rum_dr_code_06				= toHTML(trim($record['control_rum_dr_code_06']));
				$control_rum_dr_code_07				= toHTML(trim($record['control_rum_dr_code_07']));
				$control_rum_dr_code_08				= toHTML(trim($record['control_rum_dr_code_08']));
				$control_rum_dr_code_09				= toHTML(trim($record['control_rum_dr_code_09']));
				$control_rum_dr_code_10				= toHTML(trim($record['control_rum_dr_code_10']));
				$control_rum_da_code_01				= toHTML(trim($record['control_rum_da_code_01']));
				$control_rum_da_code_02				= toHTML(trim($record['control_rum_da_code_02']));
				$control_rum_da_code_03				= toHTML(trim($record['control_rum_da_code_03']));
				$control_rum_da_code_04				= toHTML(trim($record['control_rum_da_code_04']));
				$control_rum_da_code_05				= toHTML(trim($record['control_rum_da_code_05']));
				$control_rum_da_code_06				= toHTML(trim($record['control_rum_da_code_06']));
				$control_rum_da_code_07				= toHTML(trim($record['control_rum_da_code_07']));
				$control_rum_da_code_08				= toHTML(trim($record['control_rum_da_code_08']));
				$control_rum_da_code_09				= toHTML(trim($record['control_rum_da_code_09']));
				$control_rum_da_code_10				= toHTML(trim($record['control_rum_da_code_10']));
				$control_rum_ccam_code_01			= toHTML(trim($record['control_rum_ccam_code_01']));
				$control_rum_ccam_code_02			= toHTML(trim($record['control_rum_ccam_code_02']));
				$control_rum_ccam_code_03			= toHTML(trim($record['control_rum_ccam_code_03']));
				$control_rum_ccam_code_04			= toHTML(trim($record['control_rum_ccam_code_04']));
				$control_rum_ccam_code_05			= toHTML(trim($record['control_rum_ccam_code_05']));
				$control_rum_ccam_code_06			= toHTML(trim($record['control_rum_ccam_code_06']));
				$control_rum_ccam_code_07			= toHTML(trim($record['control_rum_ccam_code_07']));
				$control_rum_ccam_code_08			= toHTML(trim($record['control_rum_ccam_code_08']));
				$control_rum_ccam_code_09			= toHTML(trim($record['control_rum_ccam_code_09']));
				$control_rum_ccam_code_10			= toHTML(trim($record['control_rum_ccam_code_10']));
				$control_ghs_montant_total 			= floatval($record['control_ghs_montant_total']);
				$control_exb_montant_total          = floatval($record['control_exb_montant_total']);
				$control_exh_montant_total          = floatval($record['control_exh_montant_total']);
				
				$retenu_rule          				= toHTML(trim($record['retenu_rule']));
				$retenu_comment          			= toHTML(trim($record['retenu_comment']));
				$retenu_dp_code          			= toHTML(trim($record['retenu_dp_code']));
				$retenu_dp_texte          			= toHTML(trim($record['retenu_dp_texte']));
				$retenu_ghs_code                   	= toHTML(trim($record['retenu_ghs_code']));
				$retenu_ghm_code                   	= toHTML(trim($record['retenu_ghm_code']));
				$retenu_ghm_texte                  	= toHTML(trim($record['retenu_ghm_texte']));
				$retenu_rum_um_code_01				= toHTML(trim($record['retenu_rum_um_code_01']));
				$retenu_rum_um_code_02				= toHTML(trim($record['retenu_rum_um_code_02']));
				$retenu_rum_um_code_03				= toHTML(trim($record['retenu_rum_um_code_03']));
				$retenu_rum_um_code_04				= toHTML(trim($record['retenu_rum_um_code_04']));
				$retenu_rum_um_code_05				= toHTML(trim($record['retenu_rum_um_code_05']));
				$retenu_rum_um_code_06				= toHTML(trim($record['retenu_rum_um_code_06']));
				$retenu_rum_um_code_07				= toHTML(trim($record['retenu_rum_um_code_07']));
				$retenu_rum_um_code_08				= toHTML(trim($record['retenu_rum_um_code_08']));
				$retenu_rum_um_code_09				= toHTML(trim($record['retenu_rum_um_code_09']));
				$retenu_rum_um_code_10				= toHTML(trim($record['retenu_rum_um_code_10']));
				$retenu_rum_dp_code_01				= toHTML(trim($record['retenu_rum_dp_code_01']));
				$retenu_rum_dp_code_02				= toHTML(trim($record['retenu_rum_dp_code_02']));
				$retenu_rum_dp_code_03				= toHTML(trim($record['retenu_rum_dp_code_03']));
				$retenu_rum_dp_code_04				= toHTML(trim($record['retenu_rum_dp_code_04']));
				$retenu_rum_dp_code_05				= toHTML(trim($record['retenu_rum_dp_code_05']));
				$retenu_rum_dp_code_06				= toHTML(trim($record['retenu_rum_dp_code_06']));
				$retenu_rum_dp_code_07				= toHTML(trim($record['retenu_rum_dp_code_07']));
				$retenu_rum_dp_code_08				= toHTML(trim($record['retenu_rum_dp_code_08']));
				$retenu_rum_dp_code_09				= toHTML(trim($record['retenu_rum_dp_code_09']));
				$retenu_rum_dp_code_10				= toHTML(trim($record['retenu_rum_dp_code_10']));
				$retenu_rum_dr_code_01				= toHTML(trim($record['retenu_rum_dr_code_01']));
				$retenu_rum_dr_code_02				= toHTML(trim($record['retenu_rum_dr_code_02']));
				$retenu_rum_dr_code_03				= toHTML(trim($record['retenu_rum_dr_code_03']));
				$retenu_rum_dr_code_04				= toHTML(trim($record['retenu_rum_dr_code_04']));
				$retenu_rum_dr_code_05				= toHTML(trim($record['retenu_rum_dr_code_05']));
				$retenu_rum_dr_code_06				= toHTML(trim($record['retenu_rum_dr_code_06']));
				$retenu_rum_dr_code_07				= toHTML(trim($record['retenu_rum_dr_code_07']));
				$retenu_rum_dr_code_08				= toHTML(trim($record['retenu_rum_dr_code_08']));
				$retenu_rum_dr_code_09				= toHTML(trim($record['retenu_rum_dr_code_09']));
				$retenu_rum_dr_code_10				= toHTML(trim($record['retenu_rum_dr_code_10']));
				$retenu_rum_da_code_01				= toHTML(trim($record['retenu_rum_da_code_01']));
				$retenu_rum_da_code_02				= toHTML(trim($record['retenu_rum_da_code_02']));
				$retenu_rum_da_code_03				= toHTML(trim($record['retenu_rum_da_code_03']));
				$retenu_rum_da_code_04				= toHTML(trim($record['retenu_rum_da_code_04']));
				$retenu_rum_da_code_05				= toHTML(trim($record['retenu_rum_da_code_05']));
				$retenu_rum_da_code_06				= toHTML(trim($record['retenu_rum_da_code_06']));
				$retenu_rum_da_code_07				= toHTML(trim($record['retenu_rum_da_code_07']));
				$retenu_rum_da_code_08				= toHTML(trim($record['retenu_rum_da_code_08']));
				$retenu_rum_da_code_09				= toHTML(trim($record['retenu_rum_da_code_09']));
				$retenu_rum_da_code_10				= toHTML(trim($record['retenu_rum_da_code_10']));
				$retenu_rum_ccam_code_01			= toHTML(trim($record['retenu_rum_ccam_code_01']));
				$retenu_rum_ccam_code_02			= toHTML(trim($record['retenu_rum_ccam_code_02']));
				$retenu_rum_ccam_code_03			= toHTML(trim($record['retenu_rum_ccam_code_03']));
				$retenu_rum_ccam_code_04			= toHTML(trim($record['retenu_rum_ccam_code_04']));
				$retenu_rum_ccam_code_05			= toHTML(trim($record['retenu_rum_ccam_code_05']));
				$retenu_rum_ccam_code_06			= toHTML(trim($record['retenu_rum_ccam_code_06']));
				$retenu_rum_ccam_code_07			= toHTML(trim($record['retenu_rum_ccam_code_07']));
				$retenu_rum_ccam_code_08			= toHTML(trim($record['retenu_rum_ccam_code_08']));
				$retenu_rum_ccam_code_09			= toHTML(trim($record['retenu_rum_ccam_code_09']));
				$retenu_rum_ccam_code_10			= toHTML(trim($record['retenu_rum_ccam_code_10']));
				$retenu_ghs_montant_total 			= floatval($record['retenu_ghs_montant_total']);
				$retenu_exb_montant_total           = floatval($record['retenu_exb_montant_total']);
				$retenu_exh_montant_total           = floatval($record['retenu_exh_montant_total']);
				

				$httpString = $httpString . 
					"\r\n<RECORD
						oid=\"$oid\"
						texte=\"$texte\"
						enquete_id=\"$enquete_id\"
						champ_id=\"$champ_id\"
						champ_code=\"$champ_code\"
						champ_texte=\"$champ_texte\"
						no_ogc=\"+$no_ogc\"
						no_rss=\"$no_rss\"
						rss_id=\"$rss_id\"
						matricule_assure=\"$matricule_assure\"
						cle_matricule_assure=\"$cle_matricule_assure\"
						no_sejour_administratif=\"$no_sejour_administratif\"
						no_patient=\"$no_patient\"
						nom_complet=\"$nom_complet\"
						date_naissance=\"$date_naissance\"
						no_facture=\"$no_facture\"
						regime_caisse_texte=\"$regime_caisse_texte\"
						date_entree=\"$date_entree\"
						date_sortie=\"$date_sortie\"
						duree_sejour=\"+$duree_sejour\"
						taux_remboursement=\"$taux_remboursement\"
						taux_remboursement_vidhosp=\"$taux_remboursement_vidhosp\"
						montant_majoration_parcours_soins=\"$montant_majoration_parcours_soins\"
						montant_ticket_moderateur=\"$montant_ticket_moderateur\"
						montant_forfait_journalier=\"$montant_forfait_journalier\"
						nombre_forfait_journalier=\"$nombre_forfait_journalier\"
						
						status=\"$status\"
						status_texte=\"$status_texte\"
						
						facture_dp_code=\"$facture_dp_code\"
						facture_dp_texte=\"$facture_dp_texte\"
						facture_ghs_code=\"$facture_ghs_code\"
						facture_ghm_code=\"$facture_ghm_code\"
						facture_ghm_texte=\"$facture_ghm_texte\"
						facture_ghs_montant_total=\"$facture_ghs_montant_total\"
						facture_exb_montant_total=\"$facture_exb_montant_total\"
						facture_exh_montant_total=\"$facture_exh_montant_total\"
						
						initial_dp_code=\"$initial_dp_code\"
						initial_dp_texte=\"$initial_dp_texte\"
						initial_ghs_code=\"$initial_ghs_code\"
						initial_ghm_code=\"$initial_ghm_code\"
						initial_ghm_texte=\"$initial_ghm_texte\"
						initial_rum_um_code_01=\"$initial_rum_um_code_01\"
						initial_rum_um_code_02=\"$initial_rum_um_code_02\"
						initial_rum_um_code_03=\"$initial_rum_um_code_03\"
						initial_rum_um_code_04=\"$initial_rum_um_code_04\"
						initial_rum_um_code_05=\"$initial_rum_um_code_05\"
						initial_rum_um_code_06=\"$initial_rum_um_code_06\"
						initial_rum_um_code_07=\"$initial_rum_um_code_07\"
						initial_rum_um_code_08=\"$initial_rum_um_code_08\"
						initial_rum_um_code_09=\"$initial_rum_um_code_09\"
						initial_rum_um_code_10=\"$initial_rum_um_code_10\"
						initial_rum_dp_code_01=\"$initial_rum_dp_code_01\"
						initial_rum_dp_code_02=\"$initial_rum_dp_code_02\"
						initial_rum_dp_code_03=\"$initial_rum_dp_code_03\"
						initial_rum_dp_code_04=\"$initial_rum_dp_code_04\"
						initial_rum_dp_code_05=\"$initial_rum_dp_code_05\"
						initial_rum_dp_code_06=\"$initial_rum_dp_code_06\"
						initial_rum_dp_code_07=\"$initial_rum_dp_code_07\"
						initial_rum_dp_code_08=\"$initial_rum_dp_code_08\"
						initial_rum_dp_code_09=\"$initial_rum_dp_code_09\"
						initial_rum_dp_code_10=\"$initial_rum_dp_code_10\"
						initial_rum_dr_code_01=\"$initial_rum_dr_code_01\"
						initial_rum_dr_code_02=\"$initial_rum_dr_code_02\"
						initial_rum_dr_code_03=\"$initial_rum_dr_code_03\"
						initial_rum_dr_code_04=\"$initial_rum_dr_code_04\"
						initial_rum_dr_code_05=\"$initial_rum_dr_code_05\"
						initial_rum_dr_code_06=\"$initial_rum_dr_code_06\"
						initial_rum_dr_code_07=\"$initial_rum_dr_code_07\"
						initial_rum_dr_code_08=\"$initial_rum_dr_code_08\"
						initial_rum_dr_code_09=\"$initial_rum_dr_code_09\"
						initial_rum_dr_code_10=\"$initial_rum_dr_code_10\"
						initial_rum_da_code_01=\"$initial_rum_da_code_01\"
						initial_rum_da_code_02=\"$initial_rum_da_code_02\"
						initial_rum_da_code_03=\"$initial_rum_da_code_03\"
						initial_rum_da_code_04=\"$initial_rum_da_code_04\"
						initial_rum_da_code_05=\"$initial_rum_da_code_05\"
						initial_rum_da_code_06=\"$initial_rum_da_code_06\"
						initial_rum_da_code_07=\"$initial_rum_da_code_07\"
						initial_rum_da_code_08=\"$initial_rum_da_code_08\"
						initial_rum_da_code_09=\"$initial_rum_da_code_09\"
						initial_rum_da_code_10=\"$initial_rum_da_code_10\"
						initial_rum_ccam_code_01=\"$initial_rum_ccam_code_01\"
						initial_rum_ccam_code_02=\"$initial_rum_ccam_code_02\"
						initial_rum_ccam_code_03=\"$initial_rum_ccam_code_03\"
						initial_rum_ccam_code_04=\"$initial_rum_ccam_code_04\"
						initial_rum_ccam_code_05=\"$initial_rum_ccam_code_05\"
						initial_rum_ccam_code_06=\"$initial_rum_ccam_code_06\"
						initial_rum_ccam_code_07=\"$initial_rum_ccam_code_07\"
						initial_rum_ccam_code_08=\"$initial_rum_ccam_code_08\"
						initial_rum_ccam_code_09=\"$initial_rum_ccam_code_09\"
						initial_rum_ccam_code_10=\"$initial_rum_ccam_code_10\"
						initial_ghs_montant_total=\"$initial_ghs_montant_total\"
						initial_exb_montant_total=\"$initial_exb_montant_total\"
						initial_exh_montant_total=\"$initial_exh_montant_total\"
						
						scenar1_rule=\"$scenar1_rule\"
						scenar1_comment=\"$scenar1_comment\"
						scenar1_dp_code=\"$scenar1_dp_code\"
						scenar1_dp_texte=\"$scenar1_dp_texte\"
						scenar1_ghs_code=\"$scenar1_ghs_code\"
						scenar1_ghm_code=\"$scenar1_ghm_code\"
						scenar1_ghm_texte=\"$scenar1_ghm_texte\"
						scenar1_rum_um_code_01=\"$scenar1_rum_um_code_01\"
						scenar1_rum_um_code_02=\"$scenar1_rum_um_code_02\"
						scenar1_rum_um_code_03=\"$scenar1_rum_um_code_03\"
						scenar1_rum_um_code_04=\"$scenar1_rum_um_code_04\"
						scenar1_rum_um_code_05=\"$scenar1_rum_um_code_05\"
						scenar1_rum_um_code_06=\"$scenar1_rum_um_code_06\"
						scenar1_rum_um_code_07=\"$scenar1_rum_um_code_07\"
						scenar1_rum_um_code_08=\"$scenar1_rum_um_code_08\"
						scenar1_rum_um_code_09=\"$scenar1_rum_um_code_09\"
						scenar1_rum_um_code_10=\"$scenar1_rum_um_code_10\"
						scenar1_rum_dp_code_01=\"$scenar1_rum_dp_code_01\"
						scenar1_rum_dp_code_02=\"$scenar1_rum_dp_code_02\"
						scenar1_rum_dp_code_03=\"$scenar1_rum_dp_code_03\"
						scenar1_rum_dp_code_04=\"$scenar1_rum_dp_code_04\"
						scenar1_rum_dp_code_05=\"$scenar1_rum_dp_code_05\"
						scenar1_rum_dp_code_06=\"$scenar1_rum_dp_code_06\"
						scenar1_rum_dp_code_07=\"$scenar1_rum_dp_code_07\"
						scenar1_rum_dp_code_08=\"$scenar1_rum_dp_code_08\"
						scenar1_rum_dp_code_09=\"$scenar1_rum_dp_code_09\"
						scenar1_rum_dp_code_10=\"$scenar1_rum_dp_code_10\"
						scenar1_rum_dr_code_01=\"$scenar1_rum_dr_code_01\"
						scenar1_rum_dr_code_02=\"$scenar1_rum_dr_code_02\"
						scenar1_rum_dr_code_03=\"$scenar1_rum_dr_code_03\"
						scenar1_rum_dr_code_04=\"$scenar1_rum_dr_code_04\"
						scenar1_rum_dr_code_05=\"$scenar1_rum_dr_code_05\"
						scenar1_rum_dr_code_06=\"$scenar1_rum_dr_code_06\"
						scenar1_rum_dr_code_07=\"$scenar1_rum_dr_code_07\"
						scenar1_rum_dr_code_08=\"$scenar1_rum_dr_code_08\"
						scenar1_rum_dr_code_09=\"$scenar1_rum_dr_code_09\"
						scenar1_rum_dr_code_10=\"$scenar1_rum_dr_code_10\"
						scenar1_rum_da_code_01=\"$scenar1_rum_da_code_01\"
						scenar1_rum_da_code_02=\"$scenar1_rum_da_code_02\"
						scenar1_rum_da_code_03=\"$scenar1_rum_da_code_03\"
						scenar1_rum_da_code_04=\"$scenar1_rum_da_code_04\"
						scenar1_rum_da_code_05=\"$scenar1_rum_da_code_05\"
						scenar1_rum_da_code_06=\"$scenar1_rum_da_code_06\"
						scenar1_rum_da_code_07=\"$scenar1_rum_da_code_07\"
						scenar1_rum_da_code_08=\"$scenar1_rum_da_code_08\"
						scenar1_rum_da_code_09=\"$scenar1_rum_da_code_09\"
						scenar1_rum_da_code_10=\"$scenar1_rum_da_code_10\"
						scenar1_rum_ccam_code_01=\"$scenar1_rum_ccam_code_01\"
						scenar1_rum_ccam_code_02=\"$scenar1_rum_ccam_code_02\"
						scenar1_rum_ccam_code_03=\"$scenar1_rum_ccam_code_03\"
						scenar1_rum_ccam_code_04=\"$scenar1_rum_ccam_code_04\"
						scenar1_rum_ccam_code_05=\"$scenar1_rum_ccam_code_05\"
						scenar1_rum_ccam_code_06=\"$scenar1_rum_ccam_code_06\"
						scenar1_rum_ccam_code_07=\"$scenar1_rum_ccam_code_07\"
						scenar1_rum_ccam_code_08=\"$scenar1_rum_ccam_code_08\"
						scenar1_rum_ccam_code_09=\"$scenar1_rum_ccam_code_09\"
						scenar1_rum_ccam_code_10=\"$scenar1_rum_ccam_code_10\"
						scenar1_ghs_montant_total=\"$scenar1_ghs_montant_total\"
						scenar1_exb_montant_total=\"$scenar1_exb_montant_total\"
						scenar1_exh_montant_total=\"$scenar1_exh_montant_total\"
						
						scenar2_rule=\"$scenar2_rule\"
						scenar2_comment=\"$scenar2_comment\"
						scenar2_dp_code=\"$scenar2_dp_code\"
						scenar2_dp_texte=\"$scenar2_dp_texte\"
						scenar2_ghs_code=\"$scenar2_ghs_code\"
						scenar2_ghm_code=\"$scenar2_ghm_code\"
						scenar2_ghm_texte=\"$scenar2_ghm_texte\"
						scenar2_rum_um_code_01=\"$scenar2_rum_um_code_01\"
						scenar2_rum_um_code_02=\"$scenar2_rum_um_code_02\"
						scenar2_rum_um_code_03=\"$scenar2_rum_um_code_03\"
						scenar2_rum_um_code_04=\"$scenar2_rum_um_code_04\"
						scenar2_rum_um_code_05=\"$scenar2_rum_um_code_05\"
						scenar2_rum_um_code_06=\"$scenar2_rum_um_code_06\"
						scenar2_rum_um_code_07=\"$scenar2_rum_um_code_07\"
						scenar2_rum_um_code_08=\"$scenar2_rum_um_code_08\"
						scenar2_rum_um_code_09=\"$scenar2_rum_um_code_09\"
						scenar2_rum_um_code_10=\"$scenar2_rum_um_code_10\"
						scenar2_rum_dp_code_01=\"$scenar2_rum_dp_code_01\"
						scenar2_rum_dp_code_02=\"$scenar2_rum_dp_code_02\"
						scenar2_rum_dp_code_03=\"$scenar2_rum_dp_code_03\"
						scenar2_rum_dp_code_04=\"$scenar2_rum_dp_code_04\"
						scenar2_rum_dp_code_05=\"$scenar2_rum_dp_code_05\"
						scenar2_rum_dp_code_06=\"$scenar2_rum_dp_code_06\"
						scenar2_rum_dp_code_07=\"$scenar2_rum_dp_code_07\"
						scenar2_rum_dp_code_08=\"$scenar2_rum_dp_code_08\"
						scenar2_rum_dp_code_09=\"$scenar2_rum_dp_code_09\"
						scenar2_rum_dp_code_10=\"$scenar2_rum_dp_code_10\"
						scenar2_rum_dr_code_01=\"$scenar2_rum_dr_code_01\"
						scenar2_rum_dr_code_02=\"$scenar2_rum_dr_code_02\"
						scenar2_rum_dr_code_03=\"$scenar2_rum_dr_code_03\"
						scenar2_rum_dr_code_04=\"$scenar2_rum_dr_code_04\"
						scenar2_rum_dr_code_05=\"$scenar2_rum_dr_code_05\"
						scenar2_rum_dr_code_06=\"$scenar2_rum_dr_code_06\"
						scenar2_rum_dr_code_07=\"$scenar2_rum_dr_code_07\"
						scenar2_rum_dr_code_08=\"$scenar2_rum_dr_code_08\"
						scenar2_rum_dr_code_09=\"$scenar2_rum_dr_code_09\"
						scenar2_rum_dr_code_10=\"$scenar2_rum_dr_code_10\"
						scenar2_rum_da_code_01=\"$scenar2_rum_da_code_01\"
						scenar2_rum_da_code_02=\"$scenar2_rum_da_code_02\"
						scenar2_rum_da_code_03=\"$scenar2_rum_da_code_03\"
						scenar2_rum_da_code_04=\"$scenar2_rum_da_code_04\"
						scenar2_rum_da_code_05=\"$scenar2_rum_da_code_05\"
						scenar2_rum_da_code_06=\"$scenar2_rum_da_code_06\"
						scenar2_rum_da_code_07=\"$scenar2_rum_da_code_07\"
						scenar2_rum_da_code_08=\"$scenar2_rum_da_code_08\"
						scenar2_rum_da_code_09=\"$scenar2_rum_da_code_09\"
						scenar2_rum_da_code_10=\"$scenar2_rum_da_code_10\"
						scenar2_rum_ccam_code_01=\"$scenar2_rum_ccam_code_01\"
						scenar2_rum_ccam_code_02=\"$scenar2_rum_ccam_code_02\"
						scenar2_rum_ccam_code_03=\"$scenar2_rum_ccam_code_03\"
						scenar2_rum_ccam_code_04=\"$scenar2_rum_ccam_code_04\"
						scenar2_rum_ccam_code_05=\"$scenar2_rum_ccam_code_05\"
						scenar2_rum_ccam_code_06=\"$scenar2_rum_ccam_code_06\"
						scenar2_rum_ccam_code_07=\"$scenar2_rum_ccam_code_07\"
						scenar2_rum_ccam_code_08=\"$scenar2_rum_ccam_code_08\"
						scenar2_rum_ccam_code_09=\"$scenar2_rum_ccam_code_09\"
						scenar2_rum_ccam_code_10=\"$scenar2_rum_ccam_code_10\"
						scenar2_ghs_montant_total=\"$scenar2_ghs_montant_total\"
						scenar2_exb_montant_total=\"$scenar2_exb_montant_total\"
						scenar2_exh_montant_total=\"$scenar2_exh_montant_total\"
						
						control_rule=\"$control_rule\"
						control_comment=\"$control_comment\"
						control_dp_code=\"$control_dp_code\"
						control_dp_texte=\"$control_dp_texte\"
						control_ghs_code=\"$control_ghs_code\"
						control_ghm_code=\"$control_ghm_code\"
						control_ghm_texte=\"$control_ghm_texte\"
						control_rum_um_code_01=\"$control_rum_um_code_01\"
						control_rum_um_code_02=\"$control_rum_um_code_02\"
						control_rum_um_code_03=\"$control_rum_um_code_03\"
						control_rum_um_code_04=\"$control_rum_um_code_04\"
						control_rum_um_code_05=\"$control_rum_um_code_05\"
						control_rum_um_code_06=\"$control_rum_um_code_06\"
						control_rum_um_code_07=\"$control_rum_um_code_07\"
						control_rum_um_code_08=\"$control_rum_um_code_08\"
						control_rum_um_code_09=\"$control_rum_um_code_09\"
						control_rum_um_code_10=\"$control_rum_um_code_10\"
						control_rum_dp_code_01=\"$control_rum_dp_code_01\"
						control_rum_dp_code_02=\"$control_rum_dp_code_02\"
						control_rum_dp_code_03=\"$control_rum_dp_code_03\"
						control_rum_dp_code_04=\"$control_rum_dp_code_04\"
						control_rum_dp_code_05=\"$control_rum_dp_code_05\"
						control_rum_dp_code_06=\"$control_rum_dp_code_06\"
						control_rum_dp_code_07=\"$control_rum_dp_code_07\"
						control_rum_dp_code_08=\"$control_rum_dp_code_08\"
						control_rum_dp_code_09=\"$control_rum_dp_code_09\"
						control_rum_dp_code_10=\"$control_rum_dp_code_10\"
						control_rum_dr_code_01=\"$control_rum_dr_code_01\"
						control_rum_dr_code_02=\"$control_rum_dr_code_02\"
						control_rum_dr_code_03=\"$control_rum_dr_code_03\"
						control_rum_dr_code_04=\"$control_rum_dr_code_04\"
						control_rum_dr_code_05=\"$control_rum_dr_code_05\"
						control_rum_dr_code_06=\"$control_rum_dr_code_06\"
						control_rum_dr_code_07=\"$control_rum_dr_code_07\"
						control_rum_dr_code_08=\"$control_rum_dr_code_08\"
						control_rum_dr_code_09=\"$control_rum_dr_code_09\"
						control_rum_dr_code_10=\"$control_rum_dr_code_10\"
						control_rum_da_code_01=\"$control_rum_da_code_01\"
						control_rum_da_code_02=\"$control_rum_da_code_02\"
						control_rum_da_code_03=\"$control_rum_da_code_03\"
						control_rum_da_code_04=\"$control_rum_da_code_04\"
						control_rum_da_code_05=\"$control_rum_da_code_05\"
						control_rum_da_code_06=\"$control_rum_da_code_06\"
						control_rum_da_code_07=\"$control_rum_da_code_07\"
						control_rum_da_code_08=\"$control_rum_da_code_08\"
						control_rum_da_code_09=\"$control_rum_da_code_09\"
						control_rum_da_code_10=\"$control_rum_da_code_10\"
						control_rum_ccam_code_01=\"$control_rum_ccam_code_01\"
						control_rum_ccam_code_02=\"$control_rum_ccam_code_02\"
						control_rum_ccam_code_03=\"$control_rum_ccam_code_03\"
						control_rum_ccam_code_04=\"$control_rum_ccam_code_04\"
						control_rum_ccam_code_05=\"$control_rum_ccam_code_05\"
						control_rum_ccam_code_06=\"$control_rum_ccam_code_06\"
						control_rum_ccam_code_07=\"$control_rum_ccam_code_07\"
						control_rum_ccam_code_08=\"$control_rum_ccam_code_08\"
						control_rum_ccam_code_09=\"$control_rum_ccam_code_09\"
						control_rum_ccam_code_10=\"$control_rum_ccam_code_10\"
						control_ghs_montant_total=\"$control_ghs_montant_total\"
						control_exb_montant_total=\"$control_exb_montant_total\"
						control_exh_montant_total=\"$control_exh_montant_total\"
						
						retenu_rule=\"$retenu_rule\"
						retenu_comment=\"$retenu_comment\"
						retenu_dp_code=\"$retenu_dp_code\"
						retenu_dp_texte=\"$retenu_dp_texte\"
						retenu_ghs_code=\"$retenu_ghs_code\"
						retenu_ghm_code=\"$retenu_ghm_code\"
						retenu_ghm_texte=\"$retenu_ghm_texte\"
						retenu_rum_um_code_01=\"$retenu_rum_um_code_01\"
						retenu_rum_um_code_02=\"$retenu_rum_um_code_02\"
						retenu_rum_um_code_03=\"$retenu_rum_um_code_03\"
						retenu_rum_um_code_04=\"$retenu_rum_um_code_04\"
						retenu_rum_um_code_05=\"$retenu_rum_um_code_05\"
						retenu_rum_um_code_06=\"$retenu_rum_um_code_06\"
						retenu_rum_um_code_07=\"$retenu_rum_um_code_07\"
						retenu_rum_um_code_08=\"$retenu_rum_um_code_08\"
						retenu_rum_um_code_09=\"$retenu_rum_um_code_09\"
						retenu_rum_um_code_10=\"$retenu_rum_um_code_10\"
						retenu_rum_dp_code_01=\"$retenu_rum_dp_code_01\"
						retenu_rum_dp_code_02=\"$retenu_rum_dp_code_02\"
						retenu_rum_dp_code_03=\"$retenu_rum_dp_code_03\"
						retenu_rum_dp_code_04=\"$retenu_rum_dp_code_04\"
						retenu_rum_dp_code_05=\"$retenu_rum_dp_code_05\"
						retenu_rum_dp_code_06=\"$retenu_rum_dp_code_06\"
						retenu_rum_dp_code_07=\"$retenu_rum_dp_code_07\"
						retenu_rum_dp_code_08=\"$retenu_rum_dp_code_08\"
						retenu_rum_dp_code_09=\"$retenu_rum_dp_code_09\"
						retenu_rum_dp_code_10=\"$retenu_rum_dp_code_10\"
						retenu_rum_dr_code_01=\"$retenu_rum_dr_code_01\"
						retenu_rum_dr_code_02=\"$retenu_rum_dr_code_02\"
						retenu_rum_dr_code_03=\"$retenu_rum_dr_code_03\"
						retenu_rum_dr_code_04=\"$retenu_rum_dr_code_04\"
						retenu_rum_dr_code_05=\"$retenu_rum_dr_code_05\"
						retenu_rum_dr_code_06=\"$retenu_rum_dr_code_06\"
						retenu_rum_dr_code_07=\"$retenu_rum_dr_code_07\"
						retenu_rum_dr_code_08=\"$retenu_rum_dr_code_08\"
						retenu_rum_dr_code_09=\"$retenu_rum_dr_code_09\"
						retenu_rum_dr_code_10=\"$retenu_rum_dr_code_10\"
						retenu_rum_da_code_01=\"$retenu_rum_da_code_01\"
						retenu_rum_da_code_02=\"$retenu_rum_da_code_02\"
						retenu_rum_da_code_03=\"$retenu_rum_da_code_03\"
						retenu_rum_da_code_04=\"$retenu_rum_da_code_04\"
						retenu_rum_da_code_05=\"$retenu_rum_da_code_05\"
						retenu_rum_da_code_06=\"$retenu_rum_da_code_06\"
						retenu_rum_da_code_07=\"$retenu_rum_da_code_07\"
						retenu_rum_da_code_08=\"$retenu_rum_da_code_08\"
						retenu_rum_da_code_09=\"$retenu_rum_da_code_09\"
						retenu_rum_da_code_10=\"$retenu_rum_da_code_10\"
						retenu_rum_ccam_code_01=\"$retenu_rum_ccam_code_01\"
						retenu_rum_ccam_code_02=\"$retenu_rum_ccam_code_02\"
						retenu_rum_ccam_code_03=\"$retenu_rum_ccam_code_03\"
						retenu_rum_ccam_code_04=\"$retenu_rum_ccam_code_04\"
						retenu_rum_ccam_code_05=\"$retenu_rum_ccam_code_05\"
						retenu_rum_ccam_code_06=\"$retenu_rum_ccam_code_06\"
						retenu_rum_ccam_code_07=\"$retenu_rum_ccam_code_07\"
						retenu_rum_ccam_code_08=\"$retenu_rum_ccam_code_08\"
						retenu_rum_ccam_code_09=\"$retenu_rum_ccam_code_09\"
						retenu_rum_ccam_code_10=\"$retenu_rum_ccam_code_10\"
						retenu_ghs_montant_total=\"$retenu_ghs_montant_total\"
						retenu_exb_montant_total=\"$retenu_exb_montant_total\"
						retenu_exh_montant_total=\"$retenu_exh_montant_total\"
					/>";
				

			}
		}

	
	}
	
	return $httpString . getCombo_enquete();
	return $httpString . getCombo_champ();
	

}




// spécialités médecins pour combo
function getCombo_annee() {

global $database;

	$httpString = "";

	
	$httpString = $httpString . "\r\n<COMBO_ANNEE>";

	$sqlcmd = "SELECT date_part('year',date_fin),date_part('year',date_fin)
				FROM pmsi.p_imports
				WHERE date_fin <= now()
				GROUP BY 1
				ORDER BY 1 DESC";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
	
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecordInto();
										

			if ($record != FALSE) {
				$ok = TRUE;

				$oid = $record[0];
				$texte = toHTML(trim($record[1]));
			
				$httpString = $httpString . "\r\n<RECORD ";
				$httpString = $httpString . "oid=\"$oid\" ";
				$httpString = $httpString . "texte=\"$texte\" ";
				$httpString = $httpString . " />";

			}
		}

	
	}

	$httpString = $httpString . "\r\n</COMBO_ANNEE>";
	
	return $httpString;
	
	

}


// 
function getCombo_enquete() {

global $database;

	$httpString = "";

	
	$httpString = $httpString . "\r\n<COMBO_ENQ>";

	$sqlcmd = "SELECT oid, texte
				FROM pmsi.t_fiche5_enquete
				ORDER BY 1 DESC";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
	
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecordInto();
										

			if ($record != FALSE) {
				$ok = TRUE;

				$oid = $record[0];
				$texte = toHTML(trim($record[1]));
			
				$httpString = $httpString . "\r\n<RECORD ";
				$httpString = $httpString . "oid=\"$oid\" ";
				$httpString = $httpString . "texte=\"$texte\" ";
				$httpString = $httpString . " />";

			}
		}

	
	}

	$httpString = $httpString . "\r\n</COMBO_ENQ>";
	
	return $httpString;
	
	

}






// 
function getCombo_champ() {

global $database;

	$httpString = "";

	
	$httpString = $httpString . "\r\n<COMBO_CHP>";

	$sqlcmd = "SELECT oid, texte
				FROM pmsi.t_fiche5_champ
				ORDER BY 1 DESC";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
	
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecordInto();
										

			if ($record != FALSE) {
				$ok = TRUE;

				$oid = $record[0];
				$texte = toHTML(trim($record[1]));
			
				$httpString = $httpString . "\r\n<RECORD ";
				$httpString = $httpString . "oid=\"$oid\" ";
				$httpString = $httpString . "texte=\"$texte\" ";
				$httpString = $httpString . " />";

			}
		}

	
	}

	$httpString = $httpString . "\r\n</COMBO_CHP>";
	
	return $httpString;
	
	

}
    
?>