def _get_update_status(): dbcfg = gmCfg.cCfgSQL() url = dbcfg.get2 ( option = 'horstspace.update.url', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'workplace', default = 'http://www.gnumed.de/downloads/gnumed-versions.txt' ) consider_latest_branch = bool(dbcfg.get2 ( option = 'horstspace.update.consider_latest_branch', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'workplace', default = True )) _cfg = gmCfg2.gmCfgData() update_found, msg = gmNetworkTools.check_for_update ( url = url, current_branch = _cfg.get(option = 'client_branch'), current_version = _cfg.get(option = 'client_version'), consider_latest_branch = consider_latest_branch ) return update_found, msg
def check_for_updates(): dbcfg = gmCfg.cCfgSQL() url = dbcfg.get2 ( option = u'horstspace.update.url', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'workplace', default = u'http://www.gnumed.de/downloads/gnumed-versions.txt' ) consider_latest_branch = bool(dbcfg.get2 ( option = u'horstspace.update.consider_latest_branch', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'workplace', default = True )) _cfg = gmCfg2.gmCfgData() found, msg = gmNetworkTools.check_for_update ( url = url, current_branch = _cfg.get(option = 'client_branch'), current_version = _cfg.get(option = 'client_version'), consider_latest_branch = consider_latest_branch ) if found is False: gmDispatcher.send(signal = 'statustext', msg = _('Your client (%s) is up to date.') % _cfg.get(option = 'client_version')) return gmGuiHelpers.gm_show_info ( msg, _('Checking for client updates') )
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'])
def __init__ (self, *args, **kwargs): cPersonSearchCtrl.__init__(self, *args, **kwargs) # get configuration cfg = gmCfg.cCfgSQL() self.__always_dismiss_on_search = bool ( cfg.get2 ( option = 'patient_search.always_dismiss_previous_patient', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user', default = 0 ) ) self.__always_reload_after_search = bool ( cfg.get2 ( option = 'patient_search.always_reload_new_patient', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user', default = 0 ) ) self.__register_events()
def __init__ (self, *args, **kwargs): cPersonSearchCtrl.__init__(self, *args, **kwargs) # get configuration cfg = gmCfg.cCfgSQL() self.__always_dismiss_on_search = bool ( cfg.get2 ( option = 'patient_search.always_dismiss_previous_patient', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user', default = 0 ) ) self.__always_reload_after_search = bool ( cfg.get2 ( option = 'patient_search.always_reload_new_patient', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user', default = 0 ) ) self.__register_events()
def _save_as_update(self): gmPraxis.gmCurrentPraxisBranch().update_in_waiting_list( pk=self.data['pk_waiting_list'], urgency=self._SPCTRL_urgency.GetValue(), comment=self._TCTRL_comment.GetValue().strip(), zone=self._PRW_zone.GetValue().strip()) return True
def _on_down_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 gmPraxis.gmCurrentPraxisBranch().lower_in_waiting_list( current_position=item['list_position'])
def _save_as_update(self): gmPraxis.gmCurrentPraxisBranch().update_in_waiting_list ( pk = self.data['pk_waiting_list'], urgency = self._SPCTRL_urgency.GetValue(), comment = self._TCTRL_comment.GetValue().strip(), zone = self._PRW_zone.GetValue().strip() ) return True
def create_new_person(parent=None, activate=False): if parent is None: parent = wx.GetApp().GetTopWindow() if activate: # meaning we will switch away from the current patient if any msg = _('Before creating a new person review the encounter details\n' 'of the patient you just worked on:\n') gmEncounterWidgets.sanity_check_encounter_of_active_patient( parent=parent, msg=msg) msg = _( 'Edit the current encounter of the patient you are ABOUT TO LEAVE:' ) dbcfg = gmCfg.cCfgSQL() def_region = dbcfg.get2( option='person.create.default_region', workplace=gmPraxis.gmCurrentPraxisBranch().active_workplace, bias='user') def_country = None if def_region is None: def_country = dbcfg.get2( option='person.create.default_country', workplace=gmPraxis.gmCurrentPraxisBranch().active_workplace, bias='user') else: countries = gmDemographicRecord.get_country_for_region( region=def_region) if len(countries) == 1: def_country = countries[0]['code_country'] ea = cNewPatientEAPnl(parent, -1, country=def_country, region=def_region) dlg = gmEditArea.cGenericEditAreaDlg2(parent, -1, edit_area=ea, single_entry=True) dlg.SetTitle(_('Adding new person')) ea._PRW_lastname.SetFocus() result = dlg.ShowModal() pat = ea.data dlg.Destroy() if result != wx.ID_OK: return False _log.debug('created new person [%s]', pat.ID) if activate: from Gnumed.wxpython import gmPatSearchWidgets gmPatSearchWidgets.set_active_patient(patient=pat) gmDispatcher.send(signal='display_widget', name='gmNotebookedPatientEditionPlugin') return True
def configure_string_option(parent=None, message=None, option=None, bias='user', default_value='', validator=None): dbcfg = gmCfg.cCfgSQL() current_value = dbcfg.get2 ( option = option, workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = bias, default = default_value ) if current_value is not None: current_value = '%s' % current_value if parent is None: parent = wx.GetApp().GetTopWindow() if validator is None: validator = lambda in_val: (True, in_val) while True: dlg = wx.TextEntryDialog ( parent, message, caption = _('Configuration'), value = gmTools.coalesce(current_value, ''), style = wx.OK | wx.CANCEL | wx.CENTRE ) result = dlg.ShowModal() if result == wx.ID_CANCEL: dlg.DestroyLater() return None user_val = dlg.GetValue().strip() dlg.DestroyLater() if user_val == current_value: return user_val validated, user_val = validator(user_val) if validated: break gmDispatcher.send ( signal = 'statustext', msg = _('Value [%s] not valid for option <%s>.') % (user_val, option), beep = True ) dbcfg = gmCfg.cCfgSQL() dbcfg.set ( workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, option = option, value = user_val ) return user_val
def refresh(lctrl): workplaces = gmPraxis.gmCurrentPraxisBranch().workplaces curr_workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace try: sels = [workplaces.index(curr_workplace)] except ValueError: sels = [] lctrl.set_string_items(workplaces) lctrl.set_selections(selections=sels)
def refresh(lctrl): workplaces = gmPraxis.gmCurrentPraxisBranch().workplaces curr_workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace try: sels = [workplaces.index(curr_workplace)] except ValueError: sels = [] lctrl.set_string_items(workplaces) lctrl.set_selections(selections = sels)
def configure_string_from_list_option(parent=None, message=None, option=None, bias='user', default_value='', choices=None, columns=None, data=None, caption=None): dbcfg = gmCfg.cCfgSQL() current_value = dbcfg.get2( option=option, workplace=gmPraxis.gmCurrentPraxisBranch().active_workplace, bias=bias, default=default_value) if parent is None: parent = wx.GetApp().GetTopWindow() if caption is None: caption = _('Configuration') selections = None if current_value is not None: try: selections = [choices.index(current_value)] except ValueError: pass choice = gmListWidgets.get_choices_from_list(parent=parent, msg=message, caption=caption, choices=choices, columns=columns, data=data, selections=selections, single_selection=True, can_return_empty=False) # aborted if choice is None: return # same value selected again if choice == current_value: return dbcfg = gmCfg.cCfgSQL() dbcfg.set(workplace=gmPraxis.gmCurrentPraxisBranch().active_workplace, option=option, value=choice) return
def create_new_person(parent=None, activate=False): if parent is None: parent = wx.GetApp().GetTopWindow() if activate: # meaning we will switch away from the current patient if any msg = _( 'Before creating a new person review the encounter details\n' 'of the patient you just worked on:\n' ) gmEncounterWidgets.sanity_check_encounter_of_active_patient(parent = parent, msg = msg) msg = _('Edit the current encounter of the patient you are ABOUT TO LEAVE:') dbcfg = gmCfg.cCfgSQL() def_region = dbcfg.get2 ( option = 'person.create.default_region', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user' ) def_country = None if def_region is None: def_country = dbcfg.get2 ( option = 'person.create.default_country', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user' ) else: countries = gmDemographicRecord.get_country_for_region(region = def_region) if len(countries) == 1: def_country = countries[0]['code_country'] ea = cNewPatientEAPnl(parent, -1, country = def_country, region = def_region) dlg = gmEditArea.cGenericEditAreaDlg2(parent, -1, edit_area = ea, single_entry = True) dlg.SetTitle(_('Adding new person')) ea._PRW_lastname.SetFocus() result = dlg.ShowModal() pat = ea.data dlg.DestroyLater() if result != wx.ID_OK: return False _log.debug('created new person [%s]', pat.ID) if activate: from Gnumed.wxpython import gmPatSearchWidgets gmPatSearchWidgets.set_active_patient(patient = pat) gmDispatcher.send(signal = 'display_widget', name = 'gmNotebookedPatientEditionPlugin') return True
def configure_string_option(parent=None, message=None, option=None, bias='user', default_value='', validator=None): dbcfg = gmCfg.cCfgSQL() current_value = dbcfg.get2 ( option = option, workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = bias, default = default_value ) if current_value is not None: current_value = '%s' % current_value if parent is None: parent = wx.GetApp().GetTopWindow() while True: dlg = wx.TextEntryDialog ( parent, message, caption = _('Configuration'), value = gmTools.coalesce(current_value, ''), style = wx.OK | wx.CANCEL | wx.CENTRE ) result = dlg.ShowModal() if result == wx.ID_CANCEL: dlg.DestroyLater() return None user_val = dlg.GetValue().strip() dlg.DestroyLater() if user_val == current_value: return user_val validated, user_val = validator(user_val) if validated: break gmDispatcher.send ( signal = 'statustext', msg = _('Value [%s] not valid for option <%s>.') % (user_val, option), beep = True ) dbcfg = gmCfg.cCfgSQL() dbcfg.set ( workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, option = option, value = user_val ) return user_val
def configure_string_from_list_option(parent=None, message=None, option=None, bias='user', default_value='', choices=None, columns=None, data=None, caption=None): dbcfg = gmCfg.cCfgSQL() current_value = dbcfg.get2 ( option = option, workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = bias, default = default_value ) if parent is None: parent = wx.GetApp().GetTopWindow() if caption is None: caption = _('Configuration') selections = None if current_value is not None: try: selections = [choices.index(current_value)] except ValueError: pass choice = gmListWidgets.get_choices_from_list ( parent = parent, msg = message, caption = caption, choices = choices, columns = columns, data = data, selections = selections, single_selection = True, can_return_empty = False ) # aborted if choice is None: return # same value selected again if choice == current_value: return dbcfg = gmCfg.cCfgSQL() dbcfg.set ( workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, option = option, value = choice ) return
def _on_report_button_pressed(self, event): event.Skip() dbcfg = gmCfg.cCfgSQL() url = dbcfg.get2 ( option = 'external.urls.report_vaccine_ADR', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user' ) if url.strip() == '': url = dbcfg.get2 ( option = 'external.urls.report_ADR', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user' ) gmNetworkTools.open_url_in_browser(url = url)
def _on_report_button_pressed(self, event): event.Skip() dbcfg = gmCfg.cCfgSQL() url = dbcfg.get2 ( option = 'external.urls.report_vaccine_ADR', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user' ) if url.strip() == '': url = dbcfg.get2 ( option = 'external.urls.report_ADR', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user' ) gmNetworkTools.open_url_in_browser(url = url)
def install_wx_exception_handler(): global _logfile_name _logfile_name = gmLog2._logfile_name global _local_account _local_account = os.path.basename(os.path.expanduser('~')) set_helpdesk(gmPraxis.gmCurrentPraxisBranch().helpdesk) set_staff_name(_local_account) set_is_public_database(False) set_sender_email(None) set_client_version('gmExceptionHandlingWidgets.py <default>') gmDispatcher.connect(signal='application_closing', receiver=_on_application_closing) global APP_PID APP_PID = os.getpid() _log.debug('registered PID [%s] for aborting if necessary', APP_PID) global _prev_excepthook _prev_excepthook = sys.excepthook sys.excepthook = handle_uncaught_exception_wx return True
def archive_forms(episode_name=None, comment=None): if episode_name is None: epi = None # will ask for episode further down else: pat = gmPerson.gmCurrentPatient() emr = pat.emr epi = emr.add_episode(episode_name = episode_name, is_open = False) for form in forms: files2import = [] files2import.extend(form.final_output_filenames) files2import.extend(form.re_editable_filenames) if len(files2import) == 0: continue save_files_as_new_document ( parent = parent, filenames = files2import, document_type = form.template['instance_type'], unlock_patient = False, episode = epi, review_as_normal = review_copy_as_normal, reference = None, pk_org_unit = gmPraxis.gmCurrentPraxisBranch()['pk_org_unit'], comment = comment ) return True
def OnHelp(self, event): praxis = gmPraxis.gmCurrentPraxisBranch() wx.MessageBox( _( u"""Unable to connect to the database ? "PostgreSQL: FATAL: password authentication failed ..." The default user name and password are {any-doc, any-doc} for the public and any new GNUmed databases. "... could not connect to server ..." Mostly this is a case of new users who did not yet install or configure a PostgreSQL server and/or a GNUmed database of their own, which you must do before you can connect to anything other than the public demonstration database, see http://wiki.gnumed.de/bin/view/Gnumed/GmManualServerInstall For assistance on using GNUmed please consult the wiki: http://wiki.gnumed.de/bin/view/Gnumed/GnumedManual For more help than the above, please contact: GNUmed Development List <*****@*****.**> For local assistance please contact: %s""" ) % praxis.helpdesk, caption=_("HELP for GNUmed main login screen"), )
def __init__ (self, *args, **kwargs): try: self.patient = kwargs['patient'] del kwargs['patient'] except KeyError: self.patient = None try: data = kwargs['entry'] del kwargs['entry'] except KeyError: data = None wxgWaitingListEntryEditAreaPnl.wxgWaitingListEntryEditAreaPnl.__init__(self, *args, **kwargs) gmEditArea.cGenericEditAreaMixin.__init__(self) if data is None: self.mode = 'new' else: self.data = data self.mode = 'edit' praxis = gmPraxis.gmCurrentPraxisBranch() pats = praxis.waiting_list_patients zones = {} zones.update([ [p['waiting_zone'], None] for p in pats if p['waiting_zone'] is not None ]) self._PRW_zone.update_matcher(items = zones.keys())
def __get_lab_panel(self): # get panel to use dbcfg = gmCfg.cCfgSQL() pk_panel = dbcfg.get2( option=u'horstspace.top_panel.lab_panel', workplace=gmPraxis.gmCurrentPraxisBranch().active_workplace, bias='user') if pk_panel is None: return None try: panel = gmPathLab.cTestPanel(aPK_obj=pk_panel) except gmExceptions.ConstructorError: _log.exception('cannot load configured test panel') panel = None if panel is not None: return panel _log.error( 'Cannot load test panel [#%s] configured for patient pane (horstspace.top_panel.lab_panel).', pk_panel) gmGuiHelpers.gm_show_error( title=_('GNUmed startup'), error=_('Cannot load test panel [#%s] configured\n' 'for the top pane with option\n' '\n' ' <horstspace.top_panel.lab_panel>\n' '\n' 'Please reconfigure.') % pk_panel) return None
def __on_add_unassociated(self, evt): """Add new editor for as-yet unassociated progress note. Clinical logic as per discussion with Jim Busser: - if patient has no episodes: - new patient - always allow several NEWs - if patient has episodes: - allow several NEWs per configuration """ emr = self.__pat.emr epis = emr.get_episodes() if len(epis) == 0: value = True else: dbcfg = gmCfg.cCfgSQL() value = bool(dbcfg.get2 ( option = 'horstspace.soap_editor.allow_same_episode_multiple_times', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user', default = False )) self.__soap_notebook.add_editor(allow_same_problem = value)
def __init_ui(self): cfg = gmCfg2.gmCfgData() if cfg.get(option = 'slave'): self._TCTRL_patient_selector.SetEditable(0) self._TCTRL_patient_selector.SetToolTip(None) if sys.platform == u'darwin': _log.debug('adjusting font size on Mac for top panel parts') for ctrl in [self._TCTRL_patient_selector, self._LBL_age, self._LBL_allergies, self._TCTRL_allergies]: curr_font = ctrl.GetFont() mac_font = wx.FontFromNativeInfo(curr_font.NativeFontInfo) mac_font.SetPointSize(pointSize = int(curr_font.GetPointSize() / 0.8)) ctrl.SetFont(mac_font) # get panel to use dbcfg = gmCfg.cCfgSQL() pk_panel = dbcfg.get2 ( option = u'horstspace.top_panel.lab_panel', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user' ) if pk_panel is None: self.__lab_panel = None else: self.__lab_panel = gmPathLab.cTestPanel(aPK_obj = pk_panel)
def GetWidget (self, parent): # get current workplace name workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace currUser = gmStaff.gmCurrentProvider()['db_user'] _log.Log (gmLog.lInfo, "ConfigReg: %s@%s" % (currUser,workplace)) self._widget = gmConfigEditorPanel(parent,currUser,workplace) return self._widget
def _on_problem_activated(self, event): """Open progress note editor for this problem. """ problem = self._LCTRL_active_problems.get_selected_item_data(only_one = True) if problem is None: return True dbcfg = gmCfg.cCfgSQL() allow_duplicate_editors = bool(dbcfg.get2 ( option = 'horstspace.soap_editor.allow_same_episode_multiple_times', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user', default = False )) if self._PNL_editors.add_editor(problem = problem, allow_same_problem = allow_duplicate_editors): return True gmGuiHelpers.gm_show_error ( aMessage = _( 'Cannot open progress note editor for\n\n' '[%s].\n\n' ) % problem['problem'], aTitle = _('opening progress note editor') ) return False
def _check_birthday(patient=None): if patient['dob'] is None: return dbcfg = gmCfg.cCfgSQL() dob_distance = dbcfg.get2 ( option = 'patient_search.dob_warn_interval', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user', default = '1 week' ) if not patient.dob_in_range(dob_distance, dob_distance): return now = gmDateTime.pydt_now_here() enc = gmI18N.get_encoding() msg = _('%(pat)s turns %(age)s on %(month)s %(day)s ! (today is %(month_now)s %(day_now)s)') % { 'pat': patient.get_description_gender(), 'age': patient.get_medical_age().strip('y'), 'month': patient.get_formatted_dob(format = '%B'), 'day': patient.get_formatted_dob(format = '%d'), 'month_now': gmDateTime.pydt_strftime(now, '%B', gmDateTime.acc_months), 'day_now': gmDateTime.pydt_strftime(now, '%d', gmDateTime.acc_days) } gmDispatcher.send(signal = 'statustext', msg = msg)
def _check_birthday(patient=None): if patient['dob'] is None: return dbcfg = gmCfg.cCfgSQL() dob_distance = dbcfg.get2 ( option = 'patient_search.dob_warn_interval', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user', default = '1 week' ) if not patient.dob_in_range(dob_distance, dob_distance): return now = gmDateTime.pydt_now_here() msg = _('%(pat)s turns %(age)s on %(month)s %(day)s ! (today is %(month_now)s %(day_now)s)') % { 'pat': patient.get_description_gender(), 'age': patient.get_medical_age(at_date = patient.birthday_this_year).strip('y'), 'month': patient.get_formatted_dob(format = '%B'), 'day': patient.get_formatted_dob(format = '%d'), 'month_now': gmDateTime.pydt_strftime(now, '%B', gmDateTime.acc_months), 'day_now': gmDateTime.pydt_strftime(now, '%d', gmDateTime.acc_days) } gmDispatcher.send(signal = 'statustext', msg = msg)
def _on_mail_items_button_pressed(self, event): event.Skip() _log.debug('gm-mail_doc(.bat) API: "MAIL-PROGRAM PRAXIS-VCF ZIP-ARCHIVE"') found, external_cmd = gmShellAPI.detect_external_binary('gm-mail_doc') if not found: gmDispatcher.send(signal = 'statustext', msg = _('Cannot send e-mail: <gm-mail_doc(.bat)> not found')) return False zip_file = self.__export_as_zip ( _('Mailing documents as zip archive'), encrypt = True ) if zip_file is None: gmDispatcher.send(signal = 'statustext', msg = _('Cannot send e-mail: no archive created.')) return False prax = gmPraxis.gmCurrentPraxisBranch() args = [external_cmd, prax.vcf, zip_file] success, ret_code, stdout = gmShellAPI.run_process(cmd_line = args, verbose = _cfg.get(option = 'debug')) if not success: gmGuiHelpers.gm_show_error ( aMessage = _('Error mailing documents.'), aTitle = _('Mailing documents') ) return False self.__save_soap_note(soap = _('Mailed:\n - %s') % '\n - '.join([ i['description'] for i in items ])) return True
def OnHelp(self, event): praxis = gmPraxis.gmCurrentPraxisBranch() wx.MessageBox(_("""Unable to connect to the database ? "PostgreSQL: FATAL: password authentication failed ..." The default user name and password are {any-doc, any-doc} for the public and any new GNUmed databases. "... could not connect to server ..." Mostly this is a case of new users who did not yet install or configure a PostgreSQL server and/or a GNUmed database of their own, which you must do before you can connect to anything other than the public demonstration database, see http://wiki.gnumed.de/bin/view/Gnumed/GmManualServerInstall For assistance on using GNUmed please consult the wiki: http://wiki.gnumed.de/bin/view/Gnumed/GnumedManual For more help than the above, please contact: GNUmed Development List <*****@*****.**> For local assistance please contact: %s""") % praxis.helpdesk, caption=_('HELP for GNUmed main login screen'))
def __init__ (self, *args, **kwargs): try: self.patient = kwargs['patient'] del kwargs['patient'] except KeyError: self.patient = None try: data = kwargs['entry'] del kwargs['entry'] except KeyError: data = None wxgWaitingListEntryEditAreaPnl.wxgWaitingListEntryEditAreaPnl.__init__(self, *args, **kwargs) gmEditArea.cGenericEditAreaMixin.__init__(self) if data is None: self.mode = 'new' else: self.data = data self.mode = 'edit' praxis = gmPraxis.gmCurrentPraxisBranch() pats = praxis.waiting_list_patients zones = {} zones.update([ [p['waiting_zone'], None] for p in pats if p['waiting_zone'] is not None ]) self._PRW_zone.update_matcher(items = zones.keys())
def __init_ui(self): cfg = gmCfg2.gmCfgData() if cfg.get(option='slave'): self._TCTRL_patient_selector.SetEditable(0) self._TCTRL_patient_selector.SetToolTip(None) if sys.platform == 'darwin': _log.debug('adjusting font size on Mac for top panel parts') for ctrl in [ self._TCTRL_patient_selector, self._LBL_age, self._LBL_allergies, self._TCTRL_allergies ]: curr_font = ctrl.GetFont() mac_font = wx.Font(curr_font.GetNativeFontInfo()) mac_font.SetPointSize(pointSize=int(curr_font.GetPointSize() / 0.8)) ctrl.SetFont(mac_font) # get panel to use dbcfg = gmCfg.cCfgSQL() pk_panel = dbcfg.get2( option='horstspace.top_panel.lab_panel', workplace=gmPraxis.gmCurrentPraxisBranch().active_workplace, bias='user') if pk_panel is None: self.__lab_panel = None else: self.__lab_panel = gmPathLab.cTestPanel(aPK_obj=pk_panel)
def _on_problem_activated(self, event): """Open progress note editor for this problem. """ problem = self._LCTRL_active_problems.get_selected_item_data(only_one = True) if problem is None: return True dbcfg = gmCfg.cCfgSQL() allow_duplicate_editors = bool(dbcfg.get2 ( option = 'horstspace.soap_editor.allow_same_episode_multiple_times', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user', default = False )) if self._PNL_editors.add_editor(problem = problem, allow_same_problem = allow_duplicate_editors): return True gmGuiHelpers.gm_show_error ( aMessage = _( 'Cannot open progress note editor for\n\n' '[%s].\n\n' ) % problem['problem'], aTitle = _('opening progress note editor') ) return False
def GetWidget(self, parent): # get current workplace name workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace currUser = gmStaff.gmCurrentProvider()['db_user'] _log.info("ConfigReg: %s@%s" % (currUser, workplace)) self._widget = gmConfigEditorPanel(parent, currUser, workplace) return self._widget
def archive_forms(episode_name=None, comment=None): if episode_name is None: epi = None # will ask for episode further down else: pat = gmPerson.gmCurrentPatient() emr = pat.emr epi = emr.add_episode(episode_name = episode_name, is_open = False) for form in forms: files2import = [] files2import.extend(form.final_output_filenames) files2import.extend(form.re_editable_filenames) if len(files2import) == 0: continue save_files_as_new_document ( parent = parent, filenames = files2import, document_type = form.template['instance_type'], unlock_patient = False, episode = epi, review_as_normal = review_copy_as_normal, reference = None, pk_org_unit = gmPraxis.gmCurrentPraxisBranch()['pk_org_unit'], comment = comment, date_generated = gmDateTime.pydt_now_here() ) return True
def __init__(self, *args, **kwargs): try: self.problem = kwargs['problem'] del kwargs['problem'] except KeyError: self.problem = None wxgProgressNotesEAPnl.wxgProgressNotesEAPnl.__init__(self, *args, **kwargs) dbcfg = gmCfg.cCfgSQL() self.__use_soap_fields = bool(dbcfg.get2 ( option = 'horstspace.soap_editor.use_one_field_per_soap_category', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user', default = True )) self.__soap_fields = [ self._TCTRL_Soap, self._TCTRL_sOap, self._TCTRL_soAp, self._TCTRL_soaP ] self.__init_ui() self.__register_interests() return
def __on_add_unassociated(self, evt): """Add new editor for as-yet unassociated progress note. Clinical logic as per discussion with Jim Busser: - if patient has no episodes: - new patient - always allow several NEWs - if patient has episodes: - allow several NEWs per configuration """ emr = self.__pat.emr epis = emr.get_episodes() if len(epis) == 0: value = True else: dbcfg = gmCfg.cCfgSQL() value = bool( dbcfg.get2( option= 'horstspace.soap_editor.allow_same_episode_multiple_times', workplace=gmPraxis.gmCurrentPraxisBranch( ).active_workplace, bias='user', default=False)) self.__soap_notebook.add_editor(allow_same_problem=value)
def configure_boolean_option(parent=None, question=None, option=None, button_tooltips=None): if parent is None: parent = wx.GetApp().GetTopWindow() tooltips = [ _('Set "%s" to <True>.') % option, _('Set "%s" to <False>.') % option, _('Abort the dialog and do not change the current setting.') ] if button_tooltips is not None: for idx in range(len(button_tooltips)): tooltips[idx] = button_tooltips[idx] dlg = gmGuiHelpers.c3ButtonQuestionDlg(parent, -1, caption=_('Configuration'), question=question, button_defs=[{ 'label': _('Yes'), 'tooltip': tooltips[0] }, { 'label': _('No'), 'tooltip': tooltips[1] }, { 'label': _('Cancel'), 'tooltip': tooltips[2], 'default': True }]) decision = dlg.ShowModal() if decision == wx.ID_YES: gmCfgDB.set( workplace=gmPraxis.gmCurrentPraxisBranch().active_workplace, option=option, value=True) elif decision == wx.ID_NO: gmCfgDB.set( workplace=gmPraxis.gmCurrentPraxisBranch().active_workplace, option=option, value=False) return
def _on_post_patient_selection(self, **kwargs): db_cfg = gmCfg.cCfgSQL() default_plugin = db_cfg.get2( option='patient_search.plugin_to_raise_after_search', workplace=gmPraxis.gmCurrentPraxisBranch().active_workplace, bias='user', default='gmPatientOverviewPlugin') gmDispatcher.send(signal='display_widget', name=default_plugin)
def _show_distance_on_map(self, address): if address is None: return False praxis_branch = gmPraxis.gmCurrentPraxisBranch() gmNetworkTools.open_url_in_browser( praxis_branch.get_distance2address_url(address), new=2, autoraise=True)
def configure_list_from_list_option(parent=None, message=None, option=None, bias='user', default_value=None, choices=None, columns=None, data=None, caption=None, picks=None): if default_value is None: default_value = [] dbcfg = gmCfg.cCfgSQL() current_value = dbcfg.get2( option=option, workplace=gmPraxis.gmCurrentPraxisBranch().active_workplace, bias=bias, default=default_value) if parent is None: parent = wx.GetApp().GetTopWindow() if caption is None: caption = _('Configuration') # setup item picker picker = gmListWidgets.cItemPickerDlg(parent, -1, msg=message) picker.set_columns(columns) picker.set_choices(choices) picker.set_picks(picks) result = picker.ShowModal() if result == wx.ID_CANCEL: picker.DestroyLater() return picks = picker.get_picks() picker.DestroyLater() dbcfg.set(workplace=gmPraxis.gmCurrentPraxisBranch().active_workplace, option=option, value=picks) return
def _on_report_button_pressed(self, event): event.Skip() dbcfg = gmCfg.cCfgSQL() url = dbcfg.get2 ( option = u'external.urls.report_vaccine_ADR', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = u'user', default = u'http://www.pei.de/cln_042/SharedDocs/Downloads/fachkreise/uaw/meldeboegen/b-ifsg-meldebogen,templateId=raw,property=publicationFile.pdf/b-ifsg-meldebogen.pdf' ) if url.strip() == u'': url = dbcfg.get2 ( option = u'external.urls.report_ADR', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = u'user' ) gmNetworkTools.open_url_in_browser(url = url)
def _on_post_patient_selection(self, **kwargs): db_cfg = gmCfg.cCfgSQL() default_plugin = db_cfg.get2 ( option = u'patient_search.plugin_to_raise_after_search', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = u'user', default = u'gmPatientOverviewPlugin' ) gmDispatcher.send(signal = 'display_widget', name = default_plugin)
def test_export_area(): exp = cExportArea(12) #print exp.export_with_meta_data() #print exp.items exp.add_file(sys.argv[2]) prax = gmPraxis.gmCurrentPraxisBranch(branch=gmPraxis.cPraxisBranch(1)) print prax print prax.branch print exp.export()
def _on_char(self, evt): """True: patient was selected. False: no patient was selected. """ keycode = evt.GetKeyCode() # list of previously active patients if keycode == wx.WXK_DOWN: evt.Skip() if len(self.__prev_idents) == 0: return False dlg = cSelectPersonFromListDlg(wx.GetTopLevelParent(self), -1) dlg.set_persons(persons = self.__prev_idents) result = dlg.ShowModal() if result == wx.ID_OK: wx.BeginBusyCursor() self.person = dlg.get_selected_person() dlg.DestroyLater() wx.EndBusyCursor() return True dlg.DestroyLater() return False # recall previous search fragment if keycode == wx.WXK_UP: evt.Skip() # FIXME: cycling through previous fragments if self._prev_search_term is not None: self.SetValue(self._prev_search_term) return False # invoke external patient sources if keycode == wx.WXK_F2: evt.Skip() dbcfg = gmCfg.cCfgSQL() search_immediately = bool(dbcfg.get2 ( option = 'patient_search.external_sources.immediately_search_if_single_source', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user', default = 0 )) p = get_person_from_external_sources ( parent = wx.GetTopLevelParent(self), search_immediately = search_immediately ) if p is not None: self.person = p return True return False # FIXME: invoke add new person # FIXME: add popup menu apart from system one evt.Skip()
def _on_char(self, evt): """True: patient was selected. False: no patient was selected. """ keycode = evt.GetKeyCode() # list of previously active patients if keycode == wx.WXK_DOWN: evt.Skip() if len(self.__prev_idents) == 0: return False dlg = cSelectPersonFromListDlg(wx.GetTopLevelParent(self), -1) dlg.set_persons(persons = self.__prev_idents) result = dlg.ShowModal() if result == wx.ID_OK: wx.BeginBusyCursor() self.person = dlg.get_selected_person() dlg.DestroyLater() wx.EndBusyCursor() return True dlg.DestroyLater() return False # recall previous search fragment if keycode == wx.WXK_UP: evt.Skip() # FIXME: cycling through previous fragments if self._prev_search_term is not None: self.SetValue(self._prev_search_term) return False # invoke external patient sources if keycode == wx.WXK_F2: evt.Skip() dbcfg = gmCfg.cCfgSQL() search_immediately = bool(dbcfg.get2 ( option = 'patient_search.external_sources.immediately_search_if_single_source', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user', default = 0 )) p = get_person_from_external_sources ( parent = wx.GetTopLevelParent(self), search_immediately = search_immediately ) if p is not None: self.person = p return True return False # FIXME: invoke add new person # FIXME: add popup menu apart from system one evt.Skip()
def configure_boolean_option(parent=None, question=None, option=None, button_tooltips=None): if parent is None: parent = wx.GetApp().GetTopWindow() tooltips = [ _('Set "%s" to <True>.') % option, _('Set "%s" to <False>.') % option, _('Abort the dialog and do not change the current setting.') ] if button_tooltips is not None: for idx in range(len(button_tooltips)): tooltips[idx] = button_tooltips[idx] dlg = gmGuiHelpers.c3ButtonQuestionDlg ( parent, -1, caption = _('Configuration'), question = question, button_defs = [ {'label': _('Yes'), 'tooltip': tooltips[0]}, {'label': _('No'), 'tooltip': tooltips[1]}, {'label': _('Cancel'), 'tooltip': tooltips[2], 'default': True} ] ) decision = dlg.ShowModal() dbcfg = gmCfg.cCfgSQL() if decision == wx.ID_YES: dbcfg.set ( workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, option = option, value = True ) elif decision == wx.ID_NO: dbcfg.set ( workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, option = option, value = False ) return
def test_clin_calc(): from Gnumed.business import gmPraxis branches = gmPraxis.get_praxis_branches() gmPraxis.gmCurrentPraxisBranch(branches[0]) from Gnumed.business.gmPerson import cPatient pat = cPatient(aPK_obj=201) calc = cClinicalCalculator(patient=pat) #result = calc.eGFR_MDRD_short #result = calc.eGFR_Schwartz result = calc.eGFR #result = calc.body_surface_area #result = calc.get_EDC(lmp = gmDateTime.pydt_now_here()) #result = calc.body_mass_index #result = calc.eGFRs print('%s' % result.format(with_formula=True, with_warnings=True, with_variables=True, with_sub_results=True))
def browse2schedules(vaccination=None): dbcfg = gmCfg.cCfgSQL() url = dbcfg.get2 ( option = 'external.urls.vaccination_plans', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user', default = gmVaccination.URL_vaccination_plan ) gmNetworkTools.open_url_in_browser(url = url) return False
def browse2schedules(vaccination=None): dbcfg = gmCfg.cCfgSQL() url = dbcfg.get2 ( option = 'external.urls.vaccination_plans', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user', default = gmVaccination.URL_vaccination_plan ) gmNetworkTools.open_url_in_browser(url = url) return False
def _on_activateplus_button_pressed(self, evt): item = self._LCTRL_patients.get_selected_item_data(only_one=True) if item is None: return try: pat = gmPerson.cPerson(aPK_obj = item['pk_identity']) except gmExceptions.ConstructorError: gmGuiHelpers.gm_show_info ( aTitle = _('Waiting list'), aMessage = _('Cannot activate patient.\n\nIt has probably been disabled.') ) return self.__id_most_recently_activated_patient = item['pk_identity'] self.__comment_most_recently_activated_patient = gmTools.coalesce(item['comment'], '').strip() gmPraxis.gmCurrentPraxisBranch().remove_from_waiting_list(pk = item['pk_waiting_list']) curr_pat = gmPerson.gmCurrentPatient() if curr_pat.connected: if curr_pat.ID == item['pk_identity']: return wx.CallAfter(gmPatSearchWidgets.set_active_patient, patient = pat)
def browse2schedules(vaccination=None): dbcfg = gmCfg.cCfgSQL() url = dbcfg.get2 ( option = 'external.urls.vaccination_plans', workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = 'user', default = u'http://www.bundesaerztekammer.de/downloads/STIKOEmpf2011.pdf' ) gmNetworkTools.open_url_in_browser(url = url) return False
def configure_list_from_list_option(parent=None, message=None, option=None, bias='user', default_value=None, choices=None, columns=None, data=None, caption=None, picks=None): if default_value is None: default_value = [] dbcfg = gmCfg.cCfgSQL() current_value = dbcfg.get2 ( option = option, workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, bias = bias, default = default_value ) if parent is None: parent = wx.GetApp().GetTopWindow() if caption is None: caption = _('Configuration') # setup item picker picker = gmListWidgets.cItemPickerDlg(parent, -1, msg = message) picker.set_columns(columns) picker.set_choices(choices) picker.set_picks(picks) result = picker.ShowModal() if result == wx.ID_CANCEL: picker.DestroyLater() return picks = picker.get_picks() picker.DestroyLater() dbcfg.set ( workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace, option = option, value = picks ) return
def __init__(self, nr_plugins): wx.ProgressDialog.__init__( self, title = _("GNUmed: configuring [%s] (%s plugins)") % (gmPraxis.gmCurrentPraxisBranch().active_workplace, nr_plugins), message = _("loading list of plugins "), maximum = nr_plugins, parent = None, style = wx.PD_ELAPSED_TIME ) self.SetIcon(gmTools.get_icon(wx = wx)) self.idx = 0 self.nr_plugins = nr_plugins self.prev_plugin = ""
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'])
def test_clin_calc(): from Gnumed.business.gmPraxis import gmCurrentPraxisBranch praxis = gmCurrentPraxisBranch() from Gnumed.business.gmPerson import cPatient pat = cPatient(aPK_obj = 12) calc = cClinicalCalculator(patient = pat) #result = calc.eGFR_MDRD_short #result = calc.eGFR_Schwartz result = calc.eGFR #result = calc.body_surface_area #result = calc.get_EDC(lmp = gmDateTime.pydt_now_here()) #result = calc.body_mass_index #result = calc.eGFRs print('%s' % result.format(with_formula = True, with_warnings = True, with_variables = True, with_sub_results = True))
def __init__(self, aDatabaseName=None): """ Initialize the DrugView object with information supplied via the standard config file. The data should be grouped together in the group designated by the database name. """ if aDatabaseName == None: raise gmExceptions.ConstructorError,"No database name specified." # open configuration source # if we are not inside gnumed we won't get a definite answer on # who and where we are. in this case try to get config source # from main config file (see gmCfg on how the name of this file # is determined currWorkplace = gmPraxis.gmCurrentPraxisBranch().active_workplace if currWorkplace is None: # assume we are outside gnumed self.dbConfFile = _cfg.get(aDatabaseName, 'configfile') else: # self.dbConfFile, match = gmCfg.getDBParam( workplace=currWorkplace, option="DrugReferenceBrowser.%s.configfile" % aDatabaseName ) _log.Log(gmLog.lInfo, "dbConfFile is [%s]" % str(self.dbConfFile)) if self.dbConfFile is None: _log.Log(gmLog.lErr, "No config information on drug database [%s] found." % aDatabaseName) raise gmExceptions.ConstructorError,"No DrugDB config file specified." try: self.mDrugInterface = gmDrugObject.cDrug(queryCfgSource = self.dbConfFile) except: _log.LogException("Unhandled exception while opening config file", sys.exc_info(), verbose = 0) raise gmExceptions.ConstructorError,"Couldn't initialize drug object for DB %s" % aDatabaseName self.__mFormatString = {} # format strings self.__mGroupPos = {} # query group on position x self.__mFormatType = {} # format type self.__mHeading = {} # the heading used (if any) self.__mUsedVars = {} # parameters used from the query dict # get configuration from file self.__getFormatInfo() # initialize DrugIds self.mLastId = {} self.mCurrId = -1