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

Source Code for Module Gnumed.wxpython.gmEMRTimelineWidgets

 1  """GNUmed patient EMR timeline browser. 
 2   
 3  Uses the excellent TheTimlineProject. 
 4  """ 
 5  #================================================================ 
 6  __author__ = "Karsten.Hilbert@gmx.net" 
 7  __license__ = "GPL v2 or later" 
 8   
 9  # std lib 
10  import sys 
11  import logging 
12  #os.path, codecs 
13   
14   
15  # 3rd party 
16  import wx 
17   
18   
19  # GNUmed libs 
20  if __name__ == '__main__': 
21          sys.path.insert(0, '../../') 
22  from Gnumed.timelinelib.wxgui.component import TimelineComponent 
23  from Gnumed.timelinelib.db.exceptions import TimelineIOError 
24   
25  from Gnumed.pycommon import gmDispatcher 
26  from Gnumed.business import gmPerson 
27  from Gnumed.wxpython import gmRegetMixin 
28  from Gnumed.exporters import timeline 
29   
30   
31  _log = logging.getLogger('gm.ui') 
32   
33  #============================================================ 
34 -class cEMRTimelinePnl(TimelineComponent):
35
36 - def __init__(self, *args, **kwargs):
37 # TimelineComponent.__init__(self, *args, **kwargs) 38 # def __init__(self, parent): 39 TimelineComponent.__init__(self, args[0])
40 41 #============================================================ 42 from Gnumed.wxGladeWidgets import wxgEMRTimelinePluginPnl 43
44 -class cEMRTimelinePluginPnl(wxgEMRTimelinePluginPnl.wxgEMRTimelinePluginPnl, gmRegetMixin.cRegetOnPaintMixin):
45 """Panel holding a number of widgets. Used as notebook page."""
46 - def __init__(self, *args, **kwargs):
47 wxgEMRTimelinePluginPnl.wxgEMRTimelinePluginPnl.__init__(self, *args, **kwargs) 48 gmRegetMixin.cRegetOnPaintMixin.__init__(self) 49 # self.__init_ui() 50 self.__register_interests()
51 #-------------------------------------------------------- 52 # event handling 53 #--------------------------------------------------------
54 - def __register_interests(self):
55 gmDispatcher.connect(signal = u'pre_patient_selection', receiver = self._on_pre_patient_selection)
56 # gmDispatcher.connect(signal = u'post_patient_selection', receiver = self._schedule_data_reget) 57 #--------------------------------------------------------
59 wx.CallAfter(self.__on_pre_patient_selection)
60 #--------------------------------------------------------
62 self._PNL_timeline.clear_timeline()
63 #--------------------------------------------------------
64 - def _on_refresh_button_pressed(self, event):
65 self._populate_with_data()
66 #--------------------------------------------------------
67 - def repopulate_ui(self):
68 self._populate_with_data()
69 #-------------------------------------------------------- 70 # internal API 71 #-------------------------------------------------------- 72 # def __init_ui(self): 73 # pass 74 #-------------------------------------------------------- 75 # reget mixin API 76 # 77 # remember to call 78 # self._schedule_data_reget() 79 # whenever you learn of data changes from database 80 # listener threads, dispatcher signals etc. 81 #--------------------------------------------------------
82 - def _populate_with_data(self):
83 pat = gmPerson.gmCurrentPatient() 84 if not pat.connected: 85 return True 86 try: 87 self._PNL_timeline.open_timeline(timeline.create_timeline_file(patient = pat)) 88 except: 89 # except TimelineIOError: 90 _log.exception('cannot load EMR from timeline XML') 91 self._PNL_timeline.clear_timeline() 92 self._PNL_timeline.open_timeline(timeline.create_fake_timeline_file(patient = pat)) 93 return True 94 95 return True
96 #============================================================ 97