lib/health-data-standards/models/entry.rb in health-data-standards-2.1.4 vs lib/health-data-standards/models/entry.rb in health-data-standards-2.2.0

- old
+ new

@@ -18,10 +18,11 @@ field :free_text, type: String field :mood_code, type: String, default: "EVN" field :negationInd, type: Boolean field :negationReason, type: Hash field :oid, type: String + field :reason, type: Hash alias :negation_ind :negationInd alias :negation_ind= :negationInd= alias :negation_reason :negationReason alias :negation_reason= :negationReason= @@ -31,18 +32,22 @@ attr_protected :created_at attr_protected :updated_at def times_to_s(nil_string='UNK') if start_time.present? || end_time.present? - start_string = start_time ? Time.at(start_time).utc.to_formatted_s(:long_ordinal) : nil_string - end_string = end_time ? Time.at(end_time).utc.to_formatted_s(:long_ordinal) : nil_string + start_string = start_time ? Entry.time_to_s(start_time) : nil_string + end_string = end_time ? Entry.time_to_s(end_time) : nil_string "#{start_string} - #{end_string}" elsif time.present? Time.at(time).utc.to_formatted_s(:long_ordinal) end end + def self.time_to_s(input_time) + Time.at(input_time).utc.to_formatted_s(:long_ordinal) + end + # Entry previously had a status field that dropped the code set and converted # the status to a String. Entry now preserves the original code and code set. # This method is here to maintain backwards compatibility. def status if status_code.present? @@ -67,12 +72,12 @@ self.status_code = {'SNOMED-CT' => ['55561003'], 'HL7 ActStatus' => ['active']} when 'inactive' self.status_code = {'SNOMED-CT' => ['73425007']} when 'resolved' self.status_code = {'SNOMED-CT' => ['413322009']} - when 'completed' - self.status_code = {'HL7 ActStatus' => ['completed']} + else + self.status_code = {'HL7 ActStatus' => [status_text]} end end def self.from_event_hash(event) entry = Entry.new @@ -103,9 +108,11 @@ self.values << pq_value end # Checks if a code is in the list of possible codes # @param [Array] code_set an Array of Hashes that describe the values for code sets + # The hash has a key of "set" for the code system name and "values" + # for the actual code list # @return [true, false] whether the code is in the list of desired codes def is_in_code_set?(code_set) codes.keys.each do |code_system| all_codes_in_system = code_set.find_all {|set| set['set'] == code_system} all_codes_in_system.each do |codes_in_system| \ No newline at end of file