Gnumed.wxpython.gui.gmEMRJournalPlugin

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

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

     1  #======================================================================
     2  # GNUmed patient EMR Journal plugin
     3  #======================================================================
     4  __author__ = "Karsten Hilbert"
     5  __license__ = 'GPL v2 or later (details at http://www.gnu.org)'
     6
     7  import logging
     8
     9
    10  from Gnumed.pycommon import gmI18N
    11  from Gnumed.wxpython import gmPlugin
    12  from Gnumed.wxpython import gmEMRBrowser
    13  from Gnumed.wxpython import gmAccessPermissionWidgets
    14
    15  _log = logging.getLogger('gm.ui')
    16
    17  #======================================================================
    18 -class gmEMRJournalPlugin(gmPlugin.cNotebookPlugin):
    19          """Plugin to encapsulate patient EMR Journal window."""
    20
    21          tab_name = _('EMR journal')
    22          required_minimum_role = 'full clinical access'
    23
    24 -        def name (self):
    25                  return gmEMRJournalPlugin.tab_name
    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 GetWidget (self, parent):
    37                  self._widget = gmEMRBrowser.cEMRJournalPluginPnl(parent, -1)
    38                  return self._widget
    39
    40 -        def MenuInfo (self):
    41                  return ('emr', _('EMR &Journal (chronological)'))
    42
    43 -        def can_receive_focus(self):
    44                  # need patient
    45                  if not self._verify_patient_avail():
    46                          return None
    47                  return 1
    48
    49  #======================================================================
    50  # main
    51  #----------------------------------------------------------------------
    52  if __name__ == "__main__":
    53
    54      import sys
    55
    56      import wx
    57
    58      from Gnumed.exporters import gmPatientExporter
    59      from Gnumed.business import gmPersonSearch
    60
    61      _log.info("starting emr journal plugin...")
    62
    63      try:
    64          # obtain patient
    65          patient = gmPersonSearch.ask_for_patient()
    66          if patient is None:
    67              print "None patient. Exiting gracefully..."
    68              sys.exit(0)
    69          gmPatSearchWidgets.set_active_patient(patient=patient)
    70
    71          # display standalone browser
    72          application = wx.wxPyWidgetTester(size=(800,600))
    73          emr_journal = gmEMRBrowser.cEMRJournalPluginPnl(application.frame, -1)
    74          emr_journal.refresh_journal()
    75
    76          application.frame.Show(True)
    77          application.MainLoop()
    78
    79          # clean up
    80          if patient is not None:
    81              try:
    82                  patient.cleanup()
    83              except:
    84                  print "error cleaning up patient"
    85      except StandardError:
    86          _log.exception("unhandled exception caught !")
    87          # but re-raise them
    88          raise
    89
    90      _log.info("closing emr journal plugin...")
    91
    92  #======================================================================
    93