Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implicit base not picked up in FHIR Reference search #300

Closed
prb112 opened this issue Oct 22, 2019 · 4 comments · Fixed by #1524
Closed

Implicit base not picked up in FHIR Reference search #300

prb112 opened this issue Oct 22, 2019 · 4 comments · Fixed by #1524
Assignees
Labels
cms-interop This issue is associated with the CMS interoperability rule connectathon Work derived from connectathons help wanted Extra attention is needed reference-search search
Milestone

Comments

@prb112
Copy link
Contributor

prb112 commented Oct 22, 2019

Implicit base not picked up in fhir-search... When executing the Search -> extractParameterValues with resolve(), the fhir-search module and persistence layer extracts only Patient/.

For example... consider "code" : "patient", the extractParameterValues processes a JSON:

"subject": {
        "reference": "Patient/1-2-3-4"
    },

and stores the value Patient/1-2-3-4.

The specification says the following are valid search query parameters:

[parameter]=[id] the logical [id] of a resource using a local reference (i.e. a relative reference)
[parameter]=[type]/[id] the logical [id] of a resource of a specified type using a local reference (i.e. a relative reference), for when the reference can point to different types of resources (e.g. Observation.subject)
[parameter]=[url] where the [url] is an absolute URL - a reference to a resource by its absolute location, or by it's canonical URL

Upon executing the request to
https://<SERVER>:443/<ROOT>/api/v4/MedicationRequest?patient=1-2-3-4
The request should return the resource body, however, we only support the specification #2.

The first behavior must be implemented, and the third behavior must be confirmed.

Note, the request with subject:Patient resource type works:
GET https://:443//api/v4/MedicationRequest?subject:Patient=1-2-3-4

URL: https://hl7.org/fhir/R4/search.html
In some cases, search parameters are defined with an implicitly limited scope. For example, Observation has an element subject, which is a reference to one of a number of types. This has a matching search parameter subject, which refers to any of the possible types. In addition to this, there is another search parameter patient, which also refers to Observation.subject, but is limited to only include references of type Patient. When using the patient search parameter, there is no need to specify ":Patient" as a modifier, or "Patient/" in the search value, as this must always be true.

@lmsurpre lmsurpre changed the title Implicit base not picked up in fhir-search Implicit base not picked up in fhir Reference search Oct 22, 2019
@prb112 prb112 added the search label Oct 22, 2019
@lmsurpre
Copy link
Member

Be sure to uncomment corresponding tests in AbstractSearchReferenceTest

        // TODO does this work if you define the extension in a StructureDefinition 
        // and declare the allowed types? 
//        assertSearchReturnsSavedResource("Reference-id", "Patient/123");

@prb112 prb112 changed the title Implicit base not picked up in fhir Reference search Implicit base not picked up in FHIR Reference search Oct 23, 2019
@lmsurpre lmsurpre added the help wanted Extra attention is needed label May 21, 2020
albertwang-ibm added a commit that referenced this issue Jun 10, 2020
Signed-off-by: Albert Wang <xuwang@us.ibm.com>
@prb112 prb112 added the connectathon Work derived from connectathons label Sep 11, 2020
@prb112
Copy link
Contributor Author

prb112 commented Sep 11, 2020

We hit this again in the Connectathon 25. It'd be nice to nail this one.

@lmsurpre lmsurpre added the cms-interop This issue is associated with the CMS interoperability rule label Sep 11, 2020
@kmbarton423
Copy link
Contributor

Inferno tests are not returning expected resources:
{{base}}{{contextRoot}}AllergyIntolerance?patient=1748dd8e606-de9c1bdf-3ecc-4e2f-b496-f2232ea77e1d

@prb112 prb112 self-assigned this Sep 14, 2020
@prb112 prb112 added this to the Sprint 18 milestone Sep 14, 2020
prb112 added a commit that referenced this issue Sep 24, 2020
Signed-off-by: Paul Bastide <pbastide@us.ibm.com>
@prb112 prb112 linked a pull request Sep 24, 2020 that will close this issue
prb112 added a commit that referenced this issue Sep 24, 2020
- Added Integration Test

Signed-off-by: Paul Bastide <pbastide@us.ibm.com>
@lmsurpre
Copy link
Member

lmsurpre commented Oct 5, 2020

We found the following text from https://www.hl7.org/fhir/search.html#reference

Some references may point to more than one type of resource; e.g. subject: Reference(Patient|Group|Device|..). In these cases, multiple resources may have the same logical identifier. Servers SHOULD reject a search where the logical id refers to more than one matching resource across different types.

This means that we should try to infer the resource type even in cases where the search parameter refers to multiple different types. Based on this text, it seems that omitting the resource type while searching a reference is really only an error if the target identifier exists in one or more of the target resource types that is being searched.

For this issue (#300) lets just focus on adding the implicit types at the fhir-search layer. We'll handle "is there more than one matching resource type with this id" in #1553

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cms-interop This issue is associated with the CMS interoperability rule connectathon Work derived from connectathons help wanted Extra attention is needed reference-search search
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants