Beispiel #1
0
        ///<summary></summary>
        internal static void Insert(DocAttach attach)
        {
            if (PrefB.RandomKeys)
            {
                attach.DocAttachNum = MiscDataB.GetKey("docattach", "DocAttachNum");
            }
            string command = "INSERT INTO docattach (";

            if (PrefB.RandomKeys)
            {
                command += "DocAttachNum,";
            }
            command += "PatNum, DocNum) VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(attach.DocAttachNum) + "', ";
            }
            command +=
                "'" + POut.PInt(attach.PatNum) + "', "
                + "'" + POut.PInt(attach.DocNum) + "')";
            DataConnection dcon = new DataConnection();

            if (PrefB.RandomKeys)
            {
                dcon.NonQ(command);
            }
            else
            {
                dcon.NonQ(command, true);
                attach.DocAttachNum = dcon.InsertID;
            }
        }
        ///<summary></summary>
        public static int Insert(EmailMessage message)
        {
            if (PrefB.RandomKeys)
            {
                message.EmailMessageNum = MiscDataB.GetKey("emailmessage", "EmailMessageNum");
            }
            string command = "INSERT INTO emailmessage (";

            if (PrefB.RandomKeys)
            {
                command += "EmailMessageNum,";
            }
            command += "PatNum,ToAddress,FromAddress,Subject,BodyText,"
                       + "MsgDateTime,SentOrReceived) VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(message.EmailMessageNum) + "', ";
            }
            command +=
                "'" + POut.PInt(message.PatNum) + "', "
                + "'" + POut.PString(message.ToAddress) + "', "
                + "'" + POut.PString(message.FromAddress) + "', "
                + "'" + POut.PString(message.Subject) + "', "
                + "'" + POut.PString(message.BodyText) + "', "
                + POut.PDateT(message.MsgDateTime) + ", "
                + "'" + POut.PInt((int)message.SentOrReceived) + "')";
            DataConnection dcon = new DataConnection();

            if (PrefB.RandomKeys)
            {
                dcon.NonQ(command);
            }
            else
            {
                dcon.NonQ(command, true);
                message.EmailMessageNum = dcon.InsertID;
            }
            //now, insert all the attaches.
            for (int i = 0; i < message.Attachments.Count; i++)
            {
                message.Attachments[i].EmailMessageNum = message.EmailMessageNum;
                EmailAttachB.Insert(message.Attachments[i]);
            }
            return(message.EmailMessageNum);
        }
		internal static void Insert(EmailAttach attach){
			if(PrefB.RandomKeys) {
				attach.EmailAttachNum=MiscDataB.GetKey("emailattach","EmailAttachNum");
			}
			string command= "INSERT INTO emailattach (";
			if(PrefB.RandomKeys) {
				command+="EmailAttachNum,";
			}
			command+="EmailMessageNum, DisplayedFileName, ActualFileName) VALUES(";
			if(PrefB.RandomKeys) {
				command+="'"+POut.PInt(attach.EmailAttachNum)+"', ";
			}
			command+=
				 "'"+POut.PInt   (attach.EmailMessageNum)+"', "
				+"'"+POut.PString(attach.DisplayedFileName)+"', "
				+"'"+POut.PString(attach.ActualFileName)+"')";
			//MessageBox.Show(cmd.CommandText);
			DataConnection dcon=new DataConnection();
			dcon.NonQ(command);
		}
Beispiel #4
0
        internal static void Insert(ProcNote procNote)
        {
            if (PrefB.RandomKeys)
            {
                procNote.ProcNoteNum = MiscDataB.GetKey("procnote", "ProcNoteNum");
            }
            string command = "INSERT INTO procnote (";

            if (PrefB.RandomKeys)
            {
                command += "ProcNoteNum,";
            }
            command += "PatNum, ProcNum, EntryDateTime, UserNum, Note, SigIsTopaz, Signature) VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(procNote.ProcNoteNum) + "', ";
            }
            command +=
                "'" + POut.PInt(procNote.PatNum) + "', "
                + "'" + POut.PInt(procNote.ProcNum) + "', ";
            if (DataConnection.DBtype == DatabaseType.Oracle)
            {
                command += POut.PDateT(MiscDataB.GetNowDateTime());
            }
            else              //Assume MySQL
            {
                command += "NOW()";
            }
            command += ", "          //EntryDateTime
                       + "'" + POut.PInt(procNote.UserNum) + "', "
                       + "'" + POut.PString(procNote.Note) + "', "
                       + "'" + POut.PBool(procNote.SigIsTopaz) + "', "
                       + "'" + POut.Base64(procNote.Signature) + "')";
            //MessageBox.Show(cmd.CommandText);
            DataConnection dcon = new DataConnection();

            dcon.NonQ(command);
            //Debug.WriteLine("Sig length: "+procNote.Signature.Length.ToString());
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #7
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);
        }