simple_hl7_parser 1.0.0 → 1.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e5f0cc54bb86dd2a890752e9a0219b9cb9284f4
4
- data.tar.gz: e55a21329ccf060d502a8749df1d5e751c946769
3
+ metadata.gz: b26dec750f7b5252b1f4e68a88f7c0f586b219d7
4
+ data.tar.gz: 8a74f31a6bb6f4218190244968b0a1dba4184ec5
5
5
  SHA512:
6
- metadata.gz: 7540f72fbe66a330fdafcb0ab40c43683f33c061e6c640a2f68b6f91f88db4b18291c7cd946ac46e118b068121a5a69d182f6ab3a874b91f3490d89992b552d2
7
- data.tar.gz: 0d17444d62193ab12939ca95e60c87d4276cc8784cba180cca35370375c4f252334f68474c7f4dba394cd1e9b7419b949721e2671b2f5dede7380e6477c5d08d
6
+ metadata.gz: 1663363f3e54dcb62f8eea9697ca5c82c798c159eacc5fb733b0dca0782269c83708b563df2e35eee7ad54875dca93c02899d74230a4af23f4723c77d1d1a6e1
7
+ data.tar.gz: e01c04a69770da3edabc71197751f4f0a3f57c67be61a97d9385b9c83d7d7ad7aa269a6f230e8e56a681cb66fb9cec68187669b43e5253b30c6f1d41cc0248ce
data/README.md CHANGED
@@ -38,16 +38,53 @@ msg.obx.first.observation_value #=> "^182"
38
38
  msg.obx.first.units #=> "mg/dl"
39
39
  ```
40
40
 
41
- ## Development
41
+ ## Contributing
42
42
 
43
- 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.
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sufyanadam/simple_hl7_parser. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
44
44
 
45
- 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
45
+ ### Adding support for a HL7 Segment
46
46
 
47
- ## Contributing
47
+ Just create a class under the `SimpleHL7Parser` module namespace called
48
+ `XXXSegment` (where `XXX` is a segment name, such as `PID`), include the
49
+ `Segment` module and define a column map. That's it! It's that simple; hence
50
+ the name `SimpleHL7Parser`.
48
51
 
49
- Bug reports and pull requests are welcome on GitHub at https://github.com/sufyanadam/simple_hl7_parser. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
52
+ The column map is a map of `segment_attribute => position_number`. For example,
53
+ the `placer_order_number` is the third element in the `OBR` segment. So the
54
+ column map would define `{placer_order_number: 2}`. The `segment_attribute`
55
+ part of the column map becomes the name of the function you can call to
56
+ retrieve the value of the attribute at the position it maps to.
57
+
58
+ The example below demonstrates how `SimpleHL7Parser` currently
59
+ supports parsing the `OBR` HL7 segment in Ruby:
60
+
61
+ Example:
62
+
63
+ ```ruby
64
+ # Extending SimpleHL7Parser to support another
65
+ # HL7 Segment
66
+ require 'simple_hl7_parser/segments/segment'
67
+
68
+ module SimpleHL7Parser
69
+ class OBRSegment
70
+ include Segment
71
+
72
+ COLUMN_MAP = {
73
+ set_id: 1,
74
+ placer_order_number: 2,
75
+ filler_order_number: 3,
76
+ universal_service_id: 4,
77
+ priority: 5,
78
+ requested_date_time: 6,
79
+ observation_date_time: 7,
80
+ observation_end_date_time: 8,
81
+ }
82
+ end
83
+ end
84
+ ```
50
85
 
86
+ After adding support for a new segment, add a test that demonstrates
87
+ it works correctly and make a pull request :)
51
88
 
52
89
  ## License
53
90
 
@@ -1,5 +1,9 @@
1
- require_relative 'hl7_message'
2
- require_relative 'segment'
1
+ require 'simple_hl7_parser/hl7_message'
2
+ require 'simple_hl7_parser/segments/msh_segment'
3
+ require 'simple_hl7_parser/segments/pid_segment'
4
+ require 'simple_hl7_parser/segments/orc_segment'
5
+ require 'simple_hl7_parser/segments/obr_segment'
6
+ require 'simple_hl7_parser/segments/obx_segment'
3
7
 
4
8
  module SimpleHL7Parser
5
9
  class HL7
@@ -0,0 +1,29 @@
1
+ require 'simple_hl7_parser/segments/segment'
2
+
3
+ module SimpleHL7Parser
4
+ class MSHSegment
5
+ include Segment
6
+
7
+ COLUMN_MAP = {
8
+ field_separator: 1,
9
+ sending_application: 2,
10
+ sending_facility: 3,
11
+ receiving_application: 4,
12
+ receiving_facility: 5,
13
+ date_time_of_message: 6,
14
+ security: 7,
15
+ message_type: 8,
16
+ message_control_id: 9,
17
+ processing_id: 10,
18
+ version_id: 11,
19
+ sequence_number: 12,
20
+ continuation_pointer: 13,
21
+ accept_acknowledgment_type: 14,
22
+ application_acknowledgment_type: 15,
23
+ country_code: 16,
24
+ character_set: 17,
25
+ principal_language_of_message: 18,
26
+ alternate_character_set_handling_Scheme: 19,
27
+ }
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ require 'simple_hl7_parser/segments/segment'
2
+
3
+ module SimpleHL7Parser
4
+ class OBRSegment
5
+ include Segment
6
+
7
+ COLUMN_MAP = {
8
+ set_id: 1,
9
+ placer_order_number: 2,
10
+ filler_order_number: 3,
11
+ universal_service_id: 4,
12
+ priority: 5,
13
+ requested_date_time: 6,
14
+ observation_date_time: 7,
15
+ observation_end_date_time: 8,
16
+ }
17
+ end
18
+ end
@@ -0,0 +1,27 @@
1
+ require 'simple_hl7_parser/segments/segment'
2
+
3
+ module SimpleHL7Parser
4
+ class OBXSegment
5
+ include Segment
6
+
7
+ COLUMN_MAP = {
8
+ set_id: 1,
9
+ value_type: 2,
10
+ observation_identifier: 3,
11
+ observation_sub_id: 4,
12
+ observation_value: 5,
13
+ units: 6,
14
+ references_range: 7,
15
+ abnormal_flags: 8,
16
+ probability: 9,
17
+ nature_of_abnormal_test: 10,
18
+ observation_result_status: 11,
19
+ date_last_obs_normal_values: 12,
20
+ user_defined_access_checks: 13,
21
+ date_time_of_the_observation: 14,
22
+ producer_id: 15,
23
+ responsible_observer: 16,
24
+ observation_method: 17,
25
+ }
26
+ end
27
+ end
@@ -0,0 +1,34 @@
1
+ require 'simple_hl7_parser/segments/segment'
2
+
3
+ module SimpleHL7Parser
4
+ class ORCSegment
5
+ include Segment
6
+
7
+ COLUMN_MAP = {
8
+ order_control: 1,
9
+ placer_order_number: 2,
10
+ filler_order_number: 3,
11
+ placer_group_number: 4,
12
+ order_status: 5,
13
+ response_flag: 6,
14
+ quantity_timing: 7,
15
+ parent_order: 8,
16
+ date_time_of_transaction: 9,
17
+ entered_by: 10,
18
+ verified_by: 11,
19
+ ordering_provider: 12,
20
+ enterer_s_location: 13,
21
+ call_back_phone_number: 14,
22
+ order_effective_date_time: 15,
23
+ order_control_code_reason: 16,
24
+ entering_organization: 17,
25
+ entering_device: 18,
26
+ action_by: 19,
27
+ advanced_beneficiary_notice_code: 20,
28
+ ordering_facility_name: 21,
29
+ ordering_facility_address: 22,
30
+ ordering_facility_phone_number: 23,
31
+ ordering_provider_address: 24,
32
+ }
33
+ end
34
+ end
@@ -0,0 +1,39 @@
1
+ require 'simple_hl7_parser/segments/segment'
2
+
3
+ module SimpleHL7Parser
4
+ class PIDSegment
5
+ include Segment
6
+
7
+ COLUMN_MAP = {
8
+ patient_id: 2,
9
+ patient_identifier_list: 3,
10
+ alternae_patient_id: 4,
11
+ patientname: 5,
12
+ mother_maiden_name: 6,
13
+ date_of_birth: 7,
14
+ sex: 8,
15
+ patientalias: 9,
16
+ race: 10,
17
+ patient_address: 11,
18
+ county_ode: 12,
19
+ phone_nmber_home: 13,
20
+ phone_nmber_business: 14,
21
+ primary_language: 15,
22
+ marital_status: 16,
23
+ religion: 17,
24
+ patient_account_number: 18,
25
+ ssn_numer_patient: 19,
26
+ driver_license_number_patient: 20,
27
+ mothers_identifier: 21,
28
+ ethnic_roup: 22,
29
+ birth_pace: 23,
30
+ multiple_birth_indicator: 24,
31
+ birth_oder: 25,
32
+ citizenhip: 26,
33
+ veteran_military_status: 27,
34
+ nationaity: 28,
35
+ patient_death_date_and_time: 29,
36
+ patient_death_indicator: 30,
37
+ }
38
+ end
39
+ end
@@ -0,0 +1,31 @@
1
+ module SimpleHL7Parser
2
+ module Segment
3
+ attr_reader :segment_array, :obr
4
+
5
+ def initialize(segment_array, obr = nil)
6
+ @segment_array = segment_array
7
+ @obr = obr
8
+ end
9
+
10
+ def segment_type
11
+ segment_array.first
12
+ end
13
+
14
+ def method_missing(symbol, *args, &block)
15
+ if symbol.to_s.include?('?')
16
+ return "#{segment_type}?".to_sym == symbol.upcase
17
+ end
18
+
19
+ if self.class::COLUMN_MAP[symbol]
20
+ segment_array[self.class::COLUMN_MAP[symbol]]
21
+ else
22
+ super
23
+ end
24
+ end
25
+
26
+ def respond_to_missing?(symbol, include_private = false)
27
+ "#{segment_type}?".to_sym == symbol.upcase? ||
28
+ segment_array[self.class::COLUMN_MAP[symbol]] || super
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module SimpleHL7Parser
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_hl7_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sufyan Adam
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-15 00:00:00.000000000 Z
11
+ date: 2017-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,7 +73,12 @@ files:
73
73
  - lib/simple_hl7_parser.rb
74
74
  - lib/simple_hl7_parser/hl7.rb
75
75
  - lib/simple_hl7_parser/hl7_message.rb
76
- - lib/simple_hl7_parser/segment.rb
76
+ - lib/simple_hl7_parser/segments/msh_segment.rb
77
+ - lib/simple_hl7_parser/segments/obr_segment.rb
78
+ - lib/simple_hl7_parser/segments/obx_segment.rb
79
+ - lib/simple_hl7_parser/segments/orc_segment.rb
80
+ - lib/simple_hl7_parser/segments/pid_segment.rb
81
+ - lib/simple_hl7_parser/segments/segment.rb
77
82
  - lib/simple_hl7_parser/version.rb
78
83
  - simple_hl7_parser.gemspec
79
84
  homepage: https://github.com/sufyanadam/simple_hl7_parser
@@ -1,163 +0,0 @@
1
- module SimpleHL7Parser
2
- module Segment
3
- attr_reader :segment_array, :obr
4
-
5
- def initialize(segment_array, obr = nil)
6
- @segment_array = segment_array
7
- @obr = obr
8
- end
9
-
10
- def segment_type
11
- segment_array.first
12
- end
13
-
14
- def method_missing(symbol, *args, &block)
15
- if symbol.to_s.include?('?')
16
- return "#{segment_type}?".to_sym == symbol.upcase
17
- end
18
-
19
- if self.class::COLUMN_MAP[symbol]
20
- segment_array[self.class::COLUMN_MAP[symbol]]
21
- else
22
- super
23
- end
24
- end
25
-
26
- def respond_to_missing?(symbol, include_private = false)
27
- "#{segment_type}?".to_sym == symbol.upcase? ||
28
- segment_array[self.class::COLUMN_MAP[symbol]] || super
29
- end
30
- end
31
-
32
- class MSHSegment
33
- include Segment
34
-
35
- COLUMN_MAP = {
36
- field_separator: 1,
37
- sending_application: 2,
38
- sending_facility: 3,
39
- receiving_application: 4,
40
- receiving_facility: 5,
41
- date_time_of_message: 6,
42
- security: 7,
43
- message_type: 8,
44
- message_control_id: 9,
45
- processing_id: 10,
46
- version_id: 11,
47
- sequence_number: 12,
48
- continuation_pointer: 13,
49
- accept_acknowledgment_type: 14,
50
- application_acknowledgment_type: 15,
51
- country_code: 16,
52
- character_set: 17,
53
- principal_language_of_message: 18,
54
- alternate_character_set_handling_Scheme: 19,
55
- }
56
- end
57
-
58
- class PIDSegment
59
- include Segment
60
-
61
- COLUMN_MAP = {
62
- patient_id: 2,
63
- patient_identifier_list: 3,
64
- alternae_patient_id: 4,
65
- patientname: 5,
66
- mother_maiden_name: 6,
67
- date_of_birth: 7,
68
- sex: 8,
69
- patientalias: 9,
70
- race: 10,
71
- patient_address: 11,
72
- county_ode: 12,
73
- phone_nmber_home: 13,
74
- phone_nmber_business: 14,
75
- primary_language: 15,
76
- marital_status: 16,
77
- religion: 17,
78
- patient_account_number: 18,
79
- ssn_numer_patient: 19,
80
- driver_license_number_patient: 20,
81
- mothers_identifier: 21,
82
- ethnic_roup: 22,
83
- birth_pace: 23,
84
- multiple_birth_indicator: 24,
85
- birth_oder: 25,
86
- citizenhip: 26,
87
- veteran_military_status: 27,
88
- nationaity: 28,
89
- patient_death_date_and_time: 29,
90
- patient_death_indicator: 30,
91
- }
92
- end
93
-
94
- class ORCSegment
95
- include Segment
96
-
97
- COLUMN_MAP = {
98
- order_control: 1,
99
- placer_order_number: 2,
100
- filler_order_number: 3,
101
- placer_group_number: 4,
102
- order_status: 5,
103
- response_flag: 6,
104
- quantity_timing: 7,
105
- parent_order: 8,
106
- date_time_of_transaction: 9,
107
- entered_by: 10,
108
- verified_by: 11,
109
- ordering_provider: 12,
110
- enterer_s_location: 13,
111
- call_back_phone_number: 14,
112
- order_effective_date_time: 15,
113
- order_control_code_reason: 16,
114
- entering_organization: 17,
115
- entering_device: 18,
116
- action_by: 19,
117
- advanced_beneficiary_notice_code: 20,
118
- ordering_facility_name: 21,
119
- ordering_facility_address: 22,
120
- ordering_facility_phone_number: 23,
121
- ordering_provider_address: 24,
122
- }
123
- end
124
-
125
- class OBRSegment
126
- include Segment
127
-
128
- COLUMN_MAP = {
129
- set_id: 1,
130
- placer_order_number: 2,
131
- filler_order_number: 3,
132
- universal_service_id: 4,
133
- priority: 5,
134
- requested_date_time: 6,
135
- observation_date_time: 7,
136
- observation_end_date_time: 8,
137
- }
138
- end
139
-
140
- class OBXSegment
141
- include Segment
142
-
143
- COLUMN_MAP = {
144
- set_id: 1,
145
- value_type: 2,
146
- observation_identifier: 3,
147
- observation_sub_id: 4,
148
- observation_value: 5,
149
- units: 6,
150
- references_range: 7,
151
- abnormal_flags: 8,
152
- probability: 9,
153
- nature_of_abnormal_test: 10,
154
- observation_result_status: 11,
155
- date_last_obs_normal_values: 12,
156
- user_defined_access_checks: 13,
157
- date_time_of_the_observation: 14,
158
- producer_id: 15,
159
- responsible_observer: 16,
160
- observation_method: 17,
161
- }
162
- end
163
- end