Search code examples
hl7

What should be the maximum length of the field considering it also have sub-fields/components?


If a field (for example in the PID segment) in an HL7 message contains sub-fields/components (e.g. the field PID.11.1 with & character delimiter) how I can calculate the length of the field?


Solution

  • Maximum length of field is total number of characters in all sub-fields/components.

    Let us continue with your example PID.11.1. The maximum length of the field is 106 with datatype XAD (Extended Address). This datatype may have multiple sub-fields/components. Note that Length column in there is displayed zero.

    XAD Datatype

    So the maximum length of 106 can be consumed by only one component, or it can be split by two or more components.

    Just a suggestion: Apart from standards, one must also take in to account the other party that is supposed to consume the message. There might be additional length related validations though does not match with specifications.