Exemplo n.º 1
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.º 2
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.º 3
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);
        }
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);
        }
        /// <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);
            }
        }