lib/health-data-standards/models/provider.rb in health-data-standards-0.7.1 vs lib/health-data-standards/models/provider.rb in health-data-standards-0.8.0
- old
+ new
@@ -10,18 +10,23 @@
field :phone , type: String
field :organization, type: String
validates_uniqueness_of :npi, allow_blank: true
-
+ embeds_many :addresses, as: :locatable
+ embeds_many :telecoms, as: :contactable
+ embeds_one :organization
+
+
def records(effective_date=nil)
Record.by_provider(self, effective_date)
end
# validate the NPI, should be 10 or 15 digits total with the final digit being a
# checksum using the Luhn algorithm with additional special handling as described in
# https://www.cms.gov/NationalProvIdentStand/Downloads/NPIcheckdigit.pdf
def self.valid_npi?(npi)
+ return false unless npi
return false if npi.length != 10 and npi.length != 15
return false if npi.gsub(/\d/, '').length > 0 # npi must be all digits
return false if npi.length == 15 and (npi =~ /^80840/)==nil # 15 digit npi must start with 80840
# checksum is always calculated as if 80840 prefix is present
\ No newline at end of file