Gnumed.wxpython.patient.gmGP_Measurements

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

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

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