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

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file MedRxNorm-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: MedRxNorm-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0.post20201221 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.6.1

File hashes

Hashes for MedRxNorm-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b6a89322667d2ab646882b1a722f4ffe51f12e0287e8c2d76748065555007553
MD5 aa31673a1e357294d3fdb6f074cbc2b8
BLAKE2b-256 5adedf188e8d81da2261a6125e50b13d5aa575d18740626874a68fcbf777934a

See more details on using hashes here.

Supported by

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