Gnumed.wxpython.patient.gmGP_Prescriptions

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

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

      1  #!/usr/bin/python
      2  #############################################################################
      3  #
      4  # gmPrescription:
      5  # ----------------------------------
      6  #
      7  # This panel will hold all the prescrition, and allow entry
      8  # of those details via the editing area (gmEditArea.py - currently a
      9  # vapour module
     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  #           10.06.2002 rterry initial implementation, untested
     19  #
     20  # @TODO:
     21  #       - write cmEditArea.py
     22  #       - decide on type of list and text control to use
     23  #       - someone smart to fix the code (simplify for same result)
     24  #
     25  ############################################################################
     26  try:
     27          import wxversion
     28          import wx
     29  except ImportError:
     30          from wxPython import wx
     31
     32  import gmGuiElement_HeadingCaptionPanel        #panel class to display top headings
     33  import gmGuiElement_DividerCaptionPanel        #panel class to display sub-headings or divider headings
     34  import gmGuiElement_AlertCaptionPanel          #panel to hold flashing alert messages
     35  import gmEditArea                              #panel class holding editing
     36  import gmPlugin_Patient
     37  from gmPatientHolder import PatientHolder
     38
     39
     40
     41  ID_SCRIPTICON = wxNewId ()
     42  ID_SCRIPTLIST = wxNewId()
     43  ID_SCRIPTMENU = wxNewId ()
     44  ID_POPUP1 = wxNewId()
     45
     46  gmSECTION_SCRIPT = 8
     47  # script popup
     48  ID_AuthInd = wxNewId()
     49  ID_Interactions = wxNewId()
     50  ID_PregInfo = wxNewId()
     51  ID_Restrictions = wxNewId()
     52  ID_EditItem = wxNewId()
     53  ID_DelItem = wxNewId()
     54  ID_DelAll = wxNewId()
     55  ID_MakeItemReg24 = wxNewId()
     56  ID_DrugInfoBrief = wxNewId()
     57  ID_DrugInfoFull = wxNewId()
     58  ID_PrintItem = wxNewId()
     59  ID_PrintAll = wxNewId()
     60  ID_ReprintItem = wxNewId()
     61  ID_ReprintAll = wxNewId()
     62  ID_JustSaveItem = wxNewId()
     63  ID_JustSaveAll = wxNewId()
     64  ID_ChangeFont = wxNewId()
     65  ID_SaveListLayout = wxNewId()
     66  ID_Help = wxNewId()
     67  ID_Exit = wxNewId()
     68  #------------------------------------
     69  #Dummy data to simulate script items
     70  #------------------------------------
     71  scriptdata = {
     72  1 : ("Fluvax","0.5ml", "to be injected by the doctor","flu immunisation"),
     73  2 : ("Tenormin","50mg","1 daily", "hypertension"),
     74  3 : ( "Ceclor CD","375mg","1 twice daily","sinusitis"),
     75  }
     76
     77  scriptprompts = {
     78  1:("Prescribe For"),
     79  2:("Class"),
     80  3:("Generic"),
     81  4:("Brand"),
     82  5:("Strength"),
     83  6:("Directions"),
     84  7:("For"),
     85  8:("Progress Notes"),
     86  9:(""),
     87   }
     88
     89
     90 -class PrescriptionPanel (wxPanel, PatientHolder):
     91 -        def __init__(self,parent, id):
     92                  #wxPanel.__init__(self,parent, id)
     93                  wxPanel.__init__(self, parent, id, wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER)
     94                  PatientHolder.__init__(self)
     95                  #--------------------
     96                  #add the main heading
     97                  #--------------------
     98                  self.scriptpanelheading = gmGuiElement_HeadingCaptionPanel.HeadingCaptionPanel(self,-1,"  SCRIPTS  ")
     99                  #--------------------------------------------
    100                  #sizer to hold either just date, or the
    101                  #authority details, aia, authority number
    102                  #--------------------------------------------
    103                  self.sizer_authority  = wxGridSizer(1,0,0,0)
    104                  self.sizer1 = wxBoxSizer(wxHORIZONTAL)
    105                  self.txt_scriptDate = wxTextCtrl(self,-1,"12/06/2002",wxDefaultPosition,wxDefaultSize)
    106                  self.spacer = wxWindow(self,-1, wxDefaultPosition,wxDefaultSize,0)
    107                  self.spacer.SetBackgroundColour(wxColor(222,222,222))
    108                  #self.lbl_authorityindication = gmEditArea.EditAreaPromptLabel(self,-1,"Indication")
    109                  #self.lbl_authoritynumber = gmEditArea.EditAreaPromptLabel(self,-1,"Auth No.")
    110                  #self.txt_authorityindication =  wxTextCtrl(self,-1,"",wxDefaultPosition,wxDefaultSize)
    111                  #self.txt_authorityindication.Hide()
    112                  #self.sizer_authority.Add(self.spacer,1,wxEXPAND)
    113                  self.sizer1.Add(1,0,20)
    114                  self.sizer1.Add(self.txt_scriptDate,3,wxEXPAND|wxALL,3)
    115                  #self.sizer1.Add(1,0,1)
    116                  self.sizer_authority.Add(self.sizer1,0,wxEXPAND)
    117                  #-------------------------------------------------
    118                  #now create the editarea specific for prescribing
    119                  #-------------------------------------------------
    120                  #self.editarea = gmEditArea.EditArea(self,-1,scriptprompts,gmSECTION_SCRIPT)
    121                  self.editarea = gmEditArea.gmPrescriptionEditArea(self,-1)
    122                  #---------------------------------------------------------------------
    123                  #add the divider headings below the editing area for drug interactions
    124                  #and add text control to show mini-drug interactions
    125                  #---------------------------------------------------------------------
    126                  self.interactiontext_subheading = gmGuiElement_DividerCaptionPanel.DividerCaptionPanel(self,-1,_("Drug Interactions"))
    127                  self.sizer_divider_interaction_text = wxBoxSizer(wxHORIZONTAL)
    128                  self.sizer_divider_interaction_text.Add(self.interactiontext_subheading,1, wxEXPAND)
    129                  self.interactiontxt = wxTextCtrl(self,-1,
    130                          "Mini-Drug interaction text goes here (click this for full description)\n \n"
    131                          "Also, try clicking on the list below with the right mouse button to see a pop up menu",
    132                          style=wxTE_MULTILINE)
    133                  self.interactiontxt.SetFont(wxFont(10,wxSWISS,wxNORMAL,wxNORMAL,False,''))
    134                  #------------------------------------------------------------------------------------
    135                  #add the divider headings below the drug interactions as heading for items prescribed
    136                  #------------------------------------------------------------------------------------
    137                  self.itemsprescribedheading = gmGuiElement_DividerCaptionPanel.DividerCaptionPanel(self,-1,_("Items prescribed this consultation"))
    138                  self.sizer_itemsprescribed = wxBoxSizer(wxHORIZONTAL)
    139                  self.sizer_itemsprescribed.Add(self.itemsprescribedheading,1, wxEXPAND)
    140                  #--------------------------------------------------------------------------------------
    141                  #add the list to contain the drugs person is allergic to
    142                  #
    143                  # c++ Default Constructor:
    144                  # wxListCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
    145                  # const wxSize& size = wxDefaultSize, long style = wxLC_ICON,
    146                  # const wxValidator& validator = wxDefaultValidator, const wxString& name = "listCtrl")
    147                  #
    148                  #--------------------------------------------------------------------------------------
    149                  self.list_script = wxListCtrl(self, -1,  wxDefaultPosition, wxDefaultSize,wxLC_REPORT|wxLC_NO_HEADER|wxSUNKEN_BORDER)
    150                  self.list_script.SetFont(wxFont(10,wxSWISS, wxNORMAL, wxNORMAL, False, ''))
    151                  EVT_RIGHT_UP(self.list_script, self.OnRightClickUp)
    152                  #----------------------------------------
    153                  # add some dummy data to the allergy list
    154                  self.list_script.InsertColumn(0, _("Drug"))
    155                  self.list_script.InsertColumn(1, _("Strength"))
    156                  self.list_script.InsertColumn(2, _("Directions"))
    157                  self.list_script.InsertColumn(3, _("For"))
    158                  #-------------------------------------------------------------
    159                  #loop through the scriptdata array and add to the list control
    160                  #note the different syntax for the first coloum of each row
    161                  #i.e. here > self.list_script.InsertStringItem(x, data[0])!!
    162                  #-------------------------------------------------------------
    163                  items = scriptdata.items()
    164                  for x in range(len(items)):
    165                          key, data = items[x]
    166                          self.list_script.InsertStringItem(x, data[0])
    167                          self.list_script.SetStringItem(x, 1, data[1])
    168                          self.list_script.SetStringItem(x, 2, data[2])
    169                          self.list_script.SetStringItem(x, 3, data[3])
    170                          self.list_script.SetItemData(x, key)
    171
    172                  self.list_script.SetColumnWidth(0, wxLIST_AUTOSIZE)
    173                  self.list_script.SetColumnWidth(1, wxLIST_AUTOSIZE)
    174                  self.list_script.SetColumnWidth(2, wxLIST_AUTOSIZE)
    175                  self.list_script.SetColumnWidth(3, wxLIST_AUTOSIZE)
    176                  #----------------------------------------
    177                  #add an alert caption panel to the bottom
    178                  #----------------------------------------
    179                  self.alertpanel = gmGuiElement_AlertCaptionPanel.AlertCaptionPanel(self,-1,"  Alerts  ")
    180                  #---------------------------------------------
    181                  #add all elements to the main background sizer
    182                  #---------------------------------------------
    183                  self.mainsizer = wxBoxSizer(wxVERTICAL)
    184                  self.mainsizer.Add(self.scriptpanelheading,0,wxEXPAND)
    185                  self.mainsizer.Add(self.sizer_authority,1,wxEXPAND)
    186                  self.mainsizer.Add(self.editarea,15,wxEXPAND)
    187                  self.mainsizer.Add(self.sizer_divider_interaction_text,0,wxEXPAND)
    188                  self.mainsizer.Add(self.interactiontxt,4,wxEXPAND)
    189                  self.mainsizer.Add(self.itemsprescribedheading,0,wxEXPAND)
    190                  self.mainsizer.Add(self.list_script,4,wxEXPAND)
    191                  self.mainsizer.Add(self.alertpanel,0,wxEXPAND)
    192                  self.SetSizer(self.mainsizer)
    193                  self.SetAutoLayout(True)
    194                  self.Show(True)
    195
    196 -        def OnRightClickUp(self, event):
    197                  """A right mouse click triggers a popup menu for the list script"""
    198
    199                  # create a temporary local popup menu
    200                  aMenu = wxMenu()
    201                  # Auth Ind: Australia: some drugs will only be subsidised given certain indications and explicit approval by authorities
    202                  # like German "Positivliste"
    203                  aMenu.Append(ID_AuthInd, _("Authority Indications"))
    204                  aMenu.Append(ID_Interactions, _("Interactions"))
    205                  aMenu.Append(ID_PregInfo, _("Pregnancy Information"))
    206                  aMenu.Append(ID_Restrictions, _("Restricted Use Information"))
    207                  aMenu.AppendSeparator()
    208                  aMenu.Append(ID_EditItem, _("Edit Item"))
    209                  aMenu.Append(ID_DelItem, _("Delete Item"))
    210                  aMenu.Append(ID_DelAll, _("Delete all Items"))
    211                  # Reg 24: Australia: dispense all repeats at once
    212                  aMenu.Append(ID_MakeItemReg24, _("Make Item Reg 24"))
    213                  aMenu.AppendSeparator()
    214                  aMenu.Append(ID_DrugInfoBrief, _("Brief Product Information"))
    215                  aMenu.Append(ID_DrugInfoFull, _("Full Product Information"))
    216                  aMenu.AppendSeparator()
    217                  aMenu.Append(ID_PrintItem, _("Print Single Item"))
    218                  aMenu.Append(ID_PrintAll, _("Print All Items"))
    219                  aMenu.AppendSeparator()
    220                  aMenu.Append(ID_ReprintItem, _("Reprint Item"))
    221                  aMenu.Append(ID_ReprintAll, _("Reprint All Items"))
    222                  aMenu.AppendSeparator()
    223                  aMenu.Append(ID_JustSaveItem, _("Save Item no print"))
    224                  aMenu.Append(ID_JustSaveAll, _("Save All Items no print"))
    225                  aMenu.AppendSeparator()
    226                  aMenu.Append(ID_ChangeFont, _("Change Font"))
    227                  aMenu.Append(ID_SaveListLayout, _("Save list layout"))
    228                  aMenu.AppendSeparator()
    229                  aMenu.Append(ID_Help, _("Help"))
    230                  aMenu.AppendSeparator()
    231                  aMenu.Append(ID_Exit, _("Exit"))
    232
    233                  ##connect the events to event handler functions
    234                  EVT_MENU(self, ID_POPUP1, self.OnExitMenu)
    235                  EVT_MENU(self, ID_PregInfo, gmLog.gmDefLog.Log(gmLog.lErr, "This should display Pregnancy Information !"))
    236                  #EVT_MENU(self, ID_, gmLog.gmDefLog.Log(gmLog.lErr, "This should ... !")
    237
    238                  # show the menu
    239                  self.PopupMenu(aMenu, event.GetPosition())
    240                  #self.list_script.PopupMenu(aMenu,event.GetPosition())
    241                  # whatever the user selected in the menu will have
    242                  # been handled already virtue of the MENU events
    243                  # created above
    244
    245                  # free resources
    246                  aMenu.Destroy()
    247
    248                  # anybody else needs to intercept right click events?
    249                  event.Skip()
    250
    251 -        def OnExitMenu(self, event):
    252                  print "OnExitMenu"
    253  #--------------------------------------------------------------------
    254 -class gmGP_Prescriptions (gmPlugin_Patient.wxPatientPlugin):
    255          """
    256          Plugin to encapsulate the prescriptions window
    257          """
    258
    259          __icons = {
    260  """icon_Rx_symbol""": 'x\xda\xd3\xc8)0\xe4\nV74S\x00"c\x05Cu\xae\xc4`u=\x85d\x05e\x03 p\xb3\x00\
    261  \xf3#@|\x0b\x03\x10\x04\xf3\x15\x80|\xbf\xfc\xbcT(\x07\x15\xe0\x15\xd4\x83\
    262  \x00t\xc1\x08 \x80\x8a"\t\xc2I\xb2\x04\xc1 "\x82R\x8b\x80\x08UP\x01b,\xdc\
    263  \x9b\x10+\x14\xc0\xa6\xa2\xf9\x1d\xa8\x0eI;\x02DD\xe0\x0c%=\x00D|Hk'
    264  }
    265
    266 -        def name (self):
    267                  return 'Prescription writer'
    268
    269 -        def MenuInfo (self):
    270                  return ('view', '&Script')
    271
    272 -        def GetIconData(self, anIconID = None):
    273                  if anIconID == None:
    274                          return self.__icons[_("""icon_Rx_symbol""")]
    275                  else:
    276                          if self.__icons.has_key(anIconID):
    277                                  return self.__icons[anIconID]
    278                          else:
    279                                  return self.__icons[_("""icon_Rx_symbol""")]
    280
    281 -        def GetWidget (self, parent):
    282                  panel =   PrescriptionPanel (parent, -1)
    283                  return panel
    284  #--------------------------------------------------------------------
    285  if __name__ == '__main__':
    286          app = wxPyWidgetTester(size = (600, 600))
    287          app.SetWidget(PrescriptionPanel, -1)
    288          app.MainLoop()
    289