@@ -50,6 +50,7 @@ public class X12Reader {
5050 private static final String _X223_ANSI_VERSION = "005010X223A2" ;
5151 private static final String _X231_ANSI_VERSION = "005010X231A1" ;
5252 private static final String _X214_ANSI_VERSION = "005010X214" ;
53+ private static final String _X270_271_092_ANSI_VERSION = "004010X092A1" ;
5354 private static final Map <FileType , String > _TYPES = new HashMap <>();
5455
5556 private List <String > _errors = new ArrayList <>();
@@ -73,7 +74,9 @@ public enum FileType {
7374 ANSI837_5010_X222 ("mapping/837.5010.X222.A1.xml" ),
7475 ANSI837_5010_X223 ("mapping/837Q3.I.5010.X223.A1.xml" ),
7576 ANSI837_5010_X231 ("mapping/999.5010.xml" ),
76- ANSI837_5010_X214 ("mapping/277.5010.X214.xml" );
77+ ANSI837_5010_X214 ("mapping/277.5010.X214.xml" ),
78+ ANSI270_4010_X092 ("mapping/270.4010.X092.A1.xml" ),
79+ ANSI271_4010_X092 ("mapping/271.4010.X092.A1.xml" );
7780
7881 private String _mapping ;
7982
@@ -115,6 +118,8 @@ public synchronized TransactionDefinition getDefinition() {
115118 _TYPES .put (FileType .ANSI837_5010_X223 , _X223_ANSI_VERSION );
116119 _TYPES .put (FileType .ANSI837_5010_X214 , _X214_ANSI_VERSION );
117120 _TYPES .put (FileType .ANSI837_5010_X231 , _X231_ANSI_VERSION );
121+ _TYPES .put (FileType .ANSI270_4010_X092 , _X270_271_092_ANSI_VERSION );
122+ _TYPES .put (FileType .ANSI271_4010_X092 , _X270_271_092_ANSI_VERSION );
118123 }
119124
120125 /**
@@ -404,7 +409,7 @@ private boolean checkVersionsAreConsistent(Separators separators, Reader reader)
404409 version = lineString .substring (versionStartPos + 1 );
405410 }
406411 reader .reset ();
407-
412+
408413 boolean result = _TYPES .get (_type ).equals (version );
409414
410415 if (!result )
@@ -709,7 +714,7 @@ private LoopConfig getMatchedLoop(String[] tokens, String previousLoopID) {
709714
710715 if (matchedLoops .size () > 1 ) {
711716 // starting a new loop but we aren't quite sure which one yet. Remove loops where the segment is known to be the last segment of that loop - clearly we aren't in a new loop then
712- matchedLoops = matchedLoops .stream ().filter (lc -> !(lc .getLastSegmentXid ().getXid ().equals (tokens [0 ]) && codesValidatedForLoopId (tokens , lc .getLastSegmentXid ()))).collect (
717+ matchedLoops = matchedLoops .stream ().filter (lc -> lc . getLastSegmentXid () == null || !(lc .getLastSegmentXid ().getXid ().equals (tokens [0 ]) && codesValidatedForLoopId (tokens , lc .getLastSegmentXid ()))).collect (
713718 Collectors .toList ());
714719 result = matchedLoops .isEmpty () ? null : (matchedLoops .size () == 1 ? matchedLoops .get (0 ) : getFinalizedMatch (previousLoopID , matchedLoops ));
715720 }
@@ -800,10 +805,9 @@ else if (tokens == null)
800805 _errors .add ("Unable to split elements to validate segment ID!" );
801806 i ++;
802807 }
803-
804- if (!lineMatchesFormat )
808+
809+ if (!lineMatchesFormat )
805810 _errors .add ("Unable to find a matching segment format in loop " + loopId );
806-
807811 lineMatchesFormat = false ;
808812 }
809813
0 commit comments