LP1655158 Patron Search by Date of Birth
authorblake <blake@mobiusconsortium.org>
Wed, 9 Aug 2017 14:28:41 +0000 (14:28 +0000)
committerChris Sharp <csharp@georgialibraries.org>
Thu, 24 Aug 2017 14:01:30 +0000 (10:01 -0400)
Adds three UI boxes to the WBSC "Show Extra" patron search. One for the year, month and day.
The javascript on the page is altered to deliver group "4" to the backend. Local javascript
strips out non-numeric user entered data. The backend is updated to handle the new group.
SQL is genereated using the DATE_PART postgres function.

1. Open the web based staff client and browse to the patron search UI.
2. Click the show more down arrow button. Notice the lack of birth date field.
3. Apply the patch, repeat step one. Notice the addition of birth date boxes.
4. Type 1975 into the birth year box and press enter. Notice search results.
5. Try searching for partial names and partial birthdates.
6. Try entering non-numeric data into the birth date boxes.
7. Try searching for patrons without including the dob. Try with only the dob. Try a mix.

Signed-off-by: blake <blake@mobiusconsortium.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm
Open-ILS/src/templates/staff/circ/patron/t_search.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/app.js

index bcf4508..9631f88 100644 (file)
@@ -676,6 +676,7 @@ sub patron_search {
     # group 1 = address
     # group 2 = phone, ident
     # group 3 = barcode
+    # group 4 = dob
 
     # Treatment of name fields depends on whether the org has 
     # diacritic_insensitivity turned on or off.
@@ -685,6 +686,8 @@ sub patron_search {
     $diacritic_insensitive = ($diacritic_insensitive) ? $JSON->JSON2perl($diacritic_insensitive) : 0;
     my $usr;
     my @usrv;
+    my $dob;
+    my @dobv;
 
     if ($diacritic_insensitive) {
        $usr = join ' AND ', map { "evergreen.unaccent_and_squash(CAST($_ AS text)) ~ ?" } grep { ''.$$search{$_}{group} eq '0' } keys %$search;
@@ -695,6 +698,13 @@ sub patron_search {
        @usrv = map { "^" . _clean_regex_chars($$search{$_}{value}) } grep { ''.$$search{$_}{group} eq '0' } keys %$search;
     }
 
+    $dob = join ' AND ', map { ("CAST (DATE_PART('" . ( s/year//g ? 'year' : ( s/month//g ? 'month' : 'day' ) ) . "', dob) AS text) ~ ?") } grep { ''.$$search{$_}{group} eq '4' } keys %$search;
+    @dobv = map { _clean_regex_chars($$search{$_}{value}) } grep { ''.$$search{$_}{group} eq '4' } keys %$search;
+
+    $usr .= ' AND ' if ( $usr && $dob );
+    $usr .= $dob if $dob;
+    push(@usrv, @dobv) if @dobv;
+
     my $addr = join ' AND ', map { "evergreen.lowercase(CAST($_ AS text)) ~ ?" } grep { ''.$$search{$_}{group} eq '1' } keys %$search;
     my @addrv = map { "^" . _clean_regex_chars($$search{$_}{value}) } grep { ''.$$search{$_}{group} eq '1' } keys %$search;
 
index 72e8336..0ae645f 100644 (file)
           </div>
         </div>
       </div>
+      <div class="form-group" ng-show="showExtras">
+        <div class="col-md-2">
+            <input type="text" class="form-control" ng-model="searchArgs.dob_year"
+            placeholder="[% l('DOB Year') %]" title="[% l('DOB Year') %]"/>
+        </div>
+        <div class="col-md-2">
+            <input type="text" class="form-control" ng-model="searchArgs.dob_month"
+            placeholder="[% l('DOB Month') %]" title="[% l('DOB Month') %]"/>
+        </div>
+        <div class="col-md-2">
+            <input type="text" class="form-control" ng-model="searchArgs.dob_day"
+            placeholder="[% l('DOB Day') %]" title="[% l('DOB Day') %]"/>
+        </div>
+      </div>
     </form>
   </div>
 </div>
index fe126d4..8418245 100644 (file)
@@ -1083,6 +1083,15 @@ function($scope,  $q,  $routeParams,  $timeout,  $window,  $location,  egCore,
                     search[key].group = 1;
                 } else if (key == 'card') {
                     search[key].group = 3
+                } else if (key.match(/dob_/)) {
+                    // DOB should always be numeric
+                    search[key].value = search[key].value.replace(/\D/g,'');
+                    if (search[key].value.length == 0) {
+                        delete search[key];
+                    }
+                    else {
+                        search[key].group = 4;
+                    }
                 }
             }
         });