public static bool GetPatPict(int patNum, string patFolder, out Bitmap patientPict) { patientPict = null; //first establish which category pat pics are in int defNumPicts = 0; for (int i = 0; i < DefB.Short[(int)DefCat.ImageCats].Length; i++) { if (DefB.Short[(int)DefCat.ImageCats][i].ItemValue == "P" || DefB.Short[(int)DefCat.ImageCats][i].ItemValue == "XP") { defNumPicts = DefB.Short[(int)DefCat.ImageCats][i].DefNum; break; } } if (defNumPicts == 0) //no category set for picts { return(false); } //then find string command = "SELECT document.* FROM document,docattach " + "WHERE document.DocNum=docattach.DocNum " + "AND docattach.PatNum=" + POut.PInt(patNum) + " AND document.DocCategory=" + POut.PInt(defNumPicts) + " ORDER BY DateCreated DESC "; //gets the most recent if (DataSettings.DbType == DatabaseType.Oracle) { command = "SELECT * FROM (" + command + ") WHERE ROWNUM<=1"; } else //Assume MySQL { command += "LIMIT 1"; } Document[] pictureDocs = RefreshAndFill(command); if (pictureDocs == null || pictureDocs.Length < 1) //no pictures { return(false); } string shortFileName = pictureDocs[0].FileName; if (shortFileName.Length < 1) { return(false); } string fullName = ODFileUtils.CombinePaths(patFolder, shortFileName); if (!File.Exists(fullName)) { return(false); } //create Thumbnails folder string thumbPath = ODFileUtils.CombinePaths(patFolder, "Thumbnails"); if (!Directory.Exists(thumbPath)) { try { Directory.CreateDirectory(thumbPath); } catch { throw new ImageStoreCreationException(Lan.g("Documents", "Error. Could not create thumbnails folder. ")); } } string thumbFileName = ODFileUtils.CombinePaths(new string[] { patFolder, "Thumbnails", shortFileName }); if (!ImageHelper.HasImageExtension(thumbFileName)) { return(false); } if (File.Exists(thumbFileName)) //use existing thumbnail { patientPict = (Bitmap)Bitmap.FromFile(thumbFileName); return(true); } //add thumbnail Bitmap thumbBitmap; //Gets the cropped/flipped/rotated image with any color filtering applied. Bitmap sourceImage = new Bitmap(fullName); Bitmap fullImage = ImageHelper.ApplyDocumentSettingsToImage(pictureDocs[0], sourceImage, ApplySettings.ALL); sourceImage.Dispose(); thumbBitmap = ImageHelper.GetThumbnail(fullImage, 100); fullImage.Dispose(); try { thumbBitmap.Save(thumbFileName); } catch { //Oh well, we can regenerate it next time if we have to! } patientPict = thumbBitmap; return(true); }
private static DataTable GetMiscTable(string aptNum, string apptStatus) { DataConnection dcon = new DataConnection(); DataTable table = new DataTable("Misc"); DataRow row; table.Columns.Add("LabCaseNum"); table.Columns.Add("labDescript"); table.Columns.Add("requirements"); string command = "SELECT LabCaseNum,DateTimeDue,DateTimeChecked,DateTimeRecd,DateTimeSent," + "laboratory.Description FROM labcase,laboratory " + "WHERE labcase.LaboratoryNum=laboratory.LaboratoryNum AND "; if (apptStatus == "6") //planned { command += "labcase.PlannedAptNum=" + aptNum; } else { command += "labcase.AptNum=" + aptNum; } DataTable raw = dcon.GetTable(command); DateTime date; //always return one row: row = table.NewRow(); row["LabCaseNum"] = "0"; row["labDescript"] = ""; if (raw.Rows.Count > 0) { row["LabCaseNum"] = raw.Rows[0]["LabCaseNum"].ToString(); row["labDescript"] = raw.Rows[0]["Description"].ToString(); //DateTime date=PIn.PDateT(raw.Rows[0]["DateTimeDue"].ToString()); //if(date.Year>1880) { // row["labDescript"]+="\r\n"+Lan.g("FormAppEdit","Due: ")+date.ToString("ddd")+" " // +date.ToShortDateString()+" "+date.ToShortTimeString(); //} date = PIn.PDateT(raw.Rows[0]["DateTimeChecked"].ToString()); if (date.Year > 1880) { row["labDescript"] += "\r\n" + Lan.g("FormApptEdit", "Quality Checked"); } else { date = PIn.PDateT(raw.Rows[0]["DateTimeRecd"].ToString()); if (date.Year > 1880) { row["labDescript"] += "\r\n" + Lan.g("FormApptEdit", "Received"); } else { date = PIn.PDateT(raw.Rows[0]["DateTimeSent"].ToString()); if (date.Year > 1880) { row["labDescript"] += "\r\n" + Lan.g("FormApptEdit", "Sent"); //sent but not received } else { row["labDescript"] += "\r\n" + Lan.g("FormApptEdit", "Not Sent"); } } } } //requirements------------------------------------------------------------------------------------------- command = "SELECT " + "reqstudent.Descript,LName,FName " + "FROM reqstudent,provider " //schoolcourse " + "WHERE reqstudent.ProvNum=provider.ProvNum " + "AND reqstudent.AptNum=" + aptNum; raw = dcon.GetTable(command); row["requirements"] = ""; for (int i = 0; i < raw.Rows.Count; i++) { if (i != 0) { row["requirements"] += "\r\n"; } row["requirements"] += raw.Rows[i]["LName"].ToString() + ", " + raw.Rows[i]["FName"].ToString() + ": " + raw.Rows[i]["Descript"].ToString(); } table.Rows.Add(row); return(table); }
///<summary>This does not actually delete the procedure, but just changes the status to deleted. Throws exception if not allowed to delete.</summary> public static int Delete(int procNum) { //Test to see if any payment at all has been received for this proc string command = "SELECT COUNT(*) FROM claimproc WHERE ProcNum=" + POut.PInt(procNum) + " AND InsPayAmt > 0 AND Status != " + POut.PInt((int)ClaimProcStatus.Preauth); DataConnection dcon = new DataConnection(); if (dcon.GetCount(command) != "0") { throw new Exception(Lan.g("Procedures", "Not allowed to delete a procedure that is attached to a payment.")); } //delete adjustments command = "DELETE FROM adjustment WHERE ProcNum='" + POut.PInt(procNum) + "'"; dcon.NonQ(command); //delete claimprocs command = "DELETE from claimproc WHERE ProcNum = '" + POut.PInt(procNum) + "'"; dcon.NonQ(command); //resynch appointment description------------------------------------------------------------------------------------- command = "SELECT AptNum,PlannedAptNum FROM procedurelog WHERE ProcNum = " + POut.PInt(procNum); DataTable table = dcon.GetTable(command); string aptnum = table.Rows[0][0].ToString(); string plannedaptnum = table.Rows[0][1].ToString(); string procdescript; if (aptnum != "0") { command = @"SELECT AbbrDesc FROM procedurecode,procedurelog WHERE procedurecode.CodeNum=procedurelog.CodeNum AND ProcNum != " + POut.PInt(procNum) + " AND procedurelog.AptNum=" + aptnum; table = dcon.GetTable(command); procdescript = ""; for (int i = 0; i < table.Rows.Count; i++) { if (i > 0) { procdescript += ", "; } procdescript += table.Rows[i]["AbbrDesc"].ToString(); } command = "UPDATE appointment SET ProcDescript='" + POut.PString(procdescript) + "' " + "WHERE AptNum=" + aptnum; dcon.NonQ(command); } if (plannedaptnum != "0") { command = @"SELECT AbbrDesc FROM procedurecode,procedurelog WHERE procedurecode.CodeNum=procedurelog.CodeNum AND ProcNum != " + POut.PInt(procNum) + " AND procedurelog.PlannedAptNum=" + plannedaptnum; table = dcon.GetTable(command); procdescript = ""; for (int i = 0; i < table.Rows.Count; i++) { if (i > 0) { procdescript += ", "; } procdescript += table.Rows[i]["AbbrDesc"].ToString(); } command = "UPDATE appointment SET ProcDescript='" + POut.PString(procdescript) + "' " + "WHERE NextAptNum=" + plannedaptnum; dcon.NonQ(command); } //set the procedure deleted----------------------------------------------------------------------------------------- command = "UPDATE procedurelog SET ProcStatus = " + POut.PInt((int)ProcStat.D) + ", " + "AptNum=0, " + "PlannedAptNum=0 " + "WHERE ProcNum = '" + POut.PInt(procNum) + "'"; int rowsChanged = dcon.NonQ(command); //Recalls.Synch(ProcCur.PatNum);//later return(rowsChanged); }
///<summary>If aptnum is specified, then the dates are ignored. If getting data for one planned appt, then pass isPlanned=true. This changes which procedures are retrieved.</summary> private static DataTable GetPeriodApptsTable(string strDateStart, string strDateEnd, string strAptNum, string strIsPlanned) { DateTime dateStart = PIn.PDate(strDateStart); DateTime dateEnd = PIn.PDate(strDateEnd); int aptNum = PIn.PInt(strAptNum); bool isPlanned = PIn.PBool(strIsPlanned); DataConnection dcon = new DataConnection(); DataTable table = new DataTable("Appointments"); DataRow row; //columns that start with lowercase are altered for display rather than being raw data. table.Columns.Add("age"); table.Columns.Add("addrNote"); table.Columns.Add("apptModNote"); table.Columns.Add("aptDate"); table.Columns.Add("aptDay"); table.Columns.Add("aptLength"); table.Columns.Add("aptTime"); table.Columns.Add("AptDateTime"); table.Columns.Add("AptNum"); table.Columns.Add("AptStatus"); table.Columns.Add("Assistant"); table.Columns.Add("billingType"); table.Columns.Add("chartNumber"); table.Columns.Add("chartNumAndName"); table.Columns.Add("confirmed"); table.Columns.Add("Confirmed"); table.Columns.Add("contactMethods"); table.Columns.Add("creditIns"); table.Columns.Add("famFinUrgNote"); table.Columns.Add("hmPhone"); table.Columns.Add("ImageFolder"); table.Columns.Add("insurance"); table.Columns.Add("IsHygiene"); table.Columns.Add("lab"); table.Columns.Add("MedUrgNote"); table.Columns.Add("Note"); table.Columns.Add("Op"); table.Columns.Add("patientName"); table.Columns.Add("PatNum"); table.Columns.Add("patNum"); table.Columns.Add("GuarNum"); table.Columns.Add("patNumAndName"); table.Columns.Add("Pattern"); table.Columns.Add("preMedFlag"); table.Columns.Add("procs"); table.Columns.Add("production"); table.Columns.Add("productionVal"); table.Columns.Add("provider"); table.Columns.Add("ProvHyg"); table.Columns.Add("ProvNum"); table.Columns.Add("wkPhone"); table.Columns.Add("wirelessPhone"); string command = "SELECT p1.Abbr ProvAbbr,p2.Abbr HygAbbr,patient.AddrNote," + "patient.ApptModNote,AptDateTime,appointment.AptNum,AptStatus,Assistant," + "patient.BillingType,patient.BirthDate,patient.Guarantor," + "patient.ChartNumber,Confirmed,patient.CreditType,DateTimeChecked,DateTimeRecd,DateTimeSent," + "guar.FamFinUrgNote,patient.FName,patient.HmPhone,patient.ImageFolder,IsHygiene,IsNewPatient," + "LabCaseNum,patient.LName,patient.MedUrgNote,patient.MiddleI,Note,Op,appointment.PatNum," + "Pattern,patplan.PlanNum,patient.PreferConfirmMethod,patient.PreferContactMethod,patient.Preferred," + "patient.PreferRecallMethod,patient.Premed," + "(SELECT SUM(ProcFee) FROM procedurelog "; if (isPlanned) { command += "WHERE procedurelog.PlannedAptNum=appointment.AptNum) Production, "; } else { command += "WHERE procedurelog.AptNum=appointment.AptNum) Production, "; } command += "ProvHyg,appointment.ProvNum,patient.WirelessPhone,patient.WkPhone " + "FROM appointment LEFT JOIN patient ON patient.PatNum=appointment.PatNum " + "LEFT JOIN provider p1 ON p1.ProvNum=appointment.ProvNum " + "LEFT JOIN provider p2 ON p2.ProvNum=appointment.ProvHyg "; if (isPlanned) { command += "LEFT JOIN labcase ON labcase.PlannedAptNum=appointment.AptNum "; } else { command += "LEFT JOIN labcase ON labcase.AptNum=appointment.AptNum "; } command += "LEFT JOIN patient guar ON guar.PatNum=patient.Guarantor " + "LEFT JOIN patplan ON patplan.PatNum=patient.PatNum "; if (aptNum == 0) { command += "WHERE AptDateTime >= " + POut.PDate(dateStart) + " " + "AND AptDateTime < " + POut.PDate(dateEnd.AddDays(1)) + " " + "AND (AptStatus=1 OR AptStatus=2 OR AptStatus=4 OR AptStatus=5 OR AptStatus=7 OR AptStatus=8) "; } else { command += "WHERE appointment.AptNum=" + POut.PInt(aptNum); } command += " GROUP BY appointment.AptNum"; DataTable raw = dcon.GetTable(command); command = "SELECT AbbrDesc,procedurelog.AptNum,procedurelog.CodeNum,PlannedAptNum,Surf,ToothNum,TreatArea " + "FROM procedurelog,appointment,procedurecode "; if (isPlanned) { command += "WHERE procedurelog.PlannedAptNum=appointment.AptNum "; } else { command += "WHERE procedurelog.AptNum=appointment.AptNum "; } command += "AND procedurelog.CodeNum=procedurecode.CodeNum "; if (aptNum == 0) { command += "AND AptDateTime >= " + POut.PDate(dateStart) + " " + "AND AptDateTime < " + POut.PDate(dateEnd.AddDays(1)) + " "; } else { command += "AND appointment.AptNum=" + POut.PInt(aptNum); } DataTable rawProc = dcon.GetTable(command); //procs for flag, InsNotSent command = "SELECT patient.PatNum, patient.Guarantor " + "FROM patient,procedurecode,procedurelog,claimproc " + "WHERE claimproc.procnum=procedurelog.procnum " + "AND patient.PatNum=procedurelog.PatNum " + "AND procedurelog.CodeNum=procedurecode.CodeNum " + "AND claimproc.NoBillIns=0 " + "AND procedurelog.ProcFee>0 " + "AND claimproc.Status=6 " //estimate + "AND procedurelog.procstatus=2 " + "AND procedurelog.ProcDate >= " + POut.PDate(DateTime.Now.AddYears(-1)) + " " + "AND procedurelog.ProcDate <= " + POut.PDate(DateTime.Now) + " " + "GROUP BY patient.Guarantor"; DataTable rawInsProc = dcon.GetTable(command); DateTime aptDate; TimeSpan span; int hours; int minutes; DateTime labDate; DateTime birthdate; for (int i = 0; i < raw.Rows.Count; i++) { row = table.NewRow(); if (raw.Rows[i]["AddrNote"].ToString() != "") { row["addrNote"] = Lan.g("Appointments", "AddrNote: ") + raw.Rows[i]["AddrNote"].ToString(); } aptDate = PIn.PDateT(raw.Rows[i]["AptDateTime"].ToString()); row["AptDateTime"] = aptDate; birthdate = PIn.PDate(raw.Rows[i]["Birthdate"].ToString()); row["age"] = Lan.g("Appointments", "Age: "); if (birthdate.Year > 1880) { row["age"] += PatientB.DateToAgeString(birthdate); } else { row["age"] += "?"; } if (raw.Rows[i]["ApptModNote"].ToString() != "") { row["apptModNote"] = Lan.g("Appointments", "ApptModNote: ") + raw.Rows[i]["ApptModNote"].ToString(); } row["aptDate"] = aptDate.ToShortDateString(); row["aptDay"] = aptDate.ToString("dddd"); span = TimeSpan.FromMinutes(raw.Rows[i]["Pattern"].ToString().Length *5); hours = span.Hours; minutes = span.Minutes; if (hours == 0) { row["aptLength"] = minutes.ToString() + Lan.g("Appointments", " Min"); } else if (hours == 1) { row["aptLength"] = hours.ToString() + Lan.g("Appointments", " Hr, ") + minutes.ToString() + Lan.g("Appointments", " Min"); } else { row["aptLength"] = hours.ToString() + Lan.g("Appointments", " Hrs, ") + minutes.ToString() + Lan.g("Appointments", " Min"); } row["aptTime"] = aptDate.ToShortTimeString(); row["AptNum"] = raw.Rows[i]["AptNum"].ToString(); row["AptStatus"] = raw.Rows[i]["AptStatus"].ToString(); row["Assistant"] = raw.Rows[i]["Assistant"].ToString(); row["billingType"] = DefB.GetName(DefCat.BillingTypes, PIn.PInt(raw.Rows[i]["BillingType"].ToString())); if (raw.Rows[i]["ChartNumber"].ToString() != "") { row["chartNumber"] = raw.Rows[i]["ChartNumber"].ToString(); } //row["ChartNumber"]=raw.Rows[i]["ChartNumber"].ToString(); row["chartNumAndName"] = ""; if (raw.Rows[i]["IsNewPatient"].ToString() == "1") { row["chartNumAndName"] = "NP-"; } row["chartNumAndName"] += raw.Rows[i]["ChartNumber"].ToString() + " " + PatientB.GetNameLF(raw.Rows[i]["LName"].ToString(), raw.Rows[i]["FName"].ToString(), raw.Rows[i]["Preferred"].ToString(), raw.Rows[i]["MiddleI"].ToString()); row["confirmed"] = DefB.GetName(DefCat.ApptConfirmed, PIn.PInt(raw.Rows[i]["Confirmed"].ToString())); row["Confirmed"] = raw.Rows[i]["Confirmed"].ToString(); row["contactMethods"] = ""; if (raw.Rows[i]["PreferConfirmMethod"].ToString() != "0") { row["contactMethods"] += Lan.g("Appointments", "Confirm Method: ") + ((ContactMethod)PIn.PInt(raw.Rows[i]["PreferConfirmMethod"].ToString())).ToString(); } if (raw.Rows[i]["PreferContactMethod"].ToString() != "0") { if (row["contactMethods"].ToString() != "") { row["contactMethods"] += "\r\n"; } row["contactMethods"] += Lan.g("Appointments", "Contact Method: ") + ((ContactMethod)PIn.PInt(raw.Rows[i]["PreferContactMethod"].ToString())).ToString(); } if (raw.Rows[i]["PreferRecallMethod"].ToString() != "0") { if (row["contactMethods"].ToString() != "") { row["contactMethods"] += "\r\n"; } row["contactMethods"] += Lan.g("Appointments", "Recall Method: ") + ((ContactMethod)PIn.PInt(raw.Rows[i]["PreferRecallMethod"].ToString())).ToString(); } row["creditIns"] = raw.Rows[i]["CreditType"].ToString(); //figure out if pt's family has ins claims that need to be created bool InsToSend = false; for (int j = 0; j < rawInsProc.Rows.Count; j++) { if (raw.Rows[i]["PlanNum"].ToString() != "" && raw.Rows[i]["PlanNum"].ToString() != "0") { if (raw.Rows[i]["Guarantor"].ToString() == rawInsProc.Rows[j]["Guarantor"].ToString() || raw.Rows[i]["Guarantor"].ToString() == rawInsProc.Rows[j]["PatNum"].ToString()) { InsToSend = true; } } } if (InsToSend) { row["creditIns"] += "!"; } else if (raw.Rows[i]["PlanNum"].ToString() != "" && raw.Rows[i]["PlanNum"].ToString() != "0") { row["creditIns"] += "I"; } if (raw.Rows[i]["FamFinUrgNote"].ToString() != "") { row["famFinUrgNote"] = Lan.g("Appointments", "FamFinUrgNote: ") + raw.Rows[i]["FamFinUrgNote"].ToString(); } row["hmPhone"] = Lan.g("Appointments", "Hm: ") + raw.Rows[i]["HmPhone"].ToString(); row["ImageFolder"] = raw.Rows[i]["ImageFolder"].ToString(); if (raw.Rows[i]["PlanNum"].ToString() != "" && raw.Rows[i]["PlanNum"].ToString() != "0") { row["insurance"] = Lan.g("Appointments", "Insured"); } row["IsHygiene"] = raw.Rows[i]["IsHygiene"].ToString(); row["lab"] = ""; if (raw.Rows[i]["LabCaseNum"].ToString() != "") { labDate = PIn.PDateT(raw.Rows[i]["DateTimeChecked"].ToString()); if (labDate.Year > 1880) { row["lab"] = Lan.g("Appointments", "Lab Quality Checked"); } else { labDate = PIn.PDateT(raw.Rows[i]["DateTimeRecd"].ToString()); if (labDate.Year > 1880) { row["lab"] = Lan.g("Appointments", "Lab Received"); } else { labDate = PIn.PDateT(raw.Rows[i]["DateTimeSent"].ToString()); if (labDate.Year > 1880) { row["lab"] = Lan.g("Appointments", "Lab Sent"); //sent but not received } else { row["lab"] = Lan.g("Appointments", "Lab Not Sent"); } } } } row["MedUrgNote"] = raw.Rows[i]["MedUrgNote"].ToString(); row["Note"] = raw.Rows[i]["Note"].ToString(); row["Op"] = raw.Rows[i]["Op"].ToString(); if (raw.Rows[i]["IsNewPatient"].ToString() == "1") { row["patientName"] = "NP-"; } row["patientName"] += PatientB.GetNameLF(raw.Rows[i]["LName"].ToString(), raw.Rows[i]["FName"].ToString(), raw.Rows[i]["Preferred"].ToString(), raw.Rows[i]["MiddleI"].ToString()); row["PatNum"] = raw.Rows[i]["PatNum"].ToString(); row["patNum"] = "PatNum: " + raw.Rows[i]["PatNum"].ToString(); row["GuarNum"] = raw.Rows[i]["Guarantor"].ToString(); row["patNumAndName"] = ""; if (raw.Rows[i]["IsNewPatient"].ToString() == "1") { row["patNumAndName"] = "NP-"; } row["patNumAndName"] += raw.Rows[i]["PatNum"].ToString() + " " + PatientB.GetNameLF(raw.Rows[i]["LName"].ToString(), raw.Rows[i]["FName"].ToString(), raw.Rows[i]["Preferred"].ToString(), raw.Rows[i]["MiddleI"].ToString()); row["Pattern"] = raw.Rows[i]["Pattern"].ToString(); if (raw.Rows[i]["Premed"].ToString() == "1") { row["preMedFlag"] = Lan.g("Appointments", "Premedicate"); } row["procs"] = ""; for (int p = 0; p < rawProc.Rows.Count; p++) { if (!isPlanned && rawProc.Rows[p]["AptNum"].ToString() != raw.Rows[i]["AptNum"].ToString()) { continue; } if (isPlanned && rawProc.Rows[p]["PlannedAptNum"].ToString() != raw.Rows[i]["AptNum"].ToString()) { continue; } if (row["procs"].ToString() != "") { row["procs"] += ", "; } switch (rawProc.Rows[p]["TreatArea"].ToString()) { case "1": //TreatmentArea.Surf: row["procs"] += "#" + Tooth.ToInternat(rawProc.Rows[p]["ToothNum"].ToString()) + "-" + rawProc.Rows[p]["Surf"].ToString() + "-"; //""#12-MOD-" break; case "2": //TreatmentArea.Tooth: row["procs"] += "#" + Tooth.ToInternat(rawProc.Rows[p]["ToothNum"].ToString()) + "-"; //"#12-" break; default: //area 3 or 0 (mouth) break; case "4": //TreatmentArea.Quad: row["procs"] += rawProc.Rows[p]["Surf"].ToString() + "-"; //"UL-" break; case "5": //TreatmentArea.Sextant: row["procs"] += "S" + rawProc.Rows[p]["Surf"].ToString() + "-"; //"S2-" break; case "6": //TreatmentArea.Arch: row["procs"] += rawProc.Rows[p]["Surf"].ToString() + "-"; //"U-" break; case "7": //TreatmentArea.ToothRange: //strLine+=table.Rows[j][13].ToString()+" ";//don't show range break; } row["procs"] += rawProc.Rows[p]["AbbrDesc"].ToString(); } row["production"] = PIn.PDouble(raw.Rows[i]["Production"].ToString()).ToString("c"); row["productionVal"] = raw.Rows[i]["Production"].ToString(); if (raw.Rows[i]["IsHygiene"].ToString() == "1") { row["provider"] = raw.Rows[i]["HygAbbr"].ToString(); if (raw.Rows[i]["ProvAbbr"].ToString() != "") { row["provider"] += " (" + raw.Rows[i]["ProvAbbr"].ToString() + ")"; } } else { row["provider"] = raw.Rows[i]["ProvAbbr"].ToString(); if (raw.Rows[i]["HygAbbr"].ToString() != "") { row["provider"] += " (" + raw.Rows[i]["HygAbbr"].ToString() + ")"; } } row["ProvNum"] = raw.Rows[i]["ProvNum"].ToString(); row["ProvHyg"] = raw.Rows[i]["ProvHyg"].ToString(); row["wirelessPhone"] = Lan.g("Appointments", "Cell: ") + raw.Rows[i]["WirelessPhone"].ToString(); row["wkPhone"] = Lan.g("Appointments", "Wk: ") + raw.Rows[i]["WkPhone"].ToString(); table.Rows.Add(row); } return(table); }
private static DataTable GetProcTable(string patNum, string aptNum, string apptStatus) { DataConnection dcon = new DataConnection(); DataTable table = new DataTable("Procedure"); DataRow row; //columns that start with lowercase are altered for display rather than being raw data. table.Columns.Add("attached"); //0 or 1 table.Columns.Add("CodeNum"); table.Columns.Add("descript"); table.Columns.Add("fee"); table.Columns.Add("priority"); table.Columns.Add("ProcCode"); table.Columns.Add("ProcNum"); table.Columns.Add("ProcStatus"); table.Columns.Add("ProvNum"); table.Columns.Add("status"); table.Columns.Add("toothNum"); table.Columns.Add("Surf"); string command = "SELECT procedurecode.ProcCode,AptNum,PlannedAptNum,Priority,ProcFee,ProcNum,ProcStatus,Surf,ToothNum, " + "procedurecode.Descript,procedurelog.CodeNum,procedurelog.ProvNum " + "FROM procedurelog LEFT JOIN procedurecode ON procedurelog.CodeNum=procedurecode.CodeNum " + "WHERE PatNum=" + patNum //sort later + " AND (ProcStatus=1 OR "; //tp if (apptStatus == "6") //planned { command += "PlannedAptNum=" + aptNum + ")"; } else { command += "AptNum=" + aptNum + ") "; //+"AND (AptNum=0 OR AptNum="+aptNum+")";//exclude procs attached to other appts. } DataTable rawProc = dcon.GetTable(command); for (int i = 0; i < rawProc.Rows.Count; i++) { row = table.NewRow(); if (apptStatus == "6") //planned { row["attached"] = (rawProc.Rows[i]["PlannedAptNum"].ToString() == aptNum) ? "1" : "0"; } else { row["attached"] = (rawProc.Rows[i]["AptNum"].ToString() == aptNum) ? "1" : "0"; } row["CodeNum"] = rawProc.Rows[i]["CodeNum"].ToString(); row["descript"] = ""; if (rawProc.Rows[i]["AptNum"].ToString() != "0" && rawProc.Rows[i]["AptNum"].ToString() != aptNum) { row["descript"] = Lan.g("FormApptEdit", "(other appt)"); } row["descript"] += rawProc.Rows[i]["Descript"].ToString(); row["fee"] = PIn.PDouble(rawProc.Rows[i]["ProcFee"].ToString()).ToString("F"); row["priority"] = DefB.GetName(DefCat.TxPriorities, PIn.PInt(rawProc.Rows[i]["Priority"].ToString())); row["ProcCode"] = rawProc.Rows[i]["ProcCode"].ToString(); row["ProcNum"] = rawProc.Rows[i]["ProcNum"].ToString(); row["ProcStatus"] = rawProc.Rows[i]["ProcStatus"].ToString(); row["ProvNum"] = rawProc.Rows[i]["ProvNum"].ToString(); row["status"] = ((ProcStat)PIn.PInt(rawProc.Rows[i]["ProcStatus"].ToString())).ToString(); row["toothNum"] = Tooth.ToInternat(rawProc.Rows[i]["ToothNum"].ToString()); row["Surf"] = rawProc.Rows[i]["Surf"].ToString(); table.Rows.Add(row); } return(table); }
private static DataTable GetPatTable(string patNum) { DataConnection dcon = new DataConnection(); DataTable table = new DataTable("Patient"); //columns that start with lowercase are altered for display rather than being raw data. table.Columns.Add("field"); table.Columns.Add("value"); string command = "SELECT * FROM patient WHERE PatNum=" + patNum; DataTable rawPat = dcon.GetTable(command); DataRow row; //Patient Name-------------------------------------------------------------------------- row = table.NewRow(); row["field"] = Lan.g("FormApptEdit", "Name"); row["value"] = PatientB.GetNameLF(rawPat.Rows[0]["LName"].ToString(), rawPat.Rows[0]["FName"].ToString(), rawPat.Rows[0]["Preferred"].ToString(), rawPat.Rows[0]["MiddleI"].ToString()); table.Rows.Add(row); //Patient First Name-------------------------------------------------------------------- row = table.NewRow(); row["field"] = Lan.g("FormApptEdit", "First Name"); row["value"] = rawPat.Rows[0]["FName"]; table.Rows.Add(row); //Patient Last name--------------------------------------------------------------------- row = table.NewRow(); row["field"] = Lan.g("FormApptEdit", "Last Name"); row["value"] = rawPat.Rows[0]["LName"]; table.Rows.Add(row); //Patient middle initial---------------------------------------------------------------- row = table.NewRow(); row["field"] = Lan.g("FormApptEdit", "Middle Initial"); row["value"] = rawPat.Rows[0]["MiddleI"]; table.Rows.Add(row); //Patient home phone-------------------------------------------------------------------- row = table.NewRow(); row["field"] = Lan.g("FormApptEdit", "Home Phone"); row["value"] = rawPat.Rows[0]["HmPhone"]; table.Rows.Add(row); //Patient work phone-------------------------------------------------------------------- row = table.NewRow(); row["field"] = Lan.g("FormApptEdit", "Work Phone"); row["value"] = rawPat.Rows[0]["WkPhone"]; table.Rows.Add(row); //Patient wireless phone---------------------------------------------------------------- row = table.NewRow(); row["field"] = Lan.g("FormApptEdit", "Wireless Phone"); row["value"] = rawPat.Rows[0]["WirelessPhone"]; table.Rows.Add(row); //Patient credit type------------------------------------------------------------------- row = table.NewRow(); row["field"] = Lan.g("FormApptEdit", "Credit Type"); row["value"] = rawPat.Rows[0]["CreditType"]; table.Rows.Add(row); //Patient billing type------------------------------------------------------------------ row = table.NewRow(); row["field"] = Lan.g("FormApptEdit", "Billing Type"); row["value"] = DefB.GetName(DefCat.BillingTypes, PIn.PInt(rawPat.Rows[0]["BillingType"].ToString())); table.Rows.Add(row); //Patient total balance----------------------------------------------------------------- row = table.NewRow(); row["field"] = Lan.g("FormApptEdit", "Total Balance"); double totalBalance = PIn.PDouble(rawPat.Rows[0]["EstBalance"].ToString()); row["value"] = totalBalance.ToString("F"); table.Rows.Add(row); //Patient address and phone notes------------------------------------------------------- row = table.NewRow(); row["field"] = Lan.g("FormApptEdit", "Address and Phone Notes"); row["value"] = rawPat.Rows[0]["AddrNote"]; table.Rows.Add(row); //Patient family balance---------------------------------------------------------------- command = "SELECT BalTotal,InsEst FROM patient WHERE Guarantor='" + rawPat.Rows[0]["Guarantor"].ToString() + "'"; DataTable familyBalance = dcon.GetTable(command); row = table.NewRow(); row["field"] = Lan.g("FormApptEdit", "Family Balance"); double balance = PIn.PDouble(familyBalance.Rows[0]["BalTotal"].ToString()) - PIn.PDouble(familyBalance.Rows[0]["InsEst"].ToString()); row["value"] = balance.ToString("F"); table.Rows.Add(row); return(table); }
private static DataTable GetProgNotes(int patNum, bool isAuditMode) { DataConnection dcon = new DataConnection(); DataTable table = new DataTable("ProgNotes"); DataRow row; //columns that start with lowercase are altered for display rather than being raw data. table.Columns.Add("ADACode"); table.Columns.Add("aptDateTime", typeof(DateTime)); table.Columns.Add("colorBackG"); table.Columns.Add("colorText"); table.Columns.Add("CommlogNum"); table.Columns.Add("description"); table.Columns.Add("dx"); table.Columns.Add("Dx"); table.Columns.Add("note"); table.Columns.Add("Priority"); table.Columns.Add("procDate"); table.Columns.Add("ProcDate", typeof(DateTime)); table.Columns.Add("procFee"); table.Columns.Add("ProcNum"); table.Columns.Add("ProcNumLab"); table.Columns.Add("procStatus"); table.Columns.Add("ProcStatus"); table.Columns.Add("prov"); table.Columns.Add("RxNum"); table.Columns.Add("signature"); table.Columns.Add("Surf"); table.Columns.Add("toothNum"); table.Columns.Add("ToothNum"); table.Columns.Add("ToothRange"); table.Columns.Add("user"); //table.Columns.Add(""); //but we won't actually fill this table with rows until the very end. It's more useful to use a List<> for now. List <DataRow> rows = new List <DataRow>(); //Procedures----------------------------------------------------------------------------------------------------- string command = "SELECT ProcDate,ProcStatus,ToothNum,Surf,Dx,procedurelog.ADACode,ProcNum,procedurecode.Descript," + "provider.Abbr,ProcFee,ProcNumLab,appointment.AptDateTime,Priority,ToothRange " + "FROM procedurelog " + "LEFT JOIN procedurecode ON procedurecode.ADACode=procedurelog.ADACode " + "LEFT JOIN provider ON provider.ProvNum=procedurelog.ProvNum " + "LEFT JOIN appointment ON appointment.AptNum=procedurelog.AptNum " + "AND (appointment.AptStatus=" + POut.PInt((int)ApptStatus.Scheduled) + " OR appointment.AptStatus=" + POut.PInt((int)ApptStatus.ASAP) + " OR appointment.AptStatus=" + POut.PInt((int)ApptStatus.Broken) + " OR appointment.AptStatus=" + POut.PInt((int)ApptStatus.Complete) + ") WHERE procedurelog.PatNum=" + POut.PInt(patNum); if (!isAuditMode) { command += " AND ProcStatus !=6"; //don't include deleted } command += " ORDER BY ProcDate"; //we'll just have to reorder it anyway DataTable rawProcs = dcon.GetTable(command); command = "SELECT ProcNum,EntryDateTime,UserNum,Note," + "CASE WHEN Signature!='' THEN 1 ELSE 0 END AS SigPresent " + "FROM procnote WHERE PatNum=" + POut.PInt(patNum) + " ORDER BY EntryDateTime"; // but this helps when looping for notes DataTable rawNotes = dcon.GetTable(command); DateTime dateT; List <DataRow> labRows = new List <DataRow>(); //Canadian lab procs, which must be added in a loop at the very end. for (int i = 0; i < rawProcs.Rows.Count; i++) { row = table.NewRow(); row["ADACode"] = rawProcs.Rows[i]["ADACode"].ToString(); row["aptDateTime"] = PIn.PDateT(rawProcs.Rows[i]["AptDateTime"].ToString()); row["colorBackG"] = Color.White.ToArgb(); if (((DateTime)row["aptDateTime"]).Date == DateTime.Today) { row["colorBackG"] = DefB.Long[(int)DefCat.MiscColors][6].ItemColor.ToArgb().ToString(); } switch ((ProcStat)PIn.PInt(rawProcs.Rows[i]["ProcStatus"].ToString())) { case ProcStat.TP: row["colorText"] = DefB.Long[(int)DefCat.ProgNoteColors][0].ItemColor.ToArgb().ToString(); break; case ProcStat.C: row["colorText"] = DefB.Long[(int)DefCat.ProgNoteColors][1].ItemColor.ToArgb().ToString(); break; case ProcStat.EC: row["colorText"] = DefB.Long[(int)DefCat.ProgNoteColors][2].ItemColor.ToArgb().ToString(); break; case ProcStat.EO: row["colorText"] = DefB.Long[(int)DefCat.ProgNoteColors][3].ItemColor.ToArgb().ToString(); break; case ProcStat.R: row["colorText"] = DefB.Long[(int)DefCat.ProgNoteColors][4].ItemColor.ToArgb().ToString(); break; case ProcStat.D: row["colorText"] = Color.Black.ToArgb().ToString(); break; } row["CommlogNum"] = 0; row["description"] = rawProcs.Rows[i]["Descript"].ToString(); row["dx"] = DefB.GetValue(DefCat.Diagnosis, PIn.PInt(rawProcs.Rows[i]["Dx"].ToString())); row["Dx"] = rawProcs.Rows[i]["Dx"].ToString(); //note----------------------------------------------------------------------------------------------------------- if (isAuditMode) //we will include all notes for each proc. We will concat and make readable. { for (int n = 0; n < rawNotes.Rows.Count; n++) //loop through each note { if (rawProcs.Rows[i]["ProcNum"].ToString() != rawNotes.Rows[n]["ProcNum"].ToString()) { continue; } if (row["Note"].ToString() != "") //if there is an existing note { row["note"] += "\r\n------------------------------------------------------\r\n"; //start a new line } row["note"] += PIn.PDateT(rawNotes.Rows[n]["EntryDateTime"].ToString()).ToString(); row["note"] += " " + UserodB.GetName(PIn.PInt(rawNotes.Rows[n]["UserNum"].ToString())); if (rawNotes.Rows[n]["SigPresent"].ToString() == "1") { row["note"] += " " + Lan.g("ChartModule", "(signed)"); } row["note"] += "\r\n" + rawNotes.Rows[n]["Note"].ToString(); } } else //we just want the most recent note { for (int n = rawNotes.Rows.Count - 1; n >= 0; n--) //loop through each note, backwards. { if (rawProcs.Rows[i]["ProcNum"].ToString() != rawNotes.Rows[n]["ProcNum"].ToString()) { continue; } row["user"] = UserodB.GetName(PIn.PInt(rawNotes.Rows[n]["UserNum"].ToString())); row["note"] = rawNotes.Rows[n]["Note"].ToString(); if (rawNotes.Rows[n]["SigPresent"].ToString() == "1") { row["signature"] = Lan.g("ChartModule", "Signed"); } else { row["signature"] = ""; } break; //out of note loop. } } row["Priority"] = rawProcs.Rows[i]["Priority"].ToString(); dateT = PIn.PDateT(rawProcs.Rows[i]["ProcDate"].ToString()); if (dateT.Year < 1880) { row["procDate"] = ""; } else { row["procDate"] = dateT.ToShortDateString(); } row["ProcDate"] = dateT; row["procFee"] = PIn.PDouble(rawProcs.Rows[i]["ProcFee"].ToString()).ToString("F"); row["ProcNum"] = rawProcs.Rows[i]["ProcNum"].ToString(); row["ProcNumLab"] = rawProcs.Rows[i]["ProcNumLab"].ToString(); row["procStatus"] = Lan.g("enumProcStat", ((ProcStat)PIn.PInt(rawProcs.Rows[i]["ProcStatus"].ToString())).ToString()); row["ProcStatus"] = rawProcs.Rows[i]["ProcStatus"].ToString(); row["prov"] = rawProcs.Rows[i]["Abbr"].ToString(); row["RxNum"] = 0; row["Surf"] = rawProcs.Rows[i]["Surf"].ToString(); row["toothNum"] = Tooth.ToInternat(rawProcs.Rows[i]["ToothNum"].ToString()); row["ToothNum"] = rawProcs.Rows[i]["ToothNum"].ToString(); row["ToothRange"] = rawProcs.Rows[i]["ToothRange"].ToString(); if (rawProcs.Rows[i]["ProcNumLab"].ToString() == "0") //normal proc { rows.Add(row); } else { row["description"] = "-----" + row["description"].ToString(); labRows.Add(row); //these will be added in the loop at the end } } //Commlog----------------------------------------------------------------------------------------------------------- command = "SELECT CommlogNum,CommDateTime,CommType,Note FROM commlog WHERE PatNum=" + POut.PInt(patNum) + " ORDER BY CommDateTime"; DataTable rawComm = dcon.GetTable(command); for (int i = 0; i < rawComm.Rows.Count; i++) { row = table.NewRow(); row["colorBackG"] = Color.White.ToArgb(); row["colorText"] = DefB.Long[(int)DefCat.ProgNoteColors][6].ItemColor.ToArgb().ToString(); row["CommlogNum"] = rawComm.Rows[i]["CommlogNum"].ToString(); row["description"] = Lan.g("ChartModule", "Comm - ") + Lan.g("enumCommItemType", ((CommItemType)PIn.PInt(rawComm.Rows[i]["CommType"].ToString())).ToString()); row["note"] = rawComm.Rows[i]["Note"].ToString(); dateT = PIn.PDateT(rawComm.Rows[i]["CommDateTime"].ToString()); if (dateT.Year < 1880) { row["procDate"] = ""; } else { row["procDate"] = dateT.ToShortDateString(); } row["ProcDate"] = dateT; row["ProcNum"] = 0; row["RxNum"] = 0; rows.Add(row); } //Rx------------------------------------------------------------------------------------------------------------------ command = "SELECT RxNum,RxDate,Drug,Disp,ProvNum,Notes FROM rxpat WHERE PatNum=" + POut.PInt(patNum) + " ORDER BY RxDate"; DataTable rawRx = dcon.GetTable(command); for (int i = 0; i < rawRx.Rows.Count; i++) { row = table.NewRow(); row["colorBackG"] = Color.White.ToArgb(); row["colorText"] = DefB.Long[(int)DefCat.ProgNoteColors][5].ItemColor.ToArgb().ToString(); row["CommlogNum"] = 0; row["description"] = Lan.g("ChartModule", "Rx - ") + rawRx.Rows[i]["Drug"].ToString() + " - #" + rawRx.Rows[i]["Disp"].ToString(); row["note"] = rawRx.Rows[i]["Notes"].ToString(); dateT = PIn.PDate(rawRx.Rows[i]["RxDate"].ToString()); if (dateT.Year < 1880) { row["procDate"] = ""; } else { row["procDate"] = dateT.ToShortDateString(); } row["ProcDate"] = dateT; row["ProcNum"] = 0; row["RxNum"] = rawRx.Rows[i]["RxNum"].ToString(); rows.Add(row); } //Sorting rows.Sort(CompareChartRows); //Canadian lab procedures need to come immediately after their corresponding proc--------------------------------- for (int i = 0; i < labRows.Count; i++) { for (int r = 0; r < rows.Count; r++) { if (rows[r]["ProcNum"].ToString() == labRows[i]["ProcNumLab"].ToString()) { rows.Insert(r + 1, labRows[i]); break; } } } for (int i = 0; i < rows.Count; i++) { table.Rows.Add(rows[i]); } return(table); }
///<summary>Takes a user entered string and validates/formats it for the database. Throws an ApplicationException if any formatting errors. User string can contain spaces, dashes, and commas, too.</summary> public static string FormatRangeForDb(string toothNumbers) { if (toothNumbers == null) { return(""); } toothNumbers = toothNumbers.Replace(" ", ""); //remove all spaces if (toothNumbers == "") { return(""); } string[] toothArray = toothNumbers.Split(','); //some items will contain dashes List <string> toothList = new List <string>(); string rangebegin; string rangeend; int beginint; int endint; //not sure how to handle supernumerary. Probably just not acceptable. for (int i = 0; i < toothArray.Length; i++) { if (toothArray[i].Contains("-")) { rangebegin = toothArray[i].Split('-')[0]; rangeend = toothArray[i].Split('-')[1]; if (!IsValidEntry(rangebegin)) { throw new ApplicationException(rangebegin + " " + Lan.g("Tooth", "is not a valid tooth number.")); } if (!IsValidEntry(rangeend)) { throw new ApplicationException(rangeend + " " + Lan.g("Tooth", "is not a valid tooth number.")); } beginint = Tooth.ToOrdinal(FromInternat(rangebegin)); endint = Tooth.ToInt(FromInternat(rangeend)); if (endint < beginint) { throw new ApplicationException("Range specified is impossible."); } while (beginint <= endint) { toothList.Add(Tooth.FromOrdinal(beginint)); beginint++; } } else { if (!IsValidEntry(toothArray[i])) { throw new ApplicationException(toothArray[i] + " " + Lan.g("Tooth", "is not a valid tooth number.")); } toothList.Add(Tooth.FromInternat(toothArray[i])); } } toothList.Sort(CompareTeethOrdinal); string retVal = ""; for (int i = 0; i < toothList.Count; i++) { if (i > 0) { retVal += ","; } retVal += toothList[i]; } return(retVal); }