Dumped on 2020-12-02

Index of database - gnumed_v22


Schema au


Table: au.referral

table for referrals to defined individuals

au.referral Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit.audit_fields_pk_audit_seq'::regclass)
row_version integer NOT NULL
modified_when timestamp with time zone NOT NULL DEFAULT now()
modified_by name NOT NULL DEFAULT "current_user"()
pk_item integer NOT NULL DEFAULT nextval('clin.clin_root_item_pk_item_seq'::regclass)
clin_when timestamp with time zone NOT NULL DEFAULT now()
clin.encounter.pk fk_encounter integer NOT NULL
clin.episode.pk fk_episode integer NOT NULL
narrative text

inherited from clin.clin_root_item; stores text of referral letter
soap_cat text
id serial PRIMARY KEY
dem.identity.pk fk_referee integer NOT NULL

person to whom the referral is directed
clin.form_instances.pk fk_form integer NOT NULL

foreign key to the form instance of this referral.

Table au.referral Inherits clin_root_item,

 

au.referral Constraints
Name Constraint
audit_audit_fields_sane_modified_when CHECK (((modified_when <= clock_timestamp()) IS TRUE))
clin_root_item_sane_soap_cat CHECK (((soap_cat IS NULL) OR (soap_cat = ANY (ARRAY['s'::text, 'o'::text, 'a'::text, 'p'::text, 'u'::text]))))
idx_au_referral_fk_encounter fk_encounter idx_au_referral_fk_episode fk_episode

Index - Schema au


Schema audit


Table: audit.audit_fields

this table holds all the fields needed for auditing

audit.audit_fields Structure
F-Key Name Type Description
pk_audit serial PRIMARY KEY
row_version integer NOT NULL

the version of the row; mainly just a count
modified_when timestamp with time zone NOT NULL DEFAULT now()

when has this row been committed (created/modified)
modified_by name NOT NULL DEFAULT "current_user"()

by whom has this row been committed (created/modified)

 

audit.audit_fields Constraints
Name Constraint
audit_audit_fields_sane_modified_when CHECK (((modified_when <= clock_timestamp()) IS TRUE))

Index - Schema audit


Table: audit.audit_trail

Each table that needs standard auditing must have a log table inheriting from this table. Log tables have the same name with a prepended "log_". However, log_* tables shall not have constraints.

audit.audit_trail Structure
F-Key Name Type Description
pk_audit serial PRIMARY KEY
orig_version integer NOT NULL

the version of this row in the original table previous to the modification
orig_when timestamp with time zone NOT NULL

previous modification date in the original table
orig_by name NOT NULL

who committed the row to the original table
orig_tableoid oid NOT NULL

the table oid of the original table, use this to identify the source table
audit_action text NOT NULL

either "update" or "delete"
audit_when timestamp with time zone NOT NULL DEFAULT now()

when committed to this table for auditing
audit_by name NOT NULL DEFAULT "current_user"()

committed to this table for auditing by whom

 

audit.audit_trail Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.audited_tables

All tables that need standard auditing must be recorded in this table. Audit triggers will be generated automatically for all tables recorded here.

audit.audited_tables Structure
F-Key Name Type Description
id serial PRIMARY KEY
schema name UNIQUE#1 NOT NULL DEFAULT 'public'::name
table_name name UNIQUE#1 NOT NULL

Index - Schema audit


Table: audit.log_access_log

audit.log_access_log Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
user_action text

Table audit.log_access_log Inherits audit_trail,

 

audit.log_access_log Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_address

audit.log_address Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
id integer
id_street integer
aux_street text
number text
subunit text
addendum text
lat_lon point

Table audit.log_address Inherits audit_trail,

 

audit.log_address Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_allergy

audit.log_allergy Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_item integer
clin_when timestamp with time zone
fk_encounter integer
fk_episode integer
narrative text
soap_cat text
pk integer
substance text
substance_code text
generics text
allergene text
atc_code text
fk_type integer
generic_specific boolean
definite boolean

Table audit.log_allergy Inherits audit_trail,

 

audit.log_allergy Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_allergy_state

audit.log_allergy_state Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
has_allergy integer
comment text
last_confirmed timestamp with time zone
fk_encounter integer

Table audit.log_allergy_state Inherits audit_trail,

 

audit.log_allergy_state Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_auto_hint

audit.log_auto_hint Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
query text
title text
hint text
url text
is_active boolean
source text
lang text
recommendation_query text
popup_type integer
highlight_as_priority boolean

Table audit.log_auto_hint Inherits audit_trail,

 

audit.log_auto_hint Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_beh_fall_typ

audit.log_beh_fall_typ Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
code text
kurzform text
name text

Table audit.log_beh_fall_typ Inherits audit_trail,

 

audit.log_beh_fall_typ Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_bill

audit.log_bill Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
invoice_id text
close_date timestamp with time zone
apply_vat boolean
fk_receiver_identity integer
fk_receiver_address integer
fk_doc integer
comment text

Table audit.log_bill Inherits audit_trail,

 

audit.log_bill Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_bill_item

audit.log_bill_item Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_provider integer
fk_encounter integer
date_to_bill date
description text
net_amount_per_unit numeric
currency text
status text
fk_billable integer
fk_bill integer
unit_count integer
amount_multiplier numeric

Table audit.log_bill_item Inherits audit_trail,

 

audit.log_bill_item Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_billable

audit.log_billable Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
pk_coding_system integer
code text
term text
fk_data_source integer
comment text
pk integer
amount numeric
currency text
vat_multiplier numeric
active boolean
discountable boolean

Table audit.log_billable Inherits audit_trail,

 

audit.log_billable Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_clin_aux_note

audit.log_clin_aux_note Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_item integer
clin_when timestamp with time zone
fk_encounter integer
fk_episode integer
narrative text
soap_cat text
pk integer

Table audit.log_clin_aux_note Inherits audit_trail,

 

audit.log_clin_aux_note Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_clin_diag

audit.log_clin_diag Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_narrative integer
laterality bpchar
is_chronic boolean
is_active boolean
is_definite boolean
clinically_relevant boolean

Table audit.log_clin_diag Inherits audit_trail,

 

audit.log_clin_diag Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_clin_item_type

audit.log_clin_item_type Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
type text
code text

Table audit.log_clin_item_type Inherits audit_trail,

 

audit.log_clin_item_type Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_clin_narrative

audit.log_clin_narrative Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_item integer
clin_when timestamp with time zone
fk_encounter integer
fk_episode integer
narrative text
soap_cat text
pk integer

Table audit.log_clin_narrative Inherits audit_trail,

 

audit.log_clin_narrative Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_consumable_substance

audit.log_consumable_substance Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
description text
atc_code text
amount numeric
unit text

Table audit.log_consumable_substance Inherits audit_trail,

 

audit.log_consumable_substance Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_consumed_substance

audit.log_consumed_substance Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
description text
atc_code text

Table audit.log_consumed_substance Inherits audit_trail,

 

audit.log_consumed_substance Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_data_source

audit.log_data_source Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
name_short text
name_long text
version text
description text
source text
lang text

Table audit.log_data_source Inherits audit_trail,

 

audit.log_data_source Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_doc_desc

audit.log_doc_desc Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_doc integer
text text

Table audit.log_doc_desc Inherits audit_trail,

 

audit.log_doc_desc Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_doc_med

audit.log_doc_med Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_encounter integer
fk_episode integer
fk_type integer
comment text
clin_when timestamp with time zone
ext_ref text
fk_org_unit integer
unit_is_receiver boolean
fk_hospital_stay integer

Table audit.log_doc_med Inherits audit_trail,

 

audit.log_doc_med Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_dose

audit.log_dose Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
pk integer
fk_substance integer
amount numeric
unit text
dose_unit text

Table audit.log_dose Inherits audit_trail,

 

audit.log_dose Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_drug_product

audit.log_drug_product Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
description text
preparation text
atc_code text
is_fake boolean
fk_data_source integer
external_code text
external_code_type text

Table audit.log_drug_product Inherits audit_trail,

 

audit.log_drug_product Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_encounter

audit.log_encounter Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_patient integer
fk_type integer
fk_location integer
source_time_zone interval
reason_for_encounter text
assessment_of_encounter text
started timestamp with time zone
last_affirmed timestamp with time zone

Table audit.log_encounter Inherits audit_trail,

 

audit.log_encounter Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_episode

audit.log_episode Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_health_issue integer
description text
is_open boolean
fk_encounter integer
diagnostic_certainty_classification text
summary text

Table audit.log_episode Inherits audit_trail,

 

audit.log_episode Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_external_care

audit.log_external_care Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_encounter integer
fk_health_issue integer
issue text
fk_org_unit integer
provider text
comment text
inactive boolean

Table audit.log_external_care Inherits audit_trail,

 

audit.log_external_care Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_family_history

audit.log_family_history Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_item integer
clin_when timestamp with time zone
fk_encounter integer
fk_episode integer
narrative text
soap_cat text
pk integer
fk_relation_type integer
age_noted text
age_of_death interval
contributed_to_death boolean
name_relative text
dob_relative timestamp with time zone
comment text

Table audit.log_family_history Inherits audit_trail,

 

audit.log_family_history Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_fhx_relation_type

audit.log_fhx_relation_type Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
description text
is_genetic boolean

Table audit.log_fhx_relation_type Inherits audit_trail,

 

audit.log_fhx_relation_type Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_form_data

audit.log_form_data Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_instance integer
fk_form_field integer
value text

Table audit.log_form_data Inherits audit_trail,

 

audit.log_form_data Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_form_instances

audit.log_form_instances Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_item integer
clin_when timestamp with time zone
fk_encounter integer
fk_episode integer
narrative text
soap_cat text
pk integer
fk_form_def integer
form_name text

Table audit.log_form_instances Inherits audit_trail,

 

audit.log_form_instances Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_gender_label

audit.log_gender_label Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
tag text
label text
sort_weight integer
comment text

Table audit.log_gender_label Inherits audit_trail,

 

audit.log_gender_label Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_health_issue

audit.log_health_issue Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
description text
laterality character varying
age_noted interval
is_active boolean
clinically_relevant boolean
is_confidential boolean
is_cause_of_death boolean
fk_encounter integer
grouping text
diagnostic_certainty_classification text
summary text

Table audit.log_health_issue Inherits audit_trail,

 

audit.log_health_issue Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_hospital_stay

audit.log_hospital_stay Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_item integer
clin_when timestamp with time zone
fk_encounter integer
fk_episode integer
narrative text
soap_cat text
pk integer
discharge timestamp with time zone
fk_org_unit integer

Table audit.log_hospital_stay Inherits audit_trail,

 

audit.log_hospital_stay Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_hx_family_item

audit.log_hx_family_item Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_narrative_condition integer
fk_relative integer
name_relative text
dob_relative timestamp with time zone
condition text
age_noted text
age_of_death interval
is_cause_of_death boolean

Table audit.log_hx_family_item Inherits audit_trail,

 

audit.log_hx_family_item Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_identity

audit.log_identity Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
deleted boolean
gender text
dob timestamp with time zone
fk_marital_status integer
cob bpchar
deceased timestamp with time zone
title text
tob time without time zone
emergency_contact text
fk_emergency_contact integer
comment text
fk_primary_provider integer
dob_is_estimated boolean

Table audit.log_identity Inherits audit_trail,

 

audit.log_identity Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_identity_tag

audit.log_identity_tag Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_identity integer
fk_tag integer
comment text

Table audit.log_identity_tag Inherits audit_trail,

 

audit.log_identity_tag Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_inbox_item_category

audit.log_inbox_item_category Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
description text
is_user boolean

Table audit.log_inbox_item_category Inherits audit_trail,

 

audit.log_inbox_item_category Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_inbox_item_type

audit.log_inbox_item_type Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_inbox_item_category integer
description text
is_user boolean

Table audit.log_inbox_item_type Inherits audit_trail,

 

audit.log_inbox_item_type Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_incoming_data_unmatchable

audit.log_incoming_data_unmatchable Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_patient_candidates integer[]
request_id text
firstnames text
lastnames text
dob date
postcode text
other_info text
type text
data bytea
gender text
requestor text
external_data_id text
fk_identity_disambiguated integer

Table audit.log_incoming_data_unmatchable Inherits audit_trail,

 

audit.log_incoming_data_unmatchable Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_incoming_data_unmatched

audit.log_incoming_data_unmatched Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_patient_candidates integer[]
request_id text
firstnames text
lastnames text
dob date
postcode text
other_info text
type text
data bytea
gender text
requestor text
external_data_id text
fk_identity_disambiguated integer
comment text
fk_provider_disambiguated integer

Table audit.log_incoming_data_unmatched Inherits audit_trail,

 

audit.log_incoming_data_unmatched Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lab_request

audit.log_lab_request Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_item integer
clin_when timestamp with time zone
fk_encounter integer
fk_episode integer
narrative text
soap_cat text
pk integer
fk_test_org integer
request_id text
fk_requestor integer
lab_request_id text
lab_rxd_when timestamp with time zone
results_reported_when timestamp with time zone
request_status text
is_pending boolean
diagnostic_service_section text
ordered_service text
note_test_org text

Table audit.log_lab_request Inherits audit_trail,

 

audit.log_lab_request Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lab_test_gnr

audit.log_lab_test_gnr Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
id integer
id_test integer

Table audit.log_lab_test_gnr Inherits audit_trail,

 

audit.log_lab_test_gnr Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_code2aoe

audit.log_lnk_code2aoe Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_lnk_code2item integer
fk_generic_code integer
fk_item integer
code_modifier text
pk integer

Table audit.log_lnk_code2aoe Inherits audit_trail,

 

audit.log_lnk_code2aoe Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_code2episode

audit.log_lnk_code2episode Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_lnk_code2item integer
fk_generic_code integer
fk_item integer
code_modifier text
pk integer

Table audit.log_lnk_code2episode Inherits audit_trail,

 

audit.log_lnk_code2episode Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_code2fhx

audit.log_lnk_code2fhx Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_lnk_code2item integer
fk_generic_code integer
fk_item integer
code_modifier text
pk integer

Table audit.log_lnk_code2fhx Inherits audit_trail,

 

audit.log_lnk_code2fhx Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_code2h_issue

audit.log_lnk_code2h_issue Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_lnk_code2item integer
fk_generic_code integer
fk_item integer
code_modifier text
pk integer

Table audit.log_lnk_code2h_issue Inherits audit_trail,

 

audit.log_lnk_code2h_issue Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_code2narrative

audit.log_lnk_code2narrative Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_lnk_code2item integer
fk_generic_code integer
fk_item integer
code_modifier text
pk integer

Table audit.log_lnk_code2narrative Inherits audit_trail,

 

audit.log_lnk_code2narrative Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_code2procedure

audit.log_lnk_code2procedure Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_lnk_code2item integer
fk_generic_code integer
fk_item integer
code_modifier text
pk integer

Table audit.log_lnk_code2procedure Inherits audit_trail,

 

audit.log_lnk_code2procedure Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_code2rfe

audit.log_lnk_code2rfe Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_lnk_code2item integer
fk_generic_code integer
fk_item integer
code_modifier text
pk integer

Table audit.log_lnk_code2rfe Inherits audit_trail,

 

audit.log_lnk_code2rfe Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_code2tst_pnl

audit.log_lnk_code2tst_pnl Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_lnk_code2item integer
fk_generic_code integer
fk_item integer
code_modifier text
pk integer

Table audit.log_lnk_code2tst_pnl Inherits audit_trail,

 

audit.log_lnk_code2tst_pnl Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_constraint2vacc_course

audit.log_lnk_constraint2vacc_course Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_vaccination_course integer
fk_constraint integer

Table audit.log_lnk_constraint2vacc_course Inherits audit_trail,

 

audit.log_lnk_constraint2vacc_course Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_dose2drug

audit.log_lnk_dose2drug Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
pk integer
fk_drug_product integer
fk_dose integer

Table audit.log_lnk_dose2drug Inherits audit_trail,

 

audit.log_lnk_dose2drug Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_identity2ext_id

audit.log_lnk_identity2ext_id Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
id integer
id_identity integer
external_id text
fk_origin integer
comment text

Table audit.log_lnk_identity2ext_id Inherits audit_trail,

 

audit.log_lnk_identity2ext_id Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_identity2primary_doc

audit.log_lnk_identity2primary_doc Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
pk integer
fk_identity integer
fk_primary_doc integer

Table audit.log_lnk_identity2primary_doc Inherits audit_trail,

 

audit.log_lnk_identity2primary_doc Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_job2person

audit.log_lnk_job2person Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_identity integer
fk_occupation integer
activities text

Table audit.log_lnk_job2person Inherits audit_trail,

 

audit.log_lnk_job2person Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_loinc2substance

audit.log_lnk_loinc2substance Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
pk integer
fk_substance integer
loinc text
max_age interval
comment text

Table audit.log_lnk_loinc2substance Inherits audit_trail,

 

audit.log_lnk_loinc2substance Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_loinc2test_panel

audit.log_lnk_loinc2test_panel Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
pk integer
fk_test_panel integer
loinc text

Table audit.log_lnk_loinc2test_panel Inherits audit_trail,

 

audit.log_lnk_loinc2test_panel Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_org_unit2comm

audit.log_lnk_org_unit2comm Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_org_unit integer
url text
fk_type integer
is_confidential boolean
comment text

Table audit.log_lnk_org_unit2comm Inherits audit_trail,

 

audit.log_lnk_org_unit2comm Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_org_unit2ext_id

audit.log_lnk_org_unit2ext_id Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_org_unit integer
external_id text
fk_type integer
comment text

Table audit.log_lnk_org_unit2ext_id Inherits audit_trail,

 

audit.log_lnk_org_unit2ext_id Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_pat2vaccination_course

audit.log_lnk_pat2vaccination_course Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_patient integer
fk_course integer

Table audit.log_lnk_pat2vaccination_course Inherits audit_trail,

 

audit.log_lnk_pat2vaccination_course Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_person2relative

audit.log_lnk_person2relative Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
id integer
id_identity integer
id_relative integer
id_relation_type integer
started date
ended date

Table audit.log_lnk_person2relative Inherits audit_trail,

 

audit.log_lnk_person2relative Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_substance2brand

audit.log_lnk_substance2brand Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_brand integer
fk_substance integer

Table audit.log_lnk_substance2brand Inherits audit_trail,

 

audit.log_lnk_substance2brand Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_tst2norm

audit.log_lnk_tst2norm Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
id integer
id_test integer
id_norm integer

Table audit.log_lnk_tst2norm Inherits audit_trail,

 

audit.log_lnk_tst2norm Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_type2item

audit.log_lnk_type2item Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_type integer
fk_item integer

Table audit.log_lnk_type2item Inherits audit_trail,

 

audit.log_lnk_type2item Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_vaccination_course2schedule

audit.log_lnk_vaccination_course2schedule Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_course integer
fk_schedule integer

Table audit.log_lnk_vaccination_course2schedule Inherits audit_trail,

 

audit.log_lnk_vaccination_course2schedule Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_lnk_vaccine2inds

audit.log_lnk_vaccine2inds Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
id integer
fk_vaccine integer
fk_indication integer

Table audit.log_lnk_vaccine2inds Inherits audit_trail,

 

audit.log_lnk_vaccine2inds Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_message_inbox

audit.log_message_inbox Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_staff integer
fk_inbox_item_type integer
comment text
data text
importance smallint
fk_patient integer
ufk_context integer[]
due_date date
expiry_date date

Table audit.log_message_inbox Inherits audit_trail,

 

audit.log_message_inbox Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_occupation

audit.log_occupation Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
id integer
name text

Table audit.log_occupation Inherits audit_trail,

 

audit.log_occupation Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_operation

audit.log_operation Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_health_issue integer
fk_encounter integer
clin_where text
comment text

Table audit.log_operation Inherits audit_trail,

 

audit.log_operation Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_org

audit.log_org Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
description text
fk_category integer
fk_data_source integer

Table audit.log_org Inherits audit_trail,

 

audit.log_org Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_org_unit

audit.log_org_unit Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
description text
fk_org integer
fk_address integer
fk_category integer

Table audit.log_org_unit Inherits audit_trail,

 

audit.log_org_unit Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_paperwork_templates

audit.log_paperwork_templates Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_template_type integer
instance_type text
name_short text
name_long text
external_version text
gnumed_revision double precision
engine text
in_use boolean
filename text
data bytea
edit_after_substitution boolean

Table audit.log_paperwork_templates Inherits audit_trail,

 

audit.log_paperwork_templates Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_patient

audit.log_patient Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_identity integer
edc date

Table audit.log_patient Inherits audit_trail,

 

audit.log_patient Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_prax_geb_paid

audit.log_prax_geb_paid Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_fall integer
paid_amount numeric
paid_when date
paid_with integer

Table audit.log_prax_geb_paid Inherits audit_trail,

 

audit.log_prax_geb_paid Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_praxis_branch

audit.log_praxis_branch Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_org_unit integer

Table audit.log_praxis_branch Inherits audit_trail,

 

audit.log_praxis_branch Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_procedure

audit.log_procedure Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_item integer
clin_when timestamp with time zone
fk_encounter integer
fk_episode integer
narrative text
soap_cat text
pk integer
clin_where text
fk_hospital_stay integer
clin_end timestamp with time zone
is_ongoing boolean
fk_org_unit integer
fk_doc integer
comment text

Table audit.log_procedure Inherits audit_trail,

 

audit.log_procedure Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_referral

audit.log_referral Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_item integer
clin_when timestamp with time zone
fk_encounter integer
fk_episode integer
narrative text
soap_cat text
id integer
fk_referee integer
fk_form integer

Table audit.log_referral Inherits audit_trail,

 

audit.log_referral Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_region

audit.log_region Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
code text
country bpchar
name text

Table audit.log_region Inherits audit_trail,

 

audit.log_region Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_relation_types

audit.log_relation_types Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
id integer
inverse integer
biological boolean
biol_verified boolean
description text

Table audit.log_relation_types Inherits audit_trail,

 

audit.log_relation_types Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_report_query

audit.log_report_query Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
label text
cmd text

Table audit.log_report_query Inherits audit_trail,

 

audit.log_report_query Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_staff

audit.log_staff Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_identity integer
db_user name
short_alias text
comment text
is_active boolean

Table audit.log_staff Inherits audit_trail,

 

audit.log_staff Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_street

audit.log_street Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
id integer
id_urb integer
name text
postcode text
suburb text
lat_lon point

Table audit.log_street Inherits audit_trail,

 

audit.log_street Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_substance

audit.log_substance Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
pk integer
description text
atc text
intake_instructions text

Table audit.log_substance Inherits audit_trail,

 

audit.log_substance Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_substance_in_brand

audit.log_substance_in_brand Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_brand integer
description text
atc_code text

Table audit.log_substance_in_brand Inherits audit_trail,

 

audit.log_substance_in_brand Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_substance_intake

audit.log_substance_intake Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_item integer
clin_when timestamp with time zone
fk_encounter integer
fk_episode integer
narrative text
soap_cat text
pk integer
fk_substance integer
preparation text
schedule text
aim text
duration interval
intake_is_approved_of boolean
is_long_term boolean
discontinued timestamp with time zone
discontinue_reason text
fk_drug_component integer
comment_on_start text
harmful_use_type integer

Table audit.log_substance_intake Inherits audit_trail,

 

audit.log_substance_intake Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_suppressed_hint

audit.log_suppressed_hint Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_encounter integer
fk_hint integer
suppressed_by name
suppressed_when timestamp with time zone
rationale text
md5_sum text

Table audit.log_suppressed_hint Inherits audit_trail,

 

audit.log_suppressed_hint Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_tag_image

audit.log_tag_image Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
description text
filename text
image bytea

Table audit.log_tag_image Inherits audit_trail,

 

audit.log_tag_image Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_test_org

audit.log_test_org Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_org_unit integer
fk_adm_contact integer
fk_med_contact integer
comment text
contact text

Table audit.log_test_org Inherits audit_trail,

 

audit.log_test_org Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_test_panel

audit.log_test_panel Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
description text
comment text
fk_test_types integer[]

Table audit.log_test_panel Inherits audit_trail,

 

audit.log_test_panel Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_test_result

audit.log_test_result Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_item integer
clin_when timestamp with time zone
fk_encounter integer
fk_episode integer
narrative text
soap_cat text
pk integer
fk_type integer
val_num numeric
val_alpha text
val_unit text
val_normal_min numeric
val_normal_max numeric
val_normal_range text
val_target_min numeric
val_target_max numeric
val_target_range text
abnormality_indicator text
norm_ref_group text
note_test_org text
material text
material_detail text
fk_intended_reviewer integer
fk_request integer
status text
source_data text
val_grouping text

Table audit.log_test_result Inherits audit_trail,

 

audit.log_test_result Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_test_type

audit.log_test_type Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_test_org integer
name text
comment text
reference_unit text
loinc text
abbrev text
fk_meta_test_type integer

Table audit.log_test_type Inherits audit_trail,

 

audit.log_test_type Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_urb

audit.log_urb Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
id integer
fk_region integer
postcode text
lat_lon point
name text

Table audit.log_urb Inherits audit_trail,

 

audit.log_urb Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_vacc_indication

audit.log_vacc_indication Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
id integer
description text
atcs_single_indication text[]
atcs_combi_indication text[]

Table audit.log_vacc_indication Inherits audit_trail,

 

audit.log_vacc_indication Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_vacc_route

audit.log_vacc_route Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
id integer
abbreviation text
description text

Table audit.log_vacc_route Inherits audit_trail,

 

audit.log_vacc_route Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_vaccination

audit.log_vaccination Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk_item integer
clin_when timestamp with time zone
fk_encounter integer
fk_episode integer
narrative text
soap_cat text
pk integer
fk_patient integer
fk_provider integer
fk_vaccine integer
site text
batch_no text
reaction text

Table audit.log_vaccination Inherits audit_trail,

 

audit.log_vaccination Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_vaccination_course

audit.log_vaccination_course Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_recommended_by integer
fk_indication integer
is_active boolean
comment text

Table audit.log_vaccination_course Inherits audit_trail,

 

audit.log_vaccination_course Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_vaccination_course_constraint

audit.log_vaccination_course_constraint Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
description text

Table audit.log_vaccination_course_constraint Inherits audit_trail,

 

audit.log_vaccination_course_constraint Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_vaccination_definition

audit.log_vaccination_definition Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
id integer
fk_course integer
is_booster boolean
seq_no integer
min_age_due interval
max_age_due interval
min_interval interval
comment text

Table audit.log_vaccination_definition Inherits audit_trail,

 

audit.log_vaccination_definition Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_vaccination_schedule

audit.log_vaccination_schedule Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
name text
comment text

Table audit.log_vaccination_schedule Inherits audit_trail,

 

audit.log_vaccination_schedule Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_vaccine

audit.log_vaccine Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
id_route integer
is_live boolean
min_age interval
max_age interval
comment text
fk_drug_product integer

Table audit.log_vaccine Inherits audit_trail,

 

audit.log_vaccine Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_vaccine_batches

audit.log_vaccine_batches Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_vaccine integer
batch_no text

Table audit.log_vaccine_batches Inherits audit_trail,

 

audit.log_vaccine_batches Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_waiting_list

audit.log_waiting_list Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
fk_patient integer
registered timestamp with time zone
urgency integer
list_position integer
comment text
area text

Table audit.log_waiting_list Inherits audit_trail,

 

audit.log_waiting_list Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


Table: audit.log_xlnk_identity

audit.log_xlnk_identity Structure
F-Key Name Type Description
pk_audit integer NOT NULL DEFAULT nextval('audit_trail_pk_audit_seq'::regclass)
orig_version integer NOT NULL

the .row_version in the original row before the audited action took place, should be equal to .row_version
orig_when timestamp with time zone NOT NULL

the .modified_when in the original row before the audited action took place, should be equal to .modified_when
orig_by name NOT NULL

the .modified_by in the original row before the audited action took place, should be equal to .modified_by
orig_tableoid oid NOT NULL

the TG_RELID when the audit trigger was run
audit_action text NOT NULL
audit_when timestamp with time zone NOT NULL DEFAULT now()
audit_by name NOT NULL DEFAULT "current_user"()
row_version integer
modified_when timestamp with time zone
modified_by name
pk integer
xfk_identity integer
pupic text
data text

Table audit.log_xlnk_identity Inherits audit_trail,

 

audit.log_xlnk_identity Constraints
Name Constraint
audit_audit_trail_orig_before_audit_when CHECK (((orig_when <= audit_when) IS TRUE))
audit_audit_trail_sane_audit_when CHECK (((audit_when <= clock_timestamp()) IS TRUE))
audit_audit_trail_sane_orig_when CHECK (((orig_when <= clock_timestamp()) IS TRUE))
audit_trail_audit_action_check CHECK ((audit_action = ANY (ARRAY['UPDATE'::text, 'DELETE'::text])))

Index - Schema audit


View: audit.v_audit_trail

audit.v_audit_trail Structure
F-Key Name Type Description
event_when text
event_by text
event_table regclass
row_version_before integer
row_version_after integer
event text
audit_when_ts timestamp with time zone
pk_audit integer
SELECT to_char
(aat.audit_when
     ,'YYYY-MM-DD HH24:MI'::text
) AS event_when
,
    COALESCE
(
     (
      SELECT staff.short_alias
           
        FROM dem.staff
          
       WHERE (staff.db_user = aat.audit_by)
     )
     , (
           ('<'::text || 
                 (aat.audit_by)::text
           ) || '>'::text
     )
) AS event_by
,
    
(aat.orig_tableoid)::regclass AS event_table
,
    aat.orig_version AS row_version_before
,
        CASE
            WHEN 
(aat.audit_action = 'DELETE'::text) THEN NULL::integer
            ELSE 
(aat.orig_version + 1)
        END AS row_version_after
,
    aat.audit_action AS event
,
    aat.audit_when AS audit_when_ts
,
    aat.pk_audit
   
FROM audit.audit_trail aat

UNION ALL
 
SELECT to_char
(gal.modified_when
     ,'YYYY-MM-DD HH24:MI'::text
) AS event_when
,
    COALESCE
(
     (
      SELECT staff.short_alias
           
        FROM dem.staff
          
       WHERE (staff.db_user = gal.modified_by)
     )
     , (
           ('<'::text || 
                 (gal.modified_by)::text
           ) || '>'::text
     )
) AS event_by
,
    'gm.access_log'::regclass AS event_table
,
    NULL::integer AS row_version_before
,
    0 AS row_version_after
,
    gal.user_action AS event
,
    gal.modified_when AS audit_when_ts
,
    gal.pk_audit
   
FROM gm.access_log gal
  
WHERE (gal.row_version = 0)
UNION ALL
 
SELECT to_char
(aaf.modified_when
     ,'YYYY-MM-DD HH24:MI'::text
) AS event_when
,
    COALESCE
(
     (
      SELECT staff.short_alias
           
        FROM dem.staff
          
       WHERE (staff.db_user = aaf.modified_by)
     )
     , (
           ('<'::text || 
                 (aaf.modified_by)::text
           ) || '>'::text
     )
) AS event_by
,
    
(aaf.tableoid)::regclass AS event_table
,
    NULL::integer AS row_version_before
,
    0 AS row_version_after
,
    'INSERT'::text AS event
,
    aaf.modified_when AS audit_when_ts
,
    aaf.pk_audit
   
FROM audit.audit_fields aaf
  
WHERE (aaf.row_version = 0);

Index - Schema audit


Function: audit.add_table_for_audit(name)

Returns: boolean

Language: SQL

sanity-checking convenience function for marking tables for auditing, schema is always "public"

select audit.add_table_for_audit('public', $1);

Function: audit.add_table_for_audit(name, name)

Returns: boolean

Language: PLPGSQL

sanity-checking convenience function for marking tables for auditing

DECLARE
	_relnamespace alias for $1;
	_relname ALIAS FOR $2;
	dummy RECORD;
	tmp text;
BEGIN
	-- does table exist ?
	select relname into dummy from pg_class where
		relname = _relname and
		relnamespace = (select oid from pg_namespace where nspname = _relnamespace)
	;
	if not found then
		tmp := _relnamespace || '.' || _relname;
		raise exception 'audit.add_table_for_audit: Table [%] does not exist.', tmp;
		return false;
	end if;
	-- already queued for auditing ?
	select 1 into dummy from audit.audited_tables where table_name = _relname and schema = _relnamespace;
	if found then
		return true;
	end if;
	-- add definition
	insert into audit.audited_tables (
		schema, table_name
	) values (
		_relnamespace, _relname
	);
	return true;
END;

Function: audit.ft_del_access_log()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_access_log (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, user_action
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.user_action
	);
	return OLD;
END;

Function: audit.ft_del_active_substance()

Returns: trigger

Language: PLPGSQL

BEGIN
	INSERT INTO audit.log_active_substance (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, description, atc_code
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.description, OLD.atc_code
	);
	return OLD;
END;

Function: audit.ft_del_address()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_address (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, id_street, aux_street, number, subunit, addendum, lat_lon
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.id_street, OLD.aux_street, OLD.number, OLD.subunit, OLD.addendum, OLD.lat_lon
	);
	return OLD;
END;

Function: audit.ft_del_allergy()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_allergy (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, substance, substance_code, generics, allergene, atc_code, fk_type, generic_specific, definite
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.substance, OLD.substance_code, OLD.generics, OLD.allergene, OLD.atc_code, OLD.fk_type, OLD.generic_specific, OLD.definite
	);
	return OLD;
END;

Function: audit.ft_del_allergy_state()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_allergy_state (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, has_allergy, comment, last_confirmed, fk_encounter
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.has_allergy, OLD.comment, OLD.last_confirmed, OLD.fk_encounter
	);
	return OLD;
END;

Function: audit.ft_del_atc_group()

Returns: trigger

Language: PLPGSQL

BEGIN
	INSERT INTO audit.log_atc_group (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, code, description
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.code, OLD.description
	);
	return OLD;
END;

Function: audit.ft_del_atc_substance()

Returns: trigger

Language: PLPGSQL

BEGIN
	INSERT INTO audit.log_atc_substance (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, code, name, ddd_amount, fk_ddd_unit, route, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.code, OLD.name, OLD.ddd_amount, OLD.fk_ddd_unit, OLD.route, OLD.comment
	);
	return OLD;
END;

Function: audit.ft_del_auto_hint()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_auto_hint (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, query, title, hint, url, is_active, source, lang, recommendation_query, popup_type, highlight_as_priority
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.query, OLD.title, OLD.hint, OLD.url, OLD.is_active, OLD.source, OLD.lang, OLD.recommendation_query, OLD.popup_type, OLD.highlight_as_priority
	);
	return OLD;
END;

Function: audit.ft_del_beh_fall_typ()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_beh_fall_typ (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, code, kurzform, name
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.code, OLD.kurzform, OLD.name
	);
	return OLD;
END;

Function: audit.ft_del_behandlungsfall()

Returns: trigger

Language: PLPGSQL

BEGIN
	INSERT INTO audit.log_behandlungsfall (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_patient, fk_falltyp, started, must_pay_prax_geb
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_patient, OLD.fk_falltyp, OLD.started, OLD.must_pay_prax_geb
	);
	return OLD;
END;

Function: audit.ft_del_bill()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_bill (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, invoice_id, close_date, apply_vat, fk_receiver_identity, fk_receiver_address, fk_doc, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.invoice_id, OLD.close_date, OLD.apply_vat, OLD.fk_receiver_identity, OLD.fk_receiver_address, OLD.fk_doc, OLD.comment
	);
	return OLD;
END;

Function: audit.ft_del_bill_item()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_bill_item (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_provider, fk_encounter, date_to_bill, description, net_amount_per_unit, currency, status, fk_billable, fk_bill, unit_count, amount_multiplier
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_provider, OLD.fk_encounter, OLD.date_to_bill, OLD.description, OLD.net_amount_per_unit, OLD.currency, OLD.status, OLD.fk_billable, OLD.fk_bill, OLD.unit_count, OLD.amount_multiplier
	);
	return OLD;
END;

Function: audit.ft_del_clin_aux_note()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_clin_aux_note (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk
	);
	return OLD;
END;

Function: audit.ft_del_clin_diag()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_clin_diag (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_narrative, laterality, is_chronic, is_active, is_definite, clinically_relevant
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_narrative, OLD.laterality, OLD.is_chronic, OLD.is_active, OLD.is_definite, OLD.clinically_relevant
	);
	return OLD;
END;

Function: audit.ft_del_clin_item_type()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_clin_item_type (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, type, code
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.type, OLD.code
	);
	return OLD;
END;

Function: audit.ft_del_clin_medication()

Returns: trigger

Language: PLPGSQL

BEGIN
	INSERT INTO audit.log_clin_medication (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, last_prescribed, fk_last_script, discontinued, brandname, generic, adjuvant, dosage_form, ufk_drug, drug_db, atc_code, is_cr, dosage, period, dosage_unit, directions, is_prn
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.last_prescribed, OLD.fk_last_script, OLD.discontinued, OLD.brandname, OLD.generic, OLD.adjuvant, OLD.dosage_form, OLD.ufk_drug, OLD.drug_db, OLD.atc_code, OLD.is_cr, OLD.dosage, OLD.period, OLD.dosage_unit, OLD.directions, OLD.is_prn
	);
	return OLD;
END;

Function: audit.ft_del_clin_narrative()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_clin_narrative (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk
	);
	return OLD;
END;

Function: audit.ft_del_coded_phrase()

Returns: trigger

Language: PLPGSQL

BEGIN
	INSERT INTO audit.log_coded_phrase (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, term, code, xfk_coding_system
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.term, OLD.code, OLD.xfk_coding_system
	);
	return OLD;
END;

Function: audit.ft_del_consumable_substance()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_consumable_substance (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, atc_code, amount, unit
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.atc_code, OLD.amount, OLD.unit
	);
	return OLD;
END;

Function: audit.ft_del_consumed_substance()

Returns: trigger

Language: PLPGSQL

BEGIN
	INSERT INTO audit.log_consumed_substance (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, description, atc_code
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.description, OLD.atc_code
	);
	return OLD;
END;

Function: audit.ft_del_data_source()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_data_source (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, name_long, name_short, version, description, source, lang
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.name_long, OLD.name_short, OLD.version, OLD.description, OLD.source, OLD.lang
	);
	return OLD;
END;

Function: audit.ft_del_doc_desc()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_doc_desc (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_doc, text
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_doc, OLD.text
	);
	return OLD;
END;

Function: audit.ft_del_doc_med()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_doc_med (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_encounter, fk_episode, fk_type, comment, clin_when, ext_ref, fk_org_unit, unit_is_receiver, fk_hospital_stay
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_encounter, OLD.fk_episode, OLD.fk_type, OLD.comment, OLD.clin_when, OLD.ext_ref, OLD.fk_org_unit, OLD.unit_is_receiver, OLD.fk_hospital_stay
	);
	return OLD;
END;

Function: audit.ft_del_dose()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_dose (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_substance, amount, unit, dose_unit
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_substance, OLD.amount, OLD.unit, OLD.dose_unit
	);
	return OLD;
END;

Function: audit.ft_del_drug_product()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_drug_product (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, preparation, atc_code, is_fake, fk_data_source, external_code, external_code_type
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.preparation, OLD.atc_code, OLD.is_fake, OLD.fk_data_source, OLD.external_code, OLD.external_code_type
	);
	return OLD;
END;

Function: audit.ft_del_encounter()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_encounter (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_patient, fk_type, fk_location, source_time_zone, reason_for_encounter, assessment_of_encounter, started, last_affirmed
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_patient, OLD.fk_type, OLD.fk_location, OLD.source_time_zone, OLD.reason_for_encounter, OLD.assessment_of_encounter, OLD.started, OLD.last_affirmed
	);
	return OLD;
END;

Function: audit.ft_del_episode()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_episode (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_health_issue, description, is_open, fk_encounter, diagnostic_certainty_classification, summary
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_health_issue, OLD.description, OLD.is_open, OLD.fk_encounter, OLD.diagnostic_certainty_classification, OLD.summary
	);
	return OLD;
END;

Function: audit.ft_del_external_care()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_external_care (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_encounter, fk_health_issue, issue, fk_org_unit, provider, comment, inactive
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_encounter, OLD.fk_health_issue, OLD.issue, OLD.fk_org_unit, OLD.provider, OLD.comment, OLD.inactive
	);
	return OLD;
END;

Function: audit.ft_del_family_history()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_family_history (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, fk_relation_type, age_noted, age_of_death, contributed_to_death, name_relative, dob_relative, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.fk_relation_type, OLD.age_noted, OLD.age_of_death, OLD.contributed_to_death, OLD.name_relative, OLD.dob_relative, OLD.comment
	);
	return OLD;
END;

Function: audit.ft_del_fhx_relation_type()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_fhx_relation_type (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, is_genetic
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.is_genetic
	);
	return OLD;
END;

Function: audit.ft_del_form_data()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_form_data (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_instance, fk_form_field, value
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_instance, OLD.fk_form_field, OLD.value
	);
	return OLD;
END;

Function: audit.ft_del_form_defs()

Returns: trigger

Language: PLPGSQL

BEGIN
	INSERT INTO audit.log_form_defs (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, fk_type, country, locale, soap_cat, name_short, name_long, revision, template, engine, in_use, url, is_user
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.fk_type, OLD.country, OLD.locale, OLD.soap_cat, OLD.name_short, OLD.name_long, OLD.revision, OLD.template, OLD.engine, OLD.in_use, OLD.url, OLD.is_user
	);
	return OLD;
END;

Function: audit.ft_del_form_instances()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_form_instances (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, fk_form_def, form_name
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.fk_form_def, OLD.form_name
	);
	return OLD;
END;

Function: audit.ft_del_gender_label()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_gender_label (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, tag, label, sort_weight, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.tag, OLD.label, OLD.sort_weight, OLD.comment
	);
	return OLD;
END;

Function: audit.ft_del_health_issue()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_health_issue (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, laterality, age_noted, is_active, clinically_relevant, is_confidential, is_cause_of_death, fk_encounter, grouping, diagnostic_certainty_classification, summary
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.laterality, OLD.age_noted, OLD.is_active, OLD.clinically_relevant, OLD.is_confidential, OLD.is_cause_of_death, OLD.fk_encounter, OLD.grouping, OLD.diagnostic_certainty_classification, OLD.summary
	);
	return OLD;
END;

Function: audit.ft_del_hospital_stay()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_hospital_stay (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, discharge, fk_org_unit
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.discharge, OLD.fk_org_unit
	);
	return OLD;
END;

Function: audit.ft_del_hx_family_item()

Returns: trigger

Language: PLPGSQL

BEGIN
	INSERT INTO audit.log_hx_family_item (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, fk_narrative_condition, fk_relative, name_relative, dob_relative, condition, age_noted, age_of_death, is_cause_of_death
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.fk_narrative_condition, OLD.fk_relative, OLD.name_relative, OLD.dob_relative, OLD.condition, OLD.age_noted, OLD.age_of_death, OLD.is_cause_of_death
	);
	return OLD;
END;

Function: audit.ft_del_identity()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_identity (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, deleted, gender, dob, fk_marital_status, cob, deceased, title, tob, emergency_contact, fk_emergency_contact, comment, fk_primary_provider, dob_is_estimated
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.deleted, OLD.gender, OLD.dob, OLD.fk_marital_status, OLD.cob, OLD.deceased, OLD.title, OLD.tob, OLD.emergency_contact, OLD.fk_emergency_contact, OLD.comment, OLD.fk_primary_provider, OLD.dob_is_estimated
	);
	return OLD;
END;

Function: audit.ft_del_identity_tag()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_identity_tag (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_identity, fk_tag, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_identity, OLD.fk_tag, OLD.comment
	);
	return OLD;
END;

Function: audit.ft_del_inbox_item_category()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_inbox_item_category (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, is_user
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.is_user
	);
	return OLD;
END;

Function: audit.ft_del_inbox_item_type()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_inbox_item_type (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_inbox_item_category, description, is_user
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_inbox_item_category, OLD.description, OLD.is_user
	);
	return OLD;
END;

Function: audit.ft_del_incoming_data_unmatchable()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_incoming_data_unmatchable (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_patient_candidates, request_id, firstnames, lastnames, dob, postcode, other_info, type, data, gender, requestor, external_data_id, fk_identity_disambiguated
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_patient_candidates, OLD.request_id, OLD.firstnames, OLD.lastnames, OLD.dob, OLD.postcode, OLD.other_info, OLD.type, OLD.data, OLD.gender, OLD.requestor, OLD.external_data_id, OLD.fk_identity_disambiguated
	);
	return OLD;
END;

Function: audit.ft_del_incoming_data_unmatched()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_incoming_data_unmatched (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_patient_candidates, request_id, firstnames, lastnames, dob, postcode, other_info, type, data, gender, requestor, external_data_id, fk_identity_disambiguated, comment, fk_provider_disambiguated
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_patient_candidates, OLD.request_id, OLD.firstnames, OLD.lastnames, OLD.dob, OLD.postcode, OLD.other_info, OLD.type, OLD.data, OLD.gender, OLD.requestor, OLD.external_data_id, OLD.fk_identity_disambiguated, OLD.comment, OLD.fk_provider_disambiguated
	);
	return OLD;
END;

Function: audit.ft_del_lab_request()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lab_request (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, fk_test_org, request_id, fk_requestor, lab_request_id, lab_rxd_when, results_reported_when, request_status, is_pending, diagnostic_service_section, ordered_service, note_test_org
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.fk_test_org, OLD.request_id, OLD.fk_requestor, OLD.lab_request_id, OLD.lab_rxd_when, OLD.results_reported_when, OLD.request_status, OLD.is_pending, OLD.diagnostic_service_section, OLD.ordered_service, OLD.note_test_org
	);
	return OLD;
END;

Function: audit.ft_del_lab_test_gnr()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lab_test_gnr (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, id_test
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.id_test
	);
	return OLD;
END;

Function: audit.ft_del_lnk_code2aoe()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_code2aoe (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_lnk_code2item, fk_generic_code, fk_item, code_modifier, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_lnk_code2item, OLD.fk_generic_code, OLD.fk_item, OLD.code_modifier, OLD.pk
	);
	return OLD;
END;

Function: audit.ft_del_lnk_code2episode()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_code2episode (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_lnk_code2item, fk_generic_code, fk_item, code_modifier, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_lnk_code2item, OLD.fk_generic_code, OLD.fk_item, OLD.code_modifier, OLD.pk
	);
	return OLD;
END;

Function: audit.ft_del_lnk_code2fhx()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_code2fhx (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_lnk_code2item, fk_generic_code, fk_item, code_modifier, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_lnk_code2item, OLD.fk_generic_code, OLD.fk_item, OLD.code_modifier, OLD.pk
	);
	return OLD;
END;

Function: audit.ft_del_lnk_code2h_issue()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_code2h_issue (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_lnk_code2item, fk_generic_code, fk_item, code_modifier, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_lnk_code2item, OLD.fk_generic_code, OLD.fk_item, OLD.code_modifier, OLD.pk
	);
	return OLD;
END;

Function: audit.ft_del_lnk_code2narrative()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_code2narrative (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_lnk_code2item, fk_generic_code, fk_item, code_modifier, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_lnk_code2item, OLD.fk_generic_code, OLD.fk_item, OLD.code_modifier, OLD.pk
	);
	return OLD;
END;

Function: audit.ft_del_lnk_code2procedure()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_code2procedure (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_lnk_code2item, fk_generic_code, fk_item, code_modifier, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_lnk_code2item, OLD.fk_generic_code, OLD.fk_item, OLD.code_modifier, OLD.pk
	);
	return OLD;
END;

Function: audit.ft_del_lnk_code2rfe()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_code2rfe (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_lnk_code2item, fk_generic_code, fk_item, code_modifier, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_lnk_code2item, OLD.fk_generic_code, OLD.fk_item, OLD.code_modifier, OLD.pk
	);
	return OLD;
END;

Function: audit.ft_del_lnk_code2tst_pnl()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_code2tst_pnl (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_lnk_code2item, fk_generic_code, fk_item, code_modifier, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_lnk_code2item, OLD.fk_generic_code, OLD.fk_item, OLD.code_modifier, OLD.pk
	);
	return OLD;
END;

Function: audit.ft_del_lnk_constraint2vacc_course()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_constraint2vacc_course (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_vaccination_course, fk_constraint
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_vaccination_course, OLD.fk_constraint
	);
	return OLD;
END;

Function: audit.ft_del_lnk_dose2drug()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_dose2drug (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_drug_product, fk_dose
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_drug_product, OLD.fk_dose
	);
	return OLD;
END;

Function: audit.ft_del_lnk_identity2ext_id()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_identity2ext_id (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, id_identity, external_id, fk_origin, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.id_identity, OLD.external_id, OLD.fk_origin, OLD.comment
	);
	return OLD;
END;

Function: audit.ft_del_lnk_identity2primary_doc()

Returns: trigger

Language: PLPGSQL

BEGIN
	INSERT INTO audit.log_lnk_identity2primary_doc (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_identity, fk_primary_doc
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_identity, OLD.fk_primary_doc
	);
	return OLD;
END;

Function: audit.ft_del_lnk_job2person()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_job2person (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_identity, fk_occupation, activities
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_identity, OLD.fk_occupation, OLD.activities
	);
	return OLD;
END;

Function: audit.ft_del_lnk_loinc2substance()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_loinc2substance (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_substance, loinc, max_age, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_substance, OLD.loinc, OLD.max_age, OLD.comment
	);
	return OLD;
END;

Function: audit.ft_del_lnk_loinc2test_panel()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_loinc2test_panel (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_test_panel, loinc
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_test_panel, OLD.loinc
	);
	return OLD;
END;

Function: audit.ft_del_lnk_org_unit2comm()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_org_unit2comm (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_org_unit, url, fk_type, is_confidential, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_org_unit, OLD.url, OLD.fk_type, OLD.is_confidential, OLD.comment
	);
	return OLD;
END;

Function: audit.ft_del_lnk_org_unit2ext_id()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_org_unit2ext_id (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_org_unit, external_id, fk_type, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_org_unit, OLD.external_id, OLD.fk_type, OLD.comment
	);
	return OLD;
END;

Function: audit.ft_del_lnk_pat2vaccination_course()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_pat2vaccination_course (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_patient, fk_course
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_patient, OLD.fk_course
	);
	return OLD;
END;

Function: audit.ft_del_lnk_person2relative()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_person2relative (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, id_identity, id_relative, id_relation_type, started, ended
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.id_identity, OLD.id_relative, OLD.id_relation_type, OLD.started, OLD.ended
	);
	return OLD;
END;

Function: audit.ft_del_lnk_substance2brand()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_substance2brand (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_brand, fk_substance
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_brand, OLD.fk_substance
	);
	return OLD;
END;

Function: audit.ft_del_lnk_tst2norm()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_tst2norm (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, id_test, id_norm
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.id_test, OLD.id_norm
	);
	return OLD;
END;

Function: audit.ft_del_lnk_type2item()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_type2item (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_type, fk_item
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_type, OLD.fk_item
	);
	return OLD;
END;

Function: audit.ft_del_lnk_vaccination_course2schedule()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_vaccination_course2schedule (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_course, fk_schedule
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_course, OLD.fk_schedule
	);
	return OLD;
END;

Function: audit.ft_del_lnk_vaccine2inds()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_lnk_vaccine2inds (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, fk_vaccine, fk_indication
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.fk_vaccine, OLD.fk_indication
	);
	return OLD;
END;

Function: audit.ft_del_message_inbox()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_message_inbox (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_staff, fk_inbox_item_type, comment, data, importance, fk_patient, ufk_context, due_date, expiry_date
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_staff, OLD.fk_inbox_item_type, OLD.comment, OLD.data, OLD.importance, OLD.fk_patient, OLD.ufk_context, OLD.due_date, OLD.expiry_date
	);
	return OLD;
END;

Function: audit.ft_del_occupation()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_occupation (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, name
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.name
	);
	return OLD;
END;

Function: audit.ft_del_operation()

Returns: trigger

Language: PLPGSQL

BEGIN
	INSERT INTO audit.log_operation (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, fk_health_issue, fk_encounter, clin_where, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.fk_health_issue, OLD.fk_encounter, OLD.clin_where, OLD.comment
	);
	return OLD;
END;

Function: audit.ft_del_org()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_org (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, fk_category, fk_data_source
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.fk_category, OLD.fk_data_source
	);
	return OLD;
END;

Function: audit.ft_del_org_unit()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_org_unit (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, fk_org, fk_address, fk_category
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.fk_org, OLD.fk_address, OLD.fk_category
	);
	return OLD;
END;

Function: audit.ft_del_paperwork_templates()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_paperwork_templates (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_template_type, instance_type, name_short, name_long, external_version, gnumed_revision, engine, in_use, filename, data, edit_after_substitution
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_template_type, OLD.instance_type, OLD.name_short, OLD.name_long, OLD.external_version, OLD.gnumed_revision, OLD.engine, OLD.in_use, OLD.filename, OLD.data, OLD.edit_after_substitution
	);
	return OLD;
END;

Function: audit.ft_del_patient()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_patient (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_identity, edc
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_identity, OLD.edc
	);
	return OLD;
END;

Function: audit.ft_del_prax_geb_paid()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_prax_geb_paid (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_fall, paid_amount, paid_when, paid_with
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_fall, OLD.paid_amount, OLD.paid_when, OLD.paid_with
	);
	return OLD;
END;

Function: audit.ft_del_praxis_branch()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_praxis_branch (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_org_unit
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_org_unit
	);
	return OLD;
END;

Function: audit.ft_del_procedure()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_procedure (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, fk_hospital_stay, clin_end, is_ongoing, fk_org_unit, fk_doc, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.fk_hospital_stay, OLD.clin_end, OLD.is_ongoing, OLD.fk_org_unit, OLD.fk_doc, OLD.comment
	);
	return OLD;
END;

Function: audit.ft_del_ref_source()

Returns: trigger

Language: PLPGSQL

BEGIN
	INSERT INTO audit.log_ref_source (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, name_short, name_long, version, description, source
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.name_short, OLD.name_long, OLD.version, OLD.description, OLD.source
	);
	return OLD;
END;

Function: audit.ft_del_referral()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_referral (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, id, fk_referee, fk_form
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.id, OLD.fk_referee, OLD.fk_form
	);
	return OLD;
END;

Function: audit.ft_del_region()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_region (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, code, country, name
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.code, OLD.country, OLD.name
	);
	return OLD;
END;

Function: audit.ft_del_relation_types()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_relation_types (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, inverse, biological, biol_verified, description
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.inverse, OLD.biological, OLD.biol_verified, OLD.description
	);
	return OLD;
END;

Function: audit.ft_del_report_query()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_report_query (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, label, cmd
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.label, OLD.cmd
	);
	return OLD;
END;

Function: audit.ft_del_staff()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_staff (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_identity, db_user, short_alias, comment, is_active
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_identity, OLD.db_user, OLD.short_alias, OLD.comment, OLD.is_active
	);
	return OLD;
END;

Function: audit.ft_del_staff_role()

Returns: trigger

Language: PLPGSQL

BEGIN
	INSERT INTO audit.log_staff_role (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, name, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.name, OLD.comment
	);
	return OLD;
END;

Function: audit.ft_del_street()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_street (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, id_urb, name, postcode, suburb, lat_lon
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.id_urb, OLD.name, OLD.postcode, OLD.suburb, OLD.lat_lon
	);
	return OLD;
END;

Function: audit.ft_del_substance()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_substance (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, atc, intake_instructions
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.atc, OLD.intake_instructions
	);
	return OLD;
END;

Function: audit.ft_del_substance_in_brand()

Returns: trigger

Language: PLPGSQL

BEGIN
	INSERT INTO audit.log_substance_in_brand (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, fk_brand, description, atc_code
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.fk_brand, OLD.description, OLD.atc_code
	);
	return OLD;
END;

Function: audit.ft_del_substance_intake()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_substance_intake (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, schedule, aim, duration, intake_is_approved_of, is_long_term, discontinued, discontinue_reason, fk_drug_component, comment_on_start, harmful_use_type
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.schedule, OLD.aim, OLD.duration, OLD.intake_is_approved_of, OLD.is_long_term, OLD.discontinued, OLD.discontinue_reason, OLD.fk_drug_component, OLD.comment_on_start, OLD.harmful_use_type
	);
	return OLD;
END;

Function: audit.ft_del_suppressed_hint()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_suppressed_hint (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_encounter, fk_hint, suppressed_by, suppressed_when, rationale, md5_sum
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_encounter, OLD.fk_hint, OLD.suppressed_by, OLD.suppressed_when, OLD.rationale, OLD.md5_sum
	);
	return OLD;
END;

Function: audit.ft_del_tag_image()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_tag_image (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, filename, image
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.filename, OLD.image
	);
	return OLD;
END;

Function: audit.ft_del_test_org()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_test_org (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_org_unit, fk_adm_contact, fk_med_contact, comment, contact
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_org_unit, OLD.fk_adm_contact, OLD.fk_med_contact, OLD.comment, OLD.contact
	);
	return OLD;
END;

Function: audit.ft_del_test_panel()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_test_panel (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.comment
	);
	return OLD;
END;

Function: audit.ft_del_test_result()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_test_result (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, fk_type, val_num, val_alpha, val_unit, val_normal_min, val_normal_max, val_normal_range, val_target_min, val_target_max, val_target_range, abnormality_indicator, norm_ref_group, note_test_org, material, material_detail, fk_intended_reviewer, fk_request, status, source_data, val_grouping
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.fk_type, OLD.val_num, OLD.val_alpha, OLD.val_unit, OLD.val_normal_min, OLD.val_normal_max, OLD.val_normal_range, OLD.val_target_min, OLD.val_target_max, OLD.val_target_range, OLD.abnormality_indicator, OLD.norm_ref_group, OLD.note_test_org, OLD.material, OLD.material_detail, OLD.fk_intended_reviewer, OLD.fk_request, OLD.status, OLD.source_data, OLD.val_grouping
	);
	return OLD;
END;

Function: audit.ft_del_test_type()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_test_type (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_test_org, name, comment, reference_unit, loinc, abbrev, fk_meta_test_type
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_test_org, OLD.name, OLD.comment, OLD.reference_unit, OLD.loinc, OLD.abbrev, OLD.fk_meta_test_type
	);
	return OLD;
END;

Function: audit.ft_del_urb()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_urb (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, fk_region, postcode, lat_lon, name
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.fk_region, OLD.postcode, OLD.lat_lon, OLD.name
	);
	return OLD;
END;

Function: audit.ft_del_vacc_indication()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_vacc_indication (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, description, atcs_single_indication, atcs_combi_indication
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.description, OLD.atcs_single_indication, OLD.atcs_combi_indication
	);
	return OLD;
END;

Function: audit.ft_del_vacc_route()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_vacc_route (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, abbreviation, description
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.abbreviation, OLD.description
	);
	return OLD;
END;

Function: audit.ft_del_vaccination()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_vaccination (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, fk_provider, fk_vaccine, site, batch_no, reaction
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.fk_provider, OLD.fk_vaccine, OLD.site, OLD.batch_no, OLD.reaction
	);
	return OLD;
END;

Function: audit.ft_del_vaccination_course()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_vaccination_course (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_recommended_by, fk_indication, is_active, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_recommended_by, OLD.fk_indication, OLD.is_active, OLD.comment
	);
	return OLD;
END;

Function: audit.ft_del_vaccination_course_constraint()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_vaccination_course_constraint (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description
	);
	return OLD;
END;

Function: audit.ft_del_vaccination_definition()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_vaccination_definition (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, fk_course, is_booster, seq_no, min_age_due, max_age_due, min_interval, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.fk_course, OLD.is_booster, OLD.seq_no, OLD.min_age_due, OLD.max_age_due, OLD.min_interval, OLD.comment
	);
	return OLD;
END;

Function: audit.ft_del_vaccination_schedule()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_vaccination_schedule (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, name, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.name, OLD.comment
	);
	return OLD;
END;

Function: audit.ft_del_vaccine()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_vaccine (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, id_route, is_live, min_age, max_age, comment, fk_drug_product
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.id_route, OLD.is_live, OLD.min_age, OLD.max_age, OLD.comment, OLD.fk_drug_product
	);
	return OLD;
END;

Function: audit.ft_del_vaccine_batches()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_vaccine_batches (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_vaccine, batch_no
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_vaccine, OLD.batch_no
	);
	return OLD;
END;

Function: audit.ft_del_waiting_list()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_deleter boolean;
BEGIN
	-- is the session user allowed to delete data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_deleter;
	IF _is_allowed_deleter IS FALSE THEN
		RAISE EXCEPTION
			'DELETE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return OLD;
	END IF;
	INSERT INTO audit.log_waiting_list (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_patient, registered, urgency, list_position, comment, area
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_patient, OLD.registered, OLD.urgency, OLD.list_position, OLD.comment, OLD.area
	);
	return OLD;
END;

Function: audit.ft_del_xlnk_identity()

Returns: trigger

Language: PLPGSQL

BEGIN
	INSERT INTO audit.log_xlnk_identity (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, xfk_identity, pupic, data
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.xfk_identity, OLD.pupic, OLD.data
	);
	return OLD;
END;

Function: audit.ft_ins_access_log()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_active_substance()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_address()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_allergy()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_allergy_state()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_atc_group()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_atc_substance()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_auto_hint()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_beh_fall_typ()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_behandlungsfall()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_bill()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_bill_item()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_clin_aux_note()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_clin_diag()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_clin_item_type()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_clin_medication()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_clin_narrative()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_coded_phrase()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_consumable_substance()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_consumed_substance()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_data_source()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_doc_desc()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_doc_med()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_dose()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_drug_product()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_encounter()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_episode()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_external_care()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_family_history()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_fhx_relation_type()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_form_data()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_form_defs()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_form_instances()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_gender_label()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_health_issue()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_hospital_stay()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_hx_family_item()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_identity()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_identity_tag()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_inbox_item_category()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_inbox_item_type()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_incoming_data_unmatchable()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_incoming_data_unmatched()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lab_request()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lab_test_gnr()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_code2aoe()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_code2episode()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_code2fhx()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_code2h_issue()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_code2narrative()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_code2procedure()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_code2rfe()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_code2tst_pnl()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_constraint2vacc_course()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_dose2drug()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_identity2ext_id()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_identity2primary_doc()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_job2person()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_loinc2substance()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_loinc2test_panel()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_org_unit2comm()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_org_unit2ext_id()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_pat2vaccination_course()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_person2relative()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_substance2brand()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_tst2norm()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_type2item()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_vaccination_course2schedule()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_lnk_vaccine2inds()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_message_inbox()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_occupation()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_operation()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_org()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_org_unit()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_paperwork_templates()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_patient()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_prax_geb_paid()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_praxis_branch()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_procedure()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_ref_source()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_referral()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_region()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_relation_types()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_report_query()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_staff()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_staff_role()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_street()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_substance()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_substance_in_brand()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_substance_intake()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_suppressed_hint()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_tag_image()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_test_org()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_test_panel()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_test_result()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_test_type()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_urb()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_vacc_indication()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_vacc_route()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_vaccination()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_vaccination_course()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_vaccination_course_constraint()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_vaccination_definition()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_vaccination_schedule()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_vaccine()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_vaccine_batches()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_waiting_list()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_inserter boolean;
BEGIN
	-- is the session user allowed to insert data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_inserter;
	IF _is_allowed_inserter IS FALSE THEN
		RAISE EXCEPTION
			'INSERT: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_ins_xlnk_identity()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := 0;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	return NEW;
END;

Function: audit.ft_upd_access_log()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_access_log (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, user_action
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.user_action
	);
	return NEW;
END;

Function: audit.ft_upd_active_substance()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_active_substance (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, description, atc_code
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.description, OLD.atc_code
	);
	return NEW;
END;

Function: audit.ft_upd_address()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_address (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, id_street, aux_street, number, subunit, addendum, lat_lon
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.id_street, OLD.aux_street, OLD.number, OLD.subunit, OLD.addendum, OLD.lat_lon
	);
	return NEW;
END;

Function: audit.ft_upd_allergy()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_allergy (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, substance, substance_code, generics, allergene, atc_code, fk_type, generic_specific, definite
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.substance, OLD.substance_code, OLD.generics, OLD.allergene, OLD.atc_code, OLD.fk_type, OLD.generic_specific, OLD.definite
	);
	return NEW;
END;

Function: audit.ft_upd_allergy_state()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_allergy_state (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, has_allergy, comment, last_confirmed, fk_encounter
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.has_allergy, OLD.comment, OLD.last_confirmed, OLD.fk_encounter
	);
	return NEW;
END;

Function: audit.ft_upd_atc_group()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_atc_group (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, code, description
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.code, OLD.description
	);
	return NEW;
END;

Function: audit.ft_upd_atc_substance()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_atc_substance (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, code, name, ddd_amount, fk_ddd_unit, route, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.code, OLD.name, OLD.ddd_amount, OLD.fk_ddd_unit, OLD.route, OLD.comment
	);
	return NEW;
END;

Function: audit.ft_upd_auto_hint()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_auto_hint (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, query, title, hint, url, is_active, source, lang, recommendation_query, popup_type, highlight_as_priority
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.query, OLD.title, OLD.hint, OLD.url, OLD.is_active, OLD.source, OLD.lang, OLD.recommendation_query, OLD.popup_type, OLD.highlight_as_priority
	);
	return NEW;
END;

Function: audit.ft_upd_beh_fall_typ()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_beh_fall_typ (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, code, kurzform, name
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.code, OLD.kurzform, OLD.name
	);
	return NEW;
END;

Function: audit.ft_upd_behandlungsfall()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_behandlungsfall (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_patient, fk_falltyp, started, must_pay_prax_geb
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_patient, OLD.fk_falltyp, OLD.started, OLD.must_pay_prax_geb
	);
	return NEW;
END;

Function: audit.ft_upd_bill()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_bill (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, invoice_id, close_date, apply_vat, fk_receiver_identity, fk_receiver_address, fk_doc, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.invoice_id, OLD.close_date, OLD.apply_vat, OLD.fk_receiver_identity, OLD.fk_receiver_address, OLD.fk_doc, OLD.comment
	);
	return NEW;
END;

Function: audit.ft_upd_bill_item()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_bill_item (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_provider, fk_encounter, date_to_bill, description, net_amount_per_unit, currency, status, fk_billable, fk_bill, unit_count, amount_multiplier
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_provider, OLD.fk_encounter, OLD.date_to_bill, OLD.description, OLD.net_amount_per_unit, OLD.currency, OLD.status, OLD.fk_billable, OLD.fk_bill, OLD.unit_count, OLD.amount_multiplier
	);
	return NEW;
END;

Function: audit.ft_upd_clin_aux_note()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_clin_aux_note (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk
	);
	return NEW;
END;

Function: audit.ft_upd_clin_diag()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_clin_diag (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_narrative, laterality, is_chronic, is_active, is_definite, clinically_relevant
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_narrative, OLD.laterality, OLD.is_chronic, OLD.is_active, OLD.is_definite, OLD.clinically_relevant
	);
	return NEW;
END;

Function: audit.ft_upd_clin_item_type()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_clin_item_type (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, type, code
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.type, OLD.code
	);
	return NEW;
END;

Function: audit.ft_upd_clin_medication()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_clin_medication (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, last_prescribed, fk_last_script, discontinued, brandname, generic, adjuvant, dosage_form, ufk_drug, drug_db, atc_code, is_cr, dosage, period, dosage_unit, directions, is_prn
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.last_prescribed, OLD.fk_last_script, OLD.discontinued, OLD.brandname, OLD.generic, OLD.adjuvant, OLD.dosage_form, OLD.ufk_drug, OLD.drug_db, OLD.atc_code, OLD.is_cr, OLD.dosage, OLD.period, OLD.dosage_unit, OLD.directions, OLD.is_prn
	);
	return NEW;
END;

Function: audit.ft_upd_clin_narrative()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_clin_narrative (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk
	);
	return NEW;
END;

Function: audit.ft_upd_coded_phrase()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_coded_phrase (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, term, code, xfk_coding_system
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.term, OLD.code, OLD.xfk_coding_system
	);
	return NEW;
END;

Function: audit.ft_upd_consumable_substance()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_consumable_substance (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, atc_code, amount, unit
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.atc_code, OLD.amount, OLD.unit
	);
	return NEW;
END;

Function: audit.ft_upd_consumed_substance()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_consumed_substance (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, description, atc_code
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.description, OLD.atc_code
	);
	return NEW;
END;

Function: audit.ft_upd_data_source()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_data_source (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, name_long, name_short, version, description, source, lang
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.name_long, OLD.name_short, OLD.version, OLD.description, OLD.source, OLD.lang
	);
	return NEW;
END;

Function: audit.ft_upd_doc_desc()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_doc_desc (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_doc, text
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_doc, OLD.text
	);
	return NEW;
END;

Function: audit.ft_upd_doc_med()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_doc_med (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_encounter, fk_episode, fk_type, comment, clin_when, ext_ref, fk_org_unit, unit_is_receiver, fk_hospital_stay
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_encounter, OLD.fk_episode, OLD.fk_type, OLD.comment, OLD.clin_when, OLD.ext_ref, OLD.fk_org_unit, OLD.unit_is_receiver, OLD.fk_hospital_stay
	);
	return NEW;
END;

Function: audit.ft_upd_dose()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_dose (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_substance, amount, unit, dose_unit
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_substance, OLD.amount, OLD.unit, OLD.dose_unit
	);
	return NEW;
END;

Function: audit.ft_upd_drug_product()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_drug_product (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, preparation, atc_code, is_fake, fk_data_source, external_code, external_code_type
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.preparation, OLD.atc_code, OLD.is_fake, OLD.fk_data_source, OLD.external_code, OLD.external_code_type
	);
	return NEW;
END;

Function: audit.ft_upd_encounter()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_encounter (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_patient, fk_type, fk_location, source_time_zone, reason_for_encounter, assessment_of_encounter, started, last_affirmed
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_patient, OLD.fk_type, OLD.fk_location, OLD.source_time_zone, OLD.reason_for_encounter, OLD.assessment_of_encounter, OLD.started, OLD.last_affirmed
	);
	return NEW;
END;

Function: audit.ft_upd_episode()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_episode (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_health_issue, description, is_open, fk_encounter, diagnostic_certainty_classification, summary
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_health_issue, OLD.description, OLD.is_open, OLD.fk_encounter, OLD.diagnostic_certainty_classification, OLD.summary
	);
	return NEW;
END;

Function: audit.ft_upd_external_care()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_external_care (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_encounter, fk_health_issue, issue, fk_org_unit, provider, comment, inactive
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_encounter, OLD.fk_health_issue, OLD.issue, OLD.fk_org_unit, OLD.provider, OLD.comment, OLD.inactive
	);
	return NEW;
END;

Function: audit.ft_upd_family_history()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_family_history (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, fk_relation_type, age_noted, age_of_death, contributed_to_death, name_relative, dob_relative, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.fk_relation_type, OLD.age_noted, OLD.age_of_death, OLD.contributed_to_death, OLD.name_relative, OLD.dob_relative, OLD.comment
	);
	return NEW;
END;

Function: audit.ft_upd_fhx_relation_type()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_fhx_relation_type (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, is_genetic
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.is_genetic
	);
	return NEW;
END;

Function: audit.ft_upd_form_data()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_form_data (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_instance, fk_form_field, value
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_instance, OLD.fk_form_field, OLD.value
	);
	return NEW;
END;

Function: audit.ft_upd_form_defs()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_form_defs (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, fk_type, country, locale, soap_cat, name_short, name_long, revision, template, engine, in_use, url, is_user
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.fk_type, OLD.country, OLD.locale, OLD.soap_cat, OLD.name_short, OLD.name_long, OLD.revision, OLD.template, OLD.engine, OLD.in_use, OLD.url, OLD.is_user
	);
	return NEW;
END;

Function: audit.ft_upd_form_instances()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_form_instances (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, fk_form_def, form_name
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.fk_form_def, OLD.form_name
	);
	return NEW;
END;

Function: audit.ft_upd_gender_label()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_gender_label (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, tag, label, sort_weight, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.tag, OLD.label, OLD.sort_weight, OLD.comment
	);
	return NEW;
END;

Function: audit.ft_upd_health_issue()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_health_issue (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, laterality, age_noted, is_active, clinically_relevant, is_confidential, is_cause_of_death, fk_encounter, grouping, diagnostic_certainty_classification, summary
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.laterality, OLD.age_noted, OLD.is_active, OLD.clinically_relevant, OLD.is_confidential, OLD.is_cause_of_death, OLD.fk_encounter, OLD.grouping, OLD.diagnostic_certainty_classification, OLD.summary
	);
	return NEW;
END;

Function: audit.ft_upd_hospital_stay()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_hospital_stay (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, discharge, fk_org_unit
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.discharge, OLD.fk_org_unit
	);
	return NEW;
END;

Function: audit.ft_upd_hx_family_item()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_hx_family_item (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, fk_narrative_condition, fk_relative, name_relative, dob_relative, condition, age_noted, age_of_death, is_cause_of_death
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.fk_narrative_condition, OLD.fk_relative, OLD.name_relative, OLD.dob_relative, OLD.condition, OLD.age_noted, OLD.age_of_death, OLD.is_cause_of_death
	);
	return NEW;
END;

Function: audit.ft_upd_identity()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_identity (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, deleted, gender, dob, fk_marital_status, cob, deceased, title, tob, emergency_contact, fk_emergency_contact, comment, fk_primary_provider, dob_is_estimated
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.deleted, OLD.gender, OLD.dob, OLD.fk_marital_status, OLD.cob, OLD.deceased, OLD.title, OLD.tob, OLD.emergency_contact, OLD.fk_emergency_contact, OLD.comment, OLD.fk_primary_provider, OLD.dob_is_estimated
	);
	return NEW;
END;

Function: audit.ft_upd_identity_tag()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_identity_tag (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_identity, fk_tag, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_identity, OLD.fk_tag, OLD.comment
	);
	return NEW;
END;

Function: audit.ft_upd_inbox_item_category()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_inbox_item_category (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, is_user
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.is_user
	);
	return NEW;
END;

Function: audit.ft_upd_inbox_item_type()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_inbox_item_type (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_inbox_item_category, description, is_user
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_inbox_item_category, OLD.description, OLD.is_user
	);
	return NEW;
END;

Function: audit.ft_upd_incoming_data_unmatchable()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_incoming_data_unmatchable (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_patient_candidates, request_id, firstnames, lastnames, dob, postcode, other_info, type, data, gender, requestor, external_data_id, fk_identity_disambiguated
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_patient_candidates, OLD.request_id, OLD.firstnames, OLD.lastnames, OLD.dob, OLD.postcode, OLD.other_info, OLD.type, OLD.data, OLD.gender, OLD.requestor, OLD.external_data_id, OLD.fk_identity_disambiguated
	);
	return NEW;
END;

Function: audit.ft_upd_incoming_data_unmatched()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_incoming_data_unmatched (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_patient_candidates, request_id, firstnames, lastnames, dob, postcode, other_info, type, data, gender, requestor, external_data_id, fk_identity_disambiguated, comment, fk_provider_disambiguated
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_patient_candidates, OLD.request_id, OLD.firstnames, OLD.lastnames, OLD.dob, OLD.postcode, OLD.other_info, OLD.type, OLD.data, OLD.gender, OLD.requestor, OLD.external_data_id, OLD.fk_identity_disambiguated, OLD.comment, OLD.fk_provider_disambiguated
	);
	return NEW;
END;

Function: audit.ft_upd_lab_request()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lab_request (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, fk_test_org, request_id, fk_requestor, lab_request_id, lab_rxd_when, results_reported_when, request_status, is_pending, diagnostic_service_section, ordered_service, note_test_org
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.fk_test_org, OLD.request_id, OLD.fk_requestor, OLD.lab_request_id, OLD.lab_rxd_when, OLD.results_reported_when, OLD.request_status, OLD.is_pending, OLD.diagnostic_service_section, OLD.ordered_service, OLD.note_test_org
	);
	return NEW;
END;

Function: audit.ft_upd_lab_test_gnr()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lab_test_gnr (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, id_test
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.id_test
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_code2aoe()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_code2aoe (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_lnk_code2item, fk_generic_code, fk_item, code_modifier, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_lnk_code2item, OLD.fk_generic_code, OLD.fk_item, OLD.code_modifier, OLD.pk
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_code2episode()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_code2episode (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_lnk_code2item, fk_generic_code, fk_item, code_modifier, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_lnk_code2item, OLD.fk_generic_code, OLD.fk_item, OLD.code_modifier, OLD.pk
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_code2fhx()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_code2fhx (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_lnk_code2item, fk_generic_code, fk_item, code_modifier, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_lnk_code2item, OLD.fk_generic_code, OLD.fk_item, OLD.code_modifier, OLD.pk
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_code2h_issue()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_code2h_issue (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_lnk_code2item, fk_generic_code, fk_item, code_modifier, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_lnk_code2item, OLD.fk_generic_code, OLD.fk_item, OLD.code_modifier, OLD.pk
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_code2narrative()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_code2narrative (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_lnk_code2item, fk_generic_code, fk_item, code_modifier, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_lnk_code2item, OLD.fk_generic_code, OLD.fk_item, OLD.code_modifier, OLD.pk
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_code2procedure()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_code2procedure (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_lnk_code2item, fk_generic_code, fk_item, code_modifier, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_lnk_code2item, OLD.fk_generic_code, OLD.fk_item, OLD.code_modifier, OLD.pk
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_code2rfe()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_code2rfe (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_lnk_code2item, fk_generic_code, fk_item, code_modifier, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_lnk_code2item, OLD.fk_generic_code, OLD.fk_item, OLD.code_modifier, OLD.pk
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_code2tst_pnl()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_code2tst_pnl (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_lnk_code2item, fk_generic_code, fk_item, code_modifier, pk
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_lnk_code2item, OLD.fk_generic_code, OLD.fk_item, OLD.code_modifier, OLD.pk
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_constraint2vacc_course()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_constraint2vacc_course (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_vaccination_course, fk_constraint
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_vaccination_course, OLD.fk_constraint
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_dose2drug()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_dose2drug (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_drug_product, fk_dose
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_drug_product, OLD.fk_dose
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_identity2ext_id()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_identity2ext_id (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, id_identity, external_id, fk_origin, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.id_identity, OLD.external_id, OLD.fk_origin, OLD.comment
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_identity2primary_doc()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_identity2primary_doc (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_identity, fk_primary_doc
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_identity, OLD.fk_primary_doc
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_job2person()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_job2person (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_identity, fk_occupation, activities
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_identity, OLD.fk_occupation, OLD.activities
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_loinc2substance()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_loinc2substance (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_substance, loinc, max_age, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_substance, OLD.loinc, OLD.max_age, OLD.comment
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_loinc2test_panel()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_loinc2test_panel (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_test_panel, loinc
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_test_panel, OLD.loinc
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_org_unit2comm()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_org_unit2comm (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_org_unit, url, fk_type, is_confidential, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_org_unit, OLD.url, OLD.fk_type, OLD.is_confidential, OLD.comment
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_org_unit2ext_id()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_org_unit2ext_id (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_org_unit, external_id, fk_type, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_org_unit, OLD.external_id, OLD.fk_type, OLD.comment
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_pat2vaccination_course()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_pat2vaccination_course (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_patient, fk_course
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_patient, OLD.fk_course
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_person2relative()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_person2relative (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, id_identity, id_relative, id_relation_type, started, ended
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.id_identity, OLD.id_relative, OLD.id_relation_type, OLD.started, OLD.ended
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_substance2brand()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_substance2brand (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_brand, fk_substance
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_brand, OLD.fk_substance
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_tst2norm()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_tst2norm (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, id_test, id_norm
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.id_test, OLD.id_norm
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_type2item()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_type2item (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_type, fk_item
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_type, OLD.fk_item
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_vaccination_course2schedule()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_vaccination_course2schedule (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_course, fk_schedule
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_course, OLD.fk_schedule
	);
	return NEW;
END;

Function: audit.ft_upd_lnk_vaccine2inds()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_lnk_vaccine2inds (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, fk_vaccine, fk_indication
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.fk_vaccine, OLD.fk_indication
	);
	return NEW;
END;

Function: audit.ft_upd_message_inbox()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_message_inbox (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_staff, fk_inbox_item_type, comment, data, importance, fk_patient, ufk_context, due_date, expiry_date
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_staff, OLD.fk_inbox_item_type, OLD.comment, OLD.data, OLD.importance, OLD.fk_patient, OLD.ufk_context, OLD.due_date, OLD.expiry_date
	);
	return NEW;
END;

Function: audit.ft_upd_occupation()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_occupation (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, name
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.name
	);
	return NEW;
END;

Function: audit.ft_upd_operation()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_operation (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, fk_health_issue, fk_encounter, clin_where, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.fk_health_issue, OLD.fk_encounter, OLD.clin_where, OLD.comment
	);
	return NEW;
END;

Function: audit.ft_upd_org()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_org (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, fk_category, fk_data_source
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.fk_category, OLD.fk_data_source
	);
	return NEW;
END;

Function: audit.ft_upd_org_unit()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_org_unit (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, fk_org, fk_address, fk_category
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.fk_org, OLD.fk_address, OLD.fk_category
	);
	return NEW;
END;

Function: audit.ft_upd_paperwork_templates()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_paperwork_templates (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_template_type, instance_type, name_short, name_long, external_version, gnumed_revision, engine, in_use, filename, data, edit_after_substitution
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_template_type, OLD.instance_type, OLD.name_short, OLD.name_long, OLD.external_version, OLD.gnumed_revision, OLD.engine, OLD.in_use, OLD.filename, OLD.data, OLD.edit_after_substitution
	);
	return NEW;
END;

Function: audit.ft_upd_patient()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_patient (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_identity, edc
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_identity, OLD.edc
	);
	return NEW;
END;

Function: audit.ft_upd_prax_geb_paid()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_prax_geb_paid (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_fall, paid_amount, paid_when, paid_with
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_fall, OLD.paid_amount, OLD.paid_when, OLD.paid_with
	);
	return NEW;
END;

Function: audit.ft_upd_praxis_branch()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_praxis_branch (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_org_unit
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_org_unit
	);
	return NEW;
END;

Function: audit.ft_upd_procedure()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_procedure (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, fk_hospital_stay, clin_end, is_ongoing, fk_org_unit, fk_doc, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.fk_hospital_stay, OLD.clin_end, OLD.is_ongoing, OLD.fk_org_unit, OLD.fk_doc, OLD.comment
	);
	return NEW;
END;

Function: audit.ft_upd_ref_source()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_ref_source (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, name_short, name_long, version, description, source
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.name_short, OLD.name_long, OLD.version, OLD.description, OLD.source
	);
	return NEW;
END;

Function: audit.ft_upd_referral()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_referral (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, id, fk_referee, fk_form
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.id, OLD.fk_referee, OLD.fk_form
	);
	return NEW;
END;

Function: audit.ft_upd_region()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_region (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, code, country, name
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.code, OLD.country, OLD.name
	);
	return NEW;
END;

Function: audit.ft_upd_relation_types()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_relation_types (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, inverse, biological, biol_verified, description
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.inverse, OLD.biological, OLD.biol_verified, OLD.description
	);
	return NEW;
END;

Function: audit.ft_upd_report_query()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_report_query (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, label, cmd
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.label, OLD.cmd
	);
	return NEW;
END;

Function: audit.ft_upd_staff()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_staff (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_identity, db_user, short_alias, comment, is_active
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_identity, OLD.db_user, OLD.short_alias, OLD.comment, OLD.is_active
	);
	return NEW;
END;

Function: audit.ft_upd_staff_role()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_staff_role (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, name, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.name, OLD.comment
	);
	return NEW;
END;

Function: audit.ft_upd_street()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_street (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, id_urb, name, postcode, suburb, lat_lon
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.id_urb, OLD.name, OLD.postcode, OLD.suburb, OLD.lat_lon
	);
	return NEW;
END;

Function: audit.ft_upd_substance()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_substance (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, atc, intake_instructions
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.atc, OLD.intake_instructions
	);
	return NEW;
END;

Function: audit.ft_upd_substance_in_brand()

Returns: trigger

Language: PLPGSQL

BEGIN
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_substance_in_brand (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_audit, row_version, modified_when, modified_by, pk, fk_brand, description, atc_code
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.fk_brand, OLD.description, OLD.atc_code
	);
	return NEW;
END;

Function: audit.ft_upd_substance_intake()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_substance_intake (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, schedule, aim, duration, intake_is_approved_of, is_long_term, discontinued, discontinue_reason, fk_drug_component, comment_on_start, harmful_use_type
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.schedule, OLD.aim, OLD.duration, OLD.intake_is_approved_of, OLD.is_long_term, OLD.discontinued, OLD.discontinue_reason, OLD.fk_drug_component, OLD.comment_on_start, OLD.harmful_use_type
	);
	return NEW;
END;

Function: audit.ft_upd_suppressed_hint()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_suppressed_hint (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_encounter, fk_hint, suppressed_by, suppressed_when, rationale, md5_sum
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_encounter, OLD.fk_hint, OLD.suppressed_by, OLD.suppressed_when, OLD.rationale, OLD.md5_sum
	);
	return NEW;
END;

Function: audit.ft_upd_tag_image()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_tag_image (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, filename, image
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.filename, OLD.image
	);
	return NEW;
END;

Function: audit.ft_upd_test_org()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_test_org (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_org_unit, fk_adm_contact, fk_med_contact, comment, contact
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_org_unit, OLD.fk_adm_contact, OLD.fk_med_contact, OLD.comment, OLD.contact
	);
	return NEW;
END;

Function: audit.ft_upd_test_panel()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_test_panel (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description, OLD.comment
	);
	return NEW;
END;

Function: audit.ft_upd_test_result()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_test_result (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, fk_type, val_num, val_alpha, val_unit, val_normal_min, val_normal_max, val_normal_range, val_target_min, val_target_max, val_target_range, abnormality_indicator, norm_ref_group, note_test_org, material, material_detail, fk_intended_reviewer, fk_request, status, source_data, val_grouping
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.fk_type, OLD.val_num, OLD.val_alpha, OLD.val_unit, OLD.val_normal_min, OLD.val_normal_max, OLD.val_normal_range, OLD.val_target_min, OLD.val_target_max, OLD.val_target_range, OLD.abnormality_indicator, OLD.norm_ref_group, OLD.note_test_org, OLD.material, OLD.material_detail, OLD.fk_intended_reviewer, OLD.fk_request, OLD.status, OLD.source_data, OLD.val_grouping
	);
	return NEW;
END;

Function: audit.ft_upd_test_type()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_test_type (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_test_org, name, comment, reference_unit, loinc, abbrev, fk_meta_test_type
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_test_org, OLD.name, OLD.comment, OLD.reference_unit, OLD.loinc, OLD.abbrev, OLD.fk_meta_test_type
	);
	return NEW;
END;

Function: audit.ft_upd_urb()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_urb (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, fk_region, postcode, lat_lon, name
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.fk_region, OLD.postcode, OLD.lat_lon, OLD.name
	);
	return NEW;
END;

Function: audit.ft_upd_vacc_indication()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_vacc_indication (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, description, atcs_single_indication, atcs_combi_indication
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.description, OLD.atcs_single_indication, OLD.atcs_combi_indication
	);
	return NEW;
END;

Function: audit.ft_upd_vacc_route()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_vacc_route (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		id, abbreviation, description
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.id, OLD.abbreviation, OLD.description
	);
	return NEW;
END;

Function: audit.ft_upd_vaccination()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_vaccination (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, pk, fk_provider, fk_vaccine, site, batch_no, reaction
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk_item, OLD.clin_when, OLD.fk_encounter, OLD.fk_episode, OLD.narrative, OLD.soap_cat, OLD.pk, OLD.fk_provider, OLD.fk_vaccine, OLD.site, OLD.batch_no, OLD.reaction
	);
	return NEW;
END;

Function: audit.ft_upd_vaccination_course()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_vaccination_course (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, fk_recommended_by, fk_indication, is_active, comment
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.fk_recommended_by, OLD.fk_indication, OLD.is_active, OLD.comment
	);
	return NEW;
END;

Function: audit.ft_upd_vaccination_course_constraint()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_constraint_violation'
		;
		return NEW;
	END IF;
	NEW.row_version := OLD.row_version + 1;
	NEW.modified_when := CURRENT_TIMESTAMP;
	NEW.modified_by := SESSION_USER;
	INSERT INTO audit.log_vaccination_course_constraint (
		orig_version, orig_when, orig_by, orig_tableoid, audit_action,
		pk, description
	) VALUES (
		OLD.row_version, OLD.modified_when, OLD.modified_by, TG_RELID, TG_OP,
		OLD.pk, OLD.description
	);
	return NEW;
END;

Function: audit.ft_upd_vaccination_definition()

Returns: trigger

Language: PLPGSQL

DECLARE
	_is_allowed_updater boolean;
BEGIN
	-- is the session user allowed to update data ?
	SELECT gm.account_is_dbowner_or_staff(SESSION_USER) INTO STRICT _is_allowed_updater;
	IF _is_allowed_updater IS FALSE THEN
		RAISE EXCEPTION
			'UPDATE: gm.account_is_dbowner_or_staff(NAME): <%> is neither database owner, nor <postgres>, nor on staff', SESSION_USER
			USING ERRCODE = 'integrity_const