I'm parsing hl7 to json. I opened the file and created an array where each line is an array like so...
[['MSH', '^~\\&', 'ADM', 'SHM', 'ALL', 'ALL', '20090101010000', 'ORU^R01', 'IHS-20090101010000.00830', 'P', '2.1\n'],
['PID', '1', '9081717170722.97472', 'RUBIE^ALBERT^ALLEN^^^AS', '19930812', 'M', '3250 DEL PASO BLVD^BUTTE^CHICO^CA^95973^USA', '393-41-9499', '393-41-9499\n']]
I created few functions to parse, delete empty elements and so on. At the end of the process, I'm iterating over the matrix and created a dictionary. However, I lose the order of each row in the dictionary...
{'IN1.0': {'IN1.0.0': 'IN1',
'IN1.0.1': '1',
'IN1.0.2': 'UNIT HLTH',
'IN1.0.3': 'RUBIE^ALBERT^ALLEN^^^AS',
'IN1.0.4': 'SELF'},
'MSH.0': {'MSH.0.0': 'MSH',
'MSH.0.1': '^~\\&',
'MSH.0.10': '2.1',
'MSH.0.2': 'ADM',
'MSH.0.3': 'SHM',
'MSH.0.4': 'ALL',
'MSH.0.5': 'ALL',
'MSH.0.6': '20090101010000',
'MSH.0.7': 'ORU^R01',
'MSH.0.8': 'IHS-20090101010000.00830',
'MSH.0.9': 'P'},
The MSH should be the first line in the object and it came 2nd. Also notice the MSH.0.1 is followed by MSH.0.10. It looks like the dictionary in Python is sorting the keys by default. If so... How can I keep the order as FIFO?