Skip to content

Commit

Permalink
Document reading now verifies GS01, GS08 are in agreement. In addtion…
Browse files Browse the repository at this point in the history
…, the transaction sets are compatible with the functional group. The transaction sets now populate implementation scoped loops (Loop 2010AA in the 837 professional transaction set (Transaction837_Q1) and not just the generic Loop 2010).
  • Loading branch information
MartinJSoles committed Jul 1, 2021
1 parent 17d9ade commit 29ad3d6
Show file tree
Hide file tree
Showing 22 changed files with 63,315 additions and 61,702 deletions.
24 changes: 24 additions & 0 deletions Madjic.Edi.Dom.Tests/Madjic.Edi.Dom.Tests.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,33 @@
</ItemGroup>

<ItemGroup>
<None Update="samples\Test270.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="samples\test271.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="samples\Test277.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="samples\Test278.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="samples\Test820.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="samples\Test834.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="samples\Test835.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="samples\Test837P.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="samples\Test999.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="samples\TestMultipleEnvelopes.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
69 changes: 64 additions & 5 deletions Madjic.Edi.Dom.Tests/TestBasicFileParsing.vb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,50 @@ Imports Microsoft.VisualStudio.TestTools.UnitTesting
<TestClass>
Public Class TestBasicFileParsing

Private Shared ReadOnly AllFiles() As String = {
".\samples\TestMultipleFunctionalGroups.txt",
".\samples\TestMultipleEnvelopes.txt",
".\samples\Test270.txt",
".\samples\Test271.txt",
".\samples\Test277.txt",
".\samples\Test278.txt",
".\samples\Test820.txt",
".\samples\Test834.txt",
".\samples\Test835.txt",
".\samples\Test837P.txt",
".\samples\Test999.txt"}

<TestMethod()> Async Function TestAllFileImplementations() As Task
Dim Doc As Document
Dim ExpectedTypes() As Type = {
GetType(Transactions.Transaction270.Transaction270_B1.TransactionSet),
GetType(Transactions.Transaction271.Transaction271_B1.TransactionSet),
GetType(Transactions.Transaction277.Transaction277_A1.TransactionSet),
GetType(Transactions.Transaction278.Transaction278_A3.TransactionSet),
GetType(Transactions.Transaction820.Transaction820_A1.TransactionSet),
GetType(Transactions.Transaction834.Transaction834_A1.TransactionSet),
GetType(Transactions.Transaction835.Transaction835_W1.TransactionSet),
GetType(Transactions.Transaction837.Transaction837_Q1.TransactionSet),
GetType(Transactions.Transaction999.Transaction999.TransactionSet)}

For FileId = 2 To 10
Debug.Write("<-- File --> ")
Debug.WriteLine(AllFiles(FileId))

Using stream As New IO.FileStream(AllFiles(FileId), IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Doc = Await Document.FromStreamAsync(stream)
End Using

Assert.IsTrue(Doc.Envelopes.Count > 0, $"Parsing file ""{AllFiles(FileId)}"" did not produce any envelope.")
Assert.IsTrue(Doc.Envelopes(0).FunctionalGroups.Count > 0, $"Parsing file ""{AllFiles(FileId)}"" did not produce any functional group.")
Assert.IsTrue(Doc.Envelopes(0).FunctionalGroups(0).Transactions.Count > 0, $"Parsing file ""{AllFiles(FileId)}"" did not produce any transaction set.")
Assert.IsInstanceOfType(Doc.Envelopes(0).FunctionalGroups(0).Transactions(0), ExpectedTypes(FileId - 2), $"Parsing file ""{AllFiles(FileId)}"" did not produce correct transaction type.")
Next
End Function
<TestMethod()> Async Function CanOpenTestFile() As Task
Dim Doc As Madjic.Edi.Dom.Document

Using stream As New IO.FileStream(".\samples\test271.txt", IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Using stream As New IO.FileStream(AllFiles(3), IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Doc = Await Madjic.Edi.Dom.Document.FromStreamAsync(stream)
End Using

Expand All @@ -17,7 +57,7 @@ Public Class TestBasicFileParsing
<TestMethod()> Async Function TestMultipleFunctionalGroups() As Task
Dim Doc As Document

Using stream As New IO.FileStream(".\samples\TestMultipleFunctionalGroups.txt", IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Using stream As New IO.FileStream(AllFiles(0), IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Doc = Await Document.FromStreamAsync(stream)
End Using

Expand All @@ -27,7 +67,7 @@ Public Class TestBasicFileParsing
<TestMethod()> Async Function TestMultipleEnvelopes() As Task
Dim Doc As Document

Using stream As New IO.FileStream(".\samples\TestMultipleEnvelopes.txt", IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Using stream As New IO.FileStream(AllFiles(1), IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Doc = Await Document.FromStreamAsync(stream)
End Using

Expand All @@ -41,11 +81,11 @@ Public Class TestBasicFileParsing
Dim Output As String
Dim Doc As Document

Using stream As New IO.FileStream(".\samples\test271.txt", IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Using stream As New IO.FileStream(AllFiles(3), IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Source = ReadStreamToString(stream)
End Using

Using stream As New IO.FileStream(".\samples\test271.txt", IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Using stream As New IO.FileStream(AllFiles(3), IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Doc = Await Document.FromStreamAsync(stream)
End Using

Expand All @@ -61,6 +101,25 @@ Public Class TestBasicFileParsing
Assert.AreEqual(Source, Output, False)
End Function

<TestMethod> Async Function ReadImplementation271() As Task
Dim Doc As Document

Using stream As New IO.FileStream(AllFiles(3), IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Doc = Await Document.FromStreamAsync(stream)
End Using

Dim RawTS = Doc.Envelopes(0).FunctionalGroups(0).Transactions(0)
Dim Imp = TryCast(RawTS, Transactions.Transaction271.Transaction271_B1.TransactionSet)

Assert.IsNotNull(Imp)

Assert.IsNotNull(Imp.Loop2000A)
Assert.IsTrue(Imp.Loop2000A.Count > 0)

Assert.IsNotNull(Imp.Loop2000B)
Assert.IsTrue(Imp.Loop2000B.Count > 0)
End Function

''' <summary>
''' Strips non essential characters from a stream and returns the results as a simple string.
''' </summary>
Expand Down
20 changes: 20 additions & 0 deletions Madjic.Edi.Dom.Tests/samples/Test270.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ISA*00* *00* *ZZ*123456789 *ZZ*12345678 *201231*0050*^*00501*000000001*1*P*:~
GS*HS*SUBMITTERID*CMS*20190308*073411*222222222*X*005010X279A1~
ST*270*333333333*005010X279A1~
BHT*0022*13*TRANSA*20190308*073411~
HL*1**20*1~
NM1*PR*2*CMS*****PI*CMS~
HL*2*1*21*1~
NM1*1P*2*IRNAME*****XX*1234567893~
HL*3*2*22*0~
TRN*1*TRACKNUM*ABCDEFGHIJ~
NM1*IL*1*LNAME*FNAME****MI*MEMBERID~
DMG*D8*19200401~
DTP*291*RD8*20180101-20190204~
EQ*1^10^14^15^30^35^42^45^47^48^49^AG^67^88^AD^AE^AF^A5^A7^BF^BG^MH^RN^UC~
EQ**HC:G0106~
EQ**HC:90670~
EQ**HC:G0117~
SE*16*333333333~
GE*1*1421~
IEA*1*000006768~
41 changes: 41 additions & 0 deletions Madjic.Edi.Dom.Tests/samples/Test277.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
ISA*00* *00* *ZZ*123456789 *ZZ*12345678 *201231*0050*^*00501*000000001*1*P*:~
GS*HN*123456789*12345678*20211231*0050*1*X*005010X212~
ST*277*0001*005010X212~
BHT*0010*08*277X212*20050916*0810*DG~
HL*1**20*1~
NM1*PR*2*ABC INSURANCE*****PI*12345~
HL*2*1*21*1~
NM1*41*2*XYZ SERVICE*****46*X67E~
HL*3*2*19*1~
NM1*1P*2*HOME HOSPITAL*****XX*1666666661~
HL*4*3*22*0~
NM1*IL*1*SMITH*FRED****MI*123456789A~
TRN*2*ABCXYZ1~
STC*P3:317*20050913**8513.88~
REF*1K*05347006051~
REF*BLT*111~
REF*EJ*SM123456~
DTP*472*RD8*20050831-20050906~
HL*5*3*22*0~
NM1*IL*1*JONES*MARY****MI*234567890A~
TRN*2*ABCXYZ2~
STC*F0:3*20050915**7599*7599~
REF*1K*0529675341~
REF*BLT*111~
REF*EJ*JO234567~
DTP*472*RD8*20050731-20050809~
HL*6*2*19*1~
NM1*1P*2*HOME HOSPITAL PHYSICIANS*****XX*1666666666~
HL*7*6*22*1~
NM1*IL*1*MANN*JOHN****MI*345678901~
HL*8*7*23~
NM1*QC*1*MANN*JOSEPH~
TRN*2*ABCXYC3~
STC*F2:88:QC*20050612**150*0~
REF*1K*051681010827~
REF*EJ*MA345678~
SVC*HC:99203*150*0****1~
STC*F2:88:QC*20050612~
DTP*472*D8*20050501~
SE*38*0001~GE*1*1~
IEA*1*000000632~
34 changes: 34 additions & 0 deletions Madjic.Edi.Dom.Tests/samples/Test278.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ISA*00* *00* *ZZ*123456789 *ZZ*12345678 *201231*0050*^*00501*000000001*1*P*:~
GS*HI*TESTHIH*DBRRC*20190109*153413*165455*X*005010X217~
ST*278*0032*005010X217~
BHT*0007*13*0001*20100101*000000~
HL*1**20*1~
NM1*X3*2*BLUE CROSS BLUE SHIELD NC*****46*560894904~
HL*2*1*21*1~
NM1*1P*1*HELBY*MARCUS****XX*1111122222~
N3*200 GETWELL AVENUE~
N4*JEFFERSON*NC*28640~
PER*IC**TE*9194567890~
HL*3*2*22*1~
NM1*IL*1*RUBBLE*BARNEY****MI*YPPW1234567890~
DMG*D8*19460401*M~
HL*4*3*23*1~
NM1*QC*1*RUBBLE*BARNEY~
DMG*D8*19460401*M~
HL*5*4*EV*1~
UM*AR*I*4*21:B***2*3*M~
DTP*435*D8*20100101~
DTP*096*D8*20100101~
HI*BF:41090:D8:20050125~
HSD*DY*4~
CL1*3*1~
NM1*FA*2*FLINTSTONE UNIVERSITY HOSPITAL*****XX*1001234567~
N3*THELMA LANE~
N4*DURHAM*NC*27705~
HL*6*5*SS*0~
TRN*1*TS32-2*90004N7891~
DTP*472*RD8*20100101-20100101~
SV2**HC:33510~
NM1*1T*1*HELBY*MARCUS****XX*1111122222~
SE*31*0032~GE*1*1235~
IEA*1*000001235~
41 changes: 41 additions & 0 deletions Madjic.Edi.Dom.Tests/samples/Test820.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
ISA*00* *00* *ZZ*123456789 *ZZ*12345678 *201231*0050*^*00501*000000001*1*P*:~
GS*RA*123456789*12345678*20211231*0050*1*X*005010X218~
ST*820*0001*005010X218~
BPR*I*220*C*ACH*CCP*******01*199999999*DA*98765*20140604~
TRN*3*78905~
REF*38*123456~
REF*TV*12565496~
N1*PE*BATA INSURANCE CO.*FI*012222222~
N1*RM*GOVERNMENT AGENCY*58*123ABC~
ENT*1~
NM1*IL*1*DOE*JOHN****C1*777222~
REF*POL*1232456~
REF*AZ*12565496~
REF*0F*555666~
RMR*ZZ*APTC**35~
DTM*582****RD8*20120501-20140531~
ENT*2~
NM1*IL*1*FIRSTONE*EMILY****C1*777333~
REF*POL*1232457~
REF*AZ*12565497~
REF*0F*555777~
RMR*ZZ*APTC**35~
DTM*582****RD8*20120501-20140531~
ENT*3~
NM1*IL*1*MIDDLEONE*JULIE****C1*777444~
REF*POL*1232458~
REF*AZ*12565498~
REF*0F*544477~
RMR*ZZ*APTC**-350~
DTM*582****RD8*20140101-20140331~
ENT*4~
NM1*IL*1*NEWONE*KELLY****C1*777111~
REF*POL*1232459~
REF*AZ*12565499~
RMR*ZZ*APTC**450~
DTM*582****RD8*20140501-20140531~
RMR*ZZ*CSR**50~
DTM*582****RD8*20140501-20140531~
SE*37*0001~
GE*1*1~
IEA*1*000000001~
Loading

0 comments on commit 29ad3d6

Please sign in to comment.