public List <DateValuePair> Push(DateValuePair dvp) { if (dvp.Date >= dtNextStep) { // output collected double dMSEven = Step.TotalMilliseconds / ((double)lDVP.Count); for (int i = 0; i < lDVP.Count; i++) { lDVP[i].Date = lDVP[i].Date.AddMilliseconds(dMSEven * i); } List <DateValuePair> lDVPOutput = lDVP; // reset accumulator lDVP = new List <DateValuePair>(); lDVP.Add(dvp); // Find next step containing this dvp... this *should* be optimized while (dvp.Date >= (dtNextStep.Add(Step))) { dtNextStep = dtNextStep.Add(Step); } return(lDVPOutput); } else { // add lDVP.Add(dvp); // return empty list return(new List <DateValuePair>()); } }
public List<DateValuePair> Push(DateValuePair dvp) { if (dvp.Date >= dtNextStep) { // output collected double dMSEven = Step.TotalMilliseconds / ((double)lDVP.Count); for (int i = 0; i < lDVP.Count; i++) { lDVP[i].Date = lDVP[i].Date.AddMilliseconds(dMSEven*i); } List<DateValuePair> lDVPOutput = lDVP; // reset accumulator lDVP = new List<DateValuePair>(); lDVP.Add(dvp); // Find next step containing this dvp... this *should* be optimized while (dvp.Date >= (dtNextStep.Add(Step))) { dtNextStep = dtNextStep.Add(Step); } return lDVPOutput; } else { // add lDVP.Add(dvp); // return empty list return new List<DateValuePair>(); } }
public List<DateValuePair> Push(DateValuePair dvp) { List<DateValuePair> lDVP = new List<DateValuePair>(1); lDVP.Add((DateValuePair)dvp.Clone()); lDVP[0].Date = lDVP[0].Date.AddMilliseconds(_random.NextDouble() * Step.TotalMilliseconds); return lDVP; }
public List <DateValuePair> Push(DateValuePair dvp) { List <DateValuePair> lDVP = new List <DateValuePair>(1); lDVP.Add((DateValuePair)dvp.Clone()); lDVP[0].Date = lDVP[0].Date.AddMilliseconds(_random.NextDouble() * Step.TotalMilliseconds); return(lDVP); }
protected static void _TimeNormalize(object obj, out SqlDateTime EventTime, out SqlDouble NormalizedValue) { EventTime = SqlDateTime.Null; NormalizedValue = SqlDouble.Null; DateValuePair dvp = obj as DateValuePair; EventTime = dvp.Date; NormalizedValue = dvp.Value; }
public static void Do() { List <DateValuePair> lDVPs = new List <DateValuePair>(); lDVPs.AddRange(new DateValuePair[] { new DateValuePair() { Value = 100.0D, Date = DateTime.Parse("2014-01-01 17:00:00") }, new DateValuePair() { Value = 50.0D, Date = DateTime.Parse("2014-01-01 17:00:01") }, new DateValuePair() { Value = 0.0D, Date = DateTime.Parse("2014-01-01 17:00:02") }, new DateValuePair() { Value = 180.0D, Date = DateTime.Parse("2014-01-01 17:00:02.5") } }); StreamNormalizer sn = new StreamNormalizer(new TimeSpan(0, 0, 1)); foreach (DateValuePair dvp in lDVPs) { List <DateValuePair> lOutput = sn.Push(dvp); for (int i = 0; i < lOutput.Count; i++) { System.Console.WriteLine("{0:S} - {1:N2}", lOutput[i].Date.ToString(), lOutput[i].Value); } } DateValuePair dvpLast = sn.Finish(); if (dvpLast != null) { System.Console.WriteLine("*Last {0:S} - {1:N2}", dvpLast.Date.ToString(), dvpLast.Value); } }
private List <DateValuePair> ReadAllFile(string masterFilePath) { DateValuePair textItem = new DateValuePair(); List <DateValuePair> txtFiles = new List <DateValuePair>(); // Retrieve storage account information from connection string CloudStorageAccount storageAccount = BlobStorage.Common.CreateStorageAccountFromConnectionString(); // Create a blob client for interacting with the blob service. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // Create a container for organizing blobs within the storage account. CloudBlobContainer container = blobClient.GetContainerReference("oidata"); foreach (var item in container.ListBlobs()) { textItem = new DateValuePair(); textItem.Value = item.Uri.ToString(); textItem.LastModifiedDate = ((CloudBlob)item).Properties.LastModified.Value.UtcDateTime; txtFiles.Add(textItem); } return(txtFiles.OrderByDescending(d => d.LastModifiedDate).Take(50).ToList()); }
/* * ///<summary></summary> * public static DateTime GetClosestFirst(DateTime date){ * if(date.Day > 15){ * if(date.Month!=12){ * return new DateTime(date.Year,date.Month+1,1); * } * else{ * return new DateTime(date.Year+1,1,1); * } * } * else{ * return new DateTime(date.Year,date.Month,1); * } * }*/ /* * ///<summary></summary> * public static void ComputeAging(int guarantor){ * DateTime asOfDate; * if(DateTime.Today.Day > 15){ * if(DateTime.Today.Month==12){ * asOfDate=new DateTime(DateTime.Today.Year+1,1,1); * } * else{ * asOfDate=new DateTime(DateTime.Today.Year,DateTime.Today.Month+1,1); * } * } * else{ * asOfDate=new DateTime(DateTime.Today.Year,DateTime.Today.Month,1); * } * ComputeAging(guarantor,asOfDate); * Patients.ResetAging(guarantor); * Patients.UpdateAging(guarantor,Bal[0],Bal[1],Bal[2],Bal[3],InsEst,BalTotal); * }*/ ///<summary>Computes aging for entire family. Gets all info from database.</summary> public static void ComputeAging(int guarantor, DateTime asOfDate) { AsOfDate = asOfDate; Bal = new double[4]; Bal[0] = 0; //0_30 Bal[1] = 0; //31_60 Bal[2] = 0; //61_90 Bal[3] = 0; //90plus BalTotal = 0; InsEst = 0; DateValuePair[] pairs; string wherePats = ""; ArrayList ALpatNums = new ArrayList(); //used for payplans string command = "SELECT PatNum FROM patient WHERE guarantor = '" + POut.PInt(guarantor) + "'"; //MessageBox.Show(command); DataTable table = General.GetTable(command); for (int i = 0; i < table.Rows.Count; i++) { ALpatNums.Add(PIn.PInt(table.Rows[i][0].ToString())); if (i > 0) { wherePats += " OR"; } wherePats += " PatNum = '" + table.Rows[i][0].ToString() + "'"; } //REGULAR PROCEDURES: command = "SELECT procdate,procfee,unitqty FROM procedurelog" + " WHERE procstatus = '2'" //complete + " AND (" + wherePats + ")"; table = General.GetTable(command); pairs = new DateValuePair[table.Rows.Count]; double val; double qty; for (int i = 0; i < table.Rows.Count; i++) { pairs[i].Date = PIn.PDate(table.Rows[i][0].ToString()); val = PIn.PDouble(table.Rows[i][1].ToString()); qty = PIn.PDouble(table.Rows[i][2].ToString()); if (qty > 0) { val *= qty; } pairs[i].Value = val; } for (int i = 0; i < pairs.Length; i++) { Bal[GetAgingType(pairs[i].Date)] += pairs[i].Value; } //POSITIVE ADJUSTMENTS: command = "SELECT adjdate,adjamt FROM adjustment" + " WHERE adjamt > 0" + " AND (" + wherePats + ")"; table = General.GetTable(command); pairs = new DateValuePair[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { pairs[i].Date = PIn.PDate(table.Rows[i][0].ToString()); pairs[i].Value = PIn.PDouble(table.Rows[i][1].ToString()); } for (int i = 0; i < pairs.Length; i++) { Bal[GetAgingType(pairs[i].Date)] += pairs[i].Value; } //NEGATIVE ADJUSTMENTS: command = "SELECT adjdate,adjamt FROM adjustment" + " WHERE adjamt < 0" + " AND (" + wherePats + ")" + " ORDER BY adjdate"; table = General.GetTable(command); pairs = new DateValuePair[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { pairs[i].Date = PIn.PDate(table.Rows[i][0].ToString()); pairs[i].Value = -PIn.PDouble(table.Rows[i][1].ToString()); } ComputePayments(pairs); //CLAIM PAYMENTS AND CAPITATION WRITEOFFS: //Always use DateCP rather than ProcDate to calculate the date of a claim payment command = "SELECT datecp,inspayamt,writeoff FROM claimproc" + " WHERE (status = '1' " //received + "OR status = '4'" //or supplemental + "OR status = '7'" //or CapComplete + "OR status = '5'" //or CapClaim + ")" //pending insurance is handled further down //ins adjustments do not affect patient balance, but only insurance benefits + " AND (" + wherePats + ")" + " ORDER BY datecp"; table = General.GetTable(command); pairs = new DateValuePair[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { pairs[i].Date = PIn.PDate(table.Rows[i][0].ToString()); pairs[i].Value = PIn.PDouble(table.Rows[i][1].ToString()) + PIn.PDouble(table.Rows[i][2].ToString()); } ComputePayments(pairs); //PAYSPLITS: command = "SELECT procdate,splitamt FROM paysplit" + " WHERE" + wherePats + " ORDER BY procdate"; table = General.GetTable(command); pairs = new DateValuePair[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { pairs[i].Date = PIn.PDate(table.Rows[i][0].ToString()); pairs[i].Value = PIn.PDouble(table.Rows[i][1].ToString()); } ComputePayments(pairs); //PAYMENT PLANS: string whereGuars = ""; for (int i = 0; i < ALpatNums.Count; i++) { if (i > 0) { whereGuars += " OR"; } whereGuars += " Guarantor = '" + ((int)ALpatNums[i]).ToString() + "'"; } command = "SELECT PatNum,Guarantor,Principal,Interest,ChargeDate FROM payplancharge" //"SELECT currentdue,totalamount,patnum,guarantor FROM payplan" + " WHERE" + wherePats + " OR" + whereGuars + " ORDER BY ChargeDate"; table = General.GetTable(command); pairs = new DateValuePair[1]; //always just one single combined entry pairs[0].Date = DateTime.Today; foreach (int patNum in ALpatNums) { for (int i = 0; i < table.Rows.Count; i++) { //one or both of these conditions may be met: //if is guarantor if (PIn.PInt(table.Rows[i][1].ToString()) == patNum) { if (PIn.PDate(table.Rows[i][4].ToString()) <= DateTime.Today) { pairs[0].Value += PIn.PDouble(table.Rows[i][2].ToString()) + PIn.PDouble(table.Rows[i][3].ToString()); } } //if is patient if (PIn.PInt(table.Rows[i][0].ToString()) == patNum) { pairs[0].Value -= PIn.PDouble(table.Rows[i][2].ToString()); } } } if (pairs[0].Value > 0) { Bal[GetAgingType(pairs[0].Date)] += pairs[0].Value; } else if (pairs[0].Value < 0) { pairs[0].Value = -pairs[0].Value; ComputePayments(pairs); } //CLAIM ESTIMATES command = "SELECT inspayest,writeoff FROM claimproc" + " WHERE status = '0'" //not received + " AND (" + wherePats + ")"; table = General.GetTable(command); for (int i = 0; i < table.Rows.Count; i++) { InsEst += PIn.PDouble(table.Rows[i][0].ToString()) + PIn.PDouble(table.Rows[i][1].ToString()); } //balance is sum of 4 aging periods BalTotal = Bal[0] + Bal[1] + Bal[2] + Bal[3]; //after this, balance will NOT necessarily be the same as the sum of the 4. //clean up negative numbers: if (Bal[3] < 0) { Bal[2] += Bal[3]; Bal[3] = 0; } if (Bal[2] < 0) { Bal[1] += Bal[2]; Bal[2] = 0; } if (Bal[1] < 0) { Bal[0] += Bal[1]; Bal[1] = 0; } if (Bal[0] < 0) { Bal[0] = 0; } //must complete by updating patient table. Done from wherever this was called. }
public void Start(DateValuePair Start) { this.dtNextStep = Start.Date.Add(Step); lDVP = new List<DateValuePair>(); }
public static System.Collections.IEnumerable TimeNormalize(SqlString statement, SqlInt32 days, SqlInt32 hours, SqlInt32 minutes, SqlInt32 seconds, SqlInt32 milliseconds) { using (SqlConnection conn = new SqlConnection("context connection = true")) { conn.Open(); List <DateValuePair> lDVPs = new List <DateValuePair>(); StreamNormalizer sn = new StreamNormalizer(new TimeSpan( days.Value, hours.Value, minutes.Value, seconds.Value, milliseconds.Value)); using (SqlCommand cmd = new SqlCommand(statement.Value, conn)) { using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { if (!(reader[0] is DateTime)) { throw new ArgumentException("Field 0 must be a " + typeof(DateTime).FullName + ". It is " + reader[0].GetType().FullName + " instead."); } DateValuePair dvp = new DateValuePair { Date = reader.GetDateTime(0) }; object oVal = reader[1]; try { if (oVal is Int32) { dvp.Value = (int)oVal; } else if (oVal is double) { dvp.Value = (double)oVal; } else { dvp.Value = Decimal.ToDouble((Decimal)oVal); } } catch (Exception exce) { throw new ArgumentException("Field 1 must be a numeric value. It is " + oVal.GetType().FullName + " instead. (Internal exception: " + exce.Message + ")."); } lDVPs.AddRange(sn.Push(dvp)); } } } DateValuePair dvpFinish = sn.Finish(); if (dvpFinish != null) { lDVPs.Add(dvpFinish); } return(lDVPs); } }
public void Start(DateValuePair Start) { this.dtNextStep = Start.Date.Add(Step); lDVP = new List <DateValuePair>(); }