Last active
February 3, 2016 16:25
-
-
Save joshbooker/ed5ddad079dc8f71bb1b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
https://jsfiddle.net/7tt7fw04/14/ | |
Let's make a function to call RXNorm 'Related' endpoint to get ingredients as seen here: | |
http://mor.nlm.nih.gov/download/rxnav/RxNormAPIREST.html#uLink=RxNorm_REST_getRelatedByRelationship | |
The request url: for Plavix (rxcui: 174742) is this: | |
https://rxnav.nlm.nih.gov/REST/rxcui/174742/related?rela=tradename_of+has_precise_ingredient | |
*/ | |
//make sure jquery is working - required for ajax | |
$("#message").text("jQuery Loaded"); | |
//set base url | |
var uri = "https://rxnav.nlm.nih.gov/REST/rxcui/" | |
//our function | |
var getPreciseIngredient = function(rxcui){ | |
var requestUri = uri + rxcui + | |
"/related.json?rela=tradename_of+has_precise_ingredient" | |
//alert(requestUri); | |
$.ajax({ | |
url: requestUri | |
}) | |
.done(function( data ) { | |
$("#label").text("Ingredients:"); | |
var ingredients = ""; | |
data.relatedGroup.conceptGroup.forEach(function(c){ | |
ingredients += c.conceptProperties[0].name + "\r\n"; | |
}); | |
alert(ingredients); | |
$("#message").text(ingredients); | |
}) | |
.fail(function(jqXHR, textStatus, errorThrown) { | |
alert( "error" + ": " + textStatus + ": " + errorThrown ); | |
}) | |
.always(function() { | |
alert( "complete" ); | |
}); | |
}; | |
var result = getPreciseIngredient(174742); |
This file contains hidden or 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
/* | |
https://jsfiddle.net/r8vcxt53/4/ | |
Let's make a function to call RXNorm 'Interactions' endpoint to as seen here: | |
http://mor.nlm.nih.gov/download/rxnav/InteractionAPIREST.html#uLink=Interaction_REST_findInteractionsFromList | |
In the following example, the interactions between Diflucan 50 mg oral tablet (RxCUI=207106), Zocor 40 mg oral tablet (RxCUI=152923) and bosentan 125 mg oral tablet (RxCUI=656659) are returned. | |
https://rxnav.nlm.nih.gov/REST/interaction/list.json?rxcuis=207106+152923+656659 | |
*/ | |
//make sure jquery is working - required for ajax | |
$("#message").text("jQuery Loaded"); | |
//set base url | |
var uri = "https://rxnav.nlm.nih.gov/REST/interaction/list.json" | |
//our function | |
var getInteractions = function(rxcuis){ | |
var requestUri = uri + "?rxcuis=" + rxcuis | |
alert(requestUri); | |
$.ajax({ | |
url: requestUri | |
}) | |
.done(function( data ) { | |
$("#label").text("Interactions:"); | |
var interactions = ""; | |
data.fullInteractionTypeGroup[0].fullInteractionType.forEach(function(i){ | |
interactions += i.interactionPair[0].description + "\r\n"; | |
}); | |
alert(interactions); | |
$("#message").text(interactions); | |
}) | |
.fail(function(jqXHR, textStatus, errorThrown) { | |
alert( "error" + ": " + textStatus + ": " + errorThrown ); | |
}) | |
.always(function() { | |
alert( "complete" ); | |
}); | |
}; | |
var result = getInteractions("207106+152923+656659"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment