<?xml version="1.0" encoding="ISO-8859-15"?>
<VUE name="PMSI000149" label="PMSI. Justificatif UCD par RSS" title="= 'Justificatif UCD par RSS (' + SELECT.QUELLEDATE_LABEL + ' : ' +  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" helpDokuWIkiDir="pmsi:sejour_analyse_detaillee:ucd" helpDokuWIkiFile="pmsi000146"  helpFile="iCTI_PMSI_PMSI000149.HTML">
	<VIEWPROPERTIES componentName="PROPERTIES_UCD" />
	<SELECTIONS label="Paramètres de l'analyse">
		<GROUP label="Période">
			<FIELD name="QUELLEDATE" label="" UI="combo" default="1" default2="date_fin" printable="false">
				<OPTION label="Date sortie" data="1" data2="date_sortie" />
				<OPTION label="Date ucd" data="2" data2="date_ucd" />
			</FIELD>
			<FIELD name="ALIAS_PERIODE" label="" UI="combo" width="220" default="CUM_LAST_MONTH" tree="true" globalListProvider="ALIAS_PERIODE" />
			<FIELD name="PERIODE" label="de" UI="combo" tree="true" width="200" default="2014-01-01" default2="201401" printable="false" globalListProvider="DATE_DEBUT" />
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2014-12-31" default2="201412" printable="false" globalListProvider="DATE_FIN" />
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_UCD_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::text || ' '::text || identite_prenom::text,
						v_rss_1.date_naissance,
						v_rss_1.date_entree,
						v_rss_1.date_sortie,
						date_ucd, 
						ucd_code, 
						ucd_texte, 
						nombre, 
						prix_unitaire, 
						montant_facture,
						montant_ecart_indemnisable,
						prix_unitaire_tr, 
						montant_tr,
						montant_t2a_accorde,
						CASE WHEN v_rss_ucd_1.type_ucd_code = 'SUS' THEN montant_t2a_accorde - montant_facture ELSE NULL END,
                        v_rss_ucd_1.type_ucd_code as type_ucd,
                        v_rss_ucd_1.coefficient_fractionnement,
                        v_rss_ucd_1.coefficient_fractionnement * v_rss_ucd_1.nombre,
                        v_rss_ucd_1.indication_code

					FROM #V_RSS_X#
					JOIN pmsi.v_rss_ucd_1 ON v_rss_1.rss_id = v_rss_ucd_1.rss_id 
					WHERE 
						[VIEW.QUELLEDATE] BETWEEN '[PERIODE]' AND '[TOPERIODE]'
					
						[VIEW.UCD_SELECT]
						[VIEW.FILTRE_RSS_SELECT]
					)
					
					UNION ALL
					
					(SELECT 
					
						-9999999, 
						COUNT(DISTINCT v_rss_1.no_sejour_administratif), 
						'', 
						'', 
						COUNT(DISTINCT v_rss_ucd_1.rss_id)::text || ' séjours,  '::text || COUNT(DISTINCT v_rss_1.patient_id)::text || ' patients'::text, 
						null, 
						null, 
						null, 
						null, 
						'', 
						COUNT(DISTINCT v_rss_ucd_1.ucd_id)::text || ' codes'::text, 
						sum(nombre), 
						0, 
						sum(montant_facture),
						sum(montant_ecart_indemnisable),
						0,
						sum(montant_tr),
						sum(montant_t2a_accorde),
						sum(CASE WHEN v_rss_ucd_1.type_ucd_code = 'SUS' THEN montant_t2a_accorde ELSE NULL END) - sum(CASE WHEN v_rss_ucd_1.type_ucd_code = 'SUS' THEN montant_facture ELSE NULL END),
                        ''::text as typ_ucd,
                        sum(v_rss_ucd_1.coefficient_fractionnement),
                        sum(v_rss_ucd_1.coefficient_fractionnement * v_rss_ucd_1.nombre),
                        COUNT(DISTINCT v_rss_ucd_1.indication_id)::text

					FROM #V_RSS_X#
					JOIN pmsi.v_rss_ucd_1 ON v_rss_1.rss_id = v_rss_ucd_1.rss_id 
					WHERE 
						[VIEW.QUELLEDATE] BETWEEN '[PERIODE]' AND '[TOPERIODE]'
					
						[VIEW.UCD_SELECT]
						[VIEW.FILTRE_RSS_SELECT]
					)
						
					ORDER BY 2, 5
				]]></select>
				<FIELDS>
					<FIELD name="OID" />
					<FIELD name="RSS" />
					<FIELD name="SEJ" />
					<FIELD name="FIN" />
					<FIELD name="NOM" ifHideNames="Non autorisé" />
					<FIELD name="DNA"/>
					<FIELD name="DEN"/>
					<FIELD name="DSO"/>
					<FIELD name="DAT" />
					<FIELD name="COD" />
					<FIELD name="TXT" />
					<FIELD name="NB" />
					<FIELD name="PU" />
					<FIELD name="MF" />
					<FIELD name="MEMI" />
					<FIELD name="PTR" />
					<FIELD name="MTR" />
					<FIELD name="MTA" />
					<FIELD name="MTE" />
					<FIELD name="TUCD" />
					<FIELD name="FRAC" />
					<FIELD name="QTE" />
					<FIELD name="IND" />
				</FIELDS>
			</SQL>
		</QUERY>
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forRows="false" />
	</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="Justificatif UCD" label="Justificatif UCD">
			<DATAGRID title="" total="true" showOthers="false" key="RSS" headerHeight="48" totalRowInRows="= ROW.OID == '-9999999'">
				<COLUMN dataField="OID" type="Char" visible="false" />
				<COLUMN dataField="FIN" width="60" type="Char" visible="true" headerText="Etablissement" textAlign="left" visibleCondition="ENV.CONSOLIDATION == '1'" otherFunction="text" totalFunction="text" totalComplement="" />
				<COLUMN dataField="RSS" width="60" type="Char" visible="true" headerText="N° RSS" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="TOTAL" />
				<COLUMN dataField="SEJ" width="90" type="Char" visible="true" outputFormat="#" headerText="N° séjour" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="" />
				<COLUMN dataField="DEN" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" visible="true" headerText="Date&#xD;Entrée" width="60" textAlign="left"/>
				<COLUMN dataField="DSO" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" visible="true" headerText="Date&#xD;Sortie" width="60" textAlign="left"/>
				<COLUMN dataField="NOM" minWidth="150" type="Char" visible="true" headerText="Nom" textAlign="left" totalFunction="text" totalComplement="*ROW" />
				<COLUMN dataField="DNA" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" visible="true" headerText="Date&#xD;Naissance" width="75" textAlign="left"/>
				<COLUMN dataField="COD" type="Char" visibleCondition="SELECT.UCD == '-1' || SELECT.UCD.toString().substr(0,2) == 'LI'" headerText="Code&#xD;UCD" width="60" textAlign="left" />
				<COLUMN dataField="TXT" type="Char" visibleCondition="SELECT.UCD == '-1' || SELECT.UCD.toString().substr(0,2) == 'LI'" headerText="Libellé&#xD;UCD" minWidth="100" textAlign="left" totalFunction="text" totalComplement="*ROW" />
				<COLUMN dataField="DAT" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" visible="true" headerText="Date&#xD;UCD" width="60" textAlign="left" />
				<COLUMN dataField="NB" type="Number" visible="true" outputFormat="#,000" headerText="Nombre" width="60" textAlign="left" totalFunction="sum" />
				<COLUMN dataField="FRAC" type="Number" visible="true" outputFormat="#,000" headerText="Coeff.&#xD;Frac." width="60" textAlign="left" totalFunction="sum" />
				<COLUMN dataField="QTE" type="Number" visible="true" outputFormat="#,000" headerText="Quantité" width="60" textAlign="left" totalFunction="sum"
                    description="Produit des colonnes &lt;b&gt;Nombre&lt;/b&gt; et &lt;b&gt;Coef. Frac.&lt;/b&gt;" />
				<COLUMN dataField="TUCD" type="Char" visible="true" headerText="Type&#xD;UCD" width="60" textAlign="left" totalFunction="text" />
				<COLUMN dataField="IND" type="Char" visible="true" headerText="Indication&#xD;UCD" width="70" textAlign="left" totalFunction="text" />
				<COLUMN dataField="PU" type="Number" visible="true" outputFormat="#,00E" headerText="Prix&#xD;unitaire" width="80" textAlign="left" />
				<COLUMN dataField="MF" type="Number" visible="true" outputFormat="#,00E" headerText="Montant&#xD;facturé" width="100" textAlign="left" totalFunction="sum" />
				<COLUMN dataField="MEMI" type="Number" visibleCondition="ENV.TYPEETS == '1'" outputFormat="#,00E" headerText="Montant&#xD;EMI" width="100" textAlign="left" totalFunction="sum" />
				<COLUMN dataField="PTR" width="80" type="Number" visibleCondition="ENV.TYPEETS == '2' || ENV.TYPEETS == '3'" outputFormat="#,00E" headerText="Prix&#xD;unitaire TR" textAlign="right" />
				<COLUMN dataField="MTR" width="80" type="Number" visibleCondition="ENV.TYPEETS == '2' || ENV.TYPEETS == '3'" outputFormat="#E" headerText="Montant&#xD;TR" textAlign="right" totalFunction="sum" otherFunction="sum" />
				<COLUMN dataField="MTA" width="80" type="Number" visibleCondition="ENV.TYPEETS == '2' || ENV.TYPEETS == '3'" outputFormat="#,00E" headerText="Montant&#xD;T2A" textAlign="right" totalFunction="sum" otherFunction="sum" />
				<COLUMN dataField="MTE" width="80" type="Number" visibleCondition="ENV.TYPEETS == '2' || ENV.TYPEETS == '3'" outputFormat="#,00E" headerText="Ecart&#xD;T2A-Facturé" textAlign="right" totalFunction="sum" otherFunction="sum" />
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
