ex_hl7 v0.3.0 HL7.Reader

Reader for the HL7 protocol. You can test its functionality with the following lines on ìex:

r HL7.Lexer
r HL7.Reader
reader = HL7.Reader.new
buffer = 
"MSH|^~\&|SERV|223344^^II|POSM|CARRIER^CL9999^IP|20030127202538||RPA^I08|5307938|P|2.3|||NE|NE

“ <>

"MSA|AA|CL999920030127203647||||B006^

“ <>

"AUT|TESTPLAN|223344^^II||||5307938||0|0

“ <>

"PRD|RT|NOMBRE PRESTADOR SALUD|||||99999999999^CU^GUARDIA

“ <>

"PRD|RP||||||9^^N

“ <>

"PID|||2233441000013527101=0000000000002|1|APELLIDO^NOMBRE

“ <>

"PR1|1||420101^CONSULTA EN CONSULTORIO^NA^||20030127203642|Z

“ <>

"AUT|PLANSALUD|||20030127|20030127|5307938|0.00^$|1|1

“ <>

"NTE|1||SIN CARGO

“ <>

"NTE|2||IVA: SI

b1 =
MSH|^~\&|SERV|223344^^II|POSM|CARRIER^CL9999^IP|20030127202538||RPA^I08|5307938|P|2.3|||NE|NE
MSA|AA|CL999920030127203647||||B006
AUT|TESTPLAN|223344^^II||||5307938||0|0
PRD|RT|NOMBRE PRESTADOR SALUD|||||99999999999^CU^GUARDIA
PRD|RP||||||9^^N
PID|||2233441000013527101=0000000000002|1|APELLIDO^NOMBRE
PR1|1||420101^CONSULTA EN CONSULTORIO^NA^||20030127203642|Z
AUT|PLANSALUD|||20030127|20030127|5307938|0.00^$|1|1
NTE|1||SIN CARGO
NTE|2||IVA: SI

{:ok, {reader, token, rest}} = HL7.Reader.read(reader, buffer)
token
{:ok, {reader, token, rest}} = HL7.Reader.read(reader, rest); {reader.segment_id, reader.sequence, token}

{:ok, msg} = HL7.read(buffer)
buf2 = HL7.write(msg, input_format: :text)
IO.puts(buf2)

Summary

Functions

Create a new Reader instance

Read a token from the reader

Return the segment ID of the segment that is being read by the Reader

Return the separators that were used in the message that was read by the Reader

Return the sequence number of the last field that was read by the Reader

Types

t :: %HL7.Reader{item_type: HL7.Type.item_type, lexer: HL7.Lexer.t, segment_creator: (HL7.Type.segment_id -> {module, HL7.Segment.t}), segment_id: HL7.Type.segment_id, sequence: non_neg_integer, trim: boolean}
token ::
  {:start_segment, HL7.Type.segment_id} |
  {:end_segment, HL7.Type.segment_id} |
  {:field, HL7.Type.field}

Functions

create_segment(reader, segment_id)

Specs

create_segment(t, HL7.Type.segment_id) :: {module, HL7.Segment.t}
new(options \\ [])

Specs

new([option]) :: t

Create a new Reader instance

read(reader, buffer)

Specs

read(t, binary) ::
  {:token, {t, token, binary}} |
  {:incomplete, {t, binary}} |
  {:complete, t} |
  {:error, any}

Read a token from the reader.

segment_id(reader)

Specs

segment_id(t) :: HL7.Type.segment_id

Return the segment ID of the segment that is being read by the Reader.

separators(reader)

Specs

separators(t) :: binary

Return the separators that were used in the message that was read by the Reader.

sequence(reader)

Specs

sequence(t) :: 0 | HL7.Type.sequence

Return the sequence number of the last field that was read by the Reader.