Skip to content

NHS dm+d and Medication Lookup

MedTracker uses the NHS Dictionary of Medicines and Devices (dm+d) as its main UK medication catalogue. It combines dm+d with local barcode records, curated fallbacks, and Open Food Facts supplement data.

Loco migration checkout

The root Loco application uses local NHS release records, custom CSV products, cached products and the curated catalogue. Its scanner and Medicine Finder do not call live NHS or Open Food Facts services. The live-provider instructions below apply to the Rails reference application.

Accounts with an active platform administrator record upload releases at /admin/nhs-dmd. Household owner or administrator access alone does not qualify. The development/test seed does not create a platform administrator, and the current administration navigation has no importer link. See platform administrators and the seed and navigation audit. Configure the same private object store for the web process and worker:

Variable Purpose
S3_ENDPOINT S3-compatible endpoint, including a RustFS endpoint
S3_BUCKET Existing private bucket for uploaded archives
AWS_ACCESS_KEY_ID Storage credential with object read, write and delete access
AWS_SECRET_ACCESS_KEY Matching storage secret
AWS_REGION Storage region; defaults to us-east-1

Keep credentials outside the repository. Run task worker with the same database and storage configuration as the web application. This starts the PostgreSQL queue worker and the configured scheduler. The upload is read back and checked before its import ID is queued, so queued work survives an application restart.

The scheduler checks imports every five minutes. A run with no progress for 30 minutes becomes failed. Failed imports do not restart automatically; review the error and upload the release again. Archive deletion is retried separately. Only one import can be active at a time.

Archives are limited to 500 MiB, with at most 200 extracted entries, 150 MiB per entry and 500 MiB total extracted bytes. Traversal paths and symbolic links are rejected. The page retains status and counters after the archive is removed. These local migration capabilities do not authorise production cutover.

What dm+d provides

dm+d assigns SNOMED CT identifiers to medicines and packs used in the UK. The live terminology search can return:

  • virtual medicinal products (VMP);
  • actual medicinal products (AMP); and
  • actual medicinal product packs (AMPP).

Imported release data adds GTIN barcode mappings and trade-family information. Every search result identifies its source and product. Depending on that source, it can also include package details, trade-family data, match reasons, product guidance links, directions, or warnings.

dm+d is a product catalogue. It is not a drug-interaction checker and does not replace prescribing guidance.

Lookup order

NhsDmd::Search uses several sources:

  1. A barcode query first checks the local barcode catalogue populated by dm+d release imports and curated records.
  2. A barcode without a local match can use Open Food Facts.
  3. A text query uses the live NHS terminology service when credentials are available.
  4. Supplement-like text queries can also use Open Food Facts.

MedTracker merges and deduplicates suitable results. A supplement lookup can make a remote Open Food Facts request even when NHS credentials are absent. Do not state that disabling NHS credentials prevents every external lookup.

External lookups write source, outcome, and result-count metadata to the audit trail. Query text is handled by the external-lookup audit policy.

NHS terminology credentials

Live dm+d text search needs a system-to-system account from the NHS England Terminology Server. This is separate from the NHS API Platform.

  1. Read the system-to-system account agreement.
  2. Complete the account request form.
  3. Request read-only consumer access for the application's clinical use.
  4. Store the issued client ID and secret outside the repository.

Configure both values:

Variable Purpose
NHS_DMD_CLIENT_ID OAuth client ID from NHS England
NHS_DMD_CLIENT_SECRET OAuth client secret

Set Fish shell variables before starting local development:

set -x NHS_DMD_CLIENT_ID "your-client-id"
set -x NHS_DMD_CLIENT_SECRET "your-client-secret"
task dev:up

Use a Secret or ExternalSecret in production. Never put either value in a ConfigMap, image, or committed environment file.

When one of these values is absent, live NHS terminology search is unavailable. Local barcode data, curated data, and eligible supplement lookups can still return results.

Import NHS release data

In the root Rust application, platform administrators open /admin/nhs-dmd directly and upload the NHSBSA release ZIP. There is currently no importer link in the administration menus. MedTracker stores the archive, queues the import, shows progress and record counts, and removes the archive when the run ends.

In the archived Rails application, operators could use a one-off Job with an extracted release directory when the admin upload is unsuitable. See Import an NHS dm+d release.

The staged-release import wrappers belonged to the archived Rails application. Use the admin upload or the scheduled nhs_dmd_reconcile job configured in config/*.yaml.

Verify the integration

  1. Search for a known generic medicine and confirm a VMP result.
  2. Search for a known branded product and confirm an AMP or AMPP result.
  3. Enter a GTIN from the imported release and confirm the expected pack.
  4. Try a supplement query and identify its source before saving it.
  5. Confirm that failed external lookups do not expose credentials in logs.

Automated tests stub remote services. A green test suite does not prove that deployment credentials or NHS access are valid.

Measure local release imports

Loco emits nhs_dmd_import_timing tracing events with numeric run_id and duration_ms, plus phase and outcome. Phases cover extraction, counting, AMPP, supplementary and GTIN parsing, persistence and commit. total measures the core import from archive extraction through commit and temporary-directory cleanup. It excludes queue delay, upload, archive retrieval and worker cleanup. Early returns emit a failure outcome for the active phase and core total.

Product guidance and interactions

Some source records include patient-information or product-characteristic links. Their presence depends on the returned product data.

MedTracker does not provide a drug-interaction database. Any future interaction feature needs a separately licensed and clinically governed source. SNOMED CT or dm+d identifiers can link the selected medication to that source.