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  if __name__ == '__main__': 
 30          _ = lambda x:x 
 31   
 32  # generated by wxGlade 0.3.3 on Tue Jun 15 13:29:57 2004 
 33   
 34  import wx 
 35   
36 -class RequestsPanel(wx.Panel):
37 - def __init__(self, *args, **kwds):
38 # begin wxGlade: RequestsPanel.__init__ 39 kwds["style"] = wx.TAB_TRAVERSAL 40 wx.Panel.__init__(self, *args, **kwds) 41 self.label_1 = wxStaticText(self, -1, _("Type")) 42 self.wheel_type = cPhraseWheel(self, -1, "") 43 self.label_2 = wxStaticText(self, -1, _("Form")) 44 self.wheel_form = cPhraseWheel(self, -1, "") 45 self.label_3 = wxStaticText(self, -1, _("Request")) 46 self.text_ctrl_request = wx.TextCtrl(self, -1, "") 47 self.label_4 = wxStaticText(self, -1, _("Clinical")) 48 self.text_ctrl_clinical = wx.TextCtrl(self, -1, "", style=wx.TE_PROCESS_ENTER|wx.TE_MULTILINE) 49 self.label_5 = wxStaticText(self, -1, _("Instructions")) 50 self.text_ctrl_instructions = wx.TextCtrl(self, -1, "", style=wx.TE_PROCESS_ENTER|wx.TE_MULTILINE) 51 self.button_OK = wx.Button(self, -1, _("OK")) 52 53 self.__set_properties() 54 self.__do_layout()
55 # end wxGlade 56
57 - def __set_properties(self):
58 # begin wxGlade: RequestsPanel.__set_properties 59 pass
60 # end wxGlade 61
62 - def __do_layout(self):
63 # begin wxGlade: RequestsPanel.__do_layout 64 sizer_1 = wx.BoxSizer(wx.VERTICAL) 65 grid_sizer_1 = wxFlexGridSizer(5, 2, 0, 0) 66 grid_sizer_1.Add(self.label_1, 0, 0, 0) 67 grid_sizer_1.Add(self.wheel_type, 0, wxEXPAND, 0) 68 grid_sizer_1.Add(self.label_2, 0, 0, 0) 69 grid_sizer_1.Add(self.wheel_form, 0, wxEXPAND, 0) 70 grid_sizer_1.Add(self.label_3, 0, 0, 0) 71 grid_sizer_1.Add(self.text_ctrl_request, 0, wxEXPAND, 0) 72 grid_sizer_1.Add(self.label_4, 0, 0, 0) 73 grid_sizer_1.Add(self.text_ctrl_clinical, 0, wxEXPAND, 0) 74 grid_sizer_1.Add(self.label_5, 0, 0, 0) 75 grid_sizer_1.Add(self.text_ctrl_instructions, 0, wxEXPAND, 0) 76 grid_sizer_1.AddGrowableRow(3) 77 grid_sizer_1.AddGrowableRow(4) 78 grid_sizer_1.AddGrowableCol(1) 79 sizer_1.Add(grid_sizer_1, 1, wxEXPAND, 0) 80 sizer_1.Add(self.button_OK, 0, wxALIGN_CENTER_HORIZONTAL, 0) 81 self.SetAutoLayout(1) 82 self.SetSizer(sizer_1) 83 sizer_1.Fit(self) 84 sizer_1.SetSizeHints(self)
85 # end wxGlade 86 87 # end of class RequestsPanel 88 89 90 91
92 -class cActiveRequestsPanel (RequestsPanel):
93 """ 94 A descendant of the autogenerated class to add activity 95 """
96 - def __init__ (self, parent, id):
97 RequestsPanel.__init__ (self, parent, id) 98 self.wheel_type.matcher = gmForms.FormTypeMP() 99 self.wheel_form.matcher = gmForms.FormMP() 100 wx.EVT_BUTTON (self.button_OK, self.button_OK.GetId (), self._ok_pressed)
101
102 - def _ok_pressed (self, event):
103 form_id = self.wheel_form.getData () 104 print "Form id: %s" % form_id 105 type_id = self.wheel_type.getData () 106 print "Type : %s" % type_id 107 if form_id and type_id: 108 try: 109 form = gmForms.get_form (form_id) 110 params = {} 111 params['type'] = self.wheel_type.GetValue () 112 params['request'] = self.text_ctrl_request.GetValue () 113 params['clinical_notes'] = self.text_ctrl_clinical.GetValue () 114 params['instructions'] = self.text_ctrl_instructions.GetValue () 115 form.store (params) 116 form.process (params) 117 form.printout () 118 except gmForms.FormError, e: 119 gmGuiHelpers.gm_show_error (str(e), _("Error processing form")) 120 except: 121 gmLog.gmDefLog.LogException( "forms printing", sys.exc_info(), verbose=0) 122 else: 123 gmGuiHelpers.gm_show_error (_("You must select a form and type"), _("Missing field"))
124 125
126 -class gmRequest (gmPlugin.cNotebookPluginOld):
127 128 tab_name = _("Request") 129
130 - def name (self):
131 return gmRequest.tab_name
132
133 - def MenuInfo (self):
134 return ("view", _("&Request"))
135
136 - def GetWidget (self, parent):
137 return cActiveRequestsPanel (parent, -1)
138
139 - def can_receive_focus(self):
140 # need patient 141 if not self._verify_patient_avail(): 142 return None 143 return 1
144