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