import json
import re


def rename_terms(node_list):
    """
    Rename some terms for RDcode

    :param node_list: list of disorder objects
    :return: node_list with renamed terms
    """
    node_list = json.dumps(node_list)

    patterns = {"\"Totalstatus\":": "\"Status\":",
                "\"Name\":": "\"Preferred term\":",
                "\"PreferredTerm\":": "\"Preferred term\":",
                # "\"GroupOfType\":": "\"ClassificationLevel\":",
                "\"ExpertLink\":": "\"OrphanetURL\":",
                "\"DisorderType\":": "\"Typology\":",
                }

    for key, value in patterns.items():
        pattern = re.compile(key)
        node_list = pattern.sub(value, node_list)

    node_list = json.loads(node_list)
    return node_list