dzero 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +265 -0
  3. data/lib/dzero/segments/01_patient.rb +27 -0
  4. data/lib/dzero/segments/02_pharmacy_provider.rb +12 -0
  5. data/lib/dzero/segments/03_prescriber.rb +22 -0
  6. data/lib/dzero/segments/04_insurance.rb +29 -0
  7. data/lib/dzero/segments/05_coord_of_benefits.rb +27 -0
  8. data/lib/dzero/segments/06_workers_comp.rb +30 -0
  9. data/lib/dzero/segments/07_claim.rb +52 -0
  10. data/lib/dzero/segments/08_dur_pps.rb +17 -0
  11. data/lib/dzero/segments/09_coupon.rb +13 -0
  12. data/lib/dzero/segments/10_compound.rb +20 -0
  13. data/lib/dzero/segments/11_pricing.rb +26 -0
  14. data/lib/dzero/segments/12_prior_auth.rb +23 -0
  15. data/lib/dzero/segments/13_clinical.rb +19 -0
  16. data/lib/dzero/segments/14_additional_documentation.rb +25 -0
  17. data/lib/dzero/segments/15_facility.rb +16 -0
  18. data/lib/dzero/segments/16_narrative.rb +11 -0
  19. data/lib/dzero/segments/20_response_message.rb +11 -0
  20. data/lib/dzero/segments/21_response_status.rb +26 -0
  21. data/lib/dzero/segments/22_response_claim.rb +19 -0
  22. data/lib/dzero/segments/23_response_pricing.rb +55 -0
  23. data/lib/dzero/segments/24_response_dur_pps.rb +20 -0
  24. data/lib/dzero/segments/25_response_insurance.rb +18 -0
  25. data/lib/dzero/segments/26_response_prior_auth.rb +18 -0
  26. data/lib/dzero/segments/27_response_insurance_additional_documentation.rb +17 -0
  27. data/lib/dzero/segments/28_response_coord_of_benefits.rb +22 -0
  28. data/lib/dzero/segments/29_response_patient.rb +13 -0
  29. data/lib/dzero/segments/base.rb +128 -0
  30. data/lib/dzero/segments/concerns/parser.rb +18 -0
  31. data/lib/dzero/segments/concerns/serializer.rb +20 -0
  32. data/lib/dzero/test_support.rb +5 -0
  33. data/lib/dzero/transmissions/base.rb +47 -0
  34. data/lib/dzero/transmissions/concerns/parser.rb +23 -0
  35. data/lib/dzero/transmissions/concerns/segments_methods.rb +76 -0
  36. data/lib/dzero/transmissions/concerns/serializer.rb +11 -0
  37. data/lib/dzero/transmissions/groups/base.rb +59 -0
  38. data/lib/dzero/transmissions/groups/transaction_group.rb +3 -0
  39. data/lib/dzero/transmissions/groups/transmission_group.rb +11 -0
  40. data/lib/dzero/transmissions/request.rb +19 -0
  41. data/lib/dzero/transmissions/response.rb +17 -0
  42. data/lib/dzero/utils/fixed_width.rb +19 -0
  43. data/lib/dzero/utils/rejection_codes.rb +297 -0
  44. data/lib/dzero/utils/validator.rb +61 -0
  45. data/lib/dzero/version.rb +3 -0
  46. data/lib/dzero.rb +28 -0
  47. metadata +186 -0
@@ -0,0 +1,19 @@
1
+ module DZero::Utils
2
+ module FixedWidth
3
+ def self.parse_fixed_width(fields, string)
4
+ field_sizes = fields.values
5
+ field_pattern = "A#{field_sizes.join('A')}"
6
+ headers = fields.keys
7
+ values = string.unpack(field_pattern)
8
+ Hash[headers.zip(values)]
9
+ end
10
+
11
+ def self.to_fixed_width(source, schema)
12
+ string = ''
13
+ schema.each do |field, size|
14
+ string = string + ("%-#{size}.#{size}s" % source[field])
15
+ end
16
+ return string
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,297 @@
1
+ module DZero::Utils
2
+ module RejectionCodes
3
+ def self.get_code_by_symbol(symbol)
4
+ REJECTION_CODES.invert[symbol]
5
+ end
6
+
7
+ def self.get_symbol_by_code(code)
8
+ REJECTION_CODES[code]
9
+ end
10
+
11
+ REJECTION_CODES = {
12
+ "1" => :missing_or_invalid_bin,
13
+ "2" => :missing_or_invalid_version_number,
14
+ "3" => :missing_or_invalid_transaction_code,
15
+ "4" => :missing_or_invalid_processor_control_number,
16
+ "5" => :missing_or_invalid_pharmacy_number,
17
+ "6" => :missing_or_invalid_group_number,
18
+ "7" => :missing_or_invalid_cardholder_id_number,
19
+ "8" => :missing_or_invalid_person_code,
20
+ "9" => :missing_or_invalid_birth_date,
21
+ "10" => :missing_or_invalid_patient_gender_code,
22
+ "11" => :missing_or_invalid_patient_relationship_code,
23
+ "12" => :missing_or_invalid_patient_location,
24
+ "13" => :missing_or_invalid_other_coverage_code,
25
+ "14" => :missing_or_invalid_eligibility_clarification_code,
26
+ "15" => :missing_or_invalid_date_of_service,
27
+ "16" => :missing_or_invalid_prescription_service_reference_number,
28
+ "17" => :missing_or_invalid_fill_number,
29
+ "19" => :missing_or_invalid_days_supply,
30
+ "1C" => :missing_or_invalid_smoker_non_smoker_code,
31
+ "1E" => :missing_or_invalid_prescriber_location_code,
32
+ "20" => :missing_or_invalid_compound_code,
33
+ "21" => :missing_or_invalid_product_service_id,
34
+ "22" => :missing_or_invalid_dispense_as_written_daw_product_selection_code,
35
+ "23" => :missing_or_invalid_ingredient_cost_submitted,
36
+ "25" => :missing_or_invalid_prescriber_id,
37
+ "26" => :missing_or_invalid_unit_of_measure,
38
+ "28" => :missing_or_invalid_date_prescription_written,
39
+ "29" => :missing_or_invalid_number_refills_authorized,
40
+ "2C" => :missing_or_invalid_pregnancy_indicator,
41
+ "2E" => :missing_or_invalid_primary_care_provider_id_qualifier,
42
+ "32" => :missing_or_invalid_level_of_service,
43
+ "33" => :missing_or_invalid_prescription_origin_code,
44
+ "34" => :missing_or_invalid_submission_clarification_code,
45
+ "35" => :missing_or_invalid_primary_care_provider_id,
46
+ "38" => :missing_or_invalid_basis_of_cost,
47
+ "39" => :missing_or_invalid_diagnosis_code,
48
+ "3A" => :missing_or_invalid_request_type,
49
+ "3B" => :missing_or_invalid_request_period_date_begin,
50
+ "3C" => :missing_or_invalid_request_period_date_end,
51
+ "3D" => :missing_or_invalid_basis_of_request,
52
+ "3E" => :missing_or_invalid_authorized_representative_first_name,
53
+ "3F" => :missing_or_invalid_authorized_representative_last_name,
54
+ "3G" => :missing_or_invalid_authorized_representative_street_address,
55
+ "3H" => :missing_or_invalid_authorized_representative_city_address,
56
+ "3J" => :missing_or_invalid_authorized_representative_state_province_address,
57
+ "3K" => :missing_or_invalid_authorized_representative_zip_postal_zone,
58
+ "3M" => :missing_or_invalid_prescriber_phone_number,
59
+ "3N" => :missing_or_invalid_prior_authorized_number_assigned,
60
+ "3P" => :missing_or_invalid_authorization_number,
61
+ "3R" => :prior_authorization_not_required,
62
+ "3S" => :missing_or_invalid_prior_authorization_supporting_documentation,
63
+ "3T" => :active_prior_authorization_exists_resubmit_at_expiration_of_prior_authorization,
64
+ "3W" => :prior_authorization_in_process,
65
+ "3X" => :authorization_number_not_found,
66
+ "3Y" => :prior_authorization_denied,
67
+ "40" => :pharmacy_not_contracted_with_plan_on_date_of_service,
68
+ "41" => :submit_bill_to_other_processor_or_primary_payer,
69
+ "4C" => :missing_or_invalid_coordination_of_benefits_other_payments_count,
70
+ "4E" => :missing_or_invalid_primary_care_provider_last_name,
71
+ "50" => :non_matched_pharmacy_number,
72
+ "51" => :non_matched_group_id,
73
+ "52" => :non_matched_cardholder_id,
74
+ "53" => :non_matched_person_code,
75
+ "54" => :non_matched_product_service_id_number,
76
+ "55" => :non_matched_product_package_size,
77
+ "56" => :non_matched_prescriber_id,
78
+ "58" => :non_matched_primary_prescriber,
79
+ "5C" => :missing_or_invalid_other_payer_coverage_type,
80
+ "5E" => :missing_or_invalid_other_payer_reject_count,
81
+ "60" => :product_service_not_covered_for_patient_age,
82
+ "61" => :product_service_not_covered_for_patient_gender,
83
+ "62" => :patient_card_holder_id_name_mismatch,
84
+ "63" => :institutionalized_patient_product_service_id_not_covered,
85
+ "64" => :claim_submitted_does_not_match_prior_authorization,
86
+ "65" => :patient_is_not_covered,
87
+ "66" => :patient_age_exceeds_maximum_age,
88
+ "67" => :filled_before_coverage_effective,
89
+ "68" => :filled_after_coverage_expired,
90
+ "69" => :filled_after_coverage_terminated,
91
+ "6C" => :missing_or_invalid_other_payer_id_qualifier,
92
+ "6E" => :missing_or_invalid_other_payer_reject_code,
93
+ "70" => :product_service_not_covered,
94
+ "71" => :prescriber_is_not_covered,
95
+ "72" => :primary_prescriber_is_not_covered,
96
+ "73" => :refills_are_not_covered,
97
+ "74" => :other_carrier_payment_meets_or_exceeds_payable,
98
+ "75" => :prior_authorization_required,
99
+ "76" => :plan_limitations_exceeded,
100
+ "77" => :discontinued_product_service_id_number,
101
+ "78" => :cost_exceeds_maximum,
102
+ "79" => :refill_too_soon,
103
+ "7C" => :missing_or_invalid_other_payer_id,
104
+ "7E" => :missing_or_invalid_dur_pps_code_counter,
105
+ "80" => :drug_diagnosis_mismatch,
106
+ "81" => :claim_too_old,
107
+ "82" => :claim_is_post_dated,
108
+ "83" => :duplicate_paid_captured_claim,
109
+ "84" => :claim_has_not_been_paid_captured,
110
+ "85" => :claim_not_processed,
111
+ "86" => :submit_manual_reversal,
112
+ "87" => :reversal_not_processed,
113
+ "88" => :dur_reject_error,
114
+ "89" => :rejected_claim_fees_paid,
115
+ "8C" => :missing_or_invalid_facility_id,
116
+ "8E" => :missing_or_invalid_dur_pps_level_of_effort,
117
+ "90" => :host_hung_up,
118
+ "91" => :host_response_error,
119
+ "92" => :system_unavailable_host_unavailable,
120
+ "95" => :time_out,
121
+ "96" => :scheduled_downtime,
122
+ "97" => :payer_unavailable,
123
+ "98" => :connection_to_payer_is_down,
124
+ "99" => :host_processing_error,
125
+ "A9" => :missing_or_invalid_transaction_count,
126
+ "AA" => :patient_spenddown_not_met,
127
+ "AB" => :date_written_is_after_date_filled,
128
+ "AC" => :product_not_covered_non_participating_manufacturer,
129
+ "AD" => :billing_provider_not_eligible_to_bill_this_claim_type,
130
+ "AE" => :qmb_qualified_medicare_beneficiary_bill_medicare,
131
+ "AF" => :patient_enrolled_under_managed_care,
132
+ "AG" => :days_supply_limitation_for_product_service,
133
+ "AH" => :unit_dose_packaging_only_payable_for_nursing_home_recipients,
134
+ "AJ" => :generic_drug_required,
135
+ "AK" => :missing_or_invalid_software_vendor_certification_id,
136
+ "AM" => :missing_or_invalid_segment_identification,
137
+ "B2" => :missing_or_invalid_service_provider_id_qualifier,
138
+ "BE" => :missing_or_invalid_professional_service_fee_submitted,
139
+ "CA" => :missing_or_invalid_patient_first_name,
140
+ "CB" => :missing_or_invalid_patient_last_name,
141
+ "CC" => :missing_or_invalid_cardholder_first_name,
142
+ "CD" => :missing_or_invalid_cardholder_last_name,
143
+ "CE" => :missing_or_invalid_home_plan,
144
+ "CF" => :missing_or_invalid_employer_name,
145
+ "CG" => :missing_or_invalid_employer_street_address,
146
+ "CH" => :missing_or_invalid_employer_city_address,
147
+ "CI" => :missing_or_invalid_employer_state_province_address,
148
+ "CJ" => :missing_or_invalid_employer_zip_postal_zone,
149
+ "CK" => :missing_or_invalid_employer_phone_number,
150
+ "CL" => :missing_or_invalid_employer_contact_name,
151
+ "CM" => :missing_or_invalid_patient_street_address,
152
+ "CN" => :missing_or_invalid_patient_city_address,
153
+ "CO" => :missing_or_invalid_patient_state_province_address,
154
+ "CP" => :missing_or_invalid_patient_zip_postal_zone,
155
+ "CQ" => :missing_or_invalid_patient_phone_number,
156
+ "CR" => :missing_or_invalid_carrier_id,
157
+ "CW" => :missing_or_invalid_alternate_id,
158
+ "CX" => :missing_or_invalid_patient_id_qualifier,
159
+ "CY" => :missing_or_invalid_patient_id,
160
+ "CZ" => :missing_or_invalid_employer_id,
161
+ "DC" => :missing_or_invalid_dispensing_fee_submitted,
162
+ "DN" => :missing_or_invalid_basis_of_cost_determination,
163
+ "DQ" => :missing_or_invalid_usual_and_customary_charge,
164
+ "DR" => :missing_or_invalid_prescriber_last_name,
165
+ "DT" => :missing_or_invalid_unit_dose_indicator,
166
+ "DU" => :missing_or_invalid_gross_amount_due,
167
+ "DV" => :missing_or_invalid_other_payer_amount_paid,
168
+ "DX" => :missing_or_invalid_patient_paid_amount_submitted,
169
+ "DY" => :missing_or_invalid_date_of_injury,
170
+ "DZ" => :missing_or_invalid_claim_reference_id,
171
+ "E1" => :missing_or_invalid_product_service_id_qualifier,
172
+ "E3" => :missing_or_invalid_incentive_amount_submitted,
173
+ "E4" => :missing_or_invalid_reason_for_service_code,
174
+ "E5" => :missing_or_invalid_professional_service_code,
175
+ "E6" => :missing_or_invalid_result_of_service_code,
176
+ "E7" => :missing_or_invalid_quantity_dispensed,
177
+ "E8" => :missing_or_invalid_other_payer_date,
178
+ "E9" => :missing_or_invalid_provider_id,
179
+ "EA" => :missing_or_invalid_originally_prescribed_product_service_code,
180
+ "EB" => :missing_or_invalid_originally_prescribed_quantity,
181
+ "EC" => :missing_or_invalid_compound_ingredient_component_count,
182
+ "ED" => :missing_or_invalid_compound_ingredient_quantity,
183
+ "EE" => :missing_or_invalid_compound_ingredient_drug_cost,
184
+ "EF" => :missing_or_invalid_compound_dosage_form_description_code,
185
+ "EG" => :missing_or_invalid_compound_dispensing_unit_form_indicator,
186
+ "EH" => :missing_or_invalid_compound_route_of_administration,
187
+ "EJ" => :missing_or_invalid_originally_prescribed_product_service_id_qualifier,
188
+ "EK" => :missing_or_invalid_scheduled_prescription_id_number,
189
+ "EM" => :missing_or_invalid_prescription_service_reference_number_qualifier,
190
+ "EN" => :missing_or_invalid_associated_prescription_service_reference_number,
191
+ "EP" => :missing_or_invalid_associated_prescription_service_date,
192
+ "ER" => :missing_or_invalid_procedure_modifier_code,
193
+ "ET" => :missing_or_invalid_quantity_prescribed,
194
+ "EU" => :missing_or_invalid_prior_authorization_type_code,
195
+ "EV" => :missing_or_invalid_prior_authorization_number_submitted,
196
+ "EW" => :missing_or_invalid_intermediary_authorization_type_id,
197
+ "EX" => :missing_or_invalid_intermediary_authorization_id,
198
+ "EY" => :missing_or_invalid_provider_id_qualifier,
199
+ "EZ" => :missing_or_invalid_prescriber_id_qualifier,
200
+ "FO" => :missing_or_invalid_plan_id,
201
+ "GE" => :missing_or_invalid_percentage_sales_tax_amount_submitted,
202
+ "H1" => :missing_or_invalid_measurement_time,
203
+ "H2" => :missing_or_invalid_measurement_dimension,
204
+ "H3" => :missing_or_invalid_measurement_unit,
205
+ "H4" => :missing_or_invalid_measurement_value,
206
+ "H5" => :missing_or_invalid_primary_care_provider_location_code,
207
+ "H6" => :missing_or_invalid_dur_co_agent_id,
208
+ "H7" => :missing_or_invalid_other_amount_claimed_submitted_count,
209
+ "H8" => :missing_or_invalid_other_amount_claimed_submitted_qualifier,
210
+ "H9" => :missing_or_invalid_other_amount_claimed_submitted,
211
+ "HA" => :missing_or_invalid_flat_sales_tax_amount_submitted,
212
+ "HB" => :missing_or_invalid_other_payer_amount_paid_count,
213
+ "HC" => :missing_or_invalid_other_payer_amount_paid_qualifier,
214
+ "HD" => :missing_or_invalid_dispensing_status,
215
+ "HE" => :missing_or_invalid_percentage_sales_tax_rate_submitted,
216
+ "HF" => :missing_or_invalid_quantity_intended_to_be_dispensed,
217
+ "HG" => :missing_or_invalid_days_supply_intended_to_be_dispensed,
218
+ "J9" => :missing_or_invalid_dur_co_agent_id_qualifier,
219
+ "JE" => :missing_or_invalid_percentage_sales_tax_basis_submitted,
220
+ "KE" => :missing_or_invalid_coupon_type,
221
+ "M1" => :patient_not_covered_in_this_aid_category,
222
+ "M2" => :recipient_locked_in,
223
+ "M3" => :host_pa_mc_error,
224
+ "M4" => :prescription_service_reference_number_time_limit_exceeded,
225
+ "M5" => :requires_manual_claim,
226
+ "M6" => :host_eligibility_error,
227
+ "M7" => :host_drug_file_error,
228
+ "M8" => :host_provider_file_error,
229
+ "ME" => :missing_or_invalid_coupon_number,
230
+ "MZ" => :error_overflow,
231
+ "NE" => :missing_or_invalid_coupon_value_amount,
232
+ "NN" => :transaction_rejected_at_switch_or_intermediary,
233
+ "P1" => :associated_prescription_service_reference_number_not_found,
234
+ "P2" => :clinical_information_counter_out_of_sequence,
235
+ "P3" => :compound_ingredient_component_count_does_not_match_number_of_repetitions,
236
+ "P4" => :coordination_of_benefits_other_payments_count_does_not_match_number_of_repetitions,
237
+ "P5" => :coupon_expired,
238
+ "P6" => :date_of_service_prior_to_date_of_birth,
239
+ "P7" => :diagnosis_code_count_does_not_match_number_of_repetitions,
240
+ "P8" => :dur_pps_code_counter_out_of_sequence,
241
+ "P9" => :field_is_non_repeatable,
242
+ "PA" => :pa_exhausted_not_renewable,
243
+ "PB" => :invalid_transaction_count_for_this_transaction_code,
244
+ "PC" => :missing_or_invalid_claim_segment,
245
+ "PD" => :missing_or_invalid_clinical_segment,
246
+ "PE" => :missing_or_invalid_cob_other_payments_segment,
247
+ "PF" => :missing_or_invalid_compound_segment,
248
+ "PG" => :missing_or_invalid_coupon_segment,
249
+ "PH" => :missing_or_invalid_dur_pps_segment,
250
+ "PJ" => :missing_or_invalid_insurance_segment,
251
+ "PK" => :missing_or_invalid_patient_segment,
252
+ "PM" => :missing_or_invalid_pharmacy_provider_segment,
253
+ "PN" => :missing_or_invalid_prescriber_segment,
254
+ "PP" => :missing_or_invalid_pricing_segment,
255
+ "PR" => :missing_or_invalid_prior_authorization_segment,
256
+ "PS" => :missing_or_invalid_transaction_header_segment,
257
+ "PT" => :missing_or_invalid_workers_compensation_segment,
258
+ "PV" => :non_matched_associated_prescription_service_date,
259
+ "PW" => :non_matched_employer_id,
260
+ "PX" => :non_matched_other_payer_id,
261
+ "PY" => :non_matched_unit_form_route_of_administration,
262
+ "PZ" => :non_matched_unit_of_measure_to_product_service_id,
263
+ "R1" => :other_amount_claimed_submitted_count_does_not_match_number_of_repetitions,
264
+ "R2" => :other_payer_reject_count_does_not_match_number_of_repetitions,
265
+ "R3" => :procedure_modifier_code_count_does_not_match_number_of_repetitions,
266
+ "R4" => :procedure_modifier_code_invalid_for_product_service_id,
267
+ "R5" => :product_service_id_must_be_zero_when_product_service_id_qualifier_equals_ø6,
268
+ "R6" => :product_service_not_appropriate_for_this_location,
269
+ "R7" => :repeating_segment_not_allowed_in_same_transaction,
270
+ "R8" => :syntax_error,
271
+ "R9" => :value_in_gross_amount_due_does_not_follow_pricing_formulae,
272
+ "RA" => :pa_reversal_out_of_order,
273
+ "RB" => :multiple_partials_not_allowed,
274
+ "RC" => :different_drug_entity_between_partial_completion,
275
+ "RD" => :mismatched_cardholder_group_id_partial_to_completion,
276
+ "RE" => :missing_or_invalid_compound_product_id_qualifier,
277
+ "RF" => :improper_order_of_dispensing_status_code_on_partial_fill_transaction,
278
+ "RG" => :missing_or_invalid_associated_prescription_service_reference_number_on_completion_transaction,
279
+ "RH" => :missing_or_invalid_associated_prescription_service_date_on_completion_transaction,
280
+ "RJ" => :associated_partial_fill_transaction_not_on_file,
281
+ "RK" => :partial_fill_transaction_not_supported,
282
+ "RM" => :completion_transaction_not_permitted_with_same_date_of_service_as_partial_transaction,
283
+ "RN" => :plan_limits_exceeded_on_intended_partial_fill_values,
284
+ "RP" => :out_of_sequence_p_reversal_on_partial_fill_transaction,
285
+ "RS" => :missing_or_invalid_associated_prescription_service_date_on_partial_transaction,
286
+ "RT" => :missing_or_invalid_associated_prescription_service_reference_number_on_partial_transaction,
287
+ "RU" => :mandatory_data_elements_must_occur_before_optional_data_elements_in_a_segment,
288
+ "SE" => :missing_or_invalid_procedure_modifier_code_count,
289
+ "TE" => :missing_or_invalid_compound_product_id,
290
+ "UE" => :missing_or_invalid_compound_ingredient_basis_of_cost_determination,
291
+ "VE" => :missing_or_invalid_diagnosis_code_count,
292
+ "WE" => :missing_or_invalid_diagnosis_code_qualifier,
293
+ "XE" => :missing_or_invalid_clinical_information_counter,
294
+ "ZE" => :missing_or_invalid_measurement_date,
295
+ }
296
+ end
297
+ end
@@ -0,0 +1,61 @@
1
+ require 'dzero'
2
+ require 'classy_hash'
3
+
4
+ module DZero::Utils
5
+ class Validator
6
+ # Due to the way classy_hash is written, it cannot be extended conventionally
7
+ CHExtended = CH.dup
8
+ CHExtended.module_eval do
9
+ def self.join_path(parent_path, key)
10
+ if parent_path
11
+ parent_path + [key]
12
+ elsif key == CH::NO_VALUE
13
+ nil
14
+ else
15
+ [key]
16
+ end
17
+ end
18
+ end
19
+
20
+ class << self
21
+ def eq(expected)
22
+ Proc.new { |value| expected == value || "must be #{expected}" }
23
+ end
24
+ end
25
+
26
+ def initialize(transmission, validations)
27
+ @transmission = transmission
28
+ @validations = validations
29
+ end
30
+
31
+ attr_reader :transmission, :validations
32
+
33
+ def validate
34
+ @errors = []
35
+
36
+ CHExtended.validate(hash, validations, errors: @errors, raise_errors: false, full: true)
37
+ end
38
+
39
+ def readable_errors
40
+ @errors.map do |error|
41
+ error[:message] = 'must be present' if error[:message] == 'present'
42
+
43
+ case error[:full_path][0]
44
+ when :header
45
+ "Transaction Header: #{error[:full_path][1]} #{error[:message]}"
46
+ when :transmission_group
47
+ "#{error[:full_path][1].to_s.titlecase} Segment: #{error[:full_path][2]} #{error[:message]}"
48
+ when :transaction_groups
49
+ next unless error[:full_path][2]
50
+ "Group #{error[:full_path][1]}, #{error[:full_path][2].to_s.titlecase} Segment: #{error[:full_path][3]} #{error[:message]}"
51
+ else
52
+ "#{error[:full_path][-1]} #{error[:message]}"
53
+ end.to_s.strip.squeeze(' ')
54
+ end.compact
55
+ end
56
+
57
+ def hash
58
+ @hash ||= transmission.to_json(readable: true, key_group_by_segment_sym: true)
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,3 @@
1
+ module DZero
2
+ VERSION = "0.1.1"
3
+ end
data/lib/dzero.rb ADDED
@@ -0,0 +1,28 @@
1
+ require 'active_support'
2
+ require 'active_support/core_ext'
3
+
4
+ module DZero
5
+ module Constants
6
+ FIELD_SEPARATOR = "\x1C"
7
+ GROUP_SEPARATOR = "\x1D"
8
+ SEGMENT_SEPARATOR = "\x1E"
9
+ end
10
+
11
+ module Segments
12
+ module Concerns; end
13
+ end
14
+
15
+ module Transmissions
16
+ module Concerns; end
17
+ module Groups; end
18
+ end
19
+
20
+ module Utils; end
21
+ end
22
+
23
+ require 'dzero/utils/fixed_width.rb'
24
+ require 'dzero/utils/rejection_codes.rb'
25
+ require 'dzero/utils/validator.rb'
26
+ require 'dzero/segments/base.rb'
27
+ require 'dzero/transmissions/base.rb'
28
+
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dzero
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Austin
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-12-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: classy_hash
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: factory_bot
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 4.11.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 4.11.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.10.4
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.10.4
111
+ description: NCPDP Telecommunications Standard D0 format serializer / parser
112
+ email:
113
+ - austin.pivarnik@instacart.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - README.md
119
+ - lib/dzero.rb
120
+ - lib/dzero/segments/01_patient.rb
121
+ - lib/dzero/segments/02_pharmacy_provider.rb
122
+ - lib/dzero/segments/03_prescriber.rb
123
+ - lib/dzero/segments/04_insurance.rb
124
+ - lib/dzero/segments/05_coord_of_benefits.rb
125
+ - lib/dzero/segments/06_workers_comp.rb
126
+ - lib/dzero/segments/07_claim.rb
127
+ - lib/dzero/segments/08_dur_pps.rb
128
+ - lib/dzero/segments/09_coupon.rb
129
+ - lib/dzero/segments/10_compound.rb
130
+ - lib/dzero/segments/11_pricing.rb
131
+ - lib/dzero/segments/12_prior_auth.rb
132
+ - lib/dzero/segments/13_clinical.rb
133
+ - lib/dzero/segments/14_additional_documentation.rb
134
+ - lib/dzero/segments/15_facility.rb
135
+ - lib/dzero/segments/16_narrative.rb
136
+ - lib/dzero/segments/20_response_message.rb
137
+ - lib/dzero/segments/21_response_status.rb
138
+ - lib/dzero/segments/22_response_claim.rb
139
+ - lib/dzero/segments/23_response_pricing.rb
140
+ - lib/dzero/segments/24_response_dur_pps.rb
141
+ - lib/dzero/segments/25_response_insurance.rb
142
+ - lib/dzero/segments/26_response_prior_auth.rb
143
+ - lib/dzero/segments/27_response_insurance_additional_documentation.rb
144
+ - lib/dzero/segments/28_response_coord_of_benefits.rb
145
+ - lib/dzero/segments/29_response_patient.rb
146
+ - lib/dzero/segments/base.rb
147
+ - lib/dzero/segments/concerns/parser.rb
148
+ - lib/dzero/segments/concerns/serializer.rb
149
+ - lib/dzero/test_support.rb
150
+ - lib/dzero/transmissions/base.rb
151
+ - lib/dzero/transmissions/concerns/parser.rb
152
+ - lib/dzero/transmissions/concerns/segments_methods.rb
153
+ - lib/dzero/transmissions/concerns/serializer.rb
154
+ - lib/dzero/transmissions/groups/base.rb
155
+ - lib/dzero/transmissions/groups/transaction_group.rb
156
+ - lib/dzero/transmissions/groups/transmission_group.rb
157
+ - lib/dzero/transmissions/request.rb
158
+ - lib/dzero/transmissions/response.rb
159
+ - lib/dzero/utils/fixed_width.rb
160
+ - lib/dzero/utils/rejection_codes.rb
161
+ - lib/dzero/utils/validator.rb
162
+ - lib/dzero/version.rb
163
+ homepage: https://github.com/apiv/dzero
164
+ licenses: []
165
+ metadata: {}
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ requirements: []
181
+ rubyforge_project:
182
+ rubygems_version: 2.5.2.3
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: Parse and serialize NCPDP D0 messages
186
+ test_files: []