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

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

      1  """ This is the EMR Timeline plugin."""
      2
      3  __author__ = "karsten.hilbert@gmx.net"
      4  __license__ = "GPL v2 or later"
      5
      6  #================================================================
      7  import logging
      8
      9
     10  import wx
     11
     12
     13  from Gnumed.wxpython import gmPlugin, gmEMRTimelineWidgets
     14  from Gnumed.wxpython import gmAccessPermissionWidgets
     15
     16
     17  _log = logging.getLogger('gm.ui')
     18  #================================================================
     19 -class gmEMRTimelinePlugin(gmPlugin.cNotebookPlugin):
     20          tab_name = _("EMR Timeline")
     21          required_minimum_role = 'full clinical access'
     22
     23          @gmAccessPermissionWidgets.verify_minimum_required_role (
     24                  required_minimum_role,
     25                  activity = _('loading plugin <%s>') % tab_name,
     26                  return_value_on_failure = False,
     27                  fail_silently = False
     28          )
     29 -        def register(self):
     30                  gmPlugin.cNotebookPlugin.register(self)
     31          #-------------------------------------------------
     32 -        def name (self):
     33                  return gmEMRTimelinePlugin.tab_name
     34          #--------------------------------------------------------
     35 -        def GetWidget (self, parent):
     36                  self._widget = gmEMRTimelineWidgets.cEMRTimelinePluginPnl(parent, -1)
     37                  return self._widget
     38          #--------------------------------------------------------
     39 -        def MenuInfo (self):
     40                  return ('emr', _('Show &Timeline'))
     41          #--------------------------------------------------------
     42 -        def can_receive_focus(self):
     43                  if not self._verify_patient_avail():
     44                          return None
     45                  return 1
     46          #--------------------------------------------------------
     47 -        def _on_raise_by_signal(self, **kwds):
     48                  if not gmPlugin.cNotebookPlugin._on_raise_by_signal(self, **kwds):
     49                          return False
     50                  try:
     51                          pass
     52                  except KeyError:
     53                          pass
     54                  return True
     55  #================================================================
     56  # MAIN
     57  #----------------------------------------------------------------
     58  if __name__ == '__main__':
     59
     60          # stdlib
     61          import sys
     62          sys.path.insert(0, '../../../')
     63
     64          from Gnumed.pycommon import gmI18N
     65          gmI18N.activate_locale()
     66          gmI18N.install_domain()
     67
     68          # GNUmed
     69          from Gnumed.business import gmPersonSearch
     70          from Gnumed.wxpython import gmPatSearchWidgets
     71
     72          _log.info("starting template plugin...")
     73
     74          try:
     75                  # obtain patient
     76                  patient = gmPersonSearch.ask_for_patient()
     77                  if patient is None:
     78                          print "None patient. Exiting gracefully..."
     79                          sys.exit(0)
     80                  gmPatSearchWidgets.set_active_patient(patient=patient)
     81
     82                  # display the plugin standalone
     83                  application = wx.wx.PyWidgetTester(size = (800,600))
     84                  widgets = gmExamplePluginWidgets.cExamplePluginPnl(application.frame, -1)
     85
     86                  application.frame.Show(True)
     87                  application.MainLoop()
     88
     89                  # clean up
     90                  if patient is not None:
     91                          try:
     92                                  patient.cleanup()
     93                          except:
     94                                  print "error cleaning up patient"
     95          except StandardError:
     96                  _log.exception("unhandled exception caught !")
     97                  # but re-raise them
     98                  raise
     99
    100          _log.info("closing example plugin...")
    101