faker-medical 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5d207dab899bffc815f258b39a0b453002832a4b
4
+ data.tar.gz: 90df3c6d8daa04ef0dfa7af97874f039a230274a
5
+ SHA512:
6
+ metadata.gz: 1544ddf1f25108ac50fda3106e0f3262d5d5a3db163010fa6fc5415edfa1319226220d17dcbb0eca2cb58fca061418893ab35d5ac67dc6d93a21bac2643de3ff
7
+ data.tar.gz: 2007f8d7979c661105891670fbcbc3ef51d1d52786724a94523118b03b3313440f177117c51ac463264585d935a315a76f177d9f2330f23de07eb354ab6e7f7f
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ .bundle
18
+ coverage
19
+ rdoc
20
+ pkg
21
+
22
+ ## PROJECT::SPECIFIC
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --format progress
data/Gemfile CHANGED
@@ -1,6 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
- gem 'jeweler'
4
- gem 'faker'
5
-
6
- gem 'rspec'
3
+ # Specify your gem's dependencies in faker-medical.gemspec
4
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,16 +1,17 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ faker-medical (0.5.0)
5
+ faker
6
+
1
7
  GEM
2
- remote: http://rubygems.org/
8
+ remote: https://rubygems.org/
3
9
  specs:
4
10
  diff-lcs (1.1.2)
5
- faker (0.9.5)
6
- i18n (~> 0.4)
7
- git (1.2.5)
8
- i18n (0.6.0)
9
- jeweler (1.6.4)
10
- bundler (~> 1.0)
11
- git (>= 1.2.5)
12
- rake
13
- rake (0.9.2)
11
+ faker (1.3.0)
12
+ i18n (~> 0.5)
13
+ i18n (0.6.9)
14
+ rake (10.3.1)
14
15
  rspec (2.6.0)
15
16
  rspec-core (~> 2.6.0)
16
17
  rspec-expectations (~> 2.6.0)
@@ -19,11 +20,14 @@ GEM
19
20
  rspec-expectations (2.6.0)
20
21
  diff-lcs (~> 1.1.2)
21
22
  rspec-mocks (2.6.0)
23
+ thoughtbot-shoulda (2.11.1)
22
24
 
23
25
  PLATFORMS
24
26
  ruby
25
27
 
26
28
  DEPENDENCIES
27
- faker
28
- jeweler
29
+ bundler (~> 1.3)
30
+ faker-medical!
31
+ rake
29
32
  rspec
33
+ thoughtbot-shoulda
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # Faker::Medical
2
+
3
+ You can generate the following data elements:
4
+
5
+ ### Faker::Medical::DEA
6
+ Generate a [DEA Number](http://en.wikipedia.org/wiki/DEA_number)
7
+ ```ruby
8
+ Faker::Dea.dea
9
+ # => "AS3555565"
10
+ ```
11
+
12
+ ### Faker::Medical::NPI
13
+ Generates a 10-digit [National Provider Identifier](http://en.wikipedia.org/wiki/National_Provider_Identifier)
14
+ ```ruby
15
+ Faker::Npi.npi
16
+ # => "7419588454"
17
+
18
+ Faker::Npi.check_digits?("1490626178")
19
+ # => false
20
+ ```
21
+
22
+ ### Faker::Medical::Patient
23
+ Generate a patient gender - M or F:
24
+ ```ruby
25
+ Faker::Patient.gender
26
+ # => "F"
27
+ ```
28
+
29
+ ### Faker::Medical::SSN
30
+ Generates a Social Security Number
31
+ ```ruby
32
+ Faker::Ssn.en_ssn
33
+ # => "816-10-6425"
34
+ ```
35
+
36
+ ## Note on Patches/Pull Requests
37
+
38
+ * Fork the project.
39
+ * Make your feature addition or bug fix.
40
+ * Add tests for it. This is important so I don't break it in a
41
+ future version unintentionally.
42
+ * Commit, do not mess with Rakefile, version, or history.
43
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
44
+ * Send me a pull request. Bonus points for topic branches.
45
+
46
+ ## Copyright
47
+
48
+ Copyright (c) 2009 Tom & Russell. See [LICENSE](LICENSE) for details.
data/Rakefile CHANGED
@@ -1,53 +1 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "faker-medical"
8
- gem.summary = %Q{Faker Extension for Medical Numbers}
9
- gem.description = %Q{This gem is an extension of the Faker Gem to generate SSN, DEA, and NPI Numbers}
10
- gem.email = "thing2@jackhq.com"
11
- gem.homepage = "http://github.com/jackhq/faker-medical"
12
- gem.authors = ["Tom & Russell"]
13
- gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
- end
20
-
21
- require 'rake/testtask'
22
- Rake::TestTask.new(:test) do |test|
23
- test.libs << 'lib' << 'test'
24
- test.pattern = 'test/**/test_*.rb'
25
- test.verbose = true
26
- end
27
-
28
- begin
29
- require 'rcov/rcovtask'
30
- Rcov::RcovTask.new do |test|
31
- test.libs << 'test'
32
- test.pattern = 'test/**/test_*.rb'
33
- test.verbose = true
34
- end
35
- rescue LoadError
36
- task :rcov do
37
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
- end
39
- end
40
-
41
- task :test => :check_dependencies
42
-
43
- task :default => :test
44
-
45
- require 'rake/rdoctask'
46
- Rake::RDocTask.new do |rdoc|
47
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
-
49
- rdoc.rdoc_dir = 'rdoc'
50
- rdoc.title = "faker-medical #{version}"
51
- rdoc.rdoc_files.include('README*')
52
- rdoc.rdoc_files.include('lib/**/*.rb')
53
- end
1
+ require 'bundler/gem_tasks'
@@ -1,70 +1,27 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'faker/medical/version'
5
5
 
6
- Gem::Specification.new do |s|
7
- s.name = "faker-medical"
8
- s.version = "0.5.0"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'faker-medical'
8
+ spec.version = Faker::Medical::VERSION
9
+ spec.authors = ['Tom & Russell']
10
+ spec.email = 'thing2@jackhq.com'
11
+ spec.description = 'This gem is an extension of the Faker Gem to generate SSN, DEA, and NPI Numbers'
12
+ spec.summary = 'Faker Extension for Medical Numbers'
13
+ spec.homepage = 'https://github.com/jackhq/faker-medical'
14
+ spec.license = 'MIT'
9
15
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Tom & Russell"]
12
- s.date = "2012-12-10"
13
- s.description = "This gem is an extension of the Faker Gem to generate SSN, DEA, and NPI Numbers"
14
- s.email = "thing2@jackhq.com"
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".rspec",
22
- "CHANGELOG",
23
- "Gemfile",
24
- "Gemfile.lock",
25
- "LICENSE",
26
- "README.rdoc",
27
- "Rakefile",
28
- "faker-medical.gemspec",
29
- "lib/faker/medical.rb",
30
- "lib/faker_dea.rb",
31
- "lib/faker_npi.rb",
32
- "lib/faker_patient.rb",
33
- "lib/faker_ssn.rb",
34
- "spec/lib/faker_dea_spec.rb",
35
- "spec/lib/faker_npi_spec.rb",
36
- "spec/lib/faker_patient_spec.rb",
37
- "spec/lib/faker_ssn_spec.rb",
38
- "spec/spec.opts",
39
- "spec/spec_helper.rb",
40
- "test/helper.rb",
41
- "test/test_faker-medical.rb",
42
- "version.yml"
43
- ]
44
- s.homepage = "http://github.com/jackhq/faker-medical"
45
- s.require_paths = ["lib"]
46
- s.rubygems_version = "1.8.21"
47
- s.summary = "Faker Extension for Medical Numbers"
16
+ spec.files = `git ls-files`.split("\n")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
48
20
 
49
- if s.respond_to? :specification_version then
50
- s.specification_version = 3
21
+ spec.add_dependency 'faker'
51
22
 
52
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
- s.add_runtime_dependency(%q<jeweler>, [">= 0"])
54
- s.add_runtime_dependency(%q<faker>, [">= 0"])
55
- s.add_runtime_dependency(%q<rspec>, [">= 0"])
56
- s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
57
- else
58
- s.add_dependency(%q<jeweler>, [">= 0"])
59
- s.add_dependency(%q<faker>, [">= 0"])
60
- s.add_dependency(%q<rspec>, [">= 0"])
61
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
62
- end
63
- else
64
- s.add_dependency(%q<jeweler>, [">= 0"])
65
- s.add_dependency(%q<faker>, [">= 0"])
66
- s.add_dependency(%q<rspec>, [">= 0"])
67
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
68
- end
23
+ spec.add_development_dependency 'bundler', '~> 1.3'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'thoughtbot-shoulda'
69
27
  end
70
-
@@ -0,0 +1,27 @@
1
+ module Faker
2
+ module Medical
3
+ class DEA < Base
4
+ class << self
5
+ def dea(type = 'A', last_name = 'Smith')
6
+ prefix = type + last_name[0]
7
+ suffix = numerify('######')
8
+
9
+ "#{prefix}#{suffix}#{check_digit(suffix)}"
10
+ end
11
+
12
+ private
13
+
14
+ def check_digit(dea_suffix_number)
15
+ n_array = dea_suffix_number.split('')
16
+ first_number = n_array[0].to_i + n_array[2].to_i + n_array[4].to_i
17
+
18
+ sec_number = n_array[1].to_i + n_array[3].to_i + n_array[5].to_i
19
+ sec_number *= 2
20
+
21
+ check_digit = first_number + sec_number
22
+ check_digit.to_s.split('').last
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ # mixin random time function from http://jroller.com/obie/entry/random_times_for_rails
2
+ class Time
3
+ def self.random(params = {})
4
+ years_back = params[:year_range] || 5
5
+ year = (rand * (years_back)).ceil + (Time.now.year - years_back)
6
+ month = (rand * 12).ceil
7
+ day = (rand * 31).ceil
8
+ date = Time.local(year, month, day)
9
+
10
+ series = [date]
11
+ if params[:series]
12
+ params[:series].each do |some_time_after|
13
+ series << series.last + (rand * some_time_after).ceil
14
+ end
15
+ return series
16
+ end
17
+
18
+ date
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ module Faker
2
+ module Medical
3
+ class NPI < Base
4
+ class << self
5
+ def npi
6
+ x = []
7
+
8
+ 10.times do
9
+ x << rand(10)
10
+ end
11
+
12
+ x.join
13
+ end
14
+
15
+ # TODO: Use the Luhn algorithm to validate the NPI (by prefixing 80840)
16
+ def valid?(num)
17
+ odd = false
18
+ num.to_s.gsub(/\D/,'').reverse.split('').map(&:to_i).collect { |d|
19
+ d *= 2 if odd = !odd
20
+ d > 9 ? d - 9 : d
21
+ }.inject(:+) % 10 == 0
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ require 'faker/medical/extensions/time'
2
+
3
+ module Faker
4
+ module Medical
5
+ class Patient < Base
6
+ class << self
7
+ def date_of_birth
8
+ Time.random(:year_range => 80)
9
+ #Date.parse("#{rand(12) + 1}/#{rand(27) + 1}/19#{format("%02d", rand(99))}" )
10
+ end
11
+ alias_method :dob, :date_of_birth
12
+
13
+ def gender
14
+ %w[M F].sample
15
+ end
16
+
17
+ def phone_number
18
+ Faker::PhoneNumber.phone_number
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,12 @@
1
+ module Faker
2
+ module Medical
3
+ class SSN < Base
4
+ class << self
5
+ # English social security number has the format xxx-xx-xxxx
6
+ def ssn
7
+ numerify('###-##-####')
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Faker
2
+ module Medical
3
+ VERSION = '0.5.1'
4
+ end
5
+ end
data/lib/faker/medical.rb CHANGED
@@ -1,4 +1,6 @@
1
- require 'faker_dea'
2
- require 'faker_npi'
3
- require 'faker_patient'
4
- require 'faker_ssn'
1
+ require 'faker'
2
+ require 'faker/medical/dea'
3
+ require 'faker/medical/npi'
4
+ require 'faker/medical/patient'
5
+ require 'faker/medical/ssn'
6
+ require 'faker/medical/version'
@@ -0,0 +1,8 @@
1
+ require_relative '../../spec_helper.rb'
2
+
3
+ describe Faker::Medical::DEA do
4
+ it "should return a ssn with dashes" do
5
+ #puts Faker::Dea.dea
6
+ Faker::Medical::DEA.dea.should match(/^[A|B|F|M|P|R][A-Z](?!000000)\d{6}/)
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../../spec_helper.rb'
2
+
3
+ describe Faker::Medical::NPI do
4
+ it "should return a npi" do
5
+ Faker::Medical::NPI.npi.should match(/^\d{10}$/)
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ require_relative '../../spec_helper.rb'
2
+
3
+ describe Faker::Medical::Patient do
4
+ it "should return a patient gender" do
5
+ Faker::Medical::Patient.gender.should match(/^[M|F]$/)
6
+ end
7
+
8
+ it "should return 10 patient dates of birth" do
9
+ 100.times do
10
+ Faker::Medical::Patient.dob.should be_true
11
+ end
12
+ end
13
+
14
+ it "should return basic phone number" do
15
+ Faker::Medical::Patient.phone_number.should =~ /^[0-9]{3}-[0-9]{3}-[0-9]{4}$/
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../../spec_helper.rb'
2
+
3
+ describe Faker::Medical::SSN do
4
+ it "should return a ssn with dashes" do
5
+ Faker::Medical::SSN.ssn.should match(/^(?!000)([0-6]\d{2}|7([0-6]\d|7[012]))([ -]?)(?!00)\d\d\3(?!0000)\d{4}$/)
6
+ end
7
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'faker'
2
- require 'faker_dea'
3
- require 'faker_ssn'
4
- require 'faker_patient'
5
- require 'faker_npi'
2
+ require 'faker/medical/dea'
3
+ require 'faker/medical/ssn'
4
+ require 'faker/medical/patient'
5
+ require 'faker/medical/npi'
metadata CHANGED
@@ -1,78 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faker-medical
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
5
- prerelease:
4
+ version: 0.5.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tom & Russell
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-10 00:00:00.000000000 Z
11
+ date: 2014-05-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: jeweler
14
+ name: faker
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
- name: faker
28
+ name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
36
46
  - !ruby/object:Gem::Version
37
47
  version: '0'
38
- type: :runtime
48
+ type: :development
39
49
  prerelease: false
40
50
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
51
  requirements:
43
- - - ! '>='
52
+ - - '>='
44
53
  - !ruby/object:Gem::Version
45
54
  version: '0'
46
55
  - !ruby/object:Gem::Dependency
47
56
  name: rspec
48
57
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
58
  requirements:
51
- - - ! '>='
59
+ - - '>='
52
60
  - !ruby/object:Gem::Version
53
61
  version: '0'
54
- type: :runtime
62
+ type: :development
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
65
  requirements:
59
- - - ! '>='
66
+ - - '>='
60
67
  - !ruby/object:Gem::Version
61
68
  version: '0'
62
69
  - !ruby/object:Gem::Dependency
63
70
  name: thoughtbot-shoulda
64
71
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
72
  requirements:
67
- - - ! '>='
73
+ - - '>='
68
74
  - !ruby/object:Gem::Version
69
75
  version: '0'
70
76
  type: :development
71
77
  prerelease: false
72
78
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
79
  requirements:
75
- - - ! '>='
80
+ - - '>='
76
81
  - !ruby/object:Gem::Version
77
82
  version: '0'
78
83
  description: This gem is an extension of the Faker Gem to generate SSN, DEA, and NPI
@@ -80,55 +85,61 @@ description: This gem is an extension of the Faker Gem to generate SSN, DEA, and
80
85
  email: thing2@jackhq.com
81
86
  executables: []
82
87
  extensions: []
83
- extra_rdoc_files:
84
- - LICENSE
85
- - README.rdoc
88
+ extra_rdoc_files: []
86
89
  files:
87
90
  - .document
91
+ - .gitignore
88
92
  - .rspec
89
93
  - CHANGELOG
90
94
  - Gemfile
91
95
  - Gemfile.lock
92
96
  - LICENSE
93
- - README.rdoc
97
+ - README.md
94
98
  - Rakefile
95
99
  - faker-medical.gemspec
96
100
  - lib/faker/medical.rb
97
- - lib/faker_dea.rb
98
- - lib/faker_npi.rb
99
- - lib/faker_patient.rb
100
- - lib/faker_ssn.rb
101
- - spec/lib/faker_dea_spec.rb
102
- - spec/lib/faker_npi_spec.rb
103
- - spec/lib/faker_patient_spec.rb
104
- - spec/lib/faker_ssn_spec.rb
105
- - spec/spec.opts
101
+ - lib/faker/medical/dea.rb
102
+ - lib/faker/medical/extensions/time.rb
103
+ - lib/faker/medical/npi.rb
104
+ - lib/faker/medical/patient.rb
105
+ - lib/faker/medical/ssn.rb
106
+ - lib/faker/medical/version.rb
107
+ - spec/faker/medical/dea_spec.rb
108
+ - spec/faker/medical/npi_spec.rb
109
+ - spec/faker/medical/patient_spec.rb
110
+ - spec/faker/medical/ssn_spec.rb
106
111
  - spec/spec_helper.rb
107
112
  - test/helper.rb
108
113
  - test/test_faker-medical.rb
109
- - version.yml
110
- homepage: http://github.com/jackhq/faker-medical
111
- licenses: []
114
+ homepage: https://github.com/jackhq/faker-medical
115
+ licenses:
116
+ - MIT
117
+ metadata: {}
112
118
  post_install_message:
113
119
  rdoc_options: []
114
120
  require_paths:
115
121
  - lib
116
122
  required_ruby_version: !ruby/object:Gem::Requirement
117
- none: false
118
123
  requirements:
119
- - - ! '>='
124
+ - - '>='
120
125
  - !ruby/object:Gem::Version
121
126
  version: '0'
122
127
  required_rubygems_version: !ruby/object:Gem::Requirement
123
- none: false
124
128
  requirements:
125
- - - ! '>='
129
+ - - '>='
126
130
  - !ruby/object:Gem::Version
127
131
  version: '0'
128
132
  requirements: []
129
133
  rubyforge_project:
130
- rubygems_version: 1.8.21
134
+ rubygems_version: 2.2.2
131
135
  signing_key:
132
- specification_version: 3
136
+ specification_version: 4
133
137
  summary: Faker Extension for Medical Numbers
134
- test_files: []
138
+ test_files:
139
+ - spec/faker/medical/dea_spec.rb
140
+ - spec/faker/medical/npi_spec.rb
141
+ - spec/faker/medical/patient_spec.rb
142
+ - spec/faker/medical/ssn_spec.rb
143
+ - spec/spec_helper.rb
144
+ - test/helper.rb
145
+ - test/test_faker-medical.rb
data/README.rdoc DELETED
@@ -1,21 +0,0 @@
1
- = faker-medical
2
-
3
- You can generate the following data elements:
4
-
5
- Faker::Ssn.en_ssn - generates a Social Security Number
6
- Faker::Dea.dea - genearates a DEA Number
7
- Faker::Patient.gender - generates a patient gender (M|F)
8
-
9
- == Note on Patches/Pull Requests
10
-
11
- * Fork the project.
12
- * Make your feature addition or bug fix.
13
- * Add tests for it. This is important so I don't break it in a
14
- future version unintentionally.
15
- * Commit, do not mess with rakefile, version, or history.
16
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
17
- * Send me a pull request. Bonus points for topic branches.
18
-
19
- == Copyright
20
-
21
- Copyright (c) 2009 Tom & Russell. See LICENSE for details.
data/lib/faker_dea.rb DELETED
@@ -1,26 +0,0 @@
1
- module Faker
2
- class Dea
3
- class << self
4
- def dea(type="A",last_name="Smith")
5
- prefix = type + last_name.split("")[0]
6
- suffix = Faker::Base.numerify('######')
7
- prefix + suffix + check_digit(suffix)
8
-
9
- end
10
-
11
- def check_digit(dea_suffix_number)
12
- n_array = dea_suffix_number.split("")
13
- first_number = n_array[0].to_i + n_array[2].to_i + n_array[4].to_i
14
- #puts first_number
15
- sec_number = n_array[1].to_i + n_array[3].to_i + n_array[5].to_i
16
- sec_number = sec_number * 2
17
- #puts sec_number
18
- check_digit = first_number + sec_number
19
- #puts check_digit
20
- check_digit.to_s.split("").last
21
- end
22
-
23
- end
24
-
25
- end
26
- end
data/lib/faker_npi.rb DELETED
@@ -1,22 +0,0 @@
1
- module Faker
2
- class Npi
3
- class << self
4
- def npi
5
- x = []
6
- 10.times do
7
- x << rand(10)
8
- end
9
- x.join
10
- end
11
-
12
- def check_digits? num
13
- odd = false
14
- num.to_s.gsub(/\D/,'').reverse.split('').map(&:to_i).collect { |d|
15
- d *= 2 if odd = !odd
16
- d > 9 ? d - 9 : d
17
- }.sum % 10 == 0
18
- end
19
-
20
- end
21
- end
22
- end
data/lib/faker_patient.rb DELETED
@@ -1,43 +0,0 @@
1
- # mixin random time function from http://jroller.com/obie/entry/random_times_for_rails
2
- class Time
3
-
4
- def self.random(params={})
5
- years_back = params[:year_range] || 5
6
- year = (rand * (years_back)).ceil + (Time.now.year - years_back)
7
- month = (rand * 12).ceil
8
- day = (rand * 31).ceil
9
- series = [date = Time.local(year, month, day)]
10
- if params[:series]
11
- params[:series].each do |some_time_after|
12
- series << series.last + (rand * some_time_after).ceil
13
- end
14
- return series
15
- end
16
- date
17
- end
18
-
19
- end
20
-
21
- module Faker
22
- class Patient
23
- class << self
24
- # English social security number has the format xxx-xx-xxxx
25
- def gender
26
- gender = ['M','F']
27
- gender[rand(2)]
28
- end
29
-
30
- def dob
31
- Time.random(:year_range => 80)
32
- #Date.parse("#{rand(12) + 1}/#{rand(27) + 1}/19#{format("%02d", rand(99))}" )
33
- end
34
-
35
- def phone_number
36
- Faker::Base.numerify("###-###-####")
37
- end
38
-
39
-
40
- end
41
-
42
- end
43
- end
data/lib/faker_ssn.rb DELETED
@@ -1,11 +0,0 @@
1
- module Faker
2
- class Ssn
3
- class << self
4
- # English social security number has the format xxx-xx-xxxx
5
- def en_ssn
6
- Faker::Base.numerify('###-##-####')
7
- end
8
- end
9
-
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper.rb'
2
-
3
- describe Faker::Dea do
4
-
5
- it "should return a ssn with dashes" do
6
- #puts Faker::Dea.dea
7
- Faker::Dea.dea.should match(/^[A|B|F|M|P|R][A-Z](?!000000)\d{6}/)
8
- end
9
-
10
-
11
- end
@@ -1,10 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper.rb'
2
-
3
- describe Faker::Npi do
4
-
5
- it "should return a npi" do
6
- Faker::Npi.npi.should match(/^\d{10}$/)
7
- end
8
-
9
-
10
- end
@@ -1,19 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper.rb'
2
-
3
- describe Faker::Patient do
4
-
5
- it "should return a patient gender" do
6
- Faker::Patient.gender.should match(/^[M|F]$/)
7
- end
8
-
9
- it "should return 10 patient dates of birth" do
10
- 100.times do
11
- Faker::Patient.dob.should be_true
12
- end
13
- end
14
-
15
- it "should return basic phone number" do
16
- Faker::Patient.phone_number.should =~ /^[0-9]{3}-[0-9]{3}-[0-9]{4}$/
17
- end
18
-
19
- end
@@ -1,10 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper.rb'
2
-
3
- describe Faker::Ssn do
4
-
5
- it "should return a ssn with dashes" do
6
- Faker::Ssn.en_ssn.should match(/^(?!000)([0-6]\d{2}|7([0-6]\d|7[012]))([ -]?)(?!00)\d\d\3(?!0000)\d{4}$/)
7
- end
8
-
9
-
10
- end
data/spec/spec.opts DELETED
@@ -1,4 +0,0 @@
1
- --colour
2
- --format progress
3
- --loadby mtime
4
- --reverse
data/version.yml DELETED
@@ -1,5 +0,0 @@
1
- ---
2
- :major: 0
3
- :minor: 5
4
- :build:
5
- :patch: 0