 +    unless ($user && haspermission($user->userid, {borrowers => 1})) {
 +       return $c->$cb({error => "You don't have the required permission"}, 403);
 +    }
++    my $response = {
++        count => 0,
++        localdb => 0,
++        centraldb => 0,
++        message => ""
++    };
++
 +    # lookup by birthdate, name and/or ssn
 +    my $params = $c->req->query_params->to_hash;
++
 +    # local lookup
 +    my $localpatrons = Koha::Patrons->search({
 +        surname => $params->{surname},

+        dateofbirth => $params->{dateofbirth}
+    })->unblessed;
+    warn Dumper($localpatrons);
+    if (scalar(@$localpatrons) > 0) {
+        return $c->$cb({message => "Local user(s) found", results => scalar(@$localpatrons), users => $localpatrons}, 200);
+    }
+
+    # norwegian Patron DB lookup

+    unless ($res->fault) {
+        my $nl = $res->result();
+        warn Dumper($nl);
+        $response->{centraldb} = int($nl->{'antall_treff'});
+        $response->{count} += $response->{centraldb};
+        $response->{message} += "Result from central lookup: $nl->{'melding'}. ";
+        return $c->$cb($response, 200);
+    } else {
+        return $c->$cb({error => "Error in call against Norwegian Patron Database"}, 403);
+    }
