问题
I'm working on a project that involves HL7 messages. I've been reading the documentation to understand what the different kind of segments mean.
I've come across three different kinds of syntax when looking at the documents, they are below:
What is the difference between a segment without any sort of braces or brackets, a segment with both braces and brackets, and a segment with just brackets?
I assumed a segment with brackets may be some sort of array or list, but I haven't been able to find anything confirming this.
回答1:
Brackets indicate the segment is optional. [UAC]
means the UAC segment may or may not be in the message.
Braces (or curly brackets) indicate the segment can repeat. [{ SFT }]
means the SFT segment may or may not be in the message, and could repeat multiple times if it is.
A segment without any brackets or braces should be in the message once.
See this page for example.
回答2:
Segment with brackets ([]
):
- Brackets indicate segment is optional.
- These segments may or may not present in the message.
Segment with braces ({}
):
- Braces indicate segment is repeatable.
- These segments may repeat more than once in same message.
- The sequence of repeat segments may also matter.
Based on above, meaning of other combinations can be easily understood.
Segment without brackets and braces:
- These are mandatory segments (not optional; as not enclosed in brackets).
- These are allowed only once in the message (no repeat; as not enclosed in braces).
- That means one and only one instance of the segment must present in the message.
Segment with brackets as well as braces:
- These are optional segments (as enclosed in brackets).
- If present, these may occur once or multiple time in the message (as enclosed in braces).
You may find the details here and here.
So, in your screen shot in question:
MSH
segment must present only once.[{SFT}]
segment may not present at all; may present once; may present multiple times.[UAC]
segment may present only once or may not present at all.
来源:https://stackoverflow.com/questions/54313746/what-do-brackets-and-braces-mean-in-hl7-segments