LOINC_SCT Condition Map Script: Overview & Instructions

Background

The LOINC_SCT_ConditionMap script associates LOINC test codes and SNOMED CT result codes by condition. The script uses the Reportable Conditions Trigger Codes (RCTC), which is a compilation of condition-specific standard codes created by the RCKMS Content Team with CSTE. The codes in the RCTC are grouped by type and associated with the appropriate condition. The RCKMS Condition Code file is used to map the condition codes in the RCTC to the common condition names.

The script also uses the LOINC code system file to associate each LOINC code with the appropriate scale. For scale types other than Nominal, the associated results in the final file are set by the user in a separate Excel file called the Results List. For LOINC codes with Nominal scale, the results list is pulled from the RCTC.

Method:

The script develops output using the following method:

  • Associates SNOMED CT result codes with LOINC test codes based on the condition in the RCTC

  • Uses the LOINC code system files to find each code’s scale and determine the correct result type

  • The user manually sets results for non-nominal LOINC codes

Inputs:

R Script:

  • Download the LOINC_SCT_ConditionMap script

RCTC Excel file: https://ersd.aimsplatform.org/#/home

  • Navigate to the eRSD website and log in.

  • Click “Select an eRSD version to download” then “Latest RCTC Spreadsheet and Change Log.” Reference screenshot below.

  • Extract the files from the zip folder and save the RCTC_Release (YYYY-MM-DD) file

RCKMS Condition Code file: https://www.rckms.org/content-repository/

  • Navigate to the RCKMS Content Repository and click on “RCKMS Content Release Materials”

  • Download and save the “RCKMS Condition Codes.YYYYMMDD” file

LOINC Code System CSV File: https://loinc.org/downloads/

  • Navigate to the LOINC download page and click to download the most recent code system file

  • Extract the files from the zip folder. Click on the LoincTable folder and save the Loinc.csv file

Result List

  • A template Results List is included and pre-populated with sample values. These values can be changed, but the column headers and filename must stay the same.

  • The LOINC scale types are listed in the first column, and the appropriate results are in the second and third column. The values associated with each scale type will be matched with LOINC codes of that scale in the final output file.

Outputs:

The output of the script is an Excel workbook titled “LOINC_SCT_ConditionMap.xlsx” with one sheet. On this sheet, each LOINC code is associated with each appropriate result code based on the LOINC scale. For Nominal LOINC codes, the code has been linked to the SNOMED CT result codes associated with the same condition in the RCTC. The columns are described below:

  • MemberOID – the value set OID from the RCTC

  • TestCode – LOINC code from the RCTC

  • Descriptor – LOINC description from the RCTC

  • SCALE_TYP – scale of the LOINC code from the Loinc csv file

  • ResultCode – SNOMED CT code from the RCTC

  • ResultDescription- SNOMED CT description from the RCTC

  • Condition – condition name this code is associated with in the RCTC

Additional Considerations:

The output of the script is built from the RCTC, which is designed to list all potentially relevant condition-specific codes. Therefore, the final output will be much more inclusive than may be desired for users intending to use it for validation. It may be useful as a starting point that can be narrowed down as needed.

Within the RCTC, occasionally codes for one condition are associated with a different condition. This happens in rare cases when the organisms are closely related, or a broad condition definition encompasses multiple organisms. In these situations, codes for one organism may be listed under a different condition. This may change in the future as the RCTC is maintained by the RCKMS Content Team, but these are the current scenarios in which this occurs:

  • Mpox: organism results for Orthopox will display under Mpox

o   Orthopox (Organism or Substance in Lab Results) 2.16.840.1.113762.1.4.1146.1910

  • Orthopox: organism results for Cowpox, Mpox, Smallpox, and Vaccinia will display under Orthopox

o   Cowpox (Organism or Substance in Lab Results) 2.16.840.1.113762.1.4.1146.1911

o   Mpox (Organism or Substance in Lab Results) 2.16.840.1.113762.1.4.1146.1386

o   Smallpox (Organism or Substance in Lab Results) 2.16.840.1.113762.1.4.1146.534

o   Vaccinia (Organism or Substance in Lab Results) 2.16.840.1.113762.1.4.1146.1608

Instructions

Setup (once per machine):

  1. Install base R and RStudio on your computer from the following links:

R:

R Studio:

2. Open RStudio and run the following commands in the console to install the packages:

install.packages('dplyr')

install.packages('writexl')

install.packages('readxl')

install.packages('readr')

  1. Download the script file “LOINC_SCT_ConditionMap.R”

  2. Choose a working directory folder on your computer to save the script and associated files. Create a new folder titled “data” within your working directory folder.

  3. Copy LOINC code system file, RCTC file, Results List, and RCKMS Condition Codes file into the “data” folder within your working directory folder.

Edit the Results List if needed. The list is pre-populated with values but can be edited to the users’ preference.

  1. Copy the filepath for your working directory. Open the “LOINC_SCT_ConditionMap.R” file. On line 1 replace the text “working directory here” with the filepath encased in single quotes with forward slashes. Example:

setwd('C:/Users/EmilyAugustini/APHL/RCode')

Run the Script:

  1. Open R Studio

  2. Open the file

  3. Click the “Run” button in the top right corner. The script will take a few minutes to run.

  4. When the script completes, navigate back to the File Explorer to view the output file in your working directory. There should be one output file: “LOINC_SCT_ConditionMap.xlsx

NOTE: Each time you run the script the file will be overwritten. Save the file with a different name if you would like to preserve previous versions.

Updating Input Files:

When a new version of LOINC is available:

  1. Download the new loinc.csv from the link in the previous section.

  2. Delete the previous file from the “data” folder and copy in the new file

When a new version of the RCTC is available:

  1. Download the new RCTC from the link in the previous section

  2. Delete the previous file from the “data” folder and copy in the new file

  3. Open the script and update the RCTC filename on row 20

  4. Save the script

When a new version of the RCKMS Condition Code List is available:

  1. Download the new Condition Code List from the link in the previous section

  2. Delete the previous file from the “data” folder and copy in the new file

  3. Open the script and update the Condition Code List filename on row 17

  4. Save the script

Tool Demo:

 

Questions? Contact informatics.support@aphl.org.