Gnumed.wxpython.patient.gmGP_PastHistory

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

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

      1  #!/usr/bin/python
      2  #############################################################################
      3  #
      4  # gmGP_PastHistory.py
      5  # ----------------------------------
      6  #
      7  # This panel will hold all the pasthistory details
      8  #
      9  # If you don't like it - change this code see @TODO!
     10  #
     11  # @author: Dr. Richard Terry
     12  # @copyright: author
     13  # @license: GPL v2 or later (details at http://www.gnu.org)
     14  # @dependencies: wxPython (>= version 2.3.1)
     15  # @change log:
     16  #           10.06.2002 rterry initial implementation, untested
     17  #           31.07.2002 rterry added to cvs
     18  #
     19  # @TODO:almost everything!
     20  #       contains dummy data only
     21  #
     22  ############################################################################
     23  try:
     24          import wxversion
     25          import wx
     26  except ImportError:
     27          from wxPython import wx
     28
     29  import gmGuiElement_HeadingCaptionPanel         #panel class to display top headings
     30  import gmGuiElement_DividerCaptionPanel         #panel class to display sub-headings or divider headings
     31  import gmGuiElement_AlertCaptionPanel           #panel to hold flashing alert messages
     32  import gmEditArea                                       #panel class holding editing prompts and text boxes
     33  import gmPlugin_Patient
     34
     35  import gmDispatcher
     36
     37  from gmPatientHolder import PatientHolder
     38  import gmPatientHolder
     39
     40  from gmListCtrlMapper import gmListCtrlMapper
     41
     42  import gmMultiColumnList
     43
     44  ID_SIGNIFICANTPASTHISTORYLIST = wxNewId()
     45  ID_ACTIVEPROBLEMLIST = wxNewId()
     46  gmSECTION_PASTHISTORY = 5
     47  #------------------------------------
     48  #Dummy data to simulate allergy items
     49  #------------------------------------
     50  activehistorydata = {
     51  1 : ("1982","Hypertension"),
     52  2 : ("1990","Ischaemic Heart Disease"),
     53  3 : ("1995","NIDDM"),
     54  4 : ("1998","Lymphoma"),
     55  5:("1998","Chemotherapy"),
     56  }
     57  significanthistorydata = {
     58  1 : ("1982","Hypertension"),
     59  2 : ("1990","Acute myocardial infarction"),
     60  3 : ("1994","CABG"),
     61  4 : ("1995","Cholecystectomy"),
     62  }
     63
     64  pasthistoryprompts = {
     65  1:("Condition"),
     66  2:("Notes"),
     67  3:(""),
     68  4:("Age Onset"),
     69  5:("Year Onset"),
     70  6:(""),
     71  7:("Progress Notes"),
     72  8:(""),
     73          }
     74
     75
     76
     77 -class PastHistoryPanel(wxPanel, PatientHolder):
     78 -        def __init__(self, parent,id):
     79                  wxPanel.__init__(self, parent, id,wxDefaultPosition,wxDefaultSize,wxRAISED_BORDER)
     80                  PatientHolder.__init__(self)
     81
     82                  #--------------------
     83                  #add the main heading
     84                  #--------------------
     85                  self.pasthistorypanelheading = gmGuiElement_HeadingCaptionPanel.HeadingCaptionPanel(self,-1, " PAST HISTORY  ")
     86                  #----------------------------------
     87                  #dummy panel above the editing area
     88                  #----------------------------------
     89                  self.dummypanel1 = wxPanel(self,-1,wxDefaultPosition,wxDefaultSize,0)
     90                  self.dummypanel1.SetBackgroundColour(wxColor(222,222,222))
     91                  #--------------------------------------------------
     92                  #now create the editarea specific for past history
     93                  #-------------------------------------------------
     94                  #self.editarea = gmEditArea.EditArea(self,-1,pasthistoryprompts,gmSECTION_PASTHISTORY)
     95                  self.editarea = gmEditArea.gmPastHistoryEditArea(self,-1)
     96                  self.dummypanel2 = wxPanel(self,-1,wxDefaultPosition,wxDefaultSize,0)
     97                  self.dummypanel2.SetBackgroundColour(wxColor(222,222,222))
     98                  #-----------------------------------------------
     99                  #add the divider headings below the editing area
    100                  #-----------------------------------------------
    101                  self.significant_history_heading = gmGuiElement_DividerCaptionPanel.DividerCaptionPanel(self,-1,_("Significant Past Problems"))
    102                  self.sizer_significant_history_heading = wxBoxSizer(wxHORIZONTAL)
    103                  self.sizer_significant_history_heading.Add(self.significant_history_heading,1, wxEXPAND)
    104                  #--------------------------------------------------------------------------------------
    105                  #add the list of significant problems
    106                  #
    107                  # c++ Default Constructor:
    108                  # wxListCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
    109                  # const wxSize& size = wxDefaultSize, long style = wxLC_ICON,
    110                  # const wxValidator& validator = wxDefaultValidator, const wxString& name = "listCtrl")
    111                  #
    112                  #--------------------------------------------------------------------------------------
    113                  #self.significant_problem_list = wxListCtrl(self, ID_SIGNIFICANTPASTHISTORYLIST,  wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_NO_HEADER|wxSUNKEN_BORDER)
    114                  self.significant_problem_list = gmMultiColumnList.MultiColumnList(self, -1)
    115                  self.significant_problem_list.SetFont(wxFont(12,wxSWISS, wxNORMAL, wxNORMAL, False, ''))
    116                  #self.active_problem_list = wxListCtrl(self, ID_ACTIVEPROBLEMLIST,  wxDefaultPosition, wxDefaultSize,wxLC_REPORT|wxLC_NO_HEADER|wxSUNKEN_BORDER)
    117                  self.active_problem_list = gmMultiColumnList.MultiColumnList(self, -1)
    118                  self.active_problem_list.SetFont(wxFont(12,wxSWISS, wxNORMAL, wxNORMAL, False, ''))
    119                  #---------------------------------------------------------
    120                  # add some dummy data to the significant past problem list
    121                  #---------------------------------------------------------
    122                  #self.significant_problem_list.InsertColumn(0, _("year onset"))
    123                  #self.significant_problem_list.InsertColumn(1, _("Condition"))
    124                  #self.significant_problem_list.InsertColumn(2, _("Notes"))
    125                  #-------------------------------------------------------------------------
    126                  #loop through the significanthistorydata array and add to the list control
    127                  #note the different syntax for the first coloum of each row
    128                  #i.e. here > self.significant_problem_list.InsertStringItem(x, data[0])!!
    129                  #--------------------------------------------------------------------------
    130                  #self.significant_mapper = gmListCtrlMapper(self.significant_problem_list)
    131                  #self.significant_mapper.SetData( significanthistorydata)
    132                  self.significant_problem_list.SetData( significanthistorydata)
    133                  #items = significanthistorydata.items()
    134                  #for x in range(len(items)):
    135                  #       key, data = items[x]
    136                  #       gmLog.gmDefLog.Log (gmLog.lData, items[x])
    137                  #       self.significant_problem_list.InsertStringItem(x, data[0])
    138                  #       self.significant_problem_list.SetStringItem(x, 1, data[1])
    139                  #       self.significant_problem_list.SetItemData(x, key)
    140                  #       self.significant_problem_list.SetColumnWidth(0, wxLIST_AUTOSIZE)
    141                  #self.significant_problem_list.SetColumnWidth(1, wxLIST_AUTOSIZE)
    142                  #------------------------------------------------
    143                  #add some dummy data to the active problems list
    144                  #------------------------------------------------
    145                  #self.active_problem_list.InsertColumn(0, _("Year Onset"))
    146                  #self.active_problem_list.InsertColumn(1, _("Condition"))
    147                  #self.active_problem_list.InsertColumn(2, _("Notes"))
    148                  #-------------------------------------------------------------
    149                  #loop through the activehistorydata array and add to the list control
    150                  #note the different syntax for the first coloum of each row
    151                  #i.e. here > self.significant_problem_list.InsertStringItem(x, data[0])!!
    152                  #-------------------------------------------------------------
    153                  #self.active_mapper = gmListCtrlMapper(self.active_problem_list)
    154                  #self.active_mapper.SetData( activehistorydata)
    155                  self.active_problem_list.SetData( activehistorydata)
    156
    157                  #items = activehistorydata.items()
    158                  #for x in range(len(items)):
    159                  #       key, data = items[x]
    160                  #       gmLog.gmDefLog.Log (gmLog.lData, items[x])
    161                  #       self.active_problem_list.InsertStringItem(x, data[0])
    162                  #       self.active_problem_list.SetStringItem(x, 1, data[1])
    163                  #       self.active_problem_list.SetItemData(x, key)
    164                  #self.active_problem_list.SetColumnWidth(0, wxLIST_AUTOSIZE)
    165                  #self.active_problem_list.SetColumnWidth(1, wxLIST_AUTOSIZE)
    166                  #--------------------------------------------------------------------------------------
    167                  #add a richtext control or a wxTextCtrl multiline to display the class text information
    168                  #e.g. would contain say information re the penicillins
    169                  #--------------------------------------------------------------------------------------
    170                  self.active_problems_heading = gmGuiElement_DividerCaptionPanel.DividerCaptionPanel(self,-1,_("Active Problems"))
    171                  #----------------------------------------
    172                  #add an alert caption panel to the bottom
    173                  #----------------------------------------
    174                  self.alertpanel = gmGuiElement_AlertCaptionPanel.AlertCaptionPanel(self,-1,"  Alerts  ")
    175                  #---------------------------------------------
    176                  #add all elements to the main background sizer
    177                  #---------------------------------------------
    178                  self.mainsizer = wxBoxSizer(wxVERTICAL)
    179                  self.mainsizer.Add(self.pasthistorypanelheading,0,wxEXPAND)
    180                  #self.mainsizer.Add(self.dummypanel1,0,wxEXPAND)
    181                  self.mainsizer.Add(self.editarea,6,wxEXPAND)
    182                  #self.mainsizer.Add(self.dummypanel2,0,wxEXPAND)
    183                  self.mainsizer.Add(self.significant_history_heading,0,wxEXPAND)
    184                  self.mainsizer.Add(self.significant_problem_list,4,wxEXPAND)
    185                  self.mainsizer.Add(self.active_problems_heading,0,wxEXPAND)
    186                  self.mainsizer.Add(self.active_problem_list,4,wxEXPAND)
    187                  self.mainsizer.Add(self.alertpanel,0,wxEXPAND)
    188                  self.SetSizer(self.mainsizer)
    189                  self.mainsizer.Fit
    190                  self.SetAutoLayout(True)
    191                  self.Show(True)
    192
    193                  gmDispatcher.connect(self._updateUI,  u'clin_history_updated')
    194
    195                  self.significant_problem_list.addItemListener( self._significantPastItemSelected)
    196
    197                  self.active_problem_list.addItemListener(self._activePastItemSelected)
    198
    199 -        def _significantPastItemSelected(self, event):
    200                  clinical = self.get_past_history()
    201                  self._historyItemSelected( event ,clinical.get_significant_past_history() )
    202
    203 -        def _activePastItemSelected( self, event):
    204                  clinical = self.get_past_history()
    205                  self._historyItemSelected( event ,clinical.get_active_history() )
    206
    207 -        def _historyItemSelected( self, event, list):
    208                  (selId, str) = event['item']
    209                  for (id, map) in list:
    210                          if id == selId:
    211                                  clinical = self.get_past_history()
    212                                  self.editarea.setInputFieldValues(map, id)
    213
    214
    215 -        def _updateUI(self):
    216                  clinical = self.get_past_history()
    217                  significant_past = clinical.get_significant_past_history()
    218                  active_hx = clinical.get_active_history()
    219                  self.active_problem_list.SetData(  self._get_list_map( active_hx) , fitClientSize = 1)
    220                  #self.significant_mapper.SetData( self._get_list_map( significant_past) )
    221                  self.significant_problem_list.SetData( self._get_list_map( significant_past), fitClientSize = 1 )
    222
    223
    224 -        def _get_list_map(self, clin_history_list):
    225                  newMap = {}
    226                  for (id, map) in clin_history_list:
    227                          newMap[id] =   self.get_past_history().short_format(map)
    228                  return newMap
    229
    230
    231
    232
    233
    234  #----------------------------------------------------------------------
    235 -class gmGP_PastHistory(gmPlugin_Patient.wxPatientPlugin):
    236          """Plugin to encapsulate the immunisation window."""
    237
    238          __icons = {
    239  """icon_hx_ship""": 'x\xdaU\x8e1\x0b\x830\x10\x85\xf7\xfe\x8a\x80\x82\x85@\xa8K\xb5\xdb\x11\xc1\
    240  \xb17\xb8\xbcU\xa4S\xa5\xe9\xff\x9fz\x97\xc44^$\xe4{w\xef\x9d\xd7\xfd\xdb_\
    241  \x96\xae\xbf\x1b\xf9\x1e\xa6\xef.\xeb\xd2\xc1l\xc6\xef\xeb\xf6\x8ed\x85\x9a\
    242  \x9b\xd40F&\xe5a\x1c\xa6\xcc\xcd\xd1\x9f\x13\x9b\xd4W%r\x10~\x86\xcf+\x02ks\
    243  \x1e\xe7)\x0f\xbb\xc4e\xb8U\xf6\xa3\x9f|\x0es\xce\x18H\x85T)1\x00\xcc\x8c \
    244  \x07\x95\x18\xc0\x80e\xab\x8d"\x12\xac\xd8\x1b\x96\xc7_\xb42\x198\xe7Vv&9\
    245  \xda\xab\xec\x00\x11\xceb\x8c\xc4\xc9\x1e\x87H\x02P-\x92\x1dm\xfaU\xb0@\x11I\
    246  E\xbd\x08\x95\x1d\xf9:\xeci\x83\x84\xe6my\xb2\xae\xb2\xe8\xa4e\xbb\xadO\x14\
    247  \xdd\x0f&\xf7\x8a\xe4'
    248  }
    249
    250 -        def name (self):
    251                  return 'Pasthistory Window'
    252
    253 -        def MenuInfo (self):
    254                  return ('view', '&Past History')
    255
    256 -        def GetIconData(self, anIconID = None):
    257                  if anIconID == None:
    258                          return self.__icons[_("""icon_hx_ship""")]
    259                  else:
    260                          if self.__icons.has_key(anIconID):
    261                                  return self.__icons[anIconID]
    262                          else:
    263                                  return self.__icons[_("""icon_hx_ship""")]
    264
    265 -        def GetWidget (self, parent):
    266                  return PastHistoryPanel (parent, -1)
    267  #----------------------------------------------------------------------
    268  if __name__ == "__main__":
    269          app = wxPyWidgetTester(size = (600, 600))
    270          app.SetWidget(PastHistoryPanel, -1)
    271          app.MainLoop()
    272