Created
August 25, 2016 20:32
-
-
Save swbuehler/f0be3c35ac5d867ce570127ceae348e6 to your computer and use it in GitHub Desktop.
Get RxNorm drug name based on provided NDC (Office VBA, MSXML2)
This file contains 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
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