Builds HL7v2 ACK/NAK response messages.
Given an original message's MSH segment, generates an acknowledgment message with properly swapped sender/receiver fields and a matching message control ID in the MSA segment.
Examples
iex> msh = %HL7v2.Segment.MSH{
...> field_separator: "|",
...> encoding_characters: "^~\\&",
...> sending_application: %HL7v2.Type.HD{namespace_id: "SENDER"},
...> receiving_application: %HL7v2.Type.HD{namespace_id: "RECEIVER"},
...> message_type: %HL7v2.Type.MSG{message_code: "ADT", trigger_event: "A01"},
...> message_control_id: "MSG001",
...> processing_id: %HL7v2.Type.PT{processing_id: "P"},
...> version_id: %HL7v2.Type.VID{version_id: "2.5.1"}
...> }
iex> {ack_msh, msa} = HL7v2.Ack.accept(msh)
iex> msa.acknowledgment_code
"AA"
iex> msa.message_control_id
"MSG001"
iex> ack_msh.sending_application.namespace_id
"RECEIVER"
Summary
Functions
Builds an AA (Application Accept) acknowledgment.
Encodes an ACK response to wire format.
Builds an AE (Application Error) acknowledgment.
Builds an AR (Application Reject) acknowledgment.
Functions
@spec accept( HL7v2.Segment.MSH.t(), keyword() ) :: {HL7v2.Segment.MSH.t(), HL7v2.Segment.MSA.t()}
Builds an AA (Application Accept) acknowledgment.
Returns {ack_msh, msa}.
Options
:text— optional text message for MSA-3:message_control_id— override the generated ACK message control ID
@spec encode( {HL7v2.Segment.MSH.t(), HL7v2.Segment.MSA.t()} | {HL7v2.Segment.MSH.t(), HL7v2.Segment.MSA.t(), HL7v2.Segment.ERR.t()} ) :: binary()
Encodes an ACK response to wire format.
Accepts the tuple returned by accept/2, error/2, or reject/2.
Examples
iex> msh = %HL7v2.Segment.MSH{
...> field_separator: "|",
...> encoding_characters: "^~\\&",
...> sending_application: %HL7v2.Type.HD{namespace_id: "SENDER"},
...> message_type: %HL7v2.Type.MSG{message_code: "ADT", trigger_event: "A01"},
...> message_control_id: "MSG001",
...> processing_id: %HL7v2.Type.PT{processing_id: "P"},
...> version_id: %HL7v2.Type.VID{version_id: "2.5.1"}
...> }
iex> ack = HL7v2.Ack.accept(msh)
iex> wire = HL7v2.Ack.encode(ack)
iex> String.starts_with?(wire, "MSH|^~\\&|")
true
@spec error( HL7v2.Segment.MSH.t(), keyword() ) :: {HL7v2.Segment.MSH.t(), HL7v2.Segment.MSA.t()} | {HL7v2.Segment.MSH.t(), HL7v2.Segment.MSA.t(), HL7v2.Segment.ERR.t()}
Builds an AE (Application Error) acknowledgment.
Returns {ack_msh, msa} or {ack_msh, msa, err} when :error_code is provided.
Options
:text— optional text message for MSA-3:error_code— HL7 error code identifier (e.g., "207"); triggers ERR segment:error_text— descriptive text for the error code:severity— error severity: "E" (error), "W" (warning), "I" (information); defaults to "E":message_control_id— override the generated ACK message control ID
@spec reject( HL7v2.Segment.MSH.t(), keyword() ) :: {HL7v2.Segment.MSH.t(), HL7v2.Segment.MSA.t()} | {HL7v2.Segment.MSH.t(), HL7v2.Segment.MSA.t(), HL7v2.Segment.ERR.t()}
Builds an AR (Application Reject) acknowledgment.
Returns {ack_msh, msa} or {ack_msh, msa, err} when :error_code is provided.
Options
:text— optional text message for MSA-3:error_code— HL7 error code identifier (e.g., "207"); triggers ERR segment:error_text— descriptive text for the error code:severity— error severity: "E" (error), "W" (warning), "I" (information); defaults to "E":message_control_id— override the generated ACK message control ID