def _on_remove_button_pressed(self, evt):
     self.__id_most_recently_activated_patient = None
     item = self._LCTRL_patients.get_selected_item_data(only_one=True)
     if item is None:
         return
     cmt = gmTools.coalesce(item['comment'], '').split('\n')[0].strip()[:40]
     if cmt != '':
         cmt += '\n'
     question = _(
         'Are you sure you want to remove\n'
         '\n'
         ' %s, %s (%s)\n'
         ' born: %s\n'
         ' %s'
         '\n'
         'from the waiting list ?') % (
             item['lastnames'], item['firstnames'], item['l10n_gender'],
             gmTools.coalesce(gmTools.coalesce(
                 item['dob'], '', function4value=('strftime', '%d %b %Y')),
                              '',
                              function4value=('decode',
                                              gmI18N.get_encoding())), cmt)
     do_delete = gmGuiHelpers.gm_show_question(
         title=_('Delete waiting list entry'), question=question)
     if not do_delete:
         return
     gmPraxis.gmCurrentPraxisBranch().remove_from_waiting_list(
         pk=item['pk_waiting_list'])
Exemple #2
0
	def contribute_translations(item=None):

		do_it = gmGuiHelpers.gm_show_question (
			aTitle = _('Contributing translations'),
			aMessage = _('Do you want to contribute your translations to the GNUmed project ?')
		)
		if not do_it:
			return False

		fname = gmTools.get_unique_filename(prefix = 'gm-db-translations-', suffix = '.sql')
		gmPG2.export_translations_from_database(filename = fname)

		msg = (
			'These are database string translations contributed by a GNUmed user.\n'
			'\n'
			'\tThe GNUmed "%s" Client'
		) % gmI18N.system_locale

		if not gmNetworkTools.compose_and_send_email (
			auth = {'user': gmNetworkTools.default_mail_sender, 'password': '******'},
			sender = 'GNUmed Client <*****@*****.**>',
			receiver = ['*****@*****.**'],
			subject = '<contribution>: database translation',
			message = msg,
			attachments = [[fname, 'text/plain', 'quoted-printable']]
		):
			gmDispatcher.send(signal = 'statustext', msg = _('Unable to send mail. Cannot contribute translations to GNUmed community.') % report, beep = True)
			return False

		gmDispatcher.send(signal = 'statustext', msg = _('Thank you for your contribution to the GNUmed community!'), beep = True)
		return True
Exemple #3
0
    def delete(translation=None):
        msg = _(
            'Are you sure you want to delete the translation of:\n'
            '\n'
            '%s\n'
            '\n'
            'into [%s] as:\n'
            '\n'
            '%s\n'
            '\n'
            '?  (Note that you must know the database administrator password !)\n'
        ) % (gmTools.wrap(text=translation['orig'],
                          width=60,
                          initial_indent='  ',
                          subsequent_indent='  '), translation['lang'],
             gmTools.wrap(text=translation['trans'],
                          width=60,
                          initial_indent='  ',
                          subsequent_indent='  '))
        delete_it = gmGuiHelpers.gm_show_question(
            aTitle=_('Deleting translation from database'), aMessage=msg)
        if not delete_it:
            return False

        conn = gmAuthWidgets.get_dbowner_connection(
            procedure=_('deleting a translation'))
        if conn is None:
            return False

        return gmPG2.delete_translation_from_database(
            link_obj=conn,
            language=translation['lang'],
            original=translation['orig'])
Exemple #4
0
	def delete(item):
		delete_it = gmGuiHelpers.gm_show_question (
			aTitle = _('Deleting option'),
			aMessage = '%s\n\n%s %s (#%s) %s\n\n%s\n\n%s' % (
				tooltip(item),
				gmTools.u_box_horiz_single * 3,
				item['option'],
				item['pk_cfg_item'],
				gmTools.u_box_horiz_single * 3,
				_('Do you really want to delete this option ?'),
				_('(GNUmed will re-create options as needed.)')
			)
		)
		if not delete_it:
			return False

		from Gnumed.wxpython.gmAuthWidgets import get_dbowner_connection
		conn = get_dbowner_connection(procedure = _('Deleting option'))
		if conn is None:
			gmDispatcher.send(signal = 'statustext', msg = _('Cannot connect as database owner. Unable to delete option.'))
			return False

		cfg = gmCfg.cCfgSQL()
		cfg.delete(conn = conn, pk_option = item['pk_cfg_item'])
		return True
Exemple #5
0
    def _on_waiting_list_button_pressed(self, event):
        event.Skip()

        pat_pk_key = self._LCTRL_result.patient_pk_data_key
        if pat_pk_key is None:
            gmGuiHelpers.gm_show_info(info=_(
                'These report results do not seem to contain per-patient data.'
            ),
                                      title=_('Using report results'))
            return

        zone = wx.GetTextFromUser(
            _('Enter a waiting zone to put patients in:'),
            caption=_('Using report results'),
            default_value=_('search results'))
        if zone.strip() == '':
            return

        data = self._LCTRL_result.get_selected_item_data(only_one=False)
        if data is None:
            use_all = gmGuiHelpers.gm_show_question(
                title=_('Using report results'),
                question=
                _('No results selected.\n\nTransfer ALL patients from results to waiting list ?'
                  ),
                cancel_button=True)
            if not use_all:
                return
            data = self._LCTRL_result.data

        comment = self._PRW_report_name.GetValue().strip()
        for item in data:
            pat = gmPerson.cPerson(aPK_obj=item[pat_pk_key])
            pat.put_on_waiting_list(comment=comment, zone=zone)
Exemple #6
0
	def delete(enc=None):
		if enc is None:
			return False
		question = _(
			'Really delete encounter [%s] ?\n'
			'\n'
			'Once deletion succeeds it cannot be undone.\n'
			'\n'
			'Note that it will only succeed if there\n'
			'is no data attached to the encounter.'
		) % enc['pk_encounter']
		delete_it = gmGuiHelpers.gm_show_question (
			question = question,
			title = _('Deleting encounter'),
			cancel_button = False
		)
		if not delete_it:
			return False
		if gmEMRStructItems.delete_encounter(pk_encounter = enc['pk_encounter']):
			return True
		gmDispatcher.send (
			signal = 'statustext',
			msg = _('Cannot delete encounter [%s]. It is probably in use.') % enc['pk_encounter'],
			beep = True
		)
		return False
Exemple #7
0
	def delete(enc=None):
		if enc is None:
			return False
		question = _(
			'Really delete encounter [%s] ?\n'
			'\n'
			'Once deletion succeeds it cannot be undone.\n'
			'\n'
			'Note that it will only succeed if there\n'
			'is no data attached to the encounter.'
		) % enc['pk_encounter']
		delete_it = gmGuiHelpers.gm_show_question (
			question = question,
			title = _('Deleting encounter'),
			cancel_button = False
		)
		if not delete_it:
			return False
		if gmEMRStructItems.delete_encounter(pk_encounter = enc['pk_encounter']):
			return True
		gmDispatcher.send (
			signal = u'statustext',
			msg = _('Cannot delete encounter [%s]. It is probably in use.') % enc['pk_encounter'],
			beep = True
		)
		return False
Exemple #8
0
	def _on_waiting_list_button_pressed(self, event):
		event.Skip()

		pat_pk_key = self._LCTRL_result.patient_pk_data_key
		if pat_pk_key is None:
			gmGuiHelpers.gm_show_info (
				info = _('These report results do not seem to contain per-patient data.'),
				title = _('Using report results')
			)
			return

		zone = wx.GetTextFromUser (
			_('Enter a waiting zone to put patients in:'),
			caption = _('Using report results'),
			default_value = _('search results')
		)
		if zone.strip() == '':
			return

		data = self._LCTRL_result.get_selected_item_data(only_one = False)
		if data is None:
			use_all = gmGuiHelpers.gm_show_question (
				title = _('Using report results'),
				question = _('No results selected.\n\nTransfer ALL patients from results to waiting list ?'),
				cancel_button = True
			)
			if not use_all:
				return
			data = self._LCTRL_result.data

		comment = self._PRW_report_name.GetValue().strip()
		for item in data:
			pat = gmPerson.cPerson(aPK_obj = item[pat_pk_key])
			pat.put_on_waiting_list (comment = comment, zone = zone)
Exemple #9
0
 def _del_comm(self, comm):
     go_ahead = gmGuiHelpers.gm_show_question(
         _('Are you sure this communication channel\n'
           'can no longer be used ?'), _('Removing communication channel'))
     if not go_ahead:
         return False
     self.__channel_owner.unlink_comm_channel(comm_channel=comm)
     return True
Exemple #10
0
	def _on_contribute_button_pressed(self, evt):
		report = self._PRW_report_name.GetValue().strip()
		if report == u'':
			gmDispatcher.send(signal = 'statustext', msg = _('Report must have a name for contribution.'), beep = False)
			return

		query = self._TCTRL_query.GetValue().strip()
		if query == u'':
			gmDispatcher.send(signal = 'statustext', msg = _('Report must have a query for contribution.'), beep = False)
			return

		do_it = gmGuiHelpers.gm_show_question (
			_(	'Be careful that your contribution (the query itself) does\n'
				'not contain any person-identifiable search parameters.\n'
				'\n'
				'Note, however, that no query result data whatsoever\n'
				'is included in the contribution that will be sent.\n'
				'\n'
				'Are you sure you wish to send this query to\n'
				'the gnumed community mailing list?\n'
			),
			_('Contributing custom report')
		)
		if not do_it:
			return

		auth = {'user': gmNetworkTools.default_mail_sender, 'password': u'gnumed-at-gmx-net'}
		msg = u"""--- This is a report definition contributed by a GNUmed user.

--- Save it as a text file and drop it onto the Report Generator
--- inside GNUmed in order to take advantage of the contribution.

----------------------------------------

--- %s

%s

----------------------------------------

--- The GNUmed client.
""" % (report, query)

		if not gmNetworkTools.send_mail (
			sender = u'GNUmed Report Generator <*****@*****.**>',
			receiver = [u'*****@*****.**'],
			subject = u'user contributed report',
			message = msg,
			encoding = gmI18N.get_encoding(),
			server = gmNetworkTools.default_mail_server,
			auth = auth
		):
			gmDispatcher.send(signal = 'statustext', msg = _('Unable to send mail. Cannot contribute report [%s] to GNUmed community.') % report, beep = True)
			return False

		gmDispatcher.send(signal = 'statustext', msg = _('Thank you for your contribution to the GNUmed community!'), beep = False)
		return True
Exemple #11
0
 def _del_id(self, ext_id):
     go_ahead = gmGuiHelpers.gm_show_question(
         _('Do you really want to delete this\n'
           'external ID from the organizational unit ?'),
         _('Deleting external ID'))
     if not go_ahead:
         return False
     self.__unit.delete_external_id(pk_ext_id=ext_id['pk_id'])
     return True
Exemple #12
0
	def _on_contribute_button_pressed(self, evt):
		report = self._PRW_report_name.GetValue().strip()
		if report == u'':
			gmDispatcher.send(signal = 'statustext', msg = _('Report must have a name for contribution.'), beep = False)
			return

		query = self._TCTRL_query.GetValue().strip()
		if query == u'':
			gmDispatcher.send(signal = 'statustext', msg = _('Report must have a query for contribution.'), beep = False)
			return

		do_it = gmGuiHelpers.gm_show_question (
			_(	'Be careful that your contribution (the query itself) does\n'
				'not contain any person-identifiable search parameters.\n'
				'\n'
				'Note, however, that no query result data whatsoever\n'
				'is included in the contribution that will be sent.\n'
				'\n'
				'Are you sure you wish to send this query to\n'
				'the gnumed community mailing list?\n'
			),
			_('Contributing custom report')
		)
		if not do_it:
			return

		auth = {'user': gmNetworkTools.default_mail_sender, 'password': u'gnumed-at-gmx-net'}
		msg = u"""--- This is a report definition contributed by a GNUmed user.

--- Save it as a text file and drop it onto the Report Generator
--- inside GNUmed in order to take advantage of the contribution.

----------------------------------------

--- %s

%s

----------------------------------------

--- The GNUmed client.
""" % (report, query)

		if not gmNetworkTools.send_mail (
			sender = u'GNUmed Report Generator <*****@*****.**>',
			receiver = [u'*****@*****.**'],
			subject = u'user contributed report',
			message = msg,
			encoding = gmI18N.get_encoding(),
			server = gmNetworkTools.default_mail_server,
			auth = auth
		):
			gmDispatcher.send(signal = 'statustext', msg = _('Unable to send mail. Cannot contribute report [%s] to GNUmed community.') % report, beep = True)
			return False

		gmDispatcher.send(signal = 'statustext', msg = _('Thank you for your contribution to the GNUmed community!'), beep = False)
		return True
Exemple #13
0
	def __get_password(self, msg_title):
		while True:
			data_pwd = wx.GetPasswordFromUser (
				message = _(
					'Enter passphrase to protect the data with.\n'
					'\n'
					'(minimum length: 5, trailing blanks will be stripped)'
				),
				caption = msg_title
			)
			# minimal weakness check
			data_pwd = data_pwd.rstrip()
			if len(data_pwd) > 4:
				break
			retry = gmGuiHelpers.gm_show_question (
				title = msg_title,
				question = _(
					'Insufficient passphrase.\n'
					'\n'
					'(minimum length: 5, trailing blanks will be stripped)\n'
					'\n'
					'Enter another passphrase ?'
				)
			)
			if not retry:
				# user changed her mind
				return None
		# confidentiality
		gmLog2.add_word2hide(data_pwd)
		# reget password
		while True:
			data_pwd4comparison = wx.GetPasswordFromUser (
				message = _(
					'Once more enter passphrase to protect the data with.\n'
					'\n'
					'(this will protect you from typos)\n'
					'\n'
					'Abort by leaving empty.'
				),
				caption = msg_title
			)
			data_pwd4comparison = data_pwd4comparison.rstrip()
			if data_pwd4comparison == '':
				# user changed her mind ...
				return None
			if data_pwd == data_pwd4comparison:
				break
			gmGuiHelpers.gm_show_error (
				error = _(
					'Passphrases do not match.\n'
					'\n'
					'Retry, or abort with an empty passphrase.'
				),
				title = msg_title
			)
		return data_pwd
Exemple #14
0
	def _del_id(self, ext_id):
		go_ahead = gmGuiHelpers.gm_show_question (
			_(	'Do you really want to delete this\n'
				'external ID from the organizational unit ?'),
			_('Deleting external ID')
		)
		if not go_ahead:
			return False
		self.__unit.delete_external_id(pk_ext_id = ext_id['pk_id'])
		return True
Exemple #15
0
    def _on_burn_items_button_pressed(self, event):
        event.Skip()

        found, external_cmd = gmShellAPI.detect_external_binary('gm-burn_doc')
        if not found:
            return False

        items = self._LCTRL_items.get_selected_item_data(only_one=False)
        if len(items) == 0:
            items = self._LCTRL_items.get_item_data()

        base_dir = None
        dlg = wx.DirDialog(
            self,
            message=_(
                'If you wish to include an existing directory select it here:'
            ),
            defaultPath=os.path.join(gmTools.gmPaths().home_dir, 'gnumed'),
            style=wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST)
        choice = dlg.ShowModal()
        path2include = dlg.GetPath()
        if choice == wx.ID_OK:
            if not gmTools.dir_is_empty(path2include):
                base_dir = path2include

        export_dir = gmPerson.gmCurrentPatient().export_area.export(
            base_dir=base_dir, items=items, with_metadata=True)
        if export_dir is None:
            return False

        cmd = u'%s %s' % (external_cmd, export_dir)
        if os.name == 'nt':
            blocking = True
        else:
            blocking = False
        success = gmShellAPI.run_command_in_shell(command=cmd,
                                                  blocking=blocking)
        if not success:
            gmGuiHelpers.gm_show_error(
                aMessage=_('Error burning documents to CD/DVD.'),
                aTitle=_('Burning documents'))
            return False

        self.save_soap_note(soap=_('Burned onto CD/DVD:\n - %s') %
                            u'\n - '.join([i['description'] for i in items]))

        browse_index = gmGuiHelpers.gm_show_question(
            title=title,
            question=_('Browse patient data pack ?'),
            cancel_button=False)
        if browse_index:
            gmNetworkTools.open_url_in_browser(
                url=u'file://%s' % os.path.join(export_dir, u'index.html'))

        return True
Exemple #16
0
 def del_hint(hint=None):
     if hint is None:
         return False
     really_delete = gmGuiHelpers.gm_show_question(
         title=_("Deleting suppressed dynamic hint"),
         question=_("Really delete the suppression of this dynamic hint ?\n\n [%s]") % hint["title"],
     )
     if not really_delete:
         return False
     gmAutoHints.delete_suppressed_hint(pk_suppressed_hint=hint["pk_suppressed_hint"])
     return True
Exemple #17
0
	def _del_comm(self, comm):
		go_ahead = gmGuiHelpers.gm_show_question (
			_(	'Are you sure this communication channel\n'
				'can no longer be used ?'
			),
			_('Removing communication channel')
		)
		if not go_ahead:
			return False
		self.__channel_owner.unlink_comm_channel(comm_channel = comm)
		return True
Exemple #18
0
	def SaveCurrParam(self):
		"""save parameter dialog"""
		# self.currSelParam is the name of the parameter with optional
		# cookie part appended, defParamName the name without cookie part !
		# you must use the latter to access config definitions !

		if not (self.currSelParam is None or self.currSelSubtree is None):

			# get new value
			val = self.paramTextCtrl.GetValue()
			
			currConfSource = self.mConfSources[self.currSelSubtree]
			newValue = currConfSource.castType(self.currSelParam,val)

			if newValue is None:
				gmGuiHelpers.gm_show_error (
					_('Type of entered value is not compatible with type expected.'),
					_('saving configuration')
				)

			# a particular config definition refers to a parameter name
			# without the cookie part. we have to strip the 
			# cookie off get the correct parameter
			defParamName = currConfSource.getRawName(self.currSelParam)

			# config definition object
			confDefinition = currConfSource.hasDefinition()

			# if there is no config definition, ask the user if the
			# new value should be stored unchecked

			if not confDefinition or not currConfSource.hasParameterDefinition(defParamName):
				if gmGuiHelpers.gm_show_question (
					_("There is no config definition for this parameter.\nThus it can't be checked for validity.\n\nSave anyway ?"),
					_('saving configuration')):
					currConfSource.setConfigData( self.currSelParam,newValue)
				
					# reshow new data to mark it non modified
					self.__show_parameter(self.currSelSubtree,self.currSelParam)
				return 

			# else check parameter for validity

			if currConfSource.isValid(defParamName,newValue):
				currConfSource.setConfigData(self.currSelParam,newValue)
				
				# reshow new data to mark it non modified
				self.__show_parameter(self.currSelSubtree,self.currSelParam)
			else:
				# TODO: display some hint on what could be wrong
				gmGuiHelpers.gm_show_error (
					_('Entered value is not valid.'),
					_('saving configuration')
				)
Exemple #19
0
	def SaveCurrParam(self):
		"""save parameter dialog"""
		# self.currSelParam is the name of the parameter with optional
		# cookie part appended, defParamName the name without cookie part !
		# you must use the latter to access config definitions !

		if not (self.currSelParam is None or self.currSelSubtree is None):

			# get new value
			val = self.paramTextCtrl.GetValue()
			
			currConfSource = self.mConfSources[self.currSelSubtree]
			newValue = currConfSource.castType(self.currSelParam,val)

			if newValue is None:
				gmGuiHelpers.gm_show_error (
					_('Type of entered value is not compatible with type expected.'),
					_('saving configuration')
				)

			# a particular config definition refers to a parameter name
			# without the cookie part. we have to strip the 
			# cookie off get the correct parameter
			defParamName = currConfSource.getRawName(self.currSelParam)

			# config definition object
			confDefinition = currConfSource.hasDefinition()

			# if there is no config definition, ask the user if the
			# new value should be stored unchecked

			if not confDefinition or not currConfSource.hasParameterDefinition(defParamName):
				if gmGuiHelpers.gm_show_question (
					_("There is no config definition for this parameter.\nThus it can't be checked for validity.\n\nSave anyway ?"),
					_('saving configuration')):
					currConfSource.setConfigData( self.currSelParam,newValue)
				
					# reshow new data to mark it non modified
					self.__show_parameter(self.currSelSubtree,self.currSelParam)
				return 

			# else check parameter for validity

			if currConfSource.isValid(defParamName,newValue):
				currConfSource.setConfigData(self.currSelParam,newValue)
				
				# reshow new data to mark it non modified
				self.__show_parameter(self.currSelSubtree,self.currSelParam)
			else:
				# TODO: display some hint on what could be wrong
				gmGuiHelpers.gm_show_error (
					_('Entered value is not valid.'),
					_('saving configuration')
				)
Exemple #20
0
	def del_hint(hint=None):
		if hint is None:
			return False
		really_delete = gmGuiHelpers.gm_show_question (
			title = _('Deleting suppressed dynamic hint'),
			question = _('Really delete the suppression of this dynamic hint ?\n\n [%s]') % hint['title']
		)
		if not really_delete:
			return False
		gmAutoHints.delete_suppressed_hint(pk_suppressed_hint = hint['pk_suppressed_hint'])
		return True
Exemple #21
0
 def _del_address(self, address):
     go_ahead = gmGuiHelpers.gm_show_question(
         _('Are you sure you want to remove this\n'
           "address from the patient's addresses ?\n"
           '\n'
           'The address itself will not be deleted\n'
           'but it will no longer be associated with\n'
           'this patient.'), _('Removing address'))
     if not go_ahead:
         return False
     self.__identity.unlink_address(address=address)
     return True
Exemple #22
0
	def _on_fax_items_button_pressed(self, event):
		event.Skip()

		_log.debug('gm-fax_doc(.bat) API: "FAX-PROGRAM FAXNUMBER-OR-<EMPTY> LIST-OF-FILES-TO-FAX" (any file type !)')

		found, external_cmd = gmShellAPI.detect_external_binary('gm-fax_doc')
		if not found:
			gmDispatcher.send(signal = 'statustext', msg = _('Cannot send fax: <gm-fax_doc(.bat)> not found'))
			return False

		items = self._LCTRL_items.get_selected_item_data(only_one = False)
		if len(items) == 0:
			items = self._LCTRL_items.get_item_data()
			if len(items) == 0:
				gmDispatcher.send(signal = 'statustext', msg = _('Cannot send fax: no items'))
				return None
			if len(items) > 1:
				# ask, might be a lot
				process_all = gmGuiHelpers.gm_show_question (
					title = _('Faxing documents'),
					question = _('You have not selected any entries.\n\nSend fax with all %s entries ?') % len(items),
					cancel_button = False
				)
				if not process_all:
					return None

			return False

		files2fax = []
		for item in items:
			files2fax.append(item.save_to_file())
		fax_number = wx.GetTextFromUser (
			_('Please enter the fax number here !\n\n'
			  'It can be left empty if the external\n'
			  'fax software knows how to get the number.'),
			caption = _('Faxing documents'),
			parent = self,
			centre = True
		)
		if fax_number == '':
			fax_number = 'EMPTY'
		args = [external_cmd, fax_number, ' '.join(files2fax)]
		success, ret_code, stdout = gmShellAPI.run_process(cmd_line = args, verbose = _cfg.get(option = 'debug'))
		if not success:
			gmGuiHelpers.gm_show_error (
				aMessage = _('Error faxing documents to\n\n  %s') % fax_number,
				aTitle = _('Faxing documents')
			)
			return False

		self.__save_soap_note(soap = _('Faxed to [%s]:\n - %s') % (fax_number, '\n - '.join([ i['description'] for i in items ])))
		return True
Exemple #23
0
	def _on_remove_items_button_pressed(self, event):
		event.Skip()
		items = self._LCTRL_items.get_selected_item_data(only_one = False)
		if len(items) == 0:
			return
		really_delete = gmGuiHelpers.gm_show_question (
			title = _('Deleting document from export area.'),
			question = _('Really remove %s selected document(s)\nfrom the patient export area ?') % len(items)
		)
		if not really_delete:
			return
		for item in items:
			gmPerson.gmCurrentPatient().export_area.remove_item(item)
Exemple #24
0
	def __perhaps_save_soap(self):
		if self._TCTRL_soap.GetValue().strip() == '':
			return True
		if self.__problem is None:
			# FIXME: this could potentially lose input
			self._TCTRL_soap.SetValue('')
			return None
		save_it = gmGuiHelpers.gm_show_question (
			title = _('Saving SOAP note'),
			question = _('Do you want to save the SOAP note ?')
		)
		if save_it:
			return self.__save_soap()
		return False
Exemple #25
0
 def _del_care(self, external_care_item):
     go_ahead = gmGuiHelpers.gm_show_question(
         _('Do you really want to delete this\n'
           'external care entry from the patient ?'),
         _('Deleting external care entry'))
     if not go_ahead:
         return False
     if gmExternalCare.delete_external_care_item(
             pk_external_care=external_care_item['pk_external_care']):
         return True
     gmDispatcher.send(signal='statustext',
                       msg=_('Cannot delete external care item.'),
                       beep=True)
     return False
Exemple #26
0
	def _on_delete_button_pressed(self, event):
		event.Skip()
		printouts = self._LCTRL_printouts.get_selected_item_data(only_one = False)
		if len(printouts) == 0:
			return
		if len(printouts) > 1:
			really_delete = gmGuiHelpers.gm_show_question (
				title = _('Deleting document from export area.'),
				question = _('Really remove %s selected document(s)\nfrom the patient export area ?') % len(printouts)
			)
			if not really_delete:
				return
		for printout in printouts:
			gmExportArea.delete_export_item(pk_export_item = printout['pk_export_item'])
Exemple #27
0
	def __perhaps_save_soap(self):
		if self._TCTRL_soap.GetValue().strip() == '':
			return True
		if self.__problem is None:
			# FIXME: this could potentially lose input
			self._TCTRL_soap.SetValue('')
			return None
		save_it = gmGuiHelpers.gm_show_question (
			title = _('Saving SOAP note'),
			question = _('Do you want to save the SOAP note ?')
		)
		if save_it:
			return self.__save_soap()
		return False
Exemple #28
0
	def _on_enlist_button_pressed(self, evt):
		# sanity checks
		if self._TXT_password.GetValue() != self._TXT_password_again.GetValue():
			gmGuiHelpers.gm_show_error (
				aMessage = _('Password entries do not match. Please type in the passwords again to rule out typos.'),
				aTitle = _('Adding GNUmed user')
			)
			self._TXT_password.SetValue('')
			self._TXT_password_again.SetValue('')
			return False

		if self._TXT_password.GetValue().strip() == '':
			really_wants_empty_password = gmGuiHelpers.gm_show_question (
				aMessage = _(
					'Are you positively sure you want to create\n'
					'a user with an empty password ?\n'
					'\n'
					'Think about the record access implications !'
				),
				aTitle = _('Adding GNUmed user')
			)
			if not really_wants_empty_password:
				return False

		# connect as "gm-dbo"
		conn = gmAuthWidgets.get_dbowner_connection (
			procedure = _('Enlisting person as user.'),
			dbo_password = gmTools.none_if(self._TXT_dbo_password.GetValue(), '')
		)
		if conn is None:
			return False

		# create new user
		success, msg = gmStaff.create_staff (
			conn = conn,
			db_account = self._TXT_account.GetValue(),
			password = self._TXT_password.GetValue(),
			identity = gmPerson.gmCurrentPatient().ID,
			short_alias = self._TXT_short_alias.GetValue().strip()
		)
		conn.close()
		if not success:
			gmGuiHelpers.gm_show_error(aMessage = msg, aTitle = _('Adding GNUmed user'))
			return False

		if self.IsModal():
			self.EndModal(wx.ID_OK)
		else:
			self.Close()
	def _del_address(self, address):
		go_ahead = gmGuiHelpers.gm_show_question (
			_(	'Are you sure you want to remove this\n'
				"address from the patient's addresses ?\n"
				'\n'
				'The address itself will not be deleted\n'
				'but it will no longer be associated with\n'
				'this patient.'
			),
			_('Removing address')
		)
		if not go_ahead:
			return False
		self.__identity.unlink_address(address = address)
		return True
Exemple #30
0
 def delete(template):
     delete = gmGuiHelpers.gm_show_question(
         aTitle=_('Deleting form template.'),
         aMessage=_('Are you sure you want to delete\n'
                    'the following form template ?\n\n'
                    ' "%s (%s)"\n\n'
                    'You can only delete templates which\n'
                    'have not yet been used to generate\n'
                    'any forms from.') %
         (template['name_long'], template['external_version']))
     if delete:
         # FIXME: make this a priviledged operation ?
         gmForms.delete_form_template(template=template)
         return True
     return False
Exemple #31
0
	def __browse_patient_data(self, base_dir):

		msg = _('Documents saved into:\n\n %s') % base_dir
		browse_index = gmGuiHelpers.gm_show_question (
			title = _('Browsing patient data excerpt'),
			question = msg + '\n\n' + _('Browse saved entries ?'),
			cancel_button = False
		)
		if not browse_index:
			return

		if os.path.isfile(os.path.join(base_dir, 'index.html')):
			gmNetworkTools.open_url_in_browser(url = 'file://%s' % os.path.join(base_dir, 'index.html'))
			return

		gmMimeLib.call_viewer_on_file(base_dir, block = False)
Exemple #32
0
	def _del_care(self, external_care_item):
		go_ahead = gmGuiHelpers.gm_show_question (
			_(	'Do you really want to delete this\n'
				'external care entry from the patient ?'),
			_('Deleting external care entry')
		)
		if not go_ahead:
			return False
		if gmExternalCare.delete_external_care_item(pk_external_care = external_care_item['pk_external_care']):
			return True
		gmDispatcher.send (
			signal = u'statustext',
			msg = _('Cannot delete external care item.'),
			beep = True
		)
		return False
Exemple #33
0
    def _on_enlist_button_pressed(self, evt):
        # sanity checks
        if self._TXT_password.GetValue() != self._TXT_password_again.GetValue(
        ):
            gmGuiHelpers.gm_show_error(aMessage=_(
                'Password entries do not match. Please type in the passwords again to rule out typos.'
            ),
                                       aTitle=_('Adding GNUmed user'))
            self._TXT_password.SetValue('')
            self._TXT_password_again.SetValue('')
            return False

        if self._TXT_password.GetValue().strip() == '':
            really_wants_empty_password = gmGuiHelpers.gm_show_question(
                aMessage=_('Are you positively sure you want to create\n'
                           'a user with an empty password ?\n'
                           '\n'
                           'Think about the record access implications !'),
                aTitle=_('Adding GNUmed user'))
            if not really_wants_empty_password:
                return False

        # connect as "gm-dbo"
        conn = gmAuthWidgets.get_dbowner_connection(
            procedure=_('Enlisting person as user.'),
            dbo_password=gmTools.none_if(self._TXT_dbo_password.GetValue(),
                                         ''))
        if conn is None:
            return False

        # create new user
        success, msg = gmStaff.create_staff(
            conn=conn,
            db_account=self._TXT_account.GetValue(),
            password=self._TXT_password.GetValue(),
            identity=gmPerson.gmCurrentPatient().ID,
            short_alias=self._TXT_short_alias.GetValue().strip())
        conn.close()
        if not success:
            gmGuiHelpers.gm_show_error(aMessage=msg,
                                       aTitle=_('Adding GNUmed user'))
            return False

        if self.IsModal():
            self.EndModal(wx.ID_OK)
        else:
            self.Close()
Exemple #34
0
	def del_hint(hint=None):
		if hint is None:
			return False
		really_delete = gmGuiHelpers.gm_show_question (
			title = _('Deleting automatic dynamic hint'),
			question = _('Really delete this dynamic hint ?\n\n [%s]') % hint['title']
		)
		if not really_delete:
			return False

		conn = gmAuthWidgets.get_dbowner_connection(procedure = _('deleting a dynamic hint'))
		if conn is None:
			return False
		gmAutoHints.delete_dynamic_hint(link_obj = conn, pk_hint = hint['pk_auto_hint'])
		conn.commit()
		conn.close()
		return True
Exemple #35
0
	def delete(template):
		delete = gmGuiHelpers.gm_show_question (
			aTitle = _('Deleting form template.'),
			aMessage = _(
				'Are you sure you want to delete\n'
				'the following form template ?\n\n'
				' "%s (%s)"\n\n'
				'You can only delete templates which\n'
				'have not yet been used to generate\n'
				'any forms from.'
			) % (template['name_long'], template['external_version'])
		)
		if delete:
			# FIXME: make this a priviledged operation ?
			gmForms.delete_form_template(template = template)
			return True
		return False
Exemple #36
0
    def del_hint(hint=None):
        if hint is None:
            return False
        really_delete = gmGuiHelpers.gm_show_question(
            title=_("Deleting automatic dynamic hint"),
            question=_("Really delete this dynamic hint ?\n\n [%s]") % hint["title"],
        )
        if not really_delete:
            return False

        conn = gmAuthWidgets.get_dbowner_connection(procedure=_("deleting a dynamic hint"))
        if conn is None:
            return False
        gmAutoHints.delete_dynamic_hint(link_obj=conn, pk_hint=hint["pk_auto_hint"])
        conn.commit()
        conn.close()
        return True
Exemple #37
0
    def _on_manage_addresses_button_pressed(self, event):
        picked_address = gmAddressWidgets.manage_addresses(parent=self)
        if picked_address is None:
            return

        question = '%s\n\n  %s\n' % (
            _('Link the following address to the organizational unit ?'),
            '\n  '.join(picked_address.format()))

        link_it = gmGuiHelpers.gm_show_question(
            title=_('Linking selected address'), question=question)
        if not link_it:
            return

        self._PRW_address_searcher.address = picked_address['pk_address']
        self._PRW_address_searcher.display_as_valid(True)
        self.__unit['pk_address'] = self._PRW_address_searcher.GetData()
        self.__unit.save()
Exemple #38
0
    def close_current_editor(self):

        page_idx = self.GetSelection()
        page = self.GetPage(page_idx)

        if not page.editor_empty():
            really_discard = gmGuiHelpers.gm_show_question(
                _('Are you sure you really want to\n'
                  'discard this progress note ?\n'),
                _('Discarding progress note'))
            if really_discard is False:
                return

        self.DeletePage(page_idx)

        # always keep one unassociated editor open
        if self.GetPageCount() == 0:
            self.add_editor()
Exemple #39
0
def calculate_edc(parent=None, patient=None):

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

	dlg = cEdcCalculatorDlg(parent, -1)
	prev_edc = None
	if patient.connected:
		prev_edc = patient.emr.EDC
		dlg.patient = patient
		dlg.EDC = prev_edc
	action = dlg.ShowModal()
	new_edc = dlg.EDC
	dlg.DestroyLater()

	# cancelled ?
	if action != wx.ID_SAVE:
		return

	# but have we got a patient ?
	if not patient.connected:
		return

	# ignore setting EDC from NULL to NULL
	if (new_edc is None) and (prev_edc is None):
		return

	# setting from X to NULL -> is a deletion intended ?
	# (prev_edc MUST be not None due to the previous condition)
	if new_edc is None:
		delete_edc = gmGuiHelpers.gm_show_question (
			title = _('Editing EDC'),
			question = _(
				'Really delete the EDC documented previously ?\n'
				'\n'
				' EDC: %s'
			) % gmDateTime.pydt_strftime(prev_edc, '%Y %b %d'),
			cancel_button = False
		)
		if not delete_edc:
			return

	patient.emr.EDC = new_edc
Exemple #40
0
	def close_current_editor(self):

		page_idx = self.GetSelection()
		page = self.GetPage(page_idx)

		if not page.empty:
			really_discard = gmGuiHelpers.gm_show_question (
				_('Are you sure you really want to\n'
				  'discard this progress note ?\n'
				),
				_('Discarding progress note')
			)
			if really_discard is False:
				return

		self.DeletePage(page_idx)

		# always keep one unassociated editor open
		if self.GetPageCount() == 0:
			self.add_editor()
Exemple #41
0
	def _on_clear_directory_button_pressed(self, event):
		event.Skip()
		path = self._LBL_directory.Label.strip().rstrip(os.sep).rstrip('/')
		if not os.path.isdir(path):
			return
		delete_data = gmGuiHelpers.gm_show_question (
			title = _('Clearing out a directory'),
			question = _(
				'Do you really want to delete all existing data\n'
				'from the following directory ?\n'
				'\n'
				' %s\n'
				'\n'
				'Note, this can NOT be reversed without backups.'
			) % path,
			cancel_button = False
		)
		if delete_data:
			gmTools.rm_dir_content(path)
			self.__update_ui_state()
Exemple #42
0
	def _on_manage_addresses_button_pressed(self, event):
		picked_address = gmAddressWidgets.manage_addresses(parent = self)
		if picked_address is None:
			return

		question = u'%s\n\n  %s\n' % (
			_('Link the following address to the organizational unit ?'),
			u'\n  '.join(picked_address.format())
		)

		link_it = gmGuiHelpers.gm_show_question (
			title = _('Linking selected address'),
			question = question
		)
		if not link_it:
			return

		self._PRW_address_searcher.address = picked_address['pk_address']
		self._PRW_address_searcher.display_as_valid(True)
		self.__unit['pk_address'] = self._PRW_address_searcher.GetData()
		self.__unit.save()
Exemple #43
0
	def _on_inbox_item_activated(self, event):

		data = self._LCTRL_inbox.get_selected_item_data(only_one = True)

		# if it is a dynamic hint open the URL for that
		if isinstance(data, gmAutoHints.cDynamicHint):
			if data['url'] is not None:
				gmNetworkTools.open_url_in_browser(data['url'])
			return

		# holding down <CTRL> when double-clicking an inbox
		# item indicates the desire to delete it
		# <ctrl> down ?
		if wx.GetKeyState(wx.WXK_CONTROL):
			# better safe than sorry: can only delete real inbox items
			if data is None:
				return
			if not isinstance(data, gmProviderInbox.cInboxMessage):
				return
			delete_it = gmGuiHelpers.gm_show_question (
				question = _('Do you really want to\ndelete this inbox message ?'),
				title = _('Deleting inbox message')
			)
			if not delete_it:
				return
			gmProviderInbox.delete_inbox_message(inbox_message = data['pk_inbox_message'])
			return

		if data is None:
			gmDispatcher.send(signal = 'display_widget', name = 'gmProviderInboxPlugin')
			return

		if not isinstance(data, gmProviderInbox.cInboxMessage):
			gmDispatcher.send(signal = 'display_widget', name = 'gmProviderInboxPlugin')
			return

		gmDispatcher.send(signal = 'display_widget', name = 'gmProviderInboxPlugin', filter_by_active_patient = True)
		return
Exemple #44
0
	def _on_remove_button_pressed(self, evt):
		self.__id_most_recently_activated_patient = None
		item = self._LCTRL_patients.get_selected_item_data(only_one = True)
		if item is None:
			return
		cmt = gmTools.coalesce(item['comment'], '').split('\n')[0].strip()[:40]
		if cmt != '':
			cmt += '\n'
		question = _(
			'Are you sure you want to remove\n'
			'\n'
			' %s, %s (%s)\n'
			' born: %s\n'
			' %s'
			'\n'
			'from the waiting list ?'
		) % (
			item['lastnames'],
			item['firstnames'],
			item['l10n_gender'],
			gmTools.coalesce (
				gmTools.coalesce (
					item['dob'],
					'',
					function_initial = ('strftime', '%d %b %Y')
				),
				'',
				function_initial = ('decode', gmI18N.get_encoding())
			),
			cmt
		)
		do_delete = gmGuiHelpers.gm_show_question (
			title = _('Delete waiting list entry'),
			question = question
		)
		if not do_delete:
			return
		gmPraxis.gmCurrentPraxisBranch().remove_from_waiting_list(pk = item['pk_waiting_list'])
Exemple #45
0
	def delete(translation=None):
		msg = _(
			'Are you sure you want to delete the translation of:\n'
			'\n'
			'%s\n'
			'\n'
			'into [%s] as:\n'
			'\n'
			'%s\n'
			'\n'
			'?  (Note that you must know the database administrator password !)\n'
		) % (
			gmTools.wrap (
				text = translation['orig'],
				width = 60,
				initial_indent = '  ',
				subsequent_indent = '  '
			),
			translation['lang'],
			gmTools.wrap (
				text = translation['trans'],
				width = 60,
				initial_indent = '  ',
				subsequent_indent = '  '
			)
		)
		delete_it = gmGuiHelpers.gm_show_question (
			aTitle = _('Deleting translation from database'),
			aMessage = msg
		)
		if not delete_it:
			return False

		conn = gmAuthWidgets.get_dbowner_connection(procedure = _('deleting a translation'))
		if conn is None:
			return False

		return gmPG2.delete_translation_from_database(link_obj = conn, language = translation['lang'], original = translation['orig'])
Exemple #46
0
	def _on_inbox_item_activated(self, event):

		data = self._LCTRL_inbox.get_selected_item_data(only_one = True)

		# if it is a dynamic hint open the URL for that
		if isinstance(data, gmAutoHints.cDynamicHint):
			if data['url'] is not None:
				gmNetworkTools.open_url_in_browser(data['url'])
			return

		# holding down <CTRL> when double-clicking an inbox
		# item indicates the desire to delete it
		# <ctrl> down ?
		if wx.GetKeyState(wx.WXK_CONTROL):
			# better safe than sorry: can only delete real inbox items
			if data is None:
				return
			if not isinstance(data, gmProviderInbox.cInboxMessage):
				return
			delete_it = gmGuiHelpers.gm_show_question (
				question = _('Do you really want to\ndelete this inbox message ?'),
				title = _('Deleting inbox message')
			)
			if not delete_it:
				return
			gmProviderInbox.delete_inbox_message(inbox_message = data['pk_inbox_message'])
			return

		if data is None:
			gmDispatcher.send(signal = 'display_widget', name = 'gmProviderInboxPlugin')
			return

		if not isinstance(data, gmProviderInbox.cInboxMessage):
			gmDispatcher.send(signal = 'display_widget', name = 'gmProviderInboxPlugin')
			return

		gmDispatcher.send(signal = 'display_widget', name = 'gmProviderInboxPlugin', filter_by_active_patient = True)
		return
Exemple #47
0
	def __get_items_to_work_on(self, msg_title):

		items = self._LCTRL_items.get_selected_item_data(only_one = False)
		if len(items) > 0:
			return items

		items = self._LCTRL_items.get_item_data()
		if len(items) == 0:
			gmDispatcher.send(signal = 'statustext', msg = _('Export area empty. Nothing to do.'))
			return None

		if len(items) == 1:
			return items

		process_all = gmGuiHelpers.gm_show_question (
			title = msg_title,
			question = _('You have not selected any entries.\n\nReally use all %s entries ?') % len(items),
			cancel_button = False
		)
		if process_all:
			return items

		return None
Exemple #48
0
    def _on_save_button_pressed(self, event):
        event.Skip()

        print("Is modal ? ->", self.IsModal())

        if self.__burn2cd:
            print("EndModal on burn2cd=True")
            self.EndModal(wx.ID_SAVE)

        if self._CHBOX_use_subdirectory.IsChecked() is True:
            print("EndModal on use_subdir=True")
            self.EndModal(wx.ID_SAVE)
            print("after EndModal !!")

        path = self._LBL_directory.Label

        if gmTools.dir_is_empty(path) is True:
            print("EndModal on dir_is_empty=True")
            self.EndModal(wx.ID_SAVE)

        if self._RBTN_remove_data.Value is True:
            really_remove_existing_data = gmGuiHelpers.gm_show_question(
                title=_('Creating patient media'),
                question=_('Really delete any existing data under\n'
                           '\n'
                           ' [%s]\n'
                           '\n'
                           'from disk ?\n'
                           '\n'
                           '(this operation is generally not reversible)') %
                path)
            if really_remove_existing_data is False:
                return

        print("Is modal ? ->", self.IsModal())
        print("now calling EndModal(wx.ID_SAVE)")
        self.EndModal(wx.ID_SAVE)
Exemple #49
0
def _verify_staff_chart_access(patient=None):

	if patient is None:
		return True

	# staff ?
	if patient.ID not in [ s['pk_identity'] for s in gmStaff.get_staff_list() ]:
		return True

	curr_prov = gmStaff.gmCurrentProvider()

	# can view my own chart
	if patient.ID == curr_prov['pk_identity']:
		return True

	# primary provider can view patient
	if patient['pk_primary_provider'] == curr_prov['pk_staff']:
		return True

	proceed = gmGuiHelpers.gm_show_question (
		aTitle = _('Privacy check'),
		aMessage = _(
			'You have selected the chart of a member of staff,\n'
			'for whom privacy is especially important:\n'
			'\n'
			'  %s, %s\n'
			'\n'
			'This may be OK depending on circumstances.\n'
			'\n'
			'Please be aware that accessing patient charts is\n'
			'logged and that %s%s will be\n'
			'notified of the access if you choose to proceed.\n'
			'\n'
			'Are you sure you want to draw this chart ?'
		) % (
			patient.get_description_gender(),
			patient.get_formatted_dob(),
			gmTools.coalesce(patient['title'], '', '%s '),
			patient['lastnames']
		)
	)

	if proceed:
		prov = '%s (%s%s %s)' % (
			curr_prov['short_alias'],
			gmTools.coalesce(curr_prov['title'], '', '%s '),
			curr_prov['firstnames'],
			curr_prov['lastnames']
		)
		pat = '%s%s %s' % (
			gmTools.coalesce(patient['title'], '', '%s '),
			patient['firstnames'],
			patient['lastnames']
		)
		# notify the staff member
		gmProviderInbox.create_inbox_message (
			staff = patient.staff_id,
			message_type = _('Privacy notice'),
			message_category = 'administrative',
			subject = _('%s: Your chart has been accessed by %s.') % (pat, prov),
			patient = patient.ID
		)
		# notify /me about the staff member notification
		gmProviderInbox.create_inbox_message (
			staff = curr_prov['pk_staff'],
			message_type = _('Privacy notice'),
			message_category = 'administrative',
			subject = _('%s: Staff member %s has been notified of your chart access.') % (prov, pat)
		)

	return proceed
Exemple #50
0
	def _on_merge_button_pressed(self, event):

		if self._TCTRL_patient1.person is None:
			gmDispatcher.send(signal = 'statustext', msg = _('No patient selected on the left.'), beep = True)
			return

		if self._TCTRL_patient2.person is None:
			gmDispatcher.send(signal = 'statustext', msg = _('No patient selected on the right.'), beep = True)
			return

		if self._RBTN_patient1.GetValue():
			patient2keep = self._TCTRL_patient1.person
			patient2merge = self._TCTRL_patient2.person
		else:
			patient2keep = self._TCTRL_patient2.person
			patient2merge = self._TCTRL_patient1.person

		if patient2merge['lastnames'] == 'Kirk':
			if _cfg.get(option = 'debug'):
				gmNetworkTools.open_url_in_browser(url = 'http://en.wikipedia.org/wiki/File:Picard_as_Locutus.jpg')
				gmGuiHelpers.gm_show_info(_('\n\nYou will be assimilated.\n\n'), _('The Borg'))
				return
			else:
				gmDispatcher.send(signal = 'statustext', msg = _('Cannot merge Kirk into another patient.'), beep = True)
				return

		doit = gmGuiHelpers.gm_show_question (
			aMessage = _(
				'Are you positively sure you want to merge patient\n\n'
				' #%s: %s (%s, %s)\n\n'
				'into patient\n\n'
				' #%s: %s (%s, %s) ?\n\n'
				'Note that this action can ONLY be reversed by a laborious\n'
				'manual process requiring in-depth knowledge about databases\n'
				'and the patients in question !\n'
			) % (
				patient2merge.ID,
				patient2merge['description_gender'],
				patient2merge['gender'],
				patient2merge.get_formatted_dob(format = '%Y %b %d'),
				patient2keep.ID,
				patient2keep['description_gender'],
				patient2keep['gender'],
				patient2keep.get_formatted_dob(format = '%Y %b %d')
			),
			aTitle = _('Merging patients: confirmation'),
			cancel_button = False
		)
		if not doit:
			return

		conn = gmAuthWidgets.get_dbowner_connection(procedure = _('Merging patients'))
		if conn is None:
			gmDispatcher.send(signal = 'statustext', msg = _('Cannot merge patients without admin access.'), beep = True)
			return

		success, msg = patient2keep.assimilate_identity(other_identity = patient2merge, link_obj = conn)
		conn.close()
		if not success:
			gmDispatcher.send(signal = 'statustext', msg = msg, beep = True)
			return

		msg = _(
			'The patient\n'
			'\n'
			' #%s: %s (%s, %s)\n'
			'\n'
			'has successfully been merged into\n'
			'\n'
			' #%s: %s (%s, %s)'
		) % (
			patient2merge.ID,
			patient2merge['description_gender'],
			patient2merge['gender'],
			patient2merge.get_formatted_dob(format = '%Y %b %d'),
			patient2keep.ID,
			patient2keep['description_gender'],
			patient2keep['gender'],
			patient2keep.get_formatted_dob(format = '%Y %b %d')
		)
		title = _('Merging patients: success')

		curr_pat = gmPerson.gmCurrentPatient()
		# announce success
		if (curr_pat.connected) and (patient2keep.ID == curr_pat.ID):
			gmGuiHelpers.gm_show_info(aMessage = msg, aTitle = title)
		# and offer to activate kept patient if not active
		else:
			msg = msg + (
			'\n\n\n'
			'Do you want to activate that patient\n'
			'now for further modifications ?\n'
			)
			doit = gmGuiHelpers.gm_show_question (
				aMessage = msg,
				aTitle = title,
				cancel_button = False
			)
			if doit:
				wx.CallAfter(set_active_patient, patient = patient2keep)

		if self.IsModal():
			self.EndModal(wx.ID_OK)
		else:
			self.Close()
Exemple #51
0
	def _valid_for_save(self):

		has_errors = False

		if self._PRW_brand.GetValue().strip() == u'':
			has_errors = True
			self._PRW_brand.display_as_valid(False)
		else:
			self._PRW_brand.display_as_valid(True)

		if self._PRW_atc.GetValue().strip() in [u'', u'J07']:
			self._PRW_atc.display_as_valid(True)
		else:
			if self._PRW_atc.GetData() is None:
				self._PRW_atc.display_as_valid(True)
			else:
				has_errors = True
				self._PRW_atc.display_as_valid(False)

		val = self._PRW_age_min.GetValue().strip()
		if val == u'':
			self._PRW_age_min.display_as_valid(True)
		else:
			if gmDateTime.str2interval(val) is None:
				has_errors = True
				self._PRW_age_min.display_as_valid(False)
			else:
				self._PRW_age_min.display_as_valid(True)

		val = self._PRW_age_max.GetValue().strip()
		if val == u'':
			self._PRW_age_max.display_as_valid(True)
		else:
			if gmDateTime.str2interval(val) is None:
				has_errors = True
				self._PRW_age_max.display_as_valid(False)
			else:
				self._PRW_age_max.display_as_valid(True)

		# are we editing ?
		ask_user = (self.mode == 'edit')
		# is this vaccine in use ?
		ask_user = (ask_user and self.data.is_in_use)
		# a change ...
		ask_user = ask_user and (
			# ... of brand ...
			(self.data['pk_brand'] != self._PRW_route.GetData())
				or
			# ... or indications ?
			(set(self.data['pk_indications']) != set([ i['id'] for i in self.__indications ]))
		)

		if ask_user:
			do_it = gmGuiHelpers.gm_show_question (
				aTitle = _('Saving vaccine'),
				aMessage = _(
					u'This vaccine is already in use:\n'
					u'\n'
					u' "%s"\n'
					u' (%s)\n'
					u'\n'
					u'Are you absolutely positively sure that\n'
					u'you really want to edit this vaccine ?\n'
					'\n'
					u'This will change the vaccine name and/or target\n'
					u'conditions in each patient this vaccine was\n'
					u'used in to document a vaccination with.\n'
				) % (
					self._PRW_brand.GetValue().strip(),
					u', '.join(self.data['l10n_indications'])
				)
			)
			if not do_it:
				has_errors = True

		return (has_errors is False)
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()
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()
Exemple #54
0
def install_data_pack(data_pack=None):

	if data_pack is None:
		return False

	_log.info('attempting installation of data pack: %s', data_pack['name'])

	msg = _(
		'Note that GNUmed data packs are provided\n'
		'\n'
		'WITHOUT ANY GUARANTEE WHATSOEVER\n'
		'\n'
		'regarding their content.\n'
		'\n'
		'Despite data packs having been prepared with the\n'
		'utmost care you must still vigilantly apply caution,\n'
		'common sense, and due diligence to make sure you\n'
		'render appropriate care to your patients.\n'
		'\n'
		'Press [Yes] to declare agreement with this precaution.\n'
		'\n'
		'Press [No] to abort installation of the data pack.\n'
	)
	go_ahead = gmGuiHelpers.gm_show_question(msg, _('Terms of Data Pack Use'))
	if not go_ahead:
		_log.info('user did not agree to terms of data pack use')
		return True

	gm_dbo_conn = gmAuthWidgets.get_dbowner_connection(procedure = _('installing data pack'))
	if gm_dbo_conn is None:
		msg = _('Lacking permissions to install data pack.')
		gmGuiHelpers.gm_show_error(msg, _('Installing data pack'))
		return False

	wx.BeginBusyCursor()
	verified, data = gmNetworkTools.download_data_pack (
		data_pack['pack_url'],
		md5_url = data_pack['md5_url']
	)
	wx.EndBusyCursor()
	if not verified:
		_log.error('cannot download and verify data pack: %s', data_pack['name'])
		md5_expected, md5_calculated = data
		msg = _(
			'Cannot validate data pack.\n'
			'\n'
			'  name: %s\n'
			'  URL: %s\n'
			'\n'
			'  MD5\n'
			'   calculated: %s\n'
			'   expected: %s\n'
			'   source: %s\n'
			'\n'
			'You may want to try downloading again or you\n'
			'may need to contact your administrator.'
		) % (
			data_pack['name'],
			data_pack['pack_url'],
			md5_calculated,
			md5_expected,
			data_pack['md5_url']
		)
		gmGuiHelpers.gm_show_error(msg, _('Verifying data pack'))
		return False

	data_pack['local_archive'] = data

	wx.BeginBusyCursor()
	unzip_dir = gmNetworkTools.unzip_data_pack(filename = data)
	wx.EndBusyCursor()
	if unzip_dir is None:
		msg = _(
			'Cannot unpack data pack.\n'
			'\n'
			'  name: %s\n'
			'  URL: %s\n'
			'  local: %s\n'
			'\n'
			'You may want to try downloading again or you\n'
			'may need to contact your administrator.'
		) % (
			data_pack['name'],
			data_pack['pack_url'],
			data_pack['local_archive']
		)
		gmGuiHelpers.gm_show_error(msg, _('Unpacking data pack'))
		return False

	data_pack['unzip_dir'] = unzip_dir

	wx.BeginBusyCursor()
	try:
		installed = gmNetworkTools.install_data_pack(data_pack, gm_dbo_conn)
	finally:
		wx.EndBusyCursor()

	# check schema hash
	db_version = gmPG2.map_client_branch2required_db_version[_cfg.get(option = 'client_branch')]
	if not gmPG2.database_schema_compatible(version = db_version):
		if db_version != 0:
			msg = _(
				'Installation of data pack failed because\n'
				'it attempted to modify the database layout.\n'
				'\n'
				'  name: %s\n'
				'  URL: %s\n'
				'  local: %s\n'
				'\n'
				'You will need to contact your administrator.'
			) % (
				data_pack['name'],
				data_pack['pack_url'],
				data_pack['local_archive']
			)
			gmGuiHelpers.gm_show_error(msg, _('Installing data pack'))
			return False

	if not installed:
		msg = _(
			'Installation of data pack failed.\n'
			'\n'
			'  name: %s\n'
			'  URL: %s\n'
			'  local: %s\n'
			'\n'
			'You may want to try downloading again or you\n'
			'may need to contact your administrator.'
		) % (
			data_pack['name'],
			data_pack['pack_url'],
			data_pack['local_archive']
		)
		gmGuiHelpers.gm_show_error(msg, _('Installing data pack'))
		return False

	msg = _(
		'Successfully installed data pack.\n'
		'\n'
		'  name: %s\n'
		'  URL: %s\n'
	) % (
		data_pack['name'],
		data_pack['pack_url']
	)
	gmGuiHelpers.gm_show_info(msg, _('Installing data pack'))

	return True
Exemple #55
0
	def _valid_for_save(self):

		has_errors = False

		if self._PRW_drug_product.GetValue().strip() == '':
			has_errors = True
			self._PRW_drug_product.display_as_valid(False)
		else:
			self._PRW_drug_product.display_as_valid(True)

		atc = self._PRW_atc.GetValue().strip()
		if (atc == '') or (atc.startswith('J07')):
			self._PRW_atc.display_as_valid(True)
		else:
			if self._PRW_atc.GetData() is None:
				self._PRW_atc.display_as_valid(True)
			else:
				has_errors = True
				self._PRW_atc.display_as_valid(False)

		val = self._PRW_age_min.GetValue().strip()
		if val == '':
			self._PRW_age_min.display_as_valid(True)
		else:
			if gmDateTime.str2interval(val) is None:
				has_errors = True
				self._PRW_age_min.display_as_valid(False)
			else:
				self._PRW_age_min.display_as_valid(True)

		val = self._PRW_age_max.GetValue().strip()
		if val == '':
			self._PRW_age_max.display_as_valid(True)
		else:
			if gmDateTime.str2interval(val) is None:
				has_errors = True
				self._PRW_age_max.display_as_valid(False)
			else:
				self._PRW_age_max.display_as_valid(True)

		# complex conditions
		# are we editing ?
		if self.mode == 'edit':
			change_of_product = self.data['pk_drug_product'] != self._PRW_drug_product.GetData()
			if change_of_product and self.data.is_in_use:
				do_it = gmGuiHelpers.gm_show_question (
					aTitle = _('Saving vaccine'),
					aMessage = _(
						'This vaccine is already in use:\n'
						'\n'
						' "%s"\n'
						'\n'
						'Are you absolutely positively sure that\n'
						'you really want to edit this vaccine ?\n'
						'\n'
						'This will change the vaccine name and/or target\n'
						'conditions in each patient this vaccine was\n'
						'used in to document a vaccination with.\n'
					) % self._PRW_drug_product.GetValue().strip()
				)
				if not do_it:
					has_errors = True
		else:
			if self._PRW_drug_product.GetData() is None:
				# need to ask for indications ?
				if self._PRW_drug_product.GetValue().strip() != '':
					self.__indications = gmSubstanceMgmtWidgets.manage_substance_doses(vaccine_indications_only = True)
					if self.__indications is None:
						has_errors = True
			else:
				# existing drug product selected
				pass

		return (has_errors is False)