Gnumed.wxpython.gui.gmEMRBrowserPlugin

Package Gnumed :: Package wxpython :: Package gui :: Module gmEMRBrowserPlugin |
[frames] | no frames]

# Source Code for Module Gnumed.wxpython.gui.gmEMRBrowserPlugin

      1  # -*- coding: utf-8 -*-
      2  #======================================================================
      3  # GNUmed patient EMR browser plugin
      4  # ----------------------------------------------
      5  #
      6  # this plugin holds patient EMR tree
      7  #
      8  # @copyright: author
      9  #======================================================================
     10  __version__ = "$Revision: 1.19 $"
     11  __author__ = "Carlos Moro"
     12  __license__ = 'GPL v2 or later (details at http://www.gnu.org)'
     13
     14  import logging
     15
     16
     17  from Gnumed.pycommon import gmI18N
     18  from Gnumed.wxpython import gmPlugin
     19  from Gnumed.wxpython import gmEMRBrowser
     20  from Gnumed.wxpython import gmAccessPermissionWidgets
     21
     22  _log = logging.getLogger('gm.ui')
     23  _log.info(__version__)
     24
     25  #======================================================================
     26 -class gmEMRBrowserPlugin(gmPlugin.cNotebookPlugin):
     27          """Plugin to encapsulate patient EMR browser window."""
     28
     29          tab_name = _('EMR Tree')
     30          required_minimum_role = 'full clinical access'
     31
     32          @gmAccessPermissionWidgets.verify_minimum_required_role (
     33                  required_minimum_role,
     34                  activity = _('loading plugin <%s>') % tab_name,
     35                  return_value_on_failure = False,
     36                  fail_silently = False
     37          )
     38 -        def register(self):
     39                  gmPlugin.cNotebookPlugin.register(self)
     40          #-------------------------------------------------
     41 -        def name(self):
     42                  return gmEMRBrowserPlugin.tab_name
     43          #-------------------------------------------------
     44 -        def GetWidget(self, parent):
     45                  self._widget = gmEMRBrowser.cSplittedEMRTreeBrowserPnl(parent, -1)
     46                  return self._widget
     47          #-------------------------------------------------
     48 -        def MenuInfo(self):
     49                  return ('emr', _('EMR &Tree'))
     50          #-------------------------------------------------
     51 -        def can_receive_focus(self):
     52                  # need patient
     53                  if not self._verify_patient_avail():
     54                          return None
     55                  return 1
     56  #======================================================================
     57  # main
     58  #----------------------------------------------------------------------
     59  if __name__ == "__main__":
     60
     61      import sys
     62
     63      import wx
     64
     65      from Gnumed.exporters import gmPatientExporter
     66      from Gnumed.business import gmPersonSearch
     67
     68      _log.info("starting emr browser plugin...")
     69
     70      try:
     71          # obtain patient
     72          patient = gmPersonSearch.ask_for_patient()
     73          if patient is None:
     74              print("None patient. Exiting gracefully...")
     75              sys.exit(0)
     76          gmPatSearchWidgets.set_active_patient(patient=patient)
     77
     78          # display standalone browser
     79          application = wx.wxPyWidgetTester(size=(800,600))
     80          emr_browser = gmEMRBrowser.cEMRBrowserPanel(application.frame, -1)
     81          emr_browser.refresh_tree()
     82
     83          application.frame.Show(True)
     84          application.MainLoop()
     85
     86          # clean up
     87          if patient is not None:
     88              try:
     89                  patient.cleanup()
     90              except:
     91                  print("error cleaning up patient")
     92      except Exception:
     93          _log.exception("unhandled exception caught !")
     94          # but re-raise them
     95          raise
     96
     97      _log.info("closing emr browser plugin...")
     98
     99  #======================================================================
    100