form_block

Ordered blocks within a form.

Ordered blocks within a form.

Source

ModelLegRole
form_blockopenEHRdefines this table

A form is a sequence of blocks. Narrative blocks hold their text in content; every other block type is backed by an entry row that points at it, which is what the check constraint enforces — content is present exactly when block_type is text.

Entry tables reference (form_id, id) rather than id alone, so an entry cannot be attached to a block belonging to a different form.

Columns

ColumnTypeNullDescriptionSource
iduuid primary keynoPrimary key.
form_iduuidnoThe form this block belongs to.
positionintegernoOrder of the block within the form, from zero.
block_typetextnoWhat kind of block this is; text blocks hold narrative, the rest are backed by an entry.
contenttextyesNarrative text, present only for text blocks.
content_metadatajsonyesFree-form metadata for the block's renderer.

Constraints

check ((block_type = 'text' and content is not null) or (block_type <> 'text' and content is null))

Unique

References

ColumnsTargetOn delete
form_idformcascade

Referenced by

155 tables reference form_block, via form_id, form_block_id. The first 15 alphabetically:

Definition

create table form_block (
    id uuid primary key default uuid_generate_v4(),
    form_id uuid not null references form (id) on delete cascade,
    position integer not null check (position >= 0),
    block_type text not null,
    content text,
    content_metadata json,
    check (
        (block_type = 'text' and content is not null)
        or
        (block_type <> 'text' and content is null)
    ),
    unique (form_id, position),
    unique (form_id, id)
);