From aeaeec642ed1fcb05b7500baec176eacf2e8d496 Mon Sep 17 00:00:00 2001 From: Steven Buss Date: Wed, 23 Jan 2013 11:30:25 -0800 Subject: [PATCH] Add missing 835 footer and provider adjustment segments. --- tests/835-example.txt | 1 + tests/test_835.py | 8 ++++++++ tigershark/facade/f835.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/tests/835-example.txt b/tests/835-example.txt index 9a4deea..1657408 100644 --- a/tests/835-example.txt +++ b/tests/835-example.txt @@ -45,6 +45,7 @@ ISA|00| |00| |ZZ|MYCLEARINGHOUSE|ZZ|RECVCODE |120323|193 ~AMT|B6|12145.65 ~LQ|HE|N220 ~LQ|HE|M68 +~PLB|743238060|20121231|WO^12104411559120820 001GAL295513|-361.19 ~SE|43|0001 ~GE|1|15555 ~IEA|1|000015442 diff --git a/tests/test_835.py b/tests/test_835.py index 40ed68e..2e88194 100644 --- a/tests/test_835.py +++ b/tests/test_835.py @@ -253,6 +253,14 @@ def test_claims(self): "dispute.")) self.assertEqual(l.notes[1], "M68") + def test_footer(self): + footer = self.f.facades[0].footer + self.assertEqual(len(footer.provider_adjustments), 1) + adj = footer.provider_adjustments[0] + self.assertEqual(adj.provider_id, '743238060') + self.assertEqual(adj.date, datetime.date(2012,12,31)) + self.assertEqual(adj.amount_1, Decimal('-361.19')) + if __name__ == "__main__": logging.basicConfig( diff --git a/tigershark/facade/f835.py b/tigershark/facade/f835.py index 6dee597..b6c5e0f 100644 --- a/tigershark/facade/f835.py +++ b/tigershark/facade/f835.py @@ -1,9 +1,12 @@ from decimal import Decimal from tigershark.facade import X12LoopBridge +from tigershark.facade import X12SegmentBridge from tigershark.facade import ElementAccess from tigershark.facade import ElementSequenceAccess from tigershark.facade import CompositeAccess +from tigershark.facade import SegmentSequenceAccess +from tigershark.facade import SegmentConversion from tigershark.facade import D8 from tigershark.facade import Money from tigershark.facade import Facade @@ -125,6 +128,30 @@ def __init__(self, aLoop, *args, **kwargs): self.production_date = Header._ProductionDate(aLoop, *args, **kwargs) +class ProviderAdjustments(X12SegmentBridge): + provider_id = ElementAccess("PLB", 1) + date = ElementAccess("PLB", 2, x12type=D8) + reason_1 = ElementAccess("PLB", 3) + amount_1 = ElementAccess("PLB", 4, x12type=Money) + reason_2 = ElementAccess("PLB", 5) + amount_2 = ElementAccess("PLB", 6, x12type=Money) + reason_3 = ElementAccess("PLB", 7) + amount_3 = ElementAccess("PLB", 8, x12type=Money) + reason_4 = ElementAccess("PLB", 9) + amount_4 = ElementAccess("PLB", 10, x12type=Money) + reason_5 = ElementAccess("PLB", 11) + amount_5 = ElementAccess("PLB", 12, x12type=Money) + reason_6 = ElementAccess("PLB", 13) + amount_6 = ElementAccess("PLB", 14, x12type=Money) + + +class Footer(Facade, X12LoopBridge): + loopName = "FOOTER" + + provider_adjustments = SegmentSequenceAccess("PLB", + x12type=SegmentConversion(ProviderAdjustments)) + + class Payer(X12LoopBridge): """Payer information from the 1000A loop.""" loopName = "1000A" @@ -434,3 +461,4 @@ def __init__(self, anX12Message): self.claims_overview = first(self.loops(ClaimsOverview, anX12Message)) self.claims = self.loops(Claim, anX12Message) + self.footer = first(self.loops(Footer, anX12Message))