ctsidev / UC_Event_Care_planning

0 stars 3 forks source link

add ALS CODE #5

Closed jsanzucla closed 6 years ago

jsanzucla commented 6 years ago

After abstraction, add the code to identify this cohort, gather counts, and generate a sample for chart abstraction

-------------------------------------------
--  Step _._:     calculate counts
-------------------------------------------
SELECT 
        ,PL_ALS
        ,DX_ALS
        ,AD
        ,POLST
,COUNT(DISTINCT PAT_ID) 
FROM js_xdr_walling_final_pat_coh
WHERE PL_ALS = 1 AND DX_ALS = 1
group by ,PL_ALS
        ,DX_ALS
        ,AD
        ,POLST;

----------------------------------------------------
--Step _._:   Pull sample for chart review. Export to xlsx file
----------------------------------------------------
select mrn
        ,PL_ALS
        ,DX_ALS
        ,AD
        ,POLST
        ,'PL AND DX group' as sample_group
        --These are placeholder fields to be filled out by the Investigator reviewing the charts
        ,NULL as "Advanced Illness Group"
        ,NULL as "Advanced condition?"
        ,NULL as "Notes"
        ,NULL as "ACP Priority"
        ,NULL as "Necessary AD/POLST"
        ,NULL as "Right?"
        ,NULL as "Notes"
        ,NULL as "Year"        
from (
        SELECT ROWNUM AS RECORD_ID
                ,pat.pat_mrn_id as mrn
                ,coh.*
        FROM js_xdr_walling_final_pat_coh  coh
        join patient                        pat on coh.pat_id = pat.pat_id
        where
            PL_ALS = 1 AND DX_ALS = 1
        ORDER BY dbms_random.random)
WHERE RECORD_ID < 11