1
2
3
4 import sys
5 sys.exit()
6
7 import wx
8 from Gnumed.pycommon import gmDispatcher
9 from Gnumed.business import gmPerson, gmVaccination
10
11
12
14 if not nonzero:
15 return
16 t.Expand(root)
17 c, cookie = t.GetFirstChild(root)
18
19
20 while c.IsOk():
21 t.Expand(c)
22 if t.GetChildrenCount(c) > 0:
23 expand_tree(t, c, nonzero -1 )
24 c, cookie = t.GetNextChild(root, cookie)
25
27 orig_d = d
28 if not d:
29 return ' none'
30 unit= ' days'
31
32 if abs(d - int(d) ) < 0.001:
33 d = int(d)
34
35 if d < 0.5 :
36 d *= 24
37 d = int(d)
38 unit=' hours'
39
40 elif d > 29:
41 unit = ' months'
42 d /= 30
43
44 if d <> int (d/10) * 10:
45 d = int( d* 10) / 10
46
47 if d > 23 :
48 unit = ' years'
49 d = orig_d / 365
50
51 if d <> int (d/10) * 10:
52 d = int ( d * 10) / 10
53
54 return str(d) + unit
55
56
59
60 kwds["style"] = wx.TAB_TRAVERSAL
61 wx.Panel.__init__(self, *args, **kwds)
62 self.notebook_1 = wx.Notebook(self, -1, style=0)
63 self.notebook_1_pane_2 = wx.Panel(self.notebook_1, -1)
64 self.window_1 = wx.SplitterWindow(self.notebook_1_pane_2, -1, style=wx.SP_3D|wx.SP_BORDER)
65 self.window_1_pane_2 = wx.Panel(self.window_1, -1)
66 self.window_1_pane_1 = wx.Panel(self.window_1, -1)
67 self.notebook_1_pane_1 = wx.Panel(self.notebook_1, -1)
68 self.window_2 = wx.SplitterWindow(self.notebook_1_pane_1, -1, style=wx.SP_3D|wx.SP_BORDER|wx.CLIP_CHILDREN)
69 self.window_3 = wx.SplitterWindow(self.window_2, -1, style=wx.CLIP_CHILDREN)
70 self.window_3_pane_2 = wx.Panel(self.window_3, -1)
71 self.window_3_pane_1 = wx.Panel(self.window_3, -1)
72 self.window_2_pane_1 = wx.Panel(self.window_2, -1)
73 self.sizer_20_staticbox = wx.StaticBox(self.window_3_pane_1, -1, "vaccs scheduled")
74 self.sizer_18_staticbox = wx.StaticBox(self.window_1_pane_1, -1, "Vacc Regimes - X selected , O - not selected")
75 self.sizer_19_staticbox = wx.StaticBox(self.window_1_pane_2, -1, "vaccinations in selected regimes")
76 self.sizer_21_staticbox = wx.StaticBox(self.window_2_pane_1, -1, "Vacc Given")
77 self.list_ctrl_1 = wx.ListCtrl(self.window_2_pane_1, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
78 self.tree_ctrl_2 = wx.TreeCtrl(self.window_3_pane_1, -1, style=wx.TR_HAS_BUTTONS|wx.TR_NO_LINES|wx.TR_HIDE_ROOT|wx.TR_DEFAULT_STYLE|wx.SUNKEN_BORDER)
79 self.label_2 = wx.StaticText(self.window_3_pane_1, -1, "vaccinations given")
80 self.list_box_1 = wx.ListBox(self.window_3_pane_1, -1, choices=[])
81 self.label_3 = wx.StaticText(self.window_3_pane_2, -1, "date")
82 self.combo_box_1 = wx.ComboBox(self.window_3_pane_2, -1, choices=[], style=wx.CB_DROPDOWN)
83 self.checkbox_1 = wx.CheckBox(self.window_3_pane_2, -1, "mark schedule\nupto current age")
84 self.label_9 = wx.StaticText(self.window_3_pane_2, -1, "narrative")
85 self.text_ctrl_1 = wx.TextCtrl(self.window_3_pane_2, -1, "", style=wx.TE_MULTILINE)
86 self.label_4 = wx.StaticText(self.window_3_pane_2, -1, "vacc")
87 self.checkbox_dtpa = wx.CheckBox(self.window_3_pane_2, -1, "DTPa")
88 self.checkbox_2_ipv = wx.CheckBox(self.window_3_pane_2, -1, "IPV")
89 self.checkbox_paed_hepb = wx.CheckBox(self.window_3_pane_2, -1, "paed HepB")
90 self.checkbox_hib = wx.CheckBox(self.window_3_pane_2, -1, "HIB")
91 self.checkbox_7pneumo = wx.CheckBox(self.window_3_pane_2, -1, "7VPneumo")
92 self.checkbox_varicella = wx.CheckBox(self.window_3_pane_2, -1, "varicella")
93 self.checkbox_mmr = wx.CheckBox(self.window_3_pane_2, -1, "MMR")
94 self.checkbox_mening_c = wx.CheckBox(self.window_3_pane_2, -1, "mening-C")
95 self.checkbox_tick_enceph = wx.CheckBox(self.window_3_pane_2, -1, "tick-borne encephalitis")
96 self.static_line_1 = wx.StaticLine(self.window_3_pane_2, -1)
97 self.checkbox_opv = wx.CheckBox(self.window_3_pane_2, -1, "OPV")
98 self.label_8 = wx.StaticText(self.window_3_pane_2, -1, " not listed", style=wx.ALIGN_RIGHT)
99 self.combo_box_3 = wx.ComboBox(self.window_3_pane_2, -1, choices=[], style=wx.CB_DROPDOWN)
100 self.checkbox_Dtpa = wx.CheckBox(self.window_3_pane_2, -1, "Dtpa( less antigen, >3prev)")
101 self.checkbox_ADT = wx.CheckBox(self.window_3_pane_2, -1, "ADT")
102 self.checkbox_tettox = wx.CheckBox(self.window_3_pane_2, -1, "Tet Tox")
103 self.static_line_2 = wx.StaticLine(self.window_3_pane_2, -1)
104 self.checkbox_23vpneum = wx.CheckBox(self.window_3_pane_2, -1, "23VPneum")
105 self.checkbox_influenza = wx.CheckBox(self.window_3_pane_2, -1, "influenza")
106 self.static_line_3 = wx.StaticLine(self.window_3_pane_2, -1)
107 self.checkbox_paed_hepa = wx.CheckBox(self.window_3_pane_2, -1, "paed HepA")
108 self.checkbox_adult_hepa = wx.CheckBox(self.window_3_pane_2, -1, "adult HepA")
109 self.checkbox_adult_hepb = wx.CheckBox(self.window_3_pane_2, -1, "adult HepB")
110 self.checkbox_typhoid = wx.CheckBox(self.window_3_pane_2, -1, "typhoid")
111 self.checkbox_mening_acwy = wx.CheckBox(self.window_3_pane_2, -1, "mening-ACWY")
112 self.checkbox_yellow_fever = wx.CheckBox(self.window_3_pane_2, -1, "yellow fever")
113 self.checkbox_cholera = wx.CheckBox(self.window_3_pane_2, -1, "cholera")
114 self.static_line_4 = wx.StaticLine(self.window_3_pane_2, -1)
115 self.checkbox_rabies = wx.CheckBox(self.window_3_pane_2, -1, "rabies")
116 self.checkbox_japan_enceph = wx.CheckBox(self.window_3_pane_2, -1, "Japanese Enceph")
117 self.checkbox_qfever = wx.CheckBox(self.window_3_pane_2, -1, "Q Fever")
118 self.label_5 = wx.StaticText(self.window_3_pane_2, -1, "batch no")
119 self.combo_box_2 = wx.ComboBox(self.window_3_pane_2, -1, choices=[], style=wx.CB_DROPDOWN)
120 self.checkbox_18 = wx.CheckBox(self.window_3_pane_2, -1, "save batch no")
121 self.button_2 = wx.Button(self.window_3_pane_2, -1, "delete this no")
122 self.label_6 = wx.StaticText(self.window_3_pane_2, -1, "site")
123 self.radio_box_side = wx.RadioBox(self.window_3_pane_2, -1, "side", choices=["left", "right"], majorDimension=0, style=wx.RA_SPECIFY_COLS)
124 self.radio_box_site = wx.RadioBox(self.window_3_pane_2, -1, "site", choices=["thigh", "deltoid", "gluteal"], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
125 self.radio_box_route = wx.RadioBox(self.window_3_pane_2, -1, "route", choices=["im", "sc", "po"], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
126 self.button_1 = wx.Button(self.window_3_pane_2, -1, "add vaccination /\nnarrative / override", style=wx.BU_RIGHT)
127 self.tree_ctrl_1 = wx.TreeCtrl(self.window_1_pane_1, -1, style=wx.TR_HAS_BUTTONS|wx.TR_NO_LINES|wx.TR_HIDE_ROOT|wx.TR_DEFAULT_STYLE|wx.SUNKEN_BORDER)
128 self.list_ctrl_2 = wx.ListCtrl(self.window_1_pane_2, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
129
130 self.__set_properties()
131 self.__do_layout()
132
133 self.Bind(wx.EVT_LIST_DELETE_ITEM, self.delete_vacc_history_item, self.list_ctrl_1)
134 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.vacc_history_item_activated, self.list_ctrl_1)
135 self.Bind(wx.EVT_LISTBOX_DCLICK, self.double_clicked_vaccination_given, self.list_box_1)
136 self.Bind(wx.EVT_TEXT, self.date_being_entered, self.combo_box_1)
137 self.Bind(wx.EVT_COMBOBOX, self.select_combo_date, self.combo_box_1)
138 self.Bind(wx.EVT_TEXT, self.narrative_text, self.text_ctrl_1)
139 self.Bind(wx.EVT_CHECKBOX, self.combo_with_hep_b_selected, self.checkbox_hib)
140 self.Bind(wx.EVT_TEXT, self.unlisted_text_changed, self.combo_box_3)
141 self.Bind(wx.EVT_COMBOBOX, self.unlisted_combo_selected, self.combo_box_3)
142 self.Bind(wx.EVT_TEXT, self.check_for_similiar_batchno, self.combo_box_2)
143 self.Bind(wx.EVT_COMBOBOX, self.get_batchno_for_vacc, self.combo_box_2)
144 self.Bind(wx.EVT_BUTTON, self.delete_this_batchno, self.button_2)
145 self.Bind(wx.EVT_BUTTON, self.add_vaccination, self.button_1)
146 self.Bind(wx.EVT_TREE_DELETE_ITEM, self.deleting_node, self.tree_ctrl_1)
147 self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.activating_node, self.tree_ctrl_1)
148
149
150
151 gmDispatcher.connect(signal = u'post_patient_selection', receiver=self._on_post_patient_selection)
152
153
155
156 self.list_box_1.SetMinSize((145, 63))
157 self.combo_box_1.SetSelection(-1)
158 self.checkbox_1.SetFont(wx.Font(6, wx.MODERN, wx.NORMAL, wx.LIGHT, 0, ""))
159 self.combo_box_3.SetSelection(-1)
160 self.combo_box_2.SetSelection(-1)
161 self.radio_box_side.SetSelection(0)
162 self.radio_box_site.SetSelection(0)
163 self.radio_box_route.SetSelection(0)
164
165
167
168 sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
169 sizer_17 = wx.BoxSizer(wx.HORIZONTAL)
170 sizer_19 = wx.StaticBoxSizer(self.sizer_19_staticbox, wx.HORIZONTAL)
171 sizer_18 = wx.StaticBoxSizer(self.sizer_18_staticbox, wx.HORIZONTAL)
172 sizer_14 = wx.BoxSizer(wx.HORIZONTAL)
173 sizer_25 = wx.BoxSizer(wx.HORIZONTAL)
174 grid_sizer_1 = wx.FlexGridSizer(6, 2, 0, 0)
175 sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
176 sizer_11 = wx.BoxSizer(wx.HORIZONTAL)
177 sizer_5 = wx.BoxSizer(wx.VERTICAL)
178 sizer_13 = wx.BoxSizer(wx.HORIZONTAL)
179 sizer_12 = wx.BoxSizer(wx.HORIZONTAL)
180 sizer_10 = wx.BoxSizer(wx.HORIZONTAL)
181 sizer_9 = wx.BoxSizer(wx.HORIZONTAL)
182 sizer_8 = wx.BoxSizer(wx.HORIZONTAL)
183 sizer_15 = wx.BoxSizer(wx.HORIZONTAL)
184 sizer_7 = wx.BoxSizer(wx.HORIZONTAL)
185 sizer_6 = wx.BoxSizer(wx.HORIZONTAL)
186 sizer_16 = wx.BoxSizer(wx.HORIZONTAL)
187 sizer_2 = wx.BoxSizer(wx.VERTICAL)
188 sizer_22 = wx.BoxSizer(wx.VERTICAL)
189 sizer_24 = wx.BoxSizer(wx.HORIZONTAL)
190 sizer_3 = wx.BoxSizer(wx.VERTICAL)
191 sizer_20 = wx.StaticBoxSizer(self.sizer_20_staticbox, wx.HORIZONTAL)
192 sizer_21 = wx.StaticBoxSizer(self.sizer_21_staticbox, wx.HORIZONTAL)
193 sizer_21.Add(self.list_ctrl_1, 1, wx.EXPAND, 0)
194 self.window_2_pane_1.SetAutoLayout(True)
195 self.window_2_pane_1.SetSizer(sizer_21)
196 sizer_21.Fit(self.window_2_pane_1)
197 sizer_21.SetSizeHints(self.window_2_pane_1)
198 sizer_20.Add(self.tree_ctrl_2, 1, wx.EXPAND, 0)
199 sizer_3.Add(sizer_20, 1, wx.EXPAND, 0)
200 sizer_3.Add(self.label_2, 0, wx.ADJUST_MINSIZE, 0)
201 sizer_3.Add(self.list_box_1, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
202 sizer_24.Add(sizer_3, 1, wx.EXPAND, 0)
203 self.window_3_pane_1.SetAutoLayout(True)
204 self.window_3_pane_1.SetSizer(sizer_24)
205 sizer_24.Fit(self.window_3_pane_1)
206 sizer_24.SetSizeHints(self.window_3_pane_1)
207 grid_sizer_1.Add(self.label_3, 0, wx.ADJUST_MINSIZE, 0)
208 sizer_22.Add(self.combo_box_1, 0, wx.ADJUST_MINSIZE, 0)
209 sizer_22.Add(self.checkbox_1, 0, wx.ALL|wx.ADJUST_MINSIZE, 5)
210 sizer_2.Add(sizer_22, 0, wx.EXPAND, 0)
211 sizer_16.Add(sizer_2, 0, wx.EXPAND, 0)
212 sizer_16.Add(self.label_9, 0, wx.ADJUST_MINSIZE, 0)
213 sizer_16.Add(self.text_ctrl_1, 1, wx.ADJUST_MINSIZE, 0)
214 grid_sizer_1.Add(sizer_16, 0, wx.EXPAND, 0)
215 grid_sizer_1.Add(self.label_4, 0, wx.ADJUST_MINSIZE, 0)
216 sizer_6.Add(self.checkbox_dtpa, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 19)
217 sizer_6.Add(self.checkbox_2_ipv, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 26)
218 sizer_6.Add(self.checkbox_paed_hepb, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 20)
219 sizer_6.Add(self.checkbox_hib, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 12)
220 sizer_6.Add(self.checkbox_7pneumo, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 12)
221 sizer_5.Add(sizer_6, 0, wx.ALL|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
222 sizer_7.Add(self.checkbox_varicella, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 17)
223 sizer_7.Add(self.checkbox_mmr, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 16)
224 sizer_7.Add(self.checkbox_mening_c, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 16)
225 sizer_7.Add(self.checkbox_tick_enceph, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 16)
226 sizer_5.Add(sizer_7, 0, wx.EXPAND, 0)
227 sizer_5.Add(self.static_line_1, 0, wx.EXPAND, 0)
228 sizer_15.Add(self.checkbox_opv, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 23)
229 sizer_15.Add(self.label_8, 0, wx.ALIGN_RIGHT|wx.ADJUST_MINSIZE, 0)
230 sizer_15.Add(self.combo_box_3, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
231 sizer_5.Add(sizer_15, 0, wx.EXPAND, 0)
232 sizer_8.Add(self.checkbox_Dtpa, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 20)
233 sizer_8.Add(self.checkbox_ADT, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 14)
234 sizer_8.Add(self.checkbox_tettox, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 14)
235 sizer_5.Add(sizer_8, 0, wx.EXPAND, 0)
236 sizer_5.Add(self.static_line_2, 0, wx.EXPAND, 0)
237 sizer_9.Add(self.checkbox_23vpneum, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 12)
238 sizer_9.Add(self.checkbox_influenza, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 20)
239 sizer_5.Add(sizer_9, 0, wx.EXPAND, 0)
240 sizer_5.Add(self.static_line_3, 0, wx.EXPAND, 0)
241 sizer_10.Add(self.checkbox_paed_hepa, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 20)
242 sizer_10.Add(self.checkbox_adult_hepa, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 18)
243 sizer_10.Add(self.checkbox_adult_hepb, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 20)
244 sizer_5.Add(sizer_10, 0, wx.EXPAND, 0)
245 sizer_12.Add(self.checkbox_typhoid, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 26)
246 sizer_12.Add(self.checkbox_mening_acwy, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 20)
247 sizer_12.Add(self.checkbox_yellow_fever, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 20)
248 sizer_12.Add(self.checkbox_cholera, 0, wx.ADJUST_MINSIZE, 20)
249 sizer_5.Add(sizer_12, 0, wx.EXPAND, 0)
250 sizer_5.Add(self.static_line_4, 0, wx.EXPAND, 0)
251 sizer_13.Add(self.checkbox_rabies, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 23)
252 sizer_13.Add(self.checkbox_japan_enceph, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 15)
253 sizer_13.Add(self.checkbox_qfever, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 18)
254 sizer_5.Add(sizer_13, 0, wx.EXPAND, 0)
255 grid_sizer_1.Add(sizer_5, 0, wx.EXPAND, 0)
256 grid_sizer_1.Add(self.label_5, 0, wx.ADJUST_MINSIZE, 0)
257 sizer_11.Add(self.combo_box_2, 1, wx.ADJUST_MINSIZE, 0)
258 sizer_11.Add(self.checkbox_18, 0, wx.ADJUST_MINSIZE, 0)
259 sizer_11.Add(self.button_2, 0, wx.ADJUST_MINSIZE, 0)
260 grid_sizer_1.Add(sizer_11, 0, wx.EXPAND, 0)
261 grid_sizer_1.Add(self.label_6, 0, wx.ADJUST_MINSIZE, 0)
262 sizer_4.Add(self.radio_box_side, 0, wx.ADJUST_MINSIZE, 0)
263 sizer_4.Add(self.radio_box_site, 0, wx.ADJUST_MINSIZE, 0)
264 sizer_4.Add(self.radio_box_route, 0, wx.ADJUST_MINSIZE, 0)
265 sizer_4.Add(self.button_1, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE|wx.FIXED_MINSIZE, 0)
266 grid_sizer_1.Add(sizer_4, 0, wx.EXPAND, 0)
267 grid_sizer_1.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0)
268 sizer_25.Add(grid_sizer_1, 0, wx.EXPAND, 0)
269 self.window_3_pane_2.SetAutoLayout(True)
270 self.window_3_pane_2.SetSizer(sizer_25)
271 sizer_25.Fit(self.window_3_pane_2)
272 sizer_25.SetSizeHints(self.window_3_pane_2)
273 self.window_3.SplitVertically(self.window_3_pane_1, self.window_3_pane_2)
274 self.window_2.SplitHorizontally(self.window_2_pane_1, self.window_3, 10)
275 sizer_14.Add(self.window_2, 1, wx.EXPAND, 0)
276 self.notebook_1_pane_1.SetAutoLayout(True)
277 self.notebook_1_pane_1.SetSizer(sizer_14)
278 sizer_14.Fit(self.notebook_1_pane_1)
279 sizer_14.SetSizeHints(self.notebook_1_pane_1)
280 sizer_18.Add(self.tree_ctrl_1, 1, wx.EXPAND, 0)
281 self.window_1_pane_1.SetAutoLayout(True)
282 self.window_1_pane_1.SetSizer(sizer_18)
283 sizer_18.Fit(self.window_1_pane_1)
284 sizer_18.SetSizeHints(self.window_1_pane_1)
285 sizer_19.Add(self.list_ctrl_2, 1, wx.EXPAND, 0)
286 self.window_1_pane_2.SetAutoLayout(True)
287 self.window_1_pane_2.SetSizer(sizer_19)
288 sizer_19.Fit(self.window_1_pane_2)
289 sizer_19.SetSizeHints(self.window_1_pane_2)
290 self.window_1.SplitHorizontally(self.window_1_pane_1, self.window_1_pane_2)
291 sizer_17.Add(self.window_1, 1, wx.EXPAND, 0)
292 self.notebook_1_pane_2.SetAutoLayout(True)
293 self.notebook_1_pane_2.SetSizer(sizer_17)
294 sizer_17.Fit(self.notebook_1_pane_2)
295 sizer_17.SetSizeHints(self.notebook_1_pane_2)
296 self.notebook_1.AddPage(self.notebook_1_pane_1, "vaccinations")
297 self.notebook_1.AddPage(self.notebook_1_pane_2, "enrolled vaccinations")
298 sizer_1.Add(self.notebook_1, 1, wx.EXPAND, 0)
299 self.SetAutoLayout(True)
300 self.SetSizer(sizer_1)
301 sizer_1.Fit(self)
302 sizer_1.SetSizeHints(self)
303
304
306 print "Event handler `delete_vacc_history_item' not implemented"
307 event.Skip()
308
310 print "Event handler `vacc_history_item_activated' not implemented"
311 event.Skip()
312
314 print "Event handler `recommended_vacc_given' not implemented"
315 event.Skip()
316
318 print "Event handler `recommended_vacc_selected' not implemented"
319 event.Skip()
320
322 print "Event handler `double_clicked_vaccination_given' not implemented"
323 event.Skip()
324
326 print "Event handler `date_being_entered' not implemented"
327 event.Skip()
328
330 print "Event handler `select_combo_date' not implemented"
331 event.Skip()
332
334 print "Event handler `combo_with_hep_b_selected' not implemented"
335 event.Skip()
336
337 - def unlisted_text_changed(self, event):
338 print "Event handler `unlisted_text_changed' not implemented"
339 event.Skip()
340
342 print "Event handler `unlisted_combo_selected' not implemented"
343 event.Skip()
344
346 print "Event handler `check_for_similiar_batchno' not implemented"
347 event.Skip()
348
350 print "Event handler `get_batchno_for_vacc' not implemented"
351 event.Skip()
352
354 print "Event handler `delete_this_batchno' not implemented"
355 event.Skip()
356
358 print "Event handler `add_vaccination' not implemented"
359 event.Skip()
360 l = [ self.checkbox_dtpa.GetValue(),
361 self.checkbox_2_ipv .GetValue(),
362 self.checkbox_paed_hepb.GetValue(),
363 self.checkbox_hib.GetValue(),
364 self.checkbox_7pneumo .GetValue(),
365 self.checkbox_varicella.GetValue(),
366 self.checkbox_mmr .GetValue(),
367 self.checkbox_mening_c .GetValue(),
368 self.checkbox_tick_enceph .GetValue(),
369 self.checkbox_opv .GetValue(),
370 self.checkbox_Dtpa.GetValue(),
371 self.checkbox_ADT.GetValue(),
372 self.checkbox_tettox.GetValue(),
373 self.checkbox_23vpneum.GetValue(),
374 self.checkbox_influenza .GetValue(),
375 self.checkbox_paed_hepa.GetValue(),
376 self.checkbox_adult_hepa.GetValue(),
377 self.checkbox_adult_hepb.GetValue(),
378 self.checkbox_typhoid.GetValue(),
379 self.checkbox_mening_acwy.GetValue(),
380 self.checkbox_yellow_fever.GetValue(),
381 self.checkbox_cholera.GetValue(),
382 self.checkbox_rabies.GetValue(),
383 self.checkbox_japan_enceph.GetValue(),
384 self.checkbox_qfever.GetValue()
385
386 ]
387 [dtp , ipv, phb ,hib, p7, var, mmr, mc, tick, opv, dTpa, adt, tt, p23, flu, pha, aha, ahb, ty, acwy, yf, chol, rab, jap, qf ] = l
388
389
390
391
392
393 to_ind = zip ( [ ('diph','tet', 'pert'),('polio',), ( 'hepatitis B',), ('haemophilus',), ('pneum',), ('varicella',), ( 'measles','mumps', 'rubella'), ('meningococcus C',), ('tick',), ('polio',), ('diph', 'tet', 'pert'), ('diph','tet'), ('tet',), ('pneum',), ('influ',), ('hepatitis A',), ('hepatitis A',), ('hepatitis B',), ('typhoid',), ('meningococcus ACWY',), ('yellow fever',), ('cholera',), ('rabies',), ('japanese enc',), ('Q fever',) ], l )
394 for i , c in to_ind:
395 print "DEBUG to_ind ", i, c
396 def get_unique_indications ( indset_chosen_list):
397 """indset_chosen_list is a list of 2-tuples,
398 the 2-tuple is a tuple of indications, and a boolean value 'chosen'
399
400 returns matching vaccines that have all the indications chosen
401
402 usage: a tuple of indications can represent a combo vaccine's set of indications.
403 """
404 all_ind = []
405 for ind, chosen in to_ind:
406 if chosen:
407 for x in ind:
408 if x not in all_ind:
409 all_ind.append(x)
410 return all_ind
411 all_ind = get_unique_indications ( to_ind)
412
413
414 vaccines = gmVaccination.get_matching_vaccines_for_indications(all_ind)
415
416 nchecked = len( [ x for x in l if x] )
417
418
419 class NoVaccChosen ( Exception):
420 pass
421 class IllegalCombo (Exception):
422 pass
423
424 def _or(x, y):
425 return x or y
426
427 try:
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460 if not nchecked:
461 raise NoVaccChosen, _("No vaccines were chosen")
462 if not len(vaccines):
463 raise IllegalCombo, _("Combination of indications , %s , not found in any vaccine" % ', '.join ( all_ind) )
464 except NoVaccChosen, s:
465 wx.MessageDialog( self, str(s), style = wx.OK).ShowModal()
466 return
467
468 except IllegalCombo , s:
469 wx.MessageDialog( self, str(s), style = wx.OK).ShowModal()
470 return
471
472 wx.MessageDialog( self,"Accepted add", style = wx.OK).ShowModal()
473
474
476
477 self._populate_vaccination_history_list()
478 self._populate_vacc_regime_tree()
479 self._populate_missing_vaccinations()
480
482
483 print self, "got on patient selected"
484 p = gmPerson.gmCurrentPatient()
485 emr = p.get_emr()
486 vv = emr.get_vaccinations()
487 l = self.list_ctrl_1
488 l.ClearAll()
489 cols = [ _('Date'), _('Vaccine'), _('Sequence'), _('Batch'), _('Site'), _('Narrative'), _('Vaccinator') ]
490 for c, i in zip(cols, range(len(cols)) ):
491 l.InsertColumn( i, c)
492
493 fields = [ 'date', 'vaccine', 'seq_no', 'batch_no', 'site', 'narrative', 'pk_provider' ]
494 for v, i in zip( vv, range(len(vv))):
495 for f, j in zip(fields,range(len(fields)) ):
496 if j == 0:
497 l.InsertStringItem( i, str(v[f]))
498 else:
499 l.SetStringItem(i, j, str(v[f]) )
500
501 for i in range(len(cols)):
502 l.SetColumnWidth( i, wx.LIST_AUTOSIZE)
503 w1 = l.GetColumnWidth(i)
504 l.SetColumnWidth( i, wx.LIST_AUTOSIZE_USEHEADER)
505 w2 = l.GetColumnWidth(i)
506 if w1 > w2:
507 l.SetColumnWidth(i, w1)
508
509
510
511
512
514 s = '#'+str(v['seq_no'])+ ' : ' + v['regime']
515 s += '; min age due = ' + stringify_days( v['min_age_due'])
516
517 s += ' ; min interval: ' + stringify_days(v['min_interval'])
518
519 if v['min_age_due'] <> last_min_age:
520
521 age_node = t.AppendItem( rec_node, 'Minimum age due : ' + stringify_days(v['min_age_due']) )
522 last_min_age = v['min_age_due']
523
524
525 def_node = t.AppendItem( age_node, s, data = wx.TreeItemData( v) )
526 return t, v, age_node, last_min_age, def_node
527
529
530 p = gmPerson.gmCurrentPatient()
531 self._vreg, self._active_recs = gmVaccination.get_vacc_regimes_by_recommender_ordered( int ( p.ID ) )
532 vreg = self._vreg
533 t = self.tree_ctrl_1
534 t.DeleteAllItems()
535 root = t.AddRoot( _('Vaccinations by Recommender (X = patient on regime, O = patient not on regime) ') )
536
537 self._rec_nodes = []
538 for recommender in vreg[1]:
539
540
541 rec_node = t.AppendItem( root, str(recommender) , data = wx.TreeItemData(recommender) )
542 self._rec_nodes .append(rec_node)
543
544 last_min_age = -1
545 age_node = None
546
547 on_rec = False
548
549 for v in vreg[0][recommender]:
550 t, v, age_node, last_min_age, def_node = self._update_age_ordered_vacc_tree( t, v, rec_node, age_node, last_min_age)
551
552 if int(v['pk_regime']) in self._active_recs:
553
554 marker = ' - x'
555 colour = wx.GREEN
556 else:
557 marker = ' - O'
558 colour = wx.RED
559
560 t.SetItemText( def_node, t.GetItemText(def_node) + marker)
561 t.SetItemTextColour( def_node, colour)
562 expand_tree(t, root , 2)
563
565 t = self.tree_ctrl_2
566 t.DeleteAllItems()
567 p = gmPerson.gmCurrentPatient()
568 emr = p.get_emr()
569 mv = gmVaccination.get_missing_vaccinations_ordered_min_due( p.ID )
570 lmv = [ dict( [ (field, v[i] ) for field, i in zip(
571 ['indication', 'regime',
572 'pk_regime',
573 'pk_recommended_by',
574 'seq_no' ,
575 'min_age_due',
576 'max_age_due',
577 'min_interval' ] , range( len(v) ) ) ] ) for v in mv ]
578
579 age_node, last_min_age = None, -1
580 root = t.AddRoot(_('enrolled regime vaccinations not yet given') )
581 for v in lmv:
582 t, v, age_node, last_min_age, def_node = self._update_age_ordered_vacc_tree( t, v, root, age_node, last_min_age)
583 expand_tree(t, root, 2)
584
585 print "DEBUG missing vaccs len=", len(mv)
586
587
588
589
590
591 - def narrative_text(self, event):
592 print "Event handler `narrative_text' not implemented"
593 event.Skip()
594
596 print "Event handler `deleting_node' not implemented"
597 event.Skip()
598
600 print "Event handler `activating_node' not implemented"
601 n = event.GetItem()
602
603 event.Skip(1)
604 t = self.tree_ctrl_1
605
606
607
608 if n in self._rec_nodes:
609 recommender = t.GetItemData( n).GetData()
610 active = True
611 for v in self._vreg[0][recommender]:
612 if not v['pk_regime'] in self._active_recs:
613 active = False
614 break
615
616 if active:
617 msg = " unenrolling in the selected recommenders' regimes ( will fail if any vaccinations linked to regime)"
618 else:
619 msg = "enroll in regime of recommender " + str( recommender)
620
621 answ = wx.MessageDialog(self, _("Proceed with " + msg + "?")).ShowModal()
622 failures = []
623 success = []
624
625
626 if answ == wx.ID_OK and not active:
627 for v in self._vreg[0][recommender]:
628 result = False
629 id = gmPerson.gmCurrentPatient().ID
630 if v['pk_regime'] in success:
631 continue
632 if id:
633 result,msg = gmVaccination.put_patient_on_schedule(id, v['pk_regime'])
634 if not result:
635 failures.append(v)
636 else:
637 success.append(v['pk_regime'])
638 if len(failures):
639 wx.MessageDialog(self, _("Failed to enrol patient in %s") % ', '.join( [ f['regime'] for f in failures] ) , style = wx.OK ).ShowModal()
640
641 if answ == wx.ID_OK and active:
642 for v in self._vreg[0][recommender]:
643 result = False
644 id = gmPerson.gmCurrentPatient().ID
645 if v['pk_regime'] in success:
646 continue
647 if id:
648 result,msg = gmVaccination.remove_patient_from_schedule(id, v['pk_regime'])
649 if not result:
650 failures.append(v)
651 else:
652 success.append(v['pk_regime'])
653 if len(failures):
654 wx.MessageDialog(self, _("Failed to delist patient from %s") % ', '.join( [ f['regime'] for f in failures] ) , style = wx.OK ).ShowModal()
655
656 self._on_post_patient_selection()
657
658
659