hippo 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. data/.gitignore +6 -0
  2. data/CHANGELOG +9 -0
  3. data/Gemfile +11 -0
  4. data/Guardfile +14 -0
  5. data/README.md +227 -0
  6. data/Rakefile +12 -0
  7. data/bin/demo_270.rb +280 -0
  8. data/bin/demo_276.rb +296 -0
  9. data/bin/demo_835.rb +170 -0
  10. data/hippo.gemspec +24 -0
  11. data/lib/hippo/exceptions.rb +8 -0
  12. data/lib/hippo/field.rb +6 -0
  13. data/lib/hippo/loop.rb +0 -0
  14. data/lib/hippo/parser.rb +92 -0
  15. data/lib/hippo/samples/835.edi +88 -0
  16. data/lib/hippo/samples/sample_835_with.rb +272 -0
  17. data/lib/hippo/samples/sample_parsed.rb +1162 -0
  18. data/lib/hippo/segments/AK1.rb +32 -0
  19. data/lib/hippo/segments/AK2.rb +31 -0
  20. data/lib/hippo/segments/AK9.rb +82 -0
  21. data/lib/hippo/segments/AMT.rb +31 -0
  22. data/lib/hippo/segments/BHT.rb +55 -0
  23. data/lib/hippo/segments/BPR.rb +175 -0
  24. data/lib/hippo/segments/CAS.rb +159 -0
  25. data/lib/hippo/segments/CL1.rb +39 -0
  26. data/lib/hippo/segments/CLM.rb +223 -0
  27. data/lib/hippo/segments/CLP.rb +119 -0
  28. data/lib/hippo/segments/CN1.rb +55 -0
  29. data/lib/hippo/segments/CR1.rb +87 -0
  30. data/lib/hippo/segments/CR2.rb +104 -0
  31. data/lib/hippo/segments/CR3.rb +47 -0
  32. data/lib/hippo/segments/CR4.rb +239 -0
  33. data/lib/hippo/segments/CR5.rb +151 -0
  34. data/lib/hippo/segments/CR6.rb +175 -0
  35. data/lib/hippo/segments/CR7.rb +33 -0
  36. data/lib/hippo/segments/CR8.rb +79 -0
  37. data/lib/hippo/segments/CRC.rb +63 -0
  38. data/lib/hippo/segments/CTP.rb +212 -0
  39. data/lib/hippo/segments/CTX.rb +105 -0
  40. data/lib/hippo/segments/CUR.rb +175 -0
  41. data/lib/hippo/segments/DMG.rb +115 -0
  42. data/lib/hippo/segments/DN1.rb +39 -0
  43. data/lib/hippo/segments/DN2.rb +55 -0
  44. data/lib/hippo/segments/DSB.rb +71 -0
  45. data/lib/hippo/segments/DTM.rb +55 -0
  46. data/lib/hippo/segments/DTP.rb +31 -0
  47. data/lib/hippo/segments/FRM.rb +47 -0
  48. data/lib/hippo/segments/GE.rb +19 -0
  49. data/lib/hippo/segments/GS.rb +52 -0
  50. data/lib/hippo/segments/HCP.rb +127 -0
  51. data/lib/hippo/segments/HI.rb +919 -0
  52. data/lib/hippo/segments/HL.rb +44 -0
  53. data/lib/hippo/segments/HSD.rb +72 -0
  54. data/lib/hippo/segments/IEA.rb +19 -0
  55. data/lib/hippo/segments/IK3.rb +40 -0
  56. data/lib/hippo/segments/IK4.rb +63 -0
  57. data/lib/hippo/segments/IK5.rb +55 -0
  58. data/lib/hippo/segments/IMM.rb +55 -0
  59. data/lib/hippo/segments/ISA.rb +95 -0
  60. data/lib/hippo/segments/K3.rb +147 -0
  61. data/lib/hippo/segments/LIN.rb +255 -0
  62. data/lib/hippo/segments/LQ.rb +23 -0
  63. data/lib/hippo/segments/LX.rb +21 -0
  64. data/lib/hippo/segments/MEA.rb +219 -0
  65. data/lib/hippo/segments/MIA.rb +199 -0
  66. data/lib/hippo/segments/MOA.rb +79 -0
  67. data/lib/hippo/segments/N1.rb +55 -0
  68. data/lib/hippo/segments/N2.rb +23 -0
  69. data/lib/hippo/segments/N3.rb +23 -0
  70. data/lib/hippo/segments/N4.rb +63 -0
  71. data/lib/hippo/segments/NM1.rb +103 -0
  72. data/lib/hippo/segments/NTE.rb +23 -0
  73. data/lib/hippo/segments/OI.rb +55 -0
  74. data/lib/hippo/segments/PAT.rb +79 -0
  75. data/lib/hippo/segments/PER.rb +79 -0
  76. data/lib/hippo/segments/PLB.rb +191 -0
  77. data/lib/hippo/segments/PRV.rb +75 -0
  78. data/lib/hippo/segments/PS1.rb +31 -0
  79. data/lib/hippo/segments/PWK.rb +116 -0
  80. data/lib/hippo/segments/QTY.rb +155 -0
  81. data/lib/hippo/segments/RDM.rb +135 -0
  82. data/lib/hippo/segments/REF.rb +83 -0
  83. data/lib/hippo/segments/SBR.rb +79 -0
  84. data/lib/hippo/segments/SE.rb +24 -0
  85. data/lib/hippo/segments/ST.rb +31 -0
  86. data/lib/hippo/segments/STC.rb +187 -0
  87. data/lib/hippo/segments/SV1.rb +267 -0
  88. data/lib/hippo/segments/SV2.rb +147 -0
  89. data/lib/hippo/segments/SV3.rb +223 -0
  90. data/lib/hippo/segments/SV4.rb +211 -0
  91. data/lib/hippo/segments/SV5.rb +123 -0
  92. data/lib/hippo/segments/SV6.rb +155 -0
  93. data/lib/hippo/segments/SV7.rb +55 -0
  94. data/lib/hippo/segments/SVC.rb +183 -0
  95. data/lib/hippo/segments/SVD.rb +116 -0
  96. data/lib/hippo/segments/TOO.rb +67 -0
  97. data/lib/hippo/segments/TRN.rb +39 -0
  98. data/lib/hippo/segments/TS2.rb +159 -0
  99. data/lib/hippo/segments/TS3.rb +199 -0
  100. data/lib/hippo/segments/UR.rb +23 -0
  101. data/lib/hippo/segments/base.rb +148 -0
  102. data/lib/hippo/segments.rb +85 -0
  103. data/lib/hippo/transaction_sets/HIPAA_276/L2000A.rb +28 -0
  104. data/lib/hippo/transaction_sets/HIPAA_276/L2000B.rb +28 -0
  105. data/lib/hippo/transaction_sets/HIPAA_276/L2000C.rb +28 -0
  106. data/lib/hippo/transaction_sets/HIPAA_276/L2000D.rb +45 -0
  107. data/lib/hippo/transaction_sets/HIPAA_276/L2000E.rb +45 -0
  108. data/lib/hippo/transaction_sets/HIPAA_276/L2100A.rb +20 -0
  109. data/lib/hippo/transaction_sets/HIPAA_276/L2100B.rb +20 -0
  110. data/lib/hippo/transaction_sets/HIPAA_276/L2100C.rb +19 -0
  111. data/lib/hippo/transaction_sets/HIPAA_276/L2100D.rb +19 -0
  112. data/lib/hippo/transaction_sets/HIPAA_276/L2100E.rb +20 -0
  113. data/lib/hippo/transaction_sets/HIPAA_276/L2200D.rb +116 -0
  114. data/lib/hippo/transaction_sets/HIPAA_276/L2200E.rb +116 -0
  115. data/lib/hippo/transaction_sets/HIPAA_276/L2210D.rb +36 -0
  116. data/lib/hippo/transaction_sets/HIPAA_276/L2210E.rb +36 -0
  117. data/lib/hippo/transaction_sets/HIPAA_276/base.rb +86 -0
  118. data/lib/hippo/transaction_sets/HIPAA_276.rb +21 -0
  119. data/lib/hippo/transaction_sets/HIPAA_277/L2000A.rb +35 -0
  120. data/lib/hippo/transaction_sets/HIPAA_277/L2000B.rb +35 -0
  121. data/lib/hippo/transaction_sets/HIPAA_277/L2000C.rb +35 -0
  122. data/lib/hippo/transaction_sets/HIPAA_277/L2000D.rb +35 -0
  123. data/lib/hippo/transaction_sets/HIPAA_277/L2000E.rb +35 -0
  124. data/lib/hippo/transaction_sets/HIPAA_277/L2100A.rb +19 -0
  125. data/lib/hippo/transaction_sets/HIPAA_277/L2100B.rb +20 -0
  126. data/lib/hippo/transaction_sets/HIPAA_277/L2100C.rb +19 -0
  127. data/lib/hippo/transaction_sets/HIPAA_277/L2100D.rb +20 -0
  128. data/lib/hippo/transaction_sets/HIPAA_277/L2100E.rb +20 -0
  129. data/lib/hippo/transaction_sets/HIPAA_277/L2200A.rb +41 -0
  130. data/lib/hippo/transaction_sets/HIPAA_277/L2200B.rb +66 -0
  131. data/lib/hippo/transaction_sets/HIPAA_277/L2200C.rb +73 -0
  132. data/lib/hippo/transaction_sets/HIPAA_277/L2200D.rb +73 -0
  133. data/lib/hippo/transaction_sets/HIPAA_277/L2200E.rb +103 -0
  134. data/lib/hippo/transaction_sets/HIPAA_277/L2220D.rb +56 -0
  135. data/lib/hippo/transaction_sets/HIPAA_277/L2220E.rb +43 -0
  136. data/lib/hippo/transaction_sets/HIPAA_277/base.rb +77 -0
  137. data/lib/hippo/transaction_sets/HIPAA_277.rb +24 -0
  138. data/lib/hippo/transaction_sets/HIPAA_835/L1000A.rb +71 -0
  139. data/lib/hippo/transaction_sets/HIPAA_835/L1000B.rb +47 -0
  140. data/lib/hippo/transaction_sets/HIPAA_835/L2000.rb +37 -0
  141. data/lib/hippo/transaction_sets/HIPAA_835/L2100.rb +182 -0
  142. data/lib/hippo/transaction_sets/HIPAA_835/L2110.rb +85 -0
  143. data/lib/hippo/transaction_sets/HIPAA_835/base.rb +112 -0
  144. data/lib/hippo/transaction_sets/HIPAA_835.rb +12 -0
  145. data/lib/hippo/transaction_sets/HIPAA_837/L1000A.rb +30 -0
  146. data/lib/hippo/transaction_sets/HIPAA_837/L1000B.rb +21 -0
  147. data/lib/hippo/transaction_sets/HIPAA_837/L2000A.rb +65 -0
  148. data/lib/hippo/transaction_sets/HIPAA_837/L2000B.rb +49 -0
  149. data/lib/hippo/transaction_sets/HIPAA_837/L2000C.rb +42 -0
  150. data/lib/hippo/transaction_sets/HIPAA_837/L2010AA.rb +57 -0
  151. data/lib/hippo/transaction_sets/HIPAA_837/L2010AB.rb +33 -0
  152. data/lib/hippo/transaction_sets/HIPAA_837/L2010AC.rb +51 -0
  153. data/lib/hippo/transaction_sets/HIPAA_837/L2010BA.rb +74 -0
  154. data/lib/hippo/transaction_sets/HIPAA_837/L2010BB.rb +48 -0
  155. data/lib/hippo/transaction_sets/HIPAA_837/L2010CA.rb +72 -0
  156. data/lib/hippo/transaction_sets/HIPAA_837/L2300.rb +510 -0
  157. data/lib/hippo/transaction_sets/HIPAA_837/L2310A.rb +26 -0
  158. data/lib/hippo/transaction_sets/HIPAA_837/L2310B.rb +37 -0
  159. data/lib/hippo/transaction_sets/HIPAA_837/L2310C.rb +52 -0
  160. data/lib/hippo/transaction_sets/HIPAA_837/L2310D.rb +27 -0
  161. data/lib/hippo/transaction_sets/HIPAA_837/L2310E.rb +34 -0
  162. data/lib/hippo/transaction_sets/HIPAA_837/L2310F.rb +34 -0
  163. data/lib/hippo/transaction_sets/HIPAA_837/L2320.rb +122 -0
  164. data/lib/hippo/transaction_sets/HIPAA_837/L2330A.rb +43 -0
  165. data/lib/hippo/transaction_sets/HIPAA_837/L2330B.rb +92 -0
  166. data/lib/hippo/transaction_sets/HIPAA_837/L2330C.rb +26 -0
  167. data/lib/hippo/transaction_sets/HIPAA_837/L2330D.rb +26 -0
  168. data/lib/hippo/transaction_sets/HIPAA_837/L2330E.rb +27 -0
  169. data/lib/hippo/transaction_sets/HIPAA_837/L2330F.rb +27 -0
  170. data/lib/hippo/transaction_sets/HIPAA_837/L2330G.rb +26 -0
  171. data/lib/hippo/transaction_sets/HIPAA_837/L2400.rb +475 -0
  172. data/lib/hippo/transaction_sets/HIPAA_837/L2410.rb +30 -0
  173. data/lib/hippo/transaction_sets/HIPAA_837/L2420A.rb +37 -0
  174. data/lib/hippo/transaction_sets/HIPAA_837/L2420B.rb +26 -0
  175. data/lib/hippo/transaction_sets/HIPAA_837/L2420C.rb +41 -0
  176. data/lib/hippo/transaction_sets/HIPAA_837/L2420D.rb +27 -0
  177. data/lib/hippo/transaction_sets/HIPAA_837/L2420E.rb +51 -0
  178. data/lib/hippo/transaction_sets/HIPAA_837/L2420F.rb +26 -0
  179. data/lib/hippo/transaction_sets/HIPAA_837/L2420G.rb +34 -0
  180. data/lib/hippo/transaction_sets/HIPAA_837/L2420H.rb +34 -0
  181. data/lib/hippo/transaction_sets/HIPAA_837/L2430.rb +44 -0
  182. data/lib/hippo/transaction_sets/HIPAA_837/L2440.rb +23 -0
  183. data/lib/hippo/transaction_sets/HIPAA_837/base.rb +81 -0
  184. data/lib/hippo/transaction_sets/HIPAA_837.rb +45 -0
  185. data/lib/hippo/transaction_sets/HIPAA_999/L2000 - AK2.rb +30 -0
  186. data/lib/hippo/transaction_sets/HIPAA_999/L2000AK2.rb +30 -0
  187. data/lib/hippo/transaction_sets/HIPAA_999/L2100 - AK2.rb +37 -0
  188. data/lib/hippo/transaction_sets/HIPAA_999/L2100AK2.rb +37 -0
  189. data/lib/hippo/transaction_sets/HIPAA_999/L2110 - AK2.rb +23 -0
  190. data/lib/hippo/transaction_sets/HIPAA_999/L2110AK2.rb +23 -0
  191. data/lib/hippo/transaction_sets/HIPAA_999/base.rb +46 -0
  192. data/lib/hippo/transaction_sets/HIPAA_999.rb +10 -0
  193. data/lib/hippo/transaction_sets/base.rb +136 -0
  194. data/lib/hippo/transaction_sets.rb +11 -0
  195. data/lib/hippo/version.rb +3 -0
  196. data/lib/hippo.rb +15 -0
  197. data/samples/835_4010.edi +1 -0
  198. data/samples/837_4010A1.edi +1 -0
  199. data/test/test_helper.rb +118 -0
  200. data/test/test_hipaa_837.rb +396 -0
  201. data/test/test_segments_base.rb +106 -0
  202. data/test/test_transaction_sets_base.rb +85 -0
  203. metadata +277 -0
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ *.swp
5
+ .DS_STORE
6
+ Gemfile.lock
data/CHANGELOG ADDED
@@ -0,0 +1,9 @@
1
+ 0.0.3 - Pending
2
+ * Fix issue when no values are set in any subfield of a composite field.
3
+ * Add more segment tests.
4
+
5
+ 0.0.2 - 2011-09-06
6
+ * Import all segments and loops from the X12 CSV Table Data
7
+
8
+ 0.0.1 - 2011-02-05
9
+ * Intial version.
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in hippo.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'rb-fsevent'
8
+ gem 'growl_notify'
9
+ gem 'guard-minitest'
10
+ gem 'pry'
11
+ end
data/Guardfile ADDED
@@ -0,0 +1,14 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'minitest' do
5
+ # with Minitest::Unit
6
+ watch(%r|^test/test_(.*)\.rb|)
7
+ watch(%r|^lib/(.+).rb|) { "test" }
8
+ watch(%r|^test/test_helper\.rb|) { "test" }
9
+
10
+ # with Minitest::Spec
11
+ # watch(%r|^spec/(.*)_spec\.rb|)
12
+ # watch(%r|^lib/(.*)\.rb|) { |m| "spec/#{m[1]}_spec.rb" }
13
+ # watch(%r|^spec/spec_helper\.rb|) { "spec" }
14
+ end
data/README.md ADDED
@@ -0,0 +1,227 @@
1
+ Hippo
2
+ =====
3
+
4
+ The Hippo library is an attempt at creating a simple DSL to generate and parse HIPAA
5
+ transaction sets. HIPAA or the Health Insurance Portability Accountability Act is a
6
+ series of regulations which place restrictions and requirements on the way transaction
7
+ sets (ie. Claims, Remittances, Eligibility, Claim Status, etc.) must be formatted.
8
+
9
+ The HIPAA required transactions sets are created by the X12
10
+ organization. The current production version (as of 2011/02/05) is 4010A1, but
11
+ effective 2012/01/01 all organizations must be migrated to using version
12
+ 5010.
13
+
14
+ To obtain copies of the implementation guides you must purchase them from the X12
15
+ organization. The implementation data is also available in tabular format (CSV). The
16
+ transaction sets, loops, and segments in Hippo were created from the X12 CSV Table Data.
17
+
18
+ More information can be found at the following sites:
19
+
20
+ * [General HIPAA information from CMS](https://www.cms.gov/HIPAAGenInfo/01_Overview.asp)
21
+ * [Wikipedia HIPAA Article](http://en.wikipedia.org/wiki/Hipaa)
22
+ * [5010 Implementation Timeline](https://www.cms.gov/ElectronicBillingEDITrans/18_5010D0.asp)
23
+ * [X12 Store](https://store.x12.org)
24
+
25
+ Installation
26
+ ------------
27
+ gem install hippo
28
+
29
+ Usage
30
+ -----
31
+ This is very straight forward. Basically, create an instance of the
32
+ transaction set that you will be working with, and start filling in the
33
+ loops, segments, and fields. For a complete example from the 222A1 (837-P) implementation
34
+ guide please review [test/test_hipaa_837.rb](/promedical/hippo/test/test_hipaa_837.rb).
35
+
36
+ Below is a small sample of how to create a transaction set.
37
+
38
+ ```ruby
39
+ ts = Hippo::TransactionSets::HIPAA_837::Base.new
40
+
41
+ ts.ST do |st|
42
+ st.TransactionSetControlNumber = '0021'
43
+ st.ImplementationConventionReference = '005010X222A1'
44
+ end
45
+
46
+ ts.BHT do |bht|
47
+ bht.TransactionSetPurposeCode = '00'
48
+ bht.ReferenceIdentification = '244579'
49
+ bht.Date = '20061015'
50
+ bht.Time = '1023'
51
+ bht.TransactionTypeCode = 'CH'
52
+ end
53
+
54
+ ts.L1000A do |l1000a|
55
+ l1000a.NM1 do |nm1|
56
+ nm1.EntityTypeQualifier = '2'
57
+ nm1.NameLastOrOrganizationName = 'PREMIER BILLING SERVICE'
58
+ nm1.IdentificationCode = 'TGJ23'
59
+ end
60
+
61
+ l1000a.PER do |per|
62
+ per.Name = 'JERRY'
63
+ per.CommunicationNumberQualifier_01 = 'TE'
64
+ per.CommunicationNumber_01 = '3055552222'
65
+ per.CommunicationNumberQualifier_02 = 'EX'
66
+ per.CommunicationNumber_02 = '231'
67
+ end
68
+ end
69
+
70
+ puts ts.to_s
71
+
72
+ => "ST*837*0021*005010X222A1~BHT*0019*00*244579*20061015*1023*CH~NM1*41*2*PREMIER BILLING SERVICE*****46*TGJ23~PER*IC*JERRY*TE*3055552222*EX*231~"
73
+ ```
74
+
75
+ Transaction Set/Loop and Segment DSL
76
+ ------------------------------------
77
+ Transaction Sets/Loops and Segments are defined with a very straight forward DSL.
78
+
79
+ ```ruby
80
+ module Hippo::Segments
81
+ class TestSimpleSegment < Hippo::Segments::Base
82
+ segment_identifier 'TSS'
83
+
84
+ field :name => 'Field1'
85
+ field :name => 'Field2'
86
+ field :name => 'Field3'
87
+ field :name => 'Field4'
88
+ field :name => 'CommonName'
89
+ field :name => 'CommonName'
90
+ end
91
+
92
+ class TestCompoundSegment < Hippo::Segments::Base
93
+ segment_identifier 'TCS'
94
+
95
+ composite_field 'CompositeField' do
96
+ field :name => 'Field1'
97
+ field :name => 'Field2'
98
+ field :name => 'Field3'
99
+ field :name => 'CompositeCommonName'
100
+ end
101
+
102
+ composite_field 'CompositeField' do
103
+ field :name => 'Field4'
104
+ field :name => 'Field5'
105
+ field :name => 'Field6'
106
+ field :name => 'CompositeCommonName'
107
+ end
108
+
109
+ field :name => 'Field7'
110
+ end
111
+ end
112
+
113
+ module Hippo::TransactionSets
114
+ module Test
115
+ class Base < Hippo::TransactionSets::Base
116
+
117
+ segment Hippo::Segments::TestSimpleSegment,
118
+ :name => 'Test Simple Segment #1',
119
+ :minimum => 1,
120
+ :maximum => 5,
121
+ :position => 50,
122
+ :defaults => {
123
+ 'TSS01' => 'Blah'
124
+ }
125
+
126
+ segment Hippo::Segments::TestCompoundSegment,
127
+ :name => 'Test Compound Segment #2',
128
+ :minimum => 1,
129
+ :maximum => 1,
130
+ :position => 100,
131
+ :defaults => {
132
+ 'Field7' => 'Preset Field 7'
133
+ }
134
+
135
+ segment Hippo::Segments::TestSimpleSegment,
136
+ :name => 'Test Simple Segment #3',
137
+ :minimum => 1,
138
+ :maximum => 1,
139
+ :position => 50,
140
+ :defaults => {
141
+ 'TSS01' => 'Last Segment'
142
+ }
143
+ end
144
+ end
145
+ end
146
+ ```
147
+
148
+ Quick Guide to Populating a Transaction Set
149
+ -------------------------------------------
150
+ Using the simple transaction set and segments defined above, here are a few ways to access
151
+ the fields.
152
+
153
+ To create a transaction set simple choose the set you want and call new on it's Base class.
154
+
155
+ ```ruby
156
+ ts = Hippo::TransactionSets::Test::Base.new
157
+ ```
158
+
159
+ The segments can be accessed directly from the created transaction set using the segment
160
+ identifier.
161
+
162
+ ```ruby
163
+ ts.TCS
164
+ ```
165
+
166
+ Since the TSS segment can be repeated we must call #build to generate a new
167
+ instance for each repeat. (You will be returned the first instance each time if you
168
+ do not call #build.)
169
+
170
+ ```ruby
171
+ ts.TSS.build
172
+ ```
173
+
174
+ The code above produces the following string output (notice how the values from
175
+ :defaults are prefilled, and the output is automatically sorted based on the order
176
+ that the segments were declared):
177
+
178
+ ```ruby
179
+ # ts.to_s => 'TSS*Blah~TCS***Preset Field 7~'
180
+ ```
181
+
182
+ To set field values on a given segment you can access it either by calling the field directly
183
+ on the segment or by passing a block to the segment.
184
+
185
+ ```ruby
186
+ # this is one way to populate the fields
187
+ ts.TCS.Field1 = 'Foo'
188
+ ts.TSS.Field2 = 'Bar'
189
+
190
+ # this is another way
191
+ ts.TCS do |tcs|
192
+ tcs.Field1 = 'Foo'
193
+ end
194
+
195
+ ts.TSS do |tss|
196
+ tss.Field2 = 'Bar'
197
+ end
198
+
199
+ # both of the mechanisms above have the same string representation:
200
+ #
201
+ # ts.to_s => 'TSS*Blah*Bar~TCS*Foo**Preset Field 7~'
202
+ ```
203
+
204
+ If you read the transaction set declaration from above you will notice that the TSS segment
205
+ can be set in two different sequences (with different preset values). By default (as you
206
+ can see from the previous example) when we call TSS we are referring to the first segment,
207
+ but if you need to access the second instance of TSS in the transaction set you would specify
208
+ TSS_02 instead.
209
+
210
+ ```ruby
211
+ ts.TCS.Field1 = 'Foo'
212
+ ts.TSS.Field2 = 'Bar'
213
+ ts.TSS_02.Field2 = 'Baz'
214
+
215
+ # ts.to_s => 'TSS*Blah*Bar~TCS*Foo**Preset Field 7~TSS*Last Segment*Baz~'
216
+ ```
217
+
218
+ The same technique can be used to reference fields within a segment that have the same name.
219
+
220
+ ```ruby
221
+ ts.TSS.CommonName = 'Value1'
222
+ ts.TSS.CommonName_02 = 'Value2'
223
+
224
+ # ts.to_s => 'TSS*Blah*Bar***Value1*Value2~TCS*Foo**Preset Field 7~TSS*Last Segment*Baz~'
225
+ ```
226
+
227
+ For more example please review the test suite.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'bundler'
2
+ require 'rake/testtask'
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << 'test'
7
+ t.test_files = FileList['test/test_*.rb']
8
+ t.verbose = true
9
+ end
10
+
11
+
12
+ task :default => [:test]
data/bin/demo_270.rb ADDED
@@ -0,0 +1,280 @@
1
+ require './lib/hippo.rb'
2
+ require 'pp'
3
+
4
+ class Demo270
5
+ def self.run
6
+ ts = Hippo::TransactionSets::HIPAA_270::Base.new
7
+
8
+ ts.ST do |seg|
9
+ seg.TransactionSetIdentifierCode = "270"
10
+ seg.TransactionSetControlNumber = rand(10 * 100)
11
+ end
12
+
13
+ ts.BHT do |seg|
14
+ seg.HierarchicalStructureCode = '0001'
15
+ seg.TransactionSetPurposeCode = '00'
16
+ seg.ReferenceIdentification = ''
17
+ seg.Date = ''
18
+ seg.Time = ''
19
+ seg.TransactionTypeCode = ''
20
+ end
21
+
22
+ ts.L2000A do |loop|
23
+ loop.HL do |seg|
24
+ seg.HierarchicalIdNumber = ''
25
+ seg.HierarchicalParentIdNumber = ''
26
+ seg.HierarchicalLevelCode = ''
27
+ seg.HierarchicalChildCode = ''
28
+ end
29
+ loop.L2100A do |sub_loop|
30
+ sub_loop.NM1 do |seg|
31
+ seg.EntityIdentifierCode1 = ''
32
+ seg.EntityTypeQualifier = ''
33
+ seg.NameLastOrOrganizationName = ''
34
+ seg.NameFirst = ''
35
+ end
36
+ end
37
+ end
38
+
39
+ ts.L2000B do |loop|
40
+ loop.HL do |seg|
41
+ seg.HierarchicalIdNumber = ''
42
+ seg.HierarchicalParentIdNumber = ''
43
+ seg.HierarchicalLevelCode = ''
44
+ seg.HierarchicalChildCode = ''
45
+ end
46
+ loop.L2100B do |sub_loop|
47
+ sub_loop.NM1 do |seg|
48
+ seg.EntityIdentifierCode1 = ''
49
+ seg.EntityTypeQualifier = ''
50
+ seg.NameLastOrOrganizationName = ''
51
+ seg.NameFirst = ''
52
+ end
53
+ sub_loop.REF do |seg|
54
+ seg.ReferenceIdentificationQualifier = ""
55
+ seg.ReferenceIdentification = ""
56
+ seg.Description = ""
57
+ seg.ReferenceIdentifier = ""
58
+ end
59
+ sub_loop.N3 do |seg|
60
+ seg.AddressInformation1 = ""
61
+ seg.AddressInformation2 = ""
62
+ end
63
+ sub_loop.N4 do |seg|
64
+ seg.CityName = ""
65
+ seg.StateOrProvinceCode = ""
66
+ seg.PostalCode = ""
67
+ seg.CountryCode = ""
68
+ end
69
+ sub_loop.PER do |seg|
70
+ seg.ContactFunctionCode = ""
71
+ seg.Name = ""
72
+ end
73
+ sub_loop.PRV do |seg|
74
+ seg.ProviderCode = ""
75
+ seg.ReferenceIdentificationQualifier = ""
76
+ seg.ReferenceIdentification = ""
77
+ seg.StateOrProvinceCode = ""
78
+ seg.ProviderSpecialtyInformation = ""
79
+ seg.ProviderOrganizationCode = ""
80
+ end
81
+ end
82
+ end
83
+
84
+ ts.L2000C do |loop|
85
+ loop.HL do |seg|
86
+ seg.HierarchicalIdNumber = ''
87
+ seg.HierarchicalParentIdNumber = ''
88
+ seg.HierarchicalLevelCode = ''
89
+ seg.HierarchicalChildCode = ''
90
+ end
91
+ loop.TRN do |seg|
92
+ seg.TraceTypeCode = rand(10 * 100)
93
+ seg.ReferenceIdentification1 = rand(10 * 100)
94
+ seg.OriginatingCompanyIdentifier = rand(10 * 100)
95
+ seg.ReferenceIdentification2 = rand(10 * 100)
96
+ end
97
+ loop.L2100C do |sub_loop|
98
+ sub_loop.NM1 do |seg|
99
+ seg.EntityIdentifierCode1 = ''
100
+ seg.EntityTypeQualifier = ''
101
+ seg.NameLastOrOrganizationName = ''
102
+ seg.NameFirst = ''
103
+ end
104
+ sub_loop.REF do |seg|
105
+ seg.ReferenceIdentificationQualifier = "00"
106
+ seg.ReferenceIdentification = "R0203"
107
+ seg.Description = "Description"
108
+ seg.ReferenceIdentifier = "1241"
109
+ end
110
+ sub_loop.N3 do |seg|
111
+ seg.AddressInformation1 = ""
112
+ seg.AddressInformation2 = ""
113
+ end
114
+ sub_loop.N4 do |seg|
115
+ seg.CityName = ""
116
+ seg.StateOrProvinceCode = ""
117
+ seg.PostalCode = ""
118
+ seg.CountryCode = ""
119
+ end
120
+ sub_loop.PRV do |seg|
121
+ seg.ProviderCode = ""
122
+ seg.ReferenceIdentificationQualifier = ""
123
+ seg.ReferenceIdentification = ""
124
+ seg.StateOrProvinceCode = ""
125
+ seg.ProviderSpecialtyInformation = ""
126
+ seg.ProviderOrganizationCode = ""
127
+ end
128
+ sub_loop.DMG do |seg|
129
+ seg.DateTimePeriodFormatQualifier = ''
130
+ seg.DateTimePeriod = ''
131
+ seg.GenderCode = ''
132
+ seg.MaritalStatusCode = ''
133
+ seg.CompositeRaceOrEthnicityInformation = ''
134
+ seg.CitizenshipStatusCode = ''
135
+ seg.CountryCode = ''
136
+ seg.BasisOfVerificationCode = ''
137
+ seg.Quantity = ''
138
+ seg.CodeListQualifierCode = ''
139
+ seg.IndustryCode = ''
140
+ end
141
+ sub_loop.INS do |seg|
142
+ seg.YesNoConditionOrResponseCode = ''
143
+ seg.IndividualRelationshipCode = ''
144
+ end
145
+ sub_loop.DTP do |seg|
146
+ seg.DateTimeQualifier = ''
147
+ seg.DateTimePeriodFormatQualifier = ''
148
+ seg.DateTimePeriod = ''
149
+ end
150
+ sub_loop.L2110C do |sub_loop_child|
151
+ sub_loop_child.EQ do |seg|
152
+ seg.ServiceTypeCode = ""
153
+ seg.CoverageLevelCode = ""
154
+ seg.InsuranceTypeCode = ""
155
+ end
156
+ sub_loop_child.AMT do |seg|
157
+ seg.AmountQualifierCode = ''
158
+ seg.MonetaryAmount = ''
159
+ seg.CreditDebitFlagCode = ''
160
+ end
161
+ sub_loop_child.III do |seg|
162
+ seg.CodeListQualifierCode = ""
163
+ seg.IndustryCode = ""
164
+ end
165
+ sub_loop_child.REF do |seg|
166
+ seg.ReferenceIdentificationQualifier = ""
167
+ seg.ReferenceIdentification = ""
168
+ seg.Description = ""
169
+ seg.ReferenceIdentifier = ""
170
+ end
171
+ sub_loop_child.DTP do |seg|
172
+ seg.DateTimeQualifier = ''
173
+ seg.DateTimePeriodFormatQualifier = ''
174
+ seg.DateTimePeriod = ''
175
+ end
176
+ end
177
+ end
178
+ end
179
+
180
+ ts.L2000D do |loop|
181
+ loop.HL do |seg|
182
+ seg.HierarchicalIdNumber = ''
183
+ seg.HierarchicalParentIdNumber = ''
184
+ seg.HierarchicalLevelCode = ''
185
+ seg.HierarchicalChildCode = ''
186
+ end
187
+ loop.TRN do |seg|
188
+ seg.TraceTypeCode = rand(10 * 100)
189
+ seg.ReferenceIdentification1 = rand(10 * 100)
190
+ seg.OriginatingCompanyIdentifier = rand(10 * 100)
191
+ seg.ReferenceIdentification2 = rand(10 * 100)
192
+ end
193
+ loop.L2100D do |sub_loop|
194
+ sub_loop.NM1 do |seg|
195
+ seg.EntityIdentifierCode1 = ''
196
+ seg.EntityTypeQualifier = ''
197
+ seg.NameLastOrOrganizationName = ''
198
+ seg.NameFirst = ''
199
+ end
200
+ sub_loop.REF do |seg|
201
+ seg.ReferenceIdentificationQualifier = ""
202
+ seg.ReferenceIdentification = ""
203
+ seg.Description = ""
204
+ seg.ReferenceIdentifier = ""
205
+ end
206
+ sub_loop.N3 do |seg|
207
+ seg.AddressInformation1 = ""
208
+ seg.AddressInformation2 = ""
209
+ end
210
+ sub_loop.N4 do |seg|
211
+ seg.CityName = ""
212
+ seg.StateOrProvinceCode = ""
213
+ seg.PostalCode = ""
214
+ seg.CountryCode = ""
215
+ end
216
+ sub_loop.PRV do |seg|
217
+ seg.ProviderCode = ""
218
+ seg.ReferenceIdentificationQualifier = ""
219
+ seg.ReferenceIdentification = ""
220
+ seg.StateOrProvinceCode = ""
221
+ seg.ProviderSpecialtyInformation = ""
222
+ seg.ProviderOrganizationCode = ""
223
+ end
224
+ sub_loop.DMG do |seg|
225
+ seg.DateTimePeriodFormatQualifier = ''
226
+ seg.DateTimePeriod = ''
227
+ seg.GenderCode = ''
228
+ seg.MaritalStatusCode = ''
229
+ seg.CompositeRaceOrEthnicityInformation = ''
230
+ seg.CitizenshipStatusCode = ''
231
+ seg.CountryCode = ''
232
+ seg.BasisOfVerificationCode = ''
233
+ seg.Quantity = ''
234
+ seg.CodeListQualifierCode = ''
235
+ seg.IndustryCode = ''
236
+ end
237
+ sub_loop.INS do |seg|
238
+ seg.YesNoConditionOrResponseCode = ''
239
+ seg.IndividualRelationshipCode = ''
240
+ end
241
+ sub_loop.DTP do |seg|
242
+ seg.DateTimeQualifier = ''
243
+ seg.DateTimePeriodFormatQualifier = ''
244
+ seg.DateTimePeriod = ''
245
+ end
246
+ sub_loop.L2110D do |sub_loop_child|
247
+ sub_loop_child.EQ do |seg|
248
+ seg.ServiceTypeCode = ""
249
+ seg.CoverageLevelCode = ""
250
+ seg.InsuranceTypeCode = ""
251
+ end
252
+ sub_loop_child.III do |seg|
253
+ seg.CodeListQualifierCode = ""
254
+ seg.IndustryCode = ""
255
+ end
256
+ sub_loop_child.REF do |seg|
257
+ seg.ReferenceIdentificationQualifier = ""
258
+ seg.ReferenceIdentification = ""
259
+ seg.Description = ""
260
+ seg.ReferenceIdentifier = ""
261
+ end
262
+ sub_loop_child.DTP do |seg|
263
+ seg.DateTimeQualifier = ''
264
+ seg.DateTimePeriodFormatQualifier = ''
265
+ seg.DateTimePeriod = ''
266
+ end
267
+ end
268
+ end
269
+ end
270
+ ts.SE do |seg|
271
+ seg.NumberOfIncludedSegments = ''
272
+ seg.TransactionSetControlNumber = ''
273
+ end
274
+ puts ts.to_s
275
+ end #end self.run
276
+ end #end Class Demo270
277
+
278
+ if __FILE__ == $0
279
+ Demo270.run
280
+ end