コード例 #1
0
ファイル: FormRpAging.cs プロジェクト: steev90/opendental
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (!checkBillTypesAll.Checked && listBillType.SelectedIndices.Count == 0)
            {
                MsgBox.Show(this, "At least one billing type must be selected.");
                return;
            }
            if (!checkProvAll.Checked && listProv.SelectedIndices.Count == 0)
            {
                MsgBox.Show(this, "At least one provider must be selected.");
                return;
            }
            if (textDate.errorProvider1.GetError(textDate) != "")
            {
                MsgBox.Show(this, "Invalid date.");
                return;
            }
            DateTime asOfDate = PIn.Date(textDate.Text);

            //The aging report always show historical numbers based on the date entered.
            Ledgers.ComputeAging(0, asOfDate, true);
            ReportSimpleGrid report = new ReportSimpleGrid();
            string           cmd    = "SELECT ";

            if (PrefC.GetBool(PrefName.ReportsShowPatNum))
            {
                cmd += DbHelper.Concat("Cast(PatNum AS CHAR)", "'-'", "LName", "', '", "FName", "' '", "MiddleI");
            }
            else
            {
                cmd += DbHelper.Concat("LName", "', '", "FName", "' '", "MiddleI");
            }
            cmd += ",Bal_0_30,Bal_31_60,Bal_61_90,BalOver90"
                   + ",BalTotal "
                   + ",InsEst"
                   + ",BalTotal-InsEst AS ";            //\"$pat\" ";
            if (DataConnection.DBtype == DatabaseType.MySql)
            {
                cmd += "$pat ";
            }
            else               //Oracle needs quotes.
            {
                cmd += "\"$pat\" ";
            }
            cmd += "FROM patient "
                   + "WHERE ";
            if (checkExcludeInactive.Checked)
            {
                cmd += "(patstatus != 2) AND ";
            }
            if (checkBadAddress.Checked)
            {
                cmd += "(zip !='') AND ";
            }
            if (checkOnlyNeg.Checked)
            {
                cmd += "BalTotal < '-.005' ";
            }
            else
            {
                if (radioAny.Checked)
                {
                    cmd +=
                        "(Bal_0_30 > '.005' OR Bal_31_60 > '.005' OR Bal_61_90 > '.005' OR BalOver90 > '.005'";
                }
                else if (radio30.Checked)
                {
                    cmd +=
                        "(Bal_31_60 > '.005' OR Bal_61_90 > '.005' OR BalOver90 > '.005'";
                }
                else if (radio60.Checked)
                {
                    cmd +=
                        "(Bal_61_90 > '.005' OR BalOver90 > '.005'";
                }
                else if (radio90.Checked)
                {
                    cmd +=
                        "(BalOver90 > '.005'";
                }
                if (checkIncludeNeg.Checked)
                {
                    cmd += " OR BalTotal < '-.005'";
                }
                cmd += ") ";
            }
            if (!checkBillTypesAll.Checked)
            {
                for (int i = 0; i < listBillType.SelectedIndices.Count; i++)
                {
                    if (i == 0)
                    {
                        cmd += " AND (billingtype = ";
                    }
                    else
                    {
                        cmd += " OR billingtype = ";
                    }
                    cmd += POut.Long(DefC.Short[(int)DefCat.BillingTypes][listBillType.SelectedIndices[i]].DefNum);
                }
                cmd += ") ";
            }
            if (!checkProvAll.Checked)
            {
                for (int i = 0; i < listProv.SelectedIndices.Count; i++)
                {
                    if (i == 0)
                    {
                        cmd += " AND (PriProv = ";
                    }
                    else
                    {
                        cmd += " OR PriProv = ";
                    }
                    cmd += POut.Long(ProviderC.ListShort[listProv.SelectedIndices[i]].ProvNum);
                }
                cmd += ") ";
            }
            cmd                += "ORDER BY LName,FName";
            report.Query        = cmd;
            FormQuery2          = new FormQuery(report);
            FormQuery2.IsReport = true;
            FormQuery2.SubmitReportQuery();
            //Recompute aging in a non-historical way, so that the numbers are returned to the way they
            //are normally used in other parts of the program.
            Ledgers.RunAging();
            //if(Prefs.UpdateString(PrefName.DateLastAging",POut.PDate(asOfDate,false))) {
            //	DataValid.SetInvalid(InvalidType.Prefs);
            //}
            report.Title = "AGING OF ACCOUNTS RECEIVABLE REPORT";
            report.SubTitle.Add(PrefC.GetString(PrefName.PracticeTitle));
            report.SubTitle.Add("As of " + textDate.Text);
            if (radioAny.Checked)
            {
                report.SubTitle.Add("Any Balance");
            }
            if (radio30.Checked)
            {
                report.SubTitle.Add("Over 30 Days");
            }
            if (radio60.Checked)
            {
                report.SubTitle.Add("Over 60 Days");
            }
            if (radio90.Checked)
            {
                report.SubTitle.Add("Over 90 Days");
            }
            if (checkBillTypesAll.Checked)
            {
                report.SubTitle.Add("All Billing Types");
            }
            else
            {
                string subt = DefC.Short[(int)DefCat.BillingTypes][listBillType.SelectedIndices[0]].ItemName;
                for (int i = 1; i < listBillType.SelectedIndices.Count; i++)
                {
                    subt += ", " + DefC.Short[(int)DefCat.BillingTypes][listBillType.SelectedIndices[i]].ItemName;
                }
                report.SubTitle.Add(subt);
            }
            //report.InitializeColumns(8);
            report.SetColumn(this, 0, "GUARANTOR", 160);
            report.SetColumn(this, 1, "0-30 DAYS", 80, HorizontalAlignment.Right);
            report.SetColumn(this, 2, "30-60 DAYS", 80, HorizontalAlignment.Right);
            report.SetColumn(this, 3, "60-90 DAYS", 80, HorizontalAlignment.Right);
            report.SetColumn(this, 4, "> 90 DAYS", 80, HorizontalAlignment.Right);
            report.SetColumn(this, 5, "TOTAL", 85, HorizontalAlignment.Right);
            report.SetColumn(this, 6, "-INS EST", 85, HorizontalAlignment.Right);
            report.SetColumn(this, 7, "=PATIENT", 85, HorizontalAlignment.Right);
            FormQuery2.ShowDialog();
            DialogResult = DialogResult.OK;
        }
コード例 #2
0
        private void butImportCanada_Click(object sender, EventArgs e)
        {
            if (!MsgBox.Show(this, true, "If you want a clean slate, the current fee schedule should be cleared first.  When imported, any fees that are found in the text file will overwrite values of the current fee schedule showing in the main window.  Are you sure you want to continue?"))
            {
                return;
            }
            Cursor = Cursors.WaitCursor;
            FormFeeSchedPickRemote formPick = new FormFeeSchedPickRemote();

            formPick.Url = @"http://www.opendental.com/feescanada/";          //points to index.php file
            if (formPick.ShowDialog() != DialogResult.OK)
            {
                Cursor = Cursors.Default;
                return;
            }
            Cursor = Cursors.WaitCursor;          //original wait cursor seems to go away for some reason.
            Application.DoEvents();
            string feeData = "";

            if (formPick.IsFileChosenProtected)
            {
                string memberNumberODA   = "";
                string memberPasswordODA = "";
                if (formPick.FileChosenName.StartsWith("ON_"))                 //Any and all Ontario fee schedules
                {
                    FormFeeSchedPickAuthOntario formAuth = new FormFeeSchedPickAuthOntario();
                    if (formAuth.ShowDialog() != DialogResult.OK)
                    {
                        Cursor = Cursors.Default;
                        return;
                    }
                    memberNumberODA   = formAuth.ODAMemberNumber;
                    memberPasswordODA = formAuth.ODAMemberPassword;
                }
                //prepare the xml document to send--------------------------------------------------------------------------------------
                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Indent      = true;
                settings.IndentChars = ("    ");
                StringBuilder strbuild = new StringBuilder();
                using (XmlWriter writer = XmlWriter.Create(strbuild, settings)) {
                    writer.WriteStartElement("RequestFeeSched");
                    writer.WriteStartElement("RegistrationKey");
                    writer.WriteString(PrefC.GetString(PrefName.RegistrationKey));
                    writer.WriteEndElement();                    //RegistrationKey
                    writer.WriteStartElement("FeeSchedFileName");
                    writer.WriteString(formPick.FileChosenName);
                    writer.WriteEndElement();                    //FeeSchedFileName
                    if (memberNumberODA != "")
                    {
                        writer.WriteStartElement("ODAMemberNumber");
                        writer.WriteString(memberNumberODA);
                        writer.WriteEndElement();                        //ODAMemberNumber
                        writer.WriteStartElement("ODAMemberPassword");
                        writer.WriteString(memberPasswordODA);
                        writer.WriteEndElement();                //ODAMemberPassword
                    }
                    writer.WriteEndElement();                    //RequestFeeSched
                }
#if DEBUG
                OpenDental.localhost.Service1 updateService = new OpenDental.localhost.Service1();
#else
                OpenDental.customerUpdates.Service1 updateService = new OpenDental.customerUpdates.Service1();
                updateService.Url = PrefC.GetString(PrefName.UpdateServerAddress);
#endif
                //Send the message and get the result-------------------------------------------------------------------------------------
                string result = "";
                try {
                    result = updateService.RequestFeeSched(strbuild.ToString());
                }
                catch (Exception ex) {
                    Cursor = Cursors.Default;
                    MessageBox.Show("Error: " + ex.Message);
                    return;
                }
                Cursor = Cursors.Default;
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(result);
                //Process errors------------------------------------------------------------------------------------------------------------
                XmlNode node = doc.SelectSingleNode("//Error");
                if (node != null)
                {
                    MessageBox.Show(node.InnerText, "Error");
                    return;
                }
                node = doc.SelectSingleNode("//KeyDisabled");
                if (node == null)
                {
                    //no error, and no disabled message
                    if (Prefs.UpdateBool(PrefName.RegistrationKeyIsDisabled, false))                    //this is one of three places in the program where this happens.
                    {
                        DataValid.SetInvalid(InvalidType.Prefs);
                    }
                }
                else
                {
                    MessageBox.Show(node.InnerText);
                    if (Prefs.UpdateBool(PrefName.RegistrationKeyIsDisabled, true))                    //this is one of three places in the program where this happens.
                    {
                        DataValid.SetInvalid(InvalidType.Prefs);
                    }
                    return;
                }
                //Process a valid return value------------------------------------------------------------------------------------------------
                node = doc.SelectSingleNode("//ResultCSV64");
                string feeData64    = node.InnerXml;
                byte[] feeDataBytes = Convert.FromBase64String(feeData64);
                feeData = Encoding.UTF8.GetString(feeDataBytes);
            }
            else
            {
                string    tempFile    = Path.GetTempFileName();
                WebClient myWebClient = new WebClient();
                try {
                    myWebClient.DownloadFile(formPick.FileChosenUrl, tempFile);
                }
                catch (Exception ex) {
                    MessageBox.Show(Lan.g(this, "Failed to download fee schedule file") + ": " + ex.Message);
                    Cursor = Cursors.Default;
                    return;
                }
                feeData = File.ReadAllText(tempFile);
                File.Delete(tempFile);
            }
            string[] feeLines = feeData.Split('\n');
            double   feeAmt;
            long     numImported = 0;
            long     numSkipped  = 0;
            for (int i = 0; i < feeLines.Length; i++)
            {
                string[] fields = feeLines[i].Split('\t');
                if (fields.Length > 1)               // && fields[1]!=""){//we no longer skip blank fees
                {
                    string procCode = fields[0];
                    if (ProcedureCodes.IsValidCode(procCode))                      //The Fees.Import() function will not import fees for codes that do not exist.
                    {
                        if (fields[1] == "")
                        {
                            feeAmt = -1;                          //triggers deletion of existing fee, but no insert.
                        }
                        else
                        {
                            feeAmt = PIn.Double(fields[1]);
                        }
                        Fees.Import(procCode, feeAmt, SchedNum);
                        numImported++;
                    }
                    else
                    {
                        numSkipped++;
                    }
                }
            }
            DataValid.SetInvalid(InvalidType.Fees);
            Cursor       = Cursors.Default;
            DialogResult = DialogResult.OK;
            string outputMessage = Lan.g(this, "Done. Number imported") + ": " + numImported;
            if (numSkipped > 0)
            {
                outputMessage += " " + Lan.g(this, "Number skipped") + ": " + numSkipped;
            }
            MessageBox.Show(outputMessage);
        }
コード例 #3
0
ファイル: FormImportXML.cs プロジェクト: kjb7749/testImport
        ///<summary></summary>
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textMain.Text == "")
            {
                MsgBox.Show(this, "Please paste the text generated by the other program into the large box first.");
                return;
            }
            pat               = new Patient();
            pat.PriProv       = PrefC.GetLong(PrefName.PracticeDefaultProv);
            pat.BillingType   = PrefC.GetLong(PrefName.PracticeDefaultBillType);
            guar              = new Patient();
            guar.PriProv      = PrefC.GetLong(PrefName.PracticeDefaultProv);
            guar.BillingType  = PrefC.GetLong(PrefName.PracticeDefaultBillType);
            subsc             = new Patient();
            subsc.PriProv     = PrefC.GetLong(PrefName.PracticeDefaultProv);
            subsc.BillingType = PrefC.GetLong(PrefName.PracticeDefaultBillType);
            sub               = new InsSub();
            sub.ReleaseInfo   = true;
            sub.AssignBen     = true;
            plan              = new InsPlan();
            carrier           = new Carrier();
            insRelat          = "self"; //this is the default if not included
            guarRelat         = "self";
            InsEmp            = "";
            GuarEmp           = "";
            NoteMedicalComp   = "";
            insPresent        = false;
            annualMax         = -1;
            deductible        = -1;
            XmlTextReader reader = new XmlTextReader(new StringReader(textMain.Text));

            reader.WhitespaceHandling = WhitespaceHandling.None;
            string element     = "";
            string textValue   = "";
            string rootElement = "";
            string segment     = "";    //eg PatientIdentification
            string field       = "";    //eg NameLast
            string endelement  = "";

            warnings = "";
            try{
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        element = reader.Name;
                        if (rootElement == "")                              //should be the first node
                        {
                            if (element == "Message")
                            {
                                rootElement = "Message";
                            }
                            else
                            {
                                throw new Exception(element + " should not be the first element.");
                            }
                        }
                        else if (segment == "")                              //expecting a new segment
                        {
                            segment = element;
                            if (segment != "MessageHeader" &&
                                segment != "PatientIdentification" &&
                                segment != "Guarantor" &&
                                segment != "Insurance")
                            {
                                throw new Exception(segment + " is not a recognized segment.");
                            }
                        }
                        else                                 //expecting a new field
                        {
                            field = element;
                        }
                        if (segment == "Insurance")
                        {
                            insPresent = true;
                        }
                        break;

                    case XmlNodeType.Text:
                        textValue = reader.Value;
                        if (field == "")
                        {
                            throw new Exception("Unexpected text: " + textValue);
                        }
                        break;

                    case XmlNodeType.EndElement:
                        endelement = reader.Name;
                        if (field == "")                              //we're not in a field, so we must be closing a segment or rootelement
                        {
                            if (segment == "")                        //we're not in a segment, so we must be closing the rootelement
                            {
                                if (rootElement == "Message")
                                {
                                    rootElement = "";
                                }
                                else
                                {
                                    throw new Exception("Message closing element expected.");
                                }
                            }
                            else                                     //must be closing a segment
                            {
                                segment = "";
                            }
                        }
                        else                                 //closing a field
                        {
                            field     = "";
                            textValue = "";
                        }
                        break;
                    }                    //switch
                    if (rootElement == "")
                    {
                        break;                        //this will ignore anything after the message endelement
                    }
                    if (field != "" && textValue != "")
                    {
                        if (segment == "MessageHeader")
                        {
                            ProcessMSH(field, textValue);
                        }
                        else if (segment == "PatientIdentification")
                        {
                            ProcessPID(field, textValue);
                        }
                        else if (segment == "Guarantor")
                        {
                            ProcessGT(field, textValue);
                        }
                        else if (segment == "Insurance")
                        {
                            ProcessINS(field, textValue);
                        }
                    }
                }                //while
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                //MsgBox.Show(this,"Error in the XML format.");
                reader.Close();
                return;
            }
            finally{
                reader.Close();
            }
            //Warnings and errors-----------------------------------------------------------------------------
            if (pat.LName == "" || pat.FName == "" || pat.Birthdate.Year < 1880)
            {
                MsgBox.Show(this, "Patient first and last name and birthdate are required.  Could not import.");
                return;
            }
            //if guarRelat is not self, and name and birthdate not supplied, no error.  Just make guar self.
            if (guarRelat != "self")
            {
                if (guar.LName == "" || guar.FName == "" || guar.Birthdate.Year < 1880)
                {
                    warnings += "Guarantor information incomplete.  Guarantor will be self.\r\n";
                    guarRelat = "self";
                }
            }
            if (insPresent)
            {
                if (carrier.CarrierName == "")
                {
                    warnings  += "Insurance CompanyName is missing. No insurance info will be imported.\r\n";
                    insPresent = false;
                }
                else if (insRelat != "self")
                {
                    if (subsc.LName == "" || subsc.FName == "" || subsc.Birthdate.Year < 1880)
                    {
                        warnings  += "Subscriber name or birthdate is missing. No insurance info will be imported.\r\n";
                        insPresent = false;
                    }
                }
                else if (sub.SubscriberID == "")
                {
                    warnings        += "PolicyNumber/SubscriberID missing.\r\n";
                    sub.SubscriberID = " ";
                }
            }
            if (warnings != "")
            {
                if (MessageBox.Show("It's safe to import, but you should be aware of the following issues:\r\n" + warnings + "\r\nContinue with Import?", "Warnings", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }
            }

            //Patient-------------------------------------------------------------------------------------
            //DataTable table;
            long    patNum      = Patients.GetPatNumByNameAndBirthday(pat.LName, pat.FName, pat.Birthdate);
            Patient existingPat = null;

            existingPatOld = null;      //we will need this to do an update.
            if (patNum != 0)            //a patient already exists, so only add missing fields
            {
                existingPat    = Patients.GetPat(patNum);
                existingPatOld = existingPat.Copy();
                if (existingPat.MiddleI == "")              //only alter existing if blank
                {
                    existingPat.MiddleI = pat.MiddleI;
                }
                if (pat.Gender != PatientGender.Unknown)
                {
                    existingPat.Gender = pat.Gender;
                }
                if (existingPat.Preferred == "")
                {
                    existingPat.Preferred = pat.Preferred;
                }
                if (existingPat.Address == "")
                {
                    existingPat.Address = pat.Address;
                }
                if (existingPat.Address2 == "")
                {
                    existingPat.Address2 = pat.Address2;
                }
                if (existingPat.City == "")
                {
                    existingPat.City = pat.City;
                }
                if (existingPat.State == "")
                {
                    existingPat.State = pat.State;
                }
                if (existingPat.Zip == "")
                {
                    existingPat.Zip = pat.Zip;
                }
                if (existingPat.HmPhone == "")
                {
                    existingPat.HmPhone = pat.HmPhone;
                }
                if (existingPat.Email == "")
                {
                    existingPat.Email = pat.Email;
                }
                if (existingPat.WkPhone == "")
                {
                    existingPat.WkPhone = pat.WkPhone;
                }
                if (existingPat.Position == PatientPosition.Single)
                {
                    existingPat.Position = pat.Position;
                }
                if (existingPat.SSN == "")
                {
                    existingPat.SSN = pat.SSN;
                }
                existingPat.AddrNote += pat.AddrNote;              //concat
                Patients.Update(existingPat, existingPatOld);
                PatientNote PatientNoteCur = PatientNotes.Refresh(existingPat.PatNum, existingPat.Guarantor);
                PatientNoteCur.MedicalComp += NoteMedicalComp;
                PatientNotes.Update(PatientNoteCur, existingPat.Guarantor);
                //guarantor will not be altered in any way
            }            //if patient already exists
            else         //patient is new, so insert
            {
                Patients.Insert(pat, false);
                SecurityLogs.MakeLogEntry(Permissions.PatientCreate, pat.PatNum, "Created from Import Patient XML tool.");
                existingPatOld = pat.Copy();
                pat.Guarantor  = pat.PatNum;             //this can be changed later.
                Patients.Update(pat, existingPatOld);
                PatientNote PatientNoteCur = PatientNotes.Refresh(pat.PatNum, pat.Guarantor);
                PatientNoteCur.MedicalComp += NoteMedicalComp;
                PatientNotes.Update(PatientNoteCur, pat.Guarantor);
            }
            //guar-----------------------------------------------------------------------------------------------------
            if (existingPat == null)          //only add or alter guarantor for new patients
            {
                if (guarRelat == "self")
                {
                    //pat is already set with guar as self
                    //ignore all guar fields except EmployerName
                    existingPatOld  = pat.Copy();
                    pat.EmployerNum = Employers.GetEmployerNum(GuarEmp);
                    Patients.Update(pat, existingPatOld);
                }
                else
                {
                    //if guarRelat is not self, and name and birthdate not supplied, a warning was issued, and relat was changed to self.
                    //add guarantor or attach to an existing guarantor
                    long guarNum = Patients.GetPatNumByNameAndBirthday(guar.LName, guar.FName, guar.Birthdate);
                    if (guarNum != 0)                    //a guar already exists, so simply attach. Make no other changes
                    {
                        existingPatOld = pat.Copy();
                        pat.Guarantor  = guarNum;
                        if (guarRelat == "parent")
                        {
                            pat.Position = PatientPosition.Child;
                        }
                        Patients.Update(pat, existingPatOld);
                    }
                    else                     //we need to completely create guar, then attach
                    {
                        Patients.Insert(guar, false);
                        SecurityLogs.MakeLogEntry(Permissions.PatientCreate, guar.PatNum, "Created from Import Patient XML tool.");
                        //set guar for guar
                        existingPatOld   = guar.Copy();
                        guar.Guarantor   = guar.PatNum;
                        guar.EmployerNum = Employers.GetEmployerNum(GuarEmp);
                        Patients.Update(guar, existingPatOld);
                        //set guar for pat
                        existingPatOld = pat.Copy();
                        pat.Guarantor  = guar.PatNum;
                        if (guarRelat == "parent")
                        {
                            pat.Position = PatientPosition.Child;
                        }
                        Patients.Update(pat, existingPatOld);
                    }
                }
            }
            //subsc--------------------------------------------------------------------------------------------------
            if (!insPresent)
            {
                //this takes care of missing carrier name or subscriber info.
                MsgBox.Show(this, "Done");
                DialogResult = DialogResult.OK;
            }
            if (insRelat == "self")
            {
                sub.Subscriber = pat.PatNum;
            }
            else             //we need to find or add the subscriber
            {
                patNum = Patients.GetPatNumByNameAndBirthday(subsc.LName, subsc.FName, subsc.Birthdate);
                if (patNum != 0)                //a subsc already exists, so simply attach. Make no other changes
                {
                    sub.Subscriber = patNum;
                }
                else                 //need to create and attach a subscriber
                {
                    Patients.Insert(subsc, false);
                    SecurityLogs.MakeLogEntry(Permissions.PatientCreate, subsc.PatNum, "Created from Import Patient XML tool.");
                    //set guar to same guar as patient
                    existingPatOld  = subsc.Copy();
                    subsc.Guarantor = pat.Guarantor;
                    Patients.Update(subsc, existingPatOld);
                    sub.Subscriber = subsc.PatNum;
                }
            }
            //carrier-------------------------------------------------------------------------------------------------
            //Carriers.Cur=carrier;
            carrier = Carriers.GetIdentical(carrier);          //this automatically finds or creates a carrier
            //plan------------------------------------------------------------------------------------------------------
            plan.EmployerNum = Employers.GetEmployerNum(InsEmp);
            plan.CarrierNum  = carrier.CarrierNum;
            InsPlans.Insert(plan);
            //Attach plan to subscriber
            sub.PlanNum = plan.PlanNum;
            InsSubs.Insert(sub);
            //Then attach plan
            List <PatPlan> PatPlanList = PatPlans.Refresh(pat.PatNum);
            PatPlan        patplan     = new PatPlan();

            patplan.Ordinal   = (byte)(PatPlanList.Count + 1);      //so the ordinal of the first entry will be 1, NOT 0.
            patplan.PatNum    = pat.PatNum;
            patplan.InsSubNum = sub.InsSubNum;
            switch (insRelat)
            {
            case "self":
                patplan.Relationship = Relat.Self;
                break;

            case "parent":
                patplan.Relationship = Relat.Child;
                break;

            case "spouse":
                patplan.Relationship = Relat.Spouse;
                break;

            case "guardian":
                patplan.Relationship = Relat.Dependent;
                break;
            }
            PatPlans.Insert(patplan);
            //benefits
            if (annualMax != -1 && CovCats.GetCount(true) > 0)
            {
                Benefit ben = new Benefit();
                ben.BenefitType = InsBenefitType.Limitations;
                ben.CovCatNum   = CovCats.GetFirst(true).CovCatNum;
                ben.MonetaryAmt = annualMax;
                ben.PlanNum     = plan.PlanNum;
                ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                Benefits.Insert(ben);
            }
            if (deductible != -1 && CovCats.GetCount(true) > 0)
            {
                Benefit ben = new Benefit();
                ben.BenefitType = InsBenefitType.Deductible;
                ben.CovCatNum   = CovCats.GetFirst(true).CovCatNum;
                ben.MonetaryAmt = deductible;
                ben.PlanNum     = plan.PlanNum;
                ben.TimePeriod  = BenefitTimePeriod.CalendarYear;
                Benefits.Insert(ben);
            }
            MsgBox.Show(this, "Done");
            DialogResult = DialogResult.OK;
        }
コード例 #4
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (checkEnabled.Checked && textPluginDllName.Text != "")
            {
                if (ODBuild.IsWeb())
                {
                    MessageBox.Show(Lan.g(this, "Plugins are not allowed in Cloud mode."));
                    return;
                }
                string dllPath = ODFileUtils.CombinePaths(Application.StartupPath, textPluginDllName.Text);
                if (dllPath.Contains("[VersionMajMin]"))
                {
                    Version vers = new Version(Application.ProductVersion);
                    dllPath = dllPath.Replace("[VersionMajMin]", "");                   //now stripped clean
                }
                if (!File.Exists(dllPath))
                {
                    MessageBox.Show(Lan.g(this, "Dll file not found:") + " " + dllPath);
                    return;
                }
            }
            if (textPluginDllName.Text != "" && textPath.Text != "")
            {
                if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "If both a path and a plug-in are specified, the path will be ignored.  Continue anyway?"))
                {
                    return;
                }
            }
            ProgramCur.ProgName = textProgName.Text;
            ProgramCur.ProgDesc = textProgDesc.Text;
            ProgramCur.Enabled  = checkEnabled.Checked;
            ProgramCur.Path     = textPath.Text;
            if (pathOverrideOld != textOverride.Text)
            {
                ProgramProperties.InsertOrUpdateLocalOverridePath(ProgramCur.ProgramNum, textOverride.Text);
                ProgramProperties.RefreshCache();
            }
            ProgramCur.CommandLine   = textCommandLine.Text;
            ProgramCur.PluginDllName = textPluginDllName.Text;
            ProgramCur.Note          = textNote.Text;
            ProgramCur.ButtonImage   = POut.Bitmap((Bitmap)pictureBox.Image, System.Drawing.Imaging.ImageFormat.Png);
            if (IsNew)
            {
                Programs.Insert(ProgramCur);
            }
            else
            {
                Programs.Update(ProgramCur);
            }
            ToolButItems.DeleteAllForProgram(ProgramCur.ProgramNum);
            //then add one toolButItem for each highlighted row in listbox
            ToolButItem ToolButItemCur;

            for (int i = 0; i < listToolBars.SelectedIndices.Count; i++)
            {
                ToolButItemCur            = new ToolButItem();
                ToolButItemCur.ProgramNum = ProgramCur.ProgramNum;
                ToolButItemCur.ButtonText = textButtonText.Text;
                ToolButItemCur.ToolBar    = (ToolBarsAvail)listToolBars.SelectedIndices[i];
                ToolButItems.Insert(ToolButItemCur);
            }
            DialogResult = DialogResult.OK;
        }
コード例 #5
0
        private void butImport_Click(object sender, EventArgs e)
        {
            if (!MsgBox.Show(this, true, "If you want a clean slate, the current fee schedule should be cleared first.  When imported, any fees that are found in the text file will overwrite values of the current fee schedule showing in the main window.  Are you sure you want to continue?"))
            {
                return;
            }
            Cursor = Cursors.WaitCursor;
            OpenFileDialog Dlg = new OpenFileDialog();

            if (Directory.Exists(PrefC.GetString(PrefName.ExportPath)))
            {
                Dlg.InitialDirectory = PrefC.GetString(PrefName.ExportPath);
            }
            else if (Directory.Exists("C:\\"))
            {
                Dlg.InitialDirectory = "C:\\";
            }
            if (Dlg.ShowDialog() != DialogResult.OK)
            {
                Cursor = Cursors.Default;
                return;
            }
            if (!File.Exists(Dlg.FileName))
            {
                Cursor = Cursors.Default;
                MsgBox.Show(this, "File not found");
                return;
            }
            string[] fields;
            double   feeAmt;

            using (StreamReader sr = new StreamReader(Dlg.FileName)){
                string line = sr.ReadLine();
                while (line != null)
                {
                    Cursor = Cursors.WaitCursor;
                    fields = line.Split(new string[1] {
                        "\t"
                    }, StringSplitOptions.None);
                    if (fields.Length > 1)                  // && fields[1]!=""){//we no longer skip blank fees
                    {
                        if (fields[1] == "")
                        {
                            feeAmt = -1;                          //triggers deletion of existing fee, but no insert.
                        }
                        else
                        {
                            feeAmt = PIn.Double(fields[1]);
                        }
                        Fees.Import(fields[0], feeAmt, SchedNum);
                        SecurityLogs.MakeLogEntry(Permissions.ProcFeeEdit, 0, Lan.g(this, "Procedure") + ": " + fields[0]
                                                  + ", " + Lan.g(this, "Fee") + ": " + feeAmt.ToString("c") + ", " + Lan.g(this, "Fee Schedule") + ": " + FeeScheds.GetDescription(SchedNum)
                                                  + ". " + Lan.g(this, "Fee changed using the Import button in the Fee Tools window."), ProcedureCodes.GetCodeNum(fields[0]));
                    }
                    line = sr.ReadLine();
                }
            }
            DataValid.SetInvalid(InvalidType.Fees);
            Cursor       = Cursors.Default;
            DialogResult = DialogResult.OK;
        }
コード例 #6
0
		private void butSave_Click(object sender,EventArgs e) {
			if(Prefs.UpdateString(PrefName.TerminalClosePassword,textPassword.Text)){
				DataValid.SetInvalid(InvalidType.Prefs);
			}
			MsgBox.Show(this,"Done.");
		}
コード例 #7
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            string[] fieldsSelected = new string[listSelect.SelectedItems.Count + listSelect2.SelectedItems.Count];
            if (listSelect.SelectedItems.Count == 0 && listSelect2.SelectedItems.Count == 0)
            {
                MsgBox.Show(this, "At least one field must be selected.");
                return;
            }
            listSelect.SelectedItems.CopyTo(fieldsSelected, 0);
            listSelect2.SelectedItems.CopyTo(fieldsSelected, listSelect.SelectedItems.Count);
            string command = "SELECT ";

            for (int i = 0; i < fieldsSelected.Length; i++)
            {
                if (i > 0)
                {
                    command += ",";
                }
                if (fieldsSelected[i] == "AptDateTime")
                {
                    command += "appointment.AptDateTime";
                }
                else if (fieldsSelected[i] == "PriCarrier")
                {
                    command += "(SELECT carrier.CarrierName FROM patplan,inssub,insplan,carrier WHERE patplan.PatNum=patient.PatNum "
                               + "AND patplan.InsSubNum=inssub.InsSubNum AND inssub.PlanNum=insplan.PlanNum AND insplan.CarrierNum=carrier.CarrierNum AND patplan.Ordinal=1 " + DbHelper.LimitAnd(1) + ") PriCarrier";
                }
                else if (fieldsSelected[i] == "PriRelationship")
                {
                    command += "(SELECT Relationship FROM patplan WHERE patplan.PatNum=patient.PatNum AND patplan.Ordinal=1 " + DbHelper.LimitAnd(1) + ") PriRelationship";
                }
                else if (fieldsSelected[i] == "SecCarrier")
                {
                    command += "(SELECT carrier.CarrierName FROM patplan,inssub,insplan,carrier WHERE patplan.PatNum=patient.PatNum "
                               + "AND patplan.InsSubNum=inssub.InsSubNum AND inssub.PlanNum=insplan.PlanNum AND insplan.CarrierNum=carrier.CarrierNum AND patplan.Ordinal=2 " + DbHelper.LimitAnd(1) + ") SecCarrier";
                }
                else if (fieldsSelected[i] == "SecRelationship")
                {
                    command += "(SELECT Relationship FROM patplan WHERE patplan.PatNum=patient.PatNum AND patplan.Ordinal=2 " + DbHelper.LimitAnd(1) + ") SecRelationship";
                }
                else
                {
                    command += "patient." + fieldsSelected[i];
                }
            }
            command += " FROM patient,appointment "
                       + "WHERE patient.PatNum=appointment.PatNum AND(";
            for (int i = 0; i < AptNums.Length; i++)
            {
                if (i > 0)
                {
                    command += " OR";
                }
                command += " appointment.AptNum='" + AptNums[i] + "'";
            }
            command += ")";
            ReportSimpleGrid report = new ReportSimpleGrid();

            report.Query = command;
            FormQuery FormQ = new FormQuery(report);

            FormQ.IsReport = false;
            FormQ.SubmitQuery();
            FormQ.textQuery.Text = report.Query;
            FormQ.ShowDialog();
            DialogResult = DialogResult.OK;
        }
コード例 #8
0
        private bool VerifyData(out int expYear, out int expMonth)
        {
            expYear  = 0;
            expMonth = 0;
            if (_trantype == PaySimple.TransType.SALE && !Regex.IsMatch(textAmount.Text, "^[0-9]+$") && !Regex.IsMatch(textAmount.Text, "^[0-9]*\\.[0-9]+$"))
            {
                MsgBox.Show(this, "Invalid amount.");
                return(false);
            }
            if ((_trantype == PaySimple.TransType.VOID || _trantype == PaySimple.TransType.RETURN) &&    //The reference number is optional for terminal returns.
                textRefNumber.Text == "")
            {
                MsgBox.Show(this, "Ref Number required.");
                return(false);
            }
            string paytype = ProgramProperties.GetPropValForClinicOrDefault(_progCur.ProgramNum, PaySimple.PropertyDescs.PaySimplePayType, _clinicNum);

            if (!Defs.GetDefsForCategory(DefCat.PaymentTypes, true).Any(x => x.DefNum.ToString() == paytype))           //paytype is not a valid DefNum
            {
                MsgBox.Show(this, "The PaySimple payment type has not been set.");
                return(false);
            }
            //Processing through Web Service
            // Consider adding more advanced verification methods using PaySimple validation requests.
            if (textCardNumber.Text.Trim().Length < 5)
            {
                MsgBox.Show(this, "Invalid Card Number.");
                return(false);
            }
            try {                                                         //PIn.Int will throw an exception if not a valid format
                if (Regex.IsMatch(textExpDate.Text, @"^\d\d[/\- ]\d\d$")) //08/07 or 08-07 or 08 07
                {
                    expYear  = PIn.Int("20" + textExpDate.Text.Substring(3, 2));
                    expMonth = PIn.Int(textExpDate.Text.Substring(0, 2));
                }
                else if (Regex.IsMatch(textExpDate.Text, @"^\d{4}$"))                //0807
                {
                    expYear  = PIn.Int("20" + textExpDate.Text.Substring(2, 2));
                    expMonth = PIn.Int(textExpDate.Text.Substring(0, 2));
                }
                else
                {
                    MsgBox.Show(this, "Expiration format invalid.");
                    return(false);
                }
            }
            catch (Exception) {
                MsgBox.Show(this, "Expiration format invalid.");
                return(false);
            }
            if (_creditCardCur == null)           //if the user selected a new CC, verify through PaySimple
            //using a new CC and the card number entered contains something other than digits
            {
                if (textCardNumber.Text.Any(x => !char.IsDigit(x)))
                {
                    MsgBox.Show(this, "Invalid card number.");
                    return(false);
                }
            }
            else if (_creditCardCur.PaySimpleToken == "" && Regex.IsMatch(textCardNumber.Text, @"X+[0-9]{4}"))          //using a stored CC
            {
                MsgBox.Show(this, "There is no saved PaySimple token for this credit card.  The card number and expiration must be re-entered.");
                return(false);
            }
            if (textNameOnCard.Text.Trim() == "" && _patCur != null && _patCur.PatNum > 0)       //Name required for patient credit cards, not prepaid cards.
            {
                MsgBox.Show(this, "Name On Card required.");
                return(false);
            }
            //verify the selected clinic has a username and password type entered
            if (string.IsNullOrWhiteSpace(ProgramProperties.GetPropValForClinicOrDefault(_progCur.ProgramNum, PaySimple.PropertyDescs.PaySimpleApiUserName, _clinicNum)) ||
                string.IsNullOrWhiteSpace(ProgramProperties.GetPropValForClinicOrDefault(_progCur.ProgramNum, PaySimple.PropertyDescs.PaySimpleApiKey, _clinicNum)))                  //if username or password is blank
            {
                MsgBox.Show(this, "The PaySimple username and/or key has not been set.");
                return(false);
            }
            return(true);
        }
コード例 #9
0
        ///<summary>Checks to see if the appointments provider has at least one mismatch provider on all the completed procedures attached to the appointment.
        ///If so, checks to see if the user has permission to edit a completed procedure. If the user does, then the user has the option to change the provider to match.</summary>
        public static bool DoRemoveCompletedProcs(Appointment apt, List <Procedure> listProcsForAppt, bool checkForAllProcCompl = false)
        {
            if (listProcsForAppt.Count == 0)
            {
                return(false);
            }
            if (checkForAllProcCompl && (apt.AptStatus != ApptStatus.Complete || listProcsForAppt.All(x => x.ProcStatus == ProcStat.C)))
            {
                return(false);
            }
            List <Procedure> listCompletedProcWithDifferentProv = new List <Procedure>();

            foreach (Procedure proc in listProcsForAppt)
            {
                if (proc.ProcStatus != ProcStat.C || proc.AptNum != apt.AptNum)             //should all be complete already.
                {
                    continue;
                }
                ProcedureCode procCode = ProcedureCodes.GetProcCode(proc.CodeNum);
                long          provNum  = Procedures.GetProvNumFromAppointment(apt, proc, procCode);
                if (provNum != proc.ProvNum)
                {
                    listCompletedProcWithDifferentProv.Add(proc);
                }
            }
            if (listCompletedProcWithDifferentProv.Count == 0)
            {
                return(true);               //All completed procs match appt, so ignore completed procedures when running Procedures.UpdateProcsInApptHelper()
            }
            if (PrefC.GetBool(PrefName.ProcProvChangesClaimProcWithClaim))
            {
                List <ClaimProc> listClaimProcs = ClaimProcs.RefreshForProcs(listCompletedProcWithDifferentProv.Select(x => x.ProcNum).ToList());
                if (listClaimProcs.Any(x => x.Status == ClaimProcStatus.Received ||
                                       x.Status == ClaimProcStatus.Supplemental ||
                                       x.Status == ClaimProcStatus.CapClaim))
                {
                    MsgBox.Show("Procedures", "The appointment provider does not match the provider on at least one procedure that is attached "
                                + "to a claim.\r\nThe provider on the procedure(s) cannot be changed.");
                    return(true);
                }
            }
            List <PaySplit> listPaySplit = PaySplits.GetPaySplitsFromProcs(listCompletedProcWithDifferentProv.Select(x => x.ProcNum).ToList());

            if (listPaySplit.Count > 0)
            {
                MsgBox.Show("Procedures", "The appointment provider does not match the provider on at least one completed procedure.\r\n"
                            + "The procedure provider cannot be changed to match the appointment provider because the paysplit provider would no longer match.  "
                            + "Any change to the provider on the completed procedure(s) or paysplit(s) will have to be made manually.");
                return(true);               //paysplits exist on one of the completed procedures. Per Nathan, don't change the provider. User will need to change manually.
            }
            foreach (Procedure proc in listCompletedProcWithDifferentProv)
            {
                Permissions perm = Permissions.ProcComplEdit;
                if (proc.ProcStatus.In(ProcStat.EC, ProcStat.EO))
                {
                    perm = Permissions.ProcExistingEdit;
                }
                if (Security.IsGlobalDateLock(perm, proc.ProcDate))
                {
                    return(true);
                }
                if (!Security.IsAuthorized(perm, proc.ProcDate, true, true))
                {
                    MessageBox.Show(Lan.g("Procedures", "The appointment provider does not match the provider on at least one completed procedure.") + "\r\n"
                                    + Lans.g("Procedures", "Not authorized for") + ": " + GroupPermissions.GetDesc(perm) + "\r\n"
                                    + Lan.g("Procedures", "Any change to the provider on the completed procedure(s) will have to be made manually."));
                    return(true);                   //user does not have permission to change the provider. Don't change provider.
                }
            }
            //The appointment is set complete, completed procedures exist, and provider does not match appointment.
            //Ask if they would like to change the providers on the completed procedure to match the appointments provider
            if (!MsgBox.Show("Procedures", MsgBoxButtons.YesNo, "The appointment provider does not match the provider on at least one completed procedure.\r\n"
                             + "Change the provider on the completed procedure(s) to match the provider on the appointment?"))
            {
                return(true);               //user does not want to change the providers
            }
            //user wants to change the provider on the completed procedure
            return(false);
        }
コード例 #10
0
        ///<summary>Return false to indicate exit app.  Only called when program first starts up at the beginning of FormOpenDental.PrefsStartup.</summary>
        public bool Convert(string fromVersion, string toVersion, bool silent)
        {
            FromVersion = new Version(fromVersion);
            ToVersion   = new Version(toVersion);        //Application.ProductVersion);
            if (FromVersion >= new Version("3.4.0") && PrefC.GetBool(PrefName.CorruptedDatabase))
            {
                MsgBox.Show(this, "Your database is corrupted because a conversion failed.  Please contact us.  This database is unusable and you will need to restore from a backup.");
                return(false);               //shuts program down.
            }
            if (FromVersion == ToVersion)
            {
                return(true);                         //no conversion necessary
            }
            if (FromVersion.CompareTo(ToVersion) > 0) //"Cannot convert database to an older version."
            //no longer necessary to catch it here.  It will be handled soon enough in CheckProgramVersion
            {
                return(true);
            }
            if (FromVersion < new Version("2.8.0"))
            {
                MsgBox.Show(this, "This database is too old to easily convert in one step. Please upgrade to 2.1 if necessary, then to 2.8.  Then you will be able to upgrade to this version. We apologize for the inconvenience.");
                return(false);
            }
            if (FromVersion < new Version("6.6.2"))
            {
                MsgBox.Show(this, "This database is too old to easily convert in one step. Please upgrade to 11.1 first.  Then you will be able to upgrade to this version. We apologize for the inconvenience.");
                return(false);
            }
            if (FromVersion < new Version("3.0.1"))
            {
                MsgBox.Show(this, "This is an old database.  The conversion must be done using MySQL 4.1 (not MySQL 5.0) or it will fail.");
            }
            if (FromVersion.ToString() == "2.9.0.0" || FromVersion.ToString() == "3.0.0.0" || FromVersion.ToString() == "4.7.0.0")
            {
                MsgBox.Show(this, "Cannot convert this database version which was only for development purposes.");
                return(false);
            }
            if (FromVersion > new Version("4.7.0") && FromVersion.Build == 0)
            {
                MsgBox.Show(this, "Cannot convert this database version which was only for development purposes.");
                return(false);
            }
            if (FromVersion >= ConvertDatabases.LatestVersion)
            {
                return(true);               //no conversion necessary
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                MsgBox.Show(this, "Web client cannot convert database.  Must be using a direct connection.");
                return(false);
            }
            if (ReplicationServers.ServerIsBlocked())
            {
                MsgBox.Show(this, "This replication server is blocked from performing updates.");
                return(false);
            }
#if TRIALONLY
            //Trial users should never be able to update a database.
            MsgBox.Show(this, "Trial versions cannot connect to live databases.  Please run the Setup.exe in the AtoZ folder to reinstall your original version.");
            return(false);
#endif
            if (PrefC.GetString(PrefName.WebServiceServerName) != "" &&       //using web service
                !ODEnvironment.IdIsThisComputer(PrefC.GetString(PrefName.WebServiceServerName).ToLower()))                   //and not on web server
            {
#if !DEBUG
                MessageBox.Show(Lan.g(this, "Updates are only allowed from the web server: ") + PrefC.GetString(PrefName.WebServiceServerName));
                return(false);
#endif
            }
            //If MyISAM and InnoDb mix, then try to fix
            if (DataConnection.DBtype == DatabaseType.MySql)                    //not for Oracle
            {
                string namesInnodb = DatabaseMaintenance.GetInnodbTableNames(); //Or possibly some other format.
                int    numMyisam   = DatabaseMaintenance.GetMyisamTableCount();
                if (namesInnodb != "" && numMyisam > 0)
                {
                    MessageBox.Show(Lan.g(this, "A mixture of database tables in InnoDB and MyISAM format were found.  A database backup will now be made, and then the following InnoDB tables will be converted to MyISAM format: ") + namesInnodb);
                    try {
                        MiscData.MakeABackup();                        //Does not work for Oracle, due to some MySQL specific commands inside.
                    }
                    catch (Exception e) {
                        Cursor.Current = Cursors.Default;
                        if (e.Message != "")
                        {
                            MessageBox.Show(e.Message);
                        }
                        MsgBox.Show(this, "Backup failed. Your database has not been altered.");
                        return(false);
                    }
                    if (!DatabaseMaintenance.ConvertTablesToMyisam())
                    {
                        MessageBox.Show(Lan.g(this, "Failed to convert InnoDB tables to MyISAM format. Please contact support."));
                        return(false);
                    }
                    MessageBox.Show(Lan.g(this, "All tables converted to MyISAM format successfully."));
                    namesInnodb = "";
                }
                if (namesInnodb == "" && numMyisam > 0)             //if all tables are myisam
                //but default storage engine is innodb, then kick them out.
                {
                    if (DatabaseMaintenance.GetStorageEngineDefaultName().ToUpper() != "MYISAM")                    //Probably InnoDB but could be another format.
                    {
                        MessageBox.Show(Lan.g(this, "The database tables are in MyISAM format, but the default database engine format is InnoDB. You must change the default storage engine within the my.ini (or my.cnf) file on the database server and restart MySQL in order to fix this problem. Exiting."));
                        return(false);
                    }
                }
            }
#if DEBUG
            if (!silent && MessageBox.Show("You are in Debug mode.  Your database can now be converted" + "\r"
                                           + "from version" + " " + FromVersion.ToString() + "\r"
                                           + "to version" + " " + ToVersion.ToString() + "\r"
                                           + "You can click Cancel to skip conversion and attempt to the newer code against the older database."
                                           , "", MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return(true);               //If user clicks cancel, then do nothing
            }
#else
            if (!silent && MessageBox.Show(Lan.g(this, "Your database will now be converted") + "\r"
                                           + Lan.g(this, "from version") + " " + FromVersion.ToString() + "\r"
                                           + Lan.g(this, "to version") + " " + ToVersion.ToString() + "\r"
                                           + Lan.g(this, "The conversion works best if you are on the server.  Depending on the speed of your computer, it can be as fast as a few seconds, or it can take as long as 10 minutes.")
                                           , "", MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return(false);               //If user clicks cancel, then close the program
            }
#endif
            Cursor.Current = Cursors.WaitCursor;
#if !DEBUG
            if (DataConnection.DBtype != DatabaseType.MySql &&
                !MsgBox.Show(this, true, "If you have not made a backup, please Cancel and backup before continuing.  Continue?"))
            {
                return(false);
            }
            try{
                if (DataConnection.DBtype == DatabaseType.MySql)
                {
                    MiscData.MakeABackup();                    //Does not work for Oracle, due to some MySQL specific commands inside.
                }
            }
            catch (Exception e) {
                Cursor.Current = Cursors.Default;
                if (e.Message != "")
                {
                    MessageBox.Show(e.Message);
                }
                MsgBox.Show(this, "Backup failed. Your database has not been altered.");
                return(false);
            }
            try{
#endif
            if (FromVersion < new Version("7.5.17"))             //Insurance Plan schema conversion
            {
                Cursor.Current = Cursors.Default;
                YN InsPlanConverstion_7_5_17_AutoMergeYN = YN.Unknown;
                if (FromVersion < new Version("7.5.1"))
                {
                    FormInsPlanConvert_7_5_17 form = new FormInsPlanConvert_7_5_17();
                    if (PrefC.GetBoolSilent(PrefName.InsurancePlansShared, true))
                    {
                        form.InsPlanConverstion_7_5_17_AutoMergeYN = YN.Yes;
                    }
                    else
                    {
                        form.InsPlanConverstion_7_5_17_AutoMergeYN = YN.No;
                    }
                    form.ShowDialog();
                    if (form.DialogResult == DialogResult.Cancel)
                    {
                        MessageBox.Show("Your database has not been altered.");
                        return(false);
                    }
                    InsPlanConverstion_7_5_17_AutoMergeYN = form.InsPlanConverstion_7_5_17_AutoMergeYN;
                }
                ConvertDatabases.Set_7_5_17_AutoMerge(InsPlanConverstion_7_5_17_AutoMergeYN);                //does nothing if this pref is already present for some reason.
                Cursor.Current = Cursors.WaitCursor;
            }
            if (FromVersion >= new Version("3.4.0"))
            {
                Prefs.UpdateBool(PrefName.CorruptedDatabase, true);
            }
            ConvertDatabases.FromVersion = FromVersion;
            ConvertDatabases.To2_8_2();            //begins going through the chain of conversion steps
            Cursor.Current = Cursors.Default;
            if (FromVersion >= new Version("3.4.0"))
            {
                //CacheL.Refresh(InvalidType.Prefs);//or it won't know it has to update in the next line.
                Prefs.UpdateBool(PrefName.CorruptedDatabase, false, true);              //more forceful refresh in order to properly change flag
            }
            if (!silent)
            {
                MsgBox.Show(this, "Database update successful");
            }
            Cache.Refresh(InvalidType.Prefs);
            return(true);

#if !DEBUG
        }

        catch (System.IO.FileNotFoundException e) {
            MessageBox.Show(e.FileName + " " + Lan.g(this, "could not be found. Your database has not been altered and is still usable if you uninstall this version, then reinstall the previous version."));
            if (FromVersion >= new Version("3.4.0"))
            {
                Prefs.UpdateBool(PrefName.CorruptedDatabase, false);
            }
            //Prefs.Refresh();
            return(false);
        }
        catch (System.IO.DirectoryNotFoundException) {
            MessageBox.Show(Lan.g(this, "ConversionFiles folder could not be found. Your database has not been altered and is still usable if you uninstall this version, then reinstall the previous version."));
            if (FromVersion >= new Version("3.4.0"))
            {
                Prefs.UpdateBool(PrefName.CorruptedDatabase, false);
            }
            //Prefs.Refresh();
            return(false);
        }
        catch (Exception ex) {
            //	MessageBox.Show();
            MessageBox.Show(ex.Message + "\r\n\r\n"
                            + Lan.g(this, "Conversion unsuccessful. Your database is now corrupted and you cannot use it.  Please contact us."));
            //Then, application will exit, and database will remain tagged as corrupted.
            return(false);
        }
#endif
        }
コード例 #11
0
        ///<summary>Processes a PaySimple payment via the PaySimple API.</summary>
        private PaySimple.ApiResponse ProcessPayment(int expYear, int expMonth)
        {
            PaySimple.ApiResponse retVal = null;
            string refNumber             = "";

            if (_trantype == PaySimple.TransType.VOID || _trantype == PaySimple.TransType.RETURN)
            {
                refNumber = textRefNumber.Text;
            }
            string magData = null;

            if (_parser != null)
            {
                magData = _parser.Track2;
            }
            string cardNumber = textCardNumber.Text;

            //if using a stored CC and there is an X-Charge token saved for the CC and the user enters the whole card number to get a PaySimple token
            //and the number entered doesn't have the same last 4 digits and exp date, then assume it's not the same card and clear out the X-Charge token.
            if (_creditCardCur != null &&       //using a saved CC
                !string.IsNullOrEmpty(_creditCardCur.XChargeToken) &&                 //there is an X-Charge token saved
                (cardNumber.Right(4) != _creditCardCur.CCNumberMasked.Right(4) ||               //the card number entered doesn't have the same last 4 digits
                 expYear != _creditCardCur.CCExpiration.Year ||                      //the card exp date entered doesn't have the same year
                 expMonth != _creditCardCur.CCExpiration.Month))                         //the card exp date entered doesn't have the same month
            {
                if (MsgBox.Show(this, MsgBoxButtons.YesNo, "The card number or expiration date entered does not match the X-Charge card on file.  Do you wish "
                                + "to replace the X-Charge card with this one?"))
                {
                    _creditCardCur.XChargeToken = "";
                }
                else
                {
                    Cursor = Cursors.Default;
                    return(null);
                }
            }
            //if the user has chosen to store CC tokens and the stored CC has a token and the token is not expired,
            //then use it instead of the CC number and CC expiration.
            if (!checkOneTimePayment.Checked &&
                _creditCardCur != null &&               //if the user selected a saved CC
                !string.IsNullOrWhiteSpace(_creditCardCur.PaySimpleToken))                    //there is a stored token for this card
            {
                cardNumber = _creditCardCur.PaySimpleToken;
                expYear    = _creditCardCur.CCExpiration.Year;
                expMonth   = _creditCardCur.CCExpiration.Month;
            }
            try {
                switch (_trantype)
                {
                case PaySimple.TransType.SALE:
                    //If _patCur is null or the PatNum is 0, we will make a one time payment for an UNKNOWN patient.  This is currently only intended for prepaid insurance cards.
                    retVal = PaySimple.MakePayment((_patCur == null ? 0 : _patCur.PatNum), _creditCardCur, PIn.Decimal(textAmount.Text), textCardNumber.Text
                                                   , new DateTime(expYear, expMonth, 1), checkOneTimePayment.Checked, textZipCode.Text, textSecurityCode.Text, _clinicNum);
                    break;

                case PaySimple.TransType.AUTH:
                    //Will retreive a new customer id from PaySimple if the patient doesn't exist already.
                    long paySimpleCustomerId = PaySimple.GetCustomerIdForPat(_patCur.PatNum, _patCur.FName, _patCur.LName, _clinicNum);
                    //I have no idea if an insurance can make an auth payment but incase they can I check for it.
                    if (paySimpleCustomerId == 0)                           //Insurance payment, make a new customer id every time per Nathan on 04/26/2018
                    {
                        if ((_patCur == null || _patCur.PatNum == 0))
                        {
                            paySimpleCustomerId = PaySimple.AddCustomer("UNKNOWN", "UNKNOWN", "", _clinicNum);
                        }
                        else
                        {
                            throw new ODException(Lan.g(this, "Invalid PaySimple Customer Id found."));
                        }
                    }
                    retVal = PaySimple.AddCreditCard(paySimpleCustomerId, textCardNumber.Text, new DateTime(expYear, expMonth, 1), textZipCode.Text, _clinicNum);
                    break;

                case PaySimple.TransType.RETURN:
                    if (string.IsNullOrWhiteSpace(textRefNumber.Text))
                    {
                        throw new ODException(Lan.g(this, "Invalid PaySimple Payment ID."));
                    }
                    if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "You are about to return a payment.  This action is irreversible.  Continue?"))
                    {
                        throw new ODException(Lan.g(this, "Payment return was cancelled by user."));
                    }
                    retVal = PaySimple.ReversePayment(textRefNumber.Text, _clinicNum);
                    break;

                case PaySimple.TransType.VOID:
                    if (string.IsNullOrWhiteSpace(textRefNumber.Text))
                    {
                        throw new ODException(Lan.g(this, "Invalid PaySimple Payment ID."));
                    }
                    if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "You are about to void a payment.  This action is irreversible.  Continue?"))
                    {
                        throw new ODException(Lan.g(this, "Payment void was cancelled by user."));
                    }
                    retVal = PaySimple.VoidPayment(textRefNumber.Text, _clinicNum);
                    break;

                default:
                    throw new Exception("Invalid transmission type: " + _trantype.ToString());
                }
            }
            catch (ODException wex) {
                MessageBox.Show(wex.Message);                //This should have already been Lans.g if applicable.
                return(null);
            }
            catch (Exception ex) {
                MessageBox.Show(Lan.g(this, "Error:") + " " + ex.Message);
                return(null);
            }
            if (_trantype.In(PaySimple.TransType.SALE, PaySimple.TransType.RETURN, PaySimple.TransType.VOID))           //Only print a receipt if transaction is an approved SALE, RETURN, or VOID
            //The isSwiped boolean could be incorrectly set if the user swipes a card and then changes the data that was entered to a different card.
            {
                retVal.BuildReceiptString(cardNumber, expMonth, expYear, textNameOnCard.Text, _clinicNum, _parser != null);
                PrintReceipt(retVal.TransactionReceipt);
            }
            if (checkOneTimePayment.Checked)             //not storing the card token
            {
                return(retVal);
            }
            if (_creditCardCur == null)           //user selected Add new card from the payment window, save it or its token depending on settings
            {
                _creditCardCur        = new CreditCard();
                _creditCardCur.IsNew  = true;
                _creditCardCur.PatNum = _patCur.PatNum;
                List <CreditCard> itemOrderCount = CreditCards.Refresh(_patCur.PatNum);
                _creditCardCur.ItemOrder = itemOrderCount.Count;
            }
            _creditCardCur.CCExpiration = new DateTime(expYear, expMonth, DateTime.DaysInMonth(expYear, expMonth));
            //I don't care about PrefName.StoreCCnumbers, I am always storing a masked number.
            _creditCardCur.CCNumberMasked = textCardNumber.Text.Right(4).PadLeft(textCardNumber.Text.Length, 'X');
            _creditCardCur.Zip            = textZipCode.Text;
            _creditCardCur.PaySimpleToken = retVal.PaySimpleToken;
            _creditCardCur.CCSource       = CreditCardSource.PaySimple;
            if (_creditCardCur.IsNew)
            {
                _creditCardCur.ClinicNum  = _clinicNum;
                _creditCardCur.Procedures = PrefC.GetString(PrefName.DefaultCCProcs);
                CreditCards.Insert(_creditCardCur);
            }
            else
            {
                CreditCards.Update(_creditCardCur);
            }
            return(retVal);
        }
コード例 #12
0
        private void butRepeat_Click(object sender, EventArgs e)
        {
            try {
                int.Parse(textRepeat.Text);
            }
            catch {
                MsgBox.Show(this, "Please fix number box first.");
                return;
            }
            if (DateCopyStart.Year < 1880)
            {
                MsgBox.Show(this, "Please copy a selection to the clipboard first.");
                return;
            }
            //calculate which day or week is currently selected.
            DateTime dateSelectedStart;
            DateTime dateSelectedEnd;
            bool     isWeek = DateCopyStart != DateCopyEnd;

            if (isWeek)
            {
                if (checkWeekend.Checked)
                {
                    dateSelectedStart = DateSelected.AddDays(-(int)DateSelected.DayOfWeek);
                    dateSelectedEnd   = dateSelectedStart.AddDays(6);
                }
                else
                {
                    dateSelectedStart = DateSelected.AddDays(-(int)DateSelected.DayOfWeek + 1);
                    dateSelectedEnd   = dateSelectedStart.AddDays(4);
                }
            }
            else
            {
                dateSelectedStart = DateSelected;
                dateSelectedEnd   = DateSelected;
            }
            //it is allowed to paste back over the same day or week.
            int[]           opNums    = ApptViewItems.GetOpsForView(ApptViewNumCur);
            List <Schedule> SchedList = Schedules.RefreshPeriodBlockouts(DateCopyStart, DateCopyEnd, opNums);
            Schedule        sched;
            int             weekDelta = 0;
            TimeSpan        span;

            if (isWeek)
            {
                span      = dateSelectedStart - DateCopyStart;
                weekDelta = span.Days / 7; //usually a positive # representing a future paste, but can be negative
            }
            int dayDelta = 0;              //this is needed when repeat pasting days in order to calculate skipping weekends.

            //dayDelta will start out zero and increment separately from r.
            for (int r = 0; r < PIn.PInt(textRepeat.Text); r++)
            {
                if (checkReplace.Checked)
                {
                    if (isWeek)
                    {
                        Schedules.ClearBlockouts(dateSelectedStart.AddDays(r * 7), dateSelectedEnd.AddDays(r * 7), opNums);
                    }
                    else
                    {
                        Schedules.ClearBlockouts(dateSelectedStart.AddDays(dayDelta), dateSelectedEnd.AddDays(dayDelta), opNums);
                    }
                }
                for (int i = 0; i < SchedList.Count; i++)
                {
                    sched = SchedList[i].Copy();
                    if (isWeek)
                    {
                        sched.SchedDate = sched.SchedDate.AddDays((weekDelta + r) * 7);
                    }
                    else
                    {
                        sched.SchedDate = dateSelectedStart.AddDays(dayDelta);
                    }
                    Schedules.Insert(sched);
                }
                if (!checkWeekend.Checked && dateSelectedStart.AddDays(dayDelta).DayOfWeek == DayOfWeek.Friday)
                {
                    dayDelta += 3;
                }
                else
                {
                    dayDelta++;
                }
            }
            Close();
        }
コード例 #13
0
        private void butPaste_Click(object sender, EventArgs e)
        {
            if (DateCopyStart.Year < 1880)
            {
                MsgBox.Show(this, "Please copy a selection to the clipboard first.");
                return;
            }
            //calculate which day or week is currently selected.
            DateTime dateSelectedStart;
            DateTime dateSelectedEnd;
            bool     isWeek = DateCopyStart != DateCopyEnd;

            if (isWeek)
            {
                if (checkWeekend.Checked)
                {
                    dateSelectedStart = DateSelected.AddDays(-(int)DateSelected.DayOfWeek);
                    dateSelectedEnd   = dateSelectedStart.AddDays(6);
                }
                else
                {
                    dateSelectedStart = DateSelected.AddDays(-(int)DateSelected.DayOfWeek + 1);
                    dateSelectedEnd   = dateSelectedStart.AddDays(4);
                }
            }
            else
            {
                dateSelectedStart = DateSelected;
                dateSelectedEnd   = DateSelected;
            }
            //it's not allowed to paste back over the same day or week.
            if (dateSelectedStart == DateCopyStart)
            {
                MsgBox.Show(this, "Not allowed to paste back onto the same date as is on the clipboard.");
                return;
            }
            int[]           opNums    = ApptViewItems.GetOpsForView(ApptViewNumCur);
            List <Schedule> SchedList = Schedules.RefreshPeriodBlockouts(DateCopyStart, DateCopyEnd, opNums);

            if (checkReplace.Checked)
            {
                Schedules.ClearBlockouts(dateSelectedStart, dateSelectedEnd, opNums);
            }
            Schedule sched;
            int      weekDelta = 0;

            if (isWeek)
            {
                TimeSpan span = dateSelectedStart - DateCopyStart;
                weekDelta = span.Days / 7;            //usually a positive # representing a future paste, but can be negative
            }
            for (int i = 0; i < SchedList.Count; i++)
            {
                sched = SchedList[i];
                if (isWeek)
                {
                    sched.SchedDate = sched.SchedDate.AddDays(weekDelta * 7);
                }
                else
                {
                    sched.SchedDate = dateSelectedStart;
                }
                Schedules.Insert(sched);
            }
            Close();
        }
コード例 #14
0
        private void FillGrid()
        {
            if (PIn.Date(textDateFrom.Text) == DateTime.MinValue || PIn.Date(textDateTo.Text) == DateTime.MinValue)
            {
                MsgBox.Show(this, "Please enter valid To and From dates.");
                return;
            }
            DateFrom = PIn.Date(textDateFrom.Text);
            DateTo   = PIn.Date(textDateTo.Text);
//todo: checkbox
            RefAttachList = RefAttaches.RefreshForReferralProcTrack(DateFrom, DateTo, checkComplete.Checked);
            Table         = Procedures.GetReferred(DateFrom, DateTo, checkComplete.Checked);
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col;

            col = new ODGridColumn(Lan.g(this, "Patient"), 125);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Referred To"), 125);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Description"), 125);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Note"), 125);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Date Referred"), 86);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Date Done"), 86);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Status"), 84);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;
            DateTime  date;

            for (int i = 0; i < Table.Rows.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(Patients.GetPat(PIn.Long(Table.Rows[i]["PatNum"].ToString())).GetNameLF());
                row.Cells.Add(Table.Rows[i]["LName"].ToString() + ", " + Table.Rows[i]["FName"].ToString() + " " + Table.Rows[i]["MName"].ToString());
                row.Cells.Add(ProcedureCodes.GetLaymanTerm(PIn.Long(Table.Rows[i]["CodeNum"].ToString())));
                row.Cells.Add(Table.Rows[i]["Note"].ToString());
                date = PIn.Date(Table.Rows[i]["RefDate"].ToString());
                if (date.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(date.ToShortDateString());
                }
                date = PIn.Date(Table.Rows[i]["DateProcComplete"].ToString());
                if (date.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(date.ToShortDateString());
                }
                ReferralToStatus refStatus = (ReferralToStatus)PIn.Int(Table.Rows[i]["RefToStatus"].ToString());
                if (refStatus == ReferralToStatus.None)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(refStatus.ToString());
                }
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
コード例 #15
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (PrefC.HasClinicsEnabled)
            {
                if (!checkAllClin.Checked && listClin.SelectedIndices.Count == 0)
                {
                    MsgBox.Show(this, "At least one clinic must be selected.");
                    return;
                }
            }
            ReportComplex report = new ReportComplex(true, false);

            Cursor = Cursors.WaitCursor;
            List <long> listClinicNums = new List <long>();

            if (PrefC.HasClinicsEnabled)
            {
                for (int i = 0; i < listClin.SelectedIndices.Count; i++)
                {
                    if (Security.CurUser.ClinicIsRestricted)
                    {
                        listClinicNums.Add(_listClinics[listClin.SelectedIndices[i]].ClinicNum);                        //we know that the list is a 1:1 to _listClinics
                    }
                    else
                    {
                        if (listClin.SelectedIndices[i] == 0)
                        {
                            listClinicNums.Add(0);
                        }
                        else
                        {
                            listClinicNums.Add(_listClinics[listClin.SelectedIndices[i] - 1].ClinicNum);                          //Minus 1 from the selected index
                        }
                    }
                }
            }
            DataTable tableOverpaid = RpInsOverpaid.GetInsuranceOverpaid(dateStart.SelectionStart, dateEnd.SelectionStart, listClinicNums,
                                                                         radioGroupByProc.Checked);

            Cursor = Cursors.Default;
            string subtitleClinics = "";

            if (PrefC.HasClinicsEnabled)
            {
                if (checkAllClin.Checked)
                {
                    subtitleClinics = Lan.g(this, "All Clinics");
                }
                else
                {
                    for (int i = 0; i < listClin.SelectedIndices.Count; i++)
                    {
                        if (i > 0)
                        {
                            subtitleClinics += ", ";
                        }
                        if (Security.CurUser.ClinicIsRestricted)
                        {
                            subtitleClinics += _listClinics[listClin.SelectedIndices[i]].Abbr;
                        }
                        else
                        {
                            if (listClin.SelectedIndices[i] == 0)
                            {
                                subtitleClinics += Lan.g(this, "Unassigned");
                            }
                            else
                            {
                                subtitleClinics += _listClinics[listClin.SelectedIndices[i] - 1].Abbr;                            //Minus 1 from the selected index
                            }
                        }
                    }
                }
            }
            report.ReportName = Lan.g(this, "Insurance Overpaid");
            report.AddTitle("Title", Lan.g(this, "Insurance Overpaid"));
            report.AddSubTitle("Practice Name", PrefC.GetString(PrefName.PracticeTitle));
            if (PrefC.HasClinicsEnabled)
            {
                report.AddSubTitle("Clinics", subtitleClinics);
            }
            QueryObject query = report.AddQuery(tableOverpaid, DateTimeOD.Today.ToShortDateString());

            query.AddColumn("Pat Name", 200, FieldValueType.String);
            query.AddColumn("Date", 90, FieldValueType.Date);
            query.GetColumnDetail("Date").StringFormat = "d";
            query.AddColumn("Fee", 100, FieldValueType.Number);
            query.AddColumn("InsPaid+W/O", 120, FieldValueType.Number);
            report.AddPageNum();
            if (!report.SubmitQueries())
            {
                return;
            }
            FormReportComplex FormR = new FormReportComplex(report);

            FormR.ShowDialog();
            DialogResult = DialogResult.OK;
        }
コード例 #16
0
        private void butPrint_Click(object sender, System.EventArgs e)
        {
#if DISABLE_MICROSOFT_OFFICE
            MessageBox.Show(this, "This version of Open Dental does not support Microsoft Word.");
            return;
#endif
            if (listLetters.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a letter first.");
                return;
            }
            LetterMerge letterCur    = ListForCat[listLetters.SelectedIndex];
            string      templateFile = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), letterCur.TemplateName);
            string      dataFile     = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), letterCur.DataFileName);
            if (!File.Exists(templateFile))
            {
                MsgBox.Show(this, "Template file does not exist.");
                return;
            }
            PrintDocument pd = new PrintDocument();
            if (!PrinterL.SetPrinter(pd, PrintSituation.Default, PatCur.PatNum, "Letter merge " + letterCur.Description + " printed"))
            {
                return;
            }
            if (!CreateDataFile(dataFile, letterCur))
            {
                return;
            }
            Word.MailMerge wrdMailMerge;
            //Create an instance of Word.
            Word.Application WrdApp;
            try {
                WrdApp = LetterMerges.WordApp;
            }
            catch {
                MsgBox.Show(this, "Error.  Is MS Word installed?");
                return;
            }
            //Open a document.
            Object oName = templateFile;
            wrdDoc = WrdApp.Documents.Open(ref oName, ref oMissing, ref oMissing,
                                           ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                           ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            wrdDoc.Select();
            wrdMailMerge = wrdDoc.MailMerge;
            //Attach the data file.
            wrdDoc.MailMerge.OpenDataSource(dataFile, ref oMissing, ref oMissing, ref oMissing,
                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            wrdMailMerge.Destination = Word.WdMailMergeDestination.wdSendToPrinter;
            //WrdApp.ActivePrinter=pd.PrinterSettings.PrinterName;
            //replaced with following 4 lines due to MS bug that changes computer default printer
            object   oWBasic   = WrdApp.WordBasic;
            object[] oWBValues = new object[] { pd.PrinterSettings.PrinterName, 1 };
            String[] sWBNames  = new String[] { "Printer", "DoNotSetAsSysDefault" };
            oWBasic.GetType().InvokeMember("FilePrintSetup", BindingFlags.InvokeMethod, null, oWBasic, oWBValues, null, null, sWBNames);
            wrdMailMerge.Execute(ref oFalse);
            //Close the original form document since just one record.
            wrdDoc.Saved = true;
            wrdDoc.Close(ref oFalse, ref oMissing, ref oMissing);
            //At this point, Word remains open with no documents.
            WrdApp.WindowState = Word.WdWindowState.wdWindowStateMinimize;
            wrdMailMerge       = null;
            wrdDoc             = null;
            Commlog CommlogCur = new Commlog();
            CommlogCur.CommDateTime   = DateTime.Now;
            CommlogCur.CommType       = Commlogs.GetTypeAuto(CommItemTypeAuto.MISC);
            CommlogCur.Mode_          = CommItemMode.Mail;
            CommlogCur.SentOrReceived = CommSentOrReceived.Sent;
            CommlogCur.PatNum         = PatCur.PatNum;
            CommlogCur.Note           = "Letter sent: " + letterCur.Description + ". ";
            CommlogCur.UserNum        = Security.CurUser.UserNum;
            Commlogs.Insert(CommlogCur);
            DialogResult = DialogResult.OK;
        }
コード例 #17
0
ファイル: FormAudit.cs プロジェクト: kjb7749/testImport
        private void FillGrid()
        {
            if (textRows.errorProvider1.GetError(textRows) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            long userNum = 0;

            if (comboUser.SelectedIndex > 0)
            {
                userNum = _listUserods[comboUser.SelectedIndex - 1].UserNum;
            }
            SecurityLog[] logList          = null;
            DateTime      datePreviousFrom = PIn.Date(textDateEditedFrom.Text);
            DateTime      datePreviousTo   = DateTime.Today;

            if (textDateEditedTo.Text != "")
            {
                datePreviousTo = PIn.Date(textDateEditedTo.Text);
            }
            if (comboPermission.SelectedIndex == 0)
            {
                logList = SecurityLogs.Refresh(PIn.Date(textDateFrom.Text), PIn.Date(textDateTo.Text),
                                               Permissions.None, PatNum, userNum, datePreviousFrom, datePreviousTo, checkIncludeArchived.Checked, PIn.Int(textRows.Text));
            }
            else
            {
                logList = SecurityLogs.Refresh(PIn.Date(textDateFrom.Text), PIn.Date(textDateTo.Text),
                                               (Permissions)Enum.Parse(typeof(Permissions), comboPermission.SelectedItem.ToString()), PatNum, userNum,
                                               datePreviousFrom, datePreviousTo, checkIncludeArchived.Checked, PIn.Int(textRows.Text));
            }
            grid.BeginUpdate();
            grid.Columns.Clear();
            grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Date"), 70, GridSortingStrategy.DateParse));
            grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Time"), 60, GridSortingStrategy.DateParse));
            grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Patient"), 100));
            grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "User"), 70));
            grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Permission"), 190));
            grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Computer"), 70));
            grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Log Text"), 279));
            grid.Columns.Add(new ODGridColumn(Lan.g("TableAudit", "Last Edit"), 100));
            grid.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < logList.Length; i++)
            {
                SecurityLog logCur = logList[i];
                row = new ODGridRow();
                row.Cells.Add(logCur.LogDateTime.ToShortDateString());
                row.Cells.Add(logCur.LogDateTime.ToShortTimeString());
                row.Cells.Add(logCur.PatientName);
                //user might be null due to old bugs.
                row.Cells.Add(Userods.GetUser(logCur.UserNum)?.UserName ?? "unknown");
                if (logCur.PermType == Permissions.ChartModule)
                {
                    row.Cells.Add("ChartModuleViewed");
                }
                else if (logCur.PermType == Permissions.FamilyModule)
                {
                    row.Cells.Add("FamilyModuleViewed");
                }
                else if (logCur.PermType == Permissions.AccountModule)
                {
                    row.Cells.Add("AccountModuleViewed");
                }
                else if (logCur.PermType == Permissions.ImagesModule)
                {
                    row.Cells.Add("ImagesModuleViewed");
                }
                else if (logCur.PermType == Permissions.TPModule)
                {
                    row.Cells.Add("TreatmentPlanModuleViewed");
                }
                else
                {
                    row.Cells.Add(logCur.PermType.ToString());
                }
                row.Cells.Add(logCur.CompName);
                if (logCur.PermType != Permissions.UserQuery)
                {
                    row.Cells.Add(logCur.LogText);
                }
                else
                {
                    //Only display the first snipet of very long queries. User can double click to view.
                    row.Cells.Add(logCur.LogText.Left(200, true));
                    row.Tag = (Action)(() => {
                        MsgBoxCopyPaste formText = new MsgBoxCopyPaste(logCur.LogText);
                        formText.NormalizeContent();
                        formText.Show();
                    });
                }
                if (logCur.DateTPrevious.Year < 1880)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(logCur.DateTPrevious.ToString());
                }
                //Get the hash for the audit log entry from the database and rehash to compare
                if (logCur.LogHash != SecurityLogHashes.GetHashString(logCur))
                {
                    row.ColorText = Color.Red;                   //Bad hash or no hash entry at all.  This prevents users from deleting the entire hash table to make the audit trail look valid and encrypted.
                    //historical entries will show as red.
                }
                grid.Rows.Add(row);
            }
            grid.EndUpdate();
            grid.ScrollToEnd();
        }
コード例 #18
0
        private void butPreview_Click(object sender, System.EventArgs e)
        {
#if !DISABLE_MICROSOFT_OFFICE
            if (listLetters.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a letter first.");
                return;
            }
            LetterMerge letterCur    = ListForCat[listLetters.SelectedIndex];
            string      templateFile = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), letterCur.TemplateName);
            string      dataFile     = ODFileUtils.CombinePaths(PrefC.GetString(PrefName.LetterMergePath), letterCur.DataFileName);
            if (!File.Exists(templateFile))
            {
                MsgBox.Show(this, "Template file does not exist.");
                return;
            }
            if (!CreateDataFile(dataFile, letterCur))
            {
                return;
            }
            Word.MailMerge wrdMailMerge;
            //Create an instance of Word.
            Word.Application WrdApp;
            try{
                WrdApp = LetterMerges.WordApp;
            }
            catch {
                MsgBox.Show(this, "Error. Is Word installed?");
                return;
            }
            //Open a document.
            Object oName = templateFile;
            wrdDoc = WrdApp.Documents.Open(ref oName, ref oMissing, ref oMissing,
                                           ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                           ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            wrdDoc.Select();
            wrdMailMerge = wrdDoc.MailMerge;
            //Attach the data file.
            wrdDoc.MailMerge.OpenDataSource(dataFile, ref oMissing, ref oMissing, ref oMissing,
                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            wrdMailMerge.Destination = Word.WdMailMergeDestination.wdSendToNewDocument;
            wrdMailMerge.Execute(ref oFalse);
            //Close the original form document since just one record.
            wrdDoc.Saved = true;
            wrdDoc.Close(ref oFalse, ref oMissing, ref oMissing);
            //At this point, Word remains open with just one new document.
            WrdApp.Activate();
            if (WrdApp.WindowState == Word.WdWindowState.wdWindowStateMinimize)
            {
                WrdApp.WindowState = Word.WdWindowState.wdWindowStateMaximize;
            }
            wrdMailMerge = null;
            wrdDoc       = null;
            Commlog CommlogCur = new Commlog();
            CommlogCur.CommDateTime   = DateTime.Now;
            CommlogCur.CommType       = Commlogs.GetTypeAuto(CommItemTypeAuto.MISC);
            CommlogCur.Mode_          = CommItemMode.Mail;
            CommlogCur.SentOrReceived = CommSentOrReceived.Sent;
            CommlogCur.PatNum         = PatCur.PatNum;
            CommlogCur.Note           = "Letter sent: " + letterCur.Description + ". ";
            CommlogCur.UserNum        = Security.CurUser.UserNum;
            Commlogs.Insert(CommlogCur);
#else
            MessageBox.Show(this, "This version of Open Dental does not support Microsoft Word.");
#endif
            //this window now closes regardless of whether the user saved the comm item.
            DialogResult = DialogResult.OK;
        }
コード例 #19
0
ファイル: FormWiki.cs プロジェクト: royedwards/DRDNet
        ///<summary>Before calling this, make sure to increment/decrement the historyNavBack index to keep track of the position in history.  If loading a new page, decrement historyNavBack before calling this function.  </summary>
        private void LoadWikiPage(string pageTitle)
        {
            //This is called from 11 different places, any time the program needs to refresh a page from the db.
            //It's also called from the browser_Navigating event when a "wiki:" link is clicked.
            WikiPage wpage = WikiPages.GetByTitle(pageTitle);

            if (wpage == null)
            {
                string errorMsg = "";
                if (!WikiPages.IsWikiPageTitleValid(pageTitle, out errorMsg))
                {
                    MsgBox.Show(this, "That page does not exist and cannot be made because the page title contains invalid characters.");
                    return;
                }
                if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "That page does not exist. Would you like to create it?"))
                {
                    return;
                }
                Action <string> onWikiSaved = new Action <string>((pageTitleNew) => {
                    //Insert the pageTitleNew where the pageTitle exists in the existing WikiPageCur
                    //(guaranteed to be unique because all INVALID WIKIPAGE LINK's have an ID at the end)
                    string pageContent      = WikiPages.GetWikiPageContentWithWikiPageTitles(WikiPageCur.PageContent);
                    WikiPageCur.PageContent = pageContent.Replace(pageTitle, pageTitleNew);
                    WikiPageCur.PageContent = WikiPages.ConvertTitlesToPageNums(WikiPageCur.PageContent);
                    WikiPages.Update(WikiPageCur);
                });
                AddWikiPage(onWikiSaved);
                return;
            }
            WikiPageCur = wpage;
            try {
                webBrowserWiki.DocumentText = WikiPages.TranslateToXhtml(WikiPageCur.PageContent, false);
            }
            catch (Exception ex) {
                webBrowserWiki.DocumentText = "";
                MessageBox.Show(this, Lan.g(this, "This page is broken and cannot be viewed.  Error message:") + " " + ex.Message);
            }
            Text = "Wiki - " + WikiPageCur.PageTitle;
            #region historyMaint
            //This region is duplicated in webBrowserWiki_Navigating() for external links.  Modifications here will need to be reflected there.
            int indexInHistory = historyNav.Count - (1 + historyNavBack); //historyNavBack number of pages before the last page in history.  This is the index of the page we are loading.
            if (historyNav.Count == 0)                                    //empty history
            {
                historyNavBack = 0;
                historyNav.Add("wiki:" + pageTitle);
            }
            else if (historyNavBack < 0)           //historyNavBack could be negative here.  This means before the action that caused this load, we were not navigating through history, simply set back to 0 and add to historyNav[] if necessary.
            {
                historyNavBack = 0;
                if (historyNav[historyNav.Count - 1] != "wiki:" + pageTitle)
                {
                    historyNav.Add("wiki:" + pageTitle);
                }
            }
            else if (historyNavBack >= 0 && historyNav[indexInHistory] != "wiki:" + pageTitle) //branching from page in history
            {
                historyNav.RemoveRange(indexInHistory, historyNavBack + 1);                    //remove "forward" history. branching off in a new direction
                historyNavBack = 0;
                historyNav.Add("wiki:" + pageTitle);
            }
            #endregion
        }
コード例 #20
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     try {
         PIn.Int(textPort.Text);
     }
     catch {
         MsgBox.Show(this, "Invalid outgoing port number.");
         return;
     }
     try {
         PIn.Int(textPortIncoming.Text);
     }
     catch {
         MsgBox.Show(this, "Invalid incoming port number.");
         return;
     }
     if (string.IsNullOrWhiteSpace(textUsername.Text))
     {
         MsgBox.Show(this, "Please enter a valid email address.");
         return;
     }
     //Only checks against non-user email addresses.
     if (EmailAddresses.AddressExists(textUsername.Text, _emailAddressCur.EmailAddressNum))
     {
         MsgBox.Show(this, "This email address already exists.");
         return;
     }
     if (!textPassword.Text.IsNullOrEmpty() && !textAccessToken.Text.IsNullOrEmpty())
     {
         MsgBox.Show(this, "There is an email password and access token entered.  Please clear one and try again.");
         return;
     }
     _emailAddressCur.AccessToken  = textAccessToken.Text;
     _emailAddressCur.RefreshToken = textRefreshToken.Text;
     if (!_isNew && (!string.IsNullOrWhiteSpace(_emailAddressCur.AccessToken) || !string.IsNullOrWhiteSpace(_emailAddressCur.RefreshToken)) &&        //If has a token
         (_emailAddressCur.SMTPserver != PIn.String(textSMTPserver.Text) || _emailAddressCur.Pop3ServerIncoming != PIn.String(textSMTPserverIncoming.Text)))               //And changed a server
     {
         if (!MsgBox.Show(MsgBoxButtons.OKCancel, "There is an access token associated to this email address.  "
                          + "Changing servers will wipe out the access token and may require reauthentication.  Continue?"))
         {
             return;
         }
         _emailAddressCur.AccessToken  = "";
         _emailAddressCur.RefreshToken = "";
         //TODO: If this is a google token, we may want to tell Google we no longer require access to their account.
         //This will limit our total number of active users
     }
     _emailAddressCur.SMTPserver         = PIn.String(textSMTPserver.Text);
     _emailAddressCur.EmailUsername      = PIn.String(textUsername.Text);
     _emailAddressCur.EmailPassword      = PIn.String(MiscUtils.Encrypt(textPassword.Text));
     _emailAddressCur.ServerPort         = PIn.Int(textPort.Text);
     _emailAddressCur.UseSSL             = checkSSL.Checked;
     _emailAddressCur.SenderAddress      = PIn.String(textSender.Text);
     _emailAddressCur.Pop3ServerIncoming = PIn.String(textSMTPserverIncoming.Text);
     _emailAddressCur.ServerPortIncoming = PIn.Int(textPortIncoming.Text);
     _emailAddressCur.UserNum            = ((Userod)(textUserod.Tag))?.UserNum ?? 0;
     if (_isNew)
     {
         EmailAddresses.Insert(_emailAddressCur);
     }
     else
     {
         EmailAddresses.Update(_emailAddressCur);
     }
     DialogResult = DialogResult.OK;
 }
コード例 #21
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (textDateStart.errorProvider1.GetError(textDateStart) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            if (textDateStart.Text == "")
            {
                MsgBox.Show(this, "Please enter a start date.");
                return;
            }
            if (textDateEnd.errorProvider1.GetError(textDateEnd) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            if (textDateEnd.Text == "")
            {
                MsgBox.Show(this, "Please enter an end date.");
                return;
            }
            if (gridCourses.SelectedIndices.Length < 1)
            {
                MsgBox.Show(this, "At least one course must be selected to run a report.  Please select a row from the course grid.");
                return;
            }
            if (gridInstructors.SelectedIndices.Length < 1)
            {
                MsgBox.Show(this, "At least one instructor must be selected to run a report.  Please select a row from the instructor grid.");
                return;
            }
            if (gridStudents.SelectedIndices.Length < 1)
            {
                MsgBox.Show(this, "At least one student must be selected to run a report.  Please select a row from the student grid.");
                return;
            }
            DateTime dateStart    = PIn.Date(textDateStart.Text);
            DateTime dateEnd      = PIn.Date(textDateEnd.Text);
            string   whereCourses = "";

            if (!checkAllCourses.Checked)
            {
                for (int i = 0; i < gridCourses.SelectedIndices.Length; i++)
                {
                    if (i == 0)
                    {
                        whereCourses += " AND evaluation.SchoolCourseNum IN(";
                    }
                    whereCourses += gridCourses.Rows[gridCourses.SelectedIndices[i]].Tag;
                    if (i != gridCourses.SelectedIndices.Length - 1)
                    {
                        whereCourses += ",";
                    }
                }
                whereCourses += ")";
            }
            string whereInstructors = "";

            if (!checkAllInstructors.Checked)
            {
                for (int i = 0; i < gridInstructors.SelectedIndices.Length; i++)
                {
                    if (i == 0)
                    {
                        whereInstructors += " AND evaluation.InstructNum IN(";
                    }
                    whereInstructors += gridInstructors.Rows[gridInstructors.SelectedIndices[i]].Tag;
                    if (i != gridInstructors.SelectedIndices.Length - 1)
                    {
                        whereInstructors += ",";
                    }
                }
                whereInstructors += ")";
            }
            //No checkbox for students
            string whereStudents = " AND evaluation.StudentNum IN(";

            for (int i = 0; i < gridStudents.SelectedIndices.Length; i++)
            {
                whereStudents += gridStudents.Rows[gridStudents.SelectedIndices[i]].Tag;
                if (i != gridStudents.SelectedIndices.Length - 1)
                {
                    whereStudents += ",";
                }
            }
            whereStudents += ")";
            ReportSimpleGrid report = new ReportSimpleGrid();

            //Evaluations------------------------------------------------------------------------------
            report.Query = "SELECT " + DbHelper.Concat("students.LName", "', '", "students.FName") + " StudentName,evaluation.DateEval,"
                           + "courses.CourseID," + DbHelper.Concat("instructors.LName", "', '", "instructors.FName") + " InstructorName,"
                           + "evaluation.EvalTitle,gradeScales.ScaleType,evaluation.OverallGradeShowing,evaluation.OverallGradeNumber";
            report.Query += " FROM evaluation"
                            + " INNER JOIN provider students ON evaluation.StudentNum=students.ProvNum"
                            + " INNER JOIN provider instructors ON evaluation.InstructNum=instructors.ProvNum"
                            + " INNER JOIN gradingscale gradeScales ON evaluation.GradingScaleNum=gradeScales.GradingScaleNum"
                            + " INNER JOIN schoolcourse courses ON evaluation.SchoolCourseNum=courses.SchoolCourseNum"
                            + " WHERE evaluation.DateEval BETWEEN " + POut.Date(dateStart) + " AND " + POut.Date(dateEnd)
                            + whereCourses
                            + whereInstructors
                            + whereStudents
                            + " ORDER BY StudentName,evaluation.DateEval";
            FormQuery2          = new FormQuery(report);
            FormQuery2.IsReport = true;
            DataTable table = report.GetTempTable();

            report.TableQ = new DataTable();
            int colI = 10;

            for (int i = 0; i < colI; i++)                               //add columns
            {
                report.TableQ.Columns.Add(new System.Data.DataColumn()); //blank columns
            }
            report.InitializeColumns();
            DataRow row;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                row    = report.TableQ.NewRow();             //create new row called 'row' based on structure of TableQ
                row[0] = table.Rows[i]["StudentName"].ToString();
                row[1] = PIn.Date(table.Rows[i]["DateEval"].ToString()).ToShortDateString();
                row[2] = table.Rows[i]["CourseID"].ToString();
                row[3] = table.Rows[i]["InstructorName"].ToString();
                row[4] = table.Rows[i]["EvalTitle"].ToString();
                switch ((EnumScaleType)PIn.Int(table.Rows[i]["ScaleType"].ToString()))
                {
                case EnumScaleType.PickList:
                    row[5] = Enum.GetName(typeof(EnumScaleType), (int)EnumScaleType.PickList);
                    break;

                case EnumScaleType.Percentage:
                    row[5] = Enum.GetName(typeof(EnumScaleType), (int)EnumScaleType.Percentage);
                    break;

                case EnumScaleType.Weighted:
                    row[5] = Enum.GetName(typeof(EnumScaleType), (int)EnumScaleType.Weighted);
                    break;
                }
                row[6] = table.Rows[i]["OverallGradeShowing"].ToString();
                row[7] = table.Rows[i]["OverallGradeNumber"].ToString();
                report.TableQ.Rows.Add(row);
            }
            FormQuery2.ResetGrid();
            report.Title = Lan.g(this, "Course Average");
            report.SubTitle.Add(dateStart.ToShortDateString() + " - " + dateEnd.ToShortDateString());
            if (checkAllInstructors.Checked)
            {
                report.SubTitle.Add(Lan.g(this, "All Instructors"));
            }
            if (checkAllCourses.Checked)
            {
                report.SubTitle.Add(Lan.g(this, "All Courses"));
            }
            report.SetColumn(this, 0, "Student", 120);
            report.SetColumn(this, 1, "Date", 80);
            report.SetColumn(this, 2, "Course", 100);
            report.SetColumn(this, 3, "Instructor", 120);
            report.SetColumn(this, 4, "Evaluation", 90);
            report.SetColumn(this, 5, "Scale Type", 90);
            report.SetColumn(this, 6, "Grade Showing", 100);
            report.SetColumn(this, 7, "Grade Number", 100);
            FormQuery2.ShowDialog();
        }
コード例 #22
0
        private void butCreateQRDAs_Click(object sender, EventArgs e)
        {
            if (comboProv.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a provider first.");
                return;
            }
            if (listQ == null)
            {
                MsgBox.Show(this, "Click Refresh first.");
                return;
            }
            long provSelected = listProvsKeyed[comboProv.SelectedIndex].ProvNum;

            if (_provNum != provSelected)
            {
                MsgBox.Show(this, "The values in the grid do not apply to the provider selected.  Click Refresh first.");
                return;
            }
            Provider provDefault  = Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv));
            long     provNumLegal = provDefault.ProvNum;

            //The practice default provider may be set to a non-person, like Apple Tree Dental, in which case there is no first name allowed and an NPI number does not make sense.
            //Prompt user to select the provider to set as the legal authenticator for the QRDA documents.
            //The Legal Authenticator must have a valid first name, last name, and NPI number and is the "single person legally responsible for the document" and "must be a person".
            if (provDefault.IsNotPerson)
            {
                MsgBox.Show(this, "The practice default provider is marked 'Not a Person'.  Please select the provider legally responsible for the documents.  The provider must have a first name, last name, and NPI number.");
                FormProviderPick FormPP = new FormProviderPick();
                if (FormPP.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                if (Providers.GetProv(FormPP.SelectedProvNum).IsNotPerson)
                {
                    MsgBox.Show(this, "The selected provider was marked 'Not a person'.");
                    return;
                }
                provNumLegal = FormPP.SelectedProvNum;
            }
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string folderPath = fbd.SelectedPath + "\\" + "CQMs_" + DateTime.Today.ToString("MM_dd_yyyy");

            if (System.IO.Directory.Exists(folderPath))             //if the folder already exists
            //find a unique folder name
            {
                int    uniqueID     = 1;
                string originalPath = folderPath;
                do
                {
                    folderPath = originalPath + "_" + uniqueID.ToString();
                    uniqueID++;
                }while(System.IO.Directory.Exists(folderPath));
            }
            try {
                System.IO.Directory.CreateDirectory(folderPath);
            }
            catch (Exception ex) {
                MessageBox.Show("Folder was not created: " + ex.Message);
                return;
            }
            Cursor = Cursors.WaitCursor;
            try {
                QualityMeasures.GenerateQRDA(listQ, _provNum, _dateStart, _dateEnd, folderPath, provNumLegal);           //folderPath is a new directory created within the chosen directory
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                MessageBox.Show(ex.Message);
                if (ex.InnerException != null && ex.InnerException.Message == "true")
                {
                    FormOIDRegistryInternal FormOIDs = new FormOIDRegistryInternal();
                    FormOIDs.ShowDialog();
                }
                return;
            }
            Cursor = Cursors.Default;
            MsgBox.Show(this, "QRDA files have been created within the selected directory.");
        }
コード例 #23
0
ファイル: FormRpNewPatients.cs プロジェクト: nampn/ODental
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDateFrom.errorProvider1.GetError(textDateFrom) != "" ||
                textDateTo.errorProvider1.GetError(textDateTo) != ""
                )
            {
                MessageBox.Show(Lan.g(this, "Please fix data entry errors first."));
                return;
            }
            if (listProv.SelectedIndices.Count == 0)
            {
                MsgBox.Show(this, "At least one provider must be selected.");
                return;
            }
            if (listProv.SelectedIndices[0] == 0 && listProv.SelectedIndices.Count > 1)
            {
                MsgBox.Show(this, "You cannot select 'all' providers as well as specific providers.");
                return;
            }
            DateTime dateFrom  = PIn.Date(textDateFrom.Text);
            DateTime dateTo    = PIn.Date(textDateTo.Text);
            string   whereProv = "";

            if (listProv.SelectedIndices[0] != 0)
            {
                for (int i = 0; i < listProv.SelectedIndices.Count; i++)
                {
                    if (i == 0)
                    {
                        whereProv += " WHERE (";
                    }
                    else
                    {
                        whereProv += "OR ";
                    }
                    whereProv += "patient.PriProv = "
                                 + POut.Long(ProviderC.ListShort[listProv.SelectedIndices[i] - 1].ProvNum) + " ";
                }
                whereProv += ") ";
            }
            ReportSimpleGrid report = new ReportSimpleGrid();

            report.Query = @"SET @pos=0;
SELECT @pos:=@pos+1 patCount,result.* FROM (SELECT dateFirstProc,patient.LName,patient.FName,"
                           + DbHelper.Concat("referral.LName", "IF(referral.FName='','',',')", "referral.FName") + " refname,SUM(procedurelog.ProcFee) ";//\"$HowMuch\"";
            if (DataConnection.DBtype == DatabaseType.MySql)
            {
                report.Query += "$HowMuch";
            }
            else               //Oracle needs quotes.
            {
                report.Query += "\"$HowMuch\"";
            }
            if (checkAddress.Checked)
            {
                report.Query += ",patient.Preferred,patient.Address,patient.Address2,patient.City,patient.State,patient.Zip";
            }
            report.Query += @" FROM
				(SELECT PatNum, MIN(ProcDate) dateFirstProc FROM procedurelog
				WHERE ProcStatus=2 GROUP BY PatNum
				HAVING dateFirstProc >= "                 + POut.Date(dateFrom) + " "
                            + "AND DATE(dateFirstProc) <= " + POut.Date(dateTo) + " ) table1 "
                            + @"INNER JOIN patient ON table1.PatNum=patient.PatNum 
				LEFT JOIN procedurelog ON patient.PatNum=procedurelog.PatNum AND procedurelog.ProcStatus=2
				LEFT JOIN refattach ON patient.PatNum=refattach.PatNum AND refattach.IsFrom=1
				AND refattach.ItemOrder=(SELECT MIN(ra.ItemOrder) FROM refattach ra WHERE ra.PatNum=refattach.PatNum AND ra.IsFrom=1)
				LEFT JOIN referral ON referral.ReferralNum=refattach.ReferralNum "
                            + whereProv;
            report.Query += "GROUP BY patient.LName,patient.FName,patient.PatNum," + DbHelper.Concat("referral.LName", "IF(referral.FName='','',',')", "referral.FName");
            if (checkAddress.Checked)
            {
                report.Query += ",patient.Preferred,patient.Address,patient.Address2,patient.City,patient.State,patient.Zip ";
            }
            if (checkProd.Checked)
            {
                if (DataConnection.DBtype == DatabaseType.MySql)
                {
                    report.Query += "HAVING $HowMuch > 0 ";
                }
                else                  //Oracle needs quotes.
                {
                    report.Query += "HAVING \"$HowMuch\" > 0 ";
                }
            }
            report.Query       += "ORDER BY dateFirstProc,patient.LName,patient.FName) result";
            FormQuery2          = new FormQuery(report);
            FormQuery2.IsReport = true;
            FormQuery2.SubmitReportQuery();
            report.Title = "New Patients";
            report.SubTitle.Add(PrefC.GetString(PrefName.PracticeTitle));
            if (listProv.SelectedIndices[0] == 0)
            {
                report.SubTitle.Add(Lan.g(this, "All Providers"));
                report.SubTitle.Add(dateFrom.ToString("d") + " - " + dateTo.ToString("d"));
            }
            else if (listProv.SelectedIndices.Count == 1)
            {
                report.SubTitle.Add(Lan.g(this, "Prov: ") + ProviderC.ListShort[listProv.SelectedIndices[0] - 1].GetLongDesc());
                report.SubTitle.Add(dateFrom.ToString("d") + " - " + dateTo.ToString("d"));
            }
            else
            {
                //I'm too lazy to build a description for multiple providers as well as ensure that it fits the space.
                report.SubTitle.Add(dateFrom.ToString("d") + " - " + dateTo.ToString("d"));
            }
            report.SetColumnPos(this, 0, "#", 40);
            report.SetColumnPos(this, 1, "Date", 120);
            report.SetColumnPos(this, 2, "Last Name", 210);
            report.SetColumnPos(this, 3, "First Name", 300);
            report.SetColumnPos(this, 4, "Referral", 380);
            report.SetColumnPos(this, 5, "Production", 450, HorizontalAlignment.Right);
            if (checkAddress.Checked)
            {
                report.SetColumnPos(this, 6, "Pref'd", 500);
                report.SetColumnPos(this, 7, "Address", 570);
                report.SetColumnPos(this, 8, "Add2", 630);
                report.SetColumnPos(this, 9, "City", 680);
                report.SetColumnPos(this, 10, "ST", 730);
                report.SetColumnPos(this, 11, "Zip", 880);             //off the right side
            }
            FormQuery2.ShowDialog();
            DialogResult = DialogResult.OK;
        }
コード例 #24
0
        private void FormPatientSmoking_Load(object sender, EventArgs e)
        {
            _patOld = PatCur.Copy();
            textDateAssessed.Text     = DateTime.Now.ToString();
            textDateIntervention.Text = DateTime.Now.ToString();
            #region ComboSmokeStatus
            comboSmokeStatus.Items.Add("None");            //First and default index
            //Smoking statuses add in the same order as they appear in the SmokingSnoMed enum (Starting at comboSmokeStatus index 1).
            //Changes to the enum order will change the order added so they will always match
            for (int i = 0; i < Enum.GetNames(typeof(SmokingSnoMed)).Length; i++)
            {
                //if snomed code exists in the snomed table, use the snomed description for the combo box, otherwise use the original abbreviated description
                Snomed smokeCur = Snomeds.GetByCode(((SmokingSnoMed)i).ToString().Substring(1));
                if (smokeCur != null)
                {
                    comboSmokeStatus.Items.Add(smokeCur.Description);
                }
                else
                {
                    switch ((SmokingSnoMed)i)
                    {
                    case SmokingSnoMed._266927001:
                        comboSmokeStatus.Items.Add("UnknownIfEver");
                        break;

                    case SmokingSnoMed._77176002:
                        comboSmokeStatus.Items.Add("SmokerUnknownCurrent");
                        break;

                    case SmokingSnoMed._266919005:
                        comboSmokeStatus.Items.Add("NeverSmoked");
                        break;

                    case SmokingSnoMed._8517006:
                        comboSmokeStatus.Items.Add("FormerSmoker");
                        break;

                    case SmokingSnoMed._428041000124106:
                        comboSmokeStatus.Items.Add("CurrentSomeDay");
                        break;

                    case SmokingSnoMed._449868002:
                        comboSmokeStatus.Items.Add("CurrentEveryDay");
                        break;

                    case SmokingSnoMed._428061000124105:
                        comboSmokeStatus.Items.Add("LightSmoker");
                        break;

                    case SmokingSnoMed._428071000124103:
                        comboSmokeStatus.Items.Add("HeavySmoker");
                        break;
                    }
                }
            }
            comboSmokeStatus.SelectedIndex = 0;          //None
            try {
                comboSmokeStatus.SelectedIndex = (int)Enum.Parse(typeof(SmokingSnoMed), "_" + PatCur.SmokingSnoMed, true) + 1;
            }
            catch {
                //if not one of the statuses in the enum, get the Snomed object from the patient's current smoking snomed code
                Snomed smokeCur = Snomeds.GetByCode(PatCur.SmokingSnoMed);
                if (smokeCur != null)               //valid snomed code, set the combo box text to this snomed description
                {
                    comboSmokeStatus.SelectedIndex = -1;
                    comboSmokeStatus.Text          = smokeCur.Description;
                }
            }
            #endregion
            //This takes a while the first time the window loads due to Code Systems.
            Cursor = Cursors.WaitCursor;
            FillGridAssessments();
            FillGridInterventions();
            Cursor = Cursors.Default;
            #region ComboAssessmentType
            _listAssessmentCodes = EhrCodes.GetForValueSetOIDs(new List <string> {
                "2.16.840.1.113883.3.526.3.1278"
            }, true);                                      //'Tobacco Use Screening' value set
            if (_listAssessmentCodes.Count == 0)           //This should only happen if the EHR.dll does not exist or if the codes in the ehrcode list do not exist in the corresponding table
            {
                MsgBox.Show(this, "The codes used for Tobacco Use Screening assessments do not exist in the LOINC table in your database.  You must run the Code System Importer tool in Setup | Chart | EHR to import this code set.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            _listAssessmentCodes.ForEach(x => comboAssessmentType.Items.Add(x.Description));
            string mostRecentAssessmentCode = "";
            if (gridAssessments.Rows.Count > 1)
            {
                //gridAssessments.Rows are tagged with all TobaccoUseAssessed events for the patient ordered by DateTEvent, last is most recent
                mostRecentAssessmentCode = ((EhrMeasureEvent)gridAssessments.Rows[gridAssessments.Rows.Count - 1].Tag).CodeValueResult;
            }
            //use Math.Max so that if _listAssessmentCodes doesn't contain the mostRecentAssessment code the combobox will default to the first in the list
            comboAssessmentType.SelectedIndex = Math.Max(0, _listAssessmentCodes.FindIndex(x => x.CodeValue == mostRecentAssessmentCode));
            #endregion ComboAssessmentType
            #region ComboTobaccoStatus
            //list is filled with the EhrCodes for all tobacco user statuses using the CQM value set
            _listUserCodes = EhrCodes.GetForValueSetOIDs(new List <string> {
                "2.16.840.1.113883.3.526.3.1170"
            }, true).OrderBy(x => x.Description).ToList();
            //list is filled with the EhrCodes for all tobacco non-user statuses using the CQM value set
            _listNonUserCodes = EhrCodes.GetForValueSetOIDs(new List <string> {
                "2.16.840.1.113883.3.526.3.1189"
            }, true).OrderBy(x => x.Description).ToList();
            _listRecentTobaccoCodes = EhrCodes.GetForEventTypeByUse(EhrMeasureEventType.TobaccoUseAssessed);
            //list is filled with any SNOMEDCT codes that are attached to EhrMeasureEvents for the patient that are not in the User and NonUser lists
            _listCustomTobaccoCodes = new List <EhrCode>();
            //codeValues is an array of all user and non-user tobacco codes
            string[] codeValues = _listUserCodes.Concat(_listNonUserCodes).Concat(_listRecentTobaccoCodes).Select(x => x.CodeValue).ToArray();
            //listEventCodes will contain all unique tobacco codes that are not in the user and non-user lists
            List <string> listEventCodes = new List <string>();
            foreach (ODGridRow row in gridAssessments.Rows)
            {
                string eventCodeCur = ((EhrMeasureEvent)row.Tag).CodeValueResult;
                if (codeValues.Contains(eventCodeCur) || listEventCodes.Contains(eventCodeCur))
                {
                    continue;
                }
                listEventCodes.Add(eventCodeCur);
            }
            Snomed sCur;
            foreach (string eventCode in listEventCodes.OrderBy(x => x))
            {
                sCur = Snomeds.GetByCode(eventCode);
                if (sCur == null)               //don't add invalid SNOMEDCT codes
                {
                    continue;
                }
                _listCustomTobaccoCodes.Add(new EhrCode {
                    CodeValue = sCur.SnomedCode, Description = sCur.Description
                });
            }
            _listCustomTobaccoCodes = _listCustomTobaccoCodes.OrderBy(x => x.Description).ToList();
            //list will contain all of the tobacco status EhrCodes currently in comboTobaccoStatus
            _listTobaccoStatuses = new List <EhrCode>();
            //default to all tobacco statuses (custom, user, and non-user) in the status dropdown box
            radioRecentStatuses.Checked = true;          //causes combo box and _listTobaccoStatuses to be filled with all statuses
            #endregion ComboTobaccoStatus
            #region ComboInterventionType and ComboInterventionCode
            //list is filled with EhrCodes for counseling interventions using the CQM value set
            _listCounselInterventionCodes = EhrCodes.GetForValueSetOIDs(new List <string> {
                "2.16.840.1.113883.3.526.3.509"
            }, true).OrderBy(x => x.Description).ToList();
            //list is filled with EhrCodes for medication interventions using the CQM value set
            _listMedInterventionCodes = EhrCodes.GetForValueSetOIDs(new List <string> {
                "2.16.840.1.113883.3.526.3.1190"
            }, true).OrderBy(x => x.Description).ToList();
            _listRecentIntvCodes = EhrCodes.GetForIntervAndMedByUse(InterventionCodeSet.TobaccoCessation, new List <string> {
                "2.16.840.1.113883.3.526.3.1190"
            });
            _listInterventionCodes = new List <EhrCode>();
            //default to all interventions (couseling and medication) in the intervention dropdown box
            radioRecentInterventions.Checked = true;          //causes combo box and _listInterventionCodes to be filled with all intervention codes
            #endregion ComboInterventionType and ComboInterventionCode
            _comboToolTip = new ToolTip()
            {
                InitialDelay = 1000, ReshowDelay = 1000, ShowAlways = true
            };
        }
コード例 #25
0
        private void butImportEcw_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            OpenFileDialog Dlg = new OpenFileDialog();

                        #if DEBUG
            Dlg.InitialDirectory = @"E:\My Documents\Bridge Info\eClinicalWorks\FeeSchedules";
                        #endif
            if (Dlg.ShowDialog() != DialogResult.OK)
            {
                Cursor = Cursors.Default;
                return;
            }
            if (!File.Exists(Dlg.FileName))
            {
                Cursor = Cursors.Default;
                MsgBox.Show(this, "File not found");
                return;
            }
            string extension = Path.GetExtension(Dlg.FileName);
            if (extension != ".csv")
            {
                Cursor = Cursors.Default;
                MsgBox.Show(this, "Only .csv files may be imported.");
                return;
            }
            string[] lines = File.ReadAllLines(Dlg.FileName);
            if (lines.Length == 0 || (lines[0] != "Code,Description,Unit Fee,Allowed Fee,POS,TOS,Modifier,RequiresCliaID,GlobalBillingDays,ChargeCode" &&
                                      lines[0] != "\"Code\",\"Description\",\"UnitFee\",\"AllowedFee\",\"POS\",\"TOS\",\"Modifier\",\"RequiresCliaID\",\"GlobalBillingDays\",\"ChargeCode\""))
            {
                Cursor = Cursors.Default;
                MessageBox.Show("Unexpected file format. First line in file should be:\r\nCode,Description,Unit Fee,Allowed Fee,POS,TOS,Modifier,RequiresCliaID,GlobalBillingDays,ChargeCode\r\nor\r\n\"Code\",\"Description\",\"UnitFee\",\"AllowedFee\",\"POS\",\"TOS\",\"Modifier\",\"RequiresCliaID\",\"GlobalBillingDays\",\"ChargeCode\"");
                return;
            }
            string   feeSchedName = Path.GetFileNameWithoutExtension(Dlg.FileName);
            FeeSched feesched     = FeeScheds.GetByExactName(feeSchedName, FeeScheduleType.Normal);
            if (feesched == null)
            {
                feesched              = new FeeSched();
                feesched.Description  = feeSchedName;
                feesched.FeeSchedType = FeeScheduleType.Normal;
                feesched.ItemOrder    = FeeSchedC.ListLong[FeeSchedC.ListLong.Count - 1].ItemOrder + 1;
                feesched.IsHidden     = false;
                //feesched.IsNew=true;
                FeeScheds.Insert(feesched);
                DataValid.SetInvalid(InvalidType.FeeScheds);
            }
            else
            {
                if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Fee schedule already exists and all the fees will be overwritten.  Continue?"))
                {
                    Cursor = Cursors.Default;
                    return;
                }
                Fees.ClearFeeSched(feesched.FeeSchedNum);
            }
            bool importAllowed = false;
            if (MsgBox.Show(this, MsgBoxButtons.YesNo, "Import Allowed Fee column instead of Unit Fee column?"))
            {
                importAllowed = true;
            }
            int           imported         = 0;
            int           skippedCode      = 0;
            int           skippedMalformed = 0;
            string[]      fieldArray;
            List <string> fields;
            double        feeAmt       = 0;
            string        codeText     = "";
            bool          formatQuotes = false;
            if (lines.Length > 1)
            {
                if (lines[1].Substring(0, 1) == "\"")
                {
                    formatQuotes = true;
                }
            }
            if (formatQuotes)             //Original format - fields are surrounded by quotes (except first row, above)
            {
                for (int i = 1; i < lines.Length; i++)
                {
                    //fieldArray=lines[i].Split(new string[1] { "\"" },StringSplitOptions.RemoveEmptyEntries);//Removing emtpy entries will misalign the columns
                    fieldArray = lines[i].Split(new string[1] {
                        "\""
                    }, StringSplitOptions.None);                                //half the 'fields' will be commas.
                    fields = new List <string>();
                    for (int f = 1; f < fieldArray.Length - 1; f++)             //this loop skips the first and last elements because they are artifacts of the string splitting.
                    {
                        if (fieldArray[f] == ",")
                        {
                            continue;
                        }
                        fields.Add(fieldArray[f]);
                    }
                    if (fields.Count < 4)
                    {
                        skippedMalformed++;
                        continue;
                    }
                    if (importAllowed)
                    {
                        feeAmt = PIn.Double(fields[3]);
                    }
                    else
                    {
                        feeAmt = PIn.Double(fields[2]);
                    }
                    codeText = fields[0];
                    if (!ProcedureCodes.IsValidCode(codeText))
                    {
                        skippedCode++;
                        continue;
                    }
                    Fees.Import(fields[0], feeAmt, feesched.FeeSchedNum);
                    imported++;
                }
            }
            else              //New format - fields are delimited by commas only (no quotes)
            {
                for (int i = 1; i < lines.Length; i++)
                {
                    fieldArray = lines[i].Split(new string[1] {
                        ","
                    }, StringSplitOptions.None);
                    fields = new List <string>();
                    for (int f = 0; f < fieldArray.Length; f++)
                    {
                        fields.Add(fieldArray[f]);
                    }
                    if (fields.Count < 4)
                    {
                        skippedMalformed++;
                        continue;
                    }
                    if (fields.Count > 10)
                    {
                        MsgBox.Show(this, "Import aborted. Commas are not allowed in text fields. Check your descriptions for commas and try again.");
                        Cursor = Cursors.Default;
                        return;
                    }
                    if (importAllowed)
                    {
                        feeAmt = PIn.Double(fields[3]);
                    }
                    else
                    {
                        feeAmt = PIn.Double(fields[2]);
                    }
                    codeText = fields[0];
                    if (!ProcedureCodes.IsValidCode(codeText))
                    {
                        skippedCode++;
                        continue;
                    }
                    Fees.Import(fields[0], feeAmt, feesched.FeeSchedNum);
                    imported++;
                }
            }
            DataValid.SetInvalid(InvalidType.Fees);
            Cursor = Cursors.Default;
            string displayMsg = "Import complete.\r\nCodes imported: " + imported.ToString();
            if (skippedCode > 0)
            {
                displayMsg += "\r\nCodes skipped because not valid codes in Open Dental: " + skippedCode.ToString();
            }
            if (skippedMalformed > 0)
            {
                displayMsg += "\r\nCodes skipped because malformed line in text file: " + skippedMalformed.ToString();
            }
            MessageBox.Show(displayMsg);
            DialogResult = DialogResult.OK;
        }
コード例 #26
0
        private void butPrint_Click(object sender, EventArgs e)
        {
            if (gridMain.ListGridRows.Count == 0)
            {
                MsgBox.Show(this, "The report has no results to show. Please click 'Refresh' to populate the grid first.");
                return;
            }
            DataTable tableReportCur = new DataTable();

            tableReportCur.Columns.Add("Patient");
            tableReportCur.Columns.Add("0_30");
            tableReportCur.Columns.Add("31_60");
            tableReportCur.Columns.Add("61_90");
            tableReportCur.Columns.Add("Over90");
            tableReportCur.Columns.Add("BatTotal");
            //Uses the grid's rows so that the user's row sorting selection is retained.
            foreach (AgingPat agingPatCur in gridMain.ListGridRows.Select(x => (AgingPat)x.Tag))
            {
                DataRow row = tableReportCur.NewRow();
                row["Patient"]  = agingPatCur.Pat.GetNameLF();
                row["0_30"]     = agingPatCur.BalZeroThirty.ToString("f");
                row["31_60"]    = agingPatCur.BalThirtySixty.ToString("f");
                row["61_90"]    = agingPatCur.BalSixtyNinety.ToString("f");
                row["Over90"]   = agingPatCur.BalOverNinety.ToString("f");
                row["BatTotal"] = agingPatCur.BalTotal.ToString("f");
                tableReportCur.Rows.Add(row);
            }
            ReportComplex report = new ReportComplex(true, false);

            report.ReportName = Lan.g(this, "Custom Aging of Accounts Receivable");
            report.AddTitle("Custom Aging Report", Lan.g(this, "Custom Aging of Accounts Receivable"));
            report.AddSubTitle("PracTitle", PrefC.GetString(PrefName.PracticeTitle));
            report.AddSubTitle("AsOf", Lan.g(this, "As of ") + _agingOptions.DateAsOf.ToShortDateString());
            List <string> listAgingInc = new List <string>();

            //Go through every aging option and for every one that is selected, add the descriptions as a subtitle
            foreach (AgingOptions.AgingInclude agingInc in Enum.GetValues(typeof(AgingOptions.AgingInclude)))
            {
                if (agingInc == AgingOptions.AgingInclude.None)
                {
                    continue;
                }
                if (_agingOptions.AgingInc.HasFlag(agingInc))
                {
                    listAgingInc.Add(Lan.g(this, agingInc.GetDescription()));
                }
            }
            //Add a newline to the list if it's too long.
            if (listAgingInc.Count > 5)
            {
                listAgingInc[(listAgingInc.Count + 1) / 2] = "\r\n" + listAgingInc[(listAgingInc.Count + 1) / 2];
            }
            report.AddSubTitle("AgeInc", Lan.g(this, "For") + ": " + string.Join(", ", listAgingInc));
            if (_agingOptions.AgeAccount == AgeOfAccount.Any)
            {
                report.AddSubTitle("Balance", Lan.g(this, "Any Balance"));
            }
            else if (_agingOptions.AgeAccount == AgeOfAccount.Over30)
            {
                report.AddSubTitle("Over30", Lan.g(this, "Over 30 Days"));
            }
            else if (_agingOptions.AgeAccount == AgeOfAccount.Over60)
            {
                report.AddSubTitle("Over60", Lan.g(this, "Over 60 Days"));
            }
            else if (_agingOptions.AgeAccount == AgeOfAccount.Over90)
            {
                report.AddSubTitle("Over90", Lan.g(this, "Over 90 Days"));
            }
            if (_agingOptions.ListBillTypes == null)
            {
                report.AddSubTitle("BillingTypes", Lan.g(this, "All Billing Types"));
            }
            else
            {
                report.AddSubTitle("BillingTypes", string.Join(", ", _agingOptions.ListBillTypes.Select(x => x.ItemName)));
            }
            if (_agingOptions.ListProvs == null)
            {
                report.AddSubTitle("Providers", Lan.g(this, "All Providers"));
            }
            else
            {
                report.AddSubTitle("Providers", string.Join(", ", _agingOptions.ListProvs.Select(x => x.Abbr)));
            }
            if (_agingOptions.ListClins == null)
            {
                report.AddSubTitle("Clinics", Lan.g(this, "All Clinics"));
            }
            else
            {
                report.AddSubTitle("Clinics", string.Join(", ", _agingOptions.ListClins.Select(x => x.Abbr)));
            }
            QueryObject query = report.AddQuery(tableReportCur, "Date " + DateTimeOD.Today.ToShortDateString());

            query.AddColumn((_agingOptions.FamGroup == AgingOptions.FamilyGrouping.Family ? "GUARANTOR" : "PATIENT"), 160, FieldValueType.String);
            query.AddColumn("0-30 DAYS", 75, FieldValueType.Number);
            query.AddColumn("31-60 DAYS", 75, FieldValueType.Number);
            query.AddColumn("61-90 DAYS", 75, FieldValueType.Number);
            query.AddColumn("> 90 DAYS", 75, FieldValueType.Number);
            query.AddColumn("TOTAL", 80, FieldValueType.Number);
            report.AddPageNum();
            report.AddGridLines();
            if (!report.SubmitQueries())
            {
                return;
            }
            FormReportComplex FormR = new FormReportComplex(report);

            FormR.ShowDialog();
        }
コード例 #27
0
        private void butApptProcs_Click(object sender, EventArgs e)
        {
            if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "This will fix procedure descriptions in the Appt module that aren't correctly showing tooth numbers.\r\nContinue?"))
            {
                return;
            }
            Cursor = Cursors.WaitCursor;
            //The ApptProcDescript region is also in FormProcEdit.SaveAndClose() and FormApptEdit.UpdateToDB()  Make any changes there as well.
            #region ApptProcDescript
            List <long>   aptNums = new List <long>();
            Appointment[] aptList = Appointments.GetForPeriod(DateTime.Now.Date.AddMonths(-6), DateTime.MaxValue.AddDays(-10));
            for (int i = 0; i < aptList.Length; i++)
            {
                aptNums.Add(aptList[i].AptNum);
            }
            for (int i = 0; i < aptList.Length; i++)
            {
                //This gets the list of procedures in the correct order.
                DataTable   procTable = Appointments.GetProcTable(aptList[i].PatNum.ToString(), aptList[i].AptNum.ToString(), ((int)aptList[i].AptStatus).ToString(), aptList[i].AptDateTime.ToString());
                Appointment newApt    = aptList[i].Clone();
                newApt.ProcDescript = "";
                newApt.ProcsColored = "";
                int count = 0;
                for (int j = 0; j < procTable.Rows.Count; j++)
                {
                    if (procTable.Rows[j]["attached"].ToString() != "1")
                    {
                        continue;
                    }
                    string procDescOne = "";
                    string procCode    = procTable.Rows[j]["ProcCode"].ToString();
                    if (count > 0)
                    {
                        newApt.ProcDescript += ", ";
                    }
                    switch (procTable.Rows[j]["TreatArea"].ToString())
                    {
                    case "1":                                                        //TreatmentArea.Surf:
                        procDescOne += "#" + Tooth.GetToothLabel(procTable.Rows[j]["ToothNum"].ToString()) + "-"
                                       + procTable.Rows[j]["Surf"].ToString() + "-"; //""#12-MOD-"
                        break;

                    case "2":                                                                                     //TreatmentArea.Tooth:
                        procDescOne += "#" + Tooth.GetToothLabel(procTable.Rows[j]["ToothNum"].ToString()) + "-"; //"#12-"
                        break;

                    default:                            //area 3 or 0 (mouth)
                        break;

                    case "4":                                                      //TreatmentArea.Quad:
                        procDescOne += procTable.Rows[j]["Surf"].ToString() + "-"; //"UL-"
                        break;

                    case "5":                                                            //TreatmentArea.Sextant:
                        procDescOne += "S" + procTable.Rows[j]["Surf"].ToString() + "-"; //"S2-"
                        break;

                    case "6":                                                      //TreatmentArea.Arch:
                        procDescOne += procTable.Rows[j]["Surf"].ToString() + "-"; //"U-"
                        break;

                    case "7":                            //TreatmentArea.ToothRange:
                        //strLine+=table.Rows[j][13].ToString()+" ";//don't show range
                        break;
                    }
                    procDescOne         += procTable.Rows[j]["AbbrDesc"].ToString();
                    newApt.ProcDescript += procDescOne;
                    //Color and previous date are determined by ProcApptColor object
                    ProcApptColor        pac    = ProcApptColors.GetMatch(procCode);
                    System.Drawing.Color pColor = System.Drawing.Color.Black;
                    string prevDateString       = "";
                    if (pac != null)
                    {
                        pColor = pac.ColorText;
                        if (pac.ShowPreviousDate)
                        {
                            prevDateString = Procedures.GetRecentProcDateString(newApt.PatNum, newApt.AptDateTime, pac.CodeRange);
                            if (prevDateString != "")
                            {
                                prevDateString = " (" + prevDateString + ")";
                            }
                        }
                    }
                    newApt.ProcsColored += "<span color=\"" + pColor.ToArgb().ToString() + "\">" + procDescOne + prevDateString + "</span>";
                    count++;
                }
                Appointments.Update(newApt, aptList[i]);
            }
            #endregion
            Cursor = Cursors.Default;
            MsgBox.Show(this, "Done. Please refresh Appt module to see the changes.");
        }
コード例 #28
0
ファイル: FormEmailJobs.cs プロジェクト: ChemBrain/OpenDental
        ///<summary></summary>
        private void butSend_Click(object sender, System.EventArgs e)
        {
            if (comboEmailFrom.SelectedIndex < 0)
            {
                MessageBox.Show("Select an email address to send from first.");
            }
            EmailAddress emailAddress;

            if (comboEmailFrom.SelectedIndex == 0)                                    //clinic/practice default
            {
                emailAddress = EmailAddresses.GetByClinic(Clinics.ClinicNum);         //practice or clinic.
            }
            else                                                                      //me or static email address
            {
                emailAddress = _listEmailAddresses[comboEmailFrom.SelectedIndex - 1]; //-1 to account for predefined "Clinic/Practice" and items in combobox
            }
            if (emailAddress == null)
            {
                MessageBox.Show("Unable to find email address.");
                return;
            }
            if (string.IsNullOrWhiteSpace(textFromAddress.Text))
            {
                MsgBox.Show(this, "Please enter a sender address.");
                return;
            }
            if (_listJobEmails.All(x => !x.IsSend))
            {
                MsgBox.Show(this, "Please select at least one recipient.");
                return;
            }
            if (emailAddress.SMTPserver == "")
            {
                MsgBox.Show(this, "The email address in email setup must have an SMTP server.");
                return;
            }
            if (string.IsNullOrEmpty(textVersions.Text))
            {
                if (MessageBox.Show("No version specified, continue?", "", MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
                {
                    return;
                }
            }
            if (string.IsNullOrEmpty(textDescriptions.Text))
            {
                if (MessageBox.Show("No description specified, continue?", "", MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
                {
                    return;
                }
            }
            if (string.IsNullOrEmpty(textSubject.Text))
            {
                if (MessageBox.Show("No subject specified, continue?", "", MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
                {
                    return;
                }
            }
            StringBuilder sb = new StringBuilder();

            Cursor = Cursors.WaitCursor;
            string template = PrefC.GetString(PrefName.JobManagerDefaultEmail);

            foreach (Jobs.JobEmail je in _listJobEmails)
            {
                if (!je.IsSend)
                {
                    continue;
                }
#if DEBUG
                je.EmailAddress = "*****@*****.**";              //send all emails to Ryan for debugging.
#endif
                EmailMessage emailMessage = GetJobEmailMessage(je);
                try {
                    EmailMessages.SendEmailUnsecure(emailMessage, emailAddress);
                    emailMessage.SentOrReceived = EmailSentOrReceived.Sent;
                    EmailMessages.Insert(emailMessage);
                    je.StatusMsg = "Sent";
                    je.IsSend    = false;
                }
                catch (Exception ex) {
                    je.StatusMsg = ex.Message;
                    sb.AppendLine(ex.Message + "\r\n");
                }
            }
            Cursor         = Cursors.Default;
            _isSent        = true;
            butSend.Text   = "Resend";
            butCancel.Text = "Close";
            if (!string.IsNullOrEmpty(sb.ToString()))
            {
                MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste("The following errors occurred while sending emails:\r\n" + sb.ToString());
                msgBox.ShowDialog();
            }
            FillGridRecipients();
        }
コード例 #29
0
        private void butOK_Click(object sender, EventArgs e)
        {
            //Verify Data.
            if (listEmployees.SelectedIndex < 0)
            {
                MsgBox.Show(this, "Please select an employee.");
                return;
            }
            TimeSpan overHoursPerDay = TimeSpan.Zero;

            if (textOverHoursPerDay.Text != "")
            {
                try {
                    if (textOverHoursPerDay.Text.Contains(":"))
                    {
                        overHoursPerDay = TimeSpan.Parse(textOverHoursPerDay.Text);
                    }
                    else
                    {
                        overHoursPerDay = TimeSpan.FromHours(PIn.Double(textOverHoursPerDay.Text));
                    }
                }
                catch {
                    MsgBox.Show(this, "Over hours per day invalid.");
                    return;
                }
                if (overHoursPerDay == TimeSpan.Zero || overHoursPerDay.Days > 0)
                {
                    MsgBox.Show(this, "Over hours per day invalid.");
                    return;
                }
            }
            TimeSpan afterTimeOfDay = TimeSpan.Zero;

            if (textAfterTimeOfDay.Text != "")
            {
                try {
                    afterTimeOfDay = DateTime.Parse(textAfterTimeOfDay.Text).TimeOfDay;
                }
                catch {
                    MsgBox.Show(this, "After time of day invalid.");
                    return;
                }
                if (afterTimeOfDay == TimeSpan.Zero || afterTimeOfDay.Days > 0)
                {
                    MsgBox.Show(this, "After time of day invalid.");
                    return;
                }
            }
            if (overHoursPerDay == TimeSpan.Zero && afterTimeOfDay == TimeSpan.Zero)
            {
                MsgBox.Show(this, "Hours or time of day must be entered.");
                return;
            }
            //save-------------------------------------------------
            if (listEmployees.SelectedIndex == 0)
            {
                timeCardRule.EmployeeNum = 0;              //All employees.
            }
            else
            {
                timeCardRule.EmployeeNum = Employees.ListShort[listEmployees.SelectedIndex - 1].EmployeeNum;
            }
            timeCardRule.OverHoursPerDay = overHoursPerDay;
            timeCardRule.AfterTimeOfDay  = afterTimeOfDay;
            if (timeCardRule.IsNew)
            {
                TimeCardRules.Insert(timeCardRule);
            }
            else
            {
                TimeCardRules.Update(timeCardRule);
            }
            DialogResult = DialogResult.OK;
        }
コード例 #30
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (listConditionType.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a condition type.");
                return;
            }
            RequiredFieldName      selectedField = _listIndexFieldNames[listConditionType.SelectedIndex];
            RequiredFieldCondition condition;

            switch (selectedField)
            {
            //Types that are continuous values
            case RequiredFieldName.Birthdate:
            case RequiredFieldName.AdmitDate:
            case RequiredFieldName.DateTimeDeceased:
                if (textConditionValue1.Text == "")
                {
                    MsgBox.Show(this, "Please enter a condition value.");
                    return;
                }
                if (comboOperator1.SelectedIndex == -1)
                {
                    MsgBox.Show(this, "Please select an operator from the drop down list.");
                    return;
                }
                //Construct the first condition
                RequiredFieldCondition condition1 = new RequiredFieldCondition();
                condition1.RequiredFieldNum = _reqField.RequiredFieldNum;
                condition1.ConditionType    = selectedField;
                int      agePlaceholder;
                DateTime datePlaceholder;
                if (selectedField == RequiredFieldName.Birthdate && !Int32.TryParse(textConditionValue1.Text, out agePlaceholder))
                {
                    MsgBox.Show(this, "Please enter a valid integer.");
                    return;
                }
                else if ((selectedField == RequiredFieldName.AdmitDate || selectedField == RequiredFieldName.DateTimeDeceased) &&
                         !DateTime.TryParse(textConditionValue1.Text, out datePlaceholder))
                {
                    MsgBox.Show(this, "Please enter a valid date.");
                    return;
                }
                condition1.ConditionValue = textConditionValue1.Text;
                condition1.Operator       = (ConditionOperator)(comboOperator1.SelectedIndex + 2);              //Plus 2 because Equals and NotEquals are not in the combo box
                RequiredFieldConditions.DeleteAll(_listReqFieldConds.Select(x => x.RequiredFieldConditionNum).ToList());
                if (textConditionValue2.Text == "")
                {
                    RequiredFieldConditions.Insert(condition1);
                    break;
                }
                //Construct the second condition if it is not blank
                if (comboOperator2.SelectedIndex == -1)
                {
                    MsgBox.Show(this, "Please select an operator from the drop down list.");
                    return;
                }
                if (listRelationships.SelectedIndex == -1)
                {
                    MsgBox.Show(this, "Please select 'And' or 'Or'.");
                    return;
                }
                RequiredFieldCondition condition2 = new RequiredFieldCondition();
                condition2.RequiredFieldNum = _reqField.RequiredFieldNum;
                condition2.ConditionType    = selectedField;
                if (selectedField == RequiredFieldName.Birthdate && !Int32.TryParse(textConditionValue2.Text, out agePlaceholder))
                {
                    MsgBox.Show(this, "Please enter a valid integer.");
                    return;
                }
                else if ((selectedField == RequiredFieldName.AdmitDate || selectedField == RequiredFieldName.DateTimeDeceased) &&
                         !DateTime.TryParse(textConditionValue2.Text, out datePlaceholder))
                {
                    MsgBox.Show(this, "Please enter a valid date.");
                    return;
                }
                condition2.ConditionValue = textConditionValue2.Text;
                condition2.Operator       = (ConditionOperator)(comboOperator2.SelectedIndex + 2); //Plus 2 because Equals and NotEquals are not in the combo box
                if (listRelationships.SelectedIndex == 0)                                          //'And' is selected
                {
                    condition1.ConditionRelationship = LogicalOperator.And;
                    condition2.ConditionRelationship = LogicalOperator.And;
                }
                else                          //'Or' is selected
                {
                    condition1.ConditionRelationship = LogicalOperator.Or;
                    condition2.ConditionRelationship = LogicalOperator.Or;
                }
                RequiredFieldConditions.Insert(condition1);
                RequiredFieldConditions.Insert(condition2);
                break;

            //Types that store the foreign key of the value
            case RequiredFieldName.BillingType:
            case RequiredFieldName.Clinic:
            case RequiredFieldName.PrimaryProvider:
                if (listRelationships.SelectedIndex == -1)
                {
                    MsgBox.Show(this, "Please select 'Is' or 'Is not'.");
                    return;
                }
                if (listConditionValues.SelectedIndices.Count == 0)
                {
                    MsgBox.Show(this, "Please select a condition value.");
                    return;
                }
                List <long> listFkNums = new List <long>();
                if (selectedField == RequiredFieldName.PrimaryProvider)
                {
                    for (int i = 0; i < listConditionValues.SelectedIndices.Count; i++)
                    {
                        listFkNums.Add(_listProvs[listConditionValues.SelectedIndices[i]].ProvNum);
                    }
                }
                else if (selectedField == RequiredFieldName.BillingType)
                {
                    for (int i = 0; i < listConditionValues.SelectedIndices.Count; i++)
                    {
                        listFkNums.Add(_listBillingTypeDefs[listConditionValues.SelectedIndices[i]].DefNum);
                    }
                }
                else                            //selectedField==RequiredFieldName.Clinic
                {
                    for (int i = 0; i < listConditionValues.SelectedIndices.Count; i++)
                    {
                        if (listConditionValues.SelectedIndices[i] == 0)                                //'Unassigned'
                        {
                            listFkNums.Add(0);
                        }
                        else
                        {
                            listFkNums.Add(_listClinics[listConditionValues.SelectedIndices[i] - 1].ClinicNum);                                  //Subtract 1 to account for 'Unassigned'
                        }
                    }
                }
                //Delete the original conditions
                RequiredFieldConditions.DeleteAll(_listReqFieldConds.Select(x => x.RequiredFieldConditionNum).ToList());
                //Insert the new conditions
                condition = new RequiredFieldCondition();
                condition.RequiredFieldNum = _reqField.RequiredFieldNum;
                condition.ConditionType    = selectedField;
                if (listRelationships.SelectedIndex == 0)                       //'Is' is selected
                {
                    condition.Operator = ConditionOperator.Equals;
                }
                else                          //'Is not' is selected
                {
                    condition.Operator = ConditionOperator.NotEquals;
                }
                for (int i = 0; i < listFkNums.Count; i++)
                {
                    condition.ConditionValue = listFkNums[i].ToString();
                    RequiredFieldConditions.Insert(condition);
                }
                break;

            //Types that store the value of listConditionValues
            case RequiredFieldName.StudentStatus:
            case RequiredFieldName.PatientStatus:
            case RequiredFieldName.Position:
            case RequiredFieldName.Gender:
            case RequiredFieldName.Language:
            case RequiredFieldName.MedicaidID:
            case RequiredFieldName.MedicaidState:
                if (listRelationships.SelectedIndex == -1)
                {
                    MsgBox.Show(this, "Please select 'Is' or 'Is not'.");
                    return;
                }
                if (listConditionValues.SelectedIndices.Count == 0)
                {
                    MsgBox.Show(this, "Please select a value.");
                    return;
                }
                //Delete the original conditions
                RequiredFieldConditions.DeleteAll(_listReqFieldConds.Select(x => x.RequiredFieldConditionNum).ToList());
                //Insert the new conditions
                condition = new RequiredFieldCondition();
                condition.RequiredFieldNum = _reqField.RequiredFieldNum;
                condition.ConditionType    = selectedField;
                if (listRelationships.SelectedIndex == 0)                       //'Is' is selected
                {
                    condition.Operator = ConditionOperator.Equals;
                }
                else                          //'Is not' is selected
                {
                    condition.Operator = ConditionOperator.NotEquals;
                }
                for (int i = 0; i < listConditionValues.SelectedIndices.Count; i++)
                {
                    condition.ConditionValue = listConditionValues.Items[listConditionValues.SelectedIndices[i]].ToString();
                    RequiredFieldConditions.Insert(condition);
                }
                break;
            }
            DialogResult = DialogResult.OK;
        }