Gnumed.wxpython.gui.gmRequest

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

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

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