<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="PMSI000381" label="PMSI. Justificatif Impact codage CMA par RSS" title="= 'Impact codage CMA par RSS ' + ' (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ')'" database="iCTI" swf="*CTI_view1" softCode="iCTI_pmsi" globals="PMSI_globals.XML" componentsFile="PMSI_components.XML" helpDokuWIkiDir="pmsi:qualite:etudes" helpDokuWIkiFile="pmsi000381"  helpFile="iCTI_PMSI_PMSI000381.HTML">
    <VIEWPROPERTIES componentName="PROPERTIES_RSS" />
    <SELECTIONS label="Paramètres de l'analyse" displayText="= var display:String = '';
					display += 'Traitement coefficient : #B#' + SELECT.OPTION_COEF_LABEL + '#/B#';
					
					return display;
					">
        <GROUP label="Période">
            <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="2016-01-01" globalListProvider="DATE_DEBUT" />
            <FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2016-12-31" globalListProvider="DATE_FIN" />
        </GROUP>
		<GROUP label="">
            <FIELD name="OPTION_COEF" width="220" label="Coefficient" UI="combo" default="-1" tree="true">
                <OPTION label="Inclure le coefficient mco" data="-1" treeLevel="1" />
                <OPTION label="Ne pas inclure le coefficient mco" data="HC" treeLevel="1" />
            </FIELD>
        </GROUP>
    </SELECTIONS>
    <SELECTIONS componentName="FILTRES_RSS_SELECTIONS" />
    <QUERIES>
        <QUERY label="">
        
            <SQL optimizer="V_RSS_X" cacheEnabled="false">
                <select><![CDATA[ 
                
                -- La table p_etude_impact_cma est alimentée par la fonction pmsi.cti_etude_impact_cma()
				
				
                (
                    SELECT 
                        v_rss_1.rss_id AS OID,
                        v_rss_1.no_rss::text AS NO_RSS,
                        v_rss_1.no_sejour_administratif::text AS NO_SEJOUR,
                        v_rss_1.finess AS FINESS,
                        identite_nom || ' ' || identite_prenom AS PATIENT,
                        p_etude_impact_cma.duree_sejour AS DUR_SEJ,
                        p_etude_impact_cma.ghm_dos AS GHM_DOS,
                        p_etude_impact_cma.ghs_dos::text AS GHS_DOS,
                        p_etude_impact_cma.sev_ghm AS SEV_GHM,
                        p_etude_impact_cma.age AS AGE,
                        p_etude_impact_cma.ghm_age_cma AS GHM_AGE_CMA,
                        
                        round(p_etude_impact_cma.ca_ghs_theorique * CASE WHEN '[OPTION_COEF]' = '-1' THEN coefficient_mco ELSE 1 END,2) AS CA_GHST,
                        round(p_etude_impact_cma.ca_exh * CASE WHEN '[OPTION_COEF]' = '-1' THEN coefficient_mco ELSE 1 END,2) AS CA_EXH,
                        round(p_etude_impact_cma.ca_perte_exb * CASE WHEN '[OPTION_COEF]' = '-1' THEN coefficient_mco ELSE 1 END,2) AS CA_EXBP,
                        round(p_etude_impact_cma.ca_ghs_dossier * CASE WHEN '[OPTION_COEF]' = '-1' THEN coefficient_mco ELSE 1 END,2) AS CA_GHS,
                        
                        p_etude_impact_cma.ghm_calc AS GHM_CALC,
                        p_etude_impact_cma.ghs_calc AS GHS_CALC,
                        round(p_etude_impact_cma.tarif_ghs_calc * CASE WHEN '[OPTION_COEF]' = '-1' THEN coefficient_mco ELSE 1 END,2) AS CA_GHS_CALC,
                        round(p_etude_impact_cma.impact_cma * CASE WHEN '[OPTION_COEF]' = '-1' THEN coefficient_mco ELSE 1 END,2) AS ECART_CA
                    FROM 
                        #V_RSS_X#
                        LEFT JOIN pmsi.p_etude_impact_cma ON v_rss_1.rss_id = p_etude_impact_cma.rss_id
                    WHERE 1=1
                        AND mois_sortie IN ([VIEW.PERIODE_MOIS_LIST]) 
                        AND v_rss_1.date_sortie BETWEEN '[PERIODE]'::date AND '[TOPERIODE]'::date
                        [VIEW.FILTRE_RSS_SELECT]
                )
                UNION ALL
                (
                    SELECT 
                        -9999999 AS OID,
                        COUNT(DISTINCT v_rss_1.no_rss)::text || ' RSS'::text AS NO_RSS,
                        COUNT(DISTINCT v_rss_1.no_sejour_administratif)::text || ' séjours'::text AS NO_SEJOUR,
                        ''::text AS FINESS,
                        COUNT(DISTINCT patient_id)::text || ' patients'::text AS PATIENT, 
                        
                        NULL AS DUR_SEJ,
                        COUNT(DISTINCT p_etude_impact_cma.ghm_dos)::text || ' GHM'::text AS GHM_DOS,
                        COUNT(DISTINCT p_etude_impact_cma.ghs_dos)::text || ' GHS'::text AS GHS_DOS,
                        ''::text AS SEV_GHM,
                        NULL AS AGE,
                        ''::text AS GHM_AGE_CMA,
                        
                        SUM(round(p_etude_impact_cma.ca_ghs_theorique * CASE WHEN '[OPTION_COEF]' = '-1' THEN coefficient_mco ELSE 1 END,2)),
                        SUM(round(p_etude_impact_cma.ca_exh * CASE WHEN '[OPTION_COEF]' = '-1' THEN coefficient_mco ELSE 1 END,2)),
						SUM(round(p_etude_impact_cma.ca_perte_exb * CASE WHEN '[OPTION_COEF]' = '-1' THEN coefficient_mco ELSE 1 END,2)),
                        SUM(round(p_etude_impact_cma.ca_ghs_dossier * CASE WHEN '[OPTION_COEF]' = '-1' THEN coefficient_mco ELSE 1 END,2)),
                        
                        ''::text AS GHM_CALC,
                        NULL AS GHS_CALC,
                        SUM(round(p_etude_impact_cma.tarif_ghs_calc * CASE WHEN '[OPTION_COEF]' = '-1' THEN coefficient_mco ELSE 1 END,2)),
                        SUM(round(p_etude_impact_cma.impact_cma * CASE WHEN '[OPTION_COEF]' = '-1' THEN coefficient_mco ELSE 1 END,2))
                    FROM 
                        #V_RSS_X#
                        LEFT JOIN pmsi.p_etude_impact_cma ON v_rss_1.rss_id = p_etude_impact_cma.rss_id
                    WHERE 1=1
                        AND mois_sortie IN ([VIEW.PERIODE_MOIS_LIST]) 
                        AND v_rss_1.date_sortie BETWEEN '[PERIODE]'::date AND '[TOPERIODE]'::date
                        [VIEW.FILTRE_RSS_SELECT]
                )
                ORDER BY 2;
                    
            ]]></select>
            <FIELDS>
                    <FIELD name="OID" />
                    <FIELD name="NO_RSS" />
                    <FIELD name="NO_SEJOUR" />
                    <FIELD name="FINESS" />
                    <FIELD name="PATIENT" />
                    
                    <FIELD name="DUR_SEJ" />
                    <FIELD name="GHM_DOS" />
                    <FIELD name="GHS_DOS" />
                    <FIELD name="SEV_GHM" />
                    <FIELD name="AGE" />
                    <FIELD name="GHM_AGE_CMA" />
                    
                    <FIELD name="CA_GHST" />
                    <FIELD name="CA_EXH" />
                    <FIELD name="CA_EXBP" />
                    <FIELD name="CA_GHS" />
                    
                    <FIELD name="GHM_CALC" />
                    <FIELD name="GHS_CALC" />
                    <FIELD name="CA_GHS_CALC" />
                    <FIELD name="ECART_CA" />
                </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="54" totalRowInRows="= ROW.OID == '-9999999'">
                <COLUMN dataField="OID" type="Char" visible="false" />
                <COLUMN dataField="FINESS" width="60" type="Char" headerText="Etablissement" textAlign="left" visibleCondition="ENV.CONSOLIDATION == '1'" otherFunction="text" totalFunction="text" totalComplement="" />
                <COLUMN dataField="NO_RSS" width="60" type="Char" headerText="N° RSS" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="TOTAL" />
                <COLUMN dataField="NO_SEJOUR" width="90" type="Char" outputFormat="#" headerText="N° séjour" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="" />
                <COLUMN dataField="PATIENT" minWidth="150" type="Char" headerText="Patient" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="*ROW" />
                <COLUMN dataField="AGE" width="40" type="Number" outputFormat="#" headerText="Age" textAlign="right" otherFunction="text" totalFunction="text" />
                <COLUMN dataField="DUR_SEJ" width="40" type="Number" outputFormat="#" headerText="Durée séjour" fixed="false" textAlign="right" otherFunction="text" totalFunction="text" />
                <COLUMN dataField="GHM_DOS" width="60" type="Char" headerText="GHM&#xD;RSS" fixed="false" textAlign="left" otherFunction="text" totalFunction="text" />
                <COLUMN dataField="SEV_GHM" width="60" type="Char" headerText="Sévérité&#xD;GHM" fixed="false" textAlign="left" otherFunction="text" totalFunction="text" />
                <COLUMN dataField="GHM_AGE_CMA" width="60" type="Char" headerText="Effet Age CMA" fixed="false" textAlign="left" otherFunction="text" totalFunction="text"
                    description="Indique les conditions pour lesquelles le GHM admet l'age comme effet de CMA. Cette information est tirée de la table DATIM &lt;b&gt;RACINE_INFO&lt;/b&gt;">
                </COLUMN>
                <COLUMN dataField="GHS_DOS" width="60" type="Char" headerText="GHS dossier" fixed="false" textAlign="left" otherFunction="text" totalFunction="text"
                    description="GHS du dossier">
                </COLUMN>
                <COLUMN dataField="CA_GHST" width="105" type="Number" outputFormat="#,00E" headerText="CA GHS&#xD;théorique" textAlign="right" totalFunction="sum" otherFunction="sum"
                    description="Chiffre d'affaires brut du GHS dossier, hors coefficients">
                </COLUMN>
                <COLUMN dataField="CA_EXH" width="95" type="Number" outputFormat="#,00E" headerText="CA EXH" textAlign="right" totalFunction="sum" otherFunction="sum"
                    description="Chiffre d'affaires EXH lié au GHS dossier, hors coefficients">
                </COLUMN>
                <COLUMN dataField="CA_EXBP" width="95" type="Number" outputFormat="#,00E" headerText="CA Perte EXB" textAlign="right" totalFunction="sum" otherFunction="sum"
                    description="Chiffre d'affaires des pertes EXB (forfaits ou tarifs journaliers) liées au GHS dossier, hors coefficients">
                </COLUMN>
                <COLUMN dataField="CA_GHS" width="105" type="Number" outputFormat="#,00E" headerText="CA GHS&#xD;dossier" textAlign="right" totalFunction="sum" otherFunction="sum"
                    description="CA GHS théorique + CA EXH - CA pertes EXB">
                </COLUMN>
                <COLUMN dataField="GHM_CALC" width="50" type="Char" headerText="GHM&#xD;calculé" fixed="false" textAlign="left" otherFunction="text" totalFunction="text"
                    description="GHM attribué par la méthodologie">
                </COLUMN>
                <COLUMN dataField="GHS_CALC" width="50" type="Char" headerText="GHS&#xD;calculé" fixed="false" textAlign="left" otherFunction="text" totalFunction="text"
                    description="GHS attribué par la méthodologie">
                </COLUMN>
                <COLUMN dataField="CA_GHS_CALC" width="105" type="Number" outputFormat="#,00E" headerText="CA GHS&#xD;calculé sans&#xD;impact CMA" textAlign="right" totalFunction="sum" otherFunction="sum"
                    description="CA GHS théorique + CA EXH - CA perte EXB en considérant non pas le GHS du dossier mais le GHS attribué par la méthodogie" />
                <COLUMN dataField="ECART_CA" width="95" type="Number" outputFormat="#,00E" headerText="Ecart =&#xD;Impact CMA" textAlign="right" totalFunction="sum" otherFunction="sum"
                    description="Ecart entre le GHS calculé et le GHS dossier">
                </COLUMN>
            </DATAGRID>
        </ONGLET>
    </PRESENTATION>
</VUE>
