simple_hl7 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/lib/simple_hl7/message.rb +16 -0
- data/lib/simple_hl7/version.rb +1 -1
- data/spec/simple_hl7/message_spec.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e291e509c760825660168925c73d836d2b4e89d
|
4
|
+
data.tar.gz: 4194eecae65086ea5da340005219591f50e4d7fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d367c7d9e314ec2132ab857b9b97572cce0a2582f2e3d777653e0821e47258f2e43daafa147fbcf64df770312f9c51d50464e54911895f328b6dfa8d1a177b1
|
7
|
+
data.tar.gz: 6635f70ab97148cfda2e6df6d33550a9203c97fb4dcd41df9e228eb9038f16d5078cc6c79177b10ae172a98ec9650d4d3518da94f248514ebe6a42462afda2b6
|
data/README.md
CHANGED
@@ -211,6 +211,17 @@ hl7_str = "MSH|^~\\&|||||||ADT^A04|12345678|D|2.5\r\nPID|||454545||Doe^John"
|
|
211
211
|
msg = SimpleHL7::Message.parse(hl7_str, segment_separator: "\r\n")
|
212
212
|
```
|
213
213
|
|
214
|
+
### Parsing LLP messages
|
215
|
+
|
216
|
+
In case you are parsing HL7 messages received over TCP/IP using the LLP protocol, use the `parse_llp` method
|
217
|
+
|
218
|
+
```ruby
|
219
|
+
llp_str = "\x0bMSH|^~\\&|||||||ADT^A04|12345678|D|2.5\rPID|||454545||Doe^John\x1c\r"
|
220
|
+
msg = SimpleHL7::Message.parse_llp(llp_str)
|
221
|
+
```
|
222
|
+
|
223
|
+
Once the message is parsed you can follow the same methods pointed above to pull out values
|
224
|
+
|
214
225
|
## Contributing
|
215
226
|
|
216
227
|
1. Fork it
|
data/lib/simple_hl7/message.rb
CHANGED
@@ -120,5 +120,21 @@ module SimpleHL7
|
|
120
120
|
end
|
121
121
|
msg
|
122
122
|
end
|
123
|
+
|
124
|
+
# Parses a HL7 LLP (Lower Layer Protocol) string into a Message
|
125
|
+
#
|
126
|
+
# @param str [String] The llp string to parse.
|
127
|
+
# @param options [Hash] Options for parsing, keys are symbols, accepted
|
128
|
+
# values:
|
129
|
+
# segment_separator [String] The string to place between segments when
|
130
|
+
# generating HL7, defaults to "\r".
|
131
|
+
# @return [Message] The parsed HL7 Message
|
132
|
+
def self.parse_llp(str, options = nil)
|
133
|
+
if llp = str.match(/\x0b(.*)\x1c\r/)
|
134
|
+
parse(llp.captures.first, options)
|
135
|
+
else
|
136
|
+
raise ArgumentError, "Invalid LLP message, header and trailer were expected."
|
137
|
+
end
|
138
|
+
end
|
123
139
|
end
|
124
140
|
end
|
data/lib/simple_hl7/version.rb
CHANGED
@@ -76,5 +76,21 @@ module SimpleHL7
|
|
76
76
|
msg.pid[5][2].to_s.should == "Test"
|
77
77
|
end
|
78
78
|
end
|
79
|
+
|
80
|
+
describe "#parse_llp" do
|
81
|
+
it "properly parses a llp string" do
|
82
|
+
msg = Message.parse_llp("\x0bMSH|^~\\&||||accountid\rPID|||||User^Test~Repeat\x1c\r")
|
83
|
+
msg.msh[6].to_s.should == "accountid"
|
84
|
+
msg.pid[5].to_s.should == "User"
|
85
|
+
msg.pid[5][2].to_s.should == "Test"
|
86
|
+
msg.pid[5].r(2)[1].to_s.should == "Repeat"
|
87
|
+
end
|
88
|
+
|
89
|
+
it "raise an error on NON llp messages" do
|
90
|
+
expect {
|
91
|
+
Message.parse_llp("MSH|^~\\&||||accountid\rPID|||||User^Test~Repeat")
|
92
|
+
}.to raise_error(ArgumentError, /Invalid LLP message/)
|
93
|
+
end
|
94
|
+
end
|
79
95
|
end
|
80
96
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_hl7
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rome Portlock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|