Dumped on 2008-09-02
table for referrals to defined individuals
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,
Name | Constraint |
---|---|
referral_soap_cat_check | CHECK (((soap_cat IS NULL) OR ((((lower(soap_cat) = 's'::text) OR (lower(soap_cat) = 'o'::text)) OR (lower(soap_cat) = 'a'::text)) OR (lower(soap_cat) = 'p'::text)))) |
this table holds all the fields needed for auditing
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) |
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.
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 |
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
All tables that need standard auditing must be recorded in this table. Audit triggers will be generated automatically for all tables recorded here.
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 |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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_patient | integer | ||
has_allergy | integer |
Table audit.log_allergy_state Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 | ||
description | text |
Table audit.log_atc_group Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 | ||
name | text | ||
ddd_amount | numeric | ||
fk_ddd_unit | integer | ||
route | text | ||
comment | text |
Table audit.log_atc_substance Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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_patient | integer | ||
fk_falltyp | integer | ||
started | date | ||
must_pay_prax_geb | boolean |
Table audit.log_behandlungsfall Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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_hx_family_item | integer |
Table audit.log_clin_hx_family Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 | ||
last_prescribed | date | ||
fk_last_script | integer | ||
discontinued | date | ||
brandname | text | ||
generic | text | ||
adjuvant | text | ||
dosage_form | text | ||
ufk_drug | text | ||
drug_db | text | ||
atc_code | text | ||
is_cr | boolean | ||
dosage | numeric[] | ||
period | interval | ||
dosage_unit | text | ||
directions | text | ||
is_prn | boolean |
Table audit.log_clin_medication Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 | ||
term | text | ||
code | text | ||
xfk_coding_system | text |
Table audit.log_coded_narrative Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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_encounter | integer | ||
fk_episode | integer | ||
fk_type | integer | ||
comment | text | ||
date | timestamp with time zone | ||
ext_ref | text |
Table audit.log_doc_med Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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_patient | integer | ||
description | text | ||
is_open | boolean |
Table audit.log_episode Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 | ||
description | text | ||
laterality | character varying | ||
age_noted | interval | ||
is_active | boolean | ||
clinically_relevant | boolean | ||
is_confidential | boolean | ||
is_cause_of_death | boolean |
Table audit.log_health_issue Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 | ||
pupic | bpchar | ||
gender | text | ||
karyotype | text | ||
dob | timestamp with time zone | ||
fk_marital_status | integer | ||
cob | bpchar | ||
deceased | timestamp with time zone | ||
title | text |
Table audit.log_identity Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 |
Table audit.log_incoming_data_unmatchable Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 |
Table audit.log_incoming_data_unmatched Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 |
Table audit.log_paperwork_templates Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 | ||
ufk_context | integer | ||
data | text | ||
importance | smallint |
Table audit.log_provider_inbox Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 |
Table audit.log_ref_source Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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_role | integer | ||
db_user | name | ||
short_alias | text | ||
comment | text | ||
is_active | boolean |
Table audit.log_staff Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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_staff_role Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 | ||
code | text | ||
country | bpchar | ||
name | text |
Table audit.log_state Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 | integer | ||
fk_adm_contact | integer | ||
fk_med_contact | integer | ||
internal_name | text | ||
comment | text |
Table audit.log_test_org Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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_provider | text | ||
material | text | ||
material_detail | text | ||
fk_intended_reviewer | integer |
Table audit.log_test_result Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 | ||
code | text | ||
coding_system | text | ||
name | text | ||
comment | text | ||
conversion_unit | text |
Table audit.log_test_type Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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_state | integer | ||
postcode | text | ||
lat_lon | point | ||
name | text |
Table audit.log_urb Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 |
Table audit.log_vacc_indication Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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_patient | integer | ||
fk_provider | integer | ||
fk_vaccine | integer | ||
site | text | ||
batch_no | text |
Table audit.log_vaccination Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 | ||
trade_name | text | ||
short_name | text | ||
is_live | boolean | ||
min_age | interval | ||
max_age | interval | ||
comment | text |
Table audit.log_vaccine Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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 |
Table audit.log_waiting_list Inherits audit_trail,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
F-Key | Name | Type | Description |
---|---|---|---|
pk_audit | integer | NOT NULL DEFAULT nextval('audit.audit_trail_pk_audit_seq'::regclass) | |
orig_version | integer | NOT NULL | |
orig_when | timestamp with time zone | NOT NULL | |
orig_by | name | NOT NULL | |
orig_tableoid | oid | NOT NULL | |
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,
Name | Constraint |
---|---|
audit_trail_audit_action_check | CHECK (((audit_action = 'UPDATE'::text) OR (audit_action = 'DELETE'::text))) |
sanity-checking convenience function for marking tables for auditing, schema is always "public"
select audit.add_table_for_audit('public', $1);
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;
BEGIN INSERT INTO audit.log_address ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, 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.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.id, OLD.id_street, OLD.aux_street, OLD.number, OLD.subunit, OLD.addendum, OLD.lat_lon ); return OLD; END;
BEGIN INSERT INTO audit.log_allergy ( 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, 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_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.substance, OLD.substance_code, OLD.generics, OLD.allergene, OLD.atc_code, OLD.fk_type, OLD.generic_specific, OLD.definite ); return OLD; END;
BEGIN INSERT INTO audit.log_allergy_state ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, id, fk_patient, has_allergy ) 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.id, OLD.fk_patient, OLD.has_allergy ); return OLD; END;
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;
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;
BEGIN INSERT INTO audit.log_beh_fall_typ ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, code, kurzform, name ) 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.kurzform, OLD.name ); return OLD; END;
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;
BEGIN INSERT INTO audit.log_clin_aux_note ( 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 ) 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 ); return OLD; END;
BEGIN INSERT INTO audit.log_clin_diag ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, 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_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.fk_narrative, OLD.laterality, OLD.is_chronic, OLD.is_active, OLD.is_definite, OLD.clinically_relevant ); return OLD; END;
BEGIN INSERT INTO audit.log_clin_hx_family ( 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, fk_hx_family_item ) 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.fk_hx_family_item ); return OLD; END;
BEGIN INSERT INTO audit.log_clin_item_type ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, type, 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.type, OLD.code ); return OLD; END;
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;
BEGIN INSERT INTO audit.log_clin_narrative ( 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 ) 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 ); return OLD; END;
BEGIN INSERT INTO audit.log_coded_narrative ( 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;
BEGIN INSERT INTO audit.log_doc_desc ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_doc, text ) 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_doc, OLD.text ); return OLD; END;
BEGIN INSERT INTO audit.log_doc_med ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_identity, fk_encounter, fk_episode, fk_type, comment, date, ext_ref ) 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_identity, OLD.fk_encounter, OLD.fk_episode, OLD.fk_type, OLD.comment, OLD.date, OLD.ext_ref ); return OLD; END;
BEGIN INSERT INTO audit.log_episode ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_health_issue, fk_patient, description, is_open ) 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_patient, OLD.description, OLD.is_open ); return OLD; END;
BEGIN INSERT INTO audit.log_form_data ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_instance, fk_form_field, value ) 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_instance, OLD.fk_form_field, OLD.value ); return OLD; END;
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;
BEGIN INSERT INTO audit.log_form_instances ( 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, fk_form_def, form_name ) 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.fk_form_def, OLD.form_name ); return OLD; END;
BEGIN INSERT INTO audit.log_gender_label ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, tag, label, sort_weight, 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.tag, OLD.label, OLD.sort_weight, OLD.comment ); return OLD; END;
BEGIN INSERT INTO audit.log_health_issue ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_patient, description, laterality, age_noted, is_active, clinically_relevant, is_confidential, 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_patient, OLD.description, OLD.laterality, OLD.age_noted, OLD.is_active, OLD.clinically_relevant, OLD.is_confidential, OLD.is_cause_of_death ); return OLD; END;
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;
BEGIN INSERT INTO audit.log_identity ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, deleted, pupic, gender, karyotype, dob, fk_marital_status, cob, deceased, title ) 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.deleted, OLD.pupic, OLD.gender, OLD.karyotype, OLD.dob, OLD.fk_marital_status, OLD.cob, OLD.deceased, OLD.title ); return OLD; END;
BEGIN INSERT INTO audit.log_inbox_item_category ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, description, 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.description, OLD.is_user ); return OLD; END;
BEGIN INSERT INTO audit.log_inbox_item_type ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_inbox_item_category, description, 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_inbox_item_category, OLD.description, OLD.is_user ); return OLD; END;
BEGIN INSERT INTO audit.log_incoming_data_unmatchable ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_patient_candidates, request_id, firstnames, lastnames, dob, postcode, other_info, type, 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.fk_patient_candidates, OLD.request_id, OLD.firstnames, OLD.lastnames, OLD.dob, OLD.postcode, OLD.other_info, OLD.type, OLD.data ); return OLD; END;
BEGIN INSERT INTO audit.log_incoming_data_unmatched ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_patient_candidates, request_id, firstnames, lastnames, dob, postcode, other_info, type, 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.fk_patient_candidates, OLD.request_id, OLD.firstnames, OLD.lastnames, OLD.dob, OLD.postcode, OLD.other_info, OLD.type, OLD.data ); return OLD; END;
BEGIN INSERT INTO audit.log_lab_test_gnr ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, id, id_test ) 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.id, OLD.id_test ); return OLD; END;
BEGIN INSERT INTO audit.log_lnk_constraint2vacc_course ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_vaccination_course, fk_constraint ) 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_vaccination_course, OLD.fk_constraint ); return OLD; END;
BEGIN INSERT INTO audit.log_lnk_identity2ext_id ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, id, id_identity, external_id, fk_origin, 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.id, OLD.id_identity, OLD.external_id, OLD.fk_origin, OLD.comment ); return OLD; END;
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;
BEGIN INSERT INTO audit.log_lnk_job2person ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_identity, fk_occupation, activities ) 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_identity, OLD.fk_occupation, OLD.activities ); return OLD; END;
BEGIN INSERT INTO audit.log_lnk_pat2vaccination_course ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_patient, fk_course ) 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_patient, OLD.fk_course ); return OLD; END;
BEGIN INSERT INTO audit.log_lnk_person2relative ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, 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.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.id, OLD.id_identity, OLD.id_relative, OLD.id_relation_type, OLD.started, OLD.ended ); return OLD; END;
BEGIN INSERT INTO audit.log_lnk_tst2norm ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, id, id_test, id_norm ) 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.id, OLD.id_test, OLD.id_norm ); return OLD; END;
BEGIN INSERT INTO audit.log_lnk_type2item ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_type, fk_item ) 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.fk_item ); return OLD; END;
BEGIN INSERT INTO audit.log_lnk_vaccination_course2schedule ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_course, fk_schedule ) 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_course, OLD.fk_schedule ); return OLD; END;
BEGIN INSERT INTO audit.log_lnk_vaccine2inds ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, id, fk_vaccine, fk_indication ) 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.id, OLD.fk_vaccine, OLD.fk_indication ); return OLD; END;
BEGIN INSERT INTO audit.log_occupation ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, id, name ) 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.id, OLD.name ); return OLD; END;
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;
BEGIN INSERT INTO audit.log_paperwork_templates ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_template_type, instance_type, name_short, name_long, external_version, gnumed_revision, engine, in_use, filename, 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.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 ); return OLD; END;
BEGIN INSERT INTO audit.log_prax_geb_paid ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, 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_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.fk_fall, OLD.paid_amount, OLD.paid_when, OLD.paid_with ); return OLD; END;
BEGIN INSERT INTO audit.log_provider_inbox ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_staff, fk_inbox_item_type, comment, ufk_context, data, importance ) 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_staff, OLD.fk_inbox_item_type, OLD.comment, OLD.ufk_context, OLD.data, OLD.importance ); return OLD; END;
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;
BEGIN INSERT INTO audit.log_referral ( 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, id, fk_referee, fk_form ) 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.id, OLD.fk_referee, OLD.fk_form ); return OLD; END;
BEGIN INSERT INTO audit.log_relation_types ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, id, inverse, biological, biol_verified, 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.id, OLD.inverse, OLD.biological, OLD.biol_verified, OLD.description ); return OLD; END;
BEGIN INSERT INTO audit.log_report_query ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, label, cmd ) 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.label, OLD.cmd ); return OLD; END;
BEGIN INSERT INTO audit.log_staff ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_identity, fk_role, db_user, short_alias, comment, is_active ) 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_identity, OLD.fk_role, OLD.db_user, OLD.short_alias, OLD.comment, OLD.is_active ); return OLD; END;
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;
BEGIN INSERT INTO audit.log_state ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, id, code, country, name ) 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.id, OLD.code, OLD.country, OLD.name ); return OLD; END;
BEGIN INSERT INTO audit.log_street ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, id, id_urb, name, postcode, suburb, lat_lon ) 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.id, OLD.id_urb, OLD.name, OLD.postcode, OLD.suburb, OLD.lat_lon ); return OLD; END;
BEGIN INSERT INTO audit.log_test_org ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_org, fk_adm_contact, fk_med_contact, internal_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.fk_org, OLD.fk_adm_contact, OLD.fk_med_contact, OLD.internal_name, OLD.comment ); return OLD; END;
BEGIN INSERT INTO audit.log_test_result ( 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, 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_provider, material, material_detail, fk_intended_reviewer ) 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.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_provider, OLD.material, OLD.material_detail, OLD.fk_intended_reviewer ); return OLD; END;
BEGIN INSERT INTO audit.log_test_type ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_test_org, code, coding_system, name, comment, conversion_unit ) 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_test_org, OLD.code, OLD.coding_system, OLD.name, OLD.comment, OLD.conversion_unit ); return OLD; END;
BEGIN INSERT INTO audit.log_urb ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, id, id_state, postcode, lat_lon, name ) 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.id, OLD.id_state, OLD.postcode, OLD.lat_lon, OLD.name ); return OLD; END;
BEGIN INSERT INTO audit.log_vacc_indication ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, id, 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.id, OLD.description ); return OLD; END;
BEGIN INSERT INTO audit.log_vacc_route ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, id, abbreviation, 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.id, OLD.abbreviation, OLD.description ); return OLD; END;
BEGIN INSERT INTO audit.log_vaccination ( 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, id, fk_provider, fk_vaccine, site, batch_no ) 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.id, OLD.fk_provider, OLD.fk_vaccine, OLD.site, OLD.batch_no ); return OLD; END;
BEGIN INSERT INTO audit.log_vaccination_course ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, 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_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.fk_recommended_by, OLD.fk_indication, OLD.is_active, OLD.comment ); return OLD; END;
BEGIN INSERT INTO audit.log_vaccination_course_constraint ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, 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.description ); return OLD; END;
BEGIN INSERT INTO audit.log_vaccination_definition ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, 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.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, 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;
BEGIN INSERT INTO audit.log_vaccination_schedule ( 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;
BEGIN INSERT INTO audit.log_vaccine ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, id_route, trade_name, short_name, is_live, min_age, max_age, 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.id_route, OLD.trade_name, OLD.short_name, OLD.is_live, OLD.min_age, OLD.max_age, OLD.comment ); return OLD; END;
BEGIN INSERT INTO audit.log_vaccine_batches ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_vaccine, batch_no ) 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_vaccine, OLD.batch_no ); return OLD; END;
BEGIN INSERT INTO audit.log_waiting_list ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_patient, registered, urgency, list_position, 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_patient, OLD.registered, OLD.urgency, OLD.list_position, OLD.comment ); return OLD; END;
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;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN NEW.row_version := 0; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; return NEW; END;
BEGIN 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, pk_audit, row_version, modified_when, modified_by, 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.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.id, OLD.id_street, OLD.aux_street, OLD.number, OLD.subunit, OLD.addendum, OLD.lat_lon ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, 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_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.substance, OLD.substance_code, OLD.generics, OLD.allergene, OLD.atc_code, OLD.fk_type, OLD.generic_specific, OLD.definite ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, id, fk_patient, has_allergy ) 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.id, OLD.fk_patient, OLD.has_allergy ); return NEW; END;
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;
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;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, code, kurzform, name ) 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.kurzform, OLD.name ); return NEW; END;
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;
BEGIN 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_audit, row_version, modified_when, modified_by, 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_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 ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, 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_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.fk_narrative, OLD.laterality, OLD.is_chronic, OLD.is_active, OLD.is_definite, OLD.clinically_relevant ); return NEW; END;
BEGIN NEW.row_version := OLD.row_version + 1; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; INSERT INTO audit.log_clin_hx_family ( 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, fk_hx_family_item ) 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.fk_hx_family_item ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, type, 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.type, OLD.code ); return NEW; END;
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;
BEGIN 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_audit, row_version, modified_when, modified_by, 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_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 ); return NEW; END;
BEGIN NEW.row_version := OLD.row_version + 1; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; INSERT INTO audit.log_coded_narrative ( 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;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_doc, text ) 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_doc, OLD.text ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_identity, fk_encounter, fk_episode, fk_type, comment, date, ext_ref ) 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_identity, OLD.fk_encounter, OLD.fk_episode, OLD.fk_type, OLD.comment, OLD.date, OLD.ext_ref ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_health_issue, fk_patient, description, is_open ) 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_patient, OLD.description, OLD.is_open ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_instance, fk_form_field, value ) 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_instance, OLD.fk_form_field, OLD.value ); return NEW; END;
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;
BEGIN 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_audit, row_version, modified_when, modified_by, 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_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.fk_form_def, OLD.form_name ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, tag, label, sort_weight, 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.tag, OLD.label, OLD.sort_weight, OLD.comment ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_patient, description, laterality, age_noted, is_active, clinically_relevant, is_confidential, 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_patient, OLD.description, OLD.laterality, OLD.age_noted, OLD.is_active, OLD.clinically_relevant, OLD.is_confidential, OLD.is_cause_of_death ); return NEW; END;
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;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, deleted, pupic, gender, karyotype, dob, fk_marital_status, cob, deceased, title ) 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.deleted, OLD.pupic, OLD.gender, OLD.karyotype, OLD.dob, OLD.fk_marital_status, OLD.cob, OLD.deceased, OLD.title ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, description, 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.description, OLD.is_user ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_inbox_item_category, description, 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_inbox_item_category, OLD.description, OLD.is_user ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_patient_candidates, request_id, firstnames, lastnames, dob, postcode, other_info, type, 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.fk_patient_candidates, OLD.request_id, OLD.firstnames, OLD.lastnames, OLD.dob, OLD.postcode, OLD.other_info, OLD.type, OLD.data ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_patient_candidates, request_id, firstnames, lastnames, dob, postcode, other_info, type, 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.fk_patient_candidates, OLD.request_id, OLD.firstnames, OLD.lastnames, OLD.dob, OLD.postcode, OLD.other_info, OLD.type, OLD.data ); return NEW; END;
BEGIN 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, pk_audit, row_version, modified_when, modified_by, id, id_test ) 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.id, OLD.id_test ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_vaccination_course, fk_constraint ) 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_vaccination_course, OLD.fk_constraint ); return NEW; END;
BEGIN 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, pk_audit, row_version, modified_when, modified_by, id, id_identity, external_id, fk_origin, 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.id, OLD.id_identity, OLD.external_id, OLD.fk_origin, OLD.comment ); return NEW; END;
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;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_identity, fk_occupation, activities ) 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_identity, OLD.fk_occupation, OLD.activities ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_patient, fk_course ) 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_patient, OLD.fk_course ); return NEW; END;
BEGIN 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, pk_audit, row_version, modified_when, modified_by, 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.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.id, OLD.id_identity, OLD.id_relative, OLD.id_relation_type, OLD.started, OLD.ended ); return NEW; END;
BEGIN 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, pk_audit, row_version, modified_when, modified_by, id, id_test, id_norm ) 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.id, OLD.id_test, OLD.id_norm ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_type, fk_item ) 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.fk_item ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_course, fk_schedule ) 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_course, OLD.fk_schedule ); return NEW; END;
BEGIN 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, pk_audit, row_version, modified_when, modified_by, id, fk_vaccine, fk_indication ) 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.id, OLD.fk_vaccine, OLD.fk_indication ); return NEW; END;
BEGIN 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, pk_audit, row_version, modified_when, modified_by, id, name ) 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.id, OLD.name ); return NEW; END;
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;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_template_type, instance_type, name_short, name_long, external_version, gnumed_revision, engine, in_use, filename, 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.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 ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, 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_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.fk_fall, OLD.paid_amount, OLD.paid_when, OLD.paid_with ); return NEW; END;
BEGIN NEW.row_version := OLD.row_version + 1; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; INSERT INTO audit.log_provider_inbox ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_staff, fk_inbox_item_type, comment, ufk_context, data, importance ) 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_staff, OLD.fk_inbox_item_type, OLD.comment, OLD.ufk_context, OLD.data, OLD.importance ); return NEW; END;
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;
BEGIN 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_audit, row_version, modified_when, modified_by, 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_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.id, OLD.fk_referee, OLD.fk_form ); return NEW; END;
BEGIN 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, pk_audit, row_version, modified_when, modified_by, id, inverse, biological, biol_verified, 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.id, OLD.inverse, OLD.biological, OLD.biol_verified, OLD.description ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, label, cmd ) 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.label, OLD.cmd ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_identity, fk_role, db_user, short_alias, comment, is_active ) 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_identity, OLD.fk_role, OLD.db_user, OLD.short_alias, OLD.comment, OLD.is_active ); return NEW; END;
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;
BEGIN NEW.row_version := OLD.row_version + 1; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; INSERT INTO audit.log_state ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, id, code, country, name ) 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.id, OLD.code, OLD.country, OLD.name ); return NEW; END;
BEGIN 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, pk_audit, row_version, modified_when, modified_by, id, id_urb, name, postcode, suburb, lat_lon ) 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.id, OLD.id_urb, OLD.name, OLD.postcode, OLD.suburb, OLD.lat_lon ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_org, fk_adm_contact, fk_med_contact, internal_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.fk_org, OLD.fk_adm_contact, OLD.fk_med_contact, OLD.internal_name, OLD.comment ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, 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_provider, material, material_detail, fk_intended_reviewer ) 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.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_provider, OLD.material, OLD.material_detail, OLD.fk_intended_reviewer ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, fk_test_org, code, coding_system, name, comment, conversion_unit ) 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_test_org, OLD.code, OLD.coding_system, OLD.name, OLD.comment, OLD.conversion_unit ); return NEW; END;
BEGIN 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, pk_audit, row_version, modified_when, modified_by, id, id_state, postcode, lat_lon, name ) 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.id, OLD.id_state, OLD.postcode, OLD.lat_lon, OLD.name ); return NEW; END;
BEGIN 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, pk_audit, row_version, modified_when, modified_by, id, 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.id, OLD.description ); return NEW; END;
BEGIN 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, pk_audit, row_version, modified_when, modified_by, id, abbreviation, 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.id, OLD.abbreviation, OLD.description ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk_item, clin_when, fk_encounter, fk_episode, narrative, soap_cat, id, fk_provider, fk_vaccine, site, batch_no ) 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.id, OLD.fk_provider, OLD.fk_vaccine, OLD.site, OLD.batch_no ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, 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_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, OLD.pk, OLD.fk_recommended_by, OLD.fk_indication, OLD.is_active, OLD.comment ); return NEW; END;
BEGIN 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_audit, row_version, modified_when, modified_by, pk, 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.description ); return NEW; END;
BEGIN NEW.row_version := OLD.row_version + 1; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; INSERT INTO audit.log_vaccination_definition ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, 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.pk_audit, OLD.row_version, OLD.modified_when, OLD.modified_by, 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 NEW; END;
BEGIN NEW.row_version := OLD.row_version + 1; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; INSERT INTO audit.log_vaccination_schedule ( 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;
BEGIN NEW.row_version := OLD.row_version + 1; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; INSERT INTO audit.log_vaccine ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, id_route, trade_name, short_name, is_live, min_age, max_age, 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.id_route, OLD.trade_name, OLD.short_name, OLD.is_live, OLD.min_age, OLD.max_age, OLD.comment ); return NEW; END;
BEGIN NEW.row_version := OLD.row_version + 1; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; INSERT INTO audit.log_vaccine_batches ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_vaccine, batch_no ) 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_vaccine, OLD.batch_no ); return NEW; END;
BEGIN NEW.row_version := OLD.row_version + 1; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; INSERT INTO audit.log_waiting_list ( orig_version, orig_when, orig_by, orig_tableoid, audit_action, pk_audit, row_version, modified_when, modified_by, pk, fk_patient, registered, urgency, list_position, 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_patient, OLD.registered, OLD.urgency, OLD.list_position, OLD.comment ); return NEW; END;
BEGIN NEW.row_version := OLD.row_version + 1; NEW.modified_when := CURRENT_TIMESTAMP; NEW.modified_by := SESSION_USER; 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 NEW; END;
declare patient_pk integer; begin -- get patient ID if TG_OP = 'DELETE' then -- if no patient in episode if OLD.fk_patient is null then -- get it from attached health issue select into patient_pk fk_patient from clin.health_issue where pk = OLD.fk_health_issue; else patient_pk := OLD.fk_patient; end if; else -- if no patient in episode if NEW.fk_patient is null then -- get it from attached health issue select into patient_pk fk_patient from clin.health_issue where pk = NEW.fk_health_issue; else patient_pk := NEW.fk_patient; end if; end if; -- execute() the NOTIFY execute 'notify "episode_change_db:' || patient_pk || '"'; return NULL; end;
declare patient_pk integer; begin -- get patient ID if TG_OP = 'DELETE' then patient_pk := OLD.fk_patient; else patient_pk := NEW.fk_patient; end if; execute 'notify "health_issue_change_db:' || patient_pk || '"'; return NULL; end;
A textual description of the content such as a result summary. Several of these may belong to one document object.
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 | serial | PRIMARY KEY | |
blobs.doc_med.pk | fk_doc | integer | UNIQUE#1 |
text | text | UNIQUE#1 |
Table blobs.doc_desc Inherits audit_fields,
a medical document object possibly containing several data objects such as several pages of a paper document
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 | serial | PRIMARY KEY | |
dem.identity.pk | fk_identity | integer |
NOT NULL
the patient this document belongs to |
clin.encounter.pk | fk_encounter | integer |
NOT NULL
the encounter in which this document was entered into the system |
clin.episode.pk | fk_episode | integer |
NOT NULL
the episode this document pertains to, this may not be the only one applicable to the document (think discharge letters), see also lnk_doc_med2episode |
blobs.doc_type.pk | fk_type | integer |
NOT NULL
semantic type of document (not type of file or mime type), such as "referral letter", "discharge summary", etc. |
comment | text |
additional short comment such as "abdominal", "ward 3, Dr. Stein", etc. |
|
date | timestamp with time zone |
NOT NULL
DEFAULT now()
date of document content creation (such as exam date), NOT date of document creation or date of import; may be imprecise such as "7/99" |
|
ext_ref | text |
external reference string of physical document, original paper copy can be found with this |
Table blobs.doc_med Inherits audit_fields,
Tables referencing this one via Foreign Key Constraints:
idx_docs_by_patient fk_identitypossibly several of these form a medical document such as multiple scanned pages/images
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
blobs.doc_med.pk | fk_doc | integer | NOT NULL |
seq_idx | integer |
index of this object in the sequence of objects for this document |
|
comment | text |
optional tiny comment for this object, such as "page 1" |
|
dem.staff.pk | fk_intended_reviewer | integer |
NOT NULL
who is *supposed* to review this item |
data | bytea |
NOT NULL
actual binary object data; here is why we use bytea: == -------------------------------------------------- To: leon@oss.minimetria.com Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Recommendation on bytea or blob for binary data like images Date: Fri, 02 Sep 2005 16:33:09 -0400 Message-ID: <17794.1125693189@sss.pgh.pa.us> From: Tom Lane <tgl@sss.pgh.pa.us> List-Archive: <http://archives.postgresql.org/pgsql-sql> List-Help: <mailto:majordomo@postgresql.org?body=help> List-ID: <pgsql-sql.postgresql.org> leon@oss.minimetria.com writes: > Hi, I"d like to know what the official recommendation is on which binary > datatype to use for common small-binary size use. If bytea will work for you, it"s definitely the thing to use. The only real drawback to bytea is that there"s currently no API to read and write bytea values in a streaming fashion. If your objects are small enough that you can load and store them as units, bytea is fine. BLOBs, on the other hand, have a number of drawbacks --- hard to dump, impossible to secure, etc. regards, tom lane == -------------------------------------------------- |
|
filename | text |
the filename from when the data was imported - if any, can be NULL, useful for re-export since legacy devices/applications might expect particular file names and not use mime types for file detection |
Name | Constraint |
---|---|
doc_obj_filename_check | CHECK ((btrim(COALESCE(filename, 'NULL'::text)) <> ''::text)) |
Tables referencing this one via Foreign Key Constraints:
this table enumerates the document types known to the system
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
name | text |
UNIQUE
NOT NULL
the name/label of the document type |
Tables referencing this one via Foreign Key Constraints:
this allows linking documents to episodes, each document can apply to several episodes but only once each
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 | serial | PRIMARY KEY | |
clin.episode.pk | fk_episode | integer | UNIQUE#1 NOT NULL |
blobs.doc_med.pk | fk_doc_med | integer | UNIQUE#1 NOT NULL |
Table blobs.lnk_doc_med2episode Inherits audit_fields,
review table for documents (per object such as a page)
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 | integer | PRIMARY KEY DEFAULT nextval('clin.review_root_pk_seq'::regclass) | |
blobs.doc_obj.pk | fk_reviewed_row | integer | UNIQUE#1 NOT NULL |
fk_reviewer | integer | UNIQUE#1 NOT NULL | |
is_technically_abnormal | boolean | NOT NULL | |
clinically_relevant | boolean | NOT NULL | |
comment | text |
Table blobs.reviewed_doc_objs Inherits review_root,
aggregates some data document descriptions
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
pk_doc | integer | ||
description | text | ||
pk_encounter | integer | ||
pk_episode | integer | ||
pk_health_issue | integer | ||
pk_doc_desc | integer |
SELECT vdm.pk_patient , dd.fk_doc AS pk_doc , dd.text AS description , vdm.pk_encounter , vdm.pk_episode , vdm.pk_health_issue , dd.pk AS pk_doc_desc FROM blobs.doc_desc dd , blobs.v_doc_med vdm WHERE (dd.fk_doc = vdm.pk_doc);
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
pk_doc | integer | ||
date | timestamp with time zone | ||
type | text | ||
l10n_type | text | ||
ext_ref | text | ||
episode | text | ||
comment | text | ||
episode_open | boolean | ||
pk_type | integer | ||
pk_encounter | integer | ||
pk_episode | integer | ||
pk_health_issue | integer | ||
modified_when | timestamp with time zone | ||
modified_by | name | ||
xmin_doc_med | xid |
SELECT dm.fk_identity AS pk_patient , dm.pk AS pk_doc , dm.date , vdt."type" , vdt.l10n_type , dm.ext_ref , cle.description AS episode , dm."comment" , cle.is_open AS episode_open , dm.fk_type AS pk_type , dm.fk_encounter AS pk_encounter , dm.fk_episode AS pk_episode , cle.fk_health_issue AS pk_health_issue , dm.modified_when , dm.modified_by , dm.xmin AS xmin_doc_med FROM blobs.doc_med dm , blobs.v_doc_type vdt , clin.episode cle WHERE ( (vdt.pk_doc_type = dm.fk_type) AND (cle.pk = dm.fk_episode) );
list active document types, those that are activated for use
F-Key | Name | Type | Description |
---|---|---|---|
pk_doc_type | integer | ||
type | text | ||
l10n_type | text | ||
is_user_defined | boolean | ||
is_in_use | boolean | ||
xmin_doc_type | xid |
SELECT dt.pk AS pk_doc_type , dt.name AS "type" , _ (dt.name) AS l10n_type , (NOT (EXISTS ( SELECT 1 FROM ref.document_type WHERE (document_type.description = dt.name) ) ) ) AS is_user_defined , (EXISTS ( SELECT 1 FROM blobs.doc_med WHERE (doc_med.fk_type = dt.pk) ) ) AS is_in_use , dt.xmin AS xmin_doc_type FROM blobs.doc_type dt;
shows the latest picture of the patient, currently the highest seq_idx of the newest document of type "patient photograph"
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
doc_comment | text | ||
date_taken | timestamp with time zone | ||
ext_ref | text | ||
obj_seq_idx | integer | ||
obj_comment | text | ||
pk_doc | integer | ||
pk_obj | integer | ||
image | bytea |
SELECT vo4d.pk_patient , vo4d.doc_comment , vo4d.date_generated AS date_taken , vo4d.ext_ref , vo4d.seq_idx AS obj_seq_idx , vo4d.obj_comment , vo4d.pk_doc , vo4d.pk_obj , bdo.data AS image FROM blobs.v_obj4doc_no_data vo4d , blobs.doc_obj bdo WHERE ( ( (vo4d."type" = 'patient photograph'::text) AND (vo4d.seq_idx = ( SELECT max (vo4d1.seq_idx) AS max FROM blobs.v_obj4doc_no_data vo4d1 WHERE ( (vo4d1.pk_patient = vo4d.pk_patient) AND (vo4d1."type" = 'patient photograph'::text) ) GROUP BY vo4d1.date_generated ORDER BY vo4d1.date_generated DESC LIMIT 1 ) ) ) AND (bdo.pk = vo4d.pk_obj) );
denormalized metadata for blobs.doc_obj but without the data itself
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
pk_obj | integer | ||
seq_idx | integer | ||
size | integer | ||
date_generated | timestamp with time zone | ||
type | text | ||
l10n_type | text | ||
ext_ref | text | ||
episode | text | ||
doc_comment | text | ||
obj_comment | text | ||
filename | text | ||
pk_intended_reviewer | integer | ||
reviewed | boolean | ||
reviewed_by_you | boolean | ||
reviewed_by_intended_reviewer | boolean | ||
pk_doc | integer | ||
pk_type | integer | ||
pk_encounter | integer | ||
pk_episode | integer | ||
pk_health_issue | integer | ||
xmin_doc_obj | xid |
SELECT vdm.pk_patient , dobj.pk AS pk_obj , dobj.seq_idx , octet_length (COALESCE (dobj.data ,''::bytea ) ) AS size , vdm.date AS date_generated , vdm."type" , vdm.l10n_type , vdm.ext_ref , vdm.episode , vdm."comment" AS doc_comment , dobj."comment" AS obj_comment , dobj.filename , dobj.fk_intended_reviewer AS pk_intended_reviewer , (EXISTS ( SELECT 1 FROM blobs.reviewed_doc_objs WHERE (reviewed_doc_objs.fk_reviewed_row = dobj.pk) ) ) AS reviewed , (EXISTS ( SELECT 1 FROM blobs.reviewed_doc_objs WHERE ( (reviewed_doc_objs.fk_reviewed_row = dobj.pk) AND (reviewed_doc_objs.fk_reviewer = ( SELECT staff.pk FROM dem.staff WHERE (staff.db_user = "current_user" () ) ) ) ) ) ) AS reviewed_by_you , (EXISTS ( SELECT 1 FROM blobs.reviewed_doc_objs WHERE ( (reviewed_doc_objs.fk_reviewed_row = dobj.pk) AND (reviewed_doc_objs.fk_reviewer = dobj.fk_intended_reviewer) ) ) ) AS reviewed_by_intended_reviewer , vdm.pk_doc , vdm.pk_type , vdm.pk_encounter , vdm.pk_episode , vdm.pk_health_issue , dobj.xmin AS xmin_doc_obj FROM blobs.v_doc_med vdm , blobs.doc_obj dobj WHERE (vdm.pk_doc = dobj.fk_doc);
F-Key | Name | Type | Description |
---|---|---|---|
pk_doc_obj | integer | ||
reviewer | text | ||
is_technically_abnormal | boolean | ||
clinically_relevant | boolean | ||
is_review_by_responsible_reviewer | boolean | ||
is_your_review | boolean | ||
comment | text | ||
reviewed_when | timestamp with time zone | ||
modified_by | name | ||
pk_review_root | integer | ||
pk_reviewer | integer | ||
pk_patient | integer | ||
pk_encounter | integer | ||
pk_episode | integer | ||
pk_health_issue | integer |
SELECT rdo.fk_reviewed_row AS pk_doc_obj , COALESCE ( ( SELECT staff.short_alias FROM dem.staff WHERE (staff.pk = rdo.fk_reviewer) ) , ( ('<#'::text || (rdo.fk_reviewer)::text ) || '>'::text ) ) AS reviewer , rdo.is_technically_abnormal , rdo.clinically_relevant , (EXISTS ( SELECT 1 FROM blobs.doc_obj WHERE ( (doc_obj.pk = rdo.fk_reviewed_row) AND (doc_obj.fk_intended_reviewer = rdo.fk_reviewer) ) ) ) AS is_review_by_responsible_reviewer , (EXISTS ( SELECT 1 FROM dem.staff WHERE ( (staff.pk = rdo.fk_reviewer) AND (staff.db_user = "current_user" () ) ) ) ) AS is_your_review , rdo."comment" , rdo.modified_when AS reviewed_when , rdo.modified_by , rdo.pk AS pk_review_root , rdo.fk_reviewer AS pk_reviewer , ( SELECT v_obj4doc_no_data.pk_patient FROM blobs.v_obj4doc_no_data WHERE (v_obj4doc_no_data.pk_obj = rdo.fk_reviewed_row) ) AS pk_patient , ( SELECT v_obj4doc_no_data.pk_encounter FROM blobs.v_obj4doc_no_data WHERE (v_obj4doc_no_data.pk_obj = rdo.fk_reviewed_row) ) AS pk_encounter , ( SELECT v_obj4doc_no_data.pk_episode FROM blobs.v_obj4doc_no_data WHERE (v_obj4doc_no_data.pk_obj = rdo.fk_reviewed_row) ) AS pk_episode , ( SELECT v_obj4doc_no_data.pk_health_issue FROM blobs.v_obj4doc_no_data WHERE (v_obj4doc_no_data.pk_obj = rdo.fk_reviewed_row) ) AS pk_health_issue FROM blobs.reviewed_doc_objs rdo;
DECLARE _pk_doc alias for $1; _pk_encounter alias for $2; _del_note text; _doc_row record; _obj_row record; tmp text; BEGIN select * into _doc_row from blobs.doc_med where pk = _pk_doc; _del_note := _('Deletion of document') || E': ' || ' ' || to_char(_doc_row.date, 'YYYY-MM-DD HH24:MI') || ' "' || (select _(dt.name) from blobs.doc_type dt where pk = _doc_row.fk_type) || '"' || coalesce(' (' || _doc_row.ext_ref || ')', '') || coalesce(E' ' || _doc_row.comment, '') ; FOR _obj_row IN select * from blobs.doc_obj where fk_doc = _pk_doc order by seq_idx LOOP _del_note := _del_note || E' ' || ' #' || coalesce(_obj_row.seq_idx, '-1') || ': "' || coalesce(_obj_row.comment, '') || E'" ' || ' ' || coalesce(_obj_row.filename, '') || E' '; end LOOP; insert into clin.clin_narrative (fk_encounter, fk_episode, narrative, soap_cat) values ( _pk_encounter, _doc_row.fk_episode, _del_note, NULL ); delete from blobs.doc_med where pk = _pk_doc; return True; END;
declare _pk_identity integer; begin _pk_identity := NULL; -- retrieve identity PK via fk_identity if TG_OP = 'DELETE' then _pk_identity := OLD.fk_identity; else _pk_identity := NEW.fk_identity; end if; -- soft error out if not found if _pk_identity is NULL then raise notice 'blobs.trf_announce_doc_mod(): cannot determine identity PK on table <blobs.doc_med>'; return NULL; end if; -- now, execute() the NOTIFY execute 'notify "doc_mod_db:' || _pk_identity || '"'; return NULL; end;
declare _pk_identity integer; begin _pk_identity := NULL; -- retrieve identity PK via fk_doc if TG_OP = 'DELETE' then select into _pk_identity fk_identity from blobs.doc_med where pk = OLD.fk_doc limit 1; else select into _pk_identity fk_identity from blobs.doc_med where pk = NEW.fk_doc limit 1; end if; -- soft error out if not found if _pk_identity is NULL then raise notice 'blobs.trf_announce_doc_page_mod(): cannot determine identity PK on table <blobs.doc_obj>'; return NULL; end if; -- now, execute() the NOTIFY execute 'notify "doc_page_mod_db:' || _pk_identity || '"'; return NULL; end;
This trigger function is called before a lnk_doc_med2episode row is inserted or updated. It makes sure the episode does not duplicate the primary episode for this document listed in doc_med. If it does the insert/update is skipped.
BEGIN -- if already in doc_med perform 1 from blobs.doc_med dm where dm.fk_episode = NEW.fk_episode and dm.pk = NEW.fk_doc_med; if FOUND then -- skip the insert/update return null; end if; return NEW; END;
BEGIN if (NEW.data != OLD.data) or ((NEW.data != OLD.data) is NULL) then delete from blobs.reviewed_doc_objs where fk_reviewed_row = OLD.pk; end if; return NEW; END;
This trigger function is called when a doc_med row is inserted or updated. It makes sure the primary episode listed in doc_med is not duplicated in lnk_doc_med2episode for the same document. If it exists in the latter it is removed from there.
BEGIN -- if update if TG_OP = 'UPDATE' then -- and no change if NEW.fk_episode = OLD.fk_episode then -- then do nothing return NEW; end if; end if; -- if already in link table perform 1 from blobs.lnk_doc_med2episode ldm2e where ldm2e.fk_episode = NEW.fk_episode and ldm2e.fk_doc_med = NEW.pk; if FOUND then -- delete from link table delete from blobs.lnk_doc_med2episode where fk_episode = NEW.fk_episode and fk_doc_med = NEW.pk; end if; return NEW; END;
declare msg text; begin if NEW.seq_idx is NULL then return NEW; end if; perform 1 from blobs.doc_obj where pk <> NEW.pk and fk_doc = NEW.fk_doc and seq_idx = NEW.seq_idx; if FOUND then msg := '[blobs.trf_verify_page_number]: uniqueness violation: seq_idx [' || NEW.seq_idx || '] already exists for fk_doc [' || NEW.fk_doc || ']'; raise exception '%', msg; end if; return NEW; end;
This schema holds all the configuration data.
stores opaque configuration data, either text or binary, note that it will be difficult to share such options among different types of clients
F-Key | Name | Type | Description |
---|---|---|---|
cfg.cfg_item.pk | fk_item | integer | NOT NULL |
value | bytea | NOT NULL |
this table holds all "instances" of cfg.cfg_template
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
cfg.cfg_template.pk | fk_template | integer |
UNIQUE#1
NOT NULL
this points to the class of this option, think of this as a base object, this also defines the data type |
owner | name |
UNIQUE#1
NOT NULL
DEFAULT "current_user"()
the database level user this option belongs to; this is the "role" of the user from the perspective of the database; can be "default" at the application level to indicate that it does not care |
|
workplace | text |
UNIQUE#1
- the logical workplace this option pertains to - can be a hostname but should be a logical rather than a physical identifier as machines get moved, workplaces do not, kind of like a "role" for the machine - associate this with a physical workplace through a local config file or environment variable |
|
cookie | text |
UNIQUE#1
an arbitrary, opaque entity the client code can use to associate this config item with even finer grained context; could be the pertinent patient ID for patient specific options |
Tables referencing this one via Foreign Key Constraints:
F-Key | Name | Type | Description |
---|---|---|---|
cfg.cfg_item.pk | fk_item | integer | NOT NULL |
value | numeric | NOT NULL |
F-Key | Name | Type | Description |
---|---|---|---|
cfg.cfg_item.pk | fk_item | integer | NOT NULL |
value | text[] | NOT NULL |
F-Key | Name | Type | Description |
---|---|---|---|
cfg.cfg_item.pk | fk_item | integer | NOT NULL |
value | text | NOT NULL |
meta definition of config items
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
name | text |
NOT NULL
DEFAULT 'must set this !'::text
the name of the option; this MUST be set to something meaningful |
|
cfg.cfg_type_enum.name | type | text |
NOT NULL
type of the value |
cfg_group | text |
NOT NULL
DEFAULT 'xxxDEFAULTxxx'::text
just for logical grouping of options according to task sets to facilitate better config management |
|
description | text |
NOT NULL
DEFAULT 'programmer is an avid Camel Book Reader'::text
arbitrary description (user visible) |
Tables referencing this one via Foreign Key Constraints:
enumeration of config option data types
F-Key | Name | Type | Description |
---|---|---|---|
name | text | UNIQUE NOT NULL |
Tables referencing this one via Foreign Key Constraints:
maps a service name to a database location for a particular user, includes user credentials for that database
F-Key | Name | Type | Description |
---|---|---|---|
id | serial | PRIMARY KEY | |
profile | character(25) |
DEFAULT 'default'::bpchar
allows multiple profiles per user/ pseudo user, one user may have different configuration profiles depending on role, need and location |
|
username | character(25) |
DEFAULT "current_user"()
user name as used within the GNUmed system |
|
ddb | integer |
which GNUmed service are we mapping to a database here |
|
db | integer |
how to reach the database host for this service |
|
crypt_pwd | text |
password for user and database, encrypted |
|
crypt_algo | text |
encryption algorithm used for password encryption |
|
pwd_hash | text |
hash of the unencrypted password |
|
hash_algo | text |
algorithm used for password hashing |
Stores a banner to show when clients log on.
F-Key | Name | Type | Description |
---|---|---|---|
message | text |
The actual message to show. |
|
singularizer | boolean |
UNIQUE
DEFAULT true
Makes sure there only ever is one such banner at any given time. |
Name | Constraint |
---|---|
db_logon_banner_message_check | CHECK ((btrim(message) <> ''::text)) |
db_logon_banner_singularizer_check | CHECK ((singularizer IS TRUE)) |
This table stores SQL commands to be used in frontend report style queries.
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 | serial | PRIMARY KEY | |
label | text | UNIQUE NOT NULL | |
cmd | text | NOT NULL |
Table cfg.report_query Inherits audit_fields,
Name | Constraint |
---|---|
report_query_cmd_check | CHECK ((btrim(COALESCE(cmd, 'NULL'::text)) <> ''::text)) |
report_query_label_check | CHECK ((btrim(COALESCE(label, 'NULL'::text)) <> ''::text)) |
F-Key | Name | Type | Description |
---|---|---|---|
option | text | ||
description | text | ||
owner | name | ||
workplace | text | ||
cookie | text | ||
type | text | ||
group | text | ||
pk_cfg_template | integer | ||
pk_cfg_item | integer |
SELECT cfg_t.name AS "option" , cfg_t.description , cfg_i."owner" , cfg_i.workplace , cfg_i.cookie , cfg_t."type" , cfg_t.cfg_group AS "group" , cfg_t.pk AS pk_cfg_template , cfg_i.pk AS pk_cfg_item FROM cfg.cfg_template cfg_t , cfg.cfg_item cfg_i WHERE (cfg_i.fk_template = cfg_t.pk);
F-Key | Name | Type | Description |
---|---|---|---|
option | text | ||
value | bytea | ||
description | text | ||
owner | name | ||
workplace | text | ||
cookie | text | ||
group | text | ||
pk_cfg_template | integer | ||
pk_cfg_item | integer |
SELECT cfg_t.name AS "option" , cfg_v.value , cfg_t.description , cfg_i."owner" , cfg_i.workplace , cfg_i.cookie , cfg_t.cfg_group AS "group" , cfg_t.pk AS pk_cfg_template , cfg_i.pk AS pk_cfg_item FROM cfg.cfg_template cfg_t , cfg.cfg_item cfg_i , cfg.cfg_data cfg_v WHERE ( (cfg_i.fk_template = cfg_t.pk) AND (cfg_v.fk_item = cfg_i.pk) );
F-Key | Name | Type | Description |
---|---|---|---|
option | text | ||
value | numeric | ||
description | text | ||
owner | name | ||
workplace | text | ||
cookie | text | ||
group | text | ||
pk_cfg_template | integer | ||
pk_cfg_item | integer |
SELECT cfg_t.name AS "option" , cfg_v.value , cfg_t.description , cfg_i."owner" , cfg_i.workplace , cfg_i.cookie , cfg_t.cfg_group AS "group" , cfg_t.pk AS pk_cfg_template , cfg_i.pk AS pk_cfg_item FROM cfg.cfg_template cfg_t , cfg.cfg_item cfg_i , cfg.cfg_numeric cfg_v WHERE ( (cfg_i.fk_template = cfg_t.pk) AND (cfg_v.fk_item = cfg_i.pk) );
F-Key | Name | Type | Description |
---|---|---|---|
option | text | ||
value | text[] | ||
description | text | ||
owner | name | ||
workplace | text | ||
cookie | text | ||
group | text | ||
pk_cfg_template | integer | ||
pk_cfg_item | integer |
SELECT cfg_t.name AS "option" , cfg_v.value , cfg_t.description , cfg_i."owner" , cfg_i.workplace , cfg_i.cookie , cfg_t.cfg_group AS "group" , cfg_t.pk AS pk_cfg_template , cfg_i.pk AS pk_cfg_item FROM cfg.cfg_template cfg_t , cfg.cfg_item cfg_i , cfg.cfg_str_array cfg_v WHERE ( (cfg_i.fk_template = cfg_t.pk) AND (cfg_v.fk_item = cfg_i.pk) );
F-Key | Name | Type | Description |
---|---|---|---|
option | text | ||
value | text | ||
description | text | ||
owner | name | ||
workplace | text | ||
cookie | text | ||
group | text | ||
pk_cfg_template | integer | ||
pk_cfg_item | integer |
SELECT cfg_t.name AS "option" , cfg_v.value , cfg_t.description , cfg_i."owner" , cfg_i.workplace , cfg_i.cookie , cfg_t.cfg_group AS "group" , cfg_t.pk AS pk_cfg_template , cfg_i.pk AS pk_cfg_item FROM cfg.cfg_template cfg_t , cfg.cfg_item cfg_i , cfg.cfg_string cfg_v WHERE ( (cfg_i.fk_template = cfg_t.pk) AND (cfg_v.fk_item = cfg_i.pk) );
declare _option alias for $1; _val_type alias for $2; _workplace alias for $3; _cookie alias for $4; _owner alias for $5; real_owner text; pk_template integer; pk_item integer; begin -- check template select into pk_template pk from cfg.cfg_template where name = _option and type = _val_type; if not FOUND then insert into cfg.cfg_template (name, type) values (_option, _val_type); select into pk_template currval('cfg.cfg_template_pk_seq'); end if; if _owner is null then select into real_owner CURRENT_USER; else real_owner := _owner; end if; -- check item if _cookie is NULL then select into pk_item pk from cfg.cfg_item where fk_template = pk_template and owner = real_owner and workplace = _workplace and cookie is null; else select into pk_item pk from cfg.cfg_item where fk_template = pk_template and owner = real_owner and workplace = _workplace and cookie = _cookie; end if; if FOUND then return pk_item; end if; insert into cfg.cfg_item ( fk_template, workplace, cookie, owner ) values ( pk_template, _workplace, _cookie, real_owner ); select into pk_item currval('cfg.cfg_item_pk_seq'); return pk_item; end;
set option, owner = NULL means CURRENT_USER
declare _option alias for $1; _value alias for $2; _workplace alias for $3; _cookie alias for $4; _owner alias for $5; val_type text; pk_item integer; rows integer; cmd text; begin -- determine data type if _value is of (text, char, varchar, name) then val_type := 'string'; elsif _value is of (smallint, integer, bigint, numeric, boolean) then val_type := 'numeric'; elsif _value is of (bytea) then val_type := 'data'; elsif _value is of (text[]) then val_type := 'str_array'; else raise exception 'cfg.set_option(text, any, text, text, text): invalid type of value'; end if; -- create template/item if need be select into pk_item cfg.create_cfg_item(_option, val_type, _workplace, _cookie, _owner); -- set item value cmd := 'select 1 from cfg.cfg_' || val_type || ' where fk_item=' || pk_item || ';'; execute cmd; get diagnostics rows = row_count; found := rows <> 0; if FOUND then if val_type = 'str_array' then cmd := 'update cfg.cfg_str_array set value=''{"' || array_to_string(_value, '","') || '"}'' where fk_item=' || pk_item || ';'; elsif val_type = 'data' then cmd := 'update cfg.cfg_data set value=''' || encode(_value, 'escape') || ''' where fk_item=' || pk_item || ';'; else cmd := 'update cfg.cfg_' || val_type || ' set value=' || quote_literal(_value) || ' where fk_item=' || pk_item || ';'; end if; execute cmd; return True; end if; if val_type = 'str_array' then cmd := 'insert into cfg.cfg_str_array(fk_item, value) values (' || pk_item || ', ''{"' || array_to_string(_value, '","') || '"}'');'; elsif val_type = 'data' then cmd := 'insert into cfg.cfg_data(fk_item, value) values (' || pk_item || ', ''' || encode(_value, 'escape') || ''');'; else cmd := 'insert into cfg.cfg_' || val_type || ' (fk_item, value) values (' || pk_item || ', ' || quote_literal(_value) || ');'; end if; execute cmd; return True; end;
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
value | text | UNIQUE NOT NULL |
Tables referencing this one via Foreign Key Constraints:
patient allergy details
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 |
used as field "reaction" |
|
soap_cat | text | DEFAULT 'o'::text | |
pk | serial | PRIMARY KEY | |
substance | text |
NOT NULL
real-world name of substance the patient reacted to, brand name if drug |
|
substance_code | text |
data source specific opaque product code; must provide a link to a unique product/substance in the database in use; should follow the parseable convention of "<source>::<source version>::<identifier>", e.g. "MIMS::2003-1::190" for Zantac; it is left as an exercise to the application to know what to do with this information |
|
generics | text |
names of generic compounds if drug; brand names change/disappear, generic names do not |
|
allergene | text |
name of allergenic ingredient in substance if known |
|
atc_code | text |
ATC code of allergene or substance if approprate, applicable for penicilline, not so for cat fur |
|
clin._enum_allergy_type.pk | fk_type | integer |
NOT NULL
allergy/sensitivity |
generic_specific | boolean |
DEFAULT false
only meaningful for *drug*/*generic* reactions: 1) true: applies to one in "generics" forming "substance", if more than one generic listed in "generics" then "allergene" *must* contain the generic in question; 2) false: applies to drug class of "substance"; |
|
definite | boolean |
DEFAULT false
true: definite, false: not definite |
Table clin.allergy Inherits clin_root_item,
Name | Constraint |
---|---|
allergy_soap_cat_check | CHECK (((soap_cat IS NULL) OR ((((lower(soap_cat) = 's'::text) OR (lower(soap_cat) = 'o'::text)) OR (lower(soap_cat) = 'a'::text)) OR (lower(soap_cat) = 'p'::text)))) |
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"() | |
id | serial | PRIMARY KEY | |
dem.identity.pk | fk_patient | integer | UNIQUE NOT NULL |
has_allergy | integer |
patient allergenic state: - null: unknown, not asked, no data available - -1: unknown, asked, no data obtained - 0: known, asked, has no known allergies - 1: known, asked, does have allergies |
Table clin.allergy_state Inherits audit_fields,
Name | Constraint |
---|---|
allergy_state_has_allergy_check | CHECK (((((has_allergy = NULL::integer) OR (has_allergy = -1)) OR (has_allergy = 0)) OR (has_allergy = 1))) |
Other tables link to this if they need more free text fields.
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 | ||
soap_cat | text | ||
pk | serial | PRIMARY KEY |
Table clin.clin_aux_note Inherits clin_root_item,
Name | Constraint |
---|---|
clin_aux_note_soap_cat_check | CHECK (((soap_cat IS NULL) OR ((((lower(soap_cat) = 's'::text) OR (lower(soap_cat) = 'o'::text)) OR (lower(soap_cat) = 'a'::text)) OR (lower(soap_cat) = 'p'::text)))) |
stores additional detail on those clin.clin_narrative rows where soap_cat=a that are true diagnoses, true diagnoses DO have a code from one of the coding systems
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 | serial | PRIMARY KEY | |
clin.clin_narrative.pk | fk_narrative | integer | UNIQUE NOT NULL |
laterality | character(1) | ||
is_chronic | boolean |
NOT NULL
DEFAULT false
whether this diagnosis is chronic, eg. no complete cure is to be expected, regardless of whether it is *active* right now (think of active/non-active phases of Multiple Sclerosis which is sure chronic) |
|
is_active | boolean |
NOT NULL
DEFAULT true
whether diagnosis is currently active or dormant |
|
is_definite | boolean | NOT NULL DEFAULT false | |
clinically_relevant | boolean |
NOT NULL
DEFAULT true
whether this diagnosis is considered clinically relevant, eg. significant; currently active diagnoses are considered to always be relevant, while inactive ones may or may not be |
Table clin.clin_diag Inherits audit_fields,
Name | Constraint |
---|---|
clin_diag_laterality_check | CHECK ((((((laterality = 'l'::bpchar) OR (laterality = 'r'::bpchar)) OR (laterality = 'b'::bpchar)) OR (laterality = '?'::bpchar)) OR (laterality IS NULL))) |
if_active_then_relevant | CHECK (((is_active = false) OR ((is_active = true) AND (clinically_relevant = true)))) |
stores family history for a given patient
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()
when the family history item became known |
|
clin.encounter.pk | fk_encounter | integer |
NOT NULL
encounter during which family history item became known |
clin.episode.pk | fk_episode | integer |
NOT NULL
episode to which family history item is of importance |
narrative | text |
how is the afflicted person related to the patient |
|
soap_cat | text |
as usual, must be NULL if fk_narrative_condition is not but this is not enforced and only done in the view |
|
pk | serial | PRIMARY KEY | |
clin.hx_family_item.pk | fk_hx_family_item | integer | NOT NULL |
Table clin.clin_hx_family Inherits clin_root_item,
Name | Constraint |
---|---|
clin_hx_family_soap_cat_check | CHECK (((soap_cat IS NULL) OR ((((lower(soap_cat) = 's'::text) OR (lower(soap_cat) = 'o'::text)) OR (lower(soap_cat) = 'a'::text)) OR (lower(soap_cat) = 'p'::text)))) |
narrative_neither_null_nor_empty | CHECK ((btrim(COALESCE(narrative, ''::text)) <> ''::text)) |
stores arbitrary types for tagging clinical items
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 | serial | PRIMARY KEY | |
type | text |
UNIQUE
NOT NULL
DEFAULT 'history'::text
the full name of the item type such as "family history" |
|
code | text |
UNIQUE
NOT NULL
DEFAULT 'Hx'::text
shorthand for the type, eg "FHx" |
Table clin.clin_item_type Inherits audit_fields,
Tables referencing this one via Foreign Key Constraints:
Representing what the patient is taking *now*, eg. a medication status (similar to vaccination status). Not a log of prescriptions. If drug was prescribed by brandname it may span several (unnamed or listed) generics. If generic substances were prescribed there would be one row per substance in this table. - forms engine will record each script and its fields - audit mechanism will record all changes to this table Note the multiple redundancy of the stored drug data. Applications should try in this order: - internal database code - brandname - ATC code - generic name(s) (in constituents)
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()
used as "started" column - when did patient start to take this medication - in many cases date of first prescription - but not always - for newly prescribed drugs identical to last_prescribed |
|
clin.encounter.pk | fk_encounter | integer | NOT NULL |
clin.episode.pk | fk_episode | integer | NOT NULL |
narrative | text |
used as "prescribed_for" column - use to specify intent beyond treating issue at hand |
|
soap_cat | text | ||
pk | serial | PRIMARY KEY | |
last_prescribed | date |
NOT NULL
DEFAULT ('now'::text)::date
date last script written for this medication |
|
clin.form_instances.pk | fk_last_script | integer |
link to the most recent script by which this drug was prescribed |
discontinued | date |
date at which medication was *discontinued*, note that the date when a script *expires* should be calculatable |
|
brandname | text |
the brand name of this drug under which it is marketed by the manufacturer |
|
generic | text |
the generic name of the active substance |
|
adjuvant | text |
free text describing adjuvants, such as "orange-flavoured" etc. |
|
dosage_form | text |
NOT NULL
the form the drug is delivered in, eg liquid, cream, table, etc. |
|
ufk_drug | text |
NOT NULL
the identifier for this drug in the source database, may or may not be an opaque value as regards GnuMed |
|
drug_db | text |
NOT NULL
the drug database used to populate this entry |
|
atc_code | text |
NOT NULL
the Anatomic Therapeutic Chemical code for this drug, used to compute possible substitutes |
|
is_cr | boolean |
NOT NULL
Controlled Release. Some drugs are marketed under the same name although one is slow release while the other is normal release. |
|
dosage | numeric[] |
NOT NULL
an array of doses describing how the drug is taken over the dosing cycle, for example: - 2 mane 2.5 nocte would be [2, 2.5], period="24 hours" - 2 one and 2.5 the next would be [2, 2.5], period="2 days" - once a week would be [1] with period="1 week" |
|
period | interval |
NOT NULL
the length of the dosing cycle, in hours |
|
dosage_unit | text |
NOT NULL
the unit the dosages are measured in, "each" for discrete objects like tablets |
|
directions | text |
free text for patient/pharmacist directions, such as "with food" etc |
|
is_prn | boolean |
DEFAULT false
true if "pro re nata" (= as required) |
Table clin.clin_medication Inherits clin_root_item,
Name | Constraint |
---|---|
brand_or_generic_required | CHECK (((brandname IS NOT NULL) OR (generic IS NOT NULL))) |
clin_medication_dosage_unit_check | CHECK ((((dosage_unit = 'g'::text) OR (dosage_unit = 'each'::text)) OR (dosage_unit = 'ml'::text))) |
clin_medication_soap_cat_check | CHECK (((soap_cat IS NULL) OR ((((lower(soap_cat) = 's'::text) OR (lower(soap_cat) = 'o'::text)) OR (lower(soap_cat) = 'a'::text)) OR (lower(soap_cat) = 'p'::text)))) |
discontinued_after_prescribed | CHECK ((discontinued >= last_prescribed)) |
medication_is_plan | CHECK ((soap_cat = 'p'::text)) |
prescribed_after_started | CHECK ((last_prescribed >= (clin_when)::date)) |
Used to store clinical free text *not* associated with any other table. Used to implement a simple SOAP structure. Also other tags can be associated via link tables.
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()
when did the item reach clinical reality |
|
clin.encounter.pk | fk_encounter | integer | NOT NULL |
clin.episode.pk | fk_episode | integer | NOT NULL |
narrative | text | ||
soap_cat | text | ||
pk | serial | PRIMARY KEY |
Table clin.clin_narrative Inherits clin_root_item,
Name | Constraint |
---|---|
clin_narrative_soap_cat_check | CHECK (((soap_cat IS NULL) OR ((((lower(soap_cat) = 's'::text) OR (lower(soap_cat) = 'o'::text)) OR (lower(soap_cat) = 'a'::text)) OR (lower(soap_cat) = 'p'::text)))) |
narrative_neither_null_nor_empty | CHECK ((btrim(COALESCE(narrative, ''::text)) <> ''::text)) |
Tables referencing this one via Foreign Key Constraints:
idx_clnarr_encounter fk_encounter idx_clnarr_episode fk_episode idx_narr_soap soap_cat) WHERE ((((lower(soap_cat) = 's'::text) OR (lower(soap_cat) = 'o'::text)) OR (lower(soap_cat) = 'a'::text)) OR (lower(soap_cat) = 'p'::text) idx_narrative_modified_by modified_byancestor table for clinical items of any kind, basic unit of clinical information, do *not* store data in here directly, use child tables, contains all the clinical narrative aggregated for full text search, ancestor for all tables that want to store clinical free text
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 | serial |
PRIMARY KEY
the primary key, not named "id" or "pk" as usual since child tables will have "id"/"pk"-named primary keys already and we would get duplicate columns while inheriting from this table |
|
clin_when | timestamp with time zone |
NOT NULL
DEFAULT now()
when this clinical item became known, can be different from when it was entered into the system (= audit.audit_fields.modified_when) |
|
clin.encounter.pk | fk_encounter | integer |
NOT NULL
the encounter this item belongs to |
clin.episode.pk | fk_episode | integer |
NOT NULL
the episode this item belongs to |
narrative | text |
each clinical item by default inherits a free text field for clinical narrative |
|
soap_cat | text |
each clinical item must be either one of the S, O, A, P categories or NULL to indicate a non-clinical item |
Table clin.clin_root_item Inherits audit_fields,
Name | Constraint |
---|---|
clin_root_item_soap_cat_check | CHECK (((soap_cat IS NULL) OR ((((lower(soap_cat) = 's'::text) OR (lower(soap_cat) = 'o'::text)) OR (lower(soap_cat) = 'a'::text)) OR (lower(soap_cat) = 'p'::text)))) |
associates codes with text snippets which may be in use in clinical tables
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 | serial | PRIMARY KEY | |
term | text |
UNIQUE#1
NOT NULL
the text snippet that is to be coded |
|
code | text |
UNIQUE#1
NOT NULL
the code in the coding system |
|
xfk_coding_system | text |
UNIQUE#1
NOT NULL
the coding system used to code the text snippet |
Table clin.coded_narrative Inherits audit_fields,
Name | Constraint |
---|---|
coded_narrative_code_check | CHECK ((btrim(code) <> ''::text)) |
coded_narrative_code_check1 | CHECK ((btrim(code) <> ''::text)) |
coded_narrative_term_check | CHECK ((btrim(term) <> ''::text)) |
a clinical encounter between a person and the health care system
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 | serial | PRIMARY KEY | |
dem.identity.pk | fk_patient | integer |
NOT NULL
PK of subject of care, should be PUPIC, actually |
clin.encounter_type.pk | fk_type | integer |
NOT NULL
DEFAULT 1
PK of type of this encounter |
fk_location | integer |
PK of location *of care*, e.g. where the provider is at |
|
source_time_zone | interval |
time zone of location, used to approximate source time zone for all timestamps in this encounter |
|
reason_for_encounter | text |
the RFE for the encounter as related by either the patient or the provider (say, in a chart review) |
|
assessment_of_encounter | text |
the Assessment of Encounter (eg consultation summary) as determined by the provider, may simply be a concatenation of soAp narrative, this assessment should go across all problems |
|
started | timestamp with time zone | NOT NULL DEFAULT now() | |
last_affirmed | timestamp with time zone | NOT NULL DEFAULT now() |
Table clin.encounter Inherits audit_fields,
Name | Constraint |
---|---|
encounter_assessment_of_encounter_check | CHECK ((btrim(COALESCE(assessment_of_encounter, 'xxxDEFAULTxxx'::text)) <> ''::text)) |
encounter_reason_for_encounter_check | CHECK ((btrim(COALESCE(reason_for_encounter, 'xxxDEFAULTxxx'::text)) <> ''::text)) |
Tables referencing this one via Foreign Key Constraints:
idx_encounter_affirmed last_affirmed idx_encounter_modified_by modified_by idx_encounter_started started idx_pat_per_encounter fk_patientthese are the types of encounter
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
description | text | UNIQUE NOT NULL |
Tables referencing this one via Foreign Key Constraints:
Clinical episodes such as "Otitis media", "traffic accident 7/99", "Hepatitis B". This covers a range of time in which activity of illness was noted for the problem episode.description.
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 | serial | PRIMARY KEY | |
clin.health_issue.pk | fk_health_issue | integer |
health issue this episode belongs to |
dem.identity.pk | fk_patient | integer |
NOT NULL
patient this episode belongs to, may only be set if fk_health_issue is Null thereby removing redundancy |
description | text |
NOT NULL
description/name of this episode |
|
is_open | boolean |
DEFAULT true
whether the episode is open (eg. there is activity for it), means open in a temporal sense as in "not closed yet"; only one episode can be open per health issue |
Table clin.episode Inherits audit_fields,
Name | Constraint |
---|---|
episode_description_check | CHECK ((btrim(description) <> ''::text)) |
Tables referencing this one via Foreign Key Constraints:
idx_episode_issue fk_health_issue idx_episode_modified_by modified_by idx_episode_with_issue fk_health_issue) WHERE (fk_health_issue IS NOT NULL idx_episode_without_issue fk_health_issue) WHERE (fk_health_issue IS NULLholds the values used in form instances, for later re-use/validation
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 | serial | PRIMARY KEY | |
clin.form_instances.pk | fk_instance | integer |
UNIQUE#1
NOT NULL
the form instance this value was used in |
public.form_fields.pk | fk_form_field | integer |
UNIQUE#1
NOT NULL
points to the definition of the field in the form which in turn defines the place holder in the template to replace with <value> |
value | text |
NOT NULL
the value to replace the place holder with |
Table clin.form_data Inherits audit_fields,
instances of forms, like a log of all processed forms
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 |
can be used as a status field, eg. "printed", "faxed" etc. |
|
soap_cat | text | ||
pk | serial | PRIMARY KEY | |
ref.paperwork_templates.pk | fk_form_def | integer |
NOT NULL
points to the definition of this instance, this FK will fail once we start separating services, make it into a x_db_fk then |
form_name | text |
NOT NULL
a string uniquely identifying the form template, necessary for the audit trail |
Table clin.form_instances Inherits clin_root_item,
Name | Constraint |
---|---|
form_instances_soap_cat_check | CHECK (((soap_cat IS NULL) OR ((((lower(soap_cat) = 's'::text) OR (lower(soap_cat) = 'o'::text)) OR (lower(soap_cat) = 'a'::text)) OR (lower(soap_cat) = 'p'::text)))) |
form_is_plan | CHECK ((soap_cat = 'p'::text)) |
Tables referencing this one via Foreign Key Constraints:
idx_formi_encounter fk_encounter idx_formi_episode fk_episodeThis is pretty much what others would call "Past Medical History" or "Foundational illness", eg. longer-ranging, underlying, encompassing issues with one's health such as "immunodeficiency", "type 2 diabetes". In Belgium it is called "problem". L.L.Weed includes lots of little things into it, we do not.
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 | serial | PRIMARY KEY | |
dem.identity.pk | fk_patient | integer |
UNIQUE#1
NOT NULL
id of patient this health issue relates to, should be reference but might be outside our own database |
description | text |
UNIQUE#1
NOT NULL
descriptive name of this health issue, may change over time as evidence increases |
|
laterality | character varying(2) |
NULL: don't know s: sinister - left d: dexter - right sd: sinister and dexter - both sides na: not applicable |
|
age_noted | interval |
at what age the patient acquired the condition |
|
is_active | boolean |
DEFAULT true
whether this health issue (problem) is active |
|
clinically_relevant | boolean |
DEFAULT true
whether this health issue (problem) has any clinical relevance |
|
is_confidential | boolean | DEFAULT false | |
is_cause_of_death | boolean | NOT NULL DEFAULT false |
Table clin.health_issue Inherits audit_fields,
Name | Constraint |
---|---|
health_issue_laterality_check | CHECK (((((((laterality)::text = NULL::text) OR ((laterality)::text = 's'::text)) OR ((laterality)::text = 'd'::text)) OR ((laterality)::text = 'sd'::text)) OR ((laterality)::text = 'na'::text))) |
issue_name_not_empty | CHECK ((btrim(description) <> ''::text)) |
Tables referencing this one via Foreign Key Constraints:
idx_health_issue_modified_by modified_bystores family history items independant of the patient, this is out-of-EMR so that several patients can link to it
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 | serial | PRIMARY KEY | |
clin.clin_narrative.pk | fk_narrative_condition | integer |
can point to a narrative item of a relative if in database |
dem.identity.pk | fk_relative | integer |
UNIQUE#1
foreign key to relative if in database |
name_relative | text |
UNIQUE#2
name of the relative if not in database |
|
dob_relative | timestamp with time zone |
UNIQUE#2
DOB of relative if not in database |
|
condition | text |
UNIQUE#1
UNIQUE#2
narrative holding the condition the relative suffered from, must be NULL if fk_narrative_condition is not |
|
age_noted | text |
at what age the relative acquired the condition |
|
age_of_death | interval |
at what age the relative died |
|
is_cause_of_death | boolean |
NOT NULL
DEFAULT false
whether relative died of this problem, Richard suggested to allow that several times per relative |
Table clin.hx_family_item Inherits audit_fields,
Name | Constraint |
---|---|
hx_family_item_condition_check | CHECK ((COALESCE(btrim(condition), 'dummy'::text) <> ''::text)) |
hx_family_item_name_relative_check | CHECK ((COALESCE(btrim(name_relative), 'dummy'::text) <> ''::text)) |
link_or_know_condition | CHECK ((((fk_narrative_condition IS NOT NULL) AND (condition IS NULL)) OR ((fk_narrative_condition IS NULL) AND (condition IS NOT NULL)))) |
link_or_know_relative | CHECK (((((((fk_narrative_condition IS NOT NULL) AND (fk_relative IS NULL)) AND (name_relative IS NULL)) AND (dob_relative IS NULL)) OR ((((fk_narrative_condition IS NULL) AND (fk_relative IS NOT NULL)) AND (name_relative IS NULL)) AND (dob_relative IS NULL))) OR (((fk_narrative_condition IS NULL) AND (fk_relative IS NULL)) AND (name_relative IS NOT NULL)))) |
Tables referencing this one via Foreign Key Constraints:
this table holds test results that could not be matched to any patient, it is intended to prevent overflow of incoming_data_unmatched with unmatchable data
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 | serial | PRIMARY KEY | |
fk_patient_candidates | integer[] | ||
request_id | text | ||
firstnames | text | ||
lastnames | text | ||
dob | date | ||
postcode | text | ||
other_info | text | ||
type | text | ||
data | bytea | NOT NULL |
Table clin.incoming_data_unmatchable Inherits audit_fields,
this table holds incoming data (lab results, documents) that could not be matched to one single patient automatically, it is intended to facilitate manual matching, - use "modified_when" for import time
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 | serial | PRIMARY KEY | |
fk_patient_candidates | integer[] |
a matching algorithm can be applied to produce a list of likely candidate patients, the question remains whether this should not be done at runtime |
|
request_id | text |
request ID as found in <data> |
|
firstnames | text |
first names as found in <data> |
|
lastnames | text |
last names as found in <data> |
|
dob | date |
date of birth as found in <data> |
|
postcode | text |
postcode as found in <data> |
|
other_info | text |
other identifying information as found in <data> |
|
type | text |
the type of <data>, eg HL7, LDT, ..., useful for selecting an importer |
|
data | bytea |
NOT NULL
the raw data |
Table clin.incoming_data_unmatched Inherits audit_fields,
test request metadata
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()
the time the sample for this request was taken LDT: 8432:8433 HL7: OBR.quantity_timing |
|
clin.encounter.pk | fk_encounter | integer | NOT NULL |
clin.episode.pk | fk_episode | integer | NOT NULL |
narrative | text |
free text comment on request |
|
soap_cat | text | DEFAULT 'p'::text | |
pk | serial | PRIMARY KEY | |
clin.test_org.pk | fk_test_org | integer | UNIQUE#1 NOT NULL |
request_id | text |
UNIQUE#1
NOT NULL
ID this request had when sent to the lab LDT: 8310 HL7: OBR.filler_order_number |
|
dem.identity.pk | fk_requestor | integer |
who requested the test - really needed ? |
lab_request_id | text |
ID this request had internally at the lab LDT: 8311 |
|
lab_rxd_when | timestamp with time zone |
when did the lab receive the request+sample LDT: 8301 HL7: OBR.requested_date_time |
|
results_reported_when | timestamp with time zone |
when was the report on the result generated, LDT: 8302 HL7: OBR.results_report_status_change |
|
request_status | text |
NOT NULL
pending, final, preliminary, partial LDT: 8401 |
|
is_pending | boolean |
NOT NULL
DEFAULT true
true if any (even partial) results are still pending |
Table clin.lab_request Inherits clin_root_item,
Name | Constraint |
---|---|
lab_request_request_id_check | CHECK ((btrim(request_id) <> ''::text)) |
lab_request_request_status_check | CHECK (((((request_status = 'pending'::text) OR (request_status = 'preliminary'::text)) OR (request_status = 'partial'::text)) OR (request_status = 'final'::text))) |
lab_request_soap_cat_check | CHECK (((soap_cat IS NULL) OR ((((lower(soap_cat) = 's'::text) OR (lower(soap_cat) = 'o'::text)) OR (lower(soap_cat) = 'a'::text)) OR (lower(soap_cat) = 'p'::text)))) |
Tables referencing this one via Foreign Key Constraints:
idx_lreq_encounter fk_encounter idx_lreq_episode fk_episodelinks constraints to courses
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 | serial | PRIMARY KEY | |
clin.vaccination_course.pk | fk_vaccination_course | integer | UNIQUE#1 NOT NULL |
clin.vaccination_course_constraint.pk | fk_constraint | integer | UNIQUE#1 NOT NULL |
Table clin.lnk_constraint2vacc_course Inherits audit_fields,
links patients to vaccination courses they are actually on, this allows for per-patient selection of courses to be followed, eg. children at different ages may be on different vaccination courses or some people are on a course due to a trip abroad while most others are not
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 | serial | PRIMARY KEY | |
dem.identity.pk | fk_patient | integer | UNIQUE#1 NOT NULL |
clin.vaccination_course.pk | fk_course | integer | UNIQUE#1 NOT NULL |
Table clin.lnk_pat2vaccination_course Inherits audit_fields,
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
clin.test_result.pk | fk_result | integer | UNIQUE NOT NULL |
clin.lab_request.pk | fk_request | integer | NOT NULL |
links test result evaluation norms to tests
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"() | |
id | serial | PRIMARY KEY | |
clin.test_type.pk | id_test | integer |
UNIQUE#1
NOT NULL
which test does the linked norm apply to |
id_norm | integer |
UNIQUE#1
NOT NULL
the norm to apply to the linked test |
Table clin.lnk_tst2norm Inherits audit_fields,
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
clin.test_type.pk | fk_test_type | integer | NOT NULL |
clin.test_type_unified.pk | fk_test_type_unified | integer | NOT NULL |
allow to link many-to-many between clin.clin_root_item and clin.clin_item_type
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 | serial | PRIMARY KEY | |
clin.clin_item_type.pk | fk_type | integer | UNIQUE#1 NOT NULL |
fk_item | integer |
UNIQUE#1
NOT NULL
the item this type is linked to, since PostgreSQL apparently cannot reference a value inserted from a child table (?) we must simulate referential integrity checks with a custom trigger, this, however, does not deal with update/delete cascading :-( |
Table clin.lnk_type2item Inherits audit_fields,
this table links vaccination courses for a single epitope into schedules defined and recommended by a vaccination council or similar entity
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 | serial | PRIMARY KEY | |
clin.vaccination_course.pk | fk_course | integer | UNIQUE NOT NULL |
clin.vaccination_schedule.pk | fk_schedule | integer | NOT NULL |
Table clin.lnk_vaccination_course2schedule Inherits audit_fields,
links vaccines to their indications
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"() | |
id | serial | PRIMARY KEY | |
clin.vaccine.pk | fk_vaccine | integer | UNIQUE#1 NOT NULL |
clin.vacc_indication.id | fk_indication | integer | UNIQUE#1 NOT NULL |
Table clin.lnk_vaccine2inds Inherits audit_fields,
data about operations a patient had, links to clin.health_issue, use clin.health_issue.age_noted for date of operation
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 | serial | PRIMARY KEY | |
clin.health_issue.pk | fk_health_issue | integer |
NOT NULL
which clin.health_issue this row refers to |
clin.encounter.pk | fk_encounter | integer |
NOT NULL
during which encounter we learned of this |
clin_where | text |
where did this operation take place |
|
comment | text |
Table clin.operation Inherits audit_fields,
this table tracks whether a particular clinical item was reviewed by a clinician or not
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 | serial | PRIMARY KEY | |
fk_reviewed_row | integer |
UNIQUE#1
NOT NULL
the row the review status is for: to be qualified as a proper foreign key in child tables |
|
dem.staff.pk | fk_reviewer | integer |
UNIQUE#1
NOT NULL
who has reviewed the item |
is_technically_abnormal | boolean |
NOT NULL
whether test provider flagged this result as abnormal, *not* a clinical assessment but rather a technical one LDT: exist(8422) |
|
clinically_relevant | boolean |
NOT NULL
whether this result is considered relevant clinically, need not correspond to the value of "techically_abnormal" since abnormal values may be irrelevant while normal ones can be of significance |
|
comment | text |
Table clin.review_root Inherits audit_fields,
review table for test results
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 | integer | PRIMARY KEY DEFAULT nextval('clin.review_root_pk_seq'::regclass) | |
clin.test_result.pk | fk_reviewed_row | integer | UNIQUE#1 NOT NULL |
fk_reviewer | integer | UNIQUE#1 NOT NULL | |
is_technically_abnormal | boolean | NOT NULL | |
clinically_relevant | boolean | NOT NULL | |
comment | text |
Table clin.reviewed_test_results Inherits review_root,
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
rank | integer | NOT NULL | |
soap_cat | character(1) |
Name | Constraint |
---|---|
soap_cat_ranks_rank_check | CHECK ((((((rank = 1) OR (rank = 2)) OR (rank = 3)) OR (rank = 4)) OR (rank = 5))) |
soap_cat_ranks_soap_cat_check | CHECK (((soap_cat IS NULL) OR ((((lower((soap_cat)::text) = 's'::text) OR (lower((soap_cat)::text) = 'o'::text)) OR (lower((soap_cat)::text) = 'a'::text)) OR (lower((soap_cat)::text) = 'p'::text)))) |
organisation providing results
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 | serial | PRIMARY KEY | |
fk_org | integer |
UNIQUE
NOT NULL
link to organisation HL7: MSH.sending_facility/sending_application |
|
dem.identity.pk | fk_adm_contact | integer |
whom to call for admin questions (modem link, etc.) |
dem.identity.pk | fk_med_contact | integer |
whom to call for medical questions (result verification, additional test requests) |
internal_name | text |
UNIQUE
you can store here the name a test org identifies itself with when sending data HL7: MSH.sending_application/OBR.universal_service_id |
|
comment | text |
useful for, say, dummy records where you want to mark up stuff like "pharmacy such-and-such" if you don't have it in your contacts |
Table clin.test_org Inherits audit_fields,
Tables referencing this one via Foreign Key Constraints:
the results of a single measurement
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()
the time when this result was *actually* obtained, if this is a lab result this should be between lab_request.clin_when and lab_request.results_reported_when, HL7: OBR.observation_date_time |
|
clin.encounter.pk | fk_encounter | integer | NOT NULL |
clin.episode.pk | fk_episode | integer | NOT NULL |
narrative | text |
clinical comment, progress note |
|
soap_cat | text | DEFAULT 'o'::text | |
pk | serial | PRIMARY KEY | |
clin.test_type.pk | fk_type | integer |
NOT NULL
the type of test this result is from |
val_num | numeric |
numeric value if any, HL7: OBX.observation_results if OBX.value_type == NM |
|
val_alpha | text |
alphanumeric value if any, HL7: OBX.observation_results if OBX.value_type == FT |
|
val_unit | text |
the unit this result came in HL7: OBX.units |
|
val_normal_min | numeric |
lower bound of normal range if numerical as defined by provider for this result |
|
val_normal_max | numeric |
upper bound of normal range if numerical as defined by provider for this result |
|
val_normal_range | text |
range of normal values if alphanumerical as defined by provider for this result, eg. "less than 0.5 but detectable" HL7: OBX.reference_range |
|
val_target_min | numeric |
lower bound of target range if numerical as defined by clinician caring this patient |
|
val_target_max | numeric |
upper bound of target range if numerical as defined by clinician caring for this patient |
|
val_target_range | text |
range of target values if alphanumerical as defined by clinician caring for this patient |
|
abnormality_indicator | text |
how the test provider flagged this result as abnormal, *not* a clinical assessment but rather a technical one LDT: 8422 |
|
norm_ref_group | text |
what sample of the population does this normal range applay to, eg what type of patient was assumed when interpreting this result, LDT: 8407 |
|
note_provider | text |
any comment the test provider should like to make, such as "may be inaccurate due to haemolyzed sample" LDT: 8470 |
|
material | text |
the submitted material, eg. smear, serum, urine, etc., LDT: 8430 |
|
material_detail | text |
details re the material, eg. site taken from, etc. LDT: 8431 |
|
dem.identity.pk | fk_intended_reviewer | integer |
NOT NULL
who is *supposed* to review this item |
Table clin.test_result Inherits clin_root_item,
Name | Constraint |
---|---|
numval_needs_unit | CHECK ((((val_num IS NOT NULL) AND (btrim(COALESCE(val_unit, ''::text)) <> ''::text)) OR (val_num IS NULL))) |
test_result_check | CHECK ((((val_num IS NOT NULL) OR (val_alpha IS NOT NULL)) OR (((val_num IS NULL) AND (val_alpha <> ''::text)) AND (val_alpha IS NOT NULL)))) |
test_result_soap_cat_check | CHECK (((soap_cat IS NULL) OR ((((lower(soap_cat) = 's'::text) OR (lower(soap_cat) = 'o'::text)) OR (lower(soap_cat) = 'a'::text)) OR (lower(soap_cat) = 'p'::text)))) |
Tables referencing this one via Foreign Key Constraints:
idx_tres_encounter fk_encounter idx_tres_episode fk_episodemeasurement type, like a "method" in a lab
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 | serial | PRIMARY KEY | |
clin.test_org.pk | fk_test_org | integer |
UNIQUE#1
organisation carrying out this type of measurement, eg. a particular lab |
code | text |
UNIQUE#1
NOT NULL
short name, acronym or code of this type of measurement, may conform to some official list or other such as LOINC, Australian Pathology request codes or German lab-specific ELVs, actually, this column should be checked against the coding system tables, too, the only problem being that we do not know which one ... as it depends on the *value* in "coding_system", HL7: OBX.observation_identifier |
|
coding_system | text |
UNIQUE#1
identifier of coding system that the code of this measurement type is taken from, should be verifiable against the "reference" service of GnuMed |
|
name | text |
descriptive name of this measurement type, HL7: OBX.observation_identifier |
|
comment | text |
arbitrary comment on this type of measurement/test such as "outdated" or "only reliable when ..." |
|
conversion_unit | text |
the basic unit for this test type, preferably SI, used for comparing results delivered in differing units, this does not relate to what unit the test provider delivers results in but rather the unit we think those results need to be converted to in order to be comparable to OTHER results |
Table clin.test_type Inherits audit_fields,
Tables referencing this one via Foreign Key Constraints:
this table merges test types from various test orgs which are intended to measure the same value but have differing names into one logical test type, this is not intended to be used for aggregating semantically different test types into "profiles"
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
code | text | UNIQUE#1 NOT NULL | |
name | text | UNIQUE#1 NOT NULL | |
coding_system | text | ||
comment | text |
Tables referencing this one via Foreign Key Constraints:
a lookup view for all the codes associated with a diagnosis, a diagnosis can appear several times, namely once per associated code
F-Key | Name | Type | Description |
---|---|---|---|
diagnosis | text | ||
code | text | ||
coding_system | text |
SELECT DISTINCT con.term AS diagnosis , con.code , con.xfk_coding_system AS coding_system FROM clin.coded_narrative con WHERE (EXISTS ( SELECT 1 FROM clin.v_pat_diag vpd WHERE (vpd.diagnosis = con.term) ) ) ORDER BY con.term , con.code , con.xfk_coding_system;
Clinical patient data formatted into one string per clinical entity even if it constains several user- visible fields. Mainly useful for display as a simple EMR journal.
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
modified_when | timestamp with time zone | ||
clin_when | timestamp with time zone | ||
modified_by | text | ||
soap_cat | text | ||
narrative | text | ||
pk_encounter | integer | ||
pk_episode | integer | ||
pk_health_issue | integer | ||
src_pk | integer | ||
src_table | text |
( ( ( ( ( ( ( SELECT vpi.pk_patient , cn.modified_when , cn.clin_when , COALESCE ( ( SELECT staff.short_alias FROM dem.staff WHERE (staff.db_user = cn.modified_by) ) , ( ('<'::text || (cn.modified_by)::text ) || '>'::text ) ) AS modified_by , cn.soap_cat , (cn.narrative || ' //'::text) AS narrative , cn.fk_encounter AS pk_encounter , cn.fk_episode AS pk_episode , vpi.pk_health_issue , cn.pk AS src_pk ,'clin.clin_narrative'::text AS src_table FROM clin.v_pat_items vpi , clin.clin_narrative cn WHERE (vpi.pk_item = cn.pk_item) UNION ALLSELECT chi.fk_patient AS pk_patient , chi.modified_when , chi.modified_when AS clin_when , COALESCE ( ( SELECT staff.short_alias FROM dem.staff WHERE (staff.db_user = chi.modified_by) ) , ( ('<'::text || (chi.modified_by)::text ) || '>'::text ) ) AS modified_by ,'a' AS soap_cat , ( ( ( ( ( ( ( ( ( ( ( ( ( (_ ('health issue'::text) || ': '::text ) || chi.description ) || COALESCE ( ( ( ' ('::text || (chi.laterality)::text ) || ')'::text ) ,''::text ) ) || ', '::text ) || _ ('noted at age'::text) ) || ': '::text ) || COALESCE ( (chi.age_noted)::text ,'?'::text ) ) || ', '::text ) || CASE WHEN chi.is_active THEN _ ('active'::text) ELSE _ ('inactive'::text) END ) || ', '::text ) || CASE WHEN chi.clinically_relevant THEN _ ('clinically relevant'::text) ELSE _ ('clinically not relevant'::text) END ) || CASE WHEN chi.is_confidential THEN ( ', '::text || _ ('confidential'::text) ) ELSE ''::text END ) || CASE WHEN chi.is_cause_of_death THEN ( ', '::text || _ ('cause of death'::text) ) ELSE ''::text END ) || ' //'::text ) AS narrative , -1 AS pk_encounter , -1 AS pk_episode , chi.pk AS pk_health_issue , chi.pk AS src_pk ,'clin.health_issue'::text AS src_table FROM clin.health_issue chi ) UNION ALLSELECT cenc.fk_patient AS pk_patient , cenc.modified_when , cenc.started AS clin_when , COALESCE ( ( SELECT staff.short_alias FROM dem.staff WHERE (staff.db_user = cenc.modified_by) ) , ( ('<'::text || (cenc.modified_by)::text ) || '>'::text ) ) AS modified_by ,'s' AS soap_cat , ( ( ( ( ( ( ( ( ( ( ( ( (_ ('encounter'::text) || ': '::text ) || ( SELECT _ (encounter_type.description) AS _ FROM clin.encounter_type WHERE (encounter_type.pk = cenc.fk_type) ) ) || to_char (cenc.started ,' YYYY-MM-DD HH24:MI'::text ) ) || to_char (cenc.last_affirmed ,' - HH24:MI'::text ) ) || '; '::text ) || _ ('RFE'::text) ) || ': '::text ) || COALESCE (cenc.reason_for_encounter ,'?'::text ) ) || '; '::text ) || _ ('AOE'::text) ) || ': '::text ) || COALESCE (cenc.assessment_of_encounter ,'?'::text ) ) || ' //'::text ) AS narrative , cenc.pk AS pk_encounter , -1 AS pk_episode , -1 AS pk_health_issue , cenc.pk AS src_pk ,'clin.encounter'::text AS src_table FROM clin.encounter cenc ) UNION ALLSELECT vpep.pk_patient , vpep.episode_modified_when AS modified_when , vpep.episode_modified_when AS clin_when , COALESCE ( ( SELECT staff.short_alias FROM dem.staff WHERE (staff.db_user = vpep.episode_modified_by) ) , ( ('<'::text || (vpep.episode_modified_by)::text ) || '>'::text ) ) AS modified_by ,'s' AS soap_cat , ( ( (_ ('episode'::text) || ': '::text ) || vpep.description ) || ' //'::text ) AS narrative , -1 AS pk_encounter , vpep.pk_episode , -1 AS pk_health_issue , vpep.pk_episode AS src_pk ,'clin.episode'::text AS src_table FROM clin.v_pat_episodes vpep ) UNION ALLSELECT vhxf.pk_patient , vhxf.modified_when , vhxf.clin_when , COALESCE ( ( SELECT staff.short_alias FROM dem.staff WHERE (staff.db_user = vhxf.modified_by) ) , ( ('<'::text || (vhxf.modified_by)::text ) || '>'::text ) ) AS modified_by , vhxf.soap_cat , ( ( ( ( ( ( ( ( (_ ('Family Hx'::text) || ': '::text ) || _ (vhxf.relationship) ) || ' '::text ) || vhxf.name_relative ) || ' @ '::text ) || vhxf.age_noted ) || ': '::text ) || vhxf.condition ) || ' //'::text ) AS narrative , vhxf.pk_encounter , vhxf.pk_episode , vhxf.pk_health_issue , vhxf.pk_hx_family_item AS src_pk ,'clin.hx_family_item'::text AS src_table FROM clin.v_hx_family vhxf ) UNION ALLSELECT vpa.pk_patient , vpa.modified_when , vpa.date AS clin_when , COALESCE ( ( SELECT staff.short_alias FROM dem.staff WHERE (staff.db_user = vpa.modified_by) ) , ( ('<'::text || (vpa.modified_by)::text ) || '>'::text ) ) AS modified_by , vpa.soap_cat , ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (_ ('allergene'::text) || ': '::text ) || COALESCE (vpa.allergene ,''::text ) ) || '; '::text ) || _ ('substance'::text) ) || ': '::text ) || vpa.substance ) || '; '::text ) || _ ('generic'::text) ) || ': '::text ) || COALESCE (vpa.generics ,''::text ) ) || '; '::text ) || _ ('ATC code'::text) ) || ': '::text ) || COALESCE (vpa.atc_code ,''::text ) ) || '; '::text ) || _ ('type'::text) ) || ': '::text ) || vpa.l10n_type ) || '; '::text ) || _ ('reaction'::text) ) || ': '::text ) || COALESCE (vpa.reaction ,''::text ) ) || ' //'::text ) AS narrative , vpa.pk_encounter , vpa.pk_episode , vpa.pk_health_issue , vpa.pk_allergy AS src_pk ,'clin.allergy' AS src_table FROM clin.v_pat_allergies vpa ) UNION ALLSELECT vlr.pk_patient , vlr.modified_when , vlr.sampled_when AS clin_when , COALESCE ( ( SELECT staff.short_alias FROM dem.staff WHERE (staff.db_user = vlr.modified_by) ) , ( ('<'::text || (vlr.modified_by)::text ) || '>'::text ) ) AS modified_by , vlr.soap_cat , ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (_ ('lab'::text) || ': '::text ) || vlr.lab_name ) || '; '::text ) || _ ('sample ID'::text) ) || ': '::text ) || vlr.request_id ) || '; '::text ) || _ ('sample taken'::text) ) || ': '::text ) || (vlr.sampled_when)::text ) || '; '::text ) || _ ('status'::text) ) || ': '::text ) || vlr.l10n_request_status ) || '; '::text ) || _ ('notes'::text) ) || ': '::text ) || COALESCE (vlr.progress_note ,''::text ) ) || ' //'::text ) AS narrative , vlr.pk_encounter , vlr.pk_episode , vlr.pk_health_issue , vlr.pk_item AS src_pk ,'lab_request' AS src_table FROM clin.v_lab_requests vlr ) UNION ALLSELECT vtr.pk_patient , vtr.modified_when , vtr.clin_when , COALESCE ( ( SELECT staff.short_alias FROM dem.staff WHERE (staff.db_user = vtr.modified_by) ) , ( ('<'::text || (vtr.modified_by)::text ) || '>'::text ) ) AS modified_by , vtr.soap_cat , ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (_ ('code'::text) || ': '::text ) || vtr.unified_code ) || '; '::text ) || _ ('name'::text) ) || ': '::text ) || vtr.unified_name ) || '; '::text ) || _ ('value'::text) ) || ': '::text ) || vtr.unified_val ) || ' '::text ) || vtr.val_unit ) || ' ('::text) || COALESCE (vtr.unified_target_range ,'?'::text ) ) || '); '::text ) || _ ('notes'::text) ) || vtr."comment" ) || ' //'::text ) AS narrative , vtr.pk_encounter , vtr.pk_episode , vtr.pk_health_issue , vtr.pk_test_result AS src_pk ,'test_result' AS src_table FROM clin.v_test_results vtr ) UNION ALLSELECT vdm.pk_patient , vdm.modified_when , vdm.date AS clin_when , COALESCE ( ( SELECT staff.short_alias FROM dem.staff WHERE (staff.db_user = vdm.modified_by) ) , ( ('<'::text || (vdm.modified_by)::text ) || '>'::text ) ) AS modified_by ,'o' AS soap_cat , ( ( ( ( ( ( ( ( (_ ('document entry'::text) || ': '::text ) || vdm.l10n_type ) || ' "'::text ) || vdm.ext_ref ) || '" ('::text) || to_char (vdm.date ,'YYYY-MM-DD HH24:MI'::text ) ) || '): '::text ) || COALESCE (vdm."comment" ,''::text ) ) || ' //'::text ) AS narrative , vdm.pk_encounter , vdm.pk_episode , vdm.pk_health_issue , vdm.pk_doc AS src_pk ,'blobs.doc_med' AS src_table FROM blobs.v_doc_med vdm;
family history denormalized
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
pk_health_issue | integer | ||
clin_when | timestamp with time zone | ||
modified_when | timestamp with time zone | ||
modified_by | name | ||
pk_encounter | integer | ||
pk_episode | integer | ||
relationship | text | ||
soap_cat | text | ||
pk_clin_hx_family | integer | ||
pk_hx_family_item | integer | ||
pk_narrative_condition | integer | ||
pk_relative_identity | integer | ||
name_relative | text | ||
dob_relative | timestamp with time zone | ||
condition | text | ||
age_noted | text | ||
age_of_death | interval | ||
is_cause_of_death | boolean |
( SELECT vpi.pk_patient , vpi.pk_health_issue , chxf.clin_when , chxf.modified_when , chxf.modified_by , chxf.fk_encounter AS pk_encounter , chxf.fk_episode AS pk_episode , chxf.narrative AS relationship , chxf.soap_cat , chxf.pk AS pk_clin_hx_family , chxf.fk_hx_family_item AS pk_hx_family_item , NULL::integer AS pk_narrative_condition , NULL::integer AS pk_relative_identity , hxfi.name_relative , hxfi.dob_relative , hxfi.condition , hxfi.age_noted , hxfi.age_of_death , hxfi.is_cause_of_death FROM clin.v_pat_items vpi , clin.clin_hx_family chxf , clin.hx_family_item hxfi WHERE ( ( ( (vpi.pk_item = chxf.pk_item) AND (hxfi.pk = chxf.fk_hx_family_item) ) AND (hxfi.fk_narrative_condition IS NULL) ) AND (hxfi.fk_relative IS NULL) ) UNIONSELECT vpi.pk_patient , vpi.pk_health_issue , chxf.clin_when , chxf.modified_when , chxf.modified_by , chxf.fk_encounter AS pk_encounter , chxf.fk_episode AS pk_episode , chxf.narrative AS relationship , chxf.soap_cat , chxf.pk AS pk_clin_hx_family , chxf.fk_hx_family_item AS pk_hx_family_item , NULL::integer AS pk_narrative_condition , hxfi.fk_relative AS pk_relative_identity , ( (vbp.firstnames || ' '::text) || vbp.lastnames ) AS name_relative , vbp.dob AS dob_relative , hxfi.condition , hxfi.age_noted , hxfi.age_of_death , hxfi.is_cause_of_death FROM clin.v_pat_items vpi , clin.clin_hx_family chxf , clin.hx_family_item hxfi , dem.v_basic_person vbp WHERE ( ( ( (vpi.pk_item = chxf.pk_item) AND (hxfi.pk = chxf.fk_hx_family_item) ) AND (hxfi.fk_narrative_condition IS NULL) ) AND (hxfi.fk_relative = vbp.pk_identity) ) ) UNIONSELECT vpn.pk_patient , vpn.pk_health_issue , chxf.clin_when , chxf.modified_when , chxf.modified_by , chxf.fk_encounter AS pk_encounter , chxf.fk_episode AS pk_episode , chxf.narrative AS relationship , chxf.soap_cat , chxf.pk AS pk_clin_hx_family , chxf.fk_hx_family_item AS pk_hx_family_item , hxfi.fk_narrative_condition AS pk_narrative_condition , vpn.pk_patient AS pk_relative_identity , ( (vbp.firstnames || ' '::text) || vbp.lastnames ) AS name_relative , vbp.dob AS dob_relative , vpn.narrative AS condition , hxfi.age_noted , hxfi.age_of_death , hxfi.is_cause_of_death FROM clin.clin_hx_family chxf , clin.hx_family_item hxfi , dem.v_basic_person vbp , clin.v_pat_narrative vpn WHERE ( ( ( (hxfi.pk = chxf.fk_hx_family_item) AND (hxfi.fk_narrative_condition = vpn.pk_narrative) ) AND (hxfi.fk_relative IS NULL) ) AND (vbp.pk_identity = vpn.pk_patient) );
lists indications for vaccines
F-Key | Name | Type | Description |
---|---|---|---|
trade_name | text | ||
short_name | text | ||
indication | text | ||
l10n_indication | text | ||
is_live | boolean | ||
min_age | interval | ||
max_age | interval | ||
comment | text | ||
pk_vaccine | integer | ||
pk_route | integer | ||
pk_vacc_indication | integer |
SELECT v.trade_name , v.short_name , i.description AS indication , _ (i.description) AS l10n_indication , v.is_live , v.min_age , v.max_age , v."comment" , v.pk AS pk_vaccine , v.id_route AS pk_route , i.id AS pk_vacc_indication FROM clin.vaccine v , clin.vacc_indication i , clin.lnk_vaccine2inds lv2i WHERE ( (v.pk = lv2i.fk_vaccine) AND (i.id = lv2i.fk_indication) );
denormalizes lab requests per test organization
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
pk_request | integer | ||
lab_name | text | ||
request_id | text | ||
lab_request_id | text | ||
sampled_when | timestamp with time zone | ||
lab_rxd_when | timestamp with time zone | ||
results_reported_when | timestamp with time zone | ||
request_status | text | ||
l10n_request_status | text | ||
is_pending | boolean | ||
progress_note | text | ||
pk_test_org | integer | ||
pk_requestor | integer | ||
pk_encounter | integer | ||
pk_episode | integer | ||
pk_health_issue | integer | ||
pk_item | integer | ||
modified_when | timestamp with time zone | ||
modified_by | name | ||
soap_cat | text | ||
xmin_lab_request | xid |
SELECT vpi.pk_patient , lr.pk AS pk_request , torg.internal_name AS lab_name , lr.request_id , lr.lab_request_id , lr.clin_when AS sampled_when , lr.lab_rxd_when , lr.results_reported_when , lr.request_status , _ (lr.request_status) AS l10n_request_status , lr.is_pending , lr.narrative AS progress_note , lr.fk_test_org AS pk_test_org , lr.fk_requestor AS pk_requestor , lr.fk_encounter AS pk_encounter , lr.fk_episode AS pk_episode , vpi.pk_health_issue , lr.pk_item , lr.modified_when , lr.modified_by , lr.soap_cat , lr.xmin AS xmin_lab_request FROM clin.lab_request lr , clin.test_org torg , clin.v_pat_items vpi WHERE ( (lr.fk_test_org = torg.pk) AND (vpi.pk_item = lr.pk_item) );
Lists the most recent encounters per patient. Logic of "most recent" is: for a patient: 1) select encounters with latest "last_affirmed", 2) from those select encounters with latest "started" 3) limit those to 1 if there are duplicates (same start and end of encounter!)
F-Key | Name | Type | Description |
---|---|---|---|
pk_encounter | integer | ||
pk_patient | integer | ||
reason_for_encounter | text | ||
assessment_of_encounter | text | ||
type | text | ||
l10n_type | text | ||
started | timestamp with time zone | ||
last_affirmed | timestamp with time zone | ||
pk_type | integer | ||
pk_location | integer |
SELECT ce1.pk AS pk_encounter , ce1.fk_patient AS pk_patient , ce1.reason_for_encounter , ce1.assessment_of_encounter , et.description AS "type" , _ (et.description) AS l10n_type , ce1.started , ce1.last_affirmed , ce1.fk_type AS pk_type , ce1.fk_location AS pk_location FROM clin.encounter ce1 , clin.encounter_type et WHERE ( (ce1.fk_type = et.pk) AND (ce1.started = ( SELECT max (ce2.started) AS max FROM clin.encounter ce2 WHERE (ce2.last_affirmed = ( SELECT max (ce3.last_affirmed) AS max FROM clin.encounter ce3 WHERE (ce3.fk_patient = ce1.fk_patient) ) ) LIMIT 1 ) ) );
unformatted *complete* narrative for patients including health issue/episode/encounter descriptions, mainly for searching the narrative
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
soap_cat | text | ||
narrative | text | ||
pk_encounter | integer | ||
pk_episode | integer | ||
pk_health_issue | integer | ||
src_pk | integer | ||
src_table | name |
( ( ( ( ( ( ( SELECT vpi.pk_patient , vpi.soap_cat , vpi.narrative , vpi.pk_encounter , vpi.pk_episode , vpi.pk_health_issue , vpi.pk_item AS src_pk , vpi.src_table FROM clin.v_pat_items vpi WHERE (btrim (COALESCE (vpi.narrative ,''::text ) ) <> ''::text ) UNION ALLSELECT chi.fk_patient AS pk_patient ,'a' AS soap_cat , chi.description AS narrative , NULL::"unknown" AS pk_encounter , NULL::"unknown" AS pk_episode , chi.pk AS pk_health_issue , chi.pk AS src_pk ,'clin.health_issue' AS src_table FROM clin.health_issue chi WHERE (btrim (COALESCE (chi.description ,''::text ) ) <> ''::text ) ) UNION ALLSELECT cenc.fk_patient AS pk_patient ,'s' AS soap_cat , ( (COALESCE (cenc.reason_for_encounter ,''::text ) || '; '::text ) || COALESCE (cenc.assessment_of_encounter ,''::text ) ) AS narrative , cenc.pk AS pk_encounter , NULL::"unknown" AS pk_episode , NULL::"unknown" AS pk_health_issue , cenc.pk AS src_pk ,'clin.encounter' AS src_table FROM clin.encounter cenc WHERE ( (btrim (COALESCE (cenc.reason_for_encounter ,''::text ) ) <> ''::text ) OR (btrim (COALESCE (cenc.assessment_of_encounter ,''::text ) ) <> ''::text ) ) ) UNION ALLSELECT vpep.pk_patient ,'s' AS soap_cat , vpep.description AS narrative , NULL::"unknown" AS pk_encounter , vpep.pk_episode , vpep.pk_health_issue , vpep.pk_episode AS src_pk ,'clin.episode' AS src_table FROM clin.v_pat_episodes vpep ) UNION ALLSELECT vhxf.pk_patient , vhxf.soap_cat , ( ( ( ( ( (_ (vhxf.relationship) || ' ('::text) || vhxf.relationship ) || ') '::text ) || vhxf.name_relative ) || ': '::text ) || vhxf.condition ) AS narrative , vhxf.pk_encounter , vhxf.pk_episode , vhxf.pk_health_issue , vhxf.pk_hx_family_item AS src_pk ,'clin.hx_family_item' AS src_table FROM clin.v_hx_family vhxf ) UNION ALLSELECT vdm.pk_patient ,'o' AS soap_cat , ( ( ( ( ( (vdm."type" || ' '::text) || vdm.l10n_type ) || ' '::text ) || COALESCE (vdm.ext_ref ,''::text ) ) || ' '::text ) || COALESCE (vdm."comment" ,''::text ) ) AS narrative , vdm.pk_encounter , vdm.pk_episode , vdm.pk_health_issue , vdm.pk_doc AS src_pk ,'blobs.doc_med' AS src_table FROM blobs.v_doc_med vdm ) UNION ALLSELECT vo4d.pk_patient ,'o' AS soap_cat , vo4d.obj_comment AS narrative , vo4d.pk_encounter , vo4d.pk_episode , vo4d.pk_health_issue , vo4d.pk_obj AS src_pk ,'blobs.doc_obj' AS src_table FROM blobs.v_obj4doc_no_data vo4d WHERE (btrim (COALESCE (vo4d.obj_comment ,''::text ) ) <> ''::text ) ) UNION ALLSELECT vdd.pk_patient ,'o' AS soap_cat , vdd.description AS narrative , vdd.pk_encounter , vdd.pk_episode , vdd.pk_health_issue , vdd.pk_doc_desc AS src_pk ,'blobs.doc_desc' AS src_table FROM blobs.v_doc_desc vdd WHERE (btrim (COALESCE (vdd.description ,''::text ) ) <> ''::text ) ) UNION ALLSELECT vrdo.pk_patient ,'s' AS soap_cat , vrdo."comment" AS narrative , NULL::"unknown" AS pk_encounter , vrdo.pk_episode , vrdo.pk_health_issue , vrdo.pk_review_root AS src_pk ,'blobs.v_reviewed_doc_objects' AS src_table FROM blobs.v_reviewed_doc_objects vrdo WHERE (btrim (COALESCE (vrdo."comment" ,''::text ) ) <> ''::text );
denormalizes clin.allergy
F-Key | Name | Type | Description |
---|---|---|---|
pk_allergy | integer | ||
pk_patient | integer | ||
soap_cat | text | ||
descriptor | text | ||
allergene | text | ||
substance | text | ||
substance_code | text | ||
generics | text | ||
generic_specific | boolean | ||
atc_code | text | ||
type | text | ||
l10n_type | text | ||
definite | boolean | ||
reaction | text | ||
pk_type | integer | ||
pk_item | integer | ||
date | timestamp with time zone | ||
pk_health_issue | integer | ||
pk_episode | integer | ||
pk_encounter | integer | ||
modified_when | timestamp with time zone | ||
modified_by | name | ||
xmin_allergy | xid |
SELECT a.pk AS pk_allergy , vpep.pk_patient , a.soap_cat , CASE WHEN (COALESCE (btrim (a.allergene) ,''::text ) = ''::text ) THEN a.substance ELSE a.allergene END AS descriptor , a.allergene , a.substance , a.substance_code , a.generics , a.generic_specific , a.atc_code ,"at".value AS "type" , _ ("at".value) AS l10n_type , a.definite , a.narrative AS reaction , a.fk_type AS pk_type , a.pk_item , a.clin_when AS date , vpep.pk_health_issue , a.fk_episode AS pk_episode , a.fk_encounter AS pk_encounter , a.modified_when , a.modified_by , a.xmin AS xmin_allergy FROM clin.allergy a , clin._enum_allergy_type "at" , clin.v_pat_episodes vpep WHERE ( (vpep.pk_episode = a.fk_episode) AND ("at".pk = a.fk_type) );
denormalizing view over diagnoses per patient
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
diagnosed_when | timestamp with time zone | ||
diagnosis | text | ||
laterality | character(1) | ||
is_chronic | boolean | ||
is_active | boolean | ||
is_definite | boolean | ||
clinically_relevant | boolean | ||
pk_diag | integer | ||
pk_narrative | integer | ||
pk_encounter | integer | ||
pk_episode | integer | ||
xmin_clin_diag | xid | ||
xmin_clin_narrative | xid |
SELECT vpi.pk_patient , cn.clin_when AS diagnosed_when , cn.narrative AS diagnosis , cd.laterality , cd.is_chronic , cd.is_active , cd.is_definite , cd.clinically_relevant , cd.pk AS pk_diag , cd.fk_narrative AS pk_narrative , cn.fk_encounter AS pk_encounter , cn.fk_episode AS pk_episode , cd.xmin AS xmin_clin_diag , cn.xmin AS xmin_clin_narrative FROM clin.clin_diag cd , clin.clin_narrative cn , clin.v_pat_items vpi WHERE ( ( (cn.soap_cat = 'a'::text) AND (cd.fk_narrative = cn.pk) ) AND (cn.pk_item = vpi.pk_item) );
F-Key | Name | Type | Description |
---|---|---|---|
pk_encounter | integer | ||
pk_patient | integer | ||
started | timestamp with time zone | ||
type | text | ||
l10n_type | text | ||
reason_for_encounter | text | ||
assessment_of_encounter | text | ||
last_affirmed | timestamp with time zone | ||
pk_location | integer | ||
pk_type | integer | ||
xmin_encounter | xid |
SELECT cle.pk AS pk_encounter , cle.fk_patient AS pk_patient , cle.started , et.description AS "type" , _ (et.description) AS l10n_type , cle.reason_for_encounter , cle.assessment_of_encounter , cle.last_affirmed , cle.fk_location AS pk_location , cle.fk_type AS pk_type , cle.xmin AS xmin_encounter FROM clin.encounter cle , clin.encounter_type et WHERE (cle.fk_type = et.pk);
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
description | text | ||
episode_open | boolean | ||
health_issue | text | ||
issue_active | boolean | ||
issue_clinically_relevant | boolean | ||
pk_episode | integer | ||
pk_health_issue | integer | ||
episode_modified_when | timestamp with time zone | ||
episode_modified_by | name | ||
xmin_episode | xid |
SELECT cep.fk_patient AS pk_patient , cep.description , cep.is_open AS episode_open , NULL::"unknown" AS health_issue , NULL::"unknown" AS issue_active , NULL::"unknown" AS issue_clinically_relevant , cep.pk AS pk_episode , NULL::"unknown" AS pk_health_issue , cep.modified_when AS episode_modified_when , cep.modified_by AS episode_modified_by , cep.xmin AS xmin_episode FROM clin.episode cep WHERE (cep.fk_health_issue IS NULL) UNION ALLSELECT chi.fk_patient AS pk_patient , cep.description , cep.is_open AS episode_open , chi.description AS health_issue , chi.is_active AS issue_active , chi.clinically_relevant AS issue_clinically_relevant , cep.pk AS pk_episode , cep.fk_health_issue AS pk_health_issue , cep.modified_when AS episode_modified_when , cep.modified_by AS episode_modified_by , cep.xmin AS xmin_episode FROM clin.episode cep , clin.health_issue chi WHERE (cep.fk_health_issue = chi.pk);
F-Key | Name | Type | Description |
---|---|---|---|
pk_item | integer | ||
pk_patient | integer | ||
code | text | ||
narrative | text | ||
type | text |
SELECT items.pk_item , items.pk_patient , items.code , items.narrative , items."type" FROM ( (clin.v_pat_items vpi JOIN clin.lnk_type2item lt2i ON ( (vpi.pk_item = lt2i.fk_item) ) ) lnkd_items JOIN clin.clin_item_type cit ON ( (lnkd_items.fk_type = cit.pk) ) ) items;
F-Key | Name | Type | Description |
---|---|---|---|
modified_when | timestamp with time zone | ||
modified_by | name | ||
clin_when | timestamp with time zone | ||
is_modified | boolean | ||
pk_patient | integer | ||
pk_item | integer | ||
pk_encounter | integer | ||
pk_episode | integer | ||
pk_health_issue | integer | ||
soap_cat | text | ||
narrative | text | ||
src_table | name |
SELECT cri.modified_when , cri.modified_by , cri.clin_when , CASE cri.row_version WHEN 0 THEN false ELSE true END AS is_modified , vpep.pk_patient , cri.pk_item , cri.fk_encounter AS pk_encounter , cri.fk_episode AS pk_episode , vpep.pk_health_issue , cri.soap_cat , cri.narrative , pgc.relname AS src_table FROM clin.clin_root_item cri , clin.v_pat_episodes vpep , pg_class pgc WHERE ( (vpep.pk_episode = cri.fk_episode) AND (cri.tableoid = pgc.oid) );
patient narrative aggregated from all clin_root_item child tables; the narrative is unprocessed and denormalized context using v_pat_items is added
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
date | timestamp with time zone | ||
provider | text | ||
soap_cat | text | ||
narrative | text | ||
pk_item | integer | ||
pk_narrative | integer | ||
pk_health_issue | integer | ||
pk_episode | integer | ||
pk_encounter | integer | ||
xmin_clin_narrative | xid |
SELECT vpi.pk_patient , cn.clin_when AS date , COALESCE ( ( SELECT staff.short_alias FROM dem.staff WHERE (staff.db_user = cn.modified_by) ) , ( ('<'::text || (cn.modified_by)::text ) || '>'::text ) ) AS provider , cn.soap_cat , cn.narrative , cn.pk_item , cn.pk AS pk_narrative , vpi.pk_health_issue , cn.fk_episode AS pk_episode , cn.fk_encounter AS pk_encounter , cn.xmin AS xmin_clin_narrative FROM clin.clin_narrative cn , clin.v_pat_items vpi WHERE (cn.pk_item = vpi.pk_item);
patient SOAP-only narrative; this view aggregates all clin.clin_narrative rows and adds denormalized context
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
date | timestamp with time zone | ||
provider | text | ||
soap_cat | text | ||
narrative | text | ||
pk_item | integer | ||
pk_narrative | integer | ||
pk_health_issue | integer | ||
pk_episode | integer | ||
pk_encounter | integer | ||
xmin_clin_narrative | xid |
SELECT vpep.pk_patient , cn.clin_when AS date , COALESCE ( ( SELECT staff.short_alias FROM dem.staff WHERE (staff.db_user = cn.modified_by) ) , ( ('<'::text || (cn.modified_by)::text ) || '>'::text ) ) AS provider , cn.soap_cat , cn.narrative , cn.pk_item , cn.pk AS pk_narrative , vpep.pk_health_issue , cn.fk_episode AS pk_episode , cn.fk_encounter AS pk_encounter , cn.xmin AS xmin_clin_narrative FROM clin.clin_narrative cn , clin.v_pat_episodes vpep WHERE (vpep.pk_episode = cn.fk_episode);
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
problem | text | ||
type | text | ||
l10n_type | text | ||
problem_active | boolean | ||
clinically_relevant | boolean | ||
pk_episode | integer | ||
pk_health_issue | integer |
SELECT vpep.pk_patient , vpep.description AS problem ,'episode' AS "type" , _ ('episode'::text) AS l10n_type , true AS problem_active , true AS clinically_relevant , vpep.pk_episode , vpep.pk_health_issue FROM clin.v_pat_episodes vpep WHERE (vpep.episode_open IS TRUE) UNIONSELECT chi.fk_patient AS pk_patient , chi.description AS problem ,'issue' AS "type" , _ ('health issue'::text) AS l10n_type , chi.is_active AS problem_active , true AS clinically_relevant , NULL::"unknown" AS pk_episode , chi.pk AS pk_health_issue FROM clin.health_issue chi WHERE (chi.clinically_relevant IS TRUE);
shows denormalized lab results per request
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
pk_result | integer | ||
req_when | timestamp with time zone | ||
lab_rxd_when | timestamp with time zone | ||
val_when | timestamp with time zone | ||
reported_when | timestamp with time zone | ||
unified_code | text | ||
unified_name | text | ||
lab_code | text | ||
lab_name | text | ||
unified_val | text | ||
val_num | numeric | ||
val_alpha | text | ||
val_unit | text | ||
conversion_unit | text | ||
soap_cat | text | ||
progress_note_result | text | ||
progress_note_request | text | ||
val_normal_range | text | ||
val_normal_min | numeric | ||
val_normal_max | numeric | ||
val_target_range | text | ||
val_target_min | numeric | ||
val_target_max | numeric | ||
abnormal | text | ||
note_provider | text | ||
request_status | text | ||
ref_group | text | ||
request_id | text | ||
lab_request_id | text | ||
material | text | ||
material_detail | text | ||
pk_test_type | integer | ||
pk_request | integer | ||
pk_test_org | integer | ||
pk_requestor | integer | ||
pk_health_issue | integer | ||
pk_encounter | integer | ||
pk_episode | integer | ||
xmin_test_result | xid |
SELECT vtr.pk_patient , vtr.pk_test_result AS pk_result , lr.clin_when AS req_when , lr.lab_rxd_when , vtr.clin_when AS val_when , lr.results_reported_when AS reported_when , vtr.unified_code , vtr.unified_name , vtr.code_tt AS lab_code , vtr.name_tt AS lab_name , vtr.unified_val , vtr.val_num , vtr.val_alpha , vtr.val_unit , vtr.conversion_unit , vtr.soap_cat , vtr."comment" AS progress_note_result , COALESCE (lr.narrative ,''::text ) AS progress_note_request , vtr.val_normal_range , vtr.val_normal_min , vtr.val_normal_max , vtr.val_target_range , vtr.val_target_min , vtr.val_target_max , vtr.abnormality_indicator AS abnormal , vtr.note_provider , lr.request_status , vtr.norm_ref_group AS ref_group , lr.request_id , lr.lab_request_id , vtr.material , vtr.material_detail , vtr.pk_test_type , lr.pk AS pk_request , lr.fk_test_org AS pk_test_org , lr.fk_requestor AS pk_requestor , vtr.pk_health_issue , vtr.pk_encounter , vtr.pk_episode , vtr.xmin_test_result FROM clin.v_test_results vtr , clin.lab_request lr , clin.lnk_result2lab_req lr2lr WHERE ( (lr2lr.fk_result = vtr.pk_test_result) AND (lr2lr.fk_request = lr.pk) );
F-Key | Name | Type | Description |
---|---|---|---|
src_schema | oid | ||
src_table | name | ||
pk_reviewed_row | integer | ||
is_technically_abnormal | boolean | ||
clinically_relevant | boolean | ||
reviewer | text | ||
comment | text | ||
pk_review_root | integer | ||
pk_reviewer | integer |
SELECT ( SELECT pg_class.relnamespace FROM pg_class WHERE (pg_class.oid = rr.tableoid) ) AS src_schema , ( SELECT pg_class.relname FROM pg_class WHERE (pg_class.oid = rr.tableoid) ) AS src_table , rr.fk_reviewed_row AS pk_reviewed_row , rr.is_technically_abnormal , rr.clinically_relevant , ( SELECT v_staff.short_alias FROM dem.v_staff WHERE (v_staff.pk_staff = rr.fk_reviewer) ) AS reviewer , rr."comment" , rr.pk AS pk_review_root , rr.fk_reviewer AS pk_reviewer FROM clin.review_root rr;
the tests a given test org provides
F-Key | Name | Type | Description |
---|---|---|---|
pk_test_org | integer | ||
internal_name | text | ||
pk_test_type | integer | ||
test_code | text | ||
coding_system_tt | text | ||
coding_system_unified | text | ||
unified_code | text | ||
test_name | text | ||
unified_name | text | ||
conversion_unit | text | ||
test_comment | text | ||
comment_unified | text | ||
org_comment | text | ||
pk_org | integer |
SELECT torg.pk AS pk_test_org , torg.internal_name , vttu.pk_test_type , vttu.code_tt AS test_code , vttu.coding_system_tt , vttu.coding_system_unified , vttu.unified_code , vttu.name_tt AS test_name , vttu.unified_name , vttu.conversion_unit , vttu.comment_tt AS test_comment , vttu.comment_unified , torg."comment" AS org_comment , torg.fk_org AS pk_org FROM clin.test_org torg , clin.v_unified_test_types vttu WHERE (vttu.pk_test_org = torg.pk);
denormalized view over test_results joined with (possibly unified) test type and patient/episode/encounter keys
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
pk_test_result | integer | ||
clin_when | timestamp with time zone | ||
unified_code | text | ||
unified_name | text | ||
unified_val | text | ||
unified_target_min | numeric | ||
unified_target_max | numeric | ||
unified_target_range | text | ||
soap_cat | text | ||
comment | text | ||
val_num | numeric | ||
val_alpha | text | ||
val_unit | text | ||
conversion_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_provider | text | ||
material | text | ||
material_detail | text | ||
code_tt | text | ||
name_tt | text | ||
coding_system_tt | text | ||
comment_tt | text | ||
code_unified | text | ||
name_unified | text | ||
coding_system_unified | text | ||
comment_unified | text | ||
pk_item | integer | ||
pk_encounter | integer | ||
pk_episode | integer | ||
pk_test_type | integer | ||
modified_when | timestamp with time zone | ||
modified_by | name | ||
xmin_test_result | xid | ||
pk_test_org | integer | ||
pk_test_type_unified | integer | ||
pk_health_issue | integer |
SELECT vpe.pk_patient , tr.pk AS pk_test_result , tr.clin_when , vttu.unified_code , vttu.unified_name , CASE WHEN (COALESCE (btrim (tr.val_alpha) ,''::text ) = ''::text ) THEN (tr.val_num)::text ELSE CASE WHEN (tr.val_num IS NULL) THEN tr.val_alpha ELSE ( ( ( (tr.val_num)::text || ' ('::text) || tr.val_alpha ) || ')'::text ) END END AS unified_val , CASE WHEN (tr.val_target_min IS NULL) THEN tr.val_normal_min ELSE tr.val_target_min END AS unified_target_min , CASE WHEN (tr.val_target_max IS NULL) THEN tr.val_normal_max ELSE tr.val_target_max END AS unified_target_max , CASE WHEN (tr.val_target_range IS NULL) THEN tr.val_normal_range ELSE tr.val_target_range END AS unified_target_range , tr.soap_cat , COALESCE (tr.narrative ,''::text ) AS "comment" , tr.val_num , tr.val_alpha , tr.val_unit , vttu.conversion_unit , tr.val_normal_min , tr.val_normal_max , tr.val_normal_range , tr.val_target_min , tr.val_target_max , tr.val_target_range , tr.abnormality_indicator , tr.norm_ref_group , tr.note_provider , tr.material , tr.material_detail , vttu.code_tt , vttu.name_tt , vttu.coding_system_tt , vttu.comment_tt , vttu.code_unified , vttu.name_unified , vttu.coding_system_unified , vttu.comment_unified , tr.pk_item , tr.fk_encounter AS pk_encounter , tr.fk_episode AS pk_episode , tr.fk_type AS pk_test_type , tr.modified_when , tr.modified_by , tr.xmin AS xmin_test_result , vttu.pk_test_org , vttu.pk_test_type_unified , vpe.pk_health_issue FROM clin.test_result tr , clin.v_unified_test_types vttu , clin.v_pat_episodes vpe WHERE ( (vttu.pk_test_type = tr.fk_type) AND (tr.fk_episode = vpe.pk_episode) );
denormalized view of test_type_unified and link table to test_type
F-Key | Name | Type | Description |
---|---|---|---|
pk_test_type_unified | integer | ||
pk_test_type | integer | ||
code_unified | text | ||
name_unified | text | ||
coding_system_unified | text | ||
comment_unified | text | ||
pk_lnk_ttype2unified_type | integer |
SELECT ttu.pk AS pk_test_type_unified , ltt2ut.fk_test_type AS pk_test_type , ttu.code AS code_unified , ttu.name AS name_unified , ttu.coding_system AS coding_system_unified , ttu."comment" AS comment_unified , ltt2ut.pk AS pk_lnk_ttype2unified_type FROM clin.test_type_unified ttu , clin.lnk_ttype2unified_type ltt2ut WHERE (ltt2ut.fk_test_type_unified = ttu.pk);
F-Key | Name | Type | Description |
---|---|---|---|
code | text | ||
narrative | text | ||
type | text | ||
soap_cat | text | ||
src_table | name |
SELECT DISTINCT ON (items.narrative , items.code , items."type" , items.src_table ) items.code , items.narrative , items."type" , items.soap_cat , items.src_table FROM ( (clin.v_pat_items vpi JOIN clin.lnk_type2item lt2i ON ( (vpi.pk_item = lt2i.fk_item) ) ) lnkd_items JOIN clin.clin_item_type cit ON ( (lnkd_items.fk_type = cit.pk) ) ) items ORDER BY items.narrative , items.code , items."type" , items.src_table;
provides a view of test types aggregated under their corresponding unified name if any, if not linked to a unified test type name the original name is used
F-Key | Name | Type | Description |
---|---|---|---|
pk_test_type | integer | ||
unified_code | text | ||
unified_name | text | ||
code_tt | text | ||
name_tt | text | ||
coding_system_tt | text | ||
comment_tt | text | ||
conversion_unit | text | ||
code_unified | text | ||
name_unified | text | ||
coding_system_unified | text | ||
comment_unified | text | ||
pk_test_org | integer | ||
pk_test_type_unified | integer | ||
pk_lnk_ttype2unified_type | integer |
SELECT ttu0.pk AS pk_test_type , COALESCE (ttu0.code_unified , ttu0.code ) AS unified_code , COALESCE (ttu0.name_unified , ttu0.name ) AS unified_name , ttu0.code AS code_tt , ttu0.name AS name_tt , ttu0.coding_system AS coding_system_tt , ttu0."comment" AS comment_tt , ttu0.conversion_unit , ttu0.code_unified , ttu0.name_unified , ttu0.coding_system_unified , ttu0.comment_unified , ttu0.fk_test_org AS pk_test_org , ttu0.pk_test_type_unified , ttu0.pk_lnk_ttype2unified_type FROM (clin.test_type tt1 LEFT JOIN clin.v_test_type_unified vttu1 ON ( (tt1.pk = vttu1.pk_test_type) ) ) ttu0;
lists the vaccination courses a patient is actually on
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
indication | text | ||
l10n_indication | text | ||
comment | text | ||
is_active | boolean | ||
pk_course | integer | ||
pk_indication | integer | ||
pk_recommended_by | integer |
SELECT lp2vc.fk_patient AS pk_patient , vvr.indication , vvr.l10n_indication , vvr."comment" , vvr.is_active , vvr.pk_course , vvr.pk_indication , vvr.pk_recommended_by FROM clin.lnk_pat2vaccination_course lp2vc , clin.v_vaccination_courses vvr WHERE (vvr.pk_course = lp2vc.fk_course);
all vaccination courses known to the system
F-Key | Name | Type | Description |
---|---|---|---|
pk_course | integer | ||
indication | text | ||
l10n_indication | text | ||
recommended_by_name_long | text | ||
recommended_by_name_short | text | ||
recommended_by_version | text | ||
shots | integer | ||
comment | text | ||
min_age_due | interval | ||
is_active | boolean | ||
pk_indication | integer | ||
pk_recommended_by | integer | ||
xmin_vaccination_course | xid |
SELECT vcourse.pk AS pk_course , vind.description AS indication , _ (vind.description) AS l10n_indication , ( SELECT ref_source.name_long FROM ref_source WHERE (ref_source.pk = vcourse.fk_recommended_by) ) AS recommended_by_name_long , ( SELECT ref_source.name_short FROM ref_source WHERE (ref_source.pk = vcourse.fk_recommended_by) ) AS recommended_by_name_short , ( SELECT ref_source.version FROM ref_source WHERE (ref_source.pk = vcourse.fk_recommended_by) ) AS recommended_by_version , ( SELECT max (vdef.seq_no) AS max FROM clin.vaccination_definition vdef WHERE (vcourse.pk = vdef.fk_course) ) AS shots , COALESCE (vcourse."comment" ,''::text ) AS "comment" , ( SELECT vdef.min_age_due FROM clin.vaccination_definition vdef WHERE ( (vcourse.pk = vdef.fk_course) AND (vdef.seq_no = 1) ) ) AS min_age_due , vcourse.is_active , vcourse.fk_indication AS pk_indication , vcourse.fk_recommended_by AS pk_recommended_by , vcourse.xmin AS xmin_vaccination_course FROM clin.vaccination_course vcourse , clin.vacc_indication vind WHERE (vcourse.fk_indication = vind.id);
F-Key | Name | Type | Description |
---|---|---|---|
vaccination_schedule | text | ||
is_active | boolean | ||
pk_recommended_by | integer | ||
comment_course | text | ||
comment_schedule | text | ||
pk_vaccination_course | integer | ||
pk_indication | integer | ||
pk_vaccination_schedule | integer |
SELECT cvs.name AS vaccination_schedule , cvc.is_active , cvc.fk_recommended_by AS pk_recommended_by , cvc."comment" AS comment_course , cvs."comment" AS comment_schedule , cvc.pk AS pk_vaccination_course , cvc.fk_indication AS pk_indication , cvs.pk AS pk_vaccination_schedule FROM clin.vaccination_course cvc , clin.vaccination_schedule cvs , clin.lnk_vaccination_course2schedule clvc2s WHERE ( (clvc2s.fk_course = cvc.pk) AND (clvc2s.fk_schedule = cvs.pk) );
vaccination event definitions for all courses known to the system
F-Key | Name | Type | Description |
---|---|---|---|
pk_course | integer | ||
indication | text | ||
l10n_indication | text | ||
course_comment | text | ||
is_active | boolean | ||
pk_vaccination_definition | integer | ||
is_booster | boolean | ||
vacc_seq_no | integer | ||
age_due_min | interval | ||
age_due_max | interval | ||
min_interval | interval | ||
vacc_comment | text | ||
pk_indication | integer | ||
pk_recommended_by | integer |
SELECT vcourse.pk AS pk_course , vind.description AS indication , _ (vind.description) AS l10n_indication , COALESCE (vcourse."comment" ,''::text ) AS course_comment , vcourse.is_active , vdef.id AS pk_vaccination_definition , vdef.is_booster , vdef.seq_no AS vacc_seq_no , vdef.min_age_due AS age_due_min , vdef.max_age_due AS age_due_max , vdef.min_interval , COALESCE (vdef."comment" ,''::text ) AS vacc_comment , vind.id AS pk_indication , vcourse.fk_recommended_by AS pk_recommended_by FROM clin.vaccination_course vcourse , clin.vacc_indication vind , clin.vaccination_definition vdef WHERE ( (vcourse.pk = vdef.fk_course) AND (vcourse.fk_indication = vind.id) ) ORDER BY vind.description , vdef.seq_no;
denormalized data about vaccines
F-Key | Name | Type | Description |
---|---|---|---|
pk_vaccine | integer | ||
trade_name | text | ||
short_name | text | ||
route_abbreviation | text | ||
route_description | text | ||
l10n_route_description | text | ||
is_live | boolean | ||
min_age | interval | ||
max_age | interval | ||
comment | text | ||
pk_route | integer |
SELECT v.pk AS pk_vaccine , v.trade_name , v.short_name , vr.abbreviation AS route_abbreviation , vr.description AS route_description , _ (vr.description) AS l10n_route_description , v.is_live , v.min_age , v.max_age , v."comment" , v.id_route AS pk_route FROM clin.vaccine v , clin.vacc_route vr WHERE (v.id_route = vr.id);
vaccinations scheduled for a patient according to the vaccination courses he/she is on
F-Key | Name | Type | Description |
---|---|---|---|
pk_patient | integer | ||
indication | text | ||
l10n_indication | text | ||
course_comment | text | ||
is_booster | boolean | ||
vacc_seq_no | integer | ||
age_due_min | interval | ||
age_due_max | interval | ||
min_interval | interval | ||
vacc_comment | text | ||
pk_vaccination_definition | integer | ||
pk_course | integer | ||
pk_indication | integer | ||
pk_recommended_by | integer |
SELECT vvr4p.pk_patient , vvr4p.indication , vvr4p.l10n_indication , vvr4p."comment" AS course_comment , vvd4r.is_booster , vvd4r.vacc_seq_no , vvd4r.age_due_min , vvd4r.age_due_max , vvd4r.min_interval , vvd4r.vacc_comment , vvd4r.pk_vaccination_definition , vvr4p.pk_course , vvr4p.pk_indication , vvr4p.pk_recommended_by FROM clin.v_vacc_courses4pat vvr4p , clin.v_vaccination_definitions4course vvd4r WHERE (vvd4r.pk_course = vvr4p.pk_course);
definition of indications for vaccinations
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"() | |
id | serial | PRIMARY KEY | |
description | text |
UNIQUE
NOT NULL
description of indication, eg "Measles", note that this does not have to be a scientific diagnosis, it is simply intended to be an agreed-upon, medically-comprehensible unique identifier for the indication |
Table clin.vacc_indication Inherits audit_fields,
Tables referencing this one via Foreign Key Constraints:
definition of route via which vaccine is given, currently i.m. and p.o. only but may include "via genetically engineered food" etc in the future
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"() | |
id | serial | PRIMARY KEY | |
abbreviation | text | UNIQUE NOT NULL | |
description | text | UNIQUE NOT NULL |
Table clin.vacc_route Inherits audit_fields,
Tables referencing this one via Foreign Key Constraints:
holds vaccinations actually given
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 | ||
soap_cat | text | DEFAULT 'p'::text | |
id | serial | PRIMARY KEY | |
fk_provider | integer | NOT NULL | |
clin.vaccine.pk | fk_vaccine | integer | NOT NULL |
site | text | DEFAULT 'not recorded'::text | |
batch_no | text | NOT NULL DEFAULT 'not recorded'::text |
Table clin.vaccination Inherits clin_root_item,
Name | Constraint |
---|---|
vaccination_soap_cat_check | CHECK (((soap_cat IS NULL) OR ((((lower(soap_cat) = 's'::text) OR (lower(soap_cat) = 'o'::text)) OR (lower(soap_cat) = 'a'::text)) OR (lower(soap_cat) = 'p'::text)))) |
holds vaccination courses defined at a techno-medical level for a single indication and will in many cases represent a part of a "recommended multi-epitope schedule", note that one organization can indeed recommend several courses for one and the same indication - which then only differ in their constraints, PostgreSQL does not currently offer the best tools to enforce such constraints
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 | serial | PRIMARY KEY | |
fk_recommended_by | integer |
the source/organization which defined this course, can be used to differentiate several locale-dependant courses for the same indication and yet tell them apart |
|
clin.vacc_indication.id | fk_indication | integer |
NOT NULL
vaccination indication this course is targeted at |
is_active | boolean |
NOT NULL
DEFAULT true
whether this course is active or not, if False: do not newly *start* patients on this course |
|
comment | text |
a free-text comment on this vaccination course |
Table clin.vaccination_course Inherits audit_fields,
Tables referencing this one via Foreign Key Constraints:
holds constraints which apply to a vaccination course
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 | serial | PRIMARY KEY | |
description | text |
UNIQUE
NOT NULL
description/label/name of the constraint |
Table clin.vaccination_course_constraint Inherits audit_fields,
Tables referencing this one via Foreign Key Constraints:
defines a given vaccination event for a particular course
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"() | |
id | serial | PRIMARY KEY | |
clin.vaccination_course.pk | fk_course | integer |
UNIQUE#1
NOT NULL
course to which this event belongs |
is_booster | boolean |
NOT NULL
DEFAULT false
does this definition represent a booster, also set for quasi-booster courses such as Influenza |
|
seq_no | integer |
UNIQUE#1
sequence number for this vaccination event within a particular course, NULL if (is_booster == true) |
|
min_age_due | interval |
NOT NULL
minimum age at which this shot is due |
|
max_age_due | interval |
NOT NULL
DEFAULT '01:32:35'::interval
maximum age at which this shot is due, if max_age_due = "5555 years": no maximum age |
|
min_interval | interval |
if (is_booster == true): recommended interval for boostering id (is_booster == false): minimum interval after previous vaccination, NULL if seq_no == 1 |
|
comment | text |
Table clin.vaccination_definition Inherits audit_fields,
Name | Constraint |
---|---|
numbered_shot_xor_booster | CHECK ((((is_booster IS TRUE) AND (seq_no IS NULL)) OR ((is_booster IS FALSE) AND (seq_no > 0)))) |
sensible_min_interval | CHECK (((((min_interval IS NULL) AND (seq_no = 1)) OR (((min_interval IS NOT NULL) AND (min_interval > '00:00:00'::interval)) AND (is_booster IS TRUE))) OR (((min_interval IS NOT NULL) AND (min_interval > '00:00:00'::interval)) AND (seq_no > 1)))) |
vaccination_definition_check | CHECK ((((max_age_due >= min_age_due) AND (max_age_due <= '150 years'::interval)) OR (max_age_due = '01:32:35'::interval))) |
vaccination_definition_min_age_due_check | CHECK (((min_age_due >= '00:00:01'::interval) AND (min_age_due <= '150 years'::interval))) |
This table holds schedules as recommended by some authority such as a Vaccination Council. There will be numerous schedules depending on locale, constraints, age group etc. These schedules may be single or multi-epitope depending on their definition. A schedule acts as a convenient handle aggregating possibly several vaccination courses under a common name.
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 | serial | PRIMARY KEY | |
name | text |
UNIQUE
NOT NULL
name of the schedule as defined by some authority |
|
comment | text |
Table clin.vaccination_schedule Inherits audit_fields,
Tables referencing this one via Foreign Key Constraints:
definition of a vaccine as available on the market
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 | serial | PRIMARY KEY | |
clin.vacc_route.id | id_route | integer |
NOT NULL
DEFAULT 1
route this vaccine is given |
trade_name | text |
UNIQUE
UNIQUE#1
NOT NULL
full name the vaccine is traded under |
|
short_name | text |
UNIQUE#1
NOT NULL
common, maybe practice-specific shorthand name for referring to this vaccine |
|
is_live | boolean |
NOT NULL
DEFAULT false
whether this is a live vaccine |
|
min_age | interval |
NOT NULL
minimum age this vaccine is licensed for according to the information by the manufacturer |
|
max_age | interval |
NOT NULL
DEFAULT '5555 years'::interval
maximum age this vaccine is licensed for according to the information by the manufacturer, use "5555 years" to indicate "no maximum age" |
|
comment | text |
Table clin.vaccine Inherits audit_fields,
Name | Constraint |
---|---|
vaccine_check | CHECK ((((max_age >= min_age) AND (max_age <= '150 years'::interval)) OR (max_age = '5555 years'::interval))) |
vaccine_min_age_check | CHECK (((min_age >= '00:00:01'::interval) AND (min_age <= '150 years'::interval))) |
Tables referencing this one via Foreign Key Constraints:
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 | serial | PRIMARY KEY | |
clin.vaccine.pk | fk_vaccine | integer | NOT NULL |
batch_no | text |
UNIQUE
NOT NULL
serial # of a batch of a given vaccine that is awaiting usage in the fridge |
Table clin.vaccine_batches Inherits audit_fields,
aggregates all the patients currently waiting for an encounter
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 | serial | PRIMARY KEY | |
dem.identity.pk | fk_patient | integer |
NOT NULL
the waiting patient |
registered | timestamp with time zone |
NOT NULL
DEFAULT now()
when did the patient arrive (enter the waiting list, that is) |
|
urgency | integer |
NOT NULL
relative urgency, used by practices as they see fit, 0 - "standard" urgency < 0 - less urgent > 0 - more urgent |
|
list_position | integer |
UNIQUE
NOT NULL
the currently assigned position of this patient on the waiting list |
|
comment | text |
a free comment regarding this entry, NOT THE RFE ! |
Table clin.waiting_list Inherits audit_fields,
Name | Constraint |
---|---|
waiting_list_list_position_check | CHECK ((list_position > 0)) |
declare _term alias for $1; _code alias for $2; _system alias for $3; _tmp text; begin select into _tmp '1' from clin.coded_narrative where term = _term and code = _code and xfk_coding_system = _system; if found then return True; end if; insert into clin.coded_narrative (term, code, xfk_coding_system) values (_term, _code, _system); return True; end;
declare episode_id integer; patient_id integer; begin -- get episode ID if TG_OP = 'DELETE' then episode_id := OLD.fk_episode; else episode_id := NEW.fk_episode; end if; -- track back to patient ID select into patient_id pk_patient from clin.v_pat_episodes vpep where vpep.pk_episode = episode_id limit 1; -- now, execute() the NOTIFY execute 'notify "item_change_db:' || patient_id || '"'; return NULL; end;
DECLARE msg text; BEGIN -- do not worry about booster deletes if OLD.is_booster then return null; end if; -- any non-booster rows left ? perform 1 from clin.vaccination_definition where fk_course = OLD.fk_course and seq_no is not null; if FOUND then return null; end if; -- *any* rows left ? perform 1 from clin.vaccination_definition where fk_course = OLD.fk_course; if not FOUND then -- no problem return null; end if; -- any remaining rows can only be booster rows - which is a problem msg := 'Cannot delete last non-booster vacc def [' || OLD.pk || '] from course [' || OLD.fk_course || ']. There would be only booster definitions left.'; raise exception '%', msg; return null; END;
BEGIN -- do not worry about non-booster inserts if NEW.is_booster is false then return NEW; end if; -- only insert booster def if non-booster def exists perform 1 from clin.vaccination_definition where fk_course = NEW.fk_course and seq_no is not null; if FOUND then return NEW; end if; raise exception 'Cannot define booster shot for course [%]. There is no base immunization definition.', NEW.fk_course; return null; END;
protect from direct inserts/deletes which the inheritance system cannot handle properly
begin raise exception 'INSERT/DELETE on <clin_root_item> not allowed.'; return False; end;
DECLARE msg text; BEGIN -- do not worry about non-booster updates if NEW.is_booster is false then return null; end if; -- after update to booster still non-booster def available ? perform 1 from clin.vaccination_definition where fk_course = NEW.fk_course and seq_no is not null; if FOUND then return null; end if; msg := 'Cannot set vacc def [' || NEW.pk || '] to booster for course [' || NEW.fk_course || ']. There would be no base immunization definition left.'; raise exception '%', msg; return null; END;
declare _pk_identity integer; begin _pk_identity := NULL; -- retrieve identity PK via fk_encounter if TG_OP = 'DELETE' then select into _pk_identity fk_patient from clin.encounter where pk = OLD.fk_encounter limit 1; else select into _pk_identity fk_patient from clin.encounter where pk = NEW.fk_encounter limit 1; end if; -- soft error out if not found if _pk_identity is NULL then raise notice 'clin.trf_announce_allg_mod(): cannot determine identity PK on table <clin.allergy>'; return NULL; end if; -- now, execute() the NOTIFY execute 'notify "allg_mod_db:' || _pk_identity || '"'; return NULL; end;
declare _pk_identity integer; begin _pk_identity := NULL; -- retrieve identity PK via fk_patient if TG_OP = 'DELETE' then _pk_identity := OLD.fk_patient; else _pk_identity := NEW.fk_patient; end if; -- soft error out if not found if _pk_identity is NULL then raise notice 'clin.trf_announce_allg_state_mod(): cannot determine identity PK on table <clin.allergy_state>'; return NULL; end if; -- now, execute() the NOTIFY execute 'notify "allg_state_mod_db:' || _pk_identity || '"'; return NULL; end;
declare _pk_identity integer; begin _pk_identity := NULL; -- retrieve identity PK via fk_encounter if TG_OP = 'DELETE' then select into _pk_identity fk_patient from clin.encounter where pk = OLD.fk_encounter limit 1; else select into _pk_identity fk_patient from clin.encounter where pk = NEW.fk_encounter limit 1; end if; -- soft error out if not found if _pk_identity is NULL then raise notice 'clin.trf_announce_vacc_mod(): cannot determine identity PK on table <clin.vaccination>'; return NULL; end if; -- now, execute() the NOTIFY execute 'notify "vacc_mod_db:' || _pk_identity || '"'; return NULL; end;
declare issue_patient integer; msg text; begin -- insert or update, both have NEW.* if NEW.fk_health_issue is not NULL then select into issue_patient fk_patient from clin.health_issue where pk = NEW.fk_health_issue; if issue_patient != NEW.fk_patient then msg := 'clin.trf_ensure_episode_issue_patient_consistency(): clin.episode must have the same <fk_patient> as the clin.health_issue it is attached to'; raise exception '%', msg; end if; end if; return NEW; end;
trigger function to sync the allergy state on insert/delete
DECLARE _fk_patient integer; _state integer; _no_of_allergies integer; BEGIN if TG_OP = 'INSERT' then select into _fk_patient fk_patient from clin.encounter where pk = NEW.fk_encounter; _state := 1; end if; if TG_OP = 'DELETE' then -- only run this trigger if deleting last allergy select into _fk_patient fk_patient from clin.encounter where pk = OLD.fk_encounter; select into _no_of_allergies count(1) from clin.allergy where fk_encounter in ( select pk from clin.encounter where fk_patient = _fk_patient ); if _no_of_allergies > 1 then return OLD; -- still allergies left end if; _state := NULL; end if; update clin.allergy_state set has_allergy = _state where fk_patient = _fk_patient; if not FOUND then insert into clin.allergy_state (fk_patient, has_allergy) values (_fk_patient, _state); end if; return NEW; END;
DECLARE _msg text; BEGIN -- is the indication already linked ? perform 1 from clin.v_vaccination_courses_in_schedule where pk_vaccination_schedule = NEW.fk_schedule and pk_indication = (select fk_indication from clin.vaccination_course where pk=NEW.fk_course); if FOUND then _msg := 'Cannot link course [' || NEW.fk_course || '] into schedule [' || NEW.fk_schedule || ']. The indication is already linked.'; raise exception '%', _msg; return null; end if; return null; END;
Art des Behandlungsfalls (MuVo/Impfung/...)
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 | serial | PRIMARY KEY | |
code | text | UNIQUE NOT NULL | |
kurzform | text | UNIQUE NOT NULL | |
name | text | UNIQUE NOT NULL |
Table de_de.beh_fall_typ Inherits audit_fields,
Tables referencing this one via Foreign Key Constraints:
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
dem.identity.pk | fk_patient | integer | NOT NULL |
de_de.beh_fall_typ.pk | fk_falltyp | integer | NOT NULL |
started | date | NOT NULL DEFAULT ('now'::text)::date | |
must_pay_prax_geb | boolean | NOT NULL DEFAULT true |
Tables referencing this one via Foreign Key Constraints:
Speichert die Daten einer bestimmten KVK. Wir trennen die KVK-Daten von den Daten ueber Person, Wohnort, Kassenzugehoerigkeit, Mitgliedsstatus und Abrechnungsfaellen. Diese Daten werden jedoch a) als Vorgaben fuer die eigentlichen Personendaten und b) als gueltig fuer abrechnungstechnische Belange angesehen.
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
dem.identity.pk | fk_patient | integer | NOT NULL |
kk_name | character varying(28) | NOT NULL | |
kk_nummer | character(7) | NOT NULL | |
kvk_nummer | character(5) | ||
mitgliedsnummer | character varying(12) | NOT NULL | |
mitgliedsstatus | character varying(4) | NOT NULL | |
zusatzstatus | character varying(3) | ||
titel | character varying(15) | ||
vorname | character varying(28) | ||
namenszuatz | character varying(15) | ||
familienname | character varying(28) | NOT NULL | |
geburtsdatum | character(8) | NOT NULL | |
strasse | character varying(28) | ||
landescode | character varying(3) | ||
plz | character varying(7) | NOT NULL | |
ort | character varying(23) | NOT NULL | |
gueltigkeit | character(4) | ||
crc | character(1) | NOT NULL | |
is_valid_address | boolean | DEFAULT true | |
valid_since | timestamp with time zone | NOT NULL | |
presented | timestamp with time zone[] | NOT NULL | |
invalidated | timestamp with time zone |
Kann durchaus vor Ende von "Gueltigkeit" liegen. Zeitpunkt des Austritts aus der Krankenkasse. Beim Setzen dieses Feldes muss auch die Zuzahlungsbefreiung auf NULL gesetzt werden. |
specific for Germany, GNR = GebuehrenordnungsNummeR = billing item, build index before lab import and drop afterwards, check against this table when importing, build table during import
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"() | |
id | serial | PRIMARY KEY | |
clin.test_type.pk | id_test | integer |
NOT NULL
link to test in our practice |
Table de_de.lab_test_gnr Inherits audit_fields,
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
description | text | UNIQUE NOT NULL |
Tables referencing this one via Foreign Key Constraints:
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 | serial | PRIMARY KEY | |
de_de.behandlungsfall.pk | fk_fall | integer | NOT NULL |
paid_amount | numeric | NOT NULL | |
paid_when | date | NOT NULL DEFAULT ('now'::text)::date | |
de_de.payment_method.pk | paid_with | integer | NOT NULL |
Table de_de.prax_geb_paid Inherits audit_fields,
F-Key | Name | Type | Description |
---|---|---|---|
id | serial | PRIMARY KEY | |
dem.identity.pk | id_patient | integer | |
medikamente | date | ||
heilmittel | date | ||
hilfsmittel | date | ||
presented | timestamp with time zone | NOT NULL DEFAULT now() |
an address aka a location, void of attached meaning such as type of address
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"() | |
id | serial | PRIMARY KEY | |
dem.street.id | id_street | integer |
UNIQUE#1
NOT NULL
the street this address is at from whence the urb is to be found, it thus indirectly references dem.urb(id) |
aux_street | text |
UNIQUE#1
additional street-level information which formatters would usually put on lines directly below the street line of an address, such as postal box directions in CA |
|
number | text |
UNIQUE#1
NOT NULL
number of the house |
|
subunit | text |
UNIQUE#1
directions *below* the unit (eg.number) level, such as appartment number, room number, level, entrance or even verbal directions |
|
addendum | text |
UNIQUE#1
any additional information that did not fit anywhere else |
|
lat_lon | point |
the exact location of this address in latitude-longtitude |
Table dem.address Inherits audit_fields,
Tables referencing this one via Foreign Key Constraints:
F-Key | Name | Type | Description |
---|---|---|---|
id | serial | PRIMARY KEY | |
name | text | UNIQUE NOT NULL |
Tables referencing this one via Foreign Key Constraints:
countries coded per ISO 3166-1
F-Key | Name | Type | Description |
---|---|---|---|
id | serial | PRIMARY KEY | |
code | character(2) |
UNIQUE
NOT NULL
international two character country code as per ISO 3166-1 |
|
name | text | UNIQUE NOT NULL | |
deprecated | date |
date when this country ceased officially to exist (if applicable) |
Name | Constraint |
---|---|
no_linebreaks | CHECK ((((("position"(((COALESCE(code, ''::bpchar))::text || COALESCE(name, ''::text)), E'\014'::text) = 0) AND ("position"(((COALESCE(code, ''::bpchar))::text || COALESCE(name, ''::text)), E'\012'::text) = 0)) AND ("position"(((COALESCE(code, ''::bpchar))::text || COALESCE(name, ''::text)), E'\015'::text) = 0)) AND ("position"(((COALESCE(code, ''::bpchar))::text || COALESCE(name, ''::text)), E'\013'::text) = 0))) |
Tables referencing this one via Foreign Key Constraints:
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
description | text | UNIQUE NOT NULL |
Tables referencing this one via Foreign Key Constraints:
a list of all bureaucratic IDs/serial numbers/3rd party primary keys, etc.
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
name | text | UNIQUE#1 | |
issuer | text |
UNIQUE#1
the authority/system issuing the number |
|
context | character(1) |
DEFAULT 'p'::bpchar
the context in which this number is used - p for ordinary persons - o for organisations - c for clinicians - s for staff in this clinic FIXME: is context really a property of *type* ? |
Name | Constraint |
---|---|
enum_ext_id_types_context_check | CHECK (((((context = 'p'::bpchar) OR (context = 'o'::bpchar)) OR (context = 'c'::bpchar)) OR (context = 's'::bpchar))) |
Tables referencing this one via Foreign Key Constraints:
This table stores the genders known to GNUmed. FIXME: cross-check with CDA:administrative-gender-code
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 | serial | PRIMARY KEY | |
tag | text | UNIQUE NOT NULL | |
label | text | UNIQUE NOT NULL | |
sort_weight | integer | NOT NULL | |
comment | text | NOT NULL |
Table dem.gender_label Inherits audit_fields,
Name | Constraint |
---|---|
gender_label_tag_check | CHECK ((((((tag = 'm'::text) OR (tag = 'f'::text)) OR (tag = 'h'::text)) OR (tag = 'tm'::text)) OR (tag = 'tf'::text))) |
Tables referencing this one via Foreign Key Constraints:
represents the unique identity of a person
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 | serial | PRIMARY KEY | |
deleted | boolean |
NOT NULL
DEFAULT false
whether this identity is considered deleted |
|
pupic | character(24) |
Portable Unique Person Identification Code as per gnumed white papers |
|
dem.gender_label.tag | gender | text |
the gender code |
karyotype | text | ||
dob | timestamp with time zone |
NOT NULL
date/time of birth |
|
dem.marital_status.pk | fk_marital_status | integer | |
cob | character(2) |
country of birth as per date of birth, coded as 2 character ISO code |
|
deceased | timestamp with time zone |
date when a person has died |
|
title | text |
Yes, a title is an attribute of an identity, not of a name ! Also, there are some incredible rants of titles. |
Table dem.identity Inherits audit_fields,
Name | Constraint |
---|---|
identity_check | CHECK (((deceased IS NULL) OR (deceased >= dob))) |
identity_title_check | CHECK ((btrim(COALESCE(title, 'NULL'::text)) <> ''::text)) |
Tables referencing this one via Foreign Key Constraints:
idx_identity_dob_ymd dem.date_trunc_utc('day'::text, dob)Holds the various categories of messages that can show up in the provider inbox.
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 | serial | PRIMARY KEY | |
description | text |
UNIQUE
NOT NULL
"clinical" "admin" "personal" ... |
|
is_user | boolean |
NOT NULL
DEFAULT true
whether this category was added locally, as to be left alone by database upgrades |
Table dem.inbox_item_category Inherits audit_fields,
Name | Constraint |
---|---|
inbox_item_category_description_check | CHECK ((btrim(COALESCE(description, 'xxxDEFAULTxxx'::text)) <> ''::text)) |
Tables referencing this one via Foreign Key Constraints:
Holds the various types of messages that can show up in the provider inbox.
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 | serial | PRIMARY KEY | |
dem.inbox_item_category.pk | fk_inbox_item_category | integer |
NOT NULL
The category of this item type. |
description | text |
UNIQUE
NOT NULL
the various types of inbox items |
|
is_user | boolean |
NOT NULL
DEFAULT true
whether this type was added locally, as to be left alone by database upgrades |
Table dem.inbox_item_type Inherits audit_fields,
Name | Constraint |
---|---|
inbox_item_type_description_check | CHECK ((btrim(COALESCE(description, 'xxxDEFAULTxxx'::text)) <> ''::text)) |
Tables referencing this one via Foreign Key Constraints:
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
dem.identity.pk | fk_identity | integer | UNIQUE#1 NOT NULL |
dem.address.id | fk_address | integer | |
url | text | UNIQUE#1 | |
dem.enum_comm_types.pk | fk_type | integer | |
is_confidential | boolean | NOT NULL DEFAULT false |
link external IDs to GnuMed identities
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"() | |
id | serial | PRIMARY KEY | |
dem.identity.pk | id_identity | integer | UNIQUE#1 NOT NULL |
external_id | text |
UNIQUE#1
NOT NULL
textual representation of external ID which may be Social Security Number, patient ID of another EMR system, you-name-it |
|
dem.enum_ext_id_types.pk | fk_origin | integer |
UNIQUE#1
NOT NULL
originating system |
comment | text |
Table dem.lnk_identity2ext_id Inherits audit_fields,
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
dem.identity.pk | fk_identity | integer | UNIQUE#1 NOT NULL |
dem.staff.pk | fk_primary_doc | integer | UNIQUE#1 NOT NULL |
linking (possibly several) jobs to a person
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 | serial | PRIMARY KEY | |
dem.identity.pk | fk_identity | integer | UNIQUE#1 NOT NULL |
dem.occupation.id | fk_occupation | integer | UNIQUE#1 NOT NULL |
activities | text |
describes activities the person is usually carrying out when working at this job |
Table dem.lnk_job2person Inherits audit_fields,
F-Key | Name | Type | Description |
---|---|---|---|
id_org | integer | ||
id_address | integer |
SELECT lnk_person_org_address.id_org , lnk_person_org_address.id_address FROM dem.lnk_person_org_address;
F-Key | Name | Type | Description |
---|---|---|---|
id | serial | PRIMARY KEY | |
dem.org.id | id_org | integer | UNIQUE#1 NOT NULL |
url | text | UNIQUE#1 | |
dem.enum_comm_types.pk | id_type | integer | |
is_confidential | boolean | NOT NULL DEFAULT false |
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"() | |
id | serial | PRIMARY KEY | |
dem.org.id | id_org | integer | UNIQUE#1 NOT NULL |
external_id | text | UNIQUE#1 NOT NULL | |
dem.enum_ext_id_types.pk | fk_origin | integer | UNIQUE#1 NOT NULL |
comment | text |
Table dem.lnk_org2ext_id Inherits audit_fields,
F-Key | Name | Type | Description |
---|---|---|---|
id_identity | integer | ||
id_address | integer | ||
id_type | integer |
SELECT lnk_person_org_address.id_identity , lnk_person_org_address.id_address , lnk_person_org_address.id_type FROM dem.lnk_person_org_address;
biological and social relationships between an identity and other identities
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"() | |
id | serial | PRIMARY KEY | |
dem.identity.pk | id_identity | integer |
NOT NULL
primary identity to whom the relationship applies |
dem.identity.pk | id_relative | integer |
NOT NULL
referred-to identity of this relationship (e.g. "child" if id_identity points to the father and id_relation_type points to "parent") |
dem.relation_types.id | id_relation_type | integer | NOT NULL |
started | date |
date when this relationship began |
|
ended | date |
date when this relationship ended, biological relationships do not end ! |
Table dem.lnk_person2relative Inherits audit_fields,
idx_lnk_pers2rel id_identity, id_relation_typea many-to-many pivot table describing the relationship between an organisation, a person, their work address and their occupation at that location. For patients id_org is NULL
F-Key | Name | Type | Description |
---|---|---|---|
id | serial | PRIMARY KEY | |
dem.identity.pk | id_identity | integer |
UNIQUE#2
identity to which the address belongs |
dem.address.id | id_address | integer |
UNIQUE#2
UNIQUE#1
address belonging to this identity (the branch of the organisation) |
dem.address_type.id | id_type | integer |
DEFAULT 1
type of this address (like home, work, parents, holidays ...) |
address_source | text | ||
dem.org.id | id_org | integer | UNIQUE#1 |
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
name | text | UNIQUE NOT NULL |
Tables referencing this one via Foreign Key Constraints:
maps (first) names to their most frequently locally assigned gender, this table is updated nightly by a cron script, names whose gender distribution is between 70/30 and 30/70 are ignored for ambiguity reasons, names with "ambigous" gender are also ignored
F-Key | Name | Type | Description |
---|---|---|---|
id | serial | PRIMARY KEY | |
name | text | UNIQUE NOT NULL | |
gender | character(1) |
Name | Constraint |
---|---|
name_gender_map_gender_check | CHECK (((gender = 'm'::bpchar) OR (gender = 'f'::bpchar))) |
all the names an identity is known under; As opposed to the versioning of all other tables, changed names should not be moved into the audit trail tables. Search functionality must be available at any time for all names a person ever had.
F-Key | Name | Type | Description |
---|---|---|---|
id | serial | PRIMARY KEY | |
dem.identity.pk | id_identity | integer | UNIQUE#1 NOT NULL |
active | boolean |
DEFAULT true
true if the name is still in use |
|
lastnames | text |
UNIQUE#1
NOT NULL
all last names of an identity in legal order, IOW "major" name, "group identifier", eg. family, village, tribe, ... |
|
firstnames | text |
UNIQUE#1
NOT NULL
all first names of an identity in legal order, IOW "minor" name, identifier of this identity within the group defined by <lastnames> |
|
preferred | text |
preferred first name, the name a person is usually called (nickname, warrior name) |
|
comment | text |
a comment regarding this name, useful in things like "this was the name before marriage" etc |
collects occupation names
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"() | |
id | serial | PRIMARY KEY | |
name | text | NOT NULL |
Table dem.occupation Inherits audit_fields,
Name | Constraint |
---|---|
occupation_name_check | CHECK ((btrim(name) <> ''::text)) |
Tables referencing this one via Foreign Key Constraints:
F-Key | Name | Type | Description |
---|---|---|---|
id | serial | PRIMARY KEY | |
dem.org_category.id | id_category | integer | UNIQUE#1 NOT NULL |
description | text | UNIQUE#1 NOT NULL |
Tables referencing this one via Foreign Key Constraints:
F-Key | Name | Type | Description |
---|---|---|---|
id | serial | PRIMARY KEY | |
description | text | UNIQUE NOT NULL |
Tables referencing this one via Foreign Key Constraints:
Holds per-provider messages.
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 | serial | PRIMARY KEY | |
dem.staff.pk | fk_staff | integer |
UNIQUE#1
NOT NULL
the member of staff this message is addressed to |
dem.inbox_item_type.pk | fk_inbox_item_type | integer |
UNIQUE#1
NOT NULL
the item (message) type |
comment | text |
a free-text comment, may be NULL but not empty |
|
ufk_context | integer |
UNIQUE#1
an optional, *u*nchecked *f*oreign *k*ey, it is up to the application to know what this points to, it will have to make sense within the context of the combination of staff ID, item type, and comment |
|
data | text |
arbitrary data an application might wish to attach to the message, like a cookie, basically |
|
importance | smallint |
the relative importance of this message: -1: lower than most things already in the inbox ("low") 0: same as most things ("standard") 1: higher than most things already there ("high") |
Table dem.provider_inbox Inherits audit_fields,
Name | Constraint |
---|---|
provider_inbox_comment_check | CHECK ((btrim(COALESCE("comment", 'xxxDEFAULTxxx'::text)) <> ''::text)) |
provider_inbox_importance_check | CHECK ((((importance = -1) OR (importance = 0)) OR (importance = 1))) |
types of biological/social relationships between identities
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"() | |
id | serial | PRIMARY KEY | |
dem.relation_types.id | inverse | integer | |
biological | boolean |
NOT NULL
true if relationship is biological (proven or reasonable assumption), else false |
|
biol_verified | boolean |
DEFAULT false
ONLY true if there is genetic proof for this relationship |
|
description | text |
plain text description of relationship |
Table dem.relation_types Inherits audit_fields,
Tables referencing this one via Foreign Key Constraints:
one-to-one mapping of database user accounts (db_user) to staff identities (fk_identity)
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 | serial | PRIMARY KEY | |
dem.identity.pk | fk_identity | integer | NOT NULL |
dem.staff_role.pk | fk_role | integer | UNIQUE#1 NOT NULL |
db_user | name | UNIQUE UNIQUE#1 NOT NULL DEFAULT "current_user"() | |
short_alias | text |
UNIQUE
NOT NULL
a short signature unique to this staff member to be used in the GUI, actually this is somewhat redundant with ext_person_id... |
|
comment | text | ||
is_active | boolean | NOT NULL DEFAULT true |
Table dem.staff Inherits audit_fields,
Tables referencing this one via Foreign Key Constraints:
work roles a staff member can have
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 | serial | PRIMARY KEY | |
name | text | UNIQUE NOT NULL | |
comment | text |
Table dem.staff_role Inherits audit_fields,
Tables referencing this one via Foreign Key Constraints:
state codes (country specific); Richard agreed we should require pre-existence, allow user to mail details for adding a state to developers
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"() | |
id | serial | PRIMARY KEY | |
code | text |
UNIQUE#1
NOT NULL
state code |
|
dem.country.code | country | character(2) |
UNIQUE#1
NOT NULL
2 character ISO 3166-1 country code |
name | text | NOT NULL |
Table dem.state Inherits audit_fields,
Name | Constraint |
---|---|
no_linebreaks | CHECK ((((("position"(((COALESCE(code, ''::text) || (COALESCE(country, ''::bpchar))::text) || COALESCE(name, ''::text)), E'\014'::text) = 0) AND ("position"(((COALESCE(code, ''::text) || (COALESCE(country, ''::bpchar))::text) || COALESCE(name, ''::text)), E'\012'::text) = 0)) AND ("position"(((COALESCE(code, ''::text) || (COALESCE(country, ''::bpchar))::text) || COALESCE(name, ''::text)), E'\015'::text) = 0)) AND ("position"(((COALESCE(code, ''::text) || (COALESCE(country, ''::bpchar))::text) || COALESCE(name, ''::text)), E'\013'::text) = 0))) |
Tables referencing this one via Foreign Key Constraints:
street names, specific for distinct "urbs"
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"() | |
id | serial | PRIMARY KEY | |
dem.urb.id | id_urb | integer |
UNIQUE#1
NOT NULL
reference to information postcode, city, country and state |
name | text |
UNIQUE#1
NOT NULL
name of this street |
|
postcode | text |
UNIQUE#1
postcode for systems (such as UK Royal Mail) which specify the street |
|
suburb | text |
the suburb this street is in (if any) |
|
lat_lon | point |
the approximate location of the street, as lat/long co-ordinates |
Table dem.street Inherits audit_fields,
Name | Constraint |
---|---|
no_linebreaks | CHECK ((((("position"(((COALESCE(postcode, ''::text) || COALESCE(suburb, ''::text)) || COALESCE(name, ''::text)), E'\014'::text) = 0) AND ("position"(((COALESCE(postcode, ''::text) || COALESCE(suburb, ''::text)) || COALESCE(name, ''::text)), E'\012'::text) = 0)) AND ("position"(((COALESCE(postcode, ''::text) || COALESCE(suburb, ''::text)) || COALESCE(name, ''::text)), E'\015'::text) = 0)) AND ("position"(((COALESCE(postcode, ''::text) || COALESCE(suburb, ''::text)) || COALESCE(name, ''::text)), E'\013'::text) = 0))) |
Tables referencing this one via Foreign Key Constraints:
cities, towns, dwellings ..., eg. "official" places of residence
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"() | |
id | serial | PRIMARY KEY | |
dem.state.id | id_state | integer |
UNIQUE#1
NOT NULL
reference to information about country and state |
postcode | text |
UNIQUE#1
NOT NULL
default postcode for urb.name, useful for all the smaller urbs that only have one postcode, also useful as a default when adding new streets to an urb |
|
lat_lon | point |
the location of the urb, as lat/long co-ordinates. Ideally this would be NOT NULL |
|
name | text |
UNIQUE#1
NOT NULL
the name of the city/town/dwelling |
Table dem.urb Inherits audit_fields,
Name | Constraint |
---|---|
no_linebreaks | CHECK ((((("position"((COALESCE(postcode, ''::text) || COALESCE(name, ''::text)), E'\014'::text) = 0) AND ("position"((COALESCE(postcode, ''::text) || COALESCE(name, ''::text)), E'\012'::text) = 0)) AND ("position"((COALESCE(postcode, ''::text) || COALESCE(name, ''::text)), E'\015'::text) = 0)) AND ("position"((COALESCE(postcode, ''::text) || COALESCE(name, ''::text)), E'\013'::text) = 0))) |
Tables referencing this one via Foreign Key Constraints:
fully denormalizes data about addresses as entities in themselves
F-Key | Name | Type | Description |
---|---|---|---|
pk_address | integer | ||
street | text | ||
postcode | text | ||
notes_street | text | ||
number | text | ||
subunit | text | ||
notes_subunit | text | ||
lat_lon_address | point | ||
postcode_street | text | ||
lat_lon_street | point | ||
suburb | text | ||
urb | text | ||
postcode_urb | text | ||
lat_lon_urb | point | ||
code_state | text | ||
state | text | ||
l10n_state | text | ||
code_country | character(2) | ||
country | text | ||
l10n_country | text | ||
country_deprecated | date | ||
pk_street | integer | ||
pk_urb | integer | ||
pk_state | integer | ||
xmin_address | xid |
SELECT adr.id AS pk_address , vstr.street , vstr.postcode , adr.aux_street AS notes_street , adr.number , adr.subunit , adr.addendum AS notes_subunit , adr.lat_lon AS lat_lon_address , vstr.postcode_street , vstr.lat_lon_street , vstr.suburb , vstr.urb , vstr.postcode_urb , vstr.lat_lon_urb , vstr.code_state , vstr.state , vstr.l10n_state , vstr.code_country , vstr.country , vstr.l10n_country , vstr.country_deprecated , adr.id_street AS pk_street , vstr.pk_urb , vstr.pk_state , adr.xmin AS xmin_address FROM dem.address adr , dem.v_street vstr WHERE (adr.id_street = vstr.pk_street);
F-Key | Name | Type | Description |
---|---|---|---|
id | integer | ||
country_code | character(2) | ||
state_code | text | ||
state | text | ||
country | text | ||
postcode | text | ||
urb | text | ||
number | text | ||
street | text | ||
addendum | text | ||
lat_lon | point |
SELECT adr.id , s.country AS country_code , s.code AS state_code , s.name AS state , c.name AS country , COALESCE (str.postcode , urb.postcode ) AS postcode , urb.name AS urb , adr.number , str.name AS street , adr.addendum , COALESCE (adr.lat_lon , str.lat_lon , urb.lat_lon ) AS lat_lon FROM dem.address adr , dem.state s , dem.country c , dem.urb , dem.street str WHERE ( ( ( (s.country = c.code) AND (adr.id_street = str.id) ) AND (str.id_urb = urb.id) ) AND (urb.id_state = s.id) );
F-Key | Name | Type | Description |
---|---|---|---|
pk_identity | integer | ||
n_id | integer | ||
title | text | ||
firstnames | text | ||
lastnames | text | ||
dob | timestamp with time zone | ||
cob | character(2) | ||
gender | text | ||
l10n_gender | text | ||
karyotype | text | ||
pupic | character(24) | ||
marital_status | text | ||
l10n_marital_status | text | ||
pk_marital_status | integer | ||
preferred | text | ||
xmin_identity | xid |
SELECT i.pk AS pk_identity , n.id AS n_id , i.title , n.firstnames , n.lastnames , i.dob , i.cob , i.gender , _ (i.gender) AS l10n_gender , i.karyotype , i.pupic , CASE WHEN (i.fk_marital_status IS NULL) THEN 'unknown'::text ELSE ( SELECT ms.name FROM dem.marital_status ms , dem.identity i1 WHERE ( (ms.pk = i.fk_marital_status) AND (i1.pk = i.pk) ) ) END AS marital_status , CASE WHEN (i.fk_marital_status IS NULL) THEN _ ('unknown'::text) ELSE ( SELECT _ (ms1.name) AS _ FROM dem.marital_status ms1 , dem.identity i1 WHERE ( (ms1.pk = i.fk_marital_status) AND (i1.pk = i.pk) ) ) END AS l10n_marital_status , i.fk_marital_status AS pk_marital_status , n.preferred , i.xmin AS xmin_identity FROM dem.identity i , dem."names" n WHERE ( ( ( (i.deleted IS FALSE) AND (i.deceased IS NULL) ) AND (n.active = true) ) AND (n.id_identity = i.pk) );
F-Key | Name | Type | Description |
---|---|---|---|
pk_identity | integer | ||
pk_id | integer | ||
name | text | ||
value | text | ||
issuer | text | ||
context | character(1) | ||
comment | text | ||
pk_type | integer |
SELECT li2ei.id_identity AS pk_identity , li2ei.id AS pk_id , eit.name , li2ei.external_id AS value , eit.issuer , eit.context , li2ei."comment" , li2ei.fk_origin AS pk_type FROM dem.lnk_identity2ext_id li2ei , dem.enum_ext_id_types eit WHERE (li2ei.fk_origin = eit.pk);
F-Key | Name | Type | Description |
---|---|---|---|
tag | text | ||
l10n_tag | text | ||
label | text | ||
l10n_label | text | ||
comment | text | ||
sort_weight | integer | ||
pk_gender_label | integer |
SELECT gl.tag , _ (gl.tag) AS l10n_tag , gl.label , _ (gl.label) AS l10n_label , gl."comment" , gl.sort_weight , gl.pk AS pk_gender_label FROM dem.gender_label gl;
F-Key | Name | Type | Description |
---|---|---|---|
type | text | ||
l10n_type | text | ||
category | text | ||
l10n_category | text | ||
is_user_type | boolean | ||
is_user_category | boolean | ||
pk_type | integer | ||
pk_category | integer |
SELECT it.description AS "type" , _ (it.description) AS l10n_type , ic.description AS category , _ (ic.description) AS l10n_category , it.is_user AS is_user_type , ic.is_user AS is_user_category , it.pk AS pk_type , it.fk_inbox_item_category AS pk_category FROM dem.inbox_item_type it , dem.inbox_item_category ic WHERE (it.fk_inbox_item_category = ic.pk);
denormalized addressed per patient
F-Key | Name | Type | Description |
---|---|---|---|
pk_identity | integer | ||
pk_address | integer | ||
address_type | text | ||
l10n_address_type | text | ||
title | text | ||
firstnames | text | ||
lastnames | text | ||
dob | timestamp with time zone | ||
cob | character(2) | ||
gender | text | ||
l10n_gender | text | ||
preferred | text | ||
street | text | ||
postcode | text | ||
notes_street | text | ||
number | text | ||
subunit | text | ||
notes_subunit | text | ||
lat_lon_address | point | ||
postcode_street | text | ||
lat_lon_street | point | ||
suburb | text | ||
urb | text | ||
postcode_urb | text | ||
lat_lon_urb | point | ||
code_state | text | ||
state | text | ||
l10n_state | text | ||
code_country | character(2) | ||
country | text | ||
l10n_country | text | ||
country_deprecated | date | ||
pk_street | integer | ||
pk_urb | integer | ||
pk_state | integer | ||
pk_lnk_person_org_address | integer | ||
pk_address_type | integer | ||
xmin_lnk_person_org_address | xid |
SELECT vbp.pk_identity , va.pk_address ,"at".name AS address_type , _ ("at".name) AS l10n_address_type , vbp.title , vbp.firstnames , vbp.lastnames , vbp.dob , vbp.cob , vbp.gender , vbp.l10n_gender , vbp.preferred , va.street , va.postcode , va.notes_street , va.number , va.subunit , va.notes_subunit , va.lat_lon_address , va.postcode_street , va.lat_lon_street , va.suburb , va.urb , va.postcode_urb , va.lat_lon_urb , va.code_state , va.state , va.l10n_state , va.code_country , va.country , va.l10n_country , va.country_deprecated , va.pk_street , va.pk_urb , va.pk_state , lpoa.id AS pk_lnk_person_org_address , lpoa.id_type AS pk_address_type , lpoa.xmin AS xmin_lnk_person_org_address FROM dem.v_address va , dem.lnk_person_org_address lpoa , dem.v_basic_person vbp , dem.address_type "at" WHERE ( ( (lpoa.id_identity = vbp.pk_identity) AND (lpoa.id_address = va.pk_address) ) AND (lpoa.id_type = "at".id) );
denormalizes persons to communications channels
F-Key | Name | Type | Description |
---|---|---|---|
pk_identity | integer | ||
comm_type | text | ||
l10n_comm_type | text | ||
url | text | ||
is_confidential | boolean | ||
pk_link_identity2comm | integer | ||
pk_address | integer | ||
pk_type | integer |
SELECT li2c.fk_identity AS pk_identity , ect.description AS comm_type , _ (ect.description) AS l10n_comm_type , li2c.url , li2c.is_confidential , li2c.pk AS pk_link_identity2comm , li2c.fk_address AS pk_address , li2c.fk_type AS pk_type FROM dem.lnk_identity2comm li2c , dem.enum_comm_types ect WHERE (li2c.fk_type = ect.pk);
denormalizes the jobs a person has
F-Key | Name | Type | Description |
---|---|---|---|
pk_identity | integer | ||
firstnames | text | ||
lastnames | text | ||
preferred | text | ||
dob | timestamp with time zone | ||
gender | text | ||
occupation | text | ||
l10n_occupation | text | ||
activities | text | ||
modified_when | timestamp with time zone | ||
pk_occupation | integer | ||
pk_lnk_job2person | integer | ||
xmin_lnk_job2person | xid |
SELECT lj2p.fk_identity AS pk_identity , vbp.firstnames , vbp.lastnames , vbp.preferred , vbp.dob , vbp.gender , o.name AS occupation , _ (o.name) AS l10n_occupation , lj2p.activities , lj2p.modified_when , lj2p.fk_occupation AS pk_occupation , lj2p.pk AS pk_lnk_job2person , lj2p.xmin AS xmin_lnk_job2person FROM dem.lnk_job2person lj2p , dem.v_basic_person vbp , dem.occupation o WHERE ( (lj2p.fk_identity = vbp.pk_identity) AND (lj2p.fk_occupation = o.id) );
F-Key | Name | Type | Description |
---|---|---|---|
pk_identity | integer | ||
active_name | boolean | ||
title | text | ||
firstnames | text | ||
lastnames | text | ||
preferred | text | ||
comment | text | ||
gender | text | ||
identity_deleted | boolean | ||
deceased | boolean | ||
pk_name | integer | ||
xmin_name | xid |
SELECT dn.id_identity AS pk_identity , dn.active AS active_name , di.title , dn.firstnames , dn.lastnames , dn.preferred , dn."comment" , di.gender , di.deleted AS identity_deleted , (di.deceased IS NOT NULL) AS deceased , dn.id AS pk_name , dn.xmin AS xmin_name FROM dem."names" dn , dem.identity di WHERE (di.pk = dn.id_identity);
Denormalized messages for the providers.
F-Key | Name | Type | Description |
---|---|---|---|
provider | text | ||
importance | integer | ||
category | text | ||
l10n_category | text | ||
type | text | ||
l10n_type | text | ||
comment | text | ||
pk_context | integer | ||
data | text | ||
pk_provider_inbox | integer | ||
pk_staff | integer | ||
pk_category | integer | ||
pk_type | integer |
SELECT ( SELECT staff.short_alias FROM dem.staff WHERE (staff.pk = pi.fk_staff) ) AS provider , pi.importance , vit.category , vit.l10n_category , vit."type" , vit.l10n_type , pi."comment" , pi.ufk_context AS pk_context , pi.data , pi.pk AS pk_provider_inbox , pi.fk_staff AS pk_staff , vit.pk_category , pi.fk_inbox_item_type AS pk_type FROM dem.provider_inbox pi , dem.v_inbox_item_type vit WHERE (pi.fk_inbox_item_type = vit.pk_type) UNIONSELECT ( SELECT staff.short_alias FROM dem.staff WHERE (staff.pk = vo4dnd.pk_intended_reviewer) ) AS provider , 0 AS importance ,'clinical' AS category , _ ('clinical'::text) AS l10n_category ,'review docs' AS "type" , _ ('review docs'::text) AS l10n_type , ( SELECT ( ( ( ( (_ ('unreviewed documents for patient'::text) || ' ['::text ) || vbp.lastnames ) || ', '::text ) || vbp.firstnames ) || ']'::text ) FROM dem.v_basic_person vbp WHERE (vbp.pk_identity = vo4dnd.pk_patient) ) AS "comment" , vo4dnd.pk_patient AS pk_context , NULL::"unknown" AS data , NULL::"unknown" AS pk_provider_inbox , vo4dnd.pk_intended_reviewer AS pk_staff , ( SELECT v_inbox_item_type.pk_category FROM dem.v_inbox_item_type WHERE (v_inbox_item_type."type" = 'review docs'::text) ) AS pk_category , ( SELECT v_inbox_item_type.pk_type FROM dem.v_inbox_item_type WHERE (v_inbox_item_type."type" = 'review docs'::text) ) AS pk_type FROM blobs.v_obj4doc_no_data vo4dnd WHERE (vo4dnd.reviewed IS FALSE);
F-Key | Name | Type | Description |
---|---|---|---|
pk_identity | integer | ||
pk_staff | integer | ||
title | text | ||
firstnames | text | ||
lastnames | text | ||
short_alias | text | ||
role | text | ||
dob | timestamp with time zone | ||
gender | text | ||
db_user | name | ||
comment | text | ||
is_active | boolean | ||
can_login | boolean | ||
xmin_staff | xid | ||
pk_role | integer |
SELECT vbp.pk_identity , s.pk AS pk_staff , vbp.title , vbp.firstnames , vbp.lastnames , s.short_alias , _ (sr.name) AS "role" , vbp.dob , vbp.gender , s.db_user , s."comment" , s.is_active , ( SELECT ( ( SELECT (EXISTS ( SELECT 1 FROM pg_group WHERE ( ( ( SELECT pg_user.usesysid FROM pg_user WHERE (pg_user.usename = s.db_user) ) = ANY (pg_group.grolist) ) AND (pg_group.groname = current_database () ) ) ) ) ) AND ( SELECT (EXISTS ( SELECT 1 FROM pg_group WHERE ( ( ( SELECT pg_user.usesysid FROM pg_user WHERE (pg_user.usename = s.db_user) ) = ANY (pg_group.grolist) ) AND (pg_group.groname = 'gm-logins'::name) ) ) ) ) ) ) AS can_login , s.xmin AS xmin_staff , s.fk_role AS pk_role FROM dem.staff s , dem.staff_role sr , dem.v_basic_person vbp WHERE ( (s.fk_role = sr.pk) AND (s.fk_identity = vbp.pk_identity) );
denormalizes state information
F-Key | Name | Type | Description |
---|---|---|---|
pk_state | integer | ||
code_state | text | ||
state | text | ||
l10n_state | text | ||
code_country | character(2) | ||
country | text | ||
l10n_country | text | ||
country_deprecated | date | ||
xmin_state | xid |
SELECT s.id AS pk_state , s.code AS code_state , s.name AS state , _ (s.name) AS l10n_state , s.country AS code_country , c.name AS country , _ (c.name) AS l10n_country , c.deprecated AS country_deprecated , s.xmin AS xmin_state FROM dem.state s , dem.country c WHERE (c.code = s.country);
denormalizes street data
F-Key | Name | Type | Description |
---|---|---|---|
pk_street | integer | ||
street | text | ||
postcode | text | ||
postcode_street | text | ||
lat_lon_street | point | ||
suburb | text | ||
urb | text | ||
postcode_urb | text | ||
lat_lon_urb | point | ||
code_state | text | ||
state | text | ||
l10n_state | text | ||
code_country | character(2) | ||
country | text | ||
l10n_country | text | ||
country_deprecated | date | ||
pk_urb | integer | ||
pk_state | integer | ||
xmin_street | xid |
SELECT st.id AS pk_street , st.name AS street , COALESCE (st.postcode , vu.postcode_urb ) AS postcode , st.postcode AS postcode_street , st.lat_lon AS lat_lon_street , st.suburb , vu.urb , vu.postcode_urb , vu.lat_lon_urb , vu.code_state , vu.state , vu.l10n_state , vu.code_country , vu.country , vu.l10n_country , vu.country_deprecated , st.id_urb AS pk_urb , vu.pk_state , st.xmin AS xmin_street FROM dem.street st , dem.v_urb vu WHERE (st.id_urb = vu.pk_urb);
convenience view that selects urbs which: - have a zip code - are not referenced in table "street" with that zip code
F-Key | Name | Type | Description |
---|---|---|---|
postcode | text | ||
name | text | ||
state | text | ||
code_state | text | ||
country | text | ||
l10n_country | text | ||
code_country | character(2) |
SELECT urb.postcode , urb.name , stt.name AS state , stt.code AS code_state , c.name AS country , _ (c.name) AS l10n_country , stt.country AS code_country FROM dem.urb , dem.state stt , dem.country c WHERE ( ( ( (urb.postcode IS NOT NULL) AND (NOT (EXISTS ( SELECT 1 FROM dem.v_zip2street vz2str , dem.urb WHERE ( (vz2str.postcode = urb.postcode) AND (vz2str.urb = urb.name) ) ) ) ) ) AND (urb.id_state = stt.id) ) AND (stt.country = c.code) );
denormalizes urb data
F-Key | Name | Type | Description |
---|---|---|---|
pk_urb | integer | ||
urb | text | ||
postcode_urb | text | ||
lat_lon_urb | point | ||
code_state | text | ||
state | text | ||
l10n_state | text | ||
code_country | character(2) | ||
country | text | ||
l10n_country | text | ||
country_deprecated | date | ||
pk_state | integer | ||
xmin_urb | xid |
SELECT u.id AS pk_urb , u.name AS urb , u.postcode AS postcode_urb , u.lat_lon AS lat_lon_urb , vs.code_state , vs.state , vs.l10n_state , vs.code_country , vs.country , vs.l10n_country , vs.country_deprecated , u.id_state AS pk_state , u.xmin AS xmin_urb FROM dem.urb u , dem.v_state vs WHERE (vs.pk_state = u.id_state);
aggregates nearly all known data per zip code
F-Key | Name | Type | Description |
---|---|---|---|
zip | text | ||
street | text | ||
suburb | text | ||
urb | text | ||
state | text | ||
code_state | text | ||
country | text | ||
l10n_country | text | ||
code_country | bpchar |
SELECT vz2s.postcode AS zip , vz2s.street , vz2s.suburb , vz2s.urb , vz2s.state , vz2s.code_state , vz2s.country , vz2s.l10n_country , vz2s.code_country FROM dem.v_zip2street vz2s UNIONSELECT vuzu.postcode AS zip , NULL::"unknown" AS street , NULL::"unknown" AS suburb , vuzu.name AS urb , vuzu.state , vuzu.code_state , vuzu.country , vuzu.l10n_country , vuzu.code_country FROM dem.v_uniq_zipped_urbs vuzu;
list known data for streets that have a zip code
F-Key | Name | Type | Description |
---|---|---|---|
postcode | text | ||
street | text | ||
suburb | text | ||
state | text | ||
code_state | text | ||
urb | text | ||
country | text | ||
l10n_country | text | ||
code_country | character(2) |
SELECT COALESCE (str.postcode , urb.postcode ) AS postcode , str.name AS street , str.suburb , stt.name AS state , stt.code AS code_state , urb.name AS urb , c.name AS country , _ (c.name) AS l10n_country , stt.country AS code_country FROM dem.street str , dem.urb , dem.state stt , dem.country c WHERE ( ( ( (str.postcode IS NOT NULL) AND (str.id_urb = urb.id) ) AND (urb.id_state = stt.id) ) AND (stt.country = c.code) );
list known data for urbs that have a zip code
F-Key | Name | Type | Description |
---|---|---|---|
postcode | text | ||
urb | text | ||
state | text | ||
code_state | text | ||
country | text | ||
code_country | character(2) |
SELECT urb.postcode , urb.name AS urb , stt.name AS state , stt.code AS code_state , _ (c.name) AS country , stt.country AS code_country FROM dem.urb , dem.state stt , dem.country c WHERE ( ( (urb.postcode IS NOT NULL) AND (urb.id_state = stt.id) ) AND (stt.country = c.code) );
Add an external ID type if it does not exist yet. This implementation is prone to concurrency issues.
declare _name alias for $1; _issuer alias for $2; _context alias for $3; _pk int; begin select pk into _pk from dem.enum_ext_id_types where name = _name and issuer = _issuer; if FOUND then return _pk; end if; insert into dem.enum_ext_id_types(name, issuer, context) values (_name, _issuer, _context); select currval(pg_get_serial_sequence('dem.enum_ext_id_types', 'pk')) into _pk; return _pk; end;
DECLARE _id_identity alias for $1; _first alias for $2; _last alias for $3; _active alias for $4; _id integer; BEGIN -- deactivate all the existing names if this name is to become active if _active then update dem.names set active = false where id_identity = _id_identity; end if; -- name already there for this identity ? select into _id id from dem.names where id_identity = _id_identity and firstnames = _first and lastnames = _last; if FOUND then update dem.names set active = _active where id = _id; return _id; end if; -- no, insert new name insert into dem.names (id_identity, firstnames, lastnames, active) values (_id_identity, _first, _last, _active); if FOUND then return currval('dem.names_id_seq'); end if; return NULL; END;
This function takes as parameters the number of the address, the name of the street, the postal code of the address, the name of the urb, the code of the state, the code of the country and the subunit. If the country or the state do not exist in the database, the function fails. At first, the urb, the street and the address are tried to be retrieved according to the supplied information. If the fields do not match exactly an existing row, a new urb or street is created or a new address is created and returned.
DECLARE _number ALIAS FOR $1; _street ALIAS FOR $2; _postcode ALIAS FOR $3; _urb ALIAS FOR $4; _state_code ALIAS FOR $5; _country_code ALIAS FOR $6; _subunit alias for $7; _street_id integer; _address_id integer; msg text; BEGIN -- create/get street SELECT INTO _street_id dem.create_street(_street, _postcode, _urb, _state_code, _country_code); -- create/get and return address SELECT INTO _address_id a.id from dem.address a WHERE a.number ILIKE _number and a.id_street = _street_id; IF FOUND THEN RETURN _address_id; END IF; INSERT INTO dem.address (number, id_street, subunit) VALUES ( _number, _street_id, _subunit); RETURN currval('dem.address_id_seq'); END;
DECLARE _job alias for $1; _id integer; BEGIN select into _id id from dem.occupation where name = _job; if FOUND then return _id; end if; insert into dem.occupation (name) values (_job); return currval('dem.occupation_id_seq'); END;
This function takes a parameters the name of the street, the postal code, the name of the urb, the postcode of the urb, the code of the state and the code of the country. If the country or the state does not exists in the tables, the function fails. At first, both the urb and street are tried to be retrieved according to the supplied information. If the fields do not match exactly an existing row, a new urb is created or a new street is created and returned.
DECLARE _street ALIAS FOR $1; _postcode ALIAS FOR $2; _urb ALIAS FOR $3; _state_code ALIAS FOR $4; _country_code ALIAS FOR $5; _urb_id integer; _street_id integer; msg text; BEGIN -- create/get urb SELECT INTO _urb_id dem.create_urb(_urb, _postcode, _state_code, _country_code); -- create/get and return street SELECT INTO _street_id s.id from dem.street s WHERE s.name ILIKE _street AND s.id_urb = _urb_id AND postcode ILIKE _postcode; IF FOUND THEN RETURN _street_id; END IF; INSERT INTO dem.street (name, postcode, id_urb) VALUES (_street, _postcode, _urb_id); RETURN currval('dem.street_id_seq'); END;
This function takes a parameters the name of the urb, the postcode of the urb, the name of the state and the name of the country. If the country or the state does not exists in the tables, the function fails. At first, the urb is tried to be retrieved according to the supplied information. If the fields do not match exactly an existing row, a new urb is created and returned.
DECLARE _urb ALIAS FOR $1; _urb_postcode ALIAS FOR $2; _state_code ALIAS FOR $3; _country_code ALIAS FOR $4; _state_id integer; _urb_id integer; msg text; BEGIN -- get state SELECT INTO _state_id s.id from dem.state s WHERE s.code = _state_code and s.country = _country_code; IF NOT FOUND THEN msg := 'Cannot set address [' || coalesce(_country_code, 'country_code:NULL') || ', ' || coalesce(_state_code, 'state_code:NULL') || ', ' || coalesce(_urb, 'urb:NULL') || ', ' || coalesce(_urb_postcode, 'urb_postcode:NULL') || '].'; RAISE EXCEPTION '=> %', msg; END IF; -- get/create and return urb SELECT INTO _urb_id u.id from dem.urb u WHERE u.name ILIKE _urb AND u.id_state = _state_id; IF FOUND THEN RETURN _urb_id; END IF; INSERT INTO dem.urb (name, postcode, id_state) VALUES (_urb, _urb_postcode, _state_id); RETURN currval('dem.urb_id_seq'); END;
date_trunc() is not immutable because it depends on the timezone setting, hence need to use this in index creation, but also need to use it in queries which want to use that index, so make it generally available as a function
select date_trunc($1, $2 at time zone 'UTC');
select ($1 - (extract(year from $1) * '1 year'::interval)) - (now() - (extract(year from now()) * '1 year'::interval)) between (-1 * $2) and $3
BEGIN if NEW.active = false then raise exception 'Cannot delete/disable active name. Another name must be activated first.'; return OLD; end if; return NEW; END;
DECLARE BEGIN DELETE from dem.names WHERE id_identity=OLD.id; RETURN OLD; END;
DECLARE -- tmp text; BEGIN -- tmp := 'identity:' || NEW.id_identity || ',id:' || NEW.id || ',name:' || NEW.firstnames || ' ' || NEW.lastnames; -- raise notice 'uniq_active_name: [%]', tmp; if NEW.active = true then update dem.names set active = false where id_identity = NEW.id_identity and active = true; end if; return NEW; END;
declare _state_code text; _state_name text; _country_row record; begin _state_code := '??'; _state_name := 'state/territory/province/region not available'; -- add default state to countries needing one for _country_row in select distinct code from dem.country where code not in ( select country from dem.state where code = _state_code ) loop raise notice 'adding default state for [%]', _country_row.code; execute 'insert into dem.state (code, country, name) values (' || quote_literal(_state_code) || ', ' || quote_literal(_country_row.code) || ', ' || quote_literal(_state_name) || ');'; end loop; return true; end;
DECLARE BEGIN -- how does this work? How do we get new 'unique' numbers? RETURN '0000000000'; END;
Setting the nickname only makes sense for the currently active name. However, we also want to keep track of previous nicknames. Hence we would set the nickname right in the active name if it is NULL. It it contains a previous nickname (eg IS NOT NULL) we will inactivate the currently active name and copy it into a new active name but with the nickname set to the new one. Unsetting works the same (IOW *setting* to NULL).
DECLARE _id_identity alias for $1; _nick alias for $2; _names_row record; msg text; BEGIN -- 0.1: Just always set the nickname inside the active name -- post 0.1: openEHR-like (name: pk, fk_identity, name, fk_type, comment, is_legal, is_active ...) -- does name exist ? select into _names_row * from dem.names where id_identity = _id_identity and active = true; if not found then msg := 'Cannot set nickname [' || _nick || ']. No active <names> row with id_identity [' || _id_identity || '] found.'; raise exception '%', msg; end if; update dem.names set preferred = _nick where id = _names_row.id; return _names_row.id; END;
declare _pk_identity integer; begin _pk_identity := NULL; -- retrieve identity PK via pk if TG_OP = 'DELETE' then _pk_identity := OLD.pk; else _pk_identity := NEW.pk; end if; -- soft error out if not found if _pk_identity is NULL then raise notice 'dem.trf_announce_identity_mod(): cannot determine identity PK on table <dem.identity>'; return NULL; end if; -- now, execute() the NOTIFY execute 'notify "identity_mod_db:' || _pk_identity || '"'; return NULL; end;
declare _pk_identity integer; begin _pk_identity := NULL; -- retrieve identity PK via id_identity if TG_OP = 'DELETE' then _pk_identity := OLD.id_identity; else _pk_identity := NEW.id_identity; end if; -- soft error out if not found if _pk_identity is NULL then raise notice 'dem.trf_announce_name_mod(): cannot determine identity PK on table <dem.names>'; return NULL; end if; -- now, execute() the NOTIFY execute 'notify "name_mod_db:' || _pk_identity || '"'; return NULL; end;
begin execute 'notify "provider_inbox_mod_db:"'; return NULL; end;
begin if (NEW.title is null) then return NEW; end if; if trim(NEW.title) <> '' then return NEW; end if; NEW.title := NULL; return NEW; end;
All tables that want to send standard notifications must be recorded in this table. Notification triggers will be generated automatically for all tables recorded here.
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
schema_name | name | UNIQUE#1 NOT NULL DEFAULT 'public'::name | |
table_name | name | UNIQUE#1 NOT NULL | |
signal | name |
The name of the signal to send via NOTIFY. The actual name of the signal will be "<signal>_mod_db:<identity_pk>" where the :<identity_pk> is only added if the notify trigger knows how. |
|
carries_identity_pk | boolean |
DEFAULT false
Whether or not the signal delivers the PK of the related identity. Set during bootstrapping. |
Mark given table for notification trigger generator. Parameters are: (schema, table). Defaults signal to table name.
select gm.add_table_for_notifies($1, $2, $2);
Mark given table for notification trigger generator. Parameters are: (schema, table, signal name)
DECLARE _namespace alias for $1; _table alias for $2; _signal alias for $3; dummy RECORD; tmp text; BEGIN -- does table exist ? select relname into dummy from pg_class where relname = _table and relnamespace = (select oid from pg_namespace where nspname = _namespace) ; if not found then tmp := _namespace || '.' || _table; raise exception 'add_table_for_notifies: Table [%] does not exist.', tmp; end if; -- make sure we can insert delete from gm.notifying_tables where table_name = _table and schema_name = _namespace; insert into gm.notifying_tables ( schema_name, table_name, signal ) values ( _namespace, _table, _signal ); return true; END;
declare _struct text; begin select into _struct gm.concat_table_structure_v3(); return _struct; end;
declare _db_ver alias for $1; _struct text; begin if _db_ver < 6 then select into _struct gm.concat_table_structure_v1(); return _struct; end if; if _db_ver < 8 then select into _struct gm.concat_table_structure_v2(); return _struct; end if; select into _struct gm.concat_table_structure_v3(); return _struct; end;
copy of gm_concat_table_structure() until gnumed_v5, works on public, dem, clin, blobs
declare _row record; _total text; begin _total := ''; -- schema.table.column.data_type for _row in select * from information_schema.columns cols where cols.table_name in ( select tabs.table_name from information_schema.tables tabs where -- those which hold clinical data tabs.table_schema in ('public', 'dem', 'clin', 'blobs') and tabs.table_type = 'BASE TABLE' ) order by md5(cols.table_schema || cols.table_name || cols.column_name || cols.data_type) loop _total := _total || _row.table_schema || '.' || _row.table_name || '.' || _row.column_name || '::' || _row.udt_name || ' '; end loop; return _total; end;
new concat_table_structure() starting with gnumed_v6, works on dem, clin, blobs, cfg, ref, i18n
declare _row record; _total text; begin _total := ''; -- schema.table.column.data_type for _row in select * from information_schema.columns cols where cols.table_name in ( select tabs.table_name from information_schema.tables tabs where -- those which hold clinical data tabs.table_schema in ('dem', 'clin', 'blobs', 'cfg', 'ref', 'i18n') and tabs.table_type = 'BASE TABLE' ) order by md5(cols.table_schema || cols.table_name || cols.column_name || cols.data_type) loop _total := _total || _row.table_schema || '.' || _row.table_name || '.' || _row.column_name || '::' || _row.udt_name || ' '; end loop; return _total; end;
new concat_table_structure() starting with gnumed_v8, works on dem, clin, blobs, cfg, ref, i18n, sorts properly by bytea
declare _row record; _total text; begin _total := ''; -- schema.table.column.data_type for _row in select * from information_schema.columns cols where cols.table_name in ( select tabs.table_name from information_schema.tables tabs where -- those which hold clinical data tabs.table_schema in ('dem', 'clin', 'blobs', 'cfg', 'ref', 'i18n') and tabs.table_type = 'BASE TABLE' ) order by decode(md5(cols.table_schema || cols.table_name || cols.column_name || cols.data_type), 'hex') loop _total := _total || _row.table_schema || '.' || _row.table_name || '.' || _row.column_name || '::' || _row.udt_name || ' '; end loop; return _total; end;
declare _filename alias for $1; _version alias for $2; _hash text; begin delete from gm_schema_revision where filename = _filename; insert into gm_schema_revision (filename, version) values ( _filename, _version ); select into _hash md5(gm.concat_table_structure()); return _hash; end;
holds the currently selected per-user default language for fixed strings in the database
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
user | name | UNIQUE NOT NULL DEFAULT "current_user"() | |
lang | text | NOT NULL |
this table holds all the original strings that need translation so give this to your language teams, the function i18n.i18n() will take care to enter relevant strings into this table, the table table does NOT play any role in runtime translation activity
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
orig | text | UNIQUE NOT NULL |
this table holds all the translated strings
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
lang | text |
UNIQUE#1
NOT NULL
the language (corresponding to i18n.curr_lang for a given user) that this translation belongs to |
|
orig | text |
UNIQUE#1
NOT NULL
the original, untranslated string, used as the search key. |
|
trans | text |
NOT NULL
the translation of <orig> into <lang> |
lists per language which strings are lacking a translation
F-Key | Name | Type | Description |
---|---|---|---|
lang | text | ||
orig | text |
SELECT icl.lang , ik.orig FROM ( SELECT DISTINCT curr_lang.lang FROM i18n.curr_lang ORDER BY curr_lang.lang ) icl , i18n.keys ik WHERE (NOT (ik.orig IN ( SELECT translations.orig FROM i18n.translations ) ) );
force preferred language to some language: - for "current user"
DECLARE _lang ALIAS FOR $1; BEGIN raise notice 'Forcing current language to [%] without checking for translations..', _lang; delete from i18n.curr_lang where user = CURRENT_USER; insert into i18n.curr_lang(lang) values (_lang); return 1; END;
insert original strings into i18n.keys for later translation
DECLARE original ALIAS FOR $1; BEGIN if not exists(select pk from i18n.keys where orig = original) then insert into i18n.keys (orig) values (original); end if; return original; END;
set preferred language: - for "current user" - only if translations for this language are available
DECLARE _lang ALIAS FOR $1; BEGIN if exists(select pk from i18n.translations where lang = _lang) then delete from i18n.curr_lang where user = CURRENT_USER; insert into i18n.curr_lang (lang) values (_lang); return true; end if; raise notice 'Cannot set current language to [%]. No translations available.', _lang; return false; END;
set language to first argument for the user named in the second argument if translations are available
DECLARE _lang ALIAS FOR $1; _user ALIAS FOR $2; BEGIN if exists(select pk from i18n.translations where lang = _lang) then delete from i18n.curr_lang where user = _user; insert into i18n.curr_lang("user", lang) values (_user, _lang); return true; end if; raise notice 'Cannot set current language to [%]. No translations available.', _lang; return False; END;
declare _lang alias for $1; _orig alias for $2; _trans alias for $3; _tmp text; begin if _lang is null then raise notice 'i18n.upd_tx(text, text, text): Cannot create translation for language <NULL>.'; return False; end if; select into _tmp '1' from i18n.keys where orig=_orig; if not found then _tmp := 'String "' || _orig || '" not found in i18n.keys. No use storing translation.'; raise notice '%', _tmp; -- return 'String "' || _orig || '" not found in i18n.keys. No use storing translation.'; return False; end if; delete from i18n.translations where lang=_lang and orig=_orig; insert into i18n.translations (lang, orig, trans) values (_lang, _orig, _trans); -- return _orig || ' == (' || _lang || ') ==> ' || _trans; return True; end;
Standard public schema
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 | serial | PRIMARY KEY | |
code | text | UNIQUE NOT NULL | |
description | text | UNIQUE NOT NULL |
Table public.atc_group Inherits audit_fields,
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 | serial | PRIMARY KEY | |
code | text | UNIQUE NOT NULL | |
name | text | UNIQUE NOT NULL | |
ddd_amount | numeric | ||
public.unit.pk | fk_ddd_unit | integer | |
route | text | ||
comment | text |
Table public.atc_substance Inherits audit_fields,
basic units are SI units, units derived from them and the Unity
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
name_short | text | UNIQUE NOT NULL | |
name_long | text | UNIQUE |
Tables referencing this one via Foreign Key Constraints:
F-Key | Name | Type | Description |
---|---|---|---|
name | text | UNIQUE | |
pk | serial | PRIMARY KEY |
Tables referencing this one via Foreign Key Constraints:
List of fields for a particular form
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
ref.paperwork_templates.pk | fk_form | integer | UNIQUE#2 UNIQUE#1 NOT NULL |
long_name | text |
UNIQUE#2
NOT NULL
The full name of the form field as presented to the user |
|
template_placeholder | text |
UNIQUE#1
NOT NULL
The name of the field as exposed to the form template. In other words, the placeholder in form_defs.template where the value entered into this field ist to be substituted. Must be a valid identifier in the form template's script language (viz. Python) |
|
help | text |
longer help text |
|
public.form_field_types.pk | fk_type | integer |
NOT NULL
the field type |
param | text |
a parameter for the field's behaviour, meaning is type-dependent |
|
display_order | integer |
used to *suggest* display order, but client may ignore |
Tables referencing this one via Foreign Key Constraints:
Queue table for rendered form instances. Note that the rows in this table will get deleted after processing. This is NOT an archive of form jobs.
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
clin.form_instances.pk | fk_form_instance | integer |
NOT NULL
points to the unrendered source instance of the form, useful for recalling submitted jobs for changing |
form | bytea |
NOT NULL
the rendered form, IOW binary data such as a PDF file |
|
public.form_job_targets.pk | fk_job_target | integer |
NOT NULL
points to the job target |
submitted_when | timestamp with time zone |
NOT NULL
DEFAULT now()
when was this form job submitted |
|
fk_submitted_by | integer |
NOT NULL
who of the staff submitted this form job |
|
submitted_from | text |
NOT NULL
the workplace this form job was submitted from |
|
status | text |
NOT NULL
DEFAULT 'submitted'::text
status of the form job: - submitted: ready for processing - in progress: being processed - removable: fit for removal (either cancelled, timed out or done) - halted: do not process |
the form job targets (eg. printers, faxes, smtp servers) in whatever granularity is needed locally, can be used for load balancing/round robin servicing busy queues
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
target | text | UNIQUE NOT NULL |
Tables referencing this one via Foreign Key Constraints:
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
fk_form | integer | UNIQUE NOT NULL | |
ref.papersizes.pk | fk_papersize | integer | NOT NULL |
offset_top | integer |
NOT NULL
in mm - and yes, they do change even within one type of form, but we do not want to change the offset for all the fields in that case |
|
offset_left | integer | NOT NULL | |
pages | integer | NOT NULL DEFAULT 1 | |
printer | text | NOT NULL | |
tray | text | NOT NULL | |
manual_feed | boolean | NOT NULL DEFAULT false | |
papertype | text |
NOT NULL
type of paper such as "watermarked rose", mainly for user interaction on manual_feed==true |
|
eject_direction | character(1) | NOT NULL | |
orientation | character(1) | NOT NULL |
allows lookup of whether a given client version can work with a particular database revision
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
client_type | text |
UNIQUE#1
NOT NULL
the type of client this row refers to |
|
client_version | text |
UNIQUE#1
NOT NULL
the version of the client this row refers to |
|
db_identity_hash | text |
UNIQUE#1
NOT NULL
the identity_hash of a database revision that the client version can work with |
this table holds the revisions of all SQL scripts ever inserted into this database, the values are preferably provided by CVS tags in the scripts themselves, see above for a convenient way to do that
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
filename | text |
UNIQUE#1
NOT NULL
the name of the script, handled most easily by CVS via "RCSfile" |
|
version | text |
UNIQUE#1
NOT NULL
the version of the script, handled most easily by CVS via "Revision" |
|
imported | timestamp with time zone |
NOT NULL
DEFAULT now()
when this script was imported, mainly for debugging |
this table stores items that originate in headless processes running in the background but need to be brought to the attention of someone, say, errors that an integrity checker may find
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
reported_when | timestamp with time zone | NOT NULL DEFAULT now() | |
reported_by | text |
NOT NULL
DEFAULT "current_user"()
who or what reported this condition, may be a user or software |
|
reported_to | text |
NOT NULL
DEFAULT 'admin'::text
who is this condition reported to, user or admin, used for filtering |
|
problem | text |
NOT NULL
a description of the reported condition |
|
solution | text |
a proposed solution to the problem |
|
context | text |
specific context for this condition that would make the problem field unnecessary complex and bulky |
|
category | text |
NOT NULL
a category for the condition, this is used for filtering, too |
|
cookie | text |
stores arbitrary information related to the condition, mostly used for semantic duplicates detection, eg. do not report on a single problem more than once in subsequent runs of, say, an import script |
Name | Constraint |
---|---|
housekeeping_todo_reported_to_check | CHECK (((reported_to = 'user'::text) OR (reported_to = 'admin'::text))) |
This table links data tables to sources. Source entries may appear more than once (because they describe several tables) but table names must be unique in here. Note, however, that this table only links those data tables to their sources in which all rows have the very same source (such as ICD10). Tables where each row has its own source (say, literature references on diseases etc) will have a column constrained by a foreign key into ref_source directly.
F-Key | Name | Type | Description |
---|---|---|---|
public.ref_source.pk | fk_ref_source | integer | NOT NULL |
data_table | name | UNIQUE NOT NULL |
lists the available coding systems, classifications, ontologies and term lists
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 | serial | PRIMARY KEY | |
name_short | text |
UNIQUE
UNIQUE#1
NOT NULL
shorthand for referrring to this reference entry |
|
name_long | text |
UNIQUE
long, complete (, ?official) name for this reference entry |
|
version | text |
UNIQUE#1
NOT NULL
the exact and non-ambigous version for this entry |
|
description | text |
optional arbitrary description |
|
source | text |
UNIQUE
NOT NULL
non-ambigous description of source; with this info in hand it must be possible to locate a copy of the external reference |
Table public.ref_source Inherits audit_fields,
Tables referencing this one via Foreign Key Constraints:
each row defines one set of measurement reference data
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
public.ref_source.pk | fk_ref_src | integer |
UNIQUE#1
NOT NULL
source this reference data set was taken from |
data | text |
UNIQUE#1
NOT NULL
the actual reference data in some format, say, XML or like in a *.conf file |
|
comment | text |
units as used in real life
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
public.basic_unit.pk | fk_basic_unit | integer |
what is the SI-Standard unit for this, e.g. for the unit mg it is kg |
name_short | text | NOT NULL | |
name_long | text | ||
factor | double precision |
NOT NULL
DEFAULT 1.0
what factor the value with this unit has to be multiplied with to get values in the basic_unit |
|
shift | double precision |
NOT NULL
DEFAULT 0.0
what has to be added (after multiplying by factor) to a value with this unit to get values in the basic_unit |
Tables referencing this one via Foreign Key Constraints:
will return either the translation into i18n.curr_lang.lang for the current user or the input, created in public schema for easy access
DECLARE _orig ALIAS FOR $1; trans_str text; my_lang text; BEGIN -- get language select into my_lang lang from i18n.curr_lang where user = CURRENT_USER; if not found then return _orig; end if; -- get translation select into trans_str trans from i18n.translations where lang = my_lang and orig = _orig; if found then return trans_str; end if; return _orig; END;
will return either the translation into <text> (2nd argument) for the current user or the input, created in public schema for easy access
DECLARE _orig alias for $1; _lang alias for $2; trans_str text; BEGIN -- no translation available at all ? if not exists(select 1 from i18n.translations where orig = _orig) then return _orig; end if; -- get translation select into trans_str trans from i18n.translations where lang = _lang and orig = _orig; if not found then return _orig; end if; return trans_str; END;
function used to check referential integrity from clin.lnk_type2item to clin.clin_root_item with a custom trigger
declare dummy integer; msg text; begin -- does fk_item change at all ? if TG_OP = 'UPDATE' then if NEW.fk_item = OLD.fk_item then return NEW; end if; end if; -- check referential integrity select into dummy 1 from clin.clin_root_item where pk_item=NEW.fk_item; if not found then msg := 'referential integrity violation: clin.lnk_type2item.fk_item [' || NEW.fk_item || '] not in <clin_root_item.pk_item>'; raise exception '%', msg; return NULL; end if; return NEW; end;
begin if TG_OP = 'INSERT' then NEW.source_time_zone := (select (extract(timezone from (select now()))::text || 'seconds')::interval); else NEW.source_time_zone := OLD.source_time_zone; end if; return NEW; end;
To create users one needs to have superuser rights. We do not want to grant superuser rights to any GNUmed account, however. Therefore this function is owned by postgres and is set SECURITY DEFINER. Only gm-dbo is GRANTed EXECUTE. This way users need to know the gm-dbo (GNUmed admin) password to execute the function. Later on roles should be used to limit execution of this function.
DECLARE _username alias for $1; _password alias for $2; _database text; _query text; BEGIN perform 1 from pg_user where usename = _username; if not FOUND then _query := 'create user ' || quote_ident(_username) || ' with password ' || quote_literal(_password) || ';'; execute _query; perform 1 from pg_user where usename = _username; if not FOUND then raise exception 'cannot create user [%]', _username; return false; end if; end if; _query := 'alter group "gm-logins" add user ' || quote_ident(_username) || ';'; execute _query; _query := 'alter group "gm-doctors" add user ' || quote_ident(_username) || ';'; execute _query; _query := 'alter group "gm-public" add user ' || quote_ident(_username) || ';'; execute _query; -- satisfy "database = samegroup" in pg_hba.conf select into _database current_database(); _query := 'alter group ' || quote_ident(_database) || ' add user ' || quote_ident(_username) || ';'; execute _query; return true; END;
To disable users one needs to have superuser rights. We do not want to grant superuser rights to any GNUmed account, however. Therefore this function is owned by postgres and is set SECURITY DEFINER. Only gm-dbo is GRANTed EXECUTE. This way users need to know the gm-dbo (GNUmed admin) password to execute the function. Later on roles should be used to limit execution of this function.
DECLARE _username alias for $1; _query text; BEGIN perform 1 from pg_user where usename = _username; if not FOUND then return true; end if; _query := 'alter group "gm-logins" drop user ' || quote_ident(_username) || ';'; execute _query; return true; END;
To drop users one needs to have superuser rights. We do not want to grant superuser rights to any GNUmed account, however. Therefore this function is owned by postgres and is set SECURITY DEFINER. Only gm-dbo is GRANTed EXECUTE. This way users need to know the gm-dbo (GNUmed admin) password to execute the function. Later on roles should be used to limit execution of this function.
DECLARE _username alias for $1; _query text; BEGIN perform 1 from pg_user where usename = _username; if not FOUND then return true; end if; _query := 'drop user ' || quote_ident(_username) || ';'; execute _query; perform 1 from pg_user where usename = _username; if FOUND then return false; end if; return true; END;
DECLARE _source_group alias for $1; target_group text; member_ids int[]; member_id int; member_name text; tmp text; BEGIN -- source group exists ? perform 1 from pg_group where groname = _source_group; if not FOUND then raise exception 'gm_transfer_users(): source group [%] does not exist', _source_group; return false; end if; -- target group exists ? select into target_group current_database(); perform 1 from pg_group where groname = target_group; if not FOUND then raise exception 'gm_transfer_users(): target group [%] does not exist', target_group; return false; end if; -- loop over group member IDs select into member_ids grolist from pg_group where groname = _source_group; FOR idx IN coalesce(array_lower(member_ids, 1), 0) .. coalesce(array_upper(member_ids, 1), -1) LOOP member_id := member_ids[idx]; select into member_name usename from pg_user where usesysid = member_id; tmp := 'gm_transfer_users(text): transferring "' || member_name || '" (' || member_id || ') from group "' || _source_group || '" to group "' || target_group || '"'; raise notice '%', tmp; -- satisfy "database = samegroup" in pg_hba.conf tmp := 'alter group ' || quote_ident(target_group) || ' add user ' || quote_ident(member_name) || ';'; execute tmp; end LOOP; return true; END;
This schema holds data that is "reference material" which comes pre-installed with a GNUmed database. Examples are: - document types - ICD codes - form templates
pre-installed document types, do not change these as they will be overwritten during database upgrades at the discretion of the GNUmed team
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
scope | text |
can be used to group document types according to applicability, say, per country |
|
description | text | NOT NULL |
types of forms which are available, generally by purpose (radiology, pathology, sick leave, Therapiebericht etc.)
F-Key | Name | Type | Description |
---|---|---|---|
name | text | UNIQUE NOT NULL | |
pk | serial | PRIMARY KEY |
Tables referencing this one via Foreign Key Constraints:
F-Key | Name | Type | Description |
---|---|---|---|
pk | serial | PRIMARY KEY | |
name | text | UNIQUE NOT NULL | |
size | point |
NOT NULL
(cm, cm) |
Tables referencing this one via Foreign Key Constraints:
form and letter template definitions
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 | serial | PRIMARY KEY | |
ref.form_types.pk | fk_template_type | integer | NOT NULL |
instance_type | text |
default document type to store documents generated from this form under, note that this may generate rows in blobs.doc_type if set to a non-existant document type |
|
name_short | text |
UNIQUE#1
NOT NULL
a short name for use in a GUI or some such |
|
name_long | text |
UNIQUE#2
UNIQUE#1
NOT NULL
a long name unambigously describing the form |
|
external_version | text | UNIQUE#2 NOT NULL | |
gnumed_revision | double precision |
UNIQUE#2
GnuMed internal form def version, may occur if we rolled out a faulty form def |
|
engine | text |
NOT NULL
DEFAULT 'O'::text
the business layer forms engine used to process this form, currently: - T: plain text - L: LaTeX - H: Health Layer 7 - O: OpenOffice |
|
in_use | boolean |
NOT NULL
DEFAULT true
whether this template is currently actively used in a given practice |
|
filename | text |
the filename from when the template data was imported if applicable, used by some engines (such as OOo) to differentiate what to do with certain files, such as *.ott vs. *.ods, GNUmed uses it to derive a file extension when exporting the template data |
|
data | bytea |
the template complete with placeholders in the format accepted by the engine defined in ref.paperwork_templates.engine |
Table ref.paperwork_templates Inherits audit_fields,
Name | Constraint |
---|---|
paperwork_templates_engine_check | CHECK (((((engine = 'T'::text) OR (engine = 'L'::text)) OR (engine = 'H'::text)) OR (engine = 'O'::text))) |
Tables referencing this one via Foreign Key Constraints:
F-Key | Name | Type | Description |
---|---|---|---|
pk_paperwork_template | integer | ||
name_short | text | ||
name_long | text | ||
external_version | text | ||
template_type | text | ||
l10n_template_type | text | ||
instance_type | text | ||
l10n_instance_type | text | ||
engine | text | ||
in_use | boolean | ||
filename | text | ||
has_template_data | boolean | ||
has_instances | boolean | ||
last_modified | timestamp with time zone | ||
modified_by | text | ||
pk_template_type | integer | ||
xmin_paperwork_template | xid |
SELECT rpt.pk AS pk_paperwork_template , rpt.name_short , rpt.name_long , rpt.external_version , ( SELECT form_types.name FROM ref.form_types WHERE (form_types.pk = rpt.fk_template_type) ) AS template_type , ( SELECT _ (form_types.name) AS _ FROM ref.form_types WHERE (form_types.pk = rpt.fk_template_type) ) AS l10n_template_type , COALESCE (rpt.instance_type , ( SELECT form_types.name FROM ref.form_types WHERE (form_types.pk = rpt.fk_template_type) ) ) AS instance_type , COALESCE (_ (rpt.instance_type) , ( SELECT _ (form_types.name) AS _ FROM ref.form_types WHERE (form_types.pk = rpt.fk_template_type) ) ) AS l10n_instance_type , rpt.engine , rpt.in_use , rpt.filename , CASE WHEN (rpt.data IS NOT NULL) THEN true ELSE false END AS has_template_data , ( SELECT (EXISTS ( SELECT 1 FROM form_fields WHERE (form_fields.fk_form = rpt.pk) LIMIT 1 ) ) ) AS has_instances , rpt.modified_when AS last_modified , COALESCE ( ( SELECT staff.short_alias FROM dem.staff WHERE (staff.db_user = rpt.modified_by) ) , ( ('<'::text || (rpt.modified_by)::text ) || '>'::text ) ) AS modified_by , rpt.fk_template_type AS pk_template_type , rpt.xmin AS xmin_paperwork_template FROM ref.paperwork_templates rpt;
Do not allow updates to the template data if any forms already use this template.
BEGIN if NEW.data != OLD.data then -- look for references in clin.form_instances -- if there are any we fail this update no matter what perform 1 from clin.form_instances where fk_form_def = NEW.pk; if FOUND then raise exception 'Updating ref.paperwork_templates.data not allowed because it is referenced from existing forms.'; end if; end if; -- otherwise let it happen return NEW; END;
Generated by PostgreSQL Autodoc