Showing posts with label healthcare. Show all posts
Showing posts with label healthcare. Show all posts

Monday, November 7, 2016

Converting an ADT HL7 message to JSON

If anyone has ever had the pleasure of working the HL7 ADT messages in to exchange information between healthcare systems, you'll know the frustration of trying to actually using that information in a meaningful way (i.e. trying to work with it without having to read 200 pages of documentation to understand what the different segments of an HL7 message are).

Although the HL7 standard makes it less verbose when sending the information along, I prefer working with JSON objects as opposed to pipe delimited strings. If you are in the same boat, then you can use the following two python functions to convert an HL7 message to an easier to digest/understand. (Note these two functsion depend on the hl7apy python library)

Yes, these functions return a python dictionary and not a JSON object, but you can trivially convert a dictionary to a JSON string.
import json

from hl7apy.parser import parse_message

# Taken from http://hl7apy.org/tutorial/index.html#elements-manipulation
s = """MSH|^~\&|GHH_ADT||||20080115153000||ADT^A01^ADT_A01|0123456789|P|2.5||||AL
EVN||20080115153000||AAA|AAA|20080114003000
PID|1||566-554-3423^^^GHH^MR||EVERYMAN^ADAM^A|||M|||2222 HOME STREET^^ANN ARBOR^MI^^USA||555-555-2004~444-333-222|||M
NK1|1|NUCLEAR^NELDA^W|SPO|2222 HOME STREET^^ANN ARBOR^MI^^USA"""

# Convert it
d = hl7_str_to_dict(s)

# Dump it as a JSON string
print json.dumps(d)
Hope this helps someone who appreciates new data representations more than old data representations ;)

Tuesday, December 15, 2015

Can your coworkers work in healthcare?

For those of you who work in the healthcare industry, it comes as no surprise that things have to be checked, double checked, and then for good measure, checked again (not that this always happens, but that's the hope). One of the things that has to be reviewed is the list of people that work with patient information and to ensure that they are not part of any "special" lists. The main ones are: All of these provide some sort of web search interface (SDN, OIG, SAM), but this gets a bit tedious there are more than 3 employees... especially if you have to check this for every employee every month (which we do).

As such, I put together a simple python script that checks a list of people against all three lists by downloading the actual exclusion lists. The lists that it downloads are: You may have noticed that there are no downloads for the FDA Debarment List (Drug Product Applications) and the TRICARE excluded provider sanction list. Unfortunately, those lists aren't available for download, and so this script scrapes the appropriate sites to obtain the lists.

It's nothing fancy and doesn't cover all cases, but it should be enough to get you started. Note, you will still have to perform actual background checks as well, but this can be run more frequently. You can run the script via:
python background_exclusion_check.py
Note, you will need to have requests installed as it uses that to download the files. In case you don't feel like going over to github to take a look at the code, here it is in full.