healthcare_phony 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +1 -0
  3. data/.github/workflows/gem-push.yml +42 -0
  4. data/.github/workflows/ruby.yml +33 -0
  5. data/.gitignore +64 -0
  6. data/.rdoc_options +23 -0
  7. data/.rubocop.yml +10 -0
  8. data/CODE_OF_CONDUCT.md +84 -0
  9. data/Gemfile +8 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +285 -0
  12. data/Rakefile +12 -0
  13. data/VERSION +1 -0
  14. data/healthcare_phony.gemspec +36 -0
  15. data/lib/healthcare_phony.rb +88 -0
  16. data/lib/healthcare_phony/address.rb +89 -0
  17. data/lib/healthcare_phony/assigning_authority.rb +6 -0
  18. data/lib/healthcare_phony/cell_phone_number.rb +20 -0
  19. data/lib/healthcare_phony/data_files/address_type.yml +7 -0
  20. data/lib/healthcare_phony/data_files/adt_event_types.yml +59 -0
  21. data/lib/healthcare_phony/data_files/degree.yml +9 -0
  22. data/lib/healthcare_phony/data_files/discharge_disposition.yml +15 -0
  23. data/lib/healthcare_phony/data_files/ethnic_group.yml +10 -0
  24. data/lib/healthcare_phony/data_files/hl7_message_types.yml +4 -0
  25. data/lib/healthcare_phony/data_files/language.yml +7 -0
  26. data/lib/healthcare_phony/data_files/marital_status.yml +49 -0
  27. data/lib/healthcare_phony/data_files/mdm_event_types.yml +12 -0
  28. data/lib/healthcare_phony/data_files/oru_event_types.yml +2 -0
  29. data/lib/healthcare_phony/data_files/race.yml +13 -0
  30. data/lib/healthcare_phony/data_files/religion.yml +250 -0
  31. data/lib/healthcare_phony/data_files/tele_equipment_type.yml +10 -0
  32. data/lib/healthcare_phony/data_files/tele_use_code.yml +9 -0
  33. data/lib/healthcare_phony/diagnosis.rb +12 -0
  34. data/lib/healthcare_phony/doctor.rb +25 -0
  35. data/lib/healthcare_phony/email.rb +25 -0
  36. data/lib/healthcare_phony/ethnic_group.rb +34 -0
  37. data/lib/healthcare_phony/gender.rb +22 -0
  38. data/lib/healthcare_phony/helper.rb +72 -0
  39. data/lib/healthcare_phony/hl7_message.rb +136 -0
  40. data/lib/healthcare_phony/home_phone_number.rb +20 -0
  41. data/lib/healthcare_phony/identifier.rb +23 -0
  42. data/lib/healthcare_phony/insurance.rb +6 -0
  43. data/lib/healthcare_phony/language.rb +30 -0
  44. data/lib/healthcare_phony/marital_status.rb +31 -0
  45. data/lib/healthcare_phony/patient.rb +114 -0
  46. data/lib/healthcare_phony/patient_visit.rb +96 -0
  47. data/lib/healthcare_phony/person_name.rb +104 -0
  48. data/lib/healthcare_phony/phone_number.rb +85 -0
  49. data/lib/healthcare_phony/procedure.rb +6 -0
  50. data/lib/healthcare_phony/race.rb +30 -0
  51. data/lib/healthcare_phony/religion.rb +32 -0
  52. data/lib/healthcare_phony/templates/adt_example.erb +6 -0
  53. data/lib/healthcare_phony/templates/csv_example.erb +4 -0
  54. data/lib/healthcare_phony/version.rb +5 -0
  55. data/lib/healthcare_phony/visit_admission.rb +53 -0
  56. data/lib/healthcare_phony/visit_discharge.rb +62 -0
  57. data/lib/healthcare_phony/visit_doctors.rb +19 -0
  58. data/lib/healthcare_phony/visit_location.rb +106 -0
  59. data/lib/healthcare_phony/work_phone_number.rb +20 -0
  60. metadata +185 -0
@@ -0,0 +1,13 @@
1
+ ---
2
+ - :code: 1002-5
3
+ :description: American Indian or Alaska Native
4
+ - :code: 2028-9
5
+ :description: Asian
6
+ - :code: 2054-5
7
+ :description: Black or African American
8
+ - :code: 2076-8
9
+ :description: Native Hawaiian or Other Pacific Islander
10
+ - :code: 2106-3
11
+ :description: White
12
+ - :code: 2131-1
13
+ :description: Other Race
@@ -0,0 +1,250 @@
1
+ ---
2
+ - :code: ABC
3
+ :description: 'Christian: American Baptist Church'
4
+ :coding_system: HL70006
5
+ - :code: AGN
6
+ :description: Agnostic
7
+ :coding_system: HL70006
8
+ - :code: AME
9
+ :description: 'Christian: African Methodist Episcopal Zion'
10
+ :coding_system: HL70006
11
+ - :code: AMT
12
+ :description: 'Christian: African Methodist Episcopal'
13
+ :coding_system: HL70006
14
+ - :code: ANG
15
+ :description: 'Christian: Anglican'
16
+ :coding_system: HL70006
17
+ - :code: AOG
18
+ :description: 'Christian: Assembly of God'
19
+ :coding_system: HL70006
20
+ - :code: ATH
21
+ :description: Atheist
22
+ :coding_system: HL70006
23
+ - :code: BAH
24
+ :description: Bahai
25
+ :coding_system: HL70006
26
+ - :code: BAP
27
+ :description: 'Christian: Baptist'
28
+ :coding_system: HL70006
29
+ - :code: BMA
30
+ :description: 'Buddhist: Mahayana'
31
+ :coding_system: HL70006
32
+ - :code: BOT
33
+ :description: 'Buddhist: Other'
34
+ :coding_system: HL70006
35
+ - :code: BTA
36
+ :description: 'Buddhist: Tantrayana'
37
+ :coding_system: HL70006
38
+ - :code: BTH
39
+ :description: 'Buddhist: Theravada'
40
+ :coding_system: HL70006
41
+ - :code: BUD
42
+ :description: Buddhist
43
+ :coding_system: HL70006
44
+ - :code: CAT
45
+ :description: 'Christian: Roman Catholic'
46
+ :coding_system: HL70006
47
+ - :code: CFR
48
+ :description: Chinese Folk Religionist
49
+ :coding_system: HL70006
50
+ - :code: CHR
51
+ :description: Christian
52
+ :coding_system: HL70006
53
+ - :code: CHS
54
+ :description: 'Christian: Christian Science'
55
+ :coding_system: HL70006
56
+ - :code: CMA
57
+ :description: 'Christian: Christian Missionary Alliance'
58
+ :coding_system: HL70006
59
+ - :code: CNF
60
+ :description: Confucian
61
+ :coding_system: HL70006
62
+ - :code: COC
63
+ :description: 'Christian: Church of Christ'
64
+ :coding_system: HL70006
65
+ - :code: COG
66
+ :description: 'Christian: Church of God'
67
+ :coding_system: HL70006
68
+ - :code: COI
69
+ :description: 'Christian: Church of God in Christ'
70
+ :coding_system: HL70006
71
+ - :code: COL
72
+ :description: 'Christian: Congregational'
73
+ :coding_system: HL70006
74
+ - :code: COM
75
+ :description: 'Christian: Community'
76
+ :coding_system: HL70006
77
+ - :code: COP
78
+ :description: 'Christian: Other Pentecostal'
79
+ :coding_system: HL70006
80
+ - :code: COT
81
+ :description: 'Christian: Other'
82
+ :coding_system: HL70006
83
+ - :code: CRR
84
+ :description: 'Christian: Christian Reformed'
85
+ :coding_system: HL70006
86
+ - :code: EOT
87
+ :description: 'Christian: Eastern Orthodox'
88
+ :coding_system: HL70006
89
+ - :code: EPI
90
+ :description: 'Christian: Episcopalian'
91
+ :coding_system: HL70006
92
+ - :code: ERL
93
+ :description: Ethnic Religionist
94
+ :coding_system: HL70006
95
+ - :code: EVC
96
+ :description: 'Christian: Evangelical Church'
97
+ :coding_system: HL70006
98
+ - :code: FRQ
99
+ :description: 'Christian: Friends'
100
+ :coding_system: HL70006
101
+ - :code: FWB
102
+ :description: 'Christian: Free Will Baptist'
103
+ :coding_system: HL70006
104
+ - :code: GRE
105
+ :description: 'Christian: Greek Orthodox'
106
+ :coding_system: HL70006
107
+ - :code: HIN
108
+ :description: Hindu
109
+ :coding_system: HL70006
110
+ - :code: HOT
111
+ :description: 'Hindu: Other'
112
+ :coding_system: HL70006
113
+ - :code: HSH
114
+ :description: 'Hindu: Shaivites'
115
+ :coding_system: HL70006
116
+ - :code: HVA
117
+ :description: 'Hindu: Vaishnavites'
118
+ :coding_system: HL70006
119
+ - :code: JAI
120
+ :description: Jain
121
+ :coding_system: HL70006
122
+ - :code: JCO
123
+ :description: 'Jewish: Conservative'
124
+ :coding_system: HL70006
125
+ - :code: JEW
126
+ :description: Jewish
127
+ :coding_system: HL70006
128
+ - :code: JOR
129
+ :description: 'Jewish: Orthodox'
130
+ :coding_system: HL70006
131
+ - :code: JOT
132
+ :description: 'Jewish: Other'
133
+ :coding_system: HL70006
134
+ - :code: JRC
135
+ :description: 'Jewish: Reconstructionist'
136
+ :coding_system: HL70006
137
+ - :code: JRF
138
+ :description: 'Jewish: Reform'
139
+ :coding_system: HL70006
140
+ - :code: JRN
141
+ :description: 'Jewish: Renewal'
142
+ :coding_system: HL70006
143
+ - :code: JWN
144
+ :description: 'Christian: Jehovahs Witness'
145
+ :coding_system: HL70006
146
+ - :code: LMS
147
+ :description: 'Christian: Lutheran Missouri Synod'
148
+ :coding_system: HL70006
149
+ - :code: LUT
150
+ :description: 'Christian: Lutheran'
151
+ :coding_system: HL70006
152
+ - :code: MEN
153
+ :description: 'Christian: Mennonite'
154
+ :coding_system: HL70006
155
+ - :code: MET
156
+ :description: 'Christian: Methodist'
157
+ :coding_system: HL70006
158
+ - :code: MOM
159
+ :description: 'Christian: Latter-day Saints'
160
+ :coding_system: HL70006
161
+ - :code: MOS
162
+ :description: Muslim
163
+ :coding_system: HL70006
164
+ - :code: MOT
165
+ :description: 'Muslim: Other'
166
+ :coding_system: HL70006
167
+ - :code: MSH
168
+ :description: 'Muslim: Shiite'
169
+ :coding_system: HL70006
170
+ - :code: MSU
171
+ :description: 'Muslim: Sunni'
172
+ :coding_system: HL70006
173
+ - :code: NAM
174
+ :description: Native American
175
+ :coding_system: HL70006
176
+ - :code: NAZ
177
+ :description: 'Christian: Church of the Nazarene'
178
+ :coding_system: HL70006
179
+ - :code: NOE
180
+ :description: Nonreligious
181
+ :coding_system: HL70006
182
+ - :code: NRL
183
+ :description: New Religionist
184
+ :coding_system: HL70006
185
+ - :code: ORT
186
+ :description: 'Christian: Orthodox'
187
+ :coding_system: HL70006
188
+ - :code: OTH
189
+ :description: Other
190
+ :coding_system: HL70006
191
+ - :code: PEN
192
+ :description: 'Christian: Pentecostal'
193
+ :coding_system: HL70006
194
+ - :code: PRC
195
+ :description: 'Christian: Other Protestant'
196
+ :coding_system: HL70006
197
+ - :code: PRE
198
+ :description: 'Christian: Presbyterian'
199
+ :coding_system: HL70006
200
+ - :code: PRO
201
+ :description: 'Christian: Protestant'
202
+ :coding_system: HL70006
203
+ - :code: QUA
204
+ :description: 'Christian: Friends'
205
+ :coding_system: HL70006
206
+ - :code: REC
207
+ :description: 'Christian: Reformed Church'
208
+ :coding_system: HL70006
209
+ - :code: REO
210
+ :description: 'Christian: Reorganized Church of Jesus Christ-LDS'
211
+ :coding_system: HL70006
212
+ - :code: SAA
213
+ :description: 'Christian: Salvation Army'
214
+ :coding_system: HL70006
215
+ - :code: SEV
216
+ :description: 'Christian: Seventh Day Adventist'
217
+ :coding_system: HL70006
218
+ - :code: SHN
219
+ :description: Shintoist
220
+ :coding_system: HL70006
221
+ - :code: SIK
222
+ :description: Sikh
223
+ :coding_system: HL70006
224
+ - :code: SOU
225
+ :description: 'Christian: Southern Baptist'
226
+ :coding_system: HL70006
227
+ - :code: SPI
228
+ :description: Spiritist
229
+ :coding_system: HL70006
230
+ - :code: UCC
231
+ :description: 'Christian: United Church of Christ'
232
+ :coding_system: HL70006
233
+ - :code: UMD
234
+ :description: 'Christian: United Methodist'
235
+ :coding_system: HL70006
236
+ - :code: UNI
237
+ :description: 'Christian: Unitarian'
238
+ :coding_system: HL70006
239
+ - :code: UNU
240
+ :description: 'Christian: Unitarian Universalist'
241
+ :coding_system: HL70006
242
+ - :code: VAR
243
+ :description: Unknown
244
+ :coding_system: HL70006
245
+ - :code: WES
246
+ :description: 'Christian: Wesleyan'
247
+ :coding_system: HL70006
248
+ - :code: WMC
249
+ :description: 'Christian: Wesleyan Methodist'
250
+ :coding_system: HL70006
@@ -0,0 +1,10 @@
1
+ ---
2
+ - BP
3
+ - CP
4
+ - FX
5
+ - Internet
6
+ - MD
7
+ - PH
8
+ - TDD
9
+ - TTY
10
+ - X.400
@@ -0,0 +1,9 @@
1
+ ---
2
+ - ASN
3
+ - BPN
4
+ - EMR
5
+ - NET
6
+ - ORN
7
+ - PRN
8
+ - VHN
9
+ - WPN
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HealthcarePhony
4
+ class Diagnosis
5
+ attr_accessor :coding_method,
6
+ :code,
7
+ :description,
8
+ :coding_system,
9
+ :date_time,
10
+ :type
11
+ end
12
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HealthcarePhony
4
+ # Public: Generates a fake Doctor
5
+ class Doctor
6
+ # Public: Gets/Sets the String identifier of the doctor.
7
+ attr_accessor :identifier
8
+ # Public: Gets/Sets the PersonName name of the doctor.
9
+ attr_accessor :name
10
+
11
+ # Public: Initialize a Doctor. Pass in hash of different parameters, currently this includes:
12
+ #
13
+ # identifier - Allows you to specify an identifier for this Doctor instead of having it randomly generated.
14
+ def initialize(**init_args)
15
+ @identifier = if !init_args[:identifier].nil?
16
+ init_args[:identifier]
17
+ else
18
+ pre_check_npi = /1[0-9]{8}/.random_example.to_i
19
+ (pre_check_npi.to_s + Helper.get_npi_check_digit(pre_check_npi).to_s).to_i
20
+ end
21
+
22
+ @name = PersonName.new(degree: 'MD,DO')
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HealthcarePhony
4
+ # Public: Generate a fake email address
5
+ class Email
6
+ attr_accessor :email_address,
7
+ :use_code,
8
+ :equipment_type
9
+
10
+ def initialize(**init_args)
11
+ @set_blank = !init_args[:blank].nil? && Helper.random_with_blank('X', init_args[:blank]) == ''
12
+ @email_address = Faker::Internet.email
13
+ @email_address = '' unless @set_blank == false
14
+ @use_code = @email_address == '' ? '' : 'NET'
15
+ @use_code = '' unless @set_blank == false
16
+ @equipment_type = @email_address == '' ? '' : 'X.400'
17
+ @equipment_type = '' unless @set_blank == false
18
+ end
19
+
20
+ private
21
+
22
+ # Private: Boolean set during initialization if Address components should be set to blank.
23
+ attr_accessor :set_blank
24
+ end
25
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HealthcarePhony
4
+ # Public: Randomly generates an ethnic group
5
+ class EthnicGroup
6
+ attr_accessor :code,
7
+ :description,
8
+ :coding_system
9
+
10
+ # Public: Initializes an EthnicGroup. Pass in hash of different parameters, currently this includes:
11
+ # blank - An integer representing the % of times EthnicGroup components should be blank.
12
+ # ethnic_group_data_file - YAML file containing ethnic group information to randomly choose from if different options than
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
+ # for default values.
15
+ def initialize(**init_args)
16
+ @set_blank = !init_args[:blank].nil? && Helper.random_with_blank('X', init_args[:blank]) == ''
17
+ data_file = if !init_args[:ethnic_group_data_file].nil?
18
+ init_args[:ethnic_group_data_file]
19
+ else
20
+ "#{::File.expand_path(::File.join("..", "data_files"), __FILE__)}/ethnic_group.yml"
21
+ end
22
+ e_array = Psych.load_file(data_file)
23
+ random_ethnic = e_array.nil? ? '' : e_array.sample
24
+ @code = @set_blank == true ? '' : random_ethnic[:code]
25
+ @description = @set_blank == true ? '' : random_ethnic[:description]
26
+ @coding_system = @set_blank == true ? '' : random_ethnic[:coding_system]
27
+ end
28
+
29
+ private
30
+
31
+ # Private: Boolean set during initialization if Address components should be set to blank.
32
+ attr_accessor :set_blank
33
+ end
34
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HealthcarePhony
4
+ # Public: Randomly generates a Gender.
5
+ class Gender
6
+ attr_accessor :code,
7
+ :description
8
+
9
+ # Public: Initializes a Gender. Pass in hash of different parameters, currently this includes:
10
+ # blank - An integer representing the % of times Address components should be blank.
11
+ def initialize(**init_args)
12
+ @description = %w[Female Male Unknown].sample
13
+
14
+ @description = if !init_args[:blank].nil?
15
+ Helper.random_with_blank(@description, init_args[:blank])
16
+ else
17
+ @description
18
+ end
19
+ @code = @description == '' ? '' : @description[0]
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HealthcarePhony
4
+ class Helper
5
+ class << self
6
+ def random_with_blank(non_blank_value, blank_percentage)
7
+ b_array = [[non_blank_value, (100 - blank_percentage)], ['', blank_percentage]]
8
+ b_array.max_by { |_, weight| rand**100.fdiv(weight) }[0]
9
+ end
10
+
11
+ def get_array(input_argument)
12
+ return_array = []
13
+
14
+ if !input_argument.nil? && input_argument.instance_of?(Array)
15
+ return_array = input_argument
16
+ elsif !input_argument.nil? && input_argument.instance_of?(String)
17
+ return_array = input_argument.split(',')
18
+ end
19
+
20
+ return_array
21
+ end
22
+
23
+ def npi_step_one(input)
24
+ # Step 1: Double the value of alternate digits, beginning with the rightmost digit.
25
+ npi = []
26
+ input.to_s.split('').reverse.each_with_index do |n, i|
27
+ npi.push((n.to_i * 2).to_s) if (i + 1).odd?
28
+ end
29
+ npi.reverse!
30
+ total = 0
31
+ npi.join('').split('').each do |x|
32
+ total += x.to_i
33
+ end
34
+ total
35
+ end
36
+
37
+ def npi_step_two(input, step_one_total)
38
+ # Step 2: Add constant 24, to account for the 80840 prefix that would be present on a card issuer identifier,
39
+ # plus the individual digits of products of doubling, plus unaffected digits.
40
+ (24 + step_one_total + double_alternate_digits(input))
41
+ end
42
+
43
+ def next_number_end_with_zero(input)
44
+ input += 1 while input.to_s[-1] != '0'
45
+ input
46
+ end
47
+
48
+ def double_alternate_digits(npi)
49
+ a_total = 0
50
+ counter = 1
51
+ npi.to_s.split('').each do |n|
52
+ a_total += n.to_i if counter.even?
53
+ counter += 1
54
+ end
55
+ a_total
56
+ end
57
+
58
+ def get_npi_check_digit(npi)
59
+ step_one = npi_step_one(npi)
60
+
61
+ # Add totals from above two steps + 24
62
+ # c_total = 24 + a_total + b_total
63
+ step_two = npi_step_two(npi, step_one)
64
+
65
+ next_high = next_number_end_with_zero(step_two)
66
+
67
+ # Step 3: Subtract from next higher number ending in zero.
68
+ (next_high - step_two)
69
+ end
70
+ end
71
+ end
72
+ end