[med-svn] [gnumed-client] 01/03: New upstream version 1.6.10+dfsg

Andreas Tille tille at debian.org
Tue Nov 8 17:20:42 UTC 2016


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository gnumed-client.

commit fe81f4dc079cb0bb458b0b428ae207da186f7fc4
Author: Andreas Tille <tille at debian.org>
Date:   Tue Nov 8 18:08:13 2016 +0100

    New upstream version 1.6.10+dfsg
---
 client/CHANGELOG                            | 16 ++++++
 client/business/gmAllergy.py                |  6 +-
 client/business/gmAutoHints.py              | 28 +++++++--
 client/business/gmClinNarrative.py          |  5 +-
 client/business/gmClinicalRecord.py         |  7 +++
 client/business/gmDICOM.py                  |  7 ++-
 client/business/gmMedication.py             |  7 ++-
 client/business/gmPerson.py                 |  8 ++-
 client/doc/gnumed.1                         | 14 ++++-
 client/doc/schema/gnumed-entire_schema.html |  2 +-
 client/gnumed.py                            | 10 +++-
 client/wxpython/gmAutoHintWidgets.py        |  8 +--
 client/wxpython/gmGuiMain.py                | 52 ++++++++++++-----
 client/wxpython/gmMacro.py                  | 88 ++++++++++++++++++++++++++++-
 client/wxpython/gmMedicationWidgets.py      | 34 ++++++-----
 client/wxpython/gmPatOverviewWidgets.py     |  4 +-
 16 files changed, 235 insertions(+), 61 deletions(-)

diff --git a/client/CHANGELOG b/client/CHANGELOG
index aa1c7c3..83eb9ab 100644
--- a/client/CHANGELOG
+++ b/client/CHANGELOG
@@ -6,6 +6,18 @@
 # rel-1-6-patches
 ------------------------------------------------
 
+	1.6.10
+
+FIX: more faults with dynamic hint detection
+FIX: exception on verifying substance intake EA
+FIX: failure to download studies from early Orthanc versions
+FIX: failure to create BMP when no allergy check date available
+
+IMPROVED: LaTeX formatting of current medications
+
+NEW: placeholders $<bill_adr_*>$ for accessing the address of a bill
+NEW: --wxp=2|3 command line option
+
 	1.6.9
 
 FIX: faulty detection of dynamic hint applicability
@@ -1805,6 +1817,10 @@ FIX: missing cast to ::text in dem.date_trunc_utc() calls
 # gnumed_v21
 ------------------------------------------------
 
+	21.10
+
+FIX: clin.get_hints_for_patient()
+
 	21.3
 
 FIX: GRANTs on demographics views [thanks Marc]
diff --git a/client/business/gmAllergy.py b/client/business/gmAllergy.py
index 9d29ba4..e7b43ef 100644
--- a/client/business/gmAllergy.py
+++ b/client/business/gmAllergy.py
@@ -138,7 +138,7 @@ class cAllergyState(gmBusinessDBObject.cBusinessDBObject):
 		# Zwischenüberschrift: 31 Zeichen, $..., 14pt, no frame, \textwidth
 		state = u'%s (%s)' % (
 			self.state_string,
-			gmDateTime.pydt_strftime(self['last_confirmed'], '%b %Y')
+			gmDateTime.pydt_strftime(self['last_confirmed'], '%b %Y', none_str = u'?')
 		)
 		if strict:
 			state = state[:31]
@@ -162,7 +162,7 @@ class cAllergyState(gmBusinessDBObject.cBusinessDBObject):
 		# Zwischenüberschrift: 31 Zeichen, $..., \textwidth
 		txt = u'$%s (%s)' % (
 			self.state_string,
-			gmDateTime.pydt_strftime(self['last_confirmed'], '%b %Y')
+			gmDateTime.pydt_strftime(self['last_confirmed'], '%b %Y', none_str = u'?')
 		)
 		if strict:
 			lines.append(txt[:32])
@@ -179,7 +179,7 @@ class cAllergyState(gmBusinessDBObject.cBusinessDBObject):
 	#--------------------------------------------------------
 	def _get_as_amts_data(self, strict=True):
 		# Zwischenüberschrift
-		state = u'%s (%s)' % (self.state_string, gmDateTime.pydt_strftime(self['last_confirmed'], '%b %Y'))
+		state = u'%s (%s)' % (self.state_string, gmDateTime.pydt_strftime(self['last_confirmed'], '%b %Y', none_str = u'?'))
 		if strict:
 			state = state[:32]
 		# Freitextzeile
diff --git a/client/business/gmAutoHints.py b/client/business/gmAutoHints.py
index 7230585..8bab052 100644
--- a/client/business/gmAutoHints.py
+++ b/client/business/gmAutoHints.py
@@ -125,7 +125,6 @@ def get_dynamic_hints(order_by=None, link_obj=None):
 		order_by = u'TRUE'
 	else:
 		order_by = u'TRUE ORDER BY %s' % order_by
-
 	cmd = _SQL_get_dynamic_hints % order_by
 	rows, idx = gmPG2.run_ro_queries(link_obj = link_obj, queries = [{'cmd': cmd}], get_col_idx = True)
 	return [ cDynamicHint(row = {'data': r, 'idx': idx, 'pk_field': 'pk_auto_hint'}) for r in rows ]
@@ -166,7 +165,7 @@ def delete_dynamic_hint(link_obj=None, pk_hint=None):
 	return True
 
 #------------------------------------------------------------
-def get_hints_for_patient(pk_identity=None, include_suppressed_needing_invalidation=False):
+def get_hints_for_patient(pk_identity=None, pk_encounter=None):
 	conn = gmPG2.get_connection()
 	curs = conn.cursor()
 	curs.callproc('clin.get_hints_for_patient', [pk_identity])
@@ -174,9 +173,26 @@ def get_hints_for_patient(pk_identity=None, include_suppressed_needing_invalidat
 	idx = gmPG2.get_col_indices(curs)
 	curs.close()
 	conn.rollback()
-	if include_suppressed_needing_invalidation:
-		return [ cDynamicHint(row = {'data': r, 'idx': idx, 'pk_field': 'pk_auto_hint'}) for r in rows ]
-	return [ cDynamicHint(row = {'data': r, 'idx': idx, 'pk_field': 'pk_auto_hint'}) for r in rows if r['rationale4suppression'] != 'magic_tag::please_invalidate_suppression' ]
+
+	applying_rows = []
+	for row in rows:
+		if row['rationale4suppression'] is None:
+			applying_rows.append(row)
+			continue
+		if row['rationale4suppression'].startswith(u'magic_tag::'):
+			_log.debug('hint with magic tag: %s', row['rationale4suppression'])
+			if u'suppression_needs_invalidation' in row['rationale4suppression']:
+				_log.debug('database asks for invalidation of suppression of hint [%s]', row)
+				if pk_encounter is not None:
+					invalidate_hint_suppression(pk_hint = row['pk_auto_hint'], pk_encounter = pk_encounter)
+			if u'does_not_apply' in row['rationale4suppression']:
+				continue
+			# we would need to reload the relevant hint at this time,
+			# however currently, only hints which do not apply ask
+			# for invalidation of suppression
+		applying_rows.append(row)
+
+	return [ cDynamicHint(row = {'data': r, 'idx': idx, 'pk_field': 'pk_auto_hint'}) for r in applying_rows ]
 
 #------------------------------------------------------------
 def suppress_dynamic_hint(pk_hint=None, rationale=None, pk_encounter=None):
@@ -303,7 +319,7 @@ def invalidate_hint_suppression(pk_hint=None, pk_encounter=None):
 						SELECT fk_patient FROM clin.encounter WHERE pk = %(enc)s
 					)
 			)
-		"""
+	"""
 	gmPG2.run_rw_queries(queries = [{'cmd': cmd, 'args': args}])
 	return True
 
diff --git a/client/business/gmClinNarrative.py b/client/business/gmClinNarrative.py
index f76dd9d..dbd5c78 100644
--- a/client/business/gmClinNarrative.py
+++ b/client/business/gmClinNarrative.py
@@ -457,10 +457,7 @@ def get_as_journal(since=None, until=None, encounters=None, episodes=None, issue
 	if active_encounter is not None:
 		# get rows from clin.get_hints_for_patient()
 		pk_identity = journal_rows[0]['pk_patient']
-		hints = gmAutoHints.get_hints_for_patient (
-			pk_identity = pk_identity,
-			include_suppressed_needing_invalidation = True
-		)
+		hints = gmAutoHints.get_hints_for_patient(pk_identity = pk_identity)
 		for hint in hints:
 			d = {}
 			d['date'] = gmDateTime.pydt_strftime(active_encounter['started'], '%Y-%m-%d')
diff --git a/client/business/gmClinicalRecord.py b/client/business/gmClinicalRecord.py
index 2ef0969..ca47211 100644
--- a/client/business/gmClinicalRecord.py
+++ b/client/business/gmClinicalRecord.py
@@ -2867,6 +2867,13 @@ SELECT MIN(earliest) FROM (
 		return self.calculator.bmi
 
 	bmi = property(_get_bmi, lambda x:x)
+
+	#------------------------------------------------------------------
+	def _get_dynamic_hints(self):
+		return gmAutoHints.get_hints_for_patient(pk_identity = self.pk_patient, pk_encounter = self.current_encounter['pk_encounter'])
+
+	dynamic_hints = property(_get_dynamic_hints, lambda x:x)
+
 	#------------------------------------------------------------------
 	#------------------------------------------------------------------
 	#------------------------------------------------------------------
diff --git a/client/business/gmDICOM.py b/client/business/gmDICOM.py
index 4a2713e..5177399 100644
--- a/client/business/gmDICOM.py
+++ b/client/business/gmDICOM.py
@@ -434,7 +434,12 @@ class cOrthancServer:
 		#  identifiers). Here is a sample command-line:
 		#  curl -X POST http://localhost:8042/tools/create-media -d '["8c4663df-c3e66066-9e20a8fc-dd14d1e5-251d3d84","2cd4848d-02f0005f-812ffef6-a210bbcf-3f01a00a","6eeded74-75005003-c3ae9738-d4a06a4f-6beedeb8","8a622020-c058291c-7693b63f-bc67aa2e-0a02e69c"]' -v > /tmp/a.zip
 		#  (this will not create duplicates but will also not check for single-patient-ness)
-		f.write(self.__run_POST(url = url, data = study_ids))
+		try:
+			f.write(self.__run_POST(url = url, data = study_ids))
+		except TypeError:
+			f.close()
+			_log.exception('cannot retrieve multiple studies as one archive with DICOMDIR, probably not supported by this Orthanc version')
+			return False
 		f.close()
 		if create_zip:
 			return filename
diff --git a/client/business/gmMedication.py b/client/business/gmMedication.py
index ce18704..8a9940c 100644
--- a/client/business/gmMedication.py
+++ b/client/business/gmMedication.py
@@ -3314,9 +3314,12 @@ def format_substance_intake(emr=None, output_format=u'latex', table_type=u'by-br
 		line_data[identifier]['brand'] = identifier
 		line_data[identifier]['strengths'].append(u'%s %s%s' % (med['substance'][:20], med['amount'], med['unit'].strip()))
 		line_data[identifier]['preparation'] = med['preparation']
+		sched_parts = []
 		if med['duration'] is not None:
-			line_data[identifier]['schedule'] = u'%s: ' % gmDateTime.format_interval(med['duration'], gmDateTime.acc_days, verbose = True)
-		line_data[identifier]['schedule'] += gmTools.coalesce(med['schedule'], u'')
+			sched_parts.append(gmDateTime.format_interval(med['duration'], gmDateTime.acc_days, verbose = True))
+		if med['schedule'] is not None:
+			sched_parts.append(med['schedule'])
+		line_data[identifier]['schedule'] = u': '.join(sched_parts)
 		if med['notes'] is not None:
 			if med['notes'] not in line_data[identifier]['notes']:
 				line_data[identifier]['notes'].append(med['notes'])
diff --git a/client/business/gmPerson.py b/client/business/gmPerson.py
index 2434cc7..603c198 100644
--- a/client/business/gmPerson.py
+++ b/client/business/gmPerson.py
@@ -1741,17 +1741,20 @@ class cPerson(gmBusinessDBObject.cBusinessDBObject):
 		return gmProviderInbox.get_overdue_messages(pk_patient = self._payload[self._idx['pk_identity']])
 
 	overdue_messages = property(_get_overdue_messages, lambda x:x)
+
 	#--------------------------------------------------------
 	def delete_message(self, pk=None):
 		return gmProviderInbox.delete_inbox_message(inbox_message = pk)
+
 	#--------------------------------------------------------
-	def _get_dynamic_hints(self, include_suppressed_needing_invalidation=False):
+	def _get_dynamic_hints(self, pk_encounter=None):
 		return gmAutoHints.get_hints_for_patient (
 			pk_identity = self._payload[self._idx['pk_identity']],
-			include_suppressed_needing_invalidation = include_suppressed_needing_invalidation
+			pk_encounter = pk_encounter
 		)
 
 	dynamic_hints = property(_get_dynamic_hints, lambda x:x)
+
 	#--------------------------------------------------------
 	def _get_suppressed_hints(self):
 		return gmAutoHints.get_suppressed_hints(pk_identity = self._payload[self._idx['pk_identity']])
@@ -1969,6 +1972,7 @@ class cPatient(cPerson):
 		return self.__emr
 
 	emr = property(get_emr, lambda x:x)
+
 	#----------------------------------------------------------
 	def get_document_folder(self):
 		if self.__doc_folder is None:
diff --git a/client/doc/gnumed.1 b/client/doc/gnumed.1
index b88b350..e3e20ee 100644
--- a/client/doc/gnumed.1
+++ b/client/doc/gnumed.1
@@ -20,6 +20,7 @@ You have been warned.
 .RB [--conf-file=FILE]
 .RB [--lang-gettext=LANGUAGE]
 .RB [--ui=UI-TYPE]
+.RB [--wxp=VERSION]
 .RB [--override-schema-check]
 .RB [--local-import]
 .RB [--help]
@@ -86,8 +87,19 @@ default the interface to wxPython.
 Valid values are:
 
 	wxp: wxPython Python client (default)
+.\"
+.\"	web: CherryPy web client
+.TP
+.B \--wxp=VERSION
+Explicitly request a wxPython major version. Omitting the argument
+will default to trying wxPython 3 first, then attempting to fall
+back to wxPython 2.
+
+Valid values are:
+
+	2: request wxPython 2
 
-	web: CherryPy web client
+	3: request wxPython 3
 .TP
 .B \--override-schema-check
 Continue loading the client even if the database schema
diff --git a/client/doc/schema/gnumed-entire_schema.html b/client/doc/schema/gnumed-entire_schema.html
index 967cdf5..c6321db 100644
--- a/client/doc/schema/gnumed-entire_schema.html
+++ b/client/doc/schema/gnumed-entire_schema.html
@@ -112,7 +112,7 @@
   <body>
 
     <!-- Primary Index -->
-	<p><br><br>Dumped on 2016-09-12</p>
+	<p><br><br>Dumped on 2016-11-07</p>
 <h1><a name="index">Index of database - gnumed_v21</a></h1>
 <ul>
     
diff --git a/client/gnumed.py b/client/gnumed.py
index 135bee9..f721e40 100644
--- a/client/gnumed.py
+++ b/client/gnumed.py
@@ -45,7 +45,10 @@ care of all the pre- and post-GUI runtime environment setup.
  Adjust the PYTHONPATH such that GNUmed can be run from a local source tree.
 --ui=<ui type>
  Start an alternative UI. Defaults to wxPython if not specified.
- Valid values: chweb (CherryPy), wxp (wxPython), web (ProxiedWeb)
+ Currently "wxp" (wxPython) only.
+--wxp=<version>
+ Explicitely request a wxPython version. Can be set to either "2" or "3".
+ Defaults to "try 3, then 2" if not set.
 --version, -V
  Show version information.
 --help, -h, or -?
@@ -88,7 +91,7 @@ against. Please run GNUmed as a non-root user.
 	sys.exit(1)
 
 #----------------------------------------------------------
-current_client_version = u'1.6.9'
+current_client_version = u'1.6.10'
 current_client_branch = u'1.6'
 
 _log = None
@@ -110,7 +113,8 @@ _known_long_options = [
 	u'local-import',
 	u'help',
 	u'version',
-	u'hipaa'
+	u'hipaa',
+	u'wxp='
 ]
 
 _known_ui_types = [
diff --git a/client/wxpython/gmAutoHintWidgets.py b/client/wxpython/gmAutoHintWidgets.py
index 1bcac5c..1f593c8 100644
--- a/client/wxpython/gmAutoHintWidgets.py
+++ b/client/wxpython/gmAutoHintWidgets.py
@@ -69,16 +69,14 @@ def _display_clinical_reminders():
 		)
 
 	# dynamic hints
+	emr = pat.get_emr(allow_user_interaction = False)
 	hint_dlg = cDynamicHintDlg(wx.GetApp().GetTopWindow(), -1)
-	for hint in pat._get_dynamic_hints(include_suppressed_needing_invalidation = True):
-		if hint['rationale4suppression'] == u'magic_tag::please_invalidate_suppression':
-			_log.debug('database asks for invalidation of suppression of hint [%s]', hint)
-			hint.invalidate_suppression(pk_encounter = pat.emr.current_encounter['pk_encounter'])
+	for hint in emr.dynamic_hints:
 		hint_dlg.hint = hint
 		if hint_dlg.ShowModal() == wx.ID_APPLY:
 			hint.suppress (
 				rationale = hint_dlg.rationale.strip(),
-				pk_encounter = pat.emr.current_encounter['pk_encounter']
+				pk_encounter = emr.current_encounter['pk_encounter']
 			)
 	hint_dlg.Destroy()
 
diff --git a/client/wxpython/gmGuiMain.py b/client/wxpython/gmGuiMain.py
index 501bde5..dab34b4 100644
--- a/client/wxpython/gmGuiMain.py
+++ b/client/wxpython/gmGuiMain.py
@@ -31,27 +31,51 @@ import glob
 
 _log = logging.getLogger('gm.main')
 
-# 3rd party libs
-# maybe show HTML page if wxversion/wx cannot be imported (and thus needs to be installed) ?
+
+# GNUmed libs
+from Gnumed.pycommon import gmCfg2
+_cfg = gmCfg2.gmCfgData()
+
+
+# 3rd party libs: wxPython
+
 # wxpython version cannot be enforced inside py2exe and friends
 if not hasattr(sys, 'frozen'):
+	# maybe show HTML page if wxversion/wx cannot be imported (and thus needs to be installed) ?
 	import wxversion
 	_log.debug(u'wxPython versions available on this machine: %s', wxversion.getInstalled())
-	# we'll check options further down because we want to
-	# support 3.0 as well and while that supports unicode
-	# builds only anyway it don't respond well to requiring
-	# a "-unicode" option indicator, ... :-/
-	# try to select wxPython 3 but fall back to 2.8 on failure
-	try:
-		wxversion.select(versions = '3.0')
-	except wxversion.VersionError:
-		_log.exception('cannot select wxPython 3.0')
+	desired_wxp = _cfg.get(option = '--wxp', source_order = [('cli', 'return')])
+	if desired_wxp is None:
+		desired_wxp = None
+	# let GNUmed work out the best wxPython available
+	if desired_wxp is None:
+		_log.debug('no wxPython version requested explicitely, trying wxp3, then wxp2')
+		# we'll check options further down because we want to
+		# support 3.0 as well and while that supports unicode
+		# builds only anyway it don't respond well to requiring
+		# a "-unicode" option indicator, ... :-/
+		# try to select wxPython 3 but fall back to 2.8 on failure
+		try:
+			wxversion.select(versions = '3.0')
+		except wxversion.VersionError:
+			_log.exception('cannot select wxPython 3.0')
+			wxversion.select(versions = '2.8-unicode', optionsRequired = True)
+	elif desired_wxp == u'2':
+		_log.debug('wxPython 2 requested explicitely')
 		wxversion.select(versions = '2.8-unicode', optionsRequired = True)
+	elif desired_wxp == u'3':
+		_log.debug('wxPython 3 requested explicitely')
+		wxversion.select(versions = '3.0')
+	else:
+		_log.error('invalid wxPython version requested: %s', desired_wxp)
+		print('CRITICAL ERROR: Invalid wxPython version requested. Halted.')
+		raise ValueError('invalid wxPython version requested: %s' % desired_wxp)
 
 try:
 	import wx
 	_log.info('wxPython version loaded: %s %s' % (wx.VERSION_STRING, wx.PlatformInfo))
 except ImportError:
+	_log.exception('cannot import wxPython')
 	print('GNUmed startup: Cannot import wxPython library.')
 	print('GNUmed startup: Make sure wxPython is installed.')
 	print('CRITICAL ERROR: Error importing wxPython. Halted.')
@@ -67,7 +91,7 @@ if (version < 28) or ('unicode' not in wx.PlatformInfo):
 	raise ValueError('wxPython 2.8+ with unicode support not found')
 
 
-# GNUmed libs
+# more GNUmed libs
 from Gnumed.pycommon import gmCfg
 from Gnumed.pycommon import gmPG2
 from Gnumed.pycommon import gmDispatcher
@@ -79,7 +103,6 @@ from Gnumed.pycommon import gmTools
 from Gnumed.pycommon import gmDateTime
 from Gnumed.pycommon import gmHooks
 from Gnumed.pycommon import gmBackendListener
-from Gnumed.pycommon import gmCfg2
 from Gnumed.pycommon import gmLog2
 from Gnumed.pycommon import gmNetworkTools
 from Gnumed.pycommon import gmMimeLib
@@ -143,7 +166,6 @@ try:
 except NameError:
 	_ = lambda x:x
 
-_cfg = gmCfg2.gmCfgData()
 _provider = None
 _scripting_listener = None
 _original_wxEndBusyCursor = None
@@ -701,7 +723,7 @@ class gmTopLevelFrame(wx.Frame):
 		item = menu_emr_edit.Append(-1, _('&Measurements'), _('Manage measurement results for the current patient.'))
 		self.Bind(wx.EVT_MENU, self.__on_manage_measurements, item)
 
-		item = menu_emr_edit.Append(-1, _('&Vaccinations'), _('Add (a) vaccination(s) for the current patient.'))
+		item = menu_emr_edit.Append(-1, _('&Vaccinations'), _('Manage vaccinations for the current patient.'))
 		self.Bind(wx.EVT_MENU, self.__on_add_vaccination, item)
 
 		item = menu_emr_edit.Append(-1, _('&Family history (FHx)'), _('Manage family history.'))
diff --git a/client/wxpython/gmMacro.py b/client/wxpython/gmMacro.py
index bed61f4..0009d30 100644
--- a/client/wxpython/gmMacro.py
+++ b/client/wxpython/gmMacro.py
@@ -430,7 +430,16 @@ __known_variant_placeholders = {
 	u'bill_item': u"""retrieve the items of a previously retrieved (and therefore cached until the next retrieval) bill
 		args: <template>//<date format>
 		template:		something %(field)s something else (do not include '//' or '::' itself in the template)
-		date format:	strftime date format"""
+		date format:	strftime date format""",
+	u'bill_adr_street': u"args: optional template (%s-style formatting template); cached per bill",
+	u'bill_adr_number': u"args: optional template (%s-style formatting template); cached per bill",
+	u'bill_adr_subunit': u"args: optional template (%s-style formatting template); cached per bill",
+	u'bill_adr_location': u"args: optional template (%s-style formatting template); cached per bill",
+	u'bill_adr_suburb': u"args: optional template (%s-style formatting template); cached per bill",
+	u'bill_adr_postcode': u"args: optional template (%s-style formatting template); cached per bill",
+	u'bill_adr_region': u"args: optional template (%s-style formatting template); cached per bill",
+	u'bill_adr_country': u"args: optional template (%s-style formatting template); cached per bill"
+
 }
 
 known_variant_placeholders = __known_variant_placeholders.keys()
@@ -2329,6 +2338,7 @@ class gmPlaceholderHandler(gmBorg.cBorg):
 			date_format = '%Y %B %d'
 
 		return template % bill.fields_as_dict(date_format = date_format, escape_style = self.__esc_style)
+
 	#--------------------------------------------------------
 	def _get_variant_bill_item(self, data=None):
 		try:
@@ -2350,6 +2360,74 @@ class gmPlaceholderHandler(gmBorg.cBorg):
 			date_format = '%Y %B %d'
 
 		return u'\n'.join([ template % i.fields_as_dict(date_format = date_format, escape_style = self.__esc_style) for i in bill.bill_items ])
+
+	#--------------------------------------------------------
+	def __get_variant_bill_adr_part(self, data=None, part=None):
+		try:
+			bill = self.__cache['bill']
+		except KeyError:
+			from Gnumed.wxpython import gmBillingWidgets
+			bill = gmBillingWidgets.manage_bills(patient = self.pat)
+			if bill is None:
+				if self.debug:
+					return self._escape(_('no bill selected'))
+				return u''
+			self.__cache['bill'] = bill
+			self.__cache['bill-adr'] = bill.address
+
+		try:
+			bill_adr = self.__cache['bill-adr']
+		except KeyError:
+			bill_adr = bill.address
+			self.__cache['bill-adr'] = bill_adr
+
+		if bill_adr is None:
+			if self.debug:
+				return self._escape(_('[%s] bill has no address') % part)
+			return u''
+
+		if bill_adr[part] is None:
+			return self._escape(u'')
+
+		if data is None:
+			return self._escape(bill_adr[part])
+
+		if data == u'':
+			return self._escape(bill_adr[part])
+
+		return data % self._escape(bill_adr[part])
+
+	#--------------------------------------------------------
+	def _get_variant_bill_adr_street(self, data=u'?'):
+		return self.__get_variant_bill_adr_part(data = data, part = 'street')
+
+	#--------------------------------------------------------
+	def _get_variant_bill_adr_number(self, data=u'?'):
+		return self.__get_variant_bill_adr_part(data = data, part = 'number')
+
+	#--------------------------------------------------------
+	def _get_variant_bill_adr_subunit(self, data=u'?'):
+		return self.__get_variant_bill_adr_part(data = data, part = 'subunit')
+	#--------------------------------------------------------
+	def _get_variant_bill_adr_location(self, data=u'?'):
+		return self.__get_variant_bill_adr_part(data = data, part = 'urb')
+
+	#--------------------------------------------------------
+	def _get_variant_bill_adr_suburb(self, data=u'?'):
+		return self.__get_variant_bill_adr_part(data = data, part = 'suburb')
+
+	#--------------------------------------------------------
+	def _get_variant_bill_adr_postcode(self, data=u'?'):
+		return self.__get_variant_bill_adr_part(data = data, part = 'postcode')
+
+	#--------------------------------------------------------
+	def _get_variant_bill_adr_region(self, data=u'?'):
+		return self.__get_variant_bill_adr_part(data = data, part = 'l10n_region')
+
+	#--------------------------------------------------------
+	def _get_variant_bill_adr_country(self, data=u'?'):
+		return self.__get_variant_bill_adr_part(data = data, part = 'l10n_country')
+
 	#--------------------------------------------------------
 	# internal helpers
 	#--------------------------------------------------------
@@ -3024,7 +3102,13 @@ if __name__ == '__main__':
 			#u'$<receiver_country::, %s::120>$',
 			#u'$<external_care::%(issue)s: %(provider)s of %(unit)s@%(organization)s (%(comment)s)::1024>$',
 			#u'$<url_escape::hello world ü::>$',
-			u'$<substance_abuse::%(substance)s (%(harmful_use_type)s) last=%(last_checked_when)s stop=%(discontinued)s // %(notes)s::>$'
+			#u'$<substance_abuse::%(substance)s (%(harmful_use_type)s) last=%(last_checked_when)s stop=%(discontinued)s // %(notes)s::>$',
+			#u'bill_adr_region::region %s::1234',
+			#u'bill_adr_country::%s::1234',
+			#u'bill_adr_subunit::subunit: %s::1234',
+			#u'bill_adr_suburb::-> %s::1234',
+			#u'bill_adr_street::::1234',
+			u'bill_adr_number::%s::1234'
 		]
 
 		handler = gmPlaceholderHandler()
diff --git a/client/wxpython/gmMedicationWidgets.py b/client/wxpython/gmMedicationWidgets.py
index 5443f18..68ca1d1 100644
--- a/client/wxpython/gmMedicationWidgets.py
+++ b/client/wxpython/gmMedicationWidgets.py
@@ -560,6 +560,7 @@ class cSubstanceIntakeEAPnl(wxgCurrentMedicationEAPnl.wxgCurrentMedicationEAPnl,
 				self._PRW_duration.display_as_valid(True)
 
 		# started must exist or be unknown
+		started = None
 		if self._CHBOX_start_unknown.IsChecked() is False:
 			started = self._DP_started.GetData()
 			if started is None:
@@ -587,23 +588,25 @@ class cSubstanceIntakeEAPnl(wxgCurrentMedicationEAPnl.wxgCurrentMedicationEAPnl,
 				validity = False
 				gmDispatcher.send(signal = 'statustext', msg = _('Discontinued (%s) in the future (now: %s)!') % (discontinued, now))
 			else:
-				started = started.replace (
-					hour = 0,
-					minute = 0,
-					second = 0,
-					microsecond = 1
-				)
-				# and not before it was started
-				if started > discontinued:
-					self._DP_started.display_as_valid(False)
-					self._DP_discontinued.display_as_valid(False)
-					validity = False
-					gmDispatcher.send(signal = 'statustext', msg = _('Discontinued (%s) before started (%s) !') % (discontinued, started))
-				else:
-					self._DP_started.display_as_valid(True)
-					self._DP_discontinued.display_as_valid(True)
+				if started is not None:
+					started = started.replace (
+						hour = 0,
+						minute = 0,
+						second = 0,
+						microsecond = 1
+					)
+					# and not before it was started
+					if started > discontinued:
+						self._DP_started.display_as_valid(False)
+						self._DP_discontinued.display_as_valid(False)
+						validity = False
+						gmDispatcher.send(signal = 'statustext', msg = _('Discontinued (%s) before started (%s) !') % (discontinued, started))
+					else:
+						self._DP_started.display_as_valid(True)
+						self._DP_discontinued.display_as_valid(True)
 
 		return validity
+
 	#----------------------------------------------------------------
 	def _save_as_new(self):
 
@@ -650,6 +653,7 @@ class cSubstanceIntakeEAPnl(wxgCurrentMedicationEAPnl.wxgCurrentMedicationEAPnl,
 		self.data = intake
 
 		return True
+
 	#----------------------------------------------------------------
 	def _save_as_update(self):
 
diff --git a/client/wxpython/gmPatOverviewWidgets.py b/client/wxpython/gmPatOverviewWidgets.py
index bb54968..bcb81af 100644
--- a/client/wxpython/gmPatOverviewWidgets.py
+++ b/client/wxpython/gmPatOverviewWidgets.py
@@ -320,7 +320,8 @@ class cPatientOverviewPnl(wxgPatientOverviewPnl.wxgPatientOverviewPnl, gmRegetMi
 			list_items.append(label)
 			list_data.append(msg)
 
-		for hint in patient.dynamic_hints:
+		pk_enc = patient.get_emr(allow_user_interaction = False).active_encounter['pk_encounter']
+		for hint in patient._get_dynamic_hints(pk_encounter = pk_enc):
 			list_items.append(hint['title'])
 			list_data.append(hint)
 
@@ -335,6 +336,7 @@ class cPatientOverviewPnl(wxgPatientOverviewPnl.wxgPatientOverviewPnl, gmRegetMi
 		if no_of_overdues > 0:
 			for idx in range(no_of_overdues):
 				self._LCTRL_inbox.SetItemTextColour(idx, wx.NamedColour('RED'))
+
 	#-----------------------------------------------------
 	def _calc_inbox_item_tooltip(self, data):
 		if isinstance(data, gmProviderInbox.cInboxMessage):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/gnumed-client.git



More information about the debian-med-commit mailing list