return: void
|
|
lang: plpgsql
|
|
src: |
|
|
BEGIN
|
|
|
|
-- Appeler les différentes fonctions de valorisation
|
|
-- Insérer les enregistrements renvoyés par ces fonctions dans la table finale p_gmt_valorises
|
|
-- TODO : Gestion des logs et des erreurs
|
|
-- TODO : Sous forme de transactions
|
|
|
|
TRUNCATE activite.p_gmt_valorises;
|
|
|
|
-- Insertion des montants calculés pour les séjours ayant des GMT forfaitisables
|
|
INSERT INTO activite.p_gmt_valorises(
|
|
no_sejour
|
|
, gme_code
|
|
, gmt_code
|
|
, gmt_libelle
|
|
, date_debut_gmt
|
|
, date_fin_gmt
|
|
, montant_valorise
|
|
, montant_valorise_par_jour
|
|
)
|
|
SELECT
|
|
no_sejour
|
|
, gme_code
|
|
, gmt_code
|
|
, gmt_libelle
|
|
, date_debut_gmt
|
|
, date_fin_gmt
|
|
, montant_valorise
|
|
, montant_valorise_par_jour
|
|
FROM activite.get_valorisation_gmt_forfaitisables();
|
|
|
|
-- Insertion des montants calculés pour les séjours ayant des GMT non forfaitisables
|
|
INSERT INTO activite.p_gmt_valorises(
|
|
no_sejour
|
|
,gme_code
|
|
,gmt_code
|
|
,gmt_libelle
|
|
,date_debut_gmt
|
|
,date_fin_gmt
|
|
,montant_valorise
|
|
,montant_valorise_par_jour
|
|
)
|
|
SELECT
|
|
no_sejour
|
|
, gme_code
|
|
, gmt_code
|
|
, gmt_libelle
|
|
, date_debut_gmt
|
|
, date_fin_gmt
|
|
, montant_valorise
|
|
, montant_valorise_par_jour
|
|
FROM activite.get_valorisation_gmt_non_forfaitisables();
|
|
|
|
-- Insertion des montants calculés pour les séjours ayant des GMT sans zone forfaitaire (GMT en 8, GMT en 7, et GMT avec DZF = FZF = 90 ou 7)
|
|
INSERT INTO activite.p_gmt_valorises(
|
|
no_sejour
|
|
, gme_code
|
|
, gmt_code
|
|
, gmt_libelle
|
|
, date_debut_gmt
|
|
, date_fin_gmt
|
|
, montant_valorise
|
|
, montant_valorise_par_jour
|
|
)
|
|
SELECT
|
|
no_sejour
|
|
, gme_code
|
|
, gmt_code
|
|
, gmt_libelle
|
|
, date_debut_gmt
|
|
, date_fin_gmt
|
|
, montant_valorise
|
|
, montant_valorise_par_jour
|
|
FROM activite.get_valorisation_gmt_hc_sans_zf();
|
|
|
|
-- Insertion des montants calculés pour les séjours ayant des GMT hospitalisation partielle
|
|
INSERT INTO activite.p_gmt_valorises(
|
|
no_sejour
|
|
, gme_code
|
|
, gmt_code
|
|
, gmt_libelle
|
|
, date_debut_gmt
|
|
, date_fin_gmt
|
|
, montant_valorise
|
|
, montant_valorise_par_jour
|
|
)
|
|
SELECT
|
|
no_sejour
|
|
, gme_code
|
|
, gmt_code
|
|
, gmt_libelle
|
|
, date_debut_gmt
|
|
, date_fin_gmt
|
|
, montant_valorise
|
|
, montant_valorise_par_jour
|
|
FROM activite.get_valorisation_gmt_hospitalisation_partielle();
|
|
END;
|