-- ============================================ create table _enum_allergy_certainty ( id serial primary key, value varchar(32) unique not null ) ; create view vi18n_enum_allergy_certainty as select _enum_allergy_certainty.id, _(_enum_allergy_certainty.value) from _enum_allergy_certainty; -- -------------------------------------------- create table _enum_allergy_type ( id serial primary key, value varchar(32) unique not null ) ; create view vi18n_enum_allergy_type as select _enum_allergy_type.id, _(_enum_allergy_type.value) from _enum_allergy_type; -- -------------------------------------------- -- IMHO this is non-episode-related data create table allergy ( id serial primary key, id_clinical_transaction integer references clinical_transaction(id), substance varchar(128) not null, allergene varchar(256) default null, description text, certainty integer references _enum_allergy_certainty(id), type integer references _enum_allergy_type(id), first_observed varchar(32), code varchar(32) ) inherits (audit_clinical); -- certainty varchar(32) references vi18n_enum_allergy_certainty(value), -- type varchar(32) references vi18n_enum_allergy_type(value), comment on table allergy is 'patient allergy details'; comment on column allergy.id_clinical_transaction is 'link to transaction, provides: patient, recorded_when'; comment on column allergy.substance is 'real-world name of substance the patient reacted to'; comment on column allergy.allergene is 'name of allergenic ingredient in substance if known'; comment on column allergy.description is 'free-text description of reaction such as "difficulty breathing, "skin rash", "diarrhea" etc.'; comment on column allergy.certainty is 'definate/likely'; comment on column allergy.type is 'allergy/sensitivity'; comment on column allergy.first_observed is 'this has been observed when for the first time, if known'; comment on column allergy.code is 'ATC code of allergene or substance if approprate, applicable for penicilline, not so for cat fur';