faker-medical 0.5.0 → 0.5.1
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +1 -0
- data/Gemfile +3 -5
- data/Gemfile.lock +16 -12
- data/README.md +48 -0
- data/Rakefile +1 -53
- data/faker-medical.gemspec +22 -65
- data/lib/faker/medical/dea.rb +27 -0
- data/lib/faker/medical/extensions/time.rb +20 -0
- data/lib/faker/medical/npi.rb +26 -0
- data/lib/faker/medical/patient.rb +23 -0
- data/lib/faker/medical/ssn.rb +12 -0
- data/lib/faker/medical/version.rb +5 -0
- data/lib/faker/medical.rb +6 -4
- data/spec/faker/medical/dea_spec.rb +8 -0
- data/spec/faker/medical/npi_spec.rb +7 -0
- data/spec/faker/medical/patient_spec.rb +17 -0
- data/spec/faker/medical/ssn_spec.rb +7 -0
- data/spec/spec_helper.rb +4 -4
- metadata +57 -46
- data/README.rdoc +0 -21
- data/lib/faker_dea.rb +0 -26
- data/lib/faker_npi.rb +0 -22
- data/lib/faker_patient.rb +0 -43
- data/lib/faker_ssn.rb +0 -11
- data/spec/lib/faker_dea_spec.rb +0 -11
- data/spec/lib/faker_npi_spec.rb +0 -10
- data/spec/lib/faker_patient_spec.rb +0 -19
- data/spec/lib/faker_ssn_spec.rb +0 -10
- data/spec/spec.opts +0 -4
- data/version.yml +0 -5
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
data/.rspec
CHANGED
data/Gemfile
CHANGED
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:
|
|
8
|
+
remote: https://rubygems.org/
|
|
3
9
|
specs:
|
|
4
10
|
diff-lcs (1.1.2)
|
|
5
|
-
faker (
|
|
6
|
-
i18n (~> 0.
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
28
|
-
|
|
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 '
|
|
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'
|
data/faker-medical.gemspec
CHANGED
|
@@ -1,70 +1,27 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 |
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
50
|
-
s.specification_version = 3
|
|
21
|
+
spec.add_dependency 'faker'
|
|
51
22
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
data/lib/faker/medical.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require '
|
|
3
|
-
require '
|
|
4
|
-
require '
|
|
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,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
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'faker'
|
|
2
|
-
require '
|
|
3
|
-
require '
|
|
4
|
-
require '
|
|
5
|
-
require '
|
|
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.
|
|
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:
|
|
11
|
+
date: 2014-05-13 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
|
-
name:
|
|
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:
|
|
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: :
|
|
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: :
|
|
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.
|
|
97
|
+
- README.md
|
|
94
98
|
- Rakefile
|
|
95
99
|
- faker-medical.gemspec
|
|
96
100
|
- lib/faker/medical.rb
|
|
97
|
-
- lib/
|
|
98
|
-
- lib/
|
|
99
|
-
- lib/
|
|
100
|
-
- lib/
|
|
101
|
-
-
|
|
102
|
-
-
|
|
103
|
-
- spec/
|
|
104
|
-
- spec/
|
|
105
|
-
- spec/
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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:
|
|
134
|
+
rubygems_version: 2.2.2
|
|
131
135
|
signing_key:
|
|
132
|
-
specification_version:
|
|
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
data/spec/lib/faker_dea_spec.rb
DELETED
data/spec/lib/faker_npi_spec.rb
DELETED
|
@@ -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
|
data/spec/lib/faker_ssn_spec.rb
DELETED
data/spec/spec.opts
DELETED