1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977
|
# -*- coding: iso-8859-1 -*-
"""GNUmed GUI client
The application framework and main window of the
all signing all dancing GNUmed reference client.
This source code is protected by the GPL licensing scheme.
Details regarding the GPL are available at http://www.gnu.org
You may use and share it as long as you don't deny this right
to anybody else.
copyright: authors
"""
#==============================================================================
# $Source: /sources/gnumed/gnumed/gnumed/client/wxpython/gmGuiMain.py,v $
# $Id: gmGuiMain.py,v 1.265 2006/08/11 13:10:08 ncq Exp $
__version__ = "$Revision: 1.265 $"
__author__ = "H. Herb <hherb@gnumed.net>,\
K. Hilbert <Karsten.Hilbert@gmx.net>,\
I. Haywood <i.haywood@ugrad.unimelb.edu.au>"
__license__ = 'GPL (details at http://www.gnu.org)'
import sys, time, os, cPickle, zlib, locale
# do not check inside py2exe and friends
if not hasattr(sys, 'frozen'):
try:
import wxversion
wxversion.select(versions='2.6-unicode', optionsRequired=True)
except ImportError:
print "GNUmed startup: Cannot import wxPython version selection support."
print "GNUmed startup: Installing 'wxversion' version selection is highly"
print "GNUmed startup: recommended. For details, see here:"
print "GNUmed startup: http://wiki.wxpython.org/index.cgi/MultiVersionInstalls"
print "GNUmed startup: Starting anyways and hoping for the best:"
print "GNUmed startup: wxPython must be > v2.6 and unicode-enabled"
except wxversion.VersionError:
print "GNUmed startup: Cannot import proper wxPython library version."
print "GNUmed startup: wxPython 2.6.x with unicode support is required."
print 'CRITICAL ERROR: Proper wxPython version not found. Halted.'
raise
try:
import wx
except ImportError:
print "GNUmed startup: Cannot import wxPython library."
print "GNUmed startup: Make sure wxPython is installed."
print 'CRITICAL ERROR: Error importing wxPython. Halted.'
raise
version = '%s.%s' % (wx.MAJOR_VERSION, wx.MINOR_VERSION)
if (version != '2.6') or ('unicode' not in wx.PlatformInfo):
print "GNUmed startup: Unsupported wxPython version (%s: %s)." % (wx.VERSION_STRING, wx.PlatformInfo)
print "GNUmed startup: wxPython 2.6.x with unicode support is required."
print 'CRITICAL ERROR: Proper wxPython version not found. Halted.'
raise ValueError('wxPython 2.6.x with unicode support not found')
from Gnumed.pycommon import gmLog, gmCfg, gmPG, gmDispatcher, gmSignals, gmCLI, gmGuiBroker, gmI18N, gmExceptions
from Gnumed.wxpython import gmGuiHelpers, gmHorstSpace, gmRichardSpace, gmEMRBrowser, gmDemographicsWidgets, gmEMRStructWidgets, gmEditArea, gmStaffWidgets, gmMedDocWidgets, gmPatSearchWidgets
from Gnumed.business import gmPerson
from Gnumed.exporters import gmPatientExporter
try:
_('do-not-translate-but-make-epydoc-happy')
except NameError:
_ = lambda x:x
_cfg = gmCfg.gmDefCfgFile
_provider = None
email_logger = None
_log = gmLog.gmDefLog
_log.Log(gmLog.lInfo, __version__)
_log.Log(gmLog.lInfo, 'wxPython GUI framework: %s %s' % (wx.VERSION_STRING, wx.PlatformInfo))
# set up database connection encoding
encoding = {}
enc = _cfg.get('backend', 'wire encoding')
if enc is None:
encoding['wire'] = locale.getlocale()[1]
else:
encoding['wire'] = enc
enc = _cfg.get('backend', 'string encoding')
if enc is None:
encoding['string'] = locale.getlocale()[1]
else:
encoding['string'] = enc
gmPG.set_default_client_encoding(encoding)
# set up database connection timezone
timezone = _cfg.get('backend', 'client timezone')
if timezone is not None:
gmPG.set_default_client_timezone(timezone)
ID_ABOUT = wx.NewId ()
ID_CONTRIBUTORS = wx.NewId()
ID_EXIT = wx.NewId ()
ID_HELP = wx.NewId ()
ID_NOTEBOOK = wx.NewId ()
ID_LEFTBOX = wx.NewId ()
ID_EXPORT_EMR = wx.NewId()
ID_EXPORT_EMR_JOURNAL = wx.NewId()
ID_EXPORT_MEDISTAR = wx.NewId()
ID_CREATE_PATIENT = wx.NewId()
ID_SEARCH_PATIENT = wx.NewId()
ID_SEARCH_EMR = wx.NewId()
ID_ADD_HEALTH_ISSUE_TO_EMR = wx.NewId()
ID_DERMTOOL = wx.NewId ()
ID_ENLIST_PATIENT_AS_STAFF = wx.NewId()
ID_ADD_NEW_STAFF = wx.NewId()
ID_EMR_SUMMARY = wx.NewId()
#==============================================================================
icon_serpent = \
"""x\xdae\x8f\xb1\x0e\x83 \x10\x86w\x9f\xe2\x92\x1blb\xf2\x07\x96\xeaH:0\xd6\
\xc1\x85\xd5\x98N5\xa5\xef?\xf5N\xd0\x8a\xdcA\xc2\xf7qw\x84\xdb\xfa\xb5\xcd\
\xd4\xda;\xc9\x1a\xc8\xb6\xcd<\xb5\xa0\x85\x1e\xeb\xbc\xbc7b!\xf6\xdeHl\x1c\
\x94\x073\xec<*\xf7\xbe\xf7\x99\x9d\xb21~\xe7.\xf5\x1f\x1c\xd3\xbdVlL\xc2\
\xcf\xf8ye\xd0\x00\x90\x0etH \x84\x80B\xaa\x8a\x88\x85\xc4(U\x9d$\xfeR;\xc5J\
\xa6\x01\xbbt9\xceR\xc8\x81e_$\x98\xb9\x9c\xa9\x8d,y\xa9t\xc8\xcf\x152\xe0x\
\xe9$\xf5\x07\x95\x0cD\x95t:\xb1\x92\xae\x9cI\xa8~\x84\x1f\xe0\xa3ec"""
#==============================================================================
class gmTopLevelFrame(wx.Frame):
"""GNUmed client's main windows frame.
This is where it all happens. Avoid popping up any other windows.
Most user interaction should happen to and from widgets within this frame
"""
#----------------------------------------------
def __init__(self, parent, id, title, size=wx.DefaultSize, layout=None):
"""You'll have to browse the source to understand what the constructor does
"""
wx.Frame.__init__(
self,
parent,
id,
title,
size,
style = wx.DEFAULT_FRAME_STYLE
)
#initialize the gui broker
self.__gb = gmGuiBroker.GuiBroker()
self.__gb['EmergencyExit'] = self._clean_exit
self.__gb['main.frame'] = self
self.bar_width = -1
_log.Log(gmLog.lData, 'workplace is >>>%s<<<' % gmPerson.gmCurrentProvider().get_workplace())
self.__setup_main_menu()
self.SetupStatusBar()
self.SetStatusText(_('You are logged in as %s%s.%s (%s). DB account <%s>.') % (
_provider['title'],
_provider['firstnames'][:1],
_provider['lastnames'],
_provider['short_alias'],
_provider['db_user']
))
self.__gb['main.statustext'] = self.SetStatusText
# set window title via template
if self.__gb['main.slave_mode']:
self.__title_template = _('Slave GNUmed [%s%s.%s@%s] %s: %s')
else:
self.__title_template = 'GNUmed [%s%s.%s@%s] %s: %s'
self.updateTitle(anActivity = _("idle"))
self.__setup_platform()
# let others have access, too
self.__gb['main.SetWindowTitle'] = self.updateTitle
if layout is None:
# get plugin layout style
cfg = gmCfg.cCfgSQL()
self.layout_style = cfg.get_by_workplace (
option = 'main.window.layout_style',
workplace = gmPerson.gmCurrentProvider().get_workplace(),
default = 'status_quo'
)
#----------------------
# create layout manager
#----------------------
if self.layout_style == 'status_quo':
_log.Log(gmLog.lInfo, 'loading Horst space layout manager')
self.LayoutMgr = gmHorstSpace.cHorstSpaceLayoutMgr(self, -1)
elif self.layout_style == 'terry':
_log.Log(gmLog.lInfo, "loading Richard Terry's layout manager")
self.LayoutMgr = gmRichardSpace.cLayoutMgr(self, -1)
else:
_log.Log(gmLog.lInfo, 'loading Horst space layout manager as default (option is missing)')
self.LayoutMgr = gmHorstSpace.cHorstSpaceLayoutMgr(self, -1)
else:
# layout class is explicitly provided, use that
_log.Log (gmLog.lInfo, "loading %s as toplevel" % layout)
l = layout.split (".")
self.LayoutMgr = getattr (__import__ (".".join (l[:-1])), l[-1]) (self, -1)
# set window icon
icon_bmp_data = wx.BitmapFromXPMData(cPickle.loads(zlib.decompress(icon_serpent)))
icon = wx.EmptyIcon()
icon.CopyFromBitmap(icon_bmp_data)
self.SetIcon(icon)
self.acctbl = []
self.__gb['main.accelerators'] = self.acctbl
self.__register_events()
self.vbox = wx.BoxSizer(wx.VERTICAL)
self.vbox.Add(self.LayoutMgr, 10, wx.EXPAND | wx.ALL, 1)
self.SetAutoLayout(True)
self.SetSizerAndFit(self.vbox)
# don't allow the window to get too small
# setsizehints only allows minimum size, therefore window can't become small enough
# effectively we need the font size to be configurable according to screen size
#self.vbox.SetSizeHints(self)
self.__set_GUI_size()
self.Centre(wx.BOTH)
self.Show(True)
#----------------------------------------------
def __set_GUI_size(self):
"""Try to get previous window size from backend."""
desired_width, desired_height = (640,480)
cfg = gmCfg.cCfgSQL()
# width
prev_width = cfg.get_by_workplace (
option = 'main.window.width',
workplace = gmPerson.gmCurrentProvider().get_workplace(),
default = desired_width
)
if prev_width is not None:
desired_width = int(prev_width)
# height
prev_height = cfg.get_by_workplace (
option = 'main.window.height',
workplace = gmPerson.gmCurrentProvider().get_workplace(),
default = desired_height
)
if prev_height is not None:
desired_height = int(prev_height)
_log.Log(gmLog.lData, 'setting GUI size to [%s:%s]' % (desired_width, desired_height))
self.SetClientSize(wx.Size(desired_width, desired_height))
#----------------------------------------------
def __setup_platform(self):
#do the platform dependent stuff
if wx.Platform == '__WXMSW__':
#windoze specific stuff here
_log.Log(gmLog.lInfo,'running on MS Windows')
elif wx.Platform == '__WXGTK__':
#GTK (Linux etc.) specific stuff here
_log.Log(gmLog.lInfo,'running on GTK (probably Linux)')
elif wx.Platform == '__WXMAC__':
#Mac OS specific stuff here
_log.Log(gmLog.lInfo,'running on Mac OS')
else:
_log.Log(gmLog.lInfo,'running on an unknown platform (%s)' % wx.Platform)
#----------------------------------------------
def __setup_accelerators(self):
self.acctbl.append ((wx.ACCEL_ALT | wx.ACCEL_CTRL, ord('X'), ID_EXIT))
self.acctbl.append ((wx.ACCEL_CTRL, ord('H'), ID_HELP))
self.SetAcceleratorTable(wx.AcceleratorTable(self.acctbl))
#----------------------------------------------
def __setup_main_menu(self):
"""Create the main menu entries.
Individual entries are farmed out to the modules.
"""
# create main menu
self.mainmenu = wx.MenuBar()
self.__gb['main.mainmenu'] = self.mainmenu
# menu "GNUmed"
menu_gnumed = wx.Menu()
# menu_gnumed.AppendSeparator()
menu_gnumed.Append(ID_EXIT, _('E&xit\tAlt-X'), _('Close this GNUmed client'))
wx.EVT_MENU(self, ID_EXIT, self.OnFileExit)
self.mainmenu.Append(menu_gnumed, '&GNUmed')
# -- menu "Administration" --------------------
menu_admin = wx.Menu()
# FIXME: regroup into sub-menus
menu_admin.Append(ID_ADD_NEW_STAFF, _('Add staff member'), _('Add a new staff member'))
wx.EVT_MENU(self, ID_ADD_NEW_STAFF, self.__on_add_new_staff)
ID_DEL_STAFF = wx.NewId()
menu_admin.Append(ID_DEL_STAFF, _('Edit staff list'), _('Edit the list of staff'))
wx.EVT_MENU(self, ID_DEL_STAFF, self.__on_edit_staff_list)
# - draw a line
menu_admin.AppendSeparator()
ID_EDIT_DOC_TYPES = wx.NewId()
menu_admin.Append(ID_EDIT_DOC_TYPES, _('Edit document types'), _('Edit the list of document types available in the system.'))
wx.EVT_MENU(self, ID_EDIT_DOC_TYPES, self.__on_edit_doc_types)
self.mainmenu.Append(menu_admin, _('&Administration'))
# -- menu "Patient" ---------------------------
menu_patient = wx.Menu()
ID_LOAD_EXT_PAT = wx.NewId()
menu_patient.Append(ID_LOAD_EXT_PAT, _('Load external patient'), _('Load patient from an external source.'))
wx.EVT_MENU(self, ID_LOAD_EXT_PAT, self.__on_load_external_patient)
menu_patient.Append(ID_CREATE_PATIENT, _('Register new patient'), _("Register a new patient with this practice"))
wx.EVT_MENU(self, ID_CREATE_PATIENT, self.__on_create_patient)
ID_DEL_PAT = wx.NewId()
menu_patient.Append(ID_DEL_PAT, _('Delete patient'), _('Deactivate patient in database.'))
wx.EVT_MENU(self, ID_DEL_PAT, self.__on_delete_patient)
menu_patient.Append(ID_ENLIST_PATIENT_AS_STAFF, _('Enlist as staff'), _('Enlist current patient as staff member'))
wx.EVT_MENU(self, ID_ENLIST_PATIENT_AS_STAFF, self.__on_enlist_patient_as_staff)
self.mainmenu.Append(menu_patient, '&Patient')
self.__gb['main.patientmenu'] = menu_patient
# -- menu "EMR" ---------------------------
menu_emr = wx.Menu()
self.mainmenu.Append(menu_emr, _("&EMR"))
self.__gb['main.emrmenu'] = menu_emr
# - submenu "export as"
menu_emr_export = wx.Menu()
menu_emr.AppendMenu(wx.NewId(), _('Export as ...'), menu_emr_export)
# 1) ASCII
menu_emr_export.Append (
ID_EXPORT_EMR,
_('Text document'),
_("Export the EMR of the active patient into a text file")
)
wx.EVT_MENU(self, ID_EXPORT_EMR, self.OnExportEMR)
# 2) journal format
menu_emr_export.Append (
ID_EXPORT_EMR_JOURNAL,
_('Journal'),
_("Export the EMR of the active patient as a chronological journal into a text file")
)
wx.EVT_MENU(self, ID_EXPORT_EMR_JOURNAL, self.__on_export_emr_as_journal)
# 3) Medistar import format
menu_emr_export.Append (
ID_EXPORT_MEDISTAR,
_('MEDISTAR import format'),
_("GNUmed -> MEDISTAR. Export progress notes of active patient's active encounter into a text file.")
)
wx.EVT_MENU(self, ID_EXPORT_MEDISTAR, self.__on_export_for_medistar)
# - summary
menu_emr.Append (
ID_EMR_SUMMARY,
_('Show Summary'),
_('Show a summary of the EMR of the active patient')
)
wx.EVT_MENU(self, ID_EMR_SUMMARY, self.__on_show_emr_summary)
# - submenu "show as"
menu_emr_show = wx.Menu()
menu_emr.AppendMenu(wx.NewId(), _('Show as ...'), menu_emr_show)
self.__gb['main.emr_showmenu'] = menu_emr_show
# - draw a line
menu_emr.AppendSeparator()
# - search
menu_emr.Append (
ID_SEARCH_EMR,
_('Search'),
_('Search for data in the EMR of the active patient')
)
wx.EVT_MENU(self, ID_SEARCH_EMR, self.__on_search_emr)
# - add health issue
menu_emr.Append (
ID_ADD_HEALTH_ISSUE_TO_EMR,
_('Add health issue (pHx item)'),
_('Add a health issue (pHx item) to the EMR of the active patient')
)
wx.EVT_MENU(self, ID_ADD_HEALTH_ISSUE_TO_EMR, self.__on_add_health_issue)
# - draw a line
menu_emr.AppendSeparator()
# menu "View" ---------------------------
# self.menu_view = wx.Menu()
# self.__gb['main.viewmenu'] = self.menu_view
# self.mainmenu.Append(self.menu_view, _("&View"));
# menu "Tools"
self.menu_tools = wx.Menu()
self.__gb['main.toolsmenu'] = self.menu_tools
self.mainmenu.Append(self.menu_tools, _("&Tools"))
self.menu_tools.Append (ID_DERMTOOL, _("Dermatology"), _("A tool to aid dermatology diagnosis"))
wx.EVT_MENU (self, ID_DERMTOOL, self.__dermtool)
# menu "Knowledge"
menu_knowledge = wx.Menu()
self.__gb['main.knowledgemenu'] = menu_knowledge
self.mainmenu.Append(menu_knowledge, _("&Knowledge"))
# menu "Help"
help_menu = wx.Menu()
# - about
help_menu.Append(ID_ABOUT, _('About GNUmed'), "")
wx.EVT_MENU (self, ID_ABOUT, self.OnAbout)
# - contributors
help_menu.Append(ID_CONTRIBUTORS, _('GNUmed contributors'), _('show GNUmed contributors'))
wx.EVT_MENU (self, ID_CONTRIBUTORS, self.__on_show_contributors)
# - among other things the Manual is added from a plugin
help_menu.AppendSeparator()
self.__gb['main.helpmenu'] = help_menu
self.mainmenu.Append(help_menu, "&Help")
# and activate menu structure
self.SetMenuBar(self.mainmenu)
#----------------------------------------------
def __load_plugins(self):
pass
#----------------------------------------------
# event handling
#----------------------------------------------
def __register_events(self):
"""register events we want to react to"""
# wxPython events
# wx.EVT_IDLE(self, self.OnIdle)
wx.EVT_CLOSE(self, self.OnClose)
wx.EVT_ICONIZE(self, self.OnIconize)
wx.EVT_MAXIMIZE(self, self.OnMaximize)
# intra-client signals
gmDispatcher.connect(self._on_pre_patient_selection, gmSignals.pre_patient_selection())
gmDispatcher.connect(self.on_post_patient_selection, gmSignals.post_patient_selection())
#-----------------------------------------------
def on_post_patient_selection(self, **kwargs):
wx.CallAfter(self.__on_post_patient_selection, **kwargs)
#----------------------------------------------
def __on_post_patient_selection(self, **kwargs):
pat = gmPerson.gmCurrentPatient()
try:
pat.get_emr()
pat.get_identity()
except:
_log.LogException("Unable to process signal. Is gmCurrentPatient up to date yet?", sys.exc_info(), verbose=1)
return False
self.updateTitle()
#----------------------------------------------
def _on_pre_patient_selection(self, **kwargs):
wx.CallAfter(self.__on_pre_patient_selection, **kwargs)
#----------------------------------------------
def __on_pre_patient_selection(self, **kwargs):
pat = gmPerson.gmCurrentPatient()
if not pat.is_connected():
return True
emr = pat.get_emr()
enc = emr.get_active_encounter()
# update encounter summary
if ((enc['assessment_of_encounter'] is None)
or (enc['assessment_of_encounter'].find('auto-created') >= 0)
or (len(enc['assessment_of_encounter'].strip()) == 0)):
# - work out suitable default
epis = emr.get_episodes_by_encounter()
if len(epis) > 0:
enc_summary = ''
for epi in epis:
enc_summary += '%s; ' % epi['description']
enc['assessment_of_encounter'] = enc_summary
# FIXME: optionally pop up modal dialog to allow editing encounter summary before saving
if not enc.save_payload():
gmGuiHelpers.gm_beep_statustext(_('Cannot update encounter summary.'), gmLog.lErr)
return True
#----------------------------------------------
def OnAbout(self, event):
from Gnumed.wxpython import gmAbout
gmAbout = gmAbout.AboutFrame(self, -1, _("About GNUmed"), size=wx.Size(350, 300), style = wx.MAXIMIZE_BOX)
gmAbout.Centre(wx.BOTH)
gmTopLevelFrame.otherWin = gmAbout
gmAbout.Show(True)
del gmAbout
#----------------------------------------------
def __on_show_contributors(self, event):
from Gnumed.wxpython import gmAbout
contribs = gmAbout.cContributorsDlg (
parent = self,
id = -1,
title = _('GNUmed contributors'),
size = wx.Size(400,600),
style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
)
contribs.ShowModal()
del contribs
del gmAbout
#----------------------------------------------
def OnFileExit(self, event):
"""Invoked from Menu->Exit (calls ID_EXIT handler)."""
# calls wx.EVT_CLOSE handler
self.Close()
#----------------------------------------------
def OnClose(self, event):
"""wx.EVT_CLOSE handler.
- framework still functional
"""
# FIXME: ask user whether to *really* close and save all data
# call cleanup helper
self._clean_exit()
#----------------------------------------------
def OnExportEMR(self, event):
"""
Export selected patient EMR to a file
"""
gmEMRBrowser.export_emr_to_ascii(parent=self)
#----------------------------------------------
def __dermtool (self, event):
import Gnumed.wxpython.gmDermTool as DT
frame = DT.DermToolDialog(None, -1)
frame.Show(True)
#----------------------------------------------
def __on_add_health_issue(self, event):
pat = gmPerson.gmCurrentPatient()
if not pat.is_connected():
gmGuiHelpers.gm_beep_statustext(_('Cannot add health issue. No active patient.'))
return False
ea = gmEMRStructWidgets.cHealthIssueEditArea (
self,
-1,
wx.DefaultPosition,
wx.DefaultSize,
wx.NO_BORDER | wx.TAB_TRAVERSAL
)
popup = gmEditArea.cEditAreaPopup (
parent = None,
id = -1,
title = _('Add health issue (pHx item)'),
style = wx.CENTRE | wx.STAY_ON_TOP | wx.CAPTION | wx.SUNKEN_BORDER,
name = '',
edit_area = ea
)
result = popup.ShowModal()
#----------------------------------------------
def __on_show_emr_summary(self, event):
pat = gmPerson.gmCurrentPatient()
if not pat.is_connected():
gmGuiHelpers.gm_beep_statustext(_('Cannot show EMR summary. No active patient.'))
return False
emr = pat.get_emr()
msg = _("""Medical problems: %(problems)s
Total visits: %(visits)s
Total EMR entries: %(items)s
Stored documents: %(documents)s
""") % emr.get_summary()
dlg = wx.MessageDialog (
parent = None,
message = msg,
caption = _('EMR Summary'),
style = wx.OK | wx.STAY_ON_TOP
)
dlg.ShowModal()
dlg.Destroy()
return True
#----------------------------------------------
def __on_search_emr(self, event):
pat = gmPerson.gmCurrentPatient()
if not pat.is_connected():
gmGuiHelpers.gm_beep_statustext(_('Cannot search EMR. No active patient.'))
return False
searcher = wx.TextEntryDialog (
parent = self,
message = _('Enter search term:'),
caption = _('Text search of entire EMR'),
style = wx.OK | wx.CANCEL | wx.CENTRE,
pos = wx.DefaultPosition
)
result = searcher.ShowModal()
if result == wx.ID_OK:
val = searcher.GetValue()
wx.BeginBusyCursor()
emr = pat.get_emr()
rows = emr.search_narrative_simple(val)
wx.EndBusyCursor()
txt = ''
for row in rows:
txt += '%s - %s\n%s\n\n' % (row[1], row[4], row[2])
msg = _(
"""Search term was: "%s"
Search results:
%s
""") % (val, txt)
dlg = wx.MessageDialog (
parent = None,
message = msg,
caption = _('search results'),
style = wx.OK | wx.STAY_ON_TOP
)
dlg.ShowModal()
dlg.Destroy()
return True
#----------------------------------------------
def __on_export_emr_as_journal(self, event):
# sanity checks
pat = gmPerson.gmCurrentPatient()
if not pat.is_connected():
gmGuiHelpers.gm_beep_statustext(_('Cannot export EMR journal. No active patient.'), gmLog.lErr)
return False
# get file name
aWildcard = "%s (*.txt)|*.txt|%s (*.*)|*.*" % (_("text files"), _("all files"))
# FIXME: make configurable
aDefDir = os.path.abspath(os.path.expanduser(os.path.join('~', 'gnumed', 'export')))
ident = pat.get_identity()
# FIXME: make configurable
fname = '%s-%s_%s.txt' % (_('emr-journal'), ident['lastnames'], ident['firstnames'])
dlg = wx.FileDialog (
parent = self,
message = _("Save patient's EMR journal as..."),
defaultDir = aDefDir,
defaultFile = fname,
wildcard = aWildcard,
style = wx.SAVE
)
choice = dlg.ShowModal()
fname = dlg.GetPath()
dlg.Destroy()
if choice != wx.ID_OK:
return True
_log.Log(gmLog.lData, 'exporting EMR journal to [%s]' % fname)
# instantiate exporter
wx.BeginBusyCursor()
exporter = gmPatientExporter.cEMRJournalExporter()
successful, fname = exporter.export_to_file(filename = fname)
wx.EndBusyCursor()
if not successful:
gmGuiHelpers.gm_show_error (
_('Error exporting patient EMR as chronological journal.'),
_('EMR journal export'),
gmLog.lErr
)
return False
# gmGuiHelpers.gm_show_info (
# _('Successfully exported EMR as chronological journal into file\n\n[%s]') % fname,
# _('EMR journal export'),
# gmLog.lInfo
# )
return True
#----------------------------------------------
def __on_export_for_medistar(self, event):
# sanity checks
pat = gmPerson.gmCurrentPatient()
if not pat.is_connected():
gmGuiHelpers.gm_beep_statustext(_('Cannot export EMR for Medistar. No active patient.'), gmLog.lErr)
return False
# get file name
aWildcard = "%s (*.txt)|*.txt|%s (*.*)|*.*" % (_("text files"), _("all files"))
# FIXME: make configurable
aDefDir = os.path.abspath(os.path.expanduser(os.path.join('~', 'gnumed','export')))
ident = pat.get_identity()
# FIXME: make configurable
fname = '%s-%s-%s-%s-%s.txt' % (
'Medistar-MD',
time.strftime('%Y-%m-%d',time.localtime()),
ident['lastnames'].replace(' ', '-'),
ident['firstnames'].replace(' ', '_'),
ident['dob'].Format('%Y-%m-%d')
)
dlg = wx.FileDialog (
parent = self,
message = _("Save patient's EMR for MEDISTAR as..."),
defaultDir = aDefDir,
defaultFile = fname,
wildcard = aWildcard,
style = wx.SAVE
)
choice = dlg.ShowModal()
fname = dlg.GetPath()
dlg.Destroy()
if choice != wx.ID_OK:
return False
_log.Log(gmLog.lData, 'exporting EMR journal to [%s]' % fname)
# instantiate exporter
wx.BeginBusyCursor()
exporter = gmPatientExporter.cMedistarSOAPExporter()
successful, fname = exporter.export_to_file(filename=fname)
wx.EndBusyCursor()
if not successful:
gmGuiHelpers.gm_show_error (
_('Error exporting progress notes of current encounter for MEDISTAR import.'),
_('MEDISTAR progress notes export'),
gmLog.lErr
)
return False
return True
#----------------------------------------------
def __on_load_external_patient(self, event):
gmPatSearchWidgets.load_patient_from_external_sources(parent=self)
#----------------------------------------------
def __on_create_patient(self, event):
"""Launch create patient wizard.
"""
wiz = gmDemographicsWidgets.cNewPatientWizard(parent=self)
wiz.RunWizard(activate=True)
#----------------------------------------------
def __on_enlist_patient_as_staff(self, event):
pat = gmPerson.gmCurrentPatient()
if not pat.is_connected():
gmGuiHelpers.gm_beep_statustext(_('Cannot add staff member. No active patient.'))
return False
dlg = gmStaffWidgets.cAddPatientAsStaffDlg(parent=self, id=-1)
dlg.ShowModal()
#----------------------------------------------
def __on_delete_patient(self, event):
pat = gmPerson.gmCurrentPatient()
if not pat.is_connected():
gmGuiHelpers.gm_beep_statustext(_('Cannot delete patient. No patient active.'))
return False
gmDemographicsWidgets.disable_identity(identity=pat.get_identity())
return True
#----------------------------------------------
def __on_add_new_staff(self, event):
"""Create new person and add it as staff."""
wiz = gmDemographicsWidgets.cNewPatientWizard(parent=self)
if not wiz.RunWizard(activate=True):
return False
dlg = gmStaffWidgets.cAddPatientAsStaffDlg(parent=self, id=-1)
dlg.ShowModal()
#----------------------------------------------
def __on_edit_staff_list(self, event):
dlg = gmStaffWidgets.cEditStaffListDlg(parent=self, id=-1)
dlg.ShowModal()
#----------------------------------------------
def __on_edit_doc_types(self, event):
dlg = gmMedDocWidgets.cEditDocumentTypesDlg(parent=self, id=-1)
dlg.ShowModal()
#----------------------------------------------
# def __on_search_patient(self, event):
# """Focus patient search widget."""
# # FIXME: directly accessing the top panel is ugly as sin
# searcher = self.__gb['horstspace.top_panel'].patient_selector
# searcher.SetFocus()
#----------------------------------------------
def _clean_exit(self):
"""Cleanup helper.
- should ALWAYS be called when this program is
to be terminated
- ANY code that should be executed before a
regular shutdown should go in here
- framework still functional
"""
# signal imminent demise to plugins
gmDispatcher.send(gmSignals.application_closing())
# remember GUI size
curr_width, curr_height = self.GetClientSizeTuple()
_log.Log(gmLog.lInfo, 'GUI size at shutdown: [%s:%s]' % (curr_width, curr_height))
gmCfg.setDBParam(
workplace = gmPerson.gmCurrentProvider().get_workplace(),
option = 'main.window.width',
value = curr_width
)
gmCfg.setDBParam(
workplace = gmPerson.gmCurrentProvider().get_workplace(),
option = 'main.window.height',
value = curr_height
)
# user changed the sidebar size -- remember that
if self.bar_width > -1 and self.bar_width != 210:
gmCfg.setDBParam(
workplace = gmPerson.gmCurrentProvider().get_workplace(),
option = 'main.window.sidebar_width',
value = self.bar_width
)
# handle our own stuff
gmPG.ConnectionPool().StopListeners()
try:
gmGuiBroker.GuiBroker()['scripting listener'].tell_thread_to_stop()
except KeyError:
pass
except:
_log.LogException('cannot stop scripting listener thread', sys.exc_info(), verbose=0)
self.timer.Stop()
self.mainmenu = None
self.Destroy()
#----------------------------------------------
# def OnIdle(self, event):
# """Here we can process any background tasks
# """
# pass
#----------------------------------------------
def OnIconize(self, event):
# FIXME: we should maximize the amount of title bar information here
#_log.Log(gmLog.lInfo, 'OnIconify')
event.Skip()
#----------------------------------------------
def OnMaximize(self, event):
# FIXME: we should change the amount of title bar information here
#_log.Log(gmLog.lInfo,'OnMaximize')
event.Skip()
#----------------------------------------------
#----------------------------------------------
def updateTitle(self, anActivity = None):
"""Update title of main window based on template.
This gives nice tooltips on iconified GNUmed instances.
User research indicates that in the title bar people want
the date of birth, not the age, so please stick to this
convention.
"""
if anActivity is not None:
self.title_activity = str(anActivity)
pat = gmPerson.gmCurrentPatient()
if pat.is_connected():
ident = pat.get_identity()
title = ident['title']
if title is None:
title = ''
else:
title = title[:4] + '.'
pat_str = "%s%s %s (%s) #%d" % (title, ident['firstnames'], ident['lastnames'], ident['dob'].Format (_('%d/%m/%y')), ident['pk_identity'])
else:
pat_str = _('no patient')
title = self.__title_template % (
_provider['title'],
_provider['firstnames'][:1],
_provider['lastnames'],
gmPerson.gmCurrentProvider().get_workplace(),
self.title_activity,
pat_str
)
self.SetTitle(title)
#----------------------------------------------
#----------------------------------------------
def SetupStatusBar(self):
sb = self.CreateStatusBar(2, wx.ST_SIZEGRIP)
sb.SetStatusWidths([-1, 150])
#add time and date display to the right corner of the status bar
self.timer = wx.PyTimer(self._cb_update_clock)
self._cb_update_clock()
#update every second
self.timer.Start(milliseconds=1000)
#----------------------------------------------
def _cb_update_clock(self):
"""Displays date and local time in the second slot of the status bar"""
t = time.localtime(time.time())
st = time.strftime('%c', t)
self.SetStatusText(st,1)
#----------------------------------------------
# def on_user_error (self, signal, message):
# "response to user_error event"
# self.SetStatusText (message, 0)
# wx.Bell()
#------------------------------------------------
def Lock(self):
"""Lock GNUmed client against unauthorized access"""
# FIXME
# for i in range(1, self.nb.GetPageCount()):
# self.nb.GetPage(i).Enable(False)
return
#----------------------------------------------
def Unlock(self):
"""Unlock the main notebook widgets
As long as we are not logged into the database backend,
all pages but the 'login' page of the main notebook widget
are locked; i.e. not accessible by the user
"""
#unlock notebook pages
# for i in range(1, self.nb.GetPageCount()):
# self.nb.GetPage(i).Enable(True)
# go straight to patient selection
# self.nb.AdvanceSelection()
return
#-----------------------------------------------
def OnPanelSize (self, event):
wx.LayoutAlgorithm().LayoutWindow (self.LayoutMgr, self.nb)
#------------------------------------------------
# def OnSashDrag (self, event):
# if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE:
# return
# self.leftbox.SetDefaultSize(wx.Size(event.GetDragRect().width, 1000))
# self.bar_width = event.GetDragRect().width
# wx.LayoutAlgorithm().LayoutWindow(self.LayoutMgr, self.nb)
# self.nb.Refresh()
#==============================================================================
class gmApp(wx.App):
def OnInit(self):
# create a GUI element dictionary that
# will be static and alive as long as app runs
self.__guibroker = gmGuiBroker.GuiBroker()
self.__setup_platform()
# check for slave mode
tmp = _cfg.get('workplace', 'slave mode')
if tmp == "1":
self.__guibroker['main.slave_mode'] = True
_log.Log(gmLog.lInfo, 'slave mode is ON')
else:
self.__guibroker['main.slave_mode'] = False
_log.Log(gmLog.lInfo, 'slave mode is OFF')
if self.__guibroker['main.slave_mode']:
self.__guibroker['main.slave_personality'] = _cfg.get('workplace', 'slave personality')
if not self.__guibroker['main.slave_personality']:
msg = _(
'Slave mode requested but personality not set.\n\n'
'(The personality must be set so that clients can\n'
'find the appropriate GNUmed instance to attach to.)\n\n'
'Set slave personality in config file !'
)
gmGuiHelpers.gm_show_error(msg, _('Starting slave mode'), gmLog.lErr)
return False
_log.Log(gmLog.lInfo, 'assuming slave mode personality [%s]' % self.__guibroker['main.slave_personality'])
# connect to backend (implicitely runs login dialog)
from Gnumed.wxpython import gmLogin
self.__backend = gmLogin.Login()
if self.__backend is None:
_log.Log(gmLog.lWarn, "Login attempt unsuccessful. Can't run GNUmed without database connection")
return False
# verify database
if not gmPG.database_schema_compatible():
msg = _(
"""You cannot use this database with a GNUmed client of version 0.2 ("Librarian" release) because the table structure is incompatible.
Choose another database server profile or ask your administrator for help.""")
if gmCLI.has_arg('--override-schema-check'):
msg = msg + _("""
The client will, however, continue to start up because you are running a development/test version of GNUmed.
There may be schema related errors. Please report and/or fix them.
Do not rely on this database to work properly in all cases !""")
gmGuiHelpers.gm_show_info(msg, _('Verifying database'), gmLog.lErr)
else:
gmGuiHelpers.gm_show_error(msg, _('Verifying database'), gmLog.lErr)
return False
# check account <-> staff member association
try:
global _provider
_provider = gmPerson.gmCurrentProvider(provider = gmPerson.cStaff())
except gmExceptions.ConstructorError, ValueError:
account = gmPG.get_current_user()
_log.LogException('DB account [%s] cannot be used as a GNUmed staff login' % account, sys.exc_info(), verbose=0)
msg = _(
'The database account [%s] cannot be used as a\n'
'staff member login for GNUmed. There was an\n'
'error retrieving staff details for it.\n\n'
'Please ask your administrator for help.\n'
) % account
gmGuiHelpers.gm_show_error(msg, _('Checking access permissions'))
return False
wx.EVT_QUERY_END_SESSION(self, self._on_query_end_session)
wx.EVT_END_SESSION(self, self._on_end_session)
# set up language in database
self.__set_db_lang()
# display database banner
msg = gmPG.run_ro_query('default', 'select message from cfg.db_logon_banner')
if msg is not None:
gmGuiHelpers.gm_show_info(msg[0][0], _('Verifying database'))
# create the main window
cli_layout = gmCLI.arg.get('--layout', None)
frame = gmTopLevelFrame(None, -1, _('GNUmed client'), (640,440), cli_layout)
# and tell the app to use it
self.SetTopWindow(frame)
# NOTE: the following only works under Windows according
# to the docs and bombs under wxPython-2.4 on GTK/Linux
#frame.Maximize(True)
frame.CentreOnScreen(wx.BOTH)
frame.Show(True)
# last but not least: start macro listener if so desired
if self.__guibroker['main.slave_mode']:
from Gnumed.pycommon import gmScriptingListener
from Gnumed.wxpython import gmMacro
macro_executor = gmMacro.cMacroPrimitives(self.__guibroker['main.slave_personality'])
port = _cfg.get('workplace', 'xml-rpc port')
if not port:
port = 9999
self.__guibroker['scripting listener'] = gmScriptingListener.cScriptingListener(port, macro_executor)
_log.Log(gmLog.lInfo, 'listening for commands on port [%s]' % port)
gmPatSearchWidgets.load_patient_from_external_sources(parent=frame)
return True
#----------------------------------------------
# def HandleEvent(self, *args, **kwargs):
# """Contains top level exception handler.
# """
# try:
# wx.App.HandleEvent(args, kwargs)
# except:
# _log.LogException('unhandled exception caught', verbose=1)
# exc_type, val = sys.exc_info()[:2]
# msg = _(
#"""An unhandled exception occurred.
#
#This probably indicates a rather severe error and this GNUmed client will be aborted.
#
#Type of exception: %s
#Exception value : %s
#""")
# gmGuiHelpers.gm_show_error (
# aMessage = msg,
# aTitle = _('Unhandled exception')
# )
# raise
#----------------------------------------------
def OnExit(self):
"""Called:
- after destroying all application windows and controls
- before wx.Windows internal cleanup
"""
pass
#----------------------------------------------
def _on_query_end_session(self):
print "unhandled event detected: QUERY_END_SESSION"
_log.Log(gmLog.lWarn, 'unhandled event detected: QUERY_END_SESSION')
_log.Log(gmLog.lInfo, 'we should be saving ourselves from here')
#----------------------------------------------
def _on_end_session(self):
print "unhandled event detected: END_SESSION"
_log.Log(gmLog.lWarn, 'unhandled event detected: END_SESSION')
#----------------------------------------------
# internal helpers
#----------------------------------------------
def __setup_platform(self):
if wx.Platform == '__WXMSW__':
# windoze specific stuff here
_log.Log(gmLog.lInfo,'running on Microsoft Windows')
# need to explicitely init image handlers on windows
wx.InitAllImageHandlers()
#----------------------------------------------
def __set_db_lang(self):
if gmI18N.system_locale is None or gmI18N.system_locale == '':
_log.Log(gmLog.lWarn, "system locale is undefined (probably meaning 'C')")
return True
db_lang = None
# get current database locale
cmd = "select lang from i18n.curr_lang where user = CURRENT_USER limit 1;"
result = gmPG.run_ro_query('default', cmd, 0)
if result is None:
# if the actual query fails assume the admin
# knows her stuff and fail graciously
_log.Log(gmLog.lWarn, 'cannot get database language')
_log.Log(gmLog.lInfo, 'assuming language settings are not wanted/needed')
return False
if len(result) == 0:
msg = _(
"There is no language selected in the database for user [%s].\n"
"Your system language is currently set to [%s].\n\n"
"Do you want to set the database language to '%s' ?\n\n"
"Answering <NO> will remember that decision until\n"
"the system language is changed. You can also reactivate\n"
"this inquiry by removing the appropriate ignore option\n"
"from the configuration file."
) % (_provider['db_user'], gmI18N.system_locale, gmI18N.system_locale)
_log.Log(gmLog.lData, "database locale currently not set")
else:
db_lang = result[0][0]
msg = _(
"The currently selected database language ('%s') does\n"
"not match the current system language ('%s').\n\n"
"Do you want to set the database language to '%s' ?\n\n"
"Answering <NO> will remember that decision until\n"
"the system language is changed. You can also reactivate\n"
"this inquiry by removing the appropriate ignore option\n"
"from the configuration file."
) % (db_lang, gmI18N.system_locale, gmI18N.system_locale)
_log.Log(gmLog.lData, "current database locale: [%s]" % db_lang)
# check if we can match up system and db language somehow
if db_lang == gmI18N.system_locale_level['full']:
_log.Log(gmLog.lData, 'Database locale (%s) up to date.' % db_lang)
return True
if db_lang == gmI18N.system_locale_level['country']:
_log.Log(gmLog.lData, 'Database locale (%s) matches system locale (%s) at country level.' % (db_lang, gmI18N.system_locale))
return True
if db_lang == gmI18N.system_locale_level['language']:
_log.Log(gmLog.lData, 'Database locale (%s) matches system locale (%s) at language level.' % (db_lang, gmI18N.system_locale))
return True
# no match
_log.Log(gmLog.lWarn, 'database locale [%s] does not match system locale [%s]' % (db_lang, gmI18N.system_locale))
# returns either None or a locale string
ignored_sys_lang = _cfg.get('backend', 'ignored mismatching system locale')
# are we to ignore *this* mismatch ?
if gmI18N.system_locale == ignored_sys_lang:
_log.Log(gmLog.lInfo, 'configured to ignore system-to-database locale mismatch')
return True
# no, so ask user
dlg = wx.MessageDialog (
parent = None,
message = msg,
caption = _('checking database language settings'),
style = wx.YES_NO | wx.CENTRE | wx.ICON_QUESTION
)
result = dlg.ShowModal()
dlg.Destroy()
if result == wx.ID_NO:
_log.Log(gmLog.lInfo, 'User did not want to set database locale. Ignoring mismatch next time.')
comment = [
"If the system locale matches this value a mismatch",
"with the database locale will be ignored.",
"Remove this option if you want to stop ignoring mismatches.",
]
_cfg.set('backend', 'ignored mismatching system locale', gmI18N.system_locale, comment)
_cfg.store()
return True
# try setting database language (only possible if translation exists)
cmd = "select i18n.set_curr_lang(%s) "
for lang in [gmI18N.system_locale_level['full'], gmI18N.system_locale_level['country'], gmI18N.system_locale_level['language']]:
if len (lang) > 0:
# users are getting confused, so don't show these "errors",
# they really are just notices about us being nice
success, data = gmPG.run_commit2 (
link_obj = 'default',
queries = [ (cmd, [lang]) ]
)
if not success:
_log.Log(gmLog.lErr, 'Cannot set database language to [%s].' % lang)
continue
rows, idx = data
if rows[0][0]:
_log.Log(gmLog.lData, "Successfully set database language to [%s]." % lang)
else:
_log.Log(gmLog.lErr, 'Cannot set database language to [%s].' % lang)
continue
return True
# user wanted to set the DB language but that failed
# so try falling back to Englisch
set_default = gmGuiHelpers.gm_show_question (
_(
'Failed to set database language to [%s].\n\n'
'No translation available.\n\n'
'Do you want to set the database language to English ?'
) % gmI18N.system_locale,
_('setting database language')
)
if set_default:
cmd = "select i18n.force_curr_lang('en_GB')"
gmPG.run_commit('default', [ (cmd, []) ])
return False
#==============================================================================
def main():
# create an instance of our GNUmed main application
app = gmApp(False)
_log.Log(gmLog.lInfo, 'display: %s:%s' % (wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X), wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)))
# and enter the main event loop
app.MainLoop()
#==============================================================================
# Main
#==============================================================================
if __name__ == '__main__':
# console is Good(tm)
aLogTarget = gmLog.cLogTargetConsole(gmLog.lInfo)
_log.AddTarget(aLogTarget)
_log.Log(gmLog.lInfo, 'Starting up as main module.')
gb = gmGuiBroker.GuiBroker()
gb['gnumed_dir'] = os.curdir + "/.."
main()
#==============================================================================
# $Log: gmGuiMain.py,v $
# Revision 1.265 2006/08/11 13:10:08 ncq
# - even if we cannot find wxversion still test for 2.6.x/unicode after
# the fact and make very unhappy noises before drifting off into coma
#
# Revision 1.264 2006/08/06 20:04:02 ncq
# - improve wxPython version checking and related messages
#
# Revision 1.263 2006/08/01 22:04:32 ncq
# - call disable_identity()
#
# Revision 1.262 2006/07/30 18:47:19 ncq
# - add load ext pat to patient menu
# - prepare patient "deletion" from menu
#
# Revision 1.261 2006/07/24 11:30:02 ncq
# - must set parent when loading external patients
#
# Revision 1.260 2006/07/21 21:34:58 ncq
# - check for minimum required version/type of wxPython
#
# Revision 1.259 2006/07/18 21:17:21 ncq
# - use gmPatSearchWidgets.load_patient_from_external_sources()
#
# Revision 1.258 2006/07/17 21:07:59 ncq
# - create new patient from BDT file if not found
#
# Revision 1.257 2006/07/17 18:50:11 ncq
# - upon startup activate patient read from xDT file if patient exists
#
# Revision 1.256 2006/07/17 10:53:50 ncq
# - don't die on missing bdt file on startup
#
# Revision 1.255 2006/07/13 21:01:26 ncq
# - display external patient on startup if XDT file available
#
# Revision 1.254 2006/07/07 12:09:00 ncq
# - cleanup
# - add document type editing to administrative menu
#
# Revision 1.253 2006/07/01 15:12:02 ncq
# - set_curr_lang() failure has been downgraded to warning
#
# Revision 1.252 2006/07/01 11:32:13 ncq
# - setting up database connection encoding now requires two encoding names
#
# Revision 1.251 2006/06/28 10:18:02 ncq
# - only set gmPG default client encoding if actually set in the config file
#
# Revision 1.250 2006/06/13 20:35:46 ncq
# - use localized date/time format taken from datetime library
#
# Revision 1.249 2006/06/10 05:12:42 ncq
# - edit staff list
#
# Revision 1.248 2006/06/07 21:04:19 ncq
# - fix re-setting DB lang to en_GB on failure to set preferred lang
#
# Revision 1.247 2006/06/06 20:48:31 ncq
# - actually implement delisting staff member
#
# Revision 1.246 2006/06/06 10:22:23 ncq
# - menu_office -> menu_administration
# - menu_reference -> menu_knowledge
# - cleanup
#
# Revision 1.245 2006/05/20 18:36:45 ncq
# - reset DB language to EN on failing to set it to the user's locale
#
# Revision 1.244 2006/05/15 13:36:00 ncq
# - signal cleanup:
# - activating_patient -> pre_patient_selection
# - patient_selected -> post_patient_selection
#
# Revision 1.243 2006/05/14 21:44:22 ncq
# - add get_workplace() to gmPerson.gmCurrentProvider and make use thereof
# - remove use of gmWhoAmI.py
#
# Revision 1.242 2006/05/14 18:09:05 ncq
# - db_account -> db_user
#
# Revision 1.241 2006/05/12 12:20:38 ncq
# - use gmCurrentProvider
# - whoami -> whereami
#
# Revision 1.240 2006/05/10 13:08:37 ncq
# - properly log physical screen size
#
# Revision 1.239 2006/05/06 18:50:43 ncq
# - improve summary display after user complaint
#
# Revision 1.238 2006/05/04 17:52:04 ncq
# - mark EMR summary for translation
#
# Revision 1.237 2006/05/04 09:49:20 ncq
# - get_clinical_record() -> get_emr()
# - adjust to changes in set_active_patient()
# - need explicit set_active_patient() after ask_for_patient() if wanted
#
# Revision 1.236 2006/04/23 16:49:41 ncq
# - add "Show EMR summary" as per list discussion
#
# Revision 1.235 2006/03/14 21:37:18 ncq
# - add menu "Office"
# - add menu item "add staff member" under "Office" serially calling new patient wizard and add staff dialog
# - fix encounter summary
#
# Revision 1.234 2006/03/09 21:12:44 ncq
# - allow current patient to be enlisted as staff from the main menu
#
# Revision 1.233 2006/02/27 22:38:36 ncq
# - spell out rfe/aoe as per Richard's request
#
# Revision 1.232 2006/01/24 21:09:45 ncq
# - use whoami.get_short_alias
#
# Revision 1.231 2006/01/15 14:29:44 ncq
# - cleanup
#
# Revision 1.230 2006/01/09 20:27:04 ncq
# - set_curr_lang() is in schema i18n, too
#
# Revision 1.229 2006/01/09 20:19:06 ncq
# - adjust to i18n schema
#
# Revision 1.228 2006/01/03 12:12:03 ncq
# - make epydoc happy re _()
#
# Revision 1.227 2005/12/27 18:54:50 ncq
# - -> GNUmed
# - enlarge About
# - verify database on startup
# - display database banner if it exists
#
# Revision 1.226 2005/12/14 17:01:51 ncq
# - use improved db cfg option getting
#
# Revision 1.225 2005/11/29 18:59:41 ncq
# - cleanup
#
# Revision 1.224 2005/11/27 20:20:46 ncq
# - slave mode cfg return is string, not integer
#
# Revision 1.223 2005/11/18 15:23:23 ncq
# - enable simple EMR search
#
# Revision 1.222 2005/11/06 11:10:42 ihaywood
# dermtool proof-of-concept
# Access from Tools|Dermatology menu item
# A small range of derm pictures using free-as-in-speech sources are included.
#
# CVm: ----------------------------------------------------------------------
#
# Revision 1.221 2005/10/12 22:32:22 ncq
# - encounter['description'] -> encounter['aoe']
#
# Revision 1.220 2005/10/08 12:37:25 sjtan
# enc['description'] can return None
#
# Revision 1.219 2005/09/28 21:27:30 ncq
# - a lot of wx2.6-ification
#
# Revision 1.218 2005/09/28 15:57:48 ncq
# - a whole bunch of wx.Foo -> wx.Foo
#
# Revision 1.217 2005/09/27 20:44:58 ncq
# - wx.wx* -> wx.*
#
# Revision 1.216 2005/09/26 18:01:50 ncq
# - use proper way to import wx26 vs wx2.4
# - note: THIS WILL BREAK RUNNING THE CLIENT IN SOME PLACES
# - time for fixup
#
# Revision 1.215 2005/09/24 09:17:28 ncq
# - some wx2.6 compatibility fixes
#
# Revision 1.214 2005/09/11 17:34:10 ncq
# - support consultation summary generation just before
# switching to the next patient
#
# Revision 1.213 2005/09/04 07:30:24 ncq
# - comment out search-patient menu item for now
#
# Revision 1.212 2005/07/24 18:57:48 ncq
# - add "search" to "patient" menu - all it does is focus the search box ...
#
# Revision 1.211 2005/07/24 11:35:59 ncq
# - use robustified gmTimer.Start() interface
#
# Revision 1.210 2005/07/11 09:05:31 ncq
# - be more careful about failing to import wxPython
# - make contributors list accessible from main menu
#
# Revision 1.209 2005/07/02 18:21:36 ncq
# - GnuMed -> GNUmed
#
# Revision 1.208 2005/06/30 10:21:01 cfmoro
# String corrections
#
# Revision 1.207 2005/06/30 10:10:08 cfmoro
# String corrections
#
# Revision 1.206 2005/06/29 20:03:45 ncq
# - cleanup
#
# Revision 1.205 2005/06/29 18:28:33 cfmoro
# Minor fix
#
# Revision 1.204 2005/06/29 15:08:47 ncq
# - some cleanup
# - allow adding past history item from EMR menu
#
# Revision 1.203 2005/06/28 16:48:45 cfmoro
# File dialog for journal and medistar EMR export
#
# Revision 1.202 2005/06/23 15:00:11 ncq
# - cleanup
#
# Revision 1.201 2005/06/21 04:59:40 rterry
# Fix to allow running gmAbout.py under wxpython26 wx.Size > wx.Size
#
# Revision 1.200 2005/06/19 16:38:03 ncq
# - set encoding of gmGuiMain.py to latin1
#
# Revision 1.199 2005/06/13 21:41:29 ncq
# - add missing function
#
# Revision 1.198 2005/06/12 22:16:22 ncq
# - allow for explicitely setting timezone via config file
# - cleanup, prepare for EMR search
#
# Revision 1.197 2005/06/07 20:52:49 ncq
# - improved EMR menu structure
#
# Revision 1.196 2005/05/24 19:50:26 ncq
# - make "patient" menu available globally
#
# Revision 1.195 2005/05/14 14:57:37 ncq
# - activate new patient after creation
#
# Revision 1.194 2005/05/12 15:11:08 ncq
# - add Medistar export menu item
#
# Revision 1.193 2005/04/28 21:29:58 ncq
# - improve status bar
#
# Revision 1.192 2005/04/26 20:02:20 ncq
# - proper call cNewPatientWizard
#
# Revision 1.191 2005/04/17 16:30:34 ncq
# - improve menu structure
#
# Revision 1.190 2005/04/14 08:54:48 ncq
# - comment out a display logging change that just might crash Richard
# - add missing wx. prefix
#
# Revision 1.189 2005/04/12 18:33:29 cfmoro
# typo fix
#
# Revision 1.188 2005/04/12 10:03:20 ncq
# - slightly rearrange main menu
# - add journal export function
# - move to wx.* use
#
# Revision 1.187 2005/04/10 17:12:09 cfmoro
# Added create patient menu option
#
# Revision 1.186 2005/04/03 20:12:12 ncq
# - better wording in status line
# - add menu "EMR" with "export" item and use gmEMRBrowser.export_emr_to_ascii()
#
# Revision 1.185 2005/04/02 20:45:12 cfmoro
# Implementated exporting emr from gui client
#
# Revision 1.184 2005/03/29 07:27:54 ncq
# - just silly cleanup
#
# Revision 1.183 2005/03/14 14:37:19 ncq
# - attempt to log display settings
#
# Revision 1.182 2005/03/08 16:45:55 ncq
# - properly handle title
#
# Revision 1.181 2005/03/06 14:50:45 ncq
# - 'demographic record' -> get_identity()
#
# Revision 1.180 2005/02/13 15:28:07 ncq
# - v_basic_person.i_pk -> pk_identity
#
# Revision 1.179 2005/02/12 13:58:20 ncq
# - v_basic_person.i_id -> i_pk
#
# Revision 1.178 2005/02/03 20:19:16 ncq
# - get_demographic_record() -> get_identity()
#
# Revision 1.177 2005/02/01 10:16:07 ihaywood
# refactoring of gmDemographicRecord and follow-on changes as discussed.
#
# gmTopPanel moves to gmHorstSpace
# gmRichardSpace added -- example code at present, haven't even run it myself
# (waiting on some icon .pngs from Richard)
#
# Revision 1.176 2005/01/31 10:37:26 ncq
# - gmPatient.py -> gmPerson.py
#
# Revision 1.175 2004/10/01 13:17:35 ncq
# - eventually do what was intended on slave_mode != 1
#
# Revision 1.174 2004/10/01 11:49:59 ncq
# - improve message on unset database language
#
# Revision 1.173 2004/09/13 09:36:43 ncq
# - cleanup
# - --slave -> 'main.slave_mode'
#
# Revision 1.172 2004/09/06 22:21:08 ncq
# - properly use setDBParam()
# - store sidebar.width if not found
#
# Revision 1.171 2004/09/05 14:47:24 ncq
# - fix setDBParam() calls
#
# Revision 1.170 2004/08/20 13:34:48 ncq
# - getFirstMatchingDBSet() -> getDBParam()
#
# Revision 1.169 2004/08/11 08:15:06 ncq
# - log debugging info on why workplace appears to be list on Richard's machine
#
# Revision 1.168 2004/08/09 00:03:19 ncq
# - Horst space layout manager factored out into its own file
#
# Revision 1.167 2004/08/04 17:16:02 ncq
# - wxNotebookPlugin -> cNotebookPlugin
# - derive cNotebookPluginOld from cNotebookPlugin
# - make cNotebookPluginOld warn on use and implement old
# explicit "main.notebook.raised_plugin"/ReceiveFocus behaviour
# - ReceiveFocus() -> receive_focus()
#
# Revision 1.166 2004/07/28 15:40:05 ncq
# - log wxWidgets version
#
# Revision 1.165 2004/07/24 17:21:49 ncq
# - some cleanup, also re from wxPython import wx
# - factored out Horst space layout manager into it's own
# wx.Panel child class
# - subsequently renamed
# 'main.notebook.plugins' -> 'horstspace.notebook.pages'
# 'modules.gui' -> 'horstspace.notebook.gui' (to be renamed horstspace.notebook.plugins later)
# - adapt to said changes
#
# Revision 1.164 2004/07/24 10:26:35 ncq
# - two missing event.Skip()s added
#
# Revision 1.163 2004/07/19 11:50:42 ncq
# - cfg: what used to be called "machine" really is "workplace", so fix
#
# Revision 1.162 2004/07/18 19:54:44 ncq
# - improved logging for page change/veto debugging
#
# Revision 1.161 2004/07/18 19:49:07 ncq
# - cleanup, commenting, better logging
# - preparation for inner-frame notebook layout manager arrival
# - use Python True, not wxWidgets true, as Python tells us to do
#
# Revision 1.160 2004/07/15 18:41:22 ncq
# - cautiously go back to previous notebook plugin handling
# avoiding to remove too much of Ian's new work
# - store window size across sessions
# - try a trick for veto()ing failing notebook page changes on broken platforms
#
# Revision 1.159 2004/07/15 14:02:43 ncq
# - refactored out __set_GUI_size() from TopLevelFrame.__init__()
# so cleanup will be easier
# - added comment on layout managers
#
# Revision 1.158 2004/07/15 07:57:20 ihaywood
# This adds function-key bindings to select notebook tabs
# (Okay, it's a bit more than that, I've changed the interaction
# between gmGuiMain and gmPlugin to be event-based.)
#
# Oh, and SOAPTextCtrl allows Ctrl-Enter
#
# Revision 1.157 2004/06/26 23:09:22 ncq
# - better comments
#
# Revision 1.156 2004/06/25 14:39:35 ncq
# - make right-click runtime load/drop of plugins work again
#
# Revision 1.155 2004/06/25 12:51:23 ncq
# - InstPlugin() -> instantiate_plugin()
#
# Revision 1.154 2004/06/25 12:37:20 ncq
# - eventually fix the import gmI18N issue
#
# Revision 1.153 2004/06/23 20:53:30 ncq
# - don't break the i18n epydoc fixup, if you don't understand it then ask
#
# Revision 1.152 2004/06/22 07:58:47 ihaywood
# minor bugfixes
# let gmCfg cope with config files that are not real files
#
# Revision 1.151 2004/06/21 16:06:54 ncq
# - fix epydoc i18n fix
#
# Revision 1.150 2004/06/21 14:48:26 sjtan
#
# restored some methods that gmContacts depends on, after they were booted
# out from gmDemographicRecord with no home to go , works again ;
# removed cCatFinder('occupation') instantiating in main module scope
# which was a source of complaint , as it still will lazy load anyway.
#
# Revision 1.149 2004/06/20 16:01:05 ncq
# - please epydoc more carefully
#
# Revision 1.148 2004/06/20 06:49:21 ihaywood
# changes required due to Epydoc's OCD
#
# Revision 1.147 2004/06/13 22:31:48 ncq
# - gb['main.toolbar'] -> gb['main.top_panel']
# - self.internal_name() -> self.__class__.__name__
# - remove set_widget_reference()
# - cleanup
# - fix lazy load in _on_patient_selected()
# - fix lazy load in ReceiveFocus()
# - use self._widget in self.GetWidget()
# - override populate_with_data()
# - use gb['main.notebook.raised_plugin']
#
# Revision 1.146 2004/06/01 07:59:55 ncq
# - comments improved
#
# Revision 1.145 2004/05/15 15:51:03 sjtan
#
# hoping to link this to organization widget.
#
# Revision 1.144 2004/03/25 11:03:23 ncq
# - getActiveName -> get_names
#
# Revision 1.143 2004/03/12 13:22:02 ncq
# - fix imports
#
# Revision 1.142 2004/03/04 19:46:54 ncq
# - switch to package based import: from Gnumed.foo import bar
#
# Revision 1.141 2004/03/03 23:53:22 ihaywood
# GUI now supports external IDs,
# Demographics GUI now ALPHA (feature-complete w.r.t. version 1.0)
# but happy to consider cosmetic changes
#
# Revision 1.140 2004/02/18 14:00:56 ncq
# - moved encounter handling to gmClinicalRecord.__init__()
#
# Revision 1.139 2004/02/12 23:55:34 ncq
# - different title bar on --slave
#
# Revision 1.138 2004/02/05 23:54:11 ncq
# - wxCallAfter()
# - start/stop scripting listener
#
# Revision 1.137 2004/01/29 16:12:18 ncq
# - add check for DB account to staff member mapping
#
# Revision 1.136 2004/01/18 21:52:20 ncq
# - stop backend listeners in clean_exit()
#
# Revision 1.135 2004/01/06 10:05:21 ncq
# - question dialog on continuing previous encounter was incorrect
#
# Revision 1.134 2004/01/04 09:33:32 ihaywood
# minor bugfixes, can now create new patients, but doesn't update properly
#
# Revision 1.133 2003/12/29 23:32:56 ncq
# - reverted tolerance to missing db account <-> staff member mapping
# - added comment as to why
#
# Revision 1.132 2003/12/29 20:44:16 uid67323
# -fixed the bug that made gnumed crash if no staff entry was available for the current user
#
# Revision 1.131 2003/12/29 16:56:00 uid66147
# - current user now handled by whoami
# - updateTitle() has only one parameter left: anActivity, the others can be derived
#
# Revision 1.130 2003/11/30 01:09:10 ncq
# - use gmGuiHelpers
#
# Revision 1.129 2003/11/29 01:33:23 ncq
# - a bit of streamlining
#
# Revision 1.128 2003/11/21 19:55:32 hinnef
# re-included patch from 1.116 that was lost before
#
# Revision 1.127 2003/11/19 14:45:32 ncq
# - re-decrease excess logging on plugin load failure which
# got dropped in Syans recent commit
#
# Revision 1.126 2003/11/19 01:22:24 ncq
# - some cleanup, some local vars renamed
#
# Revision 1.125 2003/11/19 01:01:17 shilbert
# - fix for new demographic API got lost
#
# Revision 1.124 2003/11/17 10:56:38 sjtan
#
# synced and commiting.
#
# Revision 1.123 2003/11/11 18:22:18 ncq
# - fix longstanding bug in plugin loader error handler (duh !)
#
# Revision 1.122 2003/11/09 17:37:12 shilbert
# - ['demographics'] -> ['demographic record']
#
# Revision 1.121 2003/10/31 23:23:17 ncq
# - make "attach to encounter ?" dialog more informative
#
# Revision 1.120 2003/10/27 15:53:10 ncq
# - getDOB has changed
#
# Revision 1.119 2003/10/26 17:39:00 ncq
# - cleanup
#
# Revision 1.118 2003/10/26 11:27:10 ihaywood
# gmPatient is now the "patient stub", all demographics stuff in gmDemographics.
#
# syncing with main tree.
#
# Revision 1.1 2003/10/23 06:02:39 sjtan
#
# manual edit areas modelled after r.terry's specs.
#
# Revision 1.116 2003/10/22 21:34:42 hinnef
# -changed string array for main.window.size into two separate integer parameters
#
# Revision 1.115 2003/10/19 12:17:16 ncq
# - just cleanup
#
# Revision 1.114 2003/10/13 21:00:29 hinnef
# -added main.window.size config parameter (will be set on startup)
#
# Revision 1.113 2003/09/03 17:32:41 hinnef
# make use of gmWhoAmI
#
# Revision 1.112 2003/07/21 21:05:56 ncq
# - actually set database client encoding from config file, warn if missing
#
# Revision 1.111 2003/07/07 08:34:31 ihaywood
# bugfixes on gmdrugs.sql for postgres 7.3
#
# Revision 1.110 2003/06/26 22:28:50 ncq
# - need to define self.nb before using it
# - reordered __init__ for clarity
#
# Revision 1.109 2003/06/26 21:38:28 ncq
# - fatal->verbose
# - ignore system-to-database locale mismatch if user so desires
#
# Revision 1.108 2003/06/25 22:50:30 ncq
# - large cleanup
# - lots of comments re method call order on application closing
# - send application_closing() from _clean_exit()
# - add OnExit() handler, catch/log session management events
# - add helper __show_question()
#
# Revision 1.107 2003/06/24 12:55:40 ncq
# - typo: it's qUestion, not qestion
#
# Revision 1.106 2003/06/23 22:29:59 ncq
# - in on_patient_selected() add code to attach to a
# previous encounter or create one if necessary
# - show_error/quesion() helper
#
# Revision 1.105 2003/06/19 15:27:53 ncq
# - also process wx.EVT_NOTEBOOK_PAGE_CHANGING
# - veto() page change if can_receive_focus() is false
#
# Revision 1.104 2003/06/17 22:30:41 ncq
# - some cleanup
#
# Revision 1.103 2003/06/10 09:55:34 ncq
# - don't import handler_loader anymore
#
# Revision 1.102 2003/06/01 14:34:47 sjtan
#
# hopefully complies with temporary model; not using setData now ( but that did work).
# Please leave a working and tested substitute (i.e. select a patient , allergy list
# will change; check allergy panel allows update of allergy list), if still
# not satisfied. I need a working model-view connection ; trying to get at least
# a basically database updating version going .
#
# Revision 1.101 2003/06/01 12:36:40 ncq
# - no way cluttering INFO level log files with arbitrary patient data
#
# Revision 1.100 2003/06/01 01:47:33 sjtan
#
# starting allergy connections.
#
# Revision 1.99 2003/05/12 09:13:31 ncq
# - SQL ends with ";", cleanup
#
# Revision 1.98 2003/05/10 18:47:08 hinnef
# - set 'currentUser' in GuiBroker-dict
#
# Revision 1.97 2003/05/03 14:16:33 ncq
# - we don't use OnIdle(), so don't hook it
#
# Revision 1.96 2003/04/28 12:04:09 ncq
# - use plugin.internal_name()
#
# Revision 1.95 2003/04/25 13:03:07 ncq
# - just some silly whitespace fix
#
# Revision 1.94 2003/04/08 21:24:14 ncq
# - renamed gmGP_Toolbar -> gmTopPanel
#
# Revision 1.93 2003/04/04 20:43:47 ncq
# - take advantage of gmCurrentPatient()
#
# Revision 1.92 2003/04/03 13:50:21 ncq
# - catch more early results of connection failures ...
#
# Revision 1.91 2003/04/01 15:55:24 ncq
# - fix setting of db lang, better message if no lang set yet
#
# Revision 1.90 2003/04/01 12:26:04 ncq
# - add menu "Reference"
#
# Revision 1.89 2003/03/30 00:24:00 ncq
# - typos
# - (hopefully) less confusing printk()s at startup
#
# Revision 1.88 2003/03/29 14:12:35 ncq
# - set minimum size to 320x240
#
# Revision 1.87 2003/03/29 13:48:42 ncq
# - cleanup, clarify, improve sizer use
#
# Revision 1.86 2003/03/24 17:15:05 ncq
# - slightly speed up startup by using pre-calculated system_locale_level dict
#
# Revision 1.85 2003/03/23 11:46:14 ncq
# - remove extra debugging statements
#
# Revision 1.84 2003/02/17 16:20:38 ncq
# - streamline imports
# - comment out app_init signal dispatch since it breaks
#
# Revision 1.83 2003/02/14 00:05:36 sjtan
#
# generated files more usable.
#
# Revision 1.82 2003/02/13 08:21:18 ihaywood
# bugfix for MSW
#
# Revision 1.81 2003/02/12 23:45:49 sjtan
#
# removing dead code.
#
# Revision 1.80 2003/02/12 23:37:58 sjtan
#
# now using gmDispatcher and gmSignals for initialization and cleanup.
# Comment out the import handler_loader in gmGuiMain will restore back
# to prototype GUI stage.
#
# Revision 1.79 2003/02/11 12:21:19 sjtan
#
# one more dependency formed , at closing , to implement saving of persistence objects.
# this should be temporary, if a periodic save mechanism is implemented
#
# Revision 1.78 2003/02/09 20:02:55 ncq
# - rename main.notebook.numbers to main.notebook.plugins
#
# Revision 1.77 2003/02/09 12:44:43 ncq
# - fixed my typo
#
# Revision 1.76 2003/02/09 09:47:38 sjtan
#
# handler loading placed here.
#
# Revision 1.75 2003/02/09 09:05:30 michaelb
# renamed 'icon_gui_main' to 'icon_serpent', added icon to loading-plugins-progress-dialog box
#
# Revision 1.74 2003/02/07 22:57:59 ncq
# - fixed extra (% cmd)
#
# Revision 1.73 2003/02/07 14:30:33 ncq
# - setting the db language now works
#
# Revision 1.72 2003/02/07 08:57:39 ncq
# - fixed type
#
# Revision 1.71 2003/02/07 08:37:13 ncq
# - fixed some fallout from SJT's work
# - don't die if select lang from i18n_curr_lang returns None
#
# Revision 1.70 2003/02/07 05:13:59 sjtan
#
# took out the myLog temporary so not broken when I'm running to see if hooks work.
#
# Revision 1.69 2003/02/06 14:02:47 ncq
# - some more logging to catch the set_db_lang problem
#
# Revision 1.68 2003/02/06 12:44:06 ncq
# - curr_locale -> system_locale
#
# Revision 1.67 2003/02/05 12:15:01 ncq
# - not auto-sets the database level language if so desired and possible
#
# Revision 1.66 2003/02/02 09:11:19 ihaywood
# gmDemographics will connect, search and emit patient_selected
#
# Revision 1.65 2003/02/01 21:59:42 michaelb
# moved 'About GnuMed' into module; gmGuiMain version no longer displayed in about box
#
# Revision 1.64 2003/02/01 11:57:56 ncq
# - display gmGuiMain version in About box
#
# Revision 1.63 2003/02/01 07:10:50 michaelb
# fixed scrolling problem
#
# Revision 1.61 2003/01/29 04:26:37 michaelb
# removed import images_gnuMedGP_TabbedLists.py
#
# Revision 1.60 2003/01/14 19:36:04 ncq
# - frame.Maximize() works on Windows ONLY
#
# Revision 1.59 2003/01/14 09:10:19 ncq
# - maybe icons work better now ?
#
# Revision 1.58 2003/01/13 06:30:16 michaelb
# the serpent window-icon was added
#
# Revision 1.57 2003/01/12 17:31:10 ncq
# - catch failing plugins better
#
# Revision 1.56 2003/01/12 01:46:57 ncq
# - coding style cleanup
#
# Revision 1.55 2003/01/11 22:03:30 hinnef
# removed gmConf
#
# Revision 1.54 2003/01/05 10:03:30 ncq
# - code cleanup
# - use new plugin config storage infrastructure
#
# Revision 1.53 2003/01/04 07:43:55 ihaywood
# Popup menus on notebook tabs
#
# Revision 1.52 2002/12/26 15:50:39 ncq
# - title bar fine-tuning
#
# Revision 1.51 2002/11/30 11:09:55 ncq
# - refined title bar
# - comments
#
# Revision 1.50 2002/11/13 10:07:25 ncq
# - export updateTitle() via guibroker
# - internally set title according to template
#
# Revision 1.49 2002/11/12 21:24:51 hherb
# started to use dispatcher signals
#
# Revision 1.48 2002/11/09 18:14:38 hherb
# Errors / delay caused by loading plugin progess bar fixed
#
# Revision 1.47 2002/09/30 10:57:56 ncq
# - make GnuMed consistent spelling in user-visible strings
#
# Revision 1.46 2002/09/26 13:24:15 ncq
# - log version
#
# Revision 1.45 2002/09/12 23:21:38 ncq
# - fix progress bar
#
# Revision 1.44 2002/09/10 12:25:33 ncq
# - gimmicks rule :-)
# - display plugin_nr/nr_of_plugins on load in progress bar
#
# Revision 1.43 2002/09/10 10:26:03 ncq
# - properly i18n() strings
#
# Revision 1.42 2002/09/10 09:08:49 ncq
# - set a useful window title and add a comment regarding this item
#
# Revision 1.41 2002/09/09 10:07:48 ncq
# - long initial string so module names fit into progress bar display
#
# Revision 1.40 2002/09/09 00:52:55 ncq
# - show progress bar on plugin load :-)
#
# Revision 1.39 2002/09/08 23:17:37 ncq
# - removed obsolete reference to gmLogFrame.py
#
# @change log:
# 10.06.2001 hherb initial implementation, untested
# 01.11.2001 hherb comments added, modified for distributed servers
# make no mistake: this module is still completely useless!
|