lib/health-data-standards/import/bundle/importer.rb in health-data-standards-3.4.1 vs lib/health-data-standards/import/bundle/importer.rb in health-data-standards-3.4.2
- old
+ new
@@ -162,9 +162,17 @@
contents.select! {|entry| measure_ids.include? entry['measure_id']} if collection == 'query_cache'
contents.select! {|entry| measure_ids.include? entry['value']['measure_id']} if collection == 'patient_cache'
end
contents.each do |document|
+ if name == "by_patient"
+ # Set the patient_id to the actual _id of
+ # newly created patient record
+ medical_record_id = document['value']['medical_record_id']
+ if patient = Record.by_patient_id(medical_record_id).first
+ document['value']['patient_id'] = patient.id
+ end
+ end
document['bundle_id'] = bundle.id
Mongoid.default_session[collection].insert(document)
end
end
puts "\rLoading: Results Complete "