healthcare_phony 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -0
- data/VERSION +1 -1
- data/lib/healthcare_phony.rb +9 -7
- data/lib/healthcare_phony/hl7_message.rb +58 -35
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1de41607d3c9609a86c5cfdefd9562d07c17b30e316d24ea238324c882627d85
|
4
|
+
data.tar.gz: 353036ecec7fb8c01bf417fcb39d22dfbaec87645d3e500bc00ea47111ad6e62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b6064c6bc6770d87cfec29a3ca6539131b80583a2108944ed74bc361a8576aa5d7d46dcf2858e1e62acd8a0bf931a18cef04d464468e623463dad1b60326649
|
7
|
+
data.tar.gz: 29d10f206bc1b7190a9f08fed733c998919b77c7ece24a282d6bb58a7ef21df1e1ebc287a45bce3305cd71597fd5f477e0865257a471427559a3d78b8f2a8d39
|
data/README.md
CHANGED
@@ -272,6 +272,43 @@ The creation of the PatientVisit can be customized by sending the following para
|
|
272
272
|
* 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
273
|
* admit_datetime → The admit date/time associated with this visit. If not specified the current date/time is used.
|
274
274
|
|
275
|
+
### Hl7 Message
|
276
|
+
|
277
|
+
```ruby
|
278
|
+
hl7 = HealthcarePhony::Hl7Message.new
|
279
|
+
```
|
280
|
+
|
281
|
+
The above will give you a default Hl7Message object:
|
282
|
+
|
283
|
+
```
|
284
|
+
#<HealthcarePhony::Hl7Message:0x00007f81979beb58
|
285
|
+
@message_type="MDM",
|
286
|
+
@trigger_event="T04",
|
287
|
+
@message_control_id="PHONY8408942134",
|
288
|
+
@version="2.5.1", @sending_facility="",
|
289
|
+
@sending_application="",
|
290
|
+
@receiving_application="",
|
291
|
+
@receiving_facility="",
|
292
|
+
@message_datetime=2021-01-16 20:29:10 -0500,
|
293
|
+
@processing_id="P">
|
294
|
+
```
|
295
|
+
|
296
|
+
The creation of the Hl7Message object can be customized by sending the following parameters when initializing:
|
297
|
+
|
298
|
+
* message_version - HL7v2 version (MSH.12)
|
299
|
+
* message_processing_id - Typically P or T (MSH.11)
|
300
|
+
* message_types - Array of Message Types (MSH.9.1) to randomly choose from. Specified as comma separated String or Ruby array.
|
301
|
+
* 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.
|
302
|
+
* message_events - Generic array of Trigger Events (MSH.9.2) to randomly choose from. Specified as command separated String or Ruby array.
|
303
|
+
* 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.
|
304
|
+
* 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.
|
305
|
+
* 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.
|
306
|
+
* 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
|
307
|
+
* message_sending_facility - Array of Sending Facilities (MSH.4) to randomly choose from. Specified as comma separated String or Ruby Array.
|
308
|
+
* message_sending_application - Array of Sending Applications (MSH.3) to randomly choose from. Specified as comma separated String or Ruby Array.
|
309
|
+
* message_receiving_application - Array of Receiving Applications (MSH.5) to randomly choose from. Specified as comma separated String or Ruby Array.
|
310
|
+
* message_receiving_facility - Array of Receiving Facilities (MSH.6) to randomly choose from. Specified as comma separated String or Ruby Array.
|
311
|
+
|
275
312
|
## Contributing
|
276
313
|
|
277
314
|
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.
|
1
|
+
0.4.0
|
data/lib/healthcare_phony.rb
CHANGED
@@ -11,21 +11,23 @@ Faker::Config.locale = 'en-US'
|
|
11
11
|
|
12
12
|
module HealthcarePhony
|
13
13
|
class Adt
|
14
|
-
attr_reader :template_file
|
14
|
+
attr_reader :template_file, :adt_arguments
|
15
15
|
|
16
|
-
def initialize(
|
17
|
-
@
|
16
|
+
def initialize(**init_args)
|
17
|
+
@adt_arguments = init_args
|
18
|
+
@adt_arguments[:message_types] = 'ADT'
|
19
|
+
@template_file = if adt_arguments[:template_file].nil?
|
18
20
|
File.join(File.dirname(__FILE__), 'healthcare_phony', 'templates', 'adt_example.erb')
|
19
21
|
else
|
20
|
-
template_file
|
22
|
+
adt_arguments[:template_file]
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
26
|
def to_s
|
25
27
|
template = ERB.new(File.read(@template_file))
|
26
|
-
message = Hl7Message.new
|
27
|
-
patient = Patient.new
|
28
|
-
visit = PatientVisit.new
|
28
|
+
message = Hl7Message.new(@adt_arguments)
|
29
|
+
patient = Patient.new(@adt_arguments)
|
30
|
+
visit = PatientVisit.new(@adt_arguments)
|
29
31
|
template.result_with_hash({ patient: patient, hl7: message, visit: visit })
|
30
32
|
end
|
31
33
|
end
|
@@ -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
|
-
#
|
19
|
-
#
|
20
|
-
#
|
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
|
-
#
|
25
|
-
# Ruby array.
|
26
|
-
#
|
27
|
-
# {adt_event_types.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/adt_event_types.yml]
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
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[:
|
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,7 +55,7 @@ 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[:
|
58
|
+
@processing_id = init_args[:message_processing_id].nil? ? 'P' : init_args[:message_processing_id]
|
56
59
|
end
|
57
60
|
|
58
61
|
private
|
@@ -60,8 +63,8 @@ module HealthcarePhony
|
|
60
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[:
|
64
|
-
Helper.get_array(init_args[:
|
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
|
@@ -69,10 +72,17 @@ module HealthcarePhony
|
|
69
72
|
end
|
70
73
|
|
71
74
|
def define_trigger_event(**init_args)
|
72
|
-
@trigger_event = Helper.get_array(init_args[:
|
73
|
-
|
74
|
-
|
75
|
-
|
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
88
|
def define_adt_trigger_event(**init_args)
|
@@ -92,44 +102,57 @@ module HealthcarePhony
|
|
92
102
|
|
93
103
|
def get_adt_events(**init_args)
|
94
104
|
file_name = "#{::File.expand_path(::File.join("..", "data_files"), __FILE__)}/adt_event_types.yml"
|
95
|
-
|
96
|
-
|
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
112
|
def get_oru_events(**init_args)
|
100
113
|
file_name = "#{::File.expand_path(::File.join("..", "data_files"), __FILE__)}/oru_event_types.yml"
|
101
|
-
|
102
|
-
|
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
121
|
def get_mdm_events(**init_args)
|
106
122
|
file_name = "#{::File.expand_path(::File.join("..", "data_files"), __FILE__)}/mdm_event_types.yml"
|
107
|
-
|
108
|
-
|
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
130
|
def define_control_id(**init_args)
|
112
|
-
control_id_pattern = 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
139
|
def define_sending_facility(**init_args)
|
117
|
-
sf_choices = Helper.get_array(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
144
|
def define_sending_application(**init_args)
|
122
|
-
sa_choices = Helper.get_array(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
149
|
def define_receiving_application(**init_args)
|
127
|
-
ra_choices = Helper.get_array(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
154
|
def define_receiving_facility(**init_args)
|
132
|
-
rf_choices = Helper.get_array(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
|
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.
|
4
|
+
version: 0.4.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-
|
11
|
+
date: 2021-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|