'Search for People
- can be called direct
- can be called from search_by_keyword'

def search_person(self, message, pquery=None, name=None):

    message_body = message.body
    if (not message_body):
        return None
    if ((not pquery) or (not name)):
        (pquery, name) = self._parse_keywords(message_body)
    T = current.T
    db = current.db
    s3db = current.s3db
    reply = None
    result = []
    s3_accessible_query = current.auth.s3_accessible_query
    table = s3db.pr_person
    query = ((table.deleted == False) & s3_accessible_query('read', table))
    rows = db(query).select(table.pe_id, table.first_name, table.middle_name, table.last_name)
    _name = soundex(str(name))
    for row in rows:
        if ((_name == soundex(row.first_name)) or (_name == soundex(row.middle_name)) or (_name == soundex(row.last_name))):
            presult = dict(name=row.first_name, id=row.pe_id)
            result.append(presult)
    if (len(result) == 0):
        return T('No    Match')
    elif (len(result) > 1):
        return T('Multiple    Matches')
    else:
        reply = result[0]['name']
        table = s3db.pr_contact
        if ('email' in pquery):
            query = (((table.pe_id == result[0]['id']) & (table.contact_method == 'EMAIL')) & s3_accessible_query('read', table))
            recipient = db(query).select(table.value, orderby=table.priority, limitby=(0, 1)).first()
            if recipient:
                reply = ('%s    Email->%s' % (reply, recipient.value))
            else:
                reply = ("%s    's    Email    Not    available!" % reply)
        if ('phone' in pquery):
            query = (((table.pe_id == result[0]['id']) & (table.contact_method == 'SMS')) & s3_accessible_query('read', table))
            recipient = db(query).select(table.value, orderby=table.priority, limitby=(0, 1)).first()
            if recipient:
                reply = ('%s    Mobile->%s' % (reply, recipient.value))
            else:
                reply = ("%s    's    Mobile    Contact    Not    available!" % reply)
    return reply
