<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="PMSI000052" label="PMSI. Justificatif simulation tarif public par RSS" title="= 'Justificatif simulation tarif public par RSS (' + 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"/>
	</VIEWPROPERTIES>
	<SELECTIONS label="Paramètres de l'analyse" displayText="">
		<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>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_RSS_SELECTIONS"/>
	<QUERIES>
		<QUERY label="">
			<SQL optimizer="V_RSS_X" select="
				SELECT v_rss_1.rss_id, v_rss_1.no_rss, v_rss_1.finess, identite_nom || ' ' || identite_prenom, ghm_code, ghs_code, diagnostic_principal_code, 
						date_sortie, sexe, age,
						nb_rsa, 
						view1.montant_ghs_prive,        
						view1.montant_pii_prive,        
						view1.montant_pme_prive, 
						view1.montant_sup_prive, 
						honoraires_factures,
						view2.montant_ghs_public,
						view3.montant_sup_public
				FROM  #V_RSS_X#
					LEFT JOIN (SELECT rss_id, 
						SUM(CASE WHEN prestation_code = 'GHS' OR prestation_code = 'EXH' THEN base_remboursement ELSE 0 END) AS montant_ghs_prive, 
						SUM(CASE WHEN prestation_code = 'PII'  THEN base_remboursement ELSE 0 END) AS montant_pii_prive, 
						SUM(CASE WHEN prestation_code = 'PME'  THEN base_remboursement ELSE 0 END) AS montant_pme_prive, 
						SUM(CASE WHEN prestation_code IN ('NN1', 'NN2', 'NN3', 'REA', 'REP', 'SRA', 'SRC', 'SSC', 'STF', 'REP') THEN base_remboursement ELSE 0 END) AS montant_sup_prive
						FROM pmsi.v_rsf_detail_1 GROUP BY rss_id) AS view1  ON (v_rss_1.rss_id = view1.rss_id)       
					LEFT JOIN (SELECT rss_id, 
						SUM(montant_ghs_public + montant_exh_public) AS montant_ghs_public 
						FROM pmsi.v_rsf_detail_2 GROUP BY rss_id) AS view2  ON (v_rss_1.rss_id = view2.rss_id) 
					LEFT JOIN (SELECT rss_id, 
						SUM(CASE WHEN prestation_code IN ('NN1', 'NN2', 'NN3', 'REA', 'REP', 'SRA', 'SRC', 'SSC', 'STF', 'REP') THEN montant_public ELSE 0 END) AS montant_sup_public
						FROM pmsi.v_rsf_detail_3 GROUP BY rss_id) AS view3  ON (v_rss_1.rss_id = view3.rss_id)  
				WHERE 
					date_sortie BETWEEN '[PERIODE]'	AND '[TOPERIODE]'
					
					[VIEW.FILTRE_RSS_SELECT]
					
					ORDER BY v_rss_1.no_rss
				">
				<FIELDS>
					<FIELD name="OID"/>
					<FIELD name="RSS"/>
					<FIELD name="FIN"/>
					<FIELD name="NOM" ifHideNames="Non autorisé"/>
					<FIELD name="GHM"/>
					<FIELD name="GHS"/>
					<FIELD name="DIAGP"/>
					<FIELD name="DATE"/>
					<FIELD name="SEX"/>
					<FIELD name="AGE"/>
					<FIELD name="NB_RSA"/>
					<FIELD name="PR_GHS"/>
					<FIELD name="PR_PII"/>
					<FIELD name="PR_PME"/>
					<FIELD name="PR_SUP"/>
					<FIELD name="PR_HON"/>
					<FIELD name="PU_GHS"/>
					<FIELD name="PU_SUP"/>
				</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="Liste RSS">
			<DATAGRID title="" total="true" key="RSS" headerHeight="36" printRatio="0.8">
				<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="NOM" minWidth="150" type="Char" visible="true" headerText="Nom" textAlign="left" 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="GHM" width="50" type="Char" visible="true" headerText="GHM" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="GHS" width="40" type="Char" visible="true" headerText="GHS" textAlign="left" otherFunction="text" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="NB_RSA" width="60" type="Number" outputFormat="#" headerText="RSA" textAlign="right" totalFunction="sum" otherFunction="sum" largeSeparator="true">
				</COLUMN>
				<COLUMN dataField="PR_GHS" width="80" type="Number" outputFormat="#E" fixed="false" headerText="(A) Privé   CA GHS" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="PR_SUP" width="80" type="Number" outputFormat="#E" fixed="false" headerText="(B) Privé   CA SUP" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="PR_HON" width="80" type="Number" outputFormat="#E" fixed="false" headerText="(C) Privé   CA HON" textAlign="right" totalFunction="sum" otherFunction="sum" largeSeparator="true">
				</COLUMN>
				<COLUMN dataField="PU_GHS" width="80" type="Number" outputFormat="#E" fixed="false" headerText="(X)   Public CA GHS" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="PU_SUP" width="80" type="Number" outputFormat="#E" fixed="false" headerText="(Y)   Public CA SUP" textAlign="right" totalFunction="sum" otherFunction="sum" largeSeparator="true">
				</COLUMN>
				<COLUMN dataField="PR_TOT" type="Number" headerText="(D) Privé   CA Total (A+B+C)" width="80" outputFormat="#E" fixed="false" textAlign="right" totalFunction="calc" totalComplement="" otherFunction="calc" calc="true">
					<CALC formula="ROW.PR_GHS + ROW.PR_SUP + ROW.PR_HON"/>
				</COLUMN>
				<COLUMN dataField="PU_TOT" type="Number" headerText="(Z) Public   CA Total (X+Y)" width="80" outputFormat="#E" fixed="false" textAlign="right" totalFunction="calc" totalComplement="" otherFunction="calc" calc="true">
					<CALC formula="ROW.PU_GHS + ROW.PU_SUP"/>
				</COLUMN>
				<COLUMN dataField="DIFF" type="Number" headerText="(E) Ecart   (Z-D)" width="80" outputFormat="#E" fixed="false" textAlign="right" totalFunction="calc" totalComplement="" otherFunction="calc" calc="true">
					<CALC formula="ROW.PU_TOT - ROW.PR_TOT"/>
				</COLUMN>
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
