MedCode#
We provide medical code mapping tools for (i) ontology mapping within one coding system and (ii) mapping the same concept cross different coding systems.
- class pyhealth.medcode.InnerMap(vocabulary, refresh_cache=False)[source]#
Bases:
ABC
Contains information for a specific medical code system.
InnerMap is a base abstract class for all medical code systems. It will be instantiated as a specific medical code system with InnerMap.load(vocabulary).
Note
This class cannot be instantiated using __init__() (throws an error).
- classmethod load(vocabulary, refresh_cache=False)[source]#
Initializes a specific medical code system inheriting from InnerMap.
- Parameters
Examples
>>> from pyhealth.medcode import InnerMap >>> icd9cm = InnerMap.load("ICD9CM") >>> icd9cm.lookup("428.0") 'Congestive heart failure, unspecified' >>> icd9cm.get_ancestors("428.0") ['428', '420-429.99', '390-459.99', '001-999.99']
- static standardize(code)[source]#
Standardizes a given code.
Subclass will override this method based on different medical code systems.
- Return type
- static convert(code, **kwargs)[source]#
Converts a given code.
Subclass will override this method based on different medical code systems.
- Return type
- class pyhealth.medcode.CrossMap(source_vocabulary, target_vocabulary, refresh_cache=False)[source]#
Bases:
object
Contains mapping between two medical code systems.
CrossMap is a base class for all possible mappings. It will be initialized with two specific medical code systems with CrossMap.load(source_vocabulary, target_vocabulary).
- classmethod load(source_vocabulary, target_vocabulary, refresh_cache=False)[source]#
Initializes the mapping between two medical code systems.
- Parameters
Examples
>>> from pyhealth.medcode import CrossMap >>> mapping = CrossMap("ICD9CM", "CCSCM") >>> mapping.map("428.0") ['108']
>>> mapping = CrossMap.load("NDC", "ATC") >>> mapping.map("00527051210", target_kwargs={"level": 3}) ['A11C']
- map(source_code, source_kwargs=None, target_kwargs=None)[source]#
Maps a source code to a list of target codes.
- Parameters
source_code (
str
) – source code.**source_kwargs (
Optional
[Dict
]) – additional arguments for the source code. Will be passed to self.s_class.convert(). Default is empty dict.**target_kwargs (
Optional
[Dict
]) – additional arguments for the target code. Will be passed to self.t_class.convert(). Default is empty dict.
- Return type
- Returns
A list of target codes.
Diagnosis codes:#
- class pyhealth.medcode.ICD9CM(**kwargs)[source]#
Bases:
InnerMap
9-th International Classification of Diseases, Clinical Modification.
Procedure codes:#
- class pyhealth.medcode.ICD9PROC(**kwargs)[source]#
Bases:
InnerMap
9-th International Classification of Diseases, Procedure.