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

Engine: Add support for _revinclude #658

Merged
merged 2 commits into from
Mar 14, 2024

Conversation

whyfate
Copy link
Contributor

@whyfate whyfate commented Dec 14, 2023

Only supports simple _revinclude, does not support iteration.

#307

@kennethmyhra kennethmyhra self-requested a review January 8, 2024 10:51
Copy link
Collaborator

@kennethmyhra kennethmyhra left a comment

Choose a reason for hiding this comment

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

Apologies for taking such a long time to review this.

I tested this locally with the database backup located at .docker/linux/r4.archive.gz and the following query: fhir/Observation?subject:identifier=http://example.org/ids|1234567. I would expect it to return the Observations with following ids: 48, 14, and 123. But it only returns Observation with id 48

@whyfate
Copy link
Contributor Author

whyfate commented Mar 14, 2024

Apologies for taking such a long time to review this.

I tested this locally with the database backup located at .docker/linux/r4.archive.gz and the following query: fhir/Observation?subject:identifier=http://example.org/ids|1234567. I would expect it to return the Observations with following ids: 48, 14, and 123. But it only returns Observation with id 48

It's my fault. I have reviewed the documentation for r4 and understood it as

fhir/Observation?subject.identifier=http://example.org/ids|1234567&_revinclude=Observation:subject

it's not implement subject:identifier,and this is reference search

@kennethmyhra
Copy link
Collaborator

Ah of course, I get this confused every time.

I am still not able to successfully verify this. Tried with the following: https://localhost:5001/fhir/Observation?subject=Patient/23&_revinclude=Observation.patient but I am only getting back the Observations not the Patient

@whyfate
Copy link
Contributor Author

whyfate commented Mar 14, 2024

image
The separator used by _revinclude is a : instead of a ., such as https://localhost:5001/fhir/Observation?subject=Patient/23&_revinclude=Observation:patient

@kennethmyhra
Copy link
Collaborator

Accidentally posted the wrong format in my comment. Trying with the following: https://localhost:5001/fhir/Observation?subject=Patient/23&_revinclude=Observation:patient gives me back this result without the Patient:

{
    "resourceType": "Bundle",
    "id": "42ae17d2-508c-4c07-a298-9791b0e3e409",
    "type": "searchset",
    "total": 2,
    "link": [
        {
            "relation": "self",
            "url": "https://localhost:5001/fhir/_snapshot?id=aed3da93-252e-407b-8a2e-a4f884ab8f8d&_offset=0"
        },
        {
            "relation": "first",
            "url": "https://localhost:5001/fhir/_snapshot?id=aed3da93-252e-407b-8a2e-a4f884ab8f8d&_offset=0"
        },
        {
            "relation": "last",
            "url": "https://localhost:5001/fhir/_snapshot?id=aed3da93-252e-407b-8a2e-a4f884ab8f8d&_offset=0"
        }
    ],
    "entry": [
        {
            "fullUrl": "https://localhost:5001/fhir/Observation/123/_history/1",
            "resource": {
                "resourceType": "Observation",
                "id": "123",
                "meta": {
                    "versionId": "1",
                    "lastUpdated": "2023-09-11T08:43:52.484+02:00"
                },
                "text": {
                    "status": "generated",
                    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n  <p>\n    <b>Generated Narrative with Details</b>\n  </p>\n  <p>\n    <b>id</b>: 123</p>\n  <p>\n    <b>status</b>: final</p>\n  <p>\n    <b>code</b>: Glucose [Moles/volume] in Blood <span>(Details : {LOINC code '15074-8' = 'Glucose [Moles/volume] in Blood', given as 'Glucose [Moles/volume] in Blood'})</span></p>\n  <p>\n    <b>subject</b>: <a>Patient/23</a></p>\n</div>"
                },
                "status": "final",
                "code": {
                    "coding": [
                        {
                            "system": "http://loinc.org",
                            "code": "15074-8",
                            "display": "Glucose [Moles/volume] in Blood"
                        }
                    ]
                },
                "subject": {
                    "reference": "Patient/23"
                }
            }
        },
        {
            "fullUrl": "https://localhost:5001/fhir/Observation/14/_history/2",
            "resource": {
                "resourceType": "Observation",
                "id": "14",
                "meta": {
                    "versionId": "2",
                    "lastUpdated": "2023-09-11T08:43:52.55+02:00"
                },
                "text": {
                    "status": "generated",
                    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n  <p>\n    <b>Generated Narrative with Details</b>\n  </p>\n  <p>\n    <b>id</b>: 14</p>\n  <p>\n    <b>status</b>: final</p>\n  <p>\n    <b>code</b>: Glucose [Moles/volume] in Blood <span>(Details : {LOINC code '15074-8' = 'Glucose [Moles/volume] in Blood', given as 'Glucose [Moles/volume] in Blood'})</span></p>\n  <p>\n    <b>subject</b>: <a>Patient/23</a></p>\n</div>"
                },
                "status": "final",
                "code": {
                    "coding": [
                        {
                            "system": "http://loinc.org",
                            "code": "15074-8",
                            "display": "Glucose [Moles/volume] in Blood"
                        }
                    ]
                },
                "subject": {
                    "reference": "Patient/23"
                }
            }
        }
    ]
}

@whyfate
Copy link
Contributor Author

whyfate commented Mar 14, 2024

Oh,this is indeed a bit brain burning.
This should be using _include: https://localhost:5001/fhir/Observation?subject=Patient/23&_include=Observation:patient
My understanding of _revinclude is that when we query a Patient, we want to associate their Observation with it. https://localhost:5001/fhir/Patient?_id=23&_revinclude=Observation:patient

@kennethmyhra
Copy link
Collaborator

Ah yes of course, it's the in the other direction. Nice, now it works, great!

@kennethmyhra kennethmyhra changed the title Support _revinclude Engine: Add support for _revinclude Mar 14, 2024
@kennethmyhra kennethmyhra merged commit 28194d7 into FirelyTeam:r4/master Mar 14, 2024
3 checks passed
kennethmyhra pushed a commit to kennethmyhra/spark that referenced this pull request Mar 14, 2024
Only supports simple _revinclude, does not support iteration.
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.

None yet

2 participants