Gnumed.wxpython.gui.gmRequest

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

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

      1  """This is a basic requests panel.
      2
      3  Status: hacking
      4
      5      Copyright (C) 2004 Ian Haywood
      6
      7      This program is free software; you can redistribute it and/or modify
      8      it under the terms of the GNU General Public License as published by
      9      the Free Software Foundation; either version 2 of the License, or
     10      (at your option) any later version.
     11
     12      This program is distributed in the hope that it will be useful,
     13      but WITHOUT ANY WARRANTY; without even the implied warranty of
     14      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15      GNU General Public License for more details.
     16
     17      You should have received a copy of the GNU General Public License
     18      along with this program; if not, write to the Free Software
     19      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     20
     21  """
     22  __author__ = "Ian Haywood <ihaywood@gnu.org>"
     23
     24  from Gnumed.wxpython import gmPlugin, gmGuiHelpers
     25  from Gnumed.business import gmForms
     26  from Gnumed.wxpython.gmPhraseWheel import cPhraseWheel
     27
     28  if __name__ == '__main__':
     29          _ = lambda x:x
     30
     31  # generated by wxGlade 0.3.3 on Tue Jun 15 13:29:57 2004
     32
     33  import wx
     34
     35 -class RequestsPanel(wx.Panel):
     36 -    def __init__(self, *args, **kwds):
     37          # begin wxGlade: RequestsPanel.__init__
     38          kwds["style"] = wx.TAB_TRAVERSAL
     39          wx.Panel.__init__(self, *args, **kwds)
     40          self.label_1 = wxStaticText(self, -1, _("Type"))
     41          self.wheel_type = cPhraseWheel(self, -1, "")
     42          self.label_2 = wxStaticText(self, -1, _("Form"))
     43          self.wheel_form = cPhraseWheel(self, -1, "")
     44          self.label_3 = wxStaticText(self, -1, _("Request"))
     45          self.text_ctrl_request = wx.TextCtrl(self, -1, "")
     46          self.label_4 = wxStaticText(self, -1, _("Clinical"))
     47          self.text_ctrl_clinical = wx.TextCtrl(self, -1, "", style=wx.TE_PROCESS_ENTER|wx.TE_MULTILINE)
     48          self.label_5 = wxStaticText(self, -1, _("Instructions"))
     49          self.text_ctrl_instructions = wx.TextCtrl(self, -1, "", style=wx.TE_PROCESS_ENTER|wx.TE_MULTILINE)
     50          self.button_OK = wx.Button(self, -1, _("OK"))
     51
     52          self.__set_properties()
     53          self.__do_layout()
     54          # end wxGlade
     55
     56 -    def __set_properties(self):
     57          # begin wxGlade: RequestsPanel.__set_properties
     58          pass
     59          # end wxGlade
     60
     61 -    def __do_layout(self):
     62          # begin wxGlade: RequestsPanel.__do_layout
     63          sizer_1 = wx.BoxSizer(wx.VERTICAL)
     64          grid_sizer_1 = wxFlexGridSizer(5, 2, 0, 0)
     65          grid_sizer_1.Add(self.label_1, 0, 0, 0)
     66          grid_sizer_1.Add(self.wheel_type, 0, wxEXPAND, 0)
     67          grid_sizer_1.Add(self.label_2, 0, 0, 0)
     68          grid_sizer_1.Add(self.wheel_form, 0, wxEXPAND, 0)
     69          grid_sizer_1.Add(self.label_3, 0, 0, 0)
     70          grid_sizer_1.Add(self.text_ctrl_request, 0, wxEXPAND, 0)
     71          grid_sizer_1.Add(self.label_4, 0, 0, 0)
     72          grid_sizer_1.Add(self.text_ctrl_clinical, 0, wxEXPAND, 0)
     73          grid_sizer_1.Add(self.label_5, 0, 0, 0)
     74          grid_sizer_1.Add(self.text_ctrl_instructions, 0, wxEXPAND, 0)
     75          grid_sizer_1.AddGrowableRow(3)
     76          grid_sizer_1.AddGrowableRow(4)
     77          grid_sizer_1.AddGrowableCol(1)
     78          sizer_1.Add(grid_sizer_1, 1, wxEXPAND, 0)
     79          sizer_1.Add(self.button_OK, 0, wxALIGN_CENTER_HORIZONTAL, 0)
     80          self.SetAutoLayout(1)
     81          self.SetSizer(sizer_1)
     82          sizer_1.Fit(self)
     83          sizer_1.SetSizeHints(self)
     84          # end wxGlade
     85
     86  # end of class RequestsPanel
     87
     88
     89
     90
     91 -class cActiveRequestsPanel (RequestsPanel):
     92      """
     93      A descendant of the autogenerated class to add activity
     94      """
     95 -    def __init__ (self, parent, id):
     96          RequestsPanel.__init__ (self, parent, id)
     97          self.wheel_type.matcher = gmForms.FormTypeMP()
     98          self.wheel_form.matcher = gmForms.FormMP()
     99          wx.EVT_BUTTON (self.button_OK, self.button_OK.GetId (), self._ok_pressed)
    100
    101 -    def _ok_pressed (self, event):
    102          form_id = self.wheel_form.getData ()
    103          print "Form id: %s" % form_id
    104          type_id = self.wheel_type.getData ()
    105          print "Type : %s" % type_id
    106          if form_id and type_id:
    107              try:
    108                  form = gmForms.get_form (form_id)
    109                  params = {}
    110                  params['type'] = self.wheel_type.GetValue ()
    111                  params['request'] = self.text_ctrl_request.GetValue ()
    112                  params['clinical_notes'] = self.text_ctrl_clinical.GetValue ()
    113                  params['instructions'] = self.text_ctrl_instructions.GetValue ()
    114                  form.store (params)
    115                  form.process (params)
    116                  form.printout ()
    117              except gmForms.FormError, e:
    118                  gmGuiHelpers.gm_show_error (str(e), _("Error processing form"))
    119              except:
    120                  gmLog.gmDefLog.LogException( "forms printing", sys.exc_info(), verbose=0)
    121          else:
    122              gmGuiHelpers.gm_show_error (_("You must select a form and type"), _("Missing field"))
    123
    124
    125 -class gmRequest (gmPlugin.cNotebookPluginOld):
    126
    127      tab_name = _("Request")
    128
    129 -    def name (self):
    130          return gmRequest.tab_name
    131
    132 -    def MenuInfo (self):
    133          return ("view", _("&Request"))
    134
    135 -    def GetWidget (self, parent):
    136          return cActiveRequestsPanel (parent, -1)
    137
    138 -    def can_receive_focus(self):
    139          # need patient
    140          if not self._verify_patient_avail():
    141              return None
    142          return 1
    143