1 """GnuMed scrolled window text dump of EMR content.
2 """
3
4
5
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
28
30 self.txt = wx.TextCtrl(
31 self,
32 -1,
33 _('No EMR data loaded.'),
34 style = wx.TE_MULTILINE | wx.TE_READONLY
35 )
36
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
40 self.SetAutoLayout(1)
41 self.SetSizer(szr_outer)
42 szr_outer.Fit(self)
43 szr_outer.SetSizeHints(self)
44 self.Layout()
45
47
48 gmDispatcher.connect(signal = u'post_patient_selection', receiver = self._on_post_patient_selection)
49 return 1
50
53
54
56 pat = gmPerson.gmCurrentPatient()
57
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
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
113 self.EnableScrolling(0, 1)
114 self.SetScrollRate(0, 20)
115 wx.CallAfter(self.Scroll, 0, 0)
116
117
118
119