healthcare_phony 0.3.0 → 0.6.0

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
  SHA256:
3
- metadata.gz: dd82a9bb551ceeeafe3a73126f9b09de624303e71abc98b26e1d5510fe226690
4
- data.tar.gz: ac7a04cb59c0aca105b391a1db38f4492d4b220588273b604b36156df3ff9102
3
+ metadata.gz: 52179664ed49c4f5ddac39695bf24e697078ae4f9e860a2556374fd3cfe55d59
4
+ data.tar.gz: 47e45882af902b835ae546ff2d472da3270adf07f21d8987eb71bd9ef0001467
5
5
  SHA512:
6
- metadata.gz: 3ca23f7f3eb78eaa6a3c89ba444f7293a1879852ba9b44a64b56bf2d9b3386f27cdc1640513cac0603c0f9392c808667109a5d65bd75da4b91cd9b340af3a718
7
- data.tar.gz: 7a03f56fb3d5ff4a6c9942148fd94f16c57bbdfd2a7288ebd1a21250bcf28159df91feec6de7157fca81c1f44a0a83df2544fd200b9eff01ce24744712a780ed
6
+ metadata.gz: af04102942b12b4a48732fec3ead0cc21285f21ae28f6c5606e96339079aad1fe4db3e83c80492f51a1a6968d060436cfa9f0420bc91fe21e51de24bc29d5af8
7
+ data.tar.gz: ebea7beb8d35daa149140de9c0409bfd0410bde1dac7ca8cbd935127d41fe2850e6fb9939b35d7f97d4422c853b0693af00cdd0a2eabf4e6edaec4ce1e4e5ae9
data/README.md CHANGED
@@ -147,6 +147,7 @@ The creation of the Patient can be customized by sending the following parameter
147
147
  * race_count → By default on Race is generated, this allows you to specify a number > 1.
148
148
  * gender → A Gender object which will be used to generate a Male or Female name if specified.
149
149
  * degree_data_file → Location of YAML file containing a list of potential degrees to choose from. By default the gem supplied file will be used. The default file [degree.yml](https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/degree.yml).
150
+ * visit_type → VisitType of this patient's visit
150
151
 
151
152
  ### Patient Visit
152
153
 
@@ -272,6 +273,71 @@ The creation of the PatientVisit can be customized by sending the following para
272
273
  * discharge_location → Array of discharge locations to randomly choose from. Specified as comma separated String or Ruby array. Otherwise a string of data is generated with Faker::Lorem.sentence
273
274
  * admit_datetime → The admit date/time associated with this visit. If not specified the current date/time is used.
274
275
 
276
+ ### Hl7 Message
277
+
278
+ ```ruby
279
+ hl7 = HealthcarePhony::Hl7Message.new
280
+ ```
281
+
282
+ The above will give you a default Hl7Message object:
283
+
284
+ ```
285
+ #<HealthcarePhony::Hl7Message:0x00007f81979beb58
286
+ @message_type="MDM",
287
+ @trigger_event="T04",
288
+ @message_control_id="PHONY8408942134",
289
+ @version="2.5.1", @sending_facility="",
290
+ @sending_application="",
291
+ @receiving_application="",
292
+ @receiving_facility="",
293
+ @message_datetime=2021-01-16 20:29:10 -0500,
294
+ @processing_id="P">
295
+ ```
296
+
297
+ The creation of the Hl7Message object can be customized by sending the following parameters when initializing:
298
+
299
+ * message_version - HL7v2 version (MSH.12)
300
+ * message_processing_id - Typically P or T (MSH.11)
301
+ * message_types - Array of Message Types (MSH.9.1) to randomly choose from. Specified as comma separated String or Ruby array.
302
+ * message_type_file - Location of file containing Message Types (MSH.9.1). If not specified then included [hl7_message_types.yml](https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/hl7_message_types.yml) file will be used.
303
+ * message_events - Generic array of Trigger Events (MSH.9.2) to randomly choose from. Specified as command separated String or Ruby array.
304
+ * adt_events - Array of ADT Trigger Events (MSH.9.2) to randomly choose from. Used (if specified) if the Message type for the message is ADT. ADT events from [adt_event_types.yml](https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/adt_event_types.yml) will be used by default.
305
+ * oru_events - Array of ORU Trigger Events (MSH.9.2) to randomly choose from. Used (if specified) if the Message type for the message is ORU. ORU events from [oru_event_types.yml](https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/adt_event_types.yml) will be used by default.
306
+ * mdm_events - Array of MDM Trigger Events (MSH.9.2) to randomly choose from. Used (if specified) if the Message type for the message is MDM. MDM events from [mdm_event_types.yml](https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/adt_event_types.yml) will be used by default.
307
+ * message_control_id_pattern - Regex pattern used to randomly generate MSH.10 values. Default is PHONY\d{10} which will generate a value like: PHONY6850295805
308
+ * message_sending_facility - Array of Sending Facilities (MSH.4) to randomly choose from. Specified as comma separated String or Ruby Array.
309
+ * message_sending_application - Array of Sending Applications (MSH.3) to randomly choose from. Specified as comma separated String or Ruby Array.
310
+ * message_receiving_application - Array of Receiving Applications (MSH.5) to randomly choose from. Specified as comma separated String or Ruby Array.
311
+ * message_receiving_facility - Array of Receiving Facilities (MSH.6) to randomly choose from. Specified as comma separated String or Ruby Array.
312
+
313
+ ## Examples
314
+
315
+ See the examples directory.
316
+
317
+ 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.
318
+
319
+ Command line argument description:
320
+
321
+ ```text
322
+ Usage: phony_adt_sender.rb [options]
323
+
324
+ -n, --number NUMBER Number of messages to send
325
+ -h, --host HOST IP or DNS for listening host
326
+ -p, --port PORT Listening port
327
+ -c, --config CONFIGFILE Path to configuration file (YAML) for message parameters
328
+ --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)
329
+ --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)
330
+ --help Show this message
331
+ ```
332
+
333
+ An example config file is also in the examples directory.
334
+
335
+ 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.
336
+
337
+ ```text
338
+ 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
339
+ ```
340
+
275
341
  ## Contributing
276
342
 
277
343
  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.3.0
1
+ 0.6.0
@@ -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
@@ -11,22 +11,47 @@ Faker::Config.locale = 'en-US'
11
11
 
12
12
  module HealthcarePhony
13
13
  class Adt
14
- attr_reader :template_file
14
+ attr_reader :template, :adt_arguments, :hl7_message, :patient, :visit
15
15
 
16
- def initialize(template_file = nil)
17
- @template_file = if template_file.nil?
18
- File.join(File.dirname(__FILE__), 'healthcare_phony', 'templates', 'adt_example.erb')
19
- else
20
- template_file
21
- end
16
+ def initialize(init_args = {})
17
+ @adt_arguments = init_args
18
+ @adt_arguments[:message_types] = 'ADT'
19
+ set_template
20
+ @hl7_message = Hl7Message.new(@adt_arguments)
21
+ @patient = Patient.new(@adt_arguments)
22
+ @visit = PatientVisit.new(@adt_arguments.merge({ visit_type: set_visit_type }))
22
23
  end
23
24
 
24
25
  def to_s
25
- template = ERB.new(File.read(@template_file))
26
- message = Hl7Message.new
27
- patient = Patient.new
28
- visit = PatientVisit.new
29
- template.result_with_hash({ patient: patient, hl7: message, visit: visit })
26
+ erb_template = ERB.new(@template)
27
+ erb_template.result_with_hash({ patient: @patient, hl7: @hl7_message, visit: @visit })
28
+ end
29
+
30
+ private
31
+
32
+ def set_template
33
+ unless @adt_arguments[:template].nil?
34
+ @template = @adt_arguments[:template]
35
+ return
36
+ end
37
+ @template = if @adt_arguments[:template_file].nil?
38
+ File.read(File.join(File.dirname(__FILE__), 'healthcare_phony', 'templates', 'adt_example.erb'))
39
+ else
40
+ File.read(@adt_arguments[:template_file])
41
+ end
42
+ end
43
+
44
+ def set_visit_type
45
+ case @hl7_message.trigger_event
46
+ when 'A01'
47
+ HealthcarePhony::VisitType::ADMIT
48
+ when 'A03'
49
+ HealthcarePhony::VisitType::DISCHARGE
50
+ when 'A04'
51
+ HealthcarePhony::VisitType::REGISTRATION
52
+ else
53
+ HealthcarePhony::VisitType::OTHER
54
+ end
30
55
  end
31
56
  end
32
57
 
@@ -47,7 +72,7 @@ module HealthcarePhony
47
72
  counter = 0
48
73
  output_string = ''
49
74
  while counter < @number_of_rows
50
- output_string += template.result_with_hash({ patient: Patient.new, write_header: counter == 0 }) + "\n"
75
+ output_string += "#{template.result_with_hash({ patient: Patient.new, write_header: counter.zero? })}\n"
51
76
  counter += 1
52
77
  end
53
78
  output_string
@@ -13,7 +13,7 @@ module HealthcarePhony
13
13
  # address_type_data_file - YAML file containing address types to randomly choose from if different options than
14
14
  # those that come with gem are desired.
15
15
  # See {address_type.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/address_type.yml]
16
- def initialize(**init_args)
16
+ def initialize(init_args = {})
17
17
  @set_blank = !init_args[:blank].nil? && Helper.random_with_blank('X', init_args[:blank]) == ''
18
18
  @state = init_args[:state]
19
19
  @country = init_args[:country]
@@ -9,7 +9,7 @@ module HealthcarePhony
9
9
  # blank - An integer representing the % of times phone number components should be blank.
10
10
  # use_code - Allows specification of the phone use code (PID.13.2)
11
11
  # equipment_type - Allows specification of the phone equipment type (PID.13.3)
12
- def initialize(**init_args)
12
+ def initialize(init_args = {})
13
13
  super(init_args)
14
14
  @use_code = init_args[:use_code].nil? ? 'ORN' : init_args[:use_code]
15
15
  @use_code = '' unless @set_blank == false
@@ -11,7 +11,7 @@ module HealthcarePhony
11
11
  # Public: Initialize a Doctor. Pass in hash of different parameters, currently this includes:
12
12
  #
13
13
  # identifier - Allows you to specify an identifier for this Doctor instead of having it randomly generated.
14
- def initialize(**init_args)
14
+ def initialize(init_args = {})
15
15
  @identifier = if !init_args[:identifier].nil?
16
16
  init_args[:identifier]
17
17
  else
@@ -19,7 +19,8 @@ module HealthcarePhony
19
19
  (pre_check_npi.to_s + Helper.get_npi_check_digit(pre_check_npi).to_s).to_i
20
20
  end
21
21
 
22
- @name = PersonName.new(degree: 'MD,DO')
22
+ init_args[:degree] = 'MD,DO'
23
+ @name = PersonName.new(init_args)
23
24
  end
24
25
  end
25
26
  end
@@ -7,7 +7,7 @@ module HealthcarePhony
7
7
  :use_code,
8
8
  :equipment_type
9
9
 
10
- def initialize(**init_args)
10
+ def initialize(init_args = {})
11
11
  @set_blank = !init_args[:blank].nil? && Helper.random_with_blank('X', init_args[:blank]) == ''
12
12
  @email_address = Faker::Internet.email
13
13
  @email_address = '' unless @set_blank == false
@@ -12,7 +12,7 @@ module HealthcarePhony
12
12
  # ethnic_group_data_file - YAML file containing ethnic group information to randomly choose from if different options than
13
13
  # those that come with gem are desired. See {ethnic_group.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/ethnic_group.yml]
14
14
  # for default values.
15
- def initialize(**init_args)
15
+ def initialize(init_args = {})
16
16
  @set_blank = !init_args[:blank].nil? && Helper.random_with_blank('X', init_args[:blank]) == ''
17
17
  data_file = if !init_args[:ethnic_group_data_file].nil?
18
18
  init_args[:ethnic_group_data_file]
@@ -8,7 +8,7 @@ module HealthcarePhony
8
8
 
9
9
  # Public: Initializes a Gender. Pass in hash of different parameters, currently this includes:
10
10
  # blank - An integer representing the % of times Address components should be blank.
11
- def initialize(**init_args)
11
+ def initialize(init_args = {})
12
12
  @description = %w[Female Male Unknown].sample
13
13
 
14
14
  @description = if !init_args[:blank].nil?
@@ -15,35 +15,38 @@ module HealthcarePhony
15
15
  :processing_id
16
16
 
17
17
  # Public: Initializes an Address. Pass in hash of different parameters, currently this includes:
18
- # version - HL7v2 version (MSH.12)
19
- # processing_id - Typically P or T (MSH.11)
20
- # types - Array of Message Types (MSH.9.1) to randomly choose from. Specified as comma separated String or
18
+ # message_version - HL7v2 version (MSH.12)
19
+ # message_processing_id - Typically P or T (MSH.11)
20
+ # message_types - Array of Message Types (MSH.9.1) to randomly choose from. Specified as comma separated String or
21
21
  # Ruby array.
22
22
  # message_type_file - Location of file containing Message Types (MSH.9.1). If not specified then included
23
23
  # {hl7_message_types.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/hl7_message_types.yml] file will be used.
24
- # events - Array of Trigger Events (MSH.9.2) to randomly choose from. Specified as command separated String or
25
- # Ruby array.
26
- # adt_events_file - Location of file containing ADT Trigger Events (MSH.9.2). If not specified then included
27
- # {adt_event_types.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/adt_event_types.yml] file will be used.
28
- # oru_events_file - Location of file containing ORU Trigger Events (MSH.9.2). If not specified then included
29
- # {oru_event_types.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/adt_event_types.yml] file will be used.
30
- # mdm_events_file - Location of file containing MDM Trigger Events (MSH.9.2). If not specified then included
31
- # {mdm_event_types.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/adt_event_types.yml] file will be used.
32
- # control_id_pattern - Regex pattern used to randomly generate MSH.10 values. Default is PHONY\d{10} which will
24
+ # message_events - Generic array of Trigger Events (MSH.9.2) to randomly choose from. Specified as command
25
+ # separated String or Ruby array.
26
+ # adt_events - Array of ADT Trigger Events (MSH.9.2) to randomly choose from. Used (if specified) if the Message
27
+ # type for the message is ADT. ADT events from {adt_event_types.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/adt_event_types.yml]
28
+ # will be used by default.
29
+ # oru_events - Array of ORU Trigger Events (MSH.9.2) to randomly choose from. Used (if specified) if the Message
30
+ # type for the message is ORU. ORU events from {oru_event_types.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/adt_event_types.yml]
31
+ # will be used by default.
32
+ # mdm_events - Array of MDM Trigger Events (MSH.9.2) to randomly choose from. Used (if speciifed) if the Message
33
+ # type for the message is MDM. MDM events from {mdm_event_types.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/adt_event_types.yml]
34
+ # will be used by default.
35
+ # message_control_id_pattern - Regex pattern used to randomly generate MSH.10 values. Default is PHONY\d{10} which will
33
36
  # generate a value like: PHONY6850295805
34
- # sending_facility - Array of Sending Facilities (MSH.4) to randomly choose from. Specified as comma separated
37
+ # message_sending_facility - Array of Sending Facilities (MSH.4) to randomly choose from. Specified as comma separated
35
38
  # String or Ruby Array.
36
- # sending_application - Array of Sending Applications (MSH.3) to randomly choose from. Specified as comma
39
+ # message_sending_application - Array of Sending Applications (MSH.3) to randomly choose from. Specified as comma
37
40
  # separated String or Ruby Array.
38
- # receiving_application - Array of Receiving Applications (MSH.5) to randomly choose from. Specified as comma
41
+ # message_receiving_application - Array of Receiving Applications (MSH.5) to randomly choose from. Specified as comma
39
42
  # separated String or Ruby Array.
40
- # receiving_facility - Array of Receiving Facilities (MSH.6) to randomly choose from. Specified as comma separated
43
+ # message_receiving_facility - Array of Receiving Facilities (MSH.6) to randomly choose from. Specified as comma separated
41
44
  # String or Ruby Array.
42
- def initialize(**init_args)
45
+ def initialize(init_args)
43
46
  define_message_type(init_args)
44
47
  define_trigger_event(init_args)
45
48
  define_control_id(init_args)
46
- @version = init_args[:version].nil? ? '2.5.1' : init_args[:version]
49
+ @version = init_args[:message_version].nil? ? '2.5.1' : init_args[:message_version]
47
50
  define_sending_facility(init_args)
48
51
  define_sending_application(init_args)
49
52
  define_receiving_application(init_args)
@@ -52,84 +55,104 @@ module HealthcarePhony
52
55
  # Potential use case to allow you to provide begin/end date?
53
56
  @message_datetime = Time.now
54
57
 
55
- @processing_id = init_args[:processing_id].nil? ? 'P' : init_args[:processing_id]
58
+ @processing_id = init_args[:message_processing_id].nil? ? 'P' : init_args[:message_processing_id]
56
59
  end
57
60
 
58
61
  private
59
62
 
60
- def define_message_type(**init_args)
63
+ def define_message_type(init_args = {})
61
64
  file_name = "#{::File.expand_path(::File.join("..", "data_files"), __FILE__)}/hl7_message_types.yml"
62
65
  file_name = init_args[:message_type_file] unless init_args[:message_type_file].nil?
63
- hl7_message_types = if !init_args[:types].nil?
64
- Helper.get_array(init_args[:types])
66
+ hl7_message_types = if !init_args[:message_types].nil?
67
+ Helper.get_array(init_args[:message_types])
65
68
  else
66
69
  Psych.load_file(file_name)
67
70
  end
68
71
  @message_type = hl7_message_types.nil? ? '' : hl7_message_types.sample
69
72
  end
70
73
 
71
- def define_trigger_event(**init_args)
72
- @trigger_event = Helper.get_array(init_args[:events]).sample
73
- @trigger_event = define_adt_trigger_event(init_args) unless @message_type != 'ADT'
74
- @trigger_event = define_oru_trigger_event(init_args) unless @message_type != 'ORU'
75
- @trigger_event = define_mdm_trigger_event(init_args) unless @message_type != 'MDM'
74
+ def define_trigger_event(init_args = {})
75
+ @trigger_event = Helper.get_array(init_args[:message_events]).sample
76
+ return unless @trigger_event.nil?
77
+
78
+ case @message_type
79
+ when 'ADT'
80
+ @trigger_event = define_adt_trigger_event(init_args)
81
+ when 'ORU'
82
+ @trigger_event = define_oru_trigger_event(init_args)
83
+ when 'MDM'
84
+ @trigger_event = define_mdm_trigger_event(init_args)
85
+ end
76
86
  end
77
87
 
78
- def define_adt_trigger_event(**init_args)
88
+ def define_adt_trigger_event(init_args = {})
79
89
  event_types = get_adt_events(init_args)
80
90
  event_types&.sample
81
91
  end
82
92
 
83
- def define_oru_trigger_event(**init_args)
93
+ def define_oru_trigger_event(init_args = {})
84
94
  event_types = get_oru_events(init_args)
85
95
  event_types&.sample
86
96
  end
87
97
 
88
- def define_mdm_trigger_event(**init_args)
98
+ def define_mdm_trigger_event(init_args = {})
89
99
  event_types = get_mdm_events(init_args)
90
100
  event_types&.sample
91
101
  end
92
102
 
93
- def get_adt_events(**init_args)
103
+ def get_adt_events(init_args = {})
94
104
  file_name = "#{::File.expand_path(::File.join("..", "data_files"), __FILE__)}/adt_event_types.yml"
95
- file_name = init_args[:adt_events_file] unless init_args[:adt_events_file].nil?
96
- Psych.load_file(file_name)
105
+ if init_args[:adt_events].nil?
106
+ Psych.load_file(file_name)
107
+ else
108
+ Helper.get_array(init_args[:adt_events])
109
+ end
97
110
  end
98
111
 
99
- def get_oru_events(**init_args)
112
+ def get_oru_events(init_args = {})
100
113
  file_name = "#{::File.expand_path(::File.join("..", "data_files"), __FILE__)}/oru_event_types.yml"
101
- file_name = init_args[:oru_events_file] unless init_args[:oru_events_file].nil?
102
- Psych.load_file(file_name)
114
+ if init_args[:oru_events].nil?
115
+ Psych.load_file(file_name)
116
+ else
117
+ Helper.get_array(init_args[:oru_events])
118
+ end
103
119
  end
104
120
 
105
- def get_mdm_events(**init_args)
121
+ def get_mdm_events(init_args = {})
106
122
  file_name = "#{::File.expand_path(::File.join("..", "data_files"), __FILE__)}/mdm_event_types.yml"
107
- file_name = init_args[:mdm_events_file] unless init_args[:mdm_events_file].nil?
108
- Psych.load_file(file_name)
123
+ if init_args[:mdm_events].nil?
124
+ Psych.load_file(file_name)
125
+ else
126
+ Helper.get_array(init_args[:mdm_events])
127
+ end
109
128
  end
110
129
 
111
- def define_control_id(**init_args)
112
- control_id_pattern = init_args[:control_id_pattern].nil? ? 'PHONY\d{10}' : init_args[:control_id_pattern]
130
+ def define_control_id(init_args = {})
131
+ control_id_pattern = if init_args[:message_control_id_pattern].nil?
132
+ 'PHONY\d{10}'
133
+ else
134
+ init_args[:message_control_id_pattern]
135
+ end
113
136
  @message_control_id = Regexp.new(control_id_pattern).random_example
114
137
  end
115
138
 
116
- def define_sending_facility(**init_args)
117
- sf_choices = Helper.get_array(init_args[:sending_facility])
139
+ def define_sending_facility(init_args = {})
140
+ sf_choices = Helper.get_array(init_args[:message_sending_facility])
118
141
  @sending_facility = !sf_choices.empty? ? sf_choices.sample : ''
119
142
  end
120
143
 
121
- def define_sending_application(**init_args)
122
- sa_choices = Helper.get_array(init_args[:sending_application])
144
+ def define_sending_application(init_args = {})
145
+ sa_choices = Helper.get_array(init_args[:message_sending_application])
123
146
  @sending_application = !sa_choices.empty? ? sa_choices.sample : ''
124
147
  end
125
148
 
126
- def define_receiving_application(**init_args)
127
- ra_choices = Helper.get_array(init_args[:receiving_application])
149
+ def define_receiving_application(init_args = {})
150
+ ra_choices = Helper.get_array(init_args[:message_receiving_application])
128
151
  @receiving_application = !ra_choices.empty? ? ra_choices.sample : ''
129
152
  end
130
153
 
131
- def define_receiving_facility(**init_args)
132
- rf_choices = Helper.get_array(init_args[:receiving_facility])
154
+ def define_receiving_facility(init_args = {})
155
+ rf_choices = Helper.get_array(init_args[:message_receiving_facility])
133
156
  @receiving_facility = !rf_choices.empty? ? rf_choices.sample : ''
134
157
  end
135
158
  end
@@ -9,7 +9,7 @@ module HealthcarePhony
9
9
  # blank - An integer representing the % of times phone number components should be blank.
10
10
  # use_code - Allows specification of the phone use code (PID.13.2)
11
11
  # equipment_type - Allows specification of the phone equipment type (PID.13.3)
12
- def initialize(**init_args)
12
+ def initialize(init_args = {})
13
13
  super(init_args)
14
14
  @use_code = init_args[:use_code].nil? ? 'PRN' : init_args[:use_code]
15
15
  @use_code = '' unless @set_blank == false
@@ -12,7 +12,7 @@ module HealthcarePhony
12
12
  # type_code - Identifier Type Code, example PID.3.5. HL7 Data Table 0203
13
13
  # pattern - Regex pattern used to randomly generate the identifier. Default is \d{10} which would generate an
14
14
  # identifier like 5992657933.
15
- def initialize(**init_args)
15
+ def initialize(init_args = {})
16
16
  @identifier_type_code = init_args[:type_code].nil? ? '' : init_args[:type_code]
17
17
 
18
18
  identifier_pattern = init_args[:pattern].nil? ? '\d{10}' : init_args[:pattern]
@@ -10,7 +10,7 @@ module HealthcarePhony
10
10
  # Public: Initializes an Address. Pass in hash of different parameters, currently this includes:
11
11
  # language_data_file - Location of YAML file containing Language data (Code, Description, and Coding System) if a
12
12
  # different set of random values is desired. Otherwise the default file {language.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/language.yml] will be used.
13
- def initialize(**init_args)
13
+ def initialize(init_args = {})
14
14
  # TODO: allow a way for caller to pass in a custom set of codes to choose from.
15
15
  # TODO: allow a way for caller to pass in % blank
16
16
 
@@ -25,7 +25,7 @@ module HealthcarePhony
25
25
  :death_indicator,
26
26
  :death_datetime
27
27
 
28
- def initialize(**init_args)
28
+ def initialize(init_args = {})
29
29
  define_gender(init_args)
30
30
  define_names(init_args)
31
31
  define_addresses(init_args)
@@ -40,7 +40,7 @@ module HealthcarePhony
40
40
 
41
41
  private
42
42
 
43
- def define_gender(**init_args)
43
+ def define_gender(init_args = {})
44
44
  @gender = if !init_args[:gender].nil? && init_args[:gender].is_a?(HealthcarePhony::Gender)
45
45
  init_args[:gender]
46
46
  else
@@ -48,7 +48,7 @@ module HealthcarePhony
48
48
  end
49
49
  end
50
50
 
51
- def define_names(**init_args)
51
+ def define_names(init_args = {})
52
52
  init_args[:gender] = @gender
53
53
  names_count = init_args[:names_count].nil? || init_args[:names_count] < 1 ? 1 : init_args[:names_count]
54
54
  @names = []
@@ -58,7 +58,7 @@ module HealthcarePhony
58
58
  end
59
59
  end
60
60
 
61
- def define_addresses(**init_args)
61
+ def define_addresses(init_args = {})
62
62
  address_count = init_args[:address_count].nil? || init_args[:address_count] < 1 ? 1 : init_args[:address_count]
63
63
  @addresses = []
64
64
  while address_count.positive?
@@ -67,19 +67,19 @@ module HealthcarePhony
67
67
  end
68
68
  end
69
69
 
70
- def define_phones(**init_args)
70
+ def define_phones(init_args = {})
71
71
  @home_phone = HomePhoneNumber.new(init_args)
72
72
  @cell_phone = CellPhoneNumber.new(init_args)
73
73
  @work_phone = WorkPhoneNumber.new(init_args)
74
74
  end
75
75
 
76
- def define_dob(**init_args)
76
+ def define_dob(init_args = {})
77
77
  min_age = init_args[:min_age].nil? ? 1 : init_args[:min_age]
78
78
  max_age = init_args[:max_age].nil? ? 99 : init_args[:max_age]
79
79
  @date_of_birth = Faker::Date.birthday(min_age: min_age, max_age: max_age)
80
80
  end
81
81
 
82
- def define_race(**init_args)
82
+ def define_race(init_args = {})
83
83
  races_count = init_args[:race_count].nil? || init_args[:race_count] < 1 ? 1 : init_args[:race_count]
84
84
  @races = []
85
85
  while races_count.positive?
@@ -23,8 +23,9 @@ module HealthcarePhony
23
23
  # or Ruby array. Otherwise this field is left blank.
24
24
  # vip_indicator - Array of Patient Type codes (PV1.18) to randomly choose from. Specified as comma separated String
25
25
  # or Ruby array. Otherwise this field is left blank.
26
- def initialize(**init_args)
27
- @doctors = VisitDoctors.new
26
+ # visit_type - VisitType of the patient's visit
27
+ def initialize(init_args = {})
28
+ @doctors = VisitDoctors.new(init_args)
28
29
  @location = VisitLocation.new(init_args)
29
30
  @admission = VisitAdmission.new(init_args)
30
31
  @bed_status = define_bed_status(init_args)
@@ -40,7 +41,7 @@ module HealthcarePhony
40
41
 
41
42
  private
42
43
 
43
- def define_hospital_service(**init_args)
44
+ def define_hospital_service(init_args = {})
44
45
  standard_hospital_service = %w[CAR MED PUL SUR URO]
45
46
  hs_choices = Helper.get_array(init_args[:hospital_service])
46
47
  if !hs_choices.empty?
@@ -50,13 +51,13 @@ module HealthcarePhony
50
51
  end
51
52
  end
52
53
 
53
- def define_patient_class(**init_args)
54
+ def define_patient_class(init_args = {})
54
55
  standard_pc_choices = %w[B C E I N O P R U]
55
56
  pc_choices = Helper.get_array(init_args[:patient_class])
56
57
  !pc_choices.empty? ? pc_choices.sample : standard_pc_choices.sample
57
58
  end
58
59
 
59
- def define_ambulatory_status(**init_args)
60
+ def define_ambulatory_status(init_args = {})
60
61
  standard_ambulatory_status = %w[A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 B1 B2 B3 B4 B5 B6]
61
62
  as_choices = Helper.get_array(init_args[:ambulatory_status])
62
63
  if !as_choices.empty?
@@ -66,7 +67,7 @@ module HealthcarePhony
66
67
  end
67
68
  end
68
69
 
69
- def define_bed_status(**init_args)
70
+ def define_bed_status(init_args = {})
70
71
  bs_choices = Helper.get_array(init_args[:bed_status])
71
72
  if !bs_choices.empty?
72
73
  bs_choices.sample
@@ -75,7 +76,7 @@ module HealthcarePhony
75
76
  end
76
77
  end
77
78
 
78
- def define_patient_type(**init_args)
79
+ def define_patient_type(init_args = {})
79
80
  pt_choices = Helper.get_array(init_args[:patient_type])
80
81
  if !pt_choices.empty?
81
82
  pt_choices.sample
@@ -84,7 +85,7 @@ module HealthcarePhony
84
85
  end
85
86
  end
86
87
 
87
- def define_vip(**init_args)
88
+ def define_vip(init_args = {})
88
89
  vip_choices = Helper.get_array(init_args[:vip_indicator])
89
90
  if !vip_choices.empty?
90
91
  vip_choices.sample
@@ -15,12 +15,12 @@ module HealthcarePhony
15
15
  # gender - A Gender object which will be used to generate a Male or Female name if specified.
16
16
  # degree_data_file - Location of YAML file containing a list of potential degrees to choose from. By default the
17
17
  # gem supplied file will be used. The default file {degree.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/degree.yml].
18
- def initialize(**init_args)
18
+ def initialize(init_args = {})
19
19
  @set_blank = !init_args[:blank].nil? && Helper.random_with_blank('X', init_args[:blank]) == ''
20
20
  @gender = init_args[:gender]
21
21
  @degree_data_file = get_degree_data_file(init_args)
22
- @given_name = define_given_name
23
- @family_name = define_family_name
22
+ @given_name = (init_args[:given_name_append].nil? ? '' : init_args[:given_name_append]) + define_given_name
23
+ @family_name = (init_args[:family_name_append].nil? ? '' : init_args[:family_name_append]) + define_family_name
24
24
  @middle_name = define_middle_name
25
25
  @suffix = define_suffix
26
26
  @prefix = define_prefix
@@ -33,7 +33,7 @@ module HealthcarePhony
33
33
  attr_accessor :set_blank
34
34
  attr_accessor :degree_data_file
35
35
 
36
- def get_degree_data_file(**init_args)
36
+ def get_degree_data_file(init_args = {})
37
37
  if !init_args[:degree_data_file].nil?
38
38
  init_args[:degree_data_file]
39
39
  else
@@ -85,7 +85,7 @@ module HealthcarePhony
85
85
  end
86
86
  end
87
87
 
88
- def define_degree(**init_args)
88
+ def define_degree(init_args = {})
89
89
  if @set_blank
90
90
  ''
91
91
  elsif !init_args[:degree].nil?
@@ -11,7 +11,7 @@ module HealthcarePhony
11
11
  :use_code,
12
12
  :equipment_type
13
13
 
14
- def initialize(**init_args)
14
+ def initialize(init_args = {})
15
15
  # Public: Initializes a home phone number. Pass in hash of different parameters, currently this includes:
16
16
  # blank - An integer representing the % of times phone number components should be blank.
17
17
  # use_code_data_file - YAML file containing use codes to randomly choose from. If not specified then values from
@@ -6,10 +6,11 @@ module HealthcarePhony
6
6
  attr_accessor :code,
7
7
  :description,
8
8
  :coding_system
9
+
9
10
  # Public: Initializes an Address. Pass in hash of different parameters, currently this includes:
10
11
  # race_data_file - Location of YAML file containing a list of potential degrees to choose from. By default the
11
12
  # gem supplied file will be used. The default file {race.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/race.yml].
12
- def initialize(**init_args)
13
+ def initialize(init_args = {})
13
14
  # TODO: allow a way for caller to pass in % blank
14
15
  # TODO: set coding system
15
16
 
@@ -11,7 +11,7 @@ module HealthcarePhony
11
11
  # religion_data_file - YAML file containing religion information to randomly choose from if different options than
12
12
  # those that come with gem are desired. See {religion.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/religion.yml]
13
13
  # for default values.
14
- def initialize(**init_args)
14
+ def initialize(init_args = {})
15
15
  # TODO: allow a way for caller to pass in a custom set of codes to choose from
16
16
  # TODO: allow a way for caller to pass in % blank
17
17
 
@@ -1,6 +1,6 @@
1
1
  MSH|^~\&|<%= hl7.sending_application %>|<%= hl7.sending_facility %>|<%= hl7.receiving_application %>|<%= hl7.receiving_facility %>|<%= hl7.message_datetime.to_hl7datetime() %>||<%= hl7.message_type %>^<%= hl7.trigger_event %>|<%= hl7.message_control_id %>|<%= hl7.processing_id %>|<%= hl7.version %>
2
2
  EVN|<%= hl7.trigger_event %>|<%= hl7.message_datetime.to_hl7datetime() %>
3
- PID|||<%= patient.medical_record_number.identifier %>||<%= patient.names[0].family_name %>^<%= patient.names[0].given_name %>^<%= patient.names[0].middle_name%>^||<%= patient.date_of_birth.to_hl7date %>|<%= patient.gender.code %>||<%= patient.races[0].code %>|<%= patient.addresses[0].address_line1 %>^<%= patient.addresses[0].address_line2 %>^<%= patient.addresses[0].city %>^<%= patient.addresses[0].state %>^<%= patient.addresses[0].postal_code %>||(<%= patient.home_phone.area_code %>)<%= patient.home_phone.exchange_code %>-<%= patient.home_phone.subscriber_number %>~(<%= patient.cell_phone.area_code %>)<%= patient.cell_phone.exchange_code %>-<%= patient.cell_phone.subscriber_number %>|(<%= patient.work_phone.area_code %>)<%= patient.work_phone.exchange_code %>-<%= patient.work_phone.subscriber_number %>||||<%= patient.account_number.identifier %>|<%= patient.ssn %>
4
- PV1||<%= visit.patient_class %>
5
-
3
+ PID|||<%= patient.medical_record_number.identifier %>||<%= patient.names[0].family_name %>^<%= patient.names[0].given_name %>^<%= patient.names[0].middle_name%>^||<%= patient.date_of_birth.to_hl7date %>|<%= patient.gender.code %>||<%= patient.races[0].code %>|<%= patient.addresses[0].address_line1 %>^<%= patient.addresses[0].address_line2 %>^<%= patient.addresses[0].city %>^<%= patient.addresses[0].state %>^<%= patient.addresses[0].postal_code %>||(<%= patient.home_phone.area_code %>)<%= patient.home_phone.exchange_code %>-<%= patient.home_phone.subscriber_number %>~(<%= patient.cell_phone.area_code %>)<%= patient.cell_phone.exchange_code %>-<%= patient.cell_phone.subscriber_number %>|(<%= patient.work_phone.area_code %>)<%= patient.work_phone.exchange_code %>-<%= patient.work_phone.subscriber_number %>|<%= patient.language.code %>^<%= patient.language.description %>^<%= patient.language.coding_system %>|<%= patient.marital_status.code %>^<%= patient.marital_status.description %>^<%= patient.marital_status.coding_system %>|<%= patient.religion.code %>^<%= patient.religion.description %>^<%= patient.religion.coding_system %>|<%= patient.account_number.identifier %>|<%= patient.ssn %>
4
+ PV1||<%= visit.patient_class %>|<%= visit.location.point_of_care %>^<%= visit.location.room %>^<%= visit.location.bed %>^<%= visit.location.facility %>^<%= visit.location.status %>^<%= visit.location.type %>^<%= visit.location.building %>^<%= visit.location.floor %>^<%= visit.location.description %>|<%= visit.admission.type %>|||<%= visit.doctors.attending.identifier %>^<%= visit.doctors.attending.name.family_name %>^<%= visit.doctors.attending.name.given_name %>^<%= visit.doctors.attending.name.middle_name %>^<%= visit.doctors.attending.name.suffix %>^<%= visit.doctors.attending.name.prefix %>^<%= visit.doctors.attending.name.degree %>|<%= visit.doctors.referring.identifier %>^<%= visit.doctors.referring.name.family_name %>^<%= visit.doctors.referring.name.given_name %>^<%= visit.doctors.referring.name.middle_name %>^<%= visit.doctors.referring.name.suffix %>^<%= visit.doctors.referring.name.prefix %>^<%= visit.doctors.referring.name.degree %>|<%= visit.doctors.consulting.identifier %>^<%= visit.doctors.consulting.name.family_name %>^<%= visit.doctors.consulting.name.given_name %>^<%= visit.doctors.consulting.name.middle_name %>^<%= visit.doctors.consulting.name.suffix %>^<%= visit.doctors.consulting.name.prefix %>^<%= visit.doctors.consulting.name.degree %>|<%= visit.hospital_service %>|11|12|<%= visit.readmission_indicator %>|<%= visit.admission.source %>|15|16|<%= visit.doctors.admitting.identifier %>^<%= visit.doctors.admitting.name.family_name %>^<%= visit.doctors.admitting.name.given_name %>^<%= visit.doctors.admitting.name.middle_name %>^<%= visit.doctors.admitting.name.suffix %>^<%= visit.doctors.admitting.name.prefix %>^<%= visit.doctors.admitting.name.degree %>|<%= visit.patient_type %>|<%= visit.visit_number.identifier %>^^^^<%= visit.visit_number.identifier_type_code %>|||||||||||||||||<%= visit.discharge.disposition %>|<%= visit.discharge.location %>|38|39|40|41|42|43|<%= visit.admission.datetime.to_hl7datetime() %>|<%= visit.discharge.datetime.to_hl7datetime() %>
5
+ PV2|||^<%= visit.admission.reason %>
6
6
 
@@ -12,7 +12,7 @@ module HealthcarePhony
12
12
  # Ruby array. Otherwise default HL7 v2.5.1. Table 0007 values are used.
13
13
  # admit_reason - Array of values to use as Admit Reason (PV2.3) to randomly choose from. Specified as comma
14
14
  # separated String or Ruby array. Otherwise a string of data is generated with Faker::Lorem.sentence
15
- def initialize(**init_args)
15
+ def initialize(init_args = {})
16
16
  @source = define_source(init_args)
17
17
  @type = define_type(init_args)
18
18
  @datetime = Faker::Time.backward(days: Faker::Number.number(digits: 1))
@@ -21,7 +21,7 @@ module HealthcarePhony
21
21
 
22
22
  private
23
23
 
24
- def define_source(**init_args)
24
+ def define_source(init_args = {})
25
25
  standard_admit_source = '123456789'.split('')
26
26
  as_choices = Helper.get_array(init_args[:admit_source])
27
27
  if !as_choices.empty?
@@ -31,7 +31,7 @@ module HealthcarePhony
31
31
  end
32
32
  end
33
33
 
34
- def define_type(**init_args)
34
+ def define_type(init_args = {})
35
35
  standard_admission_types = %w[A C E L N R U]
36
36
  at_choices = Helper.get_array(init_args[:admission_type])
37
37
  if !at_choices.empty?
@@ -41,7 +41,7 @@ module HealthcarePhony
41
41
  end
42
42
  end
43
43
 
44
- def define_reason(**init_args)
44
+ def define_reason(init_args = {})
45
45
  ar_choices = Helper.get_array(init_args[:admit_reason])
46
46
  if !ar_choices.empty?
47
47
  ar_choices.sample
@@ -8,14 +8,14 @@ module HealthcarePhony
8
8
  :datetime
9
9
 
10
10
  # Public: Initializes an EthnicGroup. Pass in hash of different parameters, currently this includes:
11
- # event_type - The HL7 trigger event type that this visit is associated with.
11
+ # visit_type - VisitType of this patient's visit
12
12
  # discharge_disposition - Array of discharge disposition codes (PV1.36) to randomly choose from. Specified as comma
13
13
  # separated String or Ruby array. Otherwise default HL7 v2.5.1 Table 0112 values are used.
14
14
  # discharge_location - Array of discharge locations to randomly choose from. Specified as comma separated String or
15
15
  # Ruby array. Otherwise a string of data is generated with Faker::Lorem.sentence
16
16
  # admit_datetime - The admit date/time associated with this visit. If not specified the current date/time is used.
17
- def initialize(**init_args)
18
- if init_args[:event_type] == 'A03'
17
+ def initialize(init_args = {})
18
+ if init_args[:visit_type] == HealthcarePhony::VisitType::DISCHARGE # init_args[:event_type] == 'A03'
19
19
  @disposition = define_discharge_disposition(init_args)
20
20
  @location = define_discharge_location(init_args)
21
21
  @datetime = define_discharge_datetime(init_args)
@@ -28,9 +28,9 @@ module HealthcarePhony
28
28
 
29
29
  private
30
30
 
31
- def define_discharge_disposition(**init_args)
31
+ def define_discharge_disposition(init_args = {})
32
32
  dd_choices = Helper.get_array(init_args[:discharge_disposition])
33
- if init_args[:event_type] != 'A03'
33
+ if init_args[:visit_type] != HealthcarePhony::VisitType::DISCHARGE # init_args[:event_type] != 'A03'
34
34
  ''
35
35
  elsif !dd_choices.empty?
36
36
  dd_choices.sample
@@ -41,7 +41,7 @@ module HealthcarePhony
41
41
  end
42
42
  end
43
43
 
44
- def define_discharge_location(**init_args)
44
+ def define_discharge_location(init_args = {})
45
45
  dl_choices = Helper.get_array(init_args[:discharge_location])
46
46
  if !dl_choices.empty?
47
47
  dl_choices.sample
@@ -50,7 +50,7 @@ module HealthcarePhony
50
50
  end
51
51
  end
52
52
 
53
- def define_discharge_datetime(**init_args)
53
+ def define_discharge_datetime(init_args = {})
54
54
  from_datetime = if init_args[:admit_datetime].nil?
55
55
  Time.now
56
56
  else
@@ -9,11 +9,11 @@ module HealthcarePhony
9
9
  :consulting,
10
10
  :admitting
11
11
 
12
- def initialize
13
- @attending = Doctor.new
14
- @referring = Doctor.new
15
- @consulting = Doctor.new
16
- @admitting = Doctor.new
12
+ def initialize(init_args = {})
13
+ @attending = Doctor.new(init_args)
14
+ @referring = Doctor.new(init_args)
15
+ @consulting = Doctor.new(init_args)
16
+ @admitting = Doctor.new(init_args)
17
17
  end
18
18
  end
19
19
  end
@@ -32,7 +32,7 @@ module HealthcarePhony
32
32
  # String or Ruby array. Otherwise a random 2 digit number is used.
33
33
  # location_description - Array of potential location descriptions (PV1.3.9) to randomly choose from. Specified as
34
34
  # a comma separated String or Ruby array. Otherwise a random string is generated.
35
- def initialize(**init_args)
35
+ def initialize(init_args = {})
36
36
  @point_of_care = define_point_of_care(init_args)
37
37
  @room = define_room(init_args)
38
38
  @bed = define_bed(init_args)
@@ -46,12 +46,12 @@ module HealthcarePhony
46
46
 
47
47
  private
48
48
 
49
- def define_point_of_care(**init_args)
49
+ def define_point_of_care(init_args = {})
50
50
  poc_choices = Helper.get_array(init_args[:point_of_care])
51
51
  !poc_choices.empty? ? poc_choices.sample : /[A-Z]{10}/.random_example
52
52
  end
53
53
 
54
- def define_room(**init_args)
54
+ def define_room(init_args = {})
55
55
  room_choices = Helper.get_array(init_args[:room])
56
56
  if !room_choices.empty?
57
57
  room_choices.sample
@@ -60,7 +60,7 @@ module HealthcarePhony
60
60
  end
61
61
  end
62
62
 
63
- def define_bed(**init_args)
63
+ def define_bed(init_args = {})
64
64
  bed_choices = Helper.get_array(init_args[:bed])
65
65
  if !bed_choices.empty?
66
66
  bed_choices.sample
@@ -69,32 +69,32 @@ module HealthcarePhony
69
69
  end
70
70
  end
71
71
 
72
- def define_facility(**init_args)
72
+ def define_facility(init_args = {})
73
73
  fac_choices = Helper.get_array(init_args[:facility])
74
74
  !fac_choices.empty? ? fac_choices.sample : Faker::Lorem.sentence
75
75
  end
76
76
 
77
- def define_status(**init_args)
77
+ def define_status(init_args = {})
78
78
  ls_choices = Helper.get_array(init_args[:location_status])
79
79
  !ls_choices.empty? ? ls_choices.sample : /[A-Z]/.random_example
80
80
  end
81
81
 
82
- def define_type(**init_args)
82
+ def define_type(init_args = {})
83
83
  plt_choices = Helper.get_array(init_args[:person_location_type])
84
84
  !plt_choices.empty? ? plt_choices.sample : %w[C D H N O P S].sample
85
85
  end
86
86
 
87
- def define_building(**init_args)
87
+ def define_building(init_args = {})
88
88
  building_choices = Helper.get_array(init_args[:building])
89
89
  !building_choices.empty? ? building_choices.sample : /[1-9]/.random_example
90
90
  end
91
91
 
92
- def define_floor(**init_args)
92
+ def define_floor(init_args = {})
93
93
  floor_choices = Helper.get_array(init_args[:floor])
94
94
  !floor_choices.empty? ? floor_choices.sample : /[0-9]{2}/.random_example
95
95
  end
96
96
 
97
- def define_description(**init_args)
97
+ def define_description(init_args = {})
98
98
  ld_choices = Helper.get_array(init_args[:location_description])
99
99
  if !ld_choices.empty?
100
100
  ld_choices.sample
@@ -0,0 +1,9 @@
1
+ module HealthcarePhony
2
+ module VisitType
3
+ ADMIT = 1
4
+ REGISTRATION = 2
5
+ DISCHARGE = 3
6
+ TRANSFER = 4
7
+ OTHER = 5
8
+ end
9
+ end
@@ -9,7 +9,7 @@ module HealthcarePhony
9
9
  # blank - An integer representing the % of times phone number components should be blank.
10
10
  # use_code - Allows specification of the phone use code (PID.13.2)
11
11
  # equipment_type - Allows specification of the phone equipment type (PID.13.3)
12
- def initialize(**init_args)
12
+ def initialize(init_args = {})
13
13
  super(init_args)
14
14
  @use_code = init_args[:use_code].nil? ? 'WPN' : init_args[:use_code]
15
15
  @use_code = '' unless @set_blank == false
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.3.0
4
+ version: 0.6.0
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-15 00:00:00.000000000 Z
11
+ date: 2021-03-01 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
@@ -158,6 +160,7 @@ files:
158
160
  - lib/healthcare_phony/visit_discharge.rb
159
161
  - lib/healthcare_phony/visit_doctors.rb
160
162
  - lib/healthcare_phony/visit_location.rb
163
+ - lib/healthcare_phony/visit_type.rb
161
164
  - lib/healthcare_phony/work_phone_number.rb
162
165
  homepage: http://github.com/austinmoody/healthcare_phony
163
166
  licenses: