File Coverage

blib/lib/Parse/SAMGov/Exclusion.pm
Criterion Covered Total %
statement 78 80 97.5
branch 18 36 50.0
condition n/a
subroutine 14 14 100.0
pod 0 1 0.0
total 110 131 83.9


line stmt bran cond sub pod time code
1             package Parse::SAMGov::Exclusion;
2             $Parse::SAMGov::Exclusion::VERSION = '0.105';
3 3     3   443 use strict;
  3         2  
  3         67  
4 3     3   9 use warnings;
  3         2  
  3         51  
5 3     3   45 use 5.010;
  3         6  
6 3     3   498 use Data::Dumper;
  3         4221  
  3         115  
7 3     3   722 use DateTime;
  3         84763  
  3         63  
8 3     3   519 use DateTime::Format::Strptime;
  3         9505  
  3         19  
9 3     3   491 use Parse::SAMGov::Mo;
  3         6  
  3         14  
10 3     3   1046 use Parse::SAMGov::Exclusion::Name;
  3         3  
  3         63  
11 3     3   348 use Parse::SAMGov::Entity::Address;
  3         3  
  3         660  
12              
13             #ABSTRACT: defines the SAM Exclusions object
14              
15             use overload fallback => 1,
16             '""' => sub {
17 4     4   2232 my $self = $_[0];
18 4         6 my $str = '';
19 4         10 $str .= $self->classification . ': ' . $self->name;
20 4 50       10 $str .= "\nAddress: " . $self->address if $self->address;
21 4 50       9 $str .= "\nDUNS: " . $self->DUNS if $self->DUNS;
22 4 50       7 $str .= "\nCAGE: " . $self->CAGE if $self->CAGE;
23 4 50       9 $str .= "\nSAM no.: " . $self->SAM_number if $self->SAM_number;
24 4 50       8 $str .= "\nNational Provider Identifier: " . $self->NPI if $self->NPI;
25 4 50       7 $str .= "\nActive Date: " . $self->active_date->ymd('-') if $self->active_date;
26 4 50       31 if ($self->termination_date->year() == 2200) {
27 4         18 $str .= "\nTermination Date: Indefinite";
28             } else {
29 0 0       0 $str .= "\nTermination Date: " . $self->termination_date->ymd('-') if $self->termination_date;
30             }
31 4 50       7 $str .= "\nCross Reference: " . $self->crossref if $self->crossref;
32 4 50       9 $str .= "\nRecord status: " . $self->record_status if $self->record_status;
33 4 50       9 $str .= "\nExclusion Program: " . $self->xprogram if $self->xprogram;
34 4 50       8 $str .= "\nExclusion Agency: " . $self->xagency if $self->xagency;
35 4 50       9 $str .= "\nExclusion Type: " . $self->xtype if $self->xtype;
36 4 50       8 $str .= "\nExclusion Type(Cause & Treatment Code): " . $self->CT_code if $self->CT_code;
37 4 50       7 $str .= "\nAdditional Comments: " . $self->comments if $self->comments;
38 4         11 return $str;
39 3     3   12 };
  3         3  
  3         24  
40              
41              
42             has classification => ();
43              
44              
45             has name => default => sub {
46             return Parse::SAMGov::Exclusion::Name->new;
47             };
48              
49              
50             has address => default => sub {
51             return Parse::SAMGov::Entity::Address->new;
52             };
53              
54              
55             has 'DUNS';
56              
57              
58             has 'xprogram';
59              
60              
61             has 'xagency';
62              
63              
64             has 'CT_code';
65              
66              
67             has 'xtype';
68              
69              
70             has 'comments';
71              
72             sub _parse_date {
73 10 50   10   20 if (@_) {
74 10         12 my $d = shift;
75 10 100       33 $d = '12/31/2200' if $d =~ /indefinite/i;
76 10         21 state $Strp =
77             DateTime::Format::Strptime->new(pattern => '%m/%d/%Y',
78             time_zone => 'America/New_York',);
79 10         10527 return $Strp->parse_datetime($d);
80             }
81 0         0 return;
82             }
83              
84              
85             has active_date => (coerce => sub { _parse_date $_[0] });
86              
87              
88             has termination_date => (coerce => sub { _parse_date $_[0] });
89              
90              
91             has 'record_status';
92              
93              
94             has 'crossref';
95              
96              
97             has 'SAM_number';
98              
99              
100             has 'CAGE';
101              
102              
103             has 'NPI';
104              
105             sub _trim {
106             # from Mojo::Util::trim
107 92     92   70 my $s = shift;
108 92         91 $s =~ s/^\s+//g;
109 92         84 $s =~ s/\s+$//g;
110 92         179 return $s;
111             }
112              
113             sub load {
114 4     4 0 6 my $self = shift;
115 4 50       9 return unless scalar(@_) >= 28;
116 4         7 $self->classification(_trim(shift));
117 4         6 my $name = Parse::SAMGov::Exclusion::Name->new(
118             entity => _trim(shift),
119             prefix => _trim(shift),
120             first => _trim(shift),
121             middle => _trim(shift),
122             last => _trim(shift),
123             suffix => _trim(shift),
124             );
125 4         15 $self->name($name);
126 4         21 my $addr = Parse::SAMGov::Entity::Address->new(
127             # the order of shifting matters
128             address => _trim(join(' ', shift, shift, shift, shift)),
129             city => _trim(shift),
130             state => _trim(shift),
131             country => _trim(shift),
132             zip => _trim(shift),
133             );
134 4         12 $self->address($addr);
135 4         11 $self->DUNS(_trim(shift));
136 4         6 $self->xprogram(_trim(shift));
137 4         7 $self->xagency(_trim(shift));
138 4         6 $self->CT_code(_trim(shift));
139 4         5 $self->xtype(_trim(shift));
140 4         4 $self->comments(_trim(shift));
141 4         10 $self->active_date(shift);
142 4         16 $self->termination_date(shift);
143 4         13 $self->record_status(_trim(shift));
144 4         6 $self->crossref(_trim(shift));
145 4         6 $self->SAM_number(_trim (shift));
146 4         7 $self->CAGE(_trim(shift));
147 4         6 $self->NPI(_trim(shift));
148 4         14 return 1;
149             }
150              
151             1;
152              
153             =pod
154              
155             =encoding UTF-8
156              
157             =head1 NAME
158              
159             Parse::SAMGov::Exclusion - defines the SAM Exclusions object
160              
161             =head1 VERSION
162              
163             version 0.105
164              
165             =head1 SYNOPSIS
166              
167             my $exclusion = Parse::SAMGov::Exclusion->new;
168             $exclusion->classification("firm");
169             $exclusion->DUNS('123456789');
170             $exclusion->CAGE('7ABZ1');
171              
172             ...
173              
174             =head1 METHODS
175              
176             =head2 new
177              
178             This method creates a new Exclusion object.
179              
180             =head2 classification
181              
182             Identifies the exclusion Classification Type as either a Firm, Individual,
183             Special Entity Designation, or Vessel. The maximum length of this field is 50
184             characters.
185              
186             =head2 name
187              
188             This sets/gets an object of L which can hold
189             either the entity name being excluded or the individual name being excluded.
190              
191             =head2 address
192              
193             This sets/gets an object of L which holds the
194             primary address of the entity or individual being excluded. It includes the
195             city, two character abbreviation of state/province, three character abbreviation
196             of country and a 10 character zip/postal code.
197              
198             =head2 DUNS
199              
200             This holds the unique identifier of the excluded entity, currently the Data
201             Universal Numbering System (DUNS) number. Exclusion records with a
202             classification type of Firm must have a DUNS number. It may be found in
203             exclusion records of other classification types if the individual, special
204             entity or vessel has a DUNS number. This has a maximum length of 9 characters.
205              
206             =head2 xprogram
207              
208             Exclusion Program identifies if the exclusion is Reciprocal, Nonreciprocal or Procurement.
209             For any exclusion record created on or after August 25, 1995, the value will
210             always be Reciprocal.
211              
212             =head2 agency
213              
214             Exclusion Agency identifies the agency which created the exclusion.
215              
216             =head2 CT_code
217              
218             This identifies the legacy Excluded Parties List System (EPLS) Cause & Treatment
219             (CT) Code associated with the exclusion. CT Codes were replayed by the Exclusion
220             Type in SAM. Exclusions created after August 2012 will not have CT Codes. They
221             will only have Exclusion Types.
222              
223             =head2 xtype
224              
225             This identifies the Exclusion Type for the record replacing the CT Code.
226             Exclusion Type is a simplified, easier to understand way to identify why the
227             entity is being excluded.
228              
229             =head2 comments
230              
231             This field provides the agency creating the exclusion space to enter additional
232             information as necessary. The maximum length allowed is 4000 characters.
233              
234             =head2 active_date
235              
236             This field identifies the date the exclusion went active. It returns a DateTime
237             object. It accepts an input of the format MM/DD/YYYY, and converts it to a
238             DateTime object with the timezone used as America/New_York.
239              
240             =head2 termination_date
241              
242             This field identifies the date the exclusion will be terminated. The date
243             '12/31/2200' is denoted as indefinite exclusion for now. This field also returns
244             a DateTime object.
245              
246             =head2 record_status
247              
248             This identifies the record as begin Active or Inactive. This can be blank if the
249             record is active.
250              
251             =head2 crossref
252              
253             Identifies other names/aliases with which the entity being excluded has been
254             identified. For example, companies who do business under other names may have
255             those other names listed here.
256              
257             =head2 SAM_number
258              
259             The internal number used by SAM to identify exclusion records. Since only Firm
260             exclusion records are required to have a DUNS number, SAM needed a way to
261             uniquely track exclusion records of other classification types.
262              
263             =head2 CAGE
264              
265             The CAGE code associated with the excluded entity. Mostly found on Firm
266             exclusion records, but could be in other types if the Individual, Special
267             Entity, or Vessel has a CAGE code.
268              
269             =head2 NPI
270              
271             The National Provider Identifier (NPI) associated with the exclusion. Healthcare
272             providers acquire their unique 10-digit NPIs from the Centers for Medicare &
273             Medicaid Services (CMS) at the Department of Health & Human Services (HHS) to
274             identify themselves in a standard way throughout their industry.
275              
276             =head1 AUTHOR
277              
278             Vikas N Kumar
279              
280             =head1 COPYRIGHT AND LICENSE
281              
282             This software is copyright (c) 2016 by Selective Intellect LLC.
283              
284             This is free software; you can redistribute it and/or modify it under
285             the same terms as the Perl 5 programming language system itself.
286              
287             =cut
288              
289             __END__