Gnumed.wxpython.patient.gmGP_FamilyHistory

Package Gnumed :: Package wxpython :: Package patient :: Module gmGP_FamilyHistory |
[frames] | no frames]

# Source Code for Module Gnumed.wxpython.patient.gmGP_FamilyHistory

      1  # -*- coding: utf-8 -*-
      2  #!/usr/bin/python
      3  #############################################################################
      4  #
      5  # gmGP_FamilyHistory.py
      6  # ----------------------------------
      7  #
      8  # This panel will hold all the family history details
      9  #
     10  # If you don't like it - change this code see @TODO!
     11  #
     12  # @author: Dr. Richard Terry
     13  # @copyright: author
     14  # @license: GPL v2 or later (details at http://www.gnu.org)
     15  # @dependencies: wxPython (>= version 2.3.1)
     16
     17  # @TODO:
     18  #       almost everything
     19  #
     20  ############################################################################
     21  __author__  = "R.Terry <rterry@gnumed.net>, H.Herb <hherb@gnumed.net>, S.Tan"
     22
     23
     24  import wx
     25
     26  import gmEditArea, gmPlugin_Patient
     27  import gmGuiElement_HeadingCaptionPanel         #panel class to display top headings
     28  import gmGuiElement_DividerCaptionPanel         #panel class to display sub-headings or divider headings
     29  import gmGuiElement_AlertCaptionPanel           #panel to hold flashing alert messages
     30  from gmPatientHolder import PatientHolder
     31
     32
     33  ID_MEMBERCONDITIONSLIST = wxNewId()
     34  ID_FAMILYMEMBERSLIST = wxNewId()
     35  ID_IMMUNISATIONS = wxNewId()
     36  ID_ALL_MENU  = wxNewId()
     37  gmSECTION_FAMILYHISTORY = 4
     38  #------------------------------------
     39  #Dummy data to simulate allergy items
     40  #------------------------------------
     41  familymemberdata = {
     42  1 : ("Mother",""),
     43  2 : ("General Family History",""),
     44  3 : ("Freda -Aunt",""),
     45  }
     46  membersconditionsdata = {
     47  1 : ("Acute myocardial infarction aged 73, caused death 73",""),
     48  2 : ("Hypertension age onset 40",""),
     49  }
     50
     51  #----------------------------------------------------------------------
     52 -class FamilyHistoryPanel(wxPanel, PatientHolder):
     53
     54 -        def __init__(self, parent,id):
     55                  wxPanel.__init__(self, parent, id,wxDefaultPosition,wxDefaultSize,wxRAISED_BORDER)
     56                  PatientHolder.__init__(self)
     57                  # main heading
     58                  self.FamilyHistoryPanelheading = gmGuiElement_HeadingCaptionPanel.HeadingCaptionPanel(self,-1,"  FAMILY AND SOCIAL HISTORY  ")
     59                  # editarea
     60                  self.editarea = gmEditArea.gmFamilyHxEditArea(self, -1)
     61                  #self.editarea = gmFamilyHxEditArea(self, -1)
     62                  #-----------------------------------------------
     63                  #add the divider headings below the editing area
     64                  #-----------------------------------------------
     65                  self.family_members_heading = gmGuiElement_DividerCaptionPanel.DividerCaptionPanel(self,-1,"Family Members")
     66                  self.members_disease_conditions = gmGuiElement_DividerCaptionPanel.DividerCaptionPanel(self,-1,"Condition")
     67                  self.sizer_divider_members_condition = wxBoxSizer(wxHORIZONTAL)
     68                  self.sizer_divider_members_condition.Add(self.family_members_heading,1, wxEXPAND)
     69                  self.sizer_divider_members_condition.Add( self.members_disease_conditions,1, wxEXPAND)
     70                  #--------------------------------------------------------------------------------------
     71                  #add the list to contain the family members
     72                  #
     73                  # c++ Default Constructor:
     74                  # wxListCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
     75                  # const wxSize& size = wxDefaultSize, long style = wxLC_ICON,
     76                  # const wxValidator& validator = wxDefaultValidator, const wxString& name = "listCtrl")
     77                  #
     78                  #--------------------------------------------------------------------------------------
     79                  self.family_members_list = wxListCtrl(self, ID_FAMILYMEMBERSLIST,  wxDefaultPosition, wxDefaultSize,wxLC_REPORT|wxLC_NO_HEADER|wxSUNKEN_BORDER)
     80                  self.family_members_list.SetFont(wxFont(12,wxSWISS, wxNORMAL, wxNORMAL, False, ''))
     81                  self.member_conditions_list = wxListCtrl(self,ID_MEMBERCONDITIONSLIST,  wxDefaultPosition, wxDefaultSize,wxLC_REPORT|wxLC_NO_HEADER|wxSUNKEN_BORDER)
     82                  self.member_conditions_list.SetFont(wxFont(12,wxSWISS, wxNORMAL, wxNORMAL, False, ''))
     83                  self.sizer_members_conditions = wxBoxSizer(wxHORIZONTAL)
     84                  self.sizer_members_conditions.Add(self.family_members_list,4,wxEXPAND)
     85                  self.sizer_members_conditions.Add(self.member_conditions_list,6, wxEXPAND)
     86                  #----------------------------------------
     87                  # add some dummy data to the Members list
     88                  #-----------------------------------------
     89                  self.family_members_list.InsertColumn(0, "Member")
     90                  self.family_members_list.InsertColumn(1, "null")
     91                  #-------------------------------------------------------------
     92                  #loop through the familymemberdata array and add to the list control
     93                  #note the different syntax for the first coloum of each row
     94                  #i.e. here > self.family_members_list.InsertItem(x, data[0])!!
     95                  #-------------------------------------------------------------
     96                  items = familymemberdata.items()
     97                  for x in range(len(items)):
     98                          key, data = items[x]
     99                          #gmLog.gmDefLog.Log (gmLog.lData, items[x])
    100                          self.family_members_list.InsertItem(x, data[0])
    101                          self.family_members_list.SetItem(x, 1, data[1])
    102                          self.family_members_list.SetItemData(x, key)
    103                  self.family_members_list.SetColumnWidth(0, wxLIST_AUTOSIZE)
    104                  #-------------------------------------------
    105                  # add some dummy data to the conditions list
    106                  #-------------------------------------------
    107                  self.member_conditions_list.InsertColumn(0, "Condition")
    108                  self.member_conditions_list.InsertColumn(1, "null")
    109                  #-------------------------------------------------------------
    110                  #loop through the familymemberdata array and add to the list control
    111                  #note the different syntax for the first coloum of each row
    112                  #i.e. here > self.family_members_list.InsertItem(x, data[0])!!
    113                  #-------------------------------------------------------------
    114                  items = membersconditionsdata.items()
    115                  for x in range(len(items)):
    116                          key, data = items[x]
    117                          #gmLog.gmDefLog.Log (gmLog.lData, items[x])
    118                          self.member_conditions_list.InsertItem(x, data[0])
    119                          self.member_conditions_list.SetItem(x, 1, data[1])
    120                          self.member_conditions_list.SetItemData(x, key)
    121
    122                  self.member_conditions_list.SetColumnWidth(0, wxLIST_AUTOSIZE)
    123                  self.member_conditions_list.SetColumnWidth(1, wxLIST_AUTOSIZE)
    124                  #------------------------------------------------------------------------------------------
    125                  #add a richtext control or a wxTextCtrl multiline to allow user to enter the social history
    126                  #------------------------------------------------------------------------------------------
    127                  self.social_history_subheading = gmGuiElement_DividerCaptionPanel.DividerCaptionPanel(self,-1,"Social History")
    128                  self.txt_social_history = wxTextCtrl(self, 30,
    129                                          "Born in QLD, son of an itinerant drover. Mother worked as a bush nurse. "
    130                                          "Two brothers, Fred and Peter. Left school aged 15yrs, apprentice fitter "
    131                                          "then worked in industry for 10ys. At 22yrs age married Joan, two children"
    132                                          "Peter b1980 and Rachaelb1981. Retired in 1990 due to receiving a fortune.",
    133                                          wxDefaultPosition,wxDefaultSize, style=wxTE_MULTILINE|wxNO_3D|wxSIMPLE_BORDER)
    134                  self.txt_social_history.SetInsertionPoint(0)
    135                  self.txt_social_history.SetFont(wxFont(12,wxSWISS, wxNORMAL, wxNORMAL, False, ''))
    136                  #----------------------------------------
    137                  #add an alert caption panel to the bottom
    138                  #----------------------------------------
    139                  self.alertpanel = gmGuiElement_AlertCaptionPanel.AlertCaptionPanel(self,-1,"  Alerts  ")
    140                  #---------------------------------------------
    141                  #add all elements to the main background sizer
    142                  #---------------------------------------------
    143                  self.mainsizer = wxBoxSizer(wxVERTICAL)
    144                  self.mainsizer.Add(self.FamilyHistoryPanelheading,0,wxEXPAND)
    145  #               self.mainsizer.Add(self.dummypanel1,1,wxEXPAND)
    146                  self.mainsizer.Add(self.editarea,6,wxEXPAND)
    147                  self.mainsizer.Add(self.sizer_divider_members_condition,0,wxEXPAND)
    148                  self.mainsizer.Add(self.sizer_members_conditions,4,wxEXPAND)
    149                  self.mainsizer.Add(self.social_history_subheading,0,wxEXPAND)
    150                  self.mainsizer.Add(self.txt_social_history,4,wxEXPAND)
    151                  self.mainsizer.Add(self.alertpanel,0,wxEXPAND)
    152                  self.SetSizer(self.mainsizer)
    153                  self.mainsizer.Fit (self)
    154                  self.SetAutoLayout(True)
    155                  EVT_SIZE (self, self.OnSize)
    156
    157 -        def OnSize (self, event):
    158                  w, h = event.GetSize ()
    159                  self.mainsizer.SetDimension (0, 0, w, h)
    160  #----------------------------------------------------------------------
    161 -class gmGP_FamilyHistory(gmPlugin_Patient.wxPatientPlugin):
    162          """Plugin to encapsulate the family history window."""
    163
    164          __icons = {
    165  """icon_two_people""": 'x\xda\x9d\x90\xb1\x0e\x83 \x10\x86w\x9f\xe2\x12@\x9b\x98\x10X\xaa#\x81\xc4\
    166  \xb1\x0c.\xae\xc6t\xaa)}\xff\xa9w\x07\xd8\xb4n\x05\xf5\xf2}w?$^\xf6\x97m\xe6\
    167  \xce^\x81\x1e\x0b\xb6k\xd6\xb9\x93\xb0\x81\xdf\xd7\xed\xc1\xd4"\x89a\x1c\x82\
    168  1\xcc\x82x\x1a\x8d\x99F\xe6\x85\xd8\xe0\n\xb9\x1f+\x97\xbe\xcey2\xcc)\xe7C\
    169  \xed\x03\xf2-=\xef\x0c.\x87\xa7P\x9a\xaa^V\xc2=\xb1\x1f}\xf05\xfc\xbd\x8a\
    170  \xd4Z3\xe6\x9a\xa5^p\x93[\x12\xd52\x99R\xe2A\xac\x1f\t\xa9\x1c\x97\x8e3c\x8c\
    171  =\xbe\xe0\x9c\x13\xc2\xb9C\xba\x08(A:\tU\x82\x94\x92%H\xa8R\xb0\x14\xb8\x95R\
    172  \xf8-\x17I\x1a\x01rh\x7f$\'N\xb2\xc5}\xc8\x0c\x7f\xcb\xd3\xaf\xd3o\x85>c\\'
    173  }
    174
    175 -        def name (self):
    176                  return 'Family History Window'
    177
    178          #FIXME - put ampersand in correct position
    179 -        def MenuInfo (self):
    180                  return ('view', '&Family History')
    181
    182 -        def GetIconData(self, anIconID = None):
    183                  if anIconID == None:
    184                          return self.__icons[_("""icon_two_people""")]
    185                  else:
    186                          if anIconID in self.__icons:
    187                                  return self.__icons[anIconID]
    188                          else:
    189                                  return self.__icons[_("""icon_two_people""")]
    190
    191 -        def GetWidget (self, parent):
    192                  return FamilyHistoryPanel (parent, -1)
    193  #======================================================================
    194  # main
    195  #----------------------------------------------------------------------
    196  if __name__ == "__main__":
    197          app = wxPyWidgetTester(size = (600, 600))
    198          app.SetWidget(FamilyHistoryPanel, -1)
    199          app.MainLoop()
    200
    201  #======================================================================#
    202