1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
| CREATE VIEW EXPORT.V_Param_Fact_Admission
AS
SELECT 'VTE' as Code_journal,dbo.FUNC_FORMAT_DATE(Date_dossier_admission)as Echeance,Num_facture_simple as Num_piece,
'411100' as Num_compte_general,'D' AS Sens,SUM(Montant_Pris_En_Charge) AS Montant_Debit,0 AS Montant_credit, 'Facture'+'/'+ Nom_prenom + '/' + Employeur as Libelle_ecriture,
case when Num_facture_simple like'%10CFH%' then Libelle_Param_Tiers ELSE '411DIVERS'END AS Num_compte_Tiers,'G' as Type_ecriture
FROM EXPORT.V_Param_Hospitalisation
WHERE Date_dossier_admission between '01/01/2010' AND '31/01/2010'and type_facture<>'PROFORMA'--and Num_facture_simple like'%10FA%'
GROUP BY Date_dossier_admission,Num_facture_simple,Nom_prenom,Employeur,type_facture,Libelle_Param_Tiers
union all
SELECT 'VTE' as Code_journal,dbo.FUNC_FORMAT_DATE(Date_dossier_admission)as Echeance,Num_facture_simple as Num_piece,
'411100' as Num_compte_general,'D' AS Sens,SUM(Montant_Patient) AS Montant_Debit,0 AS Montant_credit,
'Facture'+'/'+ Nom_prenom + '/' + Employeur as Libelle_ecriture,'411'+ Nom_patient AS Num_compte_Tiers,'G' as Type_ecriture
FROM EXPORT.V_Param_Hospitalisation2
WHERE Date_dossier_admission between '01/01/2010' AND '31/01/2010'and type_facture<>'PROFORMA' ---and Num_facture_simple like'%10CFH%'--and Num_facture_simple like'%10FA%'
GROUP BY Date_dossier_admission,Num_facture_simple,Nom_patient,Employeur,type_facture,Libelle_Param_Tiers,Nom_prenom
union all
SELECT 'VTE'as Code_journal,dbo.FUNC_FORMAT_DATE(Date_dossier_admission) AS Echeance, Num_facture_simple AS Num_piece,
case when Libelle_famille_acte='CONSULTATION' then '706100'
when Libelle_famille_acte='CHAMBRE' then '706104'
when Libelle_famille_acte='LABORATOIRE' then '706103'
when Libelle_famille_acte='HONORAIRES MEDECINS' then '706100'
when Libelle_famille_acte='ECHOGRAPHIE' then '706103'
when Libelle_famille_acte='ECHOGRAPHIE DOPPLER CARDIAQUE' then '706103'
when Libelle_famille_acte='ECHOGRAPHIE DOPPLER CAROTIDIEN' then '706103'
when Libelle_famille_acte='ECHOGRAPHIE DOPPLER VASCULAIRE' then '706103'
when Libelle_famille_acte='RADIOLOGIE' then '706102'
when Libelle_famille_acte='CHIRURGIE' then '706101'
when Libelle_famille_acte='MEDICAMENTS' then '706100'
when Libelle_famille_acte='ACCOUCHEMENTS' then '706103'
when Libelle_famille_acte='SOIN' then '706103'
when Libelle_famille_acte='AUTRES SERVICES' then '706103'
when Libelle_famille_acte='BLOC OPERATOIRE' then '706103'
when Libelle_famille_acte='CARDIOLOGIE' then '706100'
when Libelle_famille_acte='GYNECOLOGIE' then '706100'
when Libelle_famille_acte='MEDECINE INTERNE' then '706103'
when Libelle_famille_acte='REANIMATION' then '706103'
when Libelle_famille_acte='ORL ET CCF' then '706100'
when Libelle_famille_acte='URGENCES' then '706103'
when Libelle_famille_acte='VISCERALE' then '706103'
when Libelle_famille_acte='IRM' then '706103'
when Libelle_famille_acte='SCANNER' then '706102'
when Libelle_famille_acte='OPHTALMOLOGIE' then '706100'
when Libelle_famille_acte='ORTHOPEDIE' then '706100'
when Libelle_famille_acte='SOINS INTENSIFS' then '706103'
when Libelle_famille_acte='GRANDS BRULES' then '706103'
when Libelle_famille_acte='ACTES MEDICAUX INFIRMIERS' then '706103'
when Libelle_famille_acte='DENTISTERIE' then '706100'
when Libelle_famille_acte='GASTROLOGIE' then '706100'
when Libelle_famille_acte='CERTIFICATS' then '706103'
when Libelle_famille_acte='AVANCE HOSPITALISATION' then '471201'
when Libelle_famille_acte='PHARMACIE' then '701100'
when Libelle_famille_acte='RETRAIT CAUTION' then '471201'
when Libelle_famille_acte='VISITE' then '706100'
when Libelle_famille_acte='AVANCE OU CAUTION HOSPITALISATION' then '471201'
when Libelle_famille_acte='ENDOCRINOLOGIE' then '706100'
when Libelle_famille_acte='NEUROLOGIE' then '706100'
when Libelle_famille_acte='KINESITHERAPIE' then '706100'
when Libelle_famille_acte='DERMATOLOGIE' then '706100'
when Libelle_famille_acte='ANESTHESIE' then '706103'
when Libelle_famille_acte='PRESTATIONS' then '706103'
when Libelle_famille_acte='AMBULANCE' then '706103'
when Libelle_famille_acte='CAUTIONS' then '471201'
when Libelle_famille_acte='COUVEUSE SOINS INTENSIFS/JOUR' then '706103'
when Libelle_famille_acte='PHOTOTHERAPIE' then '706103'
when Libelle_famille_acte='AMNIOCENTESE' then '706103'
when Libelle_famille_acte='DIVERS' then '706103'
when Libelle_famille_acte='OXYGENE EN URGENCE' then '706103'
when Libelle_famille_acte='FORFAIT JOURNALIER' then '706103'
-- when Code_salle '' then '443200'
when Libelle_famille_acte='FRAIS D''HOSPITALISATION' then '706103'
END as Num_compte_general,
'C' AS Sens, 0 AS Montant_Debit,
case when Libelle_famille_acte='CONSULTATION' then SUM(Montant_total_Ht)
-- when Code_salle '' then SUM(Montant_Tva)
when Libelle_famille_acte='CHAMBRE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='LABORATOIRE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='HONORAIRES MEDECINS' then SUM(Montant_total_Ht)
when Libelle_famille_acte='ECHOGRAPHIE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='ECHOGRAPHIE DOPPLER CARDIAQUE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='ECHOGRAPHIE DOPPLER CAROTIDIEN' then SUM(Montant_total_Ht)
when Libelle_famille_acte='ECHOGRAPHIE DOPPLER VASCULAIRE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='RADIOLOGIE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='CHIRURGIE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='MEDICAMENTS' then SUM(Montant_total_Ht)
when Libelle_famille_acte='ACCOUCHEMENTS' then SUM(Montant_total_Ht)
when Libelle_famille_acte='SOIN' then SUM(Montant_total_Ht)
when Libelle_famille_acte='AUTRES SERVICES' then SUM(Montant_total_Ht)
when Libelle_famille_acte='BLOC OPERATOIRE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='CARDIOLOGIE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='GYNECOLOGIE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='MEDECINE INTERNE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='REANIMATION' then SUM(Montant_total_Ht)
when Libelle_famille_acte='ORL ET CCF' then SUM(Montant_total_Ht)
when Libelle_famille_acte='URGENCES' then SUM(Montant_total_Ht)
when Libelle_famille_acte='VISCERALE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='IRM' then SUM(Montant_total_Ht)
when Libelle_famille_acte='SCANNER' then SUM(Montant_total_Ht)
when Libelle_famille_acte='OPHTALMOLOGIE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='ORTHOPEDIE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='SOINS INTENSIFS' then SUM(Montant_total_Ht)
when Libelle_famille_acte='GRANDS BRULES' then SUM(Montant_total_Ht)
when Libelle_famille_acte='ACTES MEDICAUX INFIRMIERS' then SUM(Montant_total_Ht)
when Libelle_famille_acte='DENTISTERIE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='GASTROLOGIE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='CERTIFICATS' then SUM(Montant_total_Ht)
when Libelle_famille_acte='AVANCE HOSPITALISATION' then SUM(Montant_total_Ht)
when Libelle_famille_acte='PHARMACIE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='RETRAIT CAUTION' then SUM(Montant_total_Ht)
when Libelle_famille_acte='VISITE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='AVANCE OU CAUTION HOSPITALISATION' then SUM(Montant_total_Ht)
when Libelle_famille_acte='ENDOCRINOLOGIE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='NEUROLOGIE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='KINESITHERAPIE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='DERMATOLOGIE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='ANESTHESIE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='PRESTATIONS' then SUM(Montant_total_Ht)
when Libelle_famille_acte='AMBULANCE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='CAUTIONS' then SUM(Montant_total_Ht)
when Libelle_famille_acte='COUVEUSE SOINS INTENSIFS/JOUR' then SUM(Montant_total_Ht)
when Libelle_famille_acte='PHOTOTHERAPIE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='AMNIOCENTESE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='DIVERS' then SUM(Montant_total_Ht)
when Libelle_famille_acte='OXYGENE EN URGENCE' then SUM(Montant_total_Ht)
when Libelle_famille_acte='FORFAIT JOURNALIER' then SUM(Montant_total_Ht)
when Libelle_famille_acte='FRAIS D''HOSPITALISATION' then SUM(Montant_total_Ht)
END as Montant_credit,
case when Libelle_famille_acte='CONSULTATION' then 'CONSULTATION'
when Libelle_famille_acte='CHAMBRE' then 'HOSPITALISATION'
-- when Code_salle '' then 'TVA FACTUREE/PRESTATION DE SERVICE'
when Libelle_famille_acte='LABORATOIRE' then 'LABORATOIRE'
when Libelle_famille_acte='HONORAIRES MEDECINS' then 'HONORAIRES MEDECINS'
when Libelle_famille_acte='ECHOGRAPHIE' then 'ECHOGRAPHIE'
when Libelle_famille_acte='ECHOGRAPHIE DOPPLER CARDIAQUE' then 'ECHOGRAPHIE DOPPLER CARDIAQUE'
when Libelle_famille_acte='ECHOGRAPHIE DOPPLER CAROTIDIEN' then 'ECHOGRAPHIE DOPPLER CAROTIDIEN'
when Libelle_famille_acte='ECHOGRAPHIE DOPPLER VASCULAIRE' then 'ECHOGRAPHIE DOPPLER VASCULAIRE'
when Libelle_famille_acte='RADIOLOGIE' then 'RADIOLOGIE'
when Libelle_famille_acte='CHIRURGIE' then 'CHIRURGIE'
when Libelle_famille_acte='MEDICAMENTS' then 'MEDICAMENTS'
when Libelle_famille_acte='ACCOUCHEMENTS' then 'ACCOUCHEMENTS'
when Libelle_famille_acte='SOIN' then 'SOIN'
when Libelle_famille_acte='AUTRES SERVICES' then 'AUTRES SERVICES'
when Libelle_famille_acte='BLOC OPERATOIRE' then 'BLOC OPERATOIRE'
when Libelle_famille_acte='CARDIOLOGIE' then 'CARDIOLOGIE'
when Libelle_famille_acte='GYNECOLOGIE' then 'GYNECOLOGIE'
when Libelle_famille_acte='MEDECINE INTERNE' then 'MEDECINE INTERNE'
when Libelle_famille_acte='REANIMATION' then 'REANIMATION'
when Libelle_famille_acte='ORL ET CCF' then 'ORL ET CCF'
when Libelle_famille_acte='URGENCES' then 'URGENCES'
when Libelle_famille_acte='VISCERALE' then 'VISCERALE'
when Libelle_famille_acte='IRM' then 'IRM'
when Libelle_famille_acte='SCANNER' then 'SCANNER'
when Libelle_famille_acte='OPHTALMOLOGIE' then 'OPHTALMOLOGIE'
when Libelle_famille_acte='ORTHOPEDIE' then 'ORTHOPEDIE'
when Libelle_famille_acte='SOINS INTENSIFS' then 'SOINS INTENSIFS'
when Libelle_famille_acte='GRANDS BRULES' then 'GRANDS BRULES'
when Libelle_famille_acte='ACTES MEDICAUX INFIRMIERS' then 'ACTES MEDICAUX INFIRMIERS'
when Libelle_famille_acte='DENTISTERIE' then 'DENTISTERIE'
when Libelle_famille_acte='GASTROLOGIE' then 'GASTROLOGIE'
when Libelle_famille_acte='CERTIFICATS' then 'CERTIFICATS'
when Libelle_famille_acte='AVANCE HOSPITALISATION' then 'AVANCE HOSPITALISATION'
when Libelle_famille_acte='PHARMACIE' then 'PHARMACIE'
when Libelle_famille_acte='RETRAIT CAUTION' then 'RETRAIT CAUTION'
when Libelle_famille_acte='VISITE' then 'VISITE'
when Libelle_famille_acte='AVANCE OU CAUTION HOSPITALISATION' then 'AVANCE OU CAUTION HOSPITALISATION'
when Libelle_famille_acte='ENDOCRINOLOGIE' then 'ENDOCRINOLOGIE'
when Libelle_famille_acte='NEUROLOGIE' then 'NEUROLOGIE'
when Libelle_famille_acte='KINESITHERAPIE' then 'KINESITHERAPIE'
when Libelle_famille_acte='DERMATOLOGIE' then 'DERMATOLOGIE'
when Libelle_famille_acte='ANESTHESIE' then 'ANESTHESIE'
when Libelle_famille_acte='PRESTATIONS' then 'PRESTATIONS'
when Libelle_famille_acte='AMBULANCE' then 'AMBULANCE'
when Libelle_famille_acte='CAUTIONS' then 'CAUTIONS'
when Libelle_famille_acte='COUVEUSE SOINS INTENSIFS/JOUR' then 'COUVEUSE SOINS INTENSIFS/JOUR'
when Libelle_famille_acte='PHOTOTHERAPIE' then 'PHOTOTHERAPIE'
when Libelle_famille_acte='AMNIOCENTESE' then 'AMNIOCENTESE'
when Libelle_famille_acte='DIVERS' then 'DIVERS'
when Libelle_famille_acte='OXYGENE EN URGENCE' then 'OXYGENE EN URGENCE'
when Libelle_famille_acte='FORFAIT JOURNALIER' then 'FORFAIT JOURNALIER'
when Libelle_famille_acte='FRAIS D''HOSPITALISATION' then 'FRAIS D''HOSPITALISATION'
END as Libelle_ecriture,
''as Num_compte_Tiers, 'G' AS Type_ecriture
FROM EXPORT.V_Param_Hospitalisation
WHERE Date_dossier_admission between '01/01/2010' AND '31/01/2010'and type_facture<>'PROFORMA'--and Num_facture_simple like'%10FA%'
GROUP BY Date_dossier_admission,Num_facture_simple,Libelle_FAMILLE_ACTE
union all
SELECT 'VTE'as Code_journal,dbo.FUNC_FORMAT_DATE(Date_dossier_admission) AS Echeance, Num_facture_simple AS Num_piece,'443200' as Num_compte_general,
'C' AS Sens,0 AS Montant_Debit, SUM(Montant_Tva) AS Montant_credit,'TVA FACTUREE/PRESTATION DE SERVICE' Libelle_ecriture,
'' as Num_compte_Tiers, 'G' AS Type_ecriture
FROM EXPORT.V_Param_Hospitalisation2
WHERE Date_dossier_admission between '01/01/2010' AND '31/01/2010'and type_facture<>'PROFORMA'--and Num_facture_simple like'%10FA%'
GROUP BY Date_dossier_admission,Num_facture_simple |
Partager