Skip to content

Instantly share code, notes, and snippets.

@niquola
Last active December 20, 2021 19:52
Show Gist options
  • Save niquola/02cd26348552c43420e85259aa2c6743 to your computer and use it in GitHub Desktop.
Save niquola/02cd26348552c43420e85259aa2c6743 to your computer and use it in GitHub Desktop.
select * from list
where
resource#>'{code,coding}'
@> jsonb_build_array(
jsonb_build_object(
'system', 'http://physicianslab.com/fhir/List/testing-method',
'code', {{params.teting-method}}),
jsonb_build_object(
'system', 'http://physicianslab.com/fhir/List/testing-category',
'code', {{params.teting-category}}),
jsonb_strip_nulls(
jsonb_build_object(
'system', 'http://physicianslab.com/fhir/List/batch-status',
'code', {{params.batch-status}})),
jsonb_strip_nulls(
jsonb_build_object(
'system', 'http://physicianslab.com/fhir/List/batch-id',
'code', {{params.batch-id}})),
jsonb_strip_nulls(
jsonb_build_object(
'system', 'http://physicianslab.com/fhir/List/batch-type',
'code', {{params.batch-type}})))
order by resource->>'date'
limit {{params.count}}
offset {{params.skip}}
@niquola
Copy link
Author

niquola commented Dec 20, 2021

CREATE INDEX list_code on "list" using GIN ( ( resource#>'{code,coding}' ));

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