Пример #1
0
        /// <summary>
        /// Processes the segment.
        /// Loops through all of the fields within the segment, and parsing them individually.
        /// </summary>
        /// <param name="segment">The segment.</param>
        /// <param name="parentNode">The parent node.</param>
        private static void ProcessSegmentNew(AbstractSegment segment, FieldGroup parentNode)
        {
            FieldGroup segmentNode = new FieldGroup()
            {
                Name = segment.GetStructureName(), Id = segment.GetStructureName()
            };
            int dataItemCount = 0;

            for (int i = 1; i <= segment.NumFields(); i++)
            {
                dataItemCount++;
                IType[] dataItems = segment.GetField(i);
                foreach (IType item in dataItems)
                {
                    ProcessFieldNew(item, segment.GetFieldDescription(i), dataItemCount.ToString(), segmentNode);
                }

                if (dataItems.Count() == 0 && segmentNode.FieldList.Count > 0)
                {
                    AbstractPrimitive msg = null;
                    ProcessPrimitiveFieldNew((AbstractPrimitive)msg, segment.GetFieldDescription(i), dataItemCount.ToString(), segmentNode);
                }
            }

            AddChildGroupNew(parentNode, segmentNode);
        }
Пример #2
0
        /// <summary>
        /// Processes the segment.
        /// Loops through all of the fields within the segment, and parsing them individually.
        /// </summary>
        /// <param name="segment">The segment.</param>
        /// <param name="parentNode">The parent node.</param>
        private static void ProcessSegment(AbstractSegment segment, FieldGroup parentNode)
        {
            FieldGroup segmentNode = new FieldGroup()
            {
                Name = segment.GetStructureName(), Id = segment.GetStructureName()
            };
            int dataItemCount = 0;

            for (int i = 1; i <= segment.NumFields(); i++)
            {
                dataItemCount++;
                IType[] dataItems = segment.GetField(i);
                foreach (IType item in dataItems)
                {
                    ProcessField(item, segment.GetFieldDescription(i), dataItemCount.ToString(), segmentNode);
                }
            }

            AddChildGroup(parentNode, segmentNode);
        }
Пример #3
0
        internal static string getString(AbstractSegment segment, int column, int rep)
        {
            NHapi.Base.Model.IType t = segment.GetField(column, rep);

            if (t is Varies)
            {
                return(((Varies)t).Data.ToString());
            }
            else if (t is NHapi.Model.V24.Datatype.TS)
            {
                return(((NHapi.Model.V24.Datatype.TS)t).ToString());
            }
            else if (t is NM)
            {
                return(((NM)t).Value);
            }
            else
            {
                throw new Exception("Unsupported HL7 type: " + t.TypeName);
            }
        }
        //loop through each segment
        private void LoopOnSegments(IStructure[] structures)
        {
            //Structure could be segment or a group
            foreach (IStructure structure in structures)
            {
                AbstractSegment segment = structure as AbstractSegment;
                if (segment == null)
                {
                    AbstractGroup grp = structure as AbstractGroup;
                    foreach (string name in grp.Names)
                    {
                        LoopOnSegments(grp.GetAll(name));
                    }
                }
                else
                {
                    currentSegment = segment.GetStructureName();
                    IEnumerable <CSegment> csegs = segments.Where(cseg => cseg.Name.Equals(currentSegment));
                    if (csegs.Count() > 0)
                    {
                        csegs.First().Sequence += 1;
                    }
                    else
                    {
                        segments.Add(new CSegment()
                        {
                            Name = currentSegment, Sequence = 1
                        });
                    }

                    for (int i = 1; i <= segment.NumFields(); i++)
                    {
                        fieldNumber = i;
                        LoopOnFields(segment.GetField(i));
                    }
                }
            }
        }