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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0efb8b7549e645da88bd6c6656875bed17d5b411
4
- data.tar.gz: 8e835d150c18217dce2d63572a2b2bcd0dcf6c20
3
+ metadata.gz: 4e291e509c760825660168925c73d836d2b4e89d
4
+ data.tar.gz: 4194eecae65086ea5da340005219591f50e4d7fe
5
5
  SHA512:
6
- metadata.gz: 8788fe681f3a0d762ee405b225f9fea0c37542f9347d615cfcdf282cddab3c8ec55a52efa8cd7210c20bbf1ddad708b7b97850875fb27598e6a13b5826cacd57
7
- data.tar.gz: df1c429e5b62d4f6545ae9a109aca7f6f83675ebc9974736e79f5130445399ce7fef4feea5c55781d02cdbc0f4c030037d05d561e62084806d4a13b600f1208a
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module SimpleHL7
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -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.1
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-06-22 00:00:00.000000000 Z
11
+ date: 2016-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry