'Generate an identifier for a new form'

@staticmethod
def generate_identifier():

    db = current.db
    table = db.cap_alert
    r = db().select(table.id, limitby=(0, 1), orderby=(~ table.id)).first()
    _time = datetime.datetime.strftime(datetime.datetime.utcnow(), '%Y.%m.%d')
    if r:
        next_id = (int(r.id) + 1)
    else:
        next_id = 1
    settings = current.deployment_settings
    prefix = 'urn:oid'
    oid = settings.get_cap_identifier_oid()
    oid_split = oid.split('.')
    if ((len(oid_split) >= 6) and (oid_split[5] == str(0))):
        oid_split[5] = str(1)
    oid = '.'.join(oid_split)
    return ('%s:%s.%s.%03d' % (prefix, oid, _time, next_id))
