lib/health-data-standards/models/provider.rb in health-data-standards-3.6.1 vs lib/health-data-standards/models/provider.rb in health-data-standards-3.7.0

- old
+ new

@@ -1,12 +1,13 @@ class Provider include Personable include Mongoid::Tree include Mongoid::Attributes::Dynamic - + NPI_OID = '2.16.840.1.113883.4.6' TAX_ID_OID = '2.16.840.1.113883.4.2' + CCN_OID = '2.16.840.1.113883.4.336'.freeze field :specialty , type: String field :phone , type: String validates_uniqueness_of :npi, allow_blank: true @@ -36,9 +37,24 @@ end def tin cda_id_tin = self.cda_identifiers.where(root: TAX_ID_OID).first cda_id_tin ? cda_id_tin.extension : nil + end + + def ccn=(a_ccn) + cda_id_ccn = self.cda_identifiers.where(root: CCN_OID).first + if cda_id_ccn + cda_id_ccn.extension = a_ccn + cda_id_ccn.save! + else + self.cda_identifiers << CDAIdentifier.new(root: CCN_OID, extension: a_ccn) + end + end + + def ccn + cda_id_ccn = self.cda_identifiers.where(root: CCN_OID).first + cda_id_ccn ? cda_id_ccn.extension : nil end def records(effective_date=nil) Record.by_provider(self, effective_date) end