nightscout / cgm-remote-monitor

nightscout web monitor
GNU Affero General Public License v3.0
2.39k stars 71.64k forks source link

Question: API call to query substring in note #6602

Open Arne1346 opened 3 years ago

Arne1346 commented 3 years ago

Hi,

I would like to use the API to query substrings of a note - how would the API call look like?

Example: Given my note entered in AAPS is: "Nice day, went out for a walk"

And I want to query all notes where the word "day" is part of.

https://my_server:port/api/v1/treatments?find[eventType]=Note&find[notes][$eq]=day

wouldn't find it and

https://my_server:port/api/v1/treatments?find[eventType]=Note&find[notes][$gte]=day

also doesn't pick it.

How can I do this?

stijnbrouwers commented 3 years ago

Hi @Arne1346 ,

I tried checked the code, it seems that you can pass a RegEx to the API for the following fields (for treatments):

Your example would work as follows: https://my_server:port/api/v1/treatments?find[eventType]=Note&find[notes]=/day/i

To use RegEx for these fields, you need to use equal sign, followed by a string in the format: //

is day in my example (the substring you want to use) is 'i' in my example which indicates a 'case insensitive' search Can you give feedback rather or not this worked for you?