Skip to content

Commit 7586029

Browse files
authored
FI-1071 Change one medication request to have an intent of plan if needed. (#15)
* Chnage one medication request to have an intent of plan if needed. * Set reportedReference to nil.
1 parent b8c419b commit 7586029

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/modifications.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,20 @@ def self.modify!(results, random_seed = 3)
264264
puts " - Altered Medication: #{med_bundle.entry.first.resource.id}"
265265
end
266266

267+
# change one medication request from an order to a self prescription, if needed
268+
# we need at least two intents in order to demonstrate the multi-or search requirement for intent
269+
any_non_order = results.any? {|b| b.entry.any?{|e| e.resource.resourceType == 'MedicationRequest' && e.resource.intent != 'order' }}
270+
selection_medication_request = results.find {|b| DataScript::Constraints.has(b, FHIR::MedicationRequest)}
271+
if !any_non_order && selection_medication_request
272+
changed_medication = selection_medication_request.entry.select { |e| e.resource.resourceType == 'MedicationRequest'}.last.resource
273+
changed_medication.intent = 'plan'
274+
changed_medication.reportedBoolean = true
275+
changed_medication.reportedReference = nil
276+
changed_medication.requester = changed_medication.subject.clone
277+
changed_medication.encounter = nil
278+
puts " - Altered Medication Request to have 'plan' intent: #{changed_medication.id}"
279+
end
280+
267281
# select by device
268282
selection_device = results.find {|b| DataScript::Constraints.has(b, FHIR::Device)}
269283
if selection_device

0 commit comments

Comments
 (0)