def is_prisoner_known(self):
     prisoner_number = self.cleaned_data['prisoner_number']
     prisoner_dob = serialise_date(self.cleaned_data['prisoner_dob'])
     try:
         client = get_api_client()
         filters = {
             'prisoner_number': prisoner_number,
             'prisoner_dob': prisoner_dob,
         }
         prison_set = self.get_prison_set()
         if prison_set:
             filters['prisons'] = ','.join(sorted(prison_set))
         prisoners = client.prisoner_validity().get(**filters)
         assert prisoners['count'] == len(prisoners['results']) == 1
         prisoner = prisoners['results'][0]
         return prisoner and prisoner['prisoner_number'] == prisoner_number \
             and prisoner['prisoner_dob'] == prisoner_dob
     except (HttpNotFoundError, KeyError, IndexError, AssertionError):
         pass
     return False
 def client(self):
     return get_api_client()