//Python script to translate between different identifiers

Python script to translate between different identifiers

This application was developed to translate two different identifiers which are used to identify patient information in different data sets. Given the scenarios that we have multiple systems which generate and assign a new patient identifier for holding a patients information. This application can be used to translate between the two.

Data for patients can be exported into CSV format. We need a way to translate from one identifier in one data set, to another, in another data set, when given an id map.

The code below builds up a dictionary from the given id map. It can then be used to translate from id in one system to another.

A snippet of the code from the application is provided below.


def createMappingsFromFile(fileName):
"""
This function creates two look up tables from the given 2 column csv file.

The first look up will be mapping from columnA to columnB
The second look up will be mapping columnB to columnA

"""
mapAtoB ={}
mapBtoA ={}

with open(fileName, 'rb') as f:
reader = csv.reader(f)
next(reader)#skip header
fileLines = list(reader)

for line in fileLines:
mapAtoB[line[0]] = line[1]
mapBtoA[line[1]] = line[0]

return mapAtoB, mapBtoA

The full application can be provided on request.