Exemple #1
0
        public void TestContainsReference()
        {
            var dictionary = new HierarchicalSopInstanceReferenceDictionary();

            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location2", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid2", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series2", "sopclass1", "sopinst3");
            dictionary.AddReference("study2", "series3", "sopclass1", "sopinst4");

            Assert.IsFalse(dictionary.ContainsReference("study3", "series1", "sopclass1", "sopinst2"), "nonexistent study");
            Assert.IsFalse(dictionary.ContainsReference("study1", "series9", "sopclass1", "sopinst2"), "nonexistent series");
            Assert.IsFalse(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst9"), "nonexistent sop");
            Assert.IsFalse(dictionary.ContainsReference("study1", "series1", "sopclass2", "sopinst1"), "nonexistent sop (class mismatch)");

            Assert.IsFalse(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst1", "aetitle3", "location1", "mediaid1", "mediauid2"), "nonexistent series (aetitle mismatch");
            Assert.IsFalse(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location3", "mediaid1", "mediauid2"), "nonexistent series (location mismatch");
            Assert.IsFalse(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid3", "mediauid2"), "nonexistent series (mediaid mismatch");
            Assert.IsFalse(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid3"), "nonexistent series (medauid mismatch");

            Assert.IsTrue(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2"), "contains sop1");
            Assert.IsTrue(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2"), "contains sop2");
            Assert.IsTrue(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst1"), "contains any series1 sop1");
            Assert.IsTrue(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst2"), "contains any series1 sop2");
        }
        /// <summary>
        /// Serializes the current contents into a number of key object selection document SOP instances.
        /// </summary>
        /// <param name="callback">A callback method to initialize the series-level attributes of the key object document.
        /// Should return a data set from which patient and study level attributes can be copied, otherwise a KO document will not be created for this study.
        /// </param>
        public List <DicomFile> Serialize(InitializeKeyObjectDocumentSeriesCallback callback)
        {
            callback = callback ?? DefaultInitializeKeyObjectDocumentSeriesCallback;

            if (_framePresentationStates.Count == 0)
            {
                throw new InvalidOperationException("Key object selection cannot be empty.");
            }

            List <DicomFile>            keyObjectDocuments = new List <DicomFile>();
            List <SopInstanceReference> identicalDocuments = new List <SopInstanceReference>();
            Dictionary <string, KeyObjectSelectionDocumentIod> koDocumentsByStudy = new Dictionary <string, KeyObjectSelectionDocumentIod>();

            foreach (var frame in (IEnumerable <KeyImageReference>)_framePresentationStates)
            {
                string studyInstanceUid = frame.StudyInstanceUid;
                if (!koDocumentsByStudy.ContainsKey(studyInstanceUid))
                {
                    KeyObjectDocumentSeries seriesInfo = new KeyObjectDocumentSeries(studyInstanceUid);
                    var prototypeDataSet = callback.Invoke(seriesInfo);
                    if (prototypeDataSet == null)
                    {
                        continue;
                    }

                    DicomFile keyObjectDocument = new DicomFile();
                    keyObjectDocument.SourceApplicationEntityTitle = frame.SourceApplicationEntityTitle;

                    _sopInstanceFactory.InitializeDataSet(prototypeDataSet, keyObjectDocument.DataSet);

                    KeyObjectSelectionDocumentIod iod = new KeyObjectSelectionDocumentIod(keyObjectDocument.DataSet);

                    iod.GeneralEquipment.Manufacturer                = this.Manufacturer ?? string.Empty;      // this one is type 2 - all other GenEq attributes are type 3
                    iod.GeneralEquipment.ManufacturersModelName      = string.IsNullOrEmpty(this.ManufacturersModelName) ? null : this.ManufacturersModelName;
                    iod.GeneralEquipment.DeviceSerialNumber          = string.IsNullOrEmpty(this.DeviceSerialNumber) ? null : this.DeviceSerialNumber;
                    iod.GeneralEquipment.SoftwareVersions            = string.IsNullOrEmpty(this.SoftwareVersions) ? null : this.SoftwareVersions;
                    iod.GeneralEquipment.InstitutionName             = string.IsNullOrEmpty(this.Institution.Name) ? null : this.Institution.Name;
                    iod.GeneralEquipment.InstitutionAddress          = string.IsNullOrEmpty(this.Institution.Address) ? null : this.Institution.Address;
                    iod.GeneralEquipment.InstitutionalDepartmentName = string.IsNullOrEmpty(this.Institution.DepartmentName) ? null : this.Institution.DepartmentName;
                    iod.GeneralEquipment.StationName = string.IsNullOrEmpty(this.StationName) ? null : this.StationName;

                    iod.KeyObjectDocumentSeries.InitializeAttributes();
                    iod.KeyObjectDocumentSeries.Modality          = Modality.KO;
                    iod.KeyObjectDocumentSeries.SeriesDateTime    = seriesInfo.SeriesDateTime;
                    iod.KeyObjectDocumentSeries.SeriesDescription = SeriesDescription;
                    iod.KeyObjectDocumentSeries.SeriesInstanceUid = CreateUid(seriesInfo.SeriesInstanceUid);
                    iod.KeyObjectDocumentSeries.SeriesNumber      = seriesInfo.SeriesNumber ?? 1;
                    iod.KeyObjectDocumentSeries.ReferencedPerformedProcedureStepSequence = null;

                    iod.SopCommon.SopClass       = SopClass.KeyObjectSelectionDocumentStorage;
                    iod.SopCommon.SopInstanceUid = DicomUid.GenerateUid().UID;

                    identicalDocuments.Add(new SopInstanceReference(
                                               studyInstanceUid,
                                               iod.KeyObjectDocumentSeries.SeriesInstanceUid,
                                               iod.SopCommon.SopClassUid,
                                               iod.SopCommon.SopInstanceUid));

                    koDocumentsByStudy.Add(studyInstanceUid, iod);
                    keyObjectDocuments.Add(keyObjectDocument);
                }
            }

            foreach (KeyObjectSelectionDocumentIod iod in koDocumentsByStudy.Values)
            {
                iod.KeyObjectDocument.InitializeAttributes();
                iod.KeyObjectDocument.InstanceNumber            = 1;
                iod.KeyObjectDocument.ContentDateTime           = DateTime;
                iod.KeyObjectDocument.ReferencedRequestSequence = null;

                // only add docuemnts other than current to the identical documents sequence (and if there's only one, it's obviously the current)
                if (identicalDocuments.Count > 1)
                {
                    var identicalDocumentsSequence = new HierarchicalSopInstanceReferenceDictionary();
                    var thisDocument = new SopInstanceReference(iod.GeneralStudy.StudyInstanceUid, iod.KeyObjectDocumentSeries.SeriesInstanceUid, iod.SopCommon.SopClassUid, iod.SopCommon.SopInstanceUid);
                    foreach (var otherDocument in identicalDocuments.Where(d => !d.Equals(thisDocument)))
                    {
                        identicalDocumentsSequence.AddReference(otherDocument.StudyInstanceUid, otherDocument.SeriesInstanceUid, otherDocument.SopClassUid, otherDocument.SopInstanceUid);
                    }
                    iod.KeyObjectDocument.IdenticalDocumentsSequence = identicalDocumentsSequence;
                }

                iod.SrDocumentContent.InitializeContainerAttributes();
                iod.SrDocumentContent.ConceptNameCodeSequence = DocumentTitle;

                List <IContentSequence> contentList = new List <IContentSequence>();
                EvidenceDictionary      currentRequestedProcedureEvidenceList = new EvidenceDictionary();

                List <KeyImageReference> frameMap = new List <KeyImageReference>();
                foreach (var frameAndPresentationState in _framePresentationStates)
                {
                    var frame = frameAndPresentationState.Key;

                    // build frame map by unique sop - used to make the evidence sequence less verbose
                    if (!frameMap.Contains(frame))
                    {
                        frameMap.Add(frame);
                    }

                    // content sequence must still list all content as it was given, including any repeats
                    IContentSequence content = iod.SrDocumentContent.CreateContentSequence();
                    {
                        content.RelationshipType = RelationshipType.Contains;

                        IImageReferenceMacro imageReferenceMacro = content.InitializeImageReferenceAttributes();
                        imageReferenceMacro.ReferencedSopSequence.InitializeAttributes();
                        imageReferenceMacro.ReferencedSopSequence.ReferencedSopClassUid    = frame.SopClassUid;
                        imageReferenceMacro.ReferencedSopSequence.ReferencedSopInstanceUid = frame.SopInstanceUid;
                        if (frame.FrameNumber.HasValue)
                        {
                            imageReferenceMacro.ReferencedSopSequence.ReferencedFrameNumber = frame.FrameNumber.Value.ToString(CultureInfo.InvariantCulture);
                        }
                        else
                        {
                            imageReferenceMacro.ReferencedSopSequence.ReferencedFrameNumber = null;
                        }

                        // save the presentation state
                        if (frameAndPresentationState.Value != null)
                        {
                            var presentationState = frameAndPresentationState.Value;
                            imageReferenceMacro.ReferencedSopSequence.CreateReferencedSopSequence();
                            imageReferenceMacro.ReferencedSopSequence.ReferencedSopSequence.InitializeAttributes();
                            imageReferenceMacro.ReferencedSopSequence.ReferencedSopSequence.ReferencedSopClassUid    = presentationState.SopClassUid;
                            imageReferenceMacro.ReferencedSopSequence.ReferencedSopSequence.ReferencedSopInstanceUid = presentationState.SopInstanceUid;
                        }
                    }
                    contentList.Add(content);
                }

                // add the author
                if (!string.IsNullOrEmpty(Author))
                {
                    IContentSequence koAuthor = iod.SrDocumentContent.CreateContentSequence();
                    koAuthor.InitializeAttributes();
                    koAuthor.ConceptNameCodeSequence = KeyObjectSelectionCodeSequences.PersonObserverName;
                    koAuthor.PersonName       = Author;
                    koAuthor.RelationshipType = RelationshipType.HasObsContext;
                    contentList.Add(koAuthor);
                }

                // add the description
                if (!string.IsNullOrEmpty(Description))
                {
                    IContentSequence koDescription = iod.SrDocumentContent.CreateContentSequence();
                    koDescription.InitializeAttributes();
                    koDescription.ConceptNameCodeSequence = KeyObjectSelectionCodeSequences.KeyObjectDescription;
                    koDescription.TextValue        = Description;
                    koDescription.RelationshipType = RelationshipType.Contains;
                    contentList.Add(koDescription);
                }

                // add each unique sop to the evidence list using the map built earlier
                foreach (var sop in frameMap.Distinct())
                {
                    currentRequestedProcedureEvidenceList.Add(sop);
                }

                // add each referenced presentation state to the evidence list as well
                foreach (var state in (IEnumerable <PresentationStateReference>)_framePresentationStates)
                {
                    if (state == null)
                    {
                        continue;
                    }
                    currentRequestedProcedureEvidenceList.Add(state);
                }

                // set the content and the evidence sequences
                iod.SrDocumentContent.ContentSequence = contentList.ToArray();
                iod.KeyObjectDocument.CurrentRequestedProcedureEvidenceSequence = currentRequestedProcedureEvidenceList.ToArray();
            }

            // set meta for the files
            foreach (DicomFile keyObjectDocument in keyObjectDocuments)
            {
                keyObjectDocument.MediaStorageSopClassUid    = keyObjectDocument.DataSet[DicomTags.SopClassUid].ToString();
                keyObjectDocument.MediaStorageSopInstanceUid = keyObjectDocument.DataSet[DicomTags.SopInstanceUid].ToString();
            }

            return(keyObjectDocuments);
        }
Exemple #3
0
        public void TestAddReference()
        {
            var dictionary = new HierarchicalSopInstanceReferenceDictionary();

            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location2", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid2", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2");
            dictionary.AddReference("study1", "series2", "sopclass1", "sopinst3");
            dictionary.AddReference("study2", "series3", "sopclass1", "sopinst4");

            Assert.AreEqual(2, dictionary.ListStudies().Count, "study count");
            Assert.AreEqual(8, dictionary.ListSeries("study1").Count, "study1 series count");
            Assert.AreEqual(1, dictionary.ListSeries("study2").Count, "study2 series count");

            Assert.AreEqual(2, dictionary.ListSops("study1", "series1", "", "", "", "").Count, "study1 series1 sop count");
            Assert.AreEqual(1, dictionary.ListSops("study1", "series2", "", "", "", "").Count, "study1 series2 sop count");
            Assert.AreEqual(1, dictionary.ListSops("study1", "series1", "aetitle1", "location1", "mediaid1", "mediauid1").Count, "study1 series1(1111) sop count");
            Assert.AreEqual(1, dictionary.ListSops("study1", "series1", "aetitle2", "location1", "mediaid1", "mediauid1").Count, "study1 series1(2111) sop count");
            Assert.AreEqual(1, dictionary.ListSops("study1", "series1", "aetitle1", "location2", "mediaid1", "mediauid1").Count, "study1 series1(1211) sop count");
            Assert.AreEqual(1, dictionary.ListSops("study1", "series1", "aetitle1", "location1", "mediaid2", "mediauid1").Count, "study1 series1(1121) sop count");
            Assert.AreEqual(1, dictionary.ListSops("study1", "series1", "aetitle1", "location1", "mediaid1", "mediauid2").Count, "study1 series1(1112) sop count");
            Assert.AreEqual(2, dictionary.ListSops("study1", "series1", "aetitle2", "location1", "mediaid1", "mediauid2").Count, "study1 series1(2112) sop count");

            Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "", "", "", ""), "study1 series1 sop check");
            Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series2", "sopinst3", "", "", "", ""), "study1 series2 sop check");
            Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid1"), "study1 series1(1111) sop check");
            Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid1"), "study1 series1(2111) sop check");
            Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle1", "location2", "mediaid1", "mediauid1"), "study1 series1(1211) sop check");
            Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle1", "location1", "mediaid2", "mediauid1"), "study1 series1(1121) sop check");
            Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid2"), "study1 series1(1112) sop check");
            Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop1 check");
            Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop2 check");

            Assert.AreEqual(1, dictionary.ListSops("study2", "series3", "", "", "", "").Count, "study2 series3 sop count");
            Assert.AreEqual("sopclass1", dictionary.GetSopClass("study2", "series3", "sopinst4", "", "", "", ""), "study2 series3 sop check");

            try
            {
                dictionary.AddReference("study1", "series1", "sopclass2", "sopinst1");
                Assert.Fail("Expected exception of type {0}", typeof(ArgumentException));
            }
            catch (ArgumentException) {}
        }
Exemple #4
0
        public void TestCount()
        {
            var dictionary = new HierarchicalSopInstanceReferenceDictionary();

            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location2", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid2", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2");
            dictionary.AddReference("study1", "series2", "sopclass1", "sopinst3");
            dictionary.AddReference("study2", "series3", "sopclass1", "sopinst4");

            Assert.AreEqual(11, dictionary.Count);
        }
Exemple #5
0
        public void TestToIod()
        {
            var dictionary = new HierarchicalSopInstanceReferenceDictionary();

            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location2", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid2", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series2", "sopclass1", "sopinst3");
            dictionary.AddReference("study2", "series3", "sopclass1", "sopinst4");

            var studies = dictionary.ToList().OrderBy(s => s.StudyInstanceUid).ToList();

            Assert.AreEqual(2, studies.Count, "study count");
            Assert.AreEqual("study1", studies[0].StudyInstanceUid, "study1");
            Assert.AreEqual("study2", studies[1].StudyInstanceUid, "study2");

            var study1Series = studies[0].ReferencedSeriesSequence.OrderBy(s => s.SeriesInstanceUid).ThenBy(s => s.RetrieveAeTitle).ThenBy(s => s.RetrieveLocationUid).ThenBy(s => s.StorageMediaFileSetId).ThenBy(s => s.StorageMediaFileSetUid).ToList();

            Assert.AreEqual(8, study1Series.Count, "study1 series count");

            Assert.AreEqual("series1", study1Series[0].SeriesInstanceUid, "study1 series1");
            Assert.AreEqual("", study1Series[0].RetrieveAeTitle, "study1 series1");
            Assert.AreEqual("", study1Series[0].RetrieveLocationUid, "study1 series1");
            Assert.AreEqual("", study1Series[0].StorageMediaFileSetId, "study1 series1");
            Assert.AreEqual("", study1Series[0].StorageMediaFileSetUid, "study1 series1");

            Assert.AreEqual("series1", study1Series[1].SeriesInstanceUid, "study1 series1(1111)");
            Assert.AreEqual("aetitle1", study1Series[1].RetrieveAeTitle, "study1 series1(1111)");
            Assert.AreEqual("location1", study1Series[1].RetrieveLocationUid, "study1 series1(1111)");
            Assert.AreEqual("mediaid1", study1Series[1].StorageMediaFileSetId, "study1 series1(1111)");
            Assert.AreEqual("mediauid1", study1Series[1].StorageMediaFileSetUid, "study1 series1(1111)");

            Assert.AreEqual("series1", study1Series[2].SeriesInstanceUid, "study1 series1(1112)");
            Assert.AreEqual("aetitle1", study1Series[2].RetrieveAeTitle, "study1 series1(1112)");
            Assert.AreEqual("location1", study1Series[2].RetrieveLocationUid, "study1 series1(1112)");
            Assert.AreEqual("mediaid1", study1Series[2].StorageMediaFileSetId, "study1 series1(1112)");
            Assert.AreEqual("mediauid2", study1Series[2].StorageMediaFileSetUid, "study1 series1(1112)");

            Assert.AreEqual("series1", study1Series[3].SeriesInstanceUid, "study1 series1(1121)");
            Assert.AreEqual("aetitle1", study1Series[3].RetrieveAeTitle, "study1 series1(1121)");
            Assert.AreEqual("location1", study1Series[3].RetrieveLocationUid, "study1 series1(1121)");
            Assert.AreEqual("mediaid2", study1Series[3].StorageMediaFileSetId, "study1 series1(1121)");
            Assert.AreEqual("mediauid1", study1Series[3].StorageMediaFileSetUid, "study1 series1(1121)");

            Assert.AreEqual("series1", study1Series[4].SeriesInstanceUid, "study1 series1(1211)");
            Assert.AreEqual("aetitle1", study1Series[4].RetrieveAeTitle, "study1 series1(1211)");
            Assert.AreEqual("location2", study1Series[4].RetrieveLocationUid, "study1 series1(1211)");
            Assert.AreEqual("mediaid1", study1Series[4].StorageMediaFileSetId, "study1 series1(1211)");
            Assert.AreEqual("mediauid1", study1Series[4].StorageMediaFileSetUid, "study1 series1(1211)");

            Assert.AreEqual("series1", study1Series[5].SeriesInstanceUid, "study1 series1(2111)");
            Assert.AreEqual("aetitle2", study1Series[5].RetrieveAeTitle, "study1 series1(2111)");
            Assert.AreEqual("location1", study1Series[5].RetrieveLocationUid, "study1 series1(2111)");
            Assert.AreEqual("mediaid1", study1Series[5].StorageMediaFileSetId, "study1 series1(2111)");
            Assert.AreEqual("mediauid1", study1Series[5].StorageMediaFileSetUid, "study1 series1(2111)");

            Assert.AreEqual("series1", study1Series[6].SeriesInstanceUid, "study1 series1(2112)");
            Assert.AreEqual("aetitle2", study1Series[6].RetrieveAeTitle, "study1 series1(2112)");
            Assert.AreEqual("location1", study1Series[6].RetrieveLocationUid, "study1 series1(2112)");
            Assert.AreEqual("mediaid1", study1Series[6].StorageMediaFileSetId, "study1 series1(2112)");
            Assert.AreEqual("mediauid2", study1Series[6].StorageMediaFileSetUid, "study1 series1(2112)");

            Assert.AreEqual("series2", study1Series[7].SeriesInstanceUid, "study1 series2");
            Assert.AreEqual("", study1Series[7].RetrieveAeTitle, "study1 series2");
            Assert.AreEqual("", study1Series[7].RetrieveLocationUid, "study1 series2");
            Assert.AreEqual("", study1Series[7].StorageMediaFileSetId, "study1 series2");
            Assert.AreEqual("", study1Series[7].StorageMediaFileSetUid, "study1 series2");

            var study1Series1Sops = study1Series[0].ReferencedSopSequence.OrderBy(s => s.ReferencedSopInstanceUid).ToList();

            Assert.AreEqual(1, study1Series1Sops.Count, "study1 series1 sop count");
            Assert.AreEqual("sopinst1", study1Series1Sops[0].ReferencedSopInstanceUid, "study1 series1 sop1");
            Assert.AreEqual("sopclass1", study1Series1Sops[0].ReferencedSopClassUid, "study1 series1 sop1");

            var study1Series12112Sops = study1Series[6].ReferencedSopSequence.OrderBy(s => s.ReferencedSopInstanceUid).ToList();

            Assert.AreEqual(2, study1Series12112Sops.Count, "study1 series1(2112) sop count");
            Assert.AreEqual("sopinst1", study1Series12112Sops[0].ReferencedSopInstanceUid, "study1 series1(2112) sop1");
            Assert.AreEqual("sopclass1", study1Series12112Sops[0].ReferencedSopClassUid, "study1 series1(2112) sop1");
            Assert.AreEqual("sopinst2", study1Series12112Sops[1].ReferencedSopInstanceUid, "study1 series1(2112) sop2");
            Assert.AreEqual("sopclass1", study1Series12112Sops[1].ReferencedSopClassUid, "study1 series1(2112) sop2");
        }
Exemple #6
0
        public void TestClear()
        {
            var dictionary = new HierarchicalSopInstanceReferenceDictionary();

            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location2", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid2", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2");
            dictionary.AddReference("study1", "series2", "sopclass1", "sopinst3");
            dictionary.AddReference("study2", "series3", "sopclass1", "sopinst4");

            dictionary.Clear();
            Assert.AreEqual(0, dictionary.Count, "count check");

            Assert.AreEqual(0, dictionary.ListSops("study1", "series1", "aetitle2", "location1", "mediaid1", "mediauid2").Count, "study1 series1(2112) sop count");
            Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop1 check");
            Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop2 check");
            Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst1", "", "", "", ""), "study1 series1 sop1 check");
            Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst2", "", "", "", ""), "study1 series1 sop1 check");
        }
		public void TestAddReference()
		{
			var dictionary = new HierarchicalSopInstanceReferenceDictionary();
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location2", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid2", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2");
			dictionary.AddReference("study1", "series2", "sopclass1", "sopinst3");
			dictionary.AddReference("study2", "series3", "sopclass1", "sopinst4");

			Assert.AreEqual(2, dictionary.ListStudies().Count, "study count");
			Assert.AreEqual(8, dictionary.ListSeries("study1").Count, "study1 series count");
			Assert.AreEqual(1, dictionary.ListSeries("study2").Count, "study2 series count");

			Assert.AreEqual(2, dictionary.ListSops("study1", "series1", "", "", "", "").Count, "study1 series1 sop count");
			Assert.AreEqual(1, dictionary.ListSops("study1", "series2", "", "", "", "").Count, "study1 series2 sop count");
			Assert.AreEqual(1, dictionary.ListSops("study1", "series1", "aetitle1", "location1", "mediaid1", "mediauid1").Count, "study1 series1(1111) sop count");
			Assert.AreEqual(1, dictionary.ListSops("study1", "series1", "aetitle2", "location1", "mediaid1", "mediauid1").Count, "study1 series1(2111) sop count");
			Assert.AreEqual(1, dictionary.ListSops("study1", "series1", "aetitle1", "location2", "mediaid1", "mediauid1").Count, "study1 series1(1211) sop count");
			Assert.AreEqual(1, dictionary.ListSops("study1", "series1", "aetitle1", "location1", "mediaid2", "mediauid1").Count, "study1 series1(1121) sop count");
			Assert.AreEqual(1, dictionary.ListSops("study1", "series1", "aetitle1", "location1", "mediaid1", "mediauid2").Count, "study1 series1(1112) sop count");
			Assert.AreEqual(2, dictionary.ListSops("study1", "series1", "aetitle2", "location1", "mediaid1", "mediauid2").Count, "study1 series1(2112) sop count");

			Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "", "", "", ""), "study1 series1 sop check");
			Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series2", "sopinst3", "", "", "", ""), "study1 series2 sop check");
			Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid1"), "study1 series1(1111) sop check");
			Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid1"), "study1 series1(2111) sop check");
			Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle1", "location2", "mediaid1", "mediauid1"), "study1 series1(1211) sop check");
			Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle1", "location1", "mediaid2", "mediauid1"), "study1 series1(1121) sop check");
			Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid2"), "study1 series1(1112) sop check");
			Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop1 check");
			Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop2 check");

			Assert.AreEqual(1, dictionary.ListSops("study2", "series3", "", "", "", "").Count, "study2 series3 sop count");
			Assert.AreEqual("sopclass1", dictionary.GetSopClass("study2", "series3", "sopinst4", "", "", "", ""), "study2 series3 sop check");

			try
			{
				dictionary.AddReference("study1", "series1", "sopclass2", "sopinst1");
				Assert.Fail("Expected exception of type {0}", typeof (ArgumentException));
			}
			catch (ArgumentException) {}
		}
Exemple #8
0
        public void TestRemoveReference()
        {
            var dictionary = new HierarchicalSopInstanceReferenceDictionary();

            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location2", "mediaid1", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid2", "mediauid1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2");
            dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2");
            dictionary.AddReference("study1", "series2", "sopclass1", "sopinst3");
            dictionary.AddReference("study2", "series3", "sopclass1", "sopinst4");

            Assert.IsFalse(dictionary.TryRemoveReference("study3", "series1", "sopclass1", "sopinst2"), "nonexistent study");
            Assert.IsFalse(dictionary.TryRemoveReference("study1", "series9", "sopclass1", "sopinst2"), "nonexistent series");
            Assert.IsFalse(dictionary.TryRemoveReference("study1", "series1", "sopclass1", "sopinst9"), "nonexistent sop");
            Assert.IsFalse(dictionary.TryRemoveReference("study1", "series1", "sopclass2", "sopinst1"), "nonexistent sop (class mismatch)");
            Assert.AreEqual(11, dictionary.Count, "count check");

            Assert.IsFalse(dictionary.TryRemoveReference("study1", "series1", "sopclass1", "sopinst1", "aetitle3", "location1", "mediaid1", "mediauid2"), "nonexistent series (aetitle mismatch");
            Assert.IsFalse(dictionary.TryRemoveReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location3", "mediaid1", "mediauid2"), "nonexistent series (location mismatch");
            Assert.IsFalse(dictionary.TryRemoveReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid3", "mediauid2"), "nonexistent series (mediaid mismatch");
            Assert.IsFalse(dictionary.TryRemoveReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid3"), "nonexistent series (medauid mismatch");
            Assert.AreEqual(11, dictionary.Count, "count check");

            Assert.IsTrue(dictionary.TryRemoveReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2"), "remove 1 sop");
            Assert.AreEqual(1, dictionary.ListSops("study1", "series1", "aetitle2", "location1", "mediaid1", "mediauid2").Count, "study1 series1(2112) sop count");
            Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop1 check");
            Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop2 check");
            Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "", "", "", ""), "study1 series1 sop1 check");
            Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst2", "", "", "", ""), "study1 series1 sop1 check");
            Assert.AreEqual(10, dictionary.Count, "count check");

            Assert.IsTrue(dictionary.TryRemoveReference("study1", "series1", "sopclass1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2"), "remove 1 sop");
            Assert.AreEqual(0, dictionary.ListSops("study1", "series1", "aetitle2", "location1", "mediaid1", "mediauid2").Count, "study1 series1(2112) sop count");
            Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop1 check");
            Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop2 check");
            Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "", "", "", ""), "study1 series1 sop1 check");
            Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst2", "", "", "", ""), "study1 series1 sop1 check");
            Assert.AreEqual(9, dictionary.Count, "count check");

            Assert.IsTrue(dictionary.TryRemoveReference("study1", "series1", "sopclass1", "sopinst1"), "remove all series1");
            Assert.AreEqual(0, dictionary.ListSops("study1", "series1", "aetitle2", "location1", "mediaid1", "mediauid2").Count, "study1 series1(2112) sop count");
            Assert.AreEqual(0, dictionary.ListSops("study1", "series1", "aetitle1", "location1", "mediaid1", "mediauid2").Count, "study1 series1(1112) sop count");
            Assert.AreEqual(1, dictionary.ListSops("study1", "series1", "", "", "", "").Count, "study1 series1(1112) sop count");
            Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop1 check");
            Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop1 check");
            Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst1", "", "", "", ""), "study1 series1 sop1 check");
            Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst2", "", "", "", ""), "study1 series1 sop1 check");
            Assert.AreEqual(3, dictionary.Count, "count check");
        }
		public void TestCount()
		{
			var dictionary = new HierarchicalSopInstanceReferenceDictionary();
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location2", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid2", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2");
			dictionary.AddReference("study1", "series2", "sopclass1", "sopinst3");
			dictionary.AddReference("study2", "series3", "sopclass1", "sopinst4");

			Assert.AreEqual(11, dictionary.Count);
		}
		public void TestToIod()
		{
			var dictionary = new HierarchicalSopInstanceReferenceDictionary();
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location2", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid2", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series2", "sopclass1", "sopinst3");
			dictionary.AddReference("study2", "series3", "sopclass1", "sopinst4");

			var studies = dictionary.ToList().OrderBy(s => s.StudyInstanceUid).ToList();
			Assert.AreEqual(2, studies.Count, "study count");
			Assert.AreEqual("study1", studies[0].StudyInstanceUid, "study1");
			Assert.AreEqual("study2", studies[1].StudyInstanceUid, "study2");

			var study1Series = studies[0].ReferencedSeriesSequence.OrderBy(s => s.SeriesInstanceUid).ThenBy(s => s.RetrieveAeTitle).ThenBy(s => s.RetrieveLocationUid).ThenBy(s => s.StorageMediaFileSetId).ThenBy(s => s.StorageMediaFileSetUid).ToList();
			Assert.AreEqual(8, study1Series.Count, "study1 series count");

			Assert.AreEqual("series1", study1Series[0].SeriesInstanceUid, "study1 series1");
			Assert.AreEqual("", study1Series[0].RetrieveAeTitle, "study1 series1");
			Assert.AreEqual("", study1Series[0].RetrieveLocationUid, "study1 series1");
			Assert.AreEqual("", study1Series[0].StorageMediaFileSetId, "study1 series1");
			Assert.AreEqual("", study1Series[0].StorageMediaFileSetUid, "study1 series1");

			Assert.AreEqual("series1", study1Series[1].SeriesInstanceUid, "study1 series1(1111)");
			Assert.AreEqual("aetitle1", study1Series[1].RetrieveAeTitle, "study1 series1(1111)");
			Assert.AreEqual("location1", study1Series[1].RetrieveLocationUid, "study1 series1(1111)");
			Assert.AreEqual("mediaid1", study1Series[1].StorageMediaFileSetId, "study1 series1(1111)");
			Assert.AreEqual("mediauid1", study1Series[1].StorageMediaFileSetUid, "study1 series1(1111)");

			Assert.AreEqual("series1", study1Series[2].SeriesInstanceUid, "study1 series1(1112)");
			Assert.AreEqual("aetitle1", study1Series[2].RetrieveAeTitle, "study1 series1(1112)");
			Assert.AreEqual("location1", study1Series[2].RetrieveLocationUid, "study1 series1(1112)");
			Assert.AreEqual("mediaid1", study1Series[2].StorageMediaFileSetId, "study1 series1(1112)");
			Assert.AreEqual("mediauid2", study1Series[2].StorageMediaFileSetUid, "study1 series1(1112)");

			Assert.AreEqual("series1", study1Series[3].SeriesInstanceUid, "study1 series1(1121)");
			Assert.AreEqual("aetitle1", study1Series[3].RetrieveAeTitle, "study1 series1(1121)");
			Assert.AreEqual("location1", study1Series[3].RetrieveLocationUid, "study1 series1(1121)");
			Assert.AreEqual("mediaid2", study1Series[3].StorageMediaFileSetId, "study1 series1(1121)");
			Assert.AreEqual("mediauid1", study1Series[3].StorageMediaFileSetUid, "study1 series1(1121)");

			Assert.AreEqual("series1", study1Series[4].SeriesInstanceUid, "study1 series1(1211)");
			Assert.AreEqual("aetitle1", study1Series[4].RetrieveAeTitle, "study1 series1(1211)");
			Assert.AreEqual("location2", study1Series[4].RetrieveLocationUid, "study1 series1(1211)");
			Assert.AreEqual("mediaid1", study1Series[4].StorageMediaFileSetId, "study1 series1(1211)");
			Assert.AreEqual("mediauid1", study1Series[4].StorageMediaFileSetUid, "study1 series1(1211)");

			Assert.AreEqual("series1", study1Series[5].SeriesInstanceUid, "study1 series1(2111)");
			Assert.AreEqual("aetitle2", study1Series[5].RetrieveAeTitle, "study1 series1(2111)");
			Assert.AreEqual("location1", study1Series[5].RetrieveLocationUid, "study1 series1(2111)");
			Assert.AreEqual("mediaid1", study1Series[5].StorageMediaFileSetId, "study1 series1(2111)");
			Assert.AreEqual("mediauid1", study1Series[5].StorageMediaFileSetUid, "study1 series1(2111)");

			Assert.AreEqual("series1", study1Series[6].SeriesInstanceUid, "study1 series1(2112)");
			Assert.AreEqual("aetitle2", study1Series[6].RetrieveAeTitle, "study1 series1(2112)");
			Assert.AreEqual("location1", study1Series[6].RetrieveLocationUid, "study1 series1(2112)");
			Assert.AreEqual("mediaid1", study1Series[6].StorageMediaFileSetId, "study1 series1(2112)");
			Assert.AreEqual("mediauid2", study1Series[6].StorageMediaFileSetUid, "study1 series1(2112)");

			Assert.AreEqual("series2", study1Series[7].SeriesInstanceUid, "study1 series2");
			Assert.AreEqual("", study1Series[7].RetrieveAeTitle, "study1 series2");
			Assert.AreEqual("", study1Series[7].RetrieveLocationUid, "study1 series2");
			Assert.AreEqual("", study1Series[7].StorageMediaFileSetId, "study1 series2");
			Assert.AreEqual("", study1Series[7].StorageMediaFileSetUid, "study1 series2");

			var study1Series1Sops = study1Series[0].ReferencedSopSequence.OrderBy(s => s.ReferencedSopInstanceUid).ToList();
			Assert.AreEqual(1, study1Series1Sops.Count, "study1 series1 sop count");
			Assert.AreEqual("sopinst1", study1Series1Sops[0].ReferencedSopInstanceUid, "study1 series1 sop1");
			Assert.AreEqual("sopclass1", study1Series1Sops[0].ReferencedSopClassUid, "study1 series1 sop1");

			var study1Series12112Sops = study1Series[6].ReferencedSopSequence.OrderBy(s => s.ReferencedSopInstanceUid).ToList();
			Assert.AreEqual(2, study1Series12112Sops.Count, "study1 series1(2112) sop count");
			Assert.AreEqual("sopinst1", study1Series12112Sops[0].ReferencedSopInstanceUid, "study1 series1(2112) sop1");
			Assert.AreEqual("sopclass1", study1Series12112Sops[0].ReferencedSopClassUid, "study1 series1(2112) sop1");
			Assert.AreEqual("sopinst2", study1Series12112Sops[1].ReferencedSopInstanceUid, "study1 series1(2112) sop2");
			Assert.AreEqual("sopclass1", study1Series12112Sops[1].ReferencedSopClassUid, "study1 series1(2112) sop2");
		}
		public void TestClear()
		{
			var dictionary = new HierarchicalSopInstanceReferenceDictionary();
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location2", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid2", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2");
			dictionary.AddReference("study1", "series2", "sopclass1", "sopinst3");
			dictionary.AddReference("study2", "series3", "sopclass1", "sopinst4");

			dictionary.Clear();
			Assert.AreEqual(0, dictionary.Count, "count check");

			Assert.AreEqual(0, dictionary.ListSops("study1", "series1", "aetitle2", "location1", "mediaid1", "mediauid2").Count, "study1 series1(2112) sop count");
			Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop1 check");
			Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop2 check");
			Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst1", "", "", "", ""), "study1 series1 sop1 check");
			Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst2", "", "", "", ""), "study1 series1 sop1 check");
		}
		public void TestContainsReference()
		{
			var dictionary = new HierarchicalSopInstanceReferenceDictionary();
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location2", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid2", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series2", "sopclass1", "sopinst3");
			dictionary.AddReference("study2", "series3", "sopclass1", "sopinst4");

			Assert.IsFalse(dictionary.ContainsReference("study3", "series1", "sopclass1", "sopinst2"), "nonexistent study");
			Assert.IsFalse(dictionary.ContainsReference("study1", "series9", "sopclass1", "sopinst2"), "nonexistent series");
			Assert.IsFalse(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst9"), "nonexistent sop");
			Assert.IsFalse(dictionary.ContainsReference("study1", "series1", "sopclass2", "sopinst1"), "nonexistent sop (class mismatch)");

			Assert.IsFalse(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst1", "aetitle3", "location1", "mediaid1", "mediauid2"), "nonexistent series (aetitle mismatch");
			Assert.IsFalse(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location3", "mediaid1", "mediauid2"), "nonexistent series (location mismatch");
			Assert.IsFalse(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid3", "mediauid2"), "nonexistent series (mediaid mismatch");
			Assert.IsFalse(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid3"), "nonexistent series (medauid mismatch");

			Assert.IsTrue(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2"), "contains sop1");
			Assert.IsTrue(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2"), "contains sop2");
			Assert.IsTrue(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst1"), "contains any series1 sop1");
			Assert.IsTrue(dictionary.ContainsReference("study1", "series1", "sopclass1", "sopinst2"), "contains any series1 sop2");
		}
		public void TestRemoveReference()
		{
			var dictionary = new HierarchicalSopInstanceReferenceDictionary();
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location2", "mediaid1", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid2", "mediauid1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst1");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2");
			dictionary.AddReference("study1", "series1", "sopclass1", "sopinst2");
			dictionary.AddReference("study1", "series2", "sopclass1", "sopinst3");
			dictionary.AddReference("study2", "series3", "sopclass1", "sopinst4");

			Assert.IsFalse(dictionary.TryRemoveReference("study3", "series1", "sopclass1", "sopinst2"), "nonexistent study");
			Assert.IsFalse(dictionary.TryRemoveReference("study1", "series9", "sopclass1", "sopinst2"), "nonexistent series");
			Assert.IsFalse(dictionary.TryRemoveReference("study1", "series1", "sopclass1", "sopinst9"), "nonexistent sop");
			Assert.IsFalse(dictionary.TryRemoveReference("study1", "series1", "sopclass2", "sopinst1"), "nonexistent sop (class mismatch)");
			Assert.AreEqual(11, dictionary.Count, "count check");

			Assert.IsFalse(dictionary.TryRemoveReference("study1", "series1", "sopclass1", "sopinst1", "aetitle3", "location1", "mediaid1", "mediauid2"), "nonexistent series (aetitle mismatch");
			Assert.IsFalse(dictionary.TryRemoveReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location3", "mediaid1", "mediauid2"), "nonexistent series (location mismatch");
			Assert.IsFalse(dictionary.TryRemoveReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid3", "mediauid2"), "nonexistent series (mediaid mismatch");
			Assert.IsFalse(dictionary.TryRemoveReference("study1", "series1", "sopclass1", "sopinst1", "aetitle1", "location1", "mediaid1", "mediauid3"), "nonexistent series (medauid mismatch");
			Assert.AreEqual(11, dictionary.Count, "count check");

			Assert.IsTrue(dictionary.TryRemoveReference("study1", "series1", "sopclass1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2"), "remove 1 sop");
			Assert.AreEqual(1, dictionary.ListSops("study1", "series1", "aetitle2", "location1", "mediaid1", "mediauid2").Count, "study1 series1(2112) sop count");
			Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop1 check");
			Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop2 check");
			Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "", "", "", ""), "study1 series1 sop1 check");
			Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst2", "", "", "", ""), "study1 series1 sop1 check");
			Assert.AreEqual(10, dictionary.Count, "count check");

			Assert.IsTrue(dictionary.TryRemoveReference("study1", "series1", "sopclass1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2"), "remove 1 sop");
			Assert.AreEqual(0, dictionary.ListSops("study1", "series1", "aetitle2", "location1", "mediaid1", "mediauid2").Count, "study1 series1(2112) sop count");
			Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop1 check");
			Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst2", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop2 check");
			Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst1", "", "", "", ""), "study1 series1 sop1 check");
			Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst2", "", "", "", ""), "study1 series1 sop1 check");
			Assert.AreEqual(9, dictionary.Count, "count check");

			Assert.IsTrue(dictionary.TryRemoveReference("study1", "series1", "sopclass1", "sopinst1"), "remove all series1");
			Assert.AreEqual(0, dictionary.ListSops("study1", "series1", "aetitle2", "location1", "mediaid1", "mediauid2").Count, "study1 series1(2112) sop count");
			Assert.AreEqual(0, dictionary.ListSops("study1", "series1", "aetitle1", "location1", "mediaid1", "mediauid2").Count, "study1 series1(1112) sop count");
			Assert.AreEqual(1, dictionary.ListSops("study1", "series1", "", "", "", "").Count, "study1 series1(1112) sop count");
			Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop1 check");
			Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst1", "aetitle2", "location1", "mediaid1", "mediauid2"), "study1 series1(2112) sop1 check");
			Assert.AreEqual(null, dictionary.GetSopClass("study1", "series1", "sopinst1", "", "", "", ""), "study1 series1 sop1 check");
			Assert.AreEqual("sopclass1", dictionary.GetSopClass("study1", "series1", "sopinst2", "", "", "", ""), "study1 series1 sop1 check");
			Assert.AreEqual(3, dictionary.Count, "count check");
		}