Example #1
0
	def format(self, *args, **kwargs):
		lines = []
		lines.append(_('%s with %s %s     #%s') % (
			gmTools.bool2subst(self._payload[self._idx['is_live']], _('Live vaccine'), _('Inactive vaccine'), '<liveness error in DB>'),
			len(self._payload[self._idx['indications']]),
			gmTools.bool2subst(len(self._payload[self._idx['indications']]) == 1, _('indication'), _('indications'), _('indication(s)')),
			self._payload[self._idx['pk_vaccine']]
		))
		lines.append(_(' Product: "%s"     #%s') % (
			self._payload[self._idx['vaccine']],
			self._payload[self._idx['pk_drug_product']]
		))
		lines.append(_('  %s%s%s%s') % (
			self._payload[self._idx['l10n_preparation']],
			gmTools.coalesce(gmTools.bool2subst(self._payload[self._idx['is_fake_vaccine']], _('fake product'), None, None), '', ', %s'),
			gmTools.coalesce(self._payload[self._idx['atc_code']], '', ' [ATC:%s]'),
			gmTools.coalesce(self._payload[self._idx['external_code']], '', ' [%s:%%s]' % self._payload[self._idx['external_code_type']])
		))
		#lines.append(_(u' %sage %s - %s') % (
		#	gmTools.coalesce(self._payload[self._idx['route_description']], u'', u'%s, '),		#route_abbreviation
		lines.append(_(' Age %s - %s') % (
			gmTools.coalesce(self._payload[self._idx['min_age']], '?'),
			gmTools.coalesce(self._payload[self._idx['max_age']], '?')
		))
		if self._payload[self._idx['comment']] is not None:
			lines.extend([ ' %s' % l for l in self._payload[self._idx['comment']].split('\n')] )
		lines.append(_(' Indications'))
		lines.extend( [ '  %s [ATC:%s]' % (i['l10n_indication'], i['atc_indication']) for i in self._payload[self._idx['indications']] ])

		return lines
Example #2
0
	def _check_RFE(self):
		"""
		This gets called when a patient has been activated, but
		only when the waiting list is actually in use (that is,
		the plugin is loaded)
		"""
		pat = gmPerson.gmCurrentPatient()
		enc = pat.emr.active_encounter
		if gmTools.coalesce(enc['reason_for_encounter'], '').strip() != '':
			return
		entries = pat.waiting_list_entries
		if len(entries) == 0:
			if self.__id_most_recently_activated_patient is None:
				return
			if self.__id_most_recently_activated_patient != pat.ID:
				return
			rfe = self.__comment_most_recently_activated_patient
		else:
			entry = entries[0]
			if gmTools.coalesce(entry['comment'], '').strip() == '':
				return
			rfe = entry['comment'].strip()
		enc['reason_for_encounter'] = rfe
		enc.save()
		self.__id_most_recently_activated_patient = None
Example #3
0
	def _display_name(self):

		curr_pat = gmPerson.gmCurrentPatient()
		if curr_pat.connected:
			name = curr_pat['description']
			if curr_pat.locked:
				name = _('%(name)s (locked)') % {'name': name}
		else:
			if curr_pat.locked:
				name = _('<patient search locked>')
			else:
				name = _('<type here to search patient>')

		self.SetValue(name)

		# adjust tooltip
		if self.person is None:
			self.SetToolTip(self._tt_search_hints)
			return

		if (self.person['emergency_contact'] is None) and (self.person['comment'] is None):
			separator = ''
		else:
			separator = '%s\n' % (gmTools.u_box_horiz_single * 40)

		tt = '%s%s%s%s' % (
			gmTools.coalesce(self.person['emergency_contact'], '', '%s\n %%s\n' % _('In case of emergency contact:')),
			gmTools.coalesce(self.person['comment'], '', '\n%s\n'),
			separator,
			self._tt_search_hints
		)
		self.SetToolTip(tt)
Example #4
0
	def acquire_pages_into_files(self, delay=None, filename=None):
		"""Call XSane.

		<filename> name part must have format name-001.ext>
		"""
		if filename is None:
			filename = gmTools.get_unique_filename(prefix = 'gm-scan-')

		name, ext = os.path.splitext(filename)
		filename = '%s-001%s' % (name, cXSaneScanner._FILETYPE)
		filename = os.path.abspath(os.path.expanduser(filename))

		cmd = 'xsane --no-mode-selection --save --force-filename "%s" --xsane-rc "%s" %s %s' % (
			filename,
			self.__get_session_xsanerc(),
			gmTools.coalesce(self.device_settings_file, '', '--device-settings %s'),
			gmTools.coalesce(self.default_device, '')
		)
		normal_exit = gmShellAPI.run_command_in_shell(command = cmd, blocking = True)

		if normal_exit:
			flist = glob.glob(filename.replace('001', '*'))
			flist.sort()
			return flist

		raise OSError(-1, 'error running XSane as [%s]' % cmd)
Example #5
0
	def _on_get_list_tooltip(self, entry):

		dob = gmTools.coalesce (
			gmTools.coalesce(entry['dob'], '', function_initial = ('strftime', '%d %b %Y')),
			'',
			' (%s)'
		)

		tt = _(
			'%s patients are waiting.\n'
			'\n'
			'Doubleclick to activate (entry will stay in list).'
		) % self._LCTRL_patients.GetItemCount()

		tt += _(
			'\n'
			'%s\n'
			'Patient: %s%s\n'
			'%s'
			'Urgency: %s\n'
			'Time: %s\n'
			'%s'
		) % (
			gmTools.u_box_horiz_single * 50,
			'%s, %s (%s)' % (entry['lastnames'], entry['firstnames'], entry['l10n_gender']),
			dob,
			gmTools.coalesce(entry['waiting_zone'], '', _('Zone: %s\n')),
			entry['urgency'],
			gmDateTime.format_interval_medically(entry['waiting_time']),
			gmTools.coalesce(entry['comment'], '', '\n%s')
		)

		return tt
Example #6
0
	def format(self):
		txt = '%s                                    [#%s]\n\n' % (
			gmTools.bool2subst (
				self._payload[self._idx['active']],
				_('Active billable item'),
				_('Inactive billable item')
			),
			self._payload[self._idx['pk_billable']]
		)
		txt += ' %s: %s\n' % (
			self._payload[self._idx['billable_code']],
			self._payload[self._idx['billable_description']]
		)
		txt += _(' %(curr)s%(raw_val)s + %(perc_vat)s%% VAT = %(curr)s%(val_w_vat)s\n') % {
			'curr': self._payload[self._idx['currency']],
			'raw_val': self._payload[self._idx['raw_amount']],
			'perc_vat': self._payload[self._idx['vat_multiplier']] * 100,
			'val_w_vat': self._payload[self._idx['amount_with_vat']]
		}
		txt += ' %s %s%s (%s)' % (
			self._payload[self._idx['catalog_short']],
			self._payload[self._idx['catalog_version']],
			gmTools.coalesce(self._payload[self._idx['catalog_language']], '', ' - %s'),
			self._payload[self._idx['catalog_long']]
		)
		txt += gmTools.coalesce(self._payload[self._idx['comment']], '', '\n %s')

		return txt
Example #7
0
def format_address_single_line(address=None, verbose=False, show_type=False):
	data = {
		'pk_adr': address['pk_address'],
		'street': address['street'],
		'notes_street': gmTools.coalesce(address['notes_street'], u'', u' (%s)'),
		'number': address['number'],
		'subunit': gmTools.coalesce(address['subunit'], u'', u'/%s'),
		'notes_subunit': gmTools.coalesce(address['notes_subunit'], u'', u' (%s)'),
		'zip': address['postcode'],
		'urb': address['urb'],
		'suburb': gmTools.coalesce(address['suburb'], u'', u' (%s)'),
		'l10n_state': address['l10n_state'],
		'code_state': address['code_state'],
		'l10n_country': address['l10n_country'],
		'code_country': address['code_country']
	}
	if show_type:
		data['type'] = address['l10n_address_type']

	if verbose:
		if show_type:
			template = _('%(type)s: %(street)s %(number)s%(subunit)s, %(zip)s %(urb)s %(suburb)s, %(code_state)s, %(code_country)s')
		else:
			template = _('%(street)s %(number)s%(subunit)s, %(zip)s %(urb)s %(suburb)s, %(code_state)s, %(code_country)s')
	else:
		if show_type:
			template = _('%(type)s: %(street)s %(number)s%(subunit)s, %(zip)s %(urb)s, %(code_state)s, %(code_country)s')
		else:
			template = _('%(street)s %(number)s%(subunit)s, %(zip)s %(urb)s, %(code_state)s, %(code_country)s')

	return template % data
Example #8
0
	def _refresh_dupe_warning(self):
		lname = self._PRW_lastname.GetValue().strip()
		if lname == '':
			self._LBL_person_exists.SetLabel('')
			return

		dob = self._PRW_dob.GetData()
		if dob is None:
			self._LBL_person_exists.SetLabel('')
			return

		fname = gmTools.none_if(self._PRW_firstnames.GetValue().strip()[:1], '')

		no_of_dupes = gmPerson.get_potential_person_dupes(lastnames = lname, firstnames = fname, dob = dob)
		if no_of_dupes == 0:
			lbl = ''
		elif no_of_dupes == 1:
			lbl = _('One "%s, %s (%s)" already exists !') % (
				lname,
				gmTools.coalesce(fname, '?', '%s %%s. %s' % (gmTools.u_ellipsis, gmTools.u_ellipsis)),
				gmDateTime.pydt_strftime(dob, '%Y %b %d', 'utf8')
			)
		else:
			lbl = _('%s "%s, %s (%s)" already exist !') % (
				no_of_dupes,
				lname,
				gmTools.coalesce(fname, '?', '%s %%s. %s' % (gmTools.u_ellipsis, gmTools.u_ellipsis)),
				gmDateTime.pydt_strftime(dob, '%Y %b %d', 'utf8')
			)

		self._LBL_person_exists.SetLabel(lbl)
Example #9
0
	def _refresh_from_existing(self):
		self._PRW_issue.SetText(value = self.data['issue'], data = self.data['pk_health_issue'], suppress_smarts = True)
		self._PRW_care_location.SetText(value = u'%s @ %s' % (self.data['unit'], self.data['organization']), data = self.data['pk_org_unit'])
		self._TCTRL_provider.SetValue(gmTools.coalesce(self.data['provider'], u''))
		self._TCTRL_comment.SetValue(gmTools.coalesce(self.data['comment'], u''))

		self._TCTRL_comment.SetFocus()
Example #10
0
	def format(self, with_patient=True):
		tt = '%s: %s%s\n' % (
			gmDateTime.pydt_strftime (
				self._payload[self._idx['received_when']],
				format = '%A, %Y %b %d, %H:%M',
				accuracy = gmDateTime.acc_minutes
			),
			gmTools.bool2subst(self._payload[self._idx['is_virtual']], _('virtual message'), _('message')),
			gmTools.coalesce(self._payload[self._idx['pk_inbox_message']], '', ' #%s ')
		)

		tt += '%s: %s\n' % (
			self._payload[self._idx['l10n_category']],
			self._payload[self._idx['l10n_type']]
		)

		tt += '%s %s %s\n' % (
			self._payload[self._idx['modified_by']],
			gmTools.u_arrow2right,
			gmTools.coalesce(self._payload[self._idx['provider']], _('everyone'))
		)

		tt += '\n%s%s%s\n\n' % (
			gmTools.u_left_double_angle_quote,
			self._payload[self._idx['comment']],
			gmTools.u_right_double_angle_quote
		)

		if with_patient and (self._payload[self._idx['pk_patient']] is not None):
			tt += _('Patient: %s, %s%s %s   #%s\n' % (
				self._payload[self._idx['lastnames']],
				self._payload[self._idx['firstnames']],
				gmTools.coalesce(self._payload[self._idx['l10n_gender']], '', ' (%s)'),
				gmDateTime.pydt_strftime(self._payload[self._idx['dob']], '%Y %b %d', none_str = ''),
				self._payload[self._idx['pk_patient']]
			))

		if self._payload[self._idx['due_date']] is not None:
			if self._payload[self._idx['is_overdue']]:
				template = _('Due: %s (%s ago)\n')
			else:
				template = _('Due: %s (in %s)\n')
			tt += template % (
				gmDateTime.pydt_strftime(self._payload[self._idx['due_date']], '%Y %b %d'),
				gmDateTime.format_interval_medically(self._payload[self._idx['interval_due']])
			)

		if self._payload[self._idx['expiry_date']] is not None:
			if self._payload[self._idx['is_expired']]:
				template = _('Expired: %s\n')
			else:
				template = _('Expires: %s\n')
			tt += template % gmDateTime.pydt_strftime(self._payload[self._idx['expiry_date']], '%Y %b %d')

		if self._payload[self._idx['data']] is not None:
			tt += self._payload[self._idx['data']][:150]
			if len(self._payload[self._idx['data']]) > 150:
				tt += gmTools.u_ellipsis

		return tt
Example #11
0
	def refresh(lctrl):
		vaccines = gmVaccination.get_vaccines(order_by = 'vaccine')

		items = [ [
			u'%s' % v['pk_brand'],
			u'%s%s' % (
				v['vaccine'],
				gmTools.bool2subst (
					v['is_fake_vaccine'],
					u' (%s)' % _('fake'),
					u''
				)
			),
			v['preparation'],
			#u'%s (%s)' % (v['route_abbreviation'], v['route_description']),
			#gmTools.bool2subst(v['is_live'], gmTools.u_checkmark_thin, u'', u'?'),
			gmTools.coalesce(v['atc_code'], u''),
			u'%s%s' % (
				gmTools.coalesce(v['min_age'], u'?'),
				gmTools.coalesce(v['max_age'], u'?', u' - %s'),
			),
			gmTools.coalesce(v['comment'], u'')
		] for v in vaccines ]
		lctrl.set_string_items(items)
		lctrl.set_data(vaccines)
Example #12
0
File: gmHL7.py Project: sk/gnumed
def __stage_MSH_as_incoming_data(filename, source=None, logfile=None):
	"""Consumes single-MSH single-PID HL7 files."""

	_log.debug('staging [%s] as unmatched incoming HL7%s', gmTools.coalesce(source, u'', u' (%s)'), filename)

	# parse HL7
	MSH_file = io.open(filename, mode = 'rt', encoding = 'utf8')
	raw_hl7 = MSH_file.read(1024 * 1024 * 5)	# 5 MB max
	MSH_file.close()
	formatted_hl7 = format_hl7_message (
		message = raw_hl7,
		skip_empty_fields = True,
		eol = u'\n'
	)
	HL7 = pyhl7.parse(raw_hl7)
	del raw_hl7

	# import file
	inc = create_incoming_data(u'HL7%s' % gmTools.coalesce(source, u'', u' (%s)'), filename)
	if inc is None:
		return None
	inc.update_data_from_file(fname = filename)
	inc['comment'] = formatted_hl7
	if logfile is not None:
		log = io.open(logfile, mode = 'rt', encoding = 'utf8')
		inc['comment'] += u'\n'
		inc['comment'] += (u'-' * 80)
		inc['comment'] += u'\n\n'
		inc['comment'] += log.read()
		log.close()
	try:
		inc['lastnames'] = HL7.extract_field('PID', segment_num = 1, field_num = PID_field__name, component_num = PID_component__lastname)
		inc['firstnames'] = HL7.extract_field('PID', segment_num = 1, field_num = PID_field__name, component_num = PID_component__firstname)
		val = HL7.extract_field('PID', segment_num = 1, field_num = PID_field__name, component_num = PID_component__middlename)
		if val is not None:
			inc['firstnames'] += u' '
			inc['firstnames'] += val
		val = HL7.extract_field('PID', segment_num = 1, field_num = PID_field__dob)
		if val is not None:
			tmp = time.strptime(val, '%Y%m%d')
			inc['dob'] = pyDT.datetime(tmp.tm_year, tmp.tm_mon, tmp.tm_mday, tzinfo = gmDateTime.gmCurrentLocalTimezone)
		val = HL7.extract_field('PID', segment_num = 1, field_num = PID_field__gender)
		if val is not None:
			inc['gender'] = val
		inc['external_data_id'] = filename
		#u'fk_patient_candidates',
		#	u'request_id',						# request ID as found in <data>
		#	u'postcode',
		#	u'other_info',						# other identifying info in .data
		#	u'requestor',						# Requestor of data (e.g. who ordered test results) if available in source data.
		#	u'fk_identity_disambiguated',
		#	u'comment',							# a free text comment on this row, eg. why is it here, error logs etc
		#	u'fk_provider_disambiguated'		# The provider the data is relevant to.
	except KeyError:
		_log.exception('no PID segment, cannot add more data')
	inc.save()

	return inc
Example #13
0
	def __refresh_meds(self, patient=None):

		emr = patient.get_emr()

		list_items = []
		data_items = []
		first_red = False

		# smoking
		ever, details = emr.smoking_status
		if ever is True:
			if details['quit_when'] is None:
				first_red = True
				list_items.append (
					_('active tobacco use (%s)') % gmDateTime.pydt_strftime(details['last_confirmed'], '%Y %b')
				)
				data_items.append (_(u'Last confirmed: %s%s') % (
					gmDateTime.pydt_strftime(details['last_confirmed'], '%Y %b %d'),
					gmTools.coalesce(details['comment'], u'', u'\n\n%s')
				))

		# list by brand or substance:
		intakes = emr.get_current_substance_intakes(include_inactive = False, include_unapproved = True, order_by = u'substance')
		multi_brands_already_seen = []
		for intake in intakes:
			brand = intake.containing_drug
			if brand is None or len(brand['pk_components']) == 1:
				list_items.append(_('%s %s %s%s') % (
					intake['substance'],
					intake['amount'],
					intake['unit'],
					gmTools.coalesce (
						intake['schedule'],
						u'',
						u': %s'
					)
				))
				data_items.append(intake)
			else:
				if intake['brand'] in multi_brands_already_seen:
					continue
				multi_brands_already_seen.append(intake['brand'])
				list_items.append(_('%s %s%s') % (
					intake['brand'],
					brand['preparation'],
					gmTools.coalesce (
						intake['schedule'],
						u'',
						u': %s'
					)
				))
				data_items.append(intake)

		self._LCTRL_meds.set_string_items(items = list_items)
		self._LCTRL_meds.set_data(data = data_items)

		if first_red:
			self._LCTRL_meds.SetItemTextColour(0, wx.NamedColour('RED'))
Example #14
0
	def format(self):
		txt = '%s (%s %s%s)         [#%s]\n' % (
			gmTools.bool2subst(
				self._payload[self._idx['pk_bill']] is None,
				_('Open item'),
				_('Billed item'),
			),
			self._payload[self._idx['catalog_short']],
			self._payload[self._idx['catalog_version']],
			gmTools.coalesce(self._payload[self._idx['catalog_language']], '', ' - %s'),
			self._payload[self._idx['pk_bill_item']]
		)
		txt += ' %s: %s\n' % (
			self._payload[self._idx['billable_code']],
			self._payload[self._idx['billable_description']]
		)
		txt += gmTools.coalesce (
			self._payload[self._idx['billable_comment']],
			'',
			'  (%s)\n',
		)
		txt += gmTools.coalesce (
			self._payload[self._idx['item_detail']],
			'',
			_(' Details: %s\n'),
		)

		txt += '\n'
		txt += _(' %s of units: %s\n') % (
			gmTools.u_numero,
			self._payload[self._idx['unit_count']]
		)
		txt += _(' Amount per unit: %(curr)s%(val_p_unit)s (%(cat_curr)s%(cat_val)s per catalog)\n') % {
			'curr': self._payload[self._idx['currency']],
			'val_p_unit': self._payload[self._idx['net_amount_per_unit']],
			'cat_curr': self._payload[self._idx['billable_currency']],
			'cat_val': self._payload[self._idx['billable_amount']]
		}
		txt += _(' Amount multiplier: %s\n') % self._payload[self._idx['amount_multiplier']]
		txt += _(' VAT would be: %(perc_vat)s%% %(equals)s %(curr)s%(vat)s\n') % {
			'perc_vat': self._payload[self._idx['vat_multiplier']] * 100,
			'equals': gmTools.u_corresponds_to,
			'curr': self._payload[self._idx['currency']],
			'vat': self._payload[self._idx['vat']]
		}

		txt += '\n'
		txt += _(' Charge date: %s') % gmDateTime.pydt_strftime (
			self._payload[self._idx['date_to_bill']],
			'%Y %b %d',
			accuracy = gmDateTime.acc_days
		)
		bill = self.bill
		if bill is not None:
			txt += _('\n On bill: %s') % bill['invoice_id']

		return txt
Example #15
0
def edit_episode(parent=None, episode=None):
	ea = cEpisodeEditAreaPnl(parent, -1)
	ea.data = episode
	ea.mode = gmTools.coalesce(episode, 'new', 'edit')
	dlg = gmEditArea.cGenericEditAreaDlg2(parent, -1, edit_area = ea, single_entry = True)
	dlg.SetTitle(gmTools.coalesce(episode, _('Adding a new episode'), _('Editing an episode')))
	if dlg.ShowModal() == wx.ID_OK:
		return True
	return False
Example #16
0
	def refresh(lctrl):
		txs = gmPG2.get_database_translations(language = language, order_by = 'orig, lang')
		items = [ [
			tx['orig'],
			gmTools.coalesce(tx['lang'], ''),
			gmTools.coalesce(tx['trans'], '')
		] for tx in txs ]
		lctrl.set_string_items(items)
		lctrl.set_data(txs)
Example #17
0
File: gmHL7.py Project: sk/gnumed
	def _format_patient_identification(self):
		tmp = u'%s %s %s' % (
			gmTools.coalesce(self._payload[self._idx['lastnames']], u'', u'last=%s'),
			gmTools.coalesce(self._payload[self._idx['firstnames']], u'', u'first=%s'),
			gmTools.coalesce(self._payload[self._idx['gender']], u'', u'gender=%s')
		)
		if self._payload[self._idx['dob']] is not None:
			tmp += u' dob=%s' % gmDateTime.pydt_strftime(self._payload[self._idx['dob']], '%Y %b %d')
		return tmp
Example #18
0
def edit_encounter_type(parent=None, encounter_type=None):
	ea = cEncounterTypeEditAreaPnl(parent = parent, id = -1)
	ea.data = encounter_type
	ea.mode = gmTools.coalesce(encounter_type, 'new', 'edit')
	dlg = gmEditArea.cGenericEditAreaDlg2(parent = parent, id = -1, edit_area = ea)
	dlg.SetTitle(gmTools.coalesce(encounter_type, _('Adding new encounter type'), _('Editing local encounter type name')))
	if dlg.ShowModal() == wx.ID_OK:
		return True
	return False
Example #19
0
	def __update_allergies(self, **kwargs):

		show_red = True

		emr = self.curr_pat.get_emr()
		state = emr.allergy_state

		# state in tooltip
		if state['last_confirmed'] is None:
			confirmed = _('never')
		else:
			confirmed = gmDateTime.pydt_strftime(state['last_confirmed'], '%Y %b %d')
		tt = (state.state_string + (90 * u' '))[:90] + u'\n'
		tt += _('last confirmed %s\n') % confirmed
		tt += gmTools.coalesce(state['comment'], u'', _('Comment (%s): %%s') % state['modified_by'])
		tt += u'\n'

		# allergies
		display = []
		for allergy in emr.get_allergies():
			# in field: "true" allergies only, not intolerances
			if allergy['type'] == u'allergy':
				display.append(allergy['descriptor'][:10].strip() + gmTools.u_ellipsis)
			# in tooltip
			if allergy['definite']:
				certainty = _('definite')
			else:
				certainty = _('suspected')
			reaction = gmTools.coalesce(allergy['reaction'], _('reaction not recorded'))
			if len(reaction) > 50:
				reaction = reaction[:50] + gmTools.u_ellipsis
			tt += u'%s (%s, %s): %s\n' % (
				allergy['descriptor'],
				allergy['l10n_type'],
				certainty,
				reaction
			)

		if len(display) == 0:
			display = state.state_symbol
			if display == gmTools.u_diameter:
				show_red = False
		else:
			display = ','.join(display)

		if state['last_confirmed'] is not None:
			display += gmDateTime.pydt_strftime(state['last_confirmed'], ' (%Y %b)')

		if show_red:
			self._LBL_allergies.SetForegroundColour('red')
			self._TCTRL_allergies.SetForegroundColour('red')
		else:
			self._LBL_allergies.SetForegroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT))
			self._TCTRL_allergies.SetForegroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT))

		self._TCTRL_allergies.SetValue(display)
		self._TCTRL_allergies.SetToolTipString(tt)
Example #20
0
	def __refresh_inbox(self, patient=None):
		list_items = []
		list_data = []
		highlight_list = []
		line_idx = -1

		overdue_messages = patient.overdue_messages
		if len(overdue_messages) > 0:
			highlight_list.extend(range(len(overdue_messages)))
		for msg in overdue_messages:
			line_idx += 1
			list_items.append(_('overdue %s: %s') % (
				gmDateTime.format_interval_medically(msg['interval_due']),
				gmTools.coalesce(msg['comment'], '?')
			))
			list_data.append(msg)

		for msg in patient.get_messages(order_by = 'due_date NULLS LAST, importance DESC, received_when DESC'):
			# already displayed above ?
			if msg['is_overdue']:
				continue
			# not relevant anymore ?
			if msg['is_expired']:
				continue
			line_idx += 1
			if msg['due_date'] is None:
				label = '%s%s' % (
					msg['l10n_type'],
					gmTools.coalesce(msg['comment'], '', ': %s')
				)
			else:
				label = _('due in %s%s') % (
					gmDateTime.format_interval_medically(msg['interval_due']),
					gmTools.coalesce(msg['comment'], '', ': %s')
				)
			list_items.append(label)
			list_data.append(msg)

		pk_enc = patient.emr.active_encounter['pk_encounter']
		for hint in patient._get_dynamic_hints(pk_encounter = pk_enc):
			line_idx += 1
			list_items.append(hint['title'])
			list_data.append(hint)
			if hint['highlight_as_priority']:
				highlight_list.append(line_idx)

		hints = patient.suppressed_hints
		if len(hints) > 0:
			list_items.append((_("suppr'd (%s):") % len(hints)) + ' ' + ','.join([h['title'][:7] + gmTools.u_ellipsis for h in hints]))
			list_data.append(_('Suppressed hints:\n') + '\n'.join(['%s: %s' % (hints.index(h) + 1, h['title']) for h in hints]))

		self._LCTRL_inbox.set_string_items(items = list_items)
		self._LCTRL_inbox.set_data(data = list_data)

		for idx in highlight_list:
			self._LCTRL_inbox.SetItemTextColour(idx, wx.Colour('RED'))
Example #21
0
	def _refresh_from_existing(self):
		self._PRW_patient.person = gmPerson.cPerson(aPK_obj = self.data['pk_identity'])
		self._PRW_patient.Enable(False)
		self._PRW_patient._display_name()

		self._TCTRL_comment.SetValue(gmTools.coalesce(self.data['comment'], ''))
		self._PRW_zone.SetValue(gmTools.coalesce(self.data['waiting_zone'], ''))
		self._SPCTRL_urgency.SetValue(self.data['urgency'])

		self._TCTRL_comment.SetFocus()
Example #22
0
	def __update_greeting(self, no_of_messages=None):
		msg = _(' Inbox of %s %s%s') % (
			gmTools.coalesce (
				self.provider['title'],
				gmPerson.map_gender2salutation(self.provider['gender'])
			),
			self.provider['lastnames'],
			gmTools.coalesce(no_of_messages, u'.', _(': %s message(s)'))
		)
		self._msg_welcome.SetLabel(msg)
Example #23
0
	def format(self, single_line=False):
		if single_line:
			return self.format_single_line()

		part_count = len(self._payload[self._idx['seq_idx_list']])
		if part_count == 0:
			parts = _('no parts')
		elif part_count == 1:
			parts = _('1 part')
		else:
			parts = _('%s parts') % part_count
		org = ''
		if self._payload[self._idx['unit']] is not None:
			if self._payload[self._idx['unit_is_receiver']]:
				org = _(' Receiver: %s @ %s\n') % (
					self._payload[self._idx['unit']],
					self._payload[self._idx['organization']]
				)
			else:
				org = _(' Sender: %s @ %s\n') % (
					self._payload[self._idx['unit']],
					self._payload[self._idx['organization']]
				)
		stay = ''
		if self._payload[self._idx['pk_hospital_stay']] is not None:
			stay = _('Hospital stay') + ': %s\n' % self.hospital_stay.format (
				left_margin = 0,
				include_procedures = False,
				include_docs = False,
				include_episode = False
			)

		txt = _(
			'%s (%s)   #%s\n'
			' Created: %s\n'
			' Episode: %s\n'
			'%s'
			'%s'
			'%s'
			'%s'
			'%s'
		) % (
			self._payload[self._idx['l10n_type']],
			parts,
			self._payload[self._idx['pk_doc']],
			gmDateTime.pydt_strftime(self._payload[self._idx['clin_when']], format = '%Y %b %d', accuracy = gmDateTime.acc_days),
			self._payload[self._idx['episode']],
			gmTools.coalesce(self._payload[self._idx['health_issue']], '', _(' Health issue: %s\n')),
			gmTools.coalesce(self._payload[self._idx['ext_ref']], '', _(' External reference: %s\n')),
			org,
			stay,
			gmTools.coalesce(self._payload[self._idx['comment']], '', ' %s')
		)

		return txt
Example #24
0
def edit_vaccine(parent=None, vaccine=None, single_entry=True):
	ea = cVaccineEAPnl(parent = parent, id = -1)
	ea.data = vaccine
	ea.mode = gmTools.coalesce(vaccine, 'new', 'edit')
	dlg = gmEditArea.cGenericEditAreaDlg2(parent = parent, id = -1, edit_area = ea, single_entry = single_entry)
	dlg.SetTitle(gmTools.coalesce(vaccine, _('Adding new vaccine'), _('Editing vaccine')))
	if dlg.ShowModal() == wx.ID_OK:
		dlg.Destroy()
		return True
	dlg.Destroy()
	return False
Example #25
0
def edit_org(parent=None, org=None, single_entry=False):
	ea = cOrganizationEAPnl(parent = parent, id = -1)
	ea.data = org
	ea.mode = gmTools.coalesce(org, 'new', 'edit')
	dlg = gmEditArea.cGenericEditAreaDlg2(parent = parent, id = -1, edit_area = ea, single_entry = single_entry)
	dlg.SetTitle(gmTools.coalesce(org, _('Adding new organization'), _('Editing organization')))
	if dlg.ShowModal() == wx.ID_OK:
		dlg.Destroy()
		return True
	dlg.Destroy()
	return False
Example #26
0
def edit_family_history(parent=None, family_history=None):
	ea = cFamilyHistoryEAPnl(parent = parent, id = -1)
	ea.data = family_history
	ea.mode = gmTools.coalesce(family_history, 'new', 'edit')
	dlg = gmEditArea.cGenericEditAreaDlg2(parent = parent, id = -1, edit_area = ea, single_entry = True)
	dlg.SetTitle(gmTools.coalesce(family_history, _('Adding family history'), _('Editing family history')))
	if dlg.ShowModal() == wx.ID_OK:
		dlg.Destroy()
		return True
	dlg.Destroy()
	return False
Example #27
0
def edit_external_care_item(parent=None, external_care_item=None):
	ea = cExternalCareEAPnl(parent = parent, id = -1)
	ea.data = external_care_item
	ea.mode = gmTools.coalesce(external_care_item, 'new', 'edit')
	dlg = gmEditArea.cGenericEditAreaDlg2(parent = parent, id = -1, edit_area = ea, single_entry = True)
	dlg.SetTitle(gmTools.coalesce(external_care_item, _('Adding external care'), _('Editing external care')))
	if dlg.ShowModal() == wx.ID_OK:
		dlg.Destroy()
		return True
	dlg.Destroy()
	return False
Example #28
0
	def __refresh_contacts(self, patient=None):
		emr = patient.get_emr()

		list_items = []
		list_data = []
		is_in_hospital = False

		stays = emr.get_hospital_stays(ongoing_only = True)
		if len(stays) > 0:
			list_items.append(_('** Currently hospitalized: %s **') % stays[0]['hospital'])
			list_data.append(stays[0])
			is_in_hospital = True

		adrs = patient.get_addresses()
		for adr in adrs:
			list_items.append(adr.format(single_line = True, verbose = False, show_type = True))
			list_data.append(adr)

		comms = patient.get_comm_channels()
		for comm in comms:
			list_items.append(u'%s: %s%s' % (
				comm['l10n_comm_type'],
				comm['url'],
				gmTools.coalesce(comm['comment'], u'', u' (%s)')
			))
			list_data.append(comm)

		ident = patient.emergency_contact_in_database
		if ident is not None:
			list_items.append(_('emergency: %s') % ident['description_gender'])
			list_data.append(ident)

		if patient['emergency_contact'] is not None:
			list_items.append(_('emergency: %s') % patient['emergency_contact'].split(u'\n')[0])
			list_data.append(patient['emergency_contact'])

		provider = patient.primary_provider
		if provider is not None:
			list_items.append(_('in-praxis: %s') % provider.identity['description_gender'])
			list_data.append(provider)

		care = emr.get_external_care_items()
		for item in care:
			list_items.append(_('care: %s%s@%s') % (
				gmTools.coalesce(item['provider'], u'', u'%s, '),
				item['unit'],
				item['organization']
			))
			list_data.append(item)

		self._LCTRL_contacts.set_string_items(items = list_items)
		self._LCTRL_contacts.set_data(data = list_data)
		if is_in_hospital:
			self._LCTRL_contacts.SetItemTextColour(0, wx.NamedColour('RED'))
Example #29
0
def edit_procedure(parent=None, procedure=None):
	ea = cProcedureEAPnl(parent, -1)
	ea.data = procedure
	ea.mode = gmTools.coalesce(procedure, 'new', 'edit')
	dlg = gmEditArea.cGenericEditAreaDlg2(parent, -1, edit_area = ea, single_entry = True)
	dlg.SetTitle(gmTools.coalesce(procedure, _('Adding a procedure'), _('Editing a procedure')))
	if dlg.ShowModal() == wx.ID_OK:
		dlg.DestroyLater()
		return True
	dlg.DestroyLater()
	return False
Example #30
0
def edit_translation(parent=None, translation=None, single_entry=False):
	ea = cDatabaseTranslationEAPnl(parent, -1)
	ea.data = translation
	ea.mode = gmTools.coalesce(translation, 'new', 'edit')
	dlg = gmEditArea.cGenericEditAreaDlg2(parent, -1, edit_area = ea, single_entry = single_entry)
	dlg.SetTitle(gmTools.coalesce(translation, _('Adding new translation'), _('Editing translation')))
	if dlg.ShowModal() == wx.ID_OK:
		dlg.DestroyLater()
		return True
	dlg.DestroyLater()
	return False
Example #31
0
    def refresh(self, allergy=None):

        if allergy is not None:
            self.__allergy = allergy

        if self.__allergy is None:
            ts = gmDateTime.cFuzzyTimestamp(timestamp=pyDT.datetime.now(
                tz=gmDateTime.gmCurrentLocalTimezone),
                                            accuracy=gmDateTime.acc_days)
            self._DPRW_date_noted.SetData(data=ts)
            self._PRW_trigger.SetText()
            self._TCTRL_product_name.SetValue('')
            self._TCTRL_generic.SetValue('')
            self._ChBOX_generic_specific.SetValue(0)
            self._TCTRL_atc_classes.SetValue('')
            self._PRW_reaction.SetText()
            self._RBTN_type_allergy.SetValue(1)
            self._RBTN_type_sensitivity.SetValue(0)
            self._ChBOX_definite.SetValue(1)
            return True

        if not isinstance(self.__allergy, gmAllergy.cAllergy):
            raise ValueError(
                '[%s].refresh(): expected gmAllergy.cAllergy instance, got [%s] instead'
                % (self.__class__.__name__, self.__allergy))

        ts = gmDateTime.cFuzzyTimestamp(timestamp=self.__allergy['date'],
                                        accuracy=gmDateTime.acc_days)
        self._DPRW_date_noted.SetData(data=ts)
        self._PRW_trigger.SetText(value=self.__allergy['allergene'])
        self._TCTRL_product_name.SetValue(self.__allergy['substance'])
        self._TCTRL_generic.SetValue(
            gmTools.coalesce(self.__allergy['generics'], ''))
        self._ChBOX_generic_specific.SetValue(
            self.__allergy['generic_specific'])
        self._TCTRL_atc_classes.SetValue(
            gmTools.coalesce(self.__allergy['atc_code'], ''))
        self._PRW_reaction.SetText(
            value=gmTools.coalesce(self.__allergy['reaction'], ''))
        if self.__allergy['type'] == 'allergy':
            self._RBTN_type_allergy.SetValue(1)
        else:
            self._RBTN_type_sensitivity.SetValue(1)
        self._ChBOX_definite.SetValue(self.__allergy['definite'])
Example #32
0
	def _calc_contacts_list_item_tooltip(self, data):

		if isinstance(data, gmEMRStructItems.cHospitalStay):
			return data.format()

		if isinstance(data, gmExternalCare.cExternalCareItem):
			return '\n'.join(data.format (
				with_health_issue = True,
				with_address = True,
				with_comms = True
			))

		if isinstance(data, gmDemographicRecord.cPatientAddress):
			return '\n'.join(data.format())

		if isinstance(data, gmDemographicRecord.cCommChannel):
			parts = []
			if data['is_confidential']:
				parts.append(_('*** CONFIDENTIAL ***'))
			if data['comment'] is not None:
				parts.append(data['comment'])
			return '\n'.join(parts)

		if isinstance(data, gmPerson.cPerson):
			return '%s\n\n%s' % (
				data.description_gender,
				'\n'.join([
					'%s: %s%s' % (
						c['l10n_comm_type'],
						c['url'],
						gmTools.bool2subst(c['is_confidential'], _(' (confidential !)'), '', '')
					)
					for c in data.get_comm_channels()
				])
			)

		if isinstance(data, str):
			return data

		if isinstance(data, gmStaff.cStaff):
			ident = data.identity
			return '%s: %s\n\n%s%s' % (
				data['short_alias'],
				ident.description_gender,
				'\n'.join([
					'%s: %s%s' % (
						c['l10n_comm_type'],
						c['url'],
						gmTools.bool2subst(c['is_confidential'], _(' (confidential !)'), '', '')
					)
					for c in ident.get_comm_channels()
				]),
				gmTools.coalesce(data['comment'], '', '\n\n%s')
			)

		return None
Example #33
0
def configure_string_option(parent=None, message=None, option=None, bias='user', default_value='', validator=None):

	dbcfg = gmCfg.cCfgSQL()

	current_value = dbcfg.get2 (
		option = option,
		workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace,
		bias = bias,
		default = default_value
	)

	if current_value is not None:
		current_value = '%s' % current_value

	if parent is None:
		parent = wx.GetApp().GetTopWindow()

	if validator is None:
		validator = lambda in_val: (True, in_val)

	while True:
		dlg = wx.TextEntryDialog (
			parent,
			message,
			caption = _('Configuration'),
			value = gmTools.coalesce(current_value, ''),
			style = wx.OK | wx.CANCEL | wx.CENTRE
		)
		result = dlg.ShowModal()
		if result == wx.ID_CANCEL:
			dlg.DestroyLater()
			return None

		user_val = dlg.GetValue().strip()
		dlg.DestroyLater()

		if user_val == current_value:
			return user_val

		validated, user_val = validator(user_val)
		if validated:
			break
		gmDispatcher.send (
			signal = 'statustext',
			msg = _('Value [%s] not valid for option <%s>.') % (user_val, option),
			beep = True
		)

	dbcfg = gmCfg.cCfgSQL()
	dbcfg.set (
		workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace,
		option = option,
		value = user_val
	)

	return user_val
Example #34
0
    def __get_previously_used_accounts(self):

        accounts = gmTools.coalesce(
            _cfg.get(group='backend',
                     option='logins',
                     source_order=[('explicit', 'extend'), ('user', 'extend'),
                                   ('workbase', 'extend')]), ['any-doc'])
        # FIXME: make unique

        return accounts
Example #35
0
    def _on_leaving_unit(self, evt):
        if self._TCTRL_unit.GetValue().strip() == '':
            adr = self._PRW_address_searcher.address
            if adr is None:
                return True
            self._TCTRL_unit.SetValue(gmTools.coalesce(adr['subunit'], ''))
            return True

        self.__perhaps_invalidate_address_searcher(self._TCTRL_unit, 'subunit')
        return True
Example #36
0
	def _get_as_amts_data_v_2_0(self, strict=True):
		# Freitextzeile: 200 Zeichen, @..., \textwidth
		txt = u'@%s %s%s' % (
			self['descriptor'],
			self['l10n_type'],
			gmTools.coalesce(self['reaction'], u'', u': %s')
		)
		if strict:
			return txt[:200]
		return txt
Example #37
0
	def __refresh_problem_list(self):
		self._LCTRL_problems.set_string_items()
		emr = self.__curr_pat.emr
		epis = emr.get_episodes(open_status = True)
		if len(epis) > 0:
			self._LCTRL_problems.set_string_items(items = [ '%s%s' % (
				e['description'],
				gmTools.coalesce(e['health_issue'], '', ' (%s)')
			) for e in epis ])
			self._LCTRL_problems.set_data(epis)
Example #38
0
	def _get_as_amts_data(self, strict=True):
		txt = u'%s %s%s' % (
			self['descriptor'],
			self['l10n_type'],
			gmTools.coalesce(self['reaction'], u'', u': %s')
		)
		if strict:
			txt = txt[:200]
		# Freitextzeile: 200 Zeichen
		return u'<X t="%s"/>' % txt
Example #39
0
    def format(self, single_line=False):
        if single_line:
            return self.format_single_line()

        part_count = len(self._payload[self._idx['seq_idx_list']])
        if part_count == 0:
            parts = _('no parts')
        elif part_count == 1:
            parts = _('1 part')
        else:
            parts = _('%s parts') % part_count
        org = u''
        if self._payload[self._idx['unit']] is not None:
            if self._payload[self._idx['unit_is_receiver']]:
                org = _(' Receiver: %s @ %s\n') % (
                    self._payload[self._idx['unit']],
                    self._payload[self._idx['organization']])
            else:
                org = _(' Sender: %s @ %s\n') % (
                    self._payload[self._idx['unit']],
                    self._payload[self._idx['organization']])
        txt = _(
            '%s (%s)   #%s\n'
            ' Created: %s\n'
            ' Episode: %s\n'
            '%s'
            '%s'
            '%s'
            '%s') % (self._payload[self._idx['l10n_type']], parts,
                     self._payload[self._idx['pk_doc']],
                     gmDateTime.pydt_strftime(
                         self._payload[self._idx['clin_when']],
                         format='%Y %b %d',
                         accuracy=gmDateTime.acc_days),
                     self._payload[self._idx['episode']],
                     gmTools.coalesce(self._payload[self._idx['health_issue']],
                                      u'', _(' Health issue: %s\n')),
                     gmTools.coalesce(self._payload[self._idx['ext_ref']], u'',
                                      _(' External reference: %s\n')), org,
                     gmTools.coalesce(self._payload[self._idx['comment']], u'',
                                      u' %s'))

        return txt
Example #40
0
	def _refresh_from_existing(self):
		self._TCTRL_title.SetValue(self.data['title'])
		self._TCTRL_hint.SetValue(self.data['hint'])
		self._TCTRL_query.SetValue(self.data['query'])
		self._TCTRL_recommendation_query.SetValue(gmTools.coalesce(self.data['recommendation_query'], u''))
		self._TCTRL_source.SetValue(self.data['source'])
		self._TCTRL_url.SetValue(gmTools.coalesce(self.data['url'], u''))
		self._CHBOX_is_active.SetValue(self.data['is_active'])
		self._CHBOX_highlight.SetValue(self.data['highlight_as_priority'])
		if self.data['popup_type'] == 0:
			self._RBTN_popup_none.SetValue(True)
		elif self.data['popup_type'] == 1:
			self._RBTN_popup_single.SetValue(True)
		elif self.data['popup_type'] == 2:
			self._RBTN_popup_multiple.SetValue(True)
		else:
			raise ValueError('invalid popup type value [%s] - should be impossible' % self.data['popup_type'])

		self._TCTRL_query.SetFocus()
Example #41
0
    def refresh(lctrl):
        units = gmOrganization.get_org_units(
            order_by='organization, unit, l10n_unit_category')
        items = [[
            u['organization'], u['unit'],
            gmTools.coalesce(u['l10n_unit_category'], ''), u['pk_org_unit']
        ] for u in units]

        lctrl.set_string_items(items=items)
        lctrl.set_data(data=units)
Example #42
0
	def __refresh_meds(self, patient=None):

		emr = patient.emr

		list_items = []
		data_items = []
		first_red = False

		# harmful substance use ?
		abuses = emr.abused_substances
		if len([ a for a in abuses if a['use_type'] in gmMedication.USE_TYPES_ACTIVE_MISUSE ]) > 0:
			list_items.append(_('active substance abuse'))
			data_items.append('\n'.join([ a.format(left_margin=0, date_format='%Y %b %d', single_line=True) for a in abuses ]))

		# list by product or substance:
		intakes = emr.get_current_medications(include_inactive = False, order_by = 'substance')
		multi_products_already_seen = []
		for intake in intakes:
			drug = intake.containing_drug
			if len(drug['components']) == 1:
				list_items.append(_('%s %s%s%s') % (
					intake['substance'],
					intake['amount'],
					intake.formatted_units,
					gmTools.coalesce(intake['schedule'], '', ': %s')
				))
				data_items.append(intake)
			else:
				if intake['drug_product'] in multi_products_already_seen:
					continue
				multi_products_already_seen.append(intake['drug_product'])
				list_items.append(_('%s %s%s') % (
					intake['drug_product'],
					drug['l10n_preparation'],
					gmTools.coalesce(intake['schedule'], '', ': %s')
				))
				data_items.append(intake)

		self._LCTRL_meds.set_string_items(items = list_items)
		self._LCTRL_meds.set_data(data = data_items)

		if first_red:
			self._LCTRL_meds.SetItemTextColour(0, wx.Colour('RED'))
Example #43
0
	def __update_address_info(self, adr):
		if adr is None:
			self._LBL_address_details.SetLabel('')
			self._LBL_final_country.SetLabel('')
			self._LBL_final_region.SetLabel('')
			self._LBL_final_zip.SetLabel('')
			self._LBL_final_location.SetLabel('')
			self._LBL_final_street.SetLabel('')
			self._LBL_final_number.SetLabel('')
			self.Layout()
			return
		self._LBL_address_details.SetLabel('\n'.join(adr.format()))
		self._LBL_final_country.SetLabel(adr['l10n_country'])
		self._LBL_final_region.SetLabel(adr['l10n_region'])
		self._LBL_final_zip.SetLabel(adr['postcode'])
		self._LBL_final_location.SetLabel('%s%s' % (adr['urb'], gmTools.coalesce(adr['suburb'], '', ' - %s')))
		self._LBL_final_street.SetLabel(adr['street'])
		self._LBL_final_number.SetLabel('%s%s' % (adr['number'], gmTools.coalesce(adr['subunit'], '', ' %s')))
		self.Layout()
Example #44
0
 def refresh(lctrl):
     hints = gmAutoHints.get_dynamic_hints(
         order_by='is_active DESC, source, hint')
     items = [[
         gmTools.bool2subst(h['is_active'], gmTools.u_checkmark_thin, ''),
         h['title'], h['source'][:30], h['hint'][:60],
         gmTools.coalesce(h['url'], '')[:60], h['lang'], h['pk_auto_hint']
     ] for h in hints]
     lctrl.set_string_items(items)
     lctrl.set_data(hints)
Example #45
0
    def _refresh_from_existing(self):

        self._RBTN_tobacco.Disable()
        self._RBTN_c2.Disable()
        self._RBTN_other_substance.Disable()
        self._PRW_substance.Disable()

        if self.data['atc_substance'] == gmATC.ATC_NICOTINE:
            self._RBTN_tobacco.SetValue(True)
            self._RBTN_c2.SetValue(False)
            self._RBTN_other_substance.SetValue(False)
            self._PRW_substance.SetText('', None)
        elif self.data['atc_substance'] == gmATC.ATC_ETHANOL:
            self._RBTN_tobacco.SetValue(False)
            self._RBTN_c2.SetValue(True)
            self._RBTN_other_substance.SetValue(False)
            self._PRW_substance.SetText('', None)
        else:
            self._RBTN_tobacco.SetValue(False)
            self._RBTN_c2.SetValue(False)
            self._RBTN_other_substance.SetValue(True)
            self._PRW_substance.SetText(self.data['substance'],
                                        self.data['pk_substance'])

        if self.data['harmful_use_type'] == 0:
            self._RBTN_nonharmful_use.SetValue(True)
            self._RBTN_harmful_use.SetValue(False)
            self._RBTN_presently_addicted.SetValue(False)
            self._RBTN_previously_addicted.SetValue(False)
        elif self.data['harmful_use_type'] == 1:
            self._RBTN_nonharmful_use.SetValue(False)
            self._RBTN_harmful_use.SetValue(True)
            self._RBTN_presently_addicted.SetValue(False)
            self._RBTN_previously_addicted.SetValue(False)
        elif self.data['harmful_use_type'] == 2:
            self._RBTN_nonharmful_use.SetValue(False)
            self._RBTN_harmful_use.SetValue(False)
            self._RBTN_presently_addicted.SetValue(True)
            self._RBTN_previously_addicted.SetValue(False)
        elif self.data['harmful_use_type'] == 3:
            self._RBTN_nonharmful_use.SetValue(False)
            self._RBTN_harmful_use.SetValue(False)
            self._RBTN_presently_addicted.SetValue(False)
            self._RBTN_previously_addicted.SetValue(True)

        self._TCTRL_comment.SetValue(gmTools.coalesce(self.data['notes'], ''))
        self._DPRW_quit_when.SetText(data=self.data['discontinued'])
        self._LBL_confirm_date.SetLabel(
            gmDateTime.pydt_strftime(self.data['last_checked_when'],
                                     '%Y %b %d',
                                     none_str=''))
        self._CHBOX_confirm.Enable()
        self._CHBOX_confirm.SetValue(True)

        self._TCTRL_comment.SetFocus()
Example #46
0
    def edit_old(workplace=None):

        available_plugins = gmPlugin.get_installed_plugins(plugin_dir='gui')
        if workplace is None:
            dlg = wx.TextEntryDialog(
                parent,
                _('Enter a descriptive name for the new workplace:'),
                caption=_('Configuring GNUmed workplaces ...'),
                value='',
                style=wx.OK | wx.CENTRE)
            dlg.ShowModal()
            workplace = dlg.GetValue().strip()
            if workplace == '':
                gmGuiHelpers.gm_show_error(
                    _('Cannot save a new workplace without a name.'),
                    _('Configuring GNUmed workplaces ...'))
                return False
            curr_plugins = []
            choices = available_plugins
        else:
            curr_plugins = gmTools.coalesce(
                gmCfgDB.get4workplace(
                    option='horstspace.notebook.plugin_load_order',
                    workplace=workplace), [])
            choices = curr_plugins[:]
            for p in available_plugins:
                if p not in choices:
                    choices.append(p)

        sels = range(len(curr_plugins))
        new_plugins = gmListWidgets.get_choices_from_list(
            parent=parent,
            msg=_('\n'
                  'Select the plugin(s) to be loaded the next time\n'
                  'the client is restarted under the workplace:\n'
                  '\n'
                  ' [%s]'
                  '\n') % workplace,
            caption=_('Configuring GNUmed workplaces ...'),
            choices=choices,
            selections=sels,
            columns=[_('Plugins')],
            single_selection=False)

        if new_plugins == curr_plugins:
            return True

        if new_plugins is None:
            return True

        gmCfgDB.set(option='horstspace.notebook.plugin_load_order',
                    value=new_plugins,
                    workplace=workplace)

        return True
Example #47
0
	def __refresh_results(self, patient=None):

		emr = patient.emr
		most_recent = emr.get_most_recent_results_for_patient()
		if len(most_recent) == 0:
			self._LCTRL_results.set_string_items(items = [])
			self._LCTRL_results.set_data(data = [])
			return
		most_recent = most_recent[0]

		list_items = []
		list_data = []
		now = gmDateTime.pydt_now_here()

		list_items.append(_('Most recent lab work: %s ago (%s)') % (
			gmDateTime.format_interval_medically(now - most_recent['clin_when']),
			gmDateTime.pydt_strftime(most_recent['clin_when'], format = '%Y %b %d')
		))
		list_data.append(most_recent)

		unsigned = emr.get_unsigned_results(order_by = "(trim(coalesce(abnormality_indicator), '') <> '') DESC NULLS LAST, unified_abbrev")
		no_of_reds = 0
		for result in unsigned:
			if result['abnormality_indicator'] is not None:
				if result['abnormality_indicator'].strip() != '':
					no_of_reds += 1
			list_items.append(_('%s %s%s%s (%s ago, %s)') % (
				result['unified_abbrev'],
				result['unified_val'],
				gmTools.coalesce(result['val_unit'], '', ' %s'),
				gmTools.coalesce(result['abnormality_indicator'], '', ' %s'),
				gmDateTime.format_interval_medically(gmDateTime.pydt_now_here() - result['clin_when']),
				gmTools.u_writing_hand
			))
			list_data.append(result)

		self._LCTRL_results.set_string_items(items = list_items)
		self._LCTRL_results.set_data(data = list_data)

		if no_of_reds > 0:
			for idx in range(1, no_of_reds + 1):
				self._LCTRL_results.SetItemTextColour(idx, wx.Colour('RED'))
Example #48
0
    def edit(workplace=None):

        dbcfg = gmCfg.cCfgSQL()

        if workplace is None:
            dlg = wx.TextEntryDialog(
                parent=parent,
                message=_('Enter a descriptive name for the new workplace:'),
                caption=_('Configuring GNUmed workplaces ...'),
                defaultValue=u'',
                style=wx.OK | wx.CENTRE)
            dlg.ShowModal()
            workplace = dlg.GetValue().strip()
            if workplace == u'':
                gmGuiHelpers.gm_show_error(
                    _('Cannot save a new workplace without a name.'),
                    _('Configuring GNUmed workplaces ...'))
                return False
            curr_plugins = []
        else:
            curr_plugins = gmTools.coalesce(
                dbcfg.get2(option=u'horstspace.notebook.plugin_load_order',
                           workplace=workplace,
                           bias='workplace'), [])

        msg = _(
            'Pick the plugin(s) to be loaded the next time the client is restarted under the workplace:\n'
            '\n'
            '    [%s]\n') % workplace

        picker = gmListWidgets.cItemPickerDlg(
            parent, -1, title=_('Configuring workplace plugins ...'), msg=msg)
        picker.set_columns(['Available plugins'], ['Active plugins'])
        available_plugins = gmPlugin.get_installed_plugins(plugin_dir='gui')
        picker.set_choices(available_plugins)
        picker.set_picks(picks=curr_plugins[:])
        btn_pressed = picker.ShowModal()
        if btn_pressed != wx.ID_OK:
            picker.Destroy()
            return False

        new_plugins = picker.get_picks()
        picker.Destroy()
        if new_plugins == curr_plugins:
            return True

        if new_plugins is None:
            return True

        dbcfg.set(option=u'horstspace.notebook.plugin_load_order',
                  value=new_plugins,
                  workplace=workplace)

        return True
Example #49
0
 def refresh_episodes(lctrl):
     all_epis = [
         epi for epi in emr.get_episodes(order_by='description')
         if epi.has_narrative
     ]
     lctrl.set_string_items([[
         '%s%s' % (e['description'],
                   gmTools.coalesce(e['health_issue'], '', ' (%s)')),
         gmTools.bool2subst(e['episode_open'], _('open'), _('closed'))
     ] for e in all_epis])
     lctrl.set_data(all_epis)
Example #50
0
def edit_region(parent=None, region=None):
    ea = cProvinceEAPnl(parent=parent, id=-1, region=region)
    dlg = gmEditArea.cGenericEditAreaDlg2(parent=parent,
                                          id=-1,
                                          edit_area=ea,
                                          single_entry=(region is not None))
    dlg.SetTitle(
        gmTools.coalesce(region, _('Adding region'), _('Editing region')))
    result = dlg.ShowModal()
    dlg.Destroy()
    return (result == wx.ID_OK)
Example #51
0
 def add_documents(self, documents=None):
     for doc in documents:
         doc_tag = _(u'%s (%s)%s') % (
             doc['l10n_type'],
             gmDateTime.pydt_strftime(doc['clin_when'], '%Y %b %d'),
             gmTools.coalesce(doc['comment'], u'', u' "%s"'))
         for obj in doc.parts:
             if self.document_part_item_exists(pk_part=obj['pk_obj']):
                 continue
             f_ext = u''
             if obj['filename'] is not None:
                 f_ext = os.path.splitext(
                     obj['filename'])[1].strip('.').strip()
             if f_ext != u'':
                 f_ext = u' .' + f_ext.upper()
             obj_tag = _(u'part %s (%s%s)%s') % (
                 obj['seq_idx'], gmTools.size2str(obj['size']), f_ext,
                 gmTools.coalesce(obj['obj_comment'], u'', u' "%s"'))
             create_export_item(description=u'%s - %s' % (doc_tag, obj_tag),
                                pk_doc_obj=obj['pk_obj'])
Example #52
0
    def _refresh_from_existing(self):
        self._PRW_relationship.SetText(self.data['l10n_relation'],
                                       self.data['pk_fhx_relation_type'])
        self._PRW_condition.SetText(self.data['condition'], None)
        val, data = self._PRW_codes.generic_linked_codes2item_dict(
            self.data.generic_codes)
        self._PRW_codes.SetText(val, data)
        self._TCTRL_age_of_onset.SetValue(
            gmTools.coalesce(self.data['age_noted'], ''))
        self._PRW_age_of_death.SetData(self.data['age_of_death'])
        self._PRW_died_of_this.SetData(self.data['contributed_to_death'])
        self._PRW_episode.SetText(self.data['episode'],
                                  self.data['pk_episode'])
        self._TCTRL_name.SetValue(
            gmTools.coalesce(self.data['name_relative'], ''))
        self._PRW_dob.SetData(self.data['dob_relative'])
        self._TCTRL_comment.SetValue(gmTools.coalesce(self.data['comment'],
                                                      ''))

        self._PRW_relationship.SetFocus()
Example #53
0
	def _refresh_from_existing(self):
		if self.__type_is_editable:
			self._PRW_type.SetText(self.data['l10n_address_type'])
		else:
			self._PRW_type.SetText('', None)
		self._PRW_zip.SetText(self.data['postcode'])
		self._PRW_street.SetText(self.data['street'], data = self.data['street'])
		self._TCTRL_notes_street.SetValue(gmTools.coalesce(self.data['notes_street'], ''))
		self._TCTRL_number.SetValue(self.data['number'])
		self._TCTRL_subunit.SetValue(gmTools.coalesce(self.data['subunit'], ''))
		self._PRW_suburb.SetText(gmTools.coalesce(self.data['suburb'], ''))
		self._PRW_urb.SetText(self.data['urb'], data = self.data['urb'])
		self._PRW_state.SetText(self.data['l10n_region'], data = self.data['code_region'])
		self._PRW_country.SetText(self.data['l10n_country'], data = self.data['code_country'])
		self._TCTRL_notes_subunit.SetValue(gmTools.coalesce(self.data['notes_subunit'], ''))

		if self.__type_is_editable:
			self._PRW_type.SetFocus()
		else:
			self._PRW_zip.SetFocus()
Example #54
0
	def refresh(lctrl):
		epis = emr.get_episodes(order_by = 'description')
		items = [
			[	e['description'],
				gmTools.bool2subst(e['episode_open'], _('ongoing'), _('closed'), '<unknown>'),
				gmDateTime.pydt_strftime(e.best_guess_clinical_start_date, '%Y %b %d'),
				gmTools.coalesce(e['health_issue'], '')
			] for e in epis
		]
		lctrl.set_string_items(items = items)
		lctrl.set_data(data = epis)
Example #55
0
 def _save_as_new(self):
     enc_type = gmEMRStructItems.create_encounter_type(
         description=gmTools.none_if(self._TCTRL_name.GetValue().strip(),
                                     ''),
         l10n_description=gmTools.coalesce(
             gmTools.none_if(self._TCTRL_l10n_name.GetValue().strip(), ''),
             self._TCTRL_name.GetValue().strip()))
     if enc_type is None:
         return False
     self.data = enc_type
     return True
Example #56
0
def edit_inbox_message(parent=None, message=None, single_entry=True):

    if parent is None:
        parent = wx.GetApp().GetTopWindow()

    ea = cInboxMessageEAPnl(parent=parent, id=-1)
    ea.data = message
    ea.mode = gmTools.coalesce(message, 'new', 'edit')
    dlg = gmEditArea.cGenericEditAreaDlg2(parent=parent,
                                          id=-1,
                                          edit_area=ea,
                                          single_entry=single_entry)
    dlg.SetTitle(
        gmTools.coalesce(message, _('Adding new inbox message'),
                         _('Editing inbox message')))
    if dlg.ShowModal() == wx.ID_OK:
        dlg.Destroy()
        return True
    dlg.Destroy()
    return False
Example #57
0
def edit_dynamic_hint(parent=None, hint=None, single_entry=True):

    if parent is None:
        parent = wx.GetApp().GetTopWindow()

    ea = cAutoHintEAPnl(parent, -1)
    ea.data = hint
    ea.mode = gmTools.coalesce(hint, 'new', 'edit')
    dlg = gmEditArea.cGenericEditAreaDlg2(parent,
                                          -1,
                                          edit_area=ea,
                                          single_entry=single_entry)
    dlg.SetTitle(
        gmTools.coalesce(hint, _('Adding automatic dynamic hint'),
                         _('Editing automatic dynamic hint')))
    if dlg.ShowModal() == wx.ID_OK:
        dlg.DestroyLater()
        return True
    dlg.DestroyLater()
    return False
Example #58
0
def format_address_single_line(address=None, verbose=False, show_type=False):
    data = {
        'pk_adr': address['pk_address'],
        'street': address['street'],
        'notes_street': gmTools.coalesce(address['notes_street'], u'',
                                         u' (%s)'),
        'number': address['number'],
        'subunit': gmTools.coalesce(address['subunit'], u'', u'/%s'),
        'notes_subunit': gmTools.coalesce(address['notes_subunit'], u'',
                                          u' (%s)'),
        'zip': address['postcode'],
        'urb': address['urb'],
        'suburb': gmTools.coalesce(address['suburb'], u'', u' (%s)'),
        'l10n_region': address['l10n_region'],
        'code_region': address['code_region'],
        'l10n_country': address['l10n_country'],
        'code_country': address['code_country']
    }
    if show_type:
        data['type'] = address['l10n_address_type']

    if verbose:
        if show_type:
            template = _(
                '%(type)s: %(street)s %(number)s%(subunit)s, %(zip)s %(urb)s %(suburb)s, %(code_region)s, %(code_country)s (%(l10n_region)s, %(l10n_country)s)'
            )
        else:
            template = _(
                '%(street)s %(number)s%(subunit)s, %(zip)s %(urb)s %(suburb)s, %(code_region)s, %(code_country)s (%(l10n_region)s, %(l10n_country)s)'
            )
    else:
        if show_type:
            template = _(
                '%(type)s: %(street)s %(number)s%(subunit)s, %(zip)s %(urb)s, %(code_region)s, %(code_country)s (%(l10n_region)s, %(l10n_country)s)'
            )
        else:
            template = _(
                '%(street)s %(number)s%(subunit)s, %(zip)s %(urb)s, %(code_region)s, %(code_country)s (%(l10n_region)s, %(l10n_country)s)'
            )

    return template % data
Example #59
0
	def set_persons(self, persons=None):
		self._LCTRL_persons.DeleteAllItems()

		pos = len(persons) + 1
		if pos == 1:
			return False

		for person in persons:
			row_num = self._LCTRL_persons.InsertItem(pos, label = gmTools.coalesce(person['title'], person['lastnames'], '%s, %%s' % person['lastnames']))
			self._LCTRL_persons.SetItem(index = row_num, column = 1, label = person['firstnames'])
			self._LCTRL_persons.SetItem(index = row_num, column = 2, label = person.get_formatted_dob(format = '%Y %b %d'))
			self._LCTRL_persons.SetItem(index = row_num, column = 3, label = gmTools.coalesce(person['l10n_gender'], '?'))

			label = ''
			if person.is_patient:
				enc = person.get_last_encounter()
				if enc is not None:
					label = '%s (%s)' % (gmDateTime.pydt_strftime(enc['started'], '%Y %b %d'), enc['l10n_type'])
			self._LCTRL_persons.SetItem(index = row_num, column = 4, label = label)

			parts = []
			if person['preferred'] is not None:
				parts.append(person['preferred'])
			if person['comment'] is not None:
				parts.append(person['comment'])
			self._LCTRL_persons.SetItem(index = row_num, column = 5, label = ' / '.join(parts))

			try:
				self._LCTRL_persons.SetItem(index = row_num, column = 6, label = person['match_type'])
			except KeyError:
				_log.warning('cannot set match_type field')
				self._LCTRL_persons.SetItem(index = row_num, column = 6, label = '??')

		for col in range(len(self.__cols)):
			self._LCTRL_persons.SetColumnWidth(col, wx.LIST_AUTOSIZE)

		self._BTN_select.Enable(False)
		self._LCTRL_persons.SetFocus()
		self._LCTRL_persons.Select(0)

		self._LCTRL_persons.set_data(data = persons)
Example #60
0
 def refresh(lctrl):
     coded_terms = gmCoding.get_coded_terms(
         coding_systems=coding_systems,
         languages=languages,
         order_by='term, coding_system, code')
     items = [[
         ct['term'], ct['code'], ct['coding_system'],
         gmTools.coalesce(ct['lang'], ''), ct['version'],
         ct['coding_system_long']
     ] for ct in coded_terms]
     lctrl.set_string_items(items)
     lctrl.set_data(coded_terms)