File: v21-clin-v_suppressed_hints_journal.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 (98 lines) | stat: -rw-r--r-- 2,590 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
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
-- ==============================================================
-- 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;

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


create view clin.v_suppressed_hints_journal as
select
	c_enc.fk_patient
		as pk_patient,
	c_sh.modified_when
		as modified_when,
	c_sh.suppressed_when
		as clin_when,
	c_sh.modified_by
		as modified_by,
	'p'::text
		as soap_cat,
	case
		when r_vah.is_active is TRUE then
			_('Active hint')
		else
			_('Inactive hint')
	end
		|| ' #' || c_sh.fk_hint || ' ' || _('suppressed by') || ' ' || c_sh.suppressed_by || E'\n'
		|| coalesce(_('Title: ') || r_vah.title || E'\n', '')
		|| coalesce(_('URL: ') || r_vah.url || E'\n', '')
		|| coalesce(_('Source: ') || r_vah.source || E'\n', '')
		|| coalesce(_('Rationale: ') || c_sh.rationale || E'\n', '')
		|| case when c_sh.md5_sum <> r_vah.md5_sum
			then _('Hint definition has been modified since suppression. Rationale for suppression may no longer apply.') || E'\n'
			else ''
		end
		|| coalesce(_('Hint: ') || r_vah.hint || E'\n', '')
		|| coalesce(_('Recommendation: ') || r_vah.recommendation, '')
		as narrative,
	c_sh.fk_encounter
		as fk_encounter,
	NULL::integer
		as pk_episode,
	NULL::integer
		as pk_health_issue,
	c_sh.pk
		as src_pk,
	'clin.suppressed_hint'::text
		as src_table,
	c_sh.row_version
		as row_version,

	-- issue
	null::text
		as health_issue,
	null::text
		as issue_laterality,
	null::boolean
		as issue_active,
	null::boolean
		as issue_clinically_relevant,
	null::boolean
		as issue_confidential,

	-- episode
	null::text
		as episode,
	null::boolean
		as episode_open,

	-- encounter
	c_enc.started
		as encounter_started,
	c_enc.last_affirmed
		as encounter_last_affirmed,
	c_ety.description
		as encounter_type,
	_(c_ety.description)
		as encounter_l10n_type

from
	clin.suppressed_hint c_sh
		inner join clin.encounter c_enc on (c_sh.fk_encounter = c_enc.pk)
			inner join clin.encounter_type c_ety on (c_enc.fk_type = c_ety.pk)
		inner join ref.v_auto_hints r_vah on (c_sh.fk_hint = r_vah.pk_auto_hint)
;


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

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