<?xml version="1.0" encoding="ISO-8859-15"?>
<VUE name="ACTI000014" 
    label="Activité. Justificatif Effets Prix - GHS" 
    title="= 'Justificatif Effets Prix - GHS-EXH par ' +  SELECT.GROUPBY_LABEL + ' (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ')' " 
    database="iCTI" 
    swf="*CTI_view1" 
    softCode="iCTI_activite" 
    globals="ACTI_globals.XML" 
    componentsFile="ACTI_components.XML" 
    helpFile="iCTI_ACTI_ACTI000123.HTML"
    helpDokuWIkiDir="activite:activite_facturee_et_valorisee:activite_clinique" 
    helpDokuWIkiFile="acti000061" 
>
	<VIEWPROPERTIES componentName="PROPERTIES_ETATDOSSIERS"/>
	<VIEWPROPERTIES>

        <PROPERTY name="connectedUserHideNames">
            <value><![CDATA[[EVAL 

                    global $connectedUserHideNames;
                    return $connectedUserHideNames;

				EVAL]]]></value>
        </PROPERTY>
        <PROPERTY name="FAC_SELECT">
			<value><![CDATA[[EVAL 
                    $status_select = "";
                    if ('[QFAC]' == '1') {
						 $status_select = "AND ok_ghs_f = '1'";
					}
                    if ('[QFAC]' == '0') {
						 $status_select = "AND ok_ghs_f = '0'";
					}
					return $status_select;
				EVAL]]]></value>
		</PROPERTY>
        
        <PROPERTY name="FAE_SELECT">
			<value><![CDATA[[EVAL 
                    $status_select = "";
                    if ('[QFAE]' == '1') {
						 $status_select = "AND ok_ghs_f = '1' AND montant_tot_f <> montant_tot_c";
					}
					return $status_select;
				EVAL]]]></value>
		</PROPERTY>
        
	</VIEWPROPERTIES>
	<SELECTIONS label="Paramètres de l'analyse" displayText="= var display:String = '';
					
					if (SELECT.QFAC  != '-1') {
						display = display + '#B#'+ SELECT.QFAC_LABEL + '#/B# ';
					}
					if (SELECT.QFAE  != '-1') {
						display = display + '#B#'+ SELECT.QFAE_LABEL + '#/B# ';
					}
					
					return display;
					">
		<GROUP label="Période sortie">
			<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="2009-01-01" globalListProvider="DATE_DEBUT" >
			</FIELD>
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2009-01-31" globalListProvider="DATE_FIN" >
			</FIELD>
		</GROUP>
		
		<GROUP label="">
			<FIELD name="GROUPBY_2" label="Autres colonnes" UI="combo" default="-1" width="200" tree="true">
				<OPTION label="" data="-1"/>
				<OPTION label="PRESTATIONS_GROUPBY" data="" globalListProvider="SEJOUR_GROUPBY"/>
			</FIELD>
		</GROUP>
		<GROUP label="">
			<FIELD name="GROUPBY_3" label="" UI="combo" default="-1" width="200" tree="true">
				<OPTION label="" data="-1"/>
				<OPTION label="PRESTATIONS_GROUPBY" data="" globalListProvider="SEJOUR_GROUPBY"/>
			</FIELD>
		</GROUP>
		<GROUP label="">
            <FIELD name="QFAC" label="Facturation" UI="combo" default="-1" width="300">
				<OPTION label="Pas de sélection" data="-1" />
                <OPTION label="Séjours non facturés" data="0" />
				<OPTION label="Séjours facturés" data="1" />
			</FIELD>
        </GROUP>
        <GROUP label="">
			<FIELD name="QFAE" label="Ecarts facturation" UI="combo" default="-1" width="300">
				<OPTION label="Pas de sélection" data="-1" />
				<OPTION label="Ecarts de facturation" data="1" />
			</FIELD>
		</GROUP>

	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_SEJOURS_SELECTIONS"/>
	<QUERIES>
		<QUERY label="">
            
			<SQL optimizer="V_SEJOURS_X" optimizer2="">
				<select><![CDATA[
                    
					CTISELECT_TREECOL
					WORKTABLE{ACTI000014}
					GROUPBY1{v_sejours_1.sejour_id,, v_sejours_1.no_sejour,,  CASE WHEN '[VIEW.connectedUserHideNames]' = 'true' THEN 'Non autorisé' ELSE (nom || ' ' || prenom) END}
					GROUPBY1MODE{COL} 
					GROUPBY2{[VIEW.GROUPBY_2_OID_FIELD],, [VIEW.GROUPBY_2_COD_FIELD],, [VIEW.GROUPBY_2_TXT_FIELD]}
					GROUPBY3{[VIEW.GROUPBY_3_OID_FIELD],, [VIEW.GROUPBY_3_COD_FIELD],, [VIEW.GROUPBY_3_TXT_FIELD]}
					INDICATORS{
                    
                    COUNT(*),
                    SUM(CASE WHEN ok_ghs_f = '1' THEN 1 ELSE 0 END),,
                    SUM(CASE WHEN ok_ghs_f = '1' AND montant_tot_f <> montant_tot_c THEN 1 ELSE 0 END),,
                    SUM(v_sejour_effet_tarif_1.montant_tot_f),,
                    SUM(v_sejour_effet_tarif_1.montant_tot_c),,
                    SUM(v_sejour_effet_tarif_1.montant_ghs_c),,
                    SUM(v_sejour_effet_tarif_1.montant_exb_c),,
                    SUM(v_sejour_effet_tarif_1.montant_exh_c),,
                    SUM(v_sejour_effet_tarif_1.montant_tot_p),,
                    SUM(v_sejour_effet_tarif_1.montant_ghs_p),,
                    SUM(v_sejour_effet_tarif_1.montant_exb_p),,
                    SUM(v_sejour_effet_tarif_1.montant_exh_p),,
                    0,,
                    SUM(CASE WHEN ok_ghs_f = '1' THEN montant_tot_f - montant_tot_c ELSE 0 END),,
                        
					}
                    INDICATORS_TEXT{
                        MIN(to_char(v_sejours_1.date_entree,'YYYY-MM-DD')),,
                        MAX(CASE WHEN v_sejours_1.date_sortie &lt;&gt; '2099-12-31' AND code_sorti = '1' THEN to_char(v_sejours_1.date_sortie,'YYYY-MM-DD') ELSE ''::text END),,
                    }
                    
					FROM activite.v_sejour_effet_tarif_1
                        JOIN #V_SEJOURS_X# ON v_sejours_1.no_sejour = v_sejour_effet_tarif_1.no_sejour
                        JOIN activite.p_patients ON v_sejours_1.no_patient = p_patients.no_patient
					WHERE v_sejours_1.date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.SEJOURS_SELECT]
                        [VIEW.FAC_SELECT]
                        [VIEW.FAE_SELECT]
                    
                    AFTER{	
						UPDATE ACTI000014 SET
                            indicateurs_text = NULL,
                            texte1 = to_char(indicateurs[1],'FM99999999999') || ' séjours'
                        WHERE level = 9
                        .,
                        UPDATE ACTI000014 SET
                            indicateurs[13] = indicateurs[5] - indicateurs[9]
					}
				
				
				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREECOL_FIELDS"/>
                    
                    <FIELD name="NSEJ" />
                    <FIELD name="NFAC" />
                    <FIELD name="NFAE" />
					<FIELD name="TOTF" />
					<FIELD name="TOTC" />
					<FIELD name="GHSC" />
					<FIELD name="EXBC" />
					<FIELD name="EXHC" />
					<FIELD name="TOTP" />
					<FIELD name="GHSP" />
					<FIELD name="EXBP" />
					<FIELD name="EXHP" />
                    <FIELD name="TOTE" />
                    <FIELD name="DIFF" />
                    
                    
                    <FIELD name="DATENT"/>
                    <FIELD name="DATSOR"/>
                    
				</FIELDS>
			</SQL>
		</QUERY>
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forRows="false">
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		
		<VIEWLINKS>
			<VIEWLINK label="Détail séjour" shortLabel="Détail séjour" view="ACTI000020.XML">
                <ARG name="_ONGLET_O1_VISIBLE" value="'true'"/>
                <ARG name="_ONGLET_O2_VISIBLE" value="'true'"/>
                <ARG name="_ONGLET_O3_VISIBLE" value="'true'"/>
                <ARG name="_ONGLET_O4_VISIBLE" value="'true'"/>
                <ARG name="_ONGLET_O5_VISIBLE" value="'true'"/>
                <ARG name="_ONGLET_O6_VISIBLE" value="'true'"/>
                <ARG name="_ONGLET_O7_VISIBLE" value="'true'"/>
                <ARG name="_ONGLET_O8_VISIBLE" value="'true'"/>
				<ARG name="SEJOUR" value="ROW.COD1"/>
			</VIEWLINK>
		</VIEWLINKS>
        <ONGLET excelLabel="Justificatif séjour" label="Justificatif séjour" multiTab="true" >
            
			<DATAGRID title=""
                    total="true"
                    showOthers="true"
                    headerHeight="70"
                    variableRowHeight="true"
                    sortable="= SELECT.GROUPBY_2 == '-1' || SELECT.GROUPBY_TAB == 'TAB' || 'COL' == 'COL'"
                    selectRowInRows="= ROW.OID == '-9999997'"
                    otherRowInRows="= ROW.OID == '-9999998'"
                    totalRowInRows="= ROW.OID == '-9999999'">
                    
				<INSERT name="DATAGRID_MULTITAB_STYLES"/>
                <HEADERROWSTYLE name="textAlign" value="center"/>
				<COLUMN dataField="OID"
                    width="60"
                    type="Char"
                    visible="false"
                    headerText="Oid">
				</COLUMN>
                
				<COLUMN dataField="COD"
                    width="70"
                    type="Char"
                    visible="false"
                    headerText="Code"
                    textAlign="left"
                    otherFunction="text"
                    totalFunction="text"
                    totalComplement="TOTAL">
					<INSERT name="COLUMN_COD_MULTITAB_STYLES"/>
                    <HEADERCELLSTYLE name="textAlign" value="left"/>
				</COLUMN>
				<COLUMN dataField="TXT"
                    type="Char"
                    visible="false"
                    minWidth="150"
                    maxWidth="300"
                    headerText="SELECT.GROUPBY_LABEL"
                    headerTextCalc="true"
                    textAlign="left"
                    totalFunction="text"
                    otherFunction="text"
                    otherComplement="*ROW">
                    <HEADERCELLSTYLE name="textAlign" value="left"/>
				</COLUMN>
                <COLUMN dataField="COD1"
                    width="70"
                    type="Char"
                    visible="true"
                    headerText="Séjour"
                    textAlign="left"
                    otherFunction="text"
                    totalFunction="text"
                    totalComplement="TOTAL">
                    <HEADERCELLSTYLE name="textAlign" value="left"/>
				</COLUMN>
                <COLUMN dataField="TXT1"
                    type="Char"
                    minWidth="150"
                    maxWidth="300"
                    headerText="Nom"
                    headerTextCalc="false"
                    textAlign="left"
                    totalFunction="text"
                    otherFunction="text"
                    otherComplement="*ROW">
                    <HEADERCELLSTYLE name="textAlign" value="left"/>
				</COLUMN>
                <COLUMN dataField="DATENT" width="60" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" fixed="false" 
                    headerText="'Date\nentrée'" headerTextCalc="true" textAlign="center" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DATSOR" width="60" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" fixed="false" 
                    headerText="'Date\nsortie'" headerTextCalc="true" textAlign="center" totalFunction="text">
				</COLUMN>
              <COLUMN dataField="COD2"
                    width="70"
                    type="Char"
                    visible="true"
                    headerText="SELECT.GROUPBY_2_LABEL + '\r(code)'"
                    headerTextCalc="true"
                    textAlign="left"
                    otherFunction="text"
                    totalFunction="text"
                    totalComplement="TOTAL"
                    visibleCondition="SELECT.GROUPBY_2 != -1">
                    <HEADERCELLSTYLE name="textAlign" value="left"/>
				</COLUMN> 
				<COLUMN dataField="TXT2"
                    type="Char"
                    minWidth="150"
                    maxWidth="300"
                    headerText="SELECT.GROUPBY_2_LABEL "
                    headerTextCalc="true"
                    textAlign="left"
                    totalFunction="text"
                    otherFunction="text"
                    otherComplement="*ROW"
                    visibleCondition="SELECT.GROUPBY_2 != -1">
                    <HEADERCELLSTYLE name="textAlign" value="left"/>
				</COLUMN>
                <COLUMN dataField="COD3"
                    width="70"
                    type="Char"
                    visible="true"
                    headerText="SELECT.GROUPBY_3_LABEL + '\r(code)'"
                    headerTextCalc="true"
                    textAlign="left"
                    otherFunction="text"
                    totalFunction="text"
                    totalComplement="TOTAL"
                    visibleCondition="SELECT.GROUPBY_3 != -1">
                    <HEADERCELLSTYLE name="textAlign" value="left"/>
				</COLUMN>
				<COLUMN dataField="TXT3"
                    type="Char"
                    minWidth="150"
                    maxWidth="300"
                    headerText="SELECT.GROUPBY_3_LABEL + '\r(texte)'"
                    headerTextCalc="true"
                    textAlign="left"
                    totalFunction="text"
                    otherFunction="text"
                    otherComplement="*ROW"
                    visibleCondition="SELECT.GROUPBY_3 != -1">
                    <HEADERCELLSTYLE name="textAlign" value="left"/>
				</COLUMN>
                
                <COLUMN dataField="NSEJ" type="Number" width="90" outputFormat="#" selectable="true" 
                    visible="false"
                    headerText="'\nNombre de séjours'" 
                    headerTextCalc="true" 
                    description="Nombre de séjours analysés"  
                    textAlign="center">

				</COLUMN>
                <COLUMN dataField="NFAC" type="Number" width="90" outputFormat="#" selectable="true" 
                    visible="false"
                    headerText="'\nNombre de séjours facturés'" 
                    headerTextCalc="true" 
                    description="Nombre de séjours avec un GHS facturé parmi les séjours choisis"  
                    textAlign="center">
				</COLUMN>
                <COLUMN dataField="NFAE" type="Number" width="90" outputFormat="#" selectable="true" 
                    visible="false"
                    headerText="'\nNombre de séjours facturés différemment'" 
                    headerTextCalc="true" 
                    description="Nombre de séjours facturés avec un montant différent de la revalorisation"  
                    textAlign="center">
				</COLUMN>
                
				<COLUMN dataField="TOTF" type="Number" width="90" outputFormat="# E" selectable="true" 
                    headerText="'(F1)'+ '\nC.A. Facturé TOTAL\n'+ '&lt;font color=\'#DB1702\'&gt;N&lt;/font&gt;'" 
                    headerTextCalc="true" 
                    description="Montant total (GHS+EXH) facturé" 
                    textAlign="center">
						<HEADERCELLSTYLE name="backgroundColor" value="0xDCDCDC"/>
						<FOOTERCELLSTYLE name="backgroundColor" value="0xDCDCDC"/>
                        <CELLSTYLE name="cellIndicator" value="circle, 5, left top, 0xFF6600" 
							condition="ROW.NFAE == 1" />
				</COLUMN>
                <COLUMN dataField="DIFF" type="Number" width="90" outputFormat="# E" selectable="true" 
                    headerText="'(D1)'+ '\nEcart Facturé Tarif TOTAL\n'+ '&lt;font color=\'#DB1702\'&gt;N&lt;/font&gt;'" 
                    headerTextCalc="true" 
                    description="Ecart entre le montant facturé et le montant recalculé selon tarif (F1-C1)" 
                    textAlign="center">
						<HEADERCELLSTYLE name="backgroundColor" value="0xDCDCDC"/>
						<FOOTERCELLSTYLE name="backgroundColor" value="0xDCDCDC"/>
                        <CELLSTYLE name="cellIndicator" value="circle, 5, left top, 0xFF6600" 
							condition="ROW.NFAE == 1" />
				</COLUMN>
                
                <COLUMN dataField="TOTC" type="Number" width="90" outputFormat="# E" selectable="true" 
                    headerText="'(C1)'+ '\nC.A. Recalculé TOTAL\n'+ '&lt;font color=\'#DB1702\'&gt;Tarifs N&lt;/font&gt;'" 
                    headerTextCalc="true" 
                    description="Montant total (GHS+EXH) recalculé à partir du tarif GHS de la période" 
                    textAlign="center">
						<HEADERCELLSTYLE name="backgroundColor" value="0xbccbed"/>
						<FOOTERCELLSTYLE name="backgroundColor" value="0xbccbed"/>
				</COLUMN>
                <COLUMN dataField="GHSC" type="Number" width="90" outputFormat="# E" selectable="true" 
                    headerText="'(C1-GHS)'+ '\nC.A. Recalculé GHS Plein\n'+ '&lt;font color=\'#DB1702\'&gt;Tarifs N&lt;/font&gt;'" 
                    headerTextCalc="true" 
                    description="Montant recalculé du GHS plein à partir du tarif GHS de la période" 
                    textAlign="center">
						<HEADERCELLSTYLE name="backgroundColor" value="0xbccbed"/>
						<FOOTERCELLSTYLE name="backgroundColor" value="0xbccbed"/>
				</COLUMN>
                <COLUMN dataField="EXBC" type="Number" width="90" outputFormat="# E" selectable="true" 
                    headerText="'(C1-EXB)'+ '\nC.A. Recalculé EXB\n'+ '&lt;font color=\'#DB1702\'&gt;Tarifs N&lt;/font&gt;'" 
                    headerTextCalc="true" 
                    description="Montant recalculé des décotes EXB à partir du tarif GHS de la période" 
                    textAlign="center">
						<HEADERCELLSTYLE name="backgroundColor" value="0xbccbed"/>
						<FOOTERCELLSTYLE name="backgroundColor" value="0xbccbed"/>
				</COLUMN>
                <COLUMN dataField="EXHC" type="Number" width="90" outputFormat="# E" selectable="true" 
                    headerText="'(C1-EXH)'+ '\nC.A. Recalculé EXH\n'+ '&lt;font color=\'#DB1702\'&gt;Tarifs N&lt;/font&gt;'" 
                    headerTextCalc="true" 
                    description="Montant recalculé des EXH à partir du tarif GHS de la période" 
                    textAlign="center">
						<HEADERCELLSTYLE name="backgroundColor" value="0xbccbed"/>
						<FOOTERCELLSTYLE name="backgroundColor" value="0xbccbed"/>
				</COLUMN>
                <COLUMN dataField="TOTP" type="Number" width="90" outputFormat="# E" selectable="true" 
                    headerText="'(P1)'+ '\nC.A. Recalculé TOTAL\n'+ '&lt;font color=\'#DB1702\'&gt;Tarifs N-1&lt;/font&gt;'" 
                    headerTextCalc="true" 
                    description="Montant total (GHS+EXH) recalculé à partir du tarif GHS de la période précédente" 
                    textAlign="center">
						<HEADERCELLSTYLE name="backgroundColor" value="0xDCDCDC"/>
						<FOOTERCELLSTYLE name="backgroundColor" value="0xDCDCDC"/>
				</COLUMN>
                <COLUMN dataField="GHSP" type="Number" width="90" outputFormat="# E" selectable="true" 
                    headerText="'(P1-GHS)'+ '\nC.A. Recalculé GHS Plein\n'+ '&lt;font color=\'#DB1702\'&gt;Tarifs N-1&lt;/font&gt;'" 
                    headerTextCalc="true" 
                    description="Montant recalculé du GHS plein à partir du tarif GHS de la période précédente" 
                    textAlign="center">
						<HEADERCELLSTYLE name="backgroundColor" value="0xDCDCDC"/>
						<FOOTERCELLSTYLE name="backgroundColor" value="0xDCDCDC"/>
				</COLUMN>
                <COLUMN dataField="EXBP" type="Number" width="90" outputFormat="# E" selectable="true" 
                    headerText="'(P1-EXB)'+ '\nC.A. Recalculé EXB\n'+ '&lt;font color=\'#DB1702\'&gt;Tarifs N-1&lt;/font&gt;'" 
                    headerTextCalc="true" 
                    description="Montant recalculé des décotes EXB à partir du tarif GHS de la période précédente" 
                    textAlign="center">
						<HEADERCELLSTYLE name="backgroundColor" value="0xDCDCDC"/>
						<FOOTERCELLSTYLE name="backgroundColor" value="0xDCDCDC"/>
				</COLUMN>
                <COLUMN dataField="EXHP" type="Number" width="90" outputFormat="# E" selectable="true" 
                    headerText="'(P1-EXH)'+ '\nC.A. Recalculé EXH\n'+ '&lt;font color=\'#DB1702\'&gt;Tarifs N-1&lt;/font&gt;'" 
                    headerTextCalc="true" 
                    description="Montant recalculé des EXH à partir du tarif GHS de la période précédente" 
                    textAlign="center">
						<HEADERCELLSTYLE name="backgroundColor" value="0xDCDCDC"/>
						<FOOTERCELLSTYLE name="backgroundColor" value="0xDCDCDC"/>
				</COLUMN>
				
                 <COLUMN dataField="TOTE" type="Number" width="90" outputFormat="# E" selectable="true" 
                    headerText="'(P1)'+ '\nEffet Prix\nen C.A.\n'+ '&lt;font color=\'#DB1702\'&gt;N - N-1&lt;/font&gt;'" 
                    headerTextCalc="true" 
                    description="Différence entre montant recalculé période (C1) et période précédente (P1)"  
                    textAlign="center">
						<HEADERCELLSTYLE name="backgroundColor" value="0xbccbed"/>
						<FOOTERCELLSTYLE name="backgroundColor" value="0xbccbed"/>
				</COLUMN>
			</DATAGRID>
		</ONGLET>
       
	</PRESENTATION>
</VUE>
