public static void CategoryStatusManipulation() { ApplicationdbContect _db = new ApplicationdbContect(); var categorystatus = _db.CategoriesStatuses.Where(p => p.BillingCategoryId == BillingCodeHelper.G0506BillingCatagoryid).ToList(); var duplicatelist = categorystatus.GroupBy(p => p.PatientId).Where(p => p.Count() > 1).Select(p => p.ToList().OrderBy(x => x.PatientId)); var duplicatecount = duplicatelist.Count(); foreach (var item in duplicatelist) { if (item.Where(p => p.Status == "Claims Submission").Count() > 0) { var claim = item.Where(p => p.Status == "Claims Submission").FirstOrDefault(); claim.Cycle = 1; _db.Entry(claim).State = EntityState.Modified; _db.SaveChanges(); var removelist = _db.CategoriesStatuses.Where(p => p.PatientId == claim.PatientId && p.Id != claim.Id).ToList(); _db.CategoriesStatuses.RemoveRange(removelist); _db.SaveChanges(); } else { if (item.Where(p => p.Status == "Clinical Sign-Off").Count() > 0) { var clinical = item.Where(p => p.Status == "Clinical Sign-Off").FirstOrDefault(); clinical.Cycle = 1; _db.Entry(clinical).State = EntityState.Modified; _db.SaveChanges(); var removelist = _db.CategoriesStatuses.Where(p => p.PatientId == clinical.PatientId && p.Id != clinical.Id).ToList(); _db.CategoriesStatuses.RemoveRange(removelist); _db.SaveChanges(); } else { if (item.Where(p => p.Status == "Enrolled").Count() > 0) { var des = item.OrderByDescending(p => p.UpdatedOn == null ? p.CreatedOn : p.UpdatedOn); var Enrolled = des.Where(p => p.Status == "Enrolled").FirstOrDefault(); if (Enrolled != null) { Enrolled.Cycle = 1; _db.Entry(Enrolled).State = EntityState.Modified; _db.SaveChanges(); var removelist = _db.CategoriesStatuses.Where(p => p.PatientId == Enrolled.PatientId && p.Id != Enrolled.Id).ToList(); _db.CategoriesStatuses.RemoveRange(removelist); _db.SaveChanges(); } } } } } }
public static string GetPatientNewOrOldCycleStatusbyCategory(int patientid, int billingCategoryId, int?cycle, bool UpdatePatientCycle = false) { using (ApplicationdbContect _db = new ApplicationdbContect()) { if (cycle != null && UpdatePatientCycle) { var patient = _db.Patients.Where(x => x.Id == patientid).FirstOrDefault(); patient.Cycle = cycle.GetInteger(); _db.Entry(patient).State = EntityState.Modified; _db.SaveChanges(); } if (billingCategoryId == BillingCodeHelper.cmmBillingCatagoryid) { bool res = UpdatePatientReviewTimeCycleByCategory(patientid, billingCategoryId, cycle); bool res1 = UpdatePatientFinalCarePlaneCycleByCategory(patientid, billingCategoryId, cycle); return(GetCCMCycleStatus(patientid, cycle)); } else { bool res = UpdatePatientReviewTimeCycleByCategory(patientid, billingCategoryId, cycle); return(GetothereCategoryCycleStatus(patientid, billingCategoryId, cycle)); } } }
private static bool UpdatePatientReviewTimeCycleByCategory(int patientid, int billingCategoryId, int?cycle) { using (var _db = new ApplicationdbContect()) { if (cycle == null) { var patient = _db.Patients.Where(x => x.Id == patientid).AsNoTracking().FirstOrDefault(); if (patient != null) { cycle = patient.Cycle; } } if (cycle > 0) { var reviewtimeccms = _db.ReviewTimeCcms.Where(x => x.PatientId == patientid && x.BillingcategoryId == billingCategoryId).ToList().Where(x => x.StartTime.Month == DateTime.Now.Month && x.StartTime.Year == DateTime.Now.Year).ToList(); foreach (var item in reviewtimeccms) { if (item.Cycle != cycle.GetInteger()) { item.Cycle = cycle.GetInteger(); _db.Entry(item).State = EntityState.Modified; _db.SaveChanges(); } } return(true); } return(false); } }
private static bool UpdatePatientFinalCarePlaneCycleByCategory(int patientid, int billingCategoryId, int?cycle) { using (var _db = new ApplicationdbContect()) { if (cycle == null) { var patient = _db.Patients.Where(x => x.Id == patientid).AsNoTracking().FirstOrDefault(); if (patient != null) { cycle = patient.Cycle; } } if (cycle > 0) { var finalcareplans = _db.FinalCarePlanNotes.Where(x => x.PatientId == patientid).ToList().Where(x => x.CarePlanCreatedOn.Value.Month == DateTime.Now.Month && x.CarePlanCreatedOn.Value.Year == DateTime.Now.Year && x.CarePlanCreatedOn != null).ToList(); foreach (var item in finalcareplans) { if (item.Cycle != cycle.GetInteger()) { item.Cycle = cycle.GetInteger(); _db.Entry(item).State = EntityState.Modified; _db.SaveChanges(); } } return(true); } return(false); } }
private static void UpdateData() { List <Liaison> liaisons = new List <Liaison>(); using (var _db = new ApplicationdbContect(Properties.Settings.Default.ConnectionString)) { liaisons = _db.Liaisons.Where(x => x.TwilioNumbersTableId != null).ToList(); foreach (var i in liaisons) { TwilioClient.Init(Properties.Settings.Default.TwilioAccountSid, Properties.Settings.Default.TwilioAuthToken); //var availablePhoneNumberCountry = AvailablePhoneNumberCountryResource.Fetch( // pathCountryCode: "US" // ); //Console.WriteLine(); #region Check Phone Number info friendly name etc var type = new List <string> { "carrier" }; var phoneNumber = PhoneNumberResource.Fetch( type: type, pathPhoneNumber: new Twilio.Types.PhoneNumber(i.TwilioCallerId) ); Console.WriteLine(phoneNumber.Carrier); Console.WriteLine(phoneNumber.NationalFormat); Console.WriteLine(phoneNumber.PhoneNumber); #endregion #region Map existing number in twilio table if (phoneNumber != null) { TwilioNumbersTable tn = new TwilioNumbersTable(); tn.FriendlyPhoneNumer = phoneNumber.NationalFormat; tn.MobilePhoneNumber = phoneNumber.PhoneNumber.ToString(); tn.Status = true; tn.CreatedOn = DateTime.Now; tn.CreatedBy = "bcbfb545-1d9e-40a5-b823-3616c5fc4050"; _db.TwilioNumbersTable.Add(tn); _db.SaveChanges(); i.TwilioNumbersTableId = tn.Id; i.UpdatedBy = "bcbfb545-1d9e-40a5-b823-3616c5fc4050"; i.UpdatedOn = DateTime.Now; _db.Entry(i).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } #endregion } } }
private static object GetUpdateRPMCycleStatus(int patientId, int Cycle, string Userid, string EnrollmentSubStatus) { using (ApplicationdbContect Db = new ApplicationdbContect()) { try { if (Cycle > 0)//means patient is enrolled in any billing category { var reviewtimeccms = Db.ReviewTimeCcms.Where(x => x.PatientId == patientId && x.BillingcategoryId == BillingCodeHelper.RPMBillingCatagoryid).ToList().Where(x => x.StartTime.Month == DateTime.Now.Month && x.StartTime.Year == DateTime.Now.Year).ToList(); foreach (var item in reviewtimeccms) { if (item.Cycle != Cycle) { item.Cycle = Cycle; Db.Entry(item).State = EntityState.Modified; Db.SaveChanges(); } } //var finalcareplans = Db.FinalCarePlanNotes.Where(x => x.PatientId == patientId).ToList().Where(x => x.CarePlanCreatedOn.Value.Month == DateTime.Now.Month && x.CarePlanCreatedOn.Value.Year == DateTime.Now.Year && x.CarePlanCreatedOn != null).ToList(); //foreach (var item in finalcareplans) //{ // if (item.Cycle != Cycle) // { // item.Cycle = Cycle; // Db.Entry(item).State = EntityState.Modified; // Db.SaveChanges(); // } //} } } catch (Exception ex) { } var RMPCyclesStatus = Db.CategoriesStatuses.Where(x => x.PatientId == patientId && x.Cycle == Cycle && x.BillingCategoryId == BillingCodeHelper.RPMBillingCatagoryid).FirstOrDefault(); if (RMPCyclesStatus == null) { CategoriesStatuses rpmStatuses = new CategoriesStatuses(); rpmStatuses.PatientId = patientId; rpmStatuses.Cycle = Cycle; rpmStatuses.RejectedCount = 0; if (Cycle == 0) { rpmStatuses.Status = "In Progress"; rpmStatuses.SubStatus = ""; } else { rpmStatuses.Status = "Enrolled"; rpmStatuses.SubStatus = ""; } if (EnrollmentSubStatus != "") { if (EnrollmentSubStatus != "Active Enrolled" && Cycle > 0) { rpmStatuses.Status = "Expired"; rpmStatuses.SubStatus = ""; } } rpmStatuses.CreatedBy = Userid; rpmStatuses.CreatedOn = DateTime.Now; Db.CategoriesStatuses.Add(rpmStatuses); Db.SaveChanges(); return(rpmStatuses.Status); } else { if (EnrollmentSubStatus != "") { if (EnrollmentSubStatus == "Active Enrolled") { if (RMPCyclesStatus.Status != "Claims Submission" && RMPCyclesStatus.Status != "Clinical Sign-Off" && RMPCyclesStatus.Status != "Ready for Clinical Sign-Off" /*&& RMPCyclesStatus.Status != "In Progress"*/) { RMPCyclesStatus.Status = "Enrolled"; RMPCyclesStatus.UpdatedOn = DateTime.Now; RMPCyclesStatus.UpdatedBy = ""; Db.Entry(RMPCyclesStatus).State = EntityState.Modified; Db.SaveChanges(); return("Enrolled"); } } else { if (RMPCyclesStatus.Status != "Claims Submission" && RMPCyclesStatus.Status != "Clinical Sign-Off" && RMPCyclesStatus.Status != "Ready for Clinical Sign-Off" /*&& RMPCyclesStatus.Status != "In Progress"*/) { RMPCyclesStatus.Status = "Expired"; RMPCyclesStatus.UpdatedOn = DateTime.Now; RMPCyclesStatus.UpdatedBy = ""; Db.Entry(RMPCyclesStatus).State = EntityState.Modified; Db.SaveChanges(); return("Expired"); } } var previouscycles = Db.CategoriesStatuses.Where(x => x.PatientId == patientId && x.BillingCategoryId == BillingCodeHelper.RPMBillingCatagoryid && x.Cycle < Cycle && x.Status != "Claims Submission" && x.Status != "Clinical Sign-Off" && x.Status != "Ready for Clinical Sign-Off" /*&& x.Status != "In Progress"*/).ToList(); foreach (var item in previouscycles) { if (item.Status == "Enrolled") { item.Status = "Expired"; item.UpdatedOn = DateTime.Now; item.UpdatedBy = ""; Db.Entry(item).State = EntityState.Modified; Db.SaveChanges(); } } } else { var patientData = Db.Patients.Where(x => x.Id == patientId).FirstOrDefault(); if (patientData.EnrollmentSubStatus == "Active Enrolled") { if (RMPCyclesStatus.Status != "Claims Submission" && RMPCyclesStatus.Status != "Clinical Sign-Off" && RMPCyclesStatus.Status != "Ready for Clinical Sign-Off" /*&& RMPCyclesStatus.Status != "In Progress"*/) { RMPCyclesStatus.Status = "Enrolled"; RMPCyclesStatus.UpdatedOn = DateTime.Now; RMPCyclesStatus.UpdatedBy = ""; Db.Entry(RMPCyclesStatus).State = EntityState.Modified; Db.SaveChanges(); return("Enrolled"); } } else { if (RMPCyclesStatus.Status != "Claims Submission" && RMPCyclesStatus.Status != "Clinical Sign-Off" && RMPCyclesStatus.Status != "Ready for Clinical Sign-Off" /*&& RMPCyclesStatus.Status != "In Progress"*/) { RMPCyclesStatus.Status = "Expired"; RMPCyclesStatus.UpdatedOn = DateTime.Now; RMPCyclesStatus.UpdatedBy = ""; Db.Entry(RMPCyclesStatus).State = EntityState.Modified; Db.SaveChanges(); return("Expired"); } } //var previouscycles = Db.CategoriesStatuses.Where(x => x.PatientId == patientId && x.Cycle < Cycle && x.Status != "Claims Submission" && x.Status != "Clinical Sign-Off" && x.CCMStatus != "Ready for Clinical Sign-Off" && x.CCMStatus != "In Progress").ToList(); //foreach (var item in previouscycles) //{ // if (item.CCMStatus == "Enrolled") // { // item.CCMStatus = "Expired"; // item.UpdatedOn = DateTime.Now; // item.UpdatedBy = ""; // Db.Entry(item).State = EntityState.Modified; // Db.SaveChanges(); // } //} } return(RMPCyclesStatus.Status); } } }
public async System.Threading.Tasks.Task SaveRecordings() { var recordingurl = Request["RecordingUrl"]; var callsid = Request["CallSid"]; var callfrom = Request["From"]; var recordingsid = Request["RecordingSid"]; var fromcode = Request["CallerCountry"]; var tocode = Request["ToCountry"]; try { TwilioClient.Init(ConfigurationManager.AppSettings["TwilioAccountSid"], ConfigurationManager.AppSettings["TwilioAuthToken"]); var calls = await CallResource.ReadAsync(parentCallSid : (callsid)); if (calls.Any()) { int?patientid = 0; foreach (var call in calls) { var callHistory = _db.CallHistories.Where(x => x.TwilioCallId == call.ParentCallSid).FirstOrDefault(); if (callHistory != null) { try { callHistory.From = callHistory.From.Replace("+1", ""); patientid = _db.Patients.AsNoTracking().Where(x => (x.MobilePhoneNumber != null && x.MobilePhoneNumber.Replace("", "").Contains(callHistory.From)) || (x.WorkPhoneNumber != null && x.WorkPhoneNumber.Replace(" ", "").Contains(callHistory.From)) || (x.EmergencyNumber != null && x.EmergencyNumber.Replace(" ", "").Contains(callHistory.From)) || (x.HomePhoneNumber != null && x.HomePhoneNumber.Replace(" ", "").Contains(callHistory.From)) || (x.CaretakerPhoneNumber != null && x.CaretakerPhoneNumber.Replace(" ", "").Contains(callHistory.From))).FirstOrDefault()?.Id; if (patientid == null) { patientid = _db.PatientProfile_Contact.AsNoTracking().Where(x => (x.CellPhoneNumber != null && x.CellPhoneNumber.Replace(" ", "").Contains(callHistory.From)) || (x.CellPhoneNumber1 != null && x.CellPhoneNumber1.Replace(" ", "").Contains(callHistory.From)) || (x.CellPhoneNumber2 != null && x.CellPhoneNumber2.Replace(" ", "").Contains(callHistory.From)) || (x.EmergencyNumber != null && x.EmergencyNumber.Replace(" ", "").Contains(callHistory.From)) || (x.EmergencyNumber1 != null && x.EmergencyNumber1.Replace(" ", "").Contains(callHistory.From)) || (x.EmergencyNumber2 != null && x.EmergencyNumber2.Replace(" ", "").Contains(callHistory.From)) || (x.HomePhoneNumber != null && x.HomePhoneNumber.Replace(" ", "").Contains(callHistory.From)) || (x.HomePhoneNumber1 != null && x.HomePhoneNumber1.Replace(" ", "").Contains(callHistory.From)) || (x.HomePhoneNumber2 != null && x.HomePhoneNumber2.Replace(" ", "").Contains(callHistory.From)) || (x.WorkPhoneNumber != null && x.WorkPhoneNumber.Replace(" ", "").Contains(callHistory.From)) || (x.WorkPhoneNumber1 != null && x.WorkPhoneNumber1.Replace(" ", "").Contains(callHistory.From)) || (x.WorkPhoneNumber2 != null && x.WorkPhoneNumber2.Replace(" ", "").Contains(callHistory.From))).FirstOrDefault()?.PatientId; if (patientid == null) { patientid = _db.PatientProfile_UrgencyContacts.AsNoTracking().Where(x => (x.PrimaryHomePhoneNumber != null && x.PrimaryHomePhoneNumber.Replace(" ", "").Contains(callHistory.From)) || (x.PrimaryHomePhoneNumber1 != null && x.PrimaryHomePhoneNumber1.Replace(" ", "").Contains(callHistory.From)) || (x.PrimaryHomePhoneNumber2 != null && x.PrimaryHomePhoneNumber2.Replace(" ", "").Contains(callHistory.From)) || (x.PrimaryMobilePhoneNumber != null && x.PrimaryMobilePhoneNumber.Replace(" ", "").Contains(callHistory.From)) || (x.PrimaryMobilePhoneNumber1 != null && x.PrimaryMobilePhoneNumber1.Replace(" ", "").Contains(callHistory.From)) || (x.PrimaryMobilePhoneNumber2 != null && x.PrimaryMobilePhoneNumber2.Replace(" ", "").Contains(callHistory.From)) || (x.SecondaryHomePhoneNumber != null && x.SecondaryHomePhoneNumber.Replace(" ", "").Contains(callHistory.From)) || (x.SecondaryHomePhoneNumber1 != null && x.SecondaryHomePhoneNumber1.Replace(" ", "").Contains(callHistory.From)) || (x.SecondaryHomePhoneNumber2 != null && x.SecondaryHomePhoneNumber2.Replace(" ", "").Contains(callHistory.From)) || (x.SecondaryMobilePhoneNumber != null && x.SecondaryMobilePhoneNumber.Replace(" ", "").Contains(callHistory.From)) || (x.SecondaryMobilePhoneNumber1 != null && x.SecondaryMobilePhoneNumber1.Replace(" ", "").Contains(callHistory.From)) || (x.SecondaryMobilePhoneNumber2 != null && x.SecondaryMobilePhoneNumber2.Replace(" ", "").Contains(callHistory.From))).FirstOrDefault()?.PatientId; if (patientid == null) { patientid = _db.CallHistories.AsNoTracking().Where(x => x.To.Replace(" ", "").Contains(callHistory.From)).FirstOrDefault()?.PatientID; } } } if (patientid == null) { patientid = 0; } } catch (Exception ex) { WriteErrorLog(ex); } callHistory.StartTime = call?.StartTime; callHistory.EndTime = call?.EndTime; callHistory.Status = call?.Status.ToString(); callHistory.Duration = call?.StartTime != null && call.EndTime != null ? (TimeSpan)(call.EndTime - call.StartTime) : TimeSpan.Zero; callHistory.PatientID = callHistory.PatientID > 0 ? callHistory.PatientID : patientid.Value; } ; //var recordings = await RecordingResource.ReadAsync(callSid: call?.ParentCallSid); //if (recordings.Any()) //{ // foreach (var recording in recordings) // callHistory.RecordingURL = recording?.Uri; // var src = callHistory.RecordingURL.Substring(0, callHistory.RecordingURL.IndexOf('.')); // var fullSource = "https://api.twilio.com" + src + ".mp3"; // WebClient webClient = new WebClient(); // string physicalPath = Server.MapPath("~/Recordings/" + callHistory.TwilioCallId + ".mp3"); // webClient.DownloadFile(fullSource, physicalPath); //} try { callHistory.RecordingURL = recordingurl; var src = recordingurl; var fullSource = src + ".mp3"; WebClient webClient = new WebClient(); string physicalPath = Server.MapPath("~/Recordings/" + callHistory.TwilioCallId + ".mp3"); webClient.DownloadFile(fullSource, physicalPath); } catch (Exception ex) { WriteErrorLog(ex); } _db.Entry(callHistory).State = EntityState.Modified; _db.SaveChanges(); } } } catch (Exception ex) { WriteErrorLog(ex); } }
private static string GetCCMCycleStatus(int patientId, int?cycle) { using (var _db = new ApplicationdbContect()) { var patient = _db.Patients.Where(x => x.Id == patientId).AsNoTracking().FirstOrDefault(); if (cycle == null) { if (patient != null) { cycle = patient.Cycle; } } int Cycle = cycle.GetInteger(); var CCMCycleStatus = _db.CCMCycleStatuses.Where(x => x.PatientId == patientId && x.Cycle == Cycle).FirstOrDefault(); if (CCMCycleStatus == null) { CCMCycleStatus cCMCycleStatus = new CCMCycleStatus(); cCMCycleStatus.PatientId = patientId; cCMCycleStatus.Cycle = Cycle; cCMCycleStatus.RejectedCount = 0; if (Cycle == 0) { cCMCycleStatus.CCMStatus = "In Progress"; cCMCycleStatus.CCMSubStatus = ""; } else { cCMCycleStatus.CCMStatus = "Enrolled"; cCMCycleStatus.CCMSubStatus = ""; } if (!string.IsNullOrEmpty(patient.EnrollmentSubStatus)) { if (patient.EnrollmentSubStatus != "Active Enrolled" && Cycle > 0) { cCMCycleStatus.CCMStatus = "Expired"; cCMCycleStatus.CCMSubStatus = ""; } } cCMCycleStatus.CreatedBy = User.Identity.GetUserId(); cCMCycleStatus.CreatedOn = DateTime.Now; _db.CCMCycleStatuses.Add(cCMCycleStatus); _db.SaveChanges(); return(cCMCycleStatus.CCMStatus); } else { if (!string.IsNullOrEmpty(patient.EnrollmentSubStatus)) { if (patient.EnrollmentSubStatus == "Active Enrolled") { if (CCMCycleStatus.CCMStatus != "Claims Submission" && CCMCycleStatus.CCMStatus != "Clinical Sign-Off" && CCMCycleStatus.CCMStatus != "Ready for Clinical Sign-Off" /*&& CCMCycleStatus.CCMStatus != "In Progress"*/) { CCMCycleStatus.CCMStatus = "Enrolled"; CCMCycleStatus.UpdatedOn = DateTime.Now; CCMCycleStatus.UpdatedBy = ""; _db.Entry(CCMCycleStatus).State = EntityState.Modified; _db.SaveChanges(); return("Enrolled"); } } else { if (CCMCycleStatus.CCMStatus != "Claims Submission" && CCMCycleStatus.CCMStatus != "Clinical Sign-Off" && CCMCycleStatus.CCMStatus != "Ready for Clinical Sign-Off" && CCMCycleStatus.CCMStatus != "In Progress") { CCMCycleStatus.CCMStatus = "Expired"; CCMCycleStatus.UpdatedOn = DateTime.Now; CCMCycleStatus.UpdatedBy = ""; _db.Entry(CCMCycleStatus).State = EntityState.Modified; _db.SaveChanges(); return("Expired"); } } var previouscycles = _db.CCMCycleStatuses.Where(x => x.PatientId == patientId && x.Cycle < Cycle && x.CCMStatus != "Claims Submission" && x.CCMStatus != "Clinical Sign-Off" && x.CCMStatus != "Ready for Clinical Sign-Off" && x.CCMStatus != "In Progress").ToList(); foreach (var item in previouscycles) { if (item.CCMStatus == "Enrolled") { item.CCMStatus = "Expired"; item.UpdatedOn = DateTime.Now; item.UpdatedBy = ""; _db.Entry(item).State = EntityState.Modified; _db.SaveChanges(); } } } else { if (patient.EnrollmentSubStatus == "Active Enrolled") { if (CCMCycleStatus.CCMStatus != "Claims Submission" && CCMCycleStatus.CCMStatus != "Clinical Sign-Off" && CCMCycleStatus.CCMStatus != "Ready for Clinical Sign-Off" /*&& CCMCycleStatus.CCMStatus != "In Progress"*/) { CCMCycleStatus.CCMStatus = "Enrolled"; CCMCycleStatus.UpdatedOn = DateTime.Now; CCMCycleStatus.UpdatedBy = ""; _db.Entry(CCMCycleStatus).State = EntityState.Modified; _db.SaveChanges(); return("Enrolled"); } } else { if (CCMCycleStatus.CCMStatus != "Claims Submission" && CCMCycleStatus.CCMStatus != "Clinical Sign-Off" && CCMCycleStatus.CCMStatus != "Ready for Clinical Sign-Off" && CCMCycleStatus.CCMStatus != "In Progress") { CCMCycleStatus.CCMStatus = "Expired"; CCMCycleStatus.UpdatedOn = DateTime.Now; CCMCycleStatus.UpdatedBy = ""; _db.Entry(CCMCycleStatus).State = EntityState.Modified; _db.SaveChanges(); return("Expired"); } } var previouscycles = _db.CCMCycleStatuses.Where(x => x.PatientId == patientId && x.Cycle < Cycle && x.CCMStatus != "Claims Submission" && x.CCMStatus != "Clinical Sign-Off" && x.CCMStatus != "Ready for Clinical Sign-Off" && x.CCMStatus != "In Progress").ToList(); foreach (var item in previouscycles) { if (item.CCMStatus == "Enrolled") { item.CCMStatus = "Expired"; item.UpdatedOn = DateTime.Now; item.UpdatedBy = ""; _db.Entry(item).State = EntityState.Modified; _db.SaveChanges(); } } } return(CCMCycleStatus.CCMStatus); } } }
public async Task <ActionResult> Create([Bind(Exclude = "Photo")] Physician physician) { // , decimal CPT99490Billing, decimal CPT99491Billing, decimal CPT99487Billing, decimal CPT99489Billing, decimal CPT99490Invoice, decimal CPT99491Invoice, decimal CPT99487Invoice, decimal CPT99489Invoice if (ModelState.IsValid) { var existingUser = await UserManager.FindByNameAsync(physician.Email); if (existingUser == null) { physician.CreatedOn = DateTime.Now; physician.CreatedBy = User.Identity.GetUserId(); var postedImageFile = Request.Files["Photo"]; if (postedImageFile?.ContentLength != 0 && postedImageFile?.InputStream != null) { using (var binary = new BinaryReader(postedImageFile.InputStream)) { var imageData = binary.ReadBytes(postedImageFile.ContentLength); if (imageData.Length > 0) { physician.Photo = imageData; } } } _db.Physicians.Add(physician); _db.SaveChanges(); try { //Physician_CPTRates physician_CPTRatesCPT99490 = new Physician_CPTRates(); //physician_CPTRatesCPT99490.BillingCode = "CPT99490"; //physician_CPTRatesCPT99490.BillingRate = CPT99490Billing; //physician_CPTRatesCPT99490.InvoiceRate = CPT99490Invoice; //physician_CPTRatesCPT99490.CreatedBy = User.Identity.GetUserId(); //physician_CPTRatesCPT99490.CreatedOn = DateTime.Now; //physician_CPTRatesCPT99490.PhysicianId = physician.Id; ////CPTpp491 //Physician_CPTRates physician_CPTRatesCPT99491 = new Physician_CPTRates(); //physician_CPTRatesCPT99491.BillingCode = "CPT99491"; //physician_CPTRatesCPT99491.BillingRate = CPT99491Billing; //physician_CPTRatesCPT99491.InvoiceRate = CPT99491Invoice; //physician_CPTRatesCPT99491.CreatedBy = User.Identity.GetUserId(); //physician_CPTRatesCPT99491.CreatedOn = DateTime.Now; //physician_CPTRatesCPT99491.PhysicianId = physician.Id; ////CPT99487 //Physician_CPTRates physician_CPTRatesCPT99487 = new Physician_CPTRates(); //physician_CPTRatesCPT99487.BillingCode = "CPT99487"; //physician_CPTRatesCPT99487.BillingRate = CPT99487Billing; //physician_CPTRatesCPT99487.InvoiceRate = CPT99487Invoice; //physician_CPTRatesCPT99487.CreatedBy = User.Identity.GetUserId(); //physician_CPTRatesCPT99487.CreatedOn = DateTime.Now; //physician_CPTRatesCPT99487.PhysicianId = physician.Id; ////CPT99489 //Physician_CPTRates physician_CPTRatesCPT99489 = new Physician_CPTRates(); //physician_CPTRatesCPT99489.BillingCode = "CPT99489"; //physician_CPTRatesCPT99489.BillingRate = CPT99489Billing; //physician_CPTRatesCPT99489.InvoiceRate = CPT99489Invoice; //physician_CPTRatesCPT99489.CreatedBy = User.Identity.GetUserId(); //physician_CPTRatesCPT99489.CreatedOn = DateTime.Now; //physician_CPTRatesCPT99489.PhysicianId = physician.Id; //_db.Physician_CPTRates.Add(physician_CPTRatesCPT99490); //_db.Physician_CPTRates.Add(physician_CPTRatesCPT99491); //_db.Physician_CPTRates.Add(physician_CPTRatesCPT99487); //_db.Physician_CPTRates.Add(physician_CPTRatesCPT99489); //_db.SaveChanges(); } catch (Exception ex) { } var user = new ApplicationUser { UserName = physician.Email, Email = physician.Email }; var password = physician.LastName.ToLower() + "#PH1013"; // + physician.Id; var result = await UserManager.CreateAsync(user, password); if (result.Succeeded) { user.Role = "Physician"; user.CCMid = physician.Id; user.FirstName = physician.FirstName; user.LastName = physician.LastName; user.PhoneNumber = physician.MobilePhoneNumber; await UserManager.AddToRoleAsync(user.Id, "Physician"); _db.Entry(user).State = EntityState.Modified; await _db.SaveChangesAsync(); ViewBag.Message = "Physician Portal Created."; ViewBag.Username = user.Email; ViewBag.Password = password; return(View(physician)); } _db.Physicians.Remove(physician); await _db.SaveChangesAsync(); ViewBag.Message = "Error: Unable To Create Physician Portal! Please, Try Again."; return(View(physician)); } ViewBag.Message = "Email Already Exists! Physician Portal Not Created!."; } return(View(physician)); }