public void Generate_SourceUidKnown_ReturnsMappedDestinationUid()
        {
            var source = DicomUIDGenerator.GenerateNew();

            var generator = new DicomUIDGenerator();
            var expected  = generator.Generate(source);
            var actual    = generator.Generate(source);

            Assert.Equal(expected, actual);
        }
Exemplo n.º 2
0
        public void Transform(DicomDataset dataset, DicomDataset modifiedAttributesSequenceItem = null)
        {
            dataset.CopyTo(modifiedAttributesSequenceItem, _tag);
            var uid = dataset.GetSingleValue <DicomUID>(_tag);

            dataset.AddOrUpdate(_tag, _generator.Generate(uid));
        }
    public void Test_that_a_generator_remembers_generated()
    {
      DicomUIDGenerator generator = new DicomUIDGenerator();
      var a = generator.Generate();
      var b = generator.Generate(a);
      var c = generator.Generate(b);
      var d = generator.Generate(a);
      var e = generator.Generate(b);

      Assert.NotEqual(a, b);
      Assert.NotEqual(a, c);
      Assert.NotEqual(a, d);
      Assert.NotEqual(a, e);
      Assert.NotEqual(b, c);
      Assert.Equal(b, d);
      Assert.NotEqual(b, e);
      Assert.NotEqual(c, d);
      Assert.Equal(c, e);
      Assert.NotEqual(d, e);
    }
Exemplo n.º 4
0
 public DicomFileMetaInformation(DicomDataset dataset)
     : this()
 {
     MediaStorageSOPClassUID = dataset.Get <DicomUID>(DicomTag.SOPClassUID);
     //部分工作站含有DicomTag.SOPInstanceUID但是值为null 需要重新生成
     if (dataset.Contains(DicomTag.SOPInstanceUID) && !string.IsNullOrEmpty(dataset.Get <string>(DicomTag.SOPInstanceUID)))
     {
         MediaStorageSOPInstanceUID = dataset.Get <DicomUID>(DicomTag.SOPInstanceUID);
     }
     else
     {
         DicomUIDGenerator uid = new DicomUIDGenerator();
         dataset.Add <string>(DicomTag.SOPInstanceUID, uid.Generate().ToString());
         MediaStorageSOPInstanceUID = dataset.Get <DicomUID>(DicomTag.SOPInstanceUID);
     }
     TransferSyntax = dataset.InternalTransferSyntax;
 }
    public void Test_RegenerateAll()
    {
      var uidGenerator = new DicomUIDGenerator();
      var dataset = new DicomDataset
                     {
                       new DicomPersonName(
                         DicomTag.PatientName,
                         new[] { "Anna^Pelle", null, "Olle^Jöns^Pyjamas" }),
                       { DicomTag.SOPClassUID, DicomUID.RTPlanStorage },
                       { DicomTag.SOPInstanceUID, uidGenerator.Generate() },
                       { DicomTag.SeriesInstanceUID,
                         new[] { uidGenerator.Generate(), uidGenerator.Generate() } },
                       { DicomTag.FrameOfReferenceUID, uidGenerator.Generate() }
                     };
      dataset.Add(
        DicomTag.ReferencedFrameOfReferenceSequence,
        new[]
          {
            new DicomDataset { { DicomTag.ReferencedFrameOfReferenceUID, uidGenerator.Generate() } },
            new DicomDataset { { DicomTag.ReferencedFrameOfReferenceUID, uidGenerator.Generate() } }
          });

      var clone = this.DeepClone_(dataset);

      uidGenerator.RegenerateAll(clone);

      Assert.Equal(dataset.Get<string>(DicomTag.PatientName), clone.Get<string>(DicomTag.PatientName));
      Assert.Equal(dataset.Get<string>(DicomTag.SOPClassUID), clone.Get<string>(DicomTag.SOPClassUID));
      Assert.NotEqual(dataset.Get<string>(DicomTag.SOPInstanceUID), clone.Get<string>(DicomTag.SOPInstanceUID));
      Assert.NotEqual(dataset.Get<string>(DicomTag.SeriesInstanceUID), clone.Get<string>(DicomTag.SeriesInstanceUID));
      Assert.NotEqual(dataset.Get<string>(DicomTag.FrameOfReferenceUID), clone.Get<string>(DicomTag.FrameOfReferenceUID));
      Assert.NotEqual(
        dataset.Get<DicomSequence>(DicomTag.ReferencedFrameOfReferenceSequence).Items[0].Get<string>(DicomTag.ReferencedFrameOfReferenceUID),
        clone.Get<DicomSequence>(DicomTag.ReferencedFrameOfReferenceSequence).Items[0].Get<string>(DicomTag.ReferencedFrameOfReferenceUID));
      Assert.NotEqual(
        dataset.Get<DicomSequence>(DicomTag.ReferencedFrameOfReferenceSequence).Items[1].Get<string>(DicomTag.ReferencedFrameOfReferenceUID),
        clone.Get<DicomSequence>(DicomTag.ReferencedFrameOfReferenceSequence).Items[1].Get<string>(DicomTag.ReferencedFrameOfReferenceUID));
    }
Exemplo n.º 6
0
		public static DicomUID Generate() {
			var generator = new DicomUIDGenerator();
			return generator.Generate();
		}
Exemplo n.º 7
0
        public static DicomUID Generate()
        {
            var generator = new DicomUIDGenerator();

            return(generator.Generate());
        }