Esempio n. 1
0
def listBilledICD(pt_ID):
    icdList = []
    billedProblems = []
    problems = []
    for i in range(1,11):
        #collect the icd10 codes billed with each note for every note in a given calendar year
        qry = "SELECT icd%d FROM notes INNER JOIN demographics USING (patient_ID) \
                WHERE date LIKE '2015%%' AND patient_ID = %s AND icd%d != '';" % (i,pt_ID,i)
        results = EMR_utilities.getAllData(qry)
	for r in results:
        #create a list from the tuple
	    icdList.append(r)
    #we make a set which eliminates any duplicates
    billedIcdList = set(icdList) #during 2015 some will be icd9 and some icd10
    for part in EMR_utilities.getAllData('SELECT short_des FROM problems10 WHERE patient_ID = %s;' % pt_ID):
        #collects problem names in a list
        problems.append(part[0])
    for item in billedIcdList:
        #gets list of billed problem's descriptions but pulls only icd10
        try:
            des = EMR_utilities.getData('SELECT short_des FROM icd10 WHERE icd10 = "%s";' % item[0])
            billedProblems.append(des[0])
        except: pass
            #print 'Icd %s not found!' % item[0]    #these should be all the icd9 codes billed
    for val in billedProblems:
        #subtracts billed problem's names from the pt's problem list
        if val in problems:
            problems.remove(val)
    EMR_utilities.MESSAGES = EMR_utilities.MESSAGES + 'ICD codes not billed this year:\n\n'
    for x in problems:
        EMR_utilities.MESSAGES = EMR_utilities.MESSAGES + '--' + x + '\n'	    
        EMR_utilities.MESSAGES = EMR_utilities.MESSAGES + '\n\n'
Esempio n. 2
0
def listBilledICD(pt_ID):
    icdList = []
    billedProblems = []
    problems = []
    for i in range(1, 11):
        qry = "SELECT icd%d FROM notes INNER JOIN demographics USING (patient_ID) WHERE date LIKE '2015%%' AND patient_ID = %s AND icd%d != '';" % (
            i, pt_ID, i)
        results = EMR_utilities.getAllData(qry)
        for r in results:
            icdList.append(r)
    billedIcdList = set(icdList)
    for part in EMR_utilities.getAllData(
            'SELECT short_des FROM problems10 WHERE patient_ID = %s;' % pt_ID):
        problems.append(part[0])
    for item in billedIcdList:
        try:
            des = EMR_utilities.getData(
                'SELECT short_des FROM icd10 WHERE icd10 = "%s";' % item[0])
            billedProblems.append(des[0])
        except:
            print 'Icd %s not found' % item[0]
    for val in billedProblems:
        if val in problems:
            problems.remove(val)
    EMR_utilities.MESSAGES = EMR_utilities.MESSAGES + 'ICD codes not billed this year:\n\n'
    for x in problems:
        EMR_utilities.MESSAGES = EMR_utilities.MESSAGES + '--' + x + '\n'
    EMR_utilities.MESSAGES = EMR_utilities.MESSAGES + '\n\n'
Esempio n. 3
0
 def OnTextEnterICD(self, event):
     #when user enters ' ' create single choice dialog with patient's problem list; inserts ICD code for selected problem
     if event.GetString() == ' ':
         qry = "SELECT short_des FROM problems10 WHERE patient_ID = %s;" % (
             self.ptID)
         results = EMR_utilities.getAllData(qry)
         ptProbList = []
         for items in results:
             ptProbList.append(items[0])
         dialog = wx.SingleChoiceDialog(self, 'Select a problem',
                                        "Patient's Problem List",
                                        ptProbList)
         if dialog.ShowModal() == wx.ID_OK:
             icdQry = 'SELECT icd_9 FROM icd_9 WHERE disease_name = "%s";' % dialog.GetStringSelection(
             )
             icdResults = EMR_utilities.getData(icdQry)
             self.icd = icdResults[0]
             event.EventObject.SetValue(dialog.GetStringSelection())
             event.EventObject.MarkDirty()
         else:
             pass
     #when user enters '?' pull up problem dialog to search for codes
     elif event.GetString() == '?':
         string = wx.GetTextFromUser("Search diagnosis list for ...")
         qry = 'SELECT disease_name FROM icd_9 WHERE disease_name LIKE "%%%s%%";' % (
             string)
         results = EMR_utilities.getAllData(qry)
         probList = []
         for items in results:
             probList.append(items[0])
         dialog = wx.SingleChoiceDialog(self, 'Select a problem',
                                        'Master Problem List', probList)
         if dialog.ShowModal() == wx.ID_OK:
             icdQry = 'SELECT icd_9 FROM icd_9 WHERE disease_name = "%s";' % dialog.GetStringSelection(
             )
             icdResults = EMR_utilities.getData(icdQry)
             self.icd = icdResults[0]
             event.EventObject.SetValue(dialog.GetStringSelection())
             event.EventObject.MarkDirty()
         else:
             pass
     elif event.GetString() == 'f':
         #this option allows search of www.icd9data.com for specified term
         term = wx.GetTextFromUser("Look up ICD-9 Code: eg, rotator+cuff")
         string = 'http://www.icd10data.com/Search.aspx?search=%s&codeBook=ICD9CM' % term
         results = EMR_utilities.HTML_Frame(self,
                                            "ICD-9 Help",
                                            html_str=string)
         results.Show()
     else:
         pass
     event.Skip()
Esempio n. 4
0
 def EvtSelRefineList(self, event):
     if self.refineListBox.GetSelection() == 0:
         #this was done because after appending new values to refineListBox the selection event was being triggered a second time
         pass
     else:
         qry1 = '(SELECT * FROM ICD10billable WHERE short_des LIKE "%%%s%%" AND billable = "1")' % self.textctrl[
             'Search'].GetValue()
         qry2 = 'SELECT * FROM %s AS custom WHERE short_des LIKE "%%%s%%";' % (
             qry1, event.GetString().split(',')[0])
         self.results = EMR_utilities.getAllData(qry2)
         self.resultListBox.Clear()
         self.refineListBox.Clear()
         short_des_list = []
         for items in self.results:
             self.resultListBox.Append(str(items[4]))
             short_des_list.append(items[4])
             refined = Counter(
                 chain.from_iterable(
                     wordpunct_tokenize(x)
                     for x in short_des_list)).most_common(10)
         for items in refined:
             if len(
                     items[0]
             ) > 3:  #removes small words that aren't useful search terms like of, and, the
                 self.refineListBox.Append(
                     str(items).strip("()'").replace("'", ""))
Esempio n. 5
0
    def __init__(self, parent, visitSince='2010-10-01'):

	'''Send letters to all my active patients.'''

	#Here is the letter
	myLtr = '''In addition to working at my practice on Big Bend, I also serve in the US Army Reserve.  They have \
decided to deploy me to Kuwait for three months starting 30 Sep 2011.  I will be back in early January 2012.  \
I will be working there in a hospital treating US servicemen/women who are also deployed.  I am happy to see you for any \
pending issues before I leave.  I will continue to answer emails sent to <i>[email protected]</i> while I'm gone.  \
The office phone will be answered by my staff during normal business hours and evening messages will be \
returned the following day.  I have arranged for the Family Care Health Center, 401 Holly Hills Avenue, \
to see anyone who needs an appointment during my absence.  Their phone number is (314) 353-5190.  Information about their \
office can be found at <i>http://www.fchcstl.org</i>.  I apologise for the limited notice, but unfortunately this came up \
rather suddenly.  I look forward to seeing you when I get back.'''
    
	#Figure out who the active patients are and create a list of their patient_ID numbers
	qry = 'SELECT patient_ID FROM notes WHERE date >= "%s";' % visitSince
	results = EMR_utilities.getAllData(qry)

	#Remove duplicates from the list
	d = {}
	for x in results:
	    d[x] = 1
	myList = list(d.keys())
	print len(myList)
	
	#Step through the list creating letter using template in Printer
	for items in myList:
	    myPtLtr(self, items[0], text=myLtr)
Esempio n. 6
0
    def __init__(self, parent, visitSince='2010-10-01'):

	'''Send letters to all my active patients.'''

	#Here is the letter
	myLtr = '''As you may recall from my letter dated September 8, 2011, I have been deployed by the US Army to Kuwait until early January 2012. I arranged for the Family Care Health Center to see my patients while I am gone. Unfortunately, their capacity to see my patients is more limited than I anticipated.

In order to address this issue, Dr Ladonna Finch has generously agreed to help. If you need an appointment, rather than calling the Family Care Health Center as my previous letter suggested, please call her office at 314-645-7265.  Her office is located at 1031 Bellevue Avenue, Suite 349 in Richmond Heights, across the street from St. Mary's Hospital.

I encourage you to call my office for medication refills and non-urgent questions/issues that can be addressed via email.  

Thank you for your understanding.'''
    
	#Figure out who the active patients are and create a list of their patient_ID numbers
	qry = 'SELECT patient_ID FROM notes WHERE date >= "%s";' % visitSince
	results = EMR_utilities.getAllData(qry)

	#Remove duplicates from the list
	d = {}
	for x in results:
	    d[x] = 1
	myList = list(d.keys())
	print len(myList)
	
	#Step through the list creating letter using template in Printer
	for items in myList:
	    myPtLtr(self, items[0], text=myLtr)
Esempio n. 7
0
    def __init__(self, parent, visitSince='2010-10-01'):
        '''Send letters to all my active patients.'''

        #Here is the letter
        myLtr = '''As you may recall from my letter dated September 8, 2011, I have been deployed by the US Army to Kuwait until early January 2012. I arranged for the Family Care Health Center to see my patients while I am gone. Unfortunately, their capacity to see my patients is more limited than I anticipated.

In order to address this issue, Dr Ladonna Finch has generously agreed to help. If you need an appointment, rather than calling the Family Care Health Center as my previous letter suggested, please call her office at 314-645-7265.  Her office is located at 1031 Bellevue Avenue, Suite 349 in Richmond Heights, across the street from St. Mary's Hospital.

I encourage you to call my office for medication refills and non-urgent questions/issues that can be addressed via email.  

Thank you for your understanding.'''

        #Figure out who the active patients are and create a list of their patient_ID numbers
        qry = 'SELECT patient_ID FROM notes WHERE date >= "%s";' % visitSince
        results = EMR_utilities.getAllData(qry)

        #Remove duplicates from the list
        d = {}
        for x in results:
            d[x] = 1
        myList = list(d.keys())
        print len(myList)

        #Step through the list creating letter using template in Printer
        for items in myList:
            myPtLtr(self, items[0], text=myLtr)
Esempio n. 8
0
def getProblems(ptID, display=''):
	qry = 'SELECT short_des FROM problems10 WHERE patient_ID = %s;' % (ptID)
	results = EMR_utilities.getAllData(qry)
	shortList = []
	try:
	    for items in results:
		#query = 'SELECT short_des FROM icd10 WHERE disease_name = "%s";' % items[0]
		#short_name = EMR_utilities.getData(query)
		shortList.append(items)
	except: pass
	if display == 'HTML':
	    string = "<b>Problems:</b><BR>"
	    separator = "<BR>"
	else:
	    string = "Problems:\n"
	    separator = "\n"
	if results == ():
	    string = string + "none"
	else:
	    n = 1
	    for p in shortList:
		try:
		    string = string + "%s) %s%s" % (n, p[0], separator)
		    n = n + 1
		except: pass
	return string
Esempio n. 9
0
 def loadList(self):
     #self.listctrl.Set("")
     qry = 'SELECT * FROM education WHERE patient_ID = %s ORDER BY date DESC;' % (
         self.PtID)
     self.results = EMR_utilities.getAllData(qry)
     for items in self.results:
         self.listctrl.Append(str(items[3]))
Esempio n. 10
0
def getProblems(ptID, display=''):
    qry = 'SELECT short_des FROM problems10 WHERE patient_ID = %s;' % (ptID)
    results = EMR_utilities.getAllData(qry)
    shortList = []
    try:
        for items in results:
            #query = 'SELECT short_des FROM icd10 WHERE disease_name = "%s";' % items[0]
            #short_name = EMR_utilities.getData(query)
            shortList.append(items)
    except:
        pass
    if display == 'HTML':
        string = "<b>Problems:</b><BR>"
        separator = "<BR>"
    else:
        string = "Problems:\n"
        separator = "\n"
    if results == ():
        string = string + "none"
    else:
        n = 1
        for p in shortList:
            try:
                string = string + "%s) %s%s" % (n, p[0], separator)
                n = n + 1
            except:
                pass
    return string
Esempio n. 11
0
    def OnTextEnterICD(self, event):
	#when user enters ' ' create single choice dialog with patient's problem list; inserts ICD code for selected problem
	if event.GetString() == ' ':
	    qry = "SELECT short_des FROM problems10 WHERE patient_ID = %s;" % (self.PtID)
	    results = EMR_utilities.getAllData(qry)
	    ptProbList = []
	    for items in results:
		ptProbList.append(items[0])
	    dialog = wx.SingleChoiceDialog(self, 'Select a problem', "Patient's Problem List", ptProbList)
	    if dialog.ShowModal() == wx.ID_OK:
		try:
		    r = EMR_utilities.getData('SELECT icd10 FROM ICD10billable WHERE short_des = "%s" AND billable = "1";' % dialog.GetStringSelection())
		    event.EventObject.SetValue((r)[0])
		    event.EventObject.MarkDirty()
		except: 
		    wx.MessageBox('Not a billable ICD10 code.  Please fix on problem list.', 'Message')
	    else: pass
	#when user enters '?' pull up problem dialog to search for codes
	elif event.GetString() == 'g':
	    string = wx.GetTextFromUser("Search diagnosis list for ...")
	    qry = 'SELECT disease_name FROM icd_9 WHERE disease_name LIKE "%%%s%%";' % (string)
	    results = EMR_utilities.getAllData(qry)
	    probList = []
	    for items in results:
		probList.append(items[0])
	    dialog = wx.SingleChoiceDialog(self, 'Select a problem', 'Master Problem List', probList)
	    if dialog.ShowModal() == wx.ID_OK:
		q = 'SELECT icd_9 FROM icd_9 WHERE disease_name = "%s";' % (dialog.GetStringSelection())
		event.EventObject.SetValue(EMR_utilities.getData(q)[0])
		event.EventObject.MarkDirty()
	    else: pass
	elif event.GetString() == 'f':
	    #this option allows search of www.icd9data.com for specified term
	    term = wx.GetTextFromUser("Look up ICD-9 Code: eg, rotator+cuff")
	    string = 'https://icd10.clindesk.org/#/?q=%s' % term
	    results = EMR_utilities.HTML_Frame(self, "ICD-9 Help", html_str=string)
            results.Show()
	elif event.GetString() == '?':
	    code = icd10picker(self, self, -1, 'ICD 10 Finder')
	    self.icd10code = ''
	    if code.ShowModal() == wx.ID_OK:
		event.EventObject.SetValue(self.icd10code[0])
		event.EventObject.MarkDirty()
	    else: pass
	    code.Destroy()
	else: pass
	event.Skip()
Esempio n. 12
0
def geesandpees(ptID):
	qry = 'SELECT short_des FROM problems10 WHERE patient_ID = %s;' % (ptID)
	results = EMR_utilities.getAllData(qry)
	for items in results:
	    r = re.search('G\dP\d', str(items))
	    if r:
		return r.group() 
	    else: pass
Esempio n. 13
0
def geesandpees(ptID):
    qry = 'SELECT short_des FROM problems10 WHERE patient_ID = %s;' % (ptID)
    results = EMR_utilities.getAllData(qry)
    for items in results:
        r = re.search('G\dP\d', str(items))
        if r:
            return r.group()
        else:
            pass
Esempio n. 14
0
def getAllergies(ptID):
    qry = 'SELECT allergy FROM allergies WHERE patient_ID = %s;' % (ptID)
    results = EMR_utilities.getAllData(qry)
    string = "Allergies: "
    if results == ():
        string = string + "not recorded in chart"
    else:
        for items in results:
            string = string + '%s, ' % (items)
    return string
Esempio n. 15
0
def getAllergies(ptID):
	qry = 'SELECT allergy FROM allergies WHERE patient_ID = %s;' % (ptID)
	results = EMR_utilities.getAllData(qry)
	string = "Allergies: "
	if results == ():
	    string = string + "not recorded in chart"
	else:
	    for items in results:
		string = string + '%s, ' % (items)
	return string
Esempio n. 16
0
    def OnSearchEnter(self, event):
	qry = 'SELECT * FROM ICD10billable WHERE short_des LIKE "%%%s%%" AND billable = "1";' % (event.GetString())
	self.results = EMR_utilities.getAllData(qry)
	short_des_list = []
	for items in self.results:
	    self.resultListBox.Append(str(items[4]))
	    short_des_list.append(items[4])
	#find common words in results and present them in the refine list
	refined = Counter(chain.from_iterable(wordpunct_tokenize(x) for x in short_des_list)).most_common(10)
	for items in refined:
	    if len(items[0]) > 3:
		self.refineListBox.Append(str(items).strip("()'").replace("'", ""))
Esempio n. 17
0
def OBweeks(ptID):
	qry = 'SELECT short_des FROM problems10 WHERE patient_ID = %s;' % (ptID)
	results = EMR_utilities.getAllData(qry)
	for items in results:
	    r = re.search('\d\d\d\d-\d\d-\d\d', str(items))
	    if r:
		edc = datetime.date(*map(int, r.group().split('-')))
		pregnancy = datetime.timedelta(weeks=-40)
		conception = edc + pregnancy
		howfar = datetime.date.today() - conception
		weeks, days = divmod(howfar.days, 7)
		return '%s %s/7 weeks' % (weeks, days) 
	    else: pass
Esempio n. 18
0
    def OnRefineEnter(self, event):
	qry1 = '(SELECT * FROM ICD10billable WHERE short_des LIKE "%%%s%%" AND billable = "1")' % self.textctrl['Search'].GetValue()
	qry2 = 'SELECT * FROM %s AS custom WHERE short_des LIKE "%%%s%%";' % (qry1, event.GetString())
        self.results = EMR_utilities.getAllData(qry2)
	self.resultListBox.Clear()
	self.refineListBox.Clear()
	short_des_list = []
	for items in self.results:
	    self.resultListBox.Append(str(items[4]))
	    short_des_list.append(items[4])
	refined = Counter(chain.from_iterable(wordpunct_tokenize(x) for x in short_des_list)).most_common(10)
	for items in refined:
	    self.refineListBox.Append(str(items).strip("()'").replace("'", ""))
Esempio n. 19
0
def OBweeks(ptID):
    qry = 'SELECT short_des FROM problems10 WHERE patient_ID = %s;' % (ptID)
    results = EMR_utilities.getAllData(qry)
    for items in results:
        r = re.search('\d\d\d\d-\d\d-\d\d', str(items))
        if r:
            edc = datetime.date(*map(int, r.group().split('-')))
            pregnancy = datetime.timedelta(weeks=-40)
            conception = edc + pregnancy
            howfar = datetime.date.today() - conception
            weeks, days = divmod(howfar.days, 7)
            return '%s %s/7 weeks' % (weeks, days)
        else:
            pass
Esempio n. 20
0
def listBilledICD(pt_ID):
    icdList = []
    billedProblems = []
    problems = []
    for i in range(1, 11):
        #collect the icd10 codes billed with each note for every note in a given calendar year
        qry = "SELECT icd%d FROM notes INNER JOIN demographics USING (patient_ID) \
                WHERE date LIKE '2015%%' AND patient_ID = %s AND icd%d != '';" % (
            i, pt_ID, i)
        results = EMR_utilities.getAllData(qry)
        for r in results:
            #create a list from the tuple
            icdList.append(r)
    #we make a set which eliminates any duplicates
    billedIcdList = set(icdList)  #during 2015 some will be icd9 and some icd10
    for part in EMR_utilities.getAllData(
            'SELECT short_des FROM problems10 WHERE patient_ID = %s;' % pt_ID):
        #collects problem names in a list
        problems.append(part[0])
    for item in billedIcdList:
        #gets list of billed problem's descriptions but pulls only icd10
        try:
            des = EMR_utilities.getData(
                'SELECT short_des FROM icd10 WHERE icd10 = "%s";' % item[0])
            billedProblems.append(des[0])
        except:
            pass
        #print 'Icd %s not found!' % item[0]    #these should be all the icd9 codes billed
    for val in billedProblems:
        #subtracts billed problem's names from the pt's problem list
        if val in problems:
            problems.remove(val)
    EMR_utilities.MESSAGES = EMR_utilities.MESSAGES + 'ICD codes not billed this year:\n\n'
    for x in problems:
        EMR_utilities.MESSAGES = EMR_utilities.MESSAGES + '--' + x + '\n'
        EMR_utilities.MESSAGES = EMR_utilities.MESSAGES + '\n\n'
Esempio n. 21
0
    def EvtSelRefineList(self, event):
	if self.refineListBox.GetSelection() == 0:
	    #this was done because after appending new values to refineListBox the selection event was being triggered a second time
	    pass   
	else:
	    qry1 = '(SELECT * FROM ICD10billable WHERE short_des LIKE "%%%s%%" AND billable = "1")' % self.textctrl['Search'].GetValue()
	    qry2 = 'SELECT * FROM %s AS custom WHERE short_des LIKE "%%%s%%";' % (qry1, event.GetString().split(',')[0])
            self.results = EMR_utilities.getAllData(qry2)
	    self.resultListBox.Clear()
	    self.refineListBox.Clear()
	    short_des_list = []
	    for items in self.results:
		self.resultListBox.Append(str(items[1]))
		short_des_list.append(items[1])
	    refined = Counter(chain.from_iterable(wordpunct_tokenize(x) for x in short_des_list)).most_common(10)
	    for items in refined:
		if len(items[0]) > 3:	#removes small words that aren't useful search terms like of, and, the
		    self.refineListBox.Append(str(items).strip("()'").replace("'", ""))
Esempio n. 22
0
def getMeds(ptID, display='wrap'):
	qry = 'SELECT med_name, dose, number_tablets, frequency FROM meds WHERE patient_ID = %s AND archive = 0;' % \
	      (ptID)
	results = EMR_utilities.getAllData(qry)
	if display == 'wrap':
	    string = "Meds: "
	    separator = ','
	elif display == 'column':
	    string = "Current Medications:\n\t"
	    separator = '\n\t'
	else: 
	    string = "<b>Meds:</b><BR> "
	    separator = '<BR>'
	if results == ():
	    string = string + "none"
	else:
	    for items in results:
		string = string + '%s %s take %s %s%s' % (items[0], items[1], items[2], items[3], separator)
	return string
Esempio n. 23
0
def getMeds(ptID, display='wrap'):
    qry = 'SELECT med_name, dose, number_tablets, frequency FROM meds WHERE patient_ID = %s AND archive = 0;' % \
          (ptID)
    results = EMR_utilities.getAllData(qry)
    if display == 'wrap':
        string = "Meds: "
        separator = ','
    elif display == 'column':
        string = "Current Medications:\n\t"
        separator = '\n\t'
    else:
        string = "<b>Meds:</b><BR> "
        separator = '<BR>'
    if results == ():
        string = string + "none"
    else:
        for items in results:
            string = string + '%s %s take %s %s%s' % (
                items[0], items[1], items[2], items[3], separator)
    return string
Esempio n. 24
0
 def OnCPTlookup(self, event):
     if event.GetString() == ' ':
         #string = wx.GetTextFromUser("Search diagnosis list for ...")
         qry = 'SELECT proc FROM fee_schedule ORDER BY proc;'
         results = EMR_utilities.getAllData(qry)
         cptList = []
         for items in results:
             cptList.append(items[0])
         dialog = wx.SingleChoiceDialog(self, 'Select a CPT code',
                                        'CPT List', cptList)
         if dialog.ShowModal() == wx.ID_OK:
             q = 'SELECT cpt_code, my_fee FROM fee_schedule WHERE proc = "%s";' % dialog.GetStringSelection(
             )
             res = EMR_utilities.getData(q)
             event.EventObject.SetValue(res[0])
             self.textctrl['Charges'].SetValue(str(res[1]))
         else:
             pass
     else:
         pass
Esempio n. 25
0
    def OnKillFocusICD(self, event):
	#for item in dir(event.GetEventObject()):
	#    print item, ": ", getattr(event.GetEventObject(), item)
	
	if event.GetEventObject().IsModified():
	    #remove any decimal points
	    icd = event.GetEventObject().GetValue().replace('.', '')
	    #save any updates to the database
	    d = {"ICD #1":"icd1", "ICD #2":"icd2", "ICD #3":"icd3", "ICD #4":"icd4", "ICD #5":"icd5",
		 "ICD #6":"icd6", "ICD #7":"icd7", "ICD #8":"icd8", "ICD #9":"icd9", "ICD #10":"icd10"}
	    try:
		qry = 'UPDATE notes SET %s = "%s" WHERE date = "%s";' % (d[event.GetEventObject().Name], \
				icd, self.textctrl['Date'].GetValue())
		EMR_utilities.updateData(qry)
	    except:
		print 'icd query didnt work, line 374'
	    if icd == ' ' or icd == '?' or icd == 'f' or icd == 'g':
		pass	#setting these values was triggering the OnTextEnterICD resulting in two dialog boxes
	    else:
		event.GetEventObject().SetValue(icd)
	    qry = 'SELECT * FROM notes WHERE patient_ID = %s ORDER BY date DESC;' % (self.PtID)
	    self.results = EMR_utilities.getAllData(qry)
	    
	else: pass
Esempio n. 26
0
    def __init__(self, parent, id=-1, title=None, ptID=None):
	wx.Panel.__init__(self, parent, id, title)

	self.ptID = ptID	
	self.textctrl = {}
	font1 = wx.Font(12, wx.SWISS, wx.NORMAL, wx.LIGHT)
	Font2 = wx.Font(7, wx.SWISS, wx.NORMAL, wx.LIGHT)
	self.labels = (('First Name', 50, 'firstname'), ('Last Name', 75, 'lastname'), ('Mid Initial', 20, 'mid_init'),
		('Address', 100, 'address'), ('City', 75, 'city'), ('State', 30, 'state'), ('Zip', 40, 'zipcode'), 
		('Phone', 40, 'phonenumber'), ('Sex', 20, 'sex'), ('DOB', 50, 'dob'), 
		('Insured', 30,  'relation_to_insured'), ('SSN', 30, 'SSN'), ('Email', 125, 'email'), 
		('Signature on File', 40, 'sof'),

		('Insurance Co', 0, 'insurance_company'), ('Policy ID', 50, 'policy_ID'), 
		('Sec Insurance', 100, 'secondary_ins'), ('Sec Policy ID', 50, 'secondary_ins_ID'), 
		('Sec Policy #', 50, 'sec_PolicyGroupOrFecaNumber'), 
		('Plan Name', 75, 'InsuredInsurancePlanNameOrProgramName'), 
		('Ins Policy/Group/FECA Number', 50, 'InsuredPolicyGroupOrFecaNumber'), 

		('Ins Last', 75, 'InsuredLast'),  ('Ins First', 50, 'InsuredFirst'), 
		('Ins Mid Initial', 20, 'InsuredMidInit'), ('Ins Address', 100, 'InsuredStreetAddress'), 
		('Ins City', 75, 'InsuredCity'), ('Ins State', 30, 'InsuredState'), ('Ins Zip', 40, 'InsuredZip'), 
		('Ins Phone', 40, 'InsuredPhone'), 

		#These were removed to make space for other demographics fields; they were not being used; still in the db though
		#('Ins DOB', 40, 'InsuredDOB'),
		#('Ins Gender', 20, 'InsuredGender'), ('Ins Employer', 100, 'InsuredEmployerNameOrSchoolName'),
		 
		('Guarantor Last', 75, 'guarantor_last'), ('Guarantor First', 50, 'guarantor_first'), 
		('Guarantor Address', 100, 'guarantor_address'), ('Guarantor City', 75, 'guarantor_city'),
		('Guarantor State', 30, 'guarantor_state'), ('Guarantor Zip', 40, 'guarantor_zip'), 
		('Guarantor Phone', 40, 'guarantor_phone'),

		('Race', 100, 'race'), ('Primary Language', 50, 'language'), ('PCP', 50, 'pcp'))
		
	for label, size, field in self.labels:
	    EMR_utilities.buildOneTextCtrl(self, label, size)

	demosizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
	demo2sizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
	demo3sizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
	demo4sizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
	demo5sizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
	demosizer.AddGrowableCol(1)
	demo2sizer.AddGrowableCol(1)
	demo3sizer.AddGrowableCol(1)
	demo4sizer.AddGrowableCol(1)
	demo5sizer.AddGrowableCol(1)

	#Patient Info
	nameLabel = wx.StaticText(self, -1, 'First, Middle, Last')
	nameLabel.SetFont(Font2)
	demosizer.Add(nameLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	namesizer = wx.BoxSizer(wx.HORIZONTAL)
	namesizer.Add(self.textctrl['First Name'], 2)
	namesizer.Add(self.textctrl['Mid Initial'], 1, wx.RIGHT|wx.LEFT, 5)
	namesizer.Add(self.textctrl['Last Name'], 3, wx.EXPAND)
	demosizer.Add(namesizer, 0, wx.EXPAND)
	addrLabel = wx.StaticText(self, -1, 'Address')
	addrLabel.SetFont(Font2)
	demosizer.Add(addrLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	demosizer.Add(self.textctrl['Address'], 1, wx.EXPAND)
	cityLabel = wx.StaticText(self, -1, ' City State Zip Phone')
	cityLabel.SetFont(Font2)
	demosizer.Add(cityLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	cstsizer = wx.BoxSizer(wx.HORIZONTAL)
	cstsizer.Add(self.textctrl['City'], 3)
	cstsizer.Add(self.textctrl['State'], 1, wx.LEFT|wx.RIGHT, 5)
	cstsizer.Add(self.textctrl['Zip'], 2, wx.RIGHT, 5)
	cstsizer.Add(self.textctrl['Phone'], 4, wx.EXPAND)
	demosizer.Add(cstsizer, 0, wx.EXPAND)
	dobLabel = wx.StaticText(self, -1, 'DOB Sex email')
	dobLabel.SetFont(Font2)
	demosizer.Add(dobLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	sexsizer = wx.BoxSizer(wx.HORIZONTAL)
	sexsizer.Add(self.textctrl['DOB'], 3)
	sexsizer.Add(self.textctrl['Sex'], 2, wx.LEFT|wx.RIGHT, 5)
	sexsizer.Add(self.textctrl['Email'], 5, wx.EXPAND)
	demosizer.Add(sexsizer, 0, wx.EXPAND)
	InsLabel = wx.StaticText(self, -1, 'Insured  SSN SOF')
	InsLabel.SetFont(Font2)
	demosizer.Add(InsLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	insuredsizer = wx.BoxSizer(wx.HORIZONTAL)
	insuredsizer.Add(self.textctrl['Insured'], 2, wx.RIGHT, 5)
	insuredsizer.Add(self.textctrl['SSN'], 4, wx.RIGHT, 5)
	insuredsizer.Add(self.textctrl['Signature on File'], 3, wx.EXPAND)
	demosizer.Add(insuredsizer, 0, wx.EXPAND)
	
	#Insurance Info
	insTuple = EMR_utilities.getAllData('SELECT InsurancePlanName FROM ins_companies;')
	insList = []	#this control forces me to choose from one of the insurance policies I accept or 'self'
	for item in insTuple:
	    insList.append(item[0])
	self.insChoice = wx.Choice(self, -1, choices=insList)

	InsCoLabel = wx.StaticText(self, -1, 'Primary Insurance Co')
	InsCoLabel.SetFont(Font2)
	demo3sizer.Add(InsCoLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	demo3sizer.Add(self.insChoice, 1, wx.EXPAND)
	IDLabel = wx.StaticText(self, -1, 'ID  Group#  Plan')
	IDLabel.SetFont(Font2)
	demo3sizer.Add(IDLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	pgrpsizer = wx.BoxSizer(wx.HORIZONTAL)
	pgrpsizer.Add(self.textctrl['Policy ID'], 1)
	pgrpsizer.Add(self.textctrl['Ins Policy/Group/FECA Number'], 1, wx.LEFT|wx.RIGHT, 5)
	pgrpsizer.Add(self.textctrl['Plan Name'], 1, wx.EXPAND)
	demo3sizer.Add(pgrpsizer, 0, wx.EXPAND)
	SecInsLabel = wx.StaticText(self, -1, 'Secondary Ins Co')
	SecInsLabel.SetFont(Font2)
	demo3sizer.Add(SecInsLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	demo3sizer.Add(self.textctrl['Sec Insurance'], 1, wx.EXPAND)
	SecIDLabel = wx.StaticText(self, -1, 'Sec ID  Policy#')
	SecIDLabel.SetFont(Font2)
	demo3sizer.Add(SecIDLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	sgrpsizer = wx.BoxSizer(wx.HORIZONTAL)
	sgrpsizer.Add(self.textctrl['Sec Policy ID'], 1, wx.RIGHT, 5)
	sgrpsizer.Add(self.textctrl['Sec Policy #'], 1, wx.EXPAND)
	demo3sizer.Add(sgrpsizer, 0, wx.EXPAND)
	
	#Insured Info (if not the patient)
	InsNameLabel = wx.StaticText(self, -1, 'First, Middle, Last')
	InsNameLabel.SetFont(Font2)
	demo2sizer.Add(InsNameLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	insnamesizer = wx.BoxSizer(wx.HORIZONTAL)
	insnamesizer.Add(self.textctrl['Ins First'], 2)
	insnamesizer.Add(self.textctrl['Ins Mid Initial'], 1, wx.LEFT|wx.RIGHT, 5)
	insnamesizer.Add(self.textctrl['Ins Last'], 3, wx.EXPAND)
	self.textctrl['Ins Last'].Bind(wx.EVT_KILL_FOCUS, self.OnInsKillFocus)
	demo2sizer.Add(insnamesizer, 0, wx.EXPAND)
	InsAddrLabel = wx.StaticText(self, -1, 'Address')
	InsAddrLabel.SetFont(Font2)
	demo2sizer.Add(InsAddrLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	demo2sizer.Add(self.textctrl['Ins Address'], 1, wx.EXPAND)
	InsCityLabel = wx.StaticText(self, -1, 'City State Zip Phone')
	InsCityLabel.SetFont(Font2)
	demo2sizer.Add(InsCityLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	inscstsizer = wx.BoxSizer(wx.HORIZONTAL)
	inscstsizer.Add(self.textctrl['Ins City'], 3)
	inscstsizer.Add(self.textctrl['Ins State'], 1, wx.LEFT|wx.RIGHT, 5)
	inscstsizer.Add(self.textctrl['Ins Zip'], 2, wx.RIGHT, 5)
	inscstsizer.Add(self.textctrl['Ins Phone'], 4, wx.EXPAND)
	demo2sizer.Add(inscstsizer, 0, wx.EXPAND)
	#InsDOBLabel = wx.StaticText(self, -1, 'DOB  Sex')
	#InsDOBLabel.SetFont(Font2)
	#demo2sizer.Add(InsDOBLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	#inssexsizer = wx.BoxSizer(wx.HORIZONTAL)
	#inssexsizer.Add(self.textctrl['Ins DOB'], 1, wx.RIGHT, 5)
	#inssexsizer.Add(self.textctrl['Ins Gender'], 1, wx.EXPAND)
	#demo2sizer.Add(inssexsizer, 0, wx.EXPAND)
	#emplLabel = wx.StaticText(self, -1, 'Employer')
	#emplLabel.SetFont(Font2)
	#demo2sizer.Add(emplLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	#demo2sizer.Add(self.textctrl['Ins Employer'], 1, wx.EXPAND)
	
	#Contact Info
	relationshipLabel = wx.StaticText(self, -1, 'Advanced Directive?') 
	relationshipLabel.SetFont(Font2)
	demo4sizer.Add(relationshipLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	relationshipSizer = wx.BoxSizer(wx.HORIZONTAL)
	self.adv_dirYesRB = wx.RadioButton(self, -1, 'Yes', style=wx.RB_GROUP)
        self.adv_dirNoRB = wx.RadioButton(self, -1, 'No')
	self.adv_dirUnknownRB = wx.RadioButton(self, -1, 'Unknown')
	self.adv_dirYesRB.SetFont(Font2)
	relationshipSizer.Add(self.adv_dirYesRB)
	self.adv_dirNoRB.SetFont(Font2)
	relationshipSizer.Add(self.adv_dirNoRB)
	self.adv_dirUnknownRB.SetFont(Font2)
	relationshipSizer.Add(self.adv_dirUnknownRB)
	self.proxyBox = wx.CheckBox(self, -1, "Contact is healthcare proxy.")
	self.proxyBox.SetFont(Font2)
	relationshipSizer.Add((35, -1))
	relationshipSizer.Add(self.proxyBox)
	demo4sizer.Add(relationshipSizer, 0, wx.EXPAND)
	guarNameLabel = wx.StaticText(self, -1, 'First, Last Name')
	guarNameLabel.SetFont(Font2)
	demo4sizer.Add(guarNameLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	guarnamesizer = wx.BoxSizer(wx.HORIZONTAL)
	guarnamesizer.Add(self.textctrl['Guarantor First'], 1, wx.RIGHT, 5)
	guarnamesizer.Add(self.textctrl['Guarantor Last'], 1, wx.EXPAND)
	self.textctrl['Guarantor Last'].Bind(wx.EVT_KILL_FOCUS, self.OnGuarKillFocus)
	demo4sizer.Add(guarnamesizer, 0, wx.EXPAND)
	gAddrLabel = wx.StaticText(self, -1, 'Address')
	gAddrLabel.SetFont(Font2)
	demo4sizer.Add(gAddrLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	demo4sizer.Add(self.textctrl['Guarantor Address'], 0, wx.EXPAND)
	gCityLabel = wx.StaticText(self, -1, 'City State Zip Phone')
	gCityLabel.SetFont(Font2)
	demo4sizer.Add(gCityLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	guarcstsizer = wx.BoxSizer(wx.HORIZONTAL)
	guarcstsizer.Add(self.textctrl['Guarantor City'], 3)
	guarcstsizer.Add(self.textctrl['Guarantor State'], 1, wx.LEFT|wx.RIGHT, 5)
	guarcstsizer.Add(self.textctrl['Guarantor Zip'], 2, wx.RIGHT, 5)
	guarcstsizer.Add(self.textctrl['Guarantor Phone'], 4, wx.EXPAND)
	demo4sizer.Add(guarcstsizer, 0, wx.EXPAND)

	#Other Info (mainly added for NCQA purposes)
	demo5sizer.Add(wx.StaticText(self, -1, '                        ')) #no label needed, spacing only
	marriedSizer = wx.BoxSizer(wx.HORIZONTAL)
	self.marriedBox = wx.CheckBox(self, -1, "Married?")
	self.marriedBox.SetFont(Font2)
	marriedSizer.Add(self.marriedBox)
	self.inactiveBox = wx.CheckBox(self, -1, "Inactive Patient")
	self.inactiveBox.SetFont(Font2)
	marriedSizer.Add(self.inactiveBox)
	demo5sizer.Add(marriedSizer, 0, wx.EXPAND)
	languageLabel = wx.StaticText(self, -1, 'Language, PCP')
	languageLabel.SetFont(Font2)
	demo5sizer.Add(languageLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	languageSizer = wx.BoxSizer(wx.HORIZONTAL)
	languageSizer.Add(self.textctrl['Primary Language'], 1, wx.RIGHT, 5)
	languageSizer.Add(self.textctrl['PCP'], 1, wx.EXPAND)
	demo5sizer.Add(languageSizer, 0, wx.EXPAND)
	raceLabel = wx.StaticText(self, -1, 'Race')
	raceLabel.SetFont(Font2)
	demo5sizer.Add(raceLabel, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	demo5sizer.Add(self.textctrl['Race'], 0, wx.EXPAND)


	
	box = wx.StaticBox(self, -1, 'Patient')
	box2 = wx.StaticBox(self, -1, 'Insured')		
	box3 = wx.StaticBox(self, -1, 'Insurance Information')		
	box4 = wx.StaticBox(self, -1, 'Contact')
	box5 = wx.StaticBox(self, -1, 'Other Info')	
	box.SetFont(font1)
	box2.SetFont(font1)
	box3.SetFont(font1)
	box4.SetFont(font1)
	box5.SetFont(font1)
	boxsizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
	box2sizer = wx.StaticBoxSizer(box2, wx.HORIZONTAL)
	box3sizer = wx.StaticBoxSizer(box3, wx.HORIZONTAL)
	box4sizer = wx.StaticBoxSizer(box4, wx.HORIZONTAL)
	box5sizer = wx.StaticBoxSizer(box5, wx.HORIZONTAL)
	boxsizer.Add(demosizer, 1, wx.EXPAND|wx.TOP|wx.BOTTOM, 25)
	box2sizer.Add(demo2sizer, 1, wx.EXPAND|wx.TOP|wx.BOTTOM, 25)
	box3sizer.Add(demo3sizer, 1, wx.EXPAND|wx.TOP|wx.BOTTOM, 25)
	box4sizer.Add(demo4sizer, 1, wx.EXPAND|wx.TOP|wx.BOTTOM, 25)
	box5sizer.Add(demo5sizer, 1, wx.EXPAND|wx.TOP|wx.BOTTOM, 25)

	leftsizer = wx.BoxSizer(wx.VERTICAL)
	leftsizer.Add(boxsizer, 0, wx.EXPAND|wx.BOTTOM, 10)
	leftsizer.Add(box3sizer, 0, wx.EXPAND)
	addPtBtn = EMR_utilities.buildOneButton(self, self, "Add New Patient", self.OnAddPt)
	buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
	leftsizer.Add((-1, 25))
	buttonSizer.Add(addPtBtn, 0)
	rightsizer = wx.BoxSizer(wx.VERTICAL)
	rightsizer.Add(box2sizer, 0, wx.EXPAND|wx.BOTTOM, 10)
	rightsizer.Add(box4sizer, 0, wx.EXPAND|wx.BOTTOM, 10)
	rightsizer.Add(box5sizer, 0, wx.EXPAND)

	if ptID == None:
	    pass
	else:
	    results = EMR_utilities.getDictData('SELECT * FROM demographics WHERE patient_ID = %s;' % (ptID))
	    for label, size, field in self.labels:
		self.textctrl[label].SetValue(str(results[field]))
	    self.textctrl['Phone'].SetValue(EMR_formats.phone_format(self.textctrl['Phone'].GetValue()))
	    self.textctrl['Ins Phone'].SetValue(EMR_formats.phone_format(self.textctrl['Ins Phone'].GetValue()))
	    self.textctrl['Guarantor Phone'].SetValue(EMR_formats.phone_format(self.textctrl['Guarantor Phone'].GetValue()))
	    self.insChoice.SetStringSelection(self.textctrl['Insurance Co'].GetValue())
	    if results['adv_dir'] == '1':
		self.adv_dirYesRB.SetValue(True)
	    elif results['adv_dir'] == '2':
		self.adv_dirNoRB.SetValue(True)
	    else: 
		self.adv_dirUnknownRB.SetValue(True)
	    if results['proxy'] == '1':
		self.proxyBox.SetValue(1)
	    if results['marital_status'] == '1':
		self.marriedBox.SetValue(1)
	    if results['inactive'] == '1':
		self.inactiveBox.SetValue(1)
	    editPtBtn = EMR_utilities.buildOneButton(self, self, "Update Demographics", self.OnEditPt)
	    scanBtn = EMR_utilities.buildOneButton(self, self, "Scan", self.OnScan)
	    buttonSizer.Add(scanBtn, wx.ALL, 10)
	    buttonSizer.Add(editPtBtn, 0)

	leftsizer.Add(buttonSizer, 0)
	mainsizer = wx.BoxSizer(wx.HORIZONTAL)
	mainsizer.Add(leftsizer, 0, wx.RIGHT, 10)
	mainsizer.Add(rightsizer, 0, wx.EXPAND)
	self.SetSizer(mainsizer)
Esempio n. 27
0
    def __init__(self, parent, PtID):
        wx.Frame.__init__(self, parent, title='Add Consult', size=(700, 1000))
        
	self.PtID = PtID
	self.consultant = ''
	self.addSpecialist = 0	#need to keep track of whether Add Consultant button has been pushed

	#Controls created
	self.textctrl = {}
	reasonLBL = wx.StaticText(self, -1, 'Reason for consult')
	self.textctrl['reason'] = wx.TextCtrl(self, -1)

	memoLBL = wx.StaticText(self, -1, 'Further info...')
	self.textctrl['memo'] = wx.TextCtrl(self, -1, size=(-1,100), style=wx.TE_MULTILINE)

	dateLBL = wx.StaticText(self, -1, 'Date Due')
	self.cal = wx.calendar.CalendarCtrl(self, -1, wx.DateTime_Now(),\
                             style = wx.calendar.CAL_SHOW_HOLIDAYS
                             | wx.calendar.CAL_SUNDAY_FIRST
                             | wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION)
	self.Bind(wx.calendar.EVT_CALENDAR, self.OnCalSelected, self.cal)
	self.Bind(wx.calendar.EVT_CALENDAR_SEL_CHANGED, self.OnCalSelected, self.cal)
	self.textctrl['Due Date'] = ''	#not actually a text ctrl but don't need it; just holds date after cal selected
	
	self.tree_ctrl = wx.TreeCtrl(self, -1, style=wx.TR_DEFAULT_STYLE | \
                                wx.TR_FULL_ROW_HIGHLIGHT | \
                                wx.TR_EDIT_LABELS)
	specialties = EMR_utilities.getAllData('SELECT DISTINCT specialty FROM consultants ORDER BY specialty;')
	self.root = self.tree_ctrl.AddRoot('Pick a specialist')
	for items in specialties:
	    try:
		child = self.tree_ctrl.AppendItem(self.root, items[0])
		doctors = EMR_utilities.getAllData('SELECT firstname, lastname, address, city, state FROM consultants WHERE specialty = "%s";' % items[0])
		for n in doctors:
		    doc = self.tree_ctrl.AppendItem(child, '%s %s, %s, %s, %s' % (n[0], n[1], n[2], n[3], n[4]))
	    except: print 'there was an error in the specialist window'
	self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, self.tree_ctrl)


	nameLBL = wx.StaticText(self, -1, 'First/Last Name')
	self.textctrl['firstname'] = wx.TextCtrl(self, -1, size=(150,-1))
	self.textctrl['lastname'] = wx.TextCtrl(self, -1, size=(150,-1))

	addrLBL = wx.StaticText(self, -1, 'Address')
	self.textctrl['address'] = wx.TextCtrl(self, -1)

	cszLBL = wx.StaticText(self, -1, 'City, State, Zip')
	self.textctrl['city'] = wx.TextCtrl(self, -1, size=(150,-1))
	self.textctrl['state'] = wx.TextCtrl(self, -1, size=(50,-1))
	self.textctrl['zipcode'] = wx.TextCtrl(self, -1, size=(70,-1))

	phoneLBL = wx.StaticText(self, -1, 'Phone/Fax')
	self.textctrl['phonenumber'] = wx.TextCtrl(self, -1)
	self.textctrl['fax'] = wx.TextCtrl(self, -1)

	specLBL = wx.StaticText(self, -1, 'Specialty')
	self.textctrl['specialty'] = wx.TextCtrl(self, -1)
	
	conButton = wx.Button(self, -1, label='Add Consultant')
	doneButton = wx.Button(self, -1, label='Done')
        conButton.Bind(wx.EVT_BUTTON, self.add_consultant)
	doneButton.Bind(wx.EVT_BUTTON, self.OnDone)
	
	#Now the layout

        # the top level sizer is called mainSizer
	mainSizer = wx.BoxSizer(wx.VERTICAL)
	
	#sizer for top part of frame is topSizer
	topSizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
	topSizer.AddGrowableCol(1)
	topSizer.Add(reasonLBL, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	topSizer.Add(self.textctrl['reason'], 0, wx.EXPAND)
	topSizer.Add(memoLBL, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	topSizer.Add(self.textctrl['memo'], 0, wx.EXPAND)
	topSizer.Add(dateLBL, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	topSizer.Add(self.cal, 0)
	mainSizer.Add(topSizer, 0, wx.EXPAND|wx.ALL, 10)
	
	#middle part of frame is the tree control of consultants
	mainSizer.Add(self.tree_ctrl, 1, wx.EXPAND|wx.ALL, 5)

	#bottom part we add new consultants
        #similar flexgridsizer to the top
	addConsultFlexGridSizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
	addConsultFlexGridSizer.AddGrowableCol(1)

	
	addConsultFlexGridSizer.Add(nameLBL, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	#name needs a horizontal sub-sizer
	nameSizer = wx.BoxSizer(wx.HORIZONTAL)
	nameSizer.Add(self.textctrl['firstname'], 1, wx.RIGHT, 5)
        nameSizer.Add(self.textctrl['lastname'], 1)
	addConsultFlexGridSizer.Add(nameSizer, 0, wx.EXPAND)

	addConsultFlexGridSizer.Add(addrLBL, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	addConsultFlexGridSizer.Add(self.textctrl['address'], 0, wx.EXPAND)

	addConsultFlexGridSizer.Add(cszLBL, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	#city, state, zip needs a horizontal sub-sizer
	cszSizer = wx.BoxSizer(wx.HORIZONTAL)
	cszSizer.Add(self.textctrl['city'], 1)
	cszSizer.Add(self.textctrl['state'], 0, wx.LEFT|wx.RIGHT, 5)
	cszSizer.Add(self.textctrl['zipcode'])
	addConsultFlexGridSizer.Add(cszSizer, 0, wx.EXPAND)

	addConsultFlexGridSizer.Add(phoneLBL, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	#phone/fax need horizontal sub-sizer
	phoneSizer = wx.BoxSizer(wx.HORIZONTAL)
	phoneSizer.Add(self.textctrl['phonenumber'], 1, wx.RIGHT, 5)
        phoneSizer.Add(self.textctrl['fax'], 1)
	addConsultFlexGridSizer.Add(phoneSizer, 0, wx.EXPAND)

	addConsultFlexGridSizer.Add(specLBL, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
	addConsultFlexGridSizer.Add(self.textctrl['specialty'], 0, wx.EXPAND)

	#add addConsultFlexGridSizer to mainSizer
	mainSizer.Add(addConsultFlexGridSizer, 0, wx.EXPAND|wx.ALL, 10)
	
	#add buttons with horizontal sizer
	buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
	buttonSizer.Add(doneButton, 1)
	buttonSizer.Add(conButton, 1)
        mainSizer.Add(buttonSizer, 0, wx.EXPAND|wx.ALL)
        self.SetSizer(mainSizer)

	self.Centre()
Esempio n. 28
0
    def __init__(self, parent, PtID):
        wx.Frame.__init__(self, parent, title='Add Consult', size=(700, 1000))

        self.PtID = PtID
        self.consultant = ''
        self.addSpecialist = 0  #need to keep track of whether Add Consultant button has been pushed

        #Controls created
        self.textctrl = {}
        reasonLBL = wx.StaticText(self, -1, 'Reason for consult')
        self.textctrl['reason'] = wx.TextCtrl(self, -1)

        memoLBL = wx.StaticText(self, -1, 'Further info...')
        self.textctrl['memo'] = wx.TextCtrl(self,
                                            -1,
                                            size=(-1, 100),
                                            style=wx.TE_MULTILINE)

        dateLBL = wx.StaticText(self, -1, 'Date Due')
        self.cal = wx.calendar.CalendarCtrl(self, -1, wx.DateTime_Now(),\
                                    style = wx.calendar.CAL_SHOW_HOLIDAYS
                                    | wx.calendar.CAL_SUNDAY_FIRST
                                    | wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION)
        self.Bind(wx.calendar.EVT_CALENDAR, self.OnCalSelected, self.cal)
        self.Bind(wx.calendar.EVT_CALENDAR_SEL_CHANGED, self.OnCalSelected,
                  self.cal)
        self.textctrl[
            'Due Date'] = ''  #not actually a text ctrl but don't need it; just holds date after cal selected

        self.tree_ctrl = wx.TreeCtrl(self, -1, style=wx.TR_DEFAULT_STYLE | \
                                       wx.TR_FULL_ROW_HIGHLIGHT | \
                                       wx.TR_EDIT_LABELS)
        specialties = EMR_utilities.getAllData(
            'SELECT DISTINCT specialty FROM consultants ORDER BY specialty;')
        self.root = self.tree_ctrl.AddRoot('Pick a specialist')
        for items in specialties:
            try:
                child = self.tree_ctrl.AppendItem(self.root, items[0])
                doctors = EMR_utilities.getAllData(
                    'SELECT firstname, lastname, address, city, state FROM consultants WHERE specialty = "%s";'
                    % items[0])
                for n in doctors:
                    doc = self.tree_ctrl.AppendItem(
                        child,
                        '%s %s, %s, %s, %s' % (n[0], n[1], n[2], n[3], n[4]))
            except:
                print 'there was an error in the specialist window'
        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, self.tree_ctrl)

        nameLBL = wx.StaticText(self, -1, 'First/Last Name')
        self.textctrl['firstname'] = wx.TextCtrl(self, -1, size=(150, -1))
        self.textctrl['lastname'] = wx.TextCtrl(self, -1, size=(150, -1))

        addrLBL = wx.StaticText(self, -1, 'Address')
        self.textctrl['address'] = wx.TextCtrl(self, -1)

        cszLBL = wx.StaticText(self, -1, 'City, State, Zip')
        self.textctrl['city'] = wx.TextCtrl(self, -1, size=(150, -1))
        self.textctrl['state'] = wx.TextCtrl(self, -1, size=(50, -1))
        self.textctrl['zipcode'] = wx.TextCtrl(self, -1, size=(70, -1))

        phoneLBL = wx.StaticText(self, -1, 'Phone/Fax')
        self.textctrl['phonenumber'] = wx.TextCtrl(self, -1)
        self.textctrl['fax'] = wx.TextCtrl(self, -1)

        specLBL = wx.StaticText(self, -1, 'Specialty')
        self.textctrl['specialty'] = wx.TextCtrl(self, -1)

        conButton = wx.Button(self, -1, label='Add Consultant')
        doneButton = wx.Button(self, -1, label='Done')
        conButton.Bind(wx.EVT_BUTTON, self.add_consultant)
        doneButton.Bind(wx.EVT_BUTTON, self.OnDone)

        #Now the layout

        # the top level sizer is called mainSizer
        mainSizer = wx.BoxSizer(wx.VERTICAL)

        #sizer for top part of frame is topSizer
        topSizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
        topSizer.AddGrowableCol(1)
        topSizer.Add(reasonLBL, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        topSizer.Add(self.textctrl['reason'], 0, wx.EXPAND)
        topSizer.Add(memoLBL, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        topSizer.Add(self.textctrl['memo'], 0, wx.EXPAND)
        topSizer.Add(dateLBL, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        topSizer.Add(self.cal, 0)
        mainSizer.Add(topSizer, 0, wx.EXPAND | wx.ALL, 10)

        #middle part of frame is the tree control of consultants
        mainSizer.Add(self.tree_ctrl, 1, wx.EXPAND | wx.ALL, 5)

        #bottom part we add new consultants
        #similar flexgridsizer to the top
        addConsultFlexGridSizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
        addConsultFlexGridSizer.AddGrowableCol(1)

        addConsultFlexGridSizer.Add(nameLBL, 0,
                                    wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        #name needs a horizontal sub-sizer
        nameSizer = wx.BoxSizer(wx.HORIZONTAL)
        nameSizer.Add(self.textctrl['firstname'], 1, wx.RIGHT, 5)
        nameSizer.Add(self.textctrl['lastname'], 1)
        addConsultFlexGridSizer.Add(nameSizer, 0, wx.EXPAND)

        addConsultFlexGridSizer.Add(addrLBL, 0,
                                    wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        addConsultFlexGridSizer.Add(self.textctrl['address'], 0, wx.EXPAND)

        addConsultFlexGridSizer.Add(cszLBL, 0,
                                    wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        #city, state, zip needs a horizontal sub-sizer
        cszSizer = wx.BoxSizer(wx.HORIZONTAL)
        cszSizer.Add(self.textctrl['city'], 1)
        cszSizer.Add(self.textctrl['state'], 0, wx.LEFT | wx.RIGHT, 5)
        cszSizer.Add(self.textctrl['zipcode'])
        addConsultFlexGridSizer.Add(cszSizer, 0, wx.EXPAND)

        addConsultFlexGridSizer.Add(phoneLBL, 0,
                                    wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        #phone/fax need horizontal sub-sizer
        phoneSizer = wx.BoxSizer(wx.HORIZONTAL)
        phoneSizer.Add(self.textctrl['phonenumber'], 1, wx.RIGHT, 5)
        phoneSizer.Add(self.textctrl['fax'], 1)
        addConsultFlexGridSizer.Add(phoneSizer, 0, wx.EXPAND)

        addConsultFlexGridSizer.Add(specLBL, 0,
                                    wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        addConsultFlexGridSizer.Add(self.textctrl['specialty'], 0, wx.EXPAND)

        #add addConsultFlexGridSizer to mainSizer
        mainSizer.Add(addConsultFlexGridSizer, 0, wx.EXPAND | wx.ALL, 10)

        #add buttons with horizontal sizer
        buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
        buttonSizer.Add(doneButton, 1)
        buttonSizer.Add(conButton, 1)
        mainSizer.Add(buttonSizer, 0, wx.EXPAND | wx.ALL)
        self.SetSizer(mainSizer)

        self.Centre()
Esempio n. 29
0
def todo_find(PtID, toggle=0):
    qry = 'SELECT date, description, priority, category, memo, due_date, complete, todo_number FROM todo WHERE patient_ID = %s AND complete = %s;' % (
        PtID, toggle)
    return EMR_utilities.getAllData(qry)
Esempio n. 30
0
 def loadList(self):
     # self.listctrl.Set("")
     qry = "SELECT * FROM education WHERE patient_ID = %s ORDER BY date DESC;" % (self.PtID)
     self.results = EMR_utilities.getAllData(qry)
     for items in self.results:
         self.listctrl.Append(str(items[3]))
Esempio n. 31
0
def todo_find(PtID, toggle=0):
    qry = 'SELECT date, description, priority, category, memo, due_date, complete, todo_number FROM todo WHERE patient_ID = %s AND complete = %s;' % (PtID, toggle)
    return EMR_utilities.getAllData(qry)