public ActionResult Get_Highcharts_Data() { DateTime dt = DateTime.Now; int month = Convert.ToInt32(dt.Month); //List<tblPatientAdmission> lst = new List<tblPatientAdmission>(); //var result = lst.Where(r => Convert.ToDateTime(r.AdmissionDate).Month == month); var list = db.tblPatientAdmissions.GroupBy(r => Convert.ToDateTime(r.AdmissionDate).Month == month && r.IsActive == true).Count(); PatientCount obj = new PatientCount(); obj.PatientsAdmittedCurrentMonth = list; //.Select(u => new PatientCount // { // PatientsAdmittedCurrentMonth = list.Count(ID), // }).ToList(); //var list = db.tblPatientAdmissions.GroupBy(u => DateTime.ParseExact(u.AdmissionDate).Month) // .Select(u => new PatientCount // { // PatientsAdmittedCurrentMonth = u.Count(), // Month = u.FirstOrDefault().AdmissionDate.Month.ToString() // }).ToList(); return(Json(obj, JsonRequestBehavior.AllowGet)); }
public CohortCountDTO(PreflightResources preflight, PatientCount count) : this(preflight) { QueryId = count.QueryId.ToString(); if (count != null) { Result = new PatientCountResultDTO { Value = count.Value, SqlStatements = count.SqlStatements }; } }
public CohortCountDTO(PreflightResources preflight, PatientCount count) : this(preflight) { QueryId = count.QueryId.ToString(); if (count != null) { Result = new PatientCountResultDTO { PlusMinus = count.PlusMinus, SqlStatements = count.SqlStatements, Value = count.Value, WithinLowCellThreshold = count.WithinLowCellThreshold }; } }
public void Obfuscate(ref PatientCount count, PanelValidationContext ctx, DeidentificationOptions opts) { if (!opts.Cohort.Enabled) { return; } // If low cell sizes should be masked and count less than or equal to threshold, set to threshold. if (opts.Cohort.LowCellSizeMasking.Enabled && count.Value <= opts.Cohort.LowCellSizeMasking.Threshold) { count.Value = opts.Cohort.LowCellSizeMasking.Threshold; count.PlusMinus = opts.Cohort.LowCellSizeMasking.Threshold; count.WithinLowCellThreshold = true; return; } // Bail if noise obfuscation not enabled if (!opts.Cohort.Noise.Enabled) { return; } // Ensure that variations of the same query (with concepts and panels moved around but the query logic identical) // always returns the same string of Guid Ids for concepts. var orderedIds = GetDeterministicConceptIdsAsString(ctx.Allowed); // Hash into a byte array. var hashed = md5.ComputeHash(Encoding.UTF8.GetBytes(orderedIds)); // Seed a random number generator from the hash. var generator = new Random(BitConverter.ToInt32(hashed, 0)); // Compute a random shifted value between the lower and upper bounds var shift = 0; while (shift == 0) { shift = generator.Next(opts.Cohort.Noise.LowerBound, opts.Cohort.Noise.UpperBound); } count.Value += shift; count.PlusMinus = Math.Max(Math.Abs(opts.Cohort.Noise.LowerBound), Math.Abs(opts.Cohort.Noise.UpperBound)); }
public void Under_Threshold_Not_Shifted() { var orig = 5; var obfuscator = new ObfuscationService(); var opts = new DeidentificationOptions { Cohort = new DeidentificationOptions.CohortObfuscationOptions { Enabled = true, LowCellSizeMasking = new DeidentificationOptions.CohortObfuscationOptions.LowCellSizeMaskingOptions { Enabled = true, Threshold = 10 } } }; var count = new PatientCount { Value = orig }; var ctx = MockPanel.Context(); obfuscator.Obfuscate(ref count, ctx, opts); Assert.NotEqual(orig, count.Value); Assert.Equal(count.Value, opts.Cohort.LowCellSizeMasking.Threshold); Assert.True(count.WithinLowCellThreshold); }
public void Original_Value_Changed() { var orig = 50; var obfuscator = new ObfuscationService(); var opts = new DeidentificationOptions { Cohort = new DeidentificationOptions.CohortObfuscationOptions { Enabled = true, Noise = new DeidentificationOptions.CohortObfuscationOptions.NoiseOptions { Enabled = true, LowerBound = -10, UpperBound = 10 } } }; var count = new PatientCount { Value = orig }; var ctx = MockPanel.Context(); obfuscator.Obfuscate(ref count, ctx, opts); Assert.NotEqual(orig, count.Value); Assert.Equal(count.PlusMinus, Math.Max(opts.Cohort.Noise.LowerBound, opts.Cohort.Noise.UpperBound)); Assert.False(count.WithinLowCellThreshold); }
public void Same_Logic_Different_Structure_Produces_Same_Shift() { var g1 = Guid.NewGuid(); var g2 = Guid.NewGuid(); var g3 = Guid.NewGuid(); var orig = 50; var obfuscator = new ObfuscationService(); var opts = new DeidentificationOptions { Cohort = new DeidentificationOptions.CohortObfuscationOptions { Enabled = true, Noise = new DeidentificationOptions.CohortObfuscationOptions.NoiseOptions { Enabled = true, LowerBound = -10, UpperBound = 10 } } }; var count1 = new PatientCount { Value = orig }; var count2 = new PatientCount { Value = orig }; var count3 = new PatientCount { Value = orig }; var count4 = new PatientCount { Value = orig }; var ctx1 = MockPanel.Context(); var ctx2 = MockPanel.Context(); var ctx3 = MockPanel.Context(); var ctx4 = MockPanel.Context(); // Set context one with two panels, the first with two concepts, second with one. ctx1.Allowed.ElementAt(0).SubPanels.ElementAt(0).PanelItems = new List <PanelItem> { new PanelItem { Concept = new Concept { Id = g1 } }, new PanelItem { Concept = new Concept { Id = g2 } } }; ctx1.Allowed.Append(new Panel { SubPanels = new List <SubPanel> { new SubPanel { PanelItems = new List <PanelItem> { new PanelItem { Concept = new Concept { Id = g3 } } } } } }); // Set context two to same as one, but with panel one concept order flipped. ctx2.Allowed.ElementAt(0).SubPanels.ElementAt(0).PanelItems = new List <PanelItem> { new PanelItem { Concept = new Concept { Id = g2 } }, new PanelItem { Concept = new Concept { Id = g1 } } }; ctx2.Allowed.Append(new Panel { SubPanels = new List <SubPanel> { new SubPanel { PanelItems = new List <PanelItem> { new PanelItem { Concept = new Concept { Id = g3 } } } } } }); // Set context three to same as one, but with panel order flipped. ctx3.Allowed.ElementAt(0).SubPanels.ElementAt(0).PanelItems = new List <PanelItem> { new PanelItem { Concept = new Concept { Id = g1 } }, new PanelItem { Concept = new Concept { Id = g2 } } }; ctx3.Allowed.Prepend(new Panel { SubPanels = new List <SubPanel> { new SubPanel { PanelItems = new List <PanelItem> { new PanelItem { Concept = new Concept { Id = g3 } } } } } }); // Set context four to a combination of two and three, with both concept order and panel order flipped. ctx4.Allowed.ElementAt(0).SubPanels.ElementAt(0).PanelItems = new List <PanelItem> { new PanelItem { Concept = new Concept { Id = g2 } }, new PanelItem { Concept = new Concept { Id = g1 } } }; ctx4.Allowed.Prepend(new Panel { SubPanels = new List <SubPanel> { new SubPanel { PanelItems = new List <PanelItem> { new PanelItem { Concept = new Concept { Id = g3 } } } } } }); obfuscator.Obfuscate(ref count1, ctx1, opts); obfuscator.Obfuscate(ref count2, ctx2, opts); obfuscator.Obfuscate(ref count3, ctx3, opts); obfuscator.Obfuscate(ref count4, ctx4, opts); Assert.NotEqual(orig, count1.Value); Assert.NotEqual(orig, count2.Value); Assert.NotEqual(orig, count3.Value); Assert.NotEqual(orig, count4.Value); Assert.False(count1.WithinLowCellThreshold); Assert.False(count2.WithinLowCellThreshold); Assert.False(count3.WithinLowCellThreshold); Assert.False(count4.WithinLowCellThreshold); Assert.Equal(count1.Value, count2.Value); Assert.Equal(count1.Value, count3.Value); Assert.Equal(count1.Value, count4.Value); }