///<summary>Attempts to create or update ClaimTrackings and calls sync to update the database at the end. ///Will update ClaimTracking if one has been inserted for a given claim that did not have one prior to calling this method. ///When called please ensure dictClaimTracking has entries.</summary> public static List <ClaimTracking> Assign(List <Tuple <long, long> > listTrackingNumsAndClaimNums, long assignUserNum) { string command = "SELECT * FROM claimtracking WHERE claimtracking.TrackingType='" + POut.String(ClaimTrackingType.ClaimUser.ToString()) + "' " + "AND claimTracking.ClaimNum IN(" + string.Join(",", listTrackingNumsAndClaimNums.Select(x => x.Item2).ToList()) + ")"; List <ClaimTracking> listClaimTrackingDb = Crud.ClaimTrackingCrud.SelectMany(command); //up to date copy from the database List <ClaimTracking> listClaimTrackingNew = listClaimTrackingDb.Select(x => x.Copy()).ToList(); foreach (Tuple <long, long> claimTrackingEntry in listTrackingNumsAndClaimNums) //Item1=>claim tracking num & Item2=>claim num { ClaimTracking claimTracking = new ClaimTracking(); if (claimTrackingEntry.Item1 == 0 && //Given claim did not have an existing ClaimTracking when dictClaimTracking was constructed. !listClaimTrackingDb.Exists(x => x.ClaimNum == claimTrackingEntry.Item2)) //DB does not contain ClaimTracking row for this claimNum. { if (assignUserNum == 0) { continue; } claimTracking.UserNum = assignUserNum; claimTracking.ClaimNum = claimTrackingEntry.Item2; //dict value is ClaimNum claimTracking.TrackingType = ClaimTrackingType.ClaimUser; listClaimTrackingNew.Add(claimTracking); } else { if (claimTrackingEntry.Item1 == 0) //claim tracking did not originally exist but someone modified while we were here and it exists in the database now. { claimTracking = listClaimTrackingNew.FirstOrDefault(x => x.ClaimNum == claimTrackingEntry.Item2); claimTracking.UserNum = assignUserNum; } else //claim tracking already exsisted in the db for this claim { claimTracking = listClaimTrackingNew.FirstOrDefault(x => x.ClaimTrackingNum == claimTrackingEntry.Item1); if (claimTracking == null) //ClaimTracking existed when method called but has been removed since. { if (assignUserNum == 0) { continue; //ClaimTracking was already removed for us. } claimTracking = new ClaimTracking(); claimTracking.UserNum = assignUserNum; claimTracking.ClaimNum = claimTrackingEntry.Item2; //dict value is ClaimNum claimTracking.TrackingType = ClaimTrackingType.ClaimUser; listClaimTrackingNew.Add(claimTracking); } if (assignUserNum == 0) { listClaimTrackingNew.Remove(claimTracking); } else { claimTracking.UserNum = assignUserNum; } } } } ClaimTrackings.Sync(listClaimTrackingNew, listClaimTrackingDb); return(listClaimTrackingNew); }
public static LoadData GetLoadData(Patient pat, Family fam, Claim claim) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <LoadData>(MethodBase.GetCurrentMethod(), pat, fam, claim)); } LoadData data = new LoadData(); data.ListPatPlans = PatPlans.Refresh(pat.PatNum); data.ListInsSubs = InsSubs.RefreshForFam(fam); data.ListInsPlans = InsPlans.RefreshForSubList(data.ListInsSubs); data.ListClaimProcs = ClaimProcs.Refresh(pat.PatNum); data.ListProcs = Procedures.Refresh(pat.PatNum); data.ListClaimValCodes = ClaimValCodeLogs.GetForClaim(claim.ClaimNum); data.ClaimCondCodeLogCur = ClaimCondCodeLogs.GetByClaimNum(claim.ClaimNum); data.TablePayments = ClaimPayments.GetForClaim(claim.ClaimNum); data.TablePayments.TableName = "ClaimPayments"; data.ListToothInitials = ToothInitials.Refresh(pat.PatNum); data.ListCustomStatusEntries = ClaimTrackings.RefreshForClaim(ClaimTrackingType.StatusHistory, claim.ClaimNum); return(data); }