ICD-11 Data
ICD is the foundation for the identification of health trends and statistics globally, and the international standard for reporting diseases and health conditions. It is the diagnostic classification standard for all clinical and research purposes. ICD defines the universe of diseases, disorders, injuries and other related health conditions, listed in a comprehensive, hierarchical fashion that allows for:
easy storage, retrieval and analysis of health information for evidenced-based decision-making; sharing and comparing health information between hospitals, regions, settings and countries; and data comparisons in the same location across different time periods. Uses include monitoring of the incidence and prevalence of diseases, observing reimbursements and resource allocation trends, and keeping track of safety and quality guidelines. They also include the counting of deaths as well as diseases, injuries, symptoms, reasons for encounter, factors that influence health status, and external causes of disease. Source
Getting Client Key for API connection
By default one client Id and client secret is provided to be able to authenticate your software to use the ICD APIs. You may however, add more clients or remove some of them. (IMPORTANT!!! If a client key is removed, clients configured with this Id/secret will not be able access the API anymore)
ClientId: xxxxxx ClientSecret: xxxxxxx
import requests import json
ClientId = "xxxxxx" ClientSecret = "xxxxxx"
token_endpoint = 'https://icdaccessmanagement.who.int/connect/token' client_id = ClientId client_secret = ClientSecret scope = 'icdapi_access' grant_type = 'client_credentials'
Get the OAUTH2 token
# set data to post payload = {'client_id': client_id, 'client_secret': client_secret, 'scope': scope, 'grant_type': grant_type} # make request r = requests.post(token_endpoint, data=payload, verify=True).json() token = r['access_token']
Access ICD API
uri = 'https://id.who.int/icd/entity' # HTTP header fields to set headers = {'Authorization': 'Bearer '+token, 'Accept': 'application/json', 'Accept-Language': 'en', 'API-Version': 'v2'} # make request r = requests.get(uri, headers=headers, verify=True) # print the result # print (r.text)
print(r.json())
{'@context': 'http://id.who.int/icd/contexts/contextForTopLevel.json', '@id': 'http://id.who.int/icd/entity', 'title': {'@language': 'en', '@value': 'International Classification of Diseases 11th Revision'}, 'releaseId': '2019-04', 'releaseDate': '2019-04-06', 'child': ['http://id.who.int/icd/entity/1435254666', 'http://id.who.int/icd/entity/1630407678', 'http://id.who.int/icd/entity/1766440644', 'http://id.who.int/icd/entity/1954798891', 'http://id.who.int/icd/entity/21500692', 'http://id.who.int/icd/entity/334423054', 'http://id.who.int/icd/entity/274880002', 'http://id.who.int/icd/entity/1296093776', 'http://id.who.int/icd/entity/868865918', 'http://id.who.int/icd/entity/1218729044', 'http://id.who.int/icd/entity/426429380', 'http://id.who.int/icd/entity/197934298', 'http://id.who.int/icd/entity/1256772020', 'http://id.who.int/icd/entity/1639304259', 'http://id.who.int/icd/entity/1473673350' ,'http://id.who.int/icd/entity/30659757', 'http://id.who.int/icd/entity/577470983', 'http://id.who.int/icd/entity/714000734', 'http://id.who.int/icd/entity/1306203631', 'http://id.who.int/icd/entity/223744320', 'http://id.who.int/icd/entity/1843895818', 'http://id.who.int/icd/entity/435227771', 'http://id.who.int/icd/entity/850137482', 'http://id.who.int/icd/entity/1249056269', 'http://id.who.int/icd/entity/1596590595', 'http://id.who.int/icd/entity/718687701', 'http://id.who.int/icd/entity/231358748', 'http://id.who.int/icd/entity/979408586', 'http://id.who.int/icd/entity/1801349023'], 'browserUrl': 'NA'}
D = r.json() ROOTS = [] for item in D['child']: ROOTS.append(item.split("/")[-1]) with open("ROOTS.json", 'w') as ff: json.dump(ROOTS,ff)
#ROOTS
MMS Data
uri = 'https://id.who.int/icd/entity/1435254666' # HTTP header fields to set headers = {'Authorization': 'Bearer '+token, 'Accept': 'application/json', 'Accept-Language': 'en', 'API-Version': 'v2'} # make request r = requests.get(uri, headers=headers, verify=True) # print the result # print (r.text) print(r.json())
{'@context': 'http://id.who.int/icd/contexts/contextForFoundationEntity.json', '@id': 'http://id.who.int/icd/entity/1435254666', 'parent': ['http://id.who.int/icd/entity'], 'child': ['http://id.who.int/icd/entity/588616678', 'http://id.who.int/icd/entity/1904876434', 'http://id.who.int/icd/entity/979278646', 'http://id.who.int/icd/entity/1539889147', 'http://id.who.int/icd/entity/1412960686', 'http://id.who.int/icd/entity/1935092859', 'http://id.who.int/icd/entity/487269828', 'http://id.who.int/icd/entity/1000704511', 'http://id.who.int/icd/entity/1104303944', 'http://id.who.int/icd/entity/1585949804', 'http://id.who.int/icd/entity/1959883044', 'http://id.who.int/icd/entity/921595235', 'http://id.who.int/icd/entity/1251496839', 'http://id.who.int/icd/entity/1136802325', 'http://id.who.int/icd/entity/145723401', 'http://id.who.int/icd/entity/985510409', 'http://id.who.int/icd/entity/293771399', 'http://id.who.int/icd/entity/5960175', 'http://id.who.int/icd/entity/911707612', 'http://id.who.int/icd/entity/1965146397', 'http://id.who.int/icd/entity/142052508', 'http://id.who.int/icd/entity/1760597414', 'http://id.who.int/icd/entity/458687859', 'http://id.who.int/icd/entity/2143513892'], 'browserUrl': 'NA', 'title': {'@language': 'en', '@value': 'Certain infectious or parasitic diseases'}, 'synonym': [{'label': {'@language': 'en', '@value': 'infection NOS'}}, {'label': {'@language': 'en', '@value': 'infection of unspecified organism and unspecified site'}}, {'label': {'@language': 'en', '@value': 'infectious disease NOS'}}, {'label': {'@language': 'en', '@value': 'infection unknown'}}, {'label': {'@language': 'en', '@value': 'infection process NOS'}}], 'definition': {'@language': 'en', '@value': 'This chapter includes certain conditions caused by a pathogenic organism or microorganism, such as a bacterium, virus, parasite, or fungus.'}, 'exclusion': [{'label': {'@language': 'en', '@value': 'Infection arising from device, implant or graft, not elsewhere classified'}, 'foundationReference': 'http://id.who.int/icd/entity/1612485599'}]}
uri = 'http://id.who.int/icd/release/11/2019-04/mms/135352227' # HTTP header fields to set headers = {'Authorization': 'Bearer '+token, 'Accept': 'application/json', 'Accept-Language': 'en', 'API-Version': 'v2'} # make request r = requests.get(uri, headers=headers, verify=True) # print the result # print (r.text) print(r.json())
{'@context': 'http://id.who.int/icd/contexts/contextForLinearizationEntity.json', '@id': 'http://id.who.int/icd/release/11/2019-04/mms/135352227', 'parent': ['http://id.who.int/icd/release/11/2019-04/mms/588616678'], 'child': ['http://id.who.int/icd/release/11/2019-04/mms/257068234', 'http://id.who.int/icd/release/11/2019-04/mms/416025325', 'http://id.who.int/icd/release/11/2019-04/mms/2080365623', 'http://id.who.int/icd/release/11/2019-04/mms/344162786', 'http://id.who.int/icd/release/11/2019-04/mms/250688797', 'http://id.who.int/icd/release/11/2019-04/mms/1000894786', 'http://id.who.int/icd/release/11/2019-04/mms/794462570', 'http://id.who.int/icd/release/11/2019-04/mms/1528414070', 'http://id.who.int/icd/release/11/2019-04/mms/1780040028', 'http://id.who.int/icd/release/11/2019-04/mms/515117475', 'http://id.who.int/icd/release/11/2019-04/mms/135352227/other', 'http://id.who.int/icd/release/11/2019-04/mms/135352227/unspecified'], 'browserUrl': 'https://icd.who.int/browse11/l-m/en#/http%3a%\ 2f%2fid.who.int%2ficd%2fentity%2f135352227', 'code': '', 'source': 'http://id.who.int/icd/entity/135352227', 'classKind': 'block', 'blockId': 'BlockL2-1A0', 'codeRange': '1A00-1A0Z', 'foundationChildElsewhere': [{'label': {'@language': 'en', '@value': 'Abdominal actinomycosis'}, 'foundationReference': 'http://id.who.int/icd/entity/2143116824', 'linearizationReference': 'http://id.who.int/icd/release/11/2019-04/mms/2143116824'}, {'label': {'@language': 'en', '@value': 'Listerial gastroenteritis'}, 'foundationReference': 'http://id.who.int/icd/entity/974967764', 'linearizationReference': 'http://id.who.int/icd/release/11/2019-04/mms/419706488/other'}], 'title': {'@language': 'en', '@value': 'Bacterial intestinal infections'}, 'definition': {'@language': 'en', '@value': 'Any condition of the intestines, caused by an infection with a bacterial source.'}, 'exclusion': [{'label': {'@language': 'en', '@value': 'Bacterial foodborne intoxications'}, 'foundationReference': 'http://id.who.int/icd/entity/1834648119', 'linearizationReference': 'http://id.who.int/icd/release/11/2019-04/mms/1834648119'}]}
A Sample File Parser
def file_parser(file): with open(file , "r")as f: FDATA = [] for line in f: raw = json.loads(line) item = collections.defaultdict(lambda : 'Key Not found') for key,value in raw.items(): item[key] = value #print(item) title = item['title']["@value"] ID = item["@id"].split("/")[-1] parents = [] if item['parent']!= "Key Not found": for pt in item['parent']: parents.append(pt.split("/")[-1]) childs = [] if item['child'] != "Key Not found": for ct in item['child']: childs.append(ct.split("/")[-1]) definition = item["definition"] if definition != "Key Not found": deff = definition["@value"] else: deff = definition synonym = item["synonym"] if synonym != "Key Not found": syn = [] for t in synonym: syn.append(t["@value"]) else: syn = synonym FDATA.append({ID :{"title":title,\ "synonym" : syn,\ "definition":deff,\ "parents":parents,\ "childs":childs}}) return FDATA