Bug 15253: Add Koha::Logger based logging for SIP2
[koha-equinox.git] / C4 / SIP / ILS / Patron.pm
1 #
2 # ILS::Patron.pm
3
4 # A Class for hiding the ILS's concept of the patron from the OpenSIP
5 # system
6 #
7
8 package C4::SIP::ILS::Patron;
9
10 use strict;
11 use warnings;
12 use Exporter;
13 use Carp;
14
15 use C4::SIP::Sip qw(syslog);
16 use Data::Dumper;
17
18 use C4::SIP::Sip qw(add_field);
19
20 use C4::Debug;
21 use C4::Context;
22 use C4::Koha;
23 use C4::Members;
24 use C4::Reserves;
25 use C4::Auth qw(checkpw);
26
27 use Koha::Items;
28 use Koha::Libraries;
29 use Koha::Patrons;
30
31 our $kp;    # koha patron
32
33 =head1 Methods
34
35 =cut
36
37 sub new {
38     my ($class, $patron_id) = @_;
39     my $type = ref($class) || $class;
40     my $self;
41     my $patron = Koha::Patrons->find( { cardnumber => $patron_id } )
42       || Koha::Patrons->find( { userid => $patron_id } );
43     $debug and warn "new Patron: " . Dumper($patron->unblessed) if $patron;
44     unless ($patron) {
45         syslog("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id);
46         return;
47     }
48     $kp = $patron->unblessed;
49     my $pw        = $kp->{password};
50     my $flags     = C4::Members::patronflags( $kp );
51     my $debarred  = $patron->is_debarred;
52     $debug and warn sprintf("Debarred = %s : ", ($debarred||'undef')); # Do we need more debug info here?
53     my ($day, $month, $year) = (localtime)[3,4,5];
54     my $today    = sprintf '%04d-%02d-%02d', $year+1900, $month+1, $day;
55     my $expired  = ($today gt $kp->{dateexpiry}) ? 1 : 0;
56     if ($expired) {
57         if ($kp->{opacnote} ) {
58             $kp->{opacnote} .= q{ };
59         }
60         $kp->{opacnote} .= 'PATRON EXPIRED';
61     }
62     my %ilspatron;
63     my $adr     = _get_address($kp);
64     my $dob     = $kp->{dateofbirth};
65     $dob and $dob =~ s/-//g;    # YYYYMMDD
66     my $dexpiry     = $kp->{dateexpiry};
67     $dexpiry and $dexpiry =~ s/-//g;    # YYYYMMDD
68     my $fines_amount = $patron->account->balance;
69     $fines_amount = ($fines_amount and $fines_amount > 0) ? $fines_amount : 0;
70     my $fee_limit = _fee_limit();
71     my $fine_blocked = $fines_amount > $fee_limit;
72     my $circ_blocked =( C4::Context->preference('OverduesBlockCirc') ne "noblock" &&  defined $flags->{ODUES}->{itemlist} ) ? 1 : 0;
73     {
74     no warnings;    # any of these $kp->{fields} being concat'd could be undef
75     %ilspatron = (
76         name => $kp->{firstname} . " " . $kp->{surname},
77         id   => $kp->{cardnumber},    # to SIP, the id is the BARCODE, not userid
78         password        => $pw,
79         ptype           => $kp->{categorycode},     # 'A'dult.  Whatever.
80         dateexpiry      => $dexpiry,
81         dateexpiry_iso  => $kp->{dateexpiry},
82         birthdate       => $dob,
83         birthdate_iso   => $kp->{dateofbirth},
84         branchcode      => $kp->{branchcode},
85         library_name    => "",                      # only populated if needed, cached here
86         borrowernumber  => $kp->{borrowernumber},
87         address         => $adr,
88         home_phone      => $kp->{phone},
89         email_addr      => $kp->{email},
90         charge_ok       => ( !$debarred && !$expired && !$fine_blocked && !$circ_blocked),
91         renew_ok        => ( !$debarred && !$expired && !$fine_blocked),
92         recall_ok       => ( !$debarred && !$expired && !$fine_blocked),
93         hold_ok         => ( !$debarred && !$expired && !$fine_blocked),
94         card_lost       => ( $kp->{lost} || $kp->{gonenoaddress} || $flags->{LOST} ),
95         claims_returned => 0,
96         fines           => $fines_amount,
97         fees            => 0,             # currently not distinct from fines
98         recall_overdue  => 0,
99         items_billed    => 0,
100         screen_msg      => 'Greetings from Koha. ' . $kp->{opacnote},
101         print_line      => '',
102         items           => [],
103         hold_items      => $flags->{WAITING}->{itemlist},
104         overdue_items   => $flags->{ODUES}->{itemlist},
105         fine_items      => [],
106         recall_items    => [],
107         unavail_holds   => [],
108         inet            => ( !$debarred && !$expired ),
109         expired         => $expired,
110         fee_limit       => $fee_limit,
111         userid          => $kp->{userid},
112     );
113     }
114     $debug and warn "patron fines: $ilspatron{fines} ... amountoutstanding: $kp->{amountoutstanding} ... CHARGES->amount: $flags->{CHARGES}->{amount}";
115
116     if ( $patron->is_debarred and $patron->debarredcomment ) {
117         $ilspatron{screen_msg} .= " -- " . $patron->debarredcomment;
118     }
119     for (qw(EXPIRED CHARGES CREDITS GNA LOST DBARRED NOTES)) {
120         ($flags->{$_}) or next;
121         if ($_ ne 'NOTES' and $flags->{$_}->{message}) {
122             $ilspatron{screen_msg} .= " -- " . $flags->{$_}->{message};  # show all but internal NOTES
123         }
124         if ($flags->{$_}->{noissues}) {
125             foreach my $toggle (qw(charge_ok renew_ok recall_ok hold_ok inet)) {
126                 $ilspatron{$toggle} = 0;    # if we get noissues, disable everything
127             }
128         }
129     }
130
131     # FIXME: populate fine_items recall_items
132     $ilspatron{unavail_holds} = _get_outstanding_holds($kp->{borrowernumber});
133
134     my $pending_checkouts = $patron->pending_checkouts;
135     my @barcodes;
136     while ( my $c = $pending_checkouts->next ) {
137         push @barcodes, { barcode => $c->item->barcode };
138     }
139     $ilspatron{items} = \@barcodes;
140
141     $self = \%ilspatron;
142     $debug and warn Dumper($self);
143     syslog("LOG_DEBUG", "new ILS::Patron(%s): found patron '%s'", $patron_id,$self->{id});
144     bless $self, $type;
145     return $self;
146 }
147
148
149 # 0 means read-only
150 # 1 means read/write
151
152 my %fields = (
153     id                      => 0,
154     name                    => 0,
155     address                 => 0,
156     email_addr              => 0,
157     home_phone              => 0,
158     birthdate               => 0,
159     birthdate_iso           => 0,
160     dateexpiry              => 0,
161     dateexpiry_iso          => 0,
162     ptype                   => 0,
163     charge_ok               => 0,   # for patron_status[0] (inverted)
164     renew_ok                => 0,   # for patron_status[1] (inverted)
165     recall_ok               => 0,   # for patron_status[2] (inverted)
166     hold_ok                 => 0,   # for patron_status[3] (inverted)
167     card_lost               => 0,   # for patron_status[4]
168     recall_overdue          => 0,
169     currency                => 1,
170     fee_limit               => 0,
171     screen_msg              => 1,
172     print_line              => 1,
173     too_many_charged        => 0,   # for patron_status[5]
174     too_many_overdue        => 0,   # for patron_status[6]
175     too_many_renewal        => 0,   # for patron_status[7]
176     too_many_claim_return   => 0,   # for patron_status[8]
177     too_many_lost           => 0,   # for patron_status[9]
178 #   excessive_fines         => 0,   # for patron_status[10]
179 #   excessive_fees          => 0,   # for patron_status[11]
180     recall_overdue          => 0,   # for patron_status[12]
181     too_many_billed         => 0,   # for patron_status[13]
182     inet                    => 0,   # EnvisionWare extension
183 );
184
185 our $AUTOLOAD;
186
187 sub DESTROY {
188     # be cool.  needed for AUTOLOAD(?)
189 }
190
191 sub AUTOLOAD {
192     my $self = shift;
193     my $class = ref($self) or croak "$self is not an object";
194     my $name = $AUTOLOAD;
195
196     $name =~ s/.*://;
197
198     unless (exists $fields{$name}) {
199         croak "Cannot access '$name' field of class '$class'";
200     }
201
202     if (@_) {
203         $fields{$name} or croak "Field '$name' of class '$class' is READ ONLY.";
204         return $self->{$name} = shift;
205     } else {
206         return $self->{$name};
207     }
208 }
209
210 sub name {
211     my ( $self, $template ) = @_;
212
213     if ($template) {
214         require Template;
215         require Koha::Patrons;
216
217         my $tt = Template->new();
218
219         my $patron = Koha::Patrons->find( $self->{borrowernumber} );
220
221         my $output;
222         $tt->process( \$template, { patron => $patron }, \$output );
223         return $output;
224     }
225     else {
226         return $self->{name};
227     }
228 }
229
230 sub check_password {
231     my ( $self, $pwd ) = @_;
232
233     # you gotta give me something (at least ''), or no deal
234     return 0 unless defined $pwd;
235
236     # If the record has a NULL password, accept '' as match
237     return $pwd eq q{} unless $self->{password};
238
239     my $dbh = C4::Context->dbh;
240     my $ret = 0;
241     ($ret) = checkpw( $dbh, $self->{userid}, $pwd, undef, undef, 1 ); # dbh, userid, query, type, no_set_userenv
242     return $ret;
243 }
244
245 # A few special cases, not in AUTOLOADed %fields
246 sub fee_amount {
247     my $self = shift;
248     if ( $self->{fines} ) {
249         return $self->{fines};
250     }
251     return;
252 }
253
254 sub fines_amount {
255     my $self = shift;
256     return $self->fee_amount;
257 }
258
259 sub language {
260     my $self = shift;
261     return $self->{language} || '000'; # Unspecified
262 }
263
264 sub expired {
265     my $self = shift;
266     return $self->{expired};
267 }
268
269 #
270 # remove the hold on item item_id from my hold queue.
271 # return true if I was holding the item, false otherwise.
272
273 sub drop_hold {
274     my ($self, $item_id) = @_;
275     return if !$item_id;
276     my $result = 0;
277     foreach (qw(hold_items unavail_holds)) {
278         $self->{$_} or next;
279         for (my $i = 0; $i < scalar @{$self->{$_}}; $i++) {
280             my $held_item = $self->{$_}[$i]->{item_id} or next;
281             if ($held_item eq $item_id) {
282                 splice @{$self->{$_}}, $i, 1;
283                 $result++;
284             }
285         }
286     }
287     return $result;
288 }
289
290 # Accessor method for array_ref values, designed to get the "start" and "end" values
291 # from the SIP request.  Note those incoming values are 1-indexed, not 0-indexed.
292 #
293 sub x_items {
294     my $self      = shift;
295     my $array_var = shift or return;
296     my ($start, $end) = @_;
297
298     my $item_list = [];
299     if ($self->{$array_var}) {
300         if ($start && $start > 1) {
301             --$start;
302         }
303         else {
304             $start = 0;
305         }
306         if ( $end && $end < @{$self->{$array_var}} ) {
307         }
308         else {
309             $end = @{$self->{$array_var}};
310             --$end;
311         }
312         @{$item_list} = @{$self->{$array_var}}[ $start .. $end ];
313
314     }
315     return $item_list;
316 }
317
318 #
319 # List of outstanding holds placed
320 #
321 sub hold_items {
322     my $self = shift;
323     my $item_arr = $self->x_items('hold_items', @_);
324     foreach my $item (@{$item_arr}) {
325         my $item_obj = Koha::Items->find($item->{itemnumber});
326         $item->{barcode} = $item_obj ? $item_obj->barcode : undef;
327     }
328     return $item_arr;
329 }
330
331 sub overdue_items {
332     my $self = shift;
333     return $self->x_items('overdue_items', @_);
334 }
335 sub charged_items {
336     my $self = shift;
337     return $self->x_items('items', @_);
338 }
339 sub fine_items {
340     require Koha::Database;
341     require Template;
342
343     my $self = shift;
344     my $start = shift;
345     my $end = shift;
346     my $server = shift;
347
348     my @fees = Koha::Database->new()->schema()->resultset('Accountline')->search(
349         {
350             borrowernumber    => $self->{borrowernumber},
351             amountoutstanding => { '>' => '0' },
352         }
353     );
354
355     $start = $start ? $start - 1 : 0;
356     $end   = $end   ? $end       : scalar @fees - 1;
357
358     my $av_field_template = $server ? $server->{account}->{av_field_template} : undef;
359     $av_field_template ||= "[% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]";
360
361     my $tt = Template->new();
362
363     my @return_values;
364     for ( my $i = $start; $i <= $end; $i++ ) {
365         my $fee = $fees[$i];
366
367         my $output;
368         $tt->process( \$av_field_template, { accountline => $fee }, \$output );
369         push( @return_values, { barcode => $output } );
370     }
371
372     return \@return_values;
373 }
374 sub recall_items {
375     my $self = shift;
376     return $self->x_items('recall_items', @_);
377 }
378 sub unavail_holds {
379     my $self = shift;
380     return $self->x_items('unavail_holds', @_);
381 }
382
383 sub block {
384     my ($self, $card_retained, $blocked_card_msg) = @_;
385     foreach my $field ('charge_ok', 'renew_ok', 'recall_ok', 'hold_ok', 'inet') {
386         $self->{$field} = 0;
387     }
388     $self->{screen_msg} = "Block feature not implemented";  # $blocked_card_msg || "Card Blocked.  Please contact library staff";
389     # TODO: not really affecting patron record
390     return $self;
391 }
392
393 sub enable {
394     my $self = shift;
395     foreach my $field ('charge_ok', 'renew_ok', 'recall_ok', 'hold_ok', 'inet') {
396         $self->{$field} = 1;
397     }
398     syslog("LOG_DEBUG", "Patron(%s)->enable: charge: %s, renew:%s, recall:%s, hold:%s",
399        $self->{id}, $self->{charge_ok}, $self->{renew_ok},
400        $self->{recall_ok}, $self->{hold_ok});
401     $self->{screen_msg} = "Enable feature not implemented."; # "All privileges restored.";   # TODO: not really affecting patron record
402     return $self;
403 }
404
405 sub inet_privileges {
406     my $self = shift;
407     return $self->{inet} ? 'Y' : 'N';
408 }
409
410 sub _fee_limit {
411     return C4::Context->preference('noissuescharge') || 5;
412 }
413
414 sub excessive_fees {
415     my $self = shift;
416     return ($self->fee_amount and $self->fee_amount > $self->fee_limit);
417 }
418
419 sub excessive_fines {
420     my $self = shift;
421     return $self->excessive_fees;   # excessive_fines is the same thing as excessive_fees for Koha
422 }
423
424 sub holds_blocked_by_excessive_fees {
425     my $self = shift;
426     return ( $self->fee_amount
427           && $self->fee_amount > C4::Context->preference("maxoutstanding") );
428 }
429     
430 sub library_name {
431     my $self = shift;
432     unless ($self->{library_name}) {
433         my $library = Koha::Libraries->find( $self->{branchcode} );
434         $self->{library_name} = $library ? $library->branchname : '';
435     }
436     return $self->{library_name};
437 }
438 #
439 # Messages
440 #
441
442 sub invalid_patron {
443     my $self = shift;
444     return "Please contact library staff";
445 }
446
447 sub charge_denied {
448     my $self = shift;
449     return "Please contact library staff";
450 }
451
452 =head2 update_lastseen
453
454     $patron->update_lastseen();
455
456     Patron method to update lastseen field in borrower
457     to record that patron has been seen via sip connection
458
459 =cut
460
461 sub update_lastseen {
462     my $self = shift;
463     my $kohaobj = Koha::Patrons->find( $self->{borrowernumber} );
464     $kohaobj->track_login if $kohaobj; # track_login checks the pref
465 }
466
467 sub _get_address {
468     my $patron = shift;
469
470     my $address = $patron->{streetnumber} || q{};
471     for my $field (qw( roaddetails address address2 city state zipcode country))
472     {
473         next unless $patron->{$field};
474         if ($address) {
475             $address .= q{ };
476             $address .= $patron->{$field};
477         }
478         else {
479             $address .= $patron->{$field};
480         }
481     }
482     return $address;
483 }
484
485 sub _get_outstanding_holds {
486     my $borrowernumber = shift;
487
488     my $patron = Koha::Patrons->find( $borrowernumber );
489     my $holds = $patron->holds->search( { -or => [ { found => undef }, { found => { '!=' => 'W' } } ] } );
490     my @holds;
491     while ( my $hold = $holds->next ) {
492         my $item;
493         if ($hold->itemnumber) {
494             $item = $hold->item;
495         }
496         else {
497             # We need to return a barcode for the biblio so the client
498             # can request the biblio info
499             my $items = $hold->biblio->items;
500             $item = $items->count ? $items->next : undef;
501         }
502         my $unblessed_hold = $hold->unblessed;
503
504         $unblessed_hold->{barcode} = $item ? $item->barcode : undef;
505
506         push @holds, $unblessed_hold;
507     }
508     return \@holds;
509 }
510
511 =head2 build_patron_attributes_string
512
513 This method builds the part of the sip message for extended patron
514 attributes as defined in the sip config
515
516 =cut
517
518 sub build_patron_attributes_string {
519     my ( $self, $server ) = @_;
520
521     my $string = q{};
522
523     if ( $server->{account}->{patron_attribute} ) {
524         my @attributes_to_send =
525           ref $server->{account}->{patron_attribute} eq "ARRAY"
526           ? @{ $server->{account}->{patron_attribute} }
527           : ( $server->{account}->{patron_attribute} );
528
529         foreach my $a ( @attributes_to_send ) {
530             my @attributes = Koha::Patron::Attributes->search(
531                 {
532                     borrowernumber => $self->{borrowernumber},
533                     code           => $a->{code}
534                 }
535             );
536
537             foreach my $attribute ( @attributes ) {
538                 my $value = $attribute->attribute();
539                 $string .= add_field( $a->{field}, $value );
540             }
541         }
542     }
543
544     return $string;
545 }
546
547 1;
548 __END__
549
550 =head1 EXAMPLES
551
552   our %patron_example = (
553           djfiander => {
554               name => "David J. Fiander",
555               id => 'djfiander',
556               password => '6789',
557               ptype => 'A', # 'A'dult.  Whatever.
558               birthdate => '19640925',
559               address => '2 Meadowvale Dr. St Thomas, ON',
560               home_phone => '(519) 555 1234',
561               email_addr => 'djfiander@hotmail.com',
562               charge_ok => 1,
563               renew_ok => 1,
564               recall_ok => 0,
565               hold_ok => 1,
566               card_lost => 0,
567               claims_returned => 0,
568               fines => 100,
569               fees => 0,
570               recall_overdue => 0,
571               items_billed => 0,
572               screen_msg => '',
573               print_line => '',
574               items => [],
575               hold_items => [],
576               overdue_items => [],
577               fine_items => ['Computer Time'],
578               recall_items => [],
579               unavail_holds => [],
580               inet => 1,
581           },
582   );
583
584  From borrowers table:
585 +---------------------+--------------+------+-----+---------+----------------+
586 | Field               | Type         | Null | Key | Default | Extra          |
587 +---------------------+--------------+------+-----+---------+----------------+
588 | borrowernumber      | int(11)      | NO   | PRI | NULL    | auto_increment |
589 | cardnumber          | varchar(16)  | YES  | UNI | NULL    |                |
590 | surname             | mediumtext   | NO   |     | NULL    |                |
591 | firstname           | text         | YES  |     | NULL    |                |
592 | title               | mediumtext   | YES  |     | NULL    |                |
593 | othernames          | mediumtext   | YES  |     | NULL    |                |
594 | initials            | text         | YES  |     | NULL    |                |
595 | streetnumber        | varchar(10)  | YES  |     | NULL    |                |
596 | streettype          | varchar(50)  | YES  |     | NULL    |                |
597 | address             | mediumtext   | NO   |     | NULL    |                |
598 | address2            | text         | YES  |     | NULL    |                |
599 | city                | mediumtext   | NO   |     | NULL    |                |
600 | state               | mediumtext   | YES  |     | NULL    |                |
601 | zipcode             | varchar(25)  | YES  |     | NULL    |                |
602 | country             | text         | YES  |     | NULL    |                |
603 | email               | mediumtext   | YES  |     | NULL    |                |
604 | phone               | text         | YES  |     | NULL    |                |
605 | mobile              | varchar(50)  | YES  |     | NULL    |                |
606 | fax                 | mediumtext   | YES  |     | NULL    |                |
607 | emailpro            | text         | YES  |     | NULL    |                |
608 | phonepro            | text         | YES  |     | NULL    |                |
609 | B_streetnumber      | varchar(10)  | YES  |     | NULL    |                |
610 | B_streettype        | varchar(50)  | YES  |     | NULL    |                |
611 | B_address           | varchar(100) | YES  |     | NULL    |                |
612 | B_address2          | text         | YES  |     | NULL    |                |
613 | B_city              | mediumtext   | YES  |     | NULL    |                |
614 | B_state             | mediumtext   | YES  |     | NULL    |                |
615 | B_zipcode           | varchar(25)  | YES  |     | NULL    |                |
616 | B_country           | text         | YES  |     | NULL    |                |
617 | B_email             | text         | YES  |     | NULL    |                |
618 | B_phone             | mediumtext   | YES  |     | NULL    |                |
619 | dateofbirth         | date         | YES  |     | NULL    |                |
620 | branchcode          | varchar(10)  | NO   | MUL |         |                |
621 | categorycode        | varchar(10)  | NO   | MUL |         |                |
622 | dateenrolled        | date         | YES  |     | NULL    |                |
623 | dateexpiry          | date         | YES  |     | NULL    |                |
624 | gonenoaddress       | tinyint(1)   | YES  |     | NULL    |                |
625 | lost                | tinyint(1)   | YES  |     | NULL    |                |
626 | debarred            | tinyint(1)   | YES  |     | NULL    |                |
627 | contactname         | mediumtext   | YES  |     | NULL    |                |
628 | contactfirstname    | text         | YES  |     | NULL    |                |
629 | contacttitle        | text         | YES  |     | NULL    |                |
630 | guarantorid         | int(11)      | YES  | MUL | NULL    |                |
631 | borrowernotes       | mediumtext   | YES  |     | NULL    |                |
632 | relationship        | varchar(100) | YES  |     | NULL    |                |
633 | ethnicity           | varchar(50)  | YES  |     | NULL    |                |
634 | ethnotes            | varchar(255) | YES  |     | NULL    |                |
635 | sex                 | varchar(1)   | YES  |     | NULL    |                |
636 | password            | varchar(30)  | YES  |     | NULL    |                |
637 | flags               | int(11)      | YES  |     | NULL    |                |
638 | userid              | varchar(30)  | YES  | MUL | NULL    |                |
639 | opacnote            | mediumtext   | YES  |     | NULL    |                |
640 | contactnote         | varchar(255) | YES  |     | NULL    |                |
641 | sort1               | varchar(80)  | YES  |     | NULL    |                |
642 | sort2               | varchar(80)  | YES  |     | NULL    |                |
643 | altcontactfirstname | varchar(255) | YES  |     | NULL    |                |
644 | altcontactsurname   | varchar(255) | YES  |     | NULL    |                |
645 | altcontactaddress1  | varchar(255) | YES  |     | NULL    |                |
646 | altcontactaddress2  | varchar(255) | YES  |     | NULL    |                |
647 | altcontactaddress3  | varchar(255) | YES  |     | NULL    |                |
648 | altcontactstate     | mediumtext   | YES  |     | NULL    |                |
649 | altcontactzipcode   | varchar(50)  | YES  |     | NULL    |                |
650 | altcontactcountry   | text         | YES  |     | NULL    |                |
651 | altcontactphone     | varchar(50)  | YES  |     | NULL    |                |
652 | smsalertnumber      | varchar(50)  | YES  |     | NULL    |                |
653 | privacy             | int(11)      | NO   |     | 1       |                |
654 +---------------------+--------------+------+-----+---------+----------------+
655
656
657  From C4::Members
658
659  $flags->{KEY}
660  {CHARGES}
661     {message}     Message showing patron's credit or debt
662     {noissues}    Set if patron owes >$5.00
663  {GNA}             Set if patron gone w/o address
664     {message}     "Borrower has no valid address"
665     {noissues}    Set.
666  {LOST}            Set if patron's card reported lost
667     {message}     Message to this effect
668     {noissues}    Set.
669  {DBARRED}         Set if patron is debarred
670     {message}     Message to this effect
671     {noissues}    Set.
672  {NOTES}           Set if patron has notes
673     {message}     Notes about patron
674  {ODUES}           Set if patron has overdue books
675     {message}     "Yes"
676     {itemlist}    ref-to-array: list of overdue books
677     {itemlisttext}    Text list of overdue items
678  {WAITING}         Set if there are items available that the patron reserved
679     {message}     Message to this effect
680     {itemlist}    ref-to-array: list of available items
681
682 =cut
683