ex_hl7 v1.0.0 HL7.Reader
Reader for the HL7 protocol. You can test its functionality with the following lines on ìex
:
alias HL7.Lexer
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
{:token, {reader, token, rest}} = HL7.Reader.read(reader, buffer)
token
{:token, {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)
Link to this section 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
.
Link to this section Types
Link to this type
option()
option() :: {:segment_builder, module()} | {:trim, boolean()} | HL7.Lexer.option()
Link to this type
t()
t() :: %HL7.Reader{ item_type: :segment | HL7.Type.item_type(), lexer: HL7.Lexer.t(), segment_builder: module(), segment_id: HL7.Type.segment_id() | nil, sequence: non_neg_integer(), trim: boolean() }
Link to this type
token()
token() :: {:start_segment, HL7.Type.segment_id()} | {:end_segment, HL7.Type.segment_id()} | {:field, HL7.Type.field()}
Link to this section Functions
Link to this function
create_segment(reader, segment_id)
create_segment(t(), HL7.Type.segment_id()) :: {:ok, {HL7.Segment.t(), HL7.Segment.spec()}} | {:error, any()}
Create a new Reader instance
Link to this function
read(reader, buffer)
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
.