def _save_as_update(self): conn = gmAuthWidgets.get_dbowner_connection(procedure = _('updating an existing dynamic hint')) if conn is None: return False self.data['title'] = self._TCTRL_title.GetValue().strip() self.data['hint'] = self._TCTRL_hint.GetValue().strip() self.data['query'] = self._TCTRL_query.GetValue().strip() self.data['source'] = self._TCTRL_source.GetValue().strip() self.data['url'] = self._TCTRL_url.GetValue().strip() self.data['recommendation_query'] = self._TCTRL_recommendation_query.GetValue().strip() self.data['is_active'] = self._CHBOX_is_active.GetValue() self.data['highlight_as_priority'] = self._CHBOX_highlight.GetValue() if self._RBTN_popup_none.GetValue() is True: self.data['popup_type'] = 0 elif self._RBTN_popup_single.GetValue() is True: self.data['popup_type'] = 1 elif self._RBTN_popup_multiple.GetValue() is True: self.data['popup_type'] = 2 else: raise ValueError('no popup type radio button selected - should be impossible') self.data.save(conn = conn) conn.commit() conn.close() return True
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
def _on_save_button_pressed(self, event): pk_staff = self._LCTRL_staff.GetItemData( self._LCTRL_staff.GetFirstSelected()) conn = gmAuthWidgets.get_dbowner_connection( procedure=_('Modifying GNUmed user.')) if conn is None: return False staff = gmStaff.cStaff(aPK_obj=pk_staff) staff['short_alias'] = self._TCTRL_alias.GetValue() staff['db_user'] = self._TCTRL_account.GetValue() staff['comment'] = self._TCTRL_comment.GetValue() success, data = staff.save_payload(conn=conn) if not success: conn.close() gmGuiHelpers.gm_show_error( aMessage=_('Failed to save changes to GNUmed database user.'), aTitle=_('Modifying GNUmed user')) return False target_role = self._PRW_user_role.GetData() if target_role is not None: if not staff.set_role(conn=conn, role=target_role): gmGuiHelpers.gm_show_error( aMessage=_( 'Failed to set role [%s] for GNUmed database user.') % self._PRW_user_role.GetValue().strip(), aTitle=_('Modifying GNUmed user')) conn.close() self.__init_ui_data() return True
def update_atc_reference_data(): dlg = wx.FileDialog ( parent = None, message = _('Choose an ATC import config file'), defaultDir = os.path.expanduser(os.path.join('~', 'gnumed')), defaultFile = '', wildcard = "%s (*.conf)|*.conf|%s (*)|*" % (_('config files'), _('all files')), style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST ) result = dlg.ShowModal() if result == wx.ID_CANCEL: return cfg_file = dlg.GetPath() dlg.DestroyLater() conn = gmAuthWidgets.get_dbowner_connection(procedure = _('importing ATC reference data')) if conn is None: return False wx.BeginBusyCursor() if gmATC.atc_import(cfg_fname = cfg_file, conn = conn): gmDispatcher.send(signal = 'statustext', msg = _('Successfully imported ATC reference data.')) else: gmDispatcher.send(signal = 'statustext', msg = _('Importing ATC reference data failed.'), beep = True) wx.EndBusyCursor() return True
def _save_as_new(self): conn = gmAuthWidgets.get_dbowner_connection(procedure=_("creating a new dynamic hint")) if conn is None: return False curs = conn.cursor() data = gmAutoHints.create_dynamic_hint( link_obj=curs, # it seems this MUST be a cursor or else the successfully created row will not show up -- but why ?!? query=self._TCTRL_query.GetValue().strip(), title=self._TCTRL_title.GetValue().strip(), hint=self._TCTRL_hint.GetValue().strip(), source=self._TCTRL_source.GetValue().strip(), ) curs.close() url = self._TCTRL_url.GetValue().strip() if url != u"": data["url"] = url data.save(conn=conn) conn.commit() conn.close() self.data = data return True
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'])
def _save_as_new(self): conn = gmAuthWidgets.get_dbowner_connection(procedure = _('creating a new dynamic hint')) if conn is None: return False curs = conn.cursor() data = gmAutoHints.create_dynamic_hint ( link_obj = curs, # it seems this MUST be a cursor or else the successfully created row will not show up -- but why ?!? query = self._TCTRL_query.GetValue().strip(), title = self._TCTRL_title.GetValue().strip(), hint = self._TCTRL_hint.GetValue().strip(), source = self._TCTRL_source.GetValue().strip() ) curs.close() data['url'] = self._TCTRL_url.GetValue().strip() data['recommendation_query'] = self._TCTRL_recommendation_query.GetValue().strip() data['is_active'] = self._CHBOX_is_active.GetValue() data['highlight_as_priority'] = self._CHBOX_highlight.GetValue() if self._RBTN_popup_none.GetValue() is True: data['popup_type'] = 0 elif self._RBTN_popup_single.GetValue() is True: data['popup_type'] = 1 elif self._RBTN_popup_multiple.GetValue() is True: data['popup_type'] = 2 else: raise ValueError('no popup type radio button selected - should be impossible') data.save(conn = conn) conn.commit() conn.close() self.data = data return True
def update_atc_reference_data(): dlg = wx.FileDialog(parent=None, message=_('Choose an ATC import config file'), defaultDir=os.path.expanduser( os.path.join('~', 'gnumed')), defaultFile='', wildcard="%s (*.conf)|*.conf|%s (*)|*" % (_('config files'), _('all files')), style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) result = dlg.ShowModal() if result == wx.ID_CANCEL: return cfg_file = dlg.GetPath() dlg.DestroyLater() conn = gmAuthWidgets.get_dbowner_connection( procedure=_('importing ATC reference data')) if conn is None: return False wx.BeginBusyCursor() if gmATC.atc_import(cfg_fname=cfg_file, conn=conn): gmDispatcher.send(signal='statustext', msg=_('Successfully imported ATC reference data.')) else: gmDispatcher.send(signal='statustext', msg=_('Importing ATC reference data failed.'), beep=True) wx.EndBusyCursor() return True
def _on_save_button_pressed(self, event): pk_staff = self._LCTRL_staff.GetItemData(self._LCTRL_staff.GetFirstSelected()) conn = gmAuthWidgets.get_dbowner_connection(procedure = _('Modifying GNUmed user.')) if conn is None: return False staff = gmStaff.cStaff(aPK_obj = pk_staff) staff['short_alias'] = self._TCTRL_alias.GetValue() staff['db_user'] = self._TCTRL_account.GetValue() staff['comment'] = self._TCTRL_comment.GetValue() success, data = staff.save_payload(conn = conn) if not success: conn.close() gmGuiHelpers.gm_show_error ( aMessage = _('Failed to save changes to GNUmed database user.'), aTitle = _('Modifying GNUmed user') ) return False target_role = self._PRW_user_role.GetData() if target_role is not None: if not staff.set_role(conn = conn, role = target_role): gmGuiHelpers.gm_show_error ( aMessage = _('Failed to set role [%s] for GNUmed database user.') % self._PRW_user_role.GetValue().strip(), aTitle = _('Modifying GNUmed user') ) conn.close() self.__init_ui_data() return True
def _on_deactivate_button_pressed(self, evt): pk_staff = self._LCTRL_staff.GetItemData(self._LCTRL_staff.GetFirstSelected()) conn = gmAuthWidgets.get_dbowner_connection(procedure = _('Deactivating GNUmed user.')) if conn is None: return False gmStaff.deactivate_staff(conn = conn, pk_staff = pk_staff) conn.close() self.__init_ui_data() return True
def _on_deactivate_button_pressed(self, evt): pk_staff = self._LCTRL_staff.GetItemData( self._LCTRL_staff.GetFirstSelected()) conn = gmAuthWidgets.get_dbowner_connection( procedure=_('Deactivating GNUmed user.')) if conn is None: return False gmStaff.deactivate_staff(conn=conn, pk_staff=pk_staff) conn.close() self.__init_ui_data() return True
def _on_delete_button_pressed(self, event): pk_staff = self._LCTRL_staff.GetItemData(self._LCTRL_staff.GetFirstSelected()) conn = gmAuthWidgets.get_dbowner_connection(procedure = _('Removing GNUmed user.')) if conn is None: return False success, msg = gmStaff.delete_staff(conn = conn, pk_staff = pk_staff) conn.close() self.__init_ui_data() if not success: gmGuiHelpers.gm_show_error(aMessage = msg, aTitle = _('Removing GNUmed user')) return False return True
def update_loinc_reference_data(): wx.BeginBusyCursor() gmDispatcher.send(signal='statustext', msg=_('Updating LOINC data can take quite a while...'), beep=True) # download loinc_zip = gmNetworkTools.download_file( url='http://www.gnumed.de/downloads/data/loinc/loinctab.zip', suffix='.zip') if loinc_zip is None: wx.EndBusyCursor() gmGuiHelpers.gm_show_warning( aTitle=_('Downloading LOINC'), aMessage=_('Error downloading the latest LOINC data.\n')) return False _log.debug('downloaded zipped LOINC data into [%s]', loinc_zip) loinc_dir = gmNetworkTools.unzip_data_pack(filename=loinc_zip) # split master data file data_fname, license_fname = gmLOINC.split_LOINCDBTXT( input_fname=os.path.join(loinc_dir, 'LOINCDB.TXT')) wx.EndBusyCursor() conn = gmAuthWidgets.get_dbowner_connection( procedure=_('importing LOINC reference data')) if conn is None: return False wx.BeginBusyCursor() # import data if gmLOINC.loinc_import(data_fname=data_fname, license_fname=license_fname, conn=conn): gmDispatcher.send(signal='statustext', msg=_('Successfully imported LOINC reference data.')) else: gmDispatcher.send(signal='statustext', msg=_('Importing LOINC reference data failed.'), beep=True) wx.EndBusyCursor() return True
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 _on_delete_button_pressed(self, event): pk_staff = self._LCTRL_staff.GetItemData( self._LCTRL_staff.GetFirstSelected()) conn = gmAuthWidgets.get_dbowner_connection( procedure=_('Removing GNUmed user.')) if conn is None: return False success, msg = gmStaff.delete_staff(conn=conn, pk_staff=pk_staff) conn.close() self.__init_ui_data() if not success: gmGuiHelpers.gm_show_error(aMessage=msg, aTitle=_('Removing GNUmed user')) return False return True
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
def _save_as_update(self): conn = gmAuthWidgets.get_dbowner_connection(procedure=_("updating an existing dynamic hint")) if conn is None: return False self.data["title"] = self._TCTRL_title.GetValue().strip() self.data["hint"] = self._TCTRL_hint.GetValue().strip() self.data["query"] = self._TCTRL_query.GetValue().strip() self.data["source"] = self._TCTRL_source.GetValue().strip() self.data["url"] = self._TCTRL_url.GetValue().strip() self.data["is_active"] = self._CHBOX_is_active.GetValue() self.data.save(conn=conn) conn.commit() conn.close() return True
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_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
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
def show_audit_trail(parent=None): if parent is None: parent = wx.GetApp().GetTopWindow() conn = gmAuthWidgets.get_dbowner_connection( procedure=_('showing audit trail')) if conn is None: return False #----------------------------------- def refresh(lctrl): cmd = u'SELECT * FROM audit.v_audit_trail ORDER BY audit_when_ts' rows, idx = gmPG2.run_ro_queries(link_obj=conn, queries=[{ 'cmd': cmd }], get_col_idx=False) lctrl.set_string_items([[ r['event_when'], r['event_by'], u'%s %s %s' % (gmTools.coalesce(r['row_version_before'], gmTools.u_diameter), gmTools.u_arrow2right, gmTools.coalesce(r['row_version_after'], gmTools.u_diameter)), r['event_table'], r['event'], r['pk_audit'] ] for r in rows]) #----------------------------------- gmListWidgets.get_choices_from_list( parent=parent, msg=u'', caption=_('GNUmed database audit log ...'), columns=[ _('When'), _('Who'), _('Revisions'), _('Table'), _('Event'), '#' ], single_selection=True, refresh_callback=refresh)
def update_loinc_reference_data(): wx.BeginBusyCursor() gmDispatcher.send(signal = 'statustext', msg = _('Updating LOINC data can take quite a while...'), beep = True) # download loinc_zip = gmNetworkTools.download_file(url = 'http://www.gnumed.de/downloads/data/loinc/loinctab.zip', suffix = '.zip') if loinc_zip is None: wx.EndBusyCursor() gmGuiHelpers.gm_show_warning ( aTitle = _('Downloading LOINC'), aMessage = _('Error downloading the latest LOINC data.\n') ) return False _log.debug('downloaded zipped LOINC data into [%s]', loinc_zip) loinc_dir = gmNetworkTools.unzip_data_pack(filename = loinc_zip) # split master data file data_fname, license_fname = gmLOINC.split_LOINCDBTXT(input_fname = os.path.join(loinc_dir, 'LOINCDB.TXT')) wx.EndBusyCursor() conn = gmAuthWidgets.get_dbowner_connection(procedure = _('importing LOINC reference data')) if conn is None: return False wx.BeginBusyCursor() # import data if gmLOINC.loinc_import(data_fname = data_fname, license_fname = license_fname, conn = conn): gmDispatcher.send(signal = 'statustext', msg = _('Successfully imported LOINC reference data.')) else: gmDispatcher.send(signal = 'statustext', msg = _('Importing LOINC reference data failed.'), beep = True) wx.EndBusyCursor() return True
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
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'])
def _save_as_new(self): conn = gmAuthWidgets.get_dbowner_connection( procedure=_('creating a new dynamic hint')) if conn is None: return False curs = conn.cursor() data = gmAutoHints.create_dynamic_hint( link_obj= curs, # it seems this MUST be a cursor or else the successfully created row will not show up -- but why ?!? query=self._TCTRL_query.GetValue().strip(), title=self._TCTRL_title.GetValue().strip(), hint=self._TCTRL_hint.GetValue().strip(), source=self._TCTRL_source.GetValue().strip()) curs.close() data['url'] = self._TCTRL_url.GetValue().strip() data[ 'recommendation_query'] = self._TCTRL_recommendation_query.GetValue( ).strip() data['is_active'] = self._CHBOX_is_active.GetValue() data['highlight_as_priority'] = self._CHBOX_highlight.GetValue() if self._RBTN_popup_none.GetValue() is True: data['popup_type'] = 0 elif self._RBTN_popup_single.GetValue() is True: data['popup_type'] = 1 elif self._RBTN_popup_multiple.GetValue() is True: data['popup_type'] = 2 else: raise ValueError( 'no popup type radio button selected - should be impossible') data.save(conn=conn) conn.commit() conn.close() self.data = data return True
def regenerate_generic_vaccines(): dbo_conn = gmAuthWidgets.get_dbowner_connection(procedure = _('Regenerating generic vaccines')) if dbo_conn is None: return False wx.BeginBusyCursor() _cfg = gmCfg2.gmCfgData() sql_script = gmVaccination.write_generic_vaccine_sql ( 'client-%s' % _cfg.get(option = 'client_version'), include_indications_mapping = False ) _log.debug('regenerating generic vaccines, SQL script: %s', sql_script) if not gmPG2.run_sql_script(sql_script, conn = dbo_conn): wx.EndBusyCursor() gmGuiHelpers.gm_show_warning ( aMessage = _('Error regenerating generic vaccines.\n\nSee [%s]') % sql_script, aTitle = _('Regenerating generic vaccines') ) return False gmDispatcher.send(signal = 'statustext', msg = _('Successfully regenerated generic vaccines ...'), beep = False) wx.EndBusyCursor() return True
def show_audit_trail(parent=None): if parent is None: parent = wx.GetApp().GetTopWindow() conn = gmAuthWidgets.get_dbowner_connection(procedure = _('showing audit trail')) if conn is None: return False #----------------------------------- def refresh(lctrl): cmd = u'SELECT * FROM audit.v_audit_trail ORDER BY audit_when_ts' rows, idx = gmPG2.run_ro_queries(link_obj = conn, queries = [{'cmd': cmd}], get_col_idx = False) lctrl.set_string_items ( [ [ r['event_when'], r['event_by'], u'%s %s %s' % ( gmTools.coalesce(r['row_version_before'], gmTools.u_diameter), gmTools.u_right_arrow, gmTools.coalesce(r['row_version_after'], gmTools.u_diameter) ), r['event_table'], r['event'], r['pk_audit'] ] for r in rows ] ) #----------------------------------- gmListWidgets.get_choices_from_list ( parent = parent, msg = u'', caption = _('GNUmed database audit log ...'), columns = [ _('When'), _('Who'), _('Revisions'), _('Table'), _('Event'), '#' ], single_selection = True, refresh_callback = refresh )
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()
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
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