line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
26074
|
use strict; # To keep Test::Perl::Critic happy, Moose does enable this too... |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
64
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Text::ResusciAnneparser; |
4
|
|
|
|
|
|
|
{ |
5
|
|
|
|
|
|
|
$Text::ResusciAnneparser::VERSION = '0.03'; |
6
|
|
|
|
|
|
|
} |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
501
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use namespace::autoclean; |
10
|
|
|
|
|
|
|
use 5.012; |
11
|
|
|
|
|
|
|
use autodie; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use DateTime; |
14
|
|
|
|
|
|
|
use XML::Simple qw(:strict); |
15
|
|
|
|
|
|
|
use Data::Dumper; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has infile => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => 'Str', |
20
|
|
|
|
|
|
|
required => 1, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use Carp qw/croak carp/; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Ensure we read the inputfile after constructing the object |
26
|
|
|
|
|
|
|
sub BUILD { |
27
|
|
|
|
|
|
|
my $self = shift; |
28
|
|
|
|
|
|
|
$self->{_data} = {}; |
29
|
|
|
|
|
|
|
$self->_read_infile; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _read_infile { |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $certificates = |
37
|
|
|
|
|
|
|
XMLin( $self->{infile}, ForceArray => 1, KeyAttr => { user => 'login' } ); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Sort users according to the ones who got a certificate and the ones who did not |
40
|
|
|
|
|
|
|
foreach my $user ( keys %{ $certificates->{user} } ) { |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $fname = $certificates->{user}->{$user}->{familyname}; |
43
|
|
|
|
|
|
|
my $gname = $certificates->{user}->{$user}->{givenname}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Ensure no leading/trailing spaces are in the name |
46
|
|
|
|
|
|
|
$fname =~ s/^\s+//; # strip white space from the beginning |
47
|
|
|
|
|
|
|
$fname =~ s/\s+$//; # strip white space from the end |
48
|
|
|
|
|
|
|
$gname =~ s/^\s+//; # strip white space from the beginning |
49
|
|
|
|
|
|
|
$gname =~ s/\s+$//; # strip white space from the end |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $names = { |
52
|
|
|
|
|
|
|
'givenname' => $gname, |
53
|
|
|
|
|
|
|
'familyname' => $fname |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
if ( defined $certificates->{user}->{$user}->{'course'} ) { |
57
|
|
|
|
|
|
|
my $course = $certificates->{user}->{$user}->{'course'}->[0]; |
58
|
|
|
|
|
|
|
my $dt = DateTime->new( |
59
|
|
|
|
|
|
|
year => $course->{year}, |
60
|
|
|
|
|
|
|
month => $course->{month}, |
61
|
|
|
|
|
|
|
day => $course->{day} |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Make an entry under {certs} |
65
|
|
|
|
|
|
|
# Entry contains the course date and email address |
66
|
|
|
|
|
|
|
push( @{ $self->{_data}->{certs}->{ $dt->ymd } }, $names ); |
67
|
|
|
|
|
|
|
} else { |
68
|
|
|
|
|
|
|
push( @{ $self->{_data}->{training} }, $names ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub certified { |
75
|
|
|
|
|
|
|
my $self = shift; |
76
|
|
|
|
|
|
|
return $self->{_data}->{certs}; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub in_training { |
80
|
|
|
|
|
|
|
my $self = shift; |
81
|
|
|
|
|
|
|
return $self->{_data}->{training}; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Speed up the Moose object construction |
85
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
86
|
|
|
|
|
|
|
no Moose; |
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# ABSTRACT: Parser for XML logfiles of the Resusci Anne Skills Station software |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=pod |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 NAME |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Text::ResusciAnneparser - Parser for XML logfiles of the Resusci Anne Skills Station software |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 VERSION |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
version 0.03 |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SYNOPSIS |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my $certificates = Text::ResusciAnneparser->new(infile => 'certificates.xml'); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 DESCRIPTION |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
The Resusci Anne Skills Station is a basic life support training station used by people |
110
|
|
|
|
|
|
|
involved in first-line support in healthcare. |
111
|
|
|
|
|
|
|
The training station keeps track of who trained when. This module enables parsing the |
112
|
|
|
|
|
|
|
xml output file to be able to process the data. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 METHODS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 C<new(%parameters)> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This constructor returns a new Text::ResusciAnneparser object. Supported parameters are listed below |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=over |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item infile |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
The input file containing the raw data log of the skill station software |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=back |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 C<certified> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Returns a hash of people who received a valid training certificate. The hash contains keys with the |
131
|
|
|
|
|
|
|
training dates in the format YYYY-MM-DD. The value attached to a date key in the hash is an array |
132
|
|
|
|
|
|
|
of people. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
A single person entry is a hash containing the givenname and the familiname of a person. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
E.g. |
137
|
|
|
|
|
|
|
'2013-04-07' => [ |
138
|
|
|
|
|
|
|
{ |
139
|
|
|
|
|
|
|
'givenname' => 'Piet', |
140
|
|
|
|
|
|
|
'familyname' => 'Konijn' |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
], |
143
|
|
|
|
|
|
|
'2013-03-25' => [ |
144
|
|
|
|
|
|
|
{ |
145
|
|
|
|
|
|
|
'givenname' => 'Zjuul', |
146
|
|
|
|
|
|
|
'familyname' => 'Cesar' |
147
|
|
|
|
|
|
|
}, |
148
|
|
|
|
|
|
|
{ |
149
|
|
|
|
|
|
|
'givenname' => 'Pette', |
150
|
|
|
|
|
|
|
'familyname' => 'Sjiekke' |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
] |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 C<in_training> |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Returns an array of people who started the exercise but who did not completed it and hence have not received |
157
|
|
|
|
|
|
|
a certificate yet |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 BUILD |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Helper function to run custome code after the object has been created by Moose. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 AUTHOR |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Lieven Hollevoet <hollie@cpan.org> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Lieven Hollevoet. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
172
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=cut |