line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
################################################################################ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# File : Segment.pm |
4
|
|
|
|
|
|
|
# Author : Duco Dokter |
5
|
|
|
|
|
|
|
# Created : Tue Mar 4 13:03:00 2003 |
6
|
|
|
|
|
|
|
# Version : $Id: MSH.pm,v 1.6 2004/02/10 14:31:54 wyldebeast Exp $ |
7
|
|
|
|
|
|
|
# Copyright : Wyldebeast & Wunderliebe |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
################################################################################ |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Net::HL7::Segments::MSH; |
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
3714
|
use 5.004; |
|
3
|
|
|
|
|
9
|
|
14
|
3
|
|
|
3
|
|
13
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
78
|
|
15
|
3
|
|
|
3
|
|
15
|
use base qw(Net::HL7::Segment); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
237
|
|
16
|
3
|
|
|
3
|
|
2211
|
use POSIX qw(strftime); |
|
3
|
|
|
|
|
19346
|
|
|
3
|
|
|
|
|
15
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=pod |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Net::HL7::Segments::MSH |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $seg = new Net::HL7::Segments::MSH(); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$seg->setField(9, "ADT^A24"); |
29
|
|
|
|
|
|
|
print $seg->getField(1); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 DESCRIPTION |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
The Net::HL7::Segments::MSH is an implementation of the |
35
|
|
|
|
|
|
|
L class. The MSH segment is a bit |
36
|
|
|
|
|
|
|
different from other segments, in that the first field is the field |
37
|
|
|
|
|
|
|
separator after the segment name. Other fields thus start counting |
38
|
|
|
|
|
|
|
from 2! The setting for the field separator for a whole message can |
39
|
|
|
|
|
|
|
be changed by the setField method on index 1 of the MSH for that |
40
|
|
|
|
|
|
|
message. The MSH segment also contains the default settings for field |
41
|
|
|
|
|
|
|
2, COMPONENT_SEPARATOR, REPETITION_SEPARATOR, ESCAPE_CHARACTER and |
42
|
|
|
|
|
|
|
SUBCOMPONENT_SEPARATOR. These fields default to ^, ~, \ and & |
43
|
|
|
|
|
|
|
respectively. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 METHODS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=over 4 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item B<$msh = new Net::HL7::Segments::MSH([$fields])> |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Create an instance of the MSH segment. If a reference to an array is |
53
|
|
|
|
|
|
|
given, all fields will be filled from that array. Note that for |
54
|
|
|
|
|
|
|
composed fields and subcomponents, the array may hold subarrays and |
55
|
|
|
|
|
|
|
subsubarrays. If the reference is not given, the MSH segment will be |
56
|
|
|
|
|
|
|
created with the MSH 1,2,7,10 and 12 fields filled in for convenience. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _init { |
61
|
|
|
|
|
|
|
|
62
|
20
|
|
|
20
|
|
47
|
my ($self, $fieldsRef) = @_; |
63
|
|
|
|
|
|
|
|
64
|
20
|
|
|
|
|
47
|
$self->SUPER::_init("MSH", $fieldsRef); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Only fill default fields if no fields ref is given |
67
|
|
|
|
|
|
|
# |
68
|
20
|
100
|
|
|
|
35
|
if (! $fieldsRef) { |
69
|
5
|
|
|
|
|
13
|
$self->setField(1, $Net::HL7::FIELD_SEPARATOR); |
70
|
5
|
|
|
|
|
17
|
$self->setField( |
71
|
|
|
|
|
|
|
2, |
72
|
|
|
|
|
|
|
$Net::HL7::COMPONENT_SEPARATOR . |
73
|
|
|
|
|
|
|
$Net::HL7::REPETITION_SEPARATOR . |
74
|
|
|
|
|
|
|
$Net::HL7::ESCAPE_CHARACTER . |
75
|
|
|
|
|
|
|
$Net::HL7::SUBCOMPONENT_SEPARATOR |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
5
|
|
|
|
|
624
|
$self->setField(7, strftime("%Y%m%d%H%M%S", localtime)); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# Set ID field |
81
|
|
|
|
|
|
|
# |
82
|
5
|
|
|
|
|
92
|
my $ext = rand(1); |
83
|
5
|
|
|
|
|
71
|
$ext =~ s/[^0-9]//g; |
84
|
5
|
|
|
|
|
11
|
$ext = "." . substr($ext, 1, 5); |
85
|
|
|
|
|
|
|
|
86
|
5
|
|
|
|
|
28
|
$self->setField(10, $self->getField(7) . $ext); |
87
|
5
|
|
|
|
|
12
|
$self->setField(12, $Net::HL7::HL7_VERSION); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
20
|
|
|
|
|
51
|
return $self; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=pod |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item B |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Set the field specified by index to value. Indices start at 1, to stay |
99
|
|
|
|
|
|
|
with the HL7 standard. Trying to set the value at index 0 has no |
100
|
|
|
|
|
|
|
effect. Setting the value on index 1, will effectively change the |
101
|
|
|
|
|
|
|
value of Net::HL7::Message::FIELD_SEPARATOR for the message containing |
102
|
|
|
|
|
|
|
this segment, if the value has length 1; setting the field on index 2 |
103
|
|
|
|
|
|
|
will change the values of COMPONENT_SEPARATOR, REPETITION_SEPARATOR, |
104
|
|
|
|
|
|
|
ESCAPE_CHARACTER and SUBCOMPONENT_SEPARATOR for the message, if the |
105
|
|
|
|
|
|
|
string is of length 4. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=back |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub setField { |
112
|
|
|
|
|
|
|
|
113
|
191
|
|
|
191
|
1
|
271
|
my ($self, $index, $value) = @_; |
114
|
|
|
|
|
|
|
|
115
|
191
|
100
|
|
|
|
346
|
if ($index == 1) { |
116
|
23
|
100
|
|
|
|
46
|
if (length($value) != 1) { |
117
|
1
|
|
|
|
|
2
|
return undef; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
190
|
100
|
|
|
|
510
|
if ($index == 2) { |
122
|
23
|
100
|
|
|
|
48
|
if (length($value) != 4) { |
123
|
1
|
|
|
|
|
4
|
return undef; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
189
|
|
|
|
|
377
|
return $self->SUPER::setField($index, $value); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 AUTHOR |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
D.A.Dokter |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 LICENSE |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Copyright (c) 2002 D.A.Dokter. All rights reserved. This program is |
141
|
|
|
|
|
|
|
free software; you can redistribute it and/or modify it under the same |
142
|
|
|
|
|
|
|
terms as Perl itself. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |