[med-svn] [Git][med-team/gnumed-server][upstream] New upstream version 22.7

Andreas Tille gitlab at salsa.debian.org
Fri Sep 13 13:02:47 BST 2019



Andreas Tille pushed to branch upstream at Debian Med / gnumed-server


Commits:
0cad4588 by Andreas Tille at 2019-09-13T11:45:10Z
New upstream version 22.7
- - - - -


13 changed files:

- server/bootstrap/fixup_db-v22.conf
- server/bootstrap/update_db-v21_v22.conf
- server/doc/schema/gnumed-entire_schema.html
- server/pycommon/gmLog2.py
- server/pycommon/gmPG2.py
- server/pycommon/gmTools.py
- + server/sql/v21-v22/data/v22-gm2gpl-plot_many_tests.gpl
- + server/sql/v21-v22/data/v22-gm2gpl-plot_one_test.gpl
- + server/sql/v21-v22/data/v22-gm2gpl-plot_two_tests.gpl
- + server/sql/v21-v22/fixups/v22-invoice_id_grants-fixup.sql
- server/sql/v21-v22/fixups/v22-ref-paperwork_templates-fixups.sql
- server/sql/v21-v22/fixups/v22-release_notes-fixup.sql
- + server/sql/v21-v22/python/v22-import-plot-scripts.py


Changes:

=====================================
server/bootstrap/fixup_db-v22.conf
=====================================
@@ -28,6 +28,7 @@ minimum postgresql version = 9.2
 schema base directory = ../sql/v21-v22/fixups/
 schema = $schema$
 v22-ref-paperwork_templates-fixups.sql
+v22-invoice_id_grants-fixup.sql
 v22-release_notes-fixup.sql
 $schema$
 
@@ -60,6 +61,7 @@ script base directory = ../sql/v21-v22/python/
 data import scripts = $data import scripts$
 v22-import-form-templates.py
 v22-2-fixup-form-templates.py
+v22-import-plot-scripts.py
 $data import scripts$
 
 #----------------------------------


=====================================
server/bootstrap/update_db-v21_v22.conf
=====================================
@@ -160,6 +160,7 @@ minimum postgresql version = 9.2
 schema base directory = ../sql/v21-v22/fixups/
 schema = $schema$
 v22-ref-paperwork_templates-fixups.sql
+v22-invoice_id_grants-fixup.sql
 v22-release_notes-fixup.sql
 $schema$
 
@@ -198,6 +199,7 @@ script base directory = ../sql/v21-v22/python/
 data import scripts = $data import scripts$
 v22-import-form-templates.py
 v22-2-fixup-form-templates.py
+v22-import-plot-scripts.py
 $data import scripts$
 
 
@@ -316,7 +318,7 @@ requests on results::::select count(1) from clin.test_result where fk_request is
 	select count(1) from clin.test_result where fk_request is not NULL
 clinical code links (total) - internal consistency::::select True
 	select ((select count(1) from clin.lnk_code2item_root) = (select ((select count(1) from clin.lnk_code2procedure) + (select count(1) from clin.lnk_code2rfe) + (select count(1) from clin.lnk_code2aoe) + (select count(1) from clin.lnk_code2episode) + (select count(1) from clin.lnk_code2h_issue) + (select count(1) from clin.lnk_code2narrative))))
-paperwork templates::::select count(1) + 1 from ref.paperwork_templates
+paperwork templates::::select count(1) + 2 from ref.paperwork_templates
 	select count(1) from ref.paperwork_templates
 automatic hints::::select count(1) from ref.auto_hint
 	select count(1) - 1 from ref.auto_hint


=====================================
server/doc/schema/gnumed-entire_schema.html
=====================================
@@ -112,7 +112,7 @@
   <body>
 
     <!-- Primary Index -->
-	<p><br><br>Dumped on 2019-07-28</p>
+	<p><br><br>Dumped on 2019-09-13</p>
 <h1><a name="index">Index of database - gnumed_v22</a></h1>
 <ul>
     


=====================================
server/pycommon/gmLog2.py
=====================================
@@ -199,10 +199,10 @@ def log_stack_trace(message=None, t=None, v=None, tb=None):
 	logger.debug(u'(locals by frame, outmost frame first)')
 	for frame in stack_of_frames:
 		logger.debug (
-			u'>>> execution frame [%s] in [%s] at line %s <<<',
+			u'--- frame [%s]: #%s, %s -------------------',
 			frame.f_code.co_name,
-			frame.f_code.co_filename,
-			frame.f_lineno
+			frame.f_lineno,
+			frame.f_code.co_filename
 		)
 		for varname, value in frame.f_locals.items():
 			if varname == u'__doc__':


=====================================
server/pycommon/gmPG2.py
=====================================
@@ -1580,6 +1580,8 @@ def sanitize_pg_regex(expression=None, escape_all=False):
 			'.', '\.'
 		).replace (
 			'*', '\*'
+		).replace (
+			'?', '\?'
 		)
 		#']', '\]',			# not needed
 
@@ -1835,17 +1837,17 @@ def run_rw_queries(link_obj=None, queries=None, end_tx=False, return_data=None,
 
 	<end_tx>
 		- controls whether the transaction is finalized (eg.
-		  committed/rolled back) or not, this allows the
+		  COMMITted/ROLLed BACK) or not, this allows the
 		  call to run_rw_queries() to be part of a framing
 		  transaction
-		- if link_obj is a connection then <end_tx> will
+		- if link_obj is a *connection* then <end_tx> will
 		  default to False unless it is explicitly set to
 		  True which is taken to mean "yes, you do have full
 		  control over the transaction" in which case the
 		  transaction is properly finalized
-		- if link_obj is a cursor we CANNOT finalize the
+		- if link_obj is a *cursor* we CANNOT finalize the
 		  transaction because we would need the connection for that
-		- if link_obj is None <end_tx> will, of course, always be True
+		- if link_obj is *None* <end_tx> will, of course, always be True
 
 	<return_data>
 		- if true, the returned data will include the rows


=====================================
server/pycommon/gmTools.py
=====================================
@@ -90,6 +90,7 @@ u_diameter = u'\u2300'
 u_checkmark_crossed_out = u'\u237B'
 u_box_vert_left = u'\u23b8'
 u_box_vert_right = u'\u23b9'
+u_space_as_open_box = u'\u2423'
 u_box_horiz_single = u'\u2500'				# -
 u_box_vert_light = u'\u2502'
 u_box_horiz_light_3dashes = u'\u2504'		# ...


=====================================
server/sql/v21-v22/data/v22-gm2gpl-plot_many_tests.gpl
=====================================
@@ -0,0 +1,152 @@
+#----------------------------------------------------
+# GNUmed gnuplotting script example:
+#
+#	plot several test results vertically aligned
+#
+#----------------------------------------------------
+
+# -- plot appearance setup ----
+# x axis: tics for data only, not mirrored (x2 shows yearly tics), and rotated *inwards*
+set xtics rotate by 45
+set xtics nomirror
+# x2 axis: yearly tics
+set x2tics out scale 1,0 format "%Y"
+# y axis: left only
+set ytics out format "{/*0.8 %h}"
+# y2 axis: no labels
+unset y2label
+# grid: stripes per year
+set grid noxtics x2tics noytics noy2tics
+# key: no key, will be shown in ylabel
+set key off
+# title: no titles per-plot
+unset title
+# adjacency of subplots
+set bmargin 1	# move closer together
+set lmargin 8	# align
+#set tmargin 0
+#set rmargin 0
+# size of PNG output:
+png_min_plot_width = 800
+png_width_per_year = 100
+png_height_per_plot = 350
+
+
+# -- helper functions and variables ----
+min_of(n, m) = (n < m)?n:m
+max_of(n, m) = (n > m)?n:m
+
+x_min_all_plots = 1e38
+x_max_all_plots = -1e38
+array y_ranges_min[multiplot_no_of_tests]
+array y_ranges_max[multiplot_no_of_tests]
+
+
+# -- debugging ----
+print "-- <show all> before plotting ----"
+show all
+print "-- <show variables all> before plotting ----"
+show variables all
+
+
+# STATS does not yet work with timedata, so dummy-plot
+# as ASCII art for accessing GP_* values
+set terminal dumb size 120, 45 * multiplot_no_of_tests feed enhanced mono #ansirgb
+set output gm2gpl_datafile.".txt"
+
+set multiplot layout multiplot_no_of_tests,1 title multiplot_title
+	do for [data_block_idx = 0:multiplot_no_of_tests-1] {
+		plot \
+			gm2gpl_datafile index data_block_idx using \
+				1: \
+				2: \
+				(valid(4) ? column(4) : column(2)): \
+				(valid(5) ? column(5) : column(2)): \
+				xticlabels(strftime("{/*.8 %b %d (%H:%M)}", timecolumn(1))) \
+			notitle with yerrorbars pointtype data_block_idx, \
+			gm2gpl_datafile index data_block_idx using \
+				1: \
+		    	2: \
+		    	(sprintf("%s%s", stringcolumn(2), stringcolumn(3))) \
+			notitle with labels right offset 0,1
+
+		x_min_all_plots = min_of(x_min_all_plots, GPVAL_X_MIN)
+		x_max_all_plots = max_of(x_max_all_plots, GPVAL_X_MAX)
+
+		y_ranges_min[data_block_idx + 1] = GPVAL_Y_MIN
+		y_ranges_max[data_block_idx + 1] = GPVAL_Y_MAX
+	}
+unset multiplot
+
+
+#print sprintf("x_min_all_plots: %d", x_min_all_plots)
+#print sprintf("x_max_all_plots: %d", x_max_all_plots)
+
+
+# -- detect x range and adjust by 10% of entire time span ----
+value_timerange = x_max_all_plots - x_min_all_plots
+timerange_offset = value_timerange * 10 / 100
+min_time_to_show = x_min_all_plots - timerange_offset
+max_time_to_show = x_max_all_plots + timerange_offset
+#print sprintf("min_time: %d", min_time_to_show)
+#print sprintf("max time: %d", max_time_to_show)
+
+
+# -- replot as PNG ----
+secs_per_year = 365 * 24 * 60 * 60
+total_secs = max_time_to_show - min_time_to_show
+total_years = total_secs / secs_per_year
+#print sprintf("total secs: %d", total_secs)
+#print sprintf("total yrs : %d", total_years)
+width_for_stack = max_of(png_min_plot_width, (total_years * png_width_per_year))
+#print sprintf("width : %d", width_for_stack)
+height_for_stack = png_height_per_plot * multiplot_no_of_tests
+#print sprintf("png: %d x %d", width_for_stack, height_for_stack)
+
+
+set terminal png size width_for_stack,height_for_stack enhanced transparent nointerlace truecolor #medium #crop
+set output gm2gpl_datafile.".png"
+
+
+set multiplot layout multiplot_no_of_tests,1 title multiplot_title
+	# adjust x/x2 range across all plots
+	set xrange [min_time_to_show:max_time_to_show]
+	set x2range [min_time_to_show:max_time_to_show]
+	do for [data_block_idx = 0:multiplot_no_of_tests - 1] {
+		if (data_block_idx > 0) {
+			# hide tic marks
+			set x2tics scale 0,0
+			# hide tic labels
+			set x2tics out format ""
+			# no top margin on lower plots
+			set tmargin 0
+		}
+		if (data_block_idx == (multiplot_no_of_tests - 1)) {
+			# lowest plot: rotate xtics down
+			set xtics rotate by -45
+			set bmargin 3
+		}
+		set ylabel multiplot_y_labels[data_block_idx + 1]
+		# adjust y range by 5% for this plot
+		five_percent = abs(y_ranges_max[data_block_idx + 1] * 5 / 100)
+		loffset = (y_ranges_min[data_block_idx + 1] == 0) ? 1 : five_percent
+		hoffset = (y_ranges_max[data_block_idx + 1] == 0) ? 1 : five_percent
+		min_y_to_show = y_ranges_min[data_block_idx + 1] - loffset
+		max_y_to_show = y_ranges_max[data_block_idx + 1] + hoffset
+		set yrange [min_y_to_show:max_y_to_show]
+		plot \
+			gm2gpl_datafile index data_block_idx using \
+				1: \
+				2: \
+				(valid(4) ? column(4) : column(2)): \
+				(valid(5) ? column(5) : column(2)): \
+				xticlabels(strftime("{/*.8 %b %d}", timecolumn(1))) \
+			notitle with yerrorbars pointtype data_block_idx, \
+			gm2gpl_datafile index data_block_idx using \
+				1: \
+		    	2: \
+		    	(sprintf("%s%s", stringcolumn(2), stringcolumn(3))) \
+		    notitle with labels boxed center
+			#notitle with labels right offset 0,1
+	}
+unset multiplot


=====================================
server/sql/v21-v22/data/v22-gm2gpl-plot_one_test.gpl
=====================================
@@ -0,0 +1,63 @@
+#----------------------------------------------------
+# GNUmed gnuplotting script example:
+#
+#	plot one test result type very space efficiently
+#
+#----------------------------------------------------
+
+# -- plot appearance setup ----
+set grid xtics noytics
+set autoscale
+set key off
+set key tmargin center horizontal Left #autotitle columnheader
+set key box opaque
+set style textbox opaque
+set bmargin 7
+# x and x2 axis:
+set xtics rotate by -45
+set xtics nomirror
+set x2tics out scale 1,0 format "%Y"
+# y and y2 axis:
+set ytics out format "{/*0.8 %h}"
+
+
+# -- debugging ----
+print "-- <show all> before plotting ----"
+show all
+print "-- <show variables all> before plotting ----"
+show variables all
+
+
+# -- plot data ----
+plot \
+	gm2gpl_datafile index 0 using \
+		1: \
+		2: \
+		(valid(4) ? column(4) : column(2)): \
+		(valid(5) ? column(5) : column(2)): \
+		xticlabels(strftime("{/*.8 %b %d (%H:%M)}", timecolumn(1))) \
+	notitle with yerrorbars pointtype 2, \
+	gm2gpl_datafile index 0 using \
+		1: \
+		2: \
+		(sprintf("%s%s", stringcolumn(2), stringcolumn(3))) \
+	notitle with labels center boxed
+	#notitle with labels offset 0, 1
+
+
+# -- adjust ranges for nicer display ----
+# detect x range and adjust by 10% of entire time span
+value_timerange = GPVAL_X_MAX - GPVAL_X_MIN
+timerange_offset = value_timerange * 10 / 100
+min_time_boundary = GPVAL_X_MIN - timerange_offset
+max_time_boundary = GPVAL_X_MAX + timerange_offset
+set xrange [min_time_boundary:max_time_boundary]
+set x2range [min_time_boundary:max_time_boundary]
+#set x2tics add (min_time_boundary, max_time_boundary)
+# detect y range and adjust by 5%
+five_percent = abs(GPVAL_Y_MIN * 5 / 100)
+loffset = (GPVAL_Y_MIN == 0) ? 1 : five_percent
+hoffset = (GPVAL_Y_MAX == 0) ? 1 : five_percent
+set yrange [(GPVAL_Y_MIN - loffset):(GPVAL_Y_MAX + hoffset)]
+# redraw with adjusted ranges
+replot


=====================================
server/sql/v21-v22/data/v22-gm2gpl-plot_two_tests.gpl
=====================================
@@ -0,0 +1,76 @@
+#----------------------------------------------------
+# GNUmed gnuplotting script example:
+#
+#	plot one test result type very space efficiently
+#
+#----------------------------------------------------
+
+# -- plot appearance setup ----
+#set title "your special title for this template"
+set grid xtics noytics
+set autoscale
+set key off
+set key tmargin center horizontal Left autotitle columnheader
+set key box opaque
+set style textbox opaque
+set bmargin 7
+# x and x2 axis:
+set xtics rotate by -45
+set xtics nomirror
+set x2tics out scale 1,0 format "%Y"
+# y and y2 axis:
+set ytics nomirror out format "{/*0.8 %h}"
+set y2tics nomirror out format "{/*0.8 %h}"
+
+
+# -- debugging ----
+print "-- <show all> before plotting ----"
+show all
+print "-- <show variables all> before plotting ----"
+show variables all
+
+
+# -- plot data ----
+plot \
+	gm2gpl_datafile index 0 using \
+		1: \
+		2: \
+		(valid(4) ? column(4) : column(2)): \
+		(valid(5) ? column(5) : column(2)): \
+		xticlabels(strftime("{/*.8 %b %d (%H:%M)}", timecolumn(1))) \
+	with yerrorbars pointtype 2, \
+	gm2gpl_datafile index 0 using \
+		1: \
+    	2: \
+    	(sprintf("%s%s", stringcolumn(2), stringcolumn(3))) \
+	notitle with labels right offset 0,1 , \
+	gm2gpl_datafile index 1 using \
+		1: \
+		2: \
+		(valid(4) ? column(4) : $2): \
+		(valid(5) ? column(5) : $2): \
+		xticlabels(strftime("{/*.8 %b %d (%H:%M)}", timecolumn(1))) \
+	with yerrorbars pointtype 3 axes x1y2, \
+	gm2gpl_datafile index 1 using \
+		1: \
+		2: \
+		(sprintf("%s%s", stringcolumn(2), stringcolumn(3))) \
+	notitle with labels left offset 0,-1 axes x1y2
+
+
+# -- adjust ranges for nicer display ----
+# detect x range and adjust by 10% of entire time span
+value_timerange = GPVAL_X_MAX - GPVAL_X_MIN
+timerange_offset = value_timerange * 10 / 100
+min_time_boundary = GPVAL_X_MIN - timerange_offset
+max_time_boundary = GPVAL_X_MAX + timerange_offset
+set xrange [min_time_boundary:max_time_boundary]
+set x2range [min_time_boundary:max_time_boundary]
+#set x2tics add (min_time_boundary, max_time_boundary)
+# detect y range and adjust by 5%
+five_percent = abs(GPVAL_Y_MIN * 5 / 100)
+loffset = (GPVAL_Y_MIN == 0) ? 1 : five_percent
+hoffset = (GPVAL_Y_MAX == 0) ? 1 : five_percent
+set yrange [(GPVAL_Y_MIN - loffset):(GPVAL_Y_MAX + hoffset)]
+# redraw with adjusted ranges
+replot


=====================================
server/sql/v21-v22/fixups/v22-invoice_id_grants-fixup.sql
=====================================
@@ -0,0 +1,16 @@
+-- ==============================================================
+-- 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;
+
+-- --------------------------------------------------------------
+-- needed for invoice ID uniqueness checks
+GRANT SELECT (invoice_id) ON audit.log_bill TO "gm-doctors" ;
+
+-- --------------------------------------------------------------
+select gm.log_script_insertion('v22-invoice_id_grants-fixup.sql', '22.7');


=====================================
server/sql/v21-v22/fixups/v22-ref-paperwork_templates-fixups.sql
=====================================
@@ -31,6 +31,29 @@ insert into ref.paperwork_templates (
 	'real template missing'::bytea
 );
 
+-- --------------------------------------------------------------
+delete from ref.paperwork_templates where name_long = 'lab results plot: many test types (GNUmed default)';
+
+insert into ref.paperwork_templates (
+	fk_template_type,
+	instance_type,
+	name_short,
+	name_long,
+	external_version,
+	engine,
+	filename,
+	data
+) values (
+	(select pk from ref.form_types where name = 'gnuplot script'),
+	'lab results plot',
+	'lab plot: >1 test (GMd)',
+	'lab results plot: many test types (GNUmed default)',
+	'22.7',
+	'G',
+	'plotscript.gpl',
+	'real template missing'::bytea
+);
+
 -- --------------------------------------------------------------
 -- convert paperwork templates
 


=====================================
server/sql/v21-v22/fixups/v22-release_notes-fixup.sql
=====================================
@@ -17,25 +17,28 @@ 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.7.6 (database v22.6)',
-	'GNUmed 1.7.6 Release Notes:
+	'Release Notes for GNUmed 1.7.7 (database v22.7)',
+	'GNUmed 1.7.7 Release Notes:
 
-	1.7.6
+	1.7.7
 
-FIX: application metadata files
-FIX: searching across all EMRs
-FIX: constrain document PRW to current patient
-FIX: lab/table: exception on double-clicking empty cell in row w/o meta test type
-FIX: lab/result EA: failure to show test type on edit
+FIX: EMR/tree: exception on showing visual progress note
+FIX: lab/result EA: exception when no previous result available
+FIX: meds/substance EA: exception when no LOINC selected
+FIX: data/ATC: fix reference data import
+FIX: meds/dose EA: exception on saving
+FIX: meds/product EA: exception on creating new product
+FIX: dist: fix appdata.xml [thanks Andreas]
 
-NEW: stub out $praxis_scan2pay$
+NEW: configurable invoice ID template [thanks Marc]
 
-	22.6
+	22.7
 
-FIX: properly include fixups in v21-v22 upgrade
+IMPROVED: lab results plotting scripts for gnuplot
+IMPROVED: bills tables grants for invoice ID generation
 
-IMPROVED: database backup script
+NEW: multi-results plotting script for gnuplot
 ');
 
 -- --------------------------------------------------------------
-select gm.log_script_insertion('v22-release_notes-fixup.sql', '22.6');
+select gm.log_script_insertion('v22-release_notes-fixup.sql', '22.7');


=====================================
server/sql/v21-v22/python/v22-import-plot-scripts.py
=====================================
@@ -0,0 +1,58 @@
+#==============================================================
+# GNUmed database schema change script
+#
+# License: GPL v2 or later
+# Author: karsten.hilbert at gmx.net
+# 
+#==============================================================
+import os
+
+from Gnumed.pycommon import gmPG2
+
+#--------------------------------------------------------------
+def run(conn=None):
+
+	# update
+	gmPG2.file2bytea (
+		query = u"""
+			UPDATE ref.paperwork_templates
+			SET
+				data = %(data)s::bytea,
+				external_version = 'v22.7'
+			WHERE
+				name_long = '1 test type plot script (GNUmed default)'
+			""",
+		filename = os.path.join('..', 'sql', 'v21-v22', 'data', 'v22-gm2gpl-plot_one_test.gpl'),
+		conn = conn
+	)
+
+	# update
+	gmPG2.file2bytea (
+		query = u"""
+			UPDATE ref.paperwork_templates
+			SET
+				data = %(data)s::bytea,
+				external_version = 'v22.7'
+			WHERE
+				name_long = '2 test types plot script (GNUmed default)'
+			""",
+		filename = os.path.join('..', 'sql', 'v21-v22', 'data', 'v22-gm2gpl-plot_two_tests.gpl'),
+		conn = conn
+	)
+
+	# new
+	gmPG2.file2bytea (
+		query = u"""
+			UPDATE ref.paperwork_templates
+			SET
+				data = %(data)s::bytea,
+				external_version = 'v22.7'
+			WHERE
+				name_long = 'lab results plot: many test types (GNUmed default)'
+			""",
+		filename = os.path.join('..', 'sql', 'v21-v22', 'data', 'v22-gm2gpl-plot_many_tests.gpl'),
+		conn = conn
+	)
+
+	return True
+#==============================================================



View it on GitLab: https://salsa.debian.org/med-team/gnumed-server/commit/0cad45888bc1fa34b86a7bbaed1e95b520ad1bde

-- 
View it on GitLab: https://salsa.debian.org/med-team/gnumed-server/commit/0cad45888bc1fa34b86a7bbaed1e95b520ad1bde
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20190913/a79ff7a8/attachment-0001.html>


More information about the debian-med-commit mailing list