Trees | Indices | Help |
|
---|
|
1 # GnuMed 2 3 #=========================================================== 4 # $Source: /cvsroot/gnumed/gnumed/gnumed/client/wxpython/gmTopPanel.py,v $ 5 # $Id: gmTopPanel.py,v 1.106 2009/07/17 09:26:53 ncq Exp $ 6 __version__ = "$Revision: 1.106 $" 7 __author__ = "R.Terry <rterry@gnumed.net>, I.Haywood <i.haywood@ugrad.unimelb.edu.au>, K.Hilbert <Karsten.Hilbert@gmx.net>" 8 __license__ = "GPL" 9 10 11 import sys, os.path, datetime as pyDT, logging 12 13 14 import wx 15 16 17 from Gnumed.pycommon import gmGuiBroker, gmPG2, gmDispatcher, gmTools, gmCfg2, gmDateTime, gmI18N 18 from Gnumed.business import gmPerson, gmEMRStructItems, gmAllergy 19 from Gnumed.wxpython import gmGuiHelpers, gmPatPicWidgets, gmPatSearchWidgets, gmAllergyWidgets 20 21 _log = logging.getLogger('gm.ui') 22 _log.info(__version__) 23 24 [ ID_BTN_pat_demographics, 25 # ID_CBOX_consult_type, 26 ID_BMITOOL, 27 ID_BMIMENU, 28 ID_PREGTOOL, 29 ID_PREGMENU, 30 ID_LOCKBUTTON, 31 ID_LOCKMENU, 32 ] = map(lambda _init_ctrls: wx.NewId(), range(7)) 33 34 # FIXME: need a better name here ! 35 bg_col = wx.Colour(214,214,214) 36 fg_col = wx.Colour(0,0,131) 37 col_brightred = wx.Colour(255,0,0) 38 #===========================================================40384 #------------------------------------------------------- 385 # def CreateBar(self): 386 # """Creates empty toolbar suited for adding to top panel.""" 387 # bar = wx.ToolBar ( 388 # self.pnl_bottom_row, 389 # -1, 390 # size = self.pnl_bottom_row.GetClientSize(), 391 # style = wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT 392 # ) 393 # return bar 394 #------------------------------------------------------- 395 # def AddBar(self, key=None, bar=None): 396 # """Creates and returns a new empty toolbar, referenced by key. 397 # 398 # Key should correspond to the notebook page number as defined 399 # by the notebook (see gmPlugin.py), so that gmGuiMain can 400 # display the toolbar with the notebook 401 # """ 402 # bar.SetToolBitmapSize((16,16)) 403 # self.subbars[key] = bar 404 # if len(self.subbars) == 1: 405 # bar.Show(1) 406 # self.__current = key 407 # else: 408 # bar.Hide() 409 # return True 410 #------------------------------------------------------- 411 # def ReFit (self): 412 # """Refits the toolbar after its been changed 413 # """ 414 # tw = 0 415 # th = 0 416 # # get maximum size for the toolbar 417 # for i in self.subbars.values (): 418 # ntw, nth = i.GetSizeTuple () 419 # if ntw > tw: 420 # tw = ntw 421 # if nth > th: 422 # th = nth 423 # #import pdb 424 # #pdb.set_trace () 425 # sz = wx.Size (tw, th) 426 # self.pnl_bottom_row.SetSize(sz) 427 # for i in self.subbars.values(): 428 # i.SetSize (sz) 429 # self.szr_main.Layout() 430 # self.szr_main.Fit(self) 431 #------------------------------------------------------- 432 # def ShowBar (self, key): 433 # """Displays the named toolbar. 434 # """ 435 # self.subbars[self.__current].Hide() 436 # try: 437 # self.subbars[key].Show(1) 438 # self.__current = key 439 # except KeyError: 440 # _log.exception("cannot show undefined toolbar [%s]" % key) 441 #------------------------------------------------------- 442 # def DeleteBar (self, key): 443 # """Removes a toolbar. 444 # """ 445 # try: 446 # self.subbars[key].Destroy() 447 # del self.subbars[key] 448 # # FIXME: ?? 449 # if self.__current == key and len(self.subbars): 450 # self.__current = self.subbars.keys()[0] 451 # self.subbars[self.__current].Show(1) 452 # except KeyError: 453 # _log.exception("cannot delete undefined toolbar [%s]" % key) 454 455 #=========================================================== 456 if __name__ == "__main__": 457 wx.InitAllImageHandlers() 458 app = wxPyWidgetTester(size = (400, 200)) 459 app.SetWidget(cMainTopPanel, -1) 460 app.MainLoop() 461 #=========================================================== 462 # $Log: gmTopPanel.py,v $ 463 # Revision 1.106 2009/07/17 09:26:53 ncq 464 # - no more main.frame in gui broker 465 # 466 # Revision 1.105 2009/07/15 12:47:57 ncq 467 # - properly display age of dead people 468 # 469 # Revision 1.104 2009/06/20 22:39:50 ncq 470 # - remove lock menu item 471 # 472 # Revision 1.103 2009/06/04 16:33:51 ncq 473 # - adjust to dob-less persons 474 # 475 # Revision 1.102 2009/03/10 14:24:53 ncq 476 # - refactor age label calculation 477 # 478 # Revision 1.101 2008/12/09 23:43:50 ncq 479 # - cleanup 480 # 481 # Revision 1.100 2008/10/22 12:22:26 ncq 482 # - improved allergies tooltip and display 483 # 484 # Revision 1.99 2008/10/12 16:36:45 ncq 485 # - cleanup 486 # - consultation -> encounter 487 # - improved allergies handling 488 # 489 # Revision 1.98 2008/08/28 18:34:47 ncq 490 # - pat search widget now takes care of updating 491 # its display itself when necessary 492 # 493 # Revision 1.97 2008/08/05 16:22:44 ncq 494 # - improve dob display and allergies tooltip 495 # 496 # Revision 1.96 2008/07/10 08:41:09 ncq 497 # - comment out toolbar handling 498 # - pat.is_connected -> connected property 499 # 500 # Revision 1.95 2008/03/09 20:18:56 ncq 501 # - use cActivePatientSelector() 502 # 503 # Revision 1.94 2008/03/05 22:30:15 ncq 504 # - new style logging 505 # 506 # Revision 1.93 2008/01/27 21:20:58 ncq 507 # - no more label "Patient" 508 # - make age field a dynamically adjusting static text, include gender and DOB 509 # - remind of birthday 510 # 511 # Revision 1.92 2007/12/23 22:04:19 ncq 512 # - no more gmCLI 513 # 514 # Revision 1.91 2007/12/23 20:29:57 ncq 515 # - use gmCfg2 516 # 517 # Revision 1.90 2007/12/11 12:49:26 ncq 518 # - explicit signal handling 519 # 520 # Revision 1.89 2007/12/02 11:00:58 ncq 521 # - update age, too, on pat identity change 522 # 523 # Revision 1.88 2007/11/28 22:36:41 ncq 524 # - listen on identity/name changes for current patient 525 # 526 # Revision 1.87 2007/10/25 12:27:29 ncq 527 # - cleanup 528 # 529 # Revision 1.86 2007/10/25 12:21:39 ncq 530 # - listen to the proper signals for allergy changes 531 # 532 # Revision 1.85 2007/08/12 00:12:41 ncq 533 # - no more gmSignals.py 534 # 535 # Revision 1.84 2007/05/21 17:13:43 ncq 536 # - translate "Allergies" in allergy field tooltip 537 # 538 # Revision 1.83 2007/04/11 20:47:13 ncq 539 # - no more 'resource dir' and 'gnumed_dir' 540 # 541 # Revision 1.82 2007/03/26 16:50:14 ncq 542 # - allergy['reaction'] can be empty 543 # 544 # Revision 1.81 2007/03/26 14:44:36 ncq 545 # - left align first line of allergies list tooltip 546 # 547 # Revision 1.80 2007/03/23 15:39:02 ncq 548 # - show allergy manager on double-clicking allergies field 549 # 550 # Revision 1.79 2007/03/23 15:03:02 ncq 551 # - improved allergies display 552 # - smaller font 553 # - 10 char truncation 554 # - align properly 555 # - patient dependant tooltip listing allergy details including sensitivities 556 # 557 # Revision 1.78 2007/03/21 08:14:32 ncq 558 # - use proper no-allergies string 559 # 560 # Revision 1.77 2007/02/22 17:41:13 ncq 561 # - adjust to gmPerson changes 562 # 563 # Revision 1.76 2006/11/05 16:04:45 ncq 564 # - some cleanup 565 # 566 # Revision 1.75 2006/10/25 07:21:57 ncq 567 # - no more gmPG 568 # 569 # Revision 1.74 2006/07/30 21:15:53 ncq 570 # - do not import preg widgets 571 # 572 # Revision 1.73 2006/07/22 12:51:13 ncq 573 # - deactivate bmi until it is cleaned up 574 # 575 # Revision 1.72 2006/07/19 20:29:50 ncq 576 # - import cleanup 577 # 578 # Revision 1.71 2006/06/28 10:18:40 ncq 579 # - comment out consultation type selector for now 580 # 581 # Revision 1.70 2006/05/15 13:36:00 ncq 582 # - signal cleanup: 583 # - activating_patient -> pre_patient_selection 584 # - patient_selected -> post_patient_selection 585 # 586 # Revision 1.69 2006/05/04 09:49:20 ncq 587 # - get_clinical_record() -> get_emr() 588 # - adjust to changes in set_active_patient() 589 # - need explicit set_active_patient() after ask_for_patient() if wanted 590 # 591 # Revision 1.68 2005/11/27 12:56:45 ncq 592 # - use gmEMRStructItems.get_encounter_types() 593 # 594 # Revision 1.67 2005/09/28 21:38:11 ncq 595 # - more 2.6-ification 596 # 597 # Revision 1.66 2005/09/28 21:27:30 ncq 598 # - a lot of wx2.6-ification 599 # 600 # Revision 1.65 2005/09/28 15:57:48 ncq 601 # - a whole bunch of wx.Foo -> wx.Foo 602 # 603 # Revision 1.64 2005/09/26 18:01:51 ncq 604 # - use proper way to import wx26 vs wx2.4 605 # - note: THIS WILL BREAK RUNNING THE CLIENT IN SOME PLACES 606 # - time for fixup 607 # 608 # Revision 1.63 2005/09/24 09:17:29 ncq 609 # - some wx2.6 compatibility fixes 610 # 611 # Revision 1.62 2005/09/04 07:34:31 ncq 612 # - comment out padlock button for now 613 # - add label "Patient" in front of patient search field as per Hilmar's request 614 # 615 # Revision 1.61 2005/07/24 11:40:21 ncq 616 # - comment out edc/pregnancy calculator 617 # 618 # Revision 1.60 2005/06/24 22:17:08 shilbert 619 # - deuglyfied , reclaim wasted gui sapce in TopPanel 620 # 621 # Revision 1.59 2005/05/17 08:12:11 ncq 622 # - move padlock tool button to inbetween patient picture and patient name 623 # as users found that more consistent and drop "demographic details" tool 624 # button from there 625 # 626 # Revision 1.58 2005/04/03 20:13:35 ncq 627 # - episode selector in top panel didn't help very much as we 628 # always work on several episodes - just as the patient suffers 629 # several problems at once 630 # 631 # Revision 1.57 2005/02/03 20:19:16 ncq 632 # - get_demographic_record() -> get_identity() 633 # 634 # Revision 1.56 2005/02/01 10:16:07 ihaywood 635 # refactoring of gmDemographicRecord and follow-on changes as discussed. 636 # 637 # gmTopPanel moves to gmHorstSpace 638 # gmRichardSpace added -- example code at present, haven't even run it myself 639 # (waiting on some icon .pngs from Richard) 640 # 641 # Revision 1.55 2005/01/31 10:37:26 ncq 642 # - gmPatient.py -> gmPerson.py 643 # 644 # Revision 1.54 2004/10/17 16:01:44 ncq 645 # - the FIXME said DEuglify, not MORE 646 # 647 # Revision 1.53 2004/10/16 22:42:12 sjtan 648 # 649 # script for unitesting; guard for unit tests where unit uses gmPhraseWheel; fixup where version of wxPython doesn't allow 650 # a child widget to be multiply inserted (gmDemographics) ; try block for later versions of wxWidgets that might fail 651 # the Add (.. w,h, ... ) because expecting Add(.. (w,h) ...) 652 # 653 # Revision 1.52 2004/10/14 12:13:58 ncq 654 # - factor out toolbar creation from toolbar registering 655 # 656 # Revision 1.51 2004/09/13 09:26:16 ncq 657 # - --slave -> 'main.slave_mode' 658 # 659 # Revision 1.50 2004/08/20 06:48:31 ncq 660 # - import gmPatSearchWidgets 661 # 662 # Revision 1.49 2004/08/18 10:16:03 ncq 663 # - import patient picture code from Richard's improved gmPatPicWidgets 664 # 665 # Revision 1.48 2004/08/09 00:05:15 ncq 666 # - cleanup 667 # - hardcode loading depluginized preg calculator/lock button 668 # - load icons from png files 669 # 670 # Revision 1.47 2004/08/06 09:25:36 ncq 671 # - always load BMI calculator 672 # 673 # Revision 1.46 2004/07/18 20:30:54 ncq 674 # - wxPython.true/false -> Python.True/False as Python tells us to do 675 # 676 # Revision 1.45 2004/07/15 20:39:51 ncq 677 # - normalize/cleanup layout, I'm sure Richard will have a 678 # say on this but it does look cleaner to me 679 # 680 # Revision 1.44 2004/06/26 07:33:55 ncq 681 # - id_episode -> fk/pk_episode 682 # 683 # Revision 1.43 2004/06/13 22:18:41 ncq 684 # - cleanup 685 # 686 # Revision 1.42 2004/06/02 00:00:47 ncq 687 # - make work on Mac AND 2.4.1 Linux wxWidgets 688 # - correctly handle episode VOs 689 # 690 # Revision 1.41 2004/05/30 09:03:46 shilbert 691 # - one more little fix regarding get_active_episode() 692 # 693 # Revision 1.40 2004/05/29 22:19:56 ncq 694 # - use get_active_episode() 695 # 696 # Revision 1.39 2004/05/28 09:03:54 shilbert 697 # - fix sizer setup to enable it on wxMac 698 # 699 # Revision 1.38 2004/05/18 22:39:15 ncq 700 # - work with episode objects now 701 # 702 # Revision 1.37 2004/05/18 20:43:17 ncq 703 # - check get_clinical_record() return status 704 # 705 # Revision 1.36 2004/05/16 14:32:51 ncq 706 # - cleanup 707 # 708 # Revision 1.35 2004/05/08 17:34:15 ncq 709 # - v_i18n_enum_encounter_type is gone, use _(encounter_type) 710 # 711 # Revision 1.34 2004/04/20 00:17:55 ncq 712 # - allergies API revamped, kudos to Carlos 713 # 714 # Revision 1.33 2004/03/25 11:03:23 ncq 715 # - getActiveName -> get_names 716 # 717 # Revision 1.32 2004/03/04 19:47:07 ncq 718 # - switch to package based import: from Gnumed.foo import bar 719 # 720 # Revision 1.31 2004/02/25 09:46:22 ncq 721 # - import from pycommon now, not python-common 722 # 723 # Revision 1.30 2004/02/18 14:03:37 ncq 724 # - hardcode encounter type "chart review", too 725 # 726 # Revision 1.29 2004/02/12 23:58:17 ncq 727 # - disable editing of patient selector when --slave()d 728 # 729 # Revision 1.28 2004/02/05 23:49:52 ncq 730 # - use wxCallAfter() 731 # 732 # Revision 1.27 2004/01/15 14:58:31 ncq 733 # - activate episode selector 734 # 735 # Revision 1.26 2004/01/06 10:07:42 ncq 736 # - add episode selector to the left of the encounter type selector 737 # 738 # Revision 1.25 2003/11/18 23:48:08 ncq 739 # - remove merge conflict remnants in update_allergy 740 # 741 # Revision 1.24 2003/11/17 10:56:39 sjtan 742 # 743 # synced and commiting. 744 # 745 # Revision 1.23 2003/11/13 08:15:25 ncq 746 # - display allergies in top panel again 747 # 748 # Revision 1.22 2003/11/09 17:33:27 shilbert 749 # - minor glitch 750 # 751 # Revision 1.21 2003/11/09 17:31:13 shilbert 752 # - ['demographics'] -> ['demographic record'] 753 # 754 # Revision 1.20 2003/11/09 14:31:25 ncq 755 # - new API style in clinical record 756 # Revision 1.19 2003/10/26 18:04:01 ncq 757 # - cleanup 758 # 759 # Revision 1.18 2003/10/26 11:27:10 ihaywood 760 # gmPatient is now the "patient stub", all demographics stuff in gmDemographics. 761 # 762 # Ergregious breakages are fixed, but needs more work 763 # 764 # Revision 1.17 2003/10/26 01:36:14 ncq 765 # - gmTmpPatient -> gmPatient 766 # 767 # Revision 1.16 2003/10/19 12:20:10 ncq 768 # - use GuiHelpers.py 769 # 770 # Revision 1.15 2003/07/07 08:34:31 ihaywood 771 # bugfixes on gmdrugs.sql for postgres 7.3 772 # 773 # Revision 1.14 2003/06/26 21:40:29 ncq 774 # - fatal->verbose 775 # 776 # Revision 1.13 2003/06/26 04:18:40 ihaywood 777 # Fixes to gmCfg for commas 778 # 779 # Revision 1.12 2003/06/01 12:31:58 ncq 780 # - logging data is not by any means lInfo 781 # 782 # Revision 1.11 2003/06/01 01:47:33 sjtan 783 # 784 # starting allergy connections. 785 # 786 # Revision 1.10 2003/05/05 00:21:00 ncq 787 # - make work with encounter types translation 788 # 789 # Revision 1.9 2003/05/05 00:00:21 ncq 790 # - do load encounter types again 791 # 792 # Revision 1.8 2003/05/04 23:33:56 ncq 793 # - comments bettered 794 # 795 # Revision 1.7 2003/05/03 14:18:06 ncq 796 # - must use wxCallAfter in _update_allergies since this can be called 797 # indirectly from a thread listening to backend signals and one cannot use 798 # wx GUI functions from Python threads other than main() 799 # 800 # Revision 1.6 2003/05/03 00:43:14 ncq 801 # - properly set allergies field on patient change 802 # - hot update of allergies in DB needs testing 803 # 804 # Revision 1.5 2003/05/01 15:04:10 ncq 805 # - connect allergies field to backend (need to filter out sensitivities, though) 806 # - update allergies on patient selection 807 # - listen to allergy change signal 808 # 809 # Revision 1.4 2003/04/28 12:05:21 ncq 810 # - use plugin.internal_name(), cleaner logging 811 # 812 # Revision 1.3 2003/04/25 13:37:22 ncq 813 # - moved combo box "consultation type" here from gmDemographics (still needs to be placed right-most) 814 # - helper __show_error() 815 # - connected "consultation type" to backend 816 # 817 # Revision 1.2 2003/04/19 15:00:30 ncq 818 # - display age, finally 819 # 820 # Revision 1.1 2003/04/08 21:24:14 ncq 821 # - renamed gmGP_Toolbar -> gmTopPanel 822 # 823 # Revision 1.13 2003/04/04 20:43:01 ncq 824 # - install new patient search widget 825 # - rework to be a more invariant top pane less dependant on gmDemographics 826 # - file should be renamed to gmTopPane.py 827 # 828 # Revision 1.12 2003/03/29 18:26:04 ncq 829 # - allow proportion/flag/border in AddWidgetTopLine() 830 # 831 # Revision 1.11 2003/03/29 13:46:44 ncq 832 # - make standalone work, cure sizerom 833 # - general cleanup, comment, clarify 834 # 835 # Revision 1.10 2003/01/12 00:24:02 ncq 836 # - CVS keywords 837 # 83842 43 wx.Panel.__init__(self, parent, id, wx.DefaultPosition, wx.DefaultSize, wx.RAISED_BORDER) 44 45 self.__gb = gmGuiBroker.GuiBroker() 46 47 self.__do_layout() 48 self.__register_interests() 49 50 # init plugin toolbars dict 51 #self.subbars = {} 52 self.curr_pat = gmPerson.gmCurrentPatient() 53 54 # and actually display ourselves 55 self.SetAutoLayout(True) 56 self.Show(True)57 #-------------------------------------------------------59 """Create the layout. 60 61 .--------------------------------. 62 | patient | top row | 63 | picture |----------------------| 64 | | bottom row | 65 `--------------------------------' 66 """ 67 self.SetBackgroundColour(bg_col) 68 69 # create rows 70 # - top row 71 # .--------------------------------------. 72 # | details | patient | age | allergies | 73 # | button | selector | | | 74 # `--------------------------------------' 75 self.szr_top_row = wx.BoxSizer(wx.HORIZONTAL) 76 77 # - details button 78 # fname = os.path.join(self.__gb['gnumed_dir'], 'bitmaps', 'binoculars_form.png') 79 # img = wxImage(fname, wx.BITMAP_TYPE_ANY) 80 # bmp = wx.BitmapFromImage(img) 81 # self.btn_pat_demographics = wx.BitmapButton ( 82 # parent = self, 83 # id = ID_BTN_pat_demographics, 84 # bitmap = bmp, 85 # style = wx.BU_EXACTFIT | wxNO_BORDER 86 # ) 87 # self.btn_pat_demographics.SetToolTip(wxToolTip(_("display patient demographics"))) 88 # self.szr_top_row.Add (self.btn_pat_demographics, 0, wxEXPAND | wx.BOTTOM, 3) 89 90 # padlock button - Dare I say HIPAA ? 91 # fname = os.path.join(self.__gb['gnumed_dir'], 'bitmaps', 'padlock_closed.png') 92 # img = wxImage(fname, wx.BITMAP_TYPE_ANY) 93 # bmp = wx.BitmapFromImage(img) 94 # self.btn_lock = wx.BitmapButton ( 95 # parent = self, 96 # id = ID_LOCKBUTTON, 97 # bitmap = bmp, 98 # style = wx.BU_EXACTFIT | wxNO_BORDER 99 # ) 100 # self.btn_lock.SetToolTip(wxToolTip(_('lock client'))) 101 # self.szr_top_row.Add(self.btn_lock, 0, wxALL, 3) 102 103 # - patient selector 104 self.patient_selector = gmPatSearchWidgets.cActivePatientSelector(self, -1) 105 cfg = gmCfg2.gmCfgData() 106 if cfg.get(option = 'slave'): 107 self.patient_selector.SetEditable(0) 108 self.patient_selector.SetToolTip(None) 109 self.patient_selector.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False, '')) 110 111 # - age 112 self.lbl_age = wx.StaticText(self, -1, u'', style = wx.ALIGN_CENTER_VERTICAL) 113 self.lbl_age.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD, False, '')) 114 115 # - allergies (substances only, like "makrolides, penicillins, eggs") 116 self.lbl_allergies = wx.StaticText (self, -1, _('Caveat'), style = wx.ALIGN_CENTER_VERTICAL) 117 self.lbl_allergies.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False, '')) 118 self.lbl_allergies.SetBackgroundColour(bg_col) 119 self.lbl_allergies.SetForegroundColour(col_brightred) 120 self.txt_allergies = wx.TextCtrl (self, -1, "", style = wx.TE_READONLY) 121 self.txt_allergies.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD, False, '')) 122 self.txt_allergies.SetForegroundColour (col_brightred) 123 124 self.szr_top_row.Add(self.patient_selector, 6, wx.LEFT | wx.BOTTOM, 3) 125 self.szr_top_row.Add(self.lbl_age, 0, wx.ALL, 3) 126 self.szr_top_row.Add(self.lbl_allergies, 0, wx.ALL, 3) 127 self.szr_top_row.Add(self.txt_allergies, 8, wx.BOTTOM, 3) 128 129 # - bottom row 130 # .----------------------------------------------------------. 131 # | plugin toolbar | bmi | edc | | encounter | lock | 132 # | | | | | type sel | | 133 # `----------------------------------------------------------' 134 #self.tb_lock.AddControl(wx.StaticBitmap(self.tb_lock, -1, getvertical_separator_thinBitmap(), wx.DefaultPosition, wx.DefaultSize)) 135 136 # (holds most of the buttons) 137 self.szr_bottom_row = wx.BoxSizer(wx.HORIZONTAL) 138 self.pnl_bottom_row = wx.Panel(self, -1) 139 self.szr_bottom_row.Add(self.pnl_bottom_row, 6, wx.GROW, 0) 140 141 # BMI calculator button 142 # fname = os.path.join(self.__gb['gnumed_dir'], 'bitmaps', 'bmi_calculator.png') 143 # img = wx.Image(fname, wx.BITMAP_TYPE_ANY) 144 # bmp = wx.BitmapFromImage(img) 145 # self.btn_bmi = wx.BitmapButton ( 146 # parent = self, 147 # id = ID_BMITOOL, 148 # bitmap = bmp, 149 # style = wx.BU_EXACTFIT | wx.NO_BORDER 150 # ) 151 # self.btn_bmi.SetToolTip(wx.ToolTip(_("BMI Calculator"))) 152 # self.szr_bottom_row.Add(self.btn_bmi, 0) 153 154 # tb = wxToolBar(self, -1, style=wx.TB_HORIZONTAL | wxNO_BORDER | wx.TB_FLAT) 155 # tb.AddTool ( 156 # ID_BMITOOL, 157 # gmImgTools.xpm2bmp(bmicalculator.get_xpm()), 158 # shortHelpString = _("BMI Calculator") 159 # ) 160 # self.szr_bottom_row.Add(tb, 0, wxRIGHT, 0) 161 162 # pregnancy calculator button 163 # fname = os.path.join(self.__gb['gnumed_dir'], 'bitmaps', 'preg_calculator.png') 164 # img = wxImage(fname, wx.BITMAP_TYPE_ANY) 165 # bmp = wx.BitmapFromImage(img) 166 # self.btn_preg = wx.BitmapButton ( 167 # parent = self, 168 # id = ID_PREGTOOL, 169 # bitmap = bmp, 170 # style = wx.BU_EXACTFIT | wxNO_BORDER 171 # ) 172 # self.btn_preg.SetToolTip(wxToolTip(_("Pregnancy Calculator"))) 173 # self.szr_bottom_row.Add(self.btn_preg, 0) 174 175 # - stack them atop each other 176 self.szr_stacked_rows = wx.BoxSizer(wx.VERTICAL) 177 # ??? (IMHO: space is at too much of a premium for such padding) 178 # FIXME: deuglify 179 try: 180 self.szr_stacked_rows.Add(1, 1, 0) 181 except: 182 self.szr_stacked_rows.Add((1, 1), 0) 183 184 # 0 here indicates the sizer cannot change its heights - which is intended 185 self.szr_stacked_rows.Add(self.szr_top_row, 0, wx.EXPAND) 186 self.szr_stacked_rows.Add(self.szr_bottom_row, 1, wx.EXPAND|wx.TOP, 5) 187 188 # create patient picture 189 self.patient_picture = gmPatPicWidgets.cPatientPicture(self, -1) 190 tt = wx.ToolTip(_('Patient picture.\nRight-click for context menu.')) 191 self.patient_picture.SetToolTip(tt) 192 193 # create main sizer 194 self.szr_main = wx.BoxSizer(wx.HORIZONTAL) 195 # - insert patient picture 196 self.szr_main.Add(self.patient_picture, 0, wx.LEFT | wx.TOP | wx.Right, 5) 197 # - insert stacked rows 198 self.szr_main.Add(self.szr_stacked_rows, 1) 199 200 # associate ourselves with our main sizer 201 self.SetSizer(self.szr_main) 202 # and auto-size to minimum calculated size 203 self.szr_main.Fit(self)204 #------------------------------------------------------- 205 # internal helpers 206 #------------------------------------------------------- 207 #------------------------------------------------------- 208 # event handling 209 #-------------------------------------------------------211 # events 212 wx.EVT_BUTTON(self, ID_BTN_pat_demographics, self.__on_display_demographics) 213 214 # tools_menu = self.__gb['main.toolsmenu'] 215 216 # - BMI calculator 217 # wx.EVT_BUTTON(self, ID_BMITOOL, self._on_show_BMI) 218 # tools_menu.Append(ID_BMIMENU, _("BMI"), _("Body Mass Index Calculator")) 219 # wx.EVT_MENU(main_frame, ID_BMIMENU, self._on_show_BMI) 220 221 # - pregnancy calculator 222 # wx.EVT_BUTTON(self, ID_PREGTOOL, self._on_show_Preg_Calc) 223 # tools_menu.Append(ID_PREGMENU, _("EDC"), _("Pregnancy Calculator")) 224 # wx.EVT_MENU(main_frame, ID_PREGMENU, self._on_show_Preg_Calc) 225 226 # - lock button 227 # wx.EVT_BUTTON(self, ID_LOCKBUTTON, self._on_lock) 228 # tools_menu.Append(ID_LOCKMENU, _("lock client"), _("locks client and hides data")) 229 # wx.EVT_MENU(main_frame, ID_LOCKMENU, self._on_lock) 230 231 wx.EVT_LEFT_DCLICK(self.txt_allergies, self._on_allergies_dclicked) 232 233 # client internal signals 234 gmDispatcher.connect(signal = u'post_patient_selection', receiver = self._on_post_patient_selection) 235 gmDispatcher.connect(signal = u'allg_mod_db', receiver = self._update_allergies) 236 gmDispatcher.connect(signal = u'allg_state_mod_db', receiver = self._update_allergies) 237 gmDispatcher.connect(signal = u'name_mod_db', receiver = self._on_name_identity_change) 238 gmDispatcher.connect(signal = u'identity_mod_db', receiver = self._on_name_identity_change)239 #---------------------------------------------- 240 # def _on_lock(self, evt): 241 # print "should be locking client now by obscuring data" 242 # print "and popping up a modal dialog box asking for a" 243 # print "password to reactivate" 244 #----------------------------------------------246 pat = gmPerson.gmCurrentPatient() 247 if not pat.connected: 248 gmDispatcher.send('statustext', msg = _('Cannot activate Allergy Manager. No active patient.')) 249 return 250 dlg = gmAllergyWidgets.cAllergyManagerDlg(parent=self, id=-1) 251 dlg.ShowModal() 252 return253 #---------------------------------------------- 254 # def _on_show_BMI(self, evt): 255 # FIXME: update patient ID ? 256 # bmi = gmBMIWidgets.BMI_Frame(self) 257 # bmi.Centre(wx.BOTH) 258 # bmi.Show(1) 259 #---------------------------------------------- 260 # def _on_show_Preg_Calc(self, evt): 261 # FIXME: update patient ID ? 262 # pc = gmPregWidgets.cPregCalcFrame(self) 263 # pc.Centre(wx.BOTH) 264 # pc.Show(1) 265 #---------------------------------------------- 268 #---------------------------------------------- 272 #----------------------------------------------274 # needed because GUI stuff can't be called from a thread (and that's 275 # where we are coming from via backend listener -> dispatcher) 276 wx.CallAfter(self.__on_post_patient_selection, **kwargs)277 #---------------------------------------------- 282 #------------------------------------------------------- 285 #------------------------------------------------------- 288 #------------------------------------------------------- 289 # internal API 290 #-------------------------------------------------------292 293 if self.curr_pat['deceased'] is None: 294 295 if self.curr_pat.get_formatted_dob(format = '%m-%d') == pyDT.datetime.now(tz = gmDateTime.gmCurrentLocalTimezone).strftime('%m-%d'): 296 template = _('%s %s (%s today !)') 297 else: 298 template = u'%s %s (%s)' 299 300 # FIXME: if the age is below, say, 2 hours we should fire 301 # a timer here that updates the age in increments of 1 minute ... :-) 302 age = template % ( 303 gmPerson.map_gender2symbol[self.curr_pat['gender']], 304 self.curr_pat.get_formatted_dob(format = '%d %b %Y', encoding = gmI18N.get_encoding()), 305 self.curr_pat['medical_age'] 306 ) 307 308 # Easter Egg ;-) 309 if self.curr_pat['lastnames'] == u'Leibner': 310 if self.curr_pat['firstnames'] == u'Steffi': 311 if self.curr_pat['preferred'] == u'Wildfang': 312 age = u'%s %s' % (gmTools.u_black_heart, age) 313 314 else: 315 316 template = u'%s %s - %s (%s)' 317 age = template % ( 318 gmPerson.map_gender2symbol[self.curr_pat['gender']], 319 self.curr_pat.get_formatted_dob(format = '%d.%b %Y', encoding = gmI18N.get_encoding()), 320 self.curr_pat['deceased'].strftime('%d.%b %Y').decode(gmI18N.get_encoding()), 321 self.curr_pat['medical_age'] 322 ) 323 324 self.lbl_age.SetLabel(age)325 #-------------------------------------------------------327 328 emr = self.curr_pat.get_emr() 329 state = emr.allergy_state 330 331 # state in tooltip 332 if state['last_confirmed'] is None: 333 confirmed = _('never') 334 else: 335 confirmed = state['last_confirmed'].strftime('%x') 336 tt = (state.state_string + (90 * u' '))[:90] + u'\n' 337 tt += _('last confirmed %s\n') % confirmed 338 tt += gmTools.coalesce(state['comment'], u'', _('Comment (%s): %%s') % state['modified_by']) 339 tt += u'\n' 340 341 # allergies 342 tmp = [] 343 for allergy in emr.get_allergies(): 344 # in field: "true" allergies only, not intolerances 345 if allergy['type'] == 'allergy': 346 tmp.append(allergy['descriptor'][:10] + gmTools.u_ellipsis) 347 # in tooltip 348 if allergy['definite']: 349 certainty = _('definite') 350 else: 351 certainty = _('suspected') 352 reaction = gmTools.coalesce(allergy['reaction'], _('reaction not recorded')) 353 if len(reaction) > 50: 354 reaction = reaction[:50] + gmTools.u_ellipsis 355 tt += u'%s (%s, %s): %s\n' % ( 356 allergy['descriptor'], 357 allergy['l10n_type'], 358 certainty, 359 reaction 360 ) 361 362 if len(tmp) == 0: 363 tmp = state.state_symbol 364 else: 365 tmp = ','.join(tmp) 366 367 if state['last_confirmed'] is not None: 368 tmp += state['last_confirmed'].strftime(' (%x)') 369 370 self.txt_allergies.SetValue(tmp) 371 self.txt_allergies.SetToolTipString(tt)372 #------------------------------------------------------- 373 # remote layout handling 374 #-------------------------------------------------------376 """Insert a widget on the right-hand side of the bottom toolbar. 377 """ 378 self.szr_bottom_row.Add(widget, 0, wx.RIGHT, 0)379 #-------------------------------------------------------
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Feb 9 04:01:27 2010 | http://epydoc.sourceforge.net |