[med-svn] [gnumed-server] 01/03: New upstream version 21.12
Andreas Tille
tille at debian.org
Tue Mar 14 13:11:25 UTC 2017
This is an automated email from the git hooks/post-receive script.
tille pushed a commit to branch master
in repository gnumed-server.
commit 5eae574001b1a5e476bff1bc1e5879eb2c645417
Author: Andreas Tille <tille at debian.org>
Date: Tue Mar 14 14:06:24 2017 +0100
New upstream version 21.12
---
server/bootstrap/fixup_db-v21.conf | 3 +
server/bootstrap/update_db-v20_v21.conf | 3 +
server/doc/schema/gnumed-entire_schema.html | 2 +-
server/pycommon/gmPG2.py | 2 +-
.../v20-v21/dynamic/v21-release_notes-dynamic.sql | 29 ++----
.../fixups/v21-clin-uppercase_soap_cat-fixup.sql | 21 ++++
.../sql/v20-v21/fixups/v21-dem-identity-fixup.sql | 108 +++++++++++++++++++++
.../v21-previously-missing-array_agg-fixup.sql | 38 ++++++++
8 files changed, 182 insertions(+), 24 deletions(-)
diff --git a/server/bootstrap/fixup_db-v21.conf b/server/bootstrap/fixup_db-v21.conf
index ad44a82..d8739da 100644
--- a/server/bootstrap/fixup_db-v21.conf
+++ b/server/bootstrap/fixup_db-v21.conf
@@ -27,6 +27,7 @@ database alias = gnumed_v21
minimum postgresql version = 9.2
schema base directory = ../sql/v20-v21/fixups/
schema = $schema$
+v21-previously-missing-array_agg-fixup.sql
v21-dem-view_grants-fixup.sql
../dynamic/v21-release_notes-dynamic.sql
v21-ref-auto_hint-tetanus_STIKO.sql
@@ -38,6 +39,8 @@ v21-ref-auto_hint-smoking_status-fixup.sql
v21-ref-GKV_CU-fixup.sql
v21-clin-get_hints_for_patient-fixup.sql
v21-notifications-dynamic.sql
+v21-clin-uppercase_soap_cat-fixup.sql
+v21-dem-identity-fixup.sql
$schema$
#----------------------------------
diff --git a/server/bootstrap/update_db-v20_v21.conf b/server/bootstrap/update_db-v20_v21.conf
index 3ac98f0..f1abb55 100644
--- a/server/bootstrap/update_db-v20_v21.conf
+++ b/server/bootstrap/update_db-v20_v21.conf
@@ -119,6 +119,7 @@ database alias = gnumed_v21
minimum postgresql version = 9.2
schema base directory = ../sql/v20-v21/fixups/
schema = $schema$
+v21-previously-missing-array_agg-fixup.sql
v21-dem-view_grants-fixup.sql
v21-ref-auto_hint-tetanus_STIKO.sql
v21-ref-auto_hint-klug_entscheiden_pulmo.sql
@@ -129,6 +130,8 @@ v21-ref-auto_hint-smoking_status-fixup.sql
v21-ref-GKV_CU-fixup.sql
v21-clin-get_hints_for_patient-fixup.sql
v21-notifications-dynamic.sql
+v21-clin-uppercase_soap_cat-fixup.sql
+v21-dem-identity-fixup.sql
$schema$
#----------------------------------
diff --git a/server/doc/schema/gnumed-entire_schema.html b/server/doc/schema/gnumed-entire_schema.html
index 26ae867..006f69d 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 2016-12-19</p>
+ <p><br><br>Dumped on 2017-02-10</p>
<h1><a name="index">Index of database - gnumed_v21</a></h1>
<ul>
diff --git a/server/pycommon/gmPG2.py b/server/pycommon/gmPG2.py
index 38990dc..70a4003 100644
--- a/server/pycommon/gmPG2.py
+++ b/server/pycommon/gmPG2.py
@@ -1540,7 +1540,7 @@ Query
conn.status,
conn.isexecuting(),
- cursor.query,
+ unicode(cursor.query, 'utf8', 'replace'),
)
return txt
diff --git a/server/sql/v20-v21/dynamic/v21-release_notes-dynamic.sql b/server/sql/v20-v21/dynamic/v21-release_notes-dynamic.sql
index a5b55b8..30fc8bb 100644
--- a/server/sql/v20-v21/dynamic/v21-release_notes-dynamic.sql
+++ b/server/sql/v20-v21/dynamic/v21-release_notes-dynamic.sql
@@ -17,32 +17,17 @@ 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.6.11 (database v21.11)',
- 'GNUmed 1.6.11 Release Notes:
+ 'Release Notes for GNUmed 1.6.12 (database v21.12)',
+ 'GNUmed 1.6.12 Release Notes:
- 1.6.11
+ 1.6.12
-IMPROVED: edit area refresh on first setting data
-IMPROVED: DB link error logging
-IMPROVED: suppressed hints display in patient overview
-IMPROVED: sorting of Hx items in patient overview
-IMPROVED: use of pdfinfo in gm-describe_file
+FIX: patient merging [thanks Marc]
-FIX: stall of gm-create_datamatrix in swap storm
-FIX: BMP creation without substance intakes
-FIX: missing quotes in BMP datafile [thanks Moritz]
-FIX: failure to sometimes store progress notes [thanks Marc]
-FIX: exception on double-clicking document tree label node
-FIX: exception on switching to drug database frontend [thanks a sk_SK]
-FIX: exception on saving hospital stay [thanks a sk_SK]
-FIX: exception on checking for upgrade [thanks Philipp]
+ 21.12
- 21.11
-
-IMPROVED: backup scripts error checking
-
-FIX: serialization failures due to table mod announcement triggers
+IMPROVED: logging on dem.identity/dem.names uniqueness violation
');
-- --------------------------------------------------------------
-select gm.log_script_insertion('v21-release_notes-dynamic.sql', '21.11');
+select gm.log_script_insertion('v21-release_notes-dynamic.sql', '21.12');
diff --git a/server/sql/v20-v21/fixups/v21-clin-uppercase_soap_cat-fixup.sql b/server/sql/v20-v21/fixups/v21-clin-uppercase_soap_cat-fixup.sql
new file mode 100644
index 0000000..1ffcf13
--- /dev/null
+++ b/server/sql/v20-v21/fixups/v21-clin-uppercase_soap_cat-fixup.sql
@@ -0,0 +1,21 @@
+-- ==============================================================
+-- GNUmed database schema change script
+--
+-- License: GPL v2 or later
+-- Author: karsten.hilbert at gmx.net
+--
+-- ==============================================================
+\set ON_ERROR_STOP 1
+--set default_transaction_read_only to off;
+
+-- --------------------------------------------------------------
+UPDATE clin.clin_root_item
+ SET soap_cat = lower(soap_cat)
+ WHERE
+ soap_cat IS DISTINCT FROM NULL
+ AND
+ soap_cat <> lower(soap_cat)
+;
+
+-- --------------------------------------------------------------
+select gm.log_script_insertion('v21-clin-uppercase_soap_cat-fixup.sql', '21.11');
diff --git a/server/sql/v20-v21/fixups/v21-dem-identity-fixup.sql b/server/sql/v20-v21/fixups/v21-dem-identity-fixup.sql
new file mode 100644
index 0000000..0f665cb
--- /dev/null
+++ b/server/sql/v20-v21/fixups/v21-dem-identity-fixup.sql
@@ -0,0 +1,108 @@
+-- ==============================================================
+-- GNUmed database schema change script
+--
+-- License: GPL v2 or later
+-- Author: karsten.hilbert at gmx.net
+--
+-- ==============================================================
+\set ON_ERROR_STOP 1
+--set default_transaction_read_only to off;
+
+set check_function_bodies to on;
+
+-- --------------------------------------------------------------
+drop function if exists clin.trf_sane_identity_comment() cascade;
+drop function if exists dem.trf_sane_identity_comment() cascade;
+
+
+-- create function and trigger
+create function dem.trf_sane_identity_comment()
+ returns trigger
+ language 'plpgsql'
+ as '
+DECLARE
+ _identity_row record;
+ _names_row record;
+ _other_identities integer[];
+BEGIN
+ -- working on dem.identity
+ if TG_TABLE_NAME = ''identity'' then
+ -- UPDATEs ...
+ if TG_OP = ''UPDATE'' then
+ -- ... which do NOT change .comment ...
+ if NEW.comment IS NOT DISTINCT FROM OLD.comment then
+ -- ... are safe because they were successfully INSERTed before
+ return NEW;
+ end if;
+ end if;
+ -- but INSERTs need checking
+ _identity_row := NEW;
+ select * into _names_row from dem.names where id_identity = NEW.pk;
+ -- working on dem.names
+ else
+ select * into _identity_row from dem.identity where pk = NEW.id_identity;
+ _names_row := NEW;
+ end if;
+
+ -- there cannot be any combination of identical
+ -- (dob, firstname, lastname, identity.comment)
+ -- so, look for clashing rows
+ SELECT array_agg(pk_identity) INTO _other_identities FROM
+ dem.v_person_names d_vpn
+ join dem.identity d_i on (d_i.pk = d_vpn.pk_identity)
+ WHERE
+ -- same firstname
+ d_vpn.firstnames = _names_row.firstnames
+ AND
+ -- same lastname
+ d_vpn.lastnames = _names_row.lastnames
+ AND
+ -- same gender
+ d_i.gender is not distinct from _identity_row.gender
+ AND
+ -- same dob (day)
+ date_trunc(''day'', d_i.dob) is not distinct from date_trunc(''day'', _identity_row.dob)
+ AND
+ -- same discriminator
+ d_i.comment is not distinct from _identity_row.comment
+ AND
+ -- but not the currently updated or inserted row
+ d_i.pk != _identity_row.pk
+ ;
+
+ if coalesce(array_length(_other_identities, 1), 0) > 0 then
+ RAISE EXCEPTION
+ ''% on %.%: More than one person with (firstnames=%), (lastnames=%), (dob=%), (comment=%): % & %'',
+ TG_OP,
+ TG_TABLE_SCHEMA,
+ TG_TABLE_NAME,
+ _names_row.firstnames,
+ _names_row.lastnames,
+ _identity_row.dob,
+ _identity_row.comment,
+ _identity_row.pk,
+ _other_identities
+ USING ERRCODE = ''unique_violation''
+ ;
+ RETURN NULL;
+ end if;
+
+ return NEW;
+END;';
+
+
+comment on function dem.trf_sane_identity_comment() is
+ 'Ensures unique(identity.dob, names.firstnames, names.lastnames, identity.comment)';
+
+
+create trigger tr_sane_identity_comment
+ after insert or update on dem.identity
+ for each row execute procedure dem.trf_sane_identity_comment();
+
+
+create trigger tr_sane_identity_comment
+ after insert or update on dem.names
+ for each row execute procedure dem.trf_sane_identity_comment();
+
+-- --------------------------------------------------------------
+select gm.log_script_insertion('v21-dem-identity-fixup.sql', '21.12');
diff --git a/server/sql/v20-v21/fixups/v21-previously-missing-array_agg-fixup.sql b/server/sql/v20-v21/fixups/v21-previously-missing-array_agg-fixup.sql
new file mode 100644
index 0000000..95b65d4
--- /dev/null
+++ b/server/sql/v20-v21/fixups/v21-previously-missing-array_agg-fixup.sql
@@ -0,0 +1,38 @@
+-- ==============================================================
+-- GNUmed database schema change script
+--
+-- License: GPL v2 or later
+-- Author: karsten.hilbert at gmx.net
+--
+-- ==============================================================
+\set ON_ERROR_STOP 1
+--set default_transaction_read_only to off;
+
+-- --------------------------------------------------------------
+-- back in the days, when GNUmed was still using pre 8.4 PGs
+-- we had to manually add a public.array_agg aggregate via
+-- v14-add_missing_array_bits.sql
+--
+-- nowadays (starting with PG 9.2), there's pg_catalog.array_agg
+-- for (anyelement), (anyarray), and (anynonarray), which results
+-- in, say:
+--
+-- PG error message: ERROR: function array_agg(integer) is not unique
+-- ZEILE 5: (SELECT array_agg(seq_idx) FROM blobs.doc_obj b_do WHERE ...
+-- TIP: Could not choose a best candidate function. You might need to add explicit type casts.
+--
+-- on using array_agg() with integers
+
+-- so, drop old helper aggregate
+drop aggregate if exists public.array_agg(anyelement) cascade;
+
+--CREATE AGGREGATE array_agg(anyelement) (
+-- SFUNC = array_append,
+-- STYPE = anyarray,
+-- INITCOND = ''{}''
+--);
+--comment on aggregate array_agg(anyelement) is
+-- ''Missing on PG 8.3, needed for vaccination handling starting with conversion from gnumed_v13 to gnumed_v14.'';
+
+-- --------------------------------------------------------------
+select gm.log_script_insertion('v21-previously-missing-array_agg-fixup.sql', '21.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