Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/modifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,20 @@ def self.modify!(results, random_seed = 3)
puts " - Altered Medication: #{med_bundle.entry.first.resource.id}"
end

# change one medication request from an order to a self prescription, if needed
# we need at least two intents in order to demonstrate the multi-or search requirement for intent
any_non_order = results.any? {|b| b.entry.any?{|e| e.resource.resourceType == 'MedicationRequest' && e.resource.intent != 'order' }}
selection_medication_request = results.find {|b| DataScript::Constraints.has(b, FHIR::MedicationRequest)}
if !any_non_order && selection_medication_request
changed_medication = selection_medication_request.entry.select { |e| e.resource.resourceType == 'MedicationRequest'}.last.resource
changed_medication.intent = 'plan'
changed_medication.reportedBoolean = true
changed_medication.reportedReference = nil
changed_medication.requester = changed_medication.subject.clone
changed_medication.encounter = nil
puts " - Altered Medication Request to have 'plan' intent: #{changed_medication.id}"
end

# select by device
selection_device = results.find {|b| DataScript::Constraints.has(b, FHIR::Device)}
if selection_device
Expand Down