Skip to content

Instantly share code, notes, and snippets.

@Nuelsville
Forked from cryocaustik/README.md
Created May 19, 2022 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nuelsville/3f9df6ccf464040a0c8e7d32a6f600bf to your computer and use it in GitHub Desktop.
Save Nuelsville/3f9df6ccf464040a0c8e7d32a6f600bf 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.
@Nuelsville
Copy link
Author

I am working on an EMR and I must say, you are a live saver

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