File: cfg-report_query.sql

package info (click to toggle)
gnumed-server 22.31-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 46,268 kB
  • sloc: sql: 1,217,633; python: 15,878; sh: 1,590; makefile: 20
file content (106 lines) | stat: -rw-r--r-- 2,630 bytes parent folder | download | duplicates (7)
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
-- ==============================================================
-- GNUmed database schema change script
--
-- Source database version: v5
-- Target database version: v6
--
-- License: GPL v2 or later
-- Author: Karsten Hilbert
-- 
-- ==============================================================
-- $Id: cfg-report_query.sql,v 1.3 2007-05-07 16:33:06 ncq Exp $
-- $Revision: 1.3 $

-- --------------------------------------------------------------
\set ON_ERROR_STOP 1

-- --------------------------------------------------------------
select audit.add_table_for_audit('cfg', 'report_query');



comment on table cfg.report_query is
	'This table stores SQL commands to be used in frontend report style queries.';



grant select, insert, update, delete on
	cfg.report_query
	, cfg.report_query_pk_seq
to group "gm-doctors";



\unset ON_ERROR_STOP
alter table cfg.report_query drop constraint "report_query_label_check";
\set ON_ERROR_STOP 1
alter table cfg.report_query
	add check (trim(coalesce(label, 'NULL')) <> '');



\unset ON_ERROR_STOP
alter table cfg.report_query drop constraint "report_query_cmd_check";
\set ON_ERROR_STOP 1
alter table cfg.report_query
	add check (trim(coalesce(cmd, 'NULL')) <> '');



delete from cfg.report_query where label = 'phone list (GNUmed)';
insert into cfg.report_query (label, cmd) values (
	'phone list (GNUmed)',
	'select
	p.lastnames || '', '' || p.firstnames as name,
	p.preferred,
	c.url
from
	dem.v_basic_person p,
	dem.v_person_comms c
where
	c.pk_identity = p.pk_identity
order by
	lastnames, firstnames'
);



delete from cfg.report_query where label = 'Tagesliste (GNUmed)';
insert into cfg.report_query (label, cmd) values (
	'Tagesliste (GNUmed)',
'select
	date_trunc(''minute'', clin_when),
	narrative
from
	clin.v_emr_journal
where
	pk_encounter in (
		-- ecnounters in range:
		select pk_encounter from
			clin.v_pat_encounters
		where
			started between dem.date_trunc_utc(''day'', now()) and now()
	)
	and modified_by like ''%'' || current_user || ''%''
order by clin_when'
);


-- --------------------------------------------------------------
select gm.log_script_insertion('$RCSfile: cfg-report_query.sql,v $', '$Revision: 1.3 $');

-- ==============================================================
-- $Log: cfg-report_query.sql,v $
-- Revision 1.3  2007-05-07 16:33:06  ncq
-- - log_script_insertion() now in gm.
--
-- Revision 1.2  2007/04/21 19:42:43  ncq
-- - add phone list and daily work list reports
--
-- Revision 1.1  2007/04/07 22:30:36  ncq
-- - factored out dynamic part
--
-- Revision 1.1  2007/04/06 23:10:54  ncq
-- - store data mining queries
--
--