def __init__(self, controller, obj, db, row=None, title="Add", addRecord=True, patientId=None):
        """
        Initializes the add/modify dialog. This consists of constructing an input form
        which has field names and a text field for entering field values.
        Arguments:
            controller - class performing the object creation, update, or deletion
            obj - object class to be processed
            row - row selected containing the object
            title - title to be displayed on form
            addRecord - flag indicating that a new record is to be created
        """
        # set up controllers
        patientController = PatientIdentificationController(db, PatientIdentification, None, None)
        
        wx.Dialog.__init__(self, None, size=wx.Size(500,300), title="%s Record" % title)
        self.controller = controller
        if row:
            key = row.getKey()
            self.objInstance = controller.getRecordByKey(key)
            if addRecord:
                curPatientId = self.objInstance.patient_id
                self.objInstance = obj()
                self.objInstance.patient_id = curPatientId
        else:
            self.objInstance = obj()
            self.objInstance.patient_id = patientId
        self.addRecord = addRecord
        self.selectedRow = row
        size = (80, -1)
        font = wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD) 
        
        # create the sizers
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
                
        # create some widgets
        lbl = wx.StaticText(self, label=self.objInstance.displayTableName)
        lbl.SetFont(font)
        mainSizer.Add(lbl, 0, wx.CENTER)
        lblfont = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD)
        txtfont = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
        
        self.ctls = []
        lbl = wx.StaticText(self, size=size)
        lbl.SetLabel("Patient:")
        lbl.SetFont(lblfont)
        if row:
            patient = patientController.getRecordByKey(row.patient_id)
        else:
            patient = patientController.getRecordByKey(patientId)
        patientName = patient.patient_name
        patientTextCtrl = wx.TextCtrl(self, value=patientName)
        patientTextCtrl.SetFont(txtfont)
        patientTextCtrl.Enable(False)
        mainSizer.Add(self.rowBuilder([lbl, patientTextCtrl]), 0, wx.EXPAND)
        
        lblrt = wx.StaticText(self, size=size)
        lblrt.SetLabel("Rounding Time:")
        lblrt.SetFont(lblfont)
        dtSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.cc_datepicker = wx.DatePickerCtrl(self, wx.ID_ANY, style=wx.DP_DROPDOWN)
        self.cc_timepicker = wx.lib.masked.timectrl.TimeCtrl(self, wx.ID_ANY)
        self.cc_datepicker.SetFont(txtfont)
        self.cc_timepicker.SetFont(txtfont)
        self.cc_timepicker.SetMinSize((100, 25))
        dtSizer.Add(self.cc_datepicker, 0, 0, 0)
        dtSizer.Add(self.cc_timepicker, 1, 0, 0)
        if row and not(self.addRecord):
            wxrt = wx.calendar._pydate2wxdate(self.objInstance.clinical_rounding_time)
            wxrt.SetHMS(self.objInstance.clinical_rounding_time.hour,self.objInstance.clinical_rounding_time.minute,self.objInstance.clinical_rounding_time.second)
            self.cc_datepicker.SetValue(wxrt)
            self.cc_timepicker.SetValue(wxrt)
        else:
            now = datetime.now()
            wxnow = wx.calendar._pydate2wxdate(now)
            wxnow.SetHMS(now.hour,now.minute,now.second)
            self.cc_datepicker.SetValue(wxnow)
            self.cc_timepicker.SetValue(wxnow)
        mainSizer.Add(self.rowBuilder([lblrt, dtSizer]), 0, wx.EXPAND)
        
        lblpr = wx.StaticText(self, size=size)
        lblpr.SetLabel("Patient Repositioned?:")
        lblpr.SetFont(lblfont)
        self.repositioning_flag = wx.CheckBox(self, wx.ID_ANY)
        self.repositioning_flag.SetFont(txtfont)
        if row and not(self.addRecord):
            self.repositioning_flag.SetValue(self.objInstance.repositioning_flag)
        else:
            self.repositioning_flag.SetValue(False)
        mainSizer.Add(self.rowBuilder([lblpr, self.repositioning_flag]), 0, wx.EXPAND)

        lblfp = wx.StaticText(self, size=size)
        lblfp.SetLabel("Final Position:")
        lblfp.SetFont(lblfont)
        self.final_position = wx.ComboBox(self, wx.ID_ANY, choices=[_("Back"), _("Left Side"), _("Right Side"), _("Stomach")], style=wx.CB_DROPDOWN | wx.CB_DROPDOWN)
        self.final_position.SetFont(txtfont)
        if row and not(self.addRecord):
            self.final_position.SetStringSelection(self.objInstance.final_position)
        else:
            self.final_position.SetSelection(0)
        mainSizer.Add(self.rowBuilder([lblfp, self.final_position]), 0, wx.EXPAND)
        
        lbln = wx.StaticText(self, size=size)
        lbln.SetLabel("Notes:")
        lbln.SetFont(lblfont)
        if row and not(self.addRecord):
            self.repositioning_description = wx.TextCtrl(self, style=wx.TE_MULTILINE, value=self.objInstance.repositioning_description)
        else:
            self.repositioning_description = wx.TextCtrl(self, style=wx.TE_MULTILINE, value="")
        self.repositioning_description.SetFont(txtfont)
        mainSizer.Add(self.rowBuilder([lbln, self.repositioning_description]), 0, wx.EXPAND)
        
        okBtn = wx.Button(self, label="%s" % title)
        okBtn.Bind(wx.EVT_BUTTON, self.onRecord)
        btnSizer.Add(okBtn, 0, wx.ALL, 5)
        cancelBtn = wx.Button(self, label="Close")
        cancelBtn.Bind(wx.EVT_BUTTON, self.onClose)
        btnSizer.Add(cancelBtn, 0, wx.ALL, 5)
        
        mainSizer.Add(btnSizer, 0, wx.CENTER)
        self.SetSizer(mainSizer)
 def __init__(self, controller, obj, db, row=None, title="Add", addRecord=True, patientId=None):
     """
     Initializes the add/modify dialog. This consists of constructing an input form
     which has field names and a text field for entering field values.
     Arguments:
         controller - class performing the object creation, update, or deletion
         obj - object class to be processed
         row - row selected containing the object
         title - title to be displayed on form
         addRecord - flag indicating that a new record is to be created
     """
     # set up controllers
     patientController = PatientIdentificationController(db, PatientIdentification, None, None)
     skeletonController = SkeletonModelController(db, SkeletonModel, None, None)
     
     wx.Dialog.__init__(self, None, title="%s Wound Record" % title)
     self.controller = controller
     if row:
         key = row.getKey()
         self.objInstance = controller.getRecordByKey(key)
         if addRecord:
             curPatientId = self.objInstance.patient_id
             self.objInstance = obj()
             self.objInstance.patient_id = curPatientId
     else:
         self.objInstance = obj()
         self.objInstance.patient_id = patientId
     self.addRecord = addRecord
     self.selectedRow = row
     size = (80, -1)
     font = wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD) 
     
     # create the sizers
     mainSizer = wx.BoxSizer(wx.VERTICAL)
     btnSizer = wx.BoxSizer(wx.HORIZONTAL)
             
     # create some widgets
     lbl = wx.StaticText(self, label=self.objInstance.displayTableName)
     lbl.SetFont(font)
     mainSizer.Add(lbl, 0, wx.CENTER)
     font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD)
     
     self.ctls = []
     lbl = wx.StaticText(self, size=size)
     lbl.SetLabel("Patient:")
     lbl.SetFont(font)
     if row:
         patientTextCtrl = wx.TextCtrl(self, value=row.patient_name)
     else:
         patient = patientController.getRecordByKey(patientId)
         patientName = patient.patient_name
         print "add_modify_wound_dialog.... patient: "+patientName
         patientTextCtrl = wx.TextCtrl(self, value=patientName)
     patientTextCtrl.Enable(False)
     mainSizer.Add(self.rowBuilder([lbl, patientTextCtrl]), 0, wx.EXPAND)
     
     lbl = wx.StaticText(self, size=size)
     lbl.SetLabel("Wound Id:")
     lbl.SetFont(font)
     if row and not(self.addRecord):
         self.woundIdTextCtrl = wx.TextCtrl(self, value=str(self.objInstance.wound_id))
     else:
         woundId = controller.getMaxWoundId(self.objInstance.patient_id)
         if woundId != None:
             woundId = woundId + 1
         else:
             woundId = 1
         self.woundIdTextCtrl = wx.TextCtrl(self, value=str(woundId))
     self.woundIdTextCtrl.Enable(False)
     mainSizer.Add(self.rowBuilder([lbl, self.woundIdTextCtrl]), 0, wx.EXPAND)
     
     lbl = wx.StaticText(self, size=size)
     lbl.SetLabel("Location (ICD_10):")
     lbl.SetFont(font)
     self.wound_loc = wx.ComboBox(self, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN | wx.CB_DROPDOWN)
     self.wound_loc.SetFont(font)
     bodyParts = skeletonController.getAll()
     for s in bodyParts:
         self.wound_loc.Append(s.description, str(s.location_id))
     if row:
         n = 0
         for s in bodyParts:
             if self.objInstance.wound_location_id == s.location_id:
                 self.wound_loc.Select(n)
                 break
             n = n + 1
     else:
         self.wound_loc.Select(0)
     mainSizer.Add(self.rowBuilder([lbl, self.wound_loc]), 0, wx.EXPAND)
     
     lbl = wx.StaticText(self, size=size)
     lbl.SetLabel("Location Description:")
     lbl.SetFont(font)
     if row and not(self.addRecord):
         self.descTextCtrl = wx.TextCtrl(self, value=self.objInstance.wound_location_description)
     else:
         self.descTextCtrl = wx.TextCtrl(self, value="")
     mainSizer.Add(self.rowBuilder([lbl, self.descTextCtrl]), 0, wx.EXPAND)
     
     okBtn = wx.Button(self, label="%s" % title)
     okBtn.Bind(wx.EVT_BUTTON, self.onRecord)
     btnSizer.Add(okBtn, 0, wx.ALL, 5)
     cancelBtn = wx.Button(self, label="Close")
     cancelBtn.Bind(wx.EVT_BUTTON, self.onClose)
     btnSizer.Add(cancelBtn, 0, wx.ALL, 5)
     
     mainSizer.Add(btnSizer, 0, wx.CENTER)
     self.SetSizer(mainSizer)
     self.SetMinSize(wx.Size(400,20))