[med-svn] [gnumed-server] 01/03: Imported Upstream version 20.10
Andreas Tille
tille at debian.org
Sun Jan 31 08:07:39 UTC 2016
This is an automated email from the git hooks/post-receive script.
tille pushed a commit to branch master
in repository gnumed-server.
commit 8c2ac71d576685edb5a56721fc1962c04a4bed24
Author: Andreas Tille <tille at debian.org>
Date: Sun Jan 31 08:44:06 2016 +0100
Imported Upstream version 20.10
---
server/bootstrap/fixup_db-v20.conf | 3 +
server/bootstrap/update_db-v19_v20.conf | 5 +-
server/doc/schema/gnumed-entire_schema.html | 2 +-
server/pycommon/gmNull.py | 4 +-
.../sql/v18-v19/fixups/v19-dem-org-idx-fixup.sql | 6 +-
.../sql/v18-v19/superuser/v19-install-pg_trgm.sql | 9 ++-
.../v19-v20/dynamic/v20-release_notes-dynamic.sql | 17 +++--
.../fixups/v20-clin-substance_intake-fixup.sql | 79 ++++++++++++++++++++++
.../fixups/v20-dem-org-idx-fixup.sql} | 15 +---
.../superuser/v20-install-pg_trgm.sql} | 9 ++-
10 files changed, 115 insertions(+), 34 deletions(-)
diff --git a/server/bootstrap/fixup_db-v20.conf b/server/bootstrap/fixup_db-v20.conf
index 995ac9f..4092da3 100644
--- a/server/bootstrap/fixup_db-v20.conf
+++ b/server/bootstrap/fixup_db-v20.conf
@@ -28,6 +28,8 @@ minimum postgresql version = 9.1
schema base directory = ../sql/v19-v20/fixups/
schema = $schema$
../dynamic/v20-release_notes-dynamic.sql
+v20-clin-substance_intake-fixup.sql
+v20-dem-org-idx-fixup.sql
$schema$
#----------------------------------
@@ -50,6 +52,7 @@ schema = $schema$
$schema$
superuser schema = $superuser schema$
+superuser/v20-install-pg_trgm.sql
$superuser schema$
upgrade plausibility checks = $upgrade plausibility checks$
diff --git a/server/bootstrap/update_db-v19_v20.conf b/server/bootstrap/update_db-v19_v20.conf
index 9eefa69..5238746 100644
--- a/server/bootstrap/update_db-v19_v20.conf
+++ b/server/bootstrap/update_db-v19_v20.conf
@@ -28,6 +28,7 @@ bundles = $bundles$
v19_fixups-pre_v20
v19-v20-static
v19-v20-dynamic
+v20-fixups
$bundles$
@@ -118,6 +119,8 @@ database alias = gnumed_v20
minimum postgresql version = 9.1
schema base directory = ../sql/v19-v20/fixups/
schema = $schema$
+v20-clin-substance_intake-fixup.sql
+v20-dem-org-idx-fixup.sql
$schema$
#----------------------------------
@@ -147,7 +150,7 @@ schema = $schema$
$schema$
superuser schema = $superuser schema$
-../v18-v19/superuser/v19-install-pg_trgm.sql
+superuser/v20-install-pg_trgm.sql
$superuser schema$
script base directory = ../sql/v19-v20/python/
diff --git a/server/doc/schema/gnumed-entire_schema.html b/server/doc/schema/gnumed-entire_schema.html
index fd98f2c..713c711 100644
--- a/server/doc/schema/gnumed-entire_schema.html
+++ b/server/doc/schema/gnumed-entire_schema.html
@@ -112,7 +112,7 @@
<body>
<!-- Primary Index -->
- <p><br><br>Dumped on 2015-11-21</p>
+ <p><br><br>Dumped on 2016-01-27</p>
<h1><a name="index">Index of database - gnumed_v20</a></h1>
<ul>
diff --git a/server/pycommon/gmNull.py b/server/pycommon/gmNull.py
index 2bc48a3..8967d80 100644
--- a/server/pycommon/gmNull.py
+++ b/server/pycommon/gmNull.py
@@ -113,7 +113,7 @@ class cNull(object):
def __str__(self):
"Convert to a string and return it."
- return 'cNull instance'
+ return '<cNull instance>'
def __nonzero__(self):
_log.debug(u'returns 0')
@@ -162,7 +162,7 @@ def test():
# representation and conversion to a string
tmp = '<cNull instance @ %s>' % id(n)
assert repr(n) == tmp
- assert str(n) == 'cNull instance'
+ assert str(n) == '<cNull instance>'
# comparing
if n == 1:
diff --git a/server/sql/v18-v19/fixups/v19-dem-org-idx-fixup.sql b/server/sql/v18-v19/fixups/v19-dem-org-idx-fixup.sql
index a64fb08..0a1ed5f 100644
--- a/server/sql/v18-v19/fixups/v19-dem-org-idx-fixup.sql
+++ b/server/sql/v18-v19/fixups/v19-dem-org-idx-fixup.sql
@@ -13,7 +13,7 @@ drop index if exists dem.idx_dem_org_fk_category cascade;
create index idx_dem_org_fk_category on dem.org(fk_category);
drop index if exists dem.idx_trgm_dem_org_desc cascade;
-create index idx_trgm_dem_org_desc on dem.org using gin (description gin_trgm_ops);
+create index idx_trgm_dem_org_desc on dem.org using gin (description pgtrgm.gin_trgm_ops);
-- --------------------------------------------------------------
drop index if exists dem.idx_dem_org_unit_fk_category cascade;
@@ -23,7 +23,7 @@ drop index if exists dem.idx_dem_org_unit_fk_address cascade;
create index idx_dem_org_unit_fk_address on dem.org_unit(fk_address);
drop index if exists dem.idx_trgm_dem_org_unit_desc cascade;
-create index idx_trgm_dem_org_unit_desc on dem.org_unit using gin (description gin_trgm_ops);
+create index idx_trgm_dem_org_unit_desc on dem.org_unit using gin (description pgtrgm.gin_trgm_ops);
-- --------------------------------------------------------------
-select gm.log_script_insertion('v19-dem-org-idx-fixup.sql', '19.9');
+select gm.log_script_insertion('v19-dem-org-idx-fixup.sql', '19.12');
diff --git a/server/sql/v18-v19/superuser/v19-install-pg_trgm.sql b/server/sql/v18-v19/superuser/v19-install-pg_trgm.sql
index 2a809fa..2c39e14 100644
--- a/server/sql/v18-v19/superuser/v19-install-pg_trgm.sql
+++ b/server/sql/v18-v19/superuser/v19-install-pg_trgm.sql
@@ -9,9 +9,12 @@
--set default_transaction_read_only to off;
-- --------------------------------------------------------------
-create extension if not exists pg_trgm with schema pg_catalog;
+drop schema if exists pgtrgm cascade;
+create schema pgtrgm;
+grant usage on schema pgtrgm to "gm-dbo";
-alter extension pg_trgm set schema pg_catalog;
+drop extension if exists pg_trgm cascade;
+create extension pg_trgm with schema pgtrgm;
-- --------------------------------------------------------------
-select gm.log_script_insertion('v19-install-pg_trgm.sql', '19.10');
+select gm.log_script_insertion('v19-install-pg_trgm.sql', '19.12');
diff --git a/server/sql/v19-v20/dynamic/v20-release_notes-dynamic.sql b/server/sql/v19-v20/dynamic/v20-release_notes-dynamic.sql
index 12b7d57..a5525b0 100644
--- a/server/sql/v19-v20/dynamic/v20-release_notes-dynamic.sql
+++ b/server/sql/v19-v20/dynamic/v20-release_notes-dynamic.sql
@@ -17,19 +17,18 @@ INSERT INTO dem.message_inbox (
) VALUES (
(select pk from dem.staff where db_user = 'any-doc'),
(select pk_type from dem.v_inbox_item_type where type = 'memo' and category = 'administrative'),
- 'Release Notes for GNUmed 1.5.9 (database v20.9)',
- 'GNUmed 1.5.9 Release Notes:
+ 'Release Notes for GNUmed 1.5.10 (database v20.10)',
+ 'GNUmed 1.5.10 Release Notes:
- 1.5.9
+ 1.5.10
-FIX: patient merging [thanks Marc]
+FIX: patient merging, again [thanks Marc]
-IMPROVED: update ES translations [thanks Uwe]
+ 20.10
- 20.9
-
-no changes
+FIX: pg_trgm placement and use
+FIX: clin.substance_intake.fk_episode SET NOT NULL
');
-- --------------------------------------------------------------
-select gm.log_script_insertion('v20-release_notes-dynamic.sql', '20.9');
+select gm.log_script_insertion('v20-release_notes-dynamic.sql', '20.10');
diff --git a/server/sql/v19-v20/fixups/v20-clin-substance_intake-fixup.sql b/server/sql/v19-v20/fixups/v20-clin-substance_intake-fixup.sql
new file mode 100644
index 0000000..15baac5
--- /dev/null
+++ b/server/sql/v19-v20/fixups/v20-clin-substance_intake-fixup.sql
@@ -0,0 +1,79 @@
+-- ==============================================================
+-- GNUmed database schema change script
+--
+-- License: GPL v2 or later
+-- Author: karsten.hilbert at gmx.net
+--
+-- ==============================================================
+\set ON_ERROR_STOP 1
+
+set check_function_bodies to 1;
+--set default_transaction_read_only to off;
+
+-- --------------------------------------------------------------
+-- .fk_episode
+create or replace function gm._add_substance_use_episodes()
+ returns boolean
+ language plpgsql
+ as '
+DECLARE
+ _curr_pat_id integer;
+ _curr_intake_id integer;
+ _substance_use_episode_id integer;
+BEGIN
+ -- loop over intakes w/o episode
+ FOR
+ _curr_intake_id, _curr_pat_id
+ IN
+ select pk_substance_intake, pk_patient from clin.v_nonbrand_intakes where pk_episode is null
+ LOOP
+
+ -- select substance use episode
+ select pk_episode INTO STRICT _substance_use_episode_id from clin.v_pat_episodes
+ where
+ summary ilike ''%[substance use]%''
+ and
+ pk_patient = _curr_pat_id;
+
+ --- create substance use episode
+ IF NOT FOUND THEN
+ insert into clin.episode
+ (description, is_open, fk_encounter, summary)
+ values (
+ ''substance use'',
+ False,
+ -- most recent encounter
+ (select pk from clin.encounter where fk_patient = _curr_pat_id order by last_affirmed desc limit 1),
+ ''[substance use] (auto-added by v20.10 @ '' || clock_timestamp()::text || '')''
+ )
+ returning pk into strict _substance_use_episode_id;
+ END IF;
+
+ -- update intake
+ update clin.substance_intake set
+ fk_episode = _substance_use_episode_id
+ where
+ pk = _curr_intake_id;
+
+ END LOOP;
+ RETURN true;
+END;';
+
+select gm._add_substance_use_episodes();
+
+drop function gm._add_substance_use_episodes() cascade;
+
+
+alter table clin.substance_intake
+ alter column fk_episode
+ set not null;
+
+
+alter table clin.substance_intake
+ drop constraint if exists sane_fk_episode cascade;
+
+
+drop function if exists clin.trf_sanity_check_substance_episode() cascade;
+
+-- --------------------------------------------------------------
+select gm.log_script_insertion('v20-clin-substance_intake-fixup.sql', '20.10');
diff --git a/server/sql/v18-v19/fixups/v19-dem-org-idx-fixup.sql b/server/sql/v19-v20/fixups/v20-dem-org-idx-fixup.sql
similarity index 59%
copy from server/sql/v18-v19/fixups/v19-dem-org-idx-fixup.sql
copy to server/sql/v19-v20/fixups/v20-dem-org-idx-fixup.sql
index a64fb08..7d43451 100644
--- a/server/sql/v18-v19/fixups/v19-dem-org-idx-fixup.sql
+++ b/server/sql/v19-v20/fixups/v20-dem-org-idx-fixup.sql
@@ -9,21 +9,12 @@
--set default_transaction_read_only to off;
-- --------------------------------------------------------------
-drop index if exists dem.idx_dem_org_fk_category cascade;
-create index idx_dem_org_fk_category on dem.org(fk_category);
-
drop index if exists dem.idx_trgm_dem_org_desc cascade;
-create index idx_trgm_dem_org_desc on dem.org using gin (description gin_trgm_ops);
+create index idx_trgm_dem_org_desc on dem.org using gin (description pgtrgm.gin_trgm_ops);
-- --------------------------------------------------------------
-drop index if exists dem.idx_dem_org_unit_fk_category cascade;
-create index idx_dem_org_unit_fk_category on dem.org_unit(fk_category);
-
-drop index if exists dem.idx_dem_org_unit_fk_address cascade;
-create index idx_dem_org_unit_fk_address on dem.org_unit(fk_address);
-
drop index if exists dem.idx_trgm_dem_org_unit_desc cascade;
-create index idx_trgm_dem_org_unit_desc on dem.org_unit using gin (description gin_trgm_ops);
+create index idx_trgm_dem_org_unit_desc on dem.org_unit using gin (description pgtrgm.gin_trgm_ops);
-- --------------------------------------------------------------
-select gm.log_script_insertion('v19-dem-org-idx-fixup.sql', '19.9');
+select gm.log_script_insertion('v20-dem-org-idx-fixup.sql', '20.10');
diff --git a/server/sql/v18-v19/superuser/v19-install-pg_trgm.sql b/server/sql/v19-v20/superuser/v20-install-pg_trgm.sql
similarity index 63%
copy from server/sql/v18-v19/superuser/v19-install-pg_trgm.sql
copy to server/sql/v19-v20/superuser/v20-install-pg_trgm.sql
index 2a809fa..2c39e14 100644
--- a/server/sql/v18-v19/superuser/v19-install-pg_trgm.sql
+++ b/server/sql/v19-v20/superuser/v20-install-pg_trgm.sql
@@ -9,9 +9,12 @@
--set default_transaction_read_only to off;
-- --------------------------------------------------------------
-create extension if not exists pg_trgm with schema pg_catalog;
+drop schema if exists pgtrgm cascade;
+create schema pgtrgm;
+grant usage on schema pgtrgm to "gm-dbo";
-alter extension pg_trgm set schema pg_catalog;
+drop extension if exists pg_trgm cascade;
+create extension pg_trgm with schema pgtrgm;
-- --------------------------------------------------------------
-select gm.log_script_insertion('v19-install-pg_trgm.sql', '19.10');
+select gm.log_script_insertion('v19-install-pg_trgm.sql', '19.12');
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/gnumed-server.git
More information about the debian-med-commit
mailing list