Skip to content

Instantly share code, notes, and snippets.

@swbuehler
Created August 25, 2016 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swbuehler/f0be3c35ac5d867ce570127ceae348e6 to your computer and use it in GitHub Desktop.
Save swbuehler/f0be3c35ac5d867ce570127ceae348e6 to your computer and use it in GitHub Desktop.
Get RxNorm drug name based on provided NDC (Office VBA, MSXML2)
Function RxNorm(ByVal strNDC As String)
Dim xmlhttprequest As MSXML2.XMLHTTP
Dim xmlresponse As New MSXML2.DOMDocument60
Set xmlhttprequest = New MSXML2.XMLHTTP
xmlhttprequest.Open "GET", ("https://rxnav.nlm.nih.gov/REST/rxcui?idtype=NDC&id=" & strNDC), False
xmlhttprequest.send
xmlresponse.Load xmlhttprequest.responseXML
If xmlresponse.SelectSingleNode("//rxnormId") Is Nothing Then
RxNorm = "**NDC Not Found**"
Exit Function
Else
rxcui = xmlresponse.SelectSingleNode("//rxnormId").Text
End If
xmlhttprequest.Open "GET", ("https://rxnav.nlm.nih.gov/REST/rxcui/" & rxcui & "/properties"), False
xmlhttprequest.send
xmlresponse.Load xmlhttprequest.responseXML
RxNorm = xmlresponse.SelectSingleNode("//name").Text
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment