Query filtering

Some endpoints have fields that can be used to filter the results. The filterable fields can be seen at the top of your Provet REST API endpoint page (eg. https://provetcloud.com/<provet_id>/api/0.1/consultation/) if the endpoint has filterable fields.

Operations

The following methods are available for filtering (synonyms are comma-separated):

is, eq

Equal

is_not, not_eq, neq

Not equal

lt

Less than

lte

Less than or equal

gt

Greater than

gte

Greater than or equal

range

Values between, needs two values in order [from,to]

not_in_range

Above inversed

contains

Text contains the searched text, case-sensitive

contains_not

Above inversed

icontains

Text contains the searched text, case-insensitive

icontains_not

Above inversed

in

Item is found in the given list [value1,value2,value3]

not_in

Above inversed

is_null

true or false

The filtering methods can be used with query parameters using the following syntaxes:

[field]__[method]=value

(eg. client__is=10 which uses the ID of the client for the search)

[field].[property]__[method]=value

(eg. client.id__is=10)

A field that the endpoint doesn’t support for filtering, or a method the field doesn’t support, is ignored, not refused. A misspelled filter therefore returns results as if it weren’t there, which on a list endpoint can be every record. Check the filterable fields on the endpoint’s page.

Two kinds of filter are refused with an error: a value the endpoint can’t read for the field, such as a malformed date or text on a number field, and a method used on a related object instead of one of its fields, such as phonenumbers__icontains instead of phonenumbers.phone_number__icontains.

Datetime values

Give dates and times in ISO 8601, for example 2017-12-24, 2017-12-24T15:30:00Z or 2017-12-24 15:30+02:00. Include a time zone, Z or an offset: a time without one is read in the time zone set for the organization in Provet, not in UTC. A value that can’t be read as a date is refused with an error.

To fetch only the records that changed since your last run, use modified__gte. See Keeping your data in sync.

Examples

If we need to find all consultations with the conditions

  • complaint contains the word “vacc” (case-insensitive)

  • the admitted_time is between 2017-12-01 00:00+00:00 (greater than or equal) and 2018-01-01 00:00+00:00 (less than)

  • department ID is 1

  • client ID is 10

  • one of the patients’ ID in the consultation is 20

we would use the following URL:

https://provetcloud.com/<provet_id>/api/0.1/consultation/
?complaint__icontains=vacc
&admitted_time__gte=2017-12-01T00:00:00%2B00:00
&admitted_time__lt=2018-01-01T00:00:00%2B00:00
&department__is=1
&client__is=10
&patients__is=20

Note that “+” signs are URL encoded (%2B) in the above example for the URL to work.

If we need to find all consultations where

  • the client’s first name is John and

  • the client’s last name is Doe

we would use the following URL:

https://provetcloud.com/<provet_id>/api/0.1/consultation/
?client.firstname__is=John
&client.lastname__is=Doe