How I used the RxNav API in my project

Hey everyone! In this blog, I wanted to write about the external API RxNav and one way in which I incorporated this into my final project. Of course, there are many ways to use this API as it is super versatile but wanted to show you how I used it.

Before I dive straight into the coding aspect I want to give a little background to my project. I created Flatiron General which is a patient management application that can be used in a hospital, urgent care, or even a private practice setting. With my background in healthcare and biology and working at urgent care in the COVID-19 pandemic, I wanted to create an app that could be relevant to what is going on in the world today. For that reason, I made my app include features such as letting the doctor/ provider know which patient is COVID negative or positive, placing those who are positive on a separate floor than those who are negative, and have the reason for the visit next to patients name for easier navigation on the UI. The way I incorporated RxNav into Flatiron General was to cross-check any drug interactions between a patient's allergies and any medications the patient is currently taking. Every patient's medical history was already logged and this included any medications the patient is currently taking as well as any prescription drug allergies the patient has. I used RxNav to retrieve prescription drug information and created an algorithm that would cross-check and report back to the doctor any contraindication in red writing. This allowed the provider to see any interaction before prescribing any medications. By including this feature, it removes any unnecessary time spent trying to google interactions and instead presents interactions right on the application the provider is using. So without further ado, let me show you how I did so.

So what is RxNav you may be wondering? RxNav is an API created by the National Institute of Health. This means that it is very reputable and it also has many different specific APIs to use such as retrieving drug data, drug classes, and more.

The general flow for how I incorporated RxNav goes like this. Create a form that allows the provider to search for medication. Make a fetch request(s) for the RxNav endpoint that I am trying to hit. Cross-check interaction by running through patients' allergies and medical history and displaying any interactions in red.

This code above shows how I actually retrieved the data from the RxNav API. As you can see I created a state, and set it to an empty array. Then I proceeded to create two fetch requests. The first fetch request was to search for the specific drug ID and the second was for the Drug Interaction API. Then I set the state to interactions from the API response.

The next part of my code was the actual algorithm. As you can see from above, I used the filter method to build a new array of interactions based on a condition. The condition was that if the current drug name was in the patient’s medication or allergies list, add it to the new interactions array. Then I used the map method to go through and place those interactions in a table. Here is the GitHub link to all this code here:

Here is a run-through of pictures displaying how this works in my project.

Above you can see I have patient Cristina Yang who is currently taking losartan and is allergic to penicillin.

This shows the API in full use. I searched up the medication rizatriptan which is a medication used to treat migraines. Once I hit the submit button, RxNav is working to run through Cristina's current medication and allergies and display to the provider any interaction it finds. I get back an interaction that the RxNav has for these two medications taken together. In this case; “Rizatriptan may decrease the antihypertensive activities of Losartan”. This information is very helpful to the provider as they want to be made of any type of effect that may occur from prescribing medication.

I hope you found this blog helpful. Even though it was specific to my final project, these types of APIs are very common so you can use the general steps to apply to incorporate APIs in your project. Thanks for reading :)