1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
-- ==============================================================
-- GNUmed database schema change script
--
-- License: GPL v2 or later
-- Author: karsten.hilbert@gmx.net
--
-- ==============================================================
\set ON_ERROR_STOP 1
--set default_transaction_read_only to off;
-- --------------------------------------------------------------
-- Check: ref.paperwork_templates_engine_check (add H: HTML and S: XSLT as possible values)'
ALTER TABLE ref.paperwork_templates DROP CONSTRAINT if exists engine_range;
ALTER TABLE ref.paperwork_templates DROP CONSTRAINT if exists ref_templates_engine_range;
ALTER TABLE ref.paperwork_templates
ADD CONSTRAINT ref_templates_engine_range CHECK (
engine = ANY(ARRAY['T'::text, 'L'::text, 'H'::text, 'O'::text, 'I'::text, 'G'::text, 'P'::text, 'A'::text, 'X'::text, 'S'::text])
);
COMMENT ON COLUMN ref.paperwork_templates.engine IS 'the business layer forms engine used to process this form,
currently:
- T: plain text (generic postprocessing)
- L: LaTeX
- H: HTML
- O: OpenOffice
- I: image editor (visual progress notes)
- G: gnuplot scripts (test results graphing)
- P: PDF form (FDF based)
- A: AbiWord
- X: Xe(La)TeX
- S: XSLT';
-- --------------------------------------------------------------
-- .edit_after_substitution
comment on column ref.paperwork_templates.edit_after_substitution is
'Whether to offer last-minute, manual, generic editing inbetween placeholder substitution and final output generation.';
alter table ref.paperwork_templates
alter column edit_after_substitution
set default True;
update ref.paperwork_templates
set edit_after_substitution = True
where edit_after_substitution is null;
alter table ref.paperwork_templates
alter column edit_after_substitution
set not null;
-- --------------------------------------------------------------
-- ref.v_paperwork_templates
\unset ON_ERROR_STOP
drop view ref.v_paperwork_templates cascade;
\set ON_ERROR_STOP 1
create view ref.v_paperwork_templates as
select
pk
as pk_paperwork_template,
name_short,
name_long,
external_version,
(select name from ref.form_types where pk = fk_template_type)
as template_type,
(select _(name) from ref.form_types where pk = fk_template_type)
as l10n_template_type,
coalesce(instance_type, (select name from ref.form_types where pk = fk_template_type))
as instance_type,
coalesce(_(instance_type), (select _(name) from ref.form_types where pk = fk_template_type))
as l10n_instance_type,
engine,
in_use,
edit_after_substitution,
filename,
case
when data is not NULL then True
else False
end
as has_template_data,
-- (select exists(select 1 from public.form_fields where fk_form = r_pt.pk limit 1))
-- as has_instances,
modified_when
as last_modified,
coalesce (
(select short_alias from dem.staff where db_user = r_pt.modified_by),
'<' || r_pt.modified_by || '>'
) as modified_by,
fk_template_type
as pk_template_type,
xmin
as xmin_paperwork_template
from
ref.paperwork_templates r_pt
;
grant select on
ref.v_paperwork_templates
to group "gm-doctors";
-- --------------------------------------------------------------
delete from ref.paperwork_templates where name_long = 'Grünes Rezept (DE, GNUmed-Vorgabe)';
insert into ref.paperwork_templates (
fk_template_type,
instance_type,
name_short,
name_long,
external_version,
engine,
filename,
data
) values (
(select pk from ref.form_types where name = 'prescription'),
'prescription',
'Rpt Grün (GMd)',
'Grünes Rezept (DE, GNUmed-Vorgabe)',
'19.0',
'L',
'form-header.tex',
'real template missing'::bytea
);
-- --------------------------------------------------------------
select gm.log_script_insertion('v19-ref-paperwork_templates.sql', '19.0');
|