Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Another example of where one shouldn’t let an edge case complicated a core design is HL7.

The Health Level Seven standard for electronic data transmission is a format which looks like this:

MSH|^~\&|EPIC|EPICADT|SMS|SMSADT|199912271408|CHARRIS|ADT^A04|1817457|D|2.5|
PID||0493575^^^2^ID 1|454721||DOE^JOHN^^^^|DOE^JOHN^^^^|19480203|M||B|254 MYSTREET AVE^^MYTOWN^O
NK1||ROE^MARIE^^^^|SPO||(216)123-4567||EC|||||||||||||||||||||||||||
PV1||O|168 ~219~C~PMA^^^^^^^^^||||277^ALLEN MYLASTNAME^BONNIE^^^^|||||||||| ||2688684|||||||

The format consists of data “delimited” by characters like | & ^ and ~.

Foolishly in my humble opinion the standard is needlessly complicated by allowing implementations to re-define the delimiter characters in the header - so if you want to use # characters instead of | then this is legal:

MSH#^~\&#EPIC#EPICADT#SMS#SMSADT#199912271408#CHARRIS#ADT^A04#1817457#D#2.5#
PID##0493575^^^2^ID 1#454721##DOE^JOHN^^^^#DOE^JOHN^^^^#19480203#M##B#254 MYSTREET AVE^^MYTOWN^O
NK1##ROE^MARIE^^^^#SPO##(216)123-4567##EC###########################
PV1##O#168 ~219~C~PMA^^^^^^^^^####277^ALLEN MYLASTNAME^BONNIE^^^^########## ##2688684#######

Legal - but not smart in my opinion. But why bother? The vast majority HL7 implementations use the standard characters. It’s just introducing friction and complexity for no good reason.

In Chameleon my first HL7 parser product I went to great effort to faithfully implement this part of the standard. What a waste of effort! Nowadays if I were to write an HL7 parser from scratch I wouldn’t implement this feature of HL7 as a core part of the filter.

Instead if a customer encountered the way that makes sense to solve the problem is just to preprocess the data with a normalization script like this:

function HL7Normalize(Msg)
   local Result = Msg
   -- Get the | delimiter
   local D= Msg:sub(4,4)
   Result:gsub(D, "|")
   -- Repeat for the other 4 delimeters
   return Result
end

Solve a one off uncommon problems with a one off simple solutions - see separation of concerns.

  • No labels