Data source/SPOR.OMS/data model/addressState/mapping/CDQ/transformation

From CDQ
Jump to navigation Jump to search


Part of Hierarchical relation between two concepts of the CDQ Data Model. Data source SPOR.OMS
Mapping source The source of a data model mapping. SPOR.OMS addressState, addressCountyADMINISTRATIVE_AREA_VALUE
Transformation type A type of a transformation applied to a data model mapping. CUSTOM_TRANSFORMATION"CUSTOM_TRANSFORMATION" is not in the list (UPPER_CASE, LOWER_CASE, CUSTOM) of allowed values for the "Has transformation type" property.
Transformation parameter A transformation parameter is an action proccessed by a data model transformation. n/a
Description Informal and comprehensive human-readable definition of a concept. n/a

Transformation code Any code (in Python, JAVA or other) that will transform values for a given data source attributes.

def transform(raw_data):
    if not raw_data.strip():
        return

    result = {}

    regionLines = [elem.strip() for elem in raw_data.split(';')]

    if len(regionLines) < 1:
        return

    regionLine1 = [elem.strip() for elem in regionLines[0].split('¦')]
    regionLine2 = [elem.strip() for elem in regionLines[1].split('¦')] if len(regionLines) > 1 else []

    if regionLine1 and regionLine1[0] and regionLine2 and regionLine2[0]:
        result["addresses[0].administrativeAreas[0].value"] = regionLine1[0] + ", " + regionLine2[0]
    elif regionLine1 and regionLine1[0]:
        result["addresses[0].administrativeAreas[0].value"] = regionLine1[0]
    elif regionLine2 and regionLine2[0]:
        result["addresses[0].administrativeAreas[0].value"] = regionLine2[0]

    if result:
        result["addresses[0].administrativeAreas[0].type.technicalKey"] = "REGION"

    return result