-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cohort characteristics should be for ONLY encounters with an **ED NOTE**
- Loading branch information
1 parent
a954496
commit 627da40
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
cumulus_library_suicidality_icd10/suicide_icd10/psm/table_1_cohort_characteristics.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,30 @@ | ||
--create table suicide_icd10__thesis_table1 as | ||
--select | ||
--count(distinct P.subject_ref) as cnt_subject, | ||
-- P.dx_suicidality, | ||
-- P.dx_subtype, | ||
-- P.age_group, | ||
-- P.gender | ||
--from suicide_icd10__prevalence P, suicide_icd10__study_period S | ||
--where P.encounter_ref = S.encounter_ref | ||
--group by cube ( | ||
-- P.dx_suicidality, | ||
-- P.dx_subtype, | ||
-- P.age_group, | ||
-- P.gender) | ||
--order by | ||
-- P.dx_suicidality, | ||
-- P.dx_subtype, | ||
-- P.age_group, | ||
-- P.gender; | ||
|
||
create table suicide_icd10__count_demographics as | ||
select | ||
dx_suicidality, dx_subtype, age_group, gender, | ||
count(distinct encounter_ref) as cnt_encounter, | ||
count(distinct subject_ref) as cnt_subject | ||
from suicide_icd10__prevalence | ||
where doc_ed_note | ||
group by cube(dx_suicidality, dx_subtype, age_group, gender) | ||
order by cnt_encounter desc, cnt_subject desc | ||
|