public void Set_dvtkDataTag_vR_parameters() { DvtkData.Dimse.Tag dvtkDataTag = new DvtkData.Dimse.Tag(0x02, 0x10); VR vR = VR.UN; fileMetaInformation.Set(dvtkDataTag, vR); }
/// <summary> /// Class Constructor. /// </summary> /// <param name="tag">Tag (group/element combination).</param> public TagType(Tag tag) { _tag = new Tag(); _tag.GroupNumber = tag.GroupNumber; _tag.ElementNumber = tag.ElementNumber; _type = TagTypeEnum.TagOptional; }
/// <summary> /// Class Constructor. /// </summary> /// <param name="tag">Tag (group/element combination).</param> /// <param name="type">Tag Type.</param> public TagType(Tag tag, TagTypeEnum type) { _tag = new Tag(); _tag.GroupNumber = tag.GroupNumber; _tag.ElementNumber = tag.ElementNumber; _type = type; }
/// <summary> /// Class constructor. /// </summary> /// <param name="parentSequenceTag">Parent Sequence Tag</param> /// <param name="tag">Comparison Tag</param> /// <param name="commonDataFormat">Data Format for Tag</param> public DicomComparisonTag(DvtkData.Dimse.Tag parentSequenceTag, DvtkData.Dimse.Tag tag, BaseCommonDataFormat commonDataFormat) { _parentSequenceTag = parentSequenceTag; _tag = tag; _commonDataFormat = commonDataFormat; }
/// <summary> /// Class constructor. /// </summary> /// <param name="segment">HL7 Segment Name.</param> /// <param name="fieldIndex">Hl7 Segment Field Index.</param> /// <param name="value1">First Compared Attribute Value.</param> /// <param name="value2">Second Compared Attribute Value.</param> public AttributeComparisonResults(System.String segment, int fieldIndex, System.String value1, System.String value2) { _tag = Tag.UNDEFINED; _segment = segment; _fieldIndex = fieldIndex; _value1 = value1; _value2 = value2; }
/// <summary> /// Try to find a DICOM tag in the collection using the HL7 Tag as index. /// </summary> /// <param name="hl7Tag">HL7 Tag used as index.</param> /// <returns>DicomTag - null if no match found</returns> public DvtkData.Dimse.Tag Find(Hl7Tag hl7Tag) { DvtkData.Dimse.Tag dicomTag = null; foreach (DicomHl7TagMap lDicomHl7TagMap in this) { if (lDicomHl7TagMap.Hl7Tag == hl7Tag) { dicomTag = lDicomHl7TagMap.DicomTag; break; } } return(dicomTag); }
/// <summary> /// Try to find a comparison tag in the collection with the same tag as the given one. /// </summary> /// <param name="tag">Tag to try to find in the collection.</param> /// <returns>DicomComparisonTag - null if no match found</returns> public DicomComparisonTag Find(DvtkData.Dimse.Tag tag) { DicomComparisonTag dicomComparisonTag = null; foreach (DicomComparisonTag lDicomComparisonTag in this) { if (lDicomComparisonTag.Tag == tag) { dicomComparisonTag = lDicomComparisonTag; break; } } return(dicomComparisonTag); }
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); }
/// <summary> /// Send all the images found in the data directory mapped from the given /// Modality Worklist item - the MapWorklistItemToStorageDirectory defines /// the data directory / worklist item attribute value mapping. /// </summary> /// <param name="modalityWorklistItem">Worklist Item used to provide overruling values for /// the Image headers.</param> /// <param name="withSingleAssociation">Boolean indicating whether the images should be sent in a single /// association or not.</param> /// <returns>Boolean indicating success or failure.</returns> public bool SendModalityImagesStored(DicomQueryItem modalityWorklistItem, bool withSingleAssociation) { if (modalityWorklistItem == null) { return(false); } // use the MapWorklistItemToStorageDirectory to get the MapTag DvtkData.Dimse.Tag mapTag = _mapWorklistItemToStorageDirectory.MapTag; if (mapTag == null) { throw new System.Exception("No MapTag defined for MapWorklistItemToStorageDirectory."); } // The MapTag is then used to search the worklist item for a matching description // - first try in the Scheduled Procedure Step Sequence System.String description = modalityWorklistItem.GetValue(Tag.SCHEDULED_PROCEDURE_STEP_SEQUENCE, mapTag); if (description == "Default") { // - now try in the remaining dataset description = modalityWorklistItem.GetValue(mapTag); } // Use the description to get the storage directory containing the DCM files that should be sent System.String storageDirectory = _mapWorklistItemToStorageDirectory.GetStorageDirectory(description); if (storageDirectory == System.String.Empty) { // Try the default mapping storageDirectory = _mapWorklistItemToStorageDirectory.GetStorageDirectory("Default"); } if (storageDirectory == System.String.Empty) { System.String message = System.String.Format("No storageDirectory mapping found for description \"{0}\" or \"Default\".", description); throw new System.Exception(message); } // Send the contents of the storage directory - updated by the modality worklist item contents return(SendModalityImagesStored(storageDirectory, modalityWorklistItem, withSingleAssociation)); }
public DicomTagPath(DvtkData.Dimse.Tag parent1Tag, DvtkData.Dimse.Tag parent2Tag, DvtkData.Dimse.Tag parent3Tag, DvtkData.Dimse.Tag tag) { _tag = parent1Tag; _nextTag = new DicomTagPath(parent2Tag, parent3Tag, tag); }
public DicomTagPath(DvtkData.Dimse.Tag parentTag, DvtkData.Dimse.Tag tag) { _tag = parentTag; _nextTag = new DicomTagPath(tag); }
/// <summary> /// Assert that the given attribute is present in the given DICOM message between the two given actors. /// Check all occurences of the given dimseCommandName in the transaction log. /// </summary> /// <param name="actorName1">First actor name in transaction.</param> /// <param name="actorName2">Second actor name in transaction.</param> /// <param name="dimseCommandName">DICOM command name.</param> /// <param name="tag">tag - Attribute tag to check for.</param> /// <returns>bool - indication if the assertion was true or false.</returns> public bool AssertDicomAttributePresentBetweenActors(ActorName actorName1, ActorName actorName2, String dimseCommandName, DvtkData.Dimse.Tag tag) { bool assertion = true; bool matchFound = false; // check all transactions // - this assertion will test the presence of the attribute tag in all occurences of the give dimseCommandName. foreach (ActorsTransaction actorsTransaction in this) { // check if a transaction exists between the required actors if (((actorsTransaction.FromActorName.TypeId == actorName1.TypeId) || (actorsTransaction.ToActorName.TypeId == actorName1.TypeId)) && ((actorsTransaction.FromActorName.TypeId == actorName2.TypeId) || (actorsTransaction.ToActorName.TypeId == actorName2.TypeId))) { // get the value of the given attribute in the DICOM message with the given DICOM command name bool attributePresent = false; if (actorsTransaction.IsDicomAttributePresent(dimseCommandName, tag, out attributePresent) == true) { matchFound = true; if (attributePresent == false) { // the attribute tag is not present String testAssertionResult = String.Format("Assertion Failure: AssertDicomAttributePresentBetweenActors {0} and {1} for DICOM Command {2} - Tag ({3},{4}) - tag not found.", actorName1.TypeId, actorName2.TypeId, dimseCommandName, tag.GroupNumber.ToString("X").PadLeft(4, '0'), tag.ElementNumber.ToString("X").PadLeft(4, '0')); _testAssertionResults.Add(testAssertionResult); assertion = false; } } } } if (matchFound == false) { // the expected count does not equal the actual count String testAssertionResult = String.Format("Assertion Failure: AssertDicomAttributePresentBetweenActors {0} and {1} for DICOM Command {2} - Tag ({3},{4}) - no corresponding messages found.", actorName1.TypeId, actorName2.TypeId, dimseCommandName, tag.GroupNumber.ToString("X").PadLeft(4, '0'), tag.ElementNumber.ToString("X").PadLeft(4, '0')); _testAssertionResults.Add(testAssertionResult); assertion = false; } return(assertion); }
/// <summary> /// Conversion function for Tag to string format /// </summary> /// <param name="groupNr"></param> /// <param name="elementNr"></param> /// <param name="display"></param> /// <returns></returns> public static string TagString(sequenceTag tag ) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); System.Byte[] groupByteArray = System.BitConverter.GetBytes(tag.GroupNumber); System.Byte[] elementByteArray = System.BitConverter.GetBytes(tag.ElementNumber); if (System.BitConverter.IsLittleEndian) { // Display as Big Endian System.Array.Reverse(groupByteArray); System.Array.Reverse(elementByteArray); } string hexByteStr0, hexByteStr1; hexByteStr0 = groupByteArray[0].ToString("x"); if (hexByteStr0.Length == 1) hexByteStr0 = "0" + hexByteStr0; // prepend with leading zero hexByteStr1 = groupByteArray[1].ToString("x"); if (hexByteStr1.Length == 1) hexByteStr1 = "0" + hexByteStr1; // prepend with leading zero sb.AppendFormat("0x{0}{1}", hexByteStr0, hexByteStr1); hexByteStr0 = elementByteArray[0].ToString("x"); if (hexByteStr0.Length == 1) hexByteStr0 = "0" + hexByteStr0; // prepend with leading zero hexByteStr1 = elementByteArray[1].ToString("x"); if (hexByteStr1.Length == 1) hexByteStr1 = "0" + hexByteStr1; // prepend with leading zero sb.AppendFormat("{0}{1}", hexByteStr0, hexByteStr1); return sb.ToString(); }
/// <summary> /// Class Constructor. /// </summary> /// <param name="group">Tag - group number.</param> /// <param name="element">Tag - element number.</param> public TagType(System.UInt16 group, System.UInt16 element) { _tag = new Tag(group, element); _type = TagTypeEnum.TagOptional; }
public static Hl7Tag DicomToHl7Tag(Tag dicomTag) { Hl7Tag hl7Tag = new Hl7Tag(Hl7SegmentEnum.Unknown, -1); foreach(DicomHl7TagMap dicomHl7TagMap in _dicomHl7TagMapCollection) { if (dicomHl7TagMap.DicomTag == dicomTag) { hl7Tag = dicomHl7TagMap.Hl7Tag; break; } } return hl7Tag; }
private static void AddEntry(DvtkData.Dimse.Tag tag, System.String segment, int fieldIndex, System.String name, BaseValueConvertor valueConvertor) { _dicomHl7TagMapCollection.Add(new DicomHl7TagMap(new DicomTagPath(tag), new Hl7TagPath(new Hl7Tag(segment, fieldIndex), name), valueConvertor)); }
public DicomTagPath(DvtkData.Dimse.Tag parentTag, DicomTagPath dicomTagPath) { _tag = parentTag; _nextTag = dicomTagPath; }
public DicomTagPath(DvtkData.Dimse.Tag tag) { _tag = tag; }
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); }
/// <summary> /// Assert that the given attribute is present in the given DICOM message between the two given actors. /// Check all occurences of the given dimseCommandName in the transaction log. /// </summary> /// <param name="actorName1">First actor name in transaction.</param> /// <param name="actorName2">Second actor name in transaction.</param> /// <param name="dimseCommandName">DICOM command name.</param> /// <param name="tag">tag - Attribute tag to check for.</param> /// <returns>bool - indication if the assertion was true or false.</returns> public bool AssertDicomAttributePresentBetweenActors(ActorName actorName1, ActorName actorName2, String dimseCommandName, DvtkData.Dimse.Tag tag) { return(_actorsTransactionLog.AssertDicomAttributePresentBetweenActors(actorName1, actorName2, dimseCommandName, tag)); }
/// <summary> /// Assert that the given attribute value in the given DICOM message has the expected value between the two given actors. /// </summary> /// <param name="actorName1">First actor name in transaction.</param> /// <param name="actorName2">Second actor name in transaction.</param> /// <param name="dimseCommandName">DICOM command name.</param> /// <param name="tag">tag - Attribute tag whose first value is the actual value.</param> /// <param name="expectedValue">The expected attribute value - this will be compared with the actual attribute value.</param> /// <returns>bool - indication if the assertion was true or false.</returns> public bool AssertDicomAttributeValueBetweenActors(ActorName actorName1, ActorName actorName2, String dimseCommandName, DvtkData.Dimse.Tag tag, String expectedValue) { return(_actorsTransactionLog.AssertDicomAttributeValueBetweenActors(actorName1, actorName2, dimseCommandName, tag, expectedValue)); }
private static void AddEntry(DvtkData.Dimse.Tag parent1Tag, DvtkData.Dimse.Tag parent2Tag, DvtkData.Dimse.Tag tag, System.String segment, int fieldIndex, System.String name) { _dicomHl7TagMapCollection.Add(new DicomHl7TagMap(new DicomTagPath(parent1Tag, parent2Tag, tag), new Hl7TagPath(new Hl7Tag(segment, fieldIndex), name))); }
public DicomTagVr(Tag tag, VR vr) { _tag = tag; _vr = vr; }
/// <summary> /// Gets first occurence of <see cref="Sequence"/> with <see cref="Tag"/>. /// </summary> /// <param name="tag">tag</param> /// <returns>sequence. Returns <see langword="null"/> if not found.</returns> public Sequence GetSequence(Tag tag) { Sequence sequence = null; foreach (Attribute attribute in this) { if ( attribute.Tag.Equals(tag) && attribute.DicomValue != null && attribute.DicomValue is DvtkData.Dimse.SequenceOfItems ) { sequence = (attribute.DicomValue as DvtkData.Dimse.SequenceOfItems).Sequence; } } return sequence; }
/// <summary> /// Class constructor. /// </summary> /// <param name="tag">Comparison Tag</param> /// <param name="vr">Tag VR.</param> /// <param name="commonDataFormat">Data Format for Tag</param> public DicomComparisonTag(DvtkData.Dimse.Tag tag, VR vr, BaseCommonDataFormat commonDataFormat) { _tag = tag; _vr = vr; _commonDataFormat = commonDataFormat; }
private System.String getValue(Tag tag) { System.String lValue = System.String.Empty; // Try to gat a value for the gievn tag from this comparator. foreach (DicomComparisonTag thisComparisonTag in this.Template.ComparisonTags) { if (thisComparisonTag.Tag == tag) { lValue = thisComparisonTag.DataFormat.ToDicomFormat(); break; } } return lValue; }
/// <summary> /// Class Constructor. /// </summary> /// <param name="group">Tag - group number.</param> /// <param name="element">Tag - element number.</param> /// <param name="type">Tag Type.</param> public TagType(System.UInt16 group, System.UInt16 element, TagTypeEnum type) { _tag = new Tag(group, element); _type = type; }
/// <summary> /// /// </summary> /// <param name="tag"></param> /// <returns></returns> public System.String GetInstantiatedValue(Tag tag) { System.String lValue = System.String.Empty; // Try to get the instantiated default tag value BaseDicomTagValue instantiatedDefaultTagValue = _instantiatedDefaultTagValues.Find(tag); if (instantiatedDefaultTagValue != null) { if (instantiatedDefaultTagValue is DicomTagValue) { DicomTagValue tagValue = (DicomTagValue)instantiatedDefaultTagValue; lValue = tagValue.Value; } } return lValue; }
public static VR GetVR(Tag tag) { return _dicomTagVrCollection.GetVR(tag); }
/// <summary> /// Gets first occurence of <see cref="Attribute"/> with <see cref="Tag"/>. /// </summary> /// <param name="tag">tag</param> /// <returns>attribute. Returns <see langword="null"/> if not found.</returns> public Attribute GetAttribute(Tag tag) { foreach (Attribute attribute in this) { if (attribute.Tag.Equals(tag)) return attribute; } return null; }
/// <summary> /// Class constructor. /// </summary> /// <param name="tag">Attribute Tag.</param> /// <param name="value1">First Compared Attribute Value.</param> /// <param name="value2">Second Compared Attribute Value.</param> public AttributeComparisonResults(Tag tag, System.String value1, System.String value2) { _Tag = tag; _Value1 = value1; _Value2 = value2; }