For handling data from the NHS DM+D, along with general prescription parsing
Project description
DMD database
A Python toolkit for building the NHS Dictionary of Medicines and Devices (DM+D) XML distribution files into a relational database. It provides an SQLAlchemy 2 ORM, CLI scripts for building single-version and multi-version warehouse databases, and a query API for looking up medicines by name, ID, or ingredient.
There is online documentation for dmd.
Please note, this is for research purposes only and was built to map prescriptions from sources such as CPRD and the UK BioBank. Please do not use for any healthcare related implementation.
Installation
Using pip
Install from a local clone for development:
git clone git@gitlab.com:cfinan/dmd.git
cd dmd
pip install -e ".[dev]"
Using conda
A conda package is available in the cfin channel for Python 3.11--3.13
(Linux-64):
conda install -c cfin -c conda-forge dmd
Usage
Command line
Build a DM+D database from the NHS TRUD zip archives:
dmd-build -v -B nhsbsa_dmdbonus_<version>.zip nhsbsa_dmd_<version>.zip ~/dmd.db
More information on DM+D can be found on the NHS digital TRUD site. You will need an account to subscribe and download.
For full CLI help:
dmd-build --help
dmd-warehouse-build --help
Python API
import sqlalchemy
from dmd.build import build_dmd
engine = sqlalchemy.create_engine("sqlite:///dmd.db")
sm = sqlalchemy.orm.sessionmaker(bind=engine)
build_dmd(
sm,
"nhsbsa_dmd_<version>.zip",
bonus_zip="nhsbsa_dmdbonus_<version>.zip",
)
Schema
The final database will have the following schema (including bonus file). Open in a separate browser tab to make it larger.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nhs_dmd-0.2.4b0.tar.gz.
File metadata
- Download URL: nhs_dmd-0.2.4b0.tar.gz
- Upload date:
- Size: 66.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c894240b9bbad22cc94db7cdc2ba4cbbc04308d089bcae7fc3ea2674b6c1577
|
|
| MD5 |
892de540242576aaeefdfae0fdc26ea1
|
|
| BLAKE2b-256 |
145fada1d6d347a0f7e6c25ce754a108c3480e2057a7f381f0871be0afb0b78e
|
File details
Details for the file nhs_dmd-0.2.4b0-py3-none-any.whl.
File metadata
- Download URL: nhs_dmd-0.2.4b0-py3-none-any.whl
- Upload date:
- Size: 68.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
548e4b11d7025f61e92d1dcca9924eef389a316bf0f84211fd2a0bd3a5f79078
|
|
| MD5 |
05456d06f47e4eb9c9bbcc63d5dfe55b
|
|
| BLAKE2b-256 |
996a98b20ab5b5b917c19c100a756824642cdbb6952ca4def26b348ff5977111
|