def OnEditPt(self, event): self.textctrl['Insurance Co'].SetValue(self.insChoice.GetStringSelection()) checkBoxes = '' if self.adv_dirYesRB.GetValue() == True: checkBoxes = ' adv_dir = "1",' elif self.adv_dirNoRB.GetValue() == True: checkBoxes = ' adv_dir = "2",' else: checkBoxes = ' adv_dir = "0",' if self.proxyBox.IsChecked(): checkBoxes = checkBoxes + ' proxy = "1",' else: checkBoxes = checkBoxes + ' proxy = "0",' if self.marriedBox.IsChecked(): checkBoxes = checkBoxes + ' marital_status = "1",' else: checkBoxes = checkBoxes + ' marital_status = "0",' if self.inactiveBox.IsChecked(): checkBoxes = checkBoxes + ' inactive = "1",' else: checkBoxes = checkBoxes + ' inactive = "0",' qry = 'UPDATE demographics SET' + checkBoxes for label, size, field in self.labels: qry = ' '.join([qry, '%s = "%s",' % (field, self.textctrl[label].GetValue())]) qry = qry.rstrip(',') + ' WHERE patient_ID = %s;' % (self.ptID) EMR_utilities.updateData(qry)
def OnAddPt(self, event): self.textctrl['Insurance Co'].SetValue(self.insChoice.GetStringSelection()) checkBoxes = '' if self.adv_dirYesRB.GetValue() == True: checkBoxes = ' adv_dir = "1",' elif self.adv_dirNoRB.GetValue() == True: checkBoxes = ' adv_dir = "2",' else: checkBoxes = ' adv_dir = "0",' if self.proxyBox.IsChecked(): checkBoxes = checkBoxes + ' proxy = "1",' if self.marriedBox.IsChecked(): checkBoxes = checkBoxes + ' marital_status = "1",' qry = 'INSERT INTO demographics SET' + checkBoxes for label, size, field in self.labels: qry = ' '.join([qry, '%s = "%s",' % (field, self.textctrl[label].GetValue())]) qry = qry.rstrip(',') + ';' #check to make sure patient doesn't already exist dupCheck = 'SELECT firstname, lastname, dob FROM demographics WHERE firstname = "%s" AND lastname = "%s";' \ % (self.textctrl['First Name'].GetValue(), self.textctrl['Last Name'].GetValue()) dupResults = EMR_utilities.getData(dupCheck) if dupResults: wx.MessageBox("A patient with this name already exists.", 'DUPLICATE', wx.OK) else: EMR_utilities.updateData(qry) pt_ID = EMR_utilities.getData("SELECT LAST_INSERT_ID();") UpdoxImporter.Importer(str(pt_ID[0]))
def OnDelPrevent(self, event): obj = self.preventList.GetSelectedObjects() for items in obj: qry = 'DELETE FROM prevents2 WHERE prevent_number = %s;' % items[ 'prevent_number'] self.preventList.RemoveObject(items) EMR_utilities.updateData(qry)
def OnDelVaccine(self, event): obj = self.vaccineList.GetSelectedObjects() for items in obj: qry = 'DELETE FROM vaccines WHERE vaccine_number = %s;' % items[ 'vaccine_number'] self.vaccineList.RemoveObject(items) EMR_utilities.updateData(qry)
def OnOk(self, event): qry = 'INSERT INTO todo SET date = "%s", description = "%s", priority = "%s", category = "%s", memo = "%s", due_date = "%s", complete = "0", patient_ID = %s;' % (self.textctrl['Date'].GetValue(), self.textctrl['Description'].GetValue(), self.textctrl['Priority'].GetValue(), self.textctrl['Category'].GetValue(), self.textctrl['Memo'].GetValue(), self.textctrl['Due Date'].GetValue(), self.PtID) EMR_utilities.updateData(qry) EMR_utilities.updateList(todo_find(self.PtID), self.List)
def OnRemAll(self, event): obj = self.allergylist.GetSelectedObjects() for items in obj: qry = 'DELETE FROM allergies WHERE allergy_number = %s;' % items[ 'allergy_number'] self.allergylist.RemoveObject(items) EMR_utilities.updateData(qry)
def OnArchMed(self, event): #need add/edit form pulled up on selected meds, update query, requery meds #open AddEditMed form with selected/checked med filled in obj = self.list.GetSelectedObjects() for items in obj: qry = 'UPDATE meds SET archive = 1 WHERE med_number = %s;' % items['med_number'] self.list.RemoveObject(items) EMR_utilities.updateData(qry)
def OnDeleteMed(self, event): obj = self.list.GetSelectedObjects() for items in obj: qry = 'DELETE FROM meds WHERE med_number = %s;' % items[ 'med_number'] self.list.RemoveObject(items) EMR_utilities.updateData(qry)
def OnRemProb(self, event): obj = self.problist.GetSelectedObjects() for items in obj: qry = 'DELETE FROM problems10 WHERE problem_number = %s;' % items[ 'problem_number'] self.problist.RemoveObject(items) EMR_utilities.updateData(qry)
def OnComplete(self, event): num = self.todo_list.GetItemCount() for i in range(num): if i == 0: pass if self.todo_list.IsChecked(i): qry = 'UPDATE todo SET complete = 1 WHERE todo_number = %s;' % (self.todo_list.GetItem(i, 7).GetText()) EMR_utilities.updateData(qry) self.todo_list.DeleteItem(i)
def add_consultant(self, evt): qry = "INSERT INTO consultants SET firstname = '%s', lastname = '%s', address = '%s', city = '%s', state = '%s', zipcode = '%s', phone = '%s', fax = '%s', specialty = '%s';" % \ (self.textctrl['firstname'].GetValue(), self.textctrl['lastname'].GetValue(), self.textctrl['address'].GetValue(), \ self.textctrl['city'].GetValue(), self.textctrl['state'].GetValue(), self.textctrl['zipcode'].GetValue(), \ self.textctrl['phonenumber'].GetValue(), self.textctrl['fax'].GetValue(), self.textctrl['specialty'].GetValue()) EMR_utilities.updateData(qry) self.consultant = self.textctrl['firstname'].GetValue() + ' ' + self.textctrl['lastname'].GetValue() + ',' self.addSpecialist = 1 #tells whether Add Consultant button has been pushed
def OnComplete(self, event): num = self.todo_list.GetItemCount() for i in range(num): if i == 0: pass if self.todo_list.IsChecked(i): qry = 'UPDATE todo SET complete = 1 WHERE todo_number = %s;' % ( self.todo_list.GetItem(i, 7).GetText()) EMR_utilities.updateData(qry) self.todo_list.DeleteItem(i)
def add_consultant(self, evt): qry = "INSERT INTO consultants SET firstname = '%s', lastname = '%s', address = '%s', city = '%s', state = '%s', zipcode = '%s', phone = '%s', fax = '%s', specialty = '%s';" % \ (self.textctrl['firstname'].GetValue(), self.textctrl['lastname'].GetValue(), self.textctrl['address'].GetValue(), \ self.textctrl['city'].GetValue(), self.textctrl['state'].GetValue(), self.textctrl['zipcode'].GetValue(), \ self.textctrl['phonenumber'].GetValue(), self.textctrl['fax'].GetValue(), self.textctrl['specialty'].GetValue()) EMR_utilities.updateData(qry) self.consultant = self.textctrl['firstname'].GetValue( ) + ' ' + self.textctrl['lastname'].GetValue() + ',' self.addSpecialist = 1 #tells whether Add Consultant button has been pushed
def OnNewAll(self, event): allergy = wx.GetTextFromUser('What is the patient allergic to?', 'New Allergy') if allergy == "": pass else: reaction = wx.GetTextFromUser('What happened?', 'Reaction') query = 'INSERT INTO allergies SET allergy = "%s", reaction = "%s", patient_ID = %s;' % \ (allergy, reaction, self.ptID) EMR_utilities.updateData(query) self.UpdateAllergy()
def OnRemove(self, event): num = self.todo_list.GetItemCount() for i in range(num): if i == 0: pass if self.todo_list.IsChecked(i): qry = 'DELETE FROM todo WHERE todo_number = %s;' % (self.todo_list.GetItem(i, 7).GetText()) EMR_utilities.updateData(qry) self.todo_list.DeleteItem(i)
def OnAddPrevent(self, event): prev = wx.GetTextFromUser('What is the new health maintance item?', 'Health Maintenance') if prev == "": pass else: note = wx.GetTextFromUser('Any notes?', 'Notes') query = 'INSERT INTO prevents2 SET prevent_name = "%s", date = "%s", reason = "normal", p_interval = 1, notes = "%s", patient_ID = %s;' % \ (prev, EMR_utilities.dateToday(), note, self.ptID) EMR_utilities.updateData(query) self.UpdatePrevents()
def OnOk(self, event): qry = 'INSERT INTO todo SET date = "%s", description = "%s", priority = "%s", category = "%s", memo = "%s", due_date = "%s", complete = "0", patient_ID = %s;' % ( self.textctrl['Date'].GetValue(), self.textctrl['Description'].GetValue(), self.textctrl['Priority'].GetValue(), self.textctrl['Category'].GetValue(), self.textctrl['Memo'].GetValue(), self.textctrl['Due Date'].GetValue(), self.PtID) EMR_utilities.updateData(qry) EMR_utilities.updateList(todo_find(self.PtID), self.List)
def OnRemove(self, event): num = self.todo_list.GetItemCount() for i in range(num): if i == 0: pass if self.todo_list.IsChecked(i): qry = 'DELETE FROM todo WHERE todo_number = %s;' % ( self.todo_list.GetItem(i, 7).GetText()) EMR_utilities.updateData(qry) self.todo_list.DeleteItem(i)
def OnArchMed( self, event ): #need add/edit form pulled up on selected meds, update query, requery meds #open AddEditMed form with selected/checked med filled in obj = self.list.GetSelectedObjects() for items in obj: qry = 'UPDATE meds SET archive = 1 WHERE med_number = %s;' % items[ 'med_number'] self.list.RemoveObject(items) EMR_utilities.updateData(qry)
def OnUpdate(self, event): qry = 'UPDATE billing SET' for label, size, field in self.cptLabels: qry = ' '.join( [qry, '%s = "%s",' % (field, self.textctrl[label].GetValue())]) qry = ' '.join([qry, 'notes = "%s" WHERE charge_number = %s;' % (self.textctrl['Notes'].GetValue(), \ self.textctrl['charge_number'].GetValue())]) EMR_utilities.updateData(qry) self.results = EMR_utilities.getAllDictData( 'SELECT * FROM billing WHERE note_number = %s;' % (self.noteID[0]))
def OnAddVaccine(self, event): vac = wx.GetTextFromUser('What is the new vaccine?', 'Vaccines') dates = wx.GetTextFromUser('What date(s) was vaccine given?', 'Vaccines') if vac == "": pass else: note = wx.GetTextFromUser('Any notes?', 'Notes') query = 'INSERT INTO vaccines SET vaccine = "%s", dates = "%s", notes = "%s", patient_ID = %s;' % \ (vac, dates, note, self.ptID) EMR_utilities.updateData(query) self.UpdateVaccines()
def OnNewProb(self, event): #opens dialog window with fields for new problem, does lookup based on description only, updates MySQL, #then clears the list and resets the lists with new query for problems dlg = AddProblemDialog(self, self, -1, 'New Problem') dlg.ProbInstance = self dlg.CenterOnScreen() if dlg.ShowModal() == wx.ID_OK: today = datetime.date.today() newICD = EMR_utilities.getData('SELECT icd10 FROM ICD10billable WHERE short_des = "%s";' % self.problem) query = 'INSERT INTO problems10 SET short_des = "%s", prob_date = "%s", patient_ID = "%s", icd10 = "%s";' % \ (self.problem, today, self.ptID, newICD[0]) EMR_utilities.updateData(query) self.UpdateList() dlg.Destroy()
def OnNewProb(self, event): #opens dialog window with fields for new problem, does lookup based on description only, updates MySQL, #then clears the list and resets the lists with new query for problems dlg = AddProblemDialog(self, self, -1, 'New Problem') dlg.ProbInstance = self dlg.CenterOnScreen() if dlg.ShowModal() == wx.ID_OK: today = datetime.date.today() newICD = EMR_utilities.getData( 'SELECT icd10 FROM ICD10billable WHERE short_des = "%s";' % self.problem) query = 'INSERT INTO problems10 SET short_des = "%s", prob_date = "%s", patient_ID = "%s", icd10 = "%s";' % \ (self.problem, today, self.ptID, newICD[0]) EMR_utilities.updateData(query) self.UpdateList() dlg.Destroy()
def OnEdit(self, event): num = self.todo_list.GetItemCount() items = [] n = 0 for i in range(num): if i == 0: pass if self.todo_list.IsChecked(i): qry = 'DELETE FROM todo WHERE todo_number = %s;' % (self.todo_list.GetItem(i, 7).GetText()) EMR_utilities.updateData(qry) for columns in range(self.todo_list.GetColumnCount()): items.append(self.todo_list.GetItem(i, columns).GetText()) self.todo_list.DeleteItem(i) ctrls = ['Date', 'Description', 'Priority', 'Category', 'Memo', 'Due Date'] for i in ctrls: self.addtodo.textctrl[i].SetValue(items[n]) n = n + 1
def OnEdit(self, event): num = self.todo_list.GetItemCount() items = [] n = 0 for i in range(num): if i == 0: pass if self.todo_list.IsChecked(i): qry = 'DELETE FROM todo WHERE todo_number = %s;' % ( self.todo_list.GetItem(i, 7).GetText()) EMR_utilities.updateData(qry) for columns in range(self.todo_list.GetColumnCount()): items.append(self.todo_list.GetItem(i, columns).GetText()) self.todo_list.DeleteItem(i) ctrls = [ 'Date', 'Description', 'Priority', 'Category', 'Memo', 'Due Date' ] for i in ctrls: self.addtodo.textctrl[i].SetValue(items[n]) n = n + 1
def UpdateVitals(self, event): updateqry = 'INSERT INTO vitals SET wt = "%s", ht = "%s", hc = "%s", temp = "%s", sBP = "%s", dBP = "%s", \ pulse = "%s", resp = "%s", sats = "%s", vitals_date = "%s", patient_ID = %s;' % (self.textctrl['Wt'].GetValue(), self.textctrl['Ht'].GetValue(), self.textctrl['HC'].GetValue(), self.textctrl['Temp'].GetValue(), self.textctrl['SBP'].GetValue(), self.textctrl['DBP'].GetValue(), self.textctrl['Pulse'].GetValue(), self.textctrl['Resp'].GetValue(), self.textctrl['O2 Sats'].GetValue(), self.textctrl['Date'].GetValue(), self.PtID) EMR_utilities.updateData(updateqry) self.UpdateList() data = EMR_utilities.getData("SELECT dob, sex FROM demographics WHERE patient_ID = %s;" % self.PtID) if data[1] == 'male': sex = 'boy' else: sex = 'girl' s = data[0].strftime("%B") + ',' + str(data[0].day) + ',' + str(data[0].year) + ',' + sex + ',' + \ self.textctrl['Ht'].GetValue() + ',' + self.textctrl['Wt'].GetValue() + ',' + self.textctrl['HC'].GetValue() with open('/home/mb/Dropbox/iMacros/Datasources/growth.txt', 'w') as f: f.write(s) f.close() self.Layout() #this line from C M and Robin Dunn on the mailing list; see 20 Feb 08 email for items in self.textctrl: self.textctrl[items].SetValue("")
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
def allergyHandleCellEditFinished(self, event): sqlstmt = 'UPDATE allergies SET %s = "%s" WHERE allergy_number = %s;' \ % (self.allergylist.columns[event.subItemIndex].valueGetter, self.allergylist.GetItem(event.rowIndex, event.subItemIndex).GetText(), event.rowModel["allergy_number"]) EMR_utilities.updateData(sqlstmt)
def __init__(self, parent, ptID): lt = "%s/EMR_outputs/%s/Orders/%s.pdf" % ( settings.LINUXPATH, ptID, EMR_utilities.dateToday('file format')) at = "%s/EMR_outputs/%s/Orders/%s.pdf" % ( settings.APPLEPATH, ptID, EMR_utilities.dateToday('file format')) wt = "%s\EMR_outputs\%s\Orders\%s.pdf" % ( settings.WINPATH, ptID, EMR_utilities.dateToday('file format')) filename = EMR_utilities.platformText(lt, at, wt) doc = SimpleDocTemplate(filename, pagesize=letter, topMargin=60) # container for the 'Flowable' objects elements = [] styleSheet = getSampleStyleSheet() styleSheet.add(ParagraphStyle(name='Address', fontSize=13, leading=15)) styleSheet.add(ParagraphStyle(name='Body', fontSize=12, leading=14)) dem_data = EMR_utilities.getDictData( 'SELECT * FROM demographics WHERE patient_ID = %s;' % ptID) dem_data['phonenumber'] = EMR_formats.phone_format( dem_data['phonenumber']) test_dlg = wx.TextEntryDialog(None, "What studies would you like to order?", "Studies", style=wx.TE_MULTILINE | wx.OK | wx.CANCEL) if test_dlg.ShowModal() == wx.ID_OK: dem_data['tests'] = test_dlg.GetValue() dem_data['date'] = EMR_utilities.dateToday() else: pass dx_dlg = wx.TextEntryDialog(None, "What is the diagnosis?", "Diagnosis", style=wx.TE_MULTILINE | wx.OK | wx.CANCEL) if dx_dlg.ShowModal() == wx.ID_OK: dem_data['dx'] = dx_dlg.GetValue() else: pass results_dlg = wx.TextEntryDialog(None, "Due Date?", style=wx.OK | wx.CANCEL) if results_dlg.ShowModal() == wx.ID_OK: dem_data['results_date'] = results_dlg.GetValue() else: pass qry = "INSERT INTO todo SET patient_ID = %s, date = '%s', description = '%s', priority = 3, \ category = 'Test', due_date = '%s', complete = 0;" % (ptID, EMR_utilities.dateToday(), \ dem_data['tests'], dem_data['results_date']) EMR_utilities.updateData(qry) styleSheet = getSampleStyleSheet() styleSheet.add(ParagraphStyle(name='Address', fontSize=13, leading=15)) styleSheet.add(ParagraphStyle(name='Body', fontSize=12, leading=14)) elements.append( Paragraph('<para align=CENTER>Barron Family Medicine</para>', styleSheet['Address'])) elements.append( Paragraph('<para align=CENTER>8515 Delmar Blvd #217</para>', styleSheet['Address'])) elements.append( Paragraph('<para align=CENTER>University City, MO 63124</para>', styleSheet['Address'])) elements.append( Paragraph( '<para align=CENTER>(314)667-5276 fax:(314)677-3838</para>', styleSheet['Address'])) elements.append( Paragraph( '<para align=CENTER>Quest #33007741, Labcorp #24864540</para>', styleSheet['Address'])) elements.append(Spacer(1, 48)) elements.append( Paragraph( '<para align=RIGHT>%s</para>' % EMR_utilities.dateToday(t='display'), styleSheet['Body'])) elements.append(Spacer(1, 48)) elements.append( Paragraph('%(firstname)s %(lastname)s' % dem_data, styleSheet['Body'])) elements.append(Paragraph('%(address)s' % dem_data, styleSheet['Body'])) elements.append( Paragraph('%(city)s, %(state)s %(zipcode)s' % dem_data, styleSheet['Body'])) elements.append( Paragraph('%(phonenumber)s' % dem_data, styleSheet['Body'])) elements.append( Paragraph('DOB: %(dob)s' % dem_data, styleSheet['Body'])) elements.append(Spacer(1, 36)) elements.append(Paragraph('<U>Tests:</U>', styleSheet['Address'])) elements.append(Spacer(1, 12)) elements.append(Paragraph(dem_data['tests'], styleSheet['Body'])) elements.append(Spacer(1, 24)) elements.append(Paragraph('<U>Diagnosis:</U>', styleSheet['Address'])) elements.append(Spacer(1, 12)) elements.append(Paragraph(dem_data['dx'], styleSheet['Body'])) elements.append(Spacer(1, 96)) #elements.append(Spacer(1, 48)) #If you want the signature automatically then can un-comment these lines. For now I will sign all. #logo = "/home/mb/Dropbox/Office/Signature.png" #im = Image(logo, 2*inch, 0.75*inch) #im.hAlign = "LEFT" #elements.append(im) chooseSig(elements) elements.append(Paragraph(settings.NAME, styleSheet['Body'])) # write the document to disk doc.build(elements) choosePrinter(filename)
def preventListHandleCellEditFinished(self, event): sqlstmt = 'UPDATE prevents2 SET %s = "%s" WHERE prevent_number = %s;' \ % (self.preventList.columns[event.subItemIndex].valueGetter, self.preventList.GetItem(event.rowIndex, event.subItemIndex).GetText(), event.rowModel["prevent_number"]) EMR_utilities.updateData(sqlstmt)
def OnRemProb(self, event): obj = self.problist.GetSelectedObjects() for items in obj: qry = 'DELETE FROM problems10 WHERE problem_number = %s;' % items.problem_number self.problist.RemoveObject(items) EMR_utilities.updateData(qry)
def HandleCellEditFinished(self, event): sqlstmt = 'UPDATE problems10 SET short_des = "%s" WHERE problem_number = %s;' \ % (self.problist.GetItem(event.rowIndex, event.subItemIndex).GetText(), event.rowModel["problem_number"]) EMR_utilities.updateData(sqlstmt)
def OnDone(self, event): #create file prnt = wx.GetTopLevelParent(self.myparent) #dem_page = parent.nb.GetPage(1) #figured this out using PyCrust (*this will mess up if you have extra pages*) path = EMR_utilities.getData( "SELECT home_dir FROM users WHERE user_name = '%s'" % prnt.user) linuxpath = "/home/%s/Desktop/GECKO/Billing/OfficeAlly" % path[ 0] + "_%s.txt" applepath = "/Users/%s/Desktop/GECKO/Billing/OfficeAlly" % path[ 0] + "_%s.txt" windowspath = "C:\\Documents and Settings\\%s\\My Documents\\GECKO\\Billing\\OfficeAlly" % path[ 0] + "_%s.txt" daily_billing = EMR_utilities.platformText( linuxpath, applepath, windowspath) % EMR_utilities.dateToday() a_file = open( daily_billing, 'a') #'a' will both append to existing and create if nonexistent gateway_file = open( "/home/%s/Desktop/GECKO/Billing/Gateway" % settings.HOME_FOLDER + "%s.txt" % EMR_utilities.dateToday(), 'a') #get demographic and insurance data insFields = (('InsurancePlanName', 1), ('InsurancePayerID', 2), ('InsuranceStreetAddr', 3), ('InsuranceCity', 4), \ ('InsuranceState', 5), ('InsuranceZip', 6), ('InsuranceCityStateZip', 7), ('InsurancePhone', 8)) fields = (('lastname', 17), ('firstname', 18), ('mid_init', 19), ('dob', 20), ('address', 26), \ ('city', 27), ('state', 28), ('zipcode', 29), ('phonenumber', 30), ('sof', 72), \ \ ('policy_ID', 16), ('InsuredLast', 23), ('InsuredFirst', 24), ('InsuredMidInit', 25), \ ('InsuredStreetAddress', 35), ('InsuredCity', 36), ('InsuredState', 37), \ ('InsuredZip', 38), ('InsuredPhone', 39), \ ('InsuredPolicyGroupOrFecaNumber', 63), ('InsuredDOB', 64), \ ('InsuredEmployerNameOrSchoolName', 67), ('InsuredInsurancePlanNameOrProgramName', 68), \ \ ('OtherInsuredLast', 46), ('OtherInsuredFirst', 47), ('OtherInsuredMidInit', 48), \ ('OtherInsuredPolicyOrGroupNumber', 49), ('OtherInsuredDOB', 50), \ ('OtherInsuredEmployerNameOrSchoolName', 53), ('OtherInsuredInsurancePlanOrProgramName', 54)) insQry = "SELECT * FROM ins_companies WHERE InsurancePlanName = '%s';" % self.whichIns insResults = EMR_utilities.getDictData(insQry) self.printImageDict.update( insResults) #adds more necessary data for print image self.createOADict(insFields, insResults) self.createOADict(fields, self.ptResults) self.get1500Data() self.columns[269] = self.columns[267] - self.columns[268] #BalanceDue if self.billSecInsBox.IsChecked(): EMR_utilities.updateData('UPDATE billing SET 2ndDate = CURDATE() \ WHERE note_number = %s;' % (self.noteNumber)) self.columns[16] = self.ptResults[ 'secondary_ins_ID'] #replaces the primary ins ID self.columns[63] = self.ptResults[ 'sec_PolicyGroupOrFecaNumber'] #replaces primary ins policy number if self.billSecAsPrim.IsChecked( ): #allows billing secondary as primary pass else: self.columns[1] = self.columns[ 1] + ' secondary' #this is how OA does sec ins billing else: EMR_utilities.updateData('UPDATE billing SET 1stDate = CURDATE() \ WHERE note_number = %s;' % (self.noteNumber)) if self.hospAdmBox.IsChecked( ): #checks to make sure dates are filled in if not self.columns[83]: self.columns[83] = EMR_utilities.dateToday('OA') if not self.columns[84]: self.columns[84] = EMR_utilities.dateToday('OA') for n in range( 1, 292): #remove all the None entries which OA doesn't like if self.columns[n] == None: self.columns[n] = '' else: pass for n in range(1, 292): a_file.write(str(self.columns[n]) + '\t') a_file.write('\n') """Print image for Gateway EDI""" self.printImageDict['Name'] = self.printImageDict[ 'lastname'] + ', ' + self.printImageDict['firstname'] self.printImageDict['InsuredName'] = self.printImageDict[ 'InsuredLast'] + ', ' + self.printImageDict['InsuredFirst'] self.printImageDict['InsuranceCityStateZip'] = insResults['InsuranceCity'] + ', ' + insResults['InsuranceState'] + ' ' \ + insResults['InsuranceZip'] self.printImageDict['Medicare'] = self.columns[9] self.printImageDict['Medicaid'] = self.columns[10] self.printImageDict['Other'] = self.columns[15] self.printImageDict['self'] = self.columns[31] self.printImageDict['spouse'] = self.columns[32] self.printImageDict['child'] = self.columns[33] self.printImageDict['other'] = self.columns[34] self.printImageDict['empl_no'] = self.columns[56] self.printImageDict['auto_no'] = self.columns[58] self.printImageDict['other_no'] = self.columns[61] self.printImageDict['empl_yes'] = self.columns[55] self.printImageDict['auto_yes'] = self.columns[57] self.printImageDict['other_yes'] = self.columns[60] self.printImageDict['auto_state'] = self.columns[59] self.printImageDict['icd1'] = self.columns[89] self.printImageDict['icd2'] = self.columns[90] self.printImageDict['icd3'] = self.columns[91] self.printImageDict['icd4'] = self.columns[92] self.printImageDict['icd5'] = self.columns[93] self.printImageDict['icd6'] = self.columns[94] self.printImageDict['icd7'] = self.columns[95] self.printImageDict['icd8'] = self.columns[96] dateList = [ 'dob', 'sof', 'Admit', 'DC', '101', '117', '133', '149', '165', '181' ] for item in dateList: #fixes problem with dates not showing up on print image try: self.printImageDict[item] = self.printImageDict[item].strftime( "%m %d %y") except: self.printImageDict[item] = self.printImageDict[item].replace( '/', ' ') self.printImageDict['sig'] = 'Signature on File' self.printImageDict['267'] = str( self.columns[267] ) #total charges converting decimal.decimal to string self.printImageDict['268'] = str( self.columns[268]) #this is amount paid, same as above #this brings in secondary/other insurance info if present if self.ptResults['secondary_ins']: self.printImageDict['OtherInsuredDOB'] = self.printImageDict['dob'] self.printImageDict['OtherName'] = self.printImageDict['Name'] self.printImageDict['Taxonomy'] = '207Q00000X' self.printImageDict['CLIA'] = '26D2013625' myMap = { 1: ((49, 'InsurancePlanName'), ), 2: ((49, 'InsuranceStreetAddr'), ), 3: ((49, 'InsuranceCityStateZip'), ), 4: ((49, 'InsurancePayerID'), ), 7: ((2, 'Medicare'), (12, 'Medicaid'), (47, 'Other'), (51, 'policy_ID')), 9: ((2, 'Name'), (31, 'dob'), (44, 'msex'), (48, 'fsex'), (51, 'InsuredName')), 11: ((2, 'address'), (33, 'self'), (35, 'spouse'), (37, 'child'), (39, 'other'), (51, 'InsuredStreetAddress')), 13: ((2, 'city'), (28, 'state'), (51, 'InsuredCity'), (74, 'InsuredState')), 15: ((2, 'zipcode'), (16, 'phonenumber'), (51, 'InsuredZip'), (66, 'InsuredPhone')), 17: ((2, 'OtherName'), (51, 'InsuredPolicyGroupOrFecaNumber')), 19: ((2, 'secondary_ins_ID'), (38, 'empl_yes'), (42, 'empl_no')), 21: ((2, 'OtherInsuredDOB'), (38, 'auto_yes'), (42, 'auto_no'), (45, 'auto_state')), 23: ((38, 'other_yes'), (42, 'other_no'), (51, 'InsuredInsurancePlanNameOrProgramName')), 25: ((2, 'secondary_ins'), ), 29: ((9, 'sig'), (39, 'sof'), (59, 'sig')), 33: ((60, 'Admit'), (72, 'DC')), #37:((4, 'icd1'), (31, 'icd3')), 37: ((4, 'icd1'), (10, 'icd3'), (16, 'icd5'), (22, 'icd7'), (28, 'icd9')), #39:((4, 'icd2'), (31, 'icd4'), (51, 'CLIA')), 39: ((4, 'icd2'), (10, 'icd4'), (16, 'icd6'), (22, 'icd8'), (28, 'icd10'), (51, 'CLIA')), #42:((2, '101'), (21, '103'), (27, '105'), (34, '106'), (37, '107'), (40, '108'), (43, '109'), (47, '110'), (54, '111'), (61, '112'), (71, '116')), #44:((2, '117'), (21, '119'), (27, '121'), (34, '122'), (37, '123'), (40, '124'), (43, '125'), (47, '126'), (54, '127'), (61, '128'), (71, '132')), #46:((2, '133'), (21, '135'), (27, '137'), (34, '138'), (37, '139'), (40, '140'), (43, '141'), (47, '142'), (54, '143'), (61, '144'), (71, '148')), #48:((2, '149'), (21, '151'), (27, '153'), (34, '154'), (37, '155'), (40, '156'), (43, '157'), (47, '158'), (54, '159'), (61, '160'), (71, '164')), #50:((2, '165'), (21, '167'), (27, '169'), (34, '170'), (37, '171'), (40, '172'), (43, '173'), (47, '174'), (54, '175'), (61, '176'), (71, '180')), #52:((2, '181'), (21, '183'), (27, '185'), (34, '186'), (37, '187'), (40, '188'), (43, '189'), (47, '190'), (54, '191'), (61, '192'), (71, '196')), 42: ((2, '101'), (21, '103'), (27, '105'), (34, '106'), (37, '107'), (40, '108'), (43, '109'), (47, '110'), (59, '111'), (66, '112'), (76, '116')), 44: ((2, '117'), (21, '119'), (27, '121'), (34, '122'), (37, '123'), (40, '124'), (43, '125'), (47, '126'), (59, '127'), (66, '128'), (76, '132')), 46: ((2, '133'), (21, '135'), (27, '137'), (34, '138'), (37, '139'), (40, '140'), (43, '141'), (47, '142'), (59, '143'), (66, '144'), (76, '148')), 48: ((2, '149'), (21, '151'), (27, '153'), (34, '154'), (37, '155'), (40, '156'), (43, '157'), (47, '158'), (59, '159'), (66, '160'), (76, '164')), 50: ((2, '165'), (21, '167'), (27, '169'), (34, '170'), (37, '171'), (40, '172'), (43, '173'), (47, '174'), (59, '175'), (66, '176'), (76, '180')), 52: ((2, '181'), (21, '183'), (27, '185'), (34, '186'), (37, '187'), (40, '188'), (43, '189'), (47, '190'), (59, '191'), (66, '192'), (76, '196')), 53: ((2, '261'), (18, '262'), (24, '264'), (40, '265'), (56, '267')), 54: ((67, '290'), ), 55: ((25, '275'), (54, '284')), 56: ((25, '276'), (54, '285')), 57: ((2, '284'), (25, 'Fac_Adr'), (54, '289')), 58: ((9, '101'), (25, '281'), (54, '291'), (71, 'Taxonomy')) } for a in range(1, 59): s = '' try: for space, entry in myMap[a]: padding = space - len(s) bump = " " * padding try: s = s + bump + self.printImageDict[entry] except: pass #print entry + ' was empty' #this takes care of empty entries except: pass s = s + '\n' #write newline to myfile gateway_file.write(s) gateway_file.write('\n\n\n\n') gateway_file.close() a_file.close() self.Destroy()
def OnBillPt(self, event): Printer.myPtBill(self.PtID) EMR_utilities.updateData('UPDATE billing SET ptDate = CURDATE() WHERE patient_ID = %s AND balance > 0;' % (self.PtID))
def OnDone(self, event): #create file prnt = wx.GetTopLevelParent(self.myparent) #dem_page = parent.nb.GetPage(1) #figured this out using PyCrust (*this will mess up if you have extra pages*) path = EMR_utilities.getData("SELECT home_dir FROM users WHERE user_name = '%s'" % prnt.user) linuxpath = "/home/%s/Desktop/GECKO/Billing/OfficeAlly" % path[0] + "_%s.txt" applepath = "/Users/%s/Desktop/GECKO/Billing/OfficeAlly" % path[0] + "_%s.txt" windowspath = "C:\\Documents and Settings\\%s\\My Documents\\GECKO\\Billing\\OfficeAlly" % path[0] + "_%s.txt" daily_billing = EMR_utilities.platformText(linuxpath, applepath, windowspath) % EMR_utilities.dateToday() a_file = open(daily_billing, 'a') #'a' will both append to existing and create if nonexistent gateway_file = open("/home/%s/Desktop/GECKO/Billing/Gateway" % settings.HOME_FOLDER + "%s.txt" % EMR_utilities.dateToday(), 'a') #get demographic and insurance data insFields = (('InsurancePlanName', 1), ('InsurancePayerID', 2), ('InsuranceStreetAddr', 3), ('InsuranceCity', 4), \ ('InsuranceState', 5), ('InsuranceZip', 6), ('InsuranceCityStateZip', 7), ('InsurancePhone', 8)) fields = (('lastname', 17), ('firstname', 18), ('mid_init', 19), ('dob', 20), ('address', 26), \ ('city', 27), ('state', 28), ('zipcode', 29), ('phonenumber', 30), ('sof', 72), \ \ ('policy_ID', 16), ('InsuredLast', 23), ('InsuredFirst', 24), ('InsuredMidInit', 25), \ ('InsuredStreetAddress', 35), ('InsuredCity', 36), ('InsuredState', 37), \ ('InsuredZip', 38), ('InsuredPhone', 39), \ ('InsuredPolicyGroupOrFecaNumber', 63), ('InsuredDOB', 64), \ ('InsuredEmployerNameOrSchoolName', 67), ('InsuredInsurancePlanNameOrProgramName', 68), \ \ ('OtherInsuredLast', 46), ('OtherInsuredFirst', 47), ('OtherInsuredMidInit', 48), \ ('OtherInsuredPolicyOrGroupNumber', 49), ('OtherInsuredDOB', 50), \ ('OtherInsuredEmployerNameOrSchoolName', 53), ('OtherInsuredInsurancePlanOrProgramName', 54)) insQry = "SELECT * FROM ins_companies WHERE InsurancePlanName = '%s';" % self.whichIns insResults = EMR_utilities.getDictData(insQry) self.printImageDict.update(insResults) #adds more necessary data for print image self.createOADict(insFields, insResults) self.createOADict(fields, self.ptResults) self.get1500Data() self.columns[269] = self.columns[267] - self.columns[268] #BalanceDue if self.billSecInsBox.IsChecked(): EMR_utilities.updateData('UPDATE billing SET 2ndDate = CURDATE() \ WHERE note_number = %s;' % (self.noteNumber)) self.columns[16] = self.ptResults['secondary_ins_ID'] #replaces the primary ins ID self.columns[63] = self.ptResults['sec_PolicyGroupOrFecaNumber'] #replaces primary ins policy number if self.billSecAsPrim.IsChecked(): #allows billing secondary as primary pass else: self.columns[1] = self.columns[1] + ' secondary' #this is how OA does sec ins billing else: EMR_utilities.updateData('UPDATE billing SET 1stDate = CURDATE() \ WHERE note_number = %s;' % (self.noteNumber)) if self.hospAdmBox.IsChecked(): #checks to make sure dates are filled in if not self.columns[83]: self.columns[83] = EMR_utilities.dateToday('OA') if not self.columns[84]: self.columns[84] = EMR_utilities.dateToday('OA') for n in range(1, 292): #remove all the None entries which OA doesn't like if self.columns[n] == None: self.columns[n] = '' else: pass for n in range(1, 292): a_file.write(str(self.columns[n]) + '\t') a_file.write('\n') """Print image for Gateway EDI""" self.printImageDict['Name'] = self.printImageDict['lastname'] + ', ' + self.printImageDict['firstname'] self.printImageDict['InsuredName'] = self.printImageDict['InsuredLast'] + ', ' + self.printImageDict['InsuredFirst'] self.printImageDict['InsuranceCityStateZip'] = insResults['InsuranceCity'] + ', ' + insResults['InsuranceState'] + ' ' \ + insResults['InsuranceZip'] self.printImageDict['Medicare'] = self.columns[9] self.printImageDict['Medicaid'] = self.columns[10] self.printImageDict['Other'] = self.columns[15] self.printImageDict['self'] = self.columns[31] self.printImageDict['spouse'] = self.columns[32] self.printImageDict['child'] = self.columns[33] self.printImageDict['other'] = self.columns[34] self.printImageDict['empl_no'] = self.columns[56] self.printImageDict['auto_no'] = self.columns[58] self.printImageDict['other_no'] = self.columns[61] self.printImageDict['empl_yes'] = self.columns[55] self.printImageDict['auto_yes'] = self.columns[57] self.printImageDict['other_yes'] = self.columns[60] self.printImageDict['auto_state'] = self.columns[59] self.printImageDict['icd1'] = self.columns[89] self.printImageDict['icd2'] = self.columns[90] self.printImageDict['icd3'] = self.columns[91] self.printImageDict['icd4'] = self.columns[92] self.printImageDict['icd5'] = self.columns[93] self.printImageDict['icd6'] = self.columns[94] self.printImageDict['icd7'] = self.columns[95] self.printImageDict['icd8'] = self.columns[96] dateList = ['dob', 'sof', 'Admit', 'DC', '101', '117', '133', '149', '165', '181'] for item in dateList: #fixes problem with dates not showing up on print image try: self.printImageDict[item] = self.printImageDict[item].strftime("%m %d %y") except: self.printImageDict[item] = self.printImageDict[item].replace('/', ' ') self.printImageDict['sig'] = 'Signature on File' self.printImageDict['267'] = str(self.columns[267]) #total charges converting decimal.decimal to string self.printImageDict['268'] = str(self.columns[268]) #this is amount paid, same as above #this brings in secondary/other insurance info if present if self.ptResults['secondary_ins']: self.printImageDict['OtherInsuredDOB'] = self.printImageDict['dob'] self.printImageDict['OtherName'] = self.printImageDict['Name'] self.printImageDict['Taxonomy'] = '207Q00000X' self.printImageDict['CLIA'] = '26D2013625' myMap = {1:((49, 'InsurancePlanName'),), 2:((49, 'InsuranceStreetAddr'),), 3:((49, 'InsuranceCityStateZip'),), 4:((49, 'InsurancePayerID'),), 7:((2, 'Medicare'), (12, 'Medicaid'), (47, 'Other'), (51, 'policy_ID')), 9:((2, 'Name'), (31, 'dob'), (44, 'msex'), (48, 'fsex'), (51, 'InsuredName')), 11:((2, 'address'), (33, 'self'), (35, 'spouse'), (37, 'child'), (39, 'other'), (51, 'InsuredStreetAddress')), 13:((2, 'city'), (28, 'state'), (51, 'InsuredCity'), (74, 'InsuredState')), 15:((2, 'zipcode'), (16, 'phonenumber'), (51, 'InsuredZip'), (66, 'InsuredPhone')), 17:((2, 'OtherName'), (51, 'InsuredPolicyGroupOrFecaNumber')), 19:((2, 'secondary_ins_ID'), (38, 'empl_yes'), (42, 'empl_no')), 21:((2, 'OtherInsuredDOB'), (38, 'auto_yes'), (42, 'auto_no'), (45, 'auto_state')), 23:((38, 'other_yes'), (42, 'other_no'), (51, 'InsuredInsurancePlanNameOrProgramName')), 25:((2, 'secondary_ins'),), 29:((9, 'sig'), (39, 'sof'), (59, 'sig')), 33:((60, 'Admit'), (72, 'DC')), #37:((4, 'icd1'), (31, 'icd3')), 37:((4, 'icd1'), (10, 'icd3'), (16, 'icd5'), (22, 'icd7'), (28, 'icd9')), #39:((4, 'icd2'), (31, 'icd4'), (51, 'CLIA')), 39:((4, 'icd2'), (10, 'icd4'), (16, 'icd6'), (22, 'icd8'), (28, 'icd10'), (51, 'CLIA')), #42:((2, '101'), (21, '103'), (27, '105'), (34, '106'), (37, '107'), (40, '108'), (43, '109'), (47, '110'), (54, '111'), (61, '112'), (71, '116')), #44:((2, '117'), (21, '119'), (27, '121'), (34, '122'), (37, '123'), (40, '124'), (43, '125'), (47, '126'), (54, '127'), (61, '128'), (71, '132')), #46:((2, '133'), (21, '135'), (27, '137'), (34, '138'), (37, '139'), (40, '140'), (43, '141'), (47, '142'), (54, '143'), (61, '144'), (71, '148')), #48:((2, '149'), (21, '151'), (27, '153'), (34, '154'), (37, '155'), (40, '156'), (43, '157'), (47, '158'), (54, '159'), (61, '160'), (71, '164')), #50:((2, '165'), (21, '167'), (27, '169'), (34, '170'), (37, '171'), (40, '172'), (43, '173'), (47, '174'), (54, '175'), (61, '176'), (71, '180')), #52:((2, '181'), (21, '183'), (27, '185'), (34, '186'), (37, '187'), (40, '188'), (43, '189'), (47, '190'), (54, '191'), (61, '192'), (71, '196')), 42:((2, '101'), (21, '103'), (27, '105'), (34, '106'), (37, '107'), (40, '108'), (43, '109'), (47, '110'), (59, '111'), (66, '112'), (76, '116')), 44:((2, '117'), (21, '119'), (27, '121'), (34, '122'), (37, '123'), (40, '124'), (43, '125'), (47, '126'), (59, '127'), (66, '128'), (76, '132')), 46:((2, '133'), (21, '135'), (27, '137'), (34, '138'), (37, '139'), (40, '140'), (43, '141'), (47, '142'), (59, '143'), (66, '144'), (76, '148')), 48:((2, '149'), (21, '151'), (27, '153'), (34, '154'), (37, '155'), (40, '156'), (43, '157'), (47, '158'), (59, '159'), (66, '160'), (76, '164')), 50:((2, '165'), (21, '167'), (27, '169'), (34, '170'), (37, '171'), (40, '172'), (43, '173'), (47, '174'), (59, '175'), (66, '176'), (76, '180')), 52:((2, '181'), (21, '183'), (27, '185'), (34, '186'), (37, '187'), (40, '188'), (43, '189'), (47, '190'), (59, '191'), (66, '192'), (76, '196')), 53:((2, '261'), (18, '262'), (24, '264'), (40, '265'), (56, '267')), 54:((67, '290'),), 55:((25, '275'), (54, '284')), 56:((25, '276'), (54, '285')), 57:((2, '284'), (25, 'Fac_Adr'), (54, '289')), 58:((9, '101'), (25, '281'), (54, '291'), (71, 'Taxonomy'))} for a in range(1,59): s = '' try: for space, entry in myMap[a]: padding = space - len(s) bump = " " * padding try: s = s + bump + self.printImageDict[entry] except: pass #print entry + ' was empty' #this takes care of empty entries except: pass s = s + '\n' #write newline to myfile gateway_file.write(s) gateway_file.write('\n\n\n\n') gateway_file.close() a_file.close() self.Destroy()
def DeleteVitals(self, event): obj = self.vitalsList.GetSelectedObjects() for items in obj: qry = 'DELETE FROM vitals WHERE vitals_number = %s;' % items['vitals_number'] EMR_utilities.updateData(qry) self.UpdateList()
def __init__(self, parent, ptID): lt = "%s/EMR_outputs/%s/Orders/%s.pdf" % (settings.LINUXPATH, ptID, EMR_utilities.dateToday('file format')) at = "%s/EMR_outputs/%s/Orders/%s.pdf" % (settings.APPLEPATH, ptID, EMR_utilities.dateToday('file format')) wt = "%s\EMR_outputs\%s\Orders\%s.pdf" % (settings.WINPATH, ptID, EMR_utilities.dateToday('file format')) filename = EMR_utilities.platformText(lt, at, wt) doc = SimpleDocTemplate(filename, pagesize=letter, topMargin=60) # container for the 'Flowable' objects elements = [] styleSheet = getSampleStyleSheet() styleSheet.add(ParagraphStyle(name='Address', fontSize=13, leading=15)) styleSheet.add(ParagraphStyle(name='Body', fontSize=12, leading=14)) dem_data = EMR_utilities.getDictData('SELECT * FROM demographics WHERE patient_ID = %s;' % ptID) dem_data['phonenumber'] = EMR_formats.phone_format(dem_data['phonenumber']) test_dlg = wx.TextEntryDialog(None, "What studies would you like to order?", "Studies",style=wx.TE_MULTILINE|wx.OK|wx.CANCEL) if test_dlg.ShowModal() == wx.ID_OK: dem_data['tests'] = test_dlg.GetValue() dem_data['date'] = EMR_utilities.dateToday() else: pass dx_dlg = wx.TextEntryDialog(None, "What is the diagnosis?", "Diagnosis", style=wx.TE_MULTILINE|wx.OK|wx.CANCEL) if dx_dlg.ShowModal() == wx.ID_OK: dem_data['dx'] = dx_dlg.GetValue() else: pass results_dlg = wx.TextEntryDialog(None, "Due Date?", style=wx.OK|wx.CANCEL) if results_dlg.ShowModal() == wx.ID_OK: dem_data['results_date'] = results_dlg.GetValue() else: pass qry = "INSERT INTO todo SET patient_ID = %s, date = '%s', description = '%s', priority = 3, \ category = 'Test', due_date = '%s', complete = 0;" % (ptID, EMR_utilities.dateToday(), \ dem_data['tests'], dem_data['results_date']) EMR_utilities.updateData(qry) styleSheet = getSampleStyleSheet() styleSheet.add(ParagraphStyle(name='Address', fontSize=13, leading=15)) styleSheet.add(ParagraphStyle(name='Body', fontSize=12, leading=14)) elements.append(Paragraph('<para align=CENTER>Barron Family Medicine</para>', styleSheet['Address'])) elements.append(Paragraph('<para align=CENTER>8515 Delmar Blvd #217</para>', styleSheet['Address'])) elements.append(Paragraph('<para align=CENTER>University City, MO 63124</para>', styleSheet['Address'])) elements.append(Paragraph('<para align=CENTER>(314)667-5276 fax:(314)677-3838</para>', styleSheet['Address'])) elements.append(Paragraph('<para align=CENTER>Quest #33007741, Labcorp #24864540</para>', styleSheet['Address'])) elements.append(Spacer(1,48)) elements.append(Paragraph('<para align=RIGHT>%s</para>' % EMR_utilities.dateToday(t='display'), styleSheet['Body'])) elements.append(Spacer(1,48)) elements.append(Paragraph('%(firstname)s %(lastname)s' % dem_data, styleSheet['Body'])) elements.append(Paragraph('%(address)s' % dem_data, styleSheet['Body'])) elements.append(Paragraph('%(city)s, %(state)s %(zipcode)s' % dem_data, styleSheet['Body'])) elements.append(Paragraph('%(phonenumber)s' % dem_data, styleSheet['Body'])) elements.append(Paragraph('DOB: %(dob)s' % dem_data, styleSheet['Body'])) elements.append(Spacer(1, 36)) elements.append(Paragraph('<U>Tests:</U>', styleSheet['Address'])) elements.append(Spacer(1, 12)) elements.append(Paragraph(dem_data['tests'], styleSheet['Body'])) elements.append(Spacer(1, 24)) elements.append(Paragraph('<U>Diagnosis:</U>', styleSheet['Address'])) elements.append(Spacer(1,12)) elements.append(Paragraph(dem_data['dx'], styleSheet['Body'])) elements.append(Spacer(1,96)) #elements.append(Spacer(1, 48)) #If you want the signature automatically then can un-comment these lines. For now I will sign all. #logo = "/home/mb/Dropbox/Office/Signature.png" #im = Image(logo, 2*inch, 0.75*inch) #im.hAlign = "LEFT" #elements.append(im) chooseSig(elements) elements.append(Paragraph(settings.NAME, styleSheet['Body'])) # write the document to disk doc.build(elements) choosePrinter(filename)
def __init__(self, parent, ptID, reason, background, consultant, dueDate): filename = "/home/mb/Desktop/GECKO/EMR_outputs/%s/Consults/%s.pdf" % ( ptID, EMR_utilities.dateToday()) doc = SimpleDocTemplate(filename, pagesize=letter, topMargin=60) # container for the 'Flowable' objects elements = [] styleSheet = getSampleStyleSheet() styleSheet.add(ParagraphStyle(name='Address', fontSize=13, leading=15)) styleSheet.add(ParagraphStyle(name='Body', fontSize=12, leading=14)) dem_data = EMR_utilities.getDictData( 'SELECT * FROM demographics WHERE patient_ID = %s;' % ptID) consultDoc = EMR_utilities.name_fixer(consultant) if consultDoc.firstname == '': consult_data = EMR_utilities.getDictData('SELECT * FROM consultants WHERE lastname = "%s";' \ % (consultDoc.lastname)) else: consult_data = EMR_utilities.getDictData( 'SELECT * FROM consultants WHERE lastname = "%s" \ AND firstname = "%s";' % (consultDoc.lastname, consultDoc.firstname)) patient = 'RE: %(firstname)s %(lastname)s, DOB: %(dob)s' % dem_data salutation = 'Dear Dr. %(lastname)s:' % consult_data body = 'I am sending %s, a %s %s, to see you regarding %s. %s' % \ (dem_data['firstname'], EMR_utilities.getAge(ptID), dem_data['sex'], reason, background) problems = EMR_formats.getProblems(ptID) meds = EMR_formats.getMeds(ptID, display='column') qry = "INSERT INTO todo SET patient_ID = %s, date = '%s', description = '%s- %s', priority = 3, \ category = 'Consult', due_date = '%s', complete = 0;" % (ptID, EMR_utilities.dateToday(), \ consult_data['lastname'], reason, dueDate) EMR_utilities.updateData(qry) styleSheet = getSampleStyleSheet() styleSheet.add(ParagraphStyle(name='Address', fontSize=13, leading=15)) styleSheet.add(ParagraphStyle(name='Body', fontSize=12, leading=14)) elements.append( Paragraph('Barron Family Medicine', styleSheet['Address'])) elements.append( Paragraph('1423 S Big Bend Blvd', styleSheet['Address'])) elements.append( Paragraph('Richmond Heights, MO 63117', styleSheet['Address'])) elements.append(Spacer(1, 24)) elements.append( Paragraph( '<para align=RIGHT>%s</para>' % EMR_utilities.dateToday(t='display'), styleSheet['Body'])) elements.append(Spacer(1, 24)) elements.append( Paragraph('Dr. %(lastname)s' % consult_data, styleSheet['Body'])) elements.append( Paragraph('%(address)s' % consult_data, styleSheet['Body'])) elements.append( Paragraph('%(city)s, %(state)s %(zipcode)s' % consult_data, styleSheet['Body'])) elements.append(Spacer(1, 12)) elements.append(Paragraph(patient, styleSheet['Body'])) elements.append(Spacer(1, 12)) elements.append(Paragraph(salutation, styleSheet['Body'])) elements.append(Spacer(1, 12)) elements.append(Paragraph(body, styleSheet['Body'])) elements.append(Spacer(1, 12)) elements.append( Paragraph( "I have attached current medications and problems. \ If you have any questions, don't hesitate to call me at (314) 667-5276.", styleSheet['Body'])) elements.append(Spacer(1, 12)) elements.append(Paragraph('Sincerely,', styleSheet['Body'])) #elements.append(Spacer(1, 48)) #If you want the signature automatically then can un-comment these lines. For now I will sign all. logo = "/home/mb/Dropbox/Office/Signature.png" im = Image(logo, 2 * inch, 0.75 * inch) im.hAlign = "LEFT" elements.append(im) elements.append(Paragraph('Michael Barron MD', styleSheet['Body'])) elements.append(Spacer(1, 12)) tableList = [[ problems, meds, ]] table = Table(tableList, colWidths=(3 * inch, 3 * inch), style=[('VALIGN', (0, 0), (-1, -1), 'TOP'), ('LEFTPADDING', (0, 0), (-1, -1), 0), ('RIGHTPADDING', (0, 0), (-1, -1), 20)]) table.hAlign = "LEFT" elements.append(table) # write the document to disk doc.build(elements) os.system("lp -d Updox %s" % filename) #extremely slick: prints directly to Updox Printer
def listHandleCellEditFinished(self, event): sqlstmt = 'UPDATE meds SET %s = "%s" WHERE med_number = %s;' \ % (self.list.columns[event.subItemIndex].valueGetter, self.list.GetItem(event.rowIndex, event.subItemIndex).GetText(), event.rowModel["med_number"]) EMR_utilities.updateData(sqlstmt)
def OnRemAll(self, event): obj = self.allergylist.GetSelectedObjects() for items in obj: qry = 'DELETE FROM allergies WHERE allergy_number = %s;' % items['allergy_number'] self.allergylist.RemoveObject(items) EMR_utilities.updateData(qry)
def __init__(self, parent, ptID, reason, background, consultant, dueDate): lt = "%s/EMR_outputs/%s/Consults/%s.pdf" % ( settings.LINUXPATH, ptID, EMR_utilities.dateToday('file format')) at = "%s/EMR_outputs/%s/Consults/%s.pdf" % ( settings.APPLEPATH, ptID, EMR_utilities.dateToday('file format')) wt = "%s\EMR_outputs\%s\Consults\%s.pdf" % ( settings.WINPATH, ptID, EMR_utilities.dateToday('file format')) filename = EMR_utilities.platformText(lt, at, wt) doc = SimpleDocTemplate(filename, pagesize=letter, topMargin=60) # container for the 'Flowable' objects elements = [] styleSheet = getSampleStyleSheet() styleSheet.add(ParagraphStyle(name='Address', fontSize=13, leading=15)) styleSheet.add(ParagraphStyle(name='Body', fontSize=12, leading=14)) dem_data = EMR_utilities.getDictData( 'SELECT * FROM demographics WHERE patient_ID = %s;' % ptID) consultDoc = EMR_utilities.name_fixer(consultant) if consultDoc.firstname == '': consult_data = EMR_utilities.getDictData('SELECT * FROM consultants WHERE lastname = "%s";' \ % (consultDoc.lastname)) else: consult_data = EMR_utilities.getDictData( 'SELECT * FROM consultants WHERE lastname = "%s" \ AND firstname = "%s";' % (consultDoc.lastname, consultDoc.firstname)) dem_data['phonenumber'] = EMR_formats.phone_format( dem_data['phonenumber']) patient = 'RE: %(firstname)s %(lastname)s, DOB: %(dob)s, Phone: %(phonenumber)s' % dem_data salutation = 'Dear Dr. %(lastname)s:' % consult_data body = 'I am sending %s, a %s %s, to see you regarding %s. %s' % \ (dem_data['firstname'], EMR_utilities.getAge(ptID), dem_data['sex'], reason, background) problems = EMR_formats.getProblems(ptID) meds = EMR_formats.getMeds(ptID, display='column') qry = "INSERT INTO todo SET patient_ID = %s, date = '%s', description = '%s- %s', priority = 3, \ category = 'Consult', due_date = '%s', complete = 0;" % (ptID, EMR_utilities.dateToday(), \ consult_data['lastname'], reason, dueDate) EMR_utilities.updateData(qry) styleSheet = getSampleStyleSheet() styleSheet.add(ParagraphStyle(name='Address', fontSize=13, leading=15)) styleSheet.add(ParagraphStyle(name='Body', fontSize=12, leading=14)) elements.append( Paragraph('Barron Family Medicine', styleSheet['Address'])) elements.append( Paragraph('8515 Delmar Blvd #217', styleSheet['Address'])) elements.append( Paragraph('University City, MO 63124', styleSheet['Address'])) elements.append( Paragraph('(314)667-5276 fax:(314)677-3838', styleSheet['Address'])) elements.append(Spacer(1, 24)) elements.append( Paragraph( '<para align=RIGHT>%s</para>' % EMR_utilities.dateToday(t='display'), styleSheet['Body'])) elements.append(Spacer(1, 24)) elements.append( Paragraph('Dr. %(lastname)s' % consult_data, styleSheet['Body'])) elements.append( Paragraph('%(address)s' % consult_data, styleSheet['Body'])) elements.append( Paragraph('%(city)s, %(state)s %(zipcode)s' % consult_data, styleSheet['Body'])) elements.append(Spacer(1, 12)) elements.append(Paragraph(patient, styleSheet['Body'])) elements.append(Spacer(1, 12)) elements.append(Paragraph(salutation, styleSheet['Body'])) elements.append(Spacer(1, 12)) elements.append(Paragraph(body, styleSheet['Body'])) elements.append(Spacer(1, 12)) elements.append( Paragraph( "I have attached current medications and problems. \ If you have any questions, don't hesitate to call me at (314) 667-5276.", styleSheet['Body'])) elements.append(Spacer(1, 12)) elements.append(Paragraph('Sincerely,', styleSheet['Body'])) #If you want the signature automatically then can un-comment these lines. For now I will sign all. #logo = "/home/%s/Dropbox/Office/%sSignature.png" % (settings.HOME_FOLDER, settings.HOME_FOLDER) #im = Image(logo, 2*inch, 0.75*inch) #im.hAlign = "LEFT" #elements.append(im) chooseSig(elements) elements.append(Paragraph(settings.NAME, styleSheet['Body'])) elements.append(Spacer(1, 12)) tableList = [[ problems, meds, ]] table = Table(tableList, colWidths=(3 * inch, 3 * inch), style=[('VALIGN', (0, 0), (-1, -1), 'TOP'), ('LEFTPADDING', (0, 0), (-1, -1), 0), ('RIGHTPADDING', (0, 0), (-1, -1), 20)]) table.hAlign = "LEFT" elements.append(table) # write the document to disk doc.build(elements) choosePrinter(filename)
def OnSubmit(self, event): #make sure numbers contain two digits in Charges self.textctrl['Charges'].SetValue( '%.2f' % float(self.textctrl['Charges'].GetValue())) #check to prevent duplicate billing entries duplQry = 'SELECT note_number, CPT_code FROM billing WHERE note_number = %s AND CPT_code = "%s";' % (self.noteID[0], \ self.textctrl['CPT'].GetValue()) dupl_results = EMR_utilities.getAllDictData(duplQry) if dupl_results: wx.MessageBox( 'This is a duplicate entry. Please adjust units on original if needed.', 'Error') pass else: qry = 'INSERT INTO billing SET ' for label, size, field in self.cptLabels: #if self.textctrl[label].GetValue() == '' Think of a way to bypass when '' qry = ' '.join([ qry, '%s = "%s",' % (field, self.textctrl[label].GetValue()) ]) qry = ' '.join([qry, 'note_number = %s, patient_ID = %s, notes = "%s";' % (self.noteID[0], \ self.ptID, self.textctrl['Notes'].GetValue())]) EMR_utilities.updateData(qry) self.results = EMR_utilities.getAllDictData( 'SELECT * FROM billing WHERE note_number = %s;' % (self.noteID[0])) if self.results: for label, size, field in self.cptLabels: # may need if statement here to check for '' self.textctrl[label].SetValue( str(self.results[self.dictNumber][field])) self.textctrl['charge_number'] = wx.TextCtrl(self, -1, size=(0, -1)) self.textctrl['charge_number'].SetValue( str(self.results[self.dictNumber]['charge_number'])) self.textctrl['Notes'].SetValue( str(self.results[self.dictNumber]['notes'])) validation = [ ('Pter', 'You forgot the diagnosis pointer!'), ('Pt Pmt', 'Did the patient give you a copay? If not enter 0.'), ('Balance', "Don't forget the balance") ] for label, msg in validation: #checks to make sure each of these fields is filled in if not self.textctrl[label].GetValue(): wx.MessageBox(msg, 'Grave Mistake!') #ask about e-prescribing codes for patients over 65 gQry = "SELECT * FROM billing WHERE note_number = %s AND CPT_code = 'G8427';" % self.noteID[ 0] gQryResult = EMR_utilities.getData(gQry) if EMR_utilities.getAgeYears(self.ptID) > 100 and gQryResult is None: dlg = wx.MessageDialog(None, "Add med review code?", "Important", wx.YES_NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: q = "INSERT INTO billing SET note_number = '%s', patient_ID = '%s', date = '%s', \ POS = '11', CPT_code = 'G8427', dx_pter = '1', total_charge = '0.01', units = '1', \ pt_pmt = '0', balance = '0.01', rendering_doc = 'Barron', mod_A = '', mod_B = '', \ mod_C = '', mod_D = '';" % (self.noteID[0], self.ptID, self.textctrl['Date'].GetValue()) EMR_utilities.updateData(q) else: pass
def __init__(self, parent, ptID, reason, background, consultant, dueDate): filename = "/home/mb/Desktop/GECKO/EMR_outputs/%s/Consults/%s.pdf" % (ptID, EMR_utilities.dateToday()) doc = SimpleDocTemplate(filename, pagesize=letter, topMargin=60) # container for the 'Flowable' objects elements = [] styleSheet = getSampleStyleSheet() styleSheet.add(ParagraphStyle(name='Address', fontSize=13, leading=15)) styleSheet.add(ParagraphStyle(name='Body', fontSize=12, leading=14)) dem_data = EMR_utilities.getDictData('SELECT * FROM demographics WHERE patient_ID = %s;' % ptID) consultDoc = EMR_utilities.name_fixer(consultant) if consultDoc.firstname == '': consult_data = EMR_utilities.getDictData('SELECT * FROM consultants WHERE lastname = "%s";' \ % (consultDoc.lastname)) else: consult_data = EMR_utilities.getDictData('SELECT * FROM consultants WHERE lastname = "%s" \ AND firstname = "%s";' % (consultDoc.lastname, consultDoc.firstname)) patient = 'RE: %(firstname)s %(lastname)s, DOB: %(dob)s' % dem_data salutation = 'Dear Dr. %(lastname)s:' % consult_data body = 'I am sending %s, a %s %s, to see you regarding %s. %s' % \ (dem_data['firstname'], EMR_utilities.getAge(ptID), dem_data['sex'], reason, background) problems = EMR_formats.getProblems(ptID) meds = EMR_formats.getMeds(ptID, display='column') qry = "INSERT INTO todo SET patient_ID = %s, date = '%s', description = '%s- %s', priority = 3, \ category = 'Consult', due_date = '%s', complete = 0;" % (ptID, EMR_utilities.dateToday(), \ consult_data['lastname'], reason, dueDate) EMR_utilities.updateData(qry) styleSheet = getSampleStyleSheet() styleSheet.add(ParagraphStyle(name='Address', fontSize=13, leading=15)) styleSheet.add(ParagraphStyle(name='Body', fontSize=12, leading=14)) elements.append(Paragraph('Barron Family Medicine', styleSheet['Address'])) elements.append(Paragraph('1423 S Big Bend Blvd', styleSheet['Address'])) elements.append(Paragraph('Richmond Heights, MO 63117', styleSheet['Address'])) elements.append(Spacer(1,24)) elements.append(Paragraph('<para align=RIGHT>%s</para>' % EMR_utilities.dateToday(t='display'), styleSheet['Body'])) elements.append(Spacer(1,24)) elements.append(Paragraph('Dr. %(lastname)s' % consult_data, styleSheet['Body'])) elements.append(Paragraph('%(address)s' % consult_data, styleSheet['Body'])) elements.append(Paragraph('%(city)s, %(state)s %(zipcode)s' % consult_data, styleSheet['Body'])) elements.append(Spacer(1, 12)) elements.append(Paragraph(patient, styleSheet['Body'])) elements.append(Spacer(1, 12)) elements.append(Paragraph(salutation, styleSheet['Body'])) elements.append(Spacer(1, 12)) elements.append(Paragraph(body, styleSheet['Body'])) elements.append(Spacer(1,12)) elements.append(Paragraph("I have attached current medications and problems. \ If you have any questions, don't hesitate to call me at (314) 667-5276.", styleSheet['Body'])) elements.append(Spacer(1,12)) elements.append(Paragraph('Sincerely,', styleSheet['Body'])) #elements.append(Spacer(1, 48)) #If you want the signature automatically then can un-comment these lines. For now I will sign all. logo = "/home/mb/Dropbox/Office/Signature.png" im = Image(logo, 2*inch, 0.75*inch) im.hAlign = "LEFT" elements.append(im) elements.append(Paragraph('Michael Barron MD', styleSheet['Body'])) elements.append(Spacer(1, 12)) tableList = [[problems, meds,]] table = Table(tableList, colWidths=(3*inch, 3*inch), style=[('VALIGN', (0,0), (-1,-1), 'TOP'), ('LEFTPADDING', (0,0), (-1,-1), 0), ('RIGHTPADDING', (0,0), (-1,-1), 20)]) table.hAlign = "LEFT" elements.append(table) # write the document to disk doc.build(elements) os.system("lp -d Updox %s" % filename) #extremely slick: prints directly to Updox Printer
def OnDeleteMed(self, event): obj = self.list.GetSelectedObjects() for items in obj: qry = 'DELETE FROM meds WHERE med_number = %s;' % items['med_number'] self.list.RemoveObject(items) EMR_utilities.updateData(qry)
def __init__(self, parent, ptID, reason, background, consultant, dueDate): lt = "%s/EMR_outputs/%s/Consults/%s.pdf" % (settings.LINUXPATH, ptID, EMR_utilities.dateToday('file format')) at = "%s/EMR_outputs/%s/Consults/%s.pdf" % (settings.APPLEPATH, ptID, EMR_utilities.dateToday('file format')) wt = "%s\EMR_outputs\%s\Consults\%s.pdf" % (settings.WINPATH, ptID, EMR_utilities.dateToday('file format')) filename = EMR_utilities.platformText(lt, at, wt) doc = SimpleDocTemplate(filename, pagesize=letter, topMargin=60) # container for the 'Flowable' objects elements = [] styleSheet = getSampleStyleSheet() styleSheet.add(ParagraphStyle(name='Address', fontSize=13, leading=15)) styleSheet.add(ParagraphStyle(name='Body', fontSize=12, leading=14)) dem_data = EMR_utilities.getDictData('SELECT * FROM demographics WHERE patient_ID = %s;' % ptID) consultDoc = EMR_utilities.name_fixer(consultant) if consultDoc.firstname == '': consult_data = EMR_utilities.getDictData('SELECT * FROM consultants WHERE lastname = "%s";' \ % (consultDoc.lastname)) else: consult_data = EMR_utilities.getDictData('SELECT * FROM consultants WHERE lastname = "%s" \ AND firstname = "%s";' % (consultDoc.lastname, consultDoc.firstname)) dem_data['phonenumber'] = EMR_formats.phone_format(dem_data['phonenumber']) patient = 'RE: %(firstname)s %(lastname)s, DOB: %(dob)s, Phone: %(phonenumber)s' % dem_data salutation = 'Dear Dr. %(lastname)s:' % consult_data body = 'I am sending %s, a %s %s, to see you regarding %s. %s' % \ (dem_data['firstname'], EMR_utilities.getAge(ptID), dem_data['sex'], reason, background) problems = EMR_formats.getProblems(ptID) meds = EMR_formats.getMeds(ptID, display='column') qry = "INSERT INTO todo SET patient_ID = %s, date = '%s', description = '%s- %s', priority = 3, \ category = 'Consult', due_date = '%s', complete = 0;" % (ptID, EMR_utilities.dateToday(), \ consult_data['lastname'], reason, dueDate) EMR_utilities.updateData(qry) styleSheet = getSampleStyleSheet() styleSheet.add(ParagraphStyle(name='Address', fontSize=13, leading=15)) styleSheet.add(ParagraphStyle(name='Body', fontSize=12, leading=14)) elements.append(Paragraph('Barron Family Medicine', styleSheet['Address'])) elements.append(Paragraph('8515 Delmar Blvd #217', styleSheet['Address'])) elements.append(Paragraph('University City, MO 63124', styleSheet['Address'])) elements.append(Paragraph('(314)667-5276 fax:(314)677-3838', styleSheet['Address'])) elements.append(Spacer(1,24)) elements.append(Paragraph('<para align=RIGHT>%s</para>' % EMR_utilities.dateToday(t='display'), styleSheet['Body'])) elements.append(Spacer(1,24)) elements.append(Paragraph('Dr. %(lastname)s' % consult_data, styleSheet['Body'])) elements.append(Paragraph('%(address)s' % consult_data, styleSheet['Body'])) elements.append(Paragraph('%(city)s, %(state)s %(zipcode)s' % consult_data, styleSheet['Body'])) elements.append(Spacer(1, 12)) elements.append(Paragraph(patient, styleSheet['Body'])) elements.append(Spacer(1, 12)) elements.append(Paragraph(salutation, styleSheet['Body'])) elements.append(Spacer(1, 12)) elements.append(Paragraph(body, styleSheet['Body'])) elements.append(Spacer(1,12)) elements.append(Paragraph("I have attached current medications and problems. \ If you have any questions, don't hesitate to call me at (314) 667-5276.", styleSheet['Body'])) elements.append(Spacer(1,12)) elements.append(Paragraph('Sincerely,', styleSheet['Body'])) #If you want the signature automatically then can un-comment these lines. For now I will sign all. #logo = "/home/%s/Dropbox/Office/%sSignature.png" % (settings.HOME_FOLDER, settings.HOME_FOLDER) #im = Image(logo, 2*inch, 0.75*inch) #im.hAlign = "LEFT" #elements.append(im) chooseSig(elements) elements.append(Paragraph(settings.NAME, styleSheet['Body'])) elements.append(Spacer(1, 12)) tableList = [[problems, meds,]] table = Table(tableList, colWidths=(3*inch, 3*inch), style=[('VALIGN', (0,0), (-1,-1), 'TOP'), ('LEFTPADDING', (0,0), (-1,-1), 0), ('RIGHTPADDING', (0,0), (-1,-1), 20)]) table.hAlign = "LEFT" elements.append(table) # write the document to disk doc.build(elements) choosePrinter(filename)