editrix 1.0.5

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a802c5a5e4fd2276203638696a76b9803b74319946abc756c7b7327525713b00
4
+ data.tar.gz: 4a3d5afe36facb3ec3c7452b860d5be6135f1e54a8804caff39cd02438ad140b
5
+ SHA512:
6
+ metadata.gz: 6f449ea75fd18effe036609f8495d3865c860af63b483192897cce12c063a489ce4ab969d57c602e3f7c3f4f9332bb35d20e58d2c980aa6855e048927aef37a4
7
+ data.tar.gz: d9addffc4defabbe3c192214ca72215c9eb93cd814207fa5e56c3169cf7a3e18f68f3ecaa906f8cbdcd8f3e526fd12a9a6bb91d00fa0d7ddf037a452f77f0093
@@ -0,0 +1,18 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 2.7.2
14
+ - name: Run the default task
15
+ run: |
16
+ gem install bundler -v 2.2.15
17
+ bundle install
18
+ bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Datasource local storage ignored files
5
+ /../../../../../../:\Users\VARMA\RubymineProjects\editrix\.idea/dataSources/
6
+ /dataSources.local.xml
7
+ # Editor-based HTTP Client requests
8
+ /httpRequests/
data/.idea/editrix.iml ADDED
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$">
8
+ <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
+ </content>
12
+ <orderEntry type="jdk" jdkName="ruby-2.7.2-p137" jdkType="RUBY_SDK" />
13
+ <orderEntry type="sourceFolder" forTests="false" />
14
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.15, ruby-2.7.2-p137) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.3, ruby-2.7.2-p137) [gem]" level="application" />
16
+ </component>
17
+ <component name="RakeTasksCache">
18
+ <option name="myRootTask">
19
+ <RakeTaskImpl id="rake" />
20
+ </option>
21
+ </component>
22
+ </module>
@@ -0,0 +1,6 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
5
+ </profile>
6
+ </component>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/editrix.iml" filepath="$PROJECT_DIR$/.idea/editrix.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ ## Changelog
2
+
3
+ ## [1.0.0] - 2021-04-21
4
+
5
+ - Initial release
6
+
7
+ ## [1.0.2] - 2021-04-21
8
+
9
+ - Bug fixes
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at TODO: Write your email address. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in editrix.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.7"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Vaisakh (V4RM4)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,194 @@
1
+ # Editrix
2
+
3
+ Editrix is a gem for parsing Healthcare Eligibility Response (271) ASC X12 EDI data into a painless data structure - hash. X12 is a very old and ugly data format that came out more than 60 years, for encoding professional documents such as health and insurance claims, business orders or delivery details, and is still widely used in industries like Healthcare, Finance, Supply Chain, Insurance, Defense etc.
4
+
5
+ Editrix takes an edi(271 only) input from a developer, like this one...
6
+ ```text
7
+ ISA*00* *00* *ZZ*CMS *ZZ*SUBMITTERID *210315*0734*^*00501*111111111*0*P*|~
8
+ GS*HB*CMS*SUBMITTERID*20210315*07340000*1*X*005010X279A1~
9
+ ST*271*0001*005010X279A1~
10
+ BHT*0022*11*TRANSA*20210315*07342355~
11
+ HL*1**20*1~
12
+ NM1*PR*2*CMS*****PI*CMS~
13
+ HL*2*1*21*1~
14
+ NM1*1P*2*IRNAME*****XX*1234567893~
15
+ HL*3*2*22*0~
16
+ TRN*2*TRACKNUM*ABCDEFGHIJ~
17
+ NM1*IL*1*LNAME*FNAME*M***MI*1EG4TE5MK73~
18
+ N3*ADDRESSLINE1*ADDRESSLINE2~
19
+ N4*CITY*ST*ZIPCODE~
20
+ DMG*D8*19400401*F~
21
+ ...
22
+ ...
23
+ ```
24
+ into a ruby hash, like this.
25
+ ```ruby
26
+ {"ISA"=>{"ISA01"=>"00", "ISA02"=>" ", "ISA03"=>"00", "ISA04"=>" ", "ISA05"=>"ZZ", "ISA06"=>"CMS ", "ISA07"=>"ZZ", "ISA08"=>"SUBMITTERID ", "ISA09"=>"210315", "ISA10"=>"0734", "ISA11"=>"^", "ISA12"=>"00501", "ISA13"=>"111111111", "ISA14"=>"0", "ISA15"=>"P", "ISA16"=>"|"},
27
+ "GS"=>{"GS01"=>"HB", "GS02"=>"CMS", "GS03"=>"SUBMITTERID", "GS04"=>"20210315", "GS05"=>"07340000", "GS06"=>"1", "GS07"=>"X", "GS08"=>"005010X279A1"}, "ST"=>{"ST01"=>"271", "ST02"=>"0001", "ST03"=>"005010X279A1"},
28
+ "BHT"=>{"BHT01"=>"0022", "BHT02"=>"11", "BHT03"=>"TRANSA", "BHT04"=>"20210315", "BHT05"=>"07342355"}, "2000A.HL"=>{"HL01"=>"1", "HL02"=>"", "HL03"=>"20", "HL04"=>"1"},
29
+ "2000A.NM1"=>{"NM101"=>"PR", "NM102"=>"2", "NM103"=>"CMS", "NM104"=>"", "NM105"=>"", "NM106"=>"", "NM107"=>"", "NM108"=>"PI", "NM109"=>"CMS"}, "2000B.HL"=>{"HL01"=>"2", "HL02"=>"1", "HL03"=>"21", "HL04"=>"1"}} #....
30
+ ```
31
+ or write to files as json, like below, if needed.
32
+ ```json
33
+ {
34
+ "ISA": {
35
+ "ISA01": "00",
36
+ "ISA02": " ",
37
+ "ISA03": "00",
38
+ "ISA04": " ",
39
+ "ISA05": "ZZ",
40
+ "ISA06": "CMS ",
41
+ "ISA07": "ZZ",
42
+ "ISA08": "SUBMITTERID ",
43
+ "ISA09": "210315",
44
+ "ISA10": "0734",
45
+ "ISA11": "^",
46
+ "ISA12": "00501",
47
+ "ISA13": "111111111",
48
+ "ISA14": "0",
49
+ "ISA15": "P",
50
+ "ISA16": "|"
51
+ },
52
+ "GS": {
53
+ "GS01": "HB",
54
+ "GS02": "CMS",
55
+ "GS03": "SUBMITTERID",
56
+ "GS04": "20210315",
57
+ "GS05": "07340000",
58
+ "GS06": "1",
59
+ "GS07": "X",
60
+ "GS08": "005010X279A1"
61
+ },
62
+ "ST": {
63
+ "ST01": "271",
64
+ "ST02": "0001",
65
+ "ST03": "005010X279A1"
66
+ },
67
+ "BHT": {
68
+ "BHT01": "0022",
69
+ "BHT02": "11",
70
+ "BHT03": "TRANSA",
71
+ "BHT04": "20210315",
72
+ "BHT05": "07342355"
73
+ },
74
+ "2000A.HL": {
75
+ "HL01": "1",
76
+ "HL02": "",
77
+ "HL03": "20",
78
+ "HL04": "1"
79
+ },
80
+ "2000A.NM1": {
81
+ "NM101": "PR",
82
+ "NM102": "2",
83
+ "NM103": "CMS",
84
+ "NM104": "",
85
+ "NM105": "",
86
+ "NM106": "",
87
+ "NM107": "",
88
+ "NM108": "PI",
89
+ "NM109": "CMS"
90
+ },
91
+ "2000B.HL": {
92
+ "HL01": "2",
93
+ "HL02": "1",
94
+ "HL03": "21",
95
+ "HL04": "1"
96
+ },
97
+ "2000B.NM1": {
98
+ "NM101": "1P",
99
+ "NM102": "2",
100
+ "NM103": "IRNAME",
101
+ "NM104": "",
102
+ "NM105": "",
103
+ "NM106": "",
104
+ "NM107": "",
105
+ "NM108": "XX",
106
+ "NM109": "1234567893"
107
+ },
108
+ "2000C.HL": {
109
+ "HL01": "3",
110
+ "HL02": "2",
111
+ "HL03": "22",
112
+ "HL04": "0"
113
+ },
114
+ "2000C.TRN1": {
115
+ "TRN01": "2",
116
+ "TRN02": "TRACKNUM",
117
+ "TRN03": "ABCDEFGHIJ"
118
+ },
119
+ "2000C.NM1": {
120
+ "NM101": "IL",
121
+ "NM102": "1",
122
+ "NM103": "LNAME",
123
+ "NM104": "FNAME",
124
+ "NM105": "M",
125
+ "NM106": "",
126
+ "NM107": "",
127
+ "NM108": "MI",
128
+ "NM109": "1EG4TE5MK73"
129
+ },
130
+ "2000C.N3": {
131
+ "N301": "ADDRESSLINE1",
132
+ "N302": "ADDRESSLINE2"
133
+ },
134
+ "2000C.N4": {
135
+ "N401": "CITY",
136
+ "N402": "ST",
137
+ "N403": "ZIPCODE"
138
+ },
139
+ "2000C.DMG": {
140
+ "DMG01": "D8",
141
+ "DMG02": "19400401",
142
+ "DMG03": "F"
143
+ }
144
+ }
145
+ ```
146
+ That's about it.
147
+
148
+
149
+ ## Installation
150
+
151
+ Add this line to your application's Gemfile:
152
+
153
+ ```ruby
154
+ gem 'editrix'
155
+ ```
156
+
157
+ And then execute:
158
+
159
+ $ bundle install
160
+
161
+ Or install it yourself as:
162
+
163
+ $ gem install editrix
164
+
165
+ ## Usage
166
+ ```ruby
167
+ edi_variable = "--271 edi here--"
168
+ parser = Editrix::Parser.new(edi_variable)
169
+ parser.parse # method that parses the raw 271 edi
170
+ puts parser.result # prints parsed 271 edi in ruby hash
171
+
172
+ # This gem uses json libraries and therefore can generate pretty json files.
173
+ File.open("Parsed_edi.json","w") do |f|
174
+ f.write(parser.prettyResult)
175
+ end
176
+ ```
177
+
178
+ ## Development
179
+
180
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
181
+
182
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
183
+
184
+ ## Contributing
185
+
186
+ Bug reports and pull requests are welcome on GitHub at https://github.com/V4RM4/editrix. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/editrix/blob/master/CODE_OF_CONDUCT.md).
187
+
188
+ ## License
189
+
190
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
191
+
192
+ ## Code of Conduct
193
+
194
+ Everyone interacting in the Editrix project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/editrix/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "editrix"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/editrix-1.0.0.gem ADDED
Binary file
data/editrix-1.0.1.gem ADDED
Binary file
data/editrix-1.0.2.gem ADDED
Binary file
data/editrix-1.0.3.gem ADDED
Binary file
data/editrix-1.0.4.gem ADDED
Binary file
data/editrix.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/editrix/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "editrix"
7
+ spec.version = Editrix::VERSION
8
+ spec.authors = ["Vaisakh (V4RM4)"]
9
+
10
+ spec.summary = "Editrix is a gem for parsing Healthcare Eligibility Response (271) ASC X12 EDI data into painless formats like hash or a json."
11
+ spec.homepage = "https://github.com/V4RM4/editrix"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
14
+
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/V4RM4/editrix"
18
+ spec.metadata["changelog_uri"] = "https://github.com/V4RM4/editrix/blob/master/CHANGELOG.md"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ # Uncomment to register a new dependency of your gem
30
+ # spec.add_dependency "example-gem", "~> 1.0"
31
+
32
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Editrix
4
+ VERSION = "1.0.5"
5
+ end
data/lib/editrix.rb ADDED
@@ -0,0 +1,435 @@
1
+ require_relative "editrix/version"
2
+ require 'json'
3
+
4
+ module Editrix
5
+ class Error < StandardError; end
6
+
7
+ class Parser
8
+ def initialize(raw_271)
9
+ @raw_271 = raw_271
10
+ end
11
+
12
+ def parse
13
+ array_271 = @raw_271.split("~") # Traversal array for split 271 segments
14
+ @hash_271 = {} # Final hash for the entire decoded 271
15
+ l_count = 0 # Loop Segment counter
16
+ dtp_count = 0 # DTP segment counter
17
+ ref_count = 0 # REF segment counter
18
+ hsd_count = 0 # HSD segment counter
19
+ per_count = 0 # PER segment counter
20
+ aaa_count = 0 # AAA segment counter
21
+ msg_count = 0 # MSG segment counter
22
+ trn_count = 0 # TRN segment counter
23
+ loop_secondary_count = 0 # loop counter
24
+
25
+ loop_alpha = "@"
26
+ loop_num = 2000
27
+ ls_flag = false
28
+
29
+
30
+ array_271.each do |each| # Iterating through each 271 segment begins...
31
+
32
+ # Declaration of individual segment hashes
33
+ isa = {}
34
+ gs = {}
35
+ st = {}
36
+ bht = {}
37
+ hl = {}
38
+ trn = {}
39
+ nm1 = {}
40
+ n3 = {}
41
+ n4 = {}
42
+ dmg = {}
43
+ ins = {}
44
+ hi = {}
45
+ dtp = {}
46
+ mpi = {}
47
+ eb = {}
48
+ hsd = {}
49
+ ref = {}
50
+ per = {}
51
+ aaa = {}
52
+ prv = {}
53
+ msg = {}
54
+ iii = {}
55
+ ls = {}
56
+ le = {}
57
+ se = {}
58
+ ge = {}
59
+ iea = {}
60
+
61
+
62
+ # Hash for ISA - Interchange Control Header begins -----------------------------------------------------------------
63
+ if each.start_with?("ISA")
64
+ segment_values = each.split("*")
65
+ (1..segment_values.length-1).each do |i|
66
+ isa["ISA%02d" % i] = segment_values[i]
67
+ end
68
+ @hash_271["ISA"] = isa
69
+ # Hash for ISA - Interchange Control Header ends -------------------------------------------------------------------
70
+
71
+
72
+
73
+ # Hash for GS - Functional Group Header begins ---------------------------------------------------------------------
74
+ elsif each.start_with?("GS")
75
+ segment_values = each.split("*")
76
+ (1..segment_values.length-1).each do |i|
77
+ gs["GS%02d" % i] = segment_values[i]
78
+ end
79
+ @hash_271["GS"] = gs
80
+ # Hash for GS - Functional Group Header ends -----------------------------------------------------------------------
81
+
82
+
83
+
84
+ # Hash for ST - Transaction Set Header begins ----------------------------------------------------------------------
85
+ elsif each.start_with?("ST")
86
+ segment_values = each.split("*")
87
+ (1..segment_values.length-1).each do |i|
88
+ st["ST%02d" % i] = segment_values[i]
89
+ end
90
+ @hash_271["ST"] = st
91
+ # Hash for ST - Transaction Set Header ends ------------------------------------------------------------------------
92
+
93
+
94
+
95
+ # Hash for BHT - Beginning Of Hierarchical Transaction begins ------------------------------------------------------
96
+ elsif each.start_with?("BHT")
97
+ segment_values = each.split("*")
98
+ (1..segment_values.length-1).each do |i|
99
+ bht["BHT%02d" % i] = segment_values[i]
100
+ end
101
+ @hash_271["BHT"] = bht
102
+ # Hash for BHT - Beginning Of Hierarchical Transaction ends --------------------------------------------------------
103
+
104
+
105
+
106
+ # Hash for HL - Hierarchical Level begins --------------------------------------------------------------------------
107
+ elsif each.start_with?("HL")
108
+ loop_num = 2000
109
+ loop_alpha.next!
110
+ segment_values = each.split("*")
111
+ (1..segment_values.length-1).each do |i|
112
+ hl["HL%02d" % i] = segment_values[i]
113
+ end
114
+ @hash_271["#{loop_num.to_s+loop_alpha}.HL"] = hl
115
+ # Hash for HL - Hierarchical Level ends ----------------------------------------------------------------------------
116
+
117
+
118
+
119
+ # Hash for TRN - Trace begins --------------------------------------------------------------------------------------
120
+ elsif each.start_with?("TRN")
121
+ segment_values = each.split("*")
122
+ (1..segment_values.length-1).each do |i|
123
+ trn["TRN%02d" % i] = segment_values[i]
124
+ end
125
+ trn_count += 1
126
+ @hash_271["#{loop_num.to_s+loop_alpha}.TRN#{trn_count}"] = trn
127
+ # Hash for TRN - Trace ends ----------------------------------------------------------------------------------------
128
+
129
+
130
+
131
+ # Hash for NM1 - Individual or Organization Name begins ------------------------------------------------------------
132
+ elsif each.start_with?("NM1")
133
+ segment_values = each.split("*")
134
+ (1..segment_values.length-1).each do |i|
135
+ nm1["NM1%02d" % i] = segment_values[i]
136
+ end
137
+ loop_num = 2100
138
+ if ls_flag == true
139
+ @hash_271["#{loop_num.to_s+loop_alpha}.#{loop_secondary_count}.2120C#{l_count}.NM1"] = nm1
140
+ else
141
+ @hash_271["#{loop_num.to_s+loop_alpha}.NM1"] = nm1
142
+ end
143
+ # loop_secondary_count = 0
144
+ # Hash for NM1 - Individual or Organization Name ends --------------------------------------------------------------
145
+
146
+
147
+
148
+ # Hash for N3 - Party Location begins ------------------------------------------------------------------------------
149
+ elsif each.start_with?("N3")
150
+ segment_values = each.split("*")
151
+ (1..segment_values.length-1).each do |i|
152
+ n3["N3%02d" % i] = segment_values[i]
153
+ end
154
+ if ls_flag == true
155
+ @hash_271["#{loop_num.to_s+loop_alpha}.#{loop_secondary_count}.2120C#{l_count}.N3"] = n3
156
+ else
157
+ @hash_271["#{loop_num.to_s+loop_alpha}.N3"] = n3
158
+ end
159
+
160
+ # Hash for N3 - Party Location ends --------------------------------------------------------------------------------
161
+
162
+
163
+
164
+ # Hash for N4 - Geographic Location begins -------------------------------------------------------------------------
165
+ elsif each.start_with?("N4")
166
+ segment_values = each.split("*")
167
+ (1..segment_values.length-1).each do |i|
168
+ n4["N4%02d" % i] = segment_values[i]
169
+ end
170
+ if l_count != 0
171
+ @hash_271["#{loop_num.to_s+loop_alpha}.#{loop_secondary_count}.2120C#{l_count}.N4"] = n4
172
+ else
173
+ @hash_271["#{loop_num.to_s+loop_alpha}.N4"] = n4
174
+ end
175
+
176
+ # Hash for N4 - Geographic Location ends ---------------------------------------------------------------------------
177
+
178
+
179
+
180
+ # Hash for DMG - Demographic Information begins --------------------------------------------------------------------
181
+ elsif each.start_with?("DMG")
182
+ segment_values = each.split("*")
183
+ (1..segment_values.length-1).each do |i|
184
+ dmg["DMG%02d" % i] = segment_values[i]
185
+ end
186
+ @hash_271["#{loop_num.to_s+loop_alpha}.DMG"] = dmg
187
+ # Hash for DMG - Demographic Information ends ----------------------------------------------------------------------
188
+
189
+
190
+
191
+ # Hash for INS - Insured Benefit begins ----------------------------------------------------------------------------
192
+ elsif each.start_with?("INS")
193
+ segment_values = each.split("*")
194
+ (1..segment_values.length-1).each do |i|
195
+ ins["INS%02d" % i] = segment_values[i]
196
+ end
197
+ @hash_271["#{loop_num.to_s+loop_alpha}.INS"] = ins
198
+ # Hash for INS - Insured Benefit ends ------------------------------------------------------------------------------
199
+
200
+
201
+
202
+ # Hash for HI - Healthcare Information codes begin -----------------------------------------------------------------
203
+ elsif each.start_with?("HI")
204
+ segment_values = each.split("*")
205
+ (1..segment_values.length-1).each do |i|
206
+ hi["HI%02d" % i] = segment_values[i]
207
+ end
208
+ @hash_271["#{loop_num.to_s+loop_alpha}.HI"] = hi
209
+ # Hash for HI - Healthcare Information codes end -------------------------------------------------------------------
210
+
211
+
212
+
213
+ # Hash for DTP - Date or Time or Period begins ---------------------------------------------------------------------
214
+ elsif each.start_with?("DTP")
215
+ segment_values = each.split("*")
216
+ (1..segment_values.length-1).each do |i|
217
+ dtp["DTP%02d" % i] = segment_values[i]
218
+ end
219
+ dtp_count += 1
220
+ if loop_secondary_count != 0
221
+ @hash_271["#{loop_num.to_s+loop_alpha}.#{loop_secondary_count}.DTP#{dtp_count}"] = dtp
222
+ else
223
+ @hash_271["#{loop_num.to_s+loop_alpha}.DTP#{dtp_count}"] = dtp
224
+ end
225
+ # Hash for DTP - Date or Time or Period ends -----------------------------------------------------------------------
226
+
227
+
228
+
229
+ # Hash for MPI - Military Personnel Information begins -------------------------------------------------------------
230
+ elsif each.start_with?("MPI")
231
+ segment_values = each.split("*")
232
+ (1..segment_values.length-1).each do |i|
233
+ mpi["MPI%02d" % i] = segment_values[i]
234
+ end
235
+ @hash_271["#{loop_num.to_s+loop_alpha}.MPI"] = mpi
236
+ # Hash for MPI - Military Personnel Information ends ---------------------------------------------------------------
237
+
238
+
239
+
240
+ # Hash for EB - Eligibility or Benefit Information Begins ----------------------------------------------------------
241
+ elsif each.start_with?("EB")
242
+ segment_values = each.split("*")
243
+ (1..segment_values.length-1).each do |i|
244
+ eb["EB%02d" % i] = segment_values[i]
245
+ end
246
+ loop_num = 2110
247
+ loop_secondary_count += 1
248
+ @hash_271["#{loop_num.to_s+loop_alpha}.#{loop_secondary_count}.EB"] = eb
249
+
250
+ # Resetting counter variable for each eligibility loop
251
+ dtp_count = 0
252
+ hsd_count = 0
253
+ ref_count = 0
254
+ aaa_count = 0
255
+ msg_count = 0
256
+ per_count = 0
257
+ l_count = 0
258
+ # Hash for EB - Eligibility or Benefit Information ends ------------------------------------------------------------
259
+
260
+
261
+
262
+ # Hash for HSD - Healthcare Services Delivery begins ---------------------------------------------------------------
263
+ elsif each.start_with?("HSD")
264
+ segment_values = each.split("*")
265
+ (1..segment_values.length-1).each do |i|
266
+ hsd["HSD%02d" % i] = segment_values[i]
267
+ end
268
+ hsd_count += 1
269
+ @hash_271["#{loop_num.to_s+loop_alpha}.#{loop_secondary_count}.HSD#{hsd_count}"] = hsd
270
+ # Hash for HSD - Healthcare Services Delivery ends -----------------------------------------------------------------
271
+
272
+
273
+
274
+ # Hash for REF - Reference Information begins ----------------------------------------------------------------------
275
+ elsif each.start_with?("REF")
276
+ segment_values = each.split("*")
277
+ (1..segment_values.length-1).each do |i|
278
+ ref["REF%02d" % i] = segment_values[i]
279
+ end
280
+ ref_count += 1
281
+ if loop_secondary_count != 0
282
+ @hash_271["#{loop_num.to_s+loop_alpha}.#{loop_secondary_count}.REF#{ref_count}"] = ref
283
+ else
284
+ @hash_271["#{loop_num.to_s+loop_alpha}.REF#{ref_count}"] = ref
285
+ end
286
+ # Hash for REF - Reference Information ends ------------------------------------------------------------------------
287
+
288
+
289
+
290
+ # Hash for PER - Administrative Communications Contact begins ------------------------------------------------------
291
+ elsif each.start_with?("PER")
292
+ segment_values = each.split("*")
293
+ (1..segment_values.length-1).each do |i|
294
+ per["PER%02d" % i] = segment_values[i]
295
+ end
296
+ per_count += 1
297
+ if ls_flag == true
298
+ @hash_271["#{loop_num.to_s+loop_alpha}.#{loop_secondary_count}.2120C#{l_count}.PER#{per_count}"] = per
299
+ else
300
+ @hash_271["#{loop_num.to_s+loop_alpha}.PER#{per_count}"] = per
301
+ end
302
+ # Hash for PER - Administrative Communications Contact ends --------------------------------------------------------
303
+
304
+
305
+
306
+ # Hash for AAA - Request Validation begins -------------------------------------------------------------------------
307
+ elsif each.start_with?("AAA")
308
+ segment_values = each.split("*")
309
+ (1..segment_values.length-1).each do |i|
310
+ aaa["AAA%02d" % i] = segment_values[i]
311
+ end
312
+ aaa_count += 1
313
+ if loop_secondary_count != 0
314
+ @hash_271["#{loop_num.to_s+loop_alpha}.#{loop_secondary_count}.AAA#{aaa_count}"] = aaa
315
+ else
316
+ @hash_271["#{loop_num.to_s+loop_alpha}.AAA#{aaa_count}"] = aaa
317
+ end
318
+ # Hash for AAA - Request Validation ends ---------------------------------------------------------------------------
319
+
320
+
321
+ # Hash for PRV - Provider Information begins -----------------------------------------------------------------------
322
+ elsif each.start_with?("PRV")
323
+ segment_values = each.split("*")
324
+ (1..segment_values.length-1).each do |i|
325
+ prv["PRV%02d" % i] = segment_values[i]
326
+ end
327
+ if ls_flag == true
328
+ @hash_271["#{loop_num.to_s+loop_alpha}.#{loop_secondary_count}.2120C#{l_count}.PRV"] = prv
329
+ else
330
+ if loop_secondary_count != 0
331
+ @hash_271["#{loop_num.to_s+loop_alpha}.#{loop_secondary_count}.PRV"] = prv
332
+ else
333
+ @hash_271["#{loop_num.to_s+loop_alpha}.PRV"] = prv
334
+ end
335
+ end
336
+ # Hash for PRV - Provider Information ends -------------------------------------------------------------------------
337
+
338
+
339
+
340
+ # Hash for MSG - Message Text begins -------------------------------------------------------------------------------
341
+ elsif each.start_with?("MSG")
342
+ segment_values = each.split("*")
343
+ (1..segment_values.length-1).each do |i|
344
+ msg["MSG%02d" % i] = segment_values[i]
345
+ end
346
+ msg_count += 1
347
+ @hash_271["#{loop_num.to_s+loop_alpha}.#{loop_secondary_count}.MSG#{msg_count}"] = msg
348
+ # Hash for MSG - Message Text ends ---------------------------------------------------------------------------------
349
+
350
+
351
+
352
+ # Hash for III - Information begins --------------------------------------------------------------------------------
353
+ elsif each.start_with?("III")
354
+ segment_values = each.split("*")
355
+ (1..segment_values.length-1).each do |i|
356
+ iii["III%02d" % i] = segment_values[i]
357
+ end
358
+ if l_count != 0
359
+ @hash_271["#{loop_num.to_s+loop_alpha}.#{loop_secondary_count}.2115C.III#{l_count}"] = iii
360
+ else
361
+ @hash_271["#{loop_num.to_s+loop_alpha}.#{loop_secondary_count}.2115C.III"] = iii
362
+ end
363
+ # Hash for III - Information ends ----------------------------------------------------------------------------------
364
+
365
+
366
+
367
+ # Hash for LS - Loop Header begins ---------------------------------------------------------------------------------
368
+ elsif each.start_with?("LS")
369
+ segment_values = each.split("*")
370
+ (1..segment_values.length-1).each do |i|
371
+ ls["LS%02d" % i] = segment_values[i]
372
+ end
373
+ l_count += 1
374
+ @hash_271["#{loop_num.to_s+loop_alpha}.#{loop_secondary_count}.LS#{l_count}"] = ls
375
+ ls_flag = true
376
+ # Hash for LS - Loop Header ends -----------------------------------------------------------------------------------
377
+
378
+
379
+
380
+ # Hash for LE - Loop Trailer begins --------------------------------------------------------------------------------
381
+ elsif each.start_with?("LE")
382
+ segment_values = each.split("*")
383
+ (1..segment_values.length-1).each do |i|
384
+ le["LE%02d" % i] = segment_values[i]
385
+ end
386
+ @hash_271["#{loop_num.to_s+loop_alpha}.#{loop_secondary_count}.LE#{l_count}"] = le
387
+ ls_flag = false
388
+ # Hash for LE - Loop Trailer ends ----------------------------------------------------------------------------------
389
+
390
+
391
+
392
+ # Hash for SE - Transaction Set Trailer begins ---------------------------------------------------------------------
393
+ elsif each.start_with?("SE")
394
+ segment_values = each.split("*")
395
+ (1..segment_values.length-1).each do |i|
396
+ se["SE%02d" % i] = segment_values[i]
397
+ end
398
+ @hash_271["SE"] = se
399
+ # Hash for SE - Transaction Set Trailer ends -----------------------------------------------------------------------
400
+
401
+
402
+
403
+ # Hash for GE - Functional Group Trailer begins --------------------------------------------------------------------
404
+ elsif each.start_with?("GE")
405
+ segment_values = each.split("*")
406
+ (1..segment_values.length-1).each do |i|
407
+ ge["GE%02d" % i] = segment_values[i]
408
+ end
409
+ @hash_271["GE"] = ge
410
+ # Hash for GE - Functional Group Trailer ends ----------------------------------------------------------------------
411
+
412
+
413
+
414
+ # Hash for IEA - Interchange Control Trailer begins ----------------------------------------------------------------
415
+ elsif each.start_with?("IEA")
416
+ segment_values = each.split("*")
417
+ (1..segment_values.length-1).each do |i|
418
+ iea["IEA%02d" % i] = segment_values[i]
419
+ end
420
+ @hash_271["IEA"] = iea
421
+ # Hash for IEA - Interchange Control Trailer ends ------------------------------------------------------------------
422
+ end
423
+ end #---------------------------------------- Iterating through each 271 segment ends...
424
+ end
425
+
426
+ def result
427
+ @hash_271
428
+ end
429
+
430
+ def prettyResult
431
+ JSON.generate(@hash_271)
432
+ end
433
+ end #End of class
434
+
435
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: editrix
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.5
5
+ platform: ruby
6
+ authors:
7
+ - Vaisakh (V4RM4)
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-04-23 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".github/workflows/main.yml"
20
+ - ".gitignore"
21
+ - ".idea/.gitignore"
22
+ - ".idea/editrix.iml"
23
+ - ".idea/inspectionProfiles/Project_Default.xml"
24
+ - ".idea/modules.xml"
25
+ - ".idea/vcs.xml"
26
+ - ".rspec"
27
+ - ".rubocop.yml"
28
+ - CHANGELOG.md
29
+ - CODE_OF_CONDUCT.md
30
+ - Gemfile
31
+ - LICENSE.txt
32
+ - README.md
33
+ - Rakefile
34
+ - bin/console
35
+ - bin/setup
36
+ - editrix-1.0.0.gem
37
+ - editrix-1.0.1.gem
38
+ - editrix-1.0.2.gem
39
+ - editrix-1.0.3.gem
40
+ - editrix-1.0.4.gem
41
+ - editrix.gemspec
42
+ - lib/editrix.rb
43
+ - lib/editrix/version.rb
44
+ homepage: https://github.com/V4RM4/editrix
45
+ licenses:
46
+ - MIT
47
+ metadata:
48
+ homepage_uri: https://github.com/V4RM4/editrix
49
+ source_code_uri: https://github.com/V4RM4/editrix
50
+ changelog_uri: https://github.com/V4RM4/editrix/blob/master/CHANGELOG.md
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 2.4.0
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubygems_version: 3.1.4
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: Editrix is a gem for parsing Healthcare Eligibility Response (271) ASC X12
70
+ EDI data into painless formats like hash or a json.
71
+ test_files: []