'Register a case event
@param person_id: the person record ID
@param type:id: the event type record ID'

@staticmethod
def register_event(person_id, type_id):

    s3db = current.s3db
    ctable = s3db.dvr_case
    etable = s3db.dvr_case_event
    query = ((ctable.person_id == person_id) & (ctable.deleted != True))
    case = current.db(query).select(ctable.id, limitby=(0, 1)).first()
    if case:
        case_id = case.id
    else:
        case_id = None
    r = S3Request('dvr', 'case_event', current.request, args=[], get_vars={})
    r.customise_resource('dvr_case_event')
    data = {'person_id': person_id, 'case_id': case_id, 'type_id': type_id, 'date': current.request.utcnow}
    record_id = etable.insert(**data)
    if record_id:
        auth = current.auth
        auth.s3_set_record_owner(etable, record_id)
        auth.s3_make_session_owner(etable, record_id)
        data['id'] = record_id
        s3db.onaccept(etable, data, method='create')
    return record_id
