Skip to content

Commit

Permalink
Merge pull request #14 from Jean-Baptiste-N/Dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Jean-Baptiste-N authored Dec 2, 2024
2 parents 25580d9 + 8507bce commit 3970d72
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 319 deletions.
36 changes: 1 addition & 35 deletions models/capacite/int_capacite_service.sql
Original file line number Diff line number Diff line change
@@ -1,37 +1,3 @@
-- With stjr1 as (
-- SELECT
-- t1.*,
-- t2.stjr
-- FROM {{ref('stg_capacite_services_h__capacite_2022_par_services')}} t1
-- LEFT JOIN (
-- SELECT DISTINCT FI, AN, stjr
-- FROM {{ref('stg_capacite_services_h__capacite_2021_service_stjr')}}
-- WHERE AN = 2021
-- ) t2
-- ON t1.fi = t2.FI
-- WHERE t1.an >= 2018 AND t1.an < 2022
-- ),
-- stjr2 as (
-- SELECT
-- t1.*,
-- t2.stjr
-- FROM {{ref('stg_capacite_services_h__capacite_2022_par_services')}} t1
-- LEFT JOIN (
-- SELECT DISTINCT fi, an, stjr
-- FROM {{ref('stg_capacite_services_h__capacite_2022_etablissement_stjr')}}
-- WHERE AN = 2022
-- ) t2
-- ON CAST(t1.fi AS STRING) = t2.fi
-- WHERE t1.an = 2022
-- ),
-- join_stjr as (
-- SELECT *
-- FROM stjr1
-- UNION ALL
-- SELECT *
-- FROM stjr2
-- )

SELECT
fi as id_etablissement,
an as annee,
Expand Down Expand Up @@ -59,5 +25,5 @@ SEHEM as seance_hemodyalise,
SERAD as seance_radiotherapie,
SECHI as seance_chimio,
cle_unique
FROM {{ref('stg_capacite_services_h__capacite_2022_par_services')}}
FROM {{ref('stg_capacite_services_h__capacite_2022_par_service')}}
WHERE an >= 2018
2 changes: 1 addition & 1 deletion models/duree_sejours_total/int_duree_sejours_total.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SELECT niveau,
cle_unique,
CONCAT(region , "_" , code_pathologie ,"_" , annee) as cle_unique,
annee,
year,
pathologie,
Expand Down
96 changes: 96 additions & 0 deletions models/join_total_morbidite/class_join_total_morbidite_sexe.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
WITH mega_join AS (
SELECT
t1.niveau
,t1.cle_unique
,t1.sexe
,t1.year
,t1.annee
,t1.pathologie
,t1.code_pathologie
,t1.nom_pathologie
,t1.region
,t1.code_region
,t1.nom_region
,t1.nbr_hospi
,t1.evolution_nbr_hospi1 as evolution_nbr_hospi
,t1.evolution_percent_nbr_hospi1 as evolution_percent_nbr_hospi

,t2.AVG_duree_hospi
,t2.evolution_hospi_total_24h1 as evolution_hospi_total_24h
,t2.evolution_percent_hospi_total_24h1 as evolution_percent_hospi_total_24h
,t2.evolution_hospi_total_jj1 as evolution_hospi_total_jj
,t2.evolution_percent_hospi_total_jj1 as evolution_percent_hospi_total_jj
,t2.evolution_total_hospi2 as evolution_total_hospi
,t2.evolution_percent_total_hospi2 as evolution_percent_total_hospi
,t2.evolution_AVG_duree_hospi1 as evolution_AVG_duree_hospi
,t2.evolution_percent_AVG_duree_hospi1 as evolution_percent_AVG_duree_hospi

,t3.tranche_age_0_1
,t3.tranche_age_1_4
,t3.tranche_age_5_14
,t3.tranche_age_15_24
,t3.tranche_age_25_34
,t3.tranche_age_35_44
,t3.tranche_age_45_54
,t3.tranche_age_55_64
,t3.tranche_age_65_74
,t3.tranche_age_75_84
,t3.tranche_age_85_et_plus
,t3.tx_brut_tt_age_pour_mille
,t3.tx_standard_tt_age_pour_mille
,t3.indice_comparatif_tt_age_percent
,t3.evolution_tx_brut_tt_age_pour_mille1 as evolution_tx_brut_tt_age_pour_mille
,t3.evolution_percent_tx_brut_tt_age_pour_mille1 as evolution_percent_tx_brut_tt_age_pour_mille
,t3.evolution_tx_standard_tt_age_pour_mille2 as evolution_tx_standard_tt_age_pour_mille
,t3.evolution_percent_tx_standard_tt_age_pour_mille2 as evolution_percent_tx_standard_tt_age_pour_mille
,t3.evolution_indice_comparatif_tt_age_percent1 as evolution_indice_comparatif_tt_age_percent
,t3.evolution_percent_indice_comparatif_tt_age_percent1 as evolution_percent_indice_comparatif_tt_age_percent

FROM
{{ref("mart_nbr_hospi_total_evol")}} t1
LEFT JOIN
{{ref("mart_duree_sejours_total_evol")}} t2
ON t1.cle_unique = t2.cle_unique
INNER JOIN
{{ref("mart_taux_recours_total_evol")}} t3
ON t1.cle_unique = t3.cle_unique
AND t1.sexe = t3.sexe
WHERE
t1.tranche_age = 'Tous âges confondus'
),
mega_join_class as (
SELECT
t1.*
,classification
FROM mega_join AS t1
LEFT JOIN {{ref("stg_morbidite_h__class_services")}} c2
ON t1.nom_pathologie = c2.pathologie
ORDER BY cle_unique
),
join_dpt AS (
SELECT
t1.*,
t2.population AS population
FROM mega_join_class t1
LEFT JOIN {{ ref("stg_pop_departement__population_departement") }} t2
ON t1.annee = t2.annee
AND t1.nom_region = t2.nom_departement
WHERE t1.niveau = 'Départements'
),
join_reg AS (
SELECT
t1.*,
t2.population AS population
FROM mega_join_class t1
LEFT JOIN {{ ref("stg_pop_departement__population_region") }} t2
ON t1.annee = t2.annee
AND t1.nom_region = t2.region
WHERE t1.niveau = 'Régions'
)

SELECT *
FROM join_dpt
UNION ALL
SELECT *
FROM join_reg

28 changes: 11 additions & 17 deletions models/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ sources:
- name: morbidite_h
schema: morbidite_h
tables:
- name: taux_recours
identifier: tranche_age_hospi_clean
- name: taux_recours3
identifier: tableau_3_ren
description: "test"
- name: duree_sejours
identifier: duree_hospi_clean
- name: duree_sejours2
identifier: tableau_2_ren
description: "test"
- name: nombre_hospit
identifier: nbr_hospi_clean
- name: nombre_hospit1
identifier: tableau_1_ren
description: 'test'

- name: class_services
Expand All @@ -32,17 +32,11 @@ sources:
- name: capacite_services_h
schema: capacite_services_h
tables:
- name: capacite_2022_par_services
identifier: capacite_2022_par_services
description: "Test"
- name: capacite_2022_par_etablissement
identifier: capacite_2022_par_etablissement
description: "Test"
- name: capacite_2022_etablissement_stjr
identifier: capacite_2022_etablissement_stjr
description: "Test"
- name: capacite_2021_service_stjr
identifier: capacite_2021_service_stjr
- name: capacite_2022_par_service_clean
identifier: capacite_2022_par_service_clean
description: "Tebrfbest"
- name: capacite_2022_par_etablissement_clean
identifier: capacite_2022_par_etablissement_clean
description: "Test"
- name: capacite_services_dpt_region
identifier: capacite_services_dpt_region
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

44 changes: 0 additions & 44 deletions models/staging/morbidite_h/stg_morbidite_h__duree_sejours.sql

This file was deleted.

Loading

0 comments on commit 3970d72

Please sign in to comment.