Gnumed.wxpython.gui.gmNotebookedPatientEditionPlugin

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

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

      1  # -*- coding: utf-8 -*-
      2  #======================================================================
      3  # GNUmed notebook based patient edition plugin
      4  # ------------------------------------------------
      5  #
      6  # this plugin displays a notebook container for patient edition
      7  # current pages (0.1): identity, contacts, occupation
      8  #
      9  # @copyright: author
     10  #======================================================================
     11  __author__ = "Carlos Moro, Karsten Hilbert"
     12  __license__ = 'GPL v2 or later (details at http://www.gnu.org)'
     13
     14  import logging
     15
     16
     17  if __name__ == '__main__':
     18
     19          # stdlib
     20          import sys
     21          sys.path.insert(0, '../../../')
     22
     23          from Gnumed.pycommon import gmI18N
     24          gmI18N.activate_locale()
     25          gmI18N.install_domain()
     26
     27  # GNUmed
     28  from Gnumed.wxpython import gmPlugin, gmDemographicsWidgets
     29  from Gnumed.wxpython import gmAccessPermissionWidgets
     30
     31
     32  _log = logging.getLogger('gm.ui')
     33  #======================================================================
     34 -class gmNotebookedPatientEditionPlugin(gmPlugin.cNotebookPlugin):
     35          """Plugin to encapsulate notebooked patient edition window."""
     36
     37          tab_name = _('Demographics')
     38          required_minimum_role = 'non-clinical access'
     39
     40          @gmAccessPermissionWidgets.verify_minimum_required_role (
     41                  required_minimum_role,
     42                  activity = _('loading plugin <%s>') % tab_name,
     43                  return_value_on_failure = False,
     44                  fail_silently = False
     45          )
     46 -        def register(self):
     47                  gmPlugin.cNotebookPlugin.register(self)
     48          #-------------------------------------------------
     49 -        def name (self):
     50                  return gmNotebookedPatientEditionPlugin.tab_name
     51
     52 -        def GetWidget (self, parent):
     53                  self._widget = gmDemographicsWidgets.cNotebookedPatEditionPanel(parent, -1)
     54                  return self._widget
     55
     56 -        def MenuInfo (self):
     57                  return ('patient', _('&Demographics'))
     58
     59 -        def can_receive_focus(self):
     60                  # need patient
     61                  if not self._verify_patient_avail():
     62                          return None
     63                  return 1
     64
     65  #======================================================================
     66  # main
     67  #----------------------------------------------------------------------
     68  if __name__ == "__main__":
     69
     70          # 3rd party
     71          import wx
     72
     73          # GNUmed
     74          from Gnumed.business import gmPersonSearch
     75
     76          _log.info("starting Notebooked patient edition plugin...")
     77
     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 Exception:
     97                          print("error cleaning up patient")
     98
     99          _log.info("closing Notebooked progress notes input plugin...")
    100
    101  #======================================================================
    102