Class: Record
- Inherits:
-
Object
- Object
- Record
- Extended by:
- Memoist
- Includes:
- Mongoid::Document
- Defined in:
- lib/health-data-standards/models/record.rb
Constant Summary collapse
- Sections =
[:allergies, :care_goals, :conditions, :encounters, :immunizations, :medical_equipment, :medications, :procedures, :results, :social_history, :vital_signs, :support, :advance_directives, :insurance_providers, :functional_statuses]
Instance Method Summary collapse
- #dedup_record! ⇒ Object
-
#dedup_section!(section) ⇒ Object
Removed duplicate entries from a section based on id.
- #entries_for_oid(oid) ⇒ Object
- #over_18? ⇒ Boolean
- #providers ⇒ Object
- #shift_dates(date_diff) ⇒ Object
Instance Method Details
#dedup_record! ⇒ Object
95 96 97 |
# File 'lib/health-data-standards/models/record.rb', line 95 def dedup_record! Record::Sections.each {|section| self.dedup_section!(section)} end |
#dedup_section!(section) ⇒ Object
Removed duplicate entries from a section based on id. This method may lose information because it does not compare entries based on clinical content
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/health-data-standards/models/record.rb', line 84 def dedup_section!(section) unique_entries = self.send(section).uniq do |entry| if entry.respond_to?(:cda_identifier) && entry.cda_identifier.present? entry.cda_identifier else entry.id end end self.send("#{section}=", unique_entries) end |
#entries_for_oid(oid) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/health-data-standards/models/record.rb', line 64 def entries_for_oid(oid) matching_entries_by_section = Sections.map do |section| section_entries = self.send(section) if section_entries.present? section_entries.find_all { |entry| (entry.respond_to? :oid) ? entry.oid == oid : false} else [] end end matching_entries_by_section.flatten end |
#over_18? ⇒ Boolean
60 61 62 |
# File 'lib/health-data-standards/models/record.rb', line 60 def over_18? Time.at(birthdate) < Time.now.years_ago(18) end |
#providers ⇒ Object
56 57 58 |
# File 'lib/health-data-standards/models/record.rb', line 56 def providers provider_performances.map {|pp| pp.provider } end |
#shift_dates(date_diff) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/health-data-standards/models/record.rb', line 99 def shift_dates(date_diff) self.birthdate = (self.birthdate.nil?) ? nil : self.birthdate + date_diff self.deathdate = (self.deathdate.nil?) ? nil : self.deathdate + date_diff self.provider_performances.each {|pp| pp.shift_dates(date_diff)} Sections.each do |sec| (self.send sec || []).each do |ent| ent.shift_dates(date_diff) end end end |