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

_lastUpdated is also filtering _revinclude results. #4896

Closed
michaelabuckley opened this issue May 16, 2023 · 1 comment · Fixed by #4899
Closed

_lastUpdated is also filtering _revinclude results. #4896

michaelabuckley opened this issue May 16, 2023 · 1 comment · Fixed by #4899

Comments

@michaelabuckley
Copy link
Contributor

When performing the following FHIR api query:

{{/Patient?_lastUpdated=gt2023-01-01&_revinclude=Group:member&_revinclude:iterate=CareTeam:subject}}

Expected behaviour:
Fetch Patients those last modified date is after 1st Jan 2023 and also fetch the Group & CareTeam linked to that Patient. Date filter should only be applied to the patient

Actual behaviour:
Patients, Group & CareTeam are all filtered based on date. This means result will only show Patient who have a last modified in Patient, CareTeam & Group after 1st Jan 2023

Complete Example of Rest API Query:

{{baseUrl}}/Patient?_count=10&_sort=-_lastUpdated&_has:Group:member:_has:CareTeam:subject:participant=Practitioner%2Fc6ca61e5-5b6a-496b-bff1-c0c2c477b31f&_has:Group:member:_has:CareTeam:subject:managing-organization=Organization/03783d3e-92ee-4cf8-b450-00632247fa6f&_lastUpdated=le2023-05-17T00:00:00+10:00&_lastUpdated=ge2023-05-15T00:00:00+10:00&_revinclude:iterate=CareTeam:subject&_revinclude=Group:member

Generated SQL:

{noformat}SELECT t1.RES_ID FROM HFJ_RESOURCE t1 
INNER JOIN HFJ_RES_LINK t0 ON (t1.RES_ID = t0.TARGET_RESOURCE_ID) 
INNER JOIN HFJ_RES_LINK t2 ON (t0.SRC_RESOURCE_ID = t2.TARGET_RESOURCE_ID) 
INNER JOIN HFJ_RES_LINK t3 ON (t2.SRC_RESOURCE_ID = t3.SRC_RESOURCE_ID) 
INNER JOIN HFJ_RES_LINK t4 ON (t1.RES_ID = t4.TARGET_RESOURCE_ID) 
INNER JOIN HFJ_RES_LINK t5 ON (t4.SRC_RESOURCE_ID = t5.TARGET_RESOURCE_ID) 
INNER JOIN HFJ_RES_LINK t6 ON (t5.SRC_RESOURCE_ID = t6.SRC_RESOURCE_ID) 
INNER JOIN HFJ_RESOURCE t7 ON (t1.RES_ID = t7.RES_ID) 
WHERE ((((t0.SRC_PATH = 'Group.member.entity') AND (t0.TARGET_RESOURCE_TYPE = 'Patient') 
    AND ((t2.SRC_PATH = 'CareTeam.subject') AND (t2.TARGET_RESOURCE_TYPE = 'Group') 
    AND ((t3.SRC_PATH = 'CareTeam.participant.member') AND (t3.TARGET_RESOURCE_ID = '3053')))) 
    AND ((t4.SRC_PATH = 'Group.member.entity') AND (t4.TARGET_RESOURCE_TYPE = 'Patient') 
    AND ((t5.SRC_PATH = 'CareTeam.subject') AND (t5.TARGET_RESOURCE_TYPE = 'Group') 
    AND ((t6.SRC_PATH = 'CareTeam.managingOrganization') AND (t6.TARGET_RESOURCE_ID = '1557'))))) 
    AND ((t7.RES_UPDATED >= '2023-05-14 14:00:00.0') AND (t7.RES_UPDATED <= '2023-05-16 14:00:00.999'))) 
    
ORDER BY t1.RES_UPDATED DESC offset 0 rows fetch next '13' rows only{noformat}
@michaelabuckley
Copy link
Contributor Author

Fixed in #4899

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 a pull request may close this issue.

1 participant