Commit ad8034eb authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF: Moved metaproc functions into their own module

parent 639c986c
...@@ -184,6 +184,7 @@ def registerBuiltIns(): ...@@ -184,6 +184,7 @@ def registerBuiltIns():
import ukbparse.exporting_tsv as uet import ukbparse.exporting_tsv as uet
import ukbparse.cleaning_functions as cf import ukbparse.cleaning_functions as cf
import ukbparse.processing_functions as pf import ukbparse.processing_functions as pf
import ukbparse.metaproc_functions as mf
if firstTime: if firstTime:
loglevel = log.getEffectiveLevel() loglevel = log.getEffectiveLevel()
...@@ -194,6 +195,7 @@ def registerBuiltIns(): ...@@ -194,6 +195,7 @@ def registerBuiltIns():
importlib.reload(uet) importlib.reload(uet)
importlib.reload(cf) importlib.reload(cf)
importlib.reload(pf) importlib.reload(pf)
importlib.reload(mf)
if firstTime: if firstTime:
log.setLevel(loglevel) log.setLevel(loglevel)
......
#!/usr/bin/env python
#
# metaproc_functions.py - Functions for manipulating column metadata.
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
"""This module contains ``metaproc`` functions - functions for manipulating
column metadata.
Some :class:`.Column` instances have a ``metadata`` attribute, containing some
additional information about the column. The functions in this module can be
used to modify these metadata values. Currently, column metadata is only used
to generate a description of each column (via the ``--description_file``
command-line option).
"""
from . import icd10
from . import custom
from . import hierarchy
@custom.metaproc('icd10.numdesc')
def icd10DescriptionFromNumeric(val):
"""Generates a description for a numeric ICD10 code. """
val = icd10.numericToCode(val)
hier = hierarchy.getHierarchyFilePath(name='icd10')
hier = hierarchy.loadHierarchyFile(hier)
desc = hier.description(val)
return '{} - {}'.format(val, desc)
@custom.metaproc('icd10.codedesc')
def icd10DescriptionFromCode(val):
"""Generates a description for an ICD10 code. """
hier = hierarchy.getHierarchyFilePath(name='icd10')
hier = hierarchy.loadHierarchyFile(hier)
desc = hier.description(val)
return '{} - {}'.format(val, desc)
...@@ -37,9 +37,7 @@ import collections ...@@ -37,9 +37,7 @@ import collections
import pyparsing as pp import pyparsing as pp
from . import util from . import util
from . import icd10
from . import custom from . import custom
from . import hierarchy
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -353,22 +351,3 @@ def makeParser(): ...@@ -353,22 +351,3 @@ def makeParser():
function = funcName + pp.Optional(allargs) function = funcName + pp.Optional(allargs)
return function return function
@custom.metaproc('icd10.numdesc')
def icd10DescriptionFromNumeric(val):
"""Generates a description for a numeric ICD10 code. """
val = icd10.numericToCode(val)
hier = hierarchy.getHierarchyFilePath(name='icd10')
hier = hierarchy.loadHierarchyFile(hier)
desc = hier.description(val)
return '{} - {}'.format(val, desc)
@custom.metaproc('icd10.codedesc')
def icd10DescriptionFromCode(val):
"""Generates a description for an ICD10 code. """
hier = hierarchy.getHierarchyFilePath(name='icd10')
hier = hierarchy.loadHierarchyFile(hier)
desc = hier.description(val)
return '{} - {}'.format(val, desc)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment