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

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

      1  #======================================================================
      2  # GNUmed notebook based patient edition plugin
      3  # ------------------------------------------------
      4  #
      5  # this plugin displays a notebook container for patient edition
      6  # current pages (0.1): identity, contacts, occupation
      7  #
      8  # @copyright: author
      9  #======================================================================
     10  __author__ = "Carlos Moro, Karsten Hilbert"
     11  __license__ = 'GPL v2 or later (details at http://www.gnu.org)'
     12
     13  import logging
     14
     15
     16  if __name__ == '__main__':
     17
     18          # stdlib
     19          import sys
     20          sys.path.insert(0, '../../../')
     21
     22          from Gnumed.pycommon import gmI18N
     23          gmI18N.activate_locale()
     24          gmI18N.install_domain()
     25
     26  # GNUmed
     27  from Gnumed.wxpython import gmPlugin, gmDemographicsWidgets
     28  from Gnumed.wxpython import gmAccessPermissionWidgets
     29
     30
     31  _log = logging.getLogger('gm.ui')
     32  #======================================================================
     33 -class gmNotebookedPatientEditionPlugin(gmPlugin.cNotebookPlugin):
     34          """Plugin to encapsulate notebooked patient edition window."""
     35
     36          tab_name = _('Demographics')
     37          required_minimum_role = 'non-clinical access'
     38
     39          @gmAccessPermissionWidgets.verify_minimum_required_role (
     40                  required_minimum_role,
     41                  activity = _('loading plugin <%s>') % tab_name,
     42                  return_value_on_failure = False,
     43                  fail_silently = False
     44          )
     45 -        def register(self):
     46                  gmPlugin.cNotebookPlugin.register(self)
     47          #-------------------------------------------------
     48 -        def name (self):
     49                  return gmNotebookedPatientEditionPlugin.tab_name
     50
     51 -        def GetWidget (self, parent):
     52                  self._widget = gmDemographicsWidgets.cNotebookedPatEditionPanel(parent, -1)
     53                  return self._widget
     54
     55 -        def MenuInfo (self):
     56                  return ('patient', _('&Demographics'))
     57
     58 -        def can_receive_focus(self):
     59                  # need patient
     60                  if not self._verify_patient_avail():
     61                          return None
     62                  return 1
     63
     64  #======================================================================
     65  # main
     66  #----------------------------------------------------------------------
     67  if __name__ == "__main__":
     68
     69          # 3rd party
     70          import wx
     71
     72          # GNUmed
     73          from Gnumed.business import gmPersonSearch
     74
     75          _log.info("starting Notebooked patient edition plugin...")
     76
     77          try:
     78                  # obtain patient
     79                  patient = gmPersonSearch.ask_for_patient()
     80                  if patient is None:
     81                          print "None patient. Exiting gracefully..."
     82                          sys.exit(0)
     83                  gmPatSearchWidgets.set_active_patient(patient=patient)
     84
     85                  # display standalone notebooked patient editor
     86                  application = wx.PyWidgetTester(size=(800,600))
     87                  application.SetWidget(gmDemographicsWidgets.cNotebookedPatEditionPanel, -1)
     88
     89                  application.frame.Show(True)
     90                  application.MainLoop()
     91
     92                  # clean up
     93                  if patient is not None:
     94                          try:
     95                                  patient.cleanup()
     96                          except:
     97                                  print "error cleaning up patient"
     98          except StandardError:
     99                  _log.exception("unhandled exception caught !")
    100                  # but re-raise them
    101                  raise
    102
    103          _log.info("closing Notebooked progress notes input plugin...")
    104
    105  #======================================================================
    106