public static DvtkData.Dimse.DataSet Convert(Hl7Message message)
        {
            DvtkData.Dimse.DataSet dataset = new DvtkData.Dimse.DataSet("Transient");

            try
            {
                if (message != null)
                {
                    // iterate over all the segments in the HL7 message
                    ICollection segments = message.Segments.Values;
                    foreach (Hl7Segment hl7Segment in segments)
                    {
                        // iterate over all the fields in the HL7 segments
                        for (int i = 1; i < hl7Segment.Count; i++)
                        {
                            System.String hl7Value = hl7Segment[i];
                            if (hl7Value != System.String.Empty)
                            {
                                // check if there is an Hl7 Tag corresponding to the value in the DicomHl7Template
                                Hl7Tag hl7Tag = new Hl7Tag(hl7Segment[0], i);
                                DicomHl7TagMap dicomHl7TagMap = DicomHl7TagMapTemplate.FindTagMap(hl7Tag);
                                if (dicomHl7TagMap != null)
                                {
                                    System.String dicomValue = hl7Value;
                                    if (dicomHl7TagMap.ValueConvertor != null)
                                    {
                                        dicomValue = dicomHl7TagMap.ValueConvertor.FromHl7ToDicom(hl7Value, dicomHl7TagMap.Hl7ComponentIndex);
                                    }
                                    AddDicomAttribute(dataset, dicomHl7TagMap.DicomTagPath, dicomValue);
                                }

                                for (int componentIndex = 2; componentIndex < 7; componentIndex++)
                                {
                                    dicomHl7TagMap = DicomHl7TagMapTemplate.FindTagMap(hl7Tag, componentIndex);
                                    if (dicomHl7TagMap != null)
                                    {
                                        System.String dicomValue = hl7Value;
                                        if (dicomHl7TagMap.ValueConvertor != null)
                                        {
                                            dicomValue = dicomHl7TagMap.ValueConvertor.FromHl7ToDicom(hl7Value, dicomHl7TagMap.Hl7ComponentIndex);
                                        }
                                        AddDicomAttribute(dataset, dicomHl7TagMap.DicomTagPath, dicomValue);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                Console.WriteLine("HL7 to DICOM conversion exception: {0} - {1}", e.Message, e.StackTrace);
            }

            return dataset;
        }
예제 #2
0
파일: Hl7Tag.cs 프로젝트: top501/DVTK-1
        /// <summary>
        /// Returns a value indicating whether this instance is equal to a specified object
        /// </summary>
        /// <param name="obj">An <see cref="object"/> to compare with this instance, or a <see langword="null"/> reference.</param>
        /// <returns><see langword="true"/> if other is an instance of <see cref="Hl7Tag"/> and equals the value of this instance; otherwise, <see langword="false"/>.</returns>
        public override bool Equals(System.Object obj)
        {
            //Check for null and compare run-time types.
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            Hl7Tag tag = (Hl7Tag)obj;

            return(
                this._segmentId.Id == tag._segmentId.Id &&
                this._fieldIndex == tag._fieldIndex);
        }
예제 #3
0
파일: Hl7Message.cs 프로젝트: ewcasas/DVTK
 /// <summary>
 /// Get the value at the indexed field.
 /// </summary>
 /// <param name="name">Segment Name.</param>
 /// <param name="fieldIndex">Zero-based field index.</param>
 /// <returns>String - value at the indexed field.</returns>
 public System.String Value(Hl7SegmentEnum name, int fieldIndex)
 {
     Hl7Tag hl7Tag = new Hl7Tag(name, fieldIndex);
     return Value(hl7Tag);
 }
예제 #4
0
파일: Hl7TagPath.cs 프로젝트: ewcasas/DVTK
 public Hl7TagPath(Hl7Tag tag, int componentIndex, System.String name)
 {
     _tag = tag;
     _componentIndex = componentIndex;
     _name = name;
 }
예제 #5
0
파일: Hl7TagPath.cs 프로젝트: ewcasas/DVTK
 public Hl7TagPath(Hl7Tag tag, System.String name)
 {
     _tag = tag;
     _name = name;
 }
예제 #6
0
파일: Hl7TagValue.cs 프로젝트: ewcasas/DVTK
 /// <summary>
 /// Class constructor.
 /// </summary>
 /// <param name="tag">HL7 Tag.</param>
 public BaseHl7TagValue(Hl7Tag tag)
 {
     _tag = tag;
 }
예제 #7
0
        public static Tag Hl7ToDicomTag(Hl7Tag hl7Tag)
        {
            Tag dicomTag = Tag.UNDEFINED;

            foreach(DicomHl7TagMap dicomHl7TagMap in _dicomHl7TagMapCollection)
            {
                if (dicomHl7TagMap.Hl7Tag == hl7Tag)
                {
                    dicomTag = dicomHl7TagMap.DicomTag;
                    break;
                }
            }

            return dicomTag;
        }
예제 #8
0
        /// <summary>
        /// Try to find a DicomHl7TagMap in the collection using the HL7 Tag as index.
        /// </summary>
        /// <param name="hl7Tag">HL7 Tag used as index.</param>
        /// <param name="componentIndex">Component index.</param>
        /// <returns>DicomHl7TagMap - null if no match found</returns>
        public static DicomHl7TagMap FindTagMap(Hl7Tag hl7Tag, int componentIndex)
        {
            DicomHl7TagMap dicomHl7TagMap = null;

            foreach(DicomHl7TagMap lDicomHl7TagMap in _dicomHl7TagMapCollection)
            {
                if ((lDicomHl7TagMap.Hl7Tag == hl7Tag) &&
                    (lDicomHl7TagMap.Hl7ComponentIndex == componentIndex))
                {
                    dicomHl7TagMap = lDicomHl7TagMap;
                    break;
                }
            }

            return dicomHl7TagMap;
        }
예제 #9
0
 /// <summary>
 /// Class constructor.
 /// Value can be empty - universal match.
 /// </summary>
 /// <param name="tag">Tag</param>
 public Hl7TagValue(Hl7Tag tag) : base(tag)
 {
     _value = System.String.Empty;
 }
예제 #10
0
 /// <summary>
 /// Class constructor.
 /// </summary>
 /// <param name="tag">HL7 Tag.</param>
 public BaseHl7TagValue(Hl7Tag tag)
 {
     _tag = tag;
 }
예제 #11
0
        internal ValidationRuleHl7Attribute(Hl7Tag hl7Tag, FlagsBase flags)
        {
            this.hl7Tag = hl7Tag;

            Flags = flags;
        }
예제 #12
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="hl7Tag">HL7 tag indicating the HL7 attribute to validate.</param>
        /// <param name="flagsHl7Attribute">The flag(s) indicating how to validate this HL7 Attribute.</param>
        public ValidationRuleHl7Attribute(Hl7Tag hl7Tag, FlagsHl7Attribute flagsHl7Attribute)
        {
            this.hl7Tag = hl7Tag;

            Flags = FlagsConvertor.ConvertToFlagsBase(flagsHl7Attribute);
        }
예제 #13
0
        /// <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>Hl7ComparisonTag - null if no match found</returns>
        public Hl7ComparisonTag Find(Hl7Tag tag)
        {
            Hl7ComparisonTag Hl7ComparisonTag = null;
            Hl7Tag nullTag = new Hl7Tag(Hl7SegmentEnum.Unknown, -1);

            if (tag != nullTag)
            {
                foreach(Hl7ComparisonTag lHl7ComparisonTag in this)
                {
                    if (lHl7ComparisonTag.Tag == tag)
                    {
                        Hl7ComparisonTag = lHl7ComparisonTag;
                        break;
                    }
                }
            }

            return Hl7ComparisonTag;
        }
예제 #14
0
파일: Hl7TagValue.cs 프로젝트: ewcasas/DVTK
 /// <summary>
 /// Class constructor.
 /// </summary>
 /// <param name="tag">Tag</param>
 /// <param name="lValue">Value</param>
 public Hl7TagValue(Hl7Tag tag, System.String lValue)
     : base(tag)
 {
     _value = lValue;
 }
예제 #15
0
파일: Hl7TagValue.cs 프로젝트: ewcasas/DVTK
 /// <summary>
 /// Class constructor.
 /// Value can be empty - universal match.
 /// </summary>
 /// <param name="tag">Tag</param>
 public Hl7TagValue(Hl7Tag tag)
     : base(tag)
 {
     _value = System.String.Empty;
 }
예제 #16
0
파일: Hl7Message.cs 프로젝트: ewcasas/DVTK
        /// <summary>
        /// Get the value at the segment/field identified by the tag.
        /// </summary>
        /// <param name="tag">Hl7 Tag.</param>
        /// <returns>String - value at the segment/field identified by the tag.</returns>
        public System.String Value(Hl7Tag tag)
        {
            System.String val = System.String.Empty;

            Hl7Segment hl7Segment = (Hl7Segment)_segments[tag.SegmentId.Id];
            if (hl7Segment != null)
            {
                if (tag.FieldIndex < hl7Segment.Count)
                {
                    val = (System.String)hl7Segment[tag.FieldIndex];
                }
            }

            return val;
        }
예제 #17
0
        /// <summary>
        /// Try to find a DicomHl7TagMap in the collection using the HL7 Tag as index.
        /// </summary>
        /// <param name="hl7Tag">HL7 Tag used as index.</param>
        /// <returns>DicomHl7TagMap - null if no match found</returns>
        public static DicomHl7TagMap FindTagMap(Hl7Tag hl7Tag)
        {
            DicomHl7TagMap dicomHl7TagMap = null;

            foreach(DicomHl7TagMap lDicomHl7TagMap in _dicomHl7TagMapCollection)
            {
                if (lDicomHl7TagMap.Hl7Tag == hl7Tag)
                {
                    dicomHl7TagMap = lDicomHl7TagMap;
                    break;
                }
            }

            return dicomHl7TagMap;
        }
예제 #18
0
 /// <summary>
 /// Class constructor.
 /// </summary>
 /// <param name="tag">Tag</param>
 /// <param name="lValue">Value</param>
 public Hl7TagValue(Hl7Tag tag, System.String lValue) : base(tag)
 {
     _value = lValue;
 }
예제 #19
0
        public static System.String Hl7NameFromHl7Tag(Hl7Tag hl7Tag)
        {
            System.String hl7Name = System.String.Empty;

            foreach(DicomHl7TagMap dicomHl7TagMap in _dicomHl7TagMapCollection)
            {
                if (dicomHl7TagMap.Hl7Tag == hl7Tag)
                {
                    hl7Name = dicomHl7TagMap.Hl7Name;
                    break;
                }
            }

            return hl7Name;
        }
예제 #20
0
        private System.String getValue(Hl7Tag tag)
        {
            System.String lValue = System.String.Empty;

            // Try to gat a value for the gievn tag from this comparator.
            foreach (Hl7ComparisonTag thisComparisonTag in this.Template.ComparisonTags)
            {
                if (thisComparisonTag.Tag == tag)
                {
                    lValue = thisComparisonTag.DataFormat.ToHl7Format();
                    break;
                }
            }

            return lValue;
        }
예제 #21
0
        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;
        }
예제 #22
0
 /// <summary>
 /// Class constructor.
 /// </summary>
 /// <param name="tag">Comparison Tag</param>
 /// <param name="commonDataFormat">Data Format for Tag</param>
 public Hl7ComparisonTag(Hl7Tag tag, BaseCommonDataFormat commonDataFormat)
 {
     _tag = tag;
     _commonDataFormat = commonDataFormat;
 }