Ejemplo n.º 1
0
 /// <summary>
 /// Processes a structure group.
 /// A structure group is, primarily, a group of segments.  This could either be the entire
 /// message or special segments that need to be grouped together.  An example of this is
 /// the result segments (OBR, OBX and NTE), these are grouped together in the model
 /// definition (e.g. REF_I12_RESULTS_NOTES).
 /// </summary>
 /// <param name="structureGroup">The structure group.</param>
 /// <param name="parentNode">The parent node, in the TreeListView.</param>
 public static void ProcessStructureGroup(AbstractGroup structureGroup, FieldGroup parentNode)
 {
     foreach (string segName in structureGroup.Names)
     {
         foreach (IStructure struc in structureGroup.GetAll(segName))
         {
             ProcessStructure(struc, parentNode);
         }
     }
 }
        public bool Validate(string hl7Text, string version)
        {
            IMessage      message = new PipeParser().Parse(hl7Text, version);
            AbstractGroup grp     = message as AbstractGroup;

            if (grp != null)
            {
                foreach (string name in grp.Names)
                {
                    LoopOnSegments(grp.GetAll(name));
                }
            }
            return(errorCollection.Count > 0);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Processes the structure.
 /// A base structure can be either a segment, or segment group. This function
 /// determines which it is before passing it on.
 /// </summary>
 /// <param name="structure">The structure.</param>
 /// <param name="parentNode">The parent node, in the TreeListView.</param>
 private static void ProcessStructure(IStructure structure, FieldGroup parentNode)
 {
     if (structure.GetType().IsSubclassOf(typeof(AbstractSegment)))
     {
         AbstractSegment seg = (AbstractSegment)structure;
         ProcessSegment(seg, parentNode);
     }
     else if (structure.GetType().IsSubclassOf(typeof(AbstractGroup)))
     {
         AbstractGroup structureGroup = (AbstractGroup)structure;
         ProcessStructureGroup(structureGroup, parentNode);
     }
     else
     {
         parentNode.FieldList.Add(new FieldGroup()
         {
             Name = "Something Else!!!"
         });
     }
 }
        //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));
                    }
                }
            }
        }