model_utils.icd

class pytrial.model_utils.icd.ICD9Graph(input_dir=None)[source]

Bases: pytrial.model_utils.icd.ICDGraphBase

Get an ICD-9 knowledge graph to query parental and children nodes for each code.

Returns

  • self.graph (nx.DiGraph) – The hierarchy of ICD codes stored as graph in networkx.

  • self.codes (list[str]) – All the unique codes.

class pytrial.model_utils.icd.ICD10Graph(input_dir=None, version='2021')[source]

Bases: pytrial.model_utils.icd.ICDGraphBase

Get an ICD-10 knowledge graph to query parental and children nodes for each code.

Parameters
  • input_dir (str) – The dir that stores the hierarchy files.

  • version ({'2022', '2021','2020','2019'}) – The version of ICD-10 codes.

Returns

  • self.graph (nx.DiGraph) – The hierarchy of ICD codes stored as graph in networkx.

  • self.codes (list[str]) – All the unique codes.

class pytrial.model_utils.icd.ICD9_DX_VOC(input_dir='./resources')[source]

Bases: object

Get a vocabulary containing the mapping of ICD9 Diagnosis code and its names.

Parameters

input_dir (str) – The dir that stores ICD9-dx file.

code2desc(code)[source]

Get description of codes.

Parameters

code (str or List[str]) – The input icd code or list of codes.

class pytrial.model_utils.icd.ICD9_SG_VOC(input_dir='./resources')[source]

Bases: object

Get a vocabulary containing the mapping of ICD9 procedure code and its names.

Parameters

input_dir (str) – The dir that stores ICD9-sg file.

code2desc(code)[source]

Get description of codes.

Parameters

code (str or List[str]) – The input icd code or list of codes.

pytrial.model_utils.icd.get_icd10_from_nih(term)[source]

Query related ICD-10 codes for input terms.

Parameters

term (str or list[str]) – Disease names or a list of disease names.

Returns

Outputs ICD codes

Return type

list[str] or list[list[str]]

pytrial.model_utils.icd.get_icd9dx_from_nih(term)[source]

Query related ICD-9-CM diagnosis codes for input terms.

Parameters

term (str or list[str]) – Disease names or a list of disease names.

Returns

Outputs ICD codes

Return type

list[str] or list[list[str]]

pytrial.model_utils.icd.get_icd9sg_from_nih(term)[source]

Query related ICD-9-CM procedure codes for input terms.

Parameters

term (str or list[str]) – Disease names or a list of disease names.

Returns

Outputs ICD codes

Return type

list[str] or list[list[str]]

pytrial.model_utils.icd.get_condition_synonym_from_nih(term)[source]

Query relevant medical conditions taking input symptoms/diseases using API: https://clinicaltables.nlm.nih.gov/apidoc/conditions/v3/doc.html

Parameters

term (str or list[str]) – Disease names or a list of disease names.

Returns

Outputs ICD codes

Return type

list[str] or list[list[str]]