SimonSays
SimonSays

Reputation: 75

Can single HL7 file contain multiple messages or just one?

I am trying to read & parse HL7 messages and have a question about how they're physically stored in a file.

Can a file contain multiple HL7 messages or will a file only contain single message?

Upvotes: 1

Views: 995

Answers (2)

Amit Joshi
Amit Joshi

Reputation: 16409

There is no such a concept in HL7 protocol as "File".

  • You choose whether to store the message in file or save it in database or elsewhere.
  • You create a file if you need.
  • You choose its extension as ".hl7" or ".txt" or else.
  • You choose whether there should be single message in a file or multiple.

HL7 message when transferred on socket needs to be enclosed in MLLP blocks. You can learn more about it here and here. Here, of-course it matters that you enclose each message separately in MLLP block.

Note that, even though you store the message in file, there is no "file header". So, to summarize it all -- "Its up to you".


I was not aware about FHS (file header) and BHS (batch header) feature (2.3.6 HL7 Batch Protocol) in HL7. I learned it from other answer from @sqlab on this question.
Yes; it is a feature for batching the messages.
But I still do not think the FHS and BHS is "file header" the way we have header for JPEG or many other file types where we can read just header and validate file type.
If there is no FHS segment in message file, we cannot say it is not a HL7 message.
Not sure though, one may have multiple "batches" in single file.
IMO, this more behaves like "batching the messages" than a "file header".

About extension ".hl7"; yes, many organizations use this extension commonly for HL7 files.
But it is not standard or mandatory or forced per say (not mentioned in Specifications).
Just making the extension ".txt" does not make it invalid HL7 file; though some third party applications may not work with it, but that is different problem.

Upvotes: 0

sqlab
sqlab

Reputation: 6436

HL7 message files have mostly the extension *.hl7.

There are the FHS (file header), FTS (file trailer) and BHS (batch header), BTS (batch trailer) segments to envelope multiple HL7-messages in one message file.

I recommend to search for "hl7 fhs bhs" in Google.

from HL7eu 2.3.6 HL7 Batch Protocol

[FHS] (file header segment)
  { [BHS] (batch header segment)
   { MSH (one or more HL7 messages)
     ....
     ....
     ....
    }
   [BTS] (batch trailer segment)
  }
  [FTS] (file trailer segment)

Upvotes: 2

Related Questions