예제 #1
0
        /// <summary>Will return 0 if string cannot be parsed to a number.  Will return 0 if the fee schedule passed in does not exactly match the description of a regular fee schedule.</summary>
        public static long FeeScheduleParse(string str)
        {
            if (str == "")
            {
                return(0);
            }
            FeeSched feeSched = FeeScheds.GetByExactName(str, FeeScheduleType.Normal);

            if (feeSched == null)
            {
                return(0);
            }
            return(feeSched.FeeSchedNum);
        }
예제 #2
0
        ///<summary>If the named fee schedule does not exist, then it will be created.  It always returns the defnum for the feesched used, regardless of whether it already existed.  procCode must have already been tested for valid code, and feeSchedName must not be blank.</summary>
        public static long ImportTrojan(string procCode, double amt, string feeSchedName)
        {
            FeeSched feeSched = FeeScheds.GetByExactName(feeSchedName);

            //if isManaged, then this should be done differently from here on out.
            if (feeSched == null)
            {
                //add the new fee schedule
                feeSched              = new FeeSched();
                feeSched.ItemOrder    = FeeSchedC.ListLong.Count;
                feeSched.Description  = feeSchedName;
                feeSched.FeeSchedType = FeeScheduleType.Normal;
                //feeSched.IsNew=true;
                FeeScheds.Insert(feeSched);
                //Cache.Refresh(InvalidType.FeeScheds);
                //Fees.Refresh();
                DataValid.SetInvalid(InvalidType.FeeScheds, InvalidType.Fees);
            }
            if (feeSched.IsHidden)
            {
                feeSched.IsHidden = false;              //unhide it
                FeeScheds.Update(feeSched);
                DataValid.SetInvalid(InvalidType.FeeScheds);
            }
            Fee fee = Fees.GetFee(ProcedureCodes.GetCodeNum(procCode), feeSched.FeeSchedNum);

            if (fee == null)
            {
                fee          = new Fee();
                fee.Amount   = amt;
                fee.FeeSched = feeSched.FeeSchedNum;
                fee.CodeNum  = ProcedureCodes.GetCodeNum(procCode);
                Fees.Insert(fee);
            }
            else
            {
                fee.Amount = amt;
                Fees.Update(fee);
            }
            return(feeSched.FeeSchedNum);
        }
예제 #3
0
        private void butImportEcw_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            OpenFileDialog Dlg = new OpenFileDialog();

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