Skip to content

medcat.utils.legacy.fixes

Functions:

Attributes:

logger module-attribute

logger = getLogger(__name__)

fix_cui2original_names_if_needed

fix_cui2original_names_if_needed(cdb: CDB) -> bool

Fix the cui2original names in CDB if needed.

This was an issue caused by faulty legacy conversion where the data wasn't moved correctly from addl_info.

Parameters:

  • cdb

    (CDB) –

    The CDB in question.

Returns:

  • bool ( bool ) –

    Whether the fix / change was made.

Source code in medcat-v2/medcat/utils/legacy/fixes.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
def fix_cui2original_names_if_needed(cdb: CDB) -> bool:
    """Fix the cui2original names in CDB if needed.

    This was an issue caused by faulty legacy conversion
    where the data wasn't moved correctly from addl_info.

    Args:
        cdb (CDB): The CDB in question.

    Returns:
        bool: Whether the fix / change was made.
    """
    if "cui2original_names" in cdb.addl_info:
        logger.info(
            "CDB addl_info contains legacy data: "
            "'cui2original_names' . Moving it to cui2info")
        _fix_cui2original_names(cdb)
        return True
    else:
        logger.debug("CDB does not contain legacy 'cui2original_names")
        return False