PageRenderTime 75ms CodeModel.GetById 37ms RepoModel.GetById 0ms app.codeStats 0ms

/test/test_hipaa_837.rb

https://github.com/PetResQ911/hippo
Ruby | 396 lines | 276 code | 55 blank | 65 comment | 0 complexity | b3875781975f3ce13ccdc817d0adf71d MD5 | raw file
  1. #!/usr/bin/env ruby
  2. require_relative 'test_helper'
  3. class TestHIPAA837 < MiniTest::Unit::TestCase
  4. def test_commercial_health_insurance
  5. =begin
  6. This example file is based on the Commercial Health Insurance example (3.1.1) published in the 5010X222A1 TR3.
  7. Patient is a different person than the Subscriber. Payer is commercial health insurance company.
  8. SUBSCRIBER: Jane Smith
  9. PATIENT ADDRESS:236 N. Main St., Miami, Fl, 33413
  10. TELEPHONE NUMBER: 305-555-1111
  11. SEX: F
  12. DOB: 05/01/43
  13. EMPLOYER: ACME Inc.
  14. GROUP #: 2222-SJ
  15. KEY INSURANCE COMPANY ID #: JS00111223333
  16. PATIENT: Ted Smith
  17. PATIENT ADDRESS:236 N. Main St., Miami, Fl, 33413
  18. TELEPHONE NUMBER: 305-555-1111
  19. SEX: M
  20. DOB: 05/01/73
  21. KEY INSURANCE COMPANY ID #: JS01111223333
  22. DESTINATION PAYER: Key Insurance Company
  23. PAYER ADDRESS: 3333 Ocean St. South Miami, FL 33000
  24. PAYER ID: 999996666
  25. SUBMITTER: Premier Billing Service
  26. EDI#: TGJ23
  27. CONTACT PERSON AND PHONE NUMBER: JERRY, 305-555-2222 ext. 231
  28. RECEIVER: Key Insurance Company
  29. EDI #:66783JJT
  30. BILLING PROVIDER: Dr. Ben Kildare,
  31. ADDRESS: 234 Seaway St, Miami, FL, 33111
  32. NPI: 9876543210
  33. TIN: 587654321
  34. KEY INSURANCE COMPANY PROVIDER ID #: KA6663
  35. Taxonomy Code: 203BF0100Y
  36. PAY-TO PROVIDER: Kildare Associates,
  37. PROVIDER ADDRESS: 2345 Ocean Blvd, Miami, Fl 33111
  38. RENDERING PROVIDER: Dr. Ben Kildare
  39. PATIENT ACCOUNT NUMBER: 2-646-3774
  40. CASE: Patient has sore throat.
  41. INITIAL VISIT: DOS=10/03/06. POS=Office
  42. SERVICES: Office visit, intermediate service, established patient, throat culture.
  43. CHARGES: Office first visit = $40.00, Lab test for strep = $15.00
  44. FOLLOW-UP VISIT: DOS=10/10/06 POS=Office
  45. Antibiotics didnt work (pain continues).
  46. SERVICES: Office visit, intermediate service, established patient, mono screening.
  47. CHARGES: Follow-up visit = $35.00, lab test for mono = $10.00.
  48. TOTAL CHARGES: $100.00.
  49. ELECTRONIC ROUTE: Billing provider (sender), to VAN to Key Insurance Company (receiver).
  50. VAN claim identification number = 17312345600006351.
  51. =end
  52. ts = Hippo::TransactionSets::HIPAA_837::Base.new
  53. ts.ST do |st|
  54. st.TransactionSetControlNumber = '0021'
  55. st.ImplementationConventionReference = '005010X222A1'
  56. end
  57. ts.BHT do |bht|
  58. bht.TransactionSetPurposeCode = '00'
  59. bht.ReferenceIdentification = '244579'
  60. bht.Date = '20061015'
  61. bht.Time = '1023'
  62. bht.TransactionTypeCode = 'CH'
  63. end
  64. ts.L1000A do |l1000a|
  65. l1000a.NM1 do |nm1|
  66. nm1.EntityTypeQualifier = '2'
  67. nm1.NameLastOrOrganizationName = 'PREMIER BILLING SERVICE'
  68. nm1.IdentificationCode = 'TGJ23'
  69. end
  70. l1000a.PER do |per|
  71. per.Name = 'JERRY'
  72. per.CommunicationNumberQualifier_01 = 'TE'
  73. per.CommunicationNumber_01 = '3055552222'
  74. per.CommunicationNumberQualifier_02 = 'EX'
  75. per.CommunicationNumber_02 = '231'
  76. end
  77. end
  78. ts.L1000B do |l1000b|
  79. l1000b.NM1 do |nm1|
  80. nm1.EntityTypeQualifier = '2'
  81. nm1.NameLastOrOrganizationName = 'KEY INSURANCE COMPANY'
  82. nm1.IdentificationCode = '66783JJT'
  83. end
  84. end
  85. ts.L2000A do |l2000a|
  86. l2000a.HL do |hl|
  87. hl.HL01 = hl.class.increment_sequence_number
  88. hl.HL04 = 1
  89. end
  90. l2000a.PRV do |prv|
  91. prv.ReferenceIdentification = '203BF0100Y'
  92. end
  93. l2000a.L2010AA do |l2010aa|
  94. l2010aa.NM1 do |nm1|
  95. nm1.EntityTypeQualifier = '2'
  96. nm1.NameLastOrOrganizationName = 'BEN KILDARE SERVICE'
  97. nm1.IdentificationCodeQualifier = 'XX'
  98. nm1.IdentificationCode = '9876543210'
  99. end
  100. l2010aa.N3 do |n3|
  101. n3.AddressInformation = '234 SEAWAY ST'
  102. end
  103. l2010aa.N4 do |n4|
  104. n4.CityName = 'MIAMI'
  105. n4.StateOrProvinceCode = 'FL'
  106. n4.PostalCode = '33111'
  107. end
  108. l2010aa.REF do |ref|
  109. ref.ReferenceIdentificationQualifier = 'EI'
  110. ref.ReferenceIdentification = '587654321'
  111. end
  112. end
  113. l2000a.L2010AB do |l2010ab|
  114. l2010ab.NM1 do |nm1|
  115. nm1.EntityTypeQualifier = '2'
  116. end
  117. l2010ab.N3 do |n3|
  118. n3.AddressInformation = '2345 OCEAN BLVD'
  119. end
  120. l2010ab.N4 do |n4|
  121. n4.CityName = 'MIAMI'
  122. n4.StateOrProvinceCode = 'FL'
  123. n4.PostalCode = '33111'
  124. end
  125. end
  126. ts.L2000B do |l2000b|
  127. l2000b.HL do |hl|
  128. hl.HL01 = hl.class.increment_sequence_number
  129. hl.HL02 = l2000a.HL.HL01
  130. hl.HL04 = 1
  131. end
  132. l2000b.SBR do |sbr|
  133. sbr.PayerResponsibilitySequenceNumberCode = 'P'
  134. sbr.ReferenceIdentification = '2222-SJ'
  135. sbr.ClaimFilingIndicatorCode = 'CI'
  136. end
  137. l2000b.L2010BA do |l2010ba|
  138. l2010ba.NM1 do |nm1|
  139. nm1.EntityTypeQualifier = '1'
  140. nm1.NameLastOrOrganizationName = 'SMITH'
  141. nm1.NameFirst = 'JANE'
  142. nm1.IdentificationCodeQualifier = 'MI'
  143. nm1.IdentificationCode = 'JS00111223333'
  144. end
  145. l2010ba.DMG do |dmg|
  146. dmg.DateTimePeriod = '19430501'
  147. dmg.GenderCode = 'F'
  148. end
  149. end
  150. l2000b.L2010BB do |l2010bb|
  151. l2010bb.NM1 do |nm1|
  152. nm1.EntityTypeQualifier = '2'
  153. nm1.NameLastOrOrganizationName = 'KEY INSURANCE COMPANY'
  154. nm1.IdentificationCodeQualifier = 'PI'
  155. nm1.IdentificationCode = '999996666'
  156. end
  157. # second ref segment in L2010BB
  158. l2010bb.REF_02 do |ref|
  159. ref.ReferenceIdentificationQualifier = 'G2'
  160. ref.ReferenceIdentification = 'KA6663'
  161. end
  162. end
  163. ts.L2000C do |l2000c|
  164. l2000c.HL do |hl|
  165. hl.HL01 = hl.class.increment_sequence_number
  166. hl.HL02 = l2000b.HL.HL01
  167. hl.HL04 = 0
  168. end
  169. l2000c.PAT do |pat|
  170. pat.IndividualRelationshipCode = '19'
  171. end
  172. l2000c.L2010CA do |l2010ca|
  173. l2010ca.NM1 do |nm1|
  174. nm1.NameLastOrOrganizationName = 'SMITH'
  175. nm1.NameFirst = 'TED'
  176. end
  177. l2010ca.N3 do |n3|
  178. n3.AddressInformation = '236 N MAIN ST'
  179. end
  180. l2010ca.N4 do |n4|
  181. n4.CityName = 'MIAMI'
  182. n4.StateOrProvinceCode = 'FL'
  183. n4.PostalCode = '33413'
  184. end
  185. l2010ca.DMG do |dmg|
  186. dmg.DateTimePeriod = '19730501'
  187. dmg.GenderCode = 'M'
  188. end
  189. end
  190. l2000c.L2300 do |l2300|
  191. l2300.CLM do |clm|
  192. clm.ClaimSubmitterSIdentifier = '26463774'
  193. clm.MonetaryAmount = '100'
  194. clm.FacilityCodeValue = '11'
  195. clm.FacilityCodeQualifier = 'B'
  196. clm.ClaimFrequencyTypeCode = '1'
  197. clm.YesNoConditionOrResponseCode = 'Y'
  198. clm.ProviderAcceptAssignmentCode = 'A'
  199. clm.YesNoConditionOrResponseCode_02 = 'Y'
  200. clm.ReleaseOfInformationCode = 'I'
  201. end
  202. l2300.REF_11 do |ref| #('Claim Identifier For Transmission Intermediaries') do |ref|
  203. ref.ReferenceIdentification = '17312345600006351'
  204. end
  205. l2300.HI do |hi|
  206. hi.CodeListQualifierCode_01 = 'BK'
  207. hi.IndustryCode_01 = '0340'
  208. hi.CodeListQualifierCode_02 = 'BF'
  209. hi.IndustryCode_03 = 'V7389'
  210. end
  211. l2300.L2400.build do |l2400|
  212. l2400.LX.LX01 = Hippo::Segments::LX.increment_sequence_number
  213. l2400.SV1 do |sv1|
  214. sv1.ProductServiceIdQualifier = 'HC'
  215. sv1.ProductServiceId = '99213'
  216. sv1.MonetaryAmount = '40'
  217. sv1.UnitOrBasisForMeasurementCode = 'UN'
  218. sv1.Quantity = '1'
  219. sv1.DiagnosisCodePointer = 1
  220. end
  221. l2400.DTP('Date - Service Date') do |dtp|
  222. dtp.DateTimePeriodFormatQualifier = 'D8'
  223. dtp.DateTimePeriod = '20061003'
  224. end
  225. end
  226. l2300.L2400.build do |l2400|
  227. l2400.LX.LX01 = Hippo::Segments::LX.increment_sequence_number
  228. l2400.SV1 do |sv1|
  229. sv1.ProductServiceIdQualifier = 'HC'
  230. sv1.ProductServiceId = '87070'
  231. sv1.MonetaryAmount = '15'
  232. sv1.UnitOrBasisForMeasurementCode = 'UN'
  233. sv1.Quantity = '1'
  234. sv1.DiagnosisCodePointer = 1
  235. end
  236. l2400.DTP('Date - Service Date') do |dtp|
  237. dtp.DateTimePeriodFormatQualifier = 'D8'
  238. dtp.DateTimePeriod = '20061003'
  239. end
  240. end
  241. l2300.L2400.build do |l2400|
  242. l2400.LX.LX01 = Hippo::Segments::LX.increment_sequence_number
  243. l2400.SV1 do |sv1|
  244. sv1.ProductServiceIdQualifier = 'HC'
  245. sv1.ProductServiceId = '99214'
  246. sv1.MonetaryAmount = '35'
  247. sv1.UnitOrBasisForMeasurementCode = 'UN'
  248. sv1.Quantity = '1'
  249. sv1.DiagnosisCodePointer = 2
  250. end
  251. l2400.DTP('Date - Service Date') do |dtp|
  252. dtp.DateTimePeriodFormatQualifier = 'D8'
  253. dtp.DateTimePeriod = '20061010'
  254. end
  255. end
  256. l2300.L2400.build do |l2400|
  257. l2400.LX.LX01 = Hippo::Segments::LX.increment_sequence_number
  258. l2400.SV1 do |sv1|
  259. sv1.ProductServiceIdQualifier = 'HC'
  260. sv1.ProductServiceId = '86663'
  261. sv1.MonetaryAmount = '10'
  262. sv1.UnitOrBasisForMeasurementCode = 'UN'
  263. sv1.Quantity = '1'
  264. sv1.DiagnosisCodePointer = 2
  265. end
  266. l2400.DTP('Date - Service Date') do |dtp|
  267. dtp.DateTimePeriodFormatQualifier = 'D8'
  268. dtp.DateTimePeriod = '20061010'
  269. end
  270. end
  271. end
  272. end
  273. end
  274. end
  275. ts.SE do |se|
  276. se.TransactionSetControlNumber = ts.ST.TransactionSetControlNumber
  277. end
  278. ts.SE.NumberOfIncludedSegments = ts.segment_count
  279. published_answer = <<EOF
  280. ST*837*0021*005010X222A1~
  281. BHT*0019*00*244579*20061015*1023*CH~
  282. NM1*41*2*PREMIER BILLING SERVICE*****46*TGJ23~
  283. PER*IC*JERRY*TE*3055552222*EX*231~
  284. NM1*40*2*KEY INSURANCE COMPANY*****46*66783JJT~
  285. HL*1**20*1~
  286. PRV*BI*PXC*203BF0100Y~
  287. NM1*85*2*BEN KILDARE SERVICE*****XX*9876543210~
  288. N3*234 SEAWAY ST~
  289. N4*MIAMI*FL*33111~
  290. REF*EI*587654321~
  291. NM1*87*2~
  292. N3*2345 OCEAN BLVD~
  293. N4*MIAMI*FL*33111~
  294. HL*2*1*22*1~
  295. SBR*P**2222-SJ******CI~
  296. NM1*IL*1*SMITH*JANE****MI*JS00111223333~
  297. DMG*D8*19430501*F~
  298. NM1*PR*2*KEY INSURANCE COMPANY*****PI*999996666~
  299. REF*G2*KA6663~
  300. HL*3*2*23*0~
  301. PAT*19~
  302. NM1*QC*1*SMITH*TED~
  303. N3*236 N MAIN ST~
  304. N4*MIAMI*FL*33413~
  305. DMG*D8*19730501*M~
  306. CLM*26463774*100***11:B:1*Y*A*Y*I~
  307. REF*D9*17312345600006351~
  308. HI*BK:0340*BF:V7389~
  309. LX*1~
  310. SV1*HC:99213*40*UN*1***1~
  311. DTP*472*D8*20061003~
  312. LX*2~
  313. SV1*HC:87070*15*UN*1***1~
  314. DTP*472*D8*20061003~
  315. LX*3~
  316. SV1*HC:99214*35*UN*1***2~
  317. DTP*472*D8*20061010~
  318. LX*4~
  319. SV1*HC:86663*10*UN*1***2~
  320. DTP*472*D8*20061010~
  321. SE*42*0021~
  322. EOF
  323. assert_equal published_answer, ts.to_s.split('~').join("~\n") + "~\n"
  324. #* not printing LX segments for each service line
  325. #* HL parent/child references wrong
  326. #* HL total segments counts should only be counting direct children
  327. end
  328. end