Esempio n. 1
0
    def delete(item):
        if item is None:
            return False
        dlg = gmGuiHelpers.c2ButtonQuestionDlg(
            parent,
            -1,
            caption=_('Deleting progress note'),
            question=_(
                'Are you positively sure you want to delete this\n'
                'progress note from the medical record ?\n'
                '\n'
                'Note that even if you chose to delete the entry it will\n'
                'still be (invisibly) kept in the audit trail to protect\n'
                'you from litigation because physical deletion is known\n'
                'to be unlawful in some jurisdictions.\n'),
            button_defs=({
                'label': _('Delete'),
                'tooltip': _('Yes, delete the progress note.'),
                'default': False
            }, {
                'label': _('Cancel'),
                'tooltip': _('No, do NOT delete the progress note.'),
                'default': True
            }))
        decision = dlg.ShowModal()

        if decision != wx.ID_YES:
            return False

        gmClinNarrative.delete_clin_narrative(narrative=item['pk_narrative'])
        return True
Esempio n. 2
0
def ask_for_encounter_continuation(msg=None, caption=None, encounter=None, parent=None):
	"""This is used as the callback when the EMR detects that the
	   patient was here rather recently and wants to ask the
	   provider whether to continue the recent encounter.
	"""
	if parent is None:
		parent = wx.GetApp().GetTopWindow()

	dlg = gmGuiHelpers.c2ButtonQuestionDlg (
		parent = None,
		id = -1,
		caption = caption,
		question = msg,
		button_defs = [
			{'label': _('Continue'), 'tooltip': _('Continue the existing recent encounter.'), 'default': False},
			{'label': _('Start new'), 'tooltip': _('Start a new encounter. The existing one will be closed.'), 'default': True}
		],
		show_checkbox = False
	)

	result = dlg.ShowModal()
	dlg.Destroy()

	if result == wx.ID_YES:
		return True

	return False
Esempio n. 3
0
	def delete(item):
		if item is None:
			return False
		dlg = gmGuiHelpers.c2ButtonQuestionDlg (
			parent,
			-1,
			caption = _('Deleting progress note'),
			question = _(
				'Are you positively sure you want to delete this\n'
				'progress note from the medical record ?\n'
				'\n'
				'Note that even if you chose to delete the entry it will\n'
				'still be (invisibly) kept in the audit trail to protect\n'
				'you from litigation because physical deletion is known\n'
				'to be unlawful in some jurisdictions.\n'
			),
			button_defs = (
				{'label': _('Delete'), 'tooltip': _('Yes, delete the progress note.'), 'default': False},
				{'label': _('Cancel'), 'tooltip': _('No, do NOT delete the progress note.'), 'default': True}
			)
		)
		decision = dlg.ShowModal()

		if decision != wx.ID_YES:
			return False

		gmClinNarrative.delete_clin_narrative(narrative = item['pk_narrative'])
		return True
Esempio n. 4
0
	def connect(self):
		# connect to GNUmed instance
		port = _cfg.get(group = 'GNUmed instance', option = 'port', source_order = [('explicit', 'return')])
		self.__gm_server = xmlrpc.client.ServerProxy('https://localhost:%s' % int(port))

		try:
			_log.info('GNUmed slave XML-RPC server version: %s' % self.__gm_server.version())
		except socket.error, e:
			# FIXME: differentiate between already-attached and not-there
			_log.exception('cannot attach to GNUmed instance at https://localhost:%s: %s' % (port, e))
			# try starting GNUmed
			# - no use trying to start GNUmed if wx cannot be imported
			import wx
			startup_cmd = _cfg.get(group = 'GNUmed instance', option = 'startup command', source_order = [('explicit', 'return')])
			if startup_cmd is None:
				_log.error('cannot start GNUmed slave, no startup command defined')
				return False
			os.system(startup_cmd)	# better be non-blocking, use gmShellAPI
			_log.info('trying to start one with [%s]' % startup_cmd)
			app = wx.PySimpleApp()
			dlg = gmGuiHelpers.c2ButtonQuestionDlg (
				caption = _('gm_ctl_client: starting slave GNUmed client'),
				question = _(
					'A GNUmed slave client has been started because\n'
					'no running client could be found. You will now\n'
					'have to enter your user name and password into\n'
					'the login dialog as usual.\n'
					'\n'
					'Switch to the GNUmed login dialog now and proceed\n'
					'with the login procedure. Once GNUmed has started\n'
					'up successfully switch back to this window.\n'
				),
				button_defs = [
					{'label': _('Connect to GNUmed'), 'tooltip': _('Proceed and try to connect to the newly started GNUmed client.'), 'default': True},
					{'label': _('Abort'), 'tooltip': _('Abort and do NOT connect to GNUmed.')}
				]
			)
			retry = (dlg.ShowModal() == wx.ID_YES)

			if not retry:
				return False

			alt_port = _cfg.get(group = 'GNUmed instance', option = 'startup port', source_order = [('explicit', 'return')])
			if alt_port is not None:
				port = alt_port

			try:
				_log.info(self.__gm_server.version())
			except socket.error, e:
				# FIXME: differentiate between already-attached and not-there
				_log.exception('cannot attach to GNUmed instance at https://localhost:%s: %s' % (port, e))
				return False
Esempio n. 5
0
	def connect(self):
		# connect to GNUmed instance
		port = _cfg.get(group = 'GNUmed instance', option = 'port', source_order = [('explicit', 'return')])
		self.__gm_server = xmlrpc.client.ServerProxy('http://localhost:%s' % int(port))

		try:
			_log.info('GNUmed slave XML-RPC server version: %s' % self.__gm_server.version())
		except socket.error, e:
			# FIXME: differentiate between already-attached and not-there
			_log.exception('cannot attach to GNUmed instance at http://localhost:%s: %s' % (port, e))
			# try starting GNUmed
			# - no use trying to start GNUmed if wx cannot be imported
			import wx
			startup_cmd = _cfg.get(group = 'GNUmed instance', option = 'startup command', source_order = [('explicit', 'return')])
			if startup_cmd is None:
				_log.error('cannot start GNUmed slave, no startup command defined')
				return False
			os.system(startup_cmd)	# better be non-blocking, use gmShellAPI
			_log.info('trying to start one with [%s]' % startup_cmd)
			app = wx.PySimpleApp()
			dlg = gmGuiHelpers.c2ButtonQuestionDlg (
				caption = _('gm_ctl_client: starting slave GNUmed client'),
				question = _(
					'A GNUmed slave client has been started because\n'
					'no running client could be found. You will now\n'
					'have to enter your user name and password into\n'
					'the login dialog as usual.\n'
					'\n'
					'Switch to the GNUmed login dialog now and proceed\n'
					'with the login procedure. Once GNUmed has started\n'
					'up successfully switch back to this window.\n'
				),
				button_defs = [
					{'label': _('Connect to GNUmed'), 'tooltip': _('Proceed and try to connect to the newly started GNUmed client.'), 'default': True},
					{'label': _('Abort'), 'tooltip': _('Abort and do NOT connect to GNUmed.')}
				]
			)
			retry = (dlg.ShowModal() == wx.ID_YES)

			if not retry:
				return False

			alt_port = _cfg.get(group = 'GNUmed instance', option = 'startup port', source_order = [('explicit', 'return')])
			if alt_port is not None:
				port = alt_port

			try:
				_log.info(self.__gm_server.version())
			except socket.error, e:
				# FIXME: differentiate between already-attached and not-there
				_log.exception('cannot attach to GNUmed instance at http://localhost:%s: %s' % (port, e))
				return False
Esempio n. 6
0
    def delete(workplace):

        curr_workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace
        if workplace == curr_workplace:
            gmDispatcher.send(signal='statustext',
                              msg=_('Cannot delete the active workplace.'),
                              beep=True)
            return False

        dlg = gmGuiHelpers.c2ButtonQuestionDlg(
            parent,
            -1,
            caption=_('Deleting workplace ...'),
            question=_(
                'Are you sure you want to delete this workplace ?\n\n "%s"\n')
            % workplace,
            show_checkbox=True,
            checkbox_msg=_('delete configuration, too'),
            checkbox_tooltip=_(
                'Check this if you want to delete all configuration items\n'
                'for this workplace along with the workplace itself.'),
            button_defs=[{
                'label': _('Delete'),
                'tooltip': _('Yes, delete this workplace.'),
                'default': True
            }, {
                'label': _('Do NOT delete'),
                'tooltip': _('No, do NOT delete this workplace'),
                'default': False
            }])

        decision = dlg.ShowModal()
        if decision != wx.ID_YES:
            dlg.Destroy()
            return False

        include_cfg = dlg.checkbox_is_checked()
        dlg.Destroy()

        dbo_conn = gmAuthWidgets.get_dbowner_connection(
            procedure=_('delete workplace'))
        if not dbo_conn:
            return False

        gmPraxis.delete_workplace(workplace=workplace,
                                  conn=dbo_conn,
                                  delete_config=include_cfg)
        return True
Esempio n. 7
0
def delete_region(parent=None, region=None):

    msg = _('Are you sure you want to delete this region ?\n'
            '\n'
            'Deletion will only work if this region is not\n'
            'yet in use in any patient addresses.')

    tt = _('Also delete any towns/cities/villages known\n'
           'to be situated in this state as long as\n'
           'no patients are recorded to live there.')

    dlg = gmGuiHelpers.c2ButtonQuestionDlg(
        parent,
        -1,
        caption=_('Deleting region'),
        question=msg,
        show_checkbox=True,
        checkbox_msg=_('delete related townships'),
        checkbox_tooltip=tt,
        button_defs=[{
            'label':
            _('Yes, delete'),
            'tooltip':
            _('Delete region and possibly related townships.'),
            'default':
            False
        }, {
            'label': _('No'),
            'tooltip': _('No, do NOT delete anything.'),
            'default': True
        }])

    decision = dlg.ShowModal()
    if decision != wx.ID_YES:
        dlg.Destroy()
        return False

    include_urbs = dlg.checkbox_is_checked()
    dlg.Destroy()

    return gmDemographicRecord.delete_region(region=region,
                                             delete_urbs=include_urbs)
Esempio n. 8
0
def delete_region(parent=None, region=None):

	msg = _(
		'Are you sure you want to delete this region ?\n'
		'\n'
		'Deletion will only work if this region is not\n'
		'yet in use in any patient addresses.'
	)

	tt = _(
		'Also delete any towns/cities/villages known\n'
		'to be situated in this state as long as\n'
		'no patients are recorded to live there.'
	)

	dlg = gmGuiHelpers.c2ButtonQuestionDlg (
		parent,
		-1,
		caption = _('Deleting region'),
		question = msg,
		show_checkbox = True,
		checkbox_msg = _('delete related townships'),
		checkbox_tooltip = tt,
		button_defs = [
			{'label': _('Yes, delete'), 'tooltip': _('Delete region and possibly related townships.'), 'default': False},
			{'label': _('No'), 'tooltip': _('No, do NOT delete anything.'), 'default': True}
		]
	)

	decision = dlg.ShowModal()
	if decision != wx.ID_YES:
		dlg.DestroyLater()
		return False

	include_urbs = dlg.checkbox_is_checked()
	dlg.DestroyLater()

	return gmDemographicRecord.delete_region(region = region, delete_urbs = include_urbs)
Esempio n. 9
0
	def delete(workplace):

		curr_workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace
		if workplace == curr_workplace:
			gmDispatcher.send(signal = 'statustext', msg = _('Cannot delete the active workplace.'), beep = True)
			return False

		dlg = gmGuiHelpers.c2ButtonQuestionDlg (
			parent,
			-1,
			caption = _('Deleting workplace ...'),
			question = _('Are you sure you want to delete this workplace ?\n\n "%s"\n') % workplace,
			show_checkbox = True,
			checkbox_msg = _('delete configuration, too'),
			checkbox_tooltip = _(
				'Check this if you want to delete all configuration items\n'
				'for this workplace along with the workplace itself.'
			),
			button_defs = [
				{'label': _('Delete'), 'tooltip': _('Yes, delete this workplace.'), 'default': True},
				{'label': _('Do NOT delete'), 'tooltip': _('No, do NOT delete this workplace'), 'default': False}
			]
		)

		decision = dlg.ShowModal()
		if decision != wx.ID_YES:
			dlg.Destroy()
			return False

		include_cfg = dlg.checkbox_is_checked()
		dlg.Destroy()

		dbo_conn = gmAuthWidgets.get_dbowner_connection(procedure = _('delete workplace'))
		if not dbo_conn:
			return False

		gmPraxis.delete_workplace(workplace = workplace, conn = dbo_conn, delete_config = include_cfg)
		return True
Esempio n. 10
0
def mail_log(parent=None, comment=None, helpdesk=None, sender=None):

		if (comment is None) or (comment.strip() == ''):
			comment = wx.GetTextFromUser (
				message = _(
					'Please enter a short note on what you\n'
					'were about to do in GNUmed:'
				),
				caption = _('Sending bug report'),
				parent = parent
			)
			if comment.strip() == '':
				comment = '<user did not comment on bug report>'

		receivers = []
		if helpdesk is not None:
			receivers = regex.findall (
				'[\S]+@[\S]+',
				helpdesk.strip(),
				flags = regex.UNICODE
			)
		if len(receivers) == 0:
			if _is_public_database:
				receivers = ['*****@*****.**']

		receiver_string = wx.GetTextFromUser (
			message = _(
				'Edit the list of email addresses to send the\n'
				'bug report to (separate addresses by spaces).\n'
				'\n'
				'Note that <*****@*****.**> refers to\n'
				'the public (!) GNUmed bugs mailing list.'
			),
			caption = _('Sending bug report'),
			default_value = ','.join(receivers),
			parent = parent
		)
		if receiver_string.strip() == '':
			return

		receivers = regex.findall (
			'[\S]+@[\S]+',
			receiver_string,
			flags = regex.UNICODE
		)

		dlg = gmGuiHelpers.c2ButtonQuestionDlg (
			parent,
			-1,
			caption = _('Sending bug report'),
			question = _(
				'Your bug report will be sent to:\n'
				'\n'
				'%s\n'
				'\n'
				'Make sure you have reviewed the log file for potentially\n'
				'sensitive information before sending out the bug report.\n'
				'\n'
				'Note that emailing the report may take a while depending\n'
				'on the speed of your internet connection.\n'
			) % '\n'.join(receivers),
			button_defs = [
				{'label': _('Send report'), 'tooltip': _('Yes, send the bug report.')},
				{'label': _('Cancel'), 'tooltip': _('No, do not send the bug report.')}
			],
			show_checkbox = True,
			checkbox_msg = _('include log file in bug report')
		)
		dlg._CHBOX_dont_ask_again.SetValue(_is_public_database)
		go_ahead = dlg.ShowModal()
		if go_ahead == wx.ID_NO:
			dlg.DestroyLater()
			return

		include_log = dlg._CHBOX_dont_ask_again.GetValue()
		if not _is_public_database:
			if include_log:
				result = gmGuiHelpers.gm_show_question (
					_(
						'The database you are connected to is marked as\n'
						'"in-production with controlled access".\n'
						'\n'
						'You indicated that you want to include the log\n'
						'file in your bug report. While this is often\n'
						'useful for debugging the log file might contain\n'
						'bits of patient data which must not be sent out\n'
						'without de-identification.\n'
						'\n'
						'Please confirm that you want to include the log !'
					),
					_('Sending bug report')
				)
				include_log = (result is True)

		if sender is None:
			sender = _('<not supplied>')
		else:
			if sender.strip() == '':
				sender = _('<not supplied>')

		msg = """\
Report sent via GNUmed's handler for unexpected exceptions.

user comment  : %s

client version: %s

system account: %s
staff member  : %s
sender email  : %s

 # enable Launchpad bug tracking
 affects gnumed
 tag automatic-report
 importance medium

""" % (comment, _client_version, _local_account, _staff_name, sender)
		if include_log:
			_log.error(comment)
			_log.warning('syncing log file for emailing')
			gmLog2.flush()
			attachments = [ [_logfile_name, 'text/plain', 'quoted-printable'] ]
		else:
			attachments = None

		dlg.DestroyLater()

		wx.BeginBusyCursor()
		_cfg = gmCfg2.gmCfgData()
		try:
			gmNetworkTools.compose_and_send_email (
				sender = '%s <%s>' % (_staff_name, gmNetworkTools.default_mail_sender),
				receiver = receivers,
				subject = '<bug>: %s' % comment,
				message = msg,
				server = gmNetworkTools.default_mail_server,
				auth = {'user': gmNetworkTools.default_mail_sender, 'password': '******'},
				debug = _cfg.get(option = 'debug'),
				attachments = attachments
			)
			gmDispatcher.send(signal='statustext', msg = _('Bug report has been emailed.'))
		except:
			_log.exception('cannot send bug report')
			gmDispatcher.send(signal='statustext', msg = _('Bug report COULD NOT be emailed.'))
		wx.EndBusyCursor()
Esempio n. 11
0
def _ask_for_encounter_continuation(new_encounter=None,
                                    fairly_recent_encounter=None):
    """This is used as the callback when the EMR detects that the
	   patient was here rather recently and wants to ask the
	   provider whether to continue the recent encounter.
	"""
    # better safe than sorry
    if new_encounter['pk_patient'] != fairly_recent_encounter['pk_patient']:
        raise ValueError(
            'pk_patient values on new (enc=%s pat=%s) and fairly-recent (enc=%s pat=%s) encounter do not match'
            % (new_encounter['pk_encounter'], new_encounter['pk_patient'],
               fairly_recent_encounter['pk_encounter'],
               fairly_recent_encounter['pk_patient']))

    # only pester user if current patient is concerned
    curr_pat = gmPerson.gmCurrentPatient()
    if new_encounter['pk_patient'] != curr_pat.ID:
        return

    # ask user
    msg = _('%s, %s  [#%s]\n'
            '\n'
            "This patient's chart was worked on only recently:\n"
            '\n'
            ' %s'
            '\n'
            'Do you want to continue that consultation ?\n'
            ' (If not a new one will be used.)\n') % (
                curr_pat.get_description_gender(with_nickname=False),
                gmDateTime.pydt_strftime(curr_pat['dob'],
                                         '%Y %b %d'), curr_pat.ID,
                fairly_recent_encounter.format(episodes=None,
                                               with_soap=False,
                                               left_margin=1,
                                               patient=None,
                                               issues=None,
                                               with_docs=False,
                                               with_tests=False,
                                               fancy_header=False,
                                               with_vaccinations=False,
                                               with_rfe_aoe=True,
                                               with_family_history=False,
                                               with_co_encountlet_hints=False,
                                               by_episode=False))
    dlg = gmGuiHelpers.c2ButtonQuestionDlg(
        parent=None,
        id=-1,
        caption=_('Pulling chart'),
        question=msg,
        button_defs=[{
            'label': _('Continue recent'),
            'tooltip': _('Continue the existing recent encounter.'),
            'default': False
        }, {
            'label':
            _('Start new'),
            'tooltip':
            _('Start a new encounter. The existing one will be closed.'),
            'default':
            True
        }],
        show_checkbox=False)
    result = dlg.ShowModal()
    dlg.DestroyLater()

    # switch encounters
    if result == wx.ID_YES:
        _log.info('user wants to continue fairly-recent encounter')
        curr_pat.emr.active_encounter = fairly_recent_encounter
        if new_encounter.transfer_all_data_to_another_encounter(
                pk_target_encounter=fairly_recent_encounter['pk_encounter']):
            if not gmEMRStructItems.delete_encounter(
                    pk_encounter=new_encounter['pk_encounter']):
                gmGuiHelpers.gm_show_info(
                    _('Properly switched to fairly recent encounter but unable to delete newly-created encounter.'
                      ), _('Pulling chart'))
        else:
            gmGuiHelpers.gm_show_info(
                _('Unable to transfer the data from newly-created to fairly recent encounter.'
                  ), _('Pulling chart'))
        return

    _log.debug('stayed with newly created encounter')
Esempio n. 12
0
	def _on_enter(self, search_term=None):
		"""This can be overridden in child classes."""

		wx.BeginBusyCursor()

		# get list of matching ids
		idents = self.__person_searcher.get_identities(search_term)

		if idents is None:
			wx.EndBusyCursor()
			gmGuiHelpers.gm_show_info (
				_('Error searching for matching persons.\n\n'
				  'Search term: "%s"'
				) % search_term,
				_('selecting person')
			)
			return None

		_log.info("%s matching person(s) found", len(idents))

		if len(idents) == 0:
			wx.EndBusyCursor()

			dlg = gmGuiHelpers.c2ButtonQuestionDlg (
				wx.GetTopLevelParent(self),
				-1,
				caption = _('Selecting patient'),
				question = _(
					'Cannot find any matching patients for the search term\n\n'
					' "%s"\n\n'
					'You may want to try a shorter search term.\n'
				) % search_term,
				button_defs = [
					{'label': _('Go back'), 'tooltip': _('Go back and search again.'), 'default': True},
					{'label': _('Create new'), 'tooltip': _('Create new patient.')}
				]
			)
			if dlg.ShowModal() != wx.ID_NO:
				return

			success = create_new_person(activate = True)
			if success:
				self.person = gmPerson.gmCurrentPatient()
			else:
				self.person = None
			return None

		# only one matching identity
		if len(idents) == 1:
			self.person = idents[0]
			wx.EndBusyCursor()
			return None

		# more than one matching identity: let user select from pick list
		dlg = cSelectPersonFromListDlg(parent=wx.GetTopLevelParent(self), id=-1)
		dlg.set_persons(persons=idents)
		wx.EndBusyCursor()
		result = dlg.ShowModal()
		if result == wx.ID_CANCEL:
			dlg.DestroyLater()
			return None

		wx.BeginBusyCursor()
		self.person = dlg.get_selected_person()
		dlg.DestroyLater()
		wx.EndBusyCursor()

		return None
Esempio n. 13
0
def mail_log(parent=None, comment=None, helpdesk=None, sender=None):

    if (comment is None) or (comment.strip() == ''):
        comment = wx.GetTextFromUser(message=_(
            'Please enter a short note on what you\n'
            'were about to do in GNUmed:'),
                                     caption=_('Sending bug report'),
                                     parent=parent)
        if comment.strip() == '':
            comment = '<user did not comment on bug report>'

    receivers = []
    if helpdesk is not None:
        receivers = regex.findall('[\S]+@[\S]+',
                                  helpdesk.strip(),
                                  flags=regex.UNICODE)
    if len(receivers) == 0:
        if _is_public_database:
            receivers = ['*****@*****.**']

    receiver_string = wx.GetTextFromUser(message=_(
        'Edit the list of email addresses to send the\n'
        'bug report to (separate addresses by spaces).\n'
        '\n'
        'Note that <*****@*****.**> refers to\n'
        'the public (!) GNUmed bugs mailing list.'),
                                         caption=_('Sending bug report'),
                                         default_value=','.join(receivers),
                                         parent=parent)
    if receiver_string.strip() == '':
        return

    receivers = regex.findall('[\S]+@[\S]+',
                              receiver_string,
                              flags=regex.UNICODE)

    dlg = gmGuiHelpers.c2ButtonQuestionDlg(
        parent,
        -1,
        caption=_('Sending bug report'),
        question=_('Your bug report will be sent to:\n'
                   '\n'
                   '%s\n'
                   '\n'
                   'Make sure you have reviewed the log file for potentially\n'
                   'sensitive information before sending out the bug report.\n'
                   '\n'
                   'Note that emailing the report may take a while depending\n'
                   'on the speed of your internet connection.\n') %
        '\n'.join(receivers),
        button_defs=[{
            'label': _('Send report'),
            'tooltip': _('Yes, send the bug report.')
        }, {
            'label': _('Cancel'),
            'tooltip': _('No, do not send the bug report.')
        }],
        show_checkbox=True,
        checkbox_msg=_('include log file in bug report'))
    dlg._CHBOX_dont_ask_again.SetValue(_is_public_database)
    go_ahead = dlg.ShowModal()
    if go_ahead == wx.ID_NO:
        dlg.DestroyLater()
        return

    include_log = dlg._CHBOX_dont_ask_again.GetValue()
    if not _is_public_database:
        if include_log:
            result = gmGuiHelpers.gm_show_question(
                _('The database you are connected to is marked as\n'
                  '"in-production with controlled access".\n'
                  '\n'
                  'You indicated that you want to include the log\n'
                  'file in your bug report. While this is often\n'
                  'useful for debugging the log file might contain\n'
                  'bits of patient data which must not be sent out\n'
                  'without de-identification.\n'
                  '\n'
                  'Please confirm that you want to include the log !'),
                _('Sending bug report'))
            include_log = (result is True)

    if sender is None:
        sender = _('<not supplied>')
    else:
        if sender.strip() == '':
            sender = _('<not supplied>')

    msg = """\
Report sent via GNUmed's handler for unexpected exceptions.

user comment  : %s

client version: %s

system account: %s
staff member  : %s
sender email  : %s

 # enable Launchpad bug tracking
 affects gnumed
 tag automatic-report
 importance medium

""" % (comment, _client_version, _local_account, _staff_name, sender)
    if include_log:
        _log.error(comment)
        _log.warning('syncing log file for emailing')
        gmLog2.flush()
        attachments = [[_logfile_name, 'text/plain', 'quoted-printable']]
    else:
        attachments = None

    dlg.DestroyLater()

    wx.BeginBusyCursor()
    _cfg = gmCfg2.gmCfgData()
    try:
        gmNetworkTools.compose_and_send_email(
            sender='%s <%s>' %
            (_staff_name, gmNetworkTools.default_mail_sender),
            receiver=receivers,
            subject='<bug>: %s' % comment,
            message=msg,
            server=gmNetworkTools.default_mail_server,
            auth={
                'user': gmNetworkTools.default_mail_sender,
                'password': '******'
            },
            debug=_cfg.get(option='debug'),
            attachments=attachments)
        gmDispatcher.send(signal='statustext',
                          msg=_('Bug report has been emailed.'))
    except:
        _log.exception('cannot send bug report')
        gmDispatcher.send(signal='statustext',
                          msg=_('Bug report COULD NOT be emailed.'))
    wx.EndBusyCursor()
Esempio n. 14
0
def mail_log(parent=None, comment=None, helpdesk=None, sender=None):

    if (comment is None) or (comment.strip() == u""):
        comment = wx.GetTextFromUser(
            message=_("Please enter a short note on what you\n" "were about to do in GNUmed:"),
            caption=_("Sending bug report"),
            parent=parent,
        )
        if comment.strip() == u"":
            comment = u"<user did not comment on bug report>"

    receivers = []
    if helpdesk is not None:
        receivers = regex.findall("[\S]+@[\S]+", helpdesk.strip(), flags=regex.UNICODE | regex.LOCALE)
    if len(receivers) == 0:
        if _is_public_database:
            receivers = [u"*****@*****.**"]

    receiver_string = wx.GetTextFromUser(
        message=_(
            "Edit the list of email addresses to send the\n"
            "bug report to (separate addresses by spaces).\n"
            "\n"
            "Note that <*****@*****.**> refers to\n"
            "the public (!) GNUmed bugs mailing list."
        ),
        caption=_("Sending bug report"),
        default_value=",".join(receivers),
        parent=parent,
    )
    if receiver_string.strip() == u"":
        return

    receivers = regex.findall("[\S]+@[\S]+", receiver_string, flags=regex.UNICODE | regex.LOCALE)

    dlg = gmGuiHelpers.c2ButtonQuestionDlg(
        parent,
        -1,
        caption=_("Sending bug report"),
        question=_(
            "Your bug report will be sent to:\n"
            "\n"
            "%s\n"
            "\n"
            "Make sure you have reviewed the log file for potentially\n"
            "sensitive information before sending out the bug report.\n"
            "\n"
            "Note that emailing the report may take a while depending\n"
            "on the speed of your internet connection.\n"
        )
        % u"\n".join(receivers),
        button_defs=[
            {"label": _("Send report"), "tooltip": _("Yes, send the bug report.")},
            {"label": _("Cancel"), "tooltip": _("No, do not send the bug report.")},
        ],
        show_checkbox=True,
        checkbox_msg=_("include log file in bug report"),
    )
    dlg._CHBOX_dont_ask_again.SetValue(_is_public_database)
    go_ahead = dlg.ShowModal()
    if go_ahead == wx.ID_NO:
        dlg.Destroy()
        return

    include_log = dlg._CHBOX_dont_ask_again.GetValue()
    if not _is_public_database:
        if include_log:
            result = gmGuiHelpers.gm_show_question(
                _(
                    "The database you are connected to is marked as\n"
                    '"in-production with controlled access".\n'
                    "\n"
                    "You indicated that you want to include the log\n"
                    "file in your bug report. While this is often\n"
                    "useful for debugging the log file might contain\n"
                    "bits of patient data which must not be sent out\n"
                    "without de-identification.\n"
                    "\n"
                    "Please confirm that you want to include the log !"
                ),
                _("Sending bug report"),
            )
            include_log = result is True

    if sender is None:
        sender = _("<not supplied>")
    else:
        if sender.strip() == u"":
            sender = _("<not supplied>")

    msg = u"""\
Report sent via GNUmed's handler for unexpected exceptions.

user comment  : %s

client version: %s

system account: %s
staff member  : %s
sender email  : %s

 # enable Launchpad bug tracking
 affects gnumed
 tag automatic-report
 importance medium

""" % (
        comment,
        _client_version,
        _local_account,
        _staff_name,
        sender,
    )
    if include_log:
        _log2.error(comment)
        _log2.warning("syncing log file for emailing")
        gmLog2.flush()
        attachments = [[_logfile_name, "text/plain", "quoted-printable"]]
    else:
        attachments = None

    dlg.Destroy()

    wx.BeginBusyCursor()
    try:
        gmNetworkTools.send_mail(
            sender="%s <%s>" % (_staff_name, gmNetworkTools.default_mail_sender),
            receiver=receivers,
            subject=u"<bug>: %s" % comment,
            message=msg,
            encoding=gmI18N.get_encoding(),
            server=gmNetworkTools.default_mail_server,
            auth={"user": gmNetworkTools.default_mail_sender, "password": u"gnumed-at-gmx-net"},
            attachments=attachments,
        )
        gmDispatcher.send(signal="statustext", msg=_("Bug report has been emailed."))
    except:
        _log2.exception("cannot send bug report")
        gmDispatcher.send(signal="statustext", msg=_("Bug report COULD NOT be emailed."))
    wx.EndBusyCursor()
Esempio n. 15
0
	def _on_enter(self, search_term=None):
		"""This can be overridden in child classes."""

		wx.BeginBusyCursor()

		# get list of matching ids
		idents = self.__person_searcher.get_identities(search_term)

		if idents is None:
			wx.EndBusyCursor()
			gmGuiHelpers.gm_show_info (
				_('Error searching for matching persons.\n\n'
				  'Search term: "%s"'
				) % search_term,
				_('selecting person')
			)
			return None

		_log.info("%s matching person(s) found", len(idents))

		if len(idents) == 0:
			wx.EndBusyCursor()

			dlg = gmGuiHelpers.c2ButtonQuestionDlg (
				wx.GetTopLevelParent(self),
				-1,
				caption = _('Selecting patient'),
				question = _(
					'Cannot find any matching patients for the search term\n\n'
					' "%s"\n\n'
					'You may want to try a shorter search term.\n'
				) % search_term,
				button_defs = [
					{'label': _('Go back'), 'tooltip': _('Go back and search again.'), 'default': True},
					{'label': _('Create new'), 'tooltip': _('Create new patient.')}
				]
			)
			if dlg.ShowModal() != wx.ID_NO:
				return

			success = create_new_person(activate = True)
			if success:
				self.person = gmPerson.gmCurrentPatient()
			else:
				self.person = None
			return None

		# only one matching identity
		if len(idents) == 1:
			self.person = idents[0]
			wx.EndBusyCursor()
			return None

		# more than one matching identity: let user select from pick list
		dlg = cSelectPersonFromListDlg(parent=wx.GetTopLevelParent(self), id=-1)
		dlg.set_persons(persons=idents)
		wx.EndBusyCursor()
		result = dlg.ShowModal()
		if result == wx.ID_CANCEL:
			dlg.DestroyLater()
			return None

		wx.BeginBusyCursor()
		self.person = dlg.get_selected_person()
		dlg.DestroyLater()
		wx.EndBusyCursor()

		return None