healthcare_phony 0.5.0 → 0.5.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
  SHA256:
3
- metadata.gz: 9bdfa5957ba72b641eea38c4c61d96c6cea69b33889f010e8b0fa58e61e48683
4
- data.tar.gz: bbbc2532c8092dc625d2be9a20cb108dbba97701eb5f510b218932421ec3bcd5
3
+ metadata.gz: 6ae7efeeef2b6a025dd43df5aaca7d92d2e042e4ede0b7e126b62629ac09adc2
4
+ data.tar.gz: c06db583438d4fa05a02c107b77317396c7f26ebef78414c9bf6a11d0bc5daf7
5
5
  SHA512:
6
- metadata.gz: 2b86d2d6978257091dd388b8c1e9f64fa40079484cdb66efd7400f50bb239cb99f6c270fe48185d9a8269e44dc96e73ce150dfcc2c56175322c8d6f2e17526a9
7
- data.tar.gz: 7283bf0ce04e1b7fa23fa32feb8d0a6bd10a4cdf232446b66def8b32d6294a8d4dab8a50fee713dd37623c41e63571a67922f4863d06d945fe2feb00769884c6
6
+ metadata.gz: 538d1d41816b27f99a8e0e41b1d11612fe2fba9532f4de0dbdee1279388089462dd96eb8b2953adc5d9309c31a11aa09f23373c45c6db27a795eca12fbf72012
7
+ data.tar.gz: 80e8a6a025ba3a33498f84a48b3d14908977c0c83934868ddfd8d1cabbff366e009014049797b53209ccabe130cc591e831669818ed21daed2e8e625e26879ad
data/README.md CHANGED
@@ -309,6 +309,34 @@ The creation of the Hl7Message object can be customized by sending the following
309
309
  * message_receiving_application - Array of Receiving Applications (MSH.5) to randomly choose from. Specified as comma separated String or Ruby Array.
310
310
  * message_receiving_facility - Array of Receiving Facilities (MSH.6) to randomly choose from. Specified as comma separated String or Ruby Array.
311
311
 
312
+ ## Examples
313
+
314
+ See the examples directory.
315
+
316
+ So far there is only one script there, phony_adt_sender.rb. This script will generate a specified number of fake ADT messages and send them to the specified host and port using TCP/IP mllp.
317
+
318
+ Command line argument description:
319
+
320
+ ```text
321
+ Usage: phony_adt_sender.rb [options]
322
+
323
+ -n, --number NUMBER Number of messages to send
324
+ -h, --host HOST IP or DNS for listening host
325
+ -p, --port PORT Listening port
326
+ -c, --config CONFIGFILE Path to configuration file (YAML) for message parameters
327
+ --mllp-start HEX Hex character(s) to denote start of message bytes. In form nn (example 0b for vertical tab) or nnnn (example 1c0d for file separator & carriage return)
328
+ --mllp-end HEX Hex character(s) to denote start of message bytes. In form nn (example 0b for vertical tab) or nnnn (example 1c0d for file separator & carriage return)
329
+ --help Show this message
330
+ ```
331
+
332
+ An example config file is also in the examples directory.
333
+
334
+ So to send 100 messages to 192.168.1.50:3022 using a config file phony_adt_sender.yml with non-standard mllp beginning/ending.
335
+
336
+ ```text
337
+ ruby phony_adt_sender.rb -h 192.168.1.50 --number 100 --port 3022 --config phony_adt_sender.yml --mllp-start 05 --mllp-end 0304
338
+ ```
339
+
312
340
  ## Contributing
313
341
 
314
342
  Bug reports and pull requests are welcome on GitHub at https://github.com/austinmoody/healthcare_phony. 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]/healthcare_phony/blob/master/CODE_OF_CONDUCT.md).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'socket'
4
+ require 'healthcare_phony'
5
+ require 'optparse'
6
+ require 'psych'
7
+
8
+ class PhonyAdtSender
9
+ attr_reader :host, :port, :number_messages, :message_parameters, :mllp_start, :mllp_end
10
+
11
+ def initialize
12
+ @message_parameters = {}
13
+ parse
14
+ end
15
+
16
+ def send
17
+ puts "Sending #{@number_messages} messages to #{@host}:#{@port}"
18
+
19
+ @number_messages.to_i.times do
20
+ t = TCPSocket.new(@host, @port)
21
+
22
+ m = HealthcarePhony::Adt.new(@message_parameters)
23
+ # #{@mllp_start}
24
+ t.send "#{[@mllp_start].pack("H*")}#{m.to_s}#{[@mllp_end].pack("H*")}", 0
25
+
26
+ pp "Message With ID #{m.hl7_message.message_control_id} sent..."
27
+
28
+ reading_response = true
29
+ ack_response = ''
30
+ while reading_response
31
+ current_read = t.read(1)
32
+ ack_response += current_read unless current_read.nil?
33
+ reading_response = false if current_read.nil?
34
+ end
35
+
36
+ pp "ACK: #{ack_response}"
37
+
38
+ t.close
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def parse
45
+ options = {}
46
+ optparse = OptionParser.new do |parser|
47
+ parser.banner = 'Usage: phony_adt_sender.rb [options]'
48
+ parser.separator ''
49
+
50
+ parser.on('-n', '--number NUMBER', Integer, 'Number of messages to send') do |number_messages|
51
+ options[:number_messages] = number_messages
52
+ end
53
+
54
+ parser.on('-h', '--host HOST', String, 'IP or DNS for listening host') do |host|
55
+ options[:host] = host
56
+ end
57
+
58
+ parser.on('-p', '--port PORT', Integer, 'Listening port') do |port|
59
+ options[:port] = port
60
+ end
61
+
62
+ parser.on('-c', '--config CONFIGFILE', String, 'Path to configuration file (YAML) for message parameters') do |config|
63
+ options[:config] = config
64
+ end
65
+
66
+ parser.on('--mllp-start HEX',
67
+ 'Hex character(s) to denote start of message bytes. In form nn (example 0b for vertical tab) or nnnn (example 1c0d for file separator & carriage return)') do |mllp_start|
68
+ options[:mllp_start] = mllp_start
69
+ end
70
+
71
+ parser.on('--mllp-end HEX', String,
72
+ 'Hex character(s) to denote start of message bytes. In form nn (example 0b for vertical tab) or nnnn (example 1c0d for file separator & carriage return)') do |mllp_end|
73
+ options[:mllp_end] = mllp_end
74
+ end
75
+
76
+ parser.on('--help', 'Show this message') do
77
+ puts parser
78
+ exit
79
+ end
80
+ end
81
+
82
+ begin
83
+ optparse.parse!
84
+ mandatory = %i[host port number_messages]
85
+ missing = mandatory.select { |param| options[param].nil? }
86
+ raise OptionParser::MissingArgument, missing.join(', ') unless missing.empty?
87
+ rescue OptionParser::InvalidOption, OptionParser::MissingArgument
88
+ puts $!.to_s
89
+ puts optparse
90
+ exit
91
+ end
92
+
93
+ @host = options[:host]
94
+ @port = options[:port]
95
+ @number_messages = options[:number_messages]
96
+ @message_parameters = Psych.load_file(options[:config]) unless options[:config].nil?
97
+ @mllp_start = if options[:mllp_start].nil?
98
+ '0b'
99
+ else
100
+ options[:mllp_start]
101
+ end
102
+ @mllp_end = if options[:mllp_end].nil?
103
+ '1c0d'
104
+ else
105
+ options[:mllp_end]
106
+ end
107
+ end
108
+ end
109
+
110
+ pas = PhonyAdtSender.new
111
+ pas.send
@@ -0,0 +1,10 @@
1
+ ---
2
+ :message_sending_facility: CLINIC1,CLINIC2,CLINIC3
3
+ :message_sending_application: RUBY
4
+ :message_receiving_application: MIRTH
5
+ :message_receiving_facility: HOSPITAL_ONE
6
+ :message_version: '2.3'
7
+ :patient_class: A,B,C,X
8
+ :adt_events: A99,A88
9
+ :message_control_id_pattern: HL7_\d{15}
10
+ :message_processing_id: X
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: healthcare_phony
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Moody
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-23 00:00:00.000000000 Z
11
+ date: 2021-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -113,6 +113,8 @@ files:
113
113
  - README.md
114
114
  - Rakefile
115
115
  - VERSION
116
+ - examples/phony_adt_sender.rb
117
+ - examples/phony_adt_sender.yml
116
118
  - healthcare_phony.gemspec
117
119
  - lib/healthcare_phony.rb
118
120
  - lib/healthcare_phony/address.rb