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

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

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