Skip to content

Instantly share code, notes, and snippets.

@cryocaustik
Last active October 3, 2023 21:16
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save cryocaustik/b86de96e66489ada97c25fc25f755de0 to your computer and use it in GitHub Desktop.
Save cryocaustik/b86de96e66489ada97c25fc25f755de0 to your computer and use it in GitHub Desktop.
JSON Dump of ICD 10 Codes & Desc

CMS ICD GEMs JSON Dump

JSON Dump of ICD 10 Codes & Desc

Data Sample (formatted)

[
    {
      "code": "A000",
      "desc": "holera due to Vibrio cholerae 01, biovar cholerae"
    }, {
      "code": "A001",
      "desc": "holera due to Vibrio cholerae 01, biovar eltor"
    },
]

Source

Data raw text data downloaded from CMS ICD GEMs

Conversion

import json

"""Convert CMS GEM ICD Dump to ICD Code:Desc JSON dump.

    Data downloaded from: https://www.cms.gov/Medicare/Coding/ICD10/2018-ICD-10-CM-and-GEMs.html
"""

# import raw txt
path_import = r'./icd10cm_codes_2018.txt'
with open(path_import, 'r') as _f:
    raw = _f.read()
    _f.close()

# convert raw txt to json
data = []
for rcd in raw.split('\n'):
    if rcd:
        data.append({
            'code': rcd[:8].strip(),
            'desc': rcd[9:],
        })

# export converted json
path_export = './codes_icd10.json'
with open(path_export, 'w') as _f:
    json.dump(data, _f)
    _f.close()
This file has been truncated, but you can view the full file.
@buecktobias
Copy link

Great!

@Nuelsville
Copy link

I am working on an EMR and I must say "You are a life saver"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment