diff --git a/RxMix/ASSOICATING NCTIDs to NDCs and Marketing dates.sql b/RxMix/ASSOICATING NCTIDs to NDCs and Marketing dates.sql new file mode 100644 index 0000000..941f443 --- /dev/null +++ b/RxMix/ASSOICATING NCTIDs to NDCs and Marketing dates.sql @@ -0,0 +1,27 @@ +/*Get relationships between brands and branded drugs and packs*/ +select * from rxnorm_migrated.rxnorm_relations rr +where tty1 = 'BN' and tty2 in ('SBD', 'BPCK') +limit 100; + +/*get all the ndc codes associated with an rxcui + * 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 + * it appears that this rxcui is a sbd or bpck (branded drug or pack) + * + * If I grab every brand, then every branded drug or pack associated with that drug and then every + * */ +select * from ALLNDC_HISTORY ah +where RXCUI ='1668240' +and SAB='RXNORM' +; +/** + * 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. + * trial -> mesh_term -> IN/MIN (rxcui) -> BN (rxcui) -> SBD/BPCK (rxcui) -> ndc11 -> nsde (marketing dates) + * */ + +/* + * 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 + */*/ \ No newline at end of file diff --git a/RxMix/migrate_rxnav.py b/RxMix/migrate_rxnav.py index 49e97d9..05076e3 100644 --- a/RxMix/migrate_rxnav.py +++ b/RxMix/migrate_rxnav.py @@ -85,7 +85,12 @@ if __name__ == "__main__": MARIADB_PORT = os.getenv("MARIADB_PORT") #get & convert datatypes for each table of interest - tables_of_interest = ["rxnorm_props","rxnorm_relations"] + tables_of_interest = [ + "rxnorm_props" + ,"rxnorm_relations" + ,"ALLNDC_HISTORY" + ,"ALLRXCUI_HISTORY" + ] mschema="rxnorm_current" pschema="rxnorm_migrated" diff --git a/justfile b/justfile index f704e90..11f779a 100644 --- a/justfile +++ b/justfile @@ -16,6 +16,9 @@ docker_container := `docker container ls -a | grep aact_db | cut -f 1 -d " " | t #Various paths for docker stuff docker-compose_path := "./AACT_downloader/docker-compose.yaml" +#rxnorm_mappings +rxnorm_mappings_url := "https://dailymed-data.nlm.nih.gov/public-release-files/rxnorm_mappings.zip" + #Number of historical trials to download. count := "100" @@ -101,3 +104,9 @@ get-histories: download-trial-histories parse-trial-histories get-nsde: cd market_data && bash download_nsde.sh cd market_data && python extract_nsde.py + +get-rxnorm-mappings: + #this may not be needed, all it does is match spls to rxcuis and I think I already have that. + curl {{rxnorm_mappings_url}} > ./market_data/rxnorm_mappings.zip + cd ./market_data && unzip ./rxnorm_mappings.zip + rm ./market_data/rxnorm_mappings.zip diff --git a/market_data/readme.md b/market_data/readme.md new file mode 100644 index 0000000..c009a81 --- /dev/null +++ b/market_data/readme.md @@ -0,0 +1 @@ +downloads and extracts nsde data.