Package Gnumed :: Package wxpython :: Module gmEditArea
[frames] | no frames]

Source Code for Module Gnumed.wxpython.gmEditArea

   1  #==================================================================== 
   2  # GNUmed Richard style Edit Area 
   3  #==================================================================== 
   4  # $Source: /cvsroot/gnumed/gnumed/gnumed/client/wxpython/gmEditArea.py,v $ 
   5  # $Id: gmEditArea.py,v 1.134 2009/12/21 15:05:53 ncq Exp $ 
   6  __license__ = 'GPL' 
   7  __version__ = "$Revision: 1.134 $" 
   8  __author__ = "R.Terry, K.Hilbert" 
   9   
  10  #====================================================================== 
  11  import logging 
  12   
  13   
  14  import wx 
  15   
  16   
  17  from Gnumed.pycommon import gmDispatcher, gmExceptions 
  18  from Gnumed.wxGladeWidgets import wxgGenericEditAreaDlg, wxgGenericEditAreaDlg2 
  19   
  20   
  21  _log = logging.getLogger('gm.ui') 
  22  _log.info(__version__) 
  23  #==================================================================== 
  24  edit_area_modes = ['new', 'edit', 'new_from_existing'] 
  25   
26 -class cGenericEditAreaMixin(object):
27 """Mixin for edit area panels providing generic functionality. 28 29 #==================================================================== 30 # Class definition: 31 32 from Gnumed.wxGladeWidgets import wxgXxxEAPnl 33 34 class cXxxEAPnl(wxgXxxEAPnl.wxgXxxEAPnl, gmEditArea.cGenericEditAreaMixin): 35 36 def __init__(self, *args, **kwargs): 37 38 try: 39 data = kwargs['xxx'] 40 del kwargs['xxx'] 41 except KeyError: 42 data = None 43 44 wxgXxxEAPnl.wxgXxxPatientEAPnl.__init__(self, *args, **kwargs) 45 gmEditArea.cGenericEditAreaMixin.__init__(self) 46 47 # Code using this mixin should set mode and data 48 # after instantiating the class: 49 self.mode = 'new' 50 self.data = data 51 if data is not None: 52 self.mode = 'edit' 53 54 #self.__init_ui() 55 #---------------------------------------------------------------- 56 # def __init_ui(self): 57 # # adjust phrasewheels etc 58 #---------------------------------------------------------------- 59 # generic Edit Area mixin API 60 #---------------------------------------------------------------- 61 def _valid_for_save(self): 62 return False 63 return True 64 #---------------------------------------------------------------- 65 def _save_as_new(self): 66 # save the data as a new instance 67 data = 68 69 data[''] = 70 data[''] = 71 72 data.save() 73 74 # must be done very late or else the property access 75 # will refresh the display such that later field 76 # access will return empty values 77 self.data = data 78 return False 79 return True 80 #---------------------------------------------------------------- 81 def _save_as_update(self): 82 # update self.data and save the changes 83 self.data[''] = 84 self.data[''] = 85 self.data[''] = 86 self.data.save() 87 return True 88 #---------------------------------------------------------------- 89 def _refresh_as_new(self): 90 pass 91 #---------------------------------------------------------------- 92 def _refresh_from_existing(self): 93 pass 94 #---------------------------------------------------------------- 95 def _refresh_as_new_from_existing(self): 96 pass 97 #---------------------------------------------------------------- 98 99 """
100 - def __init__(self):
101 self.__mode = 'new' 102 self.__data = None 103 self.successful_save_msg = None 104 self._refresh_as_new() 105 self.__tctrl_validity_colors = { 106 True: wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW), 107 False: 'pink' 108 }
109 #----------------------------------------------------------------
110 - def _get_mode(self):
111 return self.__mode
112
113 - def _set_mode(self, mode=None):
114 if mode not in edit_area_modes: 115 raise ValueError('[%s] <mode> must be in %s' % (self.__class__.__name__, edit_area_modes)) 116 if mode == 'edit': 117 if self.__data is None: 118 raise ValueError('[%s] <mode> "edit" needs data value' % self.__class__.__name__) 119 self.__mode = mode
120 121 mode = property(_get_mode, _set_mode) 122 #----------------------------------------------------------------
123 - def _get_data(self):
124 return self.__data
125
126 - def _set_data(self, data=None):
127 if data is None: 128 if self.__mode == 'edit': 129 raise ValueError('[%s] <mode> "edit" needs data value' % self.__class__.__name__) 130 self.__data = data 131 self.refresh()
132 133 data = property(_get_data, _set_data) 134 #----------------------------------------------------------------
135 - def save(self):
136 """Invoked from the generic edit area dialog. 137 138 Invokes 139 _valid_for_save, 140 _save_as_new, 141 _save_as_update 142 on the implementing edit area as needed. 143 144 _save_as_* must set self.__data and return True/False 145 """ 146 if not self._valid_for_save(): 147 return False 148 149 if self.__mode in ['new', 'new_from_existing']: 150 if self._save_as_new(): 151 self.mode = 'edit' 152 return True 153 return False 154 155 elif self.__mode == 'edit': 156 return self._save_as_update() 157 158 else: 159 raise ValueError('[%s] <mode> must be in %s' % (self.__class__.__name__, edit_area_modes))
160 #----------------------------------------------------------------
161 - def refresh(self):
162 """Invoked from the generic edit area dialog. 163 164 Invokes 165 _refresh_as_new 166 _refresh_from_existing 167 _refresh_as_new_from_existing 168 on the implementing edit area as needed. 169 """ 170 if self.__mode == 'new': 171 return self._refresh_as_new() 172 elif self.__mode == 'edit': 173 return self._refresh_from_existing() 174 elif self.__mode == 'new_from_existing': 175 return self._refresh_as_new_from_existing() 176 else: 177 raise ValueError('[%s] <mode> must be in %s' % (self.__class__.__name__, edit_area_modes))
178 #----------------------------------------------------------------
179 - def display_tctrl_as_valid(self, tctrl=None, valid=None):
180 tctrl.SetBackgroundColour(self.__tctrl_validity_colors[valid]) 181 tctrl.Refresh()
182 #====================================================================
183 -class cGenericEditAreaDlg2(wxgGenericEditAreaDlg2.wxgGenericEditAreaDlg2):
184 """Dialog for parenting edit area panels with save/clear/next/cancel""" 185
186 - def __init__(self, *args, **kwargs):
187 188 ea = kwargs['edit_area'] 189 del kwargs['edit_area'] 190 191 single_entry = False 192 try: 193 single_entry = kwargs['single_entry'] 194 del kwargs['single_entry'] 195 except KeyError: 196 pass 197 198 if not isinstance(ea, cGenericEditAreaMixin): 199 raise TypeError('[%s]: edit area instance must be child of cGenericEditAreaMixin') 200 201 wxgGenericEditAreaDlg2.wxgGenericEditAreaDlg2.__init__(self, *args, **kwargs) 202 203 # replace dummy panel 204 ea_pnl_szr = self._PNL_ea.GetContainingSizer() 205 ea_pnl_szr.Remove(self._PNL_ea) 206 ea.Reparent(self) 207 self._PNL_ea = ea 208 ea_pnl_szr.Add(self._PNL_ea, 1, wx.EXPAND, 0) 209 210 # adjust buttons 211 if single_entry: 212 self._BTN_forward.Enable(False) 213 self._BTN_forward.Hide() 214 215 self._adjust_clear_revert_buttons() 216 217 # redraw layout 218 self.Layout() 219 main_szr = self.GetSizer() 220 main_szr.Fit(self) 221 self.Refresh() 222 223 self._PNL_ea.refresh()
224 #--------------------------------------------------------
226 if self._PNL_ea.data is None: 227 self._BTN_clear.Enable(True) 228 self._BTN_clear.Show() 229 self._BTN_revert.Enable(False) 230 self._BTN_revert.Hide() 231 else: 232 self._BTN_clear.Enable(False) 233 self._BTN_clear.Hide() 234 self._BTN_revert.Enable(True) 235 self._BTN_revert.Show()
236 #--------------------------------------------------------
237 - def _on_save_button_pressed(self, evt):
238 if self._PNL_ea.save(): 239 if self.IsModal(): 240 self.EndModal(wx.ID_OK) 241 else: 242 self.Close()
243 #--------------------------------------------------------
244 - def _on_revert_button_pressed(self, evt):
245 self._PNL_ea.refresh()
246 #--------------------------------------------------------
247 - def _on_clear_button_pressed(self, evt):
248 self._PNL_ea.refresh()
249 #--------------------------------------------------------
250 - def _on_forward_button_pressed(self, evt):
251 if self._PNL_ea.save(): 252 if self._PNL_ea.successful_save_msg is not None: 253 gmDispatcher.send(signal = 'statustext', msg = self._PNL_ea.successful_save_msg) 254 self._PNL_ea.mode = 'new_from_existing' 255 256 self._adjust_clear_revert_buttons() 257 258 self.Layout() 259 main_szr = self.GetSizer() 260 main_szr.Fit(self) 261 self.Refresh() 262 263 self._PNL_ea.refresh()
264 #==================================================================== 265 # DEPRECATED:
266 -class cGenericEditAreaDlg(wxgGenericEditAreaDlg.wxgGenericEditAreaDlg):
267 """Dialog for parenting edit area with save/clear/cancel""" 268
269 - def __init__(self, *args, **kwargs):
270 271 ea = kwargs['edit_area'] 272 del kwargs['edit_area'] 273 274 wxgGenericEditAreaDlg.wxgGenericEditAreaDlg.__init__(self, *args, **kwargs) 275 276 szr = self._PNL_ea.GetContainingSizer() 277 szr.Remove(self._PNL_ea) 278 ea.Reparent(self) 279 szr.Add(ea, 1, wx.ALL|wx.EXPAND, 4) 280 self._PNL_ea = ea 281 282 self.Layout() 283 szr = self.GetSizer() 284 szr.Fit(self) 285 self.Refresh() 286 287 self._PNL_ea.refresh()
288 #--------------------------------------------------------
289 - def _on_save_button_pressed(self, evt):
290 """The edit area save() method must return True/False.""" 291 if self._PNL_ea.save(): 292 if self.IsModal(): 293 self.EndModal(wx.ID_OK) 294 else: 295 self.Close()
296 #--------------------------------------------------------
297 - def _on_clear_button_pressed(self, evt):
298 self._PNL_ea.refresh()
299 #==================================================================== 300 #==================================================================== 301 #==================================================================== 302 import time 303 304 from Gnumed.business import gmPerson, gmDemographicRecord 305 from Gnumed.pycommon import gmGuiBroker 306 from Gnumed.wxpython import gmDateTimeInput, gmPhraseWheel, gmGuiHelpers 307 308 _gb = gmGuiBroker.GuiBroker() 309 310 gmSECTION_SUMMARY = 1 311 gmSECTION_DEMOGRAPHICS = 2 312 gmSECTION_CLINICALNOTES = 3 313 gmSECTION_FAMILYHISTORY = 4 314 gmSECTION_PASTHISTORY = 5 315 gmSECTION_SCRIPT = 8 316 gmSECTION_REQUESTS = 9 317 gmSECTION_REFERRALS = 11 318 gmSECTION_RECALLS = 12 319 320 richards_blue = wx.Colour(0,0,131) 321 richards_aqua = wx.Colour(0,194,197) 322 richards_dark_gray = wx.Color(131,129,131) 323 richards_light_gray = wx.Color(255,255,255) 324 richards_coloured_gray = wx.Color(131,129,131) 325 326 327 CONTROLS_WITHOUT_LABELS =['wxTextCtrl', 'cEditAreaField', 'wx.SpinCtrl', 'gmPhraseWheel', 'wx.ComboBox'] 328
329 -def _decorate_editarea_field(widget):
330 widget.SetForegroundColour(wx.Color(255, 0, 0)) 331 widget.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False, ''))
332 #====================================================================
333 -class cEditAreaPopup(wx.Dialog):
334 - def __init__ ( 335 self, 336 parent, 337 id, 338 title = 'edit area popup', 339 pos=wx.DefaultPosition, 340 size=wx.DefaultSize, 341 style=wx.SIMPLE_BORDER, 342 name='', 343 edit_area = None 344 ):
345 if not isinstance(edit_area, cEditArea2): 346 raise gmExceptions.ConstructorError, '<edit_area> must be of type cEditArea2 but is <%s>' % type(edit_area) 347 wx.Dialog.__init__(self, parent, id, title, pos, size, style, name) 348 self.__wxID_BTN_SAVE = wx.NewId() 349 self.__wxID_BTN_RESET = wx.NewId() 350 self.__editarea = edit_area 351 self.__do_layout() 352 self.__register_events()
353 #-------------------------------------------------------- 354 # public API 355 #--------------------------------------------------------
356 - def get_summary(self):
357 return self.__editarea.get_summary()
358 #--------------------------------------------------------
359 - def __do_layout(self):
360 self.__editarea.Reparent(self) 361 362 self.__btn_SAVE = wx.Button(self, self.__wxID_BTN_SAVE, _("Save")) 363 self.__btn_SAVE.SetToolTipString(_('save entry into medical record')) 364 self.__btn_RESET = wx.Button(self, self.__wxID_BTN_RESET, _("Reset")) 365 self.__btn_RESET.SetToolTipString(_('reset entry')) 366 self.__btn_CANCEL = wx.Button(self, wx.ID_CANCEL, _("Cancel")) 367 self.__btn_CANCEL.SetToolTipString(_('discard entry and cancel')) 368 369 szr_buttons = wx.BoxSizer(wx.HORIZONTAL) 370 szr_buttons.Add(self.__btn_SAVE, 1, wx.EXPAND | wx.ALL, 1) 371 szr_buttons.Add(self.__btn_RESET, 1, wx.EXPAND | wx.ALL, 1) 372 szr_buttons.Add(self.__btn_CANCEL, 1, wx.EXPAND | wx.ALL, 1) 373 374 szr_main = wx.BoxSizer(wx.VERTICAL) 375 szr_main.Add(self.__editarea, 1, wx.EXPAND) 376 szr_main.Add(szr_buttons, 0, wx.EXPAND) 377 378 self.SetSizerAndFit(szr_main)
379 #-------------------------------------------------------- 380 # event handling 381 #--------------------------------------------------------
382 - def __register_events(self):
383 # connect standard buttons 384 wx.EVT_BUTTON(self.__btn_SAVE, self.__wxID_BTN_SAVE, self._on_SAVE_btn_pressed) 385 wx.EVT_BUTTON(self.__btn_RESET, self.__wxID_BTN_RESET, self._on_RESET_btn_pressed) 386 wx.EVT_BUTTON(self.__btn_CANCEL, wx.ID_CANCEL, self._on_CANCEL_btn_pressed) 387 388 wx.EVT_CLOSE(self, self._on_CANCEL_btn_pressed) 389 390 # client internal signals 391 # gmDispatcher.connect(signal = gmSignals.pre_patient_selection(), receiver = self._on_pre_patient_selection) 392 # gmDispatcher.connect(signal = gmSignals.application_closing(), receiver = self._on_application_closing) 393 # gmDispatcher.connect(signal = gmSignals.post_patient_selection(), receiver = self.on_post_patient_selection) 394 395 return 1
396 #--------------------------------------------------------
397 - def _on_SAVE_btn_pressed(self, evt):
398 if self.__editarea.save_data(): 399 self.__editarea.Close() 400 self.EndModal(wx.ID_OK) 401 return 402 short_err = self.__editarea.get_short_error() 403 long_err = self.__editarea.get_long_error() 404 if (short_err is None) and (long_err is None): 405 long_err = _( 406 'Unspecified error saving data in edit area.\n\n' 407 'Programmer forgot to specify proper error\n' 408 'message in [%s].' 409 ) % self.__editarea.__class__.__name__ 410 if short_err is not None: 411 gmDispatcher.send(signal = 'statustext', msg = short_err) 412 if long_err is not None: 413 gmGuiHelpers.gm_show_error(long_err, _('saving clinical data'))
414 #--------------------------------------------------------
415 - def _on_CANCEL_btn_pressed(self, evt):
416 self.__editarea.Close() 417 self.EndModal(wx.ID_CANCEL)
418 #--------------------------------------------------------
419 - def _on_RESET_btn_pressed(self, evt):
420 self.__editarea.reset_ui()
421 #====================================================================
422 -class cEditArea2(wx.Panel):
423 - def __init__(self, parent, id, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL):
424 # init main background panel 425 wx.Panel.__init__ ( 426 self, 427 parent, 428 id, 429 pos = pos, 430 size = size, 431 style = style | wx.TAB_TRAVERSAL 432 ) 433 self.SetBackgroundColour(wx.Color(222,222,222)) 434 435 self.data = None # a placeholder for opaque data 436 self.fields = {} 437 self.prompts = {} 438 self._short_error = None 439 self._long_error = None 440 self._summary = None 441 self._patient = gmPerson.gmCurrentPatient() 442 self.__wxID_BTN_OK = wx.NewId() 443 self.__wxID_BTN_CLEAR = wx.NewId() 444 self.__do_layout() 445 self.__register_events() 446 self.Show()
447 #-------------------------------------------------------- 448 # external API 449 #--------------------------------------------------------
450 - def save_data(self):
451 """This needs to be overridden by child classes.""" 452 self._long_error = _( 453 'Cannot save data from edit area.\n\n' 454 'Programmer forgot to override method:\n' 455 ' <%s.save_data>' 456 ) % self.__class__.__name__ 457 return False
458 #--------------------------------------------------------
459 - def reset_ui(self):
460 msg = _( 461 'Cannot reset fields in edit area.\n\n' 462 'Programmer forgot to override method:\n' 463 ' <%s.reset_ui>' 464 ) % self.__class__.__name__ 465 gmGuiHelpers.gm_show_error(msg)
466 #--------------------------------------------------------
467 - def get_short_error(self):
468 tmp = self._short_error 469 self._short_error = None 470 return tmp
471 #--------------------------------------------------------
472 - def get_long_error(self):
473 tmp = self._long_error 474 self._long_error = None 475 return tmp
476 #--------------------------------------------------------
477 - def get_summary(self):
478 return _('<No embed string for [%s]>') % self.__class__.__name__
479 #-------------------------------------------------------- 480 # event handling 481 #--------------------------------------------------------
482 - def __register_events(self):
483 # client internal signals 484 if self._patient.connected: 485 gmDispatcher.connect(signal = 'pre_patient_selection', receiver = self._on_pre_patient_selection) 486 gmDispatcher.connect(signal = 'post_patient_selection', receiver = self.on_post_patient_selection) 487 gmDispatcher.connect(signal = 'application_closing', receiver = self._on_application_closing) 488 489 # wxPython events 490 wx.EVT_CLOSE(self, self._on_close) 491 492 return 1
493 #--------------------------------------------------------
494 - def __deregister_events(self):
495 gmDispatcher.disconnect(signal = u'pre_patient_selection', receiver = self._on_pre_patient_selection) 496 gmDispatcher.disconnect(signal = u'post_patient_selection', receiver = self.on_post_patient_selection) 497 gmDispatcher.disconnect(signal = u'application_closing', receiver = self._on_application_closing)
498 #-------------------------------------------------------- 499 # handlers 500 #--------------------------------------------------------
501 - def _on_close(self, event):
502 self.__deregister_events() 503 event.Skip()
504 #--------------------------------------------------------
505 - def _on_OK_btn_pressed(self, event):
506 """Only active if _make_standard_buttons was called in child class.""" 507 # FIXME: this try: except: block seems to large 508 try: 509 event.Skip() 510 if self.data is None: 511 self._save_new_entry() 512 self.reset_ui() 513 else: 514 self._save_modified_entry() 515 self.reset_ui() 516 except gmExceptions.InvalidInputError, err: 517 # nasty evil popup dialogue box 518 # but for invalid input we want to interrupt user 519 gmGuiHelpers.gm_show_error (err, _("Invalid Input")) 520 except: 521 _log.exception( "save data problem in [%s]" % self.__class__.__name__)
522 #--------------------------------------------------------
523 - def _on_clear_btn_pressed(self, event):
524 """Only active if _make_standard_buttons was called in child class.""" 525 # FIXME: check for unsaved data 526 self.reset_ui() 527 event.Skip()
528 #--------------------------------------------------------
529 - def _on_application_closing(self, **kwds):
530 self.__deregister_events() 531 # remember wxCallAfter 532 if not self._patient.connected: 533 return True 534 # FIXME: should do this: 535 # if self.user_wants_save(): 536 # if self.save_data(): 537 # return True 538 return True 539 _log.error('[%s] lossage' % self.__class__.__name__) 540 return False
541 #--------------------------------------------------------
542 - def _on_pre_patient_selection(self, **kwds):
543 """Just before new patient becomes active.""" 544 # remember wxCallAfter 545 if not self._patient.connected: 546 return True 547 # FIXME: should do this: 548 # if self.user_wants_save(): 549 # if self.save_data(): 550 # return True 551 return True 552 _log.error('[%s] lossage' % self.__class__.__name__) 553 return False
554 #--------------------------------------------------------
555 - def on_post_patient_selection( self, **kwds):
556 """Just after new patient became active.""" 557 # remember to use wxCallAfter() 558 self.reset_ui()
559 #---------------------------------------------------------------- 560 # internal helpers 561 #----------------------------------------------------------------
562 - def __do_layout(self):
563 564 # define prompts and fields 565 self._define_prompts() 566 self._define_fields(parent = self) 567 if len(self.fields) != len(self.prompts): 568 _log.error('[%s]: #fields != #prompts' % self.__class__.__name__) 569 return None 570 571 # and generate edit area from it 572 szr_main_fgrid = wx.FlexGridSizer(rows = len(self.prompts), cols=2) 573 color = richards_aqua 574 lines = self.prompts.keys() 575 lines.sort() 576 for line in lines: 577 # 1) prompt 578 label, color, weight = self.prompts[line] 579 # FIXME: style for centering in vertical direction ? 580 prompt = wx.StaticText ( 581 parent = self, 582 id = -1, 583 label = label, 584 style = wx.ALIGN_CENTRE 585 ) 586 # FIXME: resolution dependant 587 prompt.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD, False, '')) 588 prompt.SetForegroundColour(color) 589 prompt.SetBackgroundColour(richards_light_gray) 590 szr_main_fgrid.Add(prompt, flag=wx.EXPAND | wx.ALIGN_RIGHT) 591 592 # 2) widget(s) for line 593 szr_line = wx.BoxSizer(wx.HORIZONTAL) 594 positions = self.fields[line].keys() 595 positions.sort() 596 for pos in positions: 597 field, weight = self.fields[line][pos] 598 # field.SetBackgroundColour(wx.Color(222,222,222)) 599 szr_line.Add(field, weight, wx.EXPAND) 600 szr_main_fgrid.Add(szr_line, flag=wx.GROW | wx.ALIGN_LEFT) 601 602 # grid can grow column 1 only, not column 0 603 szr_main_fgrid.AddGrowableCol(1) 604 605 # # use sizer for border around everything plus a little gap 606 # # FIXME: fold into szr_main_panels ? 607 # self.szr_central_container = wx.BoxSizer(wxHORIZONTAL) 608 # self.szr_central_container.Add(self.szr_main_panels, 1, wx.EXPAND | wxALL, 5) 609 610 # and do the layouting 611 self.SetSizerAndFit(szr_main_fgrid)
612 # self.FitInside() 613 #---------------------------------------------------------------- 614 # intra-class API 615 #----------------------------------------------------------------
616 - def _define_prompts(self):
617 """Child classes override this to define their prompts using _add_prompt()""" 618 _log.error('missing override in [%s]' % self.__class__.__name__)
619 #----------------------------------------------------------------
620 - def _add_prompt(self, line, label='missing label', color=richards_blue, weight=0):
621 """Add a new prompt line. 622 623 To be used from _define_fields in child classes. 624 625 - label, the label text 626 - color 627 - weight, the weight given in sizing the various rows. 0 means the row 628 always has minimum size 629 """ 630 self.prompts[line] = (label, color, weight)
631 #----------------------------------------------------------------
632 - def _define_fields(self, parent):
633 """Defines the fields. 634 635 - override in child classes 636 - mostly uses _add_field() 637 """ 638 _log.error('missing override in [%s]' % self.__class__.__name__)
639 #----------------------------------------------------------------
640 - def _add_field(self, line=None, pos=None, widget=None, weight=0):
641 if None in (line, pos, widget): 642 _log.error('argument error in [%s]: line=%s, pos=%s, widget=%s' % (self.__class__.__name__, line, pos, widget)) 643 if not self.fields.has_key(line): 644 self.fields[line] = {} 645 self.fields[line][pos] = (widget, weight)
646 #----------------------------------------------------------------
647 - def _make_standard_buttons(self, parent):
648 """Generates OK/CLEAR buttons for edit area.""" 649 self.btn_OK = wx.Button(parent, self.__wxID_BTN_OK, _("OK")) 650 self.btn_OK.SetToolTipString(_('save entry into medical record')) 651 self.btn_Clear = wx.Button(parent, self.__wxID_BTN_CLEAR, _("Clear")) 652 self.btn_Clear.SetToolTipString(_('initialize input fields for new entry')) 653 654 szr_buttons = wx.BoxSizer(wx.HORIZONTAL) 655 szr_buttons.Add(self.btn_OK, 1, wx.EXPAND | wx.ALL, 1) 656 szr_buttons.Add((5, 0), 0) 657 szr_buttons.Add(self.btn_Clear, 1, wx.EXPAND | wx.ALL, 1) 658 659 # connect standard buttons 660 wx.EVT_BUTTON(self.btn_OK, self.__wxID_BTN_OK, self._on_OK_btn_pressed) 661 wx.EVT_BUTTON(self.btn_Clear, self.__wxID_BTN_CLEAR, self._on_clear_btn_pressed) 662 663 return szr_buttons
664 #==================================================================== 665 #==================================================================== 666 #text control class to be later replaced by the gmPhraseWheel 667 #--------------------------------------------------------------------
668 -class cEditAreaField(wx.TextCtrl):
669 - def __init__ (self, parent, id = -1, pos = wx.DefaultPosition, size=wx.DefaultSize):
670 wx.TextCtrl.__init__(self,parent,id,"",pos, size ,wx.SIMPLE_BORDER) 671 _decorate_editarea_field(self)
672 #====================================================================
673 -class cEditArea(wx.Panel):
674 - def __init__(self, parent, id, pos, size, style):
675 676 print "class [%s] is deprecated, use cEditArea2 instead" % self.__class__.__name__ 677 678 # init main background panel 679 wx.Panel.__init__(self, parent, id, pos=pos, size=size, style=wx.NO_BORDER | wx.TAB_TRAVERSAL) 680 self.SetBackgroundColour(wx.Color(222,222,222)) 681 682 self.data = None 683 self.fields = {} 684 self.prompts = {} 685 686 ID_BTN_OK = wx.NewId() 687 ID_BTN_CLEAR = wx.NewId() 688 689 self.__do_layout() 690 691 # self.input_fields = {} 692 693 # self._postInit() 694 # self.old_data = {} 695 696 self._patient = gmPerson.gmCurrentPatient() 697 self.__register_events() 698 self.Show(True)
699 #---------------------------------------------------------------- 700 # internal helpers 701 #----------------------------------------------------------------
702 - def __do_layout(self):
703 # define prompts and fields 704 self._define_prompts() 705 self.fields_pnl = wx.Panel(self, -1, style = wx.RAISED_BORDER | wx.TAB_TRAVERSAL) 706 self._define_fields(parent = self.fields_pnl) 707 # and generate edit area from it 708 szr_prompts = self.__generate_prompts() 709 szr_fields = self.__generate_fields() 710 711 # stack prompts and fields horizontally 712 self.szr_main_panels = wx.BoxSizer(wx.HORIZONTAL) 713 self.szr_main_panels.Add(szr_prompts, 11, wx.EXPAND) 714 self.szr_main_panels.Add(5, 0, 0, wx.EXPAND) 715 self.szr_main_panels.Add(szr_fields, 90, wx.EXPAND) 716 717 # use sizer for border around everything plus a little gap 718 # FIXME: fold into szr_main_panels ? 719 self.szr_central_container = wx.BoxSizer(wx.HORIZONTAL) 720 self.szr_central_container.Add(self.szr_main_panels, 1, wx.EXPAND | wx.ALL, 5) 721 722 # and do the layouting 723 self.SetAutoLayout(True) 724 self.SetSizer(self.szr_central_container) 725 self.szr_central_container.Fit(self)
726 #----------------------------------------------------------------
727 - def __generate_prompts(self):
728 if len(self.fields) != len(self.prompts): 729 _log.error('[%s]: #fields != #prompts' % self.__class__.__name__) 730 return None 731 # prompts live on a panel 732 prompt_pnl = wx.Panel(self, -1, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER) 733 prompt_pnl.SetBackgroundColour(richards_light_gray) 734 # make them 735 color = richards_aqua 736 lines = self.prompts.keys() 737 lines.sort() 738 self.prompt_widget = {} 739 for line in lines: 740 label, color, weight = self.prompts[line] 741 self.prompt_widget[line] = self.__make_prompt(prompt_pnl, "%s " % label, color) 742 # make shadow below prompts in gray 743 shadow_below_prompts = wxWindow(self, -1, wx.DefaultPosition, wx.DefaultSize, 0) 744 shadow_below_prompts.SetBackgroundColour(richards_dark_gray) 745 szr_shadow_below_prompts = wx.BoxSizer (wx.HORIZONTAL) 746 szr_shadow_below_prompts.Add(5, 0, 0, wx.EXPAND) 747 szr_shadow_below_prompts.Add(shadow_below_prompts, 10, wx.EXPAND) 748 749 # stack prompt panel and shadow vertically 750 vszr_prompts = wx.BoxSizer(wx.VERTICAL) 751 vszr_prompts.Add(prompt_pnl, 97, wx.EXPAND) 752 vszr_prompts.Add(szr_shadow_below_prompts, 5, wx.EXPAND) 753 754 # make shadow to the right of the prompts 755 shadow_rightof_prompts = wxWindow(self, -1, wx.DefaultPosition, wx.DefaultSize, 0) 756 shadow_rightof_prompts.SetBackgroundColour(richards_dark_gray) 757 szr_shadow_rightof_prompts = wx.BoxSizer(wx.VERTICAL) 758 szr_shadow_rightof_prompts.Add(0,5,0,wx.EXPAND) 759 szr_shadow_rightof_prompts.Add(shadow_rightof_prompts, 1, wx.EXPAND) 760 761 # stack vertical prompt sizer and shadow horizontally 762 hszr_prompts = wx.BoxSizer(wx.HORIZONTAL) 763 hszr_prompts.Add(vszr_prompts, 10, wx.EXPAND) 764 hszr_prompts.Add(szr_shadow_rightof_prompts, 1, wx.EXPAND) 765 766 return hszr_prompts
767 #----------------------------------------------------------------
768 - def __generate_fields(self):
769 self.fields_pnl.SetBackgroundColour(wx.Color(222,222,222)) 770 # rows, cols, hgap, vgap 771 vszr = wx.BoxSizer(wx.VERTICAL) 772 lines = self.fields.keys() 773 lines.sort() 774 self.field_line_szr = {} 775 for line in lines: 776 self.field_line_szr[line] = wx.BoxSizer(wx.HORIZONTAL) 777 positions = self.fields[line].keys() 778 positions.sort() 779 for pos in positions: 780 field, weight = self.fields[line][pos] 781 self.field_line_szr[line].Add(field, weight, wx.EXPAND) 782 try: 783 vszr.Add(self.field_line_szr[line], self.prompts[line][2], flag = wx.EXPAND) # use same lineweight as prompts 784 except KeyError: 785 _log.error("Error with line=%s, self.field_line_szr has key:%s; self.prompts has key: %s" % (line, self.field_line_szr.has_key(line), self.prompts.has_key(line) ) ) 786 # put them on the panel 787 self.fields_pnl.SetSizer(vszr) 788 vszr.Fit(self.fields_pnl) 789 790 # make shadow below edit fields in gray 791 shadow_below_edit_fields = wxWindow(self, -1, wx.DefaultPosition, wx.DefaultSize, 0) 792 shadow_below_edit_fields.SetBackgroundColour(richards_coloured_gray) 793 szr_shadow_below_edit_fields = wx.BoxSizer(wx.HORIZONTAL) 794 szr_shadow_below_edit_fields.Add(5, 0, 0, wx.EXPAND) 795 szr_shadow_below_edit_fields.Add(shadow_below_edit_fields, 12, wx.EXPAND) 796 797 # stack edit fields and shadow vertically 798 vszr_edit_fields = wx.BoxSizer(wx.VERTICAL) 799 vszr_edit_fields.Add(self.fields_pnl, 92, wx.EXPAND) 800 vszr_edit_fields.Add(szr_shadow_below_edit_fields, 5, wx.EXPAND) 801 802 # make shadow to the right of the edit area 803 shadow_rightof_edit_fields = wxWindow(self, -1, wx.DefaultPosition, wx.DefaultSize, 0) 804 shadow_rightof_edit_fields.SetBackgroundColour(richards_coloured_gray) 805 szr_shadow_rightof_edit_fields = wx.BoxSizer(wx.VERTICAL) 806 szr_shadow_rightof_edit_fields.Add(0, 5, 0, wx.EXPAND) 807 szr_shadow_rightof_edit_fields.Add(shadow_rightof_edit_fields, 1, wx.EXPAND) 808 809 # stack vertical edit fields sizer and shadow horizontally 810 hszr_edit_fields = wx.BoxSizer(wx.HORIZONTAL) 811 hszr_edit_fields.Add(vszr_edit_fields, 89, wx.EXPAND) 812 hszr_edit_fields.Add(szr_shadow_rightof_edit_fields, 1, wx.EXPAND) 813 814 return hszr_edit_fields
815 #---------------------------------------------------------------
816 - def __make_prompt(self, parent, aLabel, aColor):
817 # FIXME: style for centering in vertical direction ? 818 prompt = wx.StaticText( 819 parent, 820 -1, 821 aLabel, 822 style = wx.ALIGN_RIGHT 823 ) 824 prompt.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD, False, '')) 825 prompt.SetForegroundColour(aColor) 826 return prompt
827 #---------------------------------------------------------------- 828 # intra-class API 829 #----------------------------------------------------------------
830 - def _add_prompt(self, line, label='missing label', color=richards_blue, weight=0):
831 """Add a new prompt line. 832 833 To be used from _define_fields in child classes. 834 835 - label, the label text 836 - color 837 - weight, the weight given in sizing the various rows. 0 means the rwo 838 always has minimum size 839 """ 840 self.prompts[line] = (label, color, weight)
841 #----------------------------------------------------------------
842 - def _add_field(self, line=None, pos=None, widget=None, weight=0):
843 if None in (line, pos, widget): 844 _log.error('argument error in [%s]: line=%s, pos=%s, widget=%s' % (self.__class__.__name__, line, pos, widget)) 845 if not self.fields.has_key(line): 846 self.fields[line] = {} 847 self.fields[line][pos] = (widget, weight)
848 #----------------------------------------------------------------
849 - def _define_fields(self, parent):
850 """Defines the fields. 851 852 - override in child classes 853 - mostly uses _add_field() 854 """ 855 _log.error('missing override in [%s]' % self.__class__.__name__)
856 #----------------------------------------------------------------
857 - def _define_prompts(self):
858 _log.error('missing override in [%s]' % self.__class__.__name__)
859 #----------------------------------------------------------------
860 - def _make_standard_buttons(self, parent):
861 """Generates OK/CLEAR buttons for edit area.""" 862 self.btn_OK = wx.Button(parent, ID_BTN_OK, _("OK")) 863 self.btn_OK.SetToolTipString(_('save entry into medical record')) 864 self.btn_Clear = wx.Button(parent, ID_BTN_CLEAR, _("Clear")) 865 self.btn_Clear.SetToolTipString(_('initialize input fields for new entry')) 866 867 szr_buttons = wx.BoxSizer(wx.HORIZONTAL) 868 szr_buttons.Add(self.btn_OK, 1, wx.EXPAND | wx.ALL, 1) 869 szr_buttons.Add(5, 0, 0) 870 szr_buttons.Add(self.btn_Clear, 1, wx.EXPAND | wx.ALL, 1) 871 872 return szr_buttons
873 #--------------------------------------------------------
874 - def _pre_save_data(self):
875 pass
876 #--------------------------------------------------------
877 - def _save_data(self):
878 _log.error('[%s] programmer forgot to define _save_data()' % self.__class__.__name__) 879 _log.info('child classes of cEditArea *must* override this function') 880 return False
881 #-------------------------------------------------------- 882 # event handling 883 #--------------------------------------------------------
884 - def __register_events(self):
885 # connect standard buttons 886 wx.EVT_BUTTON(self.btn_OK, ID_BTN_OK, self._on_OK_btn_pressed) 887 wx.EVT_BUTTON(self.btn_Clear, ID_BTN_CLEAR, self._on_clear_btn_pressed) 888 889 wx.EVT_SIZE (self.fields_pnl, self._on_resize_fields) 890 891 # client internal signals 892 gmDispatcher.connect(signal = u'pre_patient_selection', receiver = self._on_pre_patient_selection) 893 gmDispatcher.connect(signal = u'application_closing', receiver = self._on_application_closing) 894 gmDispatcher.connect(signal = u'post_patient_selection', receiver = self.on_post_patient_selection) 895 896 return 1
897 #-------------------------------------------------------- 898 # handlers 899 #--------------------------------------------------------
900 - def _on_OK_btn_pressed(self, event):
901 # FIXME: this try: except: block seems to large 902 try: 903 event.Skip() 904 if self.data is None: 905 self._save_new_entry() 906 self.set_data() 907 else: 908 self._save_modified_entry() 909 self.set_data() 910 except gmExceptions.InvalidInputError, err: 911 # nasty evil popup dialogue box 912 # but for invalid input we want to interrupt user 913 gmGuiHelpers.gm_show_error (err, _("Invalid Input")) 914 except: 915 _log.exception( "save data problem in [%s]" % self.__class__.__name__)
916 #--------------------------------------------------------
917 - def _on_clear_btn_pressed(self, event):
918 # FIXME: check for unsaved data 919 self.set_data() 920 event.Skip()
921 #--------------------------------------------------------
922 - def on_post_patient_selection( self, **kwds):
923 # remember to use wxCallAfter() 924 self.set_data()
925 #--------------------------------------------------------
926 - def _on_application_closing(self, **kwds):
927 # remember wxCallAfter 928 if not self._patient.connected: 929 return True 930 if self._save_data(): 931 return True 932 _log.error('[%s] lossage' % self.__class__.__name__) 933 return False
934 #--------------------------------------------------------
935 - def _on_pre_patient_selection(self, **kwds):
936 # remember wxCallAfter 937 if not self._patient.connected: 938 return True 939 if self._save_data(): 940 return True 941 _log.error('[%s] lossage' % self.__class__.__name__) 942 return False
943 #--------------------------------------------------------
944 - def _on_resize_fields (self, event):
945 self.fields_pnl.Layout() 946 # resize the prompts accordingly 947 for i in self.field_line_szr.keys(): 948 # query the BoxSizer to find where the field line is 949 pos = self.field_line_szr[i].GetPosition() 950 # and set the prompt lable to the same Y position 951 self.prompt_widget[i].SetPosition((0, pos.y))
952 #====================================================================
953 -class gmEditArea(cEditArea):
954 - def __init__(self, parent, id, aType = None):
955 956 print "class [%s] is deprecated, use cEditArea2 instead" % self.__class__.__name__ 957 958 # sanity checks 959 if aType not in _known_edit_area_types: 960 _log.error('unknown edit area type: [%s]' % aType) 961 raise gmExceptions.ConstructorError, 'unknown edit area type: [%s]' % aType 962 self._type = aType 963 964 # init main background panel 965 cEditArea.__init__(self, parent, id) 966 967 self.input_fields = {} 968 969 self._postInit() 970 self.old_data = {} 971 972 self._patient = gmPerson.gmCurrentPatient() 973 self.Show(True)
974 #---------------------------------------------------------------- 975 # internal helpers 976 #---------------------------------------------------------------- 977 #---------------------------------------------------------------- 978 # to be obsoleted 979 #----------------------------------------------------------------
980 - def __make_prompts(self, prompt_labels):
981 # prompts live on a panel 982 prompt_pnl = wx.Panel(self, -1, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER) 983 prompt_pnl.SetBackgroundColour(richards_light_gray) 984 # make them 985 gszr = wx.FlexGridSizer (len(prompt_labels)+1, 1, 2, 2) 986 color = richards_aqua 987 for prompt in prompt_labels: 988 label = self.__make_prompt(prompt_pnl, "%s " % prompt, color) 989 gszr.Add(label, 0, wx.EXPAND | wx.ALIGN_RIGHT) 990 color = richards_blue 991 gszr.RemoveGrowableRow (line-1) 992 # put sizer on panel 993 prompt_pnl.SetSizer(gszr) 994 gszr.Fit(prompt_pnl) 995 prompt_pnl.SetAutoLayout(True) 996 997 # make shadow below prompts in gray 998 shadow_below_prompts = wxWindow(self, -1, wx.DefaultPosition, wx.DefaultSize, 0) 999 shadow_below_prompts.SetBackgroundColour(richards_dark_gray) 1000 szr_shadow_below_prompts = wx.BoxSizer (wx.HORIZONTAL) 1001 szr_shadow_below_prompts.Add(5, 0, 0, wx.EXPAND) 1002 szr_shadow_below_prompts.Add(shadow_below_prompts, 10, wx.EXPAND) 1003 1004 # stack prompt panel and shadow vertically 1005 vszr_prompts = wx.BoxSizer(wx.VERTICAL) 1006 vszr_prompts.Add(prompt_pnl, 97, wx.EXPAND) 1007 vszr_prompts.Add(szr_shadow_below_prompts, 5, wx.EXPAND) 1008 1009 # make shadow to the right of the prompts 1010 shadow_rightof_prompts = wxWindow(self, -1, wx.DefaultPosition, wx.DefaultSize, 0) 1011 shadow_rightof_prompts.SetBackgroundColour(richards_dark_gray) 1012 szr_shadow_rightof_prompts = wx.BoxSizer(wx.VERTICAL) 1013 szr_shadow_rightof_prompts.Add(0,5,0,wx.EXPAND) 1014 szr_shadow_rightof_prompts.Add(shadow_rightof_prompts,1,wx.EXPAND) 1015 1016 # stack vertical prompt sizer and shadow horizontally 1017 hszr_prompts = wx.BoxSizer(wx.HORIZONTAL) 1018 hszr_prompts.Add(vszr_prompts, 10, wx.EXPAND) 1019 hszr_prompts.Add(szr_shadow_rightof_prompts, 1, wx.EXPAND) 1020 1021 return hszr_prompts
1022 #----------------------------------------------------------------
1023 - def _make_edit_lines(self, parent):
1024 _log.error('programmer forgot to define edit area lines for [%s]' % self._type) 1025 _log.info('child classes of gmEditArea *must* override this function') 1026 return []
1027 #----------------------------------------------------------------
1028 - def __make_editing_area(self):
1029 # make edit fields 1030 fields_pnl = wx.Panel(self, -1, wx.DefaultPosition, wx.DefaultSize, style = wx.RAISED_BORDER | wx.TAB_TRAVERSAL) 1031 fields_pnl.SetBackgroundColour(wx.Color(222,222,222)) 1032 # rows, cols, hgap, vgap 1033 gszr = wx.GridSizer(len(_prompt_defs[self._type]), 1, 2, 2) 1034 1035 # get lines 1036 lines = self._make_edit_lines(parent = fields_pnl) 1037 1038 self.lines = lines 1039 if len(lines) != len(_prompt_defs[self._type]): 1040 _log.error('#(edit lines) not equal #(prompts) for [%s], something is fishy' % self._type) 1041 for line in lines: 1042 gszr.Add(line, 0, wx.EXPAND | wx.ALIGN_LEFT) 1043 # put them on the panel 1044 fields_pnl.SetSizer(gszr) 1045 gszr.Fit(fields_pnl) 1046 fields_pnl.SetAutoLayout(True) 1047 1048 # make shadow below edit fields in gray 1049 shadow_below_edit_fields = wxWindow(self, -1, wx.DefaultPosition, wx.DefaultSize, 0) 1050 shadow_below_edit_fields.SetBackgroundColour(richards_coloured_gray) 1051 szr_shadow_below_edit_fields = wx.BoxSizer(wx.HORIZONTAL) 1052 szr_shadow_below_edit_fields.Add(5, 0, 0, wx.EXPAND) 1053 szr_shadow_below_edit_fields.Add(shadow_below_edit_fields, 12, wx.EXPAND) 1054 1055 # stack edit fields and shadow vertically 1056 vszr_edit_fields = wx.BoxSizer(wx.VERTICAL) 1057 vszr_edit_fields.Add(fields_pnl, 92, wx.EXPAND) 1058 vszr_edit_fields.Add(szr_shadow_below_edit_fields, 5, wx.EXPAND) 1059 1060 # make shadow to the right of the edit area 1061 shadow_rightof_edit_fields = wxWindow(self, -1, wx.DefaultPosition, wx.DefaultSize, 0) 1062 shadow_rightof_edit_fields.SetBackgroundColour(richards_coloured_gray) 1063 szr_shadow_rightof_edit_fields = wx.BoxSizer(wx.VERTICAL) 1064 szr_shadow_rightof_edit_fields.Add(0, 5, 0, wx.EXPAND) 1065 szr_shadow_rightof_edit_fields.Add(shadow_rightof_edit_fields, 1, wx.EXPAND) 1066 1067 # stack vertical edit fields sizer and shadow horizontally 1068 hszr_edit_fields = wx.BoxSizer(wx.HORIZONTAL) 1069 hszr_edit_fields.Add(vszr_edit_fields, 89, wx.EXPAND) 1070 hszr_edit_fields.Add(szr_shadow_rightof_edit_fields, 1, wx.EXPAND) 1071 1072 return hszr_edit_fields
1073
1074 - def set_old_data( self, map):
1075 self.old_data = map
1076
1077 - def _default_init_fields(self):
1078 #self.dirty = 0 #this flag is for patient_activating event to save any unsaved entries 1079 self.setInputFieldValues( self._get_init_values()) 1080 self.data = None
1081
1082 - def _get_init_values(self):
1083 map = {} 1084 for k in self.input_fields.keys(): 1085 map[k] = '' 1086 return map
1087 1088 #--------------------------------------------------------
1089 - def _init_fields(self):
1090 self._default_init_fields()
1091 1092 # _log.Log(gmLog.lErr, 'programmer forgot to define _init_fields() for [%s]' % self._type) 1093 # _log.Log(gmLog.lInfo, 'child classes of gmEditArea *must* override this function') 1094 # raise AttributeError 1095 #-------------------------------------------------------------------------------------------------------------
1096 - def _updateUI(self):
1097 _log.warning("you may want to override _updateUI for [%s]" % self.__class__.__name__)
1098 1099
1100 - def _postInit(self):
1101 """override for further control setup""" 1102 pass
1103 1104
1105 - def _makeLineSizer(self, widget, weight, spacerWeight):
1106 szr = wx.BoxSizer(wx.HORIZONTAL) 1107 szr.Add( widget, weight, wx.EXPAND) 1108 szr.Add( 0,0, spacerWeight, wx.EXPAND) 1109 return szr
1110
1111 - def _makeCheckBox(self, parent, title):
1112 1113 cb = wx.CheckBox( parent, -1, _(title)) 1114 cb.SetForegroundColour( richards_blue) 1115 return cb
1116 1117 1118
1119 - def _makeExtraColumns(self , parent, lines, weightMap = {} ):
1120 """this is a utlity method to add extra columns""" 1121 #add an extra column if the class has attribute "extraColumns" 1122 if self.__class__.__dict__.has_key("extraColumns"): 1123 for x in self.__class__.extraColumns: 1124 lines = self._addColumn(parent, lines, x, weightMap) 1125 return lines
1126 1127 1128
1129 - def _addColumn(self, parent, lines, extra, weightMap = {}, existingWeight = 5 , extraWeight = 2):
1130 """ 1131 # add ia extra column in the edit area. 1132 # preconditions: 1133 # parent is fields_pnl (weak); 1134 # self.input_fields exists (required); 1135 # ; extra is a list of tuples of format - 1136 # ( key for input_fields, widget label , widget class to instantiate ) 1137 """ 1138 1139 newlines = [] 1140 i = 0 1141 for x in lines: 1142 # adjust weight if line has specific weightings. 1143 if weightMap.has_key( x): 1144 (existingWeight, extraWeight) = weightMap[x] 1145 1146 szr = wx.BoxSizer(wx.HORIZONTAL) 1147 szr.Add( x, existingWeight, wx.EXPAND) 1148 if i < len(extra) and extra[i] <> None: 1149 1150 (inputKey, widgetLabel, aclass) = extra[i] 1151 if aclass.__name__ in CONTROLS_WITHOUT_LABELS: 1152 szr.Add( self._make_prompt(parent, widgetLabel, richards_blue) ) 1153 widgetLabel = "" 1154 1155 1156 w = aclass( parent, -1, widgetLabel) 1157 if not aclass.__name__ in CONTROLS_WITHOUT_LABELS: 1158 w.SetForegroundColour(richards_blue) 1159 1160 szr.Add(w, extraWeight , wx.EXPAND) 1161 1162 # make sure the widget is locatable via input_fields 1163 self.input_fields[inputKey] = w 1164 1165 newlines.append(szr) 1166 i += 1 1167 return newlines
1168
1169 - def setInputFieldValues(self, map, id = None ):
1170 #self.monitoring_dirty = 0 1171 for k,v in map.items(): 1172 field = self.input_fields.get(k, None) 1173 if field == None: 1174 continue 1175 try: 1176 field.SetValue( str(v) ) 1177 except: 1178 try: 1179 if type(v) == type(''): 1180 v = 0 1181 1182 field.SetValue( v) 1183 except: 1184 pass 1185 self.setDataId(id) 1186 #self.monitoring_dirty = 1 1187 self.set_old_data(self.getInputFieldValues())
1188
1189 - def getDataId(self):
1190 return self.data
1191
1192 - def setDataId(self, id):
1193 self.data = id
1194
1195 - def _getInputFieldValues(self):
1196 values = {} 1197 for k,v in self.input_fields.items(): 1198 values[k] = v.GetValue() 1199 return values
1200
1201 - def getInputFieldValues(self, fields = None):
1202 if fields == None: 1203 fields = self.input_fields.keys() 1204 values = {} 1205 for f in fields: 1206 try: 1207 values[f] = self.input_fields[f].GetValue() 1208 except: 1209 pass 1210 return values
1211 #====================================================================
1212 -class gmFamilyHxEditArea(gmEditArea):
1213 - def __init__(self, parent, id):
1214 try: 1215 gmEditArea.__init__(self, parent, id, aType = 'family history') 1216 except gmExceptions.ConstructorError: 1217 _log.exceptions('cannot instantiate family Hx edit area') 1218 raise
1219 #----------------------------------------------------------------
1220 - def _make_edit_lines(self, parent):
1221 _log.debug("making family Hx lines") 1222 lines = [] 1223 self.input_fields = {} 1224 # line 1 1225 # FIXME: put patient search widget here, too ... 1226 # add button "make active patient" 1227 self.input_fields['name'] = cEditAreaField(parent, -1, wx.DefaultPosition, wx.DefaultSize) 1228 self.input_fields['DOB'] = cEditAreaField(parent, -1, wx.DefaultPosition, wx.DefaultSize) 1229 lbl_dob = self._make_prompt(parent, _(" Date of Birth "), richards_blue) 1230 szr = wx.BoxSizer(wx.HORIZONTAL) 1231 szr.Add(self.input_fields['name'], 4, wx.EXPAND) 1232 szr.Add(lbl_dob, 2, wx.EXPAND) 1233 szr.Add(self.input_fields['DOB'], 4, wx.EXPAND) 1234 lines.append(szr) 1235 # line 2 1236 # FIXME: keep relationship attachments permamently ! (may need to make new patient ...) 1237 # FIXME: learning phrasewheel attached to list loaded from backend 1238 self.input_fields['relationship'] = cEditAreaField(parent, -1, wx.DefaultPosition, wx.DefaultSize) 1239 szr = wx.BoxSizer(wx.HORIZONTAL) 1240 szr.Add(self.input_fields['relationship'], 4, wx.EXPAND) 1241 lines.append(szr) 1242 # line 3 1243 self.input_fields['condition'] = cEditAreaField(parent, -1, wx.DefaultPosition, wx.DefaultSize) 1244 self.cb_condition_confidential = wx.CheckBox(parent, -1, _("confidental"), wx.DefaultPosition, wx.DefaultSize, wx.NO_BORDER) 1245 szr = wx.BoxSizer(wx.HORIZONTAL) 1246 szr.Add(self.input_fields['condition'], 6, wx.EXPAND) 1247 szr.Add(self.cb_condition_confidential, 0, wx.EXPAND) 1248 lines.append(szr) 1249 # line 4 1250 self.input_fields['comment'] = cEditAreaField(parent, -1, wx.DefaultPosition, wx.DefaultSize) 1251 lines.append(self.input_fields['comment']) 1252 # line 5 1253 lbl_onset = self._make_prompt(parent, _(" age onset "), richards_blue) 1254 self.input_fields['age onset'] = cEditAreaField(parent, -1, wx.DefaultPosition, wx.DefaultSize) 1255 # FIXME: combo box ... 1256 lbl_caused_death = self._make_prompt(parent, _(" caused death "), richards_blue) 1257 self.input_fields['caused death'] = cEditAreaField(parent, -1, wx.DefaultPosition, wx.DefaultSize) 1258 lbl_aod = self._make_prompt(parent, _(" age died "), richards_blue) 1259 self.input_fields['AOD'] = cEditAreaField(parent, -1, wx.DefaultPosition, wx.DefaultSize) 1260 szr = wx.BoxSizer(wx.HORIZONTAL) 1261 szr.Add(lbl_onset, 0, wx.EXPAND) 1262 szr.Add(self.input_fields['age onset'], 1,wx.EXPAND) 1263 szr.Add(lbl_caused_death, 0, wx.EXPAND) 1264 szr.Add(self.input_fields['caused death'], 2,wx.EXPAND) 1265 szr.Add(lbl_aod, 0, wx.EXPAND) 1266 szr.Add(self.input_fields['AOD'], 1, wx.EXPAND) 1267 szr.Add(2, 2, 8) 1268 lines.append(szr) 1269 # line 6 1270 self.input_fields['progress notes'] = cEditAreaField(parent, -1, wx.DefaultPosition, wx.DefaultSize) 1271 lines.append(self.input_fields['progress notes']) 1272 # line 8 1273 self.Btn_next_condition = wx.Button(parent, -1, _("Next Condition")) 1274 szr = wx.BoxSizer(wx.HORIZONTAL) 1275 szr.AddSpacer(10, 0, 0) 1276 szr.Add(self.Btn_next_condition, 0, wx.EXPAND | wx.ALL, 1) 1277 szr.Add(2, 1, 5) 1278 szr.Add(self._make_standard_buttons(parent), 0, wx.EXPAND) 1279 lines.append(szr) 1280 1281 return lines
1282
1283 - def _save_data(self):
1284 return 1
1285 1286 #====================================================================
1287 -class gmPastHistoryEditArea(gmEditArea):
1288
1289 - def __init__(self, parent, id):
1290 gmEditArea.__init__(self, parent, id, aType = 'past history')
1291
1292 - def _define_prompts(self):
1293 self._add_prompt(line = 1, label = _("When Noted")) 1294 self._add_prompt(line = 2, label = _("Laterality")) 1295 self._add_prompt(line = 3, label = _("Condition")) 1296 self._add_prompt(line = 4, label = _("Notes")) 1297 self._add_prompt(line = 6, label = _("Status")) 1298 self._add_prompt(line = 7, label = _("Progress Note")) 1299 self._add_prompt(line = 8, label = '')
1300 #--------------------------------------------------------
1301 - def _define_fields(self, parent):
1302 # line 1 1303 self.fld_date_noted = gmDateTimeInput.gmDateInput( 1304 parent = parent, 1305 id = -1, 1306 style = wx.SIMPLE_BORDER 1307 ) 1308 self._add_field( 1309 line = 1, 1310 pos = 1, 1311 widget = self.fld_date_noted, 1312 weight = 2 1313 ) 1314 self._add_field( 1315 line = 1, 1316 pos = 2, 1317 widget = cPrompt_edit_area(parent,-1, _("Age")), 1318 weight = 0) 1319 1320 self.fld_age_noted = cEditAreaField(parent) 1321 self._add_field( 1322 line = 1, 1323 pos = 3, 1324 widget = self.fld_age_noted, 1325 weight = 2 1326 ) 1327 1328 # line 2 1329 self.fld_laterality_none= wx.RadioButton(parent, -1, _("N/A")) 1330 self.fld_laterality_left= wx.RadioButton(parent, -1, _("L")) 1331 self.fld_laterality_right= wx.RadioButton(parent, -1, _("R")) 1332 self.fld_laterality_both= wx.RadioButton(parent, -1, _("both")) 1333 self._add_field( 1334 line = 2, 1335 pos = 1, 1336 widget = self.fld_laterality_none, 1337 weight = 0 1338 ) 1339 self._add_field( 1340 line = 2, 1341 pos = 2, 1342 widget = self.fld_laterality_left, 1343 weight = 0 1344 ) 1345 self._add_field( 1346 line = 2, 1347 pos = 3, 1348 widget = self.fld_laterality_right, 1349 weight = 1 1350 ) 1351 self._add_field( 1352 line = 2, 1353 pos = 4, 1354 widget = self.fld_laterality_both, 1355 weight = 1 1356 ) 1357 # line 3 1358 self.fld_condition= cEditAreaField(parent) 1359 self._add_field( 1360 line = 3, 1361 pos = 1, 1362 widget = self.fld_condition, 1363 weight = 6 1364 ) 1365 # line 4 1366 self.fld_notes= cEditAreaField(parent) 1367 self._add_field( 1368 line = 4, 1369 pos = 1, 1370 widget = self.fld_notes, 1371 weight = 6 1372 ) 1373 # line 5 1374 self.fld_significant= wx.CheckBox( 1375 parent, 1376 -1, 1377 _("significant"), 1378 style = wx.NO_BORDER 1379 ) 1380 self.fld_active= wx.CheckBox( 1381 parent, 1382 -1, 1383 _("active"), 1384 style = wx.NO_BORDER 1385 ) 1386 1387 self._add_field( 1388 line = 5, 1389 pos = 1, 1390 widget = self.fld_significant, 1391 weight = 0 1392 ) 1393 self._add_field( 1394 line = 5, 1395 pos = 2, 1396 widget = self.fld_active, 1397 weight = 0 1398 ) 1399 #line 6 1400 self.fld_progress= cEditAreaField(parent) 1401 self._add_field( 1402 line = 6, 1403 pos = 1, 1404 widget = self.fld_progress, 1405 weight = 6 1406 ) 1407 1408 #line 7 1409 self._add_field( 1410 line = 7, 1411 pos = 4, 1412 widget = self._make_standard_buttons(parent), 1413 weight = 2 1414 )
1415 #--------------------------------------------------------
1416 - def _postInit(self):
1417 return 1418 #handling of auto age or year filling. 1419 wx.EVT_KILL_FOCUS( self.fld_age_noted, self._ageKillFocus) 1420 wx.EVT_KILL_FOCUS( self.fld_date_noted, self._yearKillFocus)
1421 #--------------------------------------------------------
1422 - def _ageKillFocus( self, event):
1423 # skip first, else later failure later in block causes widget to be unfocusable 1424 event.Skip() 1425 try : 1426 year = self._getBirthYear() + int(self.fld_age_noted.GetValue().strip() ) 1427 self.fld_date_noted.SetValue( str (year) ) 1428 except: 1429 pass
1430
1431 - def _getBirthYear(self):
1432 try: 1433 birthyear = int(str(self._patient['dob']).split('-')[0]) 1434 except: 1435 birthyear = time.localtime()[0] 1436 1437 return birthyear
1438
1439 - def _yearKillFocus( self, event):
1440 event.Skip() 1441 try: 1442 age = int(self.fld_date_noted.GetValue().strip() ) - self._getBirthYear() 1443 self.fld_age_noted.SetValue( str (age) ) 1444 except: 1445 pass 1446 1447 __init_values = { 1448 "condition": "", 1449 "notes1": "", 1450 "notes2": "", 1451 "age": "", 1452 "year": str(time.localtime()[0]), 1453 "progress": "", 1454 "active": 1, 1455 "operation": 0, 1456 "confidential": 0, 1457 "significant": 1, 1458 "both": 0, 1459 "left": 0, 1460 "right": 0, 1461 "none" : 1 1462 } 1463
1464 - def _getDefaultAge(self):
1465 try: 1466 return time.localtime()[0] - self._patient.getBirthYear() 1467 except: 1468 return 0
1469
1470 - def _get_init_values(self):
1471 values = gmPastHistoryEditArea.__init_values 1472 values["age"] = str( self._getDefaultAge()) 1473 return values
1474 1475
1476 - def _save_data(self):
1477 clinical = self._patient.get_emr().get_past_history() 1478 if self.getDataId() is None: 1479 id = clinical.create_history( self.get_fields_formatting_values() ) 1480 self.setDataId(id) 1481 return 1482 1483 clinical.update_history( self.get_fields_formatting_values(), self.getDataId() )
1484 1485 #====================================================================
1486 -class gmReferralEditArea(gmEditArea):
1487
1488 - def __init__(self, parent, id):
1489 try: 1490 gmEditArea.__init__(self, parent, id, aType = 'referral') 1491 except gmExceptions.ConstructorError: 1492 _log.exception('cannot instantiate referral edit area') 1493 self.data = None # we don't use this in this widget 1494 self.recipient = None
1495
1496 - def _define_prompts(self):
1497 self._add_prompt (line = 1, label = _ ("Specialty")) 1498 self._add_prompt (line = 2, label = _ ("Name")) 1499 self._add_prompt (line = 3, label = _ ("Address")) 1500 self._add_prompt (line = 4, label = _ ("Options")) 1501 self._add_prompt (line = 5, label = _("Text"), weight =6) 1502 self._add_prompt (line = 6, label = "")
1503
1504 - def _define_fields (self, parent):
1505 self.fld_specialty = gmPhraseWheel.cPhraseWheel ( 1506 parent = parent, 1507 id = -1, 1508 style = wx.SIMPLE_BORDER 1509 ) 1510 #_decorate_editarea_field (self.fld_specialty) 1511 self._add_field ( 1512 line = 1, 1513 pos = 1, 1514 widget = self.fld_specialty, 1515 weight = 1 1516 ) 1517 self.fld_name = gmPhraseWheel.cPhraseWheel ( 1518 parent = parent, 1519 id = -1, 1520 style = wx.SIMPLE_BORDER 1521 ) 1522 #_decorate_editarea_field (self.fld_name) 1523 self._add_field ( 1524 line = 2, 1525 pos = 1, 1526 widget = self.fld_name, 1527 weight = 1 1528 ) 1529 self.fld_address = wx.ComboBox (parent, -1, style = wx.CB_READONLY) 1530 #_decorate_editarea_field (self.fld_address) 1531 self._add_field ( 1532 line = 3, 1533 pos = 1, 1534 widget = self.fld_address, 1535 weight = 1 1536 ) 1537 # FIXME: replace with set_callback_on_* 1538 # self.fld_specialty.setDependent (self.fld_name, "occupation") 1539 self.fld_name.add_callback_on_selection(self.setAddresses) 1540 # flags line 1541 self.fld_med = wx.CheckBox (parent, -1, _("Meds"), style=wx.NO_BORDER) 1542 self._add_field ( 1543 line = 4, 1544 pos = 1, 1545 widget = self.fld_med, 1546 weight = 1 1547 ) 1548 self.fld_past = wx.CheckBox (parent, -1, _("Past Hx"), style=wx.NO_BORDER) 1549 self._add_field ( 1550 line = 4, 1551 pos = 4, 1552 widget = self.fld_past, 1553 weight = 1 1554 ) 1555 self.fld_text = wx.TextCtrl (parent, -1, style= wx.TE_MULTILINE) 1556 self._add_field ( 1557 line = 5, 1558 pos = 1, 1559 widget = self.fld_text, 1560 weight = 1) 1561 # final line 1562 self._add_field( 1563 line = 6, 1564 pos = 1, 1565 widget = self._make_standard_buttons(parent), 1566 weight = 1 1567 ) 1568 return 1
1569
1570 - def set_data (self):
1571 """ 1572 Doesn't accept any value as this doesn't make sense for this edit area 1573 """ 1574 self.fld_specialty.SetValue ('') 1575 self.fld_name.SetValue ('') 1576 self.fld_address.Clear () 1577 self.fld_address.SetValue ('') 1578 self.fld_med.SetValue (0) 1579 self.fld_past.SetValue (0) 1580 self.fld_text.SetValue ('') 1581 self.recipient = None
1582
1583 - def setAddresses (self, id):
1584 """ 1585 Set the available addresses for the selected identity 1586 """ 1587 if id is None: 1588 self.recipient = None 1589 self.fld_address.Clear () 1590 self.fld_address.SetValue ('') 1591 else: 1592 self.recipient = gmDemographicRecord.cDemographicRecord_SQL (id) 1593 self.fld_address.Clear () 1594 self.addr = self.recipient.getAddresses ('work') 1595 for i in self.addr: 1596 self.fld_address.Append (_("%(number)s %(street)s, %(urb)s %(postcode)s") % i, ('post', i)) 1597 fax = self.recipient.getCommChannel (gmDemographicRecord.FAX) 1598 email = self.recipient.getCommChannel (gmDemographicRecord.EMAIL) 1599 if fax: 1600 self.fld_address.Append ("%s: %s" % (_("FAX"), fax), ('fax', fax)) 1601 if email: 1602 self.fld_address.Append ("%s: %s" % (_("E-MAIL"), email), ('email', email))
1603
1604 - def _save_new_entry(self):
1605 """ 1606 We are always saving a "new entry" here because data_ID is always None 1607 """ 1608 if not self.recipient: 1609 raise gmExceptions.InvalidInputError(_('must have a recipient')) 1610 if self.fld_address.GetSelection() == -1: 1611 raise gmExceptions.InvalidInputError(_('must select address')) 1612 channel, addr = self.fld_address.GetClientData (self.fld_address.GetSelection()) 1613 text = self.fld_text.GetValue() 1614 flags = {} 1615 flags['meds'] = self.fld_med.GetValue() 1616 flags['pasthx'] = self.fld_past.GetValue() 1617 if not gmReferral.create_referral (self._patient, self.recipient, channel, addr, text, flags): 1618 raise gmExceptions.InvalidInputError('error sending form')
1619 1620 #==================================================================== 1621 #==================================================================== 1622 # unconverted edit areas below 1623 #====================================================================
1624 -class gmPrescriptionEditArea(gmEditArea):
1625 - def __init__(self, parent, id):
1626 try: 1627 gmEditArea.__init__(self, parent, id, aType = 'prescription') 1628 except gmExceptions.ConstructorError: 1629 _log.exceptions('cannot instantiate prescription edit area') 1630 raise
1631 1632 1633 #----------------------------------------------------------------
1634 - def _make_edit_lines(self, parent):
1635 _log.debug("making prescription lines") 1636 lines = [] 1637 self.txt_problem = cEditAreaField(parent) 1638 self.txt_class = cEditAreaField(parent) 1639 self.txt_generic = cEditAreaField(parent) 1640 self.txt_brand = cEditAreaField(parent) 1641 self.txt_strength= cEditAreaField(parent) 1642 self.txt_directions= cEditAreaField(parent) 1643 self.txt_for = cEditAreaField(parent) 1644 self.txt_progress = cEditAreaField(parent) 1645 1646 lines.append(self.txt_problem) 1647 lines.append(self.txt_class) 1648 lines.append(self.txt_generic) 1649 lines.append(self.txt_brand) 1650 lines.append(self.txt_strength) 1651 lines.append(self.txt_directions) 1652 lines.append(self.txt_for) 1653 lines.append(self.txt_progress) 1654 lines.append(self._make_standard_buttons(parent)) 1655 self.input_fields = { 1656 "problem": self.txt_problem, 1657 "class" : self.txt_class, 1658 "generic" : self.txt_generic, 1659 "brand" : self.txt_brand, 1660 "strength": self.txt_strength, 1661 "directions": self.txt_directions, 1662 "for" : self.txt_for, 1663 "progress": self.txt_progress 1664 1665 } 1666 1667 return self._makeExtraColumns( parent, lines)
1668 1669 1670 # This makes gmPrescriptionEditArea more adaptable to different nationalities special requirements. 1671 # ( well, it could be.) 1672 # to change at runtime, do 1673 1674 # gmPrescriptionEditArea.extraColumns = [ one or more columnListInfo ] 1675 1676 # each columnListInfo element describes one column, 1677 # where columnListInfo is a list of 1678 # tuples of [ inputMap name, widget label, widget class to instantiate from] 1679 1680 #gmPrescriptionEditArea.extraColumns = [ basicPrescriptionExtra ] 1681 #gmPrescriptionEditArea.extraColumns = [ auPrescriptionExtra ] 1682 1683
1684 - def _save_data(self):
1685 return 1
1686 1687 #==================================================================== 1688 # old style stuff below 1689 #==================================================================== 1690 #Class which shows a blue bold label left justified 1691 #--------------------------------------------------------------------
1692 -class cPrompt_edit_area(wx.StaticText):
1693 - def __init__(self, parent, id, prompt, aColor = richards_blue):
1694 wx.StaticText.__init__(self, parent, id, prompt, wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_LEFT) 1695 self.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD, False, '')) 1696 self.SetForegroundColour(aColor)
1697 #==================================================================== 1698 # create the editorprompts class which expects a dictionary of labels 1699 # passed to it with prompts relevant to the editing area. 1700 # remove the if else from this once the edit area labelling is fixed 1701 #--------------------------------------------------------------------
1702 -class gmPnlEditAreaPrompts(wx.Panel):
1703 - def __init__(self, parent, id, prompt_labels):
1704 wx.Panel.__init__(self, parent, id, wx.DefaultPosition, wx.DefaultSize, wx.SIMPLE_BORDER) 1705 self.SetBackgroundColour(richards_light_gray) 1706 gszr = wx.GridSizer (len(prompt_labels)+1, 1, 2, 2) 1707 color = richards_aqua 1708 for prompt_key in prompt_labels.keys(): 1709 label = cPrompt_edit_area(self, -1, " %s" % prompt_labels[prompt_key], aColor = color) 1710 gszr.Add(label, 0, wx.EXPAND | wx.ALIGN_RIGHT) 1711 color = richards_blue 1712 self.SetSizer(gszr) 1713 gszr.Fit(self) 1714 self.SetAutoLayout(True)
1715 #==================================================================== 1716 #Class central to gnumed data input 1717 #allows data entry of multiple different types.e.g scripts, 1718 #referrals, measurements, recalls etc 1719 #@TODO : just about everything 1720 #section = calling section eg allergies, script 1721 #----------------------------------------------------------
1722 -class EditTextBoxes(wx.Panel):
1723 - def __init__(self, parent, id, editareaprompts, section):
1724 wx.Panel.__init__(self, parent, id, wx.DefaultPosition, wx.DefaultSize,style = wx.RAISED_BORDER | wx.TAB_TRAVERSAL) 1725 self.SetBackgroundColour(wx.Color(222,222,222)) 1726 self.parent = parent 1727 # rows, cols, hgap, vgap 1728 self.gszr = wx.GridSizer(len(editareaprompts), 1, 2, 2) 1729 1730 if section == gmSECTION_SUMMARY: 1731 pass 1732 elif section == gmSECTION_DEMOGRAPHICS: 1733 pass 1734 elif section == gmSECTION_CLINICALNOTES: 1735 pass 1736 elif section == gmSECTION_FAMILYHISTORY: 1737 pass 1738 elif section == gmSECTION_PASTHISTORY: 1739 pass 1740 # line 1 1741 1742 self.txt_condition = cEditAreaField(self,PHX_CONDITION,wx.DefaultPosition,wx.DefaultSize) 1743 self.rb_sideleft = wxRadioButton(self,PHX_LEFT, _(" (L) "), wx.DefaultPosition,wx.DefaultSize) 1744 self.rb_sideright = wxRadioButton(self, PHX_RIGHT, _("(R)"), wx.DefaultPosition,wx.DefaultSize,wx.SUNKEN_BORDER) 1745 self.rb_sideboth = wxRadioButton(self, PHX_BOTH, _("Both"), wx.DefaultPosition,wx.DefaultSize) 1746 rbsizer = wx.BoxSizer(wx.HORIZONTAL) 1747 rbsizer.Add(self.rb_sideleft,1,wx.EXPAND) 1748 rbsizer.Add(self.rb_sideright,1,wx.EXPAND) 1749 rbsizer.Add(self.rb_sideboth,1,wx.EXPAND) 1750 szr1 = wx.BoxSizer(wx.HORIZONTAL) 1751 szr1.Add(self.txt_condition, 4, wx.EXPAND) 1752 szr1.Add(rbsizer, 3, wx.EXPAND) 1753 # self.sizer_line1.Add(self.rb_sideleft,1,wx.EXPAND|wxALL,2) 1754 # self.sizer_line1.Add(self.rb_sideright,1,wx.EXPAND|wxALL,2) 1755 # self.sizer_line1.Add(self.rb_sideboth,1,wx.EXPAND|wxALL,2) 1756 # line 2 1757 self.txt_notes1 = cEditAreaField(self,PHX_NOTES,wx.DefaultPosition,wx.DefaultSize) 1758 # line 3 1759 self.txt_notes2= cEditAreaField(self,PHX_NOTES2,wx.DefaultPosition,wx.DefaultSize) 1760 # line 4 1761 self.txt_agenoted = cEditAreaField(self, PHX_AGE, wx.DefaultPosition, wx.DefaultSize) 1762 szr4 = wx.BoxSizer(wx.HORIZONTAL) 1763 szr4.Add(self.txt_agenoted, 1, wx.EXPAND) 1764 szr4.Add(5, 0, 5) 1765 # line 5 1766 self.txt_yearnoted = cEditAreaField(self,PHX_YEAR,wx.DefaultPosition,wx.DefaultSize) 1767 szr5 = wx.BoxSizer(wx.HORIZONTAL) 1768 szr5.Add(self.txt_yearnoted, 1, wx.EXPAND) 1769 szr5.Add(5, 0, 5) 1770 # line 6 1771 self.parent.cb_active = wx.CheckBox(self, PHX_ACTIVE, _("Active"), wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 1772 self.parent.cb_operation = wx.CheckBox(self, PHX_OPERATION, _("Operation"), wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 1773 self.parent.cb_confidential = wx.CheckBox(self, PHX_CONFIDENTIAL , _("Confidential"), wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 1774 self.parent.cb_significant = wx.CheckBox(self, PHX_SIGNIFICANT, _("Significant"), wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 1775 szr6 = wx.BoxSizer(wx.HORIZONTAL) 1776 szr6.Add(self.parent.cb_active, 1, wx.EXPAND) 1777 szr6.Add(self.parent.cb_operation, 1, wx.EXPAND) 1778 szr6.Add(self.parent.cb_confidential, 1, wx.EXPAND) 1779 szr6.Add(self.parent.cb_significant, 1, wx.EXPAND) 1780 # line 7 1781 self.txt_progressnotes = cEditAreaField(self,PHX_PROGRESSNOTES ,wx.DefaultPosition,wx.DefaultSize) 1782 # line 8 1783 szr8 = wx.BoxSizer(wx.HORIZONTAL) 1784 szr8.Add(5, 0, 6) 1785 szr8.Add(self._make_standard_buttons(), 0, wx.EXPAND) 1786 1787 self.gszr.Add(szr1,0,wx.EXPAND) 1788 self.gszr.Add(self.txt_notes1,0,wx.EXPAND) 1789 self.gszr.Add(self.txt_notes2,0,wx.EXPAND) 1790 self.gszr.Add(szr4,0,wx.EXPAND) 1791 self.gszr.Add(szr5,0,wx.EXPAND) 1792 self.gszr.Add(szr6,0,wx.EXPAND) 1793 self.gszr.Add(self.txt_progressnotes,0,wx.EXPAND) 1794 self.gszr.Add(szr8,0,wx.EXPAND) 1795 #self.anylist = wx.ListCtrl(self, -1, wx.DefaultPosition,wx.DefaultSize,wx.LC_REPORT|wx.LC_LIST|wx.SUNKEN_BORDER) 1796 1797 elif section == gmSECTION_SCRIPT: 1798 pass 1799 elif section == gmSECTION_REQUESTS: 1800 pass 1801 elif section == gmSECTION_RECALLS: 1802 pass 1803 else: 1804 pass 1805 1806 self.SetSizer(self.gszr) 1807 self.gszr.Fit(self) 1808 1809 self.SetAutoLayout(True) 1810 self.Show(True)
1811 #----------------------------------------------------------------
1812 - def _make_standard_buttons(self):
1813 self.btn_OK = wx.Button(self, -1, _("Ok")) 1814 self.btn_Clear = wx.Button(self, -1, _("Clear")) 1815 szr_buttons = wx.BoxSizer(wx.HORIZONTAL) 1816 szr_buttons.Add(self.btn_OK, 1, wx.EXPAND, wx.ALL, 1) 1817 szr_buttons.Add(5, 0, 0) 1818 szr_buttons.Add(self.btn_Clear, 1, wx.EXPAND, wx.ALL, 1) 1819 return szr_buttons
1820 #====================================================================
1821 -class EditArea(wx.Panel):
1822 - def __init__(self, parent, id, line_labels, section):
1823 _log.warning('***** old style EditArea instantiated, please convert *****') 1824 1825 wx.Panel.__init__(self, parent, id, wx.DefaultPosition, wx.DefaultSize, style = wx.NO_BORDER) 1826 self.SetBackgroundColour(wx.Color(222,222,222)) 1827 1828 # make prompts 1829 prompts = gmPnlEditAreaPrompts(self, -1, line_labels) 1830 # and shadow below prompts in ... 1831 shadow_below_prompts = wxWindow(self, -1, wx.DefaultPosition, wx.DefaultSize, 0) 1832 # ... gray 1833 shadow_below_prompts.SetBackgroundColour(richards_dark_gray) 1834 szr_shadow_below_prompts = wx.BoxSizer (wx.HORIZONTAL) 1835 szr_shadow_below_prompts.Add(5,0,0,wx.EXPAND) 1836 szr_shadow_below_prompts.Add(shadow_below_prompts, 10, wx.EXPAND) 1837 # stack prompts and shadow vertically 1838 szr_prompts = wx.BoxSizer(wx.VERTICAL) 1839 szr_prompts.Add(prompts, 97, wx.EXPAND) 1840 szr_prompts.Add(szr_shadow_below_prompts, 5, wx.EXPAND) 1841 1842 # make edit fields 1843 edit_fields = EditTextBoxes(self, -1, line_labels, section) 1844 # make shadow below edit area ... 1845 shadow_below_editarea = wxWindow(self, -1, wx.DefaultPosition, wx.DefaultSize, 0) 1846 # ... gray 1847 shadow_below_editarea.SetBackgroundColour(richards_coloured_gray) 1848 szr_shadow_below_editarea = wx.BoxSizer(wx.HORIZONTAL) 1849 szr_shadow_below_editarea.Add(5,0,0,wx.EXPAND) 1850 szr_shadow_below_editarea.Add(shadow_below_editarea, 12, wx.EXPAND) 1851 # stack edit fields and shadow vertically 1852 szr_editarea = wx.BoxSizer(wx.VERTICAL) 1853 szr_editarea.Add(edit_fields, 92, wx.EXPAND) 1854 szr_editarea.Add(szr_shadow_below_editarea, 5, wx.EXPAND) 1855 1856 # make shadows to the right of ... 1857 # ... the prompts ... 1858 shadow_rightof_prompts = wxWindow(self, -1, wx.DefaultPosition, wx.DefaultSize, 0) 1859 shadow_rightof_prompts.SetBackgroundColour(richards_dark_gray) 1860 szr_shadow_rightof_prompts = wx.BoxSizer(wx.VERTICAL) 1861 szr_shadow_rightof_prompts.Add(0,5,0,wx.EXPAND) 1862 szr_shadow_rightof_prompts.Add(shadow_rightof_prompts,1,wx.EXPAND) 1863 # ... and the edit area 1864 shadow_rightof_editarea = wxWindow(self, -1, wx.DefaultPosition, wx.DefaultSize, 0) 1865 shadow_rightof_editarea.SetBackgroundColour(richards_coloured_gray) 1866 szr_shadow_rightof_editarea = wx.BoxSizer(wx.VERTICAL) 1867 szr_shadow_rightof_editarea.Add(0, 5, 0, wx.EXPAND) 1868 szr_shadow_rightof_editarea.Add(shadow_rightof_editarea, 1, wx.EXPAND) 1869 1870 # stack prompts, shadows and fields horizontally 1871 self.szr_main_panels = wx.BoxSizer(wx.HORIZONTAL) 1872 self.szr_main_panels.Add(szr_prompts, 10, wx.EXPAND) 1873 self.szr_main_panels.Add(szr_shadow_rightof_prompts, 1, wx.EXPAND) 1874 self.szr_main_panels.Add(5, 0, 0, wx.EXPAND) 1875 self.szr_main_panels.Add(szr_editarea, 89, wx.EXPAND) 1876 self.szr_main_panels.Add(szr_shadow_rightof_editarea, 1, wx.EXPAND) 1877 1878 # use sizer for border around everything plus a little gap 1879 # FIXME: fold into szr_main_panels ? 1880 self.szr_central_container = wx.BoxSizer(wx.HORIZONTAL) 1881 self.szr_central_container.Add(self.szr_main_panels, 1, wx.EXPAND | wx.ALL, 5) 1882 self.SetSizer(self.szr_central_container) 1883 self.szr_central_container.Fit(self) 1884 self.SetAutoLayout(True) 1885 self.Show(True)
1886 1887 1888 #==================================================================== 1889 # old stuff still needed for conversion 1890 #-------------------------------------------------------------------- 1891 #==================================================================== 1892 1893 #==================================================================== 1894 1895 # elif section == gmSECTION_SCRIPT: 1896 # gmLog.gmDefLog.Log (gmLog.lData, "in script section now") 1897 # self.text1_prescription_reason = cEditAreaField(self,-1,wx.DefaultPosition,wx.DefaultSize) 1898 # self.text2_drug_class = cEditAreaField(self,-1,wx.DefaultPosition,wx.DefaultSize) 1899 # self.text3_generic_drug = cEditAreaField(self,-1,wx.DefaultPosition,wx.DefaultSize) 1900 # self.text4_brand_drug = cEditAreaField(self,-1,wx.DefaultPosition,wx.DefaultSize) 1901 # self.text5_strength = cEditAreaField(self,-1,wx.DefaultPosition,wx.DefaultSize) 1902 # self.text6_directions = cEditAreaField(self,-1,wx.DefaultPosition,wx.DefaultSize) 1903 # self.text7_for_duration = cEditAreaField(self,-1,wx.DefaultPosition,wx.DefaultSize) 1904 # self.text8_prescription_progress_notes = cEditAreaField(self,-1,wx.DefaultPosition,wx.DefaultSize) 1905 # self.text9_quantity = cEditAreaField(self,-1,wx.DefaultPosition,wx.DefaultSize) 1906 # lbl_veterans = cPrompt_edit_area(self,-1," Veteran ") 1907 # lbl_reg24 = cPrompt_edit_area(self,-1," Reg 24 ") 1908 # lbl_quantity = cPrompt_edit_area(self,-1," Quantity ") 1909 # lbl_repeats = cPrompt_edit_area(self,-1," Repeats ") 1910 # lbl_usualmed = cPrompt_edit_area(self,-1," Usual ") 1911 # self.cb_veteran = wx.CheckBox(self, -1, " Yes ", wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 1912 # self.cb_reg24 = wx.CheckBox(self, -1, " Yes ", wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 1913 # self.cb_usualmed = wx.CheckBox(self, -1, " Yes ", wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 1914 # self.sizer_auth_PI = wx.BoxSizer(wxHORIZONTAL) 1915 # self.btn_authority = wx.Button(self,-1,">Authority") #create authority script 1916 # self.btn_briefPI = wx.Button(self,-1,"Brief PI") #show brief drug product information 1917 # self.sizer_auth_PI.Add(self.btn_authority,1,wx.EXPAND|wxALL,2) #put authority button and PI button 1918 # self.sizer_auth_PI.Add(self.btn_briefPI,1,wx.EXPAND|wxALL,2) #on same sizer 1919 # self.text10_repeats = cEditAreaField(self,-1,wx.DefaultPosition,wx.DefaultSize) 1920 # self.sizer_line3.Add(self.text3_generic_drug,5,wx.EXPAND) 1921 # self.sizer_line3.Add(lbl_veterans,1,wx.EXPAND) 1922 # self.sizer_line3.Add(self.cb_veteran,1,wx.EXPAND) 1923 # self.sizer_line4.Add(self.text4_brand_drug,5,wx.EXPAND) 1924 # self.sizer_line4.Add(lbl_reg24,1,wx.EXPAND) 1925 # self.sizer_line4.Add(self.cb_reg24,1,wx.EXPAND) 1926 # self.sizer_line5.Add(self.text5_strength,5,wx.EXPAND) 1927 # self.sizer_line5.Add(lbl_quantity,1,wx.EXPAND) 1928 # self.sizer_line5.Add(self.text9_quantity,1,wx.EXPAND) 1929 # self.sizer_line6.Add(self.text6_directions,5,wx.EXPAND) 1930 # self.sizer_line6.Add(lbl_repeats,1,wx.EXPAND) 1931 # self.sizer_line6.Add(self.text10_repeats,1,wx.EXPAND) 1932 # self.sizer_line7.Add(self.text7_for_duration,5,wx.EXPAND) 1933 # self.sizer_line7.Add(lbl_usualmed,1,wx.EXPAND) 1934 # self.sizer_line7.Add(self.cb_usualmed,1,wx.EXPAND) 1935 # self.sizer_line8.Add(5,0,0) 1936 # self.sizer_line8.Add(self.sizer_auth_PI,2,wx.EXPAND) 1937 # self.sizer_line8.Add(5,0,2) 1938 # self.sizer_line8.Add(self.btn_OK,1,wx.EXPAND|wxALL,2) 1939 # self.sizer_line8.Add(self.btn_Clear,1,wx.EXPAND|wxALL,2) 1940 # self.gszr.Add(self.text1_prescription_reason,1,wx.EXPAND) #prescribe for 1941 # self.gszr.Add(self.text2_drug_class,1,wx.EXPAND) #prescribe by class 1942 # self.gszr.Add(self.sizer_line3,1,wx.EXPAND) #prescribe by generic, lbl_veterans, cb_veteran 1943 # self.gszr.Add(self.sizer_line4,1,wx.EXPAND) #prescribe by brand, lbl_reg24, cb_reg24 1944 # self.gszr.Add(self.sizer_line5,1,wx.EXPAND) #drug strength, lbl_quantity, text_quantity 1945 # self.gszr.Add(self.sizer_line6,1,wx.EXPAND) #txt_directions, lbl_repeats, text_repeats 1946 # self.gszr.Add(self.sizer_line7,1,wx.EXPAND) #text_for,lbl_usual,chk_usual 1947 # self.gszr.Add(self.text8_prescription_progress_notes,1,wx.EXPAND) #text_progressNotes 1948 # self.gszr.Add(self.sizer_line8,1,wx.EXPAND) 1949 1950 1951 # elif section == gmSECTION_REQUESTS: 1952 # #----------------------------------------------------------------------------- 1953 #editing area for general requests e.g pathology, radiology, physiotherapy etc 1954 #create textboxes, radiobuttons etc 1955 #----------------------------------------------------------------------------- 1956 # self.txt_request_type = cEditAreaField(self,ID_REQUEST_TYPE,wx.DefaultPosition,wx.DefaultSize) 1957 # self.txt_request_company = cEditAreaField(self,ID_REQUEST_COMPANY,wx.DefaultPosition,wx.DefaultSize) 1958 # self.txt_request_street = cEditAreaField(self,ID_REQUEST_STREET,wx.DefaultPosition,wx.DefaultSize) 1959 # self.txt_request_suburb = cEditAreaField(self,ID_REQUEST_SUBURB,wx.DefaultPosition,wx.DefaultSize) 1960 # self.txt_request_phone= cEditAreaField(self,ID_REQUEST_PHONE,wx.DefaultPosition,wx.DefaultSize) 1961 # self.txt_request_requests = cEditAreaField(self,ID_REQUEST_REQUESTS,wx.DefaultPosition,wx.DefaultSize) 1962 # self.txt_request_notes = cEditAreaField(self,ID_REQUEST_FORMNOTES,wx.DefaultPosition,wx.DefaultSize) 1963 # self.txt_request_medications = cEditAreaField(self,ID_REQUEST_MEDICATIONS,wx.DefaultPosition,wx.DefaultSize) 1964 # self.txt_request_copyto = cEditAreaField(self,ID_REQUEST_COPYTO,wx.DefaultPosition,wx.DefaultSize) 1965 # self.txt_request_progressnotes = cEditAreaField(self,ID_PROGRESSNOTES,wx.DefaultPosition,wx.DefaultSize) 1966 # self.lbl_companyphone = cPrompt_edit_area(self,-1," Phone ") 1967 # self.cb_includeallmedications = wx.CheckBox(self, -1, " Include all medications ", wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 1968 # self.rb_request_bill_bb = wxRadioButton(self, ID_REQUEST_BILL_BB, "Bulk Bill ", wx.DefaultPosition,wx.DefaultSize) 1969 # self.rb_request_bill_private = wxRadioButton(self, ID_REQUEST_BILL_PRIVATE, "Private", wx.DefaultPosition,wx.DefaultSize,wx.SUNKEN_BORDER) 1970 # self.rb_request_bill_rebate = wxRadioButton(self, ID_REQUEST_BILL_REBATE, "Rebate", wx.DefaultPosition,wx.DefaultSize) 1971 # self.rb_request_bill_wcover = wxRadioButton(self, ID_REQUEST_BILL_wcover, "w/cover", wx.DefaultPosition,wx.DefaultSize) 1972 #-------------------------------------------------------------- 1973 #add controls to sizers where multiple controls per editor line 1974 #-------------------------------------------------------------- 1975 # self.sizer_request_optionbuttons = wx.BoxSizer(wxHORIZONTAL) 1976 # self.sizer_request_optionbuttons.Add(self.rb_request_bill_bb,1,wx.EXPAND) 1977 # self.sizer_request_optionbuttons.Add(self.rb_request_bill_private ,1,wx.EXPAND) 1978 # self.sizer_request_optionbuttons.Add(self.rb_request_bill_rebate ,1,wx.EXPAND) 1979 # self.sizer_request_optionbuttons.Add(self.rb_request_bill_wcover ,1,wx.EXPAND) 1980 # self.sizer_line4.Add(self.txt_request_suburb,4,wx.EXPAND) 1981 # self.sizer_line4.Add(self.lbl_companyphone,1,wx.EXPAND) 1982 # self.sizer_line4.Add(self.txt_request_phone,2,wx.EXPAND) 1983 # self.sizer_line7.Add(self.txt_request_medications, 4,wx.EXPAND) 1984 # self.sizer_line7.Add(self.cb_includeallmedications,3,wx.EXPAND) 1985 # self.sizer_line10.AddSizer(self.sizer_request_optionbuttons,3,wx.EXPAND) 1986 # self.sizer_line10.AddSizer(self.szr_buttons,1,wx.EXPAND) 1987 #self.sizer_line10.Add(self.btn_OK,1,wx.EXPAND|wxALL,1) 1988 #self.sizer_line10.Add(self.btn_Clear,1,wx.EXPAND|wxALL,1) 1989 #------------------------------------------------------------------ 1990 #add either controls or sizers with controls to vertical grid sizer 1991 #------------------------------------------------------------------ 1992 # self.gszr.Add(self.txt_request_type,0,wx.EXPAND) #e.g Pathology 1993 # self.gszr.Add(self.txt_request_company,0,wx.EXPAND) #e.g Douglas Hanly Moir 1994 # self.gszr.Add(self.txt_request_street,0,wx.EXPAND) #e.g 120 Big Street 1995 # self.gszr.AddSizer(self.sizer_line4,0,wx.EXPAND) #e.g RYDE NSW Phone 02 1800 222 365 1996 # self.gszr.Add(self.txt_request_requests,0,wx.EXPAND) #e.g FBC;ESR;UEC;LFTS 1997 # self.gszr.Add(self.txt_request_notes,0,wx.EXPAND) #e.g generally tired;weight loss; 1998 # self.gszr.AddSizer(self.sizer_line7,0,wx.EXPAND) #e.g Lipitor;losec;zyprexa 1999 # self.gszr.Add(self.txt_request_copyto,0,wx.EXPAND) #e.g Dr I'm All Heart, 120 Big Street Smallville 2000 # self.gszr.Add(self.txt_request_progressnotes,0,wx.EXPAND) #emphasised to patient must return for results 2001 # self.sizer_line8.Add(5,0,6) 2002 # self.sizer_line8.Add(self.btn_OK,1,wx.EXPAND|wxALL,2) 2003 # self.sizer_line8.Add(self.btn_Clear,1,wx.EXPAND|wxALL,2) 2004 # self.gszr.Add(self.sizer_line10,0,wx.EXPAND) #options:b/bill private, rebate,w/cover btnok,btnclear 2005 2006 2007 # elif section == gmSECTION_MEASUREMENTS: 2008 # self.combo_measurement_type = wx.ComboBox(self, ID_MEASUREMENT_TYPE, "", wx.DefaultPosition,wx.DefaultSize, ['Blood pressure','INR','Height','Weight','Whatever other measurement you want to put in here'], wx.CB_DROPDOWN) 2009 # self.combo_measurement_type.SetFont(wx.Font(12,wx.SWISS,wx.NORMAL, wx.BOLD,False,'')) 2010 # self.combo_measurement_type.SetForegroundColour(wx.Color(255,0,0)) 2011 # self.txt_measurement_value = cEditAreaField(self,ID_MEASUREMENT_VALUE,wx.DefaultPosition,wx.DefaultSize) 2012 # self.txt_txt_measurement_date = cEditAreaField(self,ID_MEASUREMENT_DATE,wx.DefaultPosition,wx.DefaultSize) 2013 # self.txt_txt_measurement_comment = cEditAreaField(self,ID_MEASUREMENT_COMMENT,wx.DefaultPosition,wx.DefaultSize) 2014 # self.txt_txt_measurement_progressnote = cEditAreaField(self,ID_PROGRESSNOTES,wx.DefaultPosition,wx.DefaultSize) 2015 # self.sizer_graphnextbtn = wx.BoxSizer(wxHORIZONTAL) 2016 # self.btn_nextvalue = wx.Button(self,ID_MEASUREMENT_NEXTVALUE," Next Value ") #clear fields except type 2017 # self.btn_graph = wx.Button(self,ID_MEASUREMENT_GRAPH," Graph ") #graph all values of this type 2018 # self.sizer_graphnextbtn.Add(self.btn_nextvalue,1,wx.EXPAND|wxALL,2) #put next and graph button 2019 # self.sizer_graphnextbtn.Add(self.btn_graph,1,wx.EXPAND|wxALL,2) #on same sizer 2020 # self.gszr.Add(self.combo_measurement_type,0,wx.EXPAND) #e.g Blood pressure 2021 # self.gszr.Add(self.txt_measurement_value,0,wx.EXPAND) #e.g 120.70 2022 # self.gszr.Add(self.txt_txt_measurement_date,0,wx.EXPAND) #e.g 10/12/2001 2023 # self.gszr.Add(self.txt_txt_measurement_comment,0,wx.EXPAND) #e.g sitting, right arm 2024 # self.gszr.Add(self.txt_txt_measurement_progressnote,0,wx.EXPAND) #e.g given home BP montitor, see 1 week 2025 # self.sizer_line8.Add(5,0,0) 2026 # self.sizer_line8.Add(self.sizer_graphnextbtn,2,wx.EXPAND) 2027 # self.sizer_line8.Add(5,0,2) 2028 # self.sizer_line8.Add(self.btn_OK,1,wx.EXPAND|wxALL,2) 2029 # self.sizer_line8.Add(self.btn_Clear,1,wx.EXPAND|wxALL,2) 2030 # self.gszr.AddSizer(self.sizer_line8,0,wx.EXPAND) 2031 2032 2033 # elif section == gmSECTION_REFERRALS: 2034 # self.btnpreview = wx.Button(self,-1,"Preview") 2035 # self.sizer_btnpreviewok = wx.BoxSizer(wxHORIZONTAL) 2036 #-------------------------------------------------------- 2037 #editing area for referral letters, insurance letters etc 2038 #create textboxes, checkboxes etc 2039 #-------------------------------------------------------- 2040 # self.txt_referralcategory = cEditAreaField(self,ID_REFERRAL_CATEGORY,wx.DefaultPosition,wx.DefaultSize) 2041 # self.txt_referralname = cEditAreaField(self,ID_REFERRAL_NAME,wx.DefaultPosition,wx.DefaultSize) 2042 # self.txt_referralorganisation = cEditAreaField(self,ID_REFERRAL_ORGANISATION,wx.DefaultPosition,wx.DefaultSize) 2043 # self.txt_referralstreet1 = cEditAreaField(self,ID_REFERRAL_STREET1,wx.DefaultPosition,wx.DefaultSize) 2044 # self.txt_referralstreet2 = cEditAreaField(self,ID_REFERRAL_STREET2,wx.DefaultPosition,wx.DefaultSize) 2045 # self.txt_referralstreet3 = cEditAreaField(self,ID_REFERRAL_STREET3,wx.DefaultPosition,wx.DefaultSize) 2046 # self.txt_referralsuburb = cEditAreaField(self,ID_REFERRAL_SUBURB,wx.DefaultPosition,wx.DefaultSize) 2047 # self.txt_referralpostcode = cEditAreaField(self,ID_REFERRAL_POSTCODE,wx.DefaultPosition,wx.DefaultSize) 2048 # self.txt_referralfor = cEditAreaField(self,ID_REFERRAL_FOR,wx.DefaultPosition,wx.DefaultSize) 2049 # self.txt_referralwphone= cEditAreaField(self,ID_REFERRAL_WPHONE,wx.DefaultPosition,wx.DefaultSize) 2050 # self.txt_referralwfax= cEditAreaField(self,ID_REFERRAL_WFAX,wx.DefaultPosition,wx.DefaultSize) 2051 # self.txt_referralwemail= cEditAreaField(self,ID_REFERRAL_WEMAIL,wx.DefaultPosition,wx.DefaultSize) 2052 #self.txt_referralrequests = cEditAreaField(self,ID_REFERRAL_REQUESTS,wx.DefaultPosition,wx.DefaultSize) 2053 #self.txt_referralnotes = cEditAreaField(self,ID_REFERRAL_FORMNOTES,wx.DefaultPosition,wx.DefaultSize) 2054 #self.txt_referralmedications = cEditAreaField(self,ID_REFERRAL_MEDICATIONS,wx.DefaultPosition,wx.DefaultSize) 2055 # self.txt_referralcopyto = cEditAreaField(self,ID_REFERRAL_COPYTO,wx.DefaultPosition,wx.DefaultSize) 2056 # self.txt_referralprogressnotes = cEditAreaField(self,ID_PROGRESSNOTES,wx.DefaultPosition,wx.DefaultSize) 2057 # self.lbl_referralwphone = cPrompt_edit_area(self,-1," W Phone ") 2058 # self.lbl_referralwfax = cPrompt_edit_area(self,-1," W Fax ") 2059 # self.lbl_referralwemail = cPrompt_edit_area(self,-1," W Email ") 2060 # self.lbl_referralpostcode = cPrompt_edit_area(self,-1," Postcode ") 2061 # self.chkbox_referral_usefirstname = wx.CheckBox(self, -1, " Use Firstname ", wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 2062 # self.chkbox_referral_headoffice = wx.CheckBox(self, -1, " Head Office ", wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 2063 # self.chkbox_referral_medications = wx.CheckBox(self, -1, " Medications ", wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 2064 # self.chkbox_referral_socialhistory = wx.CheckBox(self, -1, " Social History ", wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 2065 # self.chkbox_referral_familyhistory = wx.CheckBox(self, -1, " Family History ", wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 2066 # self.chkbox_referral_pastproblems = wx.CheckBox(self, -1, " Past Problems ", wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 2067 # self.chkbox_referral_activeproblems = wx.CheckBox(self, -1, " Active Problems ", wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 2068 # self.chkbox_referral_habits = wx.CheckBox(self, -1, " Habits ", wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 2069 #self.chkbox_referral_Includeall = wx.CheckBox(self, -1, " Include all of the above ", wx.DefaultPosition,wx.DefaultSize, wx.NO_BORDER) 2070 #-------------------------------------------------------------- 2071 #add controls to sizers where multiple controls per editor line 2072 #-------------------------------------------------------------- 2073 # self.sizer_line2.Add(self.txt_referralname,2,wx.EXPAND) 2074 # self.sizer_line2.Add(self.chkbox_referral_usefirstname,2,wx.EXPAND) 2075 # self.sizer_line3.Add(self.txt_referralorganisation,2,wx.EXPAND) 2076 # self.sizer_line3.Add(self.chkbox_referral_headoffice,2, wx.EXPAND) 2077 # self.sizer_line4.Add(self.txt_referralstreet1,2,wx.EXPAND) 2078 # self.sizer_line4.Add(self.lbl_referralwphone,1,wx.EXPAND) 2079 # self.sizer_line4.Add(self.txt_referralwphone,1,wx.EXPAND) 2080 # self.sizer_line5.Add(self.txt_referralstreet2,2,wx.EXPAND) 2081 # self.sizer_line5.Add(self.lbl_referralwfax,1,wx.EXPAND) 2082 # self.sizer_line5.Add(self.txt_referralwfax,1,wx.EXPAND) 2083 # self.sizer_line6.Add(self.txt_referralstreet3,2,wx.EXPAND) 2084 # self.sizer_line6.Add(self.lbl_referralwemail,1,wx.EXPAND) 2085 # self.sizer_line6.Add(self.txt_referralwemail,1,wx.EXPAND) 2086 # self.sizer_line7.Add(self.txt_referralsuburb,2,wx.EXPAND) 2087 # self.sizer_line7.Add(self.lbl_referralpostcode,1,wx.EXPAND) 2088 # self.sizer_line7.Add(self.txt_referralpostcode,1,wx.EXPAND) 2089 # self.sizer_line10.Add(self.chkbox_referral_medications,1,wx.EXPAND) 2090 # self.sizer_line10.Add(self.chkbox_referral_socialhistory,1,wx.EXPAND) 2091 # self.sizer_line10.Add(self.chkbox_referral_familyhistory,1,wx.EXPAND) 2092 # self.sizer_line11.Add(self.chkbox_referral_pastproblems ,1,wx.EXPAND) 2093 # self.sizer_line11.Add(self.chkbox_referral_activeproblems ,1,wx.EXPAND) 2094 # self.sizer_line11.Add(self.chkbox_referral_habits ,1,wx.EXPAND) 2095 # self.sizer_btnpreviewok.Add(self.btnpreview,0,wx.EXPAND) 2096 # self.szr_buttons.Add(self.btn_Clear,0, wx.EXPAND) 2097 #------------------------------------------------------------------ 2098 #add either controls or sizers with controls to vertical grid sizer 2099 #------------------------------------------------------------------ 2100 # self.gszr.Add(self.txt_referralcategory,0,wx.EXPAND) #e.g Othopaedic surgeon 2101 # self.gszr.Add(self.sizer_line2,0,wx.EXPAND) #e.g Dr B Breaker 2102 # self.gszr.Add(self.sizer_line3,0,wx.EXPAND) #e.g General Orthopaedic servies 2103 # self.gszr.Add(self.sizer_line4,0,wx.EXPAND) #e.g street1 2104 # self.gszr.Add(self.sizer_line5,0,wx.EXPAND) #e.g street2 2105 # self.gszr.Add(self.sizer_line6,0,wx.EXPAND) #e.g street3 2106 # self.gszr.Add(self.sizer_line7,0,wx.EXPAND) #e.g suburb and postcode 2107 # self.gszr.Add(self.txt_referralfor,0,wx.EXPAND) #e.g Referral for an opinion 2108 # self.gszr.Add(self.txt_referralcopyto,0,wx.EXPAND) #e.g Dr I'm All Heart, 120 Big Street Smallville 2109 # self.gszr.Add(self.txt_referralprogressnotes,0,wx.EXPAND) #emphasised to patient must return for results 2110 # self.gszr.AddSizer(self.sizer_line10,0,wx.EXPAND) #e.g check boxes to include medications etc 2111 # self.gszr.Add(self.sizer_line11,0,wx.EXPAND) #e.g check boxes to include active problems etc 2112 #self.spacer = wxWindow(self,-1,wx.DefaultPosition,wx.DefaultSize) 2113 #self.spacer.SetBackgroundColour(wx.Color(255,255,255)) 2114 # self.sizer_line12.Add(5,0,6) 2115 #self.sizer_line12.Add(self.spacer,6,wx.EXPAND) 2116 # self.sizer_line12.Add(self.btnpreview,1,wx.EXPAND|wxALL,2) 2117 # self.sizer_line12.Add(self.btn_Clear,1,wx.EXPAND|wxALL,2) 2118 # self.gszr.Add(self.sizer_line12,0,wx.EXPAND) #btnpreview and btn clear 2119 2120 2121 # elif section == gmSECTION_RECALLS: 2122 #FIXME remove present options in this combo box #FIXME defaults need to be loaded from database 2123 # self.combo_tosee = wx.ComboBox(self, ID_RECALLS_TOSEE, "", wx.DefaultPosition,wx.DefaultSize, ['Doctor1','Doctor2','Nurse1','Dietition'], wx.CB_READONLY ) #wx.CB_DROPDOWN) 2124 # self.combo_tosee.SetFont(wx.Font(12,wx.SWISS,wx.NORMAL, wx.BOLD,False,'')) 2125 # self.combo_tosee.SetForegroundColour(wx.Color(255,0,0)) 2126 #FIXME defaults need to be loaded from database 2127 # self.combo_recall_method = wx.ComboBox(self, ID_RECALLS_CONTACTMETHOD, "", wx.DefaultPosition,wx.DefaultSize, ['Letter','Telephone','Email','Carrier pigeon'], wx.CB_READONLY ) 2128 # self.combo_recall_method.SetFont(wx.Font(12,wx.SWISS,wx.NORMAL, wx.BOLD,False,'')) 2129 # self.combo_recall_method.SetForegroundColour(wx.Color(255,0,0)) 2130 #FIXME defaults need to be loaded from database 2131 # self.combo_apptlength = wx.ComboBox(self, ID_RECALLS_APPNTLENGTH, "", wx.DefaultPosition,wx.DefaultSize, ['brief','standard','long','prolonged'], wx.CB_READONLY ) 2132 # self.combo_apptlength.SetFont(wx.Font(12,wx.SWISS,wx.NORMAL, wx.BOLD,False,'')) 2133 # self.combo_apptlength.SetForegroundColour(wx.Color(255,0,0)) 2134 # self.txt_recall_for = cEditAreaField(self,ID_RECALLS_TXT_FOR, wx.DefaultPosition,wx.DefaultSize) 2135 # self.txt_recall_due = cEditAreaField(self,ID_RECALLS_TXT_DATEDUE, wx.DefaultPosition,wx.DefaultSize) 2136 # self.txt_recall_addtext = cEditAreaField(self,ID_RECALLS_TXT_ADDTEXT,wx.DefaultPosition,wx.DefaultSize) 2137 # self.txt_recall_include = cEditAreaField(self,ID_RECALLS_TXT_INCLUDEFORMS,wx.DefaultPosition,wx.DefaultSize) 2138 # self.txt_recall_progressnotes = cEditAreaField(self,ID_PROGRESSNOTES,wx.DefaultPosition,wx.DefaultSize) 2139 # self.lbl_recall_consultlength = cPrompt_edit_area(self,-1," Appointment length ") 2140 #sizer_lkine1 has the method of recall and the appointment length 2141 # self.sizer_line1.Add(self.combo_recall_method,1,wx.EXPAND) 2142 # self.sizer_line1.Add(self.lbl_recall_consultlength,1,wx.EXPAND) 2143 # self.sizer_line1.Add(self.combo_apptlength,1,wx.EXPAND) 2144 #Now add the controls to the grid sizer 2145 # self.gszr.Add(self.combo_tosee,1,wx.EXPAND) #list of personel for patient to see 2146 # self.gszr.Add(self.txt_recall_for,1,wx.EXPAND) #the actual recall may be free text or word wheel 2147 # self.gszr.Add(self.txt_recall_due,1,wx.EXPAND) #date of future recall 2148 # self.gszr.Add(self.txt_recall_addtext,1,wx.EXPAND) #added explanation e.g 'come fasting' 2149 # self.gszr.Add(self.txt_recall_include,1,wx.EXPAND) #any forms to be sent out first eg FBC 2150 # self.gszr.AddSizer(self.sizer_line1,1,wx.EXPAND) #the contact method, appointment length 2151 # self.gszr.Add(self.txt_recall_progressnotes,1,wx.EXPAND) #add any progress notes for consultation 2152 # self.sizer_line8.Add(5,0,6) 2153 # self.sizer_line8.Add(self.btn_OK,1,wx.EXPAND|wxALL,2) 2154 # self.sizer_line8.Add(self.btn_Clear,1,wx.EXPAND|wxALL,2) 2155 # self.gszr.Add(self.sizer_line8,1,wx.EXPAND) 2156 # else: 2157 # pass 2158 2159 #==================================================================== 2160 # main 2161 #-------------------------------------------------------------------- 2162 if __name__ == "__main__": 2163 2164 #================================================================
2165 - class cTestEditArea(cEditArea):
2166 - def __init__(self, parent):
2167 cEditArea.__init__(self, parent, -1)
2168 - def _define_prompts(self):
2169 self._add_prompt(line=1, label='line 1') 2170 self._add_prompt(line=2, label='buttons')
2171 - def _define_fields(self, parent):
2172 # line 1 2173 self.fld_substance = cEditAreaField(parent) 2174 self._add_field( 2175 line = 1, 2176 pos = 1, 2177 widget = self.fld_substance, 2178 weight = 1 2179 ) 2180 # line 2 2181 self._add_field( 2182 line = 2, 2183 pos = 1, 2184 widget = self._make_standard_buttons(parent), 2185 weight = 1 2186 )
2187 #================================================================ 2188 app = wxPyWidgetTester(size = (400, 200)) 2189 app.SetWidget(cTestEditArea) 2190 app.MainLoop() 2191 # app = wxPyWidgetTester(size = (400, 200)) 2192 # app.SetWidget(gmFamilyHxEditArea, -1) 2193 # app.MainLoop() 2194 # app = wxPyWidgetTester(size = (400, 200)) 2195 # app.SetWidget(gmPastHistoryEditArea, -1) 2196 # app.MainLoop() 2197 #==================================================================== 2198 # $Log: gmEditArea.py,v $ 2199 # Revision 1.134 2009/12/21 15:05:53 ncq 2200 # - add comment 2201 # 2202 # Revision 1.133 2009/11/29 15:59:31 ncq 2203 # - improved boilerplate so people don't fall into the trap of 2204 # self.data being a *property* and thus needing to be set *after* 2205 # all updates to it in _save-as-new ... 2206 # - cleanup 2207 # 2208 # Revision 1.132 2009/11/24 20:55:13 ncq 2209 # - adjust clear/revert button 2210 # 2211 # Revision 1.131 2009/11/17 19:42:54 ncq 2212 # - much improved cut-n-paste boilerplate 2213 # 2214 # Revision 1.130 2009/10/29 17:21:45 ncq 2215 # - safer copy/paste boilerplate 2216 # 2217 # Revision 1.129 2009/09/01 22:30:33 ncq 2218 # - improved docs 2219 # 2220 # Revision 1.128 2009/08/11 10:47:41 ncq 2221 # - improved EA re-parenting 2222 # 2223 # Revision 1.127 2009/07/06 21:17:57 ncq 2224 # - faulty : removed 2225 # 2226 # Revision 1.126 2009/07/06 17:12:13 ncq 2227 # - support a custom message on successful save from "Another" button 2228 # 2229 # Revision 1.125 2009/07/02 20:51:00 ncq 2230 # - fine-tune layout of ea pnl 2231 # 2232 # Revision 1.124 2009/04/21 16:59:59 ncq 2233 # - edit area dlg now takes single_entry argument 2234 # 2235 # Revision 1.123 2009/04/03 09:48:04 ncq 2236 # - better docs 2237 # 2238 # Revision 1.122 2009/01/30 12:10:42 ncq 2239 # - improved docs 2240 # - new style edit area dlg w/o NEXT button 2241 # 2242 # Revision 1.121 2008/07/17 21:41:14 ncq 2243 # - .display_tctrl_as_valid 2244 # 2245 # Revision 1.120 2008/07/13 17:16:28 ncq 2246 # - generic ea dlg 2 type-checks whether ea pnl sublcasses mixin 2247 # 2248 # Revision 1.119 2008/07/13 16:07:03 ncq 2249 # - major cleanup 2250 # - cGenericEditAreaMixin implementing common edit area panel code 2251 # - make generic edit area dialog rev 2 aware of mixin code 2252 # 2253 # Revision 1.118 2008/07/07 13:43:16 ncq 2254 # - current patient .connected 2255 # 2256 # Revision 1.117 2008/06/09 15:34:26 ncq 2257 # - cleanup 2258 # 2259 # Revision 1.116 2008/03/06 18:29:29 ncq 2260 # - standard lib logging only 2261 # 2262 # Revision 1.115 2008/01/30 14:03:42 ncq 2263 # - use signal names directly 2264 # - switch to std lib logging 2265 # 2266 # Revision 1.114 2008/01/05 16:41:27 ncq 2267 # - remove logging from gm_show_*() 2268 # 2269 # Revision 1.113 2007/11/28 14:00:42 ncq 2270 # - cleanup 2271 # 2272 # Revision 1.112 2007/11/17 16:37:46 ncq 2273 # - cleanup 2274 # - cGenericEditAreaDlg 2275 # 2276 # Revision 1.111 2007/08/28 14:18:13 ncq 2277 # - no more gm_statustext() 2278 # 2279 # Revision 1.110 2007/02/22 17:41:13 ncq 2280 # - adjust to gmPerson changes 2281 # 2282 # Revision 1.109 2007/02/05 12:15:23 ncq 2283 # - no more aMatchProvider/selection_only in cPhraseWheel.__init__() 2284 # 2285 # Revision 1.108 2006/11/24 10:01:31 ncq 2286 # - gm_beep_statustext() -> gm_statustext() 2287 # 2288 # Revision 1.107 2006/10/24 13:23:03 ncq 2289 # - comment out removed match providers 2290 # 2291 # Revision 1.106 2006/07/01 15:22:50 ncq 2292 # - add comment on deprecated setDependant() 2293 # 2294 # Revision 1.105 2006/05/15 13:35:59 ncq 2295 # - signal cleanup: 2296 # - activating_patient -> pre_patient_selection 2297 # - patient_selected -> post_patient_selection 2298 # 2299 # Revision 1.104 2006/05/12 12:18:11 ncq 2300 # - whoami -> whereami cleanup 2301 # - use gmCurrentProvider() 2302 # 2303 # Revision 1.103 2006/05/04 09:49:20 ncq 2304 # - get_clinical_record() -> get_emr() 2305 # - adjust to changes in set_active_patient() 2306 # - need explicit set_active_patient() after ask_for_patient() if wanted 2307 # 2308 # Revision 1.102 2005/11/07 21:34:00 ihaywood 2309 # gmForms isn't loaded now (not yet needed) 2310 # 2311 # gmDermTool no longer dependent on my home directory (thanks Sebastian) 2312 # 2313 # Revision 1.101 2005/10/11 21:33:47 ncq 2314 # - improve fix for ID_BTN_* problems 2315 # 2316 # Revision 1.100 2005/10/04 00:04:45 sjtan 2317 # convert to wx.; catch some transitional errors temporarily 2318 # 2319 # Revision 1.99 2005/09/28 21:27:30 ncq 2320 # - a lot of wx2.6-ification 2321 # 2322 # Revision 1.98 2005/09/28 15:57:48 ncq 2323 # - a whole bunch of wx.Foo -> wx.Foo 2324 # 2325 # Revision 1.97 2005/09/27 20:44:58 ncq 2326 # - wx.wx* -> wx.* 2327 # 2328 # Revision 1.96 2005/09/26 18:01:50 ncq 2329 # - use proper way to import wx26 vs wx2.4 2330 # - note: THIS WILL BREAK RUNNING THE CLIENT IN SOME PLACES 2331 # - time for fixup 2332 # 2333 # Revision 1.95 2005/09/26 04:28:52 ihaywood 2334 # fix for wx2.6, use (x, y) for sizer.Add () 2335 # 2336 # Revision 1.94 2005/08/08 08:26:17 ncq 2337 # - explicitely class Close() on edit area in popup so signals are deregistered 2338 # 2339 # Revision 1.93 2005/08/08 08:10:22 ncq 2340 # - cleanup, commenting 2341 # - deregister signals on close() 2342 # 2343 # Revision 1.92 2005/08/07 19:01:48 ncq 2344 # - EditArea2 lacked self._patient which it used and hence produced errors, duh 2345 # 2346 # Revision 1.91 2005/06/29 20:03:11 ncq 2347 # - add proper __init__ defaults to edit area and edit area popup 2348 # 2349 # Revision 1.90 2005/05/05 06:27:00 ncq 2350 # - phrasewheel has renamed methods 2351 # 2352 # Revision 1.89 2005/04/26 20:01:43 ncq 2353 # - cleanup 2354 # 2355 # Revision 1.88 2005/04/25 17:43:55 ncq 2356 # - smooth changeover to from wxPython import wx 2357 # 2358 # Revision 1.87 2005/04/24 14:47:14 ncq 2359 # - add generic edit area popup dialog 2360 # - improve cEditArea2 2361 # 2362 # Revision 1.86 2005/04/20 22:19:01 ncq 2363 # - move std button event registration to after definition of buttons 2364 # 2365 # Revision 1.85 2005/04/18 19:21:57 ncq 2366 # - added cEditArea2 which - being based on a wx.FlexGridSizer - is a lot 2367 # simpler (hence easier to debug) but lacks some eye candy (shadows and 2368 # separate prompt panel) 2369 # 2370 # Revision 1.84 2005/03/20 17:50:15 ncq 2371 # - catch another exception on doing the layout 2372 # 2373 # Revision 1.83 2005/02/03 20:19:16 ncq 2374 # - get_demographic_record() -> get_identity() 2375 # 2376 # Revision 1.82 2005/01/31 10:37:26 ncq 2377 # - gmPatient.py -> gmPerson.py 2378 # 2379 # Revision 1.81 2005/01/31 06:27:18 ncq 2380 # - silly cleanup 2381 # 2382 # Revision 1.80 2004/12/15 22:00:12 ncq 2383 # - cleaned up/improved version of edit area 2384 # - old version still works and emits a conversion incentive 2385 # 2386 # Revision 1.79 2004/10/11 19:54:38 ncq 2387 # - cleanup 2388 # 2389 # Revision 1.78 2004/07/18 20:30:53 ncq 2390 # - wxPython.true/false -> Python.True/False as Python tells us to do 2391 # 2392 # Revision 1.77 2004/07/17 21:16:39 ncq 2393 # - cleanup/refactor allergy widgets: 2394 # - Horst space plugin added 2395 # - Richard space plugin separated out 2396 # - plugin independant GUI code aggregated 2397 # - allergies edit area factor out from generic edit area file 2398 # 2399 # Revision 1.76 2004/07/15 23:28:04 ncq 2400 # - vaccinations edit area factored out 2401 # 2402 # Revision 1.75 2004/06/20 15:48:06 ncq 2403 # - better please epydoc 2404 # 2405 # Revision 1.74 2004/06/20 06:49:21 ihaywood 2406 # changes required due to Epydoc's OCD 2407 # 2408 # Revision 1.73 2004/05/27 13:40:22 ihaywood 2409 # more work on referrals, still not there yet 2410 # 2411 # Revision 1.72 2004/05/18 20:43:17 ncq 2412 # - check get_clinical_record() return status 2413 # 2414 # Revision 1.71 2004/05/16 14:32:51 ncq 2415 # - cleanup 2416 # 2417 # Revision 1.70 2004/04/27 18:43:03 ncq 2418 # - fix _check_unsaved_data() 2419 # 2420 # Revision 1.69 2004/04/24 12:59:17 ncq 2421 # - all shiny and new, vastly improved vaccinations 2422 # handling via clinical item objects 2423 # - mainly thanks to Carlos Moro 2424 # 2425 # Revision 1.68 2004/04/11 10:10:56 ncq 2426 # - cleanup 2427 # 2428 # Revision 1.67 2004/04/10 01:48:31 ihaywood 2429 # can generate referral letters, output to xdvi at present 2430 # 2431 # Revision 1.66 2004/03/28 11:09:04 ncq 2432 # - some cleanup 2433 # 2434 # Revision 1.65 2004/03/28 04:09:31 ihaywood 2435 # referrals can now select an address from pick list. 2436 # 2437 # Revision 1.64 2004/03/10 12:56:01 ihaywood 2438 # fixed sudden loss of main.shadow 2439 # more work on referrals, 2440 # 2441 # Revision 1.63 2004/03/09 13:46:54 ihaywood 2442 # edit area now has resizable lines 2443 # referrals loads with this feature 2444 # BUG: the first line is bigger than the rest: why?? 2445 # 2446 # Revision 1.61 2004/02/25 09:46:22 ncq 2447 # - import from pycommon now, not python-common 2448 # 2449 # Revision 1.60 2004/02/05 23:49:52 ncq 2450 # - use wxCallAfter() 2451 # 2452 # Revision 1.59 2004/02/05 00:26:47 sjtan 2453 # 2454 # converting gmPastHistory to _define.., _generate.. style. 2455 # 2456 # Revision 1.58 2004/02/02 22:28:23 ncq 2457 # - OK now inits the edit area as per Richard's specs 2458 # 2459 # Revision 1.57 2004/01/26 22:15:32 ncq 2460 # - don't duplicate "Serial #" label 2461 # 2462 # Revision 1.56 2004/01/26 18:25:07 ncq 2463 # - some attribute names changed in the backend 2464 # 2465 # Revision 1.55 2004/01/24 10:24:17 ncq 2466 # - method rename for consistency 2467 # 2468 # Revision 1.54 2004/01/22 23:42:19 ncq 2469 # - follow Richard's GUI specs more closely on standard buttons 2470 # 2471 # Revision 1.53 2004/01/21 14:00:09 ncq 2472 # - no delete button as per Richards order :-) 2473 # 2474 # Revision 1.52 2004/01/18 21:51:36 ncq 2475 # - better tooltips on standard buttons 2476 # - simplify vaccination edit area 2477 # - vaccination - _save_modified_entry() 2478 # 2479 # Revision 1.51 2004/01/12 16:23:29 ncq 2480 # - SetValueStyle() -> _decorate_editarea_field() 2481 # - add phrase wheels to vaccination edit area 2482 # 2483 # Revision 1.50 2003/12/29 16:48:14 uid66147 2484 # - try to merge the "good" concepts so far 2485 # - overridden _define_fields|prompts() now use generic _add_field|prompt() 2486 # helpers to define the layout 2487 # - generic do_layout() actually creates the layout 2488 # - generic _on_*_button_pressed() now call overridden _save_new|updated_entry() 2489 # - apply concepts to vaccination and allergy edit areas 2490 # - vaccination edit area actually saves new entries by way of gmClinicalRecord.add_vaccination() 2491 # - other edit areas still broken 2492 # 2493 # Revision 1.49 2003/12/02 02:03:35 ncq 2494 # - improve logging 2495 # 2496 # Revision 1.48 2003/12/02 02:01:24 ncq 2497 # - cleanup 2498 # 2499 # Revision 1.47 2003/12/01 01:04:01 ncq 2500 # - remove excess verbosity 2501 # 2502 # Revision 1.46 2003/11/30 01:08:25 ncq 2503 # - removed dead yaml code 2504 # 2505 # Revision 1.45 2003/11/29 01:32:55 ncq 2506 # - fix no-exit-without-patient error 2507 # - start cleaning up the worst mess 2508 # 2509 # Revision 1.44 2003/11/28 16:20:31 hinnef 2510 # - commented out all yaml code; this code should be removed lateron 2511 # 2512 # Revision 1.43 2003/11/25 16:38:46 hinnef 2513 # - adjust field sizes in requests, measurements and vaccinations 2514 # 2515 # Revision 1.42 2003/11/22 02:02:53 ihaywood 2516 # fixed syntax errors 2517 # 2518 # Revision 1.41 2003/11/20 22:43:24 hinnef 2519 # added save_data() methods to prevent hanging up on exit 2520 # 2521 # Revision 1.40 2003/11/20 01:37:09 ncq 2522 # - no code in gmEditArea has any business of calling 2523 # gmCurrentPatient() with an explicit ID 2524 # 2525 # Revision 1.39 2003/11/19 23:23:53 sjtan 2526 # 2527 # extract birthyear from gmDateTime object returned by gmDemographicRecord.getDOB() locally. 2528 # 2529 # Revision 1.38 2003/11/19 13:55:57 ncq 2530 # - Syans forgot to accept kw arg list in _check_unsaved_data() 2531 # 2532 # Revision 1.37 2003/11/17 10:56:37 sjtan 2533 # 2534 # synced and commiting. 2535 # 2536 # Revision 1.6 2003/10/26 00:58:53 sjtan 2537 # 2538 # use pre-existing signalling 2539 # 2540 # Revision 1.5 2003/10/25 16:13:26 sjtan 2541 # 2542 # past history , can add after selecting patient. 2543 # 2544 # Revision 1.4 2003/10/25 08:29:40 sjtan 2545 # 2546 # uses gmDispatcher to send new currentPatient objects to toplevel gmGP_ widgets. Proprosal to use 2547 # yaml serializer to store editarea data in narrative text field of clin_root_item until 2548 # clin_root_item schema stabilizes. 2549 # 2550 # Revision 1.3 2003/10/24 04:20:17 sjtan 2551 # 2552 # yaml side-effect code; remove later if not useful. 2553 # 2554 # Revision 1.2 2003/10/24 03:50:36 sjtan 2555 # 2556 # make sure smaller widgets such as checkboxes and radiobuttons on input_fields; 2557 # "pastable" yaml input_field maps output from print statements. 2558 # 2559 # Revision 1.1 2003/10/23 06:02:39 sjtan 2560 # 2561 # manual edit areas modelled after r.terry's specs. 2562 # 2563 # Revision 1.35 2003/10/19 12:16:48 ncq 2564 # - cleanup 2565 # - add event handlers to standard buttons 2566 # - fix gmDateInput args breakage 2567 # 2568 # Revision 1.34 2003/09/21 00:24:19 sjtan 2569 # 2570 # rollback. 2571 # 2572 # Revision 1.32 2003/06/24 12:58:15 ncq 2573 # - added TODO item 2574 # 2575 # Revision 1.31 2003/06/01 01:47:33 sjtan 2576 # 2577 # starting allergy connections. 2578 # 2579 # Revision 1.30 2003/05/27 16:02:03 ncq 2580 # - some comments, some cleanup; I like the direction we are heading 2581 # 2582 # Revision 1.29 2003/05/27 14:08:51 sjtan 2583 # 2584 # read the gmLog now. 2585 # 2586 # Revision 1.28 2003/05/27 14:04:42 sjtan 2587 # 2588 # test events mapping field values on ok button press: K + I were right, 2589 # this is a lot more direct than handler scripting; just needed the additional 2590 # programming done on the ui (per K). 2591 # 2592 # Revision 1.27 2003/05/27 13:18:54 ncq 2593 # - coding style, as usual... 2594 # 2595 # Revision 1.26 2003/05/27 13:00:41 sjtan 2596 # 2597 # removed redundant property support, read directly from __dict__ 2598 # 2599 # Revision 1.25 2003/05/26 15:42:52 ncq 2600 # - some minor coding style cleanup here and there, hopefully don't break Syan's work 2601 # 2602 # Revision 1.24 2003/05/26 15:14:36 sjtan 2603 # 2604 # ok , following the class style of gmEditArea refactoring. 2605 # 2606 # Revision 1.23 2003/05/26 14:16:16 sjtan 2607 # 2608 # now trying to use the global capitalized ID to differentiate fields through one 2609 # checkbox, text control , button event handlers. Any controls without ID need 2610 # to have one defined. Propose to save the fields as a simple list on root item, 2611 # until the subclass tables of root_item catch up. Slow work because manual, but 2612 # seems to be what the doctor(s) ordered. 2613 # 2614 # Revision 1.22 2003/05/25 04:43:15 sjtan 2615 # 2616 # PropertySupport misuse for notifying Configurator objects during gui construction, 2617 # more debugging info 2618 # 2619 # Revision 1.21 2003/05/23 14:39:35 ncq 2620 # - use gmDateInput widget in gmAllergyEditArea 2621 # 2622 # Revision 1.20 2003/05/21 15:09:18 ncq 2623 # - log warning on use of old style edit area 2624 # 2625 # Revision 1.19 2003/05/21 14:24:29 ncq 2626 # - re-added old lines generating code for reference during conversion 2627 # 2628 # Revision 1.18 2003/05/21 14:11:26 ncq 2629 # - much needed rewrite/cleanup of gmEditArea 2630 # - allergies/family history edit area adapted to new gmEditArea code 2631 # - old code still there for non-converted edit areas 2632 # 2633 # Revision 1.17 2003/02/14 01:24:54 ncq 2634 # - cvs metadata keywords 2635 # 2636