| 1 | package App::HL7::Send; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Class::Utils qw(set_params); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Error::Pure qw(err); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Getopt::Std; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Net::HL7::Connection; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Net::HL7::Message; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Perl6::Slurp qw(slurp); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | our $VERSION = 0.05; | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | # Constructor. | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | my ($class, @params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | # Create object. | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | # Process params. | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | set_params($self, @params); | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | # Object. | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | # Run. | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=8 SCAR=35.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | # Process arguments. | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | $self->{'_opts'} = { | |||||||||||||||||||||||||||||||||||||||||
| 35 | 'h' => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | if (! getopts('h', $self->{'_opts'}) || @ARGV < 3 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not &getopts("h", $self->{"_opts"}) or @ARGV < 3 or $self->{"_opts"}{"h"}
not &getopts("h", $self->{"_opts"}) or @ARGV < 3
MC/DC0%0/3
not &getopts("h", $self->{"_opts"}) or @ARGV < 3 or $self->{"_opts"}{"h"}
not &getopts("h", $self->{"_opts"})
@ARGV < 3
$self->{"_opts"}{"h"}
Truth table25%1/4
not(A) or B or C
A= not &getopts("h", $self->{"_opts"})B= @ARGV < 3C= $self->{"_opts"}{"h"}
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | || $self->{'_opts'}->{'h'}) { | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | print STDERR "Usage: $0 [-h] [--version] host port hl7_file|-\n"; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | print STDERR "\t-h\t\tPrint help.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | print STDERR "\t--version\tPrint version.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $self->{'_hl7_host'} = $ARGV[0]; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $self->{'_hl7_port'} = $ARGV[1]; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $self->{'_hl7_file'} = $ARGV[2]; | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | # Get hl7_file. | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $hl7; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ($self->{'_hl7_file'} eq '-') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | while (my $line = <STDIN>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $hl7 .= $line; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $hl7 = slurp($self->{'_hl7_file'}); | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | # Create message. | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $msg = Net::HL7::Message->new($hl7); | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if (! $msg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | err 'Cannot parse HL7 file.', 'File', $self->{'_hl7_file'}; | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | # Create connection. | ||||||||||||||||||||||||||||||||||||||||||
| 66 | my $conn = Net::HL7::Connection->new($self->{'_hl7_host'}, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | $self->{'_hl7_port'}); | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if (! $conn) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | err 'Cannot connect to host.'; | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | # Send. | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $conn->send($msg); | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | print "Message was send.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | __END__ | ||||||||||||||||||||||||||||||||||||||||||