Right, so as I said. Issue a single SQL query to get all the records (or page that if the table is REALLY big).
Then for each record you got back, you need to issue a GET against the FHIR, if you get a hit, store whatever you need from the record and the returned FHIR data into a new variable.
At the end of your walk through the db records, you can delete that var and you are left with just the records that are in both the db and the patient system.
That will be the most efficient process from the DB perspective. Not terribly good for your patient system as you have to keep bombarding it with queries. Which is why you need a slight delay at the end of each loop through the db records.
Also not terribly efficient from a memory perspective since you have to load all of the db records into memory and that is why Node-RED is not as efficient at this type of processing than other platforms. One way around that is to grab the db records in batches (pages), process the batch and go round again for the next batch until you have no more db records.
That is also why something like PowerShell is more efficient because it will stream records and process each record as it is streamed. It is possible to do that using Node.js as well but Node-RED isn't really set up for that (there are a few streaming nodes I think so you may be able to do it, not sure).