<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="ACTI000075" 
	label="Cohérence base HM" 
	title="Cohérence base HM" 
	database="iCTI" 
	swf="*CTI_view1" 
	softCode="iCTI_activite"
	admProvider="r2i"
	>
	<CACHE cachable="false" />
	<SELECTIONS>
		
	</SELECTIONS>
	
	<QUERIES> 
	
		<QUERY> 
			<SQL> 
				<select><![CDATA[
					DROP TABLE IF EXISTS w_ctl_nip;
					CREATE TEMP TABLE w_ctl_nip AS
					SELECT PATI_NIP AS w_PATI_NIP, count(*) as OCCURENCES
					FROM prod_hm.IDE_PATIENT
					WHERE PATI_NIP IS NOT NULL AND PATI_NIP <> '' AND PATI_ID_PATI IN (SELECT DISTINCT SEJO_ID_PATI FROM prod_hm.IDE_SEJOUR)
					GROUP BY PATI_NIP
					HAVING count(*) > 1;

					DROP TABLE IF EXISTS w_ctl_sej;
					CREATE TEMP TABLE w_ctl_sej AS
					SELECT SEJO_NUM_SEJ AS w_SEJO_NUM_SEJ, count(*) as OCCURENCES
					FROM prod_hm.IDE_SEJOUR
					WHERE SEJO_NUM_SEJ IS NOT NULL AND SEJO_NUM_SEJ <> '' AND 
							SEJO_DAT_SUP IS NULL AND SEJO_IND_INCOMPLET IS DISTINCT FROM '1' AND SEJO_STATUT <> 'Z' AND
							SEJO_STATUT NOT IN ('A', 'P') AND
							SEJO_DAT_DEB >= '20090101'
					GROUP BY SEJO_NUM_SEJ
					HAVING count(*) > 1;

					SELECT 
						PATI_NIP, PATI_NOM_USU::text || ' ' || PATI_PRENOM::text, PATI_DAT_NAI, SEJO_NUM_SEJ, SEJO_DAT_DEB, SEJO_DAT_FIN,
						'COLLISION PATIENT'
					FROM prod_hm.IDE_SEJOUR
						JOIN prod_hm.IDE_PATIENT ON SEJO_ID_PATI = PATI_ID_PATI
						JOIN w_ctl_nip ON PATI_NIP = w_PATI_NIP
					UNION ALL
					SELECT 
						PATI_NIP, PATI_NOM_USU::text || ' ' || PATI_PRENOM::text, PATI_DAT_NAI, SEJO_NUM_SEJ, SEJO_DAT_DEB, SEJO_DAT_FIN,
						'COLLISION SEJOUR'
					FROM prod_hm.IDE_SEJOUR 
						JOIN prod_hm.IDE_PATIENT ON SEJO_ID_PATI = PATI_ID_PATI
						JOIN w_ctl_sej ON SEJO_NUM_SEJ = w_SEJO_NUM_SEJ
					ORDER BY 1

				]]></select>
				<FIELDS>
					<FIELD name="NIP"  />
					<FIELD name="NOM" ifHideNames="Non autorisé"  />
					<FIELD name="DNAI" />
					<FIELD name="SEJ" />
					<FIELD name="DENT" />
					<FIELD name="DSOR" />
					<FIELD name="ERR" />
				</FIELDS>
			</SQL>

			
		</QUERY>
		
		<QUERY> 
			<SQL>
				<select><![CDATA[
						DROP TABLE IF EXISTS w_ctl_fact_t;
						CREATE TEMP TABLE w_ctl_fact_t AS
						SELECT 
							FACT_ID_FACT, 
							FACT_TYPE,
							FACT_NUM_FAC,
							FACT_DAT_CRE,
							SEJO_NUM_SEJ,
							SEJO_IND_BGH,
							SEJO_DAT_SUP,
							ETAB_TYP_ETAB,
							CASE WHEN SEJO_IND_BGH IS NOT DISTINCT FROM '1' OR ETAB_TYP_ETAB = 'PSPH' THEN '1' ELSE '0' END AS HON_TO_SEJ,
							MAX(CASE WHEN SEJO_IND_BGH IS DISTINCT FROM '1' OR ETAB_TYP_ETAB <> 'PSPH' OR LFAC_LET_CLE NOT IN ('GHS', 'PJ', 'AMP5') THEN '1' ELSE '0' END) AS FAC_HON
						FROM prod_hm.FAC_FACTURE 
							JOIN prod_hm.FAC_LIGNE_FACTURE ON LFAC_ID_FACT = FACT_ID_FACT
							JOIN prod_hm.IDE_SEJOUR ON FACT_ID_SEJO = SEJO_ID_SEJO
							JOIN prod_hm.BAS_ETABLISSEMENT ON SEJO_ID_ETAB_CON = ETAB_ID_ETAB
							WHERE FACT_TYPE <> 'E' AND FACT_TYPE <> 'P' AND FACT_DAT_SUP IS NULL
						GROUP BY 1,2,3,4,5,6,7,8;

						CREATE INDEX w_ctl_fact_t_i1
						ON w_ctl_fact_t
						USING btree
						(FACT_ID_FACT);

						
						DROP TABLE IF EXISTS w_ctl_facd_t;
						CREATE TEMP TABLE w_ctl_facd_t AS
						SELECT 
							SEJO_NUM_SEJ, FACT_NUM_FAC, date(FACT_DAT_CRE) AS FACT_DAT_CRE, FACD_ID_FACD, SEJO_DAT_SUP,
							SUM(FACD_MTT_SEJOUR) AS FACD_MTT_SEJOUR, 
							SUM(FACD_MTT_HON_HOR_DEH + FACD_MTT_DEH) AS FACD_MTT_HON,
							SUM(FACD_MTT_CRN_SEJ) + SUM(CASE WHEN HON_TO_SEJ = '1' THEN FACD_MTT_CRN_HON ELSE 0 END) AS FACD_MTT_CRN_SEJOUR,
							SUM(CASE WHEN HON_TO_SEJ <> '1' THEN FACD_MTT_CRN_HON ELSE 0 END) AS FACD_MTT_CRN_HON
						FROM prod_hm.FAC_FACTURE_DEBITEUR
							JOIN w_ctl_fact_t ON FACD_ID_FACT = FACT_ID_FACT
						GROUP BY 1,2,3,4,5;

						CREATE INDEX w_ctl_facd_t_i1
						ON w_ctl_facd_t
						USING btree
						(FACD_ID_FACD);


						DROP TABLE IF EXISTS w_ctl_facd_v;
						CREATE TEMP TABLE w_ctl_facd_v AS
						SELECT FACD_ID_FACD AS FACV_ID_FACD,
								base.cti_group_concat(DISTINCT date(ECRI_DAT_ECRITURE)) AS FACV_DAT_VEN,
								count(DISTINCT date(ECRI_DAT_ECRITURE)) AS FACV_NB_DAT_VEN
							FROM prod_hm.CCL_LIGNE_ECRITURE, 
								prod_hm.CCL_ECRITURE, 
								prod_hm.FAC_FACTURE_DEBITEUR, 
								prod_hm.CCL_JOURNAL, 
								prod_hm.CCL_COMPTE, 
								prod_hm.BAS_CATALOGUE_GEN BAS_CATALOGUE_GEN_COMPTE,
								prod_hm.BAS_CATALOGUE_GEN BAS_CATALOGUE_GEN_JOURNAL,
								prod_hm.FAC_FACTURE
							WHERE 
								LECR_ID_ECRI = ECRI_ID_ECRI
								AND LECR_ID_FACD = FACD_ID_FACD
								AND ECRI_ID_JOUR = JOUR_ID_JOUR
								AND LECR_ID_CPTE = CPTE_ID_CPTE
								AND FACD_ID_FACT = FACT_ID_FACT
								AND CPTE_ID_CAGE = BAS_CATALOGUE_GEN_COMPTE.CAGE_ID_CAGE
								AND JOUR_ID_CAGE = BAS_CATALOGUE_GEN_JOURNAL.CAGE_ID_CAGE
								AND ECRI_DAT_SUP IS NULL
								AND FACT_DAT_SUP IS NULL
								AND BAS_CATALOGUE_GEN_COMPTE.CAGE_CODE = 'CLIENT'
								AND BAS_CATALOGUE_GEN_JOURNAL.CAGE_CODE = 'FACAV'
						GROUP BY 1;

						CREATE INDEX w_ctl_facd_v_i1
						ON w_ctl_facd_v
						USING btree
						(FACV_ID_FACD);


						DROP TABLE IF EXISTS w_ctl_facd_d;
						CREATE TEMP TABLE w_ctl_facd_d AS
						SELECT 
							LFAD_ID_FACD, 
							SUM(CASE WHEN LFAC_ID_PRSE <> 0 THEN LFAD_MTT_HOR_DEH + LFAD_MTT_DEH ELSE 0 END)  AS LFAD_MTT_SEJOUR,
							SUM(CASE WHEN LFAC_ID_PRHO <> 0 AND FAC_HON = '1' AND FACD_MTT_HON IS DISTINCT FROM 0 THEN LFAD_MTT_HOR_DEH + LFAD_MTT_DEH ELSE 0 END)  AS LFAD_MTT_HON,
							SUM(CASE WHEN LFAD_IND_DIRECT <> 1 AND LFAC_ID_PRSE <> 0 THEN LFAD_MTT_CRN ELSE 0 END) +
								SUM(CASE WHEN LFAD_IND_DIRECT <> 1 AND (HON_TO_SEJ = '1' OR LFAC_CDT_EXC = 'S') AND LFAC_ID_PRHO <> 0 THEN LFAD_MTT_CRN ELSE 0 END) AS LFAD_MTT_CRN_SEJOUR,
							SUM(CASE WHEN LFAD_IND_DIRECT IS DISTINCT FROM 1 AND HON_TO_SEJ <> '1' AND LFAC_CDT_EXC <> 'S' AND LFAC_ID_PRHO <> 0 THEN LFAD_MTT_CRN ELSE 0 END)  AS LFAD_MTT_CRN_HON
						FROM prod_hm.FAC_LIGNE_FACTURE_DEBITEUR
							JOIN prod_hm.FAC_LIGNE_FACTURE ON LFAD_ID_LFAC = LFAC_ID_LFAC
							JOIN w_ctl_fact_t ON LFAC_ID_FACT = FACT_ID_FACT
							LEFT JOIN w_ctl_facd_t ON FACD_ID_FACD = LFAD_ID_FACD
						GROUP BY 1;

						CREATE INDEX w_ctl_facd_d_i1
						ON w_ctl_facd_d
						USING btree
						(LFAD_ID_FACD);
						

					

					SELECT 'SEJ', SEJO_NUM_SEJ, FACT_NUM_FAC, FACT_DAT_CRE, FACV_DAT_VEN, FACV_NB_DAT_VEN, FACD_MTT_SEJOUR, LFAD_MTT_SEJOUR, FACD_MTT_CRN_SEJOUR, LFAD_MTT_CRN_SEJOUR,
						CASE WHEN FACV_NB_DAT_VEN > 1 THEN FACV_NB_DAT_VEN::text || ' dates de vente : ' || FACV_DAT_VEN::text
						WHEN COALESCE(LFAD_MTT_SEJOUR,0) <> FACD_MTT_SEJOUR THEN 'Somme lignes facturées différente du total facture'
						WHEN COALESCE(LFAD_MTT_CRN_SEJOUR,0) <> FACD_MTT_CRN_SEJOUR THEN 'Somme lignes comptabilisées différente du total créance'
						WHEN SEJO_DAT_SUP IS NOT NULL AND COALESCE(LFAD_MTT_CRN_SEJOUR,0) <> 0 THEN 'Séjour supprimé comptabilisé'
						else '' END
					FROM w_ctl_facd_t 
						LEFT JOIN w_ctl_facd_d ON (FACD_ID_FACD = LFAD_ID_FACD) 
						LEFT JOIN w_ctl_facd_v ON (FACD_ID_FACD = FACV_ID_FACD) 
					WHERE COALESCE(LFAD_MTT_SEJOUR,0) <> FACD_MTT_SEJOUR OR COALESCE(LFAD_MTT_CRN_SEJOUR,0) <> FACD_MTT_CRN_SEJOUR OR FACV_NB_DAT_VEN > 1 OR (SEJO_DAT_SUP IS NOT NULL AND COALESCE(LFAD_MTT_CRN_SEJOUR,0) <> 0)
					UNION
					SELECT 'HON', SEJO_NUM_SEJ, FACT_NUM_FAC, FACT_DAT_CRE, FACV_DAT_VEN, FACV_NB_DAT_VEN, FACD_MTT_HON, LFAD_MTT_HON, FACD_MTT_CRN_HON, LFAD_MTT_CRN_HON,
						CASE WHEN FACV_NB_DAT_VEN > 1 THEN FACV_NB_DAT_VEN::text || ' dates de vente : ' || FACV_DAT_VEN::text
						WHEN COALESCE(LFAD_MTT_HON,0) <> FACD_MTT_HON THEN 'Somme lignes différente du total'
						WHEN COALESCE(LFAD_MTT_CRN_HON,0) <> FACD_MTT_CRN_HON THEN 'Somme lignes différente du total'
						WHEN SEJO_DAT_SUP IS NOT NULL AND COALESCE(LFAD_MTT_CRN_HON,0) <> 0 THEN 'Séjour supprimé comptabilisé'
						else '' END
					FROM w_ctl_facd_t 
						LEFT JOIN w_ctl_facd_d ON (FACD_ID_FACD = LFAD_ID_FACD) 
						LEFT JOIN w_ctl_facd_v ON (FACD_ID_FACD = FACV_ID_FACD) 
					WHERE COALESCE(LFAD_MTT_HON,0) <> FACD_MTT_HON OR COALESCE(LFAD_MTT_CRN_HON,0) <> FACD_MTT_CRN_HON OR FACV_NB_DAT_VEN > 1 OR (SEJO_DAT_SUP IS NOT NULL AND COALESCE(LFAD_MTT_CRN_HON,0) <> 0)
					
					ORDER BY 1,2,3

					limit 1000
					
				]]></select>
				<FIELDS>
					<FIELD name="PAR"  />
					<FIELD name="SEJ"  />
					<FIELD name="FAC" />
					<FIELD name="DFAC" />
					<FIELD name="DVEN" />
					<FIELD name="NDVEN" />
					<FIELD name="MTT" />
					<FIELD name="MTD" />
					<FIELD name="MCT" />
					<FIELD name="MCD" />
					<FIELD name="ERR" />
				</FIELDS>
			</SQL>

			
		</QUERY>
		
		
		

		<QUERY> 
			<SQL>
				<select><![CDATA[
					
					DROP TABLE IF EXISTS w_ctl_ventilation_vent;
					CREATE TEMP TABLE w_ctl_ventilation_vent AS
					SELECT VENT_ID_LECR, SUM(VENT_MONTANT) AS montant_ventile
					FROM prod_hm.CCL_VENTILATION
					GROUP BY vent_id_lecr;

					CREATE INDEX w_ctl_ventilation_vent_i1
						  ON w_ctl_ventilation_vent
						  USING btree
						  (VENT_ID_LECR);

					DROP TABLE IF EXISTS w_ctl_ventilation_lecr;
					CREATE TEMP TABLE w_ctl_ventilation_lecr AS
					SELECT 
							LECR_ID_LECR,
							ECRI_LIBELLE,
							date(ECRI_DAT_ECRITURE) AS ECRI_DAT_ECRITURE,
							JOUR_CODE,
							BAS_CATALOGUE_GEN_COMPTE.CAGE_CODE,
							CPTE_NUM_COMPTE,
							LECR_ID_FACD,
							LECR_PART,
							CASE WHEN LECR_SENS = 'D' THEN 0 - LECR_MONTANT ELSE LECR_MONTANT END AS montant_ligne
							FROM prod_hm.CCL_LIGNE_ECRITURE, 
								prod_hm.CCL_ECRITURE, 
								prod_hm.CCL_JOURNAL, 
								prod_hm.CCL_COMPTE, 
								prod_hm.BAS_CATALOGUE_GEN BAS_CATALOGUE_GEN_COMPTE, 
								prod_hm.BAS_CATALOGUE_GEN BAS_CATALOGUE_GEN_JOURNAL
							WHERE 
								LECR_ID_ECRI = ECRI_ID_ECRI
								AND ECRI_ID_JOUR = JOUR_ID_JOUR
								AND LECR_ID_CPTE = CPTE_ID_CPTE
								AND CPTE_ID_CAGE = BAS_CATALOGUE_GEN_COMPTE.CAGE_ID_CAGE
								AND JOUR_ID_CAGE = BAS_CATALOGUE_GEN_JOURNAL.CAGE_ID_CAGE
								AND ECRI_DAT_SUP IS NULL
								AND BAS_CATALOGUE_GEN_COMPTE.CAGE_CODE IN ('CLIENT' , 'ACO85')
								AND BAS_CATALOGUE_GEN_JOURNAL.CAGE_CODE <> 'FACAV'

								AND ECRI_DAT_ECRITURE >= '20090101';

					CREATE INDEX w_ctl_ventilation_lecr_i1
						  ON w_ctl_ventilation_lecr
						  USING btree
						  (LECR_ID_LECR);

					DROP TABLE IF EXISTS w_ctl_ventilation_err; 
					CREATE TEMP TABLE  w_ctl_ventilation_err AS
					SELECT LECR_ID_LECR, ECRI_LIBELLE, ECRI_DAT_ECRITURE, JOUR_CODE, CAGE_CODE, CPTE_NUM_COMPTE, LECR_ID_FACD, LECR_PART, montant_ligne, montant_ventile
					FROM w_ctl_ventilation_lecr, w_ctl_ventilation_vent
					WHERE VENT_ID_LECR = LECR_ID_LECR AND montant_ligne <> montant_ventile;

					CREATE INDEX w_ctl_ventilation_err_i1
						  ON w_ctl_ventilation_err
						  USING btree
						  (LECR_ID_LECR);

					SELECT LECR_ID_LECR, ECRI_LIBELLE, ECRI_DAT_ECRITURE, JOUR_CODE, CAGE_CODE, CPTE_NUM_COMPTE, SEJO_NUM_SEJ, FACT_NUM_FAC, LECR_PART, montant_ligne, montant_ventile
					FROM w_ctl_ventilation_err 
						LEFT JOIN prod_hm.FAC_FACTURE_DEBITEUR ON (LECR_ID_FACD = FACD_ID_FACD)
						LEFT JOIN prod_hm.FAC_FACTURE ON (FACD_ID_FACT = FACT_ID_FACT)
						LEFT JOIN prod_hm.IDE_SEJOUR ON (FACT_ID_SEJO = SEJO_ID_SEJO)
					ORDER BY 1
					LIMIT 1000
			
				]]></select>
				<FIELDS>
					<FIELD name="ILE"  />
					<FIELD name="LIB"  />
					<FIELD name="DAT" />
					<FIELD name="JOU" />
					<FIELD name="TYP" />
					<FIELD name="CPT" />
					<FIELD name="SEJ" />
					<FIELD name="FAC" />
					<FIELD name="PAR" />
					<FIELD name="MTL" />
					<FIELD name="MTV" />
				</FIELDS>
			</SQL>

			
		</QUERY>
	
		<QUERY> 
			<SQL>
				<select><![CDATA[
						DROP TABLE IF EXISTS w_periode;
						CREATE TEMP TABLE w_periode AS
						SELECT date_trunc('month',date(MIN(ECRI_DAT_ECRITURE))) AS date_debut_periode	
						FROM 
							prod_hm.CCL_ECRITURE, 
							prod_hm.CCL_JOURNAL, 
							prod_hm.BAS_CATALOGUE_GEN BAS_CATALOGUE_GEN_JOURNAL
						WHERE 
							ECRI_ID_JOUR = JOUR_ID_JOUR
								AND JOUR_ID_CAGE = BAS_CATALOGUE_GEN_JOURNAL.CAGE_ID_CAGE
								AND ECRI_DAT_SUP IS NULL
								AND BAS_CATALOGUE_GEN_JOURNAL.CAGE_CODE = 'FACAV';

						DROP TABLE IF EXISTS w_IDE_SEJOUR;
						CREATE TEMP TABLE w_IDE_SEJOUR AS
						SELECT 
							CASE WHEN SEJO_NUM_SEJ IS NULL OR SEJO_NUM_SEJ = '' THEN 'W' || SEJO_ID_SEJO::text ELSE SEJO_NUM_SEJ END AS w_SEJO_NUM_SEJ,
							MAX(SEJO_ID_SEJO) AS w_SEJO_ID_SEJO,
							COUNT(*) AS w_SEJO_NB_NUM
						FROM w_periode , prod_hm.IDE_SEJOUR 
						WHERE  SEJO_DAT_SUP IS NULL AND 
							SEJO_IND_INCOMPLET IS DISTINCT FROM '1' AND
							SEJO_STATUT NOT IN ('A', 'P', 'Z') AND 
							(date(SEJO_DAT_DEB) BETWEEN date_debut_periode AND date(now()) + interval '2 day' OR date(SEJO_DAT_FIN) >= date_debut_periode OR SEJO_DAT_FIN IS NULL) AND
							(date(SEJO_DAT_FIN) IS NOT NULL AND date(SEJO_DAT_FIN) <= '20201231' OR SEJO_DAT_FIN IS NULL AND date(SEJO_DAT_DEB) >= date_debut_periode - interval '1 month' )
						GROUP BY 1;

						SELECT 
							PATI_NIP, 
							SEJO_NUM_SEJ, 
							PATI_NOM_USU::text || ' ' || PATI_PRENOM::text, 
							CASE WHEN SEJO_STATUT = 'S' THEN 'Sorti' ELSE 'Présent' END,
							date(SEJO_DAT_DEB), 
							CASE WHEN SEJO_STATUT = 'S' THEN date(SEJO_DAT_FIN) ELSE null END,
							UNFO_CODE,
							BAS_CATALOGUE_GEN_MT.CAGE_CODE::text || BAS_CATALOGUE_GEN_DMT.CAGE_CODE::text,
							CASE WHEN w_SEJO_NB_NUM > 1 THEN  'Deux séjours avec même numéro'
								WHEN PATI_NIP IS NULL OR PATI_NIP = '' THEN 'N° patient absent'
								WHEN SEJO_NUM_SEJ IS NULL OR SEJO_NUM_SEJ = '' THEN 'N° séjour absent'
								WHEN BAS_CATALOGUE_GEN_MT.CAGE_CODE IN ('07', '19', '23') AND SEJO_STATUT <> 'S' THEN 'Externe ou ambulatoire non sorti'
								END
						FROM w_IDE_SEJOUR,
							prod_hm.IDE_PATIENT, 
							prod_hm.IDE_SEJOUR 
							LEFT JOIN prod_hm.BAS_UF ON (SEJO_ID_UNFO = UNFO_ID_UNFO)
							LEFT JOIN prod_hm.BAS_CATEGORIE_UFM ON (UNFO_ID_CUFM = CUFM_ID_CUFM )
							LEFT JOIN prod_hm.BAS_CATALOGUE_GEN BAS_CATALOGUE_GEN_MT ON (CUFM_ID_CAGE_MT = BAS_CATALOGUE_GEN_MT.CAGE_ID_CAGE) 
							LEFT JOIN prod_hm.BAS_CATALOGUE_GEN BAS_CATALOGUE_GEN_DMT ON (CUFM_ID_CAGE_DMT = BAS_CATALOGUE_GEN_DMT.CAGE_ID_CAGE)
						WHERE SEJO_ID_PATI = PATI_ID_PATI AND
							SEJO_ID_SEJO = w_SEJO_ID_SEJO AND
							(
								w_SEJO_NB_NUM > 1 OR
								SEJO_NUM_SEJ IS NULL OR SEJO_NUM_SEJ = '' OR
								PATI_NIP IS NULL OR PATI_NIP = '' OR
								(BAS_CATALOGUE_GEN_MT.CAGE_CODE IN ('07', '19', '23') AND SEJO_STATUT  <>  'S')
							)


						ORDER BY 3,4
				]]></select>
				<FIELDS>
					<FIELD name="NIP"  />
					<FIELD name="SEJ"  />
					<FIELD name="NOM" ifHideNames="Non autorisé" />
					<FIELD name="STA" />
					<FIELD name="DENT" />
					<FIELD name="DSOR" />
					<FIELD name="UF" />
					<FIELD name="DMT" />
					<FIELD name="ERR" />
				</FIELDS>
			</SQL>

			
		</QUERY>
		
			
	</QUERIES> 
	
	<CALCFIELDS>
	</CALCFIELDS>
	
	<PRESENTATION>
	
		<VIEWLINKS>
		
			
		</VIEWLINKS>
		
		<ONGLET excelLabel="Collisions" label="Collisions" queryNumber="0">
				
			<DATAGRID title="" total="false" headerHeight="54" >
			
			
				<COLUMN dataField="NIP" 
					type="Char"
					width="80"
					visible="true"
					headerText="NIP" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="NOM" 
					type="Char"
					minWidth="80"
					visible="true"
					headerText="Nom patient" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="DNAI" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YYYY"
					width="80"
					visible="true"
					headerText="Date naissance" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				
				<COLUMN dataField="SEJ" 
					type="Char"
					width="80"
					visible="true"
					headerText="Séjour" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="DENT" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YYYY"
					width="80"
					visible="true"
					headerText="Date entree" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="DSOR" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YYYY"
					width="80"
					visible="true"
					headerText="Date sortie" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="ERR" 
					type="Char"
					minWidth="100"
					visible="true"
					headerText="Erreur" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>		
					
						
			</DATAGRID>
		
		</ONGLET>
		
		<ONGLET excelLabel="Erreurs Séjours" label="Erreurs Séjours" queryNumber="3">
				
			<DATAGRID title="" total="false" headerHeight="54" >
			
				<COLUMN dataField="NIP" 
					type="Char"
					width="80"
					visible="true"
					headerText="NIP" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="NOM" 
					type="Char"
					minWidth="80"
					visible="true"
					headerText="Nom patient" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				
				
				<COLUMN dataField="SEJ" 
					type="Char"
					width="80"
					visible="true"
					headerText="Séjour" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="STA" 
					type="Char"
					width="80"
					visible="true"
					headerText="Etat" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="DENT" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YYYY"
					width="80"
					visible="true"
					headerText="Date entree" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="DSOR" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YYYY"
					width="80"
					visible="true"
					headerText="Date sortie" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				
				<COLUMN dataField="UF" 
					type="Char"
					width="70"
					visible="true"
					headerText="UF" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="DMT" 
					type="Char"
					width="70"
					visible="true"
					headerText="DMT" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="ERR" 
					type="Char"
					minWidth="200"
					visible="true"
					headerText="Erreur" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
					
						
			</DATAGRID>
		
		</ONGLET>
		
		<ONGLET excelLabel="Ecarts Facturé détail/total" label="Ecarts facturé détail/total" queryNumber="1">
				
			<DATAGRID title="" total="false" headerHeight="54" >
			
				<COLUMN dataField="PAR" 
					type="Char"
					width="40"
					visible="true"
					headerText="SEJ HON" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="SEJ" 
					type="Char"
					width="80"
					visible="true"
					headerText="Séjour" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="FAC" 
					type="Char"
					width="80"
					fixed="false"
					visible="true"
					headerText="Facture" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
														
				<COLUMN dataField="DFAC" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YYYY"
					width="70"
					visible="true"
					headerText="Date facture" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				
				<COLUMN dataField="DVEN" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YYYY"
					width="70"
					visible="true"
					headerText="Date Vente" 
					textAlign="left"
					totalFunction="text"
					totalComplement="">
					<CELLSTYLE name="cellIndicator" value="circle, 5, right top, 0xFF6600" 
							condition="Number(ROW.NDVEN) > 1" />
				</COLUMN>
				<COLUMN dataField="NDVEN" 
					type="Number"
					outputFormat="0"
					width="80"
					fixed="false"
					visible="false"
					headerText="Nb dates ventes" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				
				<COLUMN dataField="MTT" 
					type="Number"
					outputFormat="0,00"
					width="80"
					fixed="false"
					visible="true"
					headerText="Montant facturé débiteur" 
					textAlign="left"
					totalFunction="text"
					totalComplement="">
					<CELLSTYLE name="cellIndicator" value="circle, 5, right top, 0xFF6600" 
							condition="ROW.MTT != ROW.MTD" />
				</COLUMN>
				<COLUMN dataField="MTD" 
					type="Number"
					outputFormat="0,00"
					width="80"
					visible="true"
					headerText="Somme lignes facturées débiteur" 
					textAlign="left"
					totalFunction="text"
					totalComplement="">
					<CELLSTYLE name="cellIndicator" value="circle, 5, right top, 0xFF6600" 
							condition="ROW.MTT != ROW.MTD" />
				</COLUMN>
				
				<COLUMN dataField="MCT" 
					type="Number"
					outputFormat="0,00"
					width="80"
					visible="true"
					headerText="Montant comptabilisé débiteur" 
					textAlign="left"
					totalFunction="text"
					totalComplement="">
					<CELLSTYLE name="cellIndicator" value="circle, 5, right top, 0xFF6600" 
							condition="ROW.MCT != ROW.MCD" />
				</COLUMN>
				<COLUMN dataField="MCD" 
					type="Number"
					outputFormat="0,00"
					width="80"
					visible="true"
					headerText="Somme lignes comptabilisées débiteur" 
					textAlign="left"
					totalFunction="text"
					totalComplement="">
					<CELLSTYLE name="cellIndicator" value="circle, 5, right top, 0xFF6600" 
							condition="ROW.MCT != ROW.MCD" />
				</COLUMN>
				<COLUMN dataField="ERR" 
					type="Char"
					minWidth="200"
					visible="true"
					headerText="Erreur" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
					
						
			</DATAGRID>
		
		</ONGLET>
		
		<ONGLET excelLabel="Ecarts Ventilation règlements" label="Ecarts Ventilation règlements" queryNumber="2">
				
			<DATAGRID title="" total="false" headerHeight="54" >
														
				<COLUMN dataField="DAT" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YYYY"
					width="80"
					visible="true"
					headerText="Date écriture" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="LIB" 
					type="Char"
					minWidth="80"
					visible="true"
					headerText="Libellé" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="SEJ" 
					type="Char"
					width="80"
					visible="true"
					headerText="Séjour" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="FAC" 
					type="Char"
					width="80"
					fixed="false"
					visible="true"
					headerText="Facture" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="JOU" 
					type="Char"
					width="80"
					visible="true"
					headerText="Journal" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="PAR" 
					type="Char"
					width="40"
					visible="true"
					headerText="SEJ HON" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="MTL" 
					type="Number"
					outputFormat="0,00"
					width="80"
					visible="true"
					headerText="Montant ligne écriture" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
				<COLUMN dataField="MTV" 
					type="Number"
					outputFormat="0,00"
					width="80"
					visible="true"
					headerText="Montant ventile facture" 
					textAlign="left"
					totalFunction="text"
					totalComplement=""
				/>
								
					
						
			</DATAGRID>
		
		</ONGLET>
		
		
		
				
				
	</PRESENTATION>
	
</VUE>

			
