'Get infos for all family members of person
@param person: the person (Row)
@param include_ids: include the person record IDs
@returns: array with family member infos, format:
[{i: the person record ID (if requested)
l: pe_label,
n: fullname,
d: dob_formatted,
p: picture_URL,
r: {
event_code: {
m: message,
e: earliest_date_ISO'

def get_family_members(self, person, include_ids=False):

    db = current.db
    s3db = current.s3db
    ptable = s3db.pr_person
    itable = s3db.pr_image
    gtable = s3db.pr_group
    mtable = s3db.pr_group_membership
    ctable = s3db.dvr_case
    stable = s3db.dvr_case_status
    person_id = person.id
    query = ((((mtable.person_id == person_id) & (mtable.deleted != True)) & (gtable.id == mtable.group_id)) & (gtable.group_type == 7))
    rows = db(query).select(gtable.id)
    group_ids = set((row.id for row in rows))
    members = {}
    if group_ids:
        join = [ptable.on((ptable.id == mtable.person_id)), ctable.on((((ctable.person_id == ptable.id) & (ctable.archived == False)) & (ctable.deleted == False)))]
        left = [stable.on((stable.id == ctable.status_id)), itable.on((((itable.pe_id == ptable.pe_id) & (itable.profile == True)) & (itable.deleted == False)))]
        query = ((mtable.group_id.belongs(group_ids) & (mtable.deleted != True)) & (stable.is_closed != True))
        rows = db(query).select(ptable.id, ptable.pe_label, ptable.first_name, ptable.last_name, ptable.date_of_birth, itable.image, join=join, left=left)
        for row in rows:
            member_id = row.pr_person.id
            if (member_id not in members):
                members[member_id] = row
    output = []
    if members:
        event_types = self.get_event_types()
        intervals = self.get_interval_rules(set(members.keys()))
        for (member_id, data) in members.items():
            member = data.pr_person
            picture = data.pr_image
            data = {'l': member.pe_label, 'n': s3_fullname(member), 'd': S3DateTime.date_represent(member.date_of_birth)}
            if include_ids:
                data['id'] = member_id
            if picture.image:
                data['p'] = URL(c='default', f='download', args=picture.image)
            event_rules = intervals.get(member_id)
            if event_rules:
                rules = {}
                for (event_type_id, rule) in event_rules.items():
                    code = event_types.get(event_type_id).code
                    rules[code] = (s3_str(rule[0]), ('%sZ' % s3_encode_iso_datetime(rule[1])))
                data['r'] = rules
            output.append(data)
    return output
