funpack.icd10

This module contains functions for working with the ICD10 disease coding hierarcy.

The toNumeric() function will take an ICD10 coding, and return a numeric variant of it.

The storeCodes() function allows sets of ICD10 codes to be stored so that they can be saved out to a file via the saveCodes() function, at a later stage.

funpack.icd10.initialise(mgr=None)[source]

Initialise the module-level storage used by the storeCodes() function.

This function must be called if this module is to be used in a multiprocessing context. Furthermore, it must be called before the multiprocessing.Pool is created, so that the shared storage is initialised before the worker processes have been created. This is so that the shared storage will be available in the worker process’ address space.

This function does not need to be called in a single-process context.

Parameters:

mgrmultiprocessing.Manager used to create the shared storage. If None, the created store will only work within-process.

funpack.icd10.saveCodes(fname, hier, fields=None)[source]

Saves any codes which have been stored via storeCodes() out to the specified file.

Parameters:
  • fname – File to save the codes to.

  • hierHierarchy object containing the ICD10 hierarchy information.

  • fields

    Sequence of fields to include in the mapfile. Defaults to ['code', 'value', 'description', 'parent_descs]. May contain any of the following:

    • 'code'

    • 'value'

    • 'description'

    • 'parent_codes'

    • 'parent_descs'

funpack.icd10.storeCodes(codes)[source]

Stores the given sequence of ICD10 codes, so they can be exported to file at a later stage.

The codes are stored in a list called store, an attribute of this function.

Parameters:

codes – Sequence of ICD10 codes to add to the mapping file

funpack.icd10.toNumeric(code)[source]

Converts an ICD10 alpha-numeric code to a unique integer number.

This function may be used by the codeToNumeric() cleaning function.

This function is intended to be used with ICD10 codes - if it is used to convert longer strings containing many letters, it may produce integer values that cannot be represented in 64 bits.

See https://www.webpt.com/blog/understanding-icd-10-code-structure/ for an overview of the ICD10 coding scheme.