File: v21-clin-v_waiting_list.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 (72 lines) | stat: -rw-r--r-- 1,514 bytes parent folder | download | duplicates (5)
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
-- ==============================================================
-- GNUmed database schema change script
--
-- License: GPL v2 or later
-- Author: Karsten Hilbert
--
-- ==============================================================
\set ON_ERROR_STOP 1

--set default_transaction_read_only to off;

-- --------------------------------------------------------------
drop view if exists clin.v_waiting_list cascade;

create view clin.v_waiting_list as
select
	c_wl.list_position
		as list_position,
	c_wl.area
		as waiting_zone,
	c_wl.urgency
		as urgency,
	d_i.title
		as title,
	d_n.firstnames
		as firstnames,
	d_n.lastnames
		as lastnames,
	d_n.preferred
		as preferred_name,
	d_i.dob
		as dob,
	d_i.gender
		as gender,
	_(d_i.gender)
		as l10n_gender,
	d_i.comment
		as comment_identity,
	c_wl.registered
		as registered,
	(select now() - c_wl.registered)
		as waiting_time,
	(select to_char(age(now(), c_wl.registered), 'DDD HH24:MI'))
		as waiting_time_formatted,
	c_wl.comment
		as comment,
	d_i.pk
		as pk_identity,
	d_n.id
		as pk_name,
	c_wl.pk
		as pk_waiting_list
from
	clin.waiting_list c_wl,
	dem.identity d_i,
	dem.names d_n
where
	c_wl.fk_patient = d_i.pk
		and
	c_wl.fk_patient = d_n.id_identity
		and
	d_i.deceased is NULL
		and
	d_n.active is TRUE
;


revoke all on clin.v_waiting_list from public;
grant select on clin.v_waiting_list to group "gm-public";

-- --------------------------------------------------------------
select gm.log_script_insertion('v21-clin-v_waiting_list.sql', '21.0');