<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE 
	name="PMSI003598" 
	label="PMSI. Justificatif Simulation FG 2223 SRC éligibles (sans autorisation)" 
	title="= 'SRC éligibles (sans autorisation) en FG 2223 (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ')' " 
	database="iCTI" 
	swf="*CTI_view1" 
	softCode="iCTI_pmsi" 
	typeEts="" 
	globals="PMSI_globals.XML" 
	componentsFile="PMSI_components.XML" 
	helpDokuWIkiDir="" 
	helpDokuWIkiFile="pmsi000038"  
	helpFile="iCTI_PMSI_PMSI000038.HTML"
>
	<VIEWPROPERTIES>
		<PROPERTY name="NO_RSS_SELECT" value="[EVAL 
											if (('[NO_RSS]' + 0) != 0) {return 'AND v_rss_1.no_rss = ' . ('[NO_RSS]' + 0);}
											return '';
										EVAL]" />
		<PROPERTY name="NOM_SELECT" value="[EVAL 
											if ('[NOM]' != '') {return 'AND identite_nom ILIKE ' .''. '[NOM]%' .''.  ' ' ;}
											return '';
										EVAL]" />
	</VIEWPROPERTIES>

	<SELECTIONS label="Paramètres de l'analyse" displayText="Séjours éligibles à une SRC mais sans autorisation de surveillance continue">
		<GROUP label="Période">
			<FIELD name="PERIODE" label="" UI="combo" tree="true" width="200" default="2022-03-01">
				<OPTION dataLink="DATE_DEBUT" treeLevelField="lvl" dataField="cod" aliasField="alias" data2Field="mois" labelField="txt" />
			</FIELD>
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2023-02-28" >
				<OPTION dataLink="DATE_FIN" treeLevelField="lvl" dataField="cod" aliasField="alias" data2Field="mois" labelField="txt" />
			</FIELD>
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_RSS_SELECTIONS"/>
	<QUERIES>
		<QUERY label="">
			<SQL optimizer="V_RSS_X">
				<select><![CDATA[
				(
				SELECT 
					v_rss_1.rss_id, 
					v_rss_1.no_rss, 
					v_rss_1.no_sejour_administratif, 
					v_rss_1.finess,
					identite_nom || ' ' || identite_prenom,
					sexe, 
					age, 
					date_sortie, 
					duree_sejour,
					diagnostic_principal_code,
					t_ghm_fg0.code,
					t_ghs_fg0.code,
					ghm_fg1_code,
					ghs_fg1_code,
					regle_src_eligible_fg1
				FROM 
					#V_RSS_X#, 
					pmsi.p_simulation_fg2223, 
					pmsi.t_ghm t_ghm_fg0, 
					pmsi.t_ghs t_ghs_fg0
				WHERE
					date_sortie >= '[PERIODE]'	
					AND date_sortie <='[TOPERIODE]'
					AND p_simulation_fg2223.rss_id = v_rss_1.rss_id
					AND p_simulation_fg2223.ghm_fg0_id = t_ghm_fg0.oid
					AND p_simulation_fg2223.ghs_fg0_id = t_ghs_fg0.oid
					AND p_simulation_fg2223.est_regroupe = '1'
					AND p_simulation_fg2223.nb_sej_src_eligibles_fg1 > 0
					[VIEW.FILTRE_RSS_SELECT]
				)
				UNION ALL
				(
				SELECT 
					-9999999, 
					0, 
					'', 
					'',
					SUM(nb_rsa)::text || ' séjours' ,
					'', 
					0, 
					null,
					0,
					'',
					'', 
					0,
					'', 
					0, 
					''
				FROM 
					#V_RSS_X#, 
					pmsi.p_simulation_fg2223
				WHERE 1=1
					AND date_sortie >= '[PERIODE]'	
					AND date_sortie <='[TOPERIODE]'
					AND p_simulation_fg2223.rss_id = v_rss_1.rss_id
					AND p_simulation_fg2223.nb_sej_src_eligibles_fg1 > 0
					AND p_simulation_fg2223.est_regroupe = '1'
					[VIEW.FILTRE_RSS_SELECT]
				)
				ORDER BY 2
				;
				]]></select>
				<FIELDS>
					<FIELD name="OID"/>
					<FIELD name="RSS"/>
					<FIELD name="SEJ"/>
					<FIELD name="FIN"/>
					<FIELD name="NOM" ifHideNames="Non autorisé"/>
					<FIELD name="SEX"/>
					<FIELD name="AGE"/>
					<FIELD name="DATE"/>
					<FIELD name="NBJ"/>
					<FIELD name="DP"/>
					<FIELD name="GHM12"/>
					<FIELD name="GHS12"/>
					<FIELD name="GHM13"/>
					<FIELD name="GHS13"/>
					<FIELD name="REGLE"/>
				</FIELDS>
			</SQL>
		</QUERY>
        <QUERY type="comboLink" name="DATE_DEBUT" > 
            <SQL select="SELECT date, alias, texte, mois, level 
				FROM pmsi.v_calendrier_1 
				WHERE date_part('year',date) IN (SELECT annee_sortie FROM pmsi.p_simulation_fg2223 WHERE est_envoye &lt;&gt; '0' GROUP BY 1)" >
                <FIELDS>
                    <FIELD name="cod" />
                    <FIELD name="alias" />
                    <FIELD name="txt" />
                    <FIELD name="mois" />
                    <FIELD name="lvl" />
                </FIELDS>
            </SQL>
        </QUERY>
        <QUERY type="comboLink" name="DATE_FIN" > 
            <SQL select="SELECT date, alias, texte, mois, level 
				FROM pmsi.v_calendrier_2 
				WHERE date_part('year',date) IN (SELECT annee_sortie FROM pmsi.p_simulation_fg2223 WHERE est_envoye &lt;&gt; '0' GROUP BY 1)" >
                <FIELDS>
                    <FIELD name="cod" />
                    <FIELD name="alias" />
                    <FIELD name="txt" />
                    <FIELD name="mois" />
                    <FIELD name="lvl" />
                </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>
		</VIEWLINKS>
		<ONGLET excelLabel="Simulation FG13">
			<DATAGRID title="" total="true" key="RSS" headerHeight="36" 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="60" type="Char" visible="true" headerText="N° RSS" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="TOTAL">
				</COLUMN>
				<COLUMN dataField="SEJ" width="90" type="Char" visible="true" outputFormat="#" headerText="N° séjour" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="">
				</COLUMN>
				<COLUMN dataField="NOM" minWidth="100" 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" textAlign="right" otherFunction="text" totalFunction="text">
					<CELLSTYLE name="cellIndicator" value="femme, 12,left middle , 0xEB76B1" condition="ROW.SEX == '2'" /> 
					<CELLSTYLE name="cellIndicator" value="homme, 12,left middle , 0x75a0eb " condition="ROW.SEX == '1'" /> 
					<CELLSTYLE name="cellIndicator" value="rectangle, 10,left middle , #FF5001 " condition="ROW.SEX == '3'" /> 
					<CELLSTYLE name="cellIndicator" value="rectangle, 10, left middle, 0x666666" condition="ROW.SEX != '2' &amp;&amp; ROW.SEX != '1' &amp;&amp; ROW.SEX != '3'" />
				</COLUMN>
				<COLUMN dataField="AGE" width="35" type="Number" outputFormat="#" 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" headerText="Date sortie" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="NBJ" width="40" visible="true" type="Number" outputFormat="#" headerText="Durée sej" fixed="false" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="DP" width="45" type="Char"  fixed="false" visible="true" headerText="DP" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="GHM12" width="45" type="Char"  fixed="false" visible="true" headerText="FG 2022 GHM" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="GHS12" width="40" type="Char" visible="true" headerText="FG 2022 GHS" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="GHM13" width="45" type="Char" visible="true" headerText="FG 2223 GHM" textAlign="left" otherFunction="text" totalFunction="text">
					<HEADERCELLSTYLE name="color" value="0xff5001"/>
					<CELLSTYLE name="color" value="0xff5001"/>
				</COLUMN>
				<COLUMN dataField="GHS13" width="40" type="Char" visible="true" headerText="FG 2223 GHS" textAlign="left" otherFunction="text" totalFunction="text">
					<HEADERCELLSTYLE name="color" value="0xff5001"/>
					<CELLSTYLE name="color" value="0xff5001"/>
				</COLUMN>
				<COLUMN dataField="REGLE" minWidth="100" type="Char" visible="true" headerText="Justificatif" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="*ROW">
				</COLUMN>
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>