Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Baptiste-N committed Dec 5, 2024
2 parents 994fafa + 5ee35a6 commit bf85836
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 99 deletions.
2 changes: 1 addition & 1 deletion models/capacite/int_capacite_service.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,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_service')}}
FROM {{ref('stg_capacite_services_h__capacite_2022_par_service1')}}
WHERE an >= 2018
2 changes: 1 addition & 1 deletion models/interrmediate/int_taux_recours_dpt_intermediate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SPLIT(region, " - ")[SAFE_OFFSET(1)] AS nom_departement,
SAFE_CAST(NULLIF(tx_brut_tt_age_pour_mille, 'ND') AS FLOAT64) AS tx_brut_tt_age_pour_mille,
SAFE_CAST(NULLIF(tx_standard_tt_age_pour_mille, 'ND') AS FLOAT64) AS tx_standard_tt_age_pour_mille,
SAFE_CAST(NULLIF(indice_comparatif_tt_age_percent, 'ND') AS FLOAT64) AS indice_comparatif_tt_age_percent
FROM {{ref("stg_morbidite_h__taux_recours")}}
FROM {{ref("stg_morbidite_h__taux_recours2")}}
WHERE NOT (region LIKE '3 - France%' OR region LIKE '1 - France%')
AND niveau LIKE "Départements"
AND nom_pathologie != 'TOTAL TOUTES CAUSES'
Expand Down
96 changes: 0 additions & 96 deletions models/join_total_morbidite/class_join_total_morbidite_sexe.sql

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ WITH mega_join AS (
,t1.evolution_nbr_hospi1 as evolution_nbr_hospi
,t1.evolution_percent_nbr_hospi1 as evolution_percent_nbr_hospi

,t2.hospi_prog_24h
,t2.hospi_autres_24h
,t2.hospi_total_24h
,t2.hospi_1J
,t2.hospi_2J
,t2.hospi_3J
,t2.hospi_4J
,t2.hospi_5J
,t2.hospi_6J
,t2.hospi_7J
,t2.hospi_8J
,t2.hospi_9J
,t2.hospi_10J_19J
,t2.hospi_20J_29J
,t2.hospi_30J
,t2.hospi_total_jj
,t2.total_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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,15 @@ SELECT
IFNULL(CAST(evolution_percent_sejour_hospi_partielle AS FLOAT64), 0) AS evolution_percent_sejour_hospi_partielle,
IFNULL(CAST(evolution_passage_urgence AS FLOAT64), 0) AS evolution_passage_urgence,
IFNULL(CAST(evolution_percent_passage_urgence AS FLOAT64), 0) AS evolution_percent_passage_urgence,
ROUND(safe_divide((nbr_hospi * AVG_duree_hospi) , (journee_hospi_complete + sejour_hospi_partielle)),2) as taux_occupation
ROUND(safe_divide((nbr_hospi * AVG_duree_hospi) , (journee_hospi_complete + sejour_hospi_partielle)),2) as taux_occupation,
ROUND(safe_divide((lit_hospi_complete + place_hospi_partielle), population)*1000,2) as taux_equipement

FROM {{ref("class_join_total_morbidite_capacite")}}
),
base_data as (
SELECT *
,AVG(taux_occupation) OVER (PARTITION BY annee, region, classification) AS taux_occupation1
,AVG(taux_equipement) OVER (PARTITION BY annee, region, classification) AS taux_equipement1
FROM nullval
)
SELECT
Expand All @@ -92,6 +95,11 @@ base_data as (
WHEN COALESCE(bd2.taux_occupation1, 0) = 0 THEN NULL
ELSE Round(safe_divide((bd1.taux_occupation1 - bd2.taux_occupation1) , bd2.taux_occupation1), 2)
END AS evolution_percent_taux_occupation1,
round(bd1.taux_equipement1 - COALESCE(bd2.taux_equipement1, 0),2) AS evolution_taux_equipement1,
CASE
WHEN COALESCE(bd2.taux_equipement1, 0) = 0 THEN NULL
ELSE Round(safe_divide((bd1.taux_equipement1 - bd2.taux_equipement1) , bd2.taux_equipement1), 2)
END AS evolution_percent_taux_equipement1,
FROM base_data bd1
LEFT JOIN base_data bd2
ON bd1.region = bd2.region
Expand Down

0 comments on commit bf85836

Please sign in to comment.