Snake_Byte #30: Python for Pharmacy People

In my last SnakeByte (Python for Non-Python People), I walked through how a non-developer here at PokitDok could use Python to run analysis and build business rules to improve our clients' transaction quality. This time, I'd like to show how PokitDok's APIs can be used in tandem to solve the common problem of unknown drug prices.

Let's say your grandma, who has asthma, goes to the doctor to get a new inhaler. The doctor knows that in the past she has been on Ventolin, Proair, and Flovent and they have all worked for her. So now her doctor has to decide which one to prescribe, but has no idea which ones (if any) are covered by her Medicare plan. That's where we come in. By using PokitDok's eligibility and pharmacy_formularyAPIs (along with a couple of others) we can show how much she'll pay for each, and help the doc prescribe a drug that she is likely to continue taking. For this example, we'll use the following drugs and dosages:

HFA 90 MCG INHALER
PROAIR HFA 90 MCG INHALER
FLOVENT HFA 110 MCG INHALER

The first step is to confirm Grandma's eligibility. Different trading partners (insurers) have different requirements to find a member in their system. Through research and request/response analysis, PokitDok maintains a list of requirements for each trading partner's "supported search options." This list details what fields need to be included in an eligibility request in order for the trading partner to find the member. This information is one of the data points included in our trading_partner API. So we'll send the request:

And get the response:

As you can see, Medicare will allow us to submit requests without a member's first name and without a member's date of birth. That's fortunate, because I don't want to ask your grandma how old she is.

For the sake of keeping PHI safe, I won't include any real member data in this example. So that I can re-use this notebook in the future to help other people get their drug coverage, I'll declare the variables that will be used:

Then we'll send the actual eligibility request:

Now we've sent the eligibility request to Medicare. Medicare has a few unique quirks as a trading partner, and one of those is they can restrict access if they receive the same request over and over. In order to keep from having to send this request again, I'm going to extract the activity_id from the response:

Now I can use our activities API to view the request/response at any time in the future:

If the member is eligible for Medicare Part D, the pharmacy plan number will be included in the response. Since this is my example, the member is always eligible. This plan number is required by our pharmacy_formulary API in order to determine which formulary the member has.

The next issue we run into is that Medicare will return this plan number in a format that differs from our data set. Medicare will return plan_number: S#### ###, but our dataset lists plan numbers in a S####### format. To fix this we'll extract the plan_number and remove the space in the middle:

Now we can we can query our pharmacy_formulary API. We'll input the names of the drugs that we'd like to query and then put them in a list:

And send those drugs and plan numbers to our pharmacy_formulary API:

We have built this API to use a fuzzy matching algorithm to assist in finding drugs. That means that we will return a large list of drugs. This is to help a user if they do not know the exact dosage or form of the drug that they querying. In this example, since we do know the exact dosage and form, we can use a basic list comprehension function to return the desired fields:

(we would repeat this for each drug we want to query)

Finally, we'll print our results, and compare:

So, you can see that Ventolin is covered in tier 3 and will cost $47.00/ fill. Proair returns no information, meaning that it is not covered by Grandma's plan. A quick google search shows that the cash price of ProAir is around $80. Flovent is in the 4th tier, costing $108.87/fill. So, all else being equal, Grandma's doctor can prescribe her Ventolin and rest easy knowing that he made the best choice for her and her plan.

Having access to information like this BEFORE a script is written will give doctors the tools they need to make sure their patients can afford their drugs. Patients who can afford their drugs tend to take their drugs, which leads to lower re-admittance rates and happier grandmas.

By using PokitDok's APIs, and basic Python functionality, someone with very little development background can start tackling a huge problem like unknown drug prices. So what are you waiting for? Go build something.

1 comment

  1. Reply

    Rock and Roll, now Grandma don't need no coding school. Well done, thanks Brooks!

Leave a Reply

Your email address will not be published.