@staticmethod
    def register_event(person_id, type_id):

        s3db = current.s3db

        ctable = s3db.dvr_case
        etable = s3db.dvr_case_event

        # Get the case ID for the person_id
        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

        # Customise event resource
        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:
            # Set record owner
            auth = current.auth
            auth.s3_set_record_owner(etable, record_id)
            auth.s3_make_session_owner(etable, record_id)
            # Execute onaccept
            data["id"] = record_id
            s3db.onaccept(etable, data, method="create")

        return record_id

    # -------------------------------------------------------------------------
Register a case event
dataset/ETHPy150Open sahana/eden/modules/s3db/dvr.py/DVRRegisterCaseEvent.register_event