Mapping from dm d objects to BNF codes - bennettoxford/openprescribing GitHub Wiki

Background

In a call with the BSA, we learnt:

  • The BSA have two systems that contain BNF codes and SNOMED codes
  • There is a legacy system and a new system
  • They are able to generate mappings between BNF code and SNOMED codes from each system, but the mappings are slightly different in each case
  • The mapping from the new system is reckoned to be more accurate
  • The mapping available on the website is generated by the legacy system
  • The mapping that we have been sent by email is generated by the new system
  • The monthly prescribing data (the BSA call this the Detailed Prescribing Information dataset) currently uses BNF codes from the legacy system
  • The BSA plan to start using BNF codes for the new system in the monthly prescribing data in six months or so, but this is not a firm commitment
  • In the legacy system, most BNF codes map to products (VMPs or AMPs) but some map to product packs (VMPPs or AMPPs)
  • In the new system, all BNF codes will map to products
  • In the new system, BNF names that contain pack sizes will be changed to remove the pack sizes
  • BNF codes that mapped to product packs in the legacy system will either be retired or repurposed to map to products in the new system
  • Since the monthly prescribing data uses BNF codes from the old system, it will reference BNF codes that are missing from the new mapping

Our goal

We get our prescribing information from the Detailed Prescribing Information dataset, which identifies presentations by BNF code. We want to be able to map between BNF codes and SNOMED codes so that we can use the richer metadata in dm+d to provide better information on the site.

  • Anywhere that we display information about presentations (ie everywhere!) we want where possible to use the nice names in dm+d over the truncated BNF names
  • We want to display metadata from dm+d against presentations in the prescribing data
    • For instance, on our PPU by presentation pages we want to show a presentation's tariff category, availability restrictions, and prescribability status, all of which come from dm+d
  • We want to be able to allow analysing prescription trends by metadata in dm+d
  • We want to accurately link presentations to the Drug Tariff and NCSO concessions
  • When displaying information about dm+d objects, we want to accurately link to the analyse page for the corresponding presentations

The mapping spreadsheet

In December 2018, the BSA sent us a spreadsheet containing a mapping between BNF codes and dm+d objects. This comes from the new system.

The spreadsheet has one row per dm+d item, and includes the following columns:

  • Presentation / Pack Level
  • VMP / AMP
  • SNOMED Code
  • BNF Code

Presentation / Pack Level and VMP / AMP combine to indicate whether the row is for a VMP, VMPP, AMP, or AMPP, and SNOMED Code identifies the dm+d object.

Using the mapping in this spreadsheet, we are able to assign BNF codes to a significant proportion of the dm+d objects in our database. See import_snomed_mapping.

Visualising the mapping

We have found the easiest way to understand the relationship between a family of dm+d objects (that is, a VMP, all its VMPPs and AMPs, and all their AMPPs) is to arrange them in a table, with VMPPs as column headings, AMPs as row headings, and AMPPs in the cells. This allows us to see at a glance how many VMPPs and AMPs a family has, and how AMPPs are distributed between VMPPs and AMPs.

Additionally, we have found it helpful to colour cells in the table according to the BNF code in the mapping.

For example, consider Dapoxetine 30mg tablets.

Dapoxetine 30mg tablets

This shows that the VMP has a BNF code, and that members of the family have 3 BNF codes. There are 3 VMPPs and 4 AMPs, with 6 AMPPs between them. 1 AMP and its AMPP do not have BNF codes, while the other AMPs do have BNF codes. One of those AMPs shares its BNF code with the VMP. For the AMPPs that do have BNF codes, their BNF code matches that of their AMP.

Interpreting the mapping

BNF codes are designed to be for products (VMPs and AMPs) and not for product packs, and so we want to be able to map a BNF code to one or more VMPs or AMPs.

In the vast majority of cases, if an AMPP has a BNF code, then this will be the same as the AMPP's AMP's BNF code. There are number of patterns here:

Problems interpreting the mapping

There are around 200 VMP families for which it is not the case that if an AMPP has a BNF code, then it will be the same as the AMPP's AMP's (as derived from DM+D) BNF code. We have observed some patterns here. For instance:

In each case, we'd like to know how the problem would be resolved, and ideally when we can expect this to happen. We can easily provide a full list of problem VMPs if requested.

Generic BNF codes and the mapping

We have assumed that

  • a VMP corresponds to a generic presentation (and conversely, that only AMPs correspond to branded presentations)
  • if an AMP corresponds to a generic presentation, its VMP will correspond to the same generic presentation

However, this is not always reflected in the BNF codes from the mapping.

There are 3204 VMPs with branded BNF codes. In all of these cases, all of the VMP's AMPs also have branded BNF codes. For example, this Lucozade drink is mapped to a VMP although it is a brand. Its VMP name is, confusingly, "Generic Lucozade Energy Original oral solution". Is this going to remain the case? What does this mean?

There are 8346 VMPs with AMPs with generic BNF codes, and for 7766 of these, the BNF codes of AMPs with generic BNF codes match that of the VMP. These are (presumably) what we call "ghost-branded" generics.

But there are 580 VMPs where an AMP has a generic BNF code which does not match the VMP's BNF code, broken down as follows:

  • VMP BNF code is generic
    • Single AMP has generic BNF code
      • This is not the VMP's BNF code (26)
    • Some AMPs have generic BNF codes
      • Only some AMPs with generic BNF codes have the VMP's BNF code (51)
      • No AMPs with generic BNF codes have the VMP's BNF code (38)
    • All AMPs have generic BNF codes
      • Only some AMPs have the VMP's BNF code (29)
  • VMP has no BNF code
    • Some AMPs have generic BNF codes (283)
    • All AMPs have generic BNF codes (114)
    • Single AMP has generic BNF code (39)