Got working connection between trials and NDA/ANDA start times
parent
39397cc224
commit
f6b56da261
Binary file not shown.
@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"folders": {},
|
||||||
|
"connections": {
|
||||||
|
"postgres-jdbc-186be7b92d8-4d6ef891885b76f5": {
|
||||||
|
"provider": "postgresql",
|
||||||
|
"driver": "postgres-jdbc",
|
||||||
|
"name": "aact_db",
|
||||||
|
"save-password": true,
|
||||||
|
"configuration": {
|
||||||
|
"host": "will-office",
|
||||||
|
"port": "5432",
|
||||||
|
"database": "aact_db",
|
||||||
|
"url": "jdbc:postgresql://will-office:5432/aact_db",
|
||||||
|
"configurationType": "MANUAL",
|
||||||
|
"type": "dev",
|
||||||
|
"auth-model": "native"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mariaDB-186be7ba5a8-7a57b538dcd4188f": {
|
||||||
|
"provider": "mysql",
|
||||||
|
"driver": "mariaDB",
|
||||||
|
"name": "rxnorm_current",
|
||||||
|
"save-password": true,
|
||||||
|
"configuration": {
|
||||||
|
"host": "will-office",
|
||||||
|
"port": "3306",
|
||||||
|
"database": "rxnorm_current",
|
||||||
|
"url": "jdbc:mariadb://will-office:3306/rxnorm_current",
|
||||||
|
"configurationType": "MANUAL",
|
||||||
|
"type": "dev",
|
||||||
|
"auth-model": "native"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"connection-types": {
|
||||||
|
"dev": {
|
||||||
|
"name": "Development",
|
||||||
|
"color": "255,255,255",
|
||||||
|
"description": "Regular development database",
|
||||||
|
"auto-commit": true,
|
||||||
|
"confirm-execute": false,
|
||||||
|
"confirm-data-change": false,
|
||||||
|
"auto-close-transactions": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"resources":{"development_sql/ASSOICATING NCTIDs to NDCs and Marketing dates.sql":{"default-datasource":"postgres-jdbc-186be7b92d8-4d6ef891885b76f5","default-catalog":"aact_db","default-schema":"public"}}}
|
||||||
@ -1,11 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>development_sql</name>
|
<name>ClinicalTrialsDataProcessing</name>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
<buildSpec>
|
<buildSpec>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
|
<nature>org.jkiss.dbeaver.DBeaverNature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
@ -1,91 +1,79 @@
|
|||||||
|
|
||||||
/*get all the ndc codes associated with an rxcui
|
/* OVERVIEW
|
||||||
* Same as query
|
|
||||||
* http://will-office:4000/REST/rxcui/1668240/allhistoricalndcs.json
|
|
||||||
* note the different formats of the dates.
|
|
||||||
*
|
*
|
||||||
* Based on http://will-office:4000/RxNav/search?searchBy=RXCUI&searchTerm=1668240
|
* This links trials to the first date each drug (indexed by NDA/ANDA etc) is
|
||||||
* it appears that this rxcui is a sbd or bpck (branded drug or pack)
|
* put on the market.
|
||||||
*
|
*
|
||||||
|
* It takes 3 views to build up to it.
|
||||||
* If I grab every brand, then every branded drug or pack associated with that drug and then attach that to the nsde data I would get the marketing dates required.
|
|
||||||
* --get brand names
|
|
||||||
* trial -> mesh_term -> IN/MIN (rxcui) -> BN (rxcui)
|
|
||||||
* -- associate brand names to marketing dates
|
|
||||||
* BN (rxcui) --> SBD/BPCK (RXCUI) --> ndc11 --> nsde
|
|
||||||
* */
|
* */
|
||||||
|
|
||||||
/*
|
--Match trials to brands and ingredients
|
||||||
* I do need to figure out a way to change the date types when importing into postgres. In mariadb they ar mmYYYY wheras in the jsonapi they are YYYYmm but I want is YYYY-mm-01
|
create or replace view public.match_trials_to_bn_in as
|
||||||
*/
|
|
||||||
|
|
||||||
---assoicate ingredients, brands, and approved packaging RXCUIs.
|
|
||||||
create temp table trial_to_pack_rxcui as
|
|
||||||
with trialncts as (
|
with trialncts as (
|
||||||
SELECT DISTINCT nct_id FROM history.trial_snapshots TS
|
SELECT DISTINCT nct_id FROM history.trial_snapshots TS
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
bi.nct_id ,
|
bi.nct_id ,
|
||||||
bi.downcase_mesh_term,
|
bi.downcase_mesh_term,
|
||||||
rp.rxcui AS drug_rxcui,
|
rr.tty2 ,
|
||||||
rn.tty1,
|
rr.rxcui2 as bn_or_in_cui --brand or ingredient
|
||||||
rn.rxcui1 as ingredient_rxcui, --ingredients
|
,count(*)
|
||||||
rn.tty2 ,
|
|
||||||
rn.rxcui2 as brand_or_pack_rxcui --brand or pack
|
|
||||||
FROM ctgov.browse_interventions bi
|
FROM ctgov.browse_interventions bi
|
||||||
LEFT OUTER JOIN rxnorm_migrated.rxnorm_props AS rp
|
left outer JOIN rxnorm_migrated.rxnorm_props AS rp
|
||||||
on bi.downcase_mesh_term = rp.propvalue1 --Link drug ingredient
|
on bi.downcase_mesh_term = rp.propvalue1 --link names to drug cuis ()
|
||||||
LEFT OUTER JOIN rxnorm_migrated.rxnorm_relations AS rn
|
left outer join rxnorm_migrated.rxnorm_relations rr
|
||||||
on rp.rxcui = rn.rxcui1 --Grab brand names
|
on rr.rxcui1 = rp.rxcui
|
||||||
WHERE
|
WHERE
|
||||||
bi.nct_id in (
|
bi.nct_id in (
|
||||||
SELECT nct_id FROM trialncts
|
SELECT nct_id FROM trialncts
|
||||||
)
|
)
|
||||||
and
|
and
|
||||||
bi.mesh_type='mesh-list'
|
bi.mesh_type='mesh-list'
|
||||||
and
|
and rp.propname = 'Active_ingredient_name'
|
||||||
rn.tty1 in ('IN','MIN')
|
and rr.tty2 in ('BN', 'IN', 'MIN')
|
||||||
and
|
group by bi.nct_id, bi.downcase_mesh_term , rr.tty2 ,rr.rxcui2
|
||||||
rn.tty2 = 'BN'
|
order by bi.nct_id
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
--link brand names to drug applications (NDA/ANDA etc)
|
--match trials to through brands NDC11
|
||||||
select rr.rxcui1 as BN, rr.rxcui2 as pack, ah.ndc as pack_ndc11
|
create or replace view public.match_trial_to_ndc11 as
|
||||||
from
|
select
|
||||||
rxnorm_migrated.rxnorm_relations rr
|
mttbi.nct_id,
|
||||||
|
ah.ndc,
|
||||||
|
count(*)
|
||||||
|
from public.match_trials_to_bn_in as mttbi
|
||||||
|
left outer join rxnorm_migrated.rxnorm_relations as rr
|
||||||
|
on mttbi.bn_or_in_cui = rr.rxcui1
|
||||||
left outer join rxnorm_migrated."ALLNDC_HISTORY" as ah
|
left outer join rxnorm_migrated."ALLNDC_HISTORY" as ah
|
||||||
on rr.rxcui2 = ah.rxcui
|
on rr.rxcui2 = ah.rxcui
|
||||||
where
|
where
|
||||||
tty1 = 'BN'
|
rr.tty1 = 'BN'
|
||||||
and
|
and
|
||||||
tty2 in ('SBD', 'BPCK')
|
rr.tty2 in ('SBD', 'BPCK')
|
||||||
and
|
and
|
||||||
ah.sab='RXNORM'
|
ah.sab='RXNORM'
|
||||||
|
group by mttbi.nct_id, ah.ndc
|
||||||
|
order by mttbi.nct_id, ah.ndc
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
---associate NDAs/ANDAs to marketing start dates
|
|
||||||
---Get start of coverage periods for NSDE dates grouped by arbitrary grouping.
|
|
||||||
SELECT n.application_number_or_citation, count(*), min( marketing_start_date )
|
|
||||||
FROM spl.nsde as n
|
|
||||||
where product_type = 'HUMAN PRESCRIPTION DRUG'
|
|
||||||
group by n.application_number_or_citation ;
|
|
||||||
|
|
||||||
|
|
||||||
---For a given date, find which NDAs/ANDAs were active were active.
|
---associate trials to marketing start dates
|
||||||
SELECT n.application_number_or_citation, count(*)
|
create or replace view public.match_trial_to_marketing_start_date as
|
||||||
FROM spl.nsde as n
|
select
|
||||||
|
mttn.nct_id,
|
||||||
|
n.application_number_or_citation,
|
||||||
|
min(n.marketing_start_date )
|
||||||
|
from match_trial_to_ndc11 mttn
|
||||||
|
inner join spl.nsde n
|
||||||
|
on mttn.ndc = n.package_ndc11
|
||||||
where
|
where
|
||||||
product_type = 'HUMAN PRESCRIPTION DRUG'
|
n.product_type = 'HUMAN PRESCRIPTION DRUG'
|
||||||
and
|
and
|
||||||
marketing_start_date < '2010-05-01'
|
n.marketing_category in ('NDA','ANDA','BLA', 'NDA authorized generic', 'NDA AUTHORIZED GENERIC')
|
||||||
and
|
group by mttn.nct_id,n.application_number_or_citation
|
||||||
marketing_end_date > '2010-05-01'
|
order by mttn.nct_id
|
||||||
group by n.application_number_or_citation ;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue