示例#1
0
        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
        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);
        }
示例#3
0
        /// <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);
        }
示例#4
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);
        }
示例#5
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);
        }
示例#6
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);
        }
示例#7
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);
        }
示例#8
0
        /// <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);
        }
示例#9
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);
        }
示例#10
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);
        }
示例#11
0
        private bool LoadTemplate(Hl7Message hl7Message)
        {
            if (hl7Message == null)
            {
                return(false);
            }

            // try to find the template tag in the dataset
            foreach (Hl7ComparisonTag comparisonTag in this.Template.ComparisonTags)
            {
                Hl7Tag        tag            = comparisonTag.Tag;
                System.String attributeValue = hl7Message.Value(tag.Segment, tag.FieldIndex);

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

            return(true);
        }
示例#12
0
        /// <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));
        }
示例#13
0
        internal ValidationRuleHl7Attribute(Hl7Tag hl7Tag, FlagsBase flags)
        {
            this.hl7Tag = hl7Tag;

            Flags = flags;
        }
示例#14
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);
        }
示例#15
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;
 }
示例#16
0
 public Hl7TagPath(Hl7Tag tag, int componentIndex, System.String name)
 {
     _tag            = tag;
     _componentIndex = componentIndex;
     _name           = name;
 }
示例#17
0
 public Hl7TagPath(Hl7Tag tag, System.String name)
 {
     _tag  = tag;
     _name = name;
 }