In [1]:
msgtxt = "MSH|^~\&|CERNER||PriorityHealth||||ORU^R01|Q479004375T431430612|P|2.3"

In [2]:
msgtxt


Out[2]:
'MSH|^~\\&|CERNER||PriorityHealth||||ORU^R01|Q479004375T431430612|P|2.3'

In [3]:
msgfields = msgtxt.split(sep="|")

In [4]:
msgfields


Out[4]:
['MSH',
 '^~\\&',
 'CERNER',
 '',
 'PriorityHealth',
 '',
 '',
 '',
 'ORU^R01',
 'Q479004375T431430612',
 'P',
 '2.3']

In [7]:
msgfields


Out[7]:
['MSH',
 '^~\\&',
 'CERNER',
 '',
 'PriorityHealth',
 '',
 '',
 '',
 'ORU^R01',
 'Q479004375T431430612',
 'P',
 '2.3']

In [12]:
msgcomps = list(map(lambda x: x.split(sep="^"), msgfields))

In [13]:
msgcomps


Out[13]:
[['MSH'],
 ['', '~\\&'],
 ['CERNER'],
 [''],
 ['PriorityHealth'],
 [''],
 [''],
 [''],
 ['ORU', 'R01'],
 ['Q479004375T431430612'],
 ['P'],
 ['2.3']]

In [11]:



Out[11]:
'<map object at 0x106c59ef0>'

In [15]:



Out[15]:
"['MSH']"

In [20]:
msgcomps[0][0]


Out[20]:
'MSH'

In [18]:
msgcomps[8][1]


Out[18]:
'R01'