|
|
-- 1/3 : Création de la table temporaire
|
|
|
DROP TABLE IF EXISTS w_dbsetup
|
|
|
;
|
|
|
|
|
|
CREATE TEMP TABLE w_dbsetup AS
|
|
|
SELECT
|
|
|
CASE WHEN t_indicateur_theme.oid = 0 THEN t_indicateur_theme.oid ELSE 1 END AS oid,
|
|
|
t_indicateur_theme.code,
|
|
|
t_indicateur_theme.texte,
|
|
|
t_indicateur_theme.level,
|
|
|
COALESCE(t_indicateur_parent_theme.code,'') AS parent_code
|
|
|
FROM activite.t_indicateur_theme
|
|
|
LEFT JOIN activite.t_indicateur_theme t_indicateur_parent_theme ON t_indicateur_theme.parent_id = t_indicateur_parent_theme.oid
|
|
|
ORDER BY 2 LIMIT 0
|
|
|
;
|
|
|
|
|
|
-- 2/3 : Peuplement de la table temporaire
|
|
|
INSERT INTO w_dbsetup(
|
|
|
oid,
|
|
|
code,
|
|
|
texte,
|
|
|
level,
|
|
|
parent_code
|
|
|
)
|
|
|
VALUES
|
|
|
(1, '--0', 'Source', 1, ''),
|
|
|
(1, '--1', 'Thèmes principaux', 1, ''),
|
|
|
(1, '--2', 'Période', 1, ''),
|
|
|
(1, '--3', 'Rapports et essentiels', 1, ''),
|
|
|
(1, '--4', 'Type de donnée', 1, ''),
|
|
|
(1, '--DACTE', 'Date acte', 2, '--2'),
|
|
|
(1, '--DCOMPTABLE', 'Date comptable', 2, '--2'),
|
|
|
(1, '--DFACTURE', 'Date facture', 2, '--2'),
|
|
|
(1, '--DGROUPAGE', 'Date groupage', 2, '--2'),
|
|
|
(1, '--DINTERVENTION', 'Date intervention', 2, '--2'),
|
|
|
(1, '--DJOUR', 'Date jour', 2, '--2'),
|
|
|
(1, '--DMOUVEMENT', 'Date mouvement', 2, '--2'),
|
|
|
(1, '--DSORTIE', 'Date sortie', 2, '--2'),
|
|
|
(1, '--DVENTES', 'Date ventes', 2, '--2'),
|
|
|
(1, '--R1', 'Rapports CTI', 2, '--3'),
|
|
|
(1, '--R3', 'Rapports Etablissement', 2, '--3'),
|
|
|
(1, '--S1', 'Indicateurs CTI', 2, '--0'),
|
|
|
(1, '--S2', 'Indicateurs Groupe', 2, '--0'),
|
|
|
(1, '--S3', 'Indicateurs spécifiques Etablissement', 2, '--0'),
|
|
|
(1, '--T0001', 'Superviseur d''activité', 2, '--1'),
|
|
|
(1, '--T0002', 'Occupation', 2, '--1'),
|
|
|
(1, '--T0003', 'Places', 2, '--1'),
|
|
|
(1, '--T0004', 'Facturation Clinique', 2, '--1'),
|
|
|
(1, '--T0005', 'Clients Clinique', 2, '--1'),
|
|
|
(1, '--T0006', 'Facturation Honoraires', 2, '--1'),
|
|
|
(1, '--T0007', 'Clients Honoraire', 2, '--1'),
|
|
|
(1, '--T0008', 'En-cours', 2, '--1'),
|
|
|
(1, '--T0011', 'Occupation bloc', 2, '--1'),
|
|
|
(1, '--T0097', 'Calendrier', 2, '--1'),
|
|
|
(1, '-TS', 'Type de séjour', 1, ''),
|
|
|
(1, '-TS1', 'Hospitalisé', 2, '-TS'),
|
|
|
(1, '-TS2', 'Ambulatoires', 2, '-TS'),
|
|
|
(1, '-TS3', 'Externes', 2, '-TS'),
|
|
|
(1, '-TS5', 'Séances', 2, '-TS'),
|
|
|
(1, 'CA', 'Chiffre d''affaire', 2, '--4'),
|
|
|
(1, 'CACP', 'C.A. Comptabilisé', 3, 'CA'),
|
|
|
(1, 'CAF', 'C.A. Facturé', 3, 'CA'),
|
|
|
(1, 'CAHON', 'C.A. Honoraire', 3, 'CA'),
|
|
|
(1, 'CARG', 'C.A. Réglé', 3, 'CA'),
|
|
|
(1, 'CASL', 'C.A. Solde', 3, 'CA'),
|
|
|
(1, 'CAV', 'C.A. Valorisé', 3, 'CA'),
|
|
|
(1, 'CAVF', 'C.A. Facturé et Valorisé', 3, 'CA'),
|
|
|
(1, 'NBENT', 'Nombre Entrées', 3, 'NOMBRE'),
|
|
|
(1, 'NBJOU', 'Nombre Jours', 3, 'NOMBRE'),
|
|
|
(1, 'NBRUB', 'Nombre Rubriques', 3, 'NOMBRE'),
|
|
|
(1, 'NBSEJ', 'Nombre Séjours', 3, 'NOMBRE'),
|
|
|
(1, 'NBSOR', 'Nombre Sorties', 3, 'NOMBRE'),
|
|
|
(1, 'NOMBRE', 'Nombre', 2, '--4'),
|
|
|
(1, 'TAUX', 'Taux', 2, '--4')
|
|
|
;
|
|
|
|
|
|
-- 3/3 : Màj de la table iCTI
|
|
|
INSERT INTO activite.t_indicateur_theme (code, texte, level)
|
|
|
SELECT code, texte, level
|
|
|
FROM w_dbsetup
|
|
|
WHERE code NOT IN (SELECT code FROM activite.t_indicateur_theme WHERE t_indicateur_theme.code IS NOT NULL)
|
|
|
;
|
|
|
|
|
|
UPDATE activite.t_indicateur_theme SET
|
|
|
texte = w_dbsetup.texte,
|
|
|
level = w_dbsetup.level,
|
|
|
parent_id = COALESCE(t_indicateur_parent_theme.oid,0)
|
|
|
FROM w_dbsetup
|
|
|
LEFT JOIN activite.t_indicateur_theme t_indicateur_parent_theme ON w_dbsetup.parent_code = t_indicateur_parent_theme.code
|
|
|
WHERE t_indicateur_theme.code = w_dbsetup.code AND
|
|
|
(
|
|
|
t_indicateur_theme.texte IS DISTINCT FROM w_dbsetup.texte OR
|
|
|
t_indicateur_theme.level IS DISTINCT FROM w_dbsetup.level OR
|
|
|
t_indicateur_theme.parent_id IS DISTINCT FROM COALESCE(t_indicateur_parent_theme.oid,0)
|
|
|
)
|
|
|
;
|
|
|
|
|
|
|
|
|
SELECT base.cti_reorganize_indicateur_theme('activite')
|
|
|
;
|