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

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

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