Esempio n. 1
0
        public void Anonymize_AvoidValidationOnAnonymization()
        {
            const string fileName = "GH064.dcm";

#if NETFX_CORE
            var originalDicom = Dicom.Helpers.ApplicationContent.OpenDicomFileAsync($"Data/{fileName}").Result;
#else
            var originalDicom = DicomFile.Open($"./Test Data/{fileName}");
#endif

            var ds         = new DicomDataset(originalDicom.Dataset).NotValidated();
            var invalidUid = "1.2.315.6666.008965..19187632.1";
            ds.AddOrUpdate(DicomTag.StudyInstanceUID, invalidUid);
            ds = ds.Validated();

            var anonymizer   = new DicomAnonymizer();
            var anonymizedDs = anonymizer.Anonymize(ds);
            Assert.NotNull(anonymizedDs);

            var df           = new DicomFile(ds);
            var anonymizedDf = anonymizer.Anonymize(df);
            Assert.NotNull(anonymizedDf);
        }
        public void Anonymize_UsePredefinedPatientNameAndId_ShouldBeSetInAnonymizedDataset()
        {
            const string fileName = "CT1_J2KI";

#if NETFX_CORE
            var dataset = Dicom.Helpers.ApplicationContent.OpenDicomFileAsync($"Data/{fileName}").Result.Dataset;
#else
            var dataset = DicomFile.Open($"./Test Data/{fileName}").Dataset;
#endif
            const string expectedName = "fo-dicom";
            const string expectedId   = "GH-575";

            var anonymizer = new DicomAnonymizer();
            anonymizer.Profile.PatientName = expectedName;
            anonymizer.Profile.PatientID   = expectedId;

            var newDataset = anonymizer.Anonymize(dataset);

            var actualName = newDataset.GetSingleValue <string>(DicomTag.PatientName);
            var actualId   = newDataset.GetSingleValue <string>(DicomTag.PatientID);

            Assert.Equal(expectedName, actualName);
            Assert.Equal(expectedId, actualId);
        }