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