Skip to content

FHIR Context With Agent Skills ​

Agent Skills that that use FHIR APIs can indicate that they require FHIR context. This is primarily handled by metadata field of the Agent Skills specification.

Metadata Declaration ​

For agent skills that are configured with FHIR context the frontmatter metadata will look like:

The scopes within the po-fhir-context-scopes should indicate SMART scopes that your script requires. The user that adds the skill can then decide to authorize the agent with the requested access. You can mark a scope as required by supplying it under the po-fhir-context-required-scopes field. When marking a scope as required, a user cannot uncheck the scope and their only option is to avoid using the skill at all if they do not consent to giving the required access.

Here is a sample metadata declaration for an agent skill that has a required scope of patient/MedicationRequest.rs (which allows reading and searching on the current patient MedicationRequest resources) and an optional scope of patient/Condition.rs (which allows reading and searching for conditions for the current patient).

YAML
---
metadata:
  po-fhir-context-required-scopes:
    patient/MedicationRequest.rs
  po-fhir-context-scopes:
    patient/Patient.rs patient/Condition.rs
---

FHIR Context Environment Variables ​

When the FHIR context is configured Prompt opinion will pass the access token and the FHIR url as environment variables:

FHIR_BEARER_TOKEN = access token restricted to the requested scopes

FHIR_BASE_URL = the FHIR url against which the requests will be executed

Python usage example:

py
    token = os.environ.get("FHIR_BEARER_TOKEN")

    fhir_url = os.environ.get("FHIR_BASE_URL")