Skip to content

FI-3817: MedicationRequest Multiple_Or Search Fix#236

Open
esemple998 wants to merge 4 commits intomainfrom
FI-3817_fix_medication_request_multiple_or
Open

FI-3817: MedicationRequest Multiple_Or Search Fix#236
esemple998 wants to merge 4 commits intomainfrom
FI-3817_fix_medication_request_multiple_or

Conversation

@esemple998
Copy link
Contributor

Summary

The MedicationRequest resource has two optional search requirements on patient+intent+encounter and patient+intent+authoredon. Previously, when testing it with reference server with patient 355 only, both test failed with errors:

Could not find plan values from intent in any of the resources returned for Patient/355
or
Could not find order values from intent in any of the resources returned for Patient/355

These searches are not the first search, so the tests use the result from first search to compile search values. From the first search, there is one MedicationRequest with intent=order and encounter=Encounter/1, and also a MedicationRequest with intent=plan and no encounter reference. The multiple_or search test therefore expected that patient 355 had MedicationRequests with intent=order, plan and encounter=Encounter/1, but it was not able to recognize that the only MedicationRequest with intent=order did not have an encounter reference.

Added a fix for this problem by adding a filter to the list of existing values that the multiple_or search test compiles. This filter makes it so that a multiple_or parameter value will not be added to the list of existing values if the value comes from a resource that does not include all of the search parameters that are currently being searched by. So, in this example, it would not add order to the list of existing values for the intent search param, since the resource that containsintent with this value does not contain all of the search parameters for the patient+intent+encounter search (missing encounter).

Testing Guidance

Run the MedicationRequest test with patient 355 and ensure the patient+intent+encounter and patient+intent+authoredonsearch tests pass. Also, run the spec tests and ensure those pass.

@esemple998 esemple998 requested a review from yunwwang March 12, 2025 20:38
@esemple998 esemple998 self-assigned this Mar 12, 2025
expect(result.result_message).to eq("Could not find order values from intent in any of the resources returned for Patient/#{patient_id}")
end

it 'passes if multiple-or search test does not return all existing values if associated resources do not contain all search params' do
Copy link
Contributor

@yunwwang yunwwang Mar 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This unit test is not working. If I commented out this line in search_test

.filter { |resource| contains_all_search_params(resource, search_params) }

This unit test still pass which should fail.

And we need another unit test for the use case when the medication_request_2 has a different encounter id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants