healthcare_phony 0.7s.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/gem-push.yml +42 -42
  3. data/.github/workflows/ruby.yml +33 -33
  4. data/.gitignore +63 -63
  5. data/.rdoc_options +23 -23
  6. data/.rubocop.yml +10 -10
  7. data/CODE_OF_CONDUCT.md +84 -84
  8. data/Gemfile +8 -8
  9. data/LICENSE.txt +21 -21
  10. data/README.md +365 -365
  11. data/Rakefile +12 -12
  12. data/VERSION +1 -1
  13. data/examples/bigger_csv_example.erb +3 -3
  14. data/examples/phony_adt_sender.rb +111 -111
  15. data/examples/phony_adt_sender.yml +11 -11
  16. data/examples/phony_csv.yml +4 -4
  17. data/healthcare_phony.gemspec +36 -36
  18. data/lib/healthcare_phony.rb +138 -139
  19. data/lib/healthcare_phony/address.rb +89 -89
  20. data/lib/healthcare_phony/assigning_authority.rb +6 -6
  21. data/lib/healthcare_phony/cell_phone_number.rb +20 -20
  22. data/lib/healthcare_phony/data_files/address_type.yml +7 -7
  23. data/lib/healthcare_phony/data_files/adt_event_types.yml +59 -59
  24. data/lib/healthcare_phony/data_files/degree.yml +9 -9
  25. data/lib/healthcare_phony/data_files/discharge_disposition.yml +15 -15
  26. data/lib/healthcare_phony/data_files/ethnic_group.yml +9 -9
  27. data/lib/healthcare_phony/data_files/hl7_message_types.yml +4 -4
  28. data/lib/healthcare_phony/data_files/language.yml +7 -7
  29. data/lib/healthcare_phony/data_files/marital_status.yml +49 -49
  30. data/lib/healthcare_phony/data_files/mdm_event_types.yml +12 -12
  31. data/lib/healthcare_phony/data_files/oru_event_types.yml +2 -2
  32. data/lib/healthcare_phony/data_files/race.yml +13 -13
  33. data/lib/healthcare_phony/data_files/religion.yml +250 -250
  34. data/lib/healthcare_phony/data_files/tele_equipment_type.yml +10 -10
  35. data/lib/healthcare_phony/data_files/tele_use_code.yml +9 -9
  36. data/lib/healthcare_phony/diagnosis.rb +12 -12
  37. data/lib/healthcare_phony/doctor.rb +26 -26
  38. data/lib/healthcare_phony/email.rb +25 -25
  39. data/lib/healthcare_phony/ethnic_group.rb +34 -34
  40. data/lib/healthcare_phony/gender.rb +22 -22
  41. data/lib/healthcare_phony/helper.rb +72 -72
  42. data/lib/healthcare_phony/hl7_message.rb +159 -159
  43. data/lib/healthcare_phony/home_phone_number.rb +20 -20
  44. data/lib/healthcare_phony/identifier.rb +23 -23
  45. data/lib/healthcare_phony/insurance.rb +6 -6
  46. data/lib/healthcare_phony/language.rb +30 -30
  47. data/lib/healthcare_phony/marital_status.rb +31 -31
  48. data/lib/healthcare_phony/patient.rb +114 -114
  49. data/lib/healthcare_phony/patient_visit.rb +97 -97
  50. data/lib/healthcare_phony/person_name.rb +104 -104
  51. data/lib/healthcare_phony/phone_number.rb +85 -85
  52. data/lib/healthcare_phony/procedure.rb +6 -6
  53. data/lib/healthcare_phony/race.rb +31 -31
  54. data/lib/healthcare_phony/religion.rb +32 -32
  55. data/lib/healthcare_phony/templates/csv_example.erb +3 -3
  56. data/lib/healthcare_phony/version.rb +5 -5
  57. data/lib/healthcare_phony/visit_admission.rb +53 -53
  58. data/lib/healthcare_phony/visit_discharge.rb +62 -62
  59. data/lib/healthcare_phony/visit_doctors.rb +19 -19
  60. data/lib/healthcare_phony/visit_location.rb +106 -106
  61. data/lib/healthcare_phony/visit_type.rb +8 -8
  62. data/lib/healthcare_phony/work_phone_number.rb +20 -20
  63. metadata +5 -5
data/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
-
7
- # Specify your gem's dependencies in healthcare_phony.gemspec
8
- gemspec
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in healthcare_phony.gemspec
8
+ gemspec
data/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2020 Austin Moody
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Austin Moody
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,365 +1,365 @@
1
- # HealthcarePhony
2
-
3
- This is an admittedly _rough_ RubyGem used to generate fake data that can be used in creating test HL7, CSV, or other data for healthcare integration testing.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'healthcare_phony'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle install
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install healthcare_phony
20
-
21
- ## Usage
22
-
23
- The general purpose of this gem is to generate various pieces of data useful in creating test healthcare integration data. Like HL7 messages or CSV files. The high level objects available are:
24
-
25
- * Patient
26
- * Patient Visit
27
- * HL7 Message
28
- * Doctor
29
-
30
- ### Patient
31
-
32
- ```ruby
33
- patient = Patient.new
34
- ```
35
-
36
- The above will give you a default Patient object:
37
-
38
- ```
39
- #<HealthcarePhony::Patient:0x00007fa7ab1b8230
40
- @account_number=
41
- #<HealthcarePhony::Identifier:0x00007fa7a9dc3ef0
42
- @identifier="4969529871",
43
- @identifier_type_code="AN">,
44
- @addresses=
45
- [#<HealthcarePhony::Address:0x00007fa7aeb337f8
46
- @address_line1="4973 Bruen Square",
47
- @address_line2="Suite 628",
48
- @address_type="L",
49
- @address_type_data_file=nil,
50
- @city="West Melva",
51
- @country="",
52
- @postal_code="48030",
53
- @set_blank=false,
54
- @state="MI">],
55
- @birth_order="",
56
- @cell_phone=
57
- #<HealthcarePhony::CellPhoneNumber:0x00007fa7a992d238
58
- @area_code="641",
59
- @country_code="++1",
60
- @equipment_type="CP",
61
- @equipment_type_data_file=nil,
62
- @exchange_code="586",
63
- @set_blank=false,
64
- @subscriber_number="9470",
65
- @use_code="ORN",
66
- @use_code_data_file=nil>,
67
- @date_of_birth=#<Date: 2005-12-01 ((2453706j,0s,0n),+0s,2299161j)>,
68
- @death_datetime=2007-11-05 15:24:26 -0500,
69
- @death_indicator="Y",
70
- @ethnic_group=
71
- #<HealthcarePhony::EthnicGroup:0x00007fa7a9d94128
72
- @code="N",
73
- @coding_system="HL70189",
74
- @description="Not Hispanic or Latino",
75
- @set_blank=false>,
76
- @gender=
77
- #<HealthcarePhony::Gender:0x00007fa7a9983458
78
- @code="U",
79
- @description="Unknown">,
80
- @home_phone=
81
- #<HealthcarePhony::HomePhoneNumber:0x00007fa7a9906cf0
82
- @area_code="504",
83
- @country_code="++1",
84
- @equipment_type="PH",
85
- @equipment_type_data_file=nil,
86
- @exchange_code="931",
87
- @set_blank=false,
88
- @subscriber_number="8965",
89
- @use_code="PRN",
90
- @use_code_data_file=nil>,
91
- @language=
92
- #<HealthcarePhony::Language:0x00007fa7a9993c40
93
- @code="spa",
94
- @coding_system="HL70296",
95
- @description="spanish">,
96
- @marital_status=
97
- #<HealthcarePhony::MaritalStatus:0x00007fa7a99909f0
98
- @code="T",
99
- @coding_system="HL70002",
100
- @description="Unreported">,
101
- @medical_record_number=
102
- #<HealthcarePhony::Identifier:0x00007fa7a9d9d840
103
- @identifier="5727985905",
104
- @identifier_type_code="MR">,
105
- @multiple_birth_indicator="N",
106
- @names=
107
- [#<HealthcarePhony::PersonName:0x00007fa7ab1b80f0
108
- @degree="CPNP",
109
- @family_name="Murray",
110
- @gender=nil,
111
- @given_name="Claude",
112
- @middle_name="Howe",
113
- @prefix="Mr.",
114
- @set_blank=false,
115
- @suffix="I">],
116
- @races=
117
- [#<HealthcarePhony::Race:0x00007fa7a9982eb8
118
- @code="1002-5",
119
- @coding_system="",
120
- @description="American Indian or Alaska Native">],
121
- @religion=
122
- #<HealthcarePhony::Religion:0x00007fa7a9d462e8
123
- @code="PRO",
124
- @coding_system="HL70006",
125
- @description="Christian: Protestant">,
126
- @ssn="320-79-1958",
127
- @work_phone=
128
- #<HealthcarePhony::WorkPhoneNumber:0x00007fa7a9959838
129
- @area_code="508",
130
- @country_code="++1",
131
- @equipment_type="PH",
132
- @equipment_type_data_file=nil,
133
- @exchange_code="760",
134
- @set_blank=false,
135
- @subscriber_number="8916",
136
- @use_code="WPN",
137
- @use_code_data_file=nil>>
138
- ```
139
-
140
- The creation of the Patient can be customized by sending the following parameters when initializing:
141
-
142
- * blank &rarr; An integer representing the % of times PatientName components should be blank.
143
- * names_count &rarr; By default one PatientName is generated, this allows you to specify a number > 1.
144
- * address_count &rarr; By default on Address is generated, this allows you to specify a number > 1.
145
- * min_age &rarr; A minimum age (in years) for the Patient.
146
- * max_age &rarr; A maximum age (in years) for the Patient.
147
- * race_count &rarr; By default on Race is generated, this allows you to specify a number > 1.
148
- * gender &rarr; A Gender object which will be used to generate a Male or Female name if specified.
149
- * degree_data_file &rarr; 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 &rarr; VisitType of this patient's visit
151
-
152
- ### Patient Visit
153
-
154
- ```ruby
155
- pv = HealthcarePhony::PatientVisit.new
156
- ```
157
-
158
- The above will give you a default PatientVisit object:
159
-
160
- ```
161
- #<HealthcarePhony::PatientVisit:0x00007fcb251055c0
162
- @admission=
163
- #<HealthcarePhony::VisitAdmission:0x00007fcb291bc6b8
164
- @datetime=2021-01-04 05:31:33 -0500,
165
- @reason="Tempore libero neque voluptatibus.",
166
- @source="2",
167
- @type="L">,
168
- @ambulatory_status="A6",
169
- @bed_status="K",
170
- @discharge=
171
- #<HealthcarePhony::VisitDischarge:0x00007fcb254b7da8
172
- @datetime=nil,
173
- @disposition="",
174
- @location="">,
175
- @doctors=
176
- #<HealthcarePhony::VisitDoctors:0x00007fcb251054a8
177
- @admitting=
178
- #<HealthcarePhony::Doctor:0x00007fcb29180a50
179
- @identifier=1777467337,
180
- @name=
181
- #<HealthcarePhony::PersonName:0x00007fcb291906f8
182
- @degree="MD",
183
- @family_name="King",
184
- @gender=nil,
185
- @given_name="Giuseppe",
186
- @middle_name="Pouros",
187
- @prefix="Miss",
188
- @set_blank=false,
189
- @suffix="Ret.">>,
190
- @attending=
191
- #<HealthcarePhony::Doctor:0x00007fcb25105480
192
- @identifier=1847601659,
193
- @name=
194
- #<HealthcarePhony::PersonName:0x00007fcb25125dc0
195
- @degree="DO",
196
- @family_name="Breitenberg",
197
- @gender=nil,
198
- @given_name="Hailey",
199
- @middle_name="Beer",
200
- @prefix="Sen.",
201
- @set_blank=false,
202
- @suffix="III">>,
203
- @consulting=
204
- #<HealthcarePhony::Doctor:0x00007fcb291730a8
205
- @identifier=1422794804,
206
- @name=
207
- #<HealthcarePhony::PersonName:0x00007fcb29182ee0
208
- @degree="DO",
209
- @family_name="McClure",
210
- @gender=nil,
211
- @given_name="Raleigh",
212
- @middle_name="Hettinger",
213
- @prefix="Rev.",
214
- @set_blank=false,
215
- @suffix="JD">>,
216
- @referring=
217
- #<HealthcarePhony::Doctor:0x00007fcb29151818
218
- @identifier=1599337791,
219
- @name=
220
- #<HealthcarePhony::PersonName:0x00007fcb29169648
221
- @degree="MD",
222
- @family_name="Kreiger",
223
- @gender=nil,
224
- @given_name="Pierre",
225
- @middle_name="Olson",
226
- @prefix="Fr.",
227
- @set_blank=false,
228
- @suffix="PhD">>>,
229
- @hospital_service="URO",
230
- @location=
231
- #<HealthcarePhony::VisitLocation:0x00007fcb2915e220
232
- @bed="8y3",
233
- @building="4",
234
- @description="Numquam officiis placeat voluptatibus.",
235
- @facility="Ipsam aut non repellat.",
236
- @floor="81",
237
- @point_of_care="QFDYRRTIFU",
238
- @room="243",
239
- @status="G",
240
- @type="D">,
241
- @patient_class="I",
242
- @patient_type="",
243
- @readmission_indicator="",
244
- @vip_indicator="",
245
- @visit_number=
246
- #<HealthcarePhony::Identifier:0x00007fcb291c6b68
247
- @identifier="3738009164",
248
- @identifier_type_code="VN">>
249
- ```
250
-
251
- The creation of the PatientVisit can be customized by sending the following parameters when initializing:
252
-
253
- * hospital_service &rarr; Array of Hospital Service codes (PV1.10) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise default HL7 v2.5.1 Table 0069 values are used.
254
- * patient_class &rarr; Array of Patient Class codes (PV1.2) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise default HL7 v2.5.1 Table 0004 values are used.
255
- * ambulatory_status &rarr; Array of Ambulatory Status codes (PV1.15) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise default HL7 v2.5.1 Table 0009 values are used.
256
- * bed_status &rarr; Array of Bed Status codes (PV1.40) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise default HL7 v2.5.1 Table 0116 values are used.
257
- * patient_type &rarr; Array of Patient Type codes (PV1.18) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise this field is left blank.
258
- * vip_indicator &rarr; Array of Patient Type codes (PV1.18) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise this field is left blank.
259
- * point_of_care &rarr; Array of potential points of care (PV1.3.1) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise random example generated.
260
- * room &rarr; Array of potential rooms (PV1.3.2) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise a random 3 digit number is generated.
261
- * bed &rarr; Array of potential beds (PV1.3.3) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise a 3 character sequence is created.
262
- * facility &rarr; Array of potential facility names (PV1.3.4) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise a random string is generated.
263
- * location_status &rarr; Array of potential location statuses (PV1.3.5) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise a random uppercase letter is generated to use.
264
- * person_location_type &rarr; Array of potential person location types (PV1.3.6) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise values from HL7 v2.5.1 Table 0305 will be used.
265
- * building &rarr; Array of potential building information (PV1.3.7) to randomly choose from. Specified as a comma separated String or Ruby array. Otherwise a random digit 1-9 is used.
266
- * floor &rarr; Array of potential floor information (PV1.3.8) to randomly choose from. Specified as a comma separated String or Ruby array. Otherwise a random 2 digit number is used.
267
- * location_description &rarr; Array of potential location descriptions (PV1.3.9) to randomly choose from. Specified as a comma separated String or Ruby array. Otherwise a random string is generated.
268
- * admit_source &rarr; Array of Admit Source codes (PV1.14) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise default HL7 v2.5.1 Table 0023 values are used.
269
- * admission_type &rarr; Array of Admission Type (PV1.4) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise default HL7 v2.5.1. Table 0007 values are used.
270
- * admit_reason &rarr; Array of values to use as Admit Reason (PV2.3) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise a string of data is generated with Faker::Lorem.sentence
271
- * event_type &rarr; The HL7 trigger event type that this visit is associated with.
272
- * discharge_disposition &rarr; Array of discharge disposition codes (PV1.36) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise default HL7 v2.5.1 Table 0112 values are used.
273
- * discharge_location &rarr; 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
274
- * admit_datetime &rarr; The admit date/time associated with this visit. If not specified the current date/time is used.
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 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
-
341
- Also in the examples directory are two files that can be used to generate a CSV.
342
-
343
- * phony_csv.yml &rarr; a configuration file that can be used to set parametesr for generation patients. Then two items specific to creating the CSV
344
- * number_of_rows &rarr; The # of rows to write
345
- * template_file &rarr; Path to a ERB template for the CSV. If not specified the default in the library is used.
346
- * bigger_csv_example.erb &rarr; Just another CSV template example.
347
-
348
- Using these files in IRB (or in a script) you could do:
349
-
350
- ```ruby
351
- csv_parameters = Psych.load_file('./examples/phony_csv.yml')
352
- csv = HealthcarePhony::CsvFile.new(csv_parameters)
353
- csv.to_file("d:/temp/testnewtemplate.csv")
354
- ```
355
- ## Contributing
356
-
357
- 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).
358
-
359
- ## License
360
-
361
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
362
-
363
- ## Code of Conduct
364
-
365
- Everyone interacting in the HealthcarePhony project's codebase, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/austinmoody/healthcare_phony/blob/master/CODE_OF_CONDUCT.md).
1
+ # HealthcarePhony
2
+
3
+ This is an admittedly _rough_ RubyGem used to generate fake data that can be used in creating test HL7, CSV, or other data for healthcare integration testing.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'healthcare_phony'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install healthcare_phony
20
+
21
+ ## Usage
22
+
23
+ The general purpose of this gem is to generate various pieces of data useful in creating test healthcare integration data. Like HL7 messages or CSV files. The high level objects available are:
24
+
25
+ * Patient
26
+ * Patient Visit
27
+ * HL7 Message
28
+ * Doctor
29
+
30
+ ### Patient
31
+
32
+ ```ruby
33
+ patient = Patient.new
34
+ ```
35
+
36
+ The above will give you a default Patient object:
37
+
38
+ ```
39
+ #<HealthcarePhony::Patient:0x00007fa7ab1b8230
40
+ @account_number=
41
+ #<HealthcarePhony::Identifier:0x00007fa7a9dc3ef0
42
+ @identifier="4969529871",
43
+ @identifier_type_code="AN">,
44
+ @addresses=
45
+ [#<HealthcarePhony::Address:0x00007fa7aeb337f8
46
+ @address_line1="4973 Bruen Square",
47
+ @address_line2="Suite 628",
48
+ @address_type="L",
49
+ @address_type_data_file=nil,
50
+ @city="West Melva",
51
+ @country="",
52
+ @postal_code="48030",
53
+ @set_blank=false,
54
+ @state="MI">],
55
+ @birth_order="",
56
+ @cell_phone=
57
+ #<HealthcarePhony::CellPhoneNumber:0x00007fa7a992d238
58
+ @area_code="641",
59
+ @country_code="++1",
60
+ @equipment_type="CP",
61
+ @equipment_type_data_file=nil,
62
+ @exchange_code="586",
63
+ @set_blank=false,
64
+ @subscriber_number="9470",
65
+ @use_code="ORN",
66
+ @use_code_data_file=nil>,
67
+ @date_of_birth=#<Date: 2005-12-01 ((2453706j,0s,0n),+0s,2299161j)>,
68
+ @death_datetime=2007-11-05 15:24:26 -0500,
69
+ @death_indicator="Y",
70
+ @ethnic_group=
71
+ #<HealthcarePhony::EthnicGroup:0x00007fa7a9d94128
72
+ @code="N",
73
+ @coding_system="HL70189",
74
+ @description="Not Hispanic or Latino",
75
+ @set_blank=false>,
76
+ @gender=
77
+ #<HealthcarePhony::Gender:0x00007fa7a9983458
78
+ @code="U",
79
+ @description="Unknown">,
80
+ @home_phone=
81
+ #<HealthcarePhony::HomePhoneNumber:0x00007fa7a9906cf0
82
+ @area_code="504",
83
+ @country_code="++1",
84
+ @equipment_type="PH",
85
+ @equipment_type_data_file=nil,
86
+ @exchange_code="931",
87
+ @set_blank=false,
88
+ @subscriber_number="8965",
89
+ @use_code="PRN",
90
+ @use_code_data_file=nil>,
91
+ @language=
92
+ #<HealthcarePhony::Language:0x00007fa7a9993c40
93
+ @code="spa",
94
+ @coding_system="HL70296",
95
+ @description="spanish">,
96
+ @marital_status=
97
+ #<HealthcarePhony::MaritalStatus:0x00007fa7a99909f0
98
+ @code="T",
99
+ @coding_system="HL70002",
100
+ @description="Unreported">,
101
+ @medical_record_number=
102
+ #<HealthcarePhony::Identifier:0x00007fa7a9d9d840
103
+ @identifier="5727985905",
104
+ @identifier_type_code="MR">,
105
+ @multiple_birth_indicator="N",
106
+ @names=
107
+ [#<HealthcarePhony::PersonName:0x00007fa7ab1b80f0
108
+ @degree="CPNP",
109
+ @family_name="Murray",
110
+ @gender=nil,
111
+ @given_name="Claude",
112
+ @middle_name="Howe",
113
+ @prefix="Mr.",
114
+ @set_blank=false,
115
+ @suffix="I">],
116
+ @races=
117
+ [#<HealthcarePhony::Race:0x00007fa7a9982eb8
118
+ @code="1002-5",
119
+ @coding_system="",
120
+ @description="American Indian or Alaska Native">],
121
+ @religion=
122
+ #<HealthcarePhony::Religion:0x00007fa7a9d462e8
123
+ @code="PRO",
124
+ @coding_system="HL70006",
125
+ @description="Christian: Protestant">,
126
+ @ssn="320-79-1958",
127
+ @work_phone=
128
+ #<HealthcarePhony::WorkPhoneNumber:0x00007fa7a9959838
129
+ @area_code="508",
130
+ @country_code="++1",
131
+ @equipment_type="PH",
132
+ @equipment_type_data_file=nil,
133
+ @exchange_code="760",
134
+ @set_blank=false,
135
+ @subscriber_number="8916",
136
+ @use_code="WPN",
137
+ @use_code_data_file=nil>>
138
+ ```
139
+
140
+ The creation of the Patient can be customized by sending the following parameters when initializing:
141
+
142
+ * blank &rarr; An integer representing the % of times PatientName components should be blank.
143
+ * names_count &rarr; By default one PatientName is generated, this allows you to specify a number > 1.
144
+ * address_count &rarr; By default on Address is generated, this allows you to specify a number > 1.
145
+ * min_age &rarr; A minimum age (in years) for the Patient.
146
+ * max_age &rarr; A maximum age (in years) for the Patient.
147
+ * race_count &rarr; By default on Race is generated, this allows you to specify a number > 1.
148
+ * gender &rarr; A Gender object which will be used to generate a Male or Female name if specified.
149
+ * degree_data_file &rarr; 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 &rarr; VisitType of this patient's visit
151
+
152
+ ### Patient Visit
153
+
154
+ ```ruby
155
+ pv = HealthcarePhony::PatientVisit.new
156
+ ```
157
+
158
+ The above will give you a default PatientVisit object:
159
+
160
+ ```
161
+ #<HealthcarePhony::PatientVisit:0x00007fcb251055c0
162
+ @admission=
163
+ #<HealthcarePhony::VisitAdmission:0x00007fcb291bc6b8
164
+ @datetime=2021-01-04 05:31:33 -0500,
165
+ @reason="Tempore libero neque voluptatibus.",
166
+ @source="2",
167
+ @type="L">,
168
+ @ambulatory_status="A6",
169
+ @bed_status="K",
170
+ @discharge=
171
+ #<HealthcarePhony::VisitDischarge:0x00007fcb254b7da8
172
+ @datetime=nil,
173
+ @disposition="",
174
+ @location="">,
175
+ @doctors=
176
+ #<HealthcarePhony::VisitDoctors:0x00007fcb251054a8
177
+ @admitting=
178
+ #<HealthcarePhony::Doctor:0x00007fcb29180a50
179
+ @identifier=1777467337,
180
+ @name=
181
+ #<HealthcarePhony::PersonName:0x00007fcb291906f8
182
+ @degree="MD",
183
+ @family_name="King",
184
+ @gender=nil,
185
+ @given_name="Giuseppe",
186
+ @middle_name="Pouros",
187
+ @prefix="Miss",
188
+ @set_blank=false,
189
+ @suffix="Ret.">>,
190
+ @attending=
191
+ #<HealthcarePhony::Doctor:0x00007fcb25105480
192
+ @identifier=1847601659,
193
+ @name=
194
+ #<HealthcarePhony::PersonName:0x00007fcb25125dc0
195
+ @degree="DO",
196
+ @family_name="Breitenberg",
197
+ @gender=nil,
198
+ @given_name="Hailey",
199
+ @middle_name="Beer",
200
+ @prefix="Sen.",
201
+ @set_blank=false,
202
+ @suffix="III">>,
203
+ @consulting=
204
+ #<HealthcarePhony::Doctor:0x00007fcb291730a8
205
+ @identifier=1422794804,
206
+ @name=
207
+ #<HealthcarePhony::PersonName:0x00007fcb29182ee0
208
+ @degree="DO",
209
+ @family_name="McClure",
210
+ @gender=nil,
211
+ @given_name="Raleigh",
212
+ @middle_name="Hettinger",
213
+ @prefix="Rev.",
214
+ @set_blank=false,
215
+ @suffix="JD">>,
216
+ @referring=
217
+ #<HealthcarePhony::Doctor:0x00007fcb29151818
218
+ @identifier=1599337791,
219
+ @name=
220
+ #<HealthcarePhony::PersonName:0x00007fcb29169648
221
+ @degree="MD",
222
+ @family_name="Kreiger",
223
+ @gender=nil,
224
+ @given_name="Pierre",
225
+ @middle_name="Olson",
226
+ @prefix="Fr.",
227
+ @set_blank=false,
228
+ @suffix="PhD">>>,
229
+ @hospital_service="URO",
230
+ @location=
231
+ #<HealthcarePhony::VisitLocation:0x00007fcb2915e220
232
+ @bed="8y3",
233
+ @building="4",
234
+ @description="Numquam officiis placeat voluptatibus.",
235
+ @facility="Ipsam aut non repellat.",
236
+ @floor="81",
237
+ @point_of_care="QFDYRRTIFU",
238
+ @room="243",
239
+ @status="G",
240
+ @type="D">,
241
+ @patient_class="I",
242
+ @patient_type="",
243
+ @readmission_indicator="",
244
+ @vip_indicator="",
245
+ @visit_number=
246
+ #<HealthcarePhony::Identifier:0x00007fcb291c6b68
247
+ @identifier="3738009164",
248
+ @identifier_type_code="VN">>
249
+ ```
250
+
251
+ The creation of the PatientVisit can be customized by sending the following parameters when initializing:
252
+
253
+ * hospital_service &rarr; Array of Hospital Service codes (PV1.10) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise default HL7 v2.5.1 Table 0069 values are used.
254
+ * patient_class &rarr; Array of Patient Class codes (PV1.2) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise default HL7 v2.5.1 Table 0004 values are used.
255
+ * ambulatory_status &rarr; Array of Ambulatory Status codes (PV1.15) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise default HL7 v2.5.1 Table 0009 values are used.
256
+ * bed_status &rarr; Array of Bed Status codes (PV1.40) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise default HL7 v2.5.1 Table 0116 values are used.
257
+ * patient_type &rarr; Array of Patient Type codes (PV1.18) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise this field is left blank.
258
+ * vip_indicator &rarr; Array of Patient Type codes (PV1.18) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise this field is left blank.
259
+ * point_of_care &rarr; Array of potential points of care (PV1.3.1) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise random example generated.
260
+ * room &rarr; Array of potential rooms (PV1.3.2) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise a random 3 digit number is generated.
261
+ * bed &rarr; Array of potential beds (PV1.3.3) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise a 3 character sequence is created.
262
+ * facility &rarr; Array of potential facility names (PV1.3.4) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise a random string is generated.
263
+ * location_status &rarr; Array of potential location statuses (PV1.3.5) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise a random uppercase letter is generated to use.
264
+ * person_location_type &rarr; Array of potential person location types (PV1.3.6) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise values from HL7 v2.5.1 Table 0305 will be used.
265
+ * building &rarr; Array of potential building information (PV1.3.7) to randomly choose from. Specified as a comma separated String or Ruby array. Otherwise a random digit 1-9 is used.
266
+ * floor &rarr; Array of potential floor information (PV1.3.8) to randomly choose from. Specified as a comma separated String or Ruby array. Otherwise a random 2 digit number is used.
267
+ * location_description &rarr; Array of potential location descriptions (PV1.3.9) to randomly choose from. Specified as a comma separated String or Ruby array. Otherwise a random string is generated.
268
+ * admit_source &rarr; Array of Admit Source codes (PV1.14) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise default HL7 v2.5.1 Table 0023 values are used.
269
+ * admission_type &rarr; Array of Admission Type (PV1.4) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise default HL7 v2.5.1. Table 0007 values are used.
270
+ * admit_reason &rarr; Array of values to use as Admit Reason (PV2.3) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise a string of data is generated with Faker::Lorem.sentence
271
+ * event_type &rarr; The HL7 trigger event type that this visit is associated with.
272
+ * discharge_disposition &rarr; Array of discharge disposition codes (PV1.36) to randomly choose from. Specified as comma separated String or Ruby array. Otherwise default HL7 v2.5.1 Table 0112 values are used.
273
+ * discharge_location &rarr; 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
274
+ * admit_datetime &rarr; The admit date/time associated with this visit. If not specified the current date/time is used.
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 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
+
341
+ Also in the examples directory are two files that can be used to generate a CSV.
342
+
343
+ * phony_csv.yml &rarr; a configuration file that can be used to set parametesr for generation patients. Then two items specific to creating the CSV
344
+ * number_of_rows &rarr; The # of rows to write
345
+ * template_file &rarr; Path to a ERB template for the CSV. If not specified the default in the library is used.
346
+ * bigger_csv_example.erb &rarr; Just another CSV template example.
347
+
348
+ Using these files in IRB (or in a script) you could do:
349
+
350
+ ```ruby
351
+ csv_parameters = Psych.load_file('./examples/phony_csv.yml')
352
+ csv = HealthcarePhony::CsvFile.new(csv_parameters)
353
+ csv.to_file("d:/temp/testnewtemplate.csv")
354
+ ```
355
+ ## Contributing
356
+
357
+ 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).
358
+
359
+ ## License
360
+
361
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
362
+
363
+ ## Code of Conduct
364
+
365
+ Everyone interacting in the HealthcarePhony project's codebase, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/austinmoody/healthcare_phony/blob/master/CODE_OF_CONDUCT.md).