Skip to main content

ATC Code Classification

Overview

ATC (Anatomical Therapeutic Chemical) codes are used to classify drugs and other medical substances based on the organ or system they act on and their therapeutic, pharmacological, and chemical properties. In our system, we support storing one or more ATC codes for both Medication and Substance resources. These codes follow the official WHO ATC classification and use the system URL:

http://www.whocc.no/atc

FHIR Representation

In FHIR, we represent ATC codes using the code field in Medication and Substance resources. The code element is of type CodeableConcept, which can contain multiple coding entries. Each ATC code is represented as a Coding with the specified system URL.

ATC-coded Medication and Substance resources are stored as inline resources in the contained field of a MedicationRequest. This allows for efficient access and referencing within a single FHIR resource.

Example

{
"resourceType": "MedicationRequest",
"contained": [
{
"resourceType": "Medication",
"id": "med1",
"code": {
"coding": [
{
"system": "http://www.whocc.no/atc",
"code": "A10BA02",
"display": "Metformin"
},
{
"system": "http://www.whocc.no/atc",
"code": "A10BD05",
"display": "Metformin and sitagliptin"
},
{
"system": "http://www.whocc.no/atc",
"code": "A",
"display": "Alimentary tract and metabolism"
}
]
}
},
{
"resourceType": "Substance",
"id": "sub1",
"code": {
"coding": [
{
"system": "http://www.whocc.no/atc",
"code": "N02BE01",
"display": "Paracetamol"
},
{
"system": "http://www.whocc.no/atc",
"code": "N",
"display": "Nervous system"
}
]
}
}
]
}

Access Pattern

To retrieve all ATC codes from a MedicationRequest, iterate through the contained resources and filter by resourceType (Medication or Substance). For each matching resource, check the code.coding array for entries with the system http://www.whocc.no/atc.

Example pseudocode:

const atcCodes = [];
for (const resource of medicationRequest.contained) {
if (resource.resourceType === 'Medication' || resource.resourceType === 'Substance') {
const codings = resource.code?.coding || [];
for (const coding of codings) {
if (coding.system === 'http://www.whocc.no/atc') {
atcCodes.push(coding);
}
}
}
}

Grouping for Prescription Overview

In the Prescription Overview, we group medications and substances based on their top-level ATC classification. This means we only consider the first character of each ATC code (e.g., "A" for the alimentary tract and metabolism group, or "N" for the nervous system).

When processing the ATC codes for grouping:

  1. Extract the first character of each ATC code (e.g., "A10BA02""A").
  2. Ignore codes that are already single characters.
  3. Remove duplicate first-level codes.
  4. Use the resulting unique set of characters for grouping.

Example pseudocode:

const groupingLetters = new Set();
for (const coding of atcCodes) {
const code = coding.code;
if (code && typeof code === 'string' && code.length > 0) {
groupingLetters.add(code.charAt(0));
}
}
const uniqueTopLevelGroups = Array.from(groupingLetters);

This logic ensures that all medication and substance entries are correctly grouped by their anatomical/therapeutic classification in the UI.