-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Jean-Baptiste-N/Dev
Dev
- Loading branch information
Showing
11 changed files
with
109 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
models/join_total_morbidite/class_join_total_morbidite_sexe.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
models/staging/capacite_services_h/stg_capacite_services_h__capacite_2021_service_stjr.sql
This file was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
...staging/capacite_services_h/stg_capacite_services_h__capacite_2022_etablissement_stjr.sql
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
.../staging/capacite_services_h/stg_capacite_services_h__capacite_2022_par_etablissement.sql
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
models/staging/capacite_services_h/stg_capacite_services_h__capacite_2022_par_services.sql
This file was deleted.
Oops, something went wrong.
44 changes: 0 additions & 44 deletions
44
models/staging/morbidite_h/stg_morbidite_h__duree_sejours.sql
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.