コード例 #1
0
        /// <summary>Returns true if ClaimProcAllowCreditsGreaterThanProcFee preference allows the user to add credits greater than the proc fee. Otherwise returns false </summary>
        private bool isClaimProcGreaterThanProcFee()
        {
            ClaimProcCreditsGreaterThanProcFee creditsGreaterPref = (ClaimProcCreditsGreaterThanProcFee)PrefC.GetInt(PrefName.ClaimProcAllowCreditsGreaterThanProcFee);

            if (creditsGreaterPref == ClaimProcCreditsGreaterThanProcFee.Allow)
            {
                return(true);
            }
            List <Procedure>  listProcs                 = Procedures.GetManyProc(ClaimProcsToEdit.Select(x => x.ProcNum).ToList(), false);
            List <ClaimProc>  listClaimProcsForPat      = ClaimProcs.Refresh(PatCur.PatNum);
            List <PaySplit>   listPaySplitForSelectedCP = PaySplits.GetPaySplitsFromProcs(ClaimProcsToEdit.Select(x => x.ProcNum).ToList());
            List <Adjustment> listAdjForSelectedCP      = Adjustments.GetForProcs(ClaimProcsToEdit.Select(x => x.ProcNum).ToList());
            bool          isCreditGreater               = false;
            List <string> listProcDescripts             = new List <string>();

            for (int i = 0; i < ClaimProcsToEdit.Length; i++)
            {
                ClaimProc claimProcCur = ClaimProcsToEdit[i];
                int       insPayIdx    = gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Ins Pay"));
                int       writeoffIdx  = gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Writeoff"));
                int       feeAcctIdx   = gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Fee"));
                decimal   insPayAmt    = (decimal)ClaimProcs.ProcInsPay(listClaimProcsForPat.FindAll(x => x.ClaimProcNum != claimProcCur.ClaimProcNum), claimProcCur.ProcNum)
                                         + PIn.Decimal(gridMain.ListGridRows[i].Cells[insPayIdx].Text);
                decimal writeOff = (decimal)ClaimProcs.ProcWriteoff(listClaimProcsForPat.FindAll(x => x.ClaimProcNum != claimProcCur.ClaimProcNum), claimProcCur.ProcNum)
                                   + PIn.Decimal(gridMain.ListGridRows[i].Cells[writeoffIdx].Text);
                decimal feeAcct   = PIn.Decimal(gridMain.ListGridRows[i].Cells[feeAcctIdx].Text);
                decimal adj       = listAdjForSelectedCP.Where(x => x.ProcNum == claimProcCur.ProcNum).Select(x => (decimal)x.AdjAmt).Sum();
                decimal patPayAmt = listPaySplitForSelectedCP.Where(x => x.ProcNum == claimProcCur.ProcNum).Select(x => (decimal)x.SplitAmt).Sum();
                //Any changes to this calculation should also consider FormClaimProc.IsClaimProcGreaterThanProcFee().
                decimal creditRem = feeAcct - patPayAmt - insPayAmt - writeOff + adj;
                isCreditGreater |= (creditRem.IsLessThanZero());
                if (creditRem.IsLessThanZero())
                {
                    Procedure proc = listProcs.FirstOrDefault(x => x.ProcNum == claimProcCur.ProcNum);
                    listProcDescripts.Add((proc == null ? "" : ProcedureCodes.GetProcCode(proc.CodeNum).ProcCode)
                                          + "\t" + Lan.g(this, "Fee") + ": " + feeAcct.ToString("F")
                                          + "\t" + Lan.g(this, "Credits") + ": " + (Math.Abs(-patPayAmt - insPayAmt - writeOff + adj)).ToString("F")
                                          + "\t" + Lan.g(this, "Remaining") + ": (" + Math.Abs(creditRem).ToString("F") + ")");
                }
            }
            if (!isCreditGreater)
            {
                return(true);
            }
            if (creditsGreaterPref == ClaimProcCreditsGreaterThanProcFee.Block)
            {
                MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste(Lan.g(this, "Remaining amount is negative for the following procedures") + ":\r\n"
                                                             + string.Join("\r\n", listProcDescripts) + "\r\n" + Lan.g(this, "Not allowed to continue."));
                msgBox.Text = Lan.g(this, "Overpaid Procedure Warning");
                msgBox.ShowDialog();
                return(false);
            }
            if (creditsGreaterPref == ClaimProcCreditsGreaterThanProcFee.Warn)
            {
                return(MessageBox.Show(Lan.g(this, "Remaining amount is negative for the following procedures") + ":\r\n"
                                       + string.Join("\r\n", listProcDescripts.Take(10)) + "\r\n" + (listProcDescripts.Count > 10?"...\r\n":"") + Lan.g(this, "Continue?")
                                       , Lan.g(this, "Overpaid Procedure Warning"), MessageBoxButtons.OKCancel) == DialogResult.OK);
            }
            return(true);           //should never get to this line, only possible if another enum value is added to allow, warn, and block
        }
コード例 #2
0
        private void butShow_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length == 0)
            {
                MessageBox.Show("Please select lab panels first.");
                return;
            }
            List <LabPanel> panels = new List <LabPanel>();

            for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
            {
                panels.Add(listLP[gridMain.SelectedIndices[i]]);
            }
            OpenDentBusiness.HL7.EhrORU oru = new OpenDentBusiness.HL7.EhrORU();
            Cursor = Cursors.WaitCursor;
            try {
                oru.Initialize(panels);
            }
            catch (ApplicationException ex) {
                Cursor = Cursors.Default;
                MessageBox.Show(ex.Message);
                return;
            }
            string outputStr = oru.GenerateMessage();

            Cursor = Cursors.Default;
            MsgBoxCopyPaste msgbox = new MsgBoxCopyPaste(outputStr);

            msgbox.ShowDialog();
        }
コード例 #3
0
 private void butDelete_Click(object sender, System.EventArgs e)
 {
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
     }
     else
     {
         string inuseby = ReqStudents.InUseBy(ReqCur.ReqNeededNum);
         if (inuseby != "")
         {
             MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste(Lan.g(this, "Requirement is already in use by student(s) with grade point(s) attached."
                                                                + "\r\n" + Lan.g(this, "Delete anyway?  Student grades will not be affected."))
                                                          + "\r\n" + inuseby);
             msgBox.ShowDialog();
             if (msgBox.DialogResult != DialogResult.OK)
             {
                 return;
             }
         }
         if (!MsgBox.Show(this, true, "Delete this Requirement?"))
         {
             return;
         }
     }
     ReqCur       = null;
     DialogResult = DialogResult.OK;
 }
コード例 #4
0
        private void butPreview_Click(object sender, EventArgs e)
        {
            if (!VerifyOutputs())
            {
                return;
            }
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("------ " + Lan.g(this, "Notification email that will be sent to the patient's email address:"));
            if (_allowSendNotificationMessage)
            {
                sb.AppendLine(Lan.g(this, "Subject") + ": " + SubjectInsecure);
                sb.AppendLine(Lan.g(this, "Body") + ": " + BodyTextInsecure);
            }
            else
            {
                sb.AppendLine(Lan.g(this, "------ " + Lan.g(this, "Notification email settings are not set up.  Click Setup from the web mail message edit window"
                                                            + " to set up notification emails") + " ------"));
            }
            sb.AppendLine();
            sb.AppendLine("------ " + Lan.g(this, "Secure web mail message that will be sent to the patient's portal:"));
            sb.AppendLine(Lan.g(this, "Subject") + ": " + textSubject.Text);
            sb.AppendLine(Lan.g(this, "Body") + ": " + textBody.Text.Replace("\n", "\r\n"));
            MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste(sb.ToString());

            msgBox.ShowDialog();
        }
コード例 #5
0
ファイル: FormInnoDb.cs プロジェクト: kjb7749/testImport
        /// <summary>Will only convert to MyISAM if default storage engine set to MyISAM.</summary>
        private void butToMyIsam_Click(object sender, EventArgs e)
        {
            if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "This will convert all tables in the database to the MyISAM storage engine.  This may take several minutes.\r\nContinue?"))
            {
                return;
            }
            if (InnoDb.GetDefaultEngine() == "InnoDB")
            {
                MsgBoxCopyPaste msgbox = new MsgBoxCopyPaste(
                    Lan.g("FormInnoDB", "You will first need to change your default storage engine to MyISAM.  Make sure that the following line is in your my.ini file: \r\n"
                          + "default-storage-engine=MyISAM.\r\n"
                          + "Then, restart the MySQL service and return here."));
                msgbox.ShowDialog();
                return;
            }
            if (!Shared.MakeABackup(BackupLocation.InnoDbTool))
            {
                return;                //A message has already shown that the backup failed.
            }
            Cursor         = Cursors.WaitCursor;
            textBox1.Text += Lans.g("FormInnoDb", "Default Storage Engine: " + InnoDb.GetDefaultEngine().ToString() + "\r\n");
            Application.DoEvents();
            int numchanged = InnoDb.ConvertTables("InnoDB", "MyISAM");

            textBox1.Text += Lan.g("FormInnoDb", "Number of tables converted to MyISAM: ") + numchanged.ToString() + "\r\n";
            Application.DoEvents();
            textBox1.Text += InnoDb.GetEngineCount();
            Application.DoEvents();
            Cursor = Cursors.Default;
        }
コード例 #6
0
 ///<summary>only visible if Canadian</summary>
 private void butPrintAck_Click(object sender, EventArgs e)
 {
     try {
         new FormCCDPrint(AckCur, textAckMessage.Text, false);              //Show the form on screen and make the user print manually if they desire to print.
     }
     catch (Exception ex) {
         MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste(Lan.g(this, "Failed to preview acknowledgment.") + "\r\n" + ex.Message);
         msgBox.ShowDialog();
     }
 }
コード例 #7
0
        private void butRun_Click(object sender, EventArgs e)
        {
            List <ClaimPaySplit> splits = Claims.GetInsPayNotAttachedForFixTool();

            if (splits.Count == 0)
            {
                MsgBox.Show(this, "There are currently no insurance payments that are not attached to an insurance check.");
                DialogResult = DialogResult.OK;              //Close the window because there is nothing else to do
                return;
            }
            Cursor = Cursors.WaitCursor;
            string   invalidClaimDate = "";
            DateTime curDate          = MiscData.GetNowDateTime().Date;

            for (int i = 0; i < splits.Count; i++)
            {
                Claim claim = Claims.GetClaim(splits[i].ClaimNum);
                if (claim == null)
                {
                    continue;
                }
                if (claim.DateReceived.Date > curDate && !PrefC.GetBool(PrefName.AllowFutureInsPayments) && !PrefC.GetBool(PrefName.FutureTransDatesAllowed))
                {
                    invalidClaimDate += "\r\n" + Lan.g(this, "PatNum") + " " + claim.PatNum + ", " + claim.DateService.ToShortDateString();
                    continue;
                }
                ClaimPayment cp = new ClaimPayment();
                cp.CheckDate   = claim.DateReceived;
                cp.CheckAmt    = splits[i].InsPayAmt;
                cp.ClinicNum   = claim.ClinicNum;
                cp.CarrierName = splits[i].Carrier;
                cp.PayType     = Defs.GetFirstForCategory(DefCat.InsurancePaymentType, true).DefNum;
                ClaimPayments.Insert(cp);
                List <ClaimProc> claimP = ClaimProcs.RefreshForClaim(splits[i].ClaimNum);
                for (int j = 0; j < claimP.Count; j++)
                {
                    if (claimP[j].ClaimPaymentNum != 0 || claimP[j].InsPayAmt == 0) //If claimpayment already attached to claimproc or ins didn't pay.
                    {
                        continue;                                                   //Do not change
                    }
                    claimP[j].DateCP          = claim.DateReceived;
                    claimP[j].ClaimPaymentNum = cp.ClaimPaymentNum;
                    ClaimProcs.Update(claimP[j]);
                }
            }
            Cursor = Cursors.Default;
            if (invalidClaimDate != "")
            {
                invalidClaimDate = "\r\n" + Lan.g(this, "Cannot make future-dated insurance payments for these claims:") + invalidClaimDate;
            }
            MsgBoxCopyPaste messageBox = new MsgBoxCopyPaste(Lan.g(this, "Insurance checks created:") + " " + splits.Count + invalidClaimDate);

            messageBox.ShowDialog();
            DialogResult = DialogResult.OK;          //Close the window because there is nothing else to do
        }
コード例 #8
0
        private void butShowXml_Click(object sender, EventArgs e)
        {
            string strCcd = File.ReadAllText(StrXmlFilePath);

            //Reformat to add newlines after each element to make more readable.
            strCcd = strCcd.Replace("\r\n", "").Replace("\n", "").Replace("\r", "");       //Remove existsing newlines.
            strCcd = strCcd.Replace(">", ">\r\n");
            MsgBoxCopyPaste msgbox = new MsgBoxCopyPaste(strCcd);

            msgbox.ShowDialog();
        }
コード例 #9
0
        private void checkIsHidden_Click(object sender, EventArgs e)
        {
            //Don't allow fees to be hidden if they are in use by a provider.
            if (!checkIsHidden.Checked)
            {
                return;                //Unhiding a fee. OK.
            }
            if (FeeSchedCur.FeeSchedType != FeeScheduleType.Normal)
            {
                return;                //Not Normal fee. Not in use by a provider.
            }
            List <InsPlan> listInsPlanForFeeSched = InsPlans.GetForFeeSchedNum(FeeSchedCur.FeeSchedNum);

            if (listInsPlanForFeeSched.Count > 0)
            {
                string insPlanMsg = Lan.g(this, "This fee schedule is tied to") + " "
                                    + listInsPlanForFeeSched.Count + " " + Lan.g(this, "insurance plans.") + " " + Lan.g(this, "Continue?");
                if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, insPlanMsg))
                {
                    checkIsHidden.Checked = false;
                    return;
                }
            }
            string providersUsingFee = "";

            for (int i = 0; i < _listProviders.Count; i++)
            {
                if (FeeSchedCur.FeeSchedNum == _listProviders[i].FeeSched)
                {
                    if (providersUsingFee != "")                  //There is a name before this on the list
                    {
                        providersUsingFee += ", ";
                    }
                    providersUsingFee += _listProviders[i].Abbr;
                }
            }
            if (providersUsingFee != "")
            {
                MessageBox.Show(Lan.g(this, "Cannot hide. Fee schedule is currently in use by the following providers") + ":\r\n" + providersUsingFee);
                checkIsHidden.Checked = false;
            }
            string patsUsingFee = "";
            //Don't allow fee schedules to be hidden if they are in use by a non-deleted patient.
            List <Patient> listPats = Patients.GetForFeeSched(FeeSchedCur.FeeSchedNum).FindAll(x => x.PatStatus != PatientStatus.Deleted);

            patsUsingFee = string.Join("\r\n", listPats.Select(x => x.LName + ", " + x.FName));
            if (patsUsingFee != "")
            {
                MsgBoxCopyPaste msgBoxCP = new MsgBoxCopyPaste(Lan.g(this, "Cannot hide. Fee schedule currently in use by the following non-deleted patients")
                                                               + ":\r\n" + patsUsingFee);
                msgBoxCP.ShowDialog();
                checkIsHidden.Checked = false;
            }
        }
コード例 #10
0
        private void butExport_Click(object sender, EventArgs e)
        {
            if (gridCustomSheet.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select a sheet from the list first.");
                return;
            }
            SheetDef             sheetdef           = SheetDefs.GetSheetDef(_listSheetDefs[gridCustomSheet.GetSelectedIndex()].SheetDefNum);
            List <SheetFieldDef> listFieldDefImages = sheetdef.SheetFieldDefs
                                                      .Where(x => x.FieldType == SheetFieldType.Image && x.FieldName != "Patient Info.gif")
                                                      .ToList();

            if (!listFieldDefImages.IsNullOrEmpty())             //Alert them of any images they need to copy if there are any.
            {
                string sheetImagesPath = "";
                ODException.SwallowAnyException(() => {
                    sheetImagesPath = SheetUtil.GetImagePath();
                });
                StringBuilder strBuilder = new StringBuilder();
                strBuilder.AppendLine(Lan.g(this, "The following images will need to be manually imported with the same file name when importing this "
                                            + "sheet to a new environment."));
                strBuilder.AppendLine();
                listFieldDefImages.ForEach(x => strBuilder.AppendLine(ODFileUtils.CombinePaths(sheetImagesPath, x.FieldName)));
                MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste(strBuilder.ToString());
                msgBox.ShowDialog();
            }
            XmlSerializer serializer = new XmlSerializer(typeof(SheetDef));
            string        filename   = "SheetDefCustom.xml";

            if (ODBuild.IsWeb())
            {
                StringBuilder strbuild = new StringBuilder();
                using (XmlWriter writer = XmlWriter.Create(strbuild)) {
                    serializer.Serialize(writer, sheetdef);
                }
                ThinfinityUtils.ExportForDownload(filename, strbuild.ToString());
            }
            else
            {
                SaveFileDialog saveDlg = new SaveFileDialog();
                saveDlg.InitialDirectory = PrefC.GetString(PrefName.ExportPath);
                saveDlg.FileName         = filename;
                if (saveDlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                using (TextWriter writer = new StreamWriter(saveDlg.FileName)) {
                    serializer.Serialize(writer, sheetdef);
                }
            }
            MsgBox.Show(this, "Exported");
        }
コード例 #11
0
        private void ShowRawMessage_Clicked(object sender, System.EventArgs e)
        {
            //accessed by right clicking on history
            if (gridHistory.SelectedIndices.Length != 1)
            {
                MsgBox.Show(this, "Please select exactly one item first.");
                return;
            }
            Etrans          et     = Etranss.GetEtrans(PIn.PInt(tableHistory.Rows[gridHistory.SelectedIndices[0]]["EtransNum"].ToString()));
            MsgBoxCopyPaste msgbox = new MsgBoxCopyPaste(et.MessageText);

            msgbox.ShowDialog();
        }
コード例 #12
0
        private void butManEdit_Click(object sender, EventArgs e)
        {
            //PumpGridIntoTable();
            Markup = GenerateMarkup();
            MsgBoxCopyPaste msgbox = new MsgBoxCopyPaste(Markup);

            msgbox.ShowDialog();
            if (msgbox.DialogResult != DialogResult.OK)
            {
                return;
            }
            Markup = msgbox.textMain.Text;
            ParseMarkup();
            FillGrid();
        }
コード例 #13
0
        private void ManuallyEdit()
        {
            MsgBoxCopyPaste msgbox = new MsgBoxCopyPaste(Markup);

            msgbox.ShowDialog();
            if (msgbox.DialogResult == DialogResult.OK)
            {
                Markup = msgbox.textMain.Text;
                ParseMarkup();                //try again
            }
            else
            {
                DialogResult = DialogResult.Cancel;
            }
        }
コード例 #14
0
        private void butShowXml_Click(object sender, EventArgs e)
        {
            string ccd = "";

            try {
                ccd = EhrCCD.GenerateElectronicCopy(PatCur);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            MsgBoxCopyPaste msgbox = new MsgBoxCopyPaste(ccd);

            msgbox.ShowDialog();
        }
コード例 #15
0
        /// <summary>Will only convert to InnoDB if default storage engine set to InnoDB and skip-innodb is not in my.ini file, which disables InnoDB engine.</summary>
        private void butToInnoDb_Click(object sender, EventArgs e)
        {
            if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "This will convert all tables in the database to the InnoDB storage engine.  This may take several minutes.\r\nContinue?"))
            {
                return;
            }
            if (!InnoDb.IsInnodbAvail())
            {
                MsgBoxCopyPaste msgbox = new MsgBoxCopyPaste(
                    Lan.g("FormInnoDb", "InnoDB storage engine is disabled.  In order for InnoDB tables to work you must comment out the skip-innodb line in your my.ini file, like this:\r\n"
                          + "#skip-innodb\r\n"
                          + "and, if present, comment out the default-storage-engine line like this: \r\n"
                          + "#default-storage-engine=MyISAM.\r\n"
                          + "Then, restart the MySQL service and return here."));
                msgbox.ShowDialog();
                return;
            }
            if (InnoDb.GetDefaultEngine() == "MyISAM")
            {
                MsgBoxCopyPaste msgbox = new MsgBoxCopyPaste(
                    Lan.g("FormInnoDB", "You will first need to change your default storage engine to InnoDB.  In your my.ini file, comment out the default-storage-engine line like this: \r\n"
                          + "#default-storage-engine=MyISAM.\r\n"
                          + "Then, restart the MySQL service and return here."));
                msgbox.ShowDialog();
                return;
            }
            try {
                MiscData.MakeABackup();
            }
            catch (Exception ex) {
                if (ex.Message != "")
                {
                    MessageBox.Show(ex.Message);
                }
                MsgBox.Show("FormInnoDb", "Backup failed. Your database has not been altered.");
                return;
            }
            Cursor         = Cursors.WaitCursor;
            textBox1.Text += Lans.g("FormInnoDb", "Default Storage Engine: " + InnoDb.GetDefaultEngine().ToString() + "\r\n");
            Application.DoEvents();
            int numchanged = InnoDb.ConvertTables("MyISAM", "InnoDB");

            textBox1.Text += Lan.g("FormInnoDb", "Number of tables converted to InnoDB: ") + numchanged.ToString() + "\r\n";
            Application.DoEvents();
            textBox1.Text += InnoDb.GetEngineCount();
            Application.DoEvents();
            Cursor = Cursors.Default;
        }
コード例 #16
0
        private void butRun_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length == 0)
            {
                MsgBox.Show(this, "Please make a selection first");
                return;
            }
            string patientStatus  = Lan.g("enumPatientStatus", "Patient");
            string inactiveStatus = Lan.g("enumPatientStatus", "Inactive");
            string msgText        = Lan.g(this, "This will change the status for selected patients from") + " "
                                    + (_isConvertToPatient? inactiveStatus : patientStatus) + " "
                                    + Lans.g(this, "to") + " "
                                    + (_isConvertToPatient ? patientStatus : inactiveStatus) + ".\r\n" +
                                    Lan.g(this, "Do you wish to continue?");

            if (MessageBox.Show(msgText, "", MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;                //The user chose not to change the statuses.
            }
            StringBuilder builder     = new StringBuilder();
            List <long>   listPatNums = new List <long>();

            foreach (int index in gridMain.SelectedIndices)
            {
                Patient patOld = (Patient)gridMain.ListGridRows[index].Tag;
                Patient patCur = patOld.Copy();
                listPatNums.Add(patCur.PatNum);
                patCur.PatStatus = (_isConvertToPatient?PatientStatus.Patient:PatientStatus.Inactive);
                Patients.UpdateRecalls(patCur, patOld, "Patient Status Tool");
                Patients.Update(patCur, patOld);
                builder.AppendLine(
                    Lans.g(this, "Patient") + " " + POut.Long(patCur.PatNum) + ": " + patCur.GetNameLF() + " "
                    + Lans.g(this, "patient status changed from") + " " + (_isConvertToPatient ? inactiveStatus : patientStatus) + " "
                    + Lans.g(this, "to") + " " + (_isConvertToPatient ? patientStatus : inactiveStatus)
                    );            //Like "Patient 123: John Doe patient status changed from X to Y"
            }
            MsgBoxCopyPaste msg = new MsgBoxCopyPaste(builder.ToString());

            msg.Text = Lans.g(this, "Done");
            msg.ShowDialog();
            SecurityLogs.MakeLogEntry(Permissions.SecurityAdmin, listPatNums, Lans.g(this, "Patient status changed from") + " "
                                      + (_isConvertToPatient ? inactiveStatus : patientStatus) + " "
                                      + Lans.g(this, "to") + " " + (_isConvertToPatient ? patientStatus : inactiveStatus)
                                      + Lans.g(this, " by the Patient Status Setter tool."));
            DialogResult = DialogResult.OK;
        }
コード例 #17
0
        ///<summary>Returns true if InsPayNoWriteoffMoreThanProc preference is turned on and the sum of write off amount is greater than the proc fee.
        ///Otherwise returns false </summary>
        private bool IsWriteOffGreaterThanProcFee()
        {
            if (!PrefC.GetBool(PrefName.InsPayNoWriteoffMoreThanProc))
            {
                return(false);               //InsPayNoWriteoffMoreThanProc preference is off. No need to check.
            }
            List <ClaimProc>  listClaimProcsForPat  = ClaimProcs.Refresh(PatCur.PatNum);
            List <Adjustment> listAdjustmentsForPat = Adjustments.GetForProcs(ClaimProcsToEdit.Select(x => x.ProcNum).Where(x => x != 0).ToList());
            bool          isWriteoffGreater         = false;
            List <string> listProcDescripts         = new List <string>();

            for (int i = 0; i < ClaimProcsToEdit.Length; i++)
            {
                ClaimProc claimProcCur = ClaimProcsToEdit[i];
                //Fetch all adjustments for the given procedure.
                List <Adjustment> listClaimProcAdjustments = listAdjustmentsForPat.Where(x => x.ProcNum == claimProcCur.ProcNum).ToList();
                int     writeoffIdx = gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Writeoff"));
                int     feeAcctIdx  = gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Fee"));
                decimal writeOff    = (decimal)ClaimProcs.ProcWriteoff(listClaimProcsForPat.FindAll(x => x.ClaimProcNum != claimProcCur.ClaimProcNum), claimProcCur.ProcNum)
                                      + PIn.Decimal(gridMain.ListGridRows[i].Cells[writeoffIdx].Text);
                decimal feeAcct = PIn.Decimal(gridMain.ListGridRows[i].Cells[feeAcctIdx].Text);
                decimal adjAcct = listClaimProcAdjustments.Sum(x => (decimal)x.AdjAmt);
                //Any changes to this calculation should also consider FormClaimProc.IsWriteOffGreaterThanProc().
                decimal writeoffRem = feeAcct - writeOff + adjAcct;
                isWriteoffGreater |= (writeoffRem.IsLessThanZero() && writeOff.IsGreaterThanZero());
                if (writeoffRem.IsLessThanZero() && writeOff.IsGreaterThanZero())
                {
                    Procedure proc = Procedures.GetProcFromList(ProcList, claimProcCur.ProcNum);                 //will return a new procedure if none found.
                    listProcDescripts.Add((proc == null ? "" : ProcedureCodes.GetProcCode(proc.CodeNum).ProcCode)
                                          + "\t" + Lan.g(this, "Fee") + ": " + feeAcct.ToString("F")
                                          + "\t" + Lan.g(this, "Adjustments") + ": " + adjAcct.ToString("F")
                                          + "\t" + Lan.g(this, "Write-off") + ": " + (Math.Abs(-writeOff)).ToString("F")
                                          + "\t" + Lan.g(this, "Remaining") + ": (" + Math.Abs(writeoffRem).ToString("F") + ")");
                }
            }
            if (isWriteoffGreater)
            {
                MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste(Lan.g(this, "Write-off amount is greater than the adjusted procedure fee for the following "
                                                                   + "procedure(s)") + ":\r\n" + string.Join("\r\n", listProcDescripts) + "\r\n" + Lan.g(this, "Not allowed to continue."));
                msgBox.Text = Lan.g(this, "Excessive Write-off");
                msgBox.ShowDialog();
                return(true);
            }
            return(false);
        }
コード例 #18
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (_fromInsPlan == null || InsPlans.GetPlan(_fromInsPlan.PlanNum, new List <InsPlan>()) == null)
     {
         MsgBox.Show(this, "Please pick a valid plan to move subscribers from.");
         return;
     }
     if (_intoInsPlan == null || InsPlans.GetPlan(_intoInsPlan.PlanNum, new List <InsPlan>()) == null)
     {
         MsgBox.Show(this, "Please pick a valid plan to move subscribers to.");
         return;
     }
     if (_fromInsPlan.PlanNum == _intoInsPlan.PlanNum)
     {
         MsgBox.Show(this, "Can not move a plan into itself.");
         return;
     }
     if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Moving subscribers is irreversible.  Always make a full backup before moving subscribers.  "
                      + "Patient specific benefits, subscriber notes, benefit notes, and effective dates will not be copied to the other plan."
                      + "\r\n\r\nRunning this tool can take several minutes to run.  We recommend running it after business hours or when network usage is low."
                      + "\r\n\r\nClick OK to continue, or click Cancel to abort."))
     {
         return;
     }
     try {
         Cursor = Cursors.WaitCursor;
         long insSubModifiedCount = InsSubs.MoveSubscribers(_fromInsPlan.PlanNum, _intoInsPlan.PlanNum);
         Cursor = Cursors.Default;
         MessageBox.Show(Lan.g(this, "Count of Subscribers Moved") + ": " + insSubModifiedCount);
     }
     catch (ApplicationException ex) {                             //The tool was blocked due to validation failure.
         Cursor = Cursors.Default;
         MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste(ex.Message); //No translaion here, because translation was done in the business layer.
         msgBox.ShowDialog();
         return;                                                   //Since this exception is due to validation failure, do not close the form.  Let the user manually click Cancel so they know what happened.
     }
     SecurityLogs.MakeLogEntry(Permissions.InsPlanChangeSubsc, 0, Lan.g(this, "Subscribers Moved from") + " " + _fromInsPlan.PlanNum + " " + Lan.g(this, "to") + " " + _intoInsPlan.PlanNum);
     DialogResult = DialogResult.OK;          //Closes the form.
 }
コード例 #19
0
        private void butShowXml_Click(object sender, EventArgs e)
        {
            string ccd = "";

            try {
                FormEhrExportCCD FormEEC = new FormEhrExportCCD(PatCur);
                FormEEC.ShowDialog();
                if (FormEEC.DialogResult == DialogResult.OK)
                {
                    ccd = FormEEC.CCD;
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            MsgBoxCopyPaste msgbox = new MsgBoxCopyPaste(ccd);

            msgbox.ShowDialog();
        }
コード例 #20
0
        private void butShow_Click(object sender, EventArgs e)
        {
            if (comboProv.SelectedIndex == -1)
            {
                MessageBox.Show("Please select a provider first.");
                return;
            }
            try {
                DateTime.Parse(textDateStart.Text);
                DateTime.Parse(textDateEnd.Text);
            }
            catch {
                MessageBox.Show("Invalid dates.");
                return;
            }
            if (listQ == null)
            {
                MessageBox.Show("Click Refresh first.");
                return;
            }
            MsgBoxCopyPaste MsgBoxCP = new MsgBoxCopyPaste(GeneratePQRS_xml());

            MsgBoxCP.ShowDialog();
        }
コード例 #21
0
        private void CreateIndividual()
        {
            ReportComplex report             = new ReportComplex(true, false);
            bool          isAnyClinicMedical = false; //Used to determine whether or not to display 'Tooth' column

            if (AnyClinicSelectedIsMedical())
            {
                isAnyClinicMedical = true;
            }
            DataTable table = new DataTable();

            try {
                table = RpProcSheet.GetIndividualTable(date1.SelectionStart, date2.SelectionStart, _listProvNums, _listClinicNums, textCode.Text,
                                                       isAnyClinicMedical, checkAllProv.Checked, PrefC.HasClinicsEnabled);
            }
            catch (Exception ex) {
                report.CloseProgressBar();
                string          text   = Lan.g(this, "Error getting report data:") + " " + ex.Message + "\r\n\r\n" + ex.StackTrace;
                MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste(text);
                msgBox.ShowDialog();
                return;
            }
            if (table.Columns.Contains("ToothNum"))
            {
                foreach (DataRow row in table.Rows)
                {
                    row["ToothNum"] = Tooth.GetToothLabel(row["ToothNum"].ToString());
                }
            }
            string subtitleProvs   = ConstructProviderSubtitle();
            string subtitleClinics = ConstructClinicSubtitle();
            Font   font            = new Font("Tahoma", 9);
            Font   fontBold        = new Font("Tahoma", 9, FontStyle.Bold);
            Font   fontTitle       = new Font("Tahoma", 17, FontStyle.Bold);
            Font   fontSubTitle    = new Font("Tahoma", 10, FontStyle.Bold);

            report.ReportName = Lan.g(this, "Daily Procedures");
            report.AddTitle("Title", Lan.g(this, "Daily Procedures"), fontTitle);
            report.AddSubTitle("Practice Title", PrefC.GetString(PrefName.PracticeTitle), fontSubTitle);
            report.AddSubTitle("Dates of Report", date1.SelectionStart.ToString("d") + " - " + date2.SelectionStart.ToString("d"), fontSubTitle);
            report.AddSubTitle("Providers", subtitleProvs, fontSubTitle);
            if (PrefC.HasClinicsEnabled)
            {
                report.AddSubTitle("Clinics", subtitleClinics, fontSubTitle);
            }
            QueryObject query = report.AddQuery(table, Lan.g(this, "Date") + ": " + DateTimeOD.Today.ToString("d"));

            query.AddColumn(Lan.g(this, "Date"), 90, FieldValueType.Date, font);
            query.GetColumnDetail(Lan.g(this, "Date")).StringFormat = "d";
            query.AddColumn(Lan.g(this, "Patient Name"), 150, FieldValueType.String, font);
            if (isAnyClinicMedical)
            {
                query.AddColumn(Lan.g(this, "Code"), 140, FieldValueType.String, font);
            }
            else
            {
                query.AddColumn(Lan.g(this, "Code"), 70, FieldValueType.String, font);
                query.AddColumn("Tooth", 40, FieldValueType.String, font);
            }
            query.AddColumn(Lan.g(this, "Description"), 140, FieldValueType.String, font);
            query.AddColumn(Lan.g(this, "Provider"), 80, FieldValueType.String, font);
            if (PrefC.HasClinicsEnabled)
            {
                query.AddColumn(Lan.g(this, "Clinic"), 100, FieldValueType.String, font);
            }
            query.AddColumn(Lan.g(this, "Fee"), 80, FieldValueType.Number, font);
            report.AddPageNum(font);
            if (!report.SubmitQueries())
            {
                return;
            }
            FormReportComplex FormR = new FormReportComplex(report);

            FormR.ShowDialog();
            DialogResult = DialogResult.OK;
        }
コード例 #22
0
        private void butDiagnostics_Click(object sender, EventArgs e)
        {
            BugSubmission.SubmissionInfo subInfo = new BugSubmission(new Exception()).Info;
            StringBuilder strBuilder             = new StringBuilder();

            foreach (FieldInfo field in subInfo.GetType().GetFields())
            {
                object value = field.GetValue(subInfo);
                if (value.In(null, ""))
                {
                    continue;
                }
                if (value is Dictionary <PrefName, string> )              //DictPrefValues
                {
                    Dictionary <PrefName, string> dictPrefValues = value as Dictionary <PrefName, string>;
                    if (dictPrefValues.Keys.Count > 0)
                    {
                        strBuilder.AppendLine(field.Name + ":");
                        dictPrefValues.ToList().ForEach(x => strBuilder.AppendLine("  " + x.Key.ToString() + ": " + x.Value));
                        strBuilder.AppendLine("-------------");
                    }
                }
                else if (value is List <string> )               //EnabledPlugins
                {
                    List <string> enabledPlugins = value as List <string>;
                    if (enabledPlugins.Count > 0)
                    {
                        strBuilder.AppendLine(field.Name + ":");
                        enabledPlugins.ForEach(x => strBuilder.AppendLine("  " + x));
                        strBuilder.AppendLine("-------------");
                    }
                }
                else if (value is bool)
                {
                    strBuilder.AppendLine(field.Name + ": " + (((bool)value) == true?"true":"false"));
                }
                else
                {
                    strBuilder.AppendLine(field.Name + ": " + value);
                }
            }
            //Display the current HQ connection information.
            if (PrefC.IsODHQ)
            {
                Action <ConnectionNames> action = (connName) => {
                    strBuilder.AppendLine($"{connName.ToString()}:");
                    strBuilder.AppendLine($"  Server Name: {DataConnection.GetServerName()}");
                    strBuilder.AppendLine($"  Database Name: {DataConnection.GetDatabaseName()}");
                    strBuilder.AppendLine($"  MySQL User: {DataConnection.GetMysqlUser()}");
                    strBuilder.AppendLine($"  MySQL Password: {DataConnection.GetMysqlPass()}");
                };
                strBuilder.AppendLine("-------------");
                strBuilder.AppendLine("HQ Connection Settings");
                try {
                    DataAction.RunBugsHQ(() => action(ConnectionNames.BugsHQ), useConnectionStore: false);
                    DataAction.RunCustomers(() => action(ConnectionNames.CustomersHQ), useConnectionStore: false);
                    DataAction.RunManualPublisherHQ(() => action(ConnectionNames.ManualPublisher));
                    DataAction.RunWebChat(() => action(ConnectionNames.WebChat));
                }
                catch (Exception ex) {
                    strBuilder.AppendLine($"ERROR: {ex.Message}");
                }
                strBuilder.AppendLine("-------------");
            }
            MsgBoxCopyPaste msgbox = new MsgBoxCopyPaste(strBuilder.ToString());

            msgbox.Text = Lans.g(this, "Diagnostics");
            msgbox.ShowDialog();
        }
コード例 #23
0
        ///<summary>Tries to import the 834. Will return false if the user cancelled out of importing.</summary>
        private bool TryImport834()
        {
            if (checkDropExistingIns.Checked &&
                !MsgBox.Show(MsgBoxButtons.YesNo, "Insurance plans for patients will be automatically replaced with the new plans. Continue?"))
            {
                return(false);
            }
            if (!MsgBox.Show(this, true, "Importing insurance plans is a database intensive operation and can take 10 minutes or more to run.  "
                             + "It is best to import insurance plans after hours or during another time period when database usage is otherwise low.\r\n"
                             + "Click OK to import insurance plans now, or click Cancel."))
            {
                return(false);
            }
            checkIsPatientCreate.Enabled = false;
            checkDropExistingIns.Enabled = false;
            gridInsPlans.Enabled         = false;
            butOK.Enabled     = false;
            butCancel.Enabled = false;
            Cursor            = Cursors.WaitCursor;
            Prefs.UpdateBool(PrefName.Ins834DropExistingPatPlans, checkDropExistingIns.Checked);
            Prefs.UpdateBool(PrefName.Ins834IsPatientCreate, checkIsPatientCreate.Checked);
            //Create all of our count variables.
            int createdPatsCount, updatedPatsCount, skippedPatsCount, createdCarrierCount, createdInsPlanCount, updatedInsPlanCount, createdInsSubCount,
                updatedInsSubCount, createdPatPlanCount, droppedPatPlanCount, updatedPatPlanCount;
            StringBuilder sbErrorMessages;

            EtransL.ImportInsurancePlans(_x834, _listPatients, checkIsPatientCreate.Checked, checkDropExistingIns.Checked, out createdPatsCount,
                                         out updatedPatsCount, out skippedPatsCount, out createdCarrierCount, out createdInsPlanCount, out updatedInsPlanCount, out createdInsSubCount,
                                         out updatedInsSubCount, out createdPatPlanCount, out droppedPatPlanCount, out updatedPatPlanCount, out sbErrorMessages, (rowIndex, pat) => {
                ShowStatus("Progress " + (rowIndex).ToString().PadLeft(6) + "/" + gridInsPlans.ListGridRows.Count.ToString().PadLeft(6)
                           + "  Importing plans for patient " + pat.GetNameLF());
            });
            Cursor = Cursors.Default;
            #region summary output
            string msg = Lan.g(this, "Done.");
            if (createdPatsCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of patients created:") + " " + createdPatsCount;
            }
            if (updatedPatsCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of patients updated:") + " " + updatedPatsCount;
            }
            if (skippedPatsCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of patients skipped:") + " " + skippedPatsCount;
                msg += sbErrorMessages.ToString();
            }
            if (createdCarrierCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of carriers created:") + " " + createdCarrierCount;
                msg += sbErrorMessages.ToString();
            }
            if (createdInsPlanCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of insurance plans created:") + " " + createdInsPlanCount;
                msg += sbErrorMessages.ToString();
            }
            if (updatedInsPlanCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of insurance plan updates:") + " " + updatedInsPlanCount;
                msg += sbErrorMessages.ToString();
            }
            if (createdInsSubCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of insurance subscriptions created:") + " " + createdInsSubCount;
                msg += sbErrorMessages.ToString();
            }
            if (updatedInsSubCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of insurance subscriptions updated:") + " " + updatedInsSubCount;
                msg += sbErrorMessages.ToString();
            }
            if (createdPatPlanCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of patients added to insurance:") + " " + createdPatPlanCount;
                msg += sbErrorMessages.ToString();
            }
            if (droppedPatPlanCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of patients dropped from insurance:") + " " + droppedPatPlanCount;
                msg += sbErrorMessages.ToString();
            }
            if (updatedPatPlanCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of patients insurance information updated:") + " " + updatedPatPlanCount;
                msg += sbErrorMessages.ToString();
            }
            #endregion summary output
            MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste(msg);
            msgBox.ShowDialog();
            return(true);
        }
コード例 #24
0
        private void butImport_Click(object sender, EventArgs e)
        {
            MsgBoxCopyPaste MBCP = new MsgBoxCopyPaste("Paste HL7 Lab Message Text Here.");

            MBCP.textMain.SelectAll();
            MBCP.ShowDialog();
            if (MBCP.DialogResult != DialogResult.OK)
            {
                return;
            }
            List <EhrLab> listEhrLabs;

            try {
                listEhrLabs = EhrLabs.ProcessHl7Message(MBCP.textMain.Text); //Not a typical use of the msg box copy paste
                if (listEhrLabs[0].PatNum == PatCur.PatNum)                  //only need to check the first lab.
                //nothing to do here. Imported lab matches the current patient.
                {
                }
                else                 //does not match current patient, redirect to import form which displays patient information and is build for importing.
                {
                    FormEhrLabOrderImport FormLOI = new FormEhrLabOrderImport();
                    FormLOI.PatCur        = PatCur;
                    FormLOI.Hl7LabMessage = MBCP.textMain.Text;
                    FormLOI.ShowDialog();
                    FillGrid();
                    return;
                }
                //else if(listEhrLabs[0].PatNum==0) {
                //	if(MessageBox.Show("Lab patient does not match current patient. Lab patient name is "
                //		+MBCP.textMain.Text.Split(new string[] { "\r\n" },StringSplitOptions.RemoveEmptyEntries)[1].Split('|')[5].Split('~')[0].Split('^')[1]+" "//first name
                //		+MBCP.textMain.Text.Split(new string[] { "\r\n" },StringSplitOptions.RemoveEmptyEntries)[1].Split('|')[5].Split('~')[0].Split('^')[1]+" "//last name
                //		+"\r\nWould you like to import lab for the current patient?","",MessageBoxButtons.OKCancel)!=DialogResult.OK)
                //	{
                //		return;
                //	}
                //	//User agreed to import current lab(s) for current patient.
                //	for(int i=0;i<listEhrLabs.Count;i++) {
                //		listEhrLabs[i].PatNum=PatCur.PatNum;
                //		//TODO: Import external OIDs and PatIDs so that we can identify this patient next time.
                //	}
                //}
                //else {//Patnum is already associated with another patient.
                //	MessageBox.Show("This lab contains patient information for a different patient. Lab patient name is "
                //		+MBCP.textMain.Text.Split(new string[] { "\r\n" },StringSplitOptions.RemoveEmptyEntries)[1].Split('|')[5].Split('~')[0].Split('^')[1]+" "//first name
                //		+MBCP.textMain.Text.Split(new string[] { "\r\n" },StringSplitOptions.RemoveEmptyEntries)[1].Split('|')[5].Split('~')[0].Split('^')[1]);
                //	return;
                //}
            }
            catch (Exception Ex) {
                MessageBox.Show(this, "Unable to import lab.\r\n" + Ex.Message);
                return;
            }
            for (int i = 0; i < listEhrLabs.Count; i++)
            {
                EhrLab tempLab = null;              //lab from DB if it exists.
                tempLab = EhrLabs.GetByGUID(listEhrLabs[i].PlacerOrderUniversalID, listEhrLabs[i].PlacerOrderNum);
                if (tempLab == null)
                {
                    tempLab = EhrLabs.GetByGUID(listEhrLabs[i].FillerOrderUniversalID, listEhrLabs[i].FillerOrderNum);
                }
                if (tempLab != null)
                {
                    //Date validation.
                    //if(tempLab.ResultDateTime.CompareTo(listEhrLabs[i].ResultDateTime)<=0) {//string compare dates will return 1+ if tempLab Date is greater.
                    //	MsgBox.Show(this,"This lab already exists in the database and has a more recent timestamp.");
                    //	continue;
                    //}
                    //TODO: The code above works, but ignores more recent lab results. Although the lab order my be unchanged there may be updated lab results.
                    //It would be better to check for updated results, unfortunately results have no unique identifiers.
                }
                Provider prov = Providers.GetProv(Security.CurUser.ProvNum);
                if (Security.CurUser.ProvNum != 0 && EhrProvKeys.GetKeysByFLName(prov.LName, prov.FName).Count > 0)            //The user who is currently logged in is a provider and has a valid EHR key.
                {
                    ListEhrLabs[i].IsCpoe = true;
                }
                listEhrLabs[i] = EhrLabs.SaveToDB(listEhrLabs[i]);               //SAVE
                for (int j = 0; j < listEhrLabs[i].ListEhrLabResults.Count; j++) //EHR TRIGGER
                {
                    if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).LabTestCDS)
                    {
                        FormCDSIntervention FormCDSI = new FormCDSIntervention();
                        FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(listEhrLabs[i].ListEhrLabResults[j], PatCur);
                        FormCDSI.ShowIfRequired(false);
                    }
                }
            }
            FillGrid();
        }
コード例 #25
0
        private void butNewClaims_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length == 0)           //No selections made.
            {
                MsgBox.Show(this, "Please select at least one procedure.");
                return;
            }
            if (!ContrAccount.CheckClearinghouseDefaults())
            {
                return;
            }
            //Generate List and Table----------------------------------------------------------------------------------------------------------------------
            //List of all procedures being shown.
            //Pulls procedures based off of the PatNum, if the row was selected in gridMain and if it has been attached to a claim.
            List <ProcNotBilled> listNotBilledProcs = new List <ProcNotBilled>();
            List <long>          listPatNums        = new List <long>();
            Patient          patOld            = new Patient();
            List <Claim>     listPatClaims     = new List <Claim>();
            List <ClaimProc> listPatClaimProcs = new List <ClaimProc>();
            List <ClaimProc> listCurClaimProcs = new List <ClaimProc>();
            //Table rows need to be 1:1 with gridMain rows due to logic in ContrAccount.toolBarButIns_Click(...).
            DataTable table = new DataTable();

            //Required columns as mentioned by ContrAccount.toolBarButIns_Click().
            table.Columns.Add("ProcNum");
            table.Columns.Add("chargesDouble");
            table.Columns.Add("ProcNumLab");
            for (int i = 0; i < gridMain.Rows.Count; i++)                         //Loop through gridMain to construct listNotBilledProcs.
            {
                long      procNumCur = PIn.Long(gridMain.Rows[i].Tag.ToString()); //Tag is set to procNum in fillGrid().
                Procedure procCur    = Procedures.GetOneProc(procNumCur, false);
                long      patNumCur  = procCur.PatNum;
                if (patOld.PatNum != patNumCur)               //Procedures in gridMain are ordered by patient, so when the patient changes, we know previous patient is complete.
                {
                    listPatClaims     = Claims.Refresh(patNumCur);
                    listPatClaimProcs = ClaimProcs.Refresh(patNumCur);
                    patOld            = Patients.GetPat(procCur.PatNum);
                }
                listCurClaimProcs = ClaimProcs.GetForProc(listPatClaimProcs, procNumCur);
                bool hasPriClaim = false;
                bool hasSecClaim = false;
                for (int j = 0; j < listCurClaimProcs.Count; j++)
                {
                    ClaimProc claimProcCur = listCurClaimProcs[j];
                    if (claimProcCur.ClaimNum > 0 && claimProcCur.Status != ClaimProcStatus.Preauth && claimProcCur.Status != ClaimProcStatus.Estimate)
                    {
                        Claim claimCur = Claims.GetFromList(listPatClaims, claimProcCur.ClaimNum);
                        switch (claimCur.ClaimType)
                        {
                        case "P":
                            hasPriClaim = true;
                            break;

                        case "S":
                            hasSecClaim = true;
                            break;
                        }
                    }
                }
                bool isSelected = gridMain.SelectedIndices.Contains(i);
                listNotBilledProcs.Add(new ProcNotBilled(patOld, procNumCur, i, isSelected, hasPriClaim, hasSecClaim, procCur.ClinicNum, procCur.PlaceService));
                DataRow row = table.NewRow();
                row["ProcNum"] = procNumCur;
                #region Calculate chargesDouble
                //Logic copied from AccountModules.GetAccount(...) line 857.
                double qty = (procCur.UnitQty + procCur.BaseUnits);
                if (qty == 0)
                {
                    qty = 1;
                }
                double writeOffCapSum = listPatClaimProcs.Where(x => x.Status == ClaimProcStatus.CapComplete).Select(y => y.WriteOff).ToList().Sum();
                row["chargesDouble"] = (procCur.ProcFee * qty) - writeOffCapSum;
                row["ProcNumLab"]    = procCur.ProcNumLab;
                #endregion Calculate chargesDouble
                table.Rows.Add(row);
                if (listPatNums.Contains(patNumCur))
                {
                    continue;
                }
                listPatNums.Add(patNumCur);
            }
            List <List <ProcNotBilled> > listGroupedProcs = new List <List <ProcNotBilled> >();
            Patient          patCur           = null;
            List <PatPlan>   listPatPlans     = null;
            List <InsSub>    listInsSubs      = null;
            List <InsPlan>   listInsPlans     = null;
            List <Procedure> listPatientProcs = null;
            ProcNotBilled    procNotBilled    = new ProcNotBilled();    //When automatically grouping,  this is used as the procedure to group by.
            long             patNumOld        = 0;
            int claimCreatedCount             = 0;
            int patIndex = 0;
            //The procedures show in the grid ordered by patient.  Also listPatNums contains unique patnums which are in the same order as the grid.
            while (patIndex < listPatNums.Count)
            {
                List <ProcNotBilled> listProcs = listNotBilledProcs.Where(x => x.Patient.PatNum == listPatNums[patIndex] && x.IsRowSelected && !x.IsAttached).ToList();
                if (listProcs.Count == 0)
                {
                    patNumOld = listPatNums[patIndex];
                    patIndex++;                    //No procedures were selected for this patient.
                    continue;
                }
                else
                {
                    //Maintain the same patient, in order to create one or more additional claims for the remaining procedures.
                    //Currently will only happen for specific instances;
                    //--Canadian customers who are attempting to create a claim with over 7 procedures.
                    //--When checkAutoGroupProcs is checked and when there are multiple procedure groupings by GroupKey status, ClinicNum, and placeService.
                }
                if (patNumOld != listPatNums[patIndex])               //The patient could repeat if we had to group the procedures for the patinet into multiple claims.
                {
                    patCur           = Patients.GetPat(listPatNums[patIndex]);
                    listPatPlans     = PatPlans.Refresh(patCur.PatNum);
                    listInsSubs      = InsSubs.RefreshForFam(Patients.GetFamily(patCur.PatNum));
                    listInsPlans     = InsPlans.RefreshForSubList(listInsSubs);
                    listPatientProcs = Procedures.Refresh(patCur.PatNum);
                }
                if (checkAutoGroupProcs.Checked)                 //Automatically Group Procedures.
                {
                    procNotBilled = listProcs[0];
                    //Update listProcs to reflect those that match the procNotBilled values.
                    listProcs = listProcs.FindAll(x => x.HasPriClaim == procNotBilled.HasPriClaim && x.HasSecClaim == procNotBilled.HasSecClaim);
                    if (PrefC.HasClinicsEnabled)                     //Group by clinic only if clinics enabled.
                    {
                        listProcs = listProcs.FindAll(x => x.ClinicNum == procNotBilled.ClinicNum);
                    }
                    else if (!PrefC.GetBool(PrefName.EasyHidePublicHealth))                     //Group by Place of Service only if Public Health feature is enabled.
                    {
                        listProcs = listProcs.FindAll(x => x.PlaceService == procNotBilled.PlaceService);
                    }
                }
                GetUniqueDiagnosticCodes(listProcs, listPatientProcs, listPatPlans, listInsSubs, listInsPlans);
                if (listProcs.Count > 7 && CultureInfo.CurrentCulture.Name.EndsWith("CA")) //Canadian. en-CA or fr-CA
                {
                    listProcs = listProcs.Take(7).ToList();                                //Returns first 7 items of the list.
                }
                listProcs.ForEach(x => x.IsAttached = true);                               //This way we can not attach procedures to multiple claims thanks to the logic above.
                if (listProcs.Any(x => listProcs[0].PlaceService != x.PlaceService) || listProcs.Any(x => listProcs[0].ClinicNum != x.ClinicNum))
                {
                    //Regardless if we are automatically grouping or not,
                    //if all procs in our list at this point do not share the same PlaceService or ClinicNum then claims will not be made.
                }
                else                  //Basic validation passed.
                {
                    if (!listProcs[0].HasPriClaim &&                 //Medical claim.
                        PatPlans.GetOrdinal(PriSecMed.Medical, listPatPlans, listInsPlans, listInsSubs) > 0 &&                    //Has medical ins.
                        PatPlans.GetOrdinal(PriSecMed.Primary, listPatPlans, listInsPlans, listInsSubs) == 0 &&                    //Does not have primary dental ins.
                        PatPlans.GetOrdinal(PriSecMed.Secondary, listPatPlans, listInsPlans, listInsSubs) == 0)                       //Does not have secondary dental ins.
                    {
                        claimCreatedCount++;
                    }
                    else                                                                                                                      //Not a medical claim.
                    {
                        if (!listProcs[0].HasPriClaim && PatPlans.GetOrdinal(PriSecMed.Primary, listPatPlans, listInsPlans, listInsSubs) > 0) //Primary claim.
                        {
                            claimCreatedCount++;
                        }
                        if (!listProcs[0].HasSecClaim && PatPlans.GetOrdinal(PriSecMed.Secondary, listPatPlans, listInsPlans, listInsSubs) > 0)                  //Secondary claim.
                        {
                            claimCreatedCount++;
                        }
                    }
                }
                listGroupedProcs.Add(listProcs);
            }
            if (!MsgBox.Show(this, true, "Clicking continue will create up to " + POut.Int(claimCreatedCount) + " claims and cannot be undone, except by manually going to each account.  "
                             + "Some claims may not be created if there are validation issues.  Would you like to proceed?"))
            {
                return;
            }
            //Create Claims--------------------------------------------------------------------------------------------------------------------------------
            claimCreatedCount = 0;
            string claimErrors = "";
            foreach (List <ProcNotBilled> listProcs in listGroupedProcs)
            {
                patCur = listProcs[0].Patient;
                gridMain.SetSelected(false);                //Need to deslect all rows each time so that ContrAccount.toolBarButIns_Click(...) only uses pertinent rows.
                for (int j = 0; j < listProcs.Count; j++)
                {
                    gridMain.SetSelected(listProcs[j].RowIndex, true);                   //Select the pertinent rows so that they will be attached to the claim below.
                }
                ContrAccount.toolBarButIns_Click(false, patCur, Patients.GetFamily(patCur.PatNum), gridMain, table,
                                                 procNotBilled.HasPriClaim, procNotBilled.HasSecClaim);
                string errorTitle = patCur.PatNum + " " + patCur.GetNameLFnoPref() + " - ";
                if (patNumOld == patCur.PatNum && !string.IsNullOrEmpty(ContrAccount.ClaimErrorsCur))
                {
                    claimErrors += "\t\t" + ContrAccount.ClaimErrorsCur + "\r\n";
                }
                else if (!string.IsNullOrEmpty(ContrAccount.ClaimErrorsCur))
                {
                    claimErrors += errorTitle + ContrAccount.ClaimErrorsCur + "\r\n";
                }
                claimCreatedCount += ContrAccount.ClaimCreatedCount;
                patNumOld          = patCur.PatNum;
            }
            FillGrid();
            if (!string.IsNullOrEmpty(claimErrors))
            {
                MsgBoxCopyPaste form = new MsgBoxCopyPaste(claimErrors);
                form.ShowDialog();
            }
            MessageBox.Show(Lan.g(this, "Number of claims created") + ": " + claimCreatedCount);
        }
コード例 #26
0
        private void RunProdGoal()
        {
            //If adding the unearned column, need more space. Set report to landscape.
            if (checkAllProv.Checked)
            {
                for (int i = 0; i < listProv.Items.Count; i++)
                {
                    listProv.SetSelected(i, true);
                }
            }
            if (checkAllClin.Checked)
            {
                for (int i = 0; i < listClin.Items.Count; i++)
                {
                    listClin.SetSelected(i, true);
                }
            }
            _dateFrom = PIn.Date(textDateFrom.Text);
            _dateTo   = PIn.Date(textDateTo.Text);
            List <Provider> listProvs = checkAllProv.Checked?_listProviders:
                                        listProv.SelectedIndices.Count > 0?listProv.SelectedIndices.OfType <int>().Select(x => _listFilteredProviders[x]).ToList():new List <Provider>();
            List <Clinic> listClinics            = new List <Clinic>();
            List <long>   listSelectedClinicNums = new List <long>();

            if (PrefC.HasClinicsEnabled)
            {
                if (listClin.SelectedIndices.Count > 0)
                {
                    int offset = Security.CurUser.ClinicIsRestricted?0:1;
                    listClinics.AddRange(listClin.SelectedIndices.OfType <int>()
                                         .Select(x => offset == 1 && x == 0?new Clinic {
                        ClinicNum = 0, Abbr = Lan.g(this, "Unassigned")
                    }:_listClinics[x - offset]));
                }
                //Check here for multi clinic schedule overlap and give notification.
                listSelectedClinicNums = listClinics.Select(x => x.ClinicNum).ToList();
                var listConflicts = listProvs
                                    .Select(x => new { x.Abbr, listScheds = Schedules.GetClinicOverlapsForProv(_dateFrom, _dateTo, x.ProvNum, listSelectedClinicNums) })
                                    .Where(x => x.listScheds.Count > 0).ToList();
                if (listConflicts.Count > 0)
                {
                    string errorMsg = "This report is designed to show production goals by clinic and provider.  You have one or more providers during the "
                                      + "specified period that are scheduled in more than one clinic at the same time.  Due to this, production goals cannot be reported "
                                      + "accurately.\r\nTo run this report, please fix your scheduling so each provider is only scheduled at one clinic at a time, or select "
                                      + "different providers or clinics.\r\nIn the mean time, you can run regular production and income reports instead.\r\n\r\n"
                                      + "Conflicts:\r\n"
                                      + string.Join("\r\n", listConflicts
                                                    .SelectMany(x => x.listScheds
                                                                .Select(y => x.Abbr + " " + y.SchedDate.ToShortDateString() + " " + y.StartTime.ToShortTimeString() + " - " + y.StopTime.ToShortTimeString())));
                    MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste(errorMsg);
                    msgBox.ShowDialog();
                    return;
                }
            }
            ReportComplex report        = new ReportComplex(true, false);
            bool          hasAllClinics = checkAllClin.Checked && listSelectedClinicNums.Contains(0) &&
                                          Clinics.GetDeepCopy().Select(x => x.ClinicNum).All(x => x.In(listSelectedClinicNums));

            using (DataSet ds = RpProdGoal.GetData(_dateFrom, _dateTo, listProvs, listClinics, checkAllProv.Checked, hasAllClinics, GetWriteoffType()))
                using (DataTable dt = ds.Tables["Total"])
                    using (DataTable dtClinic = PrefC.HasClinicsEnabled?ds.Tables["Clinic"]:new DataTable())
                        using (Font font = new Font("Tahoma", 8, FontStyle.Regular)) {
                            report.ReportName = "MonthlyP&IGoals";
                            report.AddTitle("Title", Lan.g(this, "Monthly Production Goal"));
                            report.AddSubTitle("PracName", PrefC.GetString(PrefName.PracticeTitle));
                            report.AddSubTitle("Date", _dateFrom.ToShortDateString() + " - " + _dateTo.ToShortDateString());
                            report.AddSubTitle("Providers", checkAllProv.Checked?Lan.g(this, "All Providers"):listProvs.Count == 0?"":string.Join(", ", listProvs.Select(x => x.Abbr)));
                            if (PrefC.HasClinicsEnabled)
                            {
                                report.AddSubTitle("Clinics", hasAllClinics?Lan.g(this, "All Clinics"):listClinics.Count == 0?"":string.Join(", ", listClinics.Select(x => x.Abbr)));
                            }
                            //setup query
                            QueryObject query;
                            if (PrefC.HasClinicsEnabled && checkClinicBreakdown.Checked)
                            {
                                query = report.AddQuery(dtClinic, "", "Clinic", SplitByKind.Value, 1, true);
                            }
                            else
                            {
                                query = report.AddQuery(dt, "", "", SplitByKind.None, 1, true);
                            }
                            // add columns to report
                            int dateWidth        = 70;
                            int weekdayWidth     = 65;
                            int prodWidth        = 90;
                            int prodGoalWidth    = 90;
                            int schedWidth       = 85;
                            int adjWidth         = 85;
                            int writeoffWidth    = 95;
                            int writeoffestwidth = 95;
                            int writeoffadjwidth = 70;
                            int totProdWidth     = 90;
                            int summaryOffSetY   = 30;
                            int groups           = 1;
                            if (PrefC.HasClinicsEnabled && listClin.SelectedIndices.Count > 1 && checkClinicBreakdown.Checked)
                            {
                                groups = 2;
                            }
                            for (int i = 0; i < groups; i++) //groups will be 1 or 2 if there are clinic breakdowns
                            {
                                if (i > 0)                   //If more than one clinic selected, we want to add a table to the end of the report that totals all the clinics together
                                {
                                    query = report.AddQuery(dt, "Totals", "", SplitByKind.None, 2, true);
                                }
                                query.AddColumn("Date", dateWidth, FieldValueType.String, font);
                                query.AddColumn("Weekday", weekdayWidth, FieldValueType.String, font);
                                query.AddColumn("Production", prodWidth, FieldValueType.Number, font);
                                query.AddColumn("Prod Goal", prodGoalWidth, FieldValueType.Number, font);
                                query.AddColumn("Scheduled", schedWidth, FieldValueType.Number, font);
                                query.AddColumn("Adjusts", adjWidth, FieldValueType.Number, font);
                                if (GetWriteoffType() == PPOWriteoffDateCalc.ClaimPayDate)
                                {
                                    query.AddColumn("Writeoff Est", writeoffestwidth, FieldValueType.Number, font);
                                    query.AddColumn("Writeoff Adj", writeoffadjwidth, FieldValueType.Number, font);
                                }
                                else
                                {
                                    query.AddColumn("Writeoff", writeoffWidth, FieldValueType.Number, font);
                                }
                                query.AddColumn("Tot Prod", totProdWidth, FieldValueType.Number, font);
                            }
                            string colNameAlign = "Writeoff" + (GetWriteoffType() == PPOWriteoffDateCalc.ClaimPayDate?" Est":"");//Column used to align the summary fields.
                            string summaryText  = "Total Production (Production + Scheduled + Adjustments - Writeoff"
                                                  + (GetWriteoffType() == PPOWriteoffDateCalc.ClaimPayDate?" Ests - Writeoff Adjs":"s") + "): ";
                            query.AddGroupSummaryField(summaryText, colNameAlign, "Tot Prod", SummaryOperation.Sum, new List <int> {
                                groups
                            }, Color.Black,
                                                       new Font("Tahoma", 9, FontStyle.Bold), 75, summaryOffSetY);
                            report.AddPageNum();
                            // execute query
                            if (!report.SubmitQueries())
                            {
                                return;
                            }
                            // display report
                            using (FormReportComplex FormR = new FormReportComplex(report)) {
                                FormR.ShowDialog();
                            }
                        }
        }
コード例 #27
0
        private void butRawMessage_Click(object sender, EventArgs e)
        {
            MsgBoxCopyPaste msgbox = new MsgBoxCopyPaste(MessageText);

            msgbox.ShowDialog();
        }
コード例 #28
0
        private void butProcess_Click(object sender, EventArgs e)
        {
            if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "This will add a new repeating charge for each provider in the list above"
                             + " who is new (does not already have a repeating charge), based on PatNum and NPI.  Continue?"))
            {
                return;
            }
            Cursor = Cursors.WaitCursor;
            List <NewCropCharge> listAddedCharges = new List <NewCropCharge>();
            int           numSkipped         = 0;
            StringBuilder strBldArchivedPats = new StringBuilder();

            foreach (NewCropCharge charge in _listNewCropCharges)
            {
                if (charge.repeatCharge == null)               //No such repeating charge exists yet for the given npi.
                //We consider the provider a new provider and create a new repeating charge.
                {
                    int dayOtherCharges = GetChargeDayOfMonth(charge.PatNumForRegKey);                  //The day of the month that the customer already has other repeating charges. Keeps their billing simple (one bill per month for all charges).
                    int daysInMonth     = DateTime.DaysInMonth(_dateBillingMonthYear.Year, _dateBillingMonthYear.Month);
                    if (dayOtherCharges > daysInMonth)
                    {
                        //The day that the user used eRx (signed up) was in a month that does not have the day of the other monthly charges in it.
                        //E.g.  dayOtherCharges = 31 and the user started a new eRx account in a month without 31 days.
                        //Therefore, we have to use the last day of the month that they started.
                        //This can introduce multiple statements being sent out which can potentially delay us (HQ) from getting paid in a timely fashion.
                        //A workaround for this would be to train our techs to never run billing after the 28th of every month that way incomplete statements are not sent.
                        dayOtherCharges = daysInMonth;
                    }
                    DateTime dateErxCharge = new DateTime(_dateBillingMonthYear.Year, _dateBillingMonthYear.Month, dayOtherCharges);
                    if (dateErxCharge < DateTime.Today.AddMonths(-3))                   //Just in case the user runs an older report.
                    {
                        numSkipped++;
                        continue;
                    }
                    charge.repeatCharge                = new RepeatCharge();
                    charge.repeatCharge.IsNew          = true;
                    charge.repeatCharge.PatNum         = charge.PatNumForRegKey;
                    charge.repeatCharge.ProcCode       = GetProcCodeForNewCharge(charge.PatNumForRegKey);
                    charge.repeatCharge.ChargeAmt      = 15;             //15$/month
                    charge.repeatCharge.DateStart      = dateErxCharge;
                    charge.repeatCharge.Npi            = charge.NPI;
                    charge.repeatCharge.ErxAccountId   = charge.AccountId;
                    charge.repeatCharge.ProviderName   = charge.FirstName + " " + charge.LastName;
                    charge.repeatCharge.IsEnabled      = true;
                    charge.repeatCharge.CopyNoteToProc = true;                  //Copy the billing note to the procedure note by default so that the customer can see the NPI the charge corresponds to. Can be unchecked by user if a private note is added later (rare).
                    if (!RepeatCharges.ActiveRepeatChargeExists(charge.repeatCharge.PatNum))
                    {
                        //Set the patient's billing day to the start day on the repeat charge
                        Patient patOld = Patients.GetPat(charge.repeatCharge.PatNum);
                        Patient patNew = patOld.Copy();
                        //Check the patients status and move them to Archived if they are currently deleted.
                        if (patOld.PatStatus == PatientStatus.Deleted)
                        {
                            patNew.PatStatus = PatientStatus.Archived;
                        }
                        //Notify the user about any deleted or archived patients that were just given a new repeating charge.
                        if (patOld.PatStatus == PatientStatus.Archived || patOld.PatStatus == PatientStatus.Deleted)
                        {
                            strBldArchivedPats.AppendLine("#" + patOld.PatNum + " - " + patOld.GetNameLF());
                        }
                        patNew.BillingCycleDay = charge.repeatCharge.DateStart.Day;
                        Patients.Update(patNew, patOld);
                    }
                    RepeatCharges.Insert(charge.repeatCharge);
                    _listErxRepeatCharges.Add(charge.repeatCharge);
                    listAddedCharges.Add(charge);
                }
                else                   //The repeating charge for eRx billing already exists for the given npi.
                {
                    DateTime dateEndLastMonth = (new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1)).AddDays(-1);
                    if (charge.repeatCharge.DateStop.Year > 2010)                   //eRx support for this provider was disabled at one point, but has been used since.
                    {
                        if (charge.repeatCharge.DateStop < dateEndLastMonth)        //If the stop date is in the future or already at the end of the month, then we cannot presume that there will be a charge next month.
                        {
                            charge.repeatCharge.DateStop = dateEndLastMonth;        //Make sure the recent use is reflected in the end date.
                            RepeatCharges.Update(charge.repeatCharge);
                        }
                    }
                }
            }
            FillGrid();
            Cursor = Cursors.Default;
            StringBuilder sbMsg = new StringBuilder();

            sbMsg.AppendLine("Done.");
            if (numSkipped > 0)
            {
                sbMsg.AppendLine("Number skipped due to old DateBilling (over 3 months ago): " + numSkipped);
            }
            if (listAddedCharges.Count > 0)
            {
                const int colNameWidth         = 62;
                const int colErxAccountIdWidth = 18;
                const int colNpiWidth          = 10;
                sbMsg.AppendLine("Added the following new repeating charges (" + listAddedCharges.Count + " total):");
                sbMsg.Append("  ");
                sbMsg.Append("NAME".PadRight(colNameWidth, ' '));
                sbMsg.Append("ERXACCOUNTID".PadRight(colErxAccountIdWidth, ' '));
                sbMsg.AppendLine("NPI".PadRight(colNpiWidth, ' '));
                foreach (NewCropCharge charge in listAddedCharges)
                {
                    string firstLastName = charge.FirstName + " " + charge.LastName;
                    if (firstLastName.Length > colNameWidth)
                    {
                        firstLastName = firstLastName.Substring(0, colNameWidth);
                    }
                    sbMsg.Append("  ");
                    sbMsg.Append(firstLastName.PadRight(colNameWidth, ' '));
                    sbMsg.Append(charge.AccountId.PadRight(colErxAccountIdWidth, ' '));
                    sbMsg.AppendLine(charge.NPI.PadRight(colNpiWidth, ' '));
                }
            }
            if (strBldArchivedPats.Length > 0)
            {
                sbMsg.AppendLine("Archived patients that had a repeating charge created:");
                sbMsg.AppendLine(strBldArchivedPats.ToString());
            }
            MsgBoxCopyPaste msgBoxCP = new MsgBoxCopyPaste(sbMsg.ToString());

            msgBoxCP.ShowDialog();            //Must be modal, because non-modal does not display here for some reason.
        }
コード例 #29
0
        private void Import834_Unsafe()
        {
            if (!MsgBox.Show(this, true, "Importing insurance plans is a database intensive operation and can take 10 minutes or more to run.  "
                             + "It is best to import insurance plans after hours or during another time period when database usage is otherwise low.\r\n"
                             + "Click OK to import insurance plans now, or click Cancel."))
            {
                return;
            }
            checkIsPatientCreate.Enabled = false;
            gridInsPlans.Enabled         = false;
            butOK.Enabled     = false;
            butCancel.Enabled = false;
            Cursor            = Cursors.WaitCursor;
            Prefs.UpdateBool(PrefName.Ins834IsPatientCreate, checkIsPatientCreate.Checked);
            int           rowIndex             = 1;
            int           createdPatsCount     = 0;
            int           updatedPatsCount     = 0;
            int           skippedPatsCount     = 0;
            int           createdCarrierCount  = 0;
            int           createdPlanCount     = 0;
            int           droppedPlanCount     = 0;
            int           updatedPlanCount     = 0;
            StringBuilder sbErrorMessages      = new StringBuilder();
            List <int>    listImportedSegments = new List <int> ();      //Used to reconstruct the 834 with imported patients removed.

            for (int i = 0; i < _x834.ListTransactions.Count; i++)
            {
                Hx834_Tran tran = _x834.ListTransactions[i];
                for (int j = 0; j < tran.ListMembers.Count; j++)
                {
                    Hx834_Member member = tran.ListMembers[j];
                    ShowStatus("Progress " + (rowIndex).ToString().PadLeft(6) + "/" + gridInsPlans.Rows.Count.ToString().PadLeft(6)
                               + "  Importing plans for patient " + member.Pat.GetNameLF());
                    //The patient's status is not affected by the maintenance code.  After reviewing all of the possible maintenance codes in
                    //member.MemberLevelDetail.MaintenanceTypeCode, we believe that all statuses suggest either insert or update, except for "Cancel".
                    //Nathan and Derek feel that archiving the patinet in response to a Cancel request is a bit drastic.
                    //Thus we ignore the patient maintenance code and always assume insert/update.
                    //Even if the status was "Cancel", then updating the patient does not hurt.
                    bool isMemberImported = false;
                    bool isMultiMatch     = false;
                    if (member.Pat.PatNum == 0)
                    {
                        //The patient may need to be created below.  However, the patient may have already been inserted in a pervious iteration of this loop
                        //in following scenario: Two different 834s include updates for the same patient and both documents are being imported at the same time.
                        //If the patient was already inserted, then they would show up in _listPatients and also in the database.  Attempt to locate the patient
                        //in _listPatients again before inserting.
                        List <Patient> listPatientMatches = Patients.GetPatientsByNameAndBirthday(member.Pat, _listPatients);
                        if (listPatientMatches.Count == 1)
                        {
                            member.Pat.PatNum = listPatientMatches[0].PatNum;
                        }
                        else if (listPatientMatches.Count > 1)
                        {
                            isMultiMatch = true;
                        }
                    }
                    if (isMultiMatch)
                    {
                        skippedPatsCount++;
                    }
                    else if (member.Pat.PatNum == 0 && checkIsPatientCreate.Checked)
                    {
                        //The code here mimcs the behavior of FormPatientSelect.butAddPt_Click().
                        Patients.Insert(member.Pat, false);
                        Patient memberPatOld = member.Pat.Copy();
                        member.Pat.PatStatus   = PatientStatus.Patient;
                        member.Pat.BillingType = PrefC.GetLong(PrefName.PracticeDefaultBillType);
                        if (!PrefC.GetBool(PrefName.PriProvDefaultToSelectProv))
                        {
                            //Set the patients primary provider to the practice default provider.
                            member.Pat.PriProv = Providers.GetDefaultProvider().ProvNum;
                        }
                        member.Pat.ClinicNum = Clinics.ClinicNum;
                        member.Pat.Guarantor = member.Pat.PatNum;
                        Patients.Update(member.Pat, memberPatOld);
                        int patIdx    = _listPatients.BinarySearch(member.Pat); //Preserve sort order by locating the index in which to insert the newly added patient.
                        int insertIdx = ~patIdx;                                //According to MSDN, the index returned by BinarySearch() is a "bitwise compliment", since not currently in list.
                        _listPatients.Insert(insertIdx, member.Pat);
                        SecurityLogs.MakeLogEntry(Permissions.PatientCreate, member.Pat.PatNum, "Created from Import Ins Plans 834.", LogSources.InsPlanImport834);
                        isMemberImported = true;
                        createdPatsCount++;
                    }
                    else if (member.Pat.PatNum == 0 && !checkIsPatientCreate.Checked)
                    {
                        skippedPatsCount++;
                    }
                    else                                                                                  //member.Pat.PatNum!=0
                    {
                        Patient patDb = _listPatients.FirstOrDefault(x => x.PatNum == member.Pat.PatNum); //Locate by PatNum, in case user selected manually.
                        member.MergePatientIntoDbPatient(patDb);                                          //Also updates the patient to the database and makes log entry.
                        _listPatients.Remove(patDb);                                                      //Remove patient from list so we can add it back in the correct location (in case name or bday changed).
                        int patIdx = _listPatients.BinarySearch(patDb);                                   //Preserve sort order by locating the index in which to insert the newly added patient.
                        //patIdx could be positive if the user manually selected a patient when there were multiple matches found.
                        //If patIdx is negative, then according to MSDN, the index returned by BinarySearch() is a "bitwise compliment".
                        //If there were mult instances of patDb BinarySearch() would return 0, which should not be complimented (OutOfRangeException)
                        int insertIdx = (patIdx >= 0)?patIdx:~patIdx;
                        _listPatients.Insert(insertIdx, patDb);
                        isMemberImported = true;
                        updatedPatsCount++;
                    }
                    if (isMemberImported)
                    {
                        //Import insurance changes for patient.
                        for (int k = 0; k < member.ListHealthCoverage.Count; k++)
                        {
                            Hx834_HealthCoverage healthCoverage = member.ListHealthCoverage[k];
                            if (k > 0)
                            {
                                rowIndex++;
                            }
                            List <Carrier> listCarriers = Carriers.GetByNameAndTin(tran.Payer.Name, tran.Payer.IdentificationCode);
                            if (listCarriers.Count == 0)
                            {
                                Carrier carrier = new Carrier();
                                carrier.CarrierName = tran.Payer.Name;
                                carrier.TIN         = tran.Payer.IdentificationCode;
                                Carriers.Insert(carrier);
                                DataValid.SetInvalid(InvalidType.Carriers);
                                listCarriers.Add(carrier);
                                SecurityLogs.MakeLogEntry(Permissions.CarrierCreate, 0, "Carrier '" + carrier.CarrierName
                                                          + "' created from Import Ins Plans 834.", LogSources.InsPlanImport834);
                                createdCarrierCount++;
                            }
                            //Update insurance plans.  Match based on carrier and SubscriberId.
                            bool isDropping = false;
                            if (healthCoverage.HealthCoverage.MaintenanceTypeCode == "002")
                            {
                                isDropping = true;
                            }
                            //The insPlanNew will only be inserted if necessary.  Created temporarily in order to determine if insert is needed.
                            InsPlan insPlanNew = InsertOrUpdateInsPlan(null, member, listCarriers[0], false);
                            //Since the insurance plans in the 834 do not include very much information, it is likely that many patients will share the same exact plan.
                            //We look for an existing plan being used by any other patinents which match the fields we typically import.
                            List <InsPlan> listInsPlans = InsPlans.GetAllByCarrierNum(listCarriers[0].CarrierNum);
                            InsPlan        insPlanMatch = null;
                            for (int p = 0; p < listInsPlans.Count; p++)
                            {
                                //Set the PlanNums equal so that AreEqualValue() will ignore this field.  We must ignore PlanNum, since we do not know the PlanNum.
                                insPlanNew.PlanNum = listInsPlans[p].PlanNum;
                                if (InsPlans.AreEqualValue(listInsPlans[p], insPlanNew))
                                {
                                    insPlanMatch = listInsPlans[p];
                                    break;
                                }
                            }
                            Family         fam          = Patients.GetFamily(member.Pat.PatNum);
                            List <InsSub>  listInsSubs  = InsSubs.RefreshForFam(fam);
                            List <PatPlan> listPatPlans = PatPlans.Refresh(member.Pat.PatNum);
                            InsSub         insSubMatch  = null;
                            PatPlan        patPlanMatch = null;
                            for (int p = 0; p < listInsSubs.Count; p++)
                            {
                                InsSub insSub = listInsSubs[p];
                                //According to section 1.4.3 of the standard, the preferred method of matching a dependent to a subscriber is to use the subscriberId.
                                if (insSub.SubscriberID.Trim() != member.SubscriberId.Trim())
                                {
                                    continue;
                                }
                                insSubMatch  = insSub;
                                patPlanMatch = PatPlans.GetFromList(listPatPlans, insSub.InsSubNum);
                                break;
                            }
                            if (patPlanMatch == null && isDropping)                           //No plan match and dropping plan.
                            //Nothing to do.  The plan either never existed or is already dropped.
                            {
                            }
                            else if (patPlanMatch == null && !isDropping)                           //No plan match and not dropping plan.  Create the plan.
                            {
                                insPlanMatch = InsertOrUpdateInsPlan(insPlanMatch, member, listCarriers[0]);
                                insSubMatch  = InsertOrUpdateInsSub(insSubMatch, insPlanMatch, member, healthCoverage, listCarriers[0]);
                                patPlanMatch = InsertOrUpdatePatPlan(patPlanMatch, insSubMatch, insPlanMatch, member, listCarriers[0], listPatPlans);
                                createdPlanCount++;
                            }
                            else if (patPlanMatch != null && isDropping)                           //Plan matched and dropping plan.  Drop the plan.
                            //This code mimics the behavior of FormInsPlan.butDrop_Click(), except here we do not care if there are claims for this plan today.
                            //We need this feature to be as streamlined as possible so that it might become an automated process later.
                            //Testing for claims on today's date does not seem that useful anyway, or at least not as useful as checking for any claims
                            //associated to the plan, instead of just today's date.
                            {
                                PatPlans.Delete(patPlanMatch.PatPlanNum);                                //Estimates recomputed within Delete()
                                SecurityLogs.MakeLogEntry(Permissions.InsPlanDropPat, patPlanMatch.PatNum,
                                                          "Insurance plan dropped from patient for carrier '" + listCarriers[0].CarrierName + "' and groupnum "
                                                          + "'" + insPlanMatch.GroupNum + "' and subscriber ID '" + insSubMatch.SubscriberID + "' "
                                                          + "from Import Ins Plans 834.", insPlanMatch.PlanNum, LogSources.InsPlanImport834, insPlanMatch.SecDateTEdit);
                                droppedPlanCount++;
                            }
                            else if (patPlanMatch != null && !isDropping)                            //Plan matched and not dropping plan.  Update the plan.
                            {
                                insPlanMatch = InsertOrUpdateInsPlan(insPlanMatch, member, listCarriers[0]);
                                insSubMatch  = InsertOrUpdateInsSub(insSubMatch, insPlanMatch, member, healthCoverage, listCarriers[0]);
                                patPlanMatch = InsertOrUpdatePatPlan(patPlanMatch, insSubMatch, insPlanMatch, member, listCarriers[0], listPatPlans);
                                updatedPlanCount++;
                            }
                        }                        //end loop k
                        //Remove the member from the X834.
                        int endSegIndex = 0;
                        if (j < tran.ListMembers.Count - 1)
                        {
                            endSegIndex = tran.ListMembers[j + 1].MemberLevelDetail.SegmentIndex - 1;
                        }
                        else
                        {
                            X12Segment segSe = _x834.GetNextSegmentById(member.MemberLevelDetail.SegmentIndex + 1, "SE");                       //SE segment is required.
                            endSegIndex = segSe.SegmentIndex - 1;
                        }
                        for (int s = member.MemberLevelDetail.SegmentIndex; s <= endSegIndex; s++)
                        {
                            listImportedSegments.Add(s);
                        }
                    }
                    rowIndex++;
                }                                                       //end loop j
            }                                                           //end loop i
            if (listImportedSegments.Count > 0 && skippedPatsCount > 0) //Some patients imported, while others did not.
            {
                if (MoveFileToArchiveFolder())
                {
                    //Save the unprocessed members back to the import directory, so the user can try to import them again.
                    File.WriteAllText(_x834.FilePath, _x834.ReconstructRaw(listImportedSegments));
                }
            }
            else if (listImportedSegments.Count > 0)             //All patinets imported.
            {
                MoveFileToArchiveFolder();
            }
            else if (skippedPatsCount > 0)             //No patients imported.  All patients were skipped.
            //Leave the raw file unaltered and where it is, so it can be processed again.
            {
            }
            Cursor = Cursors.Default;
            string msg = Lan.g(this, "Done.");

            if (createdPatsCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of patients created:") + " " + createdPatsCount;
            }
            if (updatedPatsCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of patients updated:") + " " + updatedPatsCount;
            }
            if (skippedPatsCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of patients skipped:") + " " + skippedPatsCount;
                msg += sbErrorMessages.ToString();
            }
            if (createdCarrierCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of carriers created:") + " " + createdCarrierCount;
                msg += sbErrorMessages.ToString();
            }
            if (createdPlanCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of plans created:") + " " + createdPlanCount;
                msg += sbErrorMessages.ToString();
            }
            if (droppedPlanCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of plans dropped:") + " " + droppedPlanCount;
                msg += sbErrorMessages.ToString();
            }
            if (updatedPlanCount > 0)
            {
                msg += "\r\n" + Lan.g(this, "Number of plans updated:") + " " + updatedPlanCount;
                msg += sbErrorMessages.ToString();
            }
            MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste(msg);

            msgBox.ShowDialog();
        }
コード例 #30
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();
        }