Skip to content

Commit

Permalink
Merge pull request sbuss#12 from CloudCray/explicit_network_benefits
Browse files Browse the repository at this point in the history
Explicit "network" values for `EligibilityOrBenefitInformation`
  • Loading branch information
jdavisp3 authored Apr 3, 2021
2 parents 2d8a628 + fd2193c commit 7924ed4
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
TigerShark is an X12 EDI message parser that can be tailored to
a specific partner in the health care payment ecosystem.

Version 0.3.3
-------------

* Adds `in_plan_network_type` to `EligibilityOrBenefitInformation` for explicit values
* Adds `out_of_plan_network` for completion's sake
* Note that `in_plan_network`, `out_of_plan_network`, and `both_in_out_network` all return `False` when no value is set, although `None` would probably be more appropriate
* It may be more intuitive if `in_plan_network` and `out_of_plan_network` returned `True` when `both_in_out_network` is `True`, but the behavior is preserved for backwards compatibility

Version 0.3.2
-------------

Expand Down
50 changes: 50 additions & 0 deletions tests/271-example-in-out-network.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
ISA|00| |00| |ZZ|ZIRMED |ZZ|10864 |160405|1354|}|00501|000184077|1|P|^~
GS|HB|ZIRMED|10864|20160301|1354|184065|X|005010X279A1~
ST|271|0001|005010X279A1~
BHT|0022|11|94309|20160301|134403~
HL|1||20|1~
NM1|PR|2|MEDICA COM|||||PI|123456789~
HL|2|1|21|1~
NM1|1P|1|James|Barraret|J.|||XX|1234567894~
HL|3|2|22|0~
TRN|2|434343434|9ZIRMEDCOM|ELR ID~
TRN|1|422422424|9ZIRMEDCOM|ELI ID~
NM1|IL|1|SMITH|JOHN||||MI|1234567899~
REF|18|0404044~
REF|6P|030030001000120|NEVADA EXCHANGE~
N3|4040 VILLAGE AB~
N4|KANSAS CITY|MO|64108~
DMG|D8|19430813|M~
INS|Y|18|001|25~
DTP|346|D8|20160201~
DTP|472|D8|20160601~
DTP|356|D8|20141208~
EB|L|EMP|30|EP~
MSG|PCP SELECTION NOT REQUIRED~
EB|W~
LS|2120~
NM1|PR|2|Mala Compania~
N3|PO Box 983322~
N4|El Fixato|TX|68887~
LE|2120~
EB|1|EMP|30|EP|Open Access Elect Choice~
EB|G|IND|30|C1|||1500|||||Y~
EB|G|IND|30|C1||24|1500|||||Y~
EB|G|IND|30|C1||29|0|||||Y~
EB|C|IND|30||||118|||||Y~
EB|C|IND|30|||24|118|||||Y~
EB|C|IND|30|||29|0|||||Y~
EB|G|IND|30|C1|||0|||||N~
EB|G|IND|30|C1||24|0|||||N~
EB|G|IND|30|C1||29|0|||||N~
EB|C|IND|30||||0|||||N~
EB|C|IND|30|||24|0|||||N~
EB|C|IND|30|||29|0|||||N~
EB|B|EMP|98||||50|||||Y~
EB|B|EMP|98||||100|||||N~
EB|A|IND|50|||27||0.1||||W~
EB|A|IND|52|||||0.1
EB|I|EMP|1}33}48}50}86}98}UC|||||||||N~
SE|74|0001~
GE|1|184065~
IEA|1|000184077~
65 changes: 65 additions & 0 deletions tests/test_271_network_indicator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import unittest
import logging
import sys

from tigershark.facade import f271
from tigershark.parsers import M271_5010_X279_A1


class TestParsed271(unittest.TestCase):
def setUp(self):
m = M271_5010_X279_A1.parsed_271
with open('tests/271-example-in-out-network.txt') as f:
parsed = m.unmarshall(f.read().strip())
self.f = f271.F271_5010(parsed)

def test_number_of_facades(self):
self.assertEqual(len(self.f.facades), 1)

def test_no_network_info(self):
subscriber = self.f.facades[0].subscribers[0]
benefit = subscriber.eligibility_or_benefit_information[2]
cov_info = benefit.coverage_information

self.assertEqual(cov_info.in_plan_network_type, None)
self.assertEqual(cov_info.in_plan_network, False)
self.assertEqual(cov_info.both_in_out_network, False)
self.assertEqual(cov_info.out_of_plan_network, False)

def test_both_network_info(self):
subscriber = self.f.facades[0].subscribers[0]
benefit = subscriber.eligibility_or_benefit_information[17]
cov_info = benefit.coverage_information

self.assertEqual(cov_info.in_plan_network_type[0], "W")
self.assertEqual(cov_info.in_plan_network, False)
self.assertEqual(cov_info.both_in_out_network, True)
self.assertEqual(cov_info.out_of_plan_network, False)

def test_out_of_network_info(self):
subscriber = self.f.facades[0].subscribers[0]
benefit = subscriber.eligibility_or_benefit_information[16]
cov_info = benefit.coverage_information

self.assertEqual(cov_info.in_plan_network_type[0], "N")
self.assertEqual(cov_info.in_plan_network, False)
self.assertEqual(cov_info.both_in_out_network, False)
self.assertEqual(cov_info.out_of_plan_network, True)

def test_in_network_info(self):
subscriber = self.f.facades[0].subscribers[0]
benefit = subscriber.eligibility_or_benefit_information[15]
cov_info = benefit.coverage_information

self.assertEqual(cov_info.in_plan_network_type[0], "Y")
self.assertEqual(cov_info.in_plan_network, True)
self.assertEqual(cov_info.both_in_out_network, False)
self.assertEqual(cov_info.out_of_plan_network, False)


if __name__ == "__main__":
logging.basicConfig(
stream=sys.stderr,
level=logging.INFO,
)
unittest.main()
4 changes: 2 additions & 2 deletions tigershark/X12/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ def parse( self, segments ):
"""If this segment matches the next segment token in the input,
create the X12Segment object.
:param segments: list of SegmentTokens for the current message.
:returns: yields a single parsed Segment or raises StopIteration
:returns: yields a single parsed Segment or ends iteration (returns)
"""
if isinstance(self.repeat, int):
length_loop = range(self.repeat)
Expand Down Expand Up @@ -745,7 +745,7 @@ def parse( self, segments ):
loops until a segment no longer matches.
:param segments: list of SegmentToken instances
:returns: Yields the next X12.message.X12Loop structure or raises StopIteration
:returns: Yields the next X12.message.X12Loop structure or ends interation (returns)
"""
# Confirm match between this loop and a segment of the structure
i = 0
Expand Down
2 changes: 1 addition & 1 deletion tigershark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
TigerShark - An X12 EDI message parser.
"""
__all__ = ['X12VersionTuple']
__version__ = "0.3.2"
__version__ = "0.3.3"
__authors__ = [
"Steven Buss <[email protected]>",
"Steven Lott <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion tigershark/facade/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def compositeList(self, *names):
sep = self.segment.message.getCompositeSeparator()
result = []
pos = 1
while self.segment.getByPos(pos) is not "":
while self.segment.getByPos(pos) != "":
composite = self.segment.getByPos(pos)
subElts = composite.split(sep)
if subElts[0] in names:
Expand Down
6 changes: 6 additions & 0 deletions tigershark/facade/f271.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ class EligibilityOrBenefitInformation(X12SegmentBridge):
authorization_or_certification = ElementAccess("EB", 11,
x12type=boolean("Y"))
in_plan_network = ElementAccess("EB", 12, x12type=boolean("Y"))
out_of_plan_network = ElementAccess("EB", 12, x12type=boolean("N"))
both_in_out_network = ElementAccess("EB", 12, x12type=boolean("W"))
in_plan_network_type = ElementAccess("EB", 12, x12type=enum({
"Y": "In Plan Network",
"N": "Out of Plan Network",
"W": "Both In and Out of Plan Network",
}))
ada_code = CompositeAccess("EB", "AD", 13)
cpt_code = CompositeAccess("EB", "CJ", 13)
hcpcs_code = CompositeAccess("EB", "HC", 13)
Expand Down

0 comments on commit 7924ed4

Please sign in to comment.