File: v15-clin-v_potential_problem_list.sql

package info (click to toggle)
gnumed-server 19.12-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 43,908 kB
  • ctags: 3,690
  • sloc: sql: 1,200,732; python: 12,836; sh: 1,145; makefile: 19
file content (84 lines) | stat: -rw-r--r-- 1,935 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
-- ==============================================================
-- GNUmed database schema change script
--
-- License: GPL v2 or later
-- Author: Karsten Hilbert
-- 
-- ==============================================================
\set ON_ERROR_STOP 1

-- --------------------------------------------------------------
\unset ON_ERROR_STOP
drop view clin.v_potential_problem_list cascade;
\set ON_ERROR_STOP 1


create view clin.v_potential_problem_list as

	-- all the (closed) episodes
	select
		(select fk_patient from clin.encounter where pk = cep.fk_encounter)
			as pk_patient,
		cep.description
			as problem,
		cep.summary
			as summary,
		'episode'
			as type,
		_('episode')
			as l10n_type,
		False
			as problem_active,
		False
			as clinically_relevant,
		cep.pk
			as pk_episode,
		cep.fk_health_issue
			as pk_health_issue,
		cep.diagnostic_certainty_classification
			as diagnostic_certainty_classification,
		cep.fk_encounter
			as pk_encounter
	from
		clin.episode cep
	where
		cep.is_open is false

union

	-- all the (clinically NOT relevant) health issues
	select
		(select fk_patient from clin.encounter where pk = chi.fk_encounter)
			as pk_patient,
		chi.description
			as problem,
		chi.summary
			as summary,
		'issue'
			as type,
		_('health issue')
			as l10n_type,
		chi.is_active
			as problem_active,
		False
			as clinically_relevant,
		null
			as pk_episode,
		chi.pk
			as pk_health_issue,
		chi.diagnostic_certainty_classification
			as diagnostic_certainty_classification,
		chi.fk_encounter
			as pk_encounter
	from
		clin.health_issue chi
	where
		chi.clinically_relevant is false
;


grant select on clin.v_potential_problem_list TO GROUP "gm-doctors";
-- --------------------------------------------------------------
select gm.log_script_insertion('$RCSfile: v15-clin-v_potential_problem_list.sql,v $', '$Revision: 1.2 $');

-- ==============================================================