Gnumed.wxpython.gui.gmEMRBrowserPlugin

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

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

     1  # -*- coding: utf-8 -*-
     2  #======================================================================
     3  # GNUmed patient EMR browser plugin
     4  # ----------------------------------------------
     5  #
     6  # this plugin holds patient EMR tree
     7  #
     8  # @copyright: author
     9  #======================================================================
    10  __version__ = "$Revision: 1.19 $"
    11  __author__ = "Carlos Moro"
    12  __license__ = 'GPL v2 or later (details at http://www.gnu.org)'
    13
    14  import logging
    15
    16
    17  from Gnumed.pycommon import gmI18N
    18  from Gnumed.wxpython import gmPlugin
    19  from Gnumed.wxpython import gmEMRBrowser
    20  from Gnumed.wxpython import gmAccessPermissionWidgets
    21
    22  _log = logging.getLogger('gm.ui')
    23  _log.info(__version__)
    24
    25  #======================================================================
    26 -class gmEMRBrowserPlugin(gmPlugin.cNotebookPlugin):
    27          """Plugin to encapsulate patient EMR browser window."""
    28
    29          tab_name = _('EMR Tree')
    30          required_minimum_role = 'full clinical access'
    31
    32          @gmAccessPermissionWidgets.verify_minimum_required_role (
    33                  required_minimum_role,
    34                  activity = _('loading plugin <%s>') % tab_name,
    35                  return_value_on_failure = False,
    36                  fail_silently = False
    37          )
    38 -        def register(self):
    39                  gmPlugin.cNotebookPlugin.register(self)
    40          #-------------------------------------------------
    41 -        def name(self):
    42                  return gmEMRBrowserPlugin.tab_name
    43          #-------------------------------------------------
    44 -        def GetWidget(self, parent):
    45                  self._widget = gmEMRBrowser.cSplittedEMRTreeBrowserPnl(parent, -1)
    46                  return self._widget
    47          #-------------------------------------------------
    48 -        def MenuInfo(self):
    49                  return ('emr', _('EMR &Tree'))
    50          #-------------------------------------------------
    51 -        def can_receive_focus(self):
    52                  # need patient
    53                  if not self._verify_patient_avail():
    54                          return None
    55                  return 1
    56  #======================================================================
    57  # main
    58  #----------------------------------------------------------------------
    59  if __name__ == "__main__":
    60
    61      import sys
    62
    63      import wx
    64
    65      from Gnumed.exporters import gmPatientExporter
    66      from Gnumed.business import gmPersonSearch
    67
    68      _log.info("starting emr browser plugin...")
    69
    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 Exception:
    90              print("error cleaning up patient")
    91
    92      _log.info("closing emr browser plugin...")
    93
    94  #======================================================================
    95