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

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

      1  #!/usr/bin/python
      2  #############################################################################
      3  #
      4  # gmGP_Measurements
      5  # ----------------------------------
      6  #
      7  # This panel will allow the input of measurements eg Blood pressure, weight
      8  # height, INR, etc, or display things '  measurable' grabbed from other sections
      9  # e.g Hb, wcc etc
     10  #
     11  # If you don't like it - change this code see @TODO!
     12  #
     13  # @author: Dr. Richard Terry
     14  # @copyright: author
     15  # @license: GPL v2 or later (details at http://www.gnu.org)
     16  # @dependencies: wxPython (>= version 2.3.1)
     17  # @change log:
     18  #           09.08.2002 rterry initial implementation, untested
     19  #
     20  # @TODO: just about everything. Gui for demonstration purposes only
     21  #
     22  #
     23  ############################################################################
     24
     25  try:
     26          import wxversion
     27          import wx
     28  except ImportError:
     29          from wxPython import wx
     30
     31  import gmGuiElement_HeadingCaptionPanel        #panel class to display top headings
     32  import gmGuiElement_DividerCaptionPanel        #panel class to display sub-headings or divider headings
     33  import gmGuiElement_AlertCaptionPanel          #panel to hold flashing alert messages
     34  import gmEditArea                              #panel class holding editing
     35  import gmPlugin_Patient
     36  import gmI18N
     37  from gmListCtrlMapper import gmListCtrlMapper
     38
     39  import gmPatientHolder
     40
     41  ID_MEASUREMENTVALUESLIST = wxNewId()
     42  gmSECTION_MEASUREMENTS = 10
     43  ID_MEASURMENTTYPESLIST = wxNewId()
     44
     45  #------------------------------------
     46  #Dummy data to simulate allergy items
     47  #------------------------------------
     48  measurementtypesdata = {
     49  1 : ("Blood Pressure",""),
     50  2 : ("Height",""),
     51  3 : ("Weight",""),
     52  4 : ("INR",""),
     53  5 : ("Etc, Etc....",""),
     54  }
     55
     56  values_BP_data = {
     57  1 : ("01/10/2001","140/80"),
     58  2 : ("19/01/2002","180/105"),
     59  3 : ("21/05/2002","156/84"),
     60  4 : ("08/08/2002","170/110"),
     61  }
     62
     63  values_INR_data = {
     64  1 : ("01/10/2001","1.1"),
     65  2 : ("19/01/2002","2.7"),
     66  3 : ("21/05/2002","3.5"),
     67  4 : ("08/08/2002","2.8"),
     68  }
     69  values_Weight_data = {
     70  1 : ("01/10/2001","79.8"),
     71  2 : ("19/01/2002","88.5"),
     72  3 : ("21/05/2002","87.4"),
     73  4 : ("08/08/2002","87.3"),
     74  }
     75  values_Height_data = {
     76  1 : ("01/10/2001","142"),
     77  2 : ("19/01/2002","148"),
     78  3 : ("21/05/2002","149"),
     79  4 : ("08/08/2002","152"),
     80  }
     81  measurement_prompts = {
     82  1:("Type"),
     83  2:("Value"),
     84  3:("Date"),
     85  4:("Comment"),
     86  5:("Progress Notes"),
     87  6:(""),
     88          }
     89
     90 -class MeasurementPanel (wxPanel, gmPatientHolder.PatientHolder):
     91 -        def __init__(self,parent, id):
     92                  wxPanel.__init__(self, parent, id, wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER)
     93                  gmPatientHolder.PatientHolder.__init__(self)
     94                  #--------------------
     95                  #add the main heading
     96                  #--------------------
     97                  self.pasthistorypanelheading = gmGuiElement_HeadingCaptionPanel.HeadingCaptionPanel(self,-1," MEASUREMENTS ")
     98                  #----------------------------------
     99                  #dummy panel above the editing area
    100                  #----------------------------------
    101                  self.dummypanel1 = wxPanel(self,-1,wxDefaultPosition,wxDefaultSize,0)
    102                  self.dummypanel1.SetBackgroundColour(wxColor(222,222,222))
    103                  ##--------------------------------------------------
    104                  #now create the editarea specific for measurements
    105                  #--------------------------------------------------
    106                  #self.editarea = gmEditArea.EditArea(self,-1,measurement_prompts,gmSECTION_MEASUREMENTS)
    107                  self.editarea = gmEditArea.gmMeasurementEditArea(self, -1)
    108                  #self.dummypanel2 = wxPanel(self,-1,wxDefaultPosition,wxDefaultSize,0)
    109                  #self.dummypanel2.SetBackgroundColour(wxColor(222,222,222))
    110                  #-----------------------------------------------
    111                  #add the divider headings below the editing area
    112                  #-----------------------------------------------
    113                  self.measurementtypes_heading = gmGuiElement_DividerCaptionPanel.DividerCaptionPanel(self,-1,"Type")
    114                  self.measurements_values_heading = gmGuiElement_DividerCaptionPanel.DividerCaptionPanel(self,-1,"Values")
    115                  self.sizer_measurements_types_heading = wxBoxSizer(wxHORIZONTAL)
    116                  self.sizer_measurements_types_heading.Add(self.measurementtypes_heading,1, wxEXPAND)
    117                  self.sizer_measurements_types_heading.Add(self.measurements_values_heading,1, wxEXPAND)
    118
    119                  #--------------------------------------------------------------------------------------
    120                  #add the list of significant problems
    121                  #
    122                  # c++ Default Constructor:
    123                  # wxListCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
    124                  # const wxSize& size = wxDefaultSize, long style = wxLC_ICON,
    125                  # const wxValidator& validator = wxDefaultValidator, const wxString& name = "listCtrl")
    126                  #
    127                  #--------------------------------------------------------------------------------------
    128                  self.measurement_types_list = wxListCtrl(self, ID_MEASURMENTTYPESLIST,  wxDefaultPosition, wxDefaultSize,wxLC_REPORT|wxLC_NO_HEADER|wxSUNKEN_BORDER)
    129                  self.measurement_types_list.SetFont(wxFont(10,wxSWISS, wxNORMAL, wxNORMAL, False, ''))
    130                  self.measurements_values_list = wxListCtrl(self, ID_MEASUREMENTVALUESLIST,  wxDefaultPosition, wxDefaultSize,wxLC_REPORT|wxLC_NO_HEADER|wxSUNKEN_BORDER)
    131                  self.measurements_values_list.SetFont(wxFont(10,wxSWISS, wxNORMAL, wxNORMAL, False, ''))
    132                  self.sizer_measurementtypes_values = wxBoxSizer(wxHORIZONTAL)
    133                  self.sizer_measurementtypes_values.Add(self.measurement_types_list,4,wxEXPAND)
    134                  self.sizer_measurementtypes_values.Add(self.measurements_values_list,6, wxEXPAND)
    135                  #---------------------------------------------
    136                  # add some dummy data to the measurements list
    137                  #---------------------------------------------
    138                  self.measurement_types_list.InsertColumn(0, _("Type"))
    139                  self.measurement_types_list.InsertColumn(1, "")
    140                  #-------------------------------------------------------------
    141                  #loop through the measurementtypesdata array and add to the list control
    142                  #note the different syntax for the first coloum of each row
    143                  #i.e. here > self.measurement_types_list.InsertStringItem(x, data[0])!!
    144                  #-------------------------------------------------------------
    145                  m = gmListCtrlMapper(self.measurement_types_list)
    146                  m.SetData(measurementtypesdata)
    147                  self.typesMapper = m
    148                  #items = measurementtypesdata.items()
    149                  #for x in range(len(items)):
    150                  #       key, data = items[x]
    151                  #       self.measurement_types_list.InsertStringItem(x, data[0])
    152                  #       self.measurement_types_list.SetStringItem(x, 1, data[1])
    153                  #       self.measurement_types_list.SetItemData(x, key)
    154                  self.measurement_types_list.SetColumnWidth(0, wxLIST_AUTOSIZE)
    155                  self.measurement_types_list.SetColumnWidth(1, wxLIST_AUTOSIZE)
    156                  #-----------------------------------------
    157                  # add some dummy data to the values list
    158                  #-----------------------------------------
    159                  self.measurements_values_list.InsertColumn(0, "Date")
    160                  self.measurements_values_list.InsertColumn(1, "Value")
    161                  #-------------------------------------------------------------
    162                  #loop through the measurementtypesdata array and add to the list control
    163                  #note the different syntax for the first coloum of each row
    164                  #i.e. here > self.measurement_types_list.InsertStringItem(x, data[0])!!
    165                  #-------------------------------------------------------------
    166                  m = gmListCtrlMapper(self.measurements_values_list)
    167                  m.SetData(values_BP_data)
    168                  self.valueMapper = m
    169                  #items = values_BP_data.items()
    170                  #for x in range(len(items)):
    171                  #       key, data = items[x]
    172                  #       self.measurements_values_list.InsertStringItem(x, data[0])
    173                  #       self.measurements_values_list.SetStringItem(x, 1, data[1])
    174                  #       self.measurements_values_list.SetItemData(x, key)
    175                  self.measurements_values_list.SetColumnWidth(0, wxLIST_AUTOSIZE)
    176                  self.measurements_values_list.SetColumnWidth(1, wxLIST_AUTOSIZE)
    177                  #----------------------------------------
    178                  #add an alert caption panel to the bottom
    179                  #----------------------------------------
    180                  self.alertpanel = gmGuiElement_AlertCaptionPanel.AlertCaptionPanel(self,-1,"  Alerts  ")
    181                  #---------------------------------------------
    182                  #add all elements to the main background sizer
    183                  #---------------------------------------------
    184                  self.mainsizer = wxBoxSizer(wxVERTICAL)
    185                  self.mainsizer.Add(self.pasthistorypanelheading,0,wxEXPAND)
    186                  self.mainsizer.Add(self.dummypanel1,0,wxEXPAND)
    187                  self.mainsizer.Add(self.editarea,1,wxEXPAND)
    188                  self.mainsizer.Add(self.sizer_measurements_types_heading,0,wxEXPAND)
    189                  self.mainsizer.Add(self.sizer_measurementtypes_values,2,wxEXPAND)
    190                  self.mainsizer.Add(self.alertpanel,0,wxEXPAND)
    191                  self.SetSizer(self.mainsizer)
    192                  self.mainsizer.Fit
    193                  self.SetAutoLayout(True)
    194                  self.Show(True)
    195
    196
    197  #--------------------------------------------------------------------
    198 -class gmGP_Measurements (gmPlugin_Patient.wxPatientPlugin):
    199          """
    200          Plugin to encapsulate the prescriptions window
    201          """
    202
    203          __icons = {
    204  """icon_Set_Square""": 'x\xda\xd3\xc8)0\xe4\nV74S\x00"S\x05Cu\xae\xc4`\xf5|\x85d\x05\xa7\x9c\xc4\
    205  \xe4l0O\x0f\xc8S6\xb70w60\x00\xf3\xfda|s\x0b0?\x02\xc4w\xb3p\x83\xc9+\x00\
    206  \xf9~\xf9y\xa9P\x8e\x82\x82^D\x84\x9e\x02\x14 \x0b\xe6c\x11\xd4\xcb\'\xac2\
    207  \x1f\r@\\\x19\x81\n\xa1\x82\xa8\x00\xb7\xa0?\x10\xe4\xeb\xe9\xe5\xfbC\x015\
    208  \xdcI}\x95z\x00\xc7\xd5_\x1b'
    209  }
    210
    211 -        def name (self):
    212                  return 'Measurements'
    213
    214 -        def MenuInfo (self):
    215                  return ('view', '&Measurements')
    216
    217 -        def GetIconData(self, anIconID = None):
    218                  if anIconID == None:
    219                          return self.__icons[_("""icon_Set_Square""")]
    220                  else:
    221                          if self.__icons.has_key(anIconID):
    222                                  return self.__icons[anIconID]
    223                          else:
    224                                  return self.__icons[_("""icon_Set_Square""")]
    225
    226 -        def GetWidget (self, parent):
    227                  return  MeasurementPanel (parent, -1)
    228
    229
    230  if __name__ == "__main__":
    231          app = wxPyWidgetTester(size = (600, 600))
    232          app.SetWidget(MeasurementPanel, -1)
    233          app.MainLoop()
    234