/// <summary> /// Check if the given match dataset is found in the local dataset using the default Tag Type list. /// A check is made to see if all the attributes in the given match dataset are present in the local /// dataset. In addition to the base match we need to try to match attributes from the /// Request Attributes Sequence (if present). /// </summary> /// <param name="matchDataset">Match dataset to check.</param> /// <returns>Boolean indicating if the match attributes are present in the local dataset.</returns> public override bool IsFoundIn(AttributeSet matchDataset) { bool isFoundIn = base.IsFoundIn(matchDataset); if (isFoundIn == false) { // check if the Request Attributes Sequence is available in the match dataset DvtkData.Dimse.Attribute requestAttributesSequence = matchDataset.GetAttribute(Tag.REQUEST_ATTRIBUTES_SEQUENCE); if (requestAttributesSequence != null) { SequenceOfItems sequenceOfItems = (SequenceOfItems)requestAttributesSequence.DicomValue; if (sequenceOfItems.Sequence.Count == 1) { // set up a temporary tag list to check the relevant tags in the Request Attributes Sequence TagTypeList itemTagTypeList = new TagTypeList(); itemTagTypeList.Add(new TagType(Tag.REQUESTED_PROCEDURE_ID, TagTypeEnum.TagOptional)); DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0]; // check if found in item isFoundIn = base.IsFoundIn(itemTagTypeList, item); } } } return(isFoundIn); }
/// <summary> /// Copy from the given source Dataset into the local Dataset as defined by the /// default Tag Type list. In addition to the base copy we need to copy attributes from the /// Request Attributes Sequence (if present) and the Scheduled Procedure Step (if present). /// </summary> /// <param name="sourceDataset">Source Dataset used to populate the local Dataset.</param> public override void CopyFrom(AttributeSet sourceDataset) { // perform base copy base.CopyFrom(sourceDataset); // check if the Request Attributes Sequence is available in the source dataset DvtkData.Dimse.Attribute requestAttributesSequence = sourceDataset.GetAttribute(Tag.REQUEST_ATTRIBUTES_SEQUENCE); if (requestAttributesSequence != null) { SequenceOfItems sequenceOfItems = (SequenceOfItems)requestAttributesSequence.DicomValue; if (sequenceOfItems.Sequence.Count == 1) { DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0]; // copy item attributes too base.CopyFrom(item); } } // check if the Scheduled Procedure Step Sequence is available in the source dataset DvtkData.Dimse.Attribute scheduledProcedureStepSequence = sourceDataset.GetAttribute(Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE); if (scheduledProcedureStepSequence != null) { SequenceOfItems sequenceOfItems = (SequenceOfItems)scheduledProcedureStepSequence.DicomValue; if (sequenceOfItems.Sequence.Count == 1) { DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0]; // copy item attributes too base.CopyFrom(item); } } }
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); }
private static void AddDefaultReturnKeys(DvtkData.Dimse.DataSet dataset) { // use the Worklist Information Entities to generate the default Return Key attribute set PatientInformationEntity patientIe = new PatientInformationEntity(); foreach(TagType tagType in patientIe.TagTypeList) { dataset.AddAttribute(tagType.Tag.GroupNumber, tagType.Tag.ElementNumber, tagType.Vr); } VisitInformationEntity visitIe = new VisitInformationEntity(); foreach(TagType tagType in visitIe.TagTypeList) { dataset.AddAttribute(tagType.Tag.GroupNumber, tagType.Tag.ElementNumber, tagType.Vr); } ImagingServiceRequestInformationEntity imagingServiceRequestIe = new ImagingServiceRequestInformationEntity(); foreach(TagType tagType in imagingServiceRequestIe.TagTypeList) { dataset.AddAttribute(tagType.Tag.GroupNumber, tagType.Tag.ElementNumber, tagType.Vr); } RequestedProcedureInformationEntity requestedProcedureIe = new RequestedProcedureInformationEntity(); foreach(TagType tagType in requestedProcedureIe.TagTypeList) { dataset.AddAttribute(tagType.Tag.GroupNumber, tagType.Tag.ElementNumber, tagType.Vr); } SequenceItem item = new SequenceItem(); ScheduledProcedureStepInformationEntity scheduledProcedureStepIe = new ScheduledProcedureStepInformationEntity(); foreach(TagType tagType in scheduledProcedureStepIe.TagTypeList) { if (tagType.Tag != Tag.SPECIFIC_CHARACTER_SET) { item.AddAttribute(tagType.Tag.GroupNumber, tagType.Tag.ElementNumber, tagType.Vr); } } dataset.AddAttribute(Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE.GroupNumber, Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE.ElementNumber, VR.SQ, item); }
private static void AddRadiationDoseDefaultValues(Dvtk.Dicom.InformationEntity.DefaultValues.DefaultValueManager defaultValueManager, DvtkData.Dimse.DataSet dataset) { if (defaultValueManager.GetInstantiatedValue(DvtkData.Dimse.Tag.DISTANCE_SOURCE_TO_DETECTOR) != System.String.Empty) { AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.DISTANCE_SOURCE_TO_DETECTOR, VR.DS, dataset); } if (defaultValueManager.GetInstantiatedValue(DvtkData.Dimse.Tag.IMAGE_AREA_DOSE_PRODUCT) != System.String.Empty) { AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.IMAGE_AREA_DOSE_PRODUCT, VR.DS, dataset); } if (defaultValueManager.GetInstantiatedValue(DvtkData.Dimse.Tag.TOTAL_TIME_OF_FLUOROSCOPY) != System.String.Empty) { AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.TOTAL_TIME_OF_FLUOROSCOPY, VR.US, dataset); } if (defaultValueManager.GetInstantiatedValue(DvtkData.Dimse.Tag.TOTAL_NUMBER_OF_EXPOSURES) != System.String.Empty) { AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.TOTAL_NUMBER_OF_EXPOSURES, VR.US, dataset); } if (defaultValueManager.GetInstantiatedValue(DvtkData.Dimse.Tag.ENTRANCE_DOSE) != System.String.Empty) { AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.ENTRANCE_DOSE, VR.US, dataset); } if (defaultValueManager.GetInstantiatedValue(DvtkData.Dimse.Tag.EXPOSED_AREA) != System.String.Empty) { AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.EXPOSED_AREA, VR.US, dataset); } if (defaultValueManager.GetInstantiatedValue(DvtkData.Dimse.Tag.DISTANCE_SOURCE_TO_ENTRANCE) != System.String.Empty) { AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.DISTANCE_SOURCE_TO_ENTRANCE, VR.DS, dataset); } if (defaultValueManager.GetInstantiatedValue(DvtkData.Dimse.Tag.COMMENTS_ON_RADIATION_DOSE) != System.String.Empty) { AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.COMMENTS_ON_RADIATION_DOSE, VR.ST, dataset); } DvtkData.Dimse.SequenceItem exposeureDoseSequenceItem = new DvtkData.Dimse.SequenceItem(); if (defaultValueManager.GetInstantiatedValue(DvtkData.Dimse.Tag.KVP) != System.String.Empty) { AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.KVP, VR.DS, exposeureDoseSequenceItem); } if (defaultValueManager.GetInstantiatedValue(DvtkData.Dimse.Tag.EXPOSURE_TIME) != System.String.Empty) { AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.EXPOSURE_TIME, VR.IS, exposeureDoseSequenceItem); } if (defaultValueManager.GetInstantiatedValue(DvtkData.Dimse.Tag.RADIATION_MODE) != System.String.Empty) { AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.RADIATION_MODE, VR.CS, exposeureDoseSequenceItem); } if (defaultValueManager.GetInstantiatedValue(DvtkData.Dimse.Tag.FILTER_TYPE) != System.String.Empty) { AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.FILTER_TYPE, VR.SH, exposeureDoseSequenceItem); } if (defaultValueManager.GetInstantiatedValue(DvtkData.Dimse.Tag.FILTER_MATERIAL) != System.String.Empty) { AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.FILTER_MATERIAL, VR.CS, exposeureDoseSequenceItem); } if (defaultValueManager.GetInstantiatedValue(DvtkData.Dimse.Tag.X_RAY_TUBE_CURRENT_IN_UA) != System.String.Empty) { AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.X_RAY_TUBE_CURRENT_IN_UA, VR.DS, exposeureDoseSequenceItem); } if (exposeureDoseSequenceItem.Count > 0) { dataset.AddAttribute(DvtkData.Dimse.Tag.EXPOSURE_DOSE_SEQUENCE.GroupNumber, DvtkData.Dimse.Tag.EXPOSURE_DOSE_SEQUENCE.ElementNumber, VR.SQ, exposeureDoseSequenceItem); } }
/// <summary> /// Determines the index of a specific <see cref="SequenceItem"/> in the <see cref="Sequence"/>. /// </summary> /// <param name="value">The <see cref="SequenceItem"/> to locate in the <see cref="Sequence"/>.</param> /// <returns>The index of <c>value</c> if found in the <see cref="Sequence"/>; otherwise, -1.</returns> public int IndexOf(SequenceItem value) { return base.IndexOf(value); }
/// <summary> /// Removes the first occurrence of a specific <see cref="SequenceItem"/> from the <see cref="Sequence"/>. /// </summary> /// <param name="value">The <see cref="SequenceItem"/> to remove from the <see cref="Sequence"/>.</param> public void Remove(SequenceItem value) { base.Remove(value); }
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); } }
/// <summary> /// Cretae a storage commitment event. /// </summary> /// <param name="informationModels">The information models.</param> /// <param name="actionMessage">The action message.</param> /// <returns>The created event.</returns> public static DvtkHighLevelInterface.Dicom.Messages.DicomMessage MakeStorageCommitEvent(QueryRetrieveInformationModels informationModels, DvtkHighLevelInterface.Dicom.Messages.DicomMessage actionMessage) { // refresh the information models informationModels.Refresh(); DvtkHighLevelInterface.Dicom.Messages.DicomMessage eventMessage = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.NEVENTREPORTRQ); eventMessage.Set("0x00000002", VR.UI, "1.2.840.10008.1.20.1"); eventMessage.Set("0x00001000", VR.UI, "1.2.840.10008.1.20.1.1"); DvtkData.Dimse.DataSet actionDataset = actionMessage.DataSet.DvtkDataDataSet; DvtkData.Dimse.DataSet eventDataset = new DvtkData.Dimse.DataSet(); DvtkData.Dimse.Attribute eventReferenceSopSequence = new DvtkData.Dimse.Attribute(0x00081199, DvtkData.Dimse.VR.SQ); SequenceOfItems eventReferenceSopSequenceOfItems = new SequenceOfItems(); eventReferenceSopSequence.DicomValue = eventReferenceSopSequenceOfItems; DvtkData.Dimse.Attribute eventFailedSopSequence = new DvtkData.Dimse.Attribute(0x00081198, DvtkData.Dimse.VR.SQ); SequenceOfItems eventFailedSopSequenceOfItems = new SequenceOfItems(); eventFailedSopSequence.DicomValue = eventFailedSopSequenceOfItems; if (actionDataset != null) { DvtkData.Dimse.Attribute transactionUid = actionDataset.GetAttribute(DvtkData.Dimse.Tag.TRANSACTION_UID); if (transactionUid != null) { eventDataset.Add(transactionUid); } DvtkData.Dimse.Attribute referencedSopSequence = actionDataset.GetAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_SEQUENCE); if (referencedSopSequence != null) { SequenceOfItems sequenceOfItems = (SequenceOfItems)referencedSopSequence.DicomValue; foreach(DvtkData.Dimse.SequenceItem item in sequenceOfItems.Sequence) { System.String sopClassUid = ""; System.String sopInstanceUid = ""; 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]; } } if (informationModels.PatientRoot.IsInstanceInInformationModel(sopClassUid, sopInstanceUid)) { DvtkData.Dimse.SequenceItem itemOk = new DvtkData.Dimse.SequenceItem(); itemOk.AddAttribute(0x00081150, DvtkData.Dimse.VR.UI, sopClassUid); itemOk.AddAttribute(0x00081155, DvtkData.Dimse.VR.UI, sopInstanceUid); // add instance to committed list eventReferenceSopSequenceOfItems.Sequence.Add(itemOk); } else { DvtkData.Dimse.SequenceItem itemNotOk = new DvtkData.Dimse.SequenceItem(); itemNotOk.AddAttribute(0x00081150, DvtkData.Dimse.VR.UI, sopClassUid); itemNotOk.AddAttribute(0x00081155, DvtkData.Dimse.VR.UI, sopInstanceUid); itemNotOk.AddAttribute(0x00081197, DvtkData.Dimse.VR.US, 0x0110); // add instance to failed list eventFailedSopSequenceOfItems.Sequence.Add(itemNotOk); } } } if (eventReferenceSopSequenceOfItems.Sequence.Count > 0) { eventMessage.Set("0x00001002", VR.US, 1); eventDataset.Add(eventReferenceSopSequence); } if (eventFailedSopSequenceOfItems.Sequence.Count > 0) { eventMessage.Set("0x00001002", VR.US, 2); eventDataset.Add(eventFailedSopSequence); } } eventMessage.DataSet.DvtkDataDataSet = eventDataset; return eventMessage; }
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); } }
private static void AddStorageCommitmentValues(ReferencedSopItemCollection storageCommitItems, DvtkData.Dimse.DataSet dataset, System.String storageCommitTransactionUid, System.String mppsInstanceUid) { DvtkData.Dimse.SequenceItem referencedStudyComponentSequenceItem = new DvtkData.Dimse.SequenceItem(); referencedStudyComponentSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.GroupNumber, DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.ElementNumber, DvtkData.Dimse.VR.UI, "1.2.840.10008.3.1.2.3.3"); referencedStudyComponentSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.GroupNumber, DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.ElementNumber, DvtkData.Dimse.VR.UI, mppsInstanceUid); dataset.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_STUDY_COMPONENT_SEQUENCE.GroupNumber, DvtkData.Dimse.Tag.REFERENCED_STUDY_COMPONENT_SEQUENCE.ElementNumber, DvtkData.Dimse.VR.SQ, referencedStudyComponentSequenceItem); AddReferencedSopSequence(storageCommitItems, 0x00081199, dataset, InstanceStateEnum.InstanceStorageCommitRequested); dataset.AddAttribute(DvtkData.Dimse.Tag.TRANSACTION_UID.GroupNumber, DvtkData.Dimse.Tag.TRANSACTION_UID.ElementNumber, DvtkData.Dimse.VR.UI, storageCommitTransactionUid); }
/// <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(); BaseInformationEntityList matchingScheduledProcedureSteps = new BaseInformationEntityList(); SequenceItem queryItem = null; TagTypeList queryTagTypeList = new TagTypeList(); TagTypeList returnTagTypeList = new TagTypeList(); foreach (DvtkData.Dimse.Attribute attribute in queryDataset) { // special check for the Scheduled Procedure Step Sequence if (attribute.Tag == Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE) { SequenceOfItems sequenceOfItems = (SequenceOfItems)attribute.DicomValue; if (sequenceOfItems.Sequence.Count == 1) { queryItem = sequenceOfItems.Sequence[0]; foreach (DvtkData.Dimse.Attribute itemAttribute in queryItem) { if (itemAttribute.Length != 0) { queryTagTypeList.Add(new TagType(itemAttribute.Tag, TagTypeEnum.TagRequired)); } returnTagTypeList.Add(new TagType(itemAttribute.Tag, TagTypeEnum.TagOptional)); } } } else { if (attribute.Length != 0) { queryTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagRequired)); } returnTagTypeList.Add(new TagType(attribute.Tag, TagTypeEnum.TagOptional)); } } // iterate over the Modality Worklist Information Model and save all the matching // Scheduled Procedure Steps // iterate of all Information Entities foreach (PatientInformationEntity patientInformationEntity in Root) { if ((patientInformationEntity.IsFoundIn(queryTagTypeList, queryDataset)) || (patientInformationEntity.UniversalMatch(queryTagTypeList))) { foreach (VisitInformationEntity visitInformationEntity in patientInformationEntity.Children) { if ((visitInformationEntity.IsFoundIn(queryTagTypeList, queryDataset)) || (visitInformationEntity.UniversalMatch(queryTagTypeList))) { foreach (ImagingServiceRequestInformationEntity imagingServiceRequestInformationEntity in visitInformationEntity.Children) { if ((imagingServiceRequestInformationEntity.IsFoundIn(queryTagTypeList, queryDataset)) || (imagingServiceRequestInformationEntity.UniversalMatch(queryTagTypeList))) { foreach (RequestedProcedureInformationEntity requestedProcedureInformationEntity in imagingServiceRequestInformationEntity.Children) { if ((requestedProcedureInformationEntity.IsFoundIn(queryTagTypeList, queryDataset)) || (requestedProcedureInformationEntity.UniversalMatch(queryTagTypeList))) { foreach (ScheduledProcedureStepInformationEntity scheduledProcedureStepInformationEntity in requestedProcedureInformationEntity.Children) { if (scheduledProcedureStepInformationEntity.IsFoundIn(queryTagTypeList, queryItem)) { // add the scheduled procedure step to the matched list matchingScheduledProcedureSteps.Add(scheduledProcedureStepInformationEntity); } } } } } } } } } } // we now have a list of all the matching scheduled procedure steps foreach (ScheduledProcedureStepInformationEntity matchingScheduledProcedureStepInformationEntity in matchingScheduledProcedureSteps) { SequenceItem responseItem = new SequenceItem(); matchingScheduledProcedureStepInformationEntity.CopyTo(returnTagTypeList, responseItem); DvtkData.Dimse.Attribute attribute = new DvtkData.Dimse.Attribute(0x00400100, VR.SQ, responseItem); DataSet queryResponse = new DataSet(); queryResponse.Add(attribute); RequestedProcedureInformationEntity matchingRequestedProcedureInformationEntity = (RequestedProcedureInformationEntity)matchingScheduledProcedureStepInformationEntity.Parent; matchingRequestedProcedureInformationEntity.CopyTo(returnTagTypeList, queryResponse); ImagingServiceRequestInformationEntity matchingImagingServiceRequestInformationEntity = (ImagingServiceRequestInformationEntity)matchingRequestedProcedureInformationEntity.Parent; matchingImagingServiceRequestInformationEntity.CopyTo(returnTagTypeList, queryResponse); VisitInformationEntity matchingVisitInformationEntity = (VisitInformationEntity)matchingImagingServiceRequestInformationEntity.Parent; matchingVisitInformationEntity.CopyTo(returnTagTypeList, queryResponse); PatientInformationEntity matchingPatientInformationEntity = (PatientInformationEntity)matchingVisitInformationEntity.Parent; matchingPatientInformationEntity.CopyTo(returnTagTypeList, queryResponse); queryResponses.Add(queryResponse); } return queryResponses; }
private bool CopyToDicomMessage(DvtkData.Dimse.DicomMessage dicomMessage, DicomComparator sourceComparator) { bool messagePopulated = true; // Check if both templates have been initialized correctly if ((this.Template == null) || (sourceComparator.Template == null)) { return(false); } // Iterate over this comparator foreach (DicomComparisonTag thisComparisonTag in this.Template.ComparisonTags) { // try to get the equivalent tag in the sourceComparator DicomComparisonTag sourceComparisonTag = sourceComparator.Template.ComparisonTags.Find(thisComparisonTag.Tag); if (sourceComparisonTag != null) { System.String stringValue = sourceComparisonTag.DataFormat.ToDicomFormat(); DvtkData.Dimse.DataSet dataset = dicomMessage.DataSet; if (dataset != null) { // we need to see if the parent sequence has been set up in the dataset if (thisComparisonTag.ParentSequenceTag != Tag.UNDEFINED) { // set up the parent sequence and add it to the dataset SequenceOfItems sequenceOfItems = null; DvtkData.Dimse.Attribute sequenceAttribute = dataset.GetAttribute(thisComparisonTag.ParentSequenceTag); if (sequenceAttribute == null) { // add in an empty item DvtkData.Dimse.SequenceItem item = new SequenceItem(); dataset.AddAttribute(thisComparisonTag.ParentSequenceTag.GroupNumber, thisComparisonTag.ParentSequenceTag.ElementNumber, VR.SQ, item); sequenceAttribute = dataset.GetAttribute(thisComparisonTag.ParentSequenceTag); } // get the sequence item and add in the required attribute sequenceOfItems = (SequenceOfItems)sequenceAttribute.DicomValue; if (sequenceOfItems.Sequence.Count == 1) { DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0]; if (item != null) { // add the attribute to the item if (sourceComparisonTag.Vr == VR.SQ) { // add in an empty item // TODO - fix this properly DvtkData.Dimse.SequenceItem item1 = new SequenceItem(); item.AddAttribute(sourceComparisonTag.Tag.GroupNumber, sourceComparisonTag.Tag.ElementNumber, VR.SQ, item1); } else { // if the attribute already exists - then we need to remove it // - it was probably set to the default value DvtkData.Dimse.Attribute attribute = item.GetAttribute(sourceComparisonTag.Tag); if (attribute != null) { item.Remove(attribute); } // add the attribute to the item item.AddAttribute(sourceComparisonTag.Tag.GroupNumber, sourceComparisonTag.Tag.ElementNumber, sourceComparisonTag.Vr, stringValue); } } } } else { // if the attribute already exists - then we need to remove it // - it was probably set to the default value DvtkData.Dimse.Attribute attribute = dataset.GetAttribute(sourceComparisonTag.Tag); if (attribute != null) { dataset.Remove(attribute); } // add the attribute at the top level dataset.AddAttribute(sourceComparisonTag.Tag.GroupNumber, sourceComparisonTag.Tag.ElementNumber, sourceComparisonTag.Vr, stringValue); } } } } return(messagePopulated); }
public static DvtkHighLevelInterface.Messages.DicomMessage MakeStorageCommitEvent(QueryRetrieveInformationModels informationModels, DvtkHighLevelInterface.Messages.DicomMessage actionMessage) { // refresh the information models informationModels.Refresh(); DvtkHighLevelInterface.Messages.DicomMessage eventMessage = new DvtkHighLevelInterface.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.NEVENTREPORTRQ); eventMessage.Set("0x00000002", DvtkData.Dimse.VR.UI, "1.2.840.10008.1.20.1"); eventMessage.Set("0x00001000", DvtkData.Dimse.VR.UI, "1.2.840.10008.1.20.1.1"); eventMessage.Set("0x00001002", DvtkData.Dimse.VR.US, 1); DvtkData.Dimse.DataSet actionDataset = actionMessage.DataSet.DvtkDataDataSet; DvtkData.Dimse.DataSet eventDataset = new DvtkData.Dimse.DataSet(); DvtkData.Dimse.Attribute eventReferenceSopSequence = new DvtkData.Dimse.Attribute(0x00081199, DvtkData.Dimse.VR.SQ); SequenceOfItems eventReferenceSopSequenceOfItems = new SequenceOfItems(); eventReferenceSopSequence.DicomValue = eventReferenceSopSequenceOfItems; DvtkData.Dimse.Attribute eventFailedSopSequence = new DvtkData.Dimse.Attribute(0x00081198, DvtkData.Dimse.VR.SQ); SequenceOfItems eventFailedSopSequenceOfItems = new SequenceOfItems(); eventFailedSopSequence.DicomValue = eventFailedSopSequenceOfItems; if (actionDataset != null) { DvtkData.Dimse.Attribute transactionUid = actionDataset.GetAttribute(DvtkData.Dimse.Tag.TRANSACTION_UID); if (transactionUid != null) { eventDataset.Add(transactionUid); } DvtkData.Dimse.Attribute referencedSopSequence = actionDataset.GetAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_SEQUENCE); if (referencedSopSequence != null) { SequenceOfItems sequenceOfItems = (SequenceOfItems)referencedSopSequence.DicomValue; foreach (DvtkData.Dimse.SequenceItem item in sequenceOfItems.Sequence) { System.String sopClassUid = ""; System.String sopInstanceUid = ""; DvtkData.Dimse.Attribute attribute = item.GetAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID); if (attribute != null) { UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue; sopClassUid = uniqueIdentifier.Values[0]; } attribute = item.GetAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID); if (attribute != null) { UniqueIdentifier uniqueIdentifier = (UniqueIdentifier)attribute.DicomValue; sopInstanceUid = uniqueIdentifier.Values[0]; } if (informationModels.PatientRoot.IsInstanceInInformationModel(sopClassUid, sopInstanceUid)) { DvtkData.Dimse.SequenceItem itemOk = new DvtkData.Dimse.SequenceItem(); itemOk.AddAttribute(0x00081150, DvtkData.Dimse.VR.UI, sopClassUid); itemOk.AddAttribute(0x00081155, DvtkData.Dimse.VR.UI, sopInstanceUid); // add instance to committed list eventReferenceSopSequenceOfItems.Sequence.Add(itemOk); } else { DvtkData.Dimse.SequenceItem itemNotOk = new DvtkData.Dimse.SequenceItem(); itemNotOk.AddAttribute(0x00081150, DvtkData.Dimse.VR.UI, sopClassUid); itemNotOk.AddAttribute(0x00081155, DvtkData.Dimse.VR.UI, sopInstanceUid); itemNotOk.AddAttribute(0x00081197, DvtkData.Dimse.VR.US, 0x0110); // add instance to failed list eventFailedSopSequenceOfItems.Sequence.Add(itemNotOk); } } } if (eventReferenceSopSequenceOfItems.Sequence.Count > 0) { eventDataset.Add(eventReferenceSopSequence); } if (eventFailedSopSequenceOfItems.Sequence.Count > 0) { eventDataset.Add(eventFailedSopSequence); } } eventMessage.DataSet.DvtkDataDataSet = eventDataset; return(eventMessage); }
/// <summary> /// Adds an <see cref="SequenceItem"/> to the <see cref="Sequence"/>. /// </summary> /// <param name="value">The <see cref="SequenceItem"/> to add to the <see cref="Sequence"/>. </param> /// <returns>The position into which the new <see cref="SequenceItem"/> was inserted.</returns> public int Add(SequenceItem value) { return base.Add(value); }
private static void AddDefaultMppsCompletedDiscontinuedValues(Dvtk.Dicom.InformationEntity.DefaultValues.DefaultValueManager defaultValueManager, ReferencedSopItemCollection storageCommitItems, DvtkData.Dimse.DataSet dataset, System.String mppsStatus) { DvtkData.Dimse.SequenceItem performedSeriesSequenceItem = new DvtkData.Dimse.SequenceItem(); // Series Entity default values AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PROTOCOL_NAME, VR.LO, performedSeriesSequenceItem); AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.RETRIEVE_AE_TITLE, VR.AE, performedSeriesSequenceItem); AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SERIES_DESCRIPTION, VR.LO, performedSeriesSequenceItem); AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMING_PHYSICIANS_NAME, VR.PN, performedSeriesSequenceItem); AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.OPERATORS_NAME, VR.PN, performedSeriesSequenceItem); AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SERIES_INSTANCE_UID, VR.UI, performedSeriesSequenceItem); performedSeriesSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_STANDALONE_SOP_INSTANCE_SEQUENCE.GroupNumber, DvtkData.Dimse.Tag.REFERENCED_STANDALONE_SOP_INSTANCE_SEQUENCE.ElementNumber, DvtkData.Dimse.VR.SQ); // Performed Procedure Step Entity default values AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_END_DATE, VR.DA, dataset); AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_END_TIME, VR.TM, dataset); if (defaultValueManager.GetInstantiatedValue(DvtkData.Dimse.Tag.COMMENTS_ON_THE_PERFORMED_PROCEDURE_STEPS) != System.String.Empty) { AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.COMMENTS_ON_THE_PERFORMED_PROCEDURE_STEPS, VR.ST, dataset); } AddReferencedSopSequence(storageCommitItems, 0x00081140, performedSeriesSequenceItem, InstanceStateEnum.InstanceMppsCompleted); dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_SERIES_SEQUENCE.GroupNumber, DvtkData.Dimse.Tag.PERFORMED_SERIES_SEQUENCE.ElementNumber, DvtkData.Dimse.VR.SQ, performedSeriesSequenceItem); dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_STATUS.GroupNumber, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_STATUS.ElementNumber, VR.CS, mppsStatus); // Add any RadiationDoseDefaultValues default values AddRadiationDoseDefaultValues(defaultValueManager, dataset); }
/// <summary> /// Determines whether the <see cref="Sequence"/> contains a specific <see cref="SequenceItem"/>. /// </summary> /// <param name="value">The <see cref="SequenceItem"/> to locate in the <see cref="Sequence"/>.</param> /// <returns><see langword="true"/> if the <see cref="SequenceItem"/> is found in the <see cref="Sequence"/>; otherwise, <see langword="false"/>.</returns> public bool Contains(SequenceItem value) { return base.Contains(value); }
private static void AddDefaultMppsInProgressValues(Dvtk.Dicom.InformationEntity.DefaultValues.DefaultValueManager defaultValueManager, DvtkData.Dimse.DataSet dataset) { DvtkData.Dimse.SequenceItem scheduledStepAttributesSequenceItem = 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_ID, VR.SH, dataset); // Requested Procedure Entity default values AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.REQUESTED_PROCEDURE_ID, VR.SH, scheduledStepAttributesSequenceItem); AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.REQUESTED_PROCEDURE_DESCRIPTION, VR.LO, scheduledStepAttributesSequenceItem); AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.STUDY_INSTANCE_UID, VR.UI, scheduledStepAttributesSequenceItem); // 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, scheduledStepAttributesSequenceItem); AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SCHEDULED_PROCEDURE_STEP_DESCRIPTION, VR.LO, scheduledStepAttributesSequenceItem); AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SCHEDULED_PROCEDURE_STEP_START_DATE, VR.DA, scheduledStepAttributesSequenceItem); AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.SCHEDULED_PROCEDURE_STEP_START_TIME, VR.TM, scheduledStepAttributesSequenceItem); // 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); AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_STATION_AE_TITLE, VR.AE, dataset); AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_STATION_NAME, VR.SH, dataset); AddDefaultValue(defaultValueManager, DvtkData.Dimse.Tag.PERFORMED_LOCATION, VR.SH, dataset); // Add in zero length attributes dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_END_DATE.GroupNumber, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_END_DATE.ElementNumber, DvtkData.Dimse.VR.DA); dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_END_TIME.GroupNumber, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_END_TIME.ElementNumber, DvtkData.Dimse.VR.TM); dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_TYPE_DESCRIPTION.GroupNumber, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_TYPE_DESCRIPTION.ElementNumber, DvtkData.Dimse.VR.LO); dataset.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_PATIENT_SEQUENCE.GroupNumber, DvtkData.Dimse.Tag.REFERENCED_PATIENT_SEQUENCE.ElementNumber, DvtkData.Dimse.VR.SQ); dataset.AddAttribute(DvtkData.Dimse.Tag.PROCEDURE_CODE_SEQUENCE.GroupNumber, DvtkData.Dimse.Tag.PROCEDURE_CODE_SEQUENCE.ElementNumber, DvtkData.Dimse.VR.SQ); dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_ACTION_ITEM_SEQUENCE.GroupNumber, DvtkData.Dimse.Tag.PERFORMED_ACTION_ITEM_SEQUENCE.ElementNumber, DvtkData.Dimse.VR.SQ); dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_SERIES_SEQUENCE.GroupNumber, DvtkData.Dimse.Tag.PERFORMED_SERIES_SEQUENCE.ElementNumber, DvtkData.Dimse.VR.SQ); scheduledStepAttributesSequenceItem.AddAttribute(DvtkData.Dimse.Tag.SCHEDULED_ACTION_ITEM_CODE_SEQUENCE.GroupNumber, DvtkData.Dimse.Tag.SCHEDULED_ACTION_ITEM_CODE_SEQUENCE.ElementNumber, DvtkData.Dimse.VR.SQ); scheduledStepAttributesSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_STUDY_SEQUENCE.GroupNumber, DvtkData.Dimse.Tag.REFERENCED_STUDY_SEQUENCE.ElementNumber, DvtkData.Dimse.VR.SQ); dataset.AddAttribute(DvtkData.Dimse.Tag.SCHEDULED_STEP_ATTRIBUTES_SEQUENCE.GroupNumber, DvtkData.Dimse.Tag.SCHEDULED_STEP_ATTRIBUTES_SEQUENCE.ElementNumber, DvtkData.Dimse.VR.SQ, scheduledStepAttributesSequenceItem); dataset.AddAttribute(DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_STATUS.GroupNumber, DvtkData.Dimse.Tag.PERFORMED_PROCEDURE_STEP_STATUS.ElementNumber, DvtkData.Dimse.VR.CS, "IN PROGRESS"); }
/// <summary> /// Inserts an <see cref="SequenceItem"/> to the <see cref="Sequence"/> at the specified position. /// </summary> /// <param name="index">The zero-based index at which <c>value</c> should be inserted. </param> /// <param name="value">The <see cref="SequenceItem"/> to insert into the <see cref="Sequence"/>.</param> public void Insert(int index, SequenceItem value) { base.Insert(index, value); }
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); }
private bool CopyToDicomMessage(DvtkData.Dimse.DicomMessage dicomMessage, DicomComparator sourceComparator) { bool messagePopulated = true; // Check if both templates have been initialized correctly if ((this.Template == null) || (sourceComparator.Template == null)) { return false; } // Iterate over this comparator foreach (DicomComparisonTag thisComparisonTag in this.Template.ComparisonTags) { // try to get the equivalent tag in the sourceComparator DicomComparisonTag sourceComparisonTag = sourceComparator.Template.ComparisonTags.Find(thisComparisonTag.Tag); if (sourceComparisonTag != null) { System.String stringValue = sourceComparisonTag.DataFormat.ToDicomFormat(); DvtkData.Dimse.DataSet dataset = dicomMessage.DataSet; if (dataset != null) { // we need to see if the parent sequence has been set up in the dataset if (thisComparisonTag.ParentSequenceTag != Tag.UNDEFINED) { // set up the parent sequence and add it to the dataset SequenceOfItems sequenceOfItems = null; DvtkData.Dimse.Attribute sequenceAttribute = dataset.GetAttribute(thisComparisonTag.ParentSequenceTag); if (sequenceAttribute == null) { // add in an empty item DvtkData.Dimse.SequenceItem item = new SequenceItem(); dataset.AddAttribute(thisComparisonTag.ParentSequenceTag.GroupNumber, thisComparisonTag.ParentSequenceTag.ElementNumber, VR.SQ, item); sequenceAttribute = dataset.GetAttribute(thisComparisonTag.ParentSequenceTag); } // get the sequence item and add in the required attribute sequenceOfItems = (SequenceOfItems)sequenceAttribute.DicomValue; if (sequenceOfItems.Sequence.Count == 1) { DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0]; if (item != null) { // add the attribute to the item if (sourceComparisonTag.Vr == VR.SQ) { // add in an empty item // TODO - fix this properly DvtkData.Dimse.SequenceItem item1 = new SequenceItem(); item.AddAttribute(sourceComparisonTag.Tag.GroupNumber, sourceComparisonTag.Tag.ElementNumber, VR.SQ, item1); } else { // if the attribute already exists - then we need to remove it // - it was probably set to the default value DvtkData.Dimse.Attribute attribute = item.GetAttribute(sourceComparisonTag.Tag); if (attribute != null) { item.Remove(attribute); } // add the attribute to the item item.AddAttribute(sourceComparisonTag.Tag.GroupNumber, sourceComparisonTag.Tag.ElementNumber, sourceComparisonTag.Vr, stringValue); } } } } else { // if the attribute already exists - then we need to remove it // - it was probably set to the default value DvtkData.Dimse.Attribute attribute = dataset.GetAttribute(sourceComparisonTag.Tag); if (attribute != null) { dataset.Remove(attribute); } // add the attribute at the top level dataset.AddAttribute(sourceComparisonTag.Tag.GroupNumber, sourceComparisonTag.Tag.ElementNumber, sourceComparisonTag.Vr, stringValue); } } } } return messagePopulated; }
/// <summary> /// Checks the SQ item having value or not /// </summary> /// <param name="items"></param> /// <returns></returns> internal bool IsSequenceHavingValue(SequenceItem items) { for (int i = 0; i < items.Count; i++) { DvtkData.Dimse.Attribute attrib = items[i]; if (attrib.ValueRepresentation == VR.SQ) { foreach (SequenceItem s in ((SequenceOfItems)attrib.DicomValue).Sequence) { if (IsSequenceHavingValue(s)) return true; } } else if ((attrib.Length != 0) && (attrib.Tag.ElementNumber != 0x0000)) { return true; } } return false; }