Skip to main content

Python module for normalizing medical prescriptions

Project description

MedRxNorm

Python module for normalizing medical prescriptions. Converts common medical abbreviations, medical shorthand, and numbers to pronouncable representations. Uses FSTs made with Pynini python module to make normalization rules.

Installation

pip install MedRxNorm

How to Use

from MedRxNorm import MedRxNorm

mrn = MedRxNorm.MedRxNorm()

print(mrn.normalize("Take 2 TAB PO Q4H x 10 days prn"))
# Output: Take two tablets by mouth every four hours for ten days as needed

It is also possible to normalize individually by route, per day frequency, medicine type, and other abbreviations if needed.

print(mrn.normalize_route("Take 2 TAB PO Q4H x 10 days prn"))
# Output: Take 2 TAB by mouth Q4H x 10 days prn

print(mrn.normalize_per_day("Take 2 TAB PO Q4H x 10 days prn"))
# Output: Take 2 TAB PO every 4 hours x 10 days prn

print(mrn.normalize_med_type("Take 2 TAB PO Q4H x 10 days prn"))
# Output: Take 2 tablets PO Q4H x 10 days prn

print(mrn.normalize_abbreviations("Take 2 TAB PO Q4H x 10 days prn"))
# Output: Take 2 TAB PO Q4H for 10 days as needed

Limitations

The normalize method can be called on strings that are not medical prescriptions with no issue, it will simply return the same string. Example:

print(mrn.normalize("Hello world"))
# Output: Hello world

However, some issues still come up. While most medical abbreviations and shorthand do not overlap with actual English words, the normalize method will still turn words like the English word "bid" to "twice a day". Example:

print(mrn.normalize("I bid you goodnight"))
# Output: I twice a day you goodnight

Furthermore, I have only equipped this tool to accept exactly as many characters as it needs to (the characters that possibly show up in prescriptions). So, if you try to use any of these methods on strings with unknown characters, it will simply break. Example:

print(mrn.normalize("Hello world!"))
# Output: _pywrapfst.FstOpError: Operation failed

I believe both of these problems can be fixed by creating another FST that only accepts strings in the right format for a medical prescription before moving on to apply the normalization rules, however that is a large task that I will save for another day for now.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

MedRxNorm-0.1.4-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page