rabbit_rabbit
07/20/2026, 9:13 PMconst records = new Map<string, PatientRecord>();
const patients = await client.searchResources('Patient', '_count=1000');
await Promise.all(
patients.map(async (patient) => {
const pid = patient.id;
const careTeams = await client.searchResources(
'CareTeam',
`subject=Patient/${pid}`,
);
records.set(pid, { patient, careTeam: careTeams[0] });
}),
);
return { records };
or I could do this as 2 parallel requests
const records = new Map<string, PatientRecord>();
const [patients, careTeams] = await Promise.all([
client.searchResources('Patient', '_count=1000'),
client.searchResources('CareTeam', '_count=1000'),
])
patients.map((patient) => {
const pid = patient.id
const careTeam = careTeams.find(careTeam =>
careTeams.reference === `Patient/${patient.id}`
)
records.set(pid, { patient, careTeam });
});
return { records };
I'm wondering though is on the backend access policies are applied after resources are found. That is, whether all matching records are found and then the filter is applied in such a way that we end up essentially scanning all records and having bad performance.
I imagine this isn't the case, but wanting to check before banking on this. Thank you!thomabig
07/21/2026, 12:57 PMrabbit_rabbit
07/21/2026, 2:23 PM