public void Should_Mask_Dynamic_PersonId_And_EncounterId() { DynamicDatasetRecord record = new DynamicDatasetRecord { Salt = Guid.NewGuid() }; List <SchemaFieldSelector> fields = new List <SchemaFieldSelector> { From(personId, true), From(encounterId, true) }; record.SetValue(personId, "abc123"); record.SetValue(encounterId, "def456"); var pepper = Guid.NewGuid(); var anon = new DynamicAnonymizer(pepper); anon.Anonymize(record, fields); var anonPer = record.GetValue(personId); var anonEnc = record.GetValue(encounterId); Assert.NotEqual("abc123", anonPer); Assert.NotEqual("def456", anonEnc); Assert.NotNull(anonPer); Assert.NotNull(anonEnc); }
Func <DynamicDatasetRecord, DynamicShapedDatumSet> GetConverter(bool anonymize, IEnumerable <SchemaFieldSelector> fields) { if (anonymize) { var anon = new DynamicAnonymizer(Pepper); return((rec) => { anon.Anonymize(rec, fields); return rec.ToDatumSet(); }); } return((rec) => rec.ToDatumSet()); }
Func <DynamicDatasetRecord, DynamicShapedDatumSet> GetConverter(bool anonymize, IEnumerable <SchemaFieldSelector> fields, DeidentificationOptions opts) { if (anonymize) { var shift = opts.Patient.DateShifting; var anon = new DynamicAnonymizer(Pepper, shift.Increment.ToString(), shift.LowerBound, shift.UpperBound); return((rec) => { anon.Anonymize(rec, fields); return rec.ToDatumSet(); }); } return((rec) => rec.ToDatumSet()); }
public void Should_Throw_On_Unmaskable_Phi() { DynamicDatasetRecord record = new DynamicDatasetRecord { Salt = Guid.NewGuid() }; List <SchemaFieldSelector> fields = new List <SchemaFieldSelector> { new SchemaFieldSelector { Mask = false, Phi = true, Required = true, Type = LeafType.DateTime, Name = dateVal } }; record.SetValue(dateVal, new DateTime(2018, 12, 14, 10, 33, 00)); var pepper = Guid.NewGuid(); var anon = new DynamicAnonymizer(pepper); Assert.Throws <LeafDynamicAnonymizerException>(() => anon.Anonymize(record, fields)); }
public void Should_Throw_On_Maskable_Boolean() { DynamicDatasetRecord record = new DynamicDatasetRecord { Salt = Guid.NewGuid() }; List <SchemaFieldSelector> fields = new List <SchemaFieldSelector> { new SchemaFieldSelector { Mask = true, Phi = true, Required = true, Type = LeafType.Bool, Name = boolVal } }; record.SetValue(boolVal, false); var pepper = Guid.NewGuid(); var anon = new DynamicAnonymizer(pepper); Assert.Throws <ArgumentException>(() => anon.Anonymize(record, fields)); }
public void Should_Not_Shift_Dynamic_Date_Null() { DynamicDatasetRecord record = new DynamicDatasetRecord { Salt = Guid.NewGuid() }; List <SchemaFieldSelector> fields = new List <SchemaFieldSelector> { From(dateVal, true, LeafType.DateTime) }; record.SetValue(dateVal, null); var pepper = Guid.NewGuid(); var anon = new DynamicAnonymizer(pepper); anon.Anonymize(record, fields); var anonDate = record.GetValue(dateVal); Assert.Null(anonDate); }
public void Should_Mask_Carry_PersonId_To_Datum() { DynamicDatasetRecord record = new DynamicDatasetRecord { Salt = Guid.NewGuid() }; List <SchemaFieldSelector> fields = new List <SchemaFieldSelector> { From(personId, true) }; record.SetValue(personId, "abc123"); var pepper = Guid.NewGuid(); var anon = new DynamicAnonymizer(pepper); anon.Anonymize(record, fields); var anonDatum = record.ToDatumSet(); Assert.NotEqual("abc123", anonDatum.PersonId); Assert.NotNull(anonDatum.PersonId); }
public void Should_Shift_Dynamic_Date_NotNull() { DynamicDatasetRecord record = new DynamicDatasetRecord { Salt = Guid.NewGuid() }; List <SchemaFieldSelector> fields = new List <SchemaFieldSelector> { From(dateVal, true, LeafType.DateTime) }; record.SetValue(dateVal, new DateTime(2018, 12, 14, 10, 33, 00)); var pepper = Guid.NewGuid(); var anon = new DynamicAnonymizer(pepper); anon.Anonymize(record, fields); var anonDate = record.GetValue(dateVal); Assert.NotNull(anonDate); Assert.NotEqual(new DateTime(2018, 12, 14, 10, 33, 00), anonDate); Assert.Equal(33, ((DateTime)anonDate).Minute); }