Gnumed.wxpython.gui.gmEMRListJournalPlugin

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

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

      1  # -*- coding: utf-8 -*-
      2  #======================================================================
      3  # GNUmed patient EMR Journal plugin (list based)
      4  #======================================================================
      5  __author__ = "Karsten Hilbert"
      6  __license__ = 'GPL v2 or later (details at http://www.gnu.org)'
      7
      8  import logging
      9
     10
     11  from Gnumed.pycommon import gmI18N
     12  from Gnumed.wxpython import gmPlugin
     13  from Gnumed.wxpython import gmEMRBrowser
     14  from Gnumed.wxpython import gmAccessPermissionWidgets
     15
     16  _log = logging.getLogger('gm.ui')
     17
     18  #======================================================================
     19 -class gmEMRListJournalPlugin(gmPlugin.cNotebookPlugin):
     20          """Plugin to encapsulate patient EMR list based Journal window."""
     21
     22          tab_name = _('EMR Journal')
     23          required_minimum_role = 'full clinical access'
     24
     25          #-------------------------------------------------
     26 -        def name (self):
     27                  return gmEMRListJournalPlugin.tab_name
     28
     29          #-------------------------------------------------
     30          @gmAccessPermissionWidgets.verify_minimum_required_role (
     31                  required_minimum_role,
     32                  activity = _('loading plugin <%s>') % tab_name,
     33                  return_value_on_failure = False,
     34                  fail_silently = False
     35          )
     36 -        def register(self):
     37                  gmPlugin.cNotebookPlugin.register(self)
     38
     39          #-------------------------------------------------
     40 -        def GetWidget (self, parent):
     41                  self._widget = gmEMRBrowser.cEMRListJournalPluginPnl(parent, -1)
     42                  return self._widget
     43
     44          #-------------------------------------------------
     45 -        def MenuInfo (self):
     46                  return ('emr', _('EMR &Journal (list)'))
     47
     48          #-------------------------------------------------
     49 -        def can_receive_focus(self):
     50                  # need patient
     51                  if not self._verify_patient_avail():
     52                          return None
     53                  return 1
     54
     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 journal 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_journal = gmEMRBrowser.cEMRListJournalPluginPnl(application.frame, -1)
     80          emr_journal.refresh_journal()
     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 Exception:
     92          _log.exception("unhandled exception caught !")
     93          # but re-raise them
     94          raise
     95
     96      _log.info("closing emr journal plugin...")
     97
     98  #======================================================================
     99