Exemplo n.º 1
0
        /// <summary>
        /// Retrieve a list of filenames from the Information Model. The filenames match the
        /// individual instances matching the retrieve dataset attributes.
        /// </summary>
        /// <param name="retrieveDataset">Retrive dataset.</param>
        /// <returns>File list - containing the filenames of all instances matching the retrieve dataset attributes.</returns>
        public DvtkData.Collections.StringCollection RetrieveInformationModel(DataSet retrieveDataset)
        {
            DvtkData.Collections.StringCollection fileList = new DvtkData.Collections.StringCollection();

            // get the query/retrieve level
            String queryRetrieveLevel = "UNKNOWN";

            DvtkData.Dimse.Attribute queryRetrieveLevelAttribute = retrieveDataset.GetAttribute(Tag.QUERY_RETRIEVE_LEVEL);
            if (queryRetrieveLevelAttribute != null)
            {
                CodeString codeString = (CodeString)queryRetrieveLevelAttribute.DicomValue;
                if (codeString.Values.Count == 1)
                {
                    queryRetrieveLevel = codeString.Values[0].Trim();
                }
            }

            // find the matching STUDY
            StudyInformationEntity studyInformationEntity = null;

            foreach (StudyInformationEntity lStudyInformationEntity in Root)
            {
                if (lStudyInformationEntity.IsUniqueTagFoundIn(retrieveDataset))
                {
                    studyInformationEntity = lStudyInformationEntity;
                    break;
                }
            }

            if (studyInformationEntity != null)
            {
                // retrieve at the STUDY level
                if (queryRetrieveLevel == "STUDY")
                {
                    foreach (SeriesInformationEntity seriesInformationEntity in studyInformationEntity.Children)
                    {
                        foreach (InstanceInformationEntity instanceInformationEntity in seriesInformationEntity.Children)
                        {
                            fileList.Add(instanceInformationEntity.Filename);
                        }
                    }
                }
                else
                {
                    // find the matching SERIES
                    SeriesInformationEntity seriesInformationEntity = null;
                    foreach (SeriesInformationEntity lSeriesInformationEntity in studyInformationEntity.Children)
                    {
                        if (lSeriesInformationEntity.IsUniqueTagFoundIn(retrieveDataset))
                        {
                            seriesInformationEntity = lSeriesInformationEntity;
                            break;
                        }
                    }
                    if (seriesInformationEntity != null)
                    {
                        // retrieve at the SERIES level
                        if (queryRetrieveLevel == "SERIES")
                        {
                            foreach (InstanceInformationEntity instanceInformationEntity in seriesInformationEntity.Children)
                            {
                                fileList.Add(instanceInformationEntity.Filename);
                            }
                        }
                        else
                        {
                            // find the matching IMAGE
                            InstanceInformationEntity instanceInformationEntity = null;
                            foreach (InstanceInformationEntity lInstanceInformationEntity in seriesInformationEntity.Children)
                            {
                                if (lInstanceInformationEntity.IsUniqueTagFoundIn(retrieveDataset))
                                {
                                    instanceInformationEntity = lInstanceInformationEntity;
                                    break;
                                }
                            }

                            // retrieve at the IMAGE level
                            if ((instanceInformationEntity != null) &&
                                (queryRetrieveLevel == "IMAGE"))
                            {
                                fileList.Add(instanceInformationEntity.Filename);
                            }
                        }
                    }
                }
            }

            return(fileList);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add the given Dataset to the Information Model. The data is normalised into the Information Model.
        /// </summary>
        /// <param name="dataset">Dataset to add to Informatio Model.</param>
        public override void AddToInformationModel(DataSet dataset)
        {
            // PATIENT level
            PatientInformationEntity patientInformationEntity = null;

            // check if the patient IE is already in the patientRootList
            foreach (PatientInformationEntity lPatientInformationEntity in Root)
            {
                if (lPatientInformationEntity.IsFoundIn(dataset))
                {
                    patientInformationEntity = lPatientInformationEntity;
                    break;
                }
            }

            // patient IE is not already in the patientRootList
            if (patientInformationEntity == null)
            {
                // create a new patient IE from the dataset and add to the patientRootList
                patientInformationEntity = new PatientInformationEntity();
                patientInformationEntity.CopyFrom(dataset);
                Root.Add(patientInformationEntity);
            }

            // STUDY level
            StudyInformationEntity studyInformationEntity = null;

            // check if the study IE is already in the patient IE children
            foreach (StudyInformationEntity lStudyInformationEntity in patientInformationEntity.Children)
            {
                if (lStudyInformationEntity.IsFoundIn(dataset))
                {
                    studyInformationEntity = lStudyInformationEntity;
                    break;
                }
            }

            // study IE is not already in the patient IE children
            if (studyInformationEntity == null)
            {
                // create a new study IE from the dataset and add to the patient IE children
                studyInformationEntity = new StudyInformationEntity();
                studyInformationEntity.CopyFrom(dataset);
                patientInformationEntity.AddChild(studyInformationEntity);
            }

            // SERIES level
            SeriesInformationEntity seriesInformationEntity = null;

            // check if the series IE is already in the study IE children
            foreach (SeriesInformationEntity lSeriesInformationEntity in studyInformationEntity.Children)
            {
                if (lSeriesInformationEntity.IsFoundIn(dataset))
                {
                    seriesInformationEntity = lSeriesInformationEntity;
                    break;
                }
            }

            // series IE is not already in the study IE children
            if (seriesInformationEntity == null)
            {
                // create a new series IE from the dataset and add to the study IE children
                seriesInformationEntity = new SeriesInformationEntity();
                seriesInformationEntity.CopyFrom(dataset);
                studyInformationEntity.AddChild(seriesInformationEntity);
            }

            // IMAGE (Instance) level
            InstanceInformationEntity instanceInformationEntity = null;

            // check if the instance IE is already in the series IE children
            foreach (InstanceInformationEntity lInstanceInformationEntity in seriesInformationEntity.Children)
            {
                if (lInstanceInformationEntity.IsFoundIn(dataset))
                {
                    instanceInformationEntity = lInstanceInformationEntity;
                    break;
                }
            }

            // instance IE is not already in the series IE children
            if (instanceInformationEntity == null)
            {
                // create a new instance IE from the dataset and add to the series IE children
                instanceInformationEntity = new InstanceInformationEntity(dataset.Filename);
                instanceInformationEntity.CopyFrom(dataset);
                seriesInformationEntity.AddChild(instanceInformationEntity);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Query the Information Model using the given Query Dataset.
        /// </summary>
        /// <param name="queryDataset">Query Dataset.</param>
        /// <returns>A collection of zero or more query reponse datasets.</returns>
        public override DataSetCollection QueryInformationModel(DataSet queryDataset)
        {
            DataSetCollection queryResponses = null;

            // get the query/retrieve level
            String queryRetrieveLevel = "UNKNOWN";

            DvtkData.Dimse.Attribute queryRetrieveLevelAttribute = queryDataset.GetAttribute(Tag.QUERY_RETRIEVE_LEVEL);
            if (queryRetrieveLevelAttribute != null)
            {
                CodeString codeString = (CodeString)queryRetrieveLevelAttribute.DicomValue;
                if (codeString.Values.Count == 1)
                {
                    queryRetrieveLevel = codeString.Values[0].Trim();
                }
            }

            // query at the STUDY level
            if (queryRetrieveLevel == "STUDY")
            {
                TagTypeList queryTagTypeList  = new TagTypeList();
                TagTypeList returnTagTypeList = new TagTypeList();
                foreach (DvtkData.Dimse.Attribute attribute in queryDataset)
                {
                    if (attribute.Length != 0)
                    {
                        queryTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagRequired));
                    }
                    returnTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagOptional));
                }


                foreach (StudyInformationEntity studyInformationEntity in Root)
                {
                    if (studyInformationEntity.IsFoundIn(queryTagTypeList, queryDataset))
                    {
                        // STUDY level matches
                        DataSet queryResponse = new DataSet();
                        studyInformationEntity.CopyTo(returnTagTypeList, queryResponse);
                        queryResponses.Add(queryResponse);
                    }
                }
            }
            else
            {
                // find the matching STUDY
                StudyInformationEntity studyInformationEntity = null;
                foreach (StudyInformationEntity lStudyInformationEntity in Root)
                {
                    if (lStudyInformationEntity.IsUniqueTagFoundIn(queryDataset))
                    {
                        studyInformationEntity = lStudyInformationEntity;
                        break;
                    }
                }

                if (studyInformationEntity != null)
                {
                    // query at the SERIES level
                    if (queryRetrieveLevel == "SERIES")
                    {
                        TagTypeList queryTagTypeList  = new TagTypeList();
                        TagTypeList returnTagTypeList = new TagTypeList();
                        foreach (DvtkData.Dimse.Attribute attribute in queryDataset)
                        {
                            // do not add higher level tags
                            if (attribute.Tag == Tag.STUDY_INSTANCE_UID)
                            {
                                continue;
                            }

                            if (attribute.Length != 0)
                            {
                                queryTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagRequired));
                            }
                            returnTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagOptional));
                        }

                        foreach (SeriesInformationEntity seriesInformationEntity in studyInformationEntity.Children)
                        {
                            if (seriesInformationEntity.IsFoundIn(queryTagTypeList, queryDataset))
                            {
                                // SERIES level matches
                                DataSet queryResponse = new DataSet();
                                studyInformationEntity.CopyUniqueTagTo(queryResponse);
                                seriesInformationEntity.CopyTo(returnTagTypeList, queryResponse);
                                queryResponses.Add(queryResponse);
                            }
                        }
                    }
                    else
                    {
                        // find the matching SERIES
                        SeriesInformationEntity seriesInformationEntity = null;
                        foreach (SeriesInformationEntity lSeriesInformationEntity in studyInformationEntity.Children)
                        {
                            if (lSeriesInformationEntity.IsUniqueTagFoundIn(queryDataset))
                            {
                                seriesInformationEntity = lSeriesInformationEntity;
                                break;
                            }
                        }

                        if (seriesInformationEntity != null)
                        {
                            // query at the IMAGE level
                            if (queryRetrieveLevel == "IMAGE")
                            {
                                TagTypeList queryTagTypeList  = new TagTypeList();
                                TagTypeList returnTagTypeList = new TagTypeList();
                                foreach (DvtkData.Dimse.Attribute attribute in queryDataset)
                                {
                                    // do not add higher level tags
                                    if ((attribute.Tag == Tag.STUDY_INSTANCE_UID) ||
                                        (attribute.Tag == Tag.SERIES_INSTANCE_UID))
                                    {
                                        continue;
                                    }

                                    if (attribute.Length != 0)
                                    {
                                        queryTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagRequired));
                                    }
                                    returnTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagOptional));
                                }

                                foreach (InstanceInformationEntity instanceInformationEntity in seriesInformationEntity.Children)
                                {
                                    if (instanceInformationEntity.IsFoundIn(queryTagTypeList, queryDataset))
                                    {
                                        // IMAGE level matches
                                        DataSet queryResponse = new DataSet();
                                        studyInformationEntity.CopyUniqueTagTo(queryResponse);
                                        seriesInformationEntity.CopyUniqueTagTo(queryResponse);
                                        instanceInformationEntity.CopyTo(returnTagTypeList, queryResponse);
                                        queryResponses.Add(queryResponse);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(queryResponses);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Add the given dataset present in a Dicom File to the Information Model. The data is normalised into the Information Model.
        /// </summary>
        /// <param name="dicomFile">The dicom File containing the dataset to be added.</param>
        /// <param name="storeFile">Boolean indicating whether the dataset should be stored or not.</param>
        public override void AddToInformationModel(DvtkData.Media.DicomFile dicomFile, bool storeFile)
        {
            // STUDY level
            PatientStudyInformationEntity patientStudyInformationEntity = null;

            this.IsDataStored = storeFile;

            // check if the patient/study IE is already in the studyRootList
            foreach (PatientStudyInformationEntity lPatientStudyInformationEntity in Root)
            {
                if (lPatientStudyInformationEntity.IsUniqueTagFoundIn(dicomFile.DataSet))
                {
                    patientStudyInformationEntity = lPatientStudyInformationEntity;
                    patientStudyInformationEntity.CheckForSpecialTags(dicomFile.DataSet);
                    break;
                }
            }

            // patient/study IE is not already in the studyRootList
            if (patientStudyInformationEntity == null)
            {
                // create a new patient/study IE from the dataset and add to the studyRootList
                patientStudyInformationEntity = new PatientStudyInformationEntity();
                patientStudyInformationEntity.CopyFrom(dicomFile.DataSet);
                Root.Add(patientStudyInformationEntity);
            }

            // SERIES level
            SeriesInformationEntity seriesInformationEntity = null;

            // check if the series IE is already in the study IE children
            foreach (SeriesInformationEntity lSeriesInformationEntity in patientStudyInformationEntity.Children)
            {
                if (lSeriesInformationEntity.IsUniqueTagFoundIn(dicomFile.DataSet))
                {
                    seriesInformationEntity = lSeriesInformationEntity;
                    seriesInformationEntity.CheckForSpecialTags(dicomFile.DataSet);
                    break;
                }
            }

            // series IE is not already in the study IE children
            if (seriesInformationEntity == null)
            {
                // create a new series IE from the dataset and add to the study IE children
                seriesInformationEntity = new SeriesInformationEntity();
                seriesInformationEntity.CopyFrom(dicomFile.DataSet);
                patientStudyInformationEntity.AddChild(seriesInformationEntity);
            }

            // IMAGE (Instance) level
            InstanceInformationEntity instanceInformationEntity = null;

            // check if the instance IE is already in the series IE children
            foreach (InstanceInformationEntity lInstanceInformationEntity in seriesInformationEntity.Children)
            {
                if (lInstanceInformationEntity.IsUniqueTagFoundIn(dicomFile.DataSet))
                {
                    instanceInformationEntity = lInstanceInformationEntity;
                    instanceInformationEntity.CheckForSpecialTags(dicomFile.DataSet);
                    break;
                }
            }

            // instance IE is not already in the series IE children
            if (instanceInformationEntity == null)
            {
                // Store the dicom File as a DCM file if requested.
                if (storeFile == true)
                {
                    StoreDicomFile(dicomFile);
                }

                // create a new instance IE from the dataset and add to the series IE children
                instanceInformationEntity = new InstanceInformationEntity(dicomFile.DataSet.Filename);
                instanceInformationEntity.CopyFrom(dicomFile.DataSet);
                seriesInformationEntity.AddChild(instanceInformationEntity);
            }

            patientStudyInformationEntity.CheckForSpecialTags(dicomFile.DataSet);
            seriesInformationEntity.CheckForSpecialTags(dicomFile.DataSet);
            instanceInformationEntity.CheckForSpecialTags(dicomFile.DataSet);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Query the Information Model using the given Query Dataset.
        /// </summary>
        /// <param name="queryDataset">Query Dataset.</param>
        /// <returns>A collection of zero or more query reponse datasets.</returns>
        public override DataSetCollection QueryInformationModel(DataSet queryDataset)
        {
            DataSetCollection queryResponses = new DataSetCollection();;

            // get the query/retrieve level
            String queryRetrieveLevel = "UNKNOWN";

            DvtkData.Dimse.Attribute queryRetrieveLevelAttribute = queryDataset.GetAttribute(Tag.QUERY_RETRIEVE_LEVEL);
            if (queryRetrieveLevelAttribute != null)
            {
                CodeString codeString = (CodeString)queryRetrieveLevelAttribute.DicomValue;
                if (codeString.Values.Count == 1)
                {
                    queryRetrieveLevel = codeString.Values[0].Trim();
                }
            }

            // query at the STUDY level
            if (queryRetrieveLevel == "STUDY")
            {
                TagTypeList queryTagTypeList  = new TagTypeList();
                TagTypeList returnTagTypeList = new TagTypeList();
                foreach (DvtkData.Dimse.Attribute attribute in queryDataset)
                {
                    if (attribute.ValueRepresentation == VR.SQ)
                    {
                        foreach (SequenceItem s in ((SequenceOfItems)attribute.DicomValue).Sequence)
                        {
                            if (IsSequenceHavingValue(s))
                            {
                                queryTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagRequired));
                            }
                        }
                    }

                    else if ((attribute.Length != 0) &&
                             (attribute.Tag.ElementNumber != 0x0000))
                    {
                        queryTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagRequired));
                    }
                    if (attribute.Tag != Tag.SPECIFIC_CHARACTER_SET)
                    {
                        returnTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagOptional));
                    }
                }

                foreach (PatientStudyInformationEntity patientStudyInformationEntity in Root)
                {
                    if (patientStudyInformationEntity.IsFoundIn(queryTagTypeList, queryDataset))
                    {
                        // STUDY level matches
                        DataSet queryResponse = new DataSet();

                        // if the specific character set attribute has been stored in the patient/study IE - return it in the query response
                        DvtkData.Dimse.Attribute specificCharacterSetAttribute = patientStudyInformationEntity.GetSpecificCharacterSet();
                        if (specificCharacterSetAttribute != null)
                        {
                            queryResponse.Add(specificCharacterSetAttribute);
                        }

                        patientStudyInformationEntity.CopyTo(returnTagTypeList, queryResponse);
                        queryResponses.Add(queryResponse);
                    }
                }
            }
            else
            {
                // find the matching STUDY
                PatientStudyInformationEntity patientStudyInformationEntity = null;
                foreach (PatientStudyInformationEntity lPatientStudyInformationEntity in Root)
                {
                    if (lPatientStudyInformationEntity.IsUniqueTagFoundIn(queryDataset))
                    {
                        patientStudyInformationEntity = lPatientStudyInformationEntity;
                        break;
                    }
                }

                if (patientStudyInformationEntity != null)
                {
                    // query at the SERIES level
                    if (queryRetrieveLevel == "SERIES")
                    {
                        TagTypeList queryTagTypeList  = new TagTypeList();
                        TagTypeList returnTagTypeList = new TagTypeList();
                        foreach (DvtkData.Dimse.Attribute attribute in queryDataset)
                        {
                            // do not add higher level tags
                            if (attribute.Tag == Tag.STUDY_INSTANCE_UID)
                            {
                                continue;
                            }

                            if (attribute.ValueRepresentation == VR.SQ)
                            {
                                foreach (SequenceItem s in ((SequenceOfItems)attribute.DicomValue).Sequence)
                                {
                                    if (IsSequenceHavingValue(s))
                                    {
                                        queryTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagRequired));
                                    }
                                }
                            }

                            else if ((attribute.Length != 0) &&
                                     (attribute.Tag.ElementNumber != 0x0000))
                            {
                                queryTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagRequired));
                            }
                            returnTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagOptional));
                        }

                        foreach (SeriesInformationEntity seriesInformationEntity in patientStudyInformationEntity.Children)
                        {
                            if (seriesInformationEntity.IsFoundIn(queryTagTypeList, queryDataset))
                            {
                                // SERIES level matches
                                DataSet queryResponse = new DataSet();

                                // if the specific character set attribute has been stored in the series IE - return it in the query response
                                DvtkData.Dimse.Attribute specificCharacterSetAttribute = seriesInformationEntity.GetSpecificCharacterSet();
                                if (specificCharacterSetAttribute != null)
                                {
                                    queryResponse.Add(specificCharacterSetAttribute);
                                }

                                patientStudyInformationEntity.CopyUniqueTagTo(queryResponse);
                                seriesInformationEntity.CopyTo(returnTagTypeList, queryResponse);
                                queryResponses.Add(queryResponse);
                            }
                        }
                    }
                    else
                    {
                        // find the matching SERIES
                        SeriesInformationEntity seriesInformationEntity = null;
                        foreach (SeriesInformationEntity lSeriesInformationEntity in patientStudyInformationEntity.Children)
                        {
                            if (lSeriesInformationEntity.IsUniqueTagFoundIn(queryDataset))
                            {
                                seriesInformationEntity = lSeriesInformationEntity;
                                break;
                            }
                        }

                        if (seriesInformationEntity != null)
                        {
                            // query at the IMAGE level
                            if (queryRetrieveLevel == "IMAGE")
                            {
                                TagTypeList queryTagTypeList  = new TagTypeList();
                                TagTypeList returnTagTypeList = new TagTypeList();
                                foreach (DvtkData.Dimse.Attribute attribute in queryDataset)
                                {
                                    // do not add higher level tags
                                    if ((attribute.Tag == Tag.STUDY_INSTANCE_UID) ||
                                        (attribute.Tag == Tag.SERIES_INSTANCE_UID))
                                    {
                                        continue;
                                    }

                                    if (attribute.ValueRepresentation == VR.SQ)
                                    {
                                        foreach (SequenceItem s in ((SequenceOfItems)attribute.DicomValue).Sequence)
                                        {
                                            if (IsSequenceHavingValue(s))
                                            {
                                                queryTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagRequired));
                                            }
                                        }
                                    }
                                    else if ((attribute.Length != 0) &&
                                             (attribute.Tag.ElementNumber != 0x0000))
                                    {
                                        queryTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagRequired));
                                    }
                                    returnTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagOptional));
                                }

                                foreach (InstanceInformationEntity instanceInformationEntity in seriesInformationEntity.Children)
                                {
                                    if (instanceInformationEntity.IsFoundIn(queryTagTypeList, queryDataset))
                                    {
                                        // IMAGE level matches
                                        DataSet queryResponse = new DataSet();

                                        // if the specific character set attribute has been stored in the instance IE - return it in the query response
                                        DvtkData.Dimse.Attribute specificCharacterSetAttribute = instanceInformationEntity.GetSpecificCharacterSet();
                                        if (specificCharacterSetAttribute != null)
                                        {
                                            queryResponse.Add(specificCharacterSetAttribute);
                                        }

                                        patientStudyInformationEntity.CopyUniqueTagTo(queryResponse);
                                        seriesInformationEntity.CopyUniqueTagTo(queryResponse);
                                        instanceInformationEntity.CopyTo(returnTagTypeList, queryResponse);
                                        queryResponses.Add(queryResponse);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(queryResponses);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Add the given dataset present in a Dicom File to the Information Model. The data is normalised into the Information Model.
        /// </summary>
        /// <param name="dicomFile">The dicom File containing the dataset to be added.</param>
        /// <param name="storeFile">Boolean indicating whether the dataset should be stored or not.</param>
        public override void AddToInformationModel(DvtkData.Media.DicomFile dicomFile, bool storeFile)
        {
            // PATIENT level
            PatientInformationEntity patientInformationEntity = null;

            this.IsDataStored = storeFile;

            // check if the patient IE is already in the patientRootList
            foreach (PatientInformationEntity lPatientInformationEntity in Root)
            {
                if (lPatientInformationEntity.IsUniqueTagFoundIn(dicomFile.DataSet))
                {
                    patientInformationEntity = lPatientInformationEntity;
                    //patientInformationEntity.CheckForSpecialTags(dicomFile.DataSet);
                    break;
                }
            }

            // patient IE is not already in the patientRootList
            if (patientInformationEntity == null)
            {
                // create a new patient IE from the dataset and add to the patientRootList
                patientInformationEntity = new PatientInformationEntity();
                patientInformationEntity.CopyFrom(dicomFile.DataSet);
                Root.Add(patientInformationEntity);
            }

            // STUDY level
            StudyInformationEntity studyInformationEntity = null;

            // check if the study IE is already in the patient IE children
            foreach (StudyInformationEntity lStudyInformationEntity in patientInformationEntity.Children)
            {
                if (lStudyInformationEntity.IsUniqueTagFoundIn(dicomFile.DataSet))
                {
                    studyInformationEntity = lStudyInformationEntity;
                    //studyInformationEntity.CheckForSpecialTags(dicomFile.DataSet);
                    break;
                }
            }

            // study IE is not already in the patient IE children
            if (studyInformationEntity == null)
            {
                // create a new study IE from the dataset and add to the patient IE children
                studyInformationEntity = new StudyInformationEntity();
                studyInformationEntity.CopyFrom(dicomFile.DataSet);
                patientInformationEntity.AddChild(studyInformationEntity);
            }

            // SERIES level
            SeriesInformationEntity seriesInformationEntity = null;

            // check if the series IE is already in the study IE children
            foreach (SeriesInformationEntity lSeriesInformationEntity in studyInformationEntity.Children)
            {
                if (lSeriesInformationEntity.IsUniqueTagFoundIn(dicomFile.DataSet))
                {
                    seriesInformationEntity = lSeriesInformationEntity;
                    //seriesInformationEntity.CheckForSpecialTags(dicomFile.DataSet);
                    break;
                }
            }

            // series IE is not already in the study IE children
            if (seriesInformationEntity == null)
            {
                // create a new series IE from the dataset and add to the study IE children
                seriesInformationEntity = new SeriesInformationEntity();
                seriesInformationEntity.CopyFrom(dicomFile.DataSet);
                studyInformationEntity.AddChild(seriesInformationEntity);
            }

            // IMAGE (Instance) level
            InstanceInformationEntity instanceInformationEntity = null;

            // check if the instance IE is already in the series IE children
            foreach (InstanceInformationEntity lInstanceInformationEntity in seriesInformationEntity.Children)
            {
                if (lInstanceInformationEntity.IsUniqueTagFoundIn(dicomFile.DataSet))
                {
                    instanceInformationEntity = lInstanceInformationEntity;
                    //instanceInformationEntity.CheckForSpecialTags(dicomFile.DataSet);
                    break;
                }
            }

            // instance IE is not already in the series IE children
            if (instanceInformationEntity == null)
            {
                // Store the dicom File as a DCM file if requested.
                if (storeFile == true)
                {
                    StoreDicomFile(dicomFile);
                }

                // create a new instance IE from the dataset and add to the series IE children
                instanceInformationEntity = new InstanceInformationEntity(dicomFile.DataSet.Filename);
                instanceInformationEntity.CopyFrom(dicomFile.DataSet);
                seriesInformationEntity.AddChild(instanceInformationEntity);
            }
            patientInformationEntity.CheckForSpecialTags(dicomFile.DataSet);
            studyInformationEntity.CheckForSpecialTags(dicomFile.DataSet);
            seriesInformationEntity.CheckForSpecialTags(dicomFile.DataSet);
            instanceInformationEntity.CheckForSpecialTags(dicomFile.DataSet);
        }
        /// <summary>
        /// Add the given Dataset to the Information Model. The data is normalised into the Information Model.
        /// </summary>
        /// <param name="dataset">Dataset to add to Informatio Model.</param>
        public override void AddToInformationModel(DataSet dataset)
        {
            // PATIENT level
            PatientInformationEntity patientInformationEntity = null;

            // check if the patient IE is already in the patientRootList
            foreach (PatientInformationEntity lPatientInformationEntity in Root)
            {
                if (lPatientInformationEntity.IsFoundIn(dataset))
                {
                    patientInformationEntity = lPatientInformationEntity;
                    break;
                }
            }

            // patient IE is not already in the patientRootList
            if (patientInformationEntity == null)
            {
                // create a new patient IE from the dataset and add to the patientRootList
                patientInformationEntity = new PatientInformationEntity();
                patientInformationEntity.CopyFrom(dataset);
                Root.Add(patientInformationEntity);
            }

            // STUDY level
            StudyInformationEntity studyInformationEntity = null;

            // check if the study IE is already in the patient IE children
            foreach (StudyInformationEntity lStudyInformationEntity in patientInformationEntity.Children)
            {
                if (lStudyInformationEntity.IsFoundIn(dataset))
                {
                    studyInformationEntity = lStudyInformationEntity;
                    break;
                }
            }

            // study IE is not already in the patient IE children
            if (studyInformationEntity == null)
            {
                // create a new study IE from the dataset and add to the patient IE children
                studyInformationEntity = new StudyInformationEntity();
                studyInformationEntity.CopyFrom(dataset);
                patientInformationEntity.AddChild(studyInformationEntity);
            }

            // SERIES level
            SeriesInformationEntity seriesInformationEntity = null;

            // check if the series IE is already in the study IE children
            foreach (SeriesInformationEntity lSeriesInformationEntity in studyInformationEntity.Children)
            {
                if (lSeriesInformationEntity.IsFoundIn(dataset))
                {
                    seriesInformationEntity = lSeriesInformationEntity;
                    break;
                }
            }

            // series IE is not already in the study IE children
            if (seriesInformationEntity == null)
            {
                // create a new series IE from the dataset and add to the study IE children
                seriesInformationEntity = new SeriesInformationEntity();
                seriesInformationEntity.CopyFrom(dataset);
                studyInformationEntity.AddChild(seriesInformationEntity);
            }

            // IMAGE (Instance) level
            InstanceInformationEntity instanceInformationEntity = null;

            // check if the instance IE is already in the series IE children
            foreach (InstanceInformationEntity lInstanceInformationEntity in seriesInformationEntity.Children)
            {
                if (lInstanceInformationEntity.IsFoundIn(dataset))
                {
                    instanceInformationEntity = lInstanceInformationEntity;
                    break;
                }
            }

            // instance IE is not already in the series IE children
            if (instanceInformationEntity == null)
            {
                // create a new instance IE from the dataset and add to the series IE children
                instanceInformationEntity = new InstanceInformationEntity(dataset.Filename);
                instanceInformationEntity.CopyFrom(dataset);
                seriesInformationEntity.AddChild(instanceInformationEntity);
            }
        }