line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DotICD9; |
2
|
|
|
|
|
|
|
# DotICD9.pm - add the dots to ICD9 codes |
3
|
|
|
|
|
|
|
# DTM -- Sun May 16 18:27:39 DST 1999 |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
591
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
6
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
415
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
@ISA = qw( Exporter ); |
11
|
|
|
|
|
|
|
@EXPORT = qw( ); |
12
|
|
|
|
|
|
|
$VERSION = '0.04'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new |
15
|
|
|
|
|
|
|
{ |
16
|
1
|
|
|
1
|
0
|
51
|
my $self = shift; |
17
|
1
|
|
|
|
|
3
|
return ( bless { }, $self ); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub dot |
21
|
|
|
|
|
|
|
{ |
22
|
|
|
|
|
|
|
# parameters: icd9code without any dots, D or 3 || O or 2 |
23
|
|
|
|
|
|
|
# returns: properly formatted ICD9 code or 0 for error |
24
|
3
|
|
|
3
|
0
|
24
|
my $self = shift; |
25
|
3
|
|
|
|
|
5
|
my $icdcode = shift; |
26
|
3
|
|
|
|
|
8
|
$icdcode =~ s/\.//g; # shed decimal point if present |
27
|
3
|
|
|
|
|
5
|
$icdcode =~ y/ //d; # remove space characters |
28
|
3
|
|
|
|
|
4
|
my $MAJOR = shift; |
29
|
|
|
|
|
|
|
# MAJOR is 3 for diagnostic, 2 for procedure codes |
30
|
3
|
100
|
|
|
|
24
|
if ( $MAJOR eq 'D' ){ $MAJOR = 3; } # D or DIAG for diagnosis codes |
|
1
|
100
|
|
|
|
2
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
31
|
1
|
|
|
|
|
2
|
elsif ( $MAJOR =~ m/DIAG/i ){ $MAJOR = 3; } |
32
|
0
|
|
|
|
|
0
|
elsif ( $MAJOR eq 'O' ){ $MAJOR = 2; } # O,SURG, or PROC for procedures |
33
|
1
|
|
|
|
|
2
|
elsif ( $MAJOR =~ m/SURG/i ){ $MAJOR = 2; } |
34
|
0
|
|
|
|
|
0
|
elsif ( $MAJOR =~ m/PROC/i ){ $MAJOR = 2; } |
35
|
3
|
|
|
|
|
3
|
my ( $codelen, $minor, $major ); |
36
|
3
|
|
|
|
|
4
|
$codelen = length($icdcode); # should be 2, 3, 4, or 5 |
37
|
3
|
50
|
|
|
|
9
|
if( $icdcode =~ /^E/ ){ $major = $MAJOR + 1; } |
|
0
|
|
|
|
|
0
|
|
38
|
3
|
|
|
|
|
3
|
else{ $major = $MAJOR; } |
39
|
3
|
|
|
|
|
4
|
$minor = $codelen - $major; # number of decimal places |
40
|
3
|
50
|
|
|
|
9
|
if( $minor < 0 ) { |
|
|
50
|
|
|
|
|
|
41
|
0
|
|
|
|
|
0
|
return 0; # strings goofed up error |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
elsif( $minor > 0 ) { |
44
|
3
|
|
|
|
|
7
|
$icdcode = substr($icdcode, 0, $major) . "." . substr( $icdcode, $major, $minor ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
0
|
|
|
|
|
0
|
$icdcode = substr( $icdcode, 0, $major ); |
48
|
|
|
|
|
|
|
} |
49
|
3
|
|
|
|
|
9
|
return $icdcode; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
__END__ |