How to query a Data Store for existing records

I’m requesting data from an API that includes changes within a 48 hour period. As the Make scenario is querying the API every 3 hours, the response may include records already processed by the scenario on a previous occasion.

To combat this I have setup a Data Store which, on completion of the scenario, will store the Patient ID number of the subject whose data is being processed. In the scenario I want to query the Data Store to see if the subject’s Patient ID number exists in the Data Store. If not, the scenario should continue. If it exists in the Data Store the scenario should stop.

Here is my current flow:

Here is the filter:

I have tried retrieving all results and then checking if stored Patient ID equals the Patient ID of this iteration but this results in the next step being completed multiple times. I’ve tried seeing if the Data Store result array contains the Patient ID but that doesn’t seem to work either.

Any thoughts?

Hi. Store the Patiend ID as an array in datastore. Then you can use the filter using the rule (with string function) “IF patient ID array” DO NOT CONTAINS patient id Interated". This way only the interated not present in the datastore array will go to the next steps.

image


Thanks, Helio!
Wemakefuture
If you have questions reach out :wink:

1 Like

Thanks @Wemakefuture for the suggestion. I’m not sure that would help as then I’d have lots of arrays I would have to search through in the Data Store. I’m really after an option like

SELECT 1 FROM `data_store` WHERE `patient_ID`  = 'patient:id'

Then if number of rows returned is > 0 the scenario would not proceed.