1Net::HL7::Message(3)  User Contributed Perl Documentation Net::HL7::Message(3)
2
3
4

NAME

6       Net::HL7::Message
7

SYNOPSIS

9       my $request = new Net::HL7::Request(); my $conn = new
10       Net::HL7::Connection('localhost', 8089);
11
12       my $msh = new Net::HL7::Segments::MSH();
13
14       my $seg1 = new Net::HL7::Segment("PID");
15
16       $seg1->setField(1, "foo");
17
18       $request->addSegment($msh); $request->addSegment($seg1);
19
20       my $response = $conn->send($request);
21

DESCRIPTION

23       In general one needn't create an instance of the Net::HL7::Message
24       class directly, but use the Net::HL7::Request class. When adding
25       segments, note that the segment index starts at 0, so to get the first
26       segment, segment, do "$msg->getSegmentByIndex(0)".
27
28       The segment separator defaults to \015. To change this, set the
29       variable $Net::HL7::SEGMENT_SEPARATOR.
30

METHODS

32       $msg = new Net::HL7::Message([$msg])
33           The constructor takes an optional string argument that is a string
34           representation of a HL7 message. If the string representation is
35           not a valid HL7 message. according to the specifications, undef is
36           returned instead of a new instance. This means that segments should
37           be separated within the message with the segment separator
38           (defaults to \015) or a newline, and segments should be
39           syntactically correct.  When using the string argument constructor,
40           make sure that you have escaped any characters that would have
41           special meaning in Perl. For instance (using a different
42           subcomponent separator):
43
44               C<$msg = new Net::HL7::Message("MSH*^~\\@*1\rPID***x^x@y@z^z\r");>
45
46           would actually mean
47
48               C<$msg = new Net::HL7::Message("MSH*^~\\@*1\rPID***x^x^z\r");>
49
50           since '@y@z' would be interpreted as two empty arrays, so do:
51
52               C<$msg = new Net::HL7::Message("MSH*^~\\@*1\rPID***x^x\@y\@z^z\r");>
53
54           instead.
55
56           The control characters and field separator will take the values
57           from the MSH segment, if set. Otherwise defaults will be used.
58           Changing the MSH fields specifying the field separator and control
59           characters after the MSH has been added to the message will result
60           in setting these values for the message.
61
62           If the message couldn't be created, for example due to a erroneous
63           HL7 message string, undef is returned.
64
65       addSegment($segment)
66           Add the segment. to the end of the message. The segment should be
67           an instance of Net::HL7::Segment.
68
69       insertSegment($segment, $idx)
70           Insert the segment. The segment should be an instance of
71           Net::HL7::Segment. If the index is not given, nothing happens.
72
73       getSegmentByIndex($index)
74           Return the segment specified by $index. Segment count within the
75           message starts at 0.
76
77       getSegmentsByName($name)
78           Return an array of all segments with the given name
79
80       removeSegmentByIndex($index)
81           Remove the segment indexed by $index. If it doesn't exist, nothing
82           happens, if it does, all segments after this one will be moved one
83           index up.
84
85       setSegment($seg, $index)
86           Set the segment on index. If index is out of range, or not
87           provided, do nothing. Setting MSH on index 0 will revalidate field
88           separator, control characters and hl7 version, based on MSH(1),
89           MSH(2) and MSH(12).
90
91       getSegments()
92           Return an array containing all segments in the right order.
93
94       toString([$pretty])
95           Return a string representation of this message. This can be used to
96           send the message over a socket to an HL7 server. To print to other
97           output, use the $pretty argument as some true value. This will not
98           use the default segment separator, but '\n' instead.
99
100       getSegmentAsString($index)
101           Get the string representation of the segment, in the context of
102           this message. That means the string representation will use the
103           message's separators.
104
105       getSegmentFieldAsString($segmentIndex, $fieldIndex)
106       removeSegmentByName($name)
107           Remove the segment indexed by $name. If it doesn't exist, nothing
108           happens, if it does, all segments after this one will be moved one
109           index up.
110

AUTHOR

112       D.A.Dokter <dokter@wyldebeast-wunderliebe.com>
113

LICENSE

115       Copyright (c) 2002 D.A.Dokter. All rights reserved.  This program is
116       free software; you can redistribute it and/or modify it under the same
117       terms as Perl itself.
118
119
120
121perl v5.34.0                      2021-07-22              Net::HL7::Message(3)
Impressum