cds-hooks / docs

CDS Hooks website & specification
http://cds-hooks.org
Apache License 2.0
166 stars 61 forks source link

Support for Relative Dates in Prefetch #658

Open msargent56 opened 3 months ago

msargent56 commented 3 months ago

Optimizing the prefetch template with query parameters can be impactful in its ability to limit the amount of data being generated by the CDS client and sent to the CDS service. Targeted filtering of prefetch can have a benefit to both performance (during CDS client request generation) and ensuring the CDS service does not need to receive more data than is necessary to perform its function.

In practice this has worked great but there is a limitation in interacting with dates since there isn't a great way to specify a time period relative to today.

For example, a CDS Service might have this pre-fetch: { "prefetch": { "meds": "MedicationRequest?patient={{context.patientId}}&status=active,completed" } }

However, the CDS Service may only care about recently completed medications. It would be beneficial if the CDS Hooks specification defined a way to communicate relative dates in the prefetch.

For example, having a way for the service to indicate it only cares about active or completed medications in the past 14 days. { "prefetch": { "meds": "MedicationRequest?patient={{context.patientId}}&status=active,completed&date=ge{{context.date.today(-14)}}" } }

Having the ability to specify relative dates in a similar manner to above would help avoid issues related to caching/manually pre-configuring prefetch templates.