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

Source Code for Module Gnumed.wxpython.gmEMRTextDump

  1  """GnuMed scrolled window text dump of EMR content. 
  2  """ 
  3  #============================================================ 
  4  # $Source: /cvsroot/gnumed/gnumed/gnumed/client/wxpython/gmEMRTextDump.py,v $ 
  5  # $Id: gmEMRTextDump.py,v 1.22 2008/07/07 13:43:16 ncq Exp $ 
  6  __version__ = "$Revision: 1.22 $" 
  7  __author__ = "K.Hilbert <Karsten.Hilbert@gmx.net>" 
  8   
  9  import sys, string 
 10   
 11   
 12  import wx 
 13   
 14   
 15  from Gnumed.pycommon import gmDispatcher, gmExceptions 
 16  from Gnumed.business import gmPerson 
 17   
 18   
 19  _log = gmLog.gmDefLog 
 20  #============================================================ 
21 -class gmEMRDumpPanel(wx.Panel):
22 - def __init__(self, *args, **kwargs):
23 wx.Panel.__init__(self, *args, **kwargs) 24 self.__do_layout() 25 26 if not self.__register_events(): 27 raise gmExceptions.ConstructorError, 'cannot register interests'
28 #--------------------------------------------------------
29 - def __do_layout(self):
30 self.txt = wx.TextCtrl( 31 self, 32 -1, 33 _('No EMR data loaded.'), 34 style = wx.TE_MULTILINE | wx.TE_READONLY 35 ) 36 # arrange widgets 37 szr_outer = wx.StaticBoxSizer(wx.StaticBox(self, -1, _("EMR text dump")), wx.VERTICAL) 38 szr_outer.Add(self.txt, 1, wx.EXPAND, 0) 39 # and do layout 40 self.SetAutoLayout(1) 41 self.SetSizer(szr_outer) 42 szr_outer.Fit(self) 43 szr_outer.SetSizeHints(self) 44 self.Layout()
45 #--------------------------------------------------------
46 - def __register_events(self):
47 # client internal signals 48 gmDispatcher.connect(signal = u'post_patient_selection', receiver = self._on_post_patient_selection) 49 return 1
50 #--------------------------------------------------------
51 - def _on_post_patient_selection(self):
52 pass
53 # FIXME: if has_focus ... 54 #--------------------------------------------------------
55 - def populate(self):
56 pat = gmPerson.gmCurrentPatient() 57 # this should not really happen 58 if not pat.connected: 59 _log.Log(gmLog.lErr, 'no active patient, cannot get EMR text dump') 60 self.txt.SetValue(_('Currently there is no active patient. Cannot retrieve EMR text.')) 61 return None 62 emr = pat.get_emr() 63 if emr is None: 64 _log.Log(gmLog.lErr, 'cannot get EMR text dump') 65 self.txt.SetValue(_( 66 'An error occurred while retrieving a text\n' 67 'dump of the EMR for the active patient.\n\n' 68 'Please check the log file for details.' 69 )) 70 return None 71 dump = emr.get_text_dump() 72 if dump is None: 73 _log.Log(gmLog.lErr, 'cannot get EMR text dump') 74 self.txt.SetValue(_( 75 'An error occurred while retrieving a text\n' 76 'dump of the EMR for the active patient.\n\n' 77 'Please check the log file for details.' 78 )) 79 return None 80 keys = dump.keys() 81 keys.sort() 82 txt = '' 83 for age in keys: 84 for line in dump[age]: 85 txt = txt + "%s\n" % line 86 self.txt.SetValue(txt) 87 return True
88 #============================================================
89 -class gmScrolledEMRTextDump(wx.ScrolledWindow):
90 - def __init__(self, parent):
91 wx.ScrolledWindow.__init__( 92 self, 93 parent, 94 -1 95 ) 96 self.txt = wx.TextCtrl( 97 self, 98 -1, 99 _('No EMR data loaded.'), 100 style = wx.TE_MULTILINE | wx.TE_READONLY 101 ) 102 szr_vbox_main = wx.BoxSizer(wx.VERTICAL) 103 szr_vbox_main.Add(self.txt, 0, wxEXPAND | wx.CENTER | wx.ALL, 5) 104 105 self.SetAutoLayout(1) 106 self.SetSizer(szr_vbox_main) 107 szr_vbox_main.Fit(self) 108 szr_vbox_main.SetSizeHints(self) 109 szr_vbox_main.SetVirtualSizeHints(self) 110 self.Layout() 111 112 # scroll back to top after initial events 113 self.EnableScrolling(0, 1) 114 self.SetScrollRate(0, 20) 115 wx.CallAfter(self.Scroll, 0, 0)
116 117 118 #============================================================ 119 # $Log: gmEMRTextDump.py,v $ 120 # Revision 1.22 2008/07/07 13:43:16 ncq 121 # - current patient .connected 122 # 123 # Revision 1.21 2008/03/06 18:29:29 ncq 124 # - standard lib logging only 125 # 126 # Revision 1.20 2008/01/30 14:03:41 ncq 127 # - use signal names directly 128 # - switch to std lib logging 129 # 130 # Revision 1.19 2008/01/22 12:21:49 ncq 131 # - cleanup 132 # 133 # Revision 1.18 2006/07/19 20:29:50 ncq 134 # - import cleanup 135 # 136 # Revision 1.17 2006/05/15 13:35:59 ncq 137 # - signal cleanup: 138 # - activating_patient -> pre_patient_selection 139 # - patient_selected -> post_patient_selection 140 # 141 # Revision 1.16 2006/05/04 09:49:20 ncq 142 # - get_clinical_record() -> get_emr() 143 # - adjust to changes in set_active_patient() 144 # - need explicit set_active_patient() after ask_for_patient() if wanted 145 # 146 # Revision 1.15 2005/09/28 21:27:30 ncq 147 # - a lot of wx2.6-ification 148 # 149 # Revision 1.14 2005/09/28 15:57:48 ncq 150 # - a whole bunch of wx.Foo -> wx.Foo 151 # 152 # Revision 1.13 2005/09/26 18:01:50 ncq 153 # - use proper way to import wx26 vs wx2.4 154 # - note: THIS WILL BREAK RUNNING THE CLIENT IN SOME PLACES 155 # - time for fixup 156 # 157 # Revision 1.12 2005/01/31 10:37:26 ncq 158 # - gmPatient.py -> gmPerson.py 159 # 160 # Revision 1.11 2004/06/13 22:31:48 ncq 161 # - gb['main.toolbar'] -> gb['main.top_panel'] 162 # - self.internal_name() -> self.__class__.__name__ 163 # - remove set_widget_reference() 164 # - cleanup 165 # - fix lazy load in _on_patient_selected() 166 # - fix lazy load in ReceiveFocus() 167 # - use self._widget in self.GetWidget() 168 # - override populate_with_data() 169 # - use gb['main.notebook.raised_plugin'] 170 # 171 # Revision 1.10 2004/03/09 10:51:50 ncq 172 # - cleanup 173 # 174 # Revision 1.9 2004/03/09 10:12:41 shilbert 175 # - adapt to new API from Gnumed.foo import bar 176 # 177 # Revision 1.8 2004/02/25 09:46:22 ncq 178 # - import from pycommon now, not python-common 179 # 180 # Revision 1.7 2004/02/05 23:49:52 ncq 181 # - use wxCallAfter() 182 # 183 # Revision 1.6 2003/11/17 10:56:37 sjtan 184 # 185 # synced and commiting. 186 # 187 # Revision 1.5 2003/11/11 18:21:30 ncq 188 # - cleanup 189 # 190 # Revision 1.4 2003/11/09 14:27:46 ncq 191 # - clinical record has new API style 192 # 193 # Revision 1.3 2003/10/26 01:36:13 ncq 194 # - gmTmpPatient -> gmPatient 195 # 196 # Revision 1.2 2003/07/19 20:20:59 ncq 197 # - use panel instead of scrolled window so it actually works nicely 198 # - maybe later put panel inside scrolled window... 199 # - code cleanup 200 # 201 # Revision 1.1 2003/07/03 15:27:08 ncq 202 # - first chekin 203