public Loop2000D(X12Doc owningDoc, LoopEntity prev, LoopCollection parent) : base(owningDoc, prev, parent)
 {
     SubscriberLevel = new HlCollection(this, nameof(SubscriberLevel));
     SegmentCollections.Add(SubscriberLevel);
     SubscriberDemographicInformation = new DmgCollection(this, nameof(SubscriberDemographicInformation));
     SegmentCollections.Add(SubscriberDemographicInformation);
 }
예제 #2
0
public Loop2100A(X12Doc owningDoc, LoopEntity prev, LoopCollection parent):base(owningDoc, prev, parent){
PayerName = new Nm1Collection(this, nameof(PayerName));
SegmentCollections.Add(PayerName);
PayerContactInformation = new PerCollection(this, nameof(PayerContactInformation));
SegmentCollections.Add(PayerContactInformation);
 
}
예제 #3
0
public Loop2200D(X12Doc owningDoc, LoopEntity prev, LoopCollection parent):base(owningDoc, prev, parent){
ClaimStatusTrackingNumber = new TrnCollection(this, nameof(ClaimStatusTrackingNumber));
SegmentCollections.Add(ClaimStatusTrackingNumber);
ClaimLevelStatusInformation = new StcCollection(this, nameof(ClaimLevelStatusInformation));
SegmentCollections.Add(ClaimLevelStatusInformation);
PayerClaimControlNumber = new RefCollection(this, nameof(PayerClaimControlNumber));
SegmentCollections.Add(PayerClaimControlNumber);
InstitutionalBillTypeIdentification = new RefCollection(this, nameof(InstitutionalBillTypeIdentification));
SegmentCollections.Add(InstitutionalBillTypeIdentification);
PatientControlNumber = new RefCollection(this, nameof(PatientControlNumber));
SegmentCollections.Add(PatientControlNumber);
PharmacyPrescriptionNumber = new RefCollection(this, nameof(PharmacyPrescriptionNumber));
SegmentCollections.Add(PharmacyPrescriptionNumber);
VoucherIdentifier = new RefCollection(this, nameof(VoucherIdentifier));
SegmentCollections.Add(VoucherIdentifier);
ClaimIdentificationNumberForClearinghousesAnd = new RefCollection(this, nameof(ClaimIdentificationNumberForClearinghousesAnd));
SegmentCollections.Add(ClaimIdentificationNumberForClearinghousesAnd);
ClaimServiceDate = new DtpCollection(this, nameof(ClaimServiceDate));
SegmentCollections.Add(ClaimServiceDate);
 
ServiceLineInformationLoop = new Loop2220DCollection("Loop2220D", nameof(ServiceLineInformationLoop), OwningDoc, parent, parent);
ChildLoopCollections.Add(ServiceLineInformationLoop);
DependentLevelLoop = new Loop2000ECollection("Loop2000E", nameof(DependentLevelLoop), OwningDoc, parent, parent);
ChildLoopCollections.Add(DependentLevelLoop);
DependentNameLoop = new Loop2100ECollection("Loop2100E", nameof(DependentNameLoop), OwningDoc, parent, parent);
ChildLoopCollections.Add(DependentNameLoop);
ClaimStatusTrackingNumberLoop = new Loop2200ECollection("Loop2200E", nameof(ClaimStatusTrackingNumberLoop), OwningDoc, parent, parent);
ChildLoopCollections.Add(ClaimStatusTrackingNumberLoop);
}
    public Loop2200E(X12Doc owningDoc, LoopEntity prev, LoopCollection parent) : base(owningDoc, prev, parent)
    {
        ClaimStatusTrackingNumber = new TrnCollection(this, nameof(ClaimStatusTrackingNumber));
        SegmentCollections.Add(ClaimStatusTrackingNumber);
        PayerClaimControlNumber = new RefCollection(this, nameof(PayerClaimControlNumber));
        SegmentCollections.Add(PayerClaimControlNumber);
        InstitutionalBillTypeIdentification = new RefCollection(this, nameof(InstitutionalBillTypeIdentification));
        SegmentCollections.Add(InstitutionalBillTypeIdentification);
        ApplicationOrLocationSystemIdentifier = new RefCollection(this, nameof(ApplicationOrLocationSystemIdentifier));
        SegmentCollections.Add(ApplicationOrLocationSystemIdentifier);
        GroupNumber = new RefCollection(this, nameof(GroupNumber));
        SegmentCollections.Add(GroupNumber);
        PatientControlNumber = new RefCollection(this, nameof(PatientControlNumber));
        SegmentCollections.Add(PatientControlNumber);
        PharmacyPrescriptionNumber = new RefCollection(this, nameof(PharmacyPrescriptionNumber));
        SegmentCollections.Add(PharmacyPrescriptionNumber);
        ClaimIdentificationNumberForClearinghousesAnd = new RefCollection(this, nameof(ClaimIdentificationNumberForClearinghousesAnd));
        SegmentCollections.Add(ClaimIdentificationNumberForClearinghousesAnd);
        ClaimSubmittedCharges = new AmtCollection(this, nameof(ClaimSubmittedCharges));
        SegmentCollections.Add(ClaimSubmittedCharges);
        ClaimServiceDate = new DtpCollection(this, nameof(ClaimServiceDate));
        SegmentCollections.Add(ClaimServiceDate);

        ServiceLineInformationLoop = new Loop2210ECollection("Loop2210E", nameof(ServiceLineInformationLoop), OwningDoc, parent, parent);
        ChildLoopCollections.Add(ServiceLineInformationLoop);
    }
예제 #5
0
public Loop2100D(X12Doc owningDoc, LoopEntity prev, LoopCollection parent):base(owningDoc, prev, parent){
SubscriberName = new Nm1Collection(this, nameof(SubscriberName));
SegmentCollections.Add(SubscriberName);
 
ClaimStatusTrackingNumberLoop = new Loop2200DCollection("Loop2200D", nameof(ClaimStatusTrackingNumberLoop), OwningDoc, parent, parent);
ChildLoopCollections.Add(ClaimStatusTrackingNumberLoop);
}
 public Loop2000E(X12Doc owningDoc, LoopEntity prev, LoopCollection parent) : base(owningDoc, prev, parent)
 {
     DependentLevel = new HlCollection(this, nameof(DependentLevel));
     SegmentCollections.Add(DependentLevel);
     DependentDemographicInformation = new DmgCollection(this, nameof(DependentDemographicInformation));
     SegmentCollections.Add(DependentDemographicInformation);
 }
 public Loop2210D(X12Doc owningDoc, LoopEntity prev, LoopCollection parent) : base(owningDoc, prev, parent)
 {
     ServiceLineInformation = new SvcCollection(this, nameof(ServiceLineInformation));
     SegmentCollections.Add(ServiceLineInformation);
     ServiceLineItemIdentification = new RefCollection(this, nameof(ServiceLineItemIdentification));
     SegmentCollections.Add(ServiceLineItemIdentification);
     ServiceLineDate = new DtpCollection(this, nameof(ServiceLineDate));
     SegmentCollections.Add(ServiceLineDate);
 }
    public Loop2100C(X12Doc owningDoc, LoopEntity prev, LoopCollection parent) : base(owningDoc, prev, parent)
    {
        ProviderName = new Nm1Collection(this, nameof(ProviderName));
        SegmentCollections.Add(ProviderName);

        SubscriberLevelLoop = new Loop2000DCollection("Loop2000D", nameof(SubscriberLevelLoop), OwningDoc, parent, parent);
        ChildLoopCollections.Add(SubscriberLevelLoop);
        SubscriberNameLoop = new Loop2100DCollection("Loop2100D", nameof(SubscriberNameLoop), OwningDoc, parent, parent);
        ChildLoopCollections.Add(SubscriberNameLoop);
    }
    public Loop2100B(X12Doc owningDoc, LoopEntity prev, LoopCollection parent) : base(owningDoc, prev, parent)
    {
        InformationReceiverName = new Nm1Collection(this, nameof(InformationReceiverName));
        SegmentCollections.Add(InformationReceiverName);

        ServiceProviderLevelLoop = new Loop2000CCollection("Loop2000C", nameof(ServiceProviderLevelLoop), OwningDoc, parent, parent);
        ChildLoopCollections.Add(ServiceProviderLevelLoop);
        ProviderNameLoop = new Loop2100CCollection("Loop2100C", nameof(ProviderNameLoop), OwningDoc, parent, parent);
        ChildLoopCollections.Add(ProviderNameLoop);
    }
예제 #10
0
 /// <summary>
 /// Default Ctor, requires both the stream of the file and a reference to the pre-created x12 document to begin populating
 /// </summary>
 /// <param name="s">x12 file in stream form</param>
 /// <param name="x12Doc">pre-created x12 doc to begin populating</param>
 public SegmentStream(Stream s, ref X12Doc x12Doc)
 {
     _buffer    = new byte[BufferSize];
     BaseStream = s;
     EndOfFile  = false;
     x12Doc.InterchagneControlHeader = new ISA();
     x12Doc.InterchagneControlHeader.FromStream(s);
     _lastPoisition = s.Position;
     _head          = _tail = 0;
 }
예제 #11
0
public Loop2200C(X12Doc owningDoc, LoopEntity prev, LoopCollection parent):base(owningDoc, prev, parent){
ProviderOfServiceTraceIdentifier = new TrnCollection(this, nameof(ProviderOfServiceTraceIdentifier));
SegmentCollections.Add(ProviderOfServiceTraceIdentifier);
ProviderStatusInformation = new StcCollection(this, nameof(ProviderStatusInformation));
SegmentCollections.Add(ProviderStatusInformation);
 
SubscriberLevelLoop = new Loop2000DCollection("Loop2000D", nameof(SubscriberLevelLoop), OwningDoc, parent, parent);
ChildLoopCollections.Add(SubscriberLevelLoop);
SubscriberNameLoop = new Loop2100DCollection("Loop2100D", nameof(SubscriberNameLoop), OwningDoc, parent, parent);
ChildLoopCollections.Add(SubscriberNameLoop);
}
예제 #12
0
public Loop2220E(X12Doc owningDoc, LoopEntity prev, LoopCollection parent):base(owningDoc, prev, parent){
ServiceLineInformation = new SvcCollection(this, nameof(ServiceLineInformation));
SegmentCollections.Add(ServiceLineInformation);
ServiceLineStatusInformation = new StcCollection(this, nameof(ServiceLineStatusInformation));
SegmentCollections.Add(ServiceLineStatusInformation);
ServiceLineItemIdentification = new RefCollection(this, nameof(ServiceLineItemIdentification));
SegmentCollections.Add(ServiceLineItemIdentification);
ServiceLineDate = new DtpCollection(this, nameof(ServiceLineDate));
SegmentCollections.Add(ServiceLineDate);
TransactionSetTrailer = new SeCollection(this, nameof(TransactionSetTrailer));
SegmentCollections.Add(TransactionSetTrailer);
 
}
예제 #13
0
public Loop01GE(X12Doc owningDoc, LoopEntity prev, LoopCollection parent):base(owningDoc, prev, parent){
FunctionalGroupHeader = new GsCollection(this, nameof(FunctionalGroupHeader));
SegmentCollections.Add(FunctionalGroupHeader);
FunctionalGroupTrailer = new GeCollection(this, nameof(FunctionalGroupTrailer));
SegmentCollections.Add(FunctionalGroupTrailer);
TransactionSetHeader = new Collection(this, nameof(TransactionSetHeader));
SegmentCollections.Add(TransactionSetHeader);
Empty = new StCollection(this, nameof(Empty));
SegmentCollections.Add(Empty);
Empty = new TableCollection(this, nameof(Empty));
SegmentCollections.Add(Empty);
 
}
예제 #14
0
public Loop2100E(X12Doc owningDoc, LoopEntity prev, LoopCollection parent):base(owningDoc, prev, parent){
DependentName = new Nm1Collection(this, nameof(DependentName));
SegmentCollections.Add(DependentName);
 
}
예제 #15
0
        private static ParserStateMachine ParseLineSegment(this X12Doc tempBuildingDoc, ParserStateMachine state, BaseFieldValues lineContent)
        {
            var retVal = (ParserStateMachine)state.Clone();

            var currentLoopProcessed = false;

            if (retVal.CurrentLoop != null)
            {
                List <BaseStdSegment> qualifiedSegments = retVal.CurrentLoop.IsQualified(lineContent, QulificationLevel.TopMost);

                if (qualifiedSegments.Count == 1) //check just the top most, so check Loop2000A to see if we have a matching def before moving to check Loop2100A and Loop2200A
                {
                    if (qualifiedSegments[0].IsLoopStarter)
                    {
                        retVal.CurrentLoop.ParentLoopCollection.Add();
                        retVal.CurrentLoop = retVal.CurrentLoop.ParentLoopCollection.LoopEntities.Last();
                    }

                    retVal.CurrentLoop.Add(qualifiedSegments[0].CreateBaseStdSegment(lineContent));
                    currentLoopProcessed = true;
                }
                else //want to try first level sub loop
                {
                    qualifiedSegments = retVal.CurrentLoop.IsQualified(lineContent, QulificationLevel.FirstChild);

                    if (qualifiedSegments.Count == 1)
                    {
                        if (qualifiedSegments[0].IsLoopStarter)
                        {
                            qualifiedSegments[0].OwningLoopCollection.Add();
                        }

                        retVal.CurrentLoop = qualifiedSegments[0].OwningLoopCollection.LoopEntities.Last();
                        retVal.CurrentLoop.Add(qualifiedSegments[0].CreateBaseStdSegment(lineContent));
                        currentLoopProcessed = true;
                    }

                    else if (!qualifiedSegments.Any()) //there were none
                    {
                        var currentLoopCollection = retVal.CurrentLoop.ParentLoopCollection;

                        //if the currentLoop and its subloops can't handle this, lets walk up the stack
                        while (currentLoopCollection.ParentLoopCollection != null)
                        {
                            currentLoopCollection = currentLoopCollection.ParentLoopCollection;

                            //the segment should never belong to the parent, because we ahve already dipped down to the next level...it CAN belong to a sibling, so check first child level
                            //for isntance, if we are in Loop2100B and get a segment for Loop2200B - both are children of Loop2000B, so we have to walk up 2100B->2000B then chekc all children (2100B and 2200B)
                            qualifiedSegments = currentLoopCollection.IsQualified(lineContent, QulificationLevel.FirstChild);

                            if (qualifiedSegments.Count == 1)
                            {
                                if (qualifiedSegments[0].IsLoopStarter) //should always be a starter
                                {
                                    qualifiedSegments[0].OwningLoopCollection.Add();
                                    retVal.CurrentLoop = qualifiedSegments[0].OwningLoopCollection.LoopEntities.Last();
                                }
                                else
                                {
                                    Console.WriteLine("new loop but not a starter segment?");
                                    retVal.Errors.Add(
                                        new ParserError(
                                            "Parser found a handler, but this handler is in a new Loop and this handler is not marked as a IsLoopStarter-this could be an issue with the coded definition",
                                            X12ErrorTypes.UnknownIntendedLoop, X12ErrorLevel.Loop, retVal.CurrentLoop,
                                            lineContent));
                                }

                                //retVal.CurrentLoop = currentLoopCollection.LoopEntities.Last();
                                retVal.CurrentLoop.Add(qualifiedSegments[0].CreateBaseStdSegment(lineContent));
                                currentLoopProcessed = true;
                            }
                            else
                            {
                                //this isn't unexpected...as we walk up the LoopCollection hierarchy, we may not find a match
                                //for instance, if we are in Loop2220D, we will walk up to Loop2200D, then to Loop2000D, before trying Loop2000E which could be our match
                                Console.Write("DEUBG - walking up the hierarchy did not find anything");
                            }
                        }
                    }
                    else //there were multiple and needs a tiebreaker
                    {
                        retVal.Errors.Add(
                            new ParserError("There were multiple handlers found, no way to determine correct state",
                                            X12ErrorTypes.MultipleDefintions, X12ErrorLevel.Loop, retVal.CurrentLoop, lineContent));
                    }
                }
            }

            //if the current loop we have saved off can not handle it, we should just interogate the whole doc again
            //this may not be efficient, we may want to walk back up our stack to make it mo' betta
            if (currentLoopProcessed)
            {
                return(retVal);
            }
            {
                var qualifiedSegments = new List <BaseStdSegment>();
                foreach (LoopCollectionBase loopCollection in tempBuildingDoc.TopLevelLoops)
                {
                    qualifiedSegments.AddRange(loopCollection.IsQualified(lineContent, QulificationLevel.FirstChild));
                }

                if (qualifiedSegments.Count == 1)
                {
                    if (qualifiedSegments[0].IsLoopStarter) //should always be
                    {
                        qualifiedSegments[0].OwningLoopCollection.Add();
                    }
                    else
                    {
                        retVal.Errors.Add(
                            new ParserError("Parser found a handler (at TopLevelLoop), but this handler is in a new Loop and this handler is not marked as a IsLoopStarter-this could be an issue with the coded definition",
                                            X12ErrorTypes.UnknownIntendedLoop, X12ErrorLevel.Loop, retVal.CurrentLoop, lineContent));
                    }

                    retVal.CurrentLoop = qualifiedSegments[0].OwningLoopCollection.LoopEntities.Last();
                    retVal.CurrentLoop.Add(qualifiedSegments[0].CreateBaseStdSegment(lineContent));
                }
                else if (qualifiedSegments.Count == 0)
                {
                    retVal.Errors.Add(
                        new ParserError("We found no handlers for this segment",
                                        X12ErrorTypes.NotDefined, X12ErrorLevel.Loop, retVal.CurrentLoop, lineContent));
                }
                else if (qualifiedSegments.Count > 1)
                {
                    retVal.Errors.Add(
                        new ParserError("There were multiple handlers found, no way to determine correct state",
                                        X12ErrorTypes.MultipleDefintions, X12ErrorLevel.Loop, retVal.CurrentLoop, lineContent));
                }
                else
                {
                    retVal.Errors.Add(
                        new ParserError("The parse failed to find a good handler and you should never see this message",
                                        X12ErrorTypes.Unknown, X12ErrorLevel.Unknown, retVal.CurrentLoop, lineContent));
                }
            }

            return(retVal);
        }
예제 #16
0
public Loop2000C(X12Doc owningDoc, LoopEntity prev, LoopCollection parent):base(owningDoc, prev, parent){
ServiceProviderLevel = new HlCollection(this, nameof(ServiceProviderLevel));
SegmentCollections.Add(ServiceProviderLevel);
 
}
예제 #17
0
public Loop2000B(X12Doc owningDoc, LoopEntity prev, LoopCollection parent):base(owningDoc, prev, parent){
InformationReceiverLevel = new HlCollection(this, nameof(InformationReceiverLevel));
SegmentCollections.Add(InformationReceiverLevel);
 
}
 public Loop2210ECollection(string loopName, string loopNameDescription, X12Doc owningDoc, LoopCollection parent, LoopCollection prev)
     : base(loopName, loopNameDescription, owningDoc, parent, prev)
 {
 }
예제 #19
0
public Loop2100B(X12Doc owningDoc, LoopEntity prev, LoopCollection parent):base(owningDoc, prev, parent){
InformationReceiverName = new Nm1Collection(this, nameof(InformationReceiverName));
SegmentCollections.Add(InformationReceiverName);
 
}
 public Loop2310ACollection(string loopName, string loopNameDescription, X12Doc owningDoc, LoopCollectionBase parent)
     : base(loopName, loopNameDescription, owningDoc, parent)
 {
 }
예제 #21
0
public Loop2100C(X12Doc owningDoc, LoopEntity prev, LoopCollection parent):base(owningDoc, prev, parent){
ProviderName = new Nm1Collection(this, nameof(ProviderName));
SegmentCollections.Add(ProviderName);
 
}
예제 #22
0
        /// <summary>
        /// Given a file, parse the x12 into the hard coded defintion of a specific format T
        /// </summary>
        /// <typeparam name="T">specific format type to parse into</typeparam>
        /// <param name="fullFilePath">location of the x12 file</param>
        /// <returns>A list of X12 documents, each of which has a unique group of ISA/GS/ST/BHT, if a file has multiple of any of these, they will be rendered as a seperate X12Document</returns>
        public static IEnumerable <X12Doc> ParseFile <T>(string fullFilePath) where T : X12Doc
        {
            X12Doc tempBuildingDoc = (T)Activator.CreateInstance(typeof(T), args: new object[] { true });

            var newHeaderSection  = false;
            var newTrailerSection = false;
            var parserState       = new ParserStateMachine();

            var retDocs = new List <X12Doc>();

            var sStream = new SegmentStream(File.OpenRead(fullFilePath), ref tempBuildingDoc);

            var lineContent = new BaseFieldValues(sStream.ReadNextLine(tempBuildingDoc.DocDelimiters));

            List <string> headerSplit  = HeaderSegments.Split(',').ToList();
            List <string> trailerSplit = TrailerSegments.Split(',').ToList();

            while (lineContent != null)
            {
                //is a head segment
                if (headerSplit.Contains(lineContent[0]))
                {
                    if (!newHeaderSection)
                    {
                        //copy the errors to date into the tempBuildingDoc so we can see if there are any errors
                        tempBuildingDoc.AddParsingErrors(parserState.Errors);
                        parserState.Errors.Clear();

                        //if we just had a trailer section, then we need to create a new tempBuildingDoc to start a new X12 document
                        if (newTrailerSection)
                        {
                            tempBuildingDoc = (T)Activator.CreateInstance(typeof(T), args: new object[] { true });
                        }

                        retDocs.Add(tempBuildingDoc);

                        newHeaderSection  = true;
                        newTrailerSection = false;
                    }

                    if (tempBuildingDoc.BeginHierarchicalTransaction.IsQualified(lineContent))
                    {
                        tempBuildingDoc.BeginHierarchicalTransaction.Populate(lineContent);
                    }
                    else if (tempBuildingDoc.TransactionSetHeader.IsQualified(lineContent))
                    {
                        tempBuildingDoc.TransactionSetHeader.Populate(lineContent);
                    }
                    else if (tempBuildingDoc.InterchagneControlHeader.IsQualified(lineContent))
                    {
                        tempBuildingDoc.InterchagneControlHeader.Populate(lineContent);
                    }
                    else if (tempBuildingDoc.FunctionGroupHeader.IsQualified(lineContent))
                    {
                        tempBuildingDoc.FunctionGroupHeader.Populate(lineContent);
                    }
                    else //should never happen, but defensive
                    {
                        parserState.Errors.Add(
                            new ParserError("Header segment found no IsQualified handlers and failed to parse",
                                            X12ErrorTypes.NotDefined, X12ErrorLevel.Segment, parserState.CurrentLoop, lineContent));
                    }
                }
                else if (trailerSplit.Contains(lineContent[0]))//is a trailer segment
                {
                    newTrailerSection = true;
                    newHeaderSection  = false;

                    if (tempBuildingDoc.TransactionSetTrailer.IsQualified(lineContent))
                    {
                        tempBuildingDoc.TransactionSetTrailer.Populate(lineContent);
                    }
                    else if (tempBuildingDoc.FunctionalGroupTrailer.IsQualified(lineContent))
                    {
                        tempBuildingDoc.FunctionalGroupTrailer.Populate(lineContent);
                    }
                    else if (tempBuildingDoc.InterchangeControlTrailer.IsQualified(lineContent))
                    {
                        tempBuildingDoc.InterchangeControlTrailer.Populate(lineContent);
                    }
                    else//should never happen, but defensive
                    {
                        parserState.Errors.Add(
                            new ParserError("Trailer segment found no IsQualified handlers and failed to parse",
                                            X12ErrorTypes.NotDefined, X12ErrorLevel.Segment, parserState.CurrentLoop, lineContent));
                    }
                }
                else //has to be in the doc def
                {
                    newHeaderSection  = false;
                    newTrailerSection = false;

                    parserState = tempBuildingDoc.ParseLineSegment(parserState, lineContent);
                }

                lineContent = sStream.ReadNextLine(tempBuildingDoc.DocDelimiters);
            }

            return(retDocs);
        }