コード例 #1
0
ファイル: Study.cs プロジェクト: ewcasas/DVTK
 protected override void LoadData(DvtkData.Dimse.DataSet _dataSet)
 {
     base.LoadData(_dataSet);
     StudyID =BaseCompositeInformationEntity.GetDicomValue(_dataSet.GetAttribute(DvtkData.Dimse.Tag.STUDY_ID));
     StudyInstanceUID =BaseCompositeInformationEntity.GetDicomValue( _dataSet.GetAttribute(DvtkData.Dimse.Tag.STUDY_INSTANCE_UID));
 }
コード例 #2
0
ファイル: GenerateTriggers.cs プロジェクト: ewcasas/DVTK
        private static void AddReferencedSopSequence(ReferencedSopItemCollection storageCommitItems,
			uint tag,
			DvtkData.Dimse.AttributeSet attributeSet,
			InstanceStateEnum newInstanceState)
        {
            ushort group = (ushort)(tag >> 16);
            ushort element = (ushort)(tag & 0x0000FFFF);
            DvtkData.Dimse.Tag tagValue = new DvtkData.Dimse.Tag(group, element);

            DvtkData.Dimse.Attribute referencedSopSequence = attributeSet.GetAttribute(tagValue);
            if (referencedSopSequence != null)
            {
                attributeSet.Remove(referencedSopSequence);
            }

            referencedSopSequence = new DvtkData.Dimse.Attribute(tag, DvtkData.Dimse.VR.SQ);
            SequenceOfItems referencedSopSequenceOfItems = new SequenceOfItems();
            referencedSopSequence.DicomValue = referencedSopSequenceOfItems;

            foreach(ReferencedSopItem  referencedSopItem in storageCommitItems)
            {
                if (((referencedSopItem.InstanceState == InstanceStateEnum.InstanceStored) &&
                    (newInstanceState == InstanceStateEnum.InstanceMppsCompleted)) ||
                    ((referencedSopItem.InstanceState == InstanceStateEnum.InstanceMppsCompleted) &&
                    (newInstanceState == InstanceStateEnum.InstanceStorageCommitRequested)))
                {

                    DvtkData.Dimse.SequenceItem referencedSopSequenceItem = new DvtkData.Dimse.SequenceItem();
                    referencedSopSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.GroupNumber,
                        DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.ElementNumber,
                        DvtkData.Dimse.VR.UI, referencedSopItem.SopClassUid);
                    referencedSopSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.GroupNumber,
                        DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.ElementNumber,
                        DvtkData.Dimse.VR.UI, referencedSopItem.SopInstanceUid);
                    referencedSopItem.InstanceState = newInstanceState;
                    referencedSopSequenceOfItems.Sequence.Add(referencedSopSequenceItem);
                }
            }
            attributeSet.Add(referencedSopSequence);
        }
コード例 #3
0
        /// <summary>
        /// Patient merge request - update modality worklist information model.
        /// </summary>
        /// <param name="dataset">Dataset containing patient merge attributes.</param>
        public override void PatientMerge(DvtkData.Dimse.DataSet dataset)
        {
            // Get the merge patient - need to use this to search for the corresponding patient IE
            DvtkData.Dimse.Attribute mergePatientId = dataset.GetAttribute(Tag.OTHER_PATIENT_IDS);
            if (mergePatientId.Length != 0)
            {
                LongString longString = (LongString)mergePatientId.DicomValue;
                System.String attributeValue = longString.Values[0];

                DataSet queryDataset = new DataSet("Transient");
                queryDataset.AddAttribute(Tag.PATIENT_ID.GroupNumber, Tag.PATIENT_ID.ElementNumber, VR.LO, attributeValue);

                // check each patient IE in the patientRootList
                foreach (PatientInformationEntity lPatientInformationEntity in Root)
                {
                    // if IE matches the unique (merge) patient id field in the query dataset
                    if (lPatientInformationEntity.IsUniqueTagFoundIn(queryDataset))
                    {
                        // update the patient demographics - including the patient id
                        lPatientInformationEntity.CopyFrom(dataset);
                        break;
                    }
                }
            }
        }
コード例 #4
0
ファイル: GenerateTriggers.cs プロジェクト: ewcasas/DVTK
        private static void AddDefaultWorklistResponseValues(Dvtk.Dicom.InformationEntity.DefaultValues.DefaultValueManager defaultValueManager, DvtkData.Dimse.DataSet dataset)
        {
            DvtkData.Dimse.SequenceItem scheduledProcedureStepSequenceItem = null;

            // try to get the scheduled procedure step sequence from the dataset
            DvtkData.Dimse.Attribute sequenceAttribute = dataset.GetAttribute(DvtkData.Dimse.Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE);
            if ((sequenceAttribute != null) &&
                (sequenceAttribute.ValueRepresentation == DvtkData.Dimse.VR.SQ))
            {
                SequenceOfItems sequenceOfItems = (SequenceOfItems)sequenceAttribute.DicomValue;
                if (sequenceOfItems.Sequence.Count == 1)
                {
                    scheduledProcedureStepSequenceItem = sequenceOfItems.Sequence[0];
                }
            }

            // if the scheduled procedure step sequence is not present - add an empty one
            if (scheduledProcedureStepSequenceItem == null)
            {
                scheduledProcedureStepSequenceItem = new DvtkData.Dimse.SequenceItem();
                dataset.AddAttribute(DvtkData.Dimse.Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE.GroupNumber,
                    DvtkData.Dimse.Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE.ElementNumber,
                    DvtkData.Dimse.VR.SQ, scheduledProcedureStepSequenceItem);
            }

            // Patient Entity default values
            AddDefaultValueEvenIfZeroLength(defaultValueManager, DvtkData.Dimse.Tag.PATIENTS_NAME, VR.PN, dataset);
            AddDefaultValueEvenIfZeroLength(defaultValueManager, DvtkData.Dimse.Tag.PATIENT_ID, VR.LO, dataset);
            AddDefaultValueEvenIfZeroLength(defaultValueManager, DvtkData.Dimse.Tag.PATIENTS_BIRTH_DATE, VR.DA, dataset);
            AddDefaultValueEvenIfZeroLength(defaultValueManager, DvtkData.Dimse.Tag.PATIENTS_SEX, VR.CS, dataset);

            // Imaging Service Request Entity default values
            AddDefaultValueEvenIfZeroLength(defaultValueManager, DvtkData.Dimse.Tag.ACCESSION_NUMBER, VR.SH, dataset);

            // Requested Procedure Entity default values
            AddDefaultValueEvenIfZeroLength(defaultValueManager, DvtkData.Dimse.Tag.REQUESTED_PROCEDURE_ID, VR.SH, dataset);
            AddDefaultValueEvenIfZeroLength(defaultValueManager, DvtkData.Dimse.Tag.REQUESTED_PROCEDURE_DESCRIPTION, VR.LO, dataset);
            AddDefaultValueEvenIfZeroLength(defaultValueManager, DvtkData.Dimse.Tag.STUDY_INSTANCE_UID, VR.UI, dataset);

            // Scheduled Procedure Step Entity default values
            AddDefaultValueEvenIfZeroLength(defaultValueManager, DvtkData.Dimse.Tag.MODALITY, VR.CS, scheduledProcedureStepSequenceItem);
            AddDefaultValueEvenIfZeroLength(defaultValueManager, DvtkData.Dimse.Tag.SCHEDULED_PROCEDURE_STEP_ID, VR.SH, scheduledProcedureStepSequenceItem);
            AddDefaultValueEvenIfZeroLength(defaultValueManager, DvtkData.Dimse.Tag.SCHEDULED_PROCEDURE_STEP_DESCRIPTION, VR.LO, scheduledProcedureStepSequenceItem);
            AddDefaultValueEvenIfZeroLength(defaultValueManager, DvtkData.Dimse.Tag.SCHEDULED_PROCEDURE_STEP_START_DATE, VR.DA, scheduledProcedureStepSequenceItem);
            AddDefaultValueEvenIfZeroLength(defaultValueManager, DvtkData.Dimse.Tag.SCHEDULED_PROCEDURE_STEP_START_TIME, VR.TM, scheduledProcedureStepSequenceItem);
        }
コード例 #5
0
ファイル: GenerateTriggers.cs プロジェクト: ewcasas/DVTK
        private static void AddQueryRetrieveKeys(TagValueCollection queryTags, DvtkData.Dimse.DataSet dataset)
        {
            // use script session to get to definition singleton
            Dvtk.Sessions.ScriptSession scriptSession = new Dvtk.Sessions.ScriptSession();

            // iterate over the query tags
            foreach(DicomTagValue queryTag in queryTags)
            {
                if (queryTag.ParentSequenceTag != DvtkData.Dimse.Tag.UNDEFINED)
                {
                    // try to get the sequence tag in the dataset
                    DvtkData.Dimse.Attribute sequenceAttribute = dataset.GetAttribute(queryTag.ParentSequenceTag);
                    if ((sequenceAttribute != null) &&
                        (sequenceAttribute.ValueRepresentation == DvtkData.Dimse.VR.SQ))
                    {
                        SequenceOfItems sequenceOfItems = (SequenceOfItems)sequenceAttribute.DicomValue;
                        if (sequenceOfItems.Sequence.Count == 1)
                        {
                            DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0];

                            if (item != null)
                            {
                                VR vr = scriptSession.DefinitionManagement.GetAttributeVrFromDefinition(queryTag.Tag);

                                // add the query value
                                item.AddAttribute(queryTag.Tag.GroupNumber,
                                    queryTag.Tag.ElementNumber,
                                    vr,
                                    queryTag.Value);
                            }
                        }
                    }
                }
                else
                {
                    VR vr = scriptSession.DefinitionManagement.GetAttributeVrFromDefinition(queryTag.Tag);

                    // add the query value
                    dataset.AddAttribute(queryTag.Tag.GroupNumber,
                        queryTag.Tag.ElementNumber,
                        vr,
                        queryTag.Value);
                }
            }
        }
コード例 #6
0
ファイル: WorklistQueryDataset.cs プロジェクト: ewcasas/DVTK
        private static void AddTagsToDataset(TagValueCollection tags, DvtkData.Dimse.DataSet dataset)
        {
            // iterate over the tags
            foreach(DicomTagValue tag in tags)
            {
                if (tag.ParentSequenceTag != Tag.UNDEFINED)
                {
                    // try to get the sequence tag in the dataset
                    DvtkData.Dimse.Attribute sequenceAttribute = dataset.GetAttribute(tag.ParentSequenceTag);
                    if ((sequenceAttribute != null) &&
                        (sequenceAttribute.ValueRepresentation == DvtkData.Dimse.VR.SQ))
                    {
                        SequenceOfItems sequenceOfItems = (SequenceOfItems)sequenceAttribute.DicomValue;
                        if (sequenceOfItems.Sequence.Count == 1)
                        {
                            SequenceItem item = sequenceOfItems.Sequence[0];

                            if (item != null)
                            {
                                VR vr = VR.UN;

                                // try to get the attribute in the item
                                DvtkData.Dimse.Attribute attribute = item.GetAttribute(tag.Tag);
                                if (attribute != null)
                                {
                                    vr = attribute.ValueRepresentation;
                                    item.Remove(attribute);
                                }

                                // add the query value
                                item.AddAttribute(tag.Tag.GroupNumber,
                                    tag.Tag.ElementNumber,
                                    vr,
                                    tag.Value);
                            }
                        }
                    }
                }
                else
                {
                    VR vr = VR.UN;

                    // try to get the attribute in the dataset
                    DvtkData.Dimse.Attribute attribute = dataset.GetAttribute(tag.Tag);
                    if (attribute != null)
                    {
                        vr = attribute.ValueRepresentation;
                        dataset.Remove(attribute);
                    }

                    // special check for the SPECIFIC CHARACTER SET attribute
                    if (tag.Tag == Tag.SPECIFIC_CHARACTER_SET)
                    {
                        vr = VR.CS;
                    }

                    // add the query value
                    dataset.AddAttribute(tag.Tag.GroupNumber,
                        tag.Tag.ElementNumber,
                        vr,
                        tag.Value);
                }
            }
        }
コード例 #7
0
ファイル: GenerateTriggers.cs プロジェクト: ewcasas/DVTK
        private static void AddDefaultValueEvenIfZeroLength(Dvtk.Dicom.InformationEntity.DefaultValues.DefaultValueManager defaultValueManager,
            DvtkData.Dimse.Tag tag,
            VR vr,
            DvtkData.Dimse.AttributeSet attributeSet)
        {
            // Only add a default value if the attribute does not already exist or has a zero length
            DvtkData.Dimse.Attribute attribute = attributeSet.GetAttribute(tag);
            if (attribute == null)
            {
                // Attribute does not exist so add a default value
                System.String lValue = defaultValueManager.GetInstantiatedValue(tag);
                attributeSet.AddAttribute(tag.GroupNumber, tag.ElementNumber, (DvtkData.Dimse.VR)vr, lValue);
            }
            else if (attribute.Length == 0)
            {
                // Remove the existing attribute
                attributeSet.Remove(attribute);

                // Attribute had zero length so add a default value
                System.String lValue = defaultValueManager.GetInstantiatedValue(tag);
                attributeSet.AddAttribute(tag.GroupNumber, tag.ElementNumber, (DvtkData.Dimse.VR)vr, lValue);
            }
        }
コード例 #8
0
ファイル: GenerateTriggers.cs プロジェクト: ewcasas/DVTK
        private static void UpdateStartDateTimeValues(Dvtk.Dicom.InformationEntity.DefaultValues.DefaultValueManager defaultValueManager, DvtkData.Dimse.DataSet dataset)
        {
            DvtkData.Dimse.Attribute ppsStartDate = dataset.GetAttribute(DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_START_DATE);
            if (ppsStartDate != null)
            {
                dataset.Remove(ppsStartDate);
            }
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_START_DATE, VR.DA, dataset);

            DvtkData.Dimse.Attribute ppsStartTime = dataset.GetAttribute(DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_START_TIME);
            if (ppsStartTime != null)
            {
                dataset.Remove(ppsStartTime);
            }
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_START_TIME, VR.TM, dataset);
        }
コード例 #9
0
ファイル: GenerateTriggers.cs プロジェクト: ewcasas/DVTK
        private static void UpdateValue(System.String attributeValue,
			DvtkData.Dimse.Tag tag,
			VR vr,
			DvtkData.Dimse.AttributeSet attributeSet)
        {
            // Only update the value if the dataset contains an attribute with the same tag
            DvtkData.Dimse.Attribute attribute = attributeSet.GetAttribute(tag);
            if (attribute != null)
            {
                // Remove the existing attribute
                attributeSet.Remove(attribute);

                // Add the new (updated) value
                attributeSet.AddAttribute(tag.GroupNumber, tag.ElementNumber, (DvtkData.Dimse.VR)vr, attributeValue);
            }
        }
コード例 #10
0
ファイル: GenerateTriggers.cs プロジェクト: ewcasas/DVTK
        private static void AddStoreInstanceValues(Dvtk.Dicom.InformationEntity.DefaultValues.DefaultValueManager defaultValueManager,
			DvtkData.Dimse.DataSet dataset,
			bool generateImageData)
        {
            DvtkData.Dimse.SequenceItem requestAttributesSequenceItem = new DvtkData.Dimse.SequenceItem();

            // Patient Entity default values
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PATIENTS_NAME, VR.PN, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PATIENT_ID, VR.LO, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PATIENTS_BIRTH_DATE, VR.DA, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PATIENTS_SEX, VR.CS, dataset);

            // Study Entity default values
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.STUDY_DESCRIPTION, VR.LO, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.STUDY_ID, VR.SH, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.STUDY_DATE, VR.DA, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.STUDY_TIME, VR.TM, dataset);

            // Series Entity default values
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PROTOCOL_NAME, VR.LO, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SERIES_DESCRIPTION, VR.LO, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMING_PHYSICIANS_NAME, VR.PN, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.OPERATORS_NAME, VR.PN, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SERIES_INSTANCE_UID, VR.UI, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SERIES_NUMBER, VR.IS, dataset);

            // Instance Entity default values
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SOP_INSTANCE_UID, VR.UI, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.INSTANCE_NUMBER, VR.IS, dataset);

            // Image Service Request Entity default values
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.ACCESSION_NUMBER, VR.SH, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.REFERRING_PHYSICIANS_NAME, VR.PN, dataset);

            // Requested Procedure Entity default values
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.REQUESTED_PROCEDURE_ID, VR.SH, requestAttributesSequenceItem);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.STUDY_INSTANCE_UID, VR.UI, dataset);

            // Scheduled Procedure Step Entity default values
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.MODALITY, VR.CS, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SCHEDULED_PROCEDURE_STEP_ID, VR.SH, requestAttributesSequenceItem);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SCHEDULED_PROCEDURE_STEP_DESCRIPTION, VR.LO, requestAttributesSequenceItem);

            // Performed Procedure Step Entity default values
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_ID, VR.SH, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_DESCRIPTION, VR.LO, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_START_DATE, VR.DA, dataset);
            AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_START_TIME, VR.TM, dataset);

            // Check if the Request Attribute Sequence is already present
            DvtkData.Dimse.Attribute requestAttributesSequence = dataset.GetAttribute(DvtkData.Dimse.Tag.REQUEST_ATTRIBUTES_SEQUENCE);
            if (requestAttributesSequence != null)
            {
                // Remove the existing (old) sequence
                dataset.Remove(requestAttributesSequence);
            }

            // Add the new sequence
            dataset.AddAttribute(DvtkData.Dimse.Tag.REQUEST_ATTRIBUTES_SEQUENCE.GroupNumber,
                DvtkData.Dimse.Tag.REQUEST_ATTRIBUTES_SEQUENCE.ElementNumber,
                DvtkData.Dimse.VR.SQ, requestAttributesSequenceItem);

            // Check if we need to generate the image data too (including pixel data)
            if (generateImageData == true)
            {
                // Add Secondary Capture image data
                dataset.AddAttribute(DvtkData.Dimse.Tag.SOP_CLASS_UID.GroupNumber,
                    DvtkData.Dimse.Tag.SOP_CLASS_UID.ElementNumber,
                    DvtkData.Dimse.VR.UI, "1.2.840.10008.5.1.4.1.1.7");

                dataset.AddAttribute(DvtkData.Dimse.Tag.CONVERSION_TYPE.GroupNumber,
                    DvtkData.Dimse.Tag.CONVERSION_TYPE.ElementNumber,
                    DvtkData.Dimse.VR.CS, "DV");
                dataset.AddAttribute(DvtkData.Dimse.Tag.PATIENT_ORIENTATION.GroupNumber,
                    DvtkData.Dimse.Tag.PATIENT_ORIENTATION.ElementNumber,
                    DvtkData.Dimse.VR.CS);

                dataset.AddAttribute(DvtkData.Dimse.Tag.SAMPLES_PER_PIXEL.GroupNumber,
                    DvtkData.Dimse.Tag.SAMPLES_PER_PIXEL.ElementNumber,
                    DvtkData.Dimse.VR.US, 1);
                dataset.AddAttribute(DvtkData.Dimse.Tag.PHOTOMETRIC_INTERPRETATION.GroupNumber,
                    DvtkData.Dimse.Tag.PHOTOMETRIC_INTERPRETATION.ElementNumber,
                    DvtkData.Dimse.VR.CS, "MONOCHROME2");
                dataset.AddAttribute(DvtkData.Dimse.Tag.ROWS.GroupNumber,
                    DvtkData.Dimse.Tag.ROWS.ElementNumber,
                    DvtkData.Dimse.VR.US, 512);
                dataset.AddAttribute(DvtkData.Dimse.Tag.COLUMNS.GroupNumber,
                    DvtkData.Dimse.Tag.COLUMNS.ElementNumber,
                    DvtkData.Dimse.VR.US, 512);
                dataset.AddAttribute(DvtkData.Dimse.Tag.BITS_ALLOCATED.GroupNumber,
                    DvtkData.Dimse.Tag.BITS_ALLOCATED.ElementNumber,
                    DvtkData.Dimse.VR.US, 8);
                dataset.AddAttribute(DvtkData.Dimse.Tag.BITS_STORED.GroupNumber,
                    DvtkData.Dimse.Tag.BITS_STORED.ElementNumber,
                    DvtkData.Dimse.VR.US, 8);
                dataset.AddAttribute(DvtkData.Dimse.Tag.HIGH_BIT.GroupNumber,
                    DvtkData.Dimse.Tag.HIGH_BIT.ElementNumber,
                    DvtkData.Dimse.VR.US, 7);
                dataset.AddAttribute(DvtkData.Dimse.Tag.PIXEL_REPRESENTATION.GroupNumber,
                    DvtkData.Dimse.Tag.PIXEL_REPRESENTATION.ElementNumber,
                    DvtkData.Dimse.VR.US, 0);

                dataset.AddAttribute(DvtkData.Dimse.Tag.PIXEL_DATA.GroupNumber,
                    DvtkData.Dimse.Tag.PIXEL_DATA.ElementNumber,
                    DvtkData.Dimse.VR.OB, 512);
            }
        }
コード例 #11
0
ファイル: GenerateTriggers.cs プロジェクト: ewcasas/DVTK
        private static void UpdateReferencedSopItem(ReferencedSopItemCollection storageCommitItems, DvtkData.Dimse.SequenceItem item, InstanceStateEnum newInstanceState)
        {
            if (item != null)
            {
                System.String sopClassUid = System.String.Empty;
                System.String sopInstanceUid = System.String.Empty;

                // Try to get the SOP Class UID and SOP Instance UID out of the item
                DvtkData.Dimse.Attribute attribute = item.GetAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID);
                if (attribute != null)
                {
                    UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue;
                    if (uniqueIdentifier.Values.Count > 0)
                    {
                        sopClassUid = uniqueIdentifier.Values[0];
                    }
                }

                attribute = item.GetAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID);
                if (attribute != null)
                {
                    UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue;
                    if (uniqueIdentifier.Values.Count > 0)
                    {
                        sopInstanceUid = uniqueIdentifier.Values[0];
                    }
                }
                ReferencedSopItem referencedSopItem = storageCommitItems.Find(sopClassUid, sopInstanceUid);
                if ((referencedSopItem != null) &&
                    (referencedSopItem.InstanceState == InstanceStateEnum.InstanceStorageCommitRequested))
                {
                    referencedSopItem.InstanceState = newInstanceState;
                }
            }
        }
コード例 #12
0
ファイル: GenerateTriggers.cs プロジェクト: ewcasas/DVTK
        private static void AddStorageCommitItems(Dvtk.Dicom.InformationEntity.DefaultValues.DefaultValueManager defaultValueManager,
			ReferencedSopItemCollection storageCommitItems,
			DvtkData.Dimse.DataSet dataset)
        {
            DvtkData.Dimse.SequenceItem performedSeriesSequenceItem = null;

            // Try to get the Performed Series Sequence
            DvtkData.Dimse.Attribute performedSeriesSequence = dataset.GetAttribute(DvtkData.Dimse.Tag.PERFORMED_SERIES_SEQUENCE);
            if (performedSeriesSequence != null)
            {
                DvtkData.Dimse.SequenceOfItems sequenceOfItems = (DvtkData.Dimse.SequenceOfItems)performedSeriesSequence.DicomValue;
                if (sequenceOfItems.Sequence.Count == 1)
                {
                    performedSeriesSequenceItem = sequenceOfItems.Sequence[0];
                }
                else
                {
                    dataset.Remove(performedSeriesSequence);

                    performedSeriesSequenceItem = new DvtkData.Dimse.SequenceItem();

                    dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_SERIES_SEQUENCE.GroupNumber,
                        DvtkData.Dimse.Tag.PERFORMED_SERIES_SEQUENCE.ElementNumber,
                        DvtkData.Dimse.VR.SQ, performedSeriesSequenceItem);
                }
            }
            else
            {
                performedSeriesSequenceItem = new DvtkData.Dimse.SequenceItem();

                dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_SERIES_SEQUENCE.GroupNumber,
                    DvtkData.Dimse.Tag.PERFORMED_SERIES_SEQUENCE.ElementNumber,
                    DvtkData.Dimse.VR.SQ, performedSeriesSequenceItem);
            }

            if (performedSeriesSequenceItem != null)
            {
                // Series Entity default values
                DvtkData.Dimse.Attribute seriesInstanceUid = performedSeriesSequenceItem.GetAttribute(DvtkData.Dimse.Tag.SERIES_INSTANCE_UID);
                if (seriesInstanceUid != null)
                {
                    performedSeriesSequenceItem.Remove(seriesInstanceUid);
                }
                AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SERIES_INSTANCE_UID, VR.UI, performedSeriesSequenceItem);

                AddReferencedSopSequence(storageCommitItems, 0x00081140, performedSeriesSequenceItem, InstanceStateEnum.InstanceMppsCompleted);
            }
        }
コード例 #13
0
ファイル: Patient.cs プロジェクト: ewcasas/DVTK
 protected override void LoadData(DvtkData.Dimse.DataSet _dataSet)
 {
     base.LoadData(_dataSet);
     patientName = BaseCompositeInformationEntity.GetDicomValue(_dataSet.GetAttribute(DvtkData.Dimse.Tag.PATIENTS_NAME));
     patientId =BaseCompositeInformationEntity.GetDicomValue(_dataSet.GetAttribute(DvtkData.Dimse.Tag.PATIENT_ID));
 }
コード例 #14
0
ファイル: Storage SCU emulator.cs プロジェクト: ewcasas/DVTK
        private ArrayList ImportRefFilesFromDicomdir(string dicomDir, DvtkData.Dimse.DataSet dataset)
        {
            int recordsCount = 0;
            ArrayList refFileNames = new ArrayList();
            FileInfo dicomDirInfo = new FileInfo(dicomDir);
            DvtkData.Dimse.Attribute recordSeqAttr = dataset.GetAttribute(DvtkData.Dimse.Tag.DIRECTORY_RECORD_SEQUENCE);
            if (recordSeqAttr!=null)
            {
                DvtkData.Dimse.SequenceOfItems sequenceOfItems = recordSeqAttr.DicomValue as DvtkData.Dimse.SequenceOfItems;

                foreach(DvtkData.Dimse.SequenceItem item in sequenceOfItems.Sequence)
                {
                    DvtkData.Media.DirectoryRecord record = (DvtkData.Media.DirectoryRecord)(item as DvtkData.Dimse.AttributeSet);
                    DvtkData.Dimse.Attribute attributeRecType = item.GetAttribute(DvtkData.Dimse.Tag.DIRECTORY_RECORD_TYPE);
                    if (attributeRecType != null)
                    {
                        DvtkData.Dimse.CodeString recType = (DvtkData.Dimse.CodeString)attributeRecType.DicomValue;
                        record.DirectoryRecordType = recType.Values[0];
                    }

                    if ((record.DirectoryRecordType == "IMAGE") || (record.DirectoryRecordType == "PRESENTATION"))
                    {
                        string refFile = "";
                        DvtkData.Dimse.Attribute attributeRefFile = item.GetAttribute(DvtkData.Dimse.Tag.REFERENCED_FILE_ID);
                        if (attributeRefFile != null)
                        {
                            DvtkData.Dimse.CodeString attrValues = (DvtkData.Dimse.CodeString)attributeRefFile.DicomValue;

                            foreach (DvtkData.Dimse.CodeString value in attrValues.Values)
                            {
                                refFile += value;
                                refFile += @"\";
                            }
                        }

                        refFile = refFile.Remove((refFile.Length - 1), 1);
                        refFileNames.Add(Path.Combine(dicomDirInfo.DirectoryName, refFile));
                    }
                }
            }

            return refFileNames;
        }
コード例 #15
0
ファイル: Series.cs プロジェクト: ewcasas/DVTK
 protected override void LoadData(DvtkData.Dimse.DataSet _dataSet)
 {
     base.LoadData(_dataSet);
     InstanceNumber =BaseCompositeInformationEntity.GetDicomValue(_dataSet.GetAttribute(DvtkData.Dimse.Tag.SERIES_NUMBER));
     SeriesInstanceUID =BaseCompositeInformationEntity.GetDicomValue(_dataSet.GetAttribute(DvtkData.Dimse.Tag.SERIES_INSTANCE_UID));
 }
コード例 #16
0
ファイル: GenerateTriggers.cs プロジェクト: ewcasas/DVTK
        private static void AddDefaultValue(Dvtk.Dicom.InformationEntity.DefaultValues.DefaultValueManager defaultValueManager,
			DvtkData.Dimse.Tag tag,
			VR vr,
			DvtkData.Dimse.AttributeSet attributeSet)
        {
            // Only add a default value if the attribute does not already exist
            DvtkData.Dimse.Attribute attribute = attributeSet.GetAttribute(tag);
            if (attribute == null)
            {
                // Attribute does not exist so add a default value
                System.String lValue = defaultValueManager.GetInstantiatedValue(tag);
                attributeSet.AddAttribute(tag.GroupNumber, tag.ElementNumber, (DvtkData.Dimse.VR)vr, lValue);
            }
        }
コード例 #17
0
ファイル: DicomComparator.cs プロジェクト: ewcasas/DVTK
        private bool LoadTemplate(DvtkData.Dimse.DataSet dataset)
        {
            if (dataset == null) return false;

            // try to find the template tag in the dataset
            foreach (DicomComparisonTag comparisonTag in this.Template.ComparisonTags)
            {
                DvtkData.Dimse.Tag tag = comparisonTag.Tag;
                DvtkData.Dimse.Tag parentSequenceTag = comparisonTag.ParentSequenceTag;
                System.String attributeValue = System.String.Empty;

                if (parentSequenceTag != Tag.UNDEFINED)
                {
                    DvtkData.Dimse.Attribute sequenceAttribute = dataset.GetAttribute(parentSequenceTag);
                    if ((sequenceAttribute != null) &&
                        (sequenceAttribute.ValueRepresentation == DvtkData.Dimse.VR.SQ))
                    {
                        SequenceOfItems sequenceOfItems = (SequenceOfItems)sequenceAttribute.DicomValue;
                        if (sequenceOfItems.Sequence.Count == 1)
                        {
                            SequenceItem item = sequenceOfItems.Sequence[0];

                            if (item != null)
                            {
                                DvtkData.Dimse.Attribute attribute = item.GetAttribute(tag);
                                attributeValue = GetAttributeValue(attribute);
                            }
                        }
                    }
                }
                else
                {
                    DvtkData.Dimse.Attribute attribute = dataset.GetAttribute(tag);
                    attributeValue = GetAttributeValue(attribute);
                }

                if (attributeValue != System.String.Empty)
                {
                    comparisonTag.DataFormat.FromDicomFormat(attributeValue);
                }
            }

            return true;
        }
コード例 #18
0
        private static void AddDicomAttribute(DvtkData.Dimse.AttributeSet dataset, DicomTagPath dicomTagPath, System.String dicomValue)
        {
            if (dicomTagPath.Next != null)
            {
                // Try to get the sequence identified by this Tag
                DvtkData.Dimse.Attribute sequenceAttribute = dataset.GetAttribute(dicomTagPath.Tag);
                if (sequenceAttribute == null)
                {
                    // Need to add the sequence
                    DvtkData.Dimse.SequenceItem item = new DvtkData.Dimse.SequenceItem();
                    dataset.AddAttribute(dicomTagPath.Tag.GroupNumber,
                        dicomTagPath.Tag.ElementNumber,
                        DvtkData.Dimse.VR.SQ, item);

                    // Get the newly added sequence
                    sequenceAttribute = dataset.GetAttribute(dicomTagPath.Tag);
                }

                // Get the contained item
                DvtkData.Dimse.SequenceOfItems sequenceOfItems = (DvtkData.Dimse.SequenceOfItems)sequenceAttribute.DicomValue;
                if (sequenceOfItems.Sequence.Count == 1)
                {
                    DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0];

                    // Call recursively
                    AddDicomAttribute(item, dicomTagPath.Next, dicomValue);
                }
            }
            else
            {
                // Try to get the attribute identified by this Tag
                DvtkData.Dimse.Attribute attribute = dataset.GetAttribute(dicomTagPath.Tag);
                if (attribute != null)
                {
                    // If present - remove the attribute - we want to update the value
                    dataset.Remove(attribute);
                }

                // Add the new value
                dataset.AddAttribute(dicomTagPath.Tag.GroupNumber, dicomTagPath.Tag.ElementNumber, DicomTagVrLookup.GetVR(dicomTagPath.Tag), dicomValue);
            }
        }