-- ============================================ -- medication tables create table clin_medication ( pk serial primary key, -- administrative last_prescribed date not null default CURRENT_DATE, fk_last_script integer default null references form_instances(pk) on update cascade on delete set null, discontinued date default null, -- identification brandname text default null, generic text default null, adjuvant text, dosage_form text not null, --check (form in ('spray', 'cap', 'tab', 'inh', 'neb', 'cream', 'syrup', 'lotion', 'drop', 'inj', 'oral liquid')) ufk_drug text not null, drug_db text not null, atc_code text not null, -- medical application dosage numeric[] not null, period interval not null, dosage_unit text not null check (dosage_unit in ('g', 'each', 'ml')), directions text default null, is_prn boolean default false -- is_SR boolean -- ??? ) inherits (clin_root_item); select add_table_for_audit ('clin_medication'); alter table clin_medication add constraint medication_is_plan check (soap_cat='p'); alter table clin_medication add constraint brand_or_generic_required check ((brandname is not null) or (generic is not null)); alter table clin_medication add constraint prescribed_after_started check (last_prescribed >= clin_when); alter table clin_medication add constraint discontinued_after_prescribed check (discontinued >= last_prescribed); comment on table clin_medication is '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) - clin_root_item.clin_when == "started": * when did patient start to take this medication * in most cases date of first prescription - but not always * for newly prescribed drugs identical to last_prescribed - clin_root_item.narrative == "prescribed_for": * use to specify intent beyond treating issue at hand '; comment on column clin_medication.last_prescribed is 'date last script written for this medication'; comment on column clin_medication.fk_last_script is 'link to the most recent script by which this drug was prescribed'; comment on column clin_medication.discontinued is 'date at which medication was *discontinued*, note that the date when a script *expires* should be calculatable'; comment on column clin_medication.brandname is 'the brand name of this drug under which it is marketed by the manufacturer'; comment on column clin_medication.generic is 'the generic name of the active substance'; comment on column clin_medication.adjuvant is 'free text describing adjuvants, such as "orange-flavoured" etc.'; comment on column clin_medication.dosage_form is 'the form the drug is delivered in, eg liquid, cream, table, etc.'; comment on column clin_medication.ufk_drug is 'the identifier for this drug in the source database, may or may not be an opaque value as regards GnuMed'; comment on column clin_medication.drug_db is 'the drug database used to populate this entry'; comment on column clin_medication.atc_code is 'the Anatomic Therapeutic Chemical code for this drug, used to compute possible substitutes'; comment on column clin_medication.dosage is '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 - 2 one and 2.5 the next would be [2, 2.5], period=48 - once a week would be [1] with period=168'; comment on column clin_medication.period is 'the length of the dosing cycle, in hours'; comment on column clin_medication.dosage_unit is 'the unit the dosages are measured in, "each" for discrete objects like tablets'; comment on column clin_medication.directions is 'free text for patient/pharmacist directions, such as "with food" etc'; comment on column clin_medication.is_prn is 'true if "pro re nata" (= as required)'; --comment on column clin_medication.is_SR is -- 'true if the slow-release preparation is used';