Exemplo n.º 1
0
 ///<summary>The new X12object will point to the same data as the x12other.  This is for efficiency and to save memory.  Be careful.</summary>
 public X12object(X12object x12other)
 {
     FilePath        = x12other.FilePath;
     DateInterchange = x12other.DateInterchange;
     Separators      = x12other.Separators;
     FunctGroups     = x12other.FunctGroups;
     Segments        = x12other.Segments;
 }
Exemplo n.º 2
0
 public X12Segment(X12Segment seg)
 {
     SegmentID    = seg.SegmentID;
     Elements     = (string[])seg.Elements.Clone();      //shallow copy is fine since just strings.
     SegmentIndex = seg.SegmentIndex;
     Separators   = seg.Separators;
     RawText      = seg.RawText;
 }
Exemplo n.º 3
0
        ///<summary>Takes raw text and converts it into an X12Object.</summary>
        public X12object(string messageText)
        {
            messageText = messageText.Replace("\r", "");
            messageText = messageText.Replace("\n", "");
            if (messageText.Substring(0, 3) != "ISA")
            {
                throw new ApplicationException("ISA not found");
            }
            Separators            = new X12Separators();
            Separators.Element    = messageText.Substring(3, 1);
            Separators.Subelement = messageText.Substring(104, 1);
            Separators.Segment    = messageText.Substring(105, 1);
            string[] messageRows = messageText.Split(new string[] { Separators.Segment }, StringSplitOptions.None);
            FunctGroups = new List <X12FunctionalGroup>();
            Segments    = new List <X12Segment>();
            string     row;
            X12Segment segment;

            for (int i = 1; i < messageRows.Length; i++)
            {
                row     = messageRows[i];
                segment = new X12Segment(row, Separators);
                Segments.Add(segment);
                if (segment.SegmentID == "IEA")              //if end of interchange
                //do nothing
                {
                }
                if (segment.SegmentID == "GS")              //if new functional group
                {
                    FunctGroups.Add(new X12FunctionalGroup(segment));
                }
                else if (segment.SegmentID == "GE")              //if end of functional group
                //do nothing
                {
                }
                else if (segment.SegmentID == "ST")              //if new transaction set
                {
                    if (LastGroup().Transactions == null)
                    {
                        LastGroup().Transactions = new List <X12Transaction>();
                    }
                    LastGroup().Transactions.Add(new X12Transaction(segment));
                }
                else if (segment.SegmentID == "SE")              //if end of transaction
                //do nothing
                {
                }
                else                 //it must be a detail segment within a transaction.
                {
                    if (LastTransaction().Segments == null)
                    {
                        LastTransaction().Segments = new List <X12Segment>();
                    }
                    LastTransaction().Segments.Add(segment);
                }
                //row=sr.ReadLine();
            }
        }
Exemplo n.º 4
0
 ///<summary></summary>
 public X12Segment(string rawTxt, X12Separators separators)
 {
     rawText    = rawTxt.ToString();
     Separators = separators;
     //first, remove the segment terminator
     rawTxt = rawTxt.Replace(separators.Segment, "");
     //then, split the row into elements, eliminating the DataElementSeparator
     Elements  = rawText.Split(Char.Parse(separators.Element));
     SegmentID = Elements[0];
 }
Exemplo n.º 5
0
		///<summary>Takes raw text and converts it into an X12Object.</summary>
		public X12object(string messageText){
			messageText=messageText.Replace("\r","");
			messageText=messageText.Replace("\n","");
			if(messageText.Substring(0,3)!="ISA"){
				throw new ApplicationException("ISA not found");
			}
			Separators=new X12Separators();
			Separators.Element=messageText.Substring(3,1);
			Separators.Subelement=messageText.Substring(104,1);
			Separators.Segment=messageText.Substring(105,1);
			string[] messageRows=messageText.Split(new string[] {Separators.Segment},StringSplitOptions.None);
			FunctGroups=new List<X12FunctionalGroup>();
			Segments=new List<X12Segment>();
			string row;
			X12Segment segment;
			for(int i=1;i<messageRows.Length;i++){
				row=messageRows[i];
				segment=new X12Segment(row,Separators);
				Segments.Add(segment);
				if(messageRows[i]=="") {
					//do nothing
				}
				else if(segment.SegmentID=="IEA") {//if end of interchange
					//do nothing
				}
				else if(segment.SegmentID=="GS") {//if new functional group
					FunctGroups.Add(new X12FunctionalGroup(segment));
				}
				else if(segment.SegmentID=="GE") {//if end of functional group
					//do nothing
				}
				else if(segment.SegmentID=="ST") {//if new transaction set
					if(LastGroup().Transactions==null) {
						LastGroup().Transactions=new List<X12Transaction>();
					}
					LastGroup().Transactions.Add(new X12Transaction(segment));
				}
				else if(segment.SegmentID=="SE") {//if end of transaction
					//do nothing
				}
				else if(segment.SegmentID=="TA1") {//This segment can either replace or supplement any GS segments for any ack type (997,999,277).  The TA1 will always be before the first GS segment.
					//Ignore for now.  We should eventually match TA101 with the ISA13 of the claim that we sent, so we can report the status to the user using fields TA104 and TA105.
					//This segment is neither mandated or prohibited (see 277.pdf pg. 207).
				}
				else {//it must be a detail segment within a transaction.
					if(LastTransaction().Segments==null) {
						LastTransaction().Segments=new List<X12Segment>();
					}
					LastTransaction().Segments.Add(segment);
				}
				//row=sr.ReadLine();
			}
		}
Exemplo n.º 6
0
 ///<summary>Takes raw text and converts it into an X12Object.</summary>
 public X12object(string messageText)
 {
     messageText=messageText.Replace("\r","");
     messageText=messageText.Replace("\n","");
     if(messageText.Substring(0,3)!="ISA"){
         throw new ApplicationException("ISA not found");
     }
     Separators=new X12Separators();
     Separators.Element=messageText.Substring(3,1);
     Separators.Subelement=messageText.Substring(104,1);
     Separators.Segment=messageText.Substring(105,1);
     string[] messageRows=messageText.Split(new string[] {Separators.Segment},StringSplitOptions.None);
     FunctGroups=new List<X12FunctionalGroup>();
     Segments=new List<X12Segment>();
     string row;
     X12Segment segment;
     for(int i=1;i<messageRows.Length;i++){
         row=messageRows[i];
         segment=new X12Segment(row,Separators);
         Segments.Add(segment);
         if(segment.SegmentID=="IEA"){//if end of interchange
             //do nothing
         }
         if(segment.SegmentID=="GS"){//if new functional group
             FunctGroups.Add(new X12FunctionalGroup(segment));
         }
         else if(segment.SegmentID=="GE"){//if end of functional group
             //do nothing
         }
         else if(segment.SegmentID=="ST"){//if new transaction set
             if(LastGroup().Transactions==null){
                 LastGroup().Transactions=new List<X12Transaction>();
             }
             LastGroup().Transactions.Add(new X12Transaction(segment));
         }
         else if(segment.SegmentID=="SE"){//if end of transaction
             //do nothing
         }
         else{//it must be a detail segment within a transaction.
             if(LastTransaction().Segments==null){
                 LastTransaction().Segments=new List<X12Segment>();
             }
             LastTransaction().Segments.Add(segment);
         }
         //row=sr.ReadLine();
     }
 }
Exemplo n.º 7
0
        ///<summary>Takes raw text and converts it into an X12Object.</summary>
        public X12object(string messageText)
        {
            messageText = messageText.Replace("\r", "");
            messageText = messageText.Replace("\n", "");
            if (messageText.Substring(0, 3) != "ISA")
            {
                throw new ApplicationException("ISA not found");
            }
            Separators            = new X12Separators();
            Separators.Element    = messageText.Substring(3, 1);
            Separators.Subelement = messageText.Substring(104, 1);
            Separators.Segment    = messageText.Substring(105, 1);
            string[] messageRows = messageText.Split(new string[] { Separators.Segment }, StringSplitOptions.None);
            FunctGroups = new List <X12FunctionalGroup>();
            Segments    = new List <X12Segment>();
            string     row;
            X12Segment segment;

            for (int i = 1; i < messageRows.Length; i++)
            {
                row     = messageRows[i];
                segment = new X12Segment(row, Separators);
                Segments.Add(segment);
                if (messageRows[i] == "")
                {
                    //do nothing
                }
                else if (segment.SegmentID == "IEA")               //if end of interchange
                //do nothing
                {
                }
                else if (segment.SegmentID == "GS")               //if new functional group
                {
                    FunctGroups.Add(new X12FunctionalGroup(segment));
                }
                else if (segment.SegmentID == "GE")               //if end of functional group
                //do nothing
                {
                }
                else if (segment.SegmentID == "ST")               //if new transaction set
                {
                    if (LastGroup().Transactions == null)
                    {
                        LastGroup().Transactions = new List <X12Transaction>();
                    }
                    LastGroup().Transactions.Add(new X12Transaction(segment));
                }
                else if (segment.SegmentID == "SE")               //if end of transaction
                //do nothing
                {
                }
                else if (segment.SegmentID == "TA1")               //This segment can either replace or supplement any GS segments for any ack type (997,999,277).  The TA1 will always be before the first GS segment.
                //Ignore for now.  We should eventually match TA101 with the ISA13 of the claim that we sent, so we can report the status to the user using fields TA104 and TA105.
                //This segment is neither mandated or prohibited (see 277.pdf pg. 207).
                {
                }
                else                  //it must be a detail segment within a transaction.
                {
                    if (LastTransaction().Segments == null)
                    {
                        LastTransaction().Segments = new List <X12Segment>();
                    }
                    LastTransaction().Segments.Add(segment);
                }
                //row=sr.ReadLine();
            }
        }
Exemplo n.º 8
0
		///<summary></summary>
		public X12Segment(string rawTxt,X12Separators separators){
			rawText=rawTxt.ToString();
			Separators=separators;
			//first, remove the segment terminator
			rawTxt=rawTxt.Replace(separators.Segment,"");
			//then, split the row into elements, eliminating the DataElementSeparator
			Elements=rawText.Split(Char.Parse(separators.Element));
			SegmentID=Elements[0];
		}
Exemplo n.º 9
0
        ///<summary>Takes raw text and converts it into an X12Object.</summary>
        public X12object(string messageText)
        {
            messageText = messageText.Replace("\r", "");
            messageText = messageText.Replace("\n", "");
            if (messageText.Substring(0, 3) != "ISA")
            {
                throw new ApplicationException("ISA not found");
            }
            Separators            = new X12Separators();
            Separators.Element    = messageText.Substring(3, 1);
            Separators.Subelement = messageText.Substring(104, 1);
            Separators.Segment    = messageText.Substring(105, 1);
            string[] arrayRawSegments = messageText.Split(new string[] { Separators.Segment }, StringSplitOptions.None);
            FunctGroups = new List <X12FunctionalGroup>();
            Segments    = new List <X12Segment>();
            X12Segment segment;

            for (int i = 0; i < arrayRawSegments.Length; i++)
            {
                segment = new X12Segment(arrayRawSegments[i], Separators);
                segment.SegmentIndex = i;
                Segments.Add(segment);
                if (arrayRawSegments[i] == "")
                {
                    //do nothing
                }
                else if (segment.SegmentID == "ISA")               //interchange control header begin
                //do not add to list of segments
                {
                    try {
                        DateInterchange = DateTime.ParseExact(segment.Get(9) + segment.Get(10), "yyMMddHHmm", CultureInfo.CurrentCulture.DateTimeFormat);
                    }
                    catch (Exception ex) {
                        ex.DoNothing();
                        DateInterchange = DateTime.MinValue;
                    }
                }
                else if (segment.SegmentID == "IEA")               //interchange control header end
                //do nothing
                {
                }
                else if (segment.SegmentID == "GS")               //if new functional group
                {
                    FunctGroups.Add(new X12FunctionalGroup(segment));
                }
                else if (segment.SegmentID == "GE")               //if end of functional group
                //do nothing
                {
                }
                else if (segment.SegmentID == "ST")               //if new transaction set
                {
                    if (LastGroup().Transactions == null)
                    {
                        LastGroup().Transactions = new List <X12Transaction>();
                    }
                    LastGroup().Transactions.Add(new X12Transaction(segment));
                }
                else if (segment.SegmentID == "SE")               //if end of transaction
                //do nothing
                {
                }
                else if (segment.SegmentID == "TA1")               //This segment can either replace or supplement any GS segments for any ack type (997,999,277).  The TA1 will always be before the first GS segment.
                //Ignore for now.  We should eventually match TA101 with the ISA13 of the claim that we sent, so we can report the status to the user using fields TA104 and TA105.
                //This segment is neither mandated or prohibited (see 277.pdf pg. 207).
                {
                }
                else                  //it must be a detail segment within a transaction.
                {
                    if (LastTransaction().Segments == null)
                    {
                        LastTransaction().Segments = new List <X12Segment>();
                    }
                    LastTransaction().Segments.Add(segment);
                }
                //row=sr.ReadLine();
            }
        }