1
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
33
34 import wx
35
38
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
56
60
61
63
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
86
87
88
89
90
91
93 """
94 A descendant of the autogenerated class to add activity
95 """
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
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
132
134 return ("view", _("&Request"))
135
138
140
141 if not self._verify_patient_avail():
142 return None
143 return 1
144