| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Dicom::UID::Generator; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Pragmas. |
|
4
|
2
|
|
|
2
|
|
16507
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
43
|
|
|
5
|
2
|
|
|
2
|
|
5
|
use warnings; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
40
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Modules. |
|
8
|
2
|
|
|
2
|
|
828
|
use Class::Utils qw(set_params); |
|
|
2
|
|
|
|
|
34567
|
|
|
|
2
|
|
|
|
|
29
|
|
|
9
|
2
|
|
|
2
|
|
841
|
use DateTime::HiRes; |
|
|
2
|
|
|
|
|
179000
|
|
|
|
2
|
|
|
|
|
53
|
|
|
10
|
2
|
|
|
2
|
|
11
|
use English; |
|
|
2
|
|
|
|
|
1
|
|
|
|
2
|
|
|
|
|
10
|
|
|
11
|
2
|
|
|
2
|
|
683
|
use Readonly; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
723
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Version. |
|
14
|
|
|
|
|
|
|
our $VERSION = 0.01; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Constants. |
|
17
|
|
|
|
|
|
|
Readonly::Scalar our $EMPTY_STR => q{}; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Constructor. |
|
20
|
|
|
|
|
|
|
sub new { |
|
21
|
0
|
|
|
0
|
1
|
|
my ($class, @params) = @_; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Create object. |
|
24
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Library number. |
|
27
|
0
|
|
|
|
|
|
$self->{'library_number'} = undef; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Model number. |
|
30
|
0
|
|
|
|
|
|
$self->{'model_number'} = undef; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Serial number. |
|
33
|
0
|
|
|
|
|
|
$self->{'serial_number'} = undef; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# TimeZone. |
|
36
|
0
|
|
|
|
|
|
$self->{'timezone'} = 'Europe/Prague'; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# UID counter. |
|
39
|
0
|
|
|
|
|
|
$self->{'uid_counter'} = 0; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Process parameters. |
|
42
|
0
|
|
|
|
|
|
set_params($self, @params); |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
return $self; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Create series instance UID. |
|
48
|
|
|
|
|
|
|
sub create_series_instance_uid { |
|
49
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
50
|
0
|
|
|
|
|
|
return $self->create_uid($self->_root_uid.'.1.3'); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Create SOP instance UID. |
|
54
|
|
|
|
|
|
|
sub create_sop_instance_uid { |
|
55
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
56
|
0
|
|
|
|
|
|
return $self->create_uid($self->_root_uid.'.1.4'); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Create study instance UID. |
|
60
|
|
|
|
|
|
|
sub create_study_instance_uid { |
|
61
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
62
|
0
|
|
|
|
|
|
return $self->create_uid($self->_root_uid.'.1.2'); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Create UID. |
|
66
|
|
|
|
|
|
|
sub create_uid { |
|
67
|
0
|
|
|
0
|
1
|
|
my ($self, $prefix) = @_; |
|
68
|
0
|
|
|
|
|
|
my $uid = $prefix; |
|
69
|
0
|
|
|
|
|
|
$uid .= '.'.$PID; |
|
70
|
0
|
|
|
|
|
|
$uid .= '.'.DateTime::HiRes->now->set_time_zone($self->{'timezone'}) |
|
71
|
|
|
|
|
|
|
->strftime('%Y%m%d%H%M%S%3N'); |
|
72
|
0
|
|
|
|
|
|
$self->{'uid_counter'}++; |
|
73
|
0
|
|
|
|
|
|
$uid .= '.'.$self->{'uid_counter'}; |
|
74
|
0
|
|
|
|
|
|
return $uid; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# Add part of UID. |
|
78
|
|
|
|
|
|
|
sub _add_part { |
|
79
|
0
|
|
|
0
|
|
|
my ($self, $uid_part_sr, $part) = @_; |
|
80
|
0
|
0
|
|
|
|
|
if (defined $self->{$part}) { |
|
81
|
0
|
0
|
|
|
|
|
if (${$uid_part_sr} ne $EMPTY_STR) { |
|
|
0
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
${$uid_part_sr} .= '.'; |
|
|
0
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} |
|
84
|
0
|
|
|
|
|
|
${$uid_part_sr} .= $self->{$part}; |
|
|
0
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
} |
|
86
|
0
|
|
|
|
|
|
return; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# Get root UID. |
|
90
|
|
|
|
|
|
|
sub _root_uid { |
|
91
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
92
|
0
|
|
|
|
|
|
my $uid_part = $EMPTY_STR; |
|
93
|
0
|
|
|
|
|
|
$self->_add_part(\$uid_part, 'library_number'); |
|
94
|
0
|
|
|
|
|
|
$self->_add_part(\$uid_part, 'model_number'); |
|
95
|
0
|
|
|
|
|
|
$self->_add_part(\$uid_part, 'serial_number'); |
|
96
|
0
|
|
|
|
|
|
return $uid_part; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |