ruby-hl7-extensions 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7c12e151a786d06b8370acd4f590a09bf48dffc6
4
+ data.tar.gz: e02137b255ceed2254c9f37012128308c47881b2
5
+ SHA512:
6
+ metadata.gz: e58d8bd28d3cd24c29cd7289fc63436e093e336577ee04cdcaf674758252b7d634cfb2df15cdc36df4f17bcf7cc8aca21a9f1b3373647c711a956094983cac64
7
+ data.tar.gz: fbec50bb1c8a0421218553dbf85bb468e5f9a94ed6ac2434ca7d0ee854e8f1fff95c80d8faa5e53c6307d69fbef4ae76f094917f5c162f504f4f9cee52568934
data/.gitignore ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem "rake", "~> 10.0.3"
4
+ gem 'rdoc'
5
+ gem 'rubyforge'
6
+ gem 'technicalpickles-jeweler'
7
+ gem 'ruby-hl7'
8
+
9
+ group :test, :development do
10
+ gem 'simplecov'
11
+ gem 'rspec', '~> 2.99.0'
12
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,47 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.2.5)
5
+ docile (1.1.5)
6
+ git (1.2.9.1)
7
+ json (1.8.3)
8
+ json_pure (1.8.3)
9
+ rake (10.0.4)
10
+ rdoc (4.2.1)
11
+ json (~> 1.4)
12
+ rspec (2.99.0)
13
+ rspec-core (~> 2.99.0)
14
+ rspec-expectations (~> 2.99.0)
15
+ rspec-mocks (~> 2.99.0)
16
+ rspec-core (2.99.2)
17
+ rspec-expectations (2.99.2)
18
+ diff-lcs (>= 1.1.3, < 2.0)
19
+ rspec-mocks (2.99.4)
20
+ ruby-hl7 (1.1.1)
21
+ rake (>= 10.0.0)
22
+ rubyforge (>= 2.0.4)
23
+ rubyforge (2.0.4)
24
+ json_pure (>= 1.1.7)
25
+ simplecov (0.11.1)
26
+ docile (~> 1.1.0)
27
+ json (~> 1.8)
28
+ simplecov-html (~> 0.10.0)
29
+ simplecov-html (0.10.0)
30
+ technicalpickles-jeweler (1.2.1)
31
+ git (>= 1.2.1)
32
+ rubyforge
33
+
34
+ PLATFORMS
35
+ ruby
36
+
37
+ DEPENDENCIES
38
+ rake (~> 10.0.3)
39
+ rdoc
40
+ rspec (~> 2.99.0)
41
+ ruby-hl7
42
+ rubyforge
43
+ simplecov
44
+ technicalpickles-jeweler
45
+
46
+ BUNDLED WITH
47
+ 1.10.6
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ = License
2
+ Permission is hereby granted, free of charge, to any person obtaining
3
+ a copy of this software and associated documentation files (the
4
+ "Software"), to deal in the Software without restriction, including
5
+ without limitation the rights to use, copy, modify, merge, publish,
6
+ distribute, sublicense, and/or sell copies of the Software, and to
7
+ permit persons to whom the Software is furnished to do so, subject to
8
+ the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be
11
+ included in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
17
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,79 @@
1
+ # $Id$
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require 'rdoc/task'
5
+ require 'rubygems/package_task'
6
+ require 'rake/contrib/sshpublisher'
7
+ require 'rbconfig'
8
+ require 'rubyforge'
9
+ require 'rspec'
10
+ require 'rspec/core/rake_task'
11
+ require 'simplecov'
12
+
13
+ $: << './lib'
14
+ require 'ruby-hl7-extensions'
15
+
16
+ full_name = "Ruby-HL7-Extensions"
17
+ short_name = full_name.downcase
18
+
19
+ # Many of these tasks were garnered from zenspider's Hoe
20
+ # just forced to work my way
21
+
22
+ desc 'Default: Run all examples'
23
+ task :default => :spec
24
+
25
+ spec = Gem::Specification.new do |s|
26
+ s.name = short_name
27
+ s.full_name
28
+ s.version = "0.0.1"
29
+ s.author = "Nick Lega"
30
+ s.email = "ruby-hl7@googlegroups.com"
31
+ s.homepage = "https://github.com/nmlynl/ruby-hl7-extensions"
32
+ s.platform = Gem::Platform::RUBY
33
+ s.summary = "Ruby HL7 Library w/Extensions"
34
+ s.rubyforge_project = short_name
35
+ s.description = "A simple library to parse and generate HL7 2.x messages and spit out json"
36
+ s.files = FileList["{bin,lib,test_data}/**/*"].to_a
37
+ s.require_path = "lib"
38
+ s.test_files = FileList["{test}/**/test*.rb"].to_a
39
+ s.has_rdoc = true
40
+ s.required_ruby_version = '>= 1.8.6'
41
+ s.extra_rdoc_files = %w[README.rdoc LICENSE]
42
+ s.add_dependency("rake", ">= #{RAKEVERSION}")
43
+ s.add_dependency("rubyforge", ">= #{::RubyForge::VERSION}")
44
+ end
45
+
46
+ desc "Run all examples"
47
+ RSpec::Core::RakeTask.new(:spec) do |spec|
48
+ spec.pattern = 'spec/**/*.rb'
49
+ end
50
+
51
+ desc "Run all examples with SimpleCov"
52
+ RSpec::Core::RakeTask.new(:spec_with_simplecov) do |spec|
53
+ ENV['COVERAGE'] = 'true'
54
+ spec.pattern = 'spec/**/*.rb'
55
+ end
56
+
57
+ RDoc::Task.new do |rd|
58
+ rd.main = "README.rdoc"
59
+ rd.rdoc_files.include("README.rdoc", "LICENSE", "lib/**/*.rb")
60
+ rd.title = "%s (%s) Documentation" % [ full_name, spec.version ]
61
+ rd.rdoc_dir = 'doc'
62
+ end
63
+
64
+ Gem::PackageTask.new(spec) do |pkg|
65
+ pkg.need_tar = true
66
+ end
67
+
68
+ desc 'Clean up all the extras'
69
+ task :clean => [ :clobber_rdoc, :clobber_package ] do
70
+ %w[*.gem ri coverage*].each do |pattern|
71
+ files = Dir[pattern]
72
+ rm_rf files unless files.empty?
73
+ end
74
+ end
75
+
76
+ desc 'Install the package as a gem'
77
+ task :install_gem => [:clean, :package] do
78
+ sh "sudo gem install pkg/*.gem"
79
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 0
4
+ :patch: 1
@@ -0,0 +1,104 @@
1
+ module Extensions
2
+ module HL7
3
+ module Message
4
+ attr_accessor :hash
5
+
6
+ def self.included base
7
+ base.send :include, InstanceMethods
8
+ base.extend ClassMethods
9
+ end
10
+
11
+ module InstanceMethods
12
+ def providers
13
+ providers = []
14
+
15
+ if self[:OBR]
16
+ obrs = self[:OBR].is_a?(Array) ? self[:OBR] : [self[:OBR]]
17
+ obrs.each do |obr|
18
+ providers << {hash: obr.ordering_provider_hash, segment: obr, provider_type: "OP"}
19
+ end
20
+ end
21
+
22
+ providers
23
+ end
24
+
25
+ def event
26
+ hash[:message][:content]["EVN"]
27
+ end
28
+
29
+ def patient_full_name
30
+ name = hash["message"]["content"]["PID"]["patientName"]
31
+ "#{name["lastName"]}, #{name["firstName"]}#{name["middleInitOrName"].blank? ? "" : " #{name["middleInitOrName"]}"}"
32
+ end
33
+
34
+ def patient_dob
35
+ Date.parse(hash["message"]["content"]["PID"]["dateTimeBirth"]).strftime("%B %d, %Y")
36
+ end
37
+
38
+ def patient_gender
39
+ hash["message"]["content"]["PID"]["sex"]
40
+ end
41
+
42
+ def obr_list
43
+ a = hash["message"]["content"]["OBR"]["array"].collect {|obr| ::HL7::Message::Segment.from_hash("OBR", obr)}
44
+ a.to_enum(:each)
45
+ end
46
+
47
+ def hash
48
+ to_hash
49
+ end
50
+
51
+ def to_hash
52
+ return @hash unless @hash.blank?
53
+ @hash ||= HashWithIndifferentAccess.new
54
+ @hash[:message] = {content: {}}
55
+
56
+ last_segment = nil
57
+ self.each do |segment|
58
+ segment_name = segment.segment_name
59
+ if segment_name == "OBR"
60
+ @hash[:message][:content][segment_name.to_sym] ||= {}
61
+ @hash[:message][:content][segment_name.to_sym]["array"] ||= []
62
+ @hash[:message][:content][segment_name.to_sym]["array"] << segment.to_hash
63
+
64
+ @hash[:message][:content][segment_name.to_sym]["array"]
65
+
66
+ last_segment = segment_name
67
+ elsif segment_name == "OBX"
68
+ if last_segment == "OBR"
69
+ @hash[:message][:content]["OBR"]["array"].last[segment_name] ||= {}
70
+ @hash[:message][:content]["OBR"]["array"].last[segment_name]["array"] ||= []
71
+ @hash[:message][:content]["OBR"]["array"].last[segment_name]["array"] << segment.to_hash
72
+ end
73
+ elsif segment_name == "NTE"
74
+ if last_segment == "OBR"
75
+ @hash[:message][:content]["OBR"]["array"].last["OBX"] ||= {}
76
+ @hash[:message][:content]["OBR"]["array"].last["OBX"]["array"] ||= []
77
+ @hash[:message][:content]["OBR"]["array"].last["OBX"]["array"].last["notes"] ||= [] if @hash[:message][:content]["OBR"]["array"].last["OBX"]["array"].length>0
78
+ @hash[:message][:content]["OBR"]["array"].last["OBX"]["array"].last["notes"] << segment.to_hash
79
+ end
80
+ else
81
+ @hash[:message][:content][segment_name.to_sym] = segment.to_hash
82
+ end
83
+ @hash[:message][:content]["EVN"] = @hash[:message][:content]["MSH"]["messageEvent"] if segment_name == "MSH"
84
+ end
85
+
86
+ @hash
87
+ end
88
+
89
+ def to_json
90
+ to_hash
91
+ @hash.to_json
92
+ end
93
+ end
94
+
95
+ module ClassMethods
96
+ end
97
+
98
+ end
99
+ end
100
+ end
101
+
102
+ class HL7::Message
103
+ include Extensions::HL7::Message
104
+ end
@@ -0,0 +1,53 @@
1
+ module Extensions
2
+ module HL7
3
+ module Segment
4
+ attr_accessor :hash
5
+
6
+ def self.included base
7
+ base.send :include, InstanceMethods
8
+ base.extend ClassMethods
9
+ end
10
+
11
+ module InstanceMethods
12
+
13
+ def segment_name
14
+ self.class.to_s.split("::").last
15
+ end
16
+
17
+ def to_hash
18
+ @hash ||= {}
19
+ fields = self.class.fields
20
+ if fields.is_a?Hash
21
+ self.class.fields.keys.each do |key|
22
+ @hash[key.to_s.camelize(:lower)] = self.handle_element(key)
23
+ end
24
+ end
25
+ @hash
26
+ end
27
+
28
+ def handle_element(key)
29
+ self.send(key)
30
+ end
31
+ end
32
+
33
+ module ClassMethods
34
+ def from_hash(type, hash)
35
+ clazz = eval("::HL7::Message::Segment::#{type}")
36
+ instance = clazz.new
37
+ instance.hash = hash
38
+
39
+ fields = clazz.fields
40
+ fields.keys.each do |field|
41
+ instance.send("#{field}=",hash[field.to_s.camelize(:lower)])
42
+ end
43
+ instance
44
+ end
45
+ end
46
+
47
+ end
48
+ end
49
+ end
50
+
51
+ class HL7::Message::Segment
52
+ include Extensions::HL7::Segment
53
+ end
@@ -0,0 +1,36 @@
1
+ module Extensions
2
+ module HL7
3
+ module Segments
4
+ module MSH
5
+
6
+ def self.included base
7
+ base.send :include, InstanceMethods
8
+ base.extend ClassMethods
9
+ end
10
+
11
+ module InstanceMethods
12
+ def to_hash
13
+ @hash = {"enc_chars" => self.enc_chars,
14
+ "seq" => self.seq,
15
+ "sendingApplication" => self.sending_app,
16
+ "sendingFacility" => self.sending_facility,
17
+ "receivingApplication" => self.recv_app,
18
+ "receivingFacility" => self.recv_facility,
19
+ "dateTime" => self.time,
20
+ "security" => self.security,
21
+ "messageType" => self.message_type.split("^").first,
22
+ "messageEvent" => self.message_type.split("^").last,
23
+ "messageControlId" => self.message_control_id,
24
+ "processingID" => self.processing_id,
25
+ "versionID" => self.version_id}
26
+ end
27
+ end
28
+
29
+ module ClassMethods
30
+ end
31
+
32
+ end
33
+ end
34
+ end
35
+ end
36
+
@@ -0,0 +1,23 @@
1
+ module Extensions
2
+ module HL7
3
+ module Segments
4
+ module NK1
5
+
6
+ def self.included base
7
+ base.send :include, InstanceMethods
8
+ base.extend ClassMethods
9
+ end
10
+
11
+ module InstanceMethods
12
+ def to_hash
13
+ @hash = {}
14
+ end
15
+ end
16
+
17
+ module ClassMethods
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ module Extensions
2
+ module HL7
3
+ module Segments
4
+ module NTE
5
+
6
+ def self.included base
7
+ base.send :include, InstanceMethods
8
+ base.extend ClassMethods
9
+ end
10
+
11
+ module InstanceMethods
12
+ def to_hash
13
+ @hash = {"setId" => self.set_id,
14
+ "source" => self.source,
15
+ "body" => self.comment}
16
+ end
17
+ end
18
+
19
+ module ClassMethods
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,132 @@
1
+ module Extensions
2
+ module HL7
3
+ module Segments
4
+ module OBR
5
+
6
+ def self.included base
7
+ base.send :include, InstanceMethods
8
+ base.extend ClassMethods
9
+ end
10
+
11
+ module InstanceMethods
12
+ def ordering_provider_hash
13
+ to_hash["orderingProvider"]
14
+ end
15
+
16
+ def ordering_provider_name
17
+ "#{@hash["orderingProvider"][0]["lastName"]}, #{@hash["orderingProvider"][0]["firstName"]}#{@hash["orderingProvider"][0]["middleInitOrName"].blank? ? "" : " #{@hash["orderingProvider"][0]["middleInitOrName"]}"}"
18
+ end
19
+
20
+ def obx_list
21
+ a = @hash["OBX"]["array"].collect {|obr| ::HL7::Message::Segment.from_hash("OBX", obr)}
22
+ a.to_enum(:each)
23
+ end
24
+
25
+ def to_hash
26
+ universalServiceId = self.universal_service_id.split("^") rescue Array.new(10) {|i|""}
27
+ collectionVolume = self.collection_volume.split("^") rescue Array.new(10) {|i|""}
28
+ orderingProvider = self.ordering_provider.split("^") rescue Array.new(20) {|i|""}
29
+ quantityTiming = self.quantity_timing.split("^") rescue Array.new(10) {|i|""}
30
+ resultCopiesTo = self.result_copies_to.split("^") rescue Array.new(10) {|i|""}
31
+ parent = self.parent.split("^") rescue Array.new(10) {|i|""}
32
+
33
+ @hash = {"setId" => self.set_id,
34
+ "placerOrderNumber" => self.placer_order_number,
35
+ "fillerOrderNumber" => self.filler_order_number,
36
+ "universalServiceId" => {"id" => universalServiceId[0],
37
+ "text" => universalServiceId[1],
38
+ "coddingSystem" => universalServiceId[2],
39
+ "alternateId" => universalServiceId[3],
40
+ "alternateText" => universalServiceId[4]},
41
+ "priority" => self.priority,
42
+ "requestedDateTime" => self.requested_date,
43
+ "observationDateTime" => self.observation_date,
44
+ "observationEndDate" => self.observation_end_date,
45
+ "collectionVolume" => {"quantity" => collectionVolume[0], "units" => collectionVolume[1]},
46
+ "collectorIdentifier" => self.collector_identifier,
47
+ "specimenActionCode" => self.specimen_action_code,
48
+ "dangerCode" => self.danger_code,
49
+ "relevantClinicalInfo" => self.relevant_clinical_info,
50
+ "specimenReceivedDateTime" => self.specimen_received_date,
51
+ "specimenSource" => self.specimen_source,
52
+ "orderingProvider" => [
53
+ {
54
+ "id" => orderingProvider[0],
55
+ "lastName" => orderingProvider[1],
56
+ "firstName" => orderingProvider[2],
57
+ "middleInitOrName" => orderingProvider[3],
58
+ "suffix" => orderingProvider[4],
59
+ "prefix" => orderingProvider[5],
60
+ "degree" => orderingProvider[6],
61
+ "sourceTable" => orderingProvider[7],
62
+ "assigningAuthority" => orderingProvider[8],
63
+ "nameTypeCode" => orderingProvider[9],
64
+ "identifierCheckDigit" => orderingProvider[10],
65
+ "checkDigitScheme" => orderingProvider[11],
66
+ "idTypeCode" => orderingProvider[12],
67
+ "isTypeCode" => orderingProvider[13],
68
+ "assigningFacility" => orderingProvider[14]
69
+ }
70
+ ],
71
+ "orderCallBackNumber" => self.order_callback_phone_number,
72
+ "placerField1" => self.placer_field_1,
73
+ "placerField2" => self.placer_field_2,
74
+ "fillerField1" => self.filler_field_1,
75
+ "fillerField2" => self.filler_field_2,
76
+ "rptStatusChangeDate" => self.results_status_change_date,
77
+ "chargeToPractice" => self.charge_to_practice,
78
+ "diagnosticServiceSectId" => self.diagnostic_serv_sect_id,
79
+ "resultStatus" => self.result_status,
80
+ "linkedResults" => self.parent_result,
81
+ "quantityTiming" => {
82
+ "quantity" => quantityTiming[0],
83
+ "interval" => quantityTiming[1],
84
+ "duration" => quantityTiming[2],
85
+ "startDateTime" => quantityTiming[3],
86
+ "endDateTime" => quantityTiming[4],
87
+ "priority" => quantityTiming[5]
88
+ },
89
+ "resultCopiesTo" => [
90
+ {
91
+ "id" => resultCopiesTo[0],
92
+ "lastName" => resultCopiesTo[1],
93
+ "firstName" => resultCopiesTo[2],
94
+ "middleInitOrName" => resultCopiesTo[3]
95
+ }
96
+ ],
97
+ "parent" => {
98
+ "placerOrderNumber" => parent[0],
99
+ "fillerOrderNumber" => parent[1]
100
+ },
101
+ "transportationMode" => self.transport_mode,
102
+ "reasonForStudy" => self.reason_for_study,
103
+ "principalResultInterpreter" => self.principal_result_interpreter,
104
+ "assistantResultInterpreter" => self.assistant_result_interpreter,
105
+ "technician" => self.technician,
106
+ "transcriptionist" => self.transcriptionist,
107
+ "scheduledDate" => self.scheduled_date,
108
+ "number_of_sample_containers" => self.number_of_sample_containers,
109
+ "transport_logistics_of_sample" => self.transport_logistics_of_sample,
110
+ "collectors_comment" => self.collectors_comment,
111
+ "transport_arrangement_responsibility" => self.transport_arrangement_responsibility,
112
+ "transport_arranged" => self.transport_arranged,
113
+ "escort_required" => self.escort_required,
114
+ "planned_patient_transport_comment" => self.planned_patient_transport_comment,
115
+ "procedure_code" => self.procedure_code,
116
+ "procedure_code_modifier" => self.procedure_code_modifier,
117
+ "placer_supplemental_service_info" => self.placer_supplemental_service_info,
118
+ "filler_supplemental_service_info" => self.filler_supplemental_service_info,
119
+ "medically_necessary_dup_procedure_reason" => self.medically_necessary_dup_procedure_reason,
120
+ "result_handling" => self.result_handling,
121
+ "parent_universal_service_identifier" => self.parent_universal_service_identifier}
122
+
123
+ end
124
+ end
125
+
126
+ module ClassMethods
127
+ end
128
+
129
+ end
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,61 @@
1
+ module Extensions
2
+ module HL7
3
+ module Segments
4
+ module OBX
5
+
6
+ def self.included base
7
+ base.send :include, InstanceMethods
8
+ base.extend ClassMethods
9
+ end
10
+
11
+ module InstanceMethods
12
+ def test_name
13
+ @hash["identifier"]["text"]
14
+ end
15
+
16
+ def to_hash
17
+ identifier = self.observation_id.split("^") rescue Array.new(10) {|i|""}
18
+ producer = self.producer_id.split("^") rescue Array.new(10) {|i|""}
19
+ responsibleObserver = self.responsible_observer rescue Array.new(10) {|i|""}
20
+ @hash = {"setId" => self.set_id,
21
+ "valueType" => self.value_type,
22
+ "identifier" => {
23
+ "id" => identifier[0],
24
+ "text" => identifier[1],
25
+ "codingSystem" => identifier[2],
26
+ "alternateId" => identifier[3],
27
+ "alternateText" => identifier[4],
28
+ "alternateCodingSystem" => identifier[5]
29
+ },
30
+ "subId" => self.observation_sub_id,
31
+ "observationValue" => self.observation_value,
32
+ "units" => self.units,
33
+ "referenceRange" => self.references_range,
34
+ "abnormalFlags" => self.abnormal_flags,
35
+ "probability" => self.probability,
36
+ "natureOfAbnormal" => self.nature_of_abnormal_test,
37
+ "observeResultStatus" => self.observation_result_status,
38
+ "effectiveDateLastNormalValue" => self.effective_date_of_reference_range,
39
+ "definedAccessChecks" => self.user_defined_access_checks,
40
+ "observationDate" => self.observation_date,
41
+ "producerId" => {
42
+ "identifier" => producer[0],
43
+ "text" => producer[1]
44
+ },
45
+ "responsibleObserver" => {
46
+ "id" => responsibleObserver[0],
47
+ "lastName" => responsibleObserver[1],
48
+ "firstName" => responsibleObserver[2]
49
+ },
50
+ "method" => self.observation_method}
51
+ end
52
+ end
53
+
54
+ module ClassMethods
55
+
56
+ end
57
+
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,56 @@
1
+ module Extensions
2
+ module HL7
3
+ module Segments
4
+ module PID
5
+
6
+ def self.included base
7
+ base.send :include, InstanceMethods
8
+ base.extend ClassMethods
9
+ end
10
+
11
+ module InstanceMethods
12
+ def to_hash
13
+ patient_name = self.patient_name.split("^") rescue Array.new(10) {|i| "" }
14
+ address = self.address.split("^") rescue Array.new(10) {|i| "" }
15
+ patientAccountNumber = self.account_number.split("^") rescue Array.new(10) {|i| "" }
16
+
17
+ @hash = {"setId" => self.set_id,
18
+ "externalId" => self.patient_id,
19
+ "internalId" => {"id" => self.patient_id_list, "type"=>""},
20
+ "alternateId" => self.alt_patient_id,
21
+ "patientName" => {"lastName" => patient_name[0], "firstName" => patient_name[1], "middleInitOrName"=> patient_name[2]},
22
+ "mothersMaidenName" => self.mother_maiden_name,
23
+ "dateTimeBirth" => self.patient_dob,
24
+ "sex" => self.admin_sex,
25
+ "alias" => self.patient_alias,
26
+ "race" => self.race,
27
+ "address"=>{"streetAddress"=>address[0], "otherDesignation"=>address[1], "city"=>address[2], "state"=>address[3], "postalCode"=>address[4], "country"=>address[5], "addressType"=>address[6]},
28
+ "countyCode"=> self.country_code,
29
+ "phoneNumbers"=>{"home"=>self.phone_home, "business"=>self.phone_business},
30
+ "homePhone"=>{"number" => "","useCode" => "", "equipmentType" => "", "email" => "", "countryCode" => "", "areaCode" => "", "phoneNumber" => ""},
31
+ "primaryLanguage"=>self.primary_language,
32
+ "maritalStatus"=>self.marital_status,
33
+ "religion"=>self.religion,
34
+ "patientAccountNumber"=>{"id"=>patientAccountNumber[0], "checkDigit"=>patientAccountNumber[1], "codeIdCheck"=>patientAccountNumber[2], "assigningAuth"=>patientAccountNumber[3], "idTypeCode"=>patientAccountNumber[4], "assigningFacility"=>patientAccountNumber[5]},
35
+ "ssn"=>self.social_security_num,
36
+ "driversLicenseNumber"=>self.driver_license_num,
37
+ "mothersId"=>self.mothers_id,
38
+ "ethnicGroup"=>self.ethnic_group,
39
+ "birthPlace"=>self.birthplace,
40
+ "multipleBirthIndicator"=>self.multi_birth,
41
+ "birthOrder"=>self.birth_order,
42
+ "citizenship"=>self.citizenship,
43
+ "veteranStatus"=>self.vet_status,
44
+ "nationality"=>self.nationality,
45
+ "deathDateTime"=>self.death_date,
46
+ "deathIndicator"=>self.death_indicator}
47
+ end
48
+ end
49
+
50
+ module ClassMethods
51
+ end
52
+
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,15 @@
1
+ require 'core_ext/segments/msh'
2
+ require 'core_ext/segments/pid'
3
+ require 'core_ext/segments/obr'
4
+ require 'core_ext/segments/obx'
5
+ require 'core_ext/segments/nte'
6
+ require 'core_ext/segments/nk1'
7
+
8
+ segments = ["MSH","PID","OBR","OBX","NTE","NK1"]
9
+ segments.each do |segment_name|
10
+
11
+ eval("class HL7::Message::Segment::#{segment_name} < HL7::Message::Segment
12
+ include Extensions::HL7::Segments::#{segment_name}
13
+ end")
14
+
15
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: UTF-8
2
+ #= ruby-hl7-json.rb
3
+ # Ruby HL7 is designed to provide a simple, easy to use library for
4
+ # parsing and generating HL7 (2.x) messages.
5
+ #
6
+ #
7
+ # Author: Mark Guzman (mailto:segfault@hasno.info)
8
+ #
9
+ # Copyright: (c) 2006-2009 Mark Guzman
10
+ #
11
+ # License: BSD
12
+ #
13
+ # $Id$
14
+ #
15
+ # == License
16
+ # see the LICENSE file
17
+ #
18
+
19
+ require 'ruby-hl7'
20
+ require 'core_ext/message'
21
+ require 'core_ext/segment'
22
+ require 'core_ext/segments/segments'
@@ -0,0 +1,40 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # stub: ruby-hl7-extensions 1.1.1 ruby lib
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "ruby-hl7-extensions"
6
+ s.version = "0.0.1"
7
+
8
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
+ s.require_paths = ["lib"]
10
+ s.authors = ["Nick Lega"]
11
+ s.date = "2014-09-09"
12
+ s.description = "A simple library to parse and generate HL7 2.x json"
13
+ s.email = "ruby-hl7-json@googlegroups.com"
14
+ s.extra_rdoc_files = ["LICENSE", "README.md"]
15
+ s.files = [".gitignore", "Gemfile", "Gemfile.lock", "LICENSE", "README.md", "Rakefile", "VERSION", "VERSION.yml",
16
+ "lib/core_ext/message.rb", "lib/core_ext/segment.rb",
17
+ "lib/core_ext/segments/msh.rb", "lib/core_ext/segments/nk1.rb", "lib/core_ext/segments/nte.rb", "lib/core_ext/segments/obr.rb", "lib/core_ext/segments/obx.rb", "lib/core_ext/segments/pid.rb", "lib/core_ext/segments/segments.rb",
18
+ "lib/ruby-hl7-extensions.rb", "ruby-hl7-extensions.gemspec"]
19
+ s.homepage = "http://github.com/nmlynl/ruby-hl7-extensions"
20
+ s.rdoc_options = ["--charset=UTF-8"]
21
+ s.required_ruby_version = Gem::Requirement.new(">= 1.8.6")
22
+ s.rubyforge_project = "ruby-hl7-extensions"
23
+ s.rubygems_version = "2.4.5"
24
+ s.summary = "Ruby HL7 Library w/Extensions"
25
+
26
+ if s.respond_to? :specification_version then
27
+ s.specification_version = 3
28
+
29
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
30
+ s.add_runtime_dependency(%q<rake>, [">= 10.0.0"])
31
+ s.add_runtime_dependency(%q<rubyforge>, [">= 2.0.4"])
32
+ else
33
+ s.add_dependency(%q<rake>, [">= 10.0.0"])
34
+ s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
35
+ end
36
+ else
37
+ s.add_dependency(%q<rake>, [">= 10.0.0"])
38
+ s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
39
+ end
40
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-hl7-extensions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nick Lega
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 10.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 10.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubyforge
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.4
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.4
41
+ description: A simple library to parse and generate HL7 2.x json
42
+ email: ruby-hl7-json@googlegroups.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files:
46
+ - LICENSE
47
+ - README.md
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE
53
+ - README.md
54
+ - Rakefile
55
+ - VERSION
56
+ - VERSION.yml
57
+ - lib/core_ext/message.rb
58
+ - lib/core_ext/segment.rb
59
+ - lib/core_ext/segments/msh.rb
60
+ - lib/core_ext/segments/nk1.rb
61
+ - lib/core_ext/segments/nte.rb
62
+ - lib/core_ext/segments/obr.rb
63
+ - lib/core_ext/segments/obx.rb
64
+ - lib/core_ext/segments/pid.rb
65
+ - lib/core_ext/segments/segments.rb
66
+ - lib/ruby-hl7-extensions.rb
67
+ - ruby-hl7-extensions.gemspec
68
+ homepage: http://github.com/nmlynl/ruby-hl7-extensions
69
+ licenses: []
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options:
73
+ - "--charset=UTF-8"
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 1.8.6
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project: ruby-hl7-extensions
88
+ rubygems_version: 2.5.0
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: Ruby HL7 Library w/Extensions
92
+ test_files: []
93
+ has_rdoc: