Skip to content

Commit 5229d69

Browse files
committed
Moved prefetch token section from hooks documentation to prefetch templates section.
1 parent 12302cb commit 5229d69

File tree

1 file changed

+64
-64
lines changed

1 file changed

+64
-64
lines changed

docs/specification/1.0.md

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,69 @@ keys match the request keys (`patient` and `hemoglobin-a1c` in this case).
297297

298298
Note that the missing `user` key indicates that either the EHR has decided not to satisfy this particular prefetch template or it was not able to retrieve this prefetched data. The CDS Service is responsible for retrieving this Practitioner data from the FHIR server (if required).
299299

300+
#### Prefetch tokens
301+
302+
Often a prefetch template builds on the contextual data associated with the hook. For example, a particular CDS Service might recommend guidance based on a patient's conditions when the chart is opened. The FHIR query to retrieve these conditions might be `Condition?patient=123`. In order to express this as a prefetch template, the CDS Service must express the FHIR identifier of the patient as a token so that the EHR can replace the token with the appropriate value. When context fields are used as tokens, their token name MUST be `context.name-of-the-field`. For example, given a context like:
303+
304+
```json
305+
"context" : {
306+
"patientId": "123"
307+
}
308+
```
309+
310+
The token name would be `{{context.patientId}}`. Again using our above conditions example, the complete prefetch template would be `Condition?patient={{context.patientId}}`.
311+
312+
Only the first level fields in context may be considered for tokens. Hook creators MUST document which fields in the context are supported as tokens. If a context field can be tokenized, the value of the context field MUST be a JSON primitive data type that can placed into a FHIR query (i.e. a string, a number, or a boolean).
313+
314+
For example, given the following context that contains amongst other things, a Patient FHIR resource:
315+
316+
```json
317+
"context" : {
318+
"encounterId": "456",
319+
"patient": {
320+
"resourceType": "Patient",
321+
"id": "123",
322+
"active": true,
323+
"name": [
324+
{
325+
"use": "official",
326+
"family": "Watts",
327+
"given": [
328+
"Wade"
329+
]
330+
}
331+
],
332+
"gender": "male",
333+
"birthDate": "2024-08-12"
334+
}
335+
}
336+
```
337+
338+
Only the `encounterId` field in this example is eligible to be a prefetch token as it is a first level field and the datatype (string) can be placed into the FHIR query. The Patient.id value in the context is not eligible to be a prefetch token because it is not a first level field. If the hook creator intends for the Patient.id value to be available as a prefetch token, it must be made available as a first level field. Using the aforementioned example, we simply add a new `patientId` field:
339+
340+
```json
341+
"context" : {
342+
"patientId": "123",
343+
"encounterId": "456",
344+
"patient": {
345+
"resourceType": "Patient",
346+
"id": "123",
347+
"active": true,
348+
"name": [
349+
{
350+
"use": "official",
351+
"family": "Watts",
352+
"given": [
353+
"Wade"
354+
]
355+
}
356+
],
357+
"gender": "male",
358+
"birthDate": "2024-08-12"
359+
}
360+
}
361+
```
362+
300363
#### Prefetch query restrictions
301364

302365
To reduce the implementation burden on EHRs that support CDS Services, this specification RECOMMENDS that prefetch queries only use a subset of the full functionality available in the FHIR specification. Valid prefetch templates SHOULD only make use of:
@@ -715,77 +778,14 @@ Prefetch data, on the other hand, is defined by CDS Services as a way to allow t
715778
}
716779
```
717780

718-
See the section on [prefetch tokens](#prefetch-tokens) below for more information on how contextual information can be used to parameterize prefetch templates.
781+
See the section on [prefetch tokens](#prefetch-tokens) for more information on how contextual information can be used to parameterize prefetch templates.
719782

720783
Consider another hook for when a new patient is being registered. In this case, it would likely be appropriate for the context to contain the full FHIR resource for the patient being registered as the patient may not be yet recorded in the EHR (and thus not available from the FHIR server) and CDS Services using this hook would predominantly be interested in the details of the patient being registered.
721784

722785
Additionally, consider a PGX CDS Service and a Zika screening CDS Service, each of which is subscribed to the same hook. The context data specified by their shared hook should contain data relevant to both CDS Services; however, each service will have other specific data needs that will necessitate disparate prefetch requests. For instance, the PGX CDS Service likely is interested in genomics data whereas the Zika screening CDS Service will want Observations.
723786

724787
In summary, context is specified in the hook definition to guide developers on the information available at the point in the workflow when the hook is triggered. Prefetch data is defined by each CDS Service because it is specific to the information that service needs in order to process.
725788

726-
#### Prefetch tokens
727-
728-
Often a prefetch template builds on the contextual data associated with the hook. For example, a particular CDS Service might recommend guidance based on a patient's conditions when the chart is opened. The FHIR query to retrieve these conditions might be `Condition?patient=123`. In order to express this as a prefetch template, the CDS Service must express the FHIR identifier of the patient as a token so that the EHR can replace the token with the appropriate value. When context fields are used as tokens, their token name MUST be `context.name-of-the-field`. For example, given a context like:
729-
730-
```json
731-
"context" : {
732-
"patientId": "123"
733-
}
734-
```
735-
736-
The token name would be `{{context.patientId}}`. Again using our above conditions example, the complete prefetch template would be `Condition?patient={{context.patientId}}`.
737-
738-
Only the first level fields in context may be considered for tokens. Hook creators MUST document which fields in the context are supported as tokens. If a context field can be tokenized, the value of the context field MUST be a JSON primitive data type that can placed into a FHIR query (i.e. a string, a number, or a boolean).
739-
740-
For example, given the following context that contains amongst other things, a Patient FHIR resource:
741-
742-
```json
743-
"context" : {
744-
"encounterId": "456",
745-
"patient": {
746-
"resourceType": "Patient",
747-
"id": "123",
748-
"active": true,
749-
"name": [
750-
{
751-
"use": "official",
752-
"family": "Watts",
753-
"given": [
754-
"Wade"
755-
]
756-
}
757-
],
758-
"gender": "male",
759-
"birthDate": "2024-08-12"
760-
}
761-
}
762-
```
763-
764-
Only the `encounterId` field in this example is eligible to be a prefetch token as it is a first level field and the datatype (string) can be placed into the FHIR query. The Patient.id value in the context is not eligible to be a prefetch token because it is not a first level field. If the hook creator intends for the Patient.id value to be available as a prefetch token, it must be made available as a first level field. Using the aforementioned example, we simply add a new `patientId` field:
765-
766-
```json
767-
"context" : {
768-
"patientId": "123",
769-
"encounterId": "456",
770-
"patient": {
771-
"resourceType": "Patient",
772-
"id": "123",
773-
"active": true,
774-
"name": [
775-
{
776-
"use": "official",
777-
"family": "Watts",
778-
"given": [
779-
"Wade"
780-
]
781-
}
782-
],
783-
"gender": "male",
784-
"birthDate": "2024-08-12"
785-
}
786-
}
787-
```
788-
789789
### Hook Definition Format
790790

791791
Hooks are defined in the following format.

0 commit comments

Comments
 (0)