예제 #1
0
        ///<summary>Inserts one Ebill into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(Ebill ebill, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                ebill.EbillNum = ReplicationServers.GetKey("ebill", "EbillNum");
            }
            string command = "INSERT INTO ebill (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "EbillNum,";
            }
            command += "ClinicNum,ClientAcctNumber,ElectUserName,ElectPassword,PracticeAddress,RemitAddress) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(ebill.EbillNum) + ",";
            }
            command +=
                POut.Long(ebill.ClinicNum) + ","
                + "'" + POut.String(ebill.ClientAcctNumber) + "',"
                + "'" + POut.String(ebill.ElectUserName) + "',"
                + "'" + POut.String(ebill.ElectPassword) + "',"
                + POut.Int((int)ebill.PracticeAddress) + ","
                + POut.Int((int)ebill.RemitAddress) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                ebill.EbillNum = Db.NonQ(command, true, "EbillNum", "ebill");
            }
            return(ebill.EbillNum);
        }
예제 #2
0
 ///<summary>Inserts one Ebill into the database.  Returns the new priKey.</summary>
 public static long Insert(Ebill ebill)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         ebill.EbillNum = DbHelper.GetNextOracleKey("ebill", "EbillNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(ebill, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     ebill.EbillNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(ebill, false));
     }
 }
예제 #3
0
        ///<summary>Generates all the xml up to the point where the first statement would go.</summary>
        public static void GeneratePracticeInfo(XmlWriter writer, long clinicNum)
        {
            Clinic clinic      = Clinics.GetClinic(clinicNum);
            Ebill  eBillClinic = Ebills.GetForClinic(clinicNum);

            if (eBillClinic == null)
            {
                eBillClinic = Ebills.GetForClinic(0);
            }
            writer.WriteProcessingInstruction("xml", "version = \"1.0\" standalone=\"yes\"");
            writer.WriteStartElement("StatementFile");
            //sender address----------------------------------------------------------
            writer.WriteStartElement("SenderAddress");
            if (clinic == null)
            {
                writer.WriteElementString("Name", PrefC.GetString(PrefName.PracticeTitle));
            }
            else
            {
                writer.WriteElementString("Name", clinic.Description);
            }
            WriteAddress(writer, eBillClinic.PracticeAddress, clinic);
            writer.WriteEndElement();            //SenderAddress
            writer.WriteStartElement("Statements");
        }
예제 #4
0
        ///<summary>Updates one Ebill in the database.</summary>
        public static void Update(Ebill ebill)
        {
            string command = "UPDATE ebill SET "
                             + "ClinicNum       =  " + POut.Long(ebill.ClinicNum) + ", "
                             + "ClientAcctNumber= '" + POut.String(ebill.ClientAcctNumber) + "', "
                             + "ElectUserName   = '******', "
                             + "ElectPassword   = '******', "
                             + "PracticeAddress =  " + POut.Int((int)ebill.PracticeAddress) + ", "
                             + "RemitAddress    =  " + POut.Int((int)ebill.RemitAddress) + " "
                             + "WHERE EbillNum = " + POut.Long(ebill.EbillNum);

            Db.NonQ(command);
        }
예제 #5
0
 ///<summary>Inserts one Ebill into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(Ebill ebill)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(ebill, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             ebill.EbillNum = DbHelper.GetNextOracleKey("ebill", "EbillNum");                  //Cacheless method
         }
         return(InsertNoCache(ebill, true));
     }
 }
예제 #6
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <Ebill> TableToList(DataTable table)
        {
            List <Ebill> retVal = new List <Ebill>();
            Ebill        ebill;

            foreach (DataRow row in table.Rows)
            {
                ebill                  = new Ebill();
                ebill.EbillNum         = PIn.Long(row["EbillNum"].ToString());
                ebill.ClinicNum        = PIn.Long(row["ClinicNum"].ToString());
                ebill.ClientAcctNumber = PIn.String(row["ClientAcctNumber"].ToString());
                ebill.ElectUserName    = PIn.String(row["ElectUserName"].ToString());
                ebill.ElectPassword    = PIn.String(row["ElectPassword"].ToString());
                ebill.PracticeAddress  = (OpenDentBusiness.EbillAddress)PIn.Int(row["PracticeAddress"].ToString());
                ebill.RemitAddress     = (OpenDentBusiness.EbillAddress)PIn.Int(row["RemitAddress"].ToString());
                retVal.Add(ebill);
            }
            return(retVal);
        }
예제 #7
0
        private void comboClinic_SelectionChangeCommitted(object sender, EventArgs e)
        {
            SaveEbill(_eBillCur);
            Ebill eBill = null;

            if ((!Security.CurUser.ClinicIsRestricted || Clinics.ClinicNum == 0) && comboClinic.SelectedIndex == 0)         //Unassigned/Default
            {
                eBill = _eBillDefault;
            }
            else              //Otherwise locate the Ebill from the cache.
            {
                for (int i = 0; i < _listEbills.Count; i++)
                {
                    if (_listEbills[i].ClinicNum == _listClinics[comboClinic.SelectedIndex].ClinicNum)                   //Check for existing Ebill entry
                    {
                        eBill = _listEbills[i];
                        break;
                    }
                }
            }
            LoadEbill(eBill);            //Could be null if user switches to a clinic which has not Ebill entry yet.
        }
예제 #8
0
 ///<summary>Saves the current Ebill information from the UI into the cache.</summary>
 private void SaveEbill(Ebill eBill)
 {
     if (eBill.ClinicNum == 0)           //If the ebill being edited is for the defaults use what's in the text
     {
         eBill.ClientAcctNumber = textClientAcctNumber.Text;
         eBill.ElectUserName    = textUserName.Text;
         eBill.ElectPassword    = textPassword.Text;
     }
     else              //If the ebill isn't the default
     {
         if (textClientAcctNumber.Text != "" && textClientAcctNumber.Text != _eBillDefault.ClientAcctNumber)
         {
             eBill.ClientAcctNumber = textClientAcctNumber.Text;
         }
         else                  //Text was blank or the same as the default, blank it.
         {
             eBill.ClientAcctNumber = "";
         }
         if (textUserName.Text != "" && textUserName.Text != _eBillDefault.ElectUserName)
         {
             eBill.ElectUserName = textUserName.Text;
         }
         else                  //Text was blank or the same as the default, blank it.
         {
             eBill.ElectUserName = "";
         }
         if (textPassword.Text != "" && textPassword.Text != _eBillDefault.ElectPassword)
         {
             eBill.ElectPassword = textPassword.Text;
         }
         else                  //Text was blank or the same as the default, blank it.
         {
             eBill.ElectPassword = "";
         }
     }
     eBill.PracticeAddress = (EbillAddress)comboPracticeAddr.SelectedIndex;
     eBill.RemitAddress    = (EbillAddress)comboRemitAddr.SelectedIndex;
 }
예제 #9
0
        //these are temporary:
        //private static string vendorID="68";
        //private static string vendorPMScode="144";
        //private static string clientAccountNumber="8011";//the dental office number set by EHG
        //private static string creditCardChoices="MC,D,V,A";//MasterCard,Discover,Visa,AmericanExpress
        //private static string userName="";
        //private static string password="";

        ///<summary>Returns empty list if no errors.  Otherwise returns a list with error messages.</summary>
        public static List <string> Validate(long clinicNum)
        {
            List <string> listErrors   = new List <string>();
            Clinic        clinic       = Clinics.GetClinic(clinicNum);
            Ebill         eBillClinic  = Ebills.GetForClinic(clinicNum);
            Ebill         eBillDefault = Ebills.GetForClinic(0);
            EHG_Address   addressRemit = null;

            if (eBillClinic == null)
            {
                addressRemit = GetAddress(eBillDefault.RemitAddress, clinic);
            }
            else
            {
                addressRemit = GetAddress(eBillClinic.RemitAddress, clinic);
            }
            if (addressRemit.Address1.Trim().Length == 0 || addressRemit.City.Trim().Length == 0 ||
                addressRemit.State.Trim().Length == 0 || addressRemit.Zip.Trim().Length == 0)
            {
                listErrors.Add(Lan.g("EHG_Statements", "invalid") + " " + Lan.g("EHG_Statements", addressRemit.Source));
            }
            return(listErrors);
        }
예제 #10
0
        ///<summary>Generates all the xml up to the point where the first statement would go.</summary>
        public static void GeneratePracticeInfo(XmlWriter writer, long clinicNum)
        {
            Clinic clinic       = Clinics.GetClinic(clinicNum);
            Ebill  eBillClinic  = Ebills.GetForClinic(clinicNum);
            Ebill  eBillDefault = Ebills.GetForClinic(0);

            writer.WriteProcessingInstruction("xml", "version = \"1.0\" standalone=\"yes\"");
            writer.WriteStartElement("EISStatementFile");
            writer.WriteAttributeString("VendorID", PrefC.GetString(PrefName.BillingElectVendorId));
            writer.WriteAttributeString("OutputFormat", "StmOut_Blue6Col");
            writer.WriteAttributeString("Version", "2");
            writer.WriteElementString("SubmitDate", DateTime.Today.ToString("yyyy-MM-dd"));
            writer.WriteElementString("PrimarySubmitter", PrefC.GetString(PrefName.BillingElectVendorPMSCode));
            writer.WriteElementString("Transmitter", "EHG");
            writer.WriteStartElement("Practice");
            string billingClientAccountNumber = eBillDefault.ClientAcctNumber;

            if (eBillClinic != null && eBillClinic.ClientAcctNumber != "")         //clinic eBill entry exists, check the fields for overrides
            {
                billingClientAccountNumber = eBillClinic.ClientAcctNumber;
            }
            writer.WriteAttributeString("AccountNumber", billingClientAccountNumber);
            //sender address----------------------------------------------------------
            writer.WriteStartElement("SenderAddress");
            if (clinic == null)
            {
                writer.WriteElementString("Name", PrefC.GetString(PrefName.PracticeTitle));
            }
            else
            {
                writer.WriteElementString("Name", clinic.Description);
            }
            if (eBillClinic == null)
            {
                WriteAddress(writer, eBillDefault.PracticeAddress, clinic);
            }
            else
            {
                WriteAddress(writer, eBillClinic.PracticeAddress, clinic);
            }
            writer.WriteEndElement();            //senderAddress
            //remit address----------------------------------------------------------
            writer.WriteStartElement("RemitAddress");
            if (clinic == null)
            {
                writer.WriteElementString("Name", PrefC.GetString(PrefName.PracticeTitle));
            }
            else
            {
                writer.WriteElementString("Name", clinic.Description);
            }
            if (eBillClinic == null)
            {
                WriteAddress(writer, eBillDefault.RemitAddress, clinic);
            }
            else
            {
                WriteAddress(writer, eBillClinic.RemitAddress, clinic);
            }
            writer.WriteEndElement();            //remitAddress
            //Rendering provider------------------------------------------------------
            Provider prov = Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv));

            writer.WriteStartElement("RenderingProvider");
            writer.WriteElementString("Name", prov.GetFormalName());
            writer.WriteElementString("LicenseNumber", prov.StateLicense);
            writer.WriteElementString("State", PrefC.GetString(PrefName.PracticeST));
            writer.WriteEndElement();            //Rendering provider
        }
예제 #11
0
        ///<summary>Surround with try catch.  The "data" is the previously constructed xml.  If the internet connection is lost or unavailable, then the exception thrown will be a 404 error similar to the following: "The remote server returned an error: (404) Not Found"</summary>
        public static void Send(string data, long clinicNum)
        {
            //Validate the structure of the XML before sending.
            StringReader sr = new StringReader(data);

            try {
                XmlReader xmlr = XmlReader.Create(sr);
                while (xmlr.Read())                  //Read every node an ensure that there are no exceptions thrown.
                {
                }
            }
            catch (Exception ex) {
                throw new ApplicationException("Invalid XML in statement batch: " + ex.Message);
            }
            finally {
                sr.Dispose();
            }
            string strHistoryFile = "";

            if (PrefC.GetBool(PrefName.BillingElectSaveHistory))
            {
                string strHistoryDir = CodeBase.ODFileUtils.CombinePaths(ImageStore.GetPreferredAtoZpath(), "EHG_History");
                if (!Directory.Exists(strHistoryDir))
                {
                    Directory.CreateDirectory(strHistoryDir);
                }
                strHistoryFile = CodeBase.ODFileUtils.CreateRandomFile(strHistoryDir, ".txt");
                File.WriteAllText(strHistoryFile, data);
            }
            //Step 1: Post authentication request:
            Version        myVersion = new Version(Application.ProductVersion);
            HttpWebRequest webReq;
            WebResponse    response;
            StreamReader   readStream;
            string         str;

            string[] responseParams;
            string   status             = "";
            string   group              = "";
            string   userid             = "";
            string   authid             = "";
            string   errormsg           = "";
            string   alertmsg           = "";
            string   curParam           = "";
            string   serverName         = "https://claimconnect.dentalxchange.com/dci/upload.svl";//live URL for claims (According to phone call with Dentalxchange)
            string   serverNameOverride = PrefC.GetString(PrefName.BillingElectStmtUploadURL);

            if (!string.IsNullOrEmpty(serverNameOverride))
            {
                serverName = serverNameOverride;
            }
#if DEBUG
            //serverName="https://prelive.dentalxchange.com/dci/upload.svl";      //test URL for claims
            //serverName="https://claimconnect.dentalxchange.com/dci/upload.svl"; //live URL for claims
            //serverName="https://prelive.dentalxchange.com/dci/upload.svl";      //test URL for Stmts
            //serverName="https://billconnect.dentalxchange.com/dci/upload.svl";  //live URL for Stmts; probably the correct one to use.
#endif
            webReq = (HttpWebRequest)WebRequest.Create(serverName);
            Ebill  ebillDefault    = Ebills.GetForClinic(0);
            string billingUserName = ebillDefault.ElectUserName;
            string billingPassword = ebillDefault.ElectPassword;
            if (PrefC.HasClinicsEnabled && clinicNum != 0)
            {
                Ebill eBill = Ebills.GetForClinic(clinicNum);
                if (eBill != null)               //eBill entry exists, check the fields for overrides.
                {
                    if (eBill.ElectUserName != "")
                    {
                        billingUserName = eBill.ElectUserName;
                    }
                    if (eBill.ElectPassword != "")
                    {
                        billingPassword = eBill.ElectPassword;
                    }
                }
            }
            string postData =
                "Function=Auth"                                                                                                          //CONSTANT; signifies that this is an authentication request
                + "&Source=STM"                                                                                                          //CONSTANT; file format
                + "&UploaderName=OpenDental"                                                                                             //CONSTANT
                + "&UploaderVersion=" + myVersion.Major.ToString() + "." + myVersion.Minor.ToString() + "." + myVersion.Build.ToString() //eg 12.3.24
                + "&Username="******"&Password="******"POST";
            webReq.ContentType   = "application/x-www-form-urlencoded";
            webReq.ContentLength = postData.Length;
            ASCIIEncoding encoding  = new ASCIIEncoding();
            byte[]        bytes     = encoding.GetBytes(postData);
            Stream        streamOut = webReq.GetRequestStream();
            streamOut.Write(bytes, 0, bytes.Length);
            streamOut.Close();
            response = webReq.GetResponse();
            //Process the authentication response:
            readStream = new StreamReader(response.GetResponseStream(), Encoding.ASCII);
            str        = readStream.ReadToEnd();
            readStream.Close();
            if (strHistoryFile != "")           //Tack the response onto the end of the saved history file if one was created above.
            {
                File.AppendAllText(strHistoryFile, "\r\n\r\nCONNECTION REQUEST: postData.Length=" + postData.Length + " bytes.Length=" + bytes.Length + "==============\r\n"
                                   + " RESPONSE TO CONNECTION REQUEST================================================================\r\n" + str);
            }
            //Debug.WriteLine(str);
            //MessageBox.Show(str);
            responseParams = str.Split('&');
            for (int i = 0; i < responseParams.Length; i++)
            {
                curParam = GetParam(responseParams[i]);
                switch (curParam)
                {
                case "Status":
                    status = GetParamValue(responseParams[i]);
                    break;

                case "GROUP":
                    group = GetParamValue(responseParams[i]);
                    break;

                case "UserID":
                    userid = GetParamValue(responseParams[i]);
                    break;

                case "AuthenticationID":
                    authid = GetParamValue(responseParams[i]);
                    break;

                case "ErrorMessage":
                    errormsg = GetParamValue(responseParams[i]);
                    break;

                case "AlertMessage":
                    alertmsg = GetParamValue(responseParams[i]);
                    break;

                default:
                    throw new Exception("Unexpected parameter: " + curParam);
                }
            }
            //Process response for errors:
            if (alertmsg != "")
            {
                MessageBox.Show(alertmsg);
            }
            switch (status)
            {
            case "0":
                //MessageBox.Show("Authentication successful.");
                break;

            case "1":
                throw new Exception("Authentication failed. " + errormsg);

            case "2":
                throw new Exception("Cannot authenticate at this time. " + errormsg);

            case "3":
                throw new Exception("Invalid authentication request. " + errormsg);

            case "4":
                throw new Exception("Invalid program version. " + errormsg);

            case "5":
                throw new Exception("No customer contract. " + errormsg);

            default:                    //some as-yet-undefined error
                throw new Exception("Error " + status + ". " + errormsg);
            }
            //Step 2: Post upload request:
            //string fileName=Directory.GetFiles(clearhouse.ExportPath)[0];
            string boundary = "------------7d13e425b00d0";
            postData =
                "--" + boundary + "\r\n"
                + "Content-Disposition: form-data; name=\"Function\"\r\n"
                + "\r\n"
                + "Upload\r\n"
                + "--" + boundary + "\r\n"
                + "Content-Disposition: form-data; name=\"Source\"\r\n"
                + "\r\n"
                + "STM\r\n"
                + "--" + boundary + "\r\n"
                + "Content-Disposition: form-data; name=\"AuthenticationID\"\r\n"
                + "\r\n"
                + authid + "\r\n"
                + "--" + boundary + "\r\n"
                + "Content-Disposition: form-data; name=\"File\"; filename=\"" + "stmt.xml" + "\"\r\n"
                + "Content-Type: text/plain\r\n"
                + "\r\n"
                //using(StreamReader sr=new StreamReader(fileName)) {
                //	postData+=sr.ReadToEnd()+"\r\n"
                + data + "\r\n"
                + "--" + boundary + "--";
            //}
            //Debug.WriteLine(postData);
            //MessageBox.Show(postData);
            webReq = (HttpWebRequest)WebRequest.Create(serverName);
            //Timeout documentation: https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.timeout(v=vs.110).aspx.
            //Timeout: "Gets or sets the time-out value in milliseconds for the GetResponse and GetRequestStream methods."
            //Timeout default is 100 seconds, which should be sufficient in waiting for a reply from dentalxchange, since the reply is small.
            //ReadWriteTimeout documentation: https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.readwritetimeout%28v=vs.110%29.aspx
            //ReadWriteTimeout: "Gets or sets a time-out in milliseconds when writing to or reading from a stream."
            //ReadWriteTimeout default is 300 seconds (5 minutes).
            //Our message box that tells the user to wait up to 10 minutes for bills to send, therefore we need at least a 10 minute ReadWriteTimeout.
            //The user sees progress in the UI when sending.  We can increase timeouts as much as we want without making the program look like it crashed.
            webReq.ReadWriteTimeout = 600000;          //10 minutes = 10*60 seconds = 600 seconds = 600*1000 milliseconds = 600,000 milliseconds.
            webReq.KeepAlive        = false;
            webReq.Method           = "POST";
            webReq.ContentType      = "multipart/form-data; boundary=" + boundary;
            webReq.ContentLength    = postData.Length;
            bytes     = encoding.GetBytes(postData);
            streamOut = webReq.GetRequestStream();
            streamOut.Write(bytes, 0, bytes.Length);
            streamOut.Close();
            response = webReq.GetResponse();
            //Process the response
            readStream = new StreamReader(response.GetResponseStream(), Encoding.ASCII);
            str        = readStream.ReadToEnd();
            readStream.Close();
            if (strHistoryFile != "")           //Tack the response onto the end of the saved history file if one was created above.
            {
                File.AppendAllText(strHistoryFile, "\r\n\r\nUPLOAD REQUEST: postData.Length=" + postData.Length + " bytes.Length=" + bytes.Length + "==============\r\n"
                                   + " RESPONSE TO DATA UPLOAD================================================================\r\n" + str);
            }
            errormsg = "";
            status   = "";
            str      = str.Replace("\r\n", "");
            //Debug.Write(str);
            if (str.Length > 300)
            {
                throw new Exception("Unknown lengthy error message received.");
            }
            responseParams = str.Split('&');
            for (int i = 0; i < responseParams.Length; i++)
            {
                curParam = GetParam(responseParams[i]);
                switch (curParam)
                {
                case "Status":
                    status = GetParamValue(responseParams[i]);
                    break;

                case "Error Message":
                case "ErrorMessage":
                    errormsg = GetParamValue(responseParams[i]);
                    break;

                case "Filename":
                case "Timestamp":
                    break;

                case "":                        //errorMessage blank
                    break;

                default:
                    throw new Exception(str);                            //"Unexpected parameter: "+str);//curParam+"*");
                }
            }
            switch (status)
            {
            case "0":
                //MessageBox.Show("Upload successful.");
                break;

            case "1":
                throw new Exception("Authentication failed. " + errormsg);

            case "2":
                throw new Exception("Cannot upload at this time. " + errormsg);
            }
        }
예제 #12
0
        private void FormBillingDefaults_Load(object sender, EventArgs e)
        {
            textDays.Text                          = PrefC.GetLong(PrefName.BillingDefaultsLastDays).ToString();
            checkIntermingled.Checked              = PrefC.GetBool(PrefName.BillingDefaultsIntermingle);
            checkSinglePatient.Checked             = PrefC.GetBool(PrefName.BillingDefaultsSinglePatient);
            textNote.Text                          = PrefC.GetString(PrefName.BillingDefaultsNote);
            checkCreatePDF.Checked                 = PrefC.GetBool(PrefName.BillingElectCreatePDF);
            checkBoxBillShowTransSinceZero.Checked = PrefC.GetBool(PrefName.BillingShowTransSinceBalZero);
            listElectBilling.SelectedIndex         = 0;
            int billingUseElectronicIdx = PrefC.GetInt(PrefName.BillingUseElectronic);

            if (billingUseElectronicIdx == 1)
            {
                listElectBilling.SelectedIndex = 1;
                checkCreatePDF.Enabled         = true;
                labelBlankForDefault.Visible   = true;
            }
            if (billingUseElectronicIdx == 2)
            {
                listElectBilling.SelectedIndex = 2;
            }
            if (billingUseElectronicIdx == 3)
            {
                checkCreatePDF.Enabled         = true;
                listElectBilling.SelectedIndex = 3;
            }
            if (billingUseElectronicIdx == 4)
            {
                listElectBilling.SelectedIndex = 4;
            }
            arrayOutputPaths[0]    = "";       //Will never be used, but is helpful to keep the indexes of arrayOutputPaths aligned with the options listed in listElectBilling.
            arrayOutputPaths[1]    = PrefC.GetString(PrefName.BillingElectStmtUploadURL);
            arrayOutputPaths[2]    = PrefC.GetString(PrefName.BillingElectStmtOutputPathPos);
            arrayOutputPaths[3]    = PrefC.GetString(PrefName.BillingElectStmtOutputPathClaimX);
            arrayOutputPaths[4]    = PrefC.GetString(PrefName.BillingElectStmtOutputPathEds);
            textStatementURL.Text  = arrayOutputPaths[billingUseElectronicIdx];
            textVendorId.Text      = PrefC.GetString(PrefName.BillingElectVendorId);
            textVendorPMScode.Text = PrefC.GetString(PrefName.BillingElectVendorPMSCode);
            string cc = PrefC.GetString(PrefName.BillingElectCreditCardChoices);

            if (cc.Contains("MC"))
            {
                checkMC.Checked = true;
            }
            if (cc.Contains("V"))
            {
                checkV.Checked = true;
            }
            if (cc.Contains("D"))
            {
                checkD.Checked = true;
            }
            if (cc.Contains("A"))
            {
                checkAmEx.Checked = true;
            }
            textBillingEmailSubject.Text = PrefC.GetString(PrefName.BillingEmailSubject);
            textBillingEmailBody.Text    = PrefC.GetString(PrefName.BillingEmailBodyText);
            textInvoiceNote.Text         = PrefC.GetString(PrefName.BillingDefaultsInvoiceNote);
            _listEbills    = Ebills.GetDeepCopy();
            _listEbillsOld = _listEbills.Select(x => x.Copy()).ToList();
            //Find the default Ebill
            for (int i = 0; i < _listEbills.Count; i++)
            {
                if (_listEbills[i].ClinicNum == 0)
                {
                    _eBillDefault = _listEbills[i];
                }
            }
            if (_eBillDefault == null)
            {
                MsgBox.Show(this, "The default ebill entry is missing. Run " + nameof(DatabaseMaintenances.EbillMissingDefaultEntry)
                            + " in the Database Maintenance Tool before continuing.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            _eBillCur = _eBillDefault;
            //Set the textboxes to default values.
            textClientAcctNumber.Text = _eBillDefault.ClientAcctNumber;
            textUserName.Text         = _eBillDefault.ElectUserName;
            textPassword.Text         = _eBillDefault.ElectPassword;
            string[] arrayEbillAddressEnums = Enum.GetNames(typeof(EbillAddress));
            for (int i = 0; i < arrayEbillAddressEnums.Length; i++)
            {
                comboPracticeAddr.Items.Add(arrayEbillAddressEnums[i]);
                comboRemitAddr.Items.Add(arrayEbillAddressEnums[i]);
                //If clinics are off don't add the Clinic specific EbillAddress enums
                if (!PrefC.HasClinicsEnabled && i == 2)
                {
                    break;
                }
            }
            if (PrefC.HasClinicsEnabled)
            {
                comboClinic.Visible = true;
                labelClinic.Visible = true;
                //Bold clinic specific fields.
                groupBoxBilling.Text   = Lan.g(this, "Electronic Billing - Bolded fields are clinic specific");
                labelAcctNum.Font      = new Font(labelAcctNum.Font, FontStyle.Bold);
                labelUserName.Font     = new Font(labelUserName.Font, FontStyle.Bold);
                labelPassword.Font     = new Font(labelPassword.Font, FontStyle.Bold);
                labelClinic.Font       = new Font(labelClinic.Font, FontStyle.Bold);
                labelPracticeAddr.Font = new Font(labelPracticeAddr.Font, FontStyle.Bold);
                labelRemitAddr.Font    = new Font(labelRemitAddr.Font, FontStyle.Bold);
                comboClinic.Items.Clear();
                _listClinics = new List <Clinic>();
                //Add "Unassigned/Default" option if the user isn't restricted or the selected clinic is 0.
                if (!Security.CurUser.ClinicIsRestricted || Clinics.ClinicNum == 0)
                {
                    Clinic clinicUnassigned = new Clinic();
                    clinicUnassigned.ClinicNum = 0;
                    clinicUnassigned.Abbr      = Lan.g(this, "Unassigned/Default");
                    _listClinics.Add(clinicUnassigned);
                }
                _listClinics.AddRange(Clinics.GetForUserod(Security.CurUser));
                for (int i = 0; i < _listClinics.Count; i++)
                {
                    comboClinic.Items.Add(_listClinics[i].Abbr);
                    //If the clinic we're adding is the one currently selected in OD, attempt to find its Ebill entry.
                    if (_listClinics[i].ClinicNum == Clinics.ClinicNum)
                    {
                        comboClinic.SelectedIndex = i;
                        Ebill eBill = null;
                        if (Clinics.ClinicNum == 0)                       //Use the default Ebill if OD has Headquarters selected or if clinics are disabled.
                        {
                            eBill = _eBillDefault;
                        }
                        else
                        {
                            eBill = _listEbills.FirstOrDefault(x => x.ClinicNum == _listClinics[i].ClinicNum);                        //Can be null.
                        }
                        //_eBillCur will be the default Ebill, the clinic's Ebill, or null if there are no existing ebills for OD's selected clinic.
                        _eBillCur = eBill;
                    }
                }
            }
            listModesToText.Items.Clear();
            foreach (StatementMode stateMode in Enum.GetValues(typeof(StatementMode)))
            {
                listModesToText.Items.Add(new ODBoxItem <StatementMode>(Lan.g("enumStatementMode", stateMode.GetDescription()), stateMode));
            }
            foreach (string modeIdx in PrefC.GetString(PrefName.BillingDefaultsModesToText)
                     .Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
            {
                listModesToText.SetSelected(PIn.Int(modeIdx), true);
            }
            textSmsTemplate.Text = PrefC.GetString(PrefName.BillingDefaultsSmsTemplate);
            //Load _eBillCur's fields into the UI.
            LoadEbill(_eBillCur);
        }
예제 #13
0
 ///<summary>eBill can be null, creates Ebill if needed.</summary>
 private void LoadEbill(Ebill eBill)
 {
     if (eBill == null)           //Matching Ebill entry not found.  Make a new entry with default values.
     {
         eBill                  = new Ebill();
         eBill.ClinicNum        = _listClinics[comboClinic.SelectedIndex].ClinicNum;
         eBill.ClientAcctNumber = "";
         eBill.ElectUserName    = "";
         eBill.ElectPassword    = "";
         eBill.PracticeAddress  = EbillAddress.PracticePhysical;
         eBill.RemitAddress     = EbillAddress.PracticeBilling;
         _listEbills.Add(eBill);
     }
     textClientAcctNumber.Text = _eBillDefault.ClientAcctNumber;
     if (eBill.ClientAcctNumber != "")           //If the Ebill field is blank use default value.
     {
         textClientAcctNumber.Text = eBill.ClientAcctNumber;
     }
     textUserName.Text = _eBillDefault.ElectUserName;
     if (eBill.ElectUserName != "")           //If the Ebill field is blank use default value.
     {
         textUserName.Text = eBill.ElectUserName;
     }
     textPassword.Text = _eBillDefault.ElectPassword;
     if (eBill.ElectPassword != "")           //If the Ebill field is blank use default value.
     {
         textPassword.Text = eBill.ElectPassword;
     }
     //If clinics are disabled and the eBill had a clinic specific enum, set it to default value.  May happen if clinics were previously enabled.
     if (PrefC.HasClinicsEnabled)
     {
         comboPracticeAddr.SelectedIndex = (int)eBill.PracticeAddress;
         comboRemitAddr.SelectedIndex    = (int)eBill.RemitAddress;
     }
     else              //No clinics
     {
         if (eBill.PracticeAddress == EbillAddress.ClinicPhysical)
         {
             comboPracticeAddr.SelectedIndex = 0;                  //PracticePhysical
         }
         else if (eBill.PracticeAddress == EbillAddress.ClinicBilling)
         {
             comboPracticeAddr.SelectedIndex = 1;                  //PracticeBilling
         }
         else if (eBill.PracticeAddress == EbillAddress.ClinicPayTo)
         {
             comboPracticeAddr.SelectedIndex = 2;                  //PracticePayTo
         }
         else
         {
             comboPracticeAddr.SelectedIndex = (int)eBill.PracticeAddress;
         }
         if (eBill.RemitAddress == EbillAddress.ClinicPhysical)
         {
             comboRemitAddr.SelectedIndex = 0;                  //PracticePhysical
         }
         else if (eBill.RemitAddress == EbillAddress.ClinicBilling)
         {
             comboRemitAddr.SelectedIndex = 1;                  //PracticeBilling
         }
         else if (eBill.RemitAddress == EbillAddress.ClinicPayTo)
         {
             comboRemitAddr.SelectedIndex = 2;                  //PracticePayTo
         }
         else
         {
             comboRemitAddr.SelectedIndex = (int)eBill.RemitAddress;
         }
     }
     _eBillCur = eBill;
     if (IsUserPassOnly)
     {
         Controls.OfType <Control>().ToList().ForEach(x => x.Enabled = false);
         groupBoxBilling.Enabled = true;
         butOK.Enabled           = true;
         butCancel.Enabled       = true;
         this.Text = Lan.g(this, "Billing Defaults") + " - {" + Lan.g(this, "Limited") + "}";
     }
 }
예제 #14
0
        ///<summary>Updates one Ebill in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(Ebill ebill, Ebill oldEbill)
        {
            string command = "";

            if (ebill.ClinicNum != oldEbill.ClinicNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ClinicNum = " + POut.Long(ebill.ClinicNum) + "";
            }
            if (ebill.ClientAcctNumber != oldEbill.ClientAcctNumber)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ClientAcctNumber = '" + POut.String(ebill.ClientAcctNumber) + "'";
            }
            if (ebill.ElectUserName != oldEbill.ElectUserName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ElectUserName = '******'";
            }
            if (ebill.ElectPassword != oldEbill.ElectPassword)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ElectPassword = '******'";
            }
            if (ebill.PracticeAddress != oldEbill.PracticeAddress)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PracticeAddress = " + POut.Int((int)ebill.PracticeAddress) + "";
            }
            if (ebill.RemitAddress != oldEbill.RemitAddress)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "RemitAddress = " + POut.Int((int)ebill.RemitAddress) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE ebill SET " + command
                      + " WHERE EbillNum = " + POut.Long(ebill.EbillNum);
            Db.NonQ(command);
            return(true);
        }
예제 #15
0
 ///<summary>Inserts one Ebill into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(Ebill ebill)
 {
     return(InsertNoCache(ebill, false));
 }
예제 #16
0
 ///<summary>Inserts one Ebill into the database.  Returns the new priKey.</summary>
 public static long Insert(Ebill ebill)
 {
     return(Insert(ebill, false));
 }