<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="PMSI000270" 
	label="PMSI. Justificatif Impact Théorique CMA" 
	title="= 'Impact Théorique CMA (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ') - ' + SELECT.VERSION_GROUPAGE_LABEL" 
	database="iCTI" 
	swf="*CTI_view1" 
	softCode="iCTI_pmsi"
	globals="PMSI_globals.XML"
	componentsFile="PMSI_components.XML">
	
	<VIEWPROPERTIES>
		
		<PROPERTYx dataLink="VIEWPROPERTIES" nameField="name" valueField="value" />
		
		<PROPERTY name="FILTRE_DIAG_RSS_SELECT">
			<value><![CDATA[[EVAL 
			
				$select = "";
				
				$mode = substr('[DIAG]',0,2);
				$oid = substr('[DIAG]',2);
				if ($mode == 'LS') {
                    $section_id = PMSI_get_section_id('[DIAG]');
                    $oid = PMSI_get_classe_oid('[DIAG]');
				}
				$diag_select = '';
					
				if ('[DIAG]' != '-1') {
					if ($mode == 'LI') {$diag_select = "diagnostic_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$diag_select = "diagnostic_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'DG') {$diag_select = "diagnostic_id = $oid ";}
					if ($mode == 'DR') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE racine_id = $oid)";}
					if ($mode == 'LS') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE $section_id = $oid)";}
					if ($mode == 'C*') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
					
					$diag_select =  "$diag_select AND type_diagnostic IN ('DA', 'DS') ";

					if ($diag_select != '') {
						if ($mode != 'SL') {
							$select = $select. " AND v_rss_1.rss_id IN (SELECT rss_id FROM pmsi.p_rss_diagnostics WHERE $diag_select)";
						}
						else {
							$select = $select. " AND v_rss_1.rss_id NOT IN (SELECT rss_id FROM pmsi.p_rss_diagnostics WHERE $diag_select)";
						}
					}
				}
				else {
					$select = " AND v_rss_1.rss_id IS DISTINCT FROM v_rss_1.rss_id";
				}
				
				return $select;
					
				
			EVAL]]]></value>
		</PROPERTY>
		
		<PROPERTY name="FILTRE_DIAG_SELECT">
			<value><![CDATA[[EVAL 
			
				$select = "";
				
				$mode = substr('[DIAG]',0,2);
				$oid = substr('[DIAG]',2);
				if ($mode == 'LS') {
                    $section_id = PMSI_get_section_id('[DIAG]');
                    $oid = PMSI_get_classe_oid('[DIAG]');
				}
				$diag_select = '';
					
				if ('[DIAG]' != '-1') {
					if ($mode == 'LI') {$diag_select = "diagnostic_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'SL') {$diag_select = "diagnostic_id IN (SELECT to_id FROM pmsi.t_listes_contenu WHERE liste_id = $oid)";}
					if ($mode == 'DG') {$diag_select = "diagnostic_id = $oid ";}
					if ($mode == 'DR') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE racine_id = $oid)";}
					if ($mode == 'LS') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE $section_id = $oid)";}
					if ($mode == 'C*') {$diag_select = "diagnostic_id IN (SELECT oid FROM pmsi.t_diagnostics WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
					

					
				}
				else {
					$diag_select = " diagnostic_id IS DISTINCT FROM diagnostic_id";
				}
				
				return $diag_select;
					
				
			EVAL]]]></value>
		</PROPERTY>
	</VIEWPROPERTIES>
	
	<SELECTIONS label="Paramètres de l'analyse" displayText="= var display:String = '';
					if (SELECT.DIAG  != '-1') {
						display = display + '#B#Analyse diagnostics#/B# : ' + SELECT.T_DIAG_LABEL + ' : #B#' + SELECT.DIAG_LABEL + '#/B#';
					}
					display = display + ' (Cette étude s appuie uniquement sur les sévérités des CMA sans tenir compte du groupeur)';
					
					return display;
					">
		<GROUP label="Date sortie">
			<FIELD name="ALIAS_PERIODE" label="" UI="combo" width="220" default="CUM_LAST_MONTH" tree="true" globalListProvider="ALIAS_PERIODE" />
			<FIELD name="PERIODE" label="" UI="combo" tree="true" width="200" default="2014-01-01" globalListProvider="DATE_DEBUT" printable="false" >
			</FIELD>
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2014-12-31"  globalListProvider="DATE_FIN" printable="false">
			</FIELD>
		</GROUP>
		<GROUP label="Diagnostic (CMA) analysé">
			<FIELD name="DIAG" label="" UI="combo" tree="true" width="400" default="" globalListProvider="DIAG" >
			</FIELD>
		</GROUP>
	</SELECTIONS>
		
	<SELECTIONS componentName="FILTRES_RSS_SELECTIONS" />

	<QUERIES>
		<QUERY label=""> 
			<SQL optimizer="V_RSS_X">
				<select><![CDATA[ 
					
					DROP TABLE IF EXISTS w_analyse;
					CREATE TEMP TABLE w_analyse AS
					SELECT
						rss_id AS anz_rss_id,
						date_sortie AS anz_date_sortie,	
						date_sortie - date_entree AS anz_duree_sejour,
						ghm_id AS anz_ghm_id,
						ghm_code AS anz_ghm_code,
						ghs_id AS anz_ghs_id,
						ghs_code AS anz_ghs_code,
						0::numeric AS coefficient_mco,

						'0'::text AS anz_max_diag_severite,
						0::numeric AS anz_montant_ghs,
						0::numeric AS anz_prix_unitaire,
						
						ghm_id AS anz_ghm_id_sans,
						ghm_code AS anz_ghm_code_sans,
						ghs_id AS anz_ghs_id_sans,
						ghs_code AS anz_ghs_code_sans,
						0::numeric AS anz_montant_ghs_sans,
						'0'::text AS anz_max_diag_severite_sans,
						0::numeric AS anz_prix_unitaire_sans,
						0::numeric AS anz_borne_basse_sans,
						0::numeric AS anz_forfait_exb_sans,
						0::numeric AS anz_tarif_exb_sans,
						''::text AS anz_cma
					FROM 
						#V_RSS_X#
					WHERE 
						mois_sortie IN ([VIEW.PERIODE_MOIS_LIST]) 
						AND date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.FILTRE_RSS_SELECT]
						[VIEW.FILTRE_DIAG_RSS_SELECT]
							
					;



					CREATE INDEX w_analyse_i1 ON w_analyse USING btree (anz_rss_id);



					UPDATE w_analyse
					SET anz_montant_ghs = subview.montant_ghs, anz_prix_unitaire = subview.prix_unitaire, coefficient_mco = subview.coefficient_mco
					FROM (
						SELECT
							rss_id,
							SUM(base_remboursement) AS montant_ghs,
							MAX(CASE WHEN p_rsf_detail.coefficient_mco <> 0 THEN p_rsf_detail.coefficient_mco ELSE 1 END) AS coefficient_mco,
							SUM(prix_unitaire) AS prix_unitaire
						FROM pmsi.p_rsf_detail
						JOIN pmsi.t_prestations ON t_prestations.oid = prestation_id AND t_prestations.code = 'GHS'
						JOIN w_analyse ON anz_rss_id = rss_id
						WHERE est_ligne_rss = '1'
						GROUP BY 1
					) subview
					WHERE rss_id = anz_rss_id;


					UPDATE w_analyse
					SET anz_max_diag_severite = subview.diagnostic_severite_code, anz_max_diag_severite_sans = subview.diagnostic_severite_code_sans, anz_cma = subview.cma
					FROM (
						SELECT
							rss_id,
							MAX(
								CASE 
								WHEN anz_date_sortie < '20100301' THEN
									CASE WHEN type_diagnostic_rss IN ('DA', 'DS') AND diagnostic_severite_fg11_code IN ('2', '3', '4') THEN diagnostic_severite_fg11_code ELSE '1' END
								WHEN anz_date_sortie < '20110301' THEN
									CASE WHEN type_diagnostic_rss IN ('DA', 'DS') AND diagnostic_severite_fg12_code IN ('2', '3', '4') THEN diagnostic_severite_fg12_code ELSE '1' END
								WHEN anz_date_sortie < '20120301' THEN
									CASE WHEN type_diagnostic_rss IN ('DA', 'DS') AND diagnostic_severite_fg13_code IN ('2', '3', '4') THEN diagnostic_severite_fg13_code ELSE '1' END
								WHEN anz_date_sortie < '20130301' THEN
									CASE WHEN type_diagnostic_rss IN ('DA', 'DS') AND diagnostic_severite_fg1311d_code IN ('2', '3', '4') THEN diagnostic_severite_fg1311d_code ELSE '1' END
								ELSE
									CASE WHEN type_diagnostic_rss IN ('DA', 'DS') AND diagnostic_severite_fg1311e_code IN ('2', '3', '4') THEN diagnostic_severite_fg1311e_code ELSE '1' END
								END) AS diagnostic_severite_code,

							MAX(
								CASE 
								WHEN [VIEW.FILTRE_DIAG_SELECT] THEN '1'
								WHEN anz_date_sortie < '20100301' THEN
									CASE WHEN type_diagnostic_rss IN ('DA', 'DS') AND diagnostic_severite_fg11_code IN ('2', '3', '4') THEN diagnostic_severite_fg11_code ELSE '1' END
								WHEN anz_date_sortie < '20110301' THEN
									CASE WHEN type_diagnostic_rss IN ('DA', 'DS') AND diagnostic_severite_fg12_code IN ('2', '3', '4') THEN diagnostic_severite_fg12_code ELSE '1' END
								WHEN anz_date_sortie < '20120301' THEN
									CASE WHEN type_diagnostic_rss IN ('DA', 'DS') AND diagnostic_severite_fg13_code IN ('2', '3', '4') THEN diagnostic_severite_fg13_code ELSE '1' END
								WHEN anz_date_sortie < '20130301' THEN
									CASE WHEN type_diagnostic_rss IN ('DA', 'DS') AND diagnostic_severite_fg1311d_code IN ('2', '3', '4') THEN diagnostic_severite_fg1311d_code ELSE '1' END
								ELSE
									CASE WHEN type_diagnostic_rss IN ('DA', 'DS') AND diagnostic_severite_fg1311e_code IN ('2', '3', '4') THEN diagnostic_severite_fg1311e_code ELSE '1' END
								END) AS diagnostic_severite_code_sans,
							base.cti_group_concat_without_sep(DISTINCT CASE WHEN [VIEW.FILTRE_DIAG_SELECT] THEN diagnostic_code || ' ' ELSE '' END) AS cma
						FROM pmsi.v_rss_diagnostics_1
						JOIN w_analyse ON anz_rss_id = rss_id
						WHERE type_diagnostic_rss IN ('DA', 'DS')
						GROUP BY 1
					) subview
					WHERE rss_id = anz_rss_id;


					UPDATE w_analyse 
					SET anz_ghm_code_sans = substr(anz_ghm_code,1,5) || anz_max_diag_severite_sans, anz_ghs_code_sans = 0, anz_ghs_id_sans = 0
					WHERE anz_max_diag_severite > anz_max_diag_severite_sans AND substr(anz_ghm_code,6,6) = anz_max_diag_severite;


					UPDATE w_analyse 
					SET anz_ghm_id_sans = t_ghm_c.oid
					FROM pmsi.t_ghm_c
					WHERE anz_ghm_code_sans = t_ghm_c.code AND anz_ghm_id_sans IS DISTINCT FROM t_ghm_c.oid;


					DROP TABLE IF EXISTS w_ghm_ghs;
					CREATE TEMP TABLE w_ghm_ghs AS
					SELECT ghm_id, (MAX(Array[nb,ghs_id]))[2] AS ghs_id
					FROM
					(
					SELECT ghm_id, ghs_id, count(*) AS nb
					FROM pmsi.p_rss
					GROUP BY 1,2
					)
					subview
					GROUP BY 1;

					
					UPDATE w_analyse 
					SET anz_ghs_id_sans = w_ghm_ghs.ghs_id, anz_ghs_code_sans = t_ghs.code
					FROM w_ghm_ghs 
					JOIN pmsi.t_ghs ON w_ghm_ghs.ghs_id = t_ghs.oid
					WHERE w_analyse.anz_ghm_id_sans = w_ghm_ghs.ghm_id AND 
						anz_ghs_id_sans = 0 ;


					UPDATE w_analyse 
					SET anz_ghs_id_sans = t_ghs.oid, anz_ghs_code_sans = t_ghs.code
					FROM pmsi.t_ghs
					WHERE w_analyse.anz_ghm_id_sans = t_ghs.ghm_id AND 
						anz_ghs_id_sans = 0 ;



					UPDATE w_analyse 
					SET 
						anz_prix_unitaire_sans = 
							CASE 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_1 AND anz_date_sortie <= t_ghs.date_fin_prive_1 THEN t_ghs.tarif_ghs_prive_1 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_2 AND anz_date_sortie <= t_ghs.date_fin_prive_2 THEN t_ghs.tarif_ghs_prive_2 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_3 AND anz_date_sortie <= t_ghs.date_fin_prive_3 THEN t_ghs.tarif_ghs_prive_3 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_4 AND anz_date_sortie <= t_ghs.date_fin_prive_4 THEN t_ghs.tarif_ghs_prive_4 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_5 AND anz_date_sortie <= t_ghs.date_fin_prive_5 THEN t_ghs.tarif_ghs_prive_5 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_6 AND anz_date_sortie <= t_ghs.date_fin_prive_6 THEN t_ghs.tarif_ghs_prive_6 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_7 AND anz_date_sortie <= t_ghs.date_fin_prive_7 THEN t_ghs.tarif_ghs_prive_7 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_8 AND anz_date_sortie <= t_ghs.date_fin_prive_8 THEN t_ghs.tarif_ghs_prive_8 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_9 AND anz_date_sortie <= t_ghs.date_fin_prive_9 THEN t_ghs.tarif_ghs_prive_9 
							ELSE 0::numeric 
							END * coefficient_mco,
						anz_borne_basse_sans = 
							CASE 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_1 AND anz_date_sortie <= t_ghs.date_fin_prive_1 THEN t_ghs.borne_basse_prive_1 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_2 AND anz_date_sortie <= t_ghs.date_fin_prive_2 THEN t_ghs.borne_basse_prive_2 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_3 AND anz_date_sortie <= t_ghs.date_fin_prive_3 THEN t_ghs.borne_basse_prive_3 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_4 AND anz_date_sortie <= t_ghs.date_fin_prive_4 THEN t_ghs.borne_basse_prive_4 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_5 AND anz_date_sortie <= t_ghs.date_fin_prive_5 THEN t_ghs.borne_basse_prive_5 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_6 AND anz_date_sortie <= t_ghs.date_fin_prive_6 THEN t_ghs.borne_basse_prive_6 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_7 AND anz_date_sortie <= t_ghs.date_fin_prive_7 THEN t_ghs.borne_basse_prive_7 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_8 AND anz_date_sortie <= t_ghs.date_fin_prive_8 THEN t_ghs.borne_basse_prive_8 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_9 AND anz_date_sortie <= t_ghs.date_fin_prive_9 THEN t_ghs.borne_basse_prive_9 
							ELSE 0::numeric 
							END,
						anz_forfait_exb_sans = 
							CASE 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_1 AND anz_date_sortie <= t_ghs.date_fin_prive_1 THEN t_ghs.forfait_exb_prive_1 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_2 AND anz_date_sortie <= t_ghs.date_fin_prive_2 THEN t_ghs.forfait_exb_prive_2 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_3 AND anz_date_sortie <= t_ghs.date_fin_prive_3 THEN t_ghs.forfait_exb_prive_3 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_4 AND anz_date_sortie <= t_ghs.date_fin_prive_4 THEN t_ghs.forfait_exb_prive_4 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_5 AND anz_date_sortie <= t_ghs.date_fin_prive_5 THEN t_ghs.forfait_exb_prive_5 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_6 AND anz_date_sortie <= t_ghs.date_fin_prive_6 THEN t_ghs.forfait_exb_prive_6 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_7 AND anz_date_sortie <= t_ghs.date_fin_prive_7 THEN t_ghs.forfait_exb_prive_7 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_8 AND anz_date_sortie <= t_ghs.date_fin_prive_8 THEN t_ghs.forfait_exb_prive_8 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_9 AND anz_date_sortie <= t_ghs.date_fin_prive_9 THEN t_ghs.forfait_exb_prive_9 
							ELSE 0::numeric 
							END * coefficient_mco,
						anz_tarif_exb_sans = 
							CASE 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_1 AND anz_date_sortie <= t_ghs.date_fin_prive_1 THEN t_ghs.tarif_exb_prive_1 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_2 AND anz_date_sortie <= t_ghs.date_fin_prive_2 THEN t_ghs.tarif_exb_prive_2 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_3 AND anz_date_sortie <= t_ghs.date_fin_prive_3 THEN t_ghs.tarif_exb_prive_3 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_4 AND anz_date_sortie <= t_ghs.date_fin_prive_4 THEN t_ghs.tarif_exb_prive_4 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_5 AND anz_date_sortie <= t_ghs.date_fin_prive_5 THEN t_ghs.tarif_exb_prive_5 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_6 AND anz_date_sortie <= t_ghs.date_fin_prive_6 THEN t_ghs.tarif_exb_prive_6 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_7 AND anz_date_sortie <= t_ghs.date_fin_prive_7 THEN t_ghs.tarif_exb_prive_7 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_8 AND anz_date_sortie <= t_ghs.date_fin_prive_8 THEN t_ghs.tarif_exb_prive_8 
							WHEN anz_date_sortie >= t_ghs.date_debut_prive_9 AND anz_date_sortie <= t_ghs.date_fin_prive_9 THEN t_ghs.tarif_exb_prive_9 
							ELSE 0::numeric 
							END * coefficient_mco
					FROM pmsi.t_ghs
					WHERE w_analyse.anz_ghs_id_sans = t_ghs.oid AND  anz_ghm_code <> anz_ghm_code_sans ;



					UPDATE w_analyse
					SET anz_montant_ghs_sans = CASE WHEN anz_montant_ghs <> 0 AND anz_ghm_code <> anz_ghm_code_sans THEN anz_prix_unitaire_sans ELSE anz_montant_ghs END;

					UPDATE w_analyse
					SET anz_montant_ghs_sans =
						CASE 
							WHEN anz_forfait_exb_sans <> 0 THEN anz_montant_ghs_sans - anz_forfait_exb_sans
							WHEN anz_tarif_exb_sans <> 0 AND anz_duree_sejour = 0 THEN round(anz_tarif_exb_sans / 2,2)
							WHEN anz_tarif_exb_sans <> 0 THEN anz_tarif_exb_sans - ((anz_borne_basse_sans - anz_duree_sejour) * anz_tarif_exb_sans)
							ELSE anz_montant_ghs_sans END
					WHERE anz_ghm_code <> anz_ghm_code_sans AND anz_duree_sejour < anz_borne_basse_sans AND
						anz_montant_ghs_sans <> 0;
						
					
					
				]]></select>
				
			</SQL>
			<SQL optimizer="V_RSS_X">
				<select><![CDATA[ 
				
				
				
				(
					SELECT 
						v_rss_1.rss_id,
						v_rss_1.no_rss,
						v_rss_1.en_cours_texte_tres_court,
						CASE WHEN patient_no_patient > 0 THEN patient_no_patient ELSE 0 END,
						v_rss_1.no_sejour_administratif,
						v_rss_1.finess,
						identite_nom || ' ' || identite_prenom,
						ghm_code,
						severite_ghm_code,
						ghs_code,
						ghm_texte,
						medecin_reference_rss_nom,
						diagnostic_principal_code,
						unite_medicale_principale_code,
						acte_principal_code,
						date_entree,
						date_sortie,
						mode_sortie,
						sexe_texte_court,
						age,
						anz_cma,
						anz_ghm_code_sans,
						CASE WHEN anz_ghm_code_sans <> anz_ghm_code THEN substr(anz_ghm_code_sans,6,1) || '->' || substr(anz_ghm_code,6,1) ELSE '' END,
						anz_montant_ghs AS montant_ghs,
						anz_montant_ghs_sans AS montant_ghs_sans,
						round(anz_montant_ghs - anz_montant_ghs_sans,2) AS ecart_ghs
					FROM 
						 #V_RSS_X#
						JOIN w_analyse ON v_rss_1.rss_id = w_analyse.anz_rss_id
				)
				UNION ALL
				(
					SELECT 
						-9999999, 
						COUNT(DISTINCT v_rss_1.no_rss), 
						'',
						0,
						'',
						'', 
						SUM(nb_rsa)::text || ' séjours, ' || SUM(CASE WHEN anz_ghm_code IS DISTINCT FROM anz_ghm_code_sans THEN 1 ELSE 0 END)::text || ' impactés' , 
						'',
						'',
						'',
						'',
						'',
						'',
						'',
						'', 
						null,
						null,
						'',
						'',
						0, 
						'',
						'',
						'',
						SUM(anz_montant_ghs) AS montant_ghs,
						SUM(anz_montant_ghs_sans) AS montant_ghs_sans,
						SUM(anz_montant_ghs - anz_montant_ghs_sans) AS ecart_ghs
					FROM #V_RSS_X#
						JOIN w_analyse ON v_rss_1.rss_id = w_analyse.anz_rss_id
					
				)
				ORDER BY 2
				;
				
				]]></select>
				<FIELDS>
					<FIELD name="OID" />
					<FIELD name="RSS" />
					<FIELD name="EXP" />
					<FIELD name="PAT" />
					<FIELD name="SEJ" />
					<FIELD name="FIN" />
					<FIELD name="NOM"  ifHideNames="Non autorisé"/>
					<FIELD name="GHM" />
					<FIELD name="SEV" />
					<FIELD name="GHS" />
					<FIELD name="GHMT" />
					<FIELD name="MED" />
					<FIELD name="DIAGP" />
					<FIELD name="UMP" />
					<FIELD name="ACTEP" />
					<FIELD name="DATE" />
					<FIELD name="DATS" />
					<FIELD name="MODS" />
					<FIELD name="SEX" />
					<FIELD name="AGE" />
					<FIELD name="CMA" />
					<FIELD name="GHMS" />
					<FIELD name="SEVE" />
					<FIELD name="MGHS" />
					<FIELD name="MGHSS" />
					<FIELD name="MGHSE" />
				</FIELDS>
			</SQL>
			
			
		</QUERY>
		
		
		
	</QUERIES>
	
	<PRESENTATION>
	
		<VIEWLINKS>
			
			<VIEWLINK label="Détail RSS" shortLabel="Détail RSS" view="PMSI000006.XML">
				<ARG name="OID" value="ROW.OID" />
			</VIEWLINK>
			
			<VIEWLINKx label="Créer un extrait de base" shortLabel="Extrait de base" view="PMSI002705.XML" rowContext="false">

			</VIEWLINKx>


		</VIEWLINKS>
	
		<ONGLET excelLabel="Liste RSS" >
				
			<DATAGRID title="" total="true" key="RSS" headerHeight="48"  
				totalRowInRows="= ROW.OID == '-9999999'"
			>
				<ROWSTYLE name="fontSize" value="11" />
				<FOOTERROWSTYLE name="fontSize" value="11" />
				<COLUMN dataField="OID"
					type="Char"
					visible="false">
				</COLUMN>
				<COLUMN dataField="FIN"
					width="60"
					type="Char"
					visible="true"
					headerText="Etablissement" 
					textAlign="left" 
					visibleCondition="ENV.CONSOLIDATION == '1'"
					otherFunction="text"
					totalFunction="text" 
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="RSS"
					width="70"
					type="Number"
					visible="true"
					outputFormat="#"
					headerText="N° RSS" 
					textAlign="center" 
					otherFunction="text"
					totalFunction="text" 
					totalComplement="TOTAL">
				</COLUMN>
				<COLUMNx dataField="PAT"
					width="60"
					type="Number"
					visible="true"
					outputFormat="#"
					headerText="N° Patient" 
					textAlign="center" 
					otherFunction="text"
					totalFunction="text" 
					totalComplement="">
				</COLUMNx>
				<COLUMN dataField="SEJ"
					width="80"
					type="Char"
					visible="true"
					outputFormat="#"
					headerText="N° séjour" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text" 
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="NOM"
					minWidth="180"
					maxWidth="230"
					type="Char"
					visible="true"
					headerText="Nom" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text"
					totalComplement="*ROW">
				</COLUMN>
				<COLUMN dataField="SEX"
					width="40"
					type="Char"
					visible="true"
					headerText="Sexe" 
					fixed="false"
					textAlign="right" 
					otherFunction="text"
					totalFunction="text">
					<CELLSTYLE name="cellIndicator" value="femme, 12,left middle , 0xEB76B1" condition="ROW.SEX == 'F'" /> 
					<CELLSTYLE name="cellIndicator" value="homme, 12,left middle , 0x75a0eb " condition="ROW.SEX == 'M'" /> 
					<CELLSTYLE name="cellIndicator" value="rectangle, 10,left middle , #FF5001 " condition="ROW.SEX == 'I'" /> 
					<CELLSTYLE name="cellIndicator" value="rectangle, 10, left middle, 0x666666" condition="ROW.SEX != 'F' &amp;&amp; ROW.SEX != 'M' &amp;&amp; ROW.SEX != 'I'" />
				</COLUMN>
				
				<COLUMN dataField="AGE"
					width="40"
					type="Number"
					outputFormat="#"
					fixed="false"
					visible="true"
					headerText="Age" 
					textAlign="right" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				
				<COLUMN dataField="DATE"
					width="60"
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YY"
					visible="true"
					fixed="false"
					headerText="Date entrée" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DATS"
					width="60"
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YY"
					visible="true"
					fixed="false"
					headerText="Date sortie" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				<COLUMN dataField="MODS"
					width="45"
					type="Char"
					visible="true"
					fixed="false"
					headerText="Mode sortie" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				<COLUMN dataField="EXP"
					width="30"
					type="Char"
					visible="true"
					fixed="false"
					headerText="EXP" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				<COLUMN dataField="GHM"
					width="55"
					type="Char"
					visible="true"
					fixed="false"
					headerText="GHM" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				<COLUMN dataField="GHMT"
					minWidth="80"
					type="Char"
					visible="true"
					headerText="GHM" 
					textAlign="left" 
					fixed="false"
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				
				<COLUMN dataField="GHS"
					width="40"
					type="Char"
					visible="true"
					fixed="false"
					headerText="GHS" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				
				<COLUMN dataField="MED"
					minWidth="60"
					maxWidth="150"
					type="Char"
					visible="true"
					fixed="false"
					headerText="Médecin" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				
				<COLUMN dataField="DIAGP"
					width="50"
					type="Char"
					fixed="false"
					visible="true"
					headerText="Diag P" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				<COLUMN dataField="ACTEP"
					width="60"
					type="Char"
					fixed="false"
					visible="true"
					headerText="Acte P" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				<COLUMN dataField="CMA"
					width="55"
					type="Char"
					visible="true"
					fixed="false"
					headerText="CMA" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				<COLUMN dataField="GHMS"
					width="55"
					type="Char"
					visible="true"
					fixed="false"
					headerText="GHM sans CMA" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				<COLUMN dataField="SEVE"
					width="55"
					type="Char"
					visible="true"
					fixed="false"
					headerText="Impact Sévérité" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				
				<COLUMN dataField="MGHS" width="80" type="Number" outputFormat="#E"  headerText="Montant GHS facturé" textAlign="right" totalFunction="sum" otherFunction="sum" />
				<COLUMN dataField="MGHSS" width="80" type="Number" outputFormat="#E"  headerText="Montant GHS sans la CMA" textAlign="right" totalFunction="sum" otherFunction="sum" />
				<COLUMN dataField="MGHSE" width="80" type="Number" outputFormat="#E"  headerText="Impact financier CMA" textAlign="right" totalFunction="sum" otherFunction="sum" />
				
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>

			
