healthcare_phony 0.6.0 → 0.7s.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/gem-push.yml +42 -42
- data/.github/workflows/ruby.yml +33 -33
- data/.gitignore +63 -63
- data/.rdoc_options +23 -23
- data/.rubocop.yml +10 -10
- data/CODE_OF_CONDUCT.md +84 -84
- data/Gemfile +8 -8
- data/LICENSE.txt +21 -21
- data/README.md +365 -351
- data/Rakefile +12 -12
- data/VERSION +1 -1
- data/examples/bigger_csv_example.erb +4 -0
- data/examples/phony_adt_sender.rb +111 -111
- data/examples/phony_adt_sender.yml +12 -10
- data/examples/phony_csv.yml +5 -0
- data/healthcare_phony.gemspec +36 -36
- data/lib/healthcare_phony.rb +139 -113
- data/lib/healthcare_phony/address.rb +89 -89
- data/lib/healthcare_phony/assigning_authority.rb +6 -6
- data/lib/healthcare_phony/cell_phone_number.rb +20 -20
- data/lib/healthcare_phony/data_files/address_type.yml +7 -7
- data/lib/healthcare_phony/data_files/adt_event_types.yml +59 -59
- data/lib/healthcare_phony/data_files/degree.yml +9 -9
- data/lib/healthcare_phony/data_files/discharge_disposition.yml +15 -15
- data/lib/healthcare_phony/data_files/ethnic_group.yml +9 -9
- data/lib/healthcare_phony/data_files/hl7_message_types.yml +4 -4
- data/lib/healthcare_phony/data_files/language.yml +7 -7
- data/lib/healthcare_phony/data_files/marital_status.yml +49 -49
- data/lib/healthcare_phony/data_files/mdm_event_types.yml +12 -12
- data/lib/healthcare_phony/data_files/oru_event_types.yml +2 -2
- data/lib/healthcare_phony/data_files/race.yml +13 -13
- data/lib/healthcare_phony/data_files/religion.yml +250 -250
- data/lib/healthcare_phony/data_files/tele_equipment_type.yml +10 -10
- data/lib/healthcare_phony/data_files/tele_use_code.yml +9 -9
- data/lib/healthcare_phony/diagnosis.rb +12 -12
- data/lib/healthcare_phony/doctor.rb +26 -26
- data/lib/healthcare_phony/email.rb +25 -25
- data/lib/healthcare_phony/ethnic_group.rb +34 -34
- data/lib/healthcare_phony/gender.rb +22 -22
- data/lib/healthcare_phony/helper.rb +72 -72
- data/lib/healthcare_phony/hl7_message.rb +159 -159
- data/lib/healthcare_phony/home_phone_number.rb +20 -20
- data/lib/healthcare_phony/identifier.rb +23 -23
- data/lib/healthcare_phony/insurance.rb +6 -6
- data/lib/healthcare_phony/language.rb +30 -30
- data/lib/healthcare_phony/marital_status.rb +31 -31
- data/lib/healthcare_phony/patient.rb +114 -114
- data/lib/healthcare_phony/patient_visit.rb +97 -97
- data/lib/healthcare_phony/person_name.rb +104 -104
- data/lib/healthcare_phony/phone_number.rb +85 -85
- data/lib/healthcare_phony/procedure.rb +6 -6
- data/lib/healthcare_phony/race.rb +31 -31
- data/lib/healthcare_phony/religion.rb +32 -32
- data/lib/healthcare_phony/templates/csv_example.erb +3 -3
- data/lib/healthcare_phony/version.rb +5 -5
- data/lib/healthcare_phony/visit_admission.rb +53 -53
- data/lib/healthcare_phony/visit_discharge.rb +62 -62
- data/lib/healthcare_phony/visit_doctors.rb +19 -19
- data/lib/healthcare_phony/visit_location.rb +106 -106
- data/lib/healthcare_phony/visit_type.rb +8 -8
- data/lib/healthcare_phony/work_phone_number.rb +20 -20
- metadata +9 -7
@@ -1,97 +1,97 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module HealthcarePhony
|
4
|
-
# Public: Randomly generates data for a PatientVisit (PV1 segment)
|
5
|
-
class PatientVisit
|
6
|
-
attr_accessor :patient_class,
|
7
|
-
:admission, :doctors,
|
8
|
-
:hospital_service, :readmission_indicator,
|
9
|
-
:ambulatory_status, :vip_indicator, :patient_type,
|
10
|
-
:visit_number, :bed_status,
|
11
|
-
:discharge, :location
|
12
|
-
|
13
|
-
# Public: Initializes an Address. Pass in hash of different parameters, currently this includes:
|
14
|
-
# hospital_service - Array of Hospital Service codes (PV1.10) to randomly choose from. Specified as comma separated
|
15
|
-
# String or Ruby array. Otherwise default HL7 v2.5.1 Table 0069 values are used.
|
16
|
-
# patient_class - Array of Patient Class codes (PV1.2) to randomly choose from. Specified as comma separated
|
17
|
-
# String or Ruby array. Otherwise default HL7 v2.5.1 Table 0004 values are used.
|
18
|
-
# ambulatory_status - Array of Ambulatory Status codes (PV1.15) to randomly choose from. Specified as comma
|
19
|
-
# separated String or Ruby array. Otherwise default HL7 v2.5.1 Table 0009 values are used.
|
20
|
-
# bed_status - Array of Bed Status codes (PV1.40) to randomly choose from. Specified as comma separated String or
|
21
|
-
# Ruby array. Otherwise default HL7 v2.5.1 Table 0116 values are used.
|
22
|
-
# patient_type - Array of Patient Type codes (PV1.18) to randomly choose from. Specified as comma separated String
|
23
|
-
# or Ruby array. Otherwise this field is left blank.
|
24
|
-
# vip_indicator - Array of Patient Type codes (PV1.18) to randomly choose from. Specified as comma separated String
|
25
|
-
# or Ruby array. Otherwise this field is left blank.
|
26
|
-
# visit_type - VisitType of the patient's visit
|
27
|
-
def initialize(init_args = {})
|
28
|
-
@doctors = VisitDoctors.new(init_args)
|
29
|
-
@location = VisitLocation.new(init_args)
|
30
|
-
@admission = VisitAdmission.new(init_args)
|
31
|
-
@bed_status = define_bed_status(init_args)
|
32
|
-
@visit_number = Identifier.new(type_code: 'VN')
|
33
|
-
@readmission_indicator = Helper.random_with_blank('R', 50)
|
34
|
-
@patient_type = define_patient_type(init_args)
|
35
|
-
@vip_indicator = define_vip(init_args)
|
36
|
-
@ambulatory_status = define_ambulatory_status(init_args)
|
37
|
-
@patient_class = define_patient_class(init_args)
|
38
|
-
@hospital_service = define_hospital_service(init_args)
|
39
|
-
@discharge = VisitDischarge.new(init_args.merge({ admit_datetime: @admission.datetime }))
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def define_hospital_service(init_args = {})
|
45
|
-
standard_hospital_service = %w[CAR MED PUL SUR URO]
|
46
|
-
hs_choices = Helper.get_array(init_args[:hospital_service])
|
47
|
-
if !hs_choices.empty?
|
48
|
-
hs_choices.sample
|
49
|
-
else
|
50
|
-
standard_hospital_service.sample
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def define_patient_class(init_args = {})
|
55
|
-
standard_pc_choices = %w[B C E I N O P R U]
|
56
|
-
pc_choices = Helper.get_array(init_args[:patient_class])
|
57
|
-
!pc_choices.empty? ? pc_choices.sample : standard_pc_choices.sample
|
58
|
-
end
|
59
|
-
|
60
|
-
def define_ambulatory_status(init_args = {})
|
61
|
-
standard_ambulatory_status = %w[A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 B1 B2 B3 B4 B5 B6]
|
62
|
-
as_choices = Helper.get_array(init_args[:ambulatory_status])
|
63
|
-
if !as_choices.empty?
|
64
|
-
as_choices.sample
|
65
|
-
else
|
66
|
-
standard_ambulatory_status.sample
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def define_bed_status(init_args = {})
|
71
|
-
bs_choices = Helper.get_array(init_args[:bed_status])
|
72
|
-
if !bs_choices.empty?
|
73
|
-
bs_choices.sample
|
74
|
-
else
|
75
|
-
%w[C H I K O U].sample
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def define_patient_type(init_args = {})
|
80
|
-
pt_choices = Helper.get_array(init_args[:patient_type])
|
81
|
-
if !pt_choices.empty?
|
82
|
-
pt_choices.sample
|
83
|
-
else
|
84
|
-
''
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def define_vip(init_args = {})
|
89
|
-
vip_choices = Helper.get_array(init_args[:vip_indicator])
|
90
|
-
if !vip_choices.empty?
|
91
|
-
vip_choices.sample
|
92
|
-
else
|
93
|
-
''
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HealthcarePhony
|
4
|
+
# Public: Randomly generates data for a PatientVisit (PV1 segment)
|
5
|
+
class PatientVisit
|
6
|
+
attr_accessor :patient_class,
|
7
|
+
:admission, :doctors,
|
8
|
+
:hospital_service, :readmission_indicator,
|
9
|
+
:ambulatory_status, :vip_indicator, :patient_type,
|
10
|
+
:visit_number, :bed_status,
|
11
|
+
:discharge, :location
|
12
|
+
|
13
|
+
# Public: Initializes an Address. Pass in hash of different parameters, currently this includes:
|
14
|
+
# hospital_service - Array of Hospital Service codes (PV1.10) to randomly choose from. Specified as comma separated
|
15
|
+
# String or Ruby array. Otherwise default HL7 v2.5.1 Table 0069 values are used.
|
16
|
+
# patient_class - Array of Patient Class codes (PV1.2) to randomly choose from. Specified as comma separated
|
17
|
+
# String or Ruby array. Otherwise default HL7 v2.5.1 Table 0004 values are used.
|
18
|
+
# ambulatory_status - Array of Ambulatory Status codes (PV1.15) to randomly choose from. Specified as comma
|
19
|
+
# separated String or Ruby array. Otherwise default HL7 v2.5.1 Table 0009 values are used.
|
20
|
+
# bed_status - Array of Bed Status codes (PV1.40) to randomly choose from. Specified as comma separated String or
|
21
|
+
# Ruby array. Otherwise default HL7 v2.5.1 Table 0116 values are used.
|
22
|
+
# patient_type - Array of Patient Type codes (PV1.18) to randomly choose from. Specified as comma separated String
|
23
|
+
# or Ruby array. Otherwise this field is left blank.
|
24
|
+
# vip_indicator - Array of Patient Type codes (PV1.18) to randomly choose from. Specified as comma separated String
|
25
|
+
# or Ruby array. Otherwise this field is left blank.
|
26
|
+
# visit_type - VisitType of the patient's visit
|
27
|
+
def initialize(init_args = {})
|
28
|
+
@doctors = VisitDoctors.new(init_args)
|
29
|
+
@location = VisitLocation.new(init_args)
|
30
|
+
@admission = VisitAdmission.new(init_args)
|
31
|
+
@bed_status = define_bed_status(init_args)
|
32
|
+
@visit_number = Identifier.new(type_code: 'VN')
|
33
|
+
@readmission_indicator = Helper.random_with_blank('R', 50)
|
34
|
+
@patient_type = define_patient_type(init_args)
|
35
|
+
@vip_indicator = define_vip(init_args)
|
36
|
+
@ambulatory_status = define_ambulatory_status(init_args)
|
37
|
+
@patient_class = define_patient_class(init_args)
|
38
|
+
@hospital_service = define_hospital_service(init_args)
|
39
|
+
@discharge = VisitDischarge.new(init_args.merge({ admit_datetime: @admission.datetime }))
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def define_hospital_service(init_args = {})
|
45
|
+
standard_hospital_service = %w[CAR MED PUL SUR URO]
|
46
|
+
hs_choices = Helper.get_array(init_args[:hospital_service])
|
47
|
+
if !hs_choices.empty?
|
48
|
+
hs_choices.sample
|
49
|
+
else
|
50
|
+
standard_hospital_service.sample
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def define_patient_class(init_args = {})
|
55
|
+
standard_pc_choices = %w[B C E I N O P R U]
|
56
|
+
pc_choices = Helper.get_array(init_args[:patient_class])
|
57
|
+
!pc_choices.empty? ? pc_choices.sample : standard_pc_choices.sample
|
58
|
+
end
|
59
|
+
|
60
|
+
def define_ambulatory_status(init_args = {})
|
61
|
+
standard_ambulatory_status = %w[A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 B1 B2 B3 B4 B5 B6]
|
62
|
+
as_choices = Helper.get_array(init_args[:ambulatory_status])
|
63
|
+
if !as_choices.empty?
|
64
|
+
as_choices.sample
|
65
|
+
else
|
66
|
+
standard_ambulatory_status.sample
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def define_bed_status(init_args = {})
|
71
|
+
bs_choices = Helper.get_array(init_args[:bed_status])
|
72
|
+
if !bs_choices.empty?
|
73
|
+
bs_choices.sample
|
74
|
+
else
|
75
|
+
%w[C H I K O U].sample
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def define_patient_type(init_args = {})
|
80
|
+
pt_choices = Helper.get_array(init_args[:patient_type])
|
81
|
+
if !pt_choices.empty?
|
82
|
+
pt_choices.sample
|
83
|
+
else
|
84
|
+
''
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def define_vip(init_args = {})
|
89
|
+
vip_choices = Helper.get_array(init_args[:vip_indicator])
|
90
|
+
if !vip_choices.empty?
|
91
|
+
vip_choices.sample
|
92
|
+
else
|
93
|
+
''
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -1,104 +1,104 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module HealthcarePhony
|
4
|
-
# Public: Randomly generates a patient name.
|
5
|
-
class PersonName
|
6
|
-
attr_accessor :family_name,
|
7
|
-
:given_name,
|
8
|
-
:middle_name,
|
9
|
-
:suffix,
|
10
|
-
:prefix,
|
11
|
-
:degree
|
12
|
-
|
13
|
-
# Public: Initializes an Address. Pass in hash of different parameters, currently this includes:
|
14
|
-
# blank - An integer representing the % of times PatientName components should be blank.
|
15
|
-
# gender - A Gender object which will be used to generate a Male or Female name if specified.
|
16
|
-
# degree_data_file - Location of YAML file containing a list of potential degrees to choose from. By default the
|
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 = {})
|
19
|
-
@set_blank = !init_args[:blank].nil? && Helper.random_with_blank('X', init_args[:blank]) == ''
|
20
|
-
@gender = init_args[:gender]
|
21
|
-
@degree_data_file = get_degree_data_file(init_args)
|
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
|
-
@middle_name = define_middle_name
|
25
|
-
@suffix = define_suffix
|
26
|
-
@prefix = define_prefix
|
27
|
-
@degree = define_degree(init_args)
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
# Private: Boolean set during initialization if Address components should be set to blank.
|
33
|
-
attr_accessor :set_blank
|
34
|
-
attr_accessor :degree_data_file
|
35
|
-
|
36
|
-
def get_degree_data_file(init_args = {})
|
37
|
-
if !init_args[:degree_data_file].nil?
|
38
|
-
init_args[:degree_data_file]
|
39
|
-
else
|
40
|
-
"#{::File.expand_path(::File.join("..", "data_files"), __FILE__)}/degree.yml"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def define_given_name
|
45
|
-
if @set_blank
|
46
|
-
''
|
47
|
-
elsif !@gender.nil? && @gender.code == 'M'
|
48
|
-
Faker::Name.male_first_name
|
49
|
-
elsif !@gender.nil? && @gender.code == 'F'
|
50
|
-
Faker::Name.female_first_name
|
51
|
-
else
|
52
|
-
Faker::Name.first_name
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def define_family_name
|
57
|
-
if @set_blank
|
58
|
-
''
|
59
|
-
else
|
60
|
-
Faker::Name.last_name
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def define_middle_name
|
65
|
-
if @set_blank
|
66
|
-
''
|
67
|
-
else
|
68
|
-
Faker::Name.middle_name
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def define_suffix
|
73
|
-
if @set_blank
|
74
|
-
''
|
75
|
-
else
|
76
|
-
Faker::Name.suffix
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def define_prefix
|
81
|
-
if @set_blank
|
82
|
-
''
|
83
|
-
else
|
84
|
-
Faker::Name.prefix
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def define_degree(init_args = {})
|
89
|
-
if @set_blank
|
90
|
-
''
|
91
|
-
elsif !init_args[:degree].nil?
|
92
|
-
degree_choices = Helper.get_array(init_args[:degree])
|
93
|
-
degree_choices.sample unless degree_choices.empty?
|
94
|
-
else
|
95
|
-
degrees_from_file
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def degrees_from_file
|
100
|
-
degrees = Psych.load_file(@degree_data_file)
|
101
|
-
degrees.nil? ? '' : degrees.sample
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HealthcarePhony
|
4
|
+
# Public: Randomly generates a patient name.
|
5
|
+
class PersonName
|
6
|
+
attr_accessor :family_name,
|
7
|
+
:given_name,
|
8
|
+
:middle_name,
|
9
|
+
:suffix,
|
10
|
+
:prefix,
|
11
|
+
:degree
|
12
|
+
|
13
|
+
# Public: Initializes an Address. Pass in hash of different parameters, currently this includes:
|
14
|
+
# blank - An integer representing the % of times PatientName components should be blank.
|
15
|
+
# gender - A Gender object which will be used to generate a Male or Female name if specified.
|
16
|
+
# degree_data_file - Location of YAML file containing a list of potential degrees to choose from. By default the
|
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 = {})
|
19
|
+
@set_blank = !init_args[:blank].nil? && Helper.random_with_blank('X', init_args[:blank]) == ''
|
20
|
+
@gender = init_args[:gender]
|
21
|
+
@degree_data_file = get_degree_data_file(init_args)
|
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
|
+
@middle_name = define_middle_name
|
25
|
+
@suffix = define_suffix
|
26
|
+
@prefix = define_prefix
|
27
|
+
@degree = define_degree(init_args)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# Private: Boolean set during initialization if Address components should be set to blank.
|
33
|
+
attr_accessor :set_blank
|
34
|
+
attr_accessor :degree_data_file
|
35
|
+
|
36
|
+
def get_degree_data_file(init_args = {})
|
37
|
+
if !init_args[:degree_data_file].nil?
|
38
|
+
init_args[:degree_data_file]
|
39
|
+
else
|
40
|
+
"#{::File.expand_path(::File.join("..", "data_files"), __FILE__)}/degree.yml"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def define_given_name
|
45
|
+
if @set_blank
|
46
|
+
''
|
47
|
+
elsif !@gender.nil? && @gender.code == 'M'
|
48
|
+
Faker::Name.male_first_name
|
49
|
+
elsif !@gender.nil? && @gender.code == 'F'
|
50
|
+
Faker::Name.female_first_name
|
51
|
+
else
|
52
|
+
Faker::Name.first_name
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def define_family_name
|
57
|
+
if @set_blank
|
58
|
+
''
|
59
|
+
else
|
60
|
+
Faker::Name.last_name
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def define_middle_name
|
65
|
+
if @set_blank
|
66
|
+
''
|
67
|
+
else
|
68
|
+
Faker::Name.middle_name
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def define_suffix
|
73
|
+
if @set_blank
|
74
|
+
''
|
75
|
+
else
|
76
|
+
Faker::Name.suffix
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def define_prefix
|
81
|
+
if @set_blank
|
82
|
+
''
|
83
|
+
else
|
84
|
+
Faker::Name.prefix
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def define_degree(init_args = {})
|
89
|
+
if @set_blank
|
90
|
+
''
|
91
|
+
elsif !init_args[:degree].nil?
|
92
|
+
degree_choices = Helper.get_array(init_args[:degree])
|
93
|
+
degree_choices.sample unless degree_choices.empty?
|
94
|
+
else
|
95
|
+
degrees_from_file
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def degrees_from_file
|
100
|
+
degrees = Psych.load_file(@degree_data_file)
|
101
|
+
degrees.nil? ? '' : degrees.sample
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -1,85 +1,85 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module HealthcarePhony
|
4
|
-
# Public: Generates a fake phone number
|
5
|
-
class PhoneNumber
|
6
|
-
attr_accessor :number,
|
7
|
-
:country_code,
|
8
|
-
:area_code,
|
9
|
-
:exchange_code,
|
10
|
-
:subscriber_number,
|
11
|
-
:use_code,
|
12
|
-
:equipment_type
|
13
|
-
|
14
|
-
def initialize(init_args = {})
|
15
|
-
# Public: Initializes a home phone number. Pass in hash of different parameters, currently this includes:
|
16
|
-
# blank - An integer representing the % of times phone number components should be blank.
|
17
|
-
# use_code_data_file - YAML file containing use codes to randomly choose from. If not specified then values from
|
18
|
-
# {tele_use_code.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/tele_use_code.yml] are used.
|
19
|
-
# equipment_type_data_file - YAML file containing equipment type codes to randomly choose from. If not specified
|
20
|
-
# then values {tele_equipment_type}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/tele_equipment_type.yml] will be used.
|
21
|
-
@set_blank = !init_args[:blank].nil? && Helper.random_with_blank('X', init_args[:blank]) == ''
|
22
|
-
@use_code_data_file = init_args[:use_code_data_file]
|
23
|
-
@equipment_type_data_file = init_args[:equipment_type_data_file]
|
24
|
-
define_country_code
|
25
|
-
define_area_code
|
26
|
-
define_exchange_code
|
27
|
-
define_subscriber_number
|
28
|
-
define_use_code
|
29
|
-
define_equipment_type
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
# Private: Boolean set during initialization if Address components should be set to blank.
|
35
|
-
attr_accessor :set_blank
|
36
|
-
|
37
|
-
# Private: Location of data file of use codes
|
38
|
-
attr_accessor :use_code_data_file
|
39
|
-
|
40
|
-
# Private: Location of data file of equipment types
|
41
|
-
attr_accessor :equipment_type_data_file
|
42
|
-
|
43
|
-
def define_country_code
|
44
|
-
@country_code = Faker::PhoneNumber.country_code
|
45
|
-
@country_code = '' unless @set_blank == false
|
46
|
-
end
|
47
|
-
|
48
|
-
def define_area_code
|
49
|
-
@area_code = Faker::PhoneNumber.area_code
|
50
|
-
@area_code = '' unless @set_blank == false
|
51
|
-
end
|
52
|
-
|
53
|
-
def define_exchange_code
|
54
|
-
@exchange_code = Faker::PhoneNumber.exchange_code
|
55
|
-
@exchange_code = '' unless @set_blank == false
|
56
|
-
end
|
57
|
-
|
58
|
-
def define_subscriber_number
|
59
|
-
@subscriber_number = Faker::PhoneNumber.subscriber_number
|
60
|
-
@subscriber_number = '' unless @set_blank == false
|
61
|
-
end
|
62
|
-
|
63
|
-
def define_use_code
|
64
|
-
data_file = if !@use_code_data_file.nil?
|
65
|
-
@use_code_data_file
|
66
|
-
else
|
67
|
-
"#{::File.expand_path(::File.join("..", "data_files"), __FILE__)}/tele_use_code.yml"
|
68
|
-
end
|
69
|
-
use_codes = Psych.load_file(data_file)
|
70
|
-
@use_code = use_codes.nil? ? '' : use_codes.sample
|
71
|
-
@use_code = '' unless @set_blank == false
|
72
|
-
end
|
73
|
-
|
74
|
-
def define_equipment_type
|
75
|
-
data_file = if !@equipment_type_data_file.nil?
|
76
|
-
@equipment_type_data_file
|
77
|
-
else
|
78
|
-
"#{::File.expand_path(::File.join("..", "data_files"), __FILE__)}/tele_equipment_type.yml"
|
79
|
-
end
|
80
|
-
equipment_types = Psych.load_file(data_file)
|
81
|
-
@equipment_type = equipment_types.nil? ? '' : equipment_types.sample
|
82
|
-
@equipment_type = '' unless @set_blank == false
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HealthcarePhony
|
4
|
+
# Public: Generates a fake phone number
|
5
|
+
class PhoneNumber
|
6
|
+
attr_accessor :number,
|
7
|
+
:country_code,
|
8
|
+
:area_code,
|
9
|
+
:exchange_code,
|
10
|
+
:subscriber_number,
|
11
|
+
:use_code,
|
12
|
+
:equipment_type
|
13
|
+
|
14
|
+
def initialize(init_args = {})
|
15
|
+
# Public: Initializes a home phone number. Pass in hash of different parameters, currently this includes:
|
16
|
+
# blank - An integer representing the % of times phone number components should be blank.
|
17
|
+
# use_code_data_file - YAML file containing use codes to randomly choose from. If not specified then values from
|
18
|
+
# {tele_use_code.yml}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/tele_use_code.yml] are used.
|
19
|
+
# equipment_type_data_file - YAML file containing equipment type codes to randomly choose from. If not specified
|
20
|
+
# then values {tele_equipment_type}[https://github.com/austinmoody/healthcare_phony/blob/main/lib/healthcare_phony/data_files/tele_equipment_type.yml] will be used.
|
21
|
+
@set_blank = !init_args[:blank].nil? && Helper.random_with_blank('X', init_args[:blank]) == ''
|
22
|
+
@use_code_data_file = init_args[:use_code_data_file]
|
23
|
+
@equipment_type_data_file = init_args[:equipment_type_data_file]
|
24
|
+
define_country_code
|
25
|
+
define_area_code
|
26
|
+
define_exchange_code
|
27
|
+
define_subscriber_number
|
28
|
+
define_use_code
|
29
|
+
define_equipment_type
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
# Private: Boolean set during initialization if Address components should be set to blank.
|
35
|
+
attr_accessor :set_blank
|
36
|
+
|
37
|
+
# Private: Location of data file of use codes
|
38
|
+
attr_accessor :use_code_data_file
|
39
|
+
|
40
|
+
# Private: Location of data file of equipment types
|
41
|
+
attr_accessor :equipment_type_data_file
|
42
|
+
|
43
|
+
def define_country_code
|
44
|
+
@country_code = Faker::PhoneNumber.country_code
|
45
|
+
@country_code = '' unless @set_blank == false
|
46
|
+
end
|
47
|
+
|
48
|
+
def define_area_code
|
49
|
+
@area_code = Faker::PhoneNumber.area_code
|
50
|
+
@area_code = '' unless @set_blank == false
|
51
|
+
end
|
52
|
+
|
53
|
+
def define_exchange_code
|
54
|
+
@exchange_code = Faker::PhoneNumber.exchange_code
|
55
|
+
@exchange_code = '' unless @set_blank == false
|
56
|
+
end
|
57
|
+
|
58
|
+
def define_subscriber_number
|
59
|
+
@subscriber_number = Faker::PhoneNumber.subscriber_number
|
60
|
+
@subscriber_number = '' unless @set_blank == false
|
61
|
+
end
|
62
|
+
|
63
|
+
def define_use_code
|
64
|
+
data_file = if !@use_code_data_file.nil?
|
65
|
+
@use_code_data_file
|
66
|
+
else
|
67
|
+
"#{::File.expand_path(::File.join("..", "data_files"), __FILE__)}/tele_use_code.yml"
|
68
|
+
end
|
69
|
+
use_codes = Psych.load_file(data_file)
|
70
|
+
@use_code = use_codes.nil? ? '' : use_codes.sample
|
71
|
+
@use_code = '' unless @set_blank == false
|
72
|
+
end
|
73
|
+
|
74
|
+
def define_equipment_type
|
75
|
+
data_file = if !@equipment_type_data_file.nil?
|
76
|
+
@equipment_type_data_file
|
77
|
+
else
|
78
|
+
"#{::File.expand_path(::File.join("..", "data_files"), __FILE__)}/tele_equipment_type.yml"
|
79
|
+
end
|
80
|
+
equipment_types = Psych.load_file(data_file)
|
81
|
+
@equipment_type = equipment_types.nil? ? '' : equipment_types.sample
|
82
|
+
@equipment_type = '' unless @set_blank == false
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|