module FFaker::Code
def npi(legacy: false)
def npi(legacy: false) max = legacy ? 299_999_999 : 999_999_999 base_npi = rand(100_000_000..max).to_s summed_digits = base_npi .chars .each_with_index .map { |n, i| (i.even? ? n.to_i * 2 : n).to_s } .join .chars .inject(0) { |sum, digit| sum + digit.to_i } npi_checksum = (10 - (24 + summed_digits) % 10).to_s.chars.last base_npi + npi_checksum end