select * from "DiseaseBurden".icd10_to_cause itc ;
select * from "DiseaseBurden".cause c ;
select


select c.id, count(distinct code)
from "DiseaseBurden".cause c 
    join "DiseaseBurden".icd10_to_cause itc 
        on c.cause = itc.cause_text 
group by c.id
order by c.id
;

select count(distinct nct_id) from "DiseaseBurden".trial_to_icd10 tti 
where tti.approved = 'accepted';

select nct_id, "condition", ui
from "DiseaseBurden".trial_to_icd10 tti 
where tti.approved = 'accepted';


select tti.nct_id, tti."condition",itc.cause_text 
from "DiseaseBurden".trial_to_icd10 tti 
    join "DiseaseBurden".icd10_to_cause itc
        on replace(REPLACE(tti.ui,'-',''),'.','') = replace(REPLACE(itc.code ,'-',''),'.','')
where 
    tti.approved = 'accepted'
    and 
    itc.cause_text not in ('Non-communicable diseases','Neoplasms','Mental disorders','Other non-communicable diseases')
group by tti.nct_id , tti."condition" , itc.cause_text 
order by nct_id 
;