Esempio n. 1
0
        ///<summary></summary>
        public static int Update(Document doc)
        {
            string command = "UPDATE document SET "
                             + "Description = '" + POut.PString(doc.Description) + "'"
                             + ",DateCreated = " + POut.PDate(doc.DateCreated)
                             + ",DocCategory = '" + POut.PInt(doc.DocCategory) + "'"
                             + ",WithPat = '" + POut.PInt(doc.WithPat) + "'"
                             + ",FileName    = '" + POut.PString(doc.FileName) + "'"
                             + ",ImgType    = '" + POut.PInt((int)doc.ImgType) + "'"
                             + ",IsFlipped   = '" + POut.PBool(doc.IsFlipped) + "'"
                             + ",DegreesRotated   = '" + POut.PInt(doc.DegreesRotated) + "'"
                             + ",ToothNumbers   = '" + POut.PString(doc.ToothNumbers) + "'"
                             + ",Note   = '" + POut.PString(doc.Note) + "'"
                             + ",SigIsTopaz    = '" + POut.PBool(doc.SigIsTopaz) + "'"
                             + ",Signature   = '" + POut.PString(doc.Signature) + "'"
                             + ",CropX       ='" + POut.PInt(doc.CropX) + "'"
                             + ",CropY       ='" + POut.PInt(doc.CropY) + "'"
                             + ",CropW       ='" + POut.PInt(doc.CropW) + "'"
                             + ",CropH       ='" + POut.PInt(doc.CropH) + "'"
                             + ",WindowingMin ='" + POut.PInt(doc.WindowingMin) + "'"
                             + ",WindowingMax ='" + POut.PInt(doc.WindowingMax) + "'"
                             + " WHERE DocNum = '" + POut.PInt(doc.DocNum) + "'";
            //MessageBox.Show(cmd.CommandText);
            DataConnection dcon = new DataConnection();

            dcon.NonQ(command);
            return(0);
        }
Esempio n. 2
0
        public static int Insert(Mount mount)
        {
            string command = "INSERT INTO mount (MountNum,PatNum,DocCategory,DateCreated,Description,Note,ImgType,Width,Height) VALUES ("
                             + "'" + POut.PInt(mount.MountNum) + "',"
                             + "'" + POut.PInt(mount.PatNum) + "',"
                             + "'" + POut.PInt(mount.DocCategory) + "',"
                             + POut.PDate(mount.DateCreated) + ","
                             + "'" + POut.PString(mount.Description) + "',"
                             + "'" + POut.PString(mount.Note) + "',"
                             + "'" + POut.PInt((int)mount.ImgType) + "',"
                             + "'" + POut.PInt(mount.Width) + "',"
                             + "'" + POut.PInt(mount.Height) + "')";

            return(General2.NonQEx(command, true));
        }
Esempio n. 3
0
        public static int Update(Mount mount)
        {
            string command = "UPDATE mount SET "
                             + "PatNum='" + POut.PInt(mount.PatNum) + "',"
                             + "DocCategory='" + POut.PInt(mount.DocCategory) + "',"
                             + "DateCreated=" + POut.PDate(mount.DateCreated) + ","
                             + "Description='" + POut.PString(mount.Description) + "',"
                             + "Note='" + POut.PString(mount.Note) + "',"
                             + "ImgType='" + POut.PInt((int)mount.ImgType) + "',"
                             + "Width='" + POut.PInt(mount.Width) + "',"
                             + "Height='" + POut.PInt(mount.Height) + "' "
                             + "WHERE MountNum='" + POut.PInt(mount.MountNum) + "'";

            return(General2.NonQEx(command));
        }
Esempio n. 4
0
        private static DataTable GetPeriodEmployeeSchedTable(string strDateStart, string strDateEnd)
        {
            DateTime       dateStart = PIn.PDate(strDateStart);
            DateTime       dateEnd   = PIn.PDate(strDateEnd);
            DataConnection dcon      = new DataConnection();
            DataTable      table     = new DataTable("EmpSched");
            DataRow        row;

            //columns that start with lowercase are altered for display rather than being raw data.
            table.Columns.Add("empName");
            table.Columns.Add("schedule");
            if (dateStart != dateEnd)
            {
                return(table);
            }
            string command = "SELECT StartTime,StopTime,FName,employee.EmployeeNum "
                             + "FROM employee,schedule "
                             + "WHERE schedule.EmployeeNum=employee.EmployeeNum "
                             + "AND SchedType=3 "  //employee
                             + "AND SchedDate = " + POut.PDate(dateStart) + " "
                             + "ORDER BY schedule.EmployeeNum,StartTime";
            DataTable raw = dcon.GetTable(command);
            DateTime  startTime;
            DateTime  stopTime;

            for (int i = 0; i < raw.Rows.Count; i++)
            {
                row = table.NewRow();
                if (i == 0 || raw.Rows[i]["EmployeeNum"].ToString() != raw.Rows[i - 1]["EmployeeNum"].ToString())
                {
                    row["empName"] = raw.Rows[i]["FName"].ToString();
                }
                else
                {
                    row["empName"] = "";
                }
                if (row["schedule"].ToString() != "")
                {
                    row["schedule"] += ",";
                }
                startTime        = PIn.PDateT(raw.Rows[i]["StartTime"].ToString());
                stopTime         = PIn.PDateT(raw.Rows[i]["StopTime"].ToString());
                row["schedule"] += startTime.ToString("h:mm") + "-" + stopTime.ToString("h:mm");
                table.Rows.Add(row);
            }
            return(table);
        }
Esempio n. 5
0
        public static int Insert(Procedure proc)
        {
            if (PrefB.RandomKeys)
            {
                proc.ProcNum = MiscDataB.GetKey("procedurelog", "ProcNum");
            }
            string command = "INSERT INTO procedurelog (";

            if (PrefB.RandomKeys)
            {
                command += "ProcNum,";
            }
            command += "PatNum, AptNum, OldCode, ProcDate,ProcFee,Surf,"
                       + "ToothNum,ToothRange,Priority,ProcStatus,ProvNum,"
                       + "Dx,PlannedAptNum,PlaceService,Prosthesis,DateOriginalProsth,ClaimNote,"
                       + "DateEntryC,ClinicNum,MedicalCode,DiagnosticCode,IsPrincDiag,ProcNumLab,"
                       + "BillingTypeOne,BillingTypeTwo,CodeNum,CodeMod1,CodeMod2,CodeMod3,CodeMod4,RevCode,UnitCode,UnitQty,BaseUnits,StartTime,StopTime) VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(proc.ProcNum) + "', ";
            }
            command +=
                "'" + POut.PInt(proc.PatNum) + "', "
                + "'" + POut.PInt(proc.AptNum) + "', "
                + "'" + POut.PString(proc.OldCode) + "', "
                + POut.PDate(proc.ProcDate) + ", "
                + "'" + POut.PDouble(proc.ProcFee) + "', "
                + "'" + POut.PString(proc.Surf) + "', "
                + "'" + POut.PString(proc.ToothNum) + "', "
                + "'" + POut.PString(proc.ToothRange) + "', "
                + "'" + POut.PInt(proc.Priority) + "', "
                + "'" + POut.PInt((int)proc.ProcStatus) + "', "
                + "'" + POut.PInt(proc.ProvNum) + "', "
                + "'" + POut.PInt(proc.Dx) + "', "
                + "'" + POut.PInt(proc.PlannedAptNum) + "', "
                + "'" + POut.PInt((int)proc.PlaceService) + "', "
                + "'" + POut.PString(proc.Prosthesis) + "', "
                + POut.PDate(proc.DateOriginalProsth) + ", "
                + "'" + POut.PString(proc.ClaimNote) + "', ";
            if (DataConnection.DBtype == DatabaseType.Oracle)
            {
                command += POut.PDateT(MiscDataB.GetNowDateTime());
            }
            else              //Assume MySQL
            {
                command += "NOW()";
            }
            command += ", "          //DateEntryC
                       + "'" + POut.PInt(proc.ClinicNum) + "', "
                       + "'" + POut.PString(proc.MedicalCode) + "', "
                       + "'" + POut.PString(proc.DiagnosticCode) + "', "
                       + "'" + POut.PBool(proc.IsPrincDiag) + "', "
                       + "'" + POut.PInt(proc.ProcNumLab) + "', "
                       + "'" + POut.PInt(proc.BillingTypeOne) + "', "
                       + "'" + POut.PInt(proc.BillingTypeTwo) + "', "
                       + "'" + POut.PInt(proc.CodeNum) + "', "
                       + "'" + POut.PString(proc.CodeMod1) + "', "
                       + "'" + POut.PString(proc.CodeMod2) + "', "
                       + "'" + POut.PString(proc.CodeMod3) + "', "
                       + "'" + POut.PString(proc.CodeMod4) + "', "
                       + "'" + POut.PString(proc.RevCode) + "', "
                       + "'" + POut.PString(proc.UnitCode) + "', "
                       + "'" + POut.PInt(proc.UnitQty) + "', "
                       + "'" + POut.PInt(proc.BaseUnits) + "', "
                       + "'" + POut.PInt(proc.StartTime) + "', "
                       + "'" + POut.PInt(proc.StopTime) + "')";
            //MessageBox.Show(cmd.CommandText);
            DataConnection dcon = new DataConnection();

            if (PrefB.RandomKeys)
            {
                dcon.NonQ(command);
            }
            else
            {
                dcon.NonQ(command, true);
                proc.ProcNum = dcon.InsertID;
            }
            if (proc.Note != "")
            {
                ProcNote note = new ProcNote();
                note.PatNum  = proc.PatNum;
                note.ProcNum = proc.ProcNum;
                note.UserNum = proc.UserNum;
                note.Note    = proc.Note;
                ProcNoteB.Insert(note);
            }
            return(proc.ProcNum);
        }
Esempio n. 6
0
        ///<summary>Updates only the changed columns.</summary>
        public static int Update(Procedure proc, Procedure oldProc)
        {
            bool   comma = false;
            string c     = "UPDATE procedurelog SET ";

            if (proc.PatNum != oldProc.PatNum)
            {
                c    += "PatNum = '" + POut.PInt(proc.PatNum) + "'";
                comma = true;
            }
            if (proc.AptNum != oldProc.AptNum)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "AptNum = '" + POut.PInt(proc.AptNum) + "'";
                comma = true;
            }
            if (proc.OldCode != oldProc.OldCode)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "OldCode = '" + POut.PString(proc.OldCode) + "'";
                comma = true;
            }
            if (proc.ProcDate != oldProc.ProcDate)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ProcDate = " + POut.PDate(proc.ProcDate);
                comma = true;
            }
            if (proc.ProcFee != oldProc.ProcFee)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ProcFee = '" + POut.PDouble(proc.ProcFee) + "'";
                comma = true;
            }
            if (proc.Surf != oldProc.Surf)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "Surf = '" + POut.PString(proc.Surf) + "'";
                comma = true;
            }
            if (proc.ToothNum != oldProc.ToothNum)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ToothNum = '" + POut.PString(proc.ToothNum) + "'";
                comma = true;
            }
            if (proc.ToothRange != oldProc.ToothRange)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ToothRange = '" + POut.PString(proc.ToothRange) + "'";
                comma = true;
            }
            if (proc.Priority != oldProc.Priority)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "Priority = '" + POut.PInt(proc.Priority) + "'";
                comma = true;
            }
            if (proc.ProcStatus != oldProc.ProcStatus)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ProcStatus = '" + POut.PInt((int)proc.ProcStatus) + "'";
                comma = true;
            }
            if (proc.ProvNum != oldProc.ProvNum)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ProvNum = '" + POut.PInt(proc.ProvNum) + "'";
                comma = true;
            }
            if (proc.Dx != oldProc.Dx)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "Dx = '" + POut.PInt(proc.Dx) + "'";
                comma = true;
            }
            if (proc.PlannedAptNum != oldProc.PlannedAptNum)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "PlannedAptNum = '" + POut.PInt(proc.PlannedAptNum) + "'";
                comma = true;
            }
            if (proc.PlaceService != oldProc.PlaceService)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "PlaceService = '" + POut.PInt((int)proc.PlaceService) + "'";
                comma = true;
            }
            if (proc.Prosthesis != oldProc.Prosthesis)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "Prosthesis = '" + POut.PString(proc.Prosthesis) + "'";
                comma = true;
            }
            if (proc.DateOriginalProsth != oldProc.DateOriginalProsth)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "DateOriginalProsth = " + POut.PDate(proc.DateOriginalProsth);
                comma = true;
            }
            if (proc.ClaimNote != oldProc.ClaimNote)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ClaimNote = '" + POut.PString(proc.ClaimNote) + "'";
                comma = true;
            }
            if (proc.DateEntryC != oldProc.DateEntryC)
            {
                if (comma)
                {
                    c += ",";
                }
                c += "DateEntryC = ";
                if (DataConnection.DBtype == DatabaseType.Oracle)
                {
                    c += POut.PDateT(MiscDataB.GetNowDateTime());
                }
                else                  //Assume MySQL
                {
                    c += "NOW()";
                }
                comma = true;
            }
            if (proc.ClinicNum != oldProc.ClinicNum)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ClinicNum = '" + POut.PInt(proc.ClinicNum) + "'";
                comma = true;
            }
            if (proc.MedicalCode != oldProc.MedicalCode)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "MedicalCode = '" + POut.PString(proc.MedicalCode) + "'";
                comma = true;
            }
            if (proc.DiagnosticCode != oldProc.DiagnosticCode)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "DiagnosticCode = '" + POut.PString(proc.DiagnosticCode) + "'";
                comma = true;
            }
            if (proc.IsPrincDiag != oldProc.IsPrincDiag)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "IsPrincDiag = '" + POut.PBool(proc.IsPrincDiag) + "'";
                comma = true;
            }
            if (proc.ProcNumLab != oldProc.ProcNumLab)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ProcNumLab = '" + POut.PInt(proc.ProcNumLab) + "'";
                comma = true;
            }
            if (proc.BillingTypeOne != oldProc.BillingTypeOne)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "BillingTypeOne = '" + POut.PInt(proc.BillingTypeOne) + "'";
                comma = true;
            }
            if (proc.BillingTypeTwo != oldProc.BillingTypeTwo)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "BillingTypeTwo = '" + POut.PInt(proc.BillingTypeTwo) + "'";
                comma = true;
            }
            if (proc.CodeNum != oldProc.CodeNum)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "CodeNum = '" + POut.PInt(proc.CodeNum) + "'";
                comma = true;
            }
            if (proc.CodeMod1 != oldProc.CodeMod1)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "CodeMod1 = '" + POut.PString(proc.CodeMod1) + "'";
                comma = true;
            }
            if (proc.CodeMod2 != oldProc.CodeMod2)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "CodeMod2 = '" + POut.PString(proc.CodeMod2) + "'";
                comma = true;
            }
            if (proc.CodeMod3 != oldProc.CodeMod3)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "CodeMod3 = '" + POut.PString(proc.CodeMod3) + "'";
                comma = true;
            }
            if (proc.CodeMod4 != oldProc.CodeMod4)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "CodeMod4 = '" + POut.PString(proc.CodeMod4) + "'";
                comma = true;
            }
            if (proc.RevCode != oldProc.RevCode)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "RevCode = '" + POut.PString(proc.RevCode) + "'";
                comma = true;
            }
            if (proc.UnitCode != oldProc.UnitCode)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "UnitCode = '" + POut.PString(proc.UnitCode) + "'";
                comma = true;
            }
            if (proc.UnitQty != oldProc.UnitQty)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "UnitQty = '" + POut.PInt(proc.UnitQty) + "'";
                comma = true;
            }
            if (proc.BaseUnits != oldProc.BaseUnits)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "BaseUnits = '" + POut.PInt(proc.BaseUnits) + "'";
                comma = true;
            }
            if (proc.StartTime != oldProc.StartTime)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "StartTime = '" + POut.PInt(proc.StartTime) + "'";
                comma = true;
            }
            if (proc.StopTime != oldProc.StopTime)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "StopTime = '" + POut.PInt(proc.StopTime) + "'";
                comma = true;
            }
            int rowsChanged = 0;

            if (comma)
            {
                c += " WHERE ProcNum = '" + POut.PInt(proc.ProcNum) + "'";
                DataConnection dcon = new DataConnection();
                rowsChanged = dcon.NonQ(c);
            }
            else
            {
                //rowsChanged=0;//this means no change is actually required.
            }
            if (proc.Note != oldProc.Note ||
                proc.UserNum != oldProc.UserNum ||
                proc.SigIsTopaz != oldProc.SigIsTopaz ||
                proc.Signature != oldProc.Signature)
            {
                ProcNote note = new ProcNote();
                note.PatNum     = proc.PatNum;
                note.ProcNum    = proc.ProcNum;
                note.UserNum    = proc.UserNum;
                note.Note       = proc.Note;
                note.SigIsTopaz = proc.SigIsTopaz;
                note.Signature  = proc.Signature;
                ProcNoteB.Insert(note);
            }
            return(rowsChanged);
        }
Esempio n. 7
0
        ///<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);
        }
Esempio n. 8
0
        ///<summary>Inserts a new document into db, creates a filename based on Cur.DocNum, and then updates the db with this filename.  Also attaches the document to the current patient.</summary>
        public static int Insert(Document doc, string patLF, int patNum)
        {
            if (PrefB.RandomKeys)
            {
                doc.DocNum = MiscDataB.GetKey("document", "DocNum");
            }
            string command = "INSERT INTO document (";

            if (PrefB.RandomKeys)
            {
                command += "DocNum,";
            }
            command += "Description,DateCreated,DocCategory,WithPat,FileName,ImgType,"
                       + "IsFlipped,DegreesRotated,ToothNumbers,Note,SigIsTopaz,Signature,CropX,CropY,CropW,CropH,"
                       + "WindowingMin,WindowingMax) VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(doc.DocNum) + "', ";
            }
            command +=
                "'" + POut.PString(doc.Description) + "', "
                + POut.PDate(doc.DateCreated) + ", "
                + "'" + POut.PInt(doc.DocCategory) + "', "
                + "'" + POut.PInt(doc.WithPat) + "', "
                + "'" + POut.PString(doc.FileName) + "', "           //this may simply be the extension at this point, or it may be the full filename.
                + "'" + POut.PInt((int)doc.ImgType) + "', "
                + "'" + POut.PBool(doc.IsFlipped) + "', "
                + "'" + POut.PInt(doc.DegreesRotated) + "', "
                + "'" + POut.PString(doc.ToothNumbers) + "', "
                + "'" + POut.PString(doc.Note) + "', "
                + "'" + POut.PBool(doc.SigIsTopaz) + "', "
                + "'" + POut.PString(doc.Signature) + "',"
                + "'" + POut.PInt(doc.CropX) + "',"
                + "'" + POut.PInt(doc.CropY) + "',"
                + "'" + POut.PInt(doc.CropW) + "',"
                + "'" + POut.PInt(doc.CropH) + "',"
                + "'" + POut.PInt(doc.WindowingMin) + "',"
                + "'" + POut.PInt(doc.WindowingMax) + "')";

            /*+"'"+POut.PDate  (LastAltered)+"', "//will later be used in backups
             +"'"+POut.PBool  (IsDeleted)+"')";//ditto*/
            //MessageBox.Show(cmd.CommandText);
            DataConnection dcon = new DataConnection();

            if (PrefB.RandomKeys)
            {
                dcon.NonQ(command);
            }
            else
            {
                dcon.NonQ(command, true);
                doc.DocNum = dcon.InsertID;
            }
            //If the current filename is just an extension, then assign it a unique name.
            if (doc.FileName == Path.GetExtension(doc.FileName))
            {
                string extension = doc.FileName;
                doc.FileName = "";
                string s = patLF;              //pat.LName+pat.FName;
                for (int i = 0; i < s.Length; i++)
                {
                    if (Char.IsLetter(s, i))
                    {
                        doc.FileName += s.Substring(i, 1);
                    }
                }
                doc.FileName += doc.DocNum.ToString() + extension;            //ensures unique name
                //there is still a slight chance that someone manually added a file with this name, so quick fix:
                command = "SELECT FileName FROM document WHERE WithPat=" + POut.PInt(doc.WithPat);
                DataTable table     = dcon.GetTable(command);
                string[]  usedNames = new string[table.Rows.Count];
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    usedNames[i] = PIn.PString(table.Rows[i][0].ToString());
                }
                while (IsFileNameInList(doc.FileName, usedNames))
                {
                    doc.FileName = "x" + doc.FileName;
                }

                /*Document[] docList=GetAllWithPat(doc.WithPat);
                 * while(IsFileNameInList(doc.FileName,docList)) {
                 *      doc.FileName="x"+doc.FileName;
                 * }*/
                Update(doc);
            }
            DocAttach docAttach = new DocAttach();

            docAttach.DocNum = doc.DocNum;
            docAttach.PatNum = patNum;
            DocAttachB.Insert(docAttach);
            return(doc.DocNum);
        }