From 8fb5941f4a0f4c2d591ec308a352a329ed8e53a0 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Mon, 22 Sep 2014 21:51:29 -0400 Subject: [PATCH] Add duplicate request check to NCIP::ILS::Evergreen->requestitem Signed-off-by: Jason Stephenson --- lib/NCIP/ILS/Evergreen.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/NCIP/ILS/Evergreen.pm b/lib/NCIP/ILS/Evergreen.pm index 153875a..2c625ea 100644 --- a/lib/NCIP/ILS/Evergreen.pm +++ b/lib/NCIP/ILS/Evergreen.pm @@ -1830,6 +1830,31 @@ sub place_hold { $params->{titleid} = $item->id(); } + # Check for a duplicate hold: + my $duplicate = $U->simplereq( + 'open-ils.pcrud', + 'open-ils.pcrud.search.ahr', + $self->{session}->{authtoken}, + { + hold_type => $hold->hold_type(), + target => $hold->target(), + usr => $hold->usr(), + expire_time => {'>' => 'now'}, + cancel_time => undef, + fulfillment_time => undef + } + ); + if ($duplicate) { + return NCIP::Problem->new( + { + ProblemType => 'Duplicate Request', + ProblemDetail => 'A request for this item already exists for this patron.', + ProblemElement => 'NULL', + ProblemValue => 'NULL' + } + ); + } + # Check if the hold is possible: my $r = $U->simplereq( 'open-ils.circ', -- 2.43.2