///<summary>Replaces variable tags with the information from the patient passed in.</summary> public static string ReplaceVarsForSms(string smsTemplate, Patient pat, Statement stmt) { //No need to check RemotingRole; no call to db. StringBuilder retVal = new StringBuilder(); retVal.Append(smsTemplate); if (smsTemplate.Contains("[monthlyCardsOnFile]")) { retVal.RegReplace("\\[monthlyCardsOnFile]", CreditCards.GetMonthlyCardsOnFile(pat.PatNum)); } retVal.RegReplace("\\[nameF]", pat.GetNameFirst()); retVal.RegReplace("\\[namePref]", pat.Preferred); retVal.RegReplace("\\[PatNum]", pat.PatNum.ToString()); retVal.RegReplace("\\[currentMonth]", DateTime.Now.ToString("MMMM")); Clinic clinic = Clinics.GetClinic(pat.ClinicNum) ?? Clinics.GetPracticeAsClinicZero(); string officePhone = clinic.Phone; if (string.IsNullOrEmpty(officePhone)) { officePhone = PrefC.GetString(PrefName.PracticePhone); } retVal.RegReplace("\\[OfficePhone]", TelephoneNumbers.ReFormat(officePhone)); string officeName = clinic.Description; if (string.IsNullOrEmpty(officeName)) { officeName = PrefC.GetString(PrefName.PracticeTitle); } retVal.RegReplace("\\[OfficeName]", officeName); retVal.RegReplace("\\[StatementURL]", stmt.StatementURL); retVal.RegReplace("\\[StatementShortURL]", stmt.StatementShortURL); return(retVal.ToString()); }
///<summary>Returns a blank string if there were no errors while attempting to update internal carriers using iTrans n-cpl.json file..</summary> public static string TryCarrierUpdate(bool isAutomatic = true, ItransImportFields fieldsToImport = ItransImportFields.None) { Clearinghouse clearinghouse = Clearinghouses.GetDefaultDental(); if (clearinghouse.CommBridge != EclaimsCommBridge.ITRANS || string.IsNullOrEmpty(clearinghouse.ResponsePath) || !File.Exists(ODFileUtils.CombinePaths(clearinghouse.ResponsePath, "ITRANS Claims Director.exe")) || (isAutomatic && PrefC.GetString(PrefName.WebServiceServerName).ToLower() != Dns.GetHostName().ToLower())) //Only server can run when isOnlyServer is true. { return(Lans.g("Clearinghouse", "ITRANS must be the default dental clearinghouse and your Report Path must be set first.")); } Process process = new Process { StartInfo = new ProcessStartInfo { FileName = ODFileUtils.CombinePaths(clearinghouse.ResponsePath, "ITRANS Claims Director.exe"), Arguments = " --getncpl" } }; process.Start(); process.WaitForExit(); string ncplFilePath = ODFileUtils.CombinePaths(clearinghouse.ResponsePath, "n-cpl.json"); string json = File.ReadAllText(ncplFilePath);//Read n-cpl.json EtransMessageText msgTextPrev = EtransMessageTexts.GetMostRecentForType(EtransType.ItransNcpl); if (msgTextPrev != null && msgTextPrev.MessageText == json) { return(Lans.g("Clearinghouse", "Carrier list has not changed since last checked.")); //json has not changed since we last checked, no need to update. } //Save json as new etrans entry. Etrans etrans = Etranss.CreateEtrans(File.GetCreationTime(ncplFilePath), clearinghouse.HqClearinghouseNum, json, 0); etrans.Etype = EtransType.ItransNcpl; Etranss.Insert(etrans); ItransNCpl iTransNCpl = null; try { iTransNCpl = JsonConvert.DeserializeObject <ItransNCpl>(json); //Deserialize n-cpl.json } catch (Exception ex) { ex.DoNothing(); return(Lans.g("Clearinghouse", "Failed to import json.")); } foreach (ItransNCpl.Carrier jsonCarrier in iTransNCpl.ListCarriers) //Update providers. { OpenDentBusiness.Carrier odCarrier = Carriers.GetByElectId(jsonCarrier.Bin); //Cached if (odCarrier == null) //Carrier can not be matched to internal Carrier based on ElectID. { if (!fieldsToImport.HasFlag(ItransImportFields.AddMissing)) { continue; } OpenDentBusiness.Carrier carrierNew = new OpenDentBusiness.Carrier(); carrierNew.ElectID = jsonCarrier.Bin; carrierNew.IsCDA = true; carrierNew.CarrierName = jsonCarrier.Name.En; carrierNew.Phone = TelephoneNumbers.ReFormat(jsonCarrier.Telephone?.First().Value); if (jsonCarrier.Address.Count() > 0) { Address add = jsonCarrier.Address.First(); carrierNew.Address = add.Street1; carrierNew.Address2 = add.Street2; carrierNew.City = add.City; carrierNew.State = add.Province; carrierNew.Zip = add.PostalCode; } carrierNew.CanadianSupportedTypes = GetSupportedTypes(jsonCarrier); carrierNew.CarrierName = jsonCarrier.Name.En; try { Carriers.Insert(carrierNew); } catch (Exception ex) { ex.DoNothing(); } continue; } else if (!odCarrier.IsCDA) { continue; } OpenDentBusiness.Carrier odCarrierOld = odCarrier.Copy(); odCarrier.CanadianSupportedTypes = GetSupportedTypes(jsonCarrier); odCarrier.CDAnetVersion = POut.Int(jsonCarrier.Versions.Max(x => PIn.Int(x))); List <ItransImportFields> listFields = Enum.GetValues(typeof(ItransImportFields)).Cast <ItransImportFields>().ToList(); foreach (ItransImportFields field in listFields) { if (fieldsToImport == ItransImportFields.None) { break; //No point in looping. } if (field == ItransImportFields.None || !fieldsToImport.HasFlag(field)) { continue; } switch (field) { case ItransImportFields.Phone: if (jsonCarrier.Telephone.Count > 0) { odCarrier.Phone = TelephoneNumbers.ReFormat(jsonCarrier.Telephone.First().Value); } break; case ItransImportFields.Address: if (jsonCarrier.Address.Count() > 0) { Address add = jsonCarrier.Address.First(); odCarrier.Address = add.Street1; odCarrier.Address2 = add.Street2; odCarrier.City = add.City; odCarrier.State = add.Province; odCarrier.Zip = add.PostalCode; } break; case ItransImportFields.Name: odCarrier.CarrierName = jsonCarrier.Name.En; break; } } try { long userNum = 0; if (!isAutomatic) { userNum = Security.CurUser.UserNum; } Carriers.Update(odCarrier, odCarrierOld, userNum); } catch (Exception ex) { ex.DoNothing(); } } return(""); //Blank string represents a completed update. }