FHIR $questionnaire-package operation for HealthLake
The $questionnaire-package operation retrieves a comprehensive bundle containing a FHIR Questionnaire and all its dependencies needed to render and process the questionnaire. This operation implements the Da Vinci Documentation Templates and Rules (DTR) Implementation Guide
How it works
-
Request: You send parameters identifying the questionnaire(s) needed, along with coverage and order context
-
Retrieve: HealthLake gathers the Questionnaire and all dependencies (ValueSets, CQL Libraries, etc.)
-
Package: All resources are bundled together in a standardized format
-
Respond: You receive a complete package ready for rendering and data collection
Use Cases
-
Prior Authorization Documentation: Collect required clinical information for prior authorization requests
-
Coverage Requirements: Gather documentation needed to satisfy payer coverage requirements
-
Clinical Data Exchange: Structure clinical data for submission to payers
-
Dynamic Forms: Render questionnaires with pre-populated patient data and conditional logic
API endpoint
POST /datastore/{datastoreId}/r4/Questionnaire/$questionnaire-package Content-Type: application/fhir+json
Request parameters
Input parameters
The request body must contain a FHIR Parameters resource with the following parameters:
| Parameter | Type | Cardinality | Description |
|---|---|---|---|
coverage |
Coverage | 1..* (Required) | Coverage resource(s) to establish the member and coverage for documentation |
questionnaire |
canonical | 0..* | Canonical URL(s) for specific Questionnaire(s) to return (may include version) |
order |
Resource | 0..* | Order resources (DeviceRequest, ServiceRequest, MedicationRequest, Encounter, Appointment) to establish context |
changedSince |
dateTime | 0..1 | If present, only return resources changed after this timestamp |
Parameter validation rules
At least ONE of the following must be provided (in addition to required coverage):
-
One or more
questionnairecanonical URLs -
One or more
orderresources
Valid Request Combinations:
-
coverage+questionnaire -
coverage+order -
coverage+questionnaire+order
Example request
POST /datastore/example-datastore/r4/Questionnaire/$questionnaire-package Content-Type: application/fhir+json Authorization: Bearer <your-token> { "resourceType": "Parameters", "parameter": [ { "name": "coverage", "resource": { "resourceType": "Coverage", "id": "example-coverage", "status": "active", "beneficiary": { "reference": "Patient/example-patient" }, "payor": [{ "reference": "Organization/example-payer" }], "class": [{ "type": { "coding": [{ "system": "http://terminology.hl7.org/CodeSystem/coverage-class", "code": "group" }] }, "value": "12345" }] } }, { "name": "questionnaire", "valueCanonical": "http://example.org/fhir/Questionnaire/home-oxygen-therapy|2.0" }, { "name": "order", "resource": { "resourceType": "ServiceRequest", "id": "example-service-request", "status": "active", "intent": "order", "code": { "coding": [{ "system": "http://www.ama-assn.org/go/cpt", "code": "94660", "display": "Continuous positive airway pressure ventilation (CPAP)" }] }, "subject": { "reference": "Patient/example-patient" } } }, { "name": "changedSince", "valueDateTime": "2024-01-01T00:00:00Z" } ] }
Response format
Success response (200 OK)
The operation returns a FHIR Parameters resource containing one or more Package Bundles. Each Package Bundle includes:
| Entry Type | Cardinality | Description |
|---|---|---|
| Questionnaire | 1 | The questionnaire to be rendered |
| QuestionnaireResponse | 0..1 | Pre-populated or partially completed response (if applicable) |
| Library | 0..* | CQL Libraries containing pre-population and conditional logic |
| ValueSet | 0..* | Expanded ValueSets (for answer choices with <40 expansions) |
Example response
{ "resourceType": "Parameters", "parameter": [ { "name": "PackageBundle", "resource": { "resourceType": "Bundle", "id": "questionnaire-package-example", "meta": { "profile": ["http://hl7.org/fhir/us/davinci-dtr/StructureDefinition/DTR-QPackageBundle"] }, "type": "collection", "timestamp": "2024-03-15T10:30:00Z", "entry": [ { "fullUrl": "http://example.org/fhir/Questionnaire/home-oxygen-therapy", "resource": { "resourceType": "Questionnaire", "id": "home-oxygen-therapy", "url": "http://example.org/fhir/Questionnaire/home-oxygen-therapy", "version": "2.0", "status": "active", "title": "Home Oxygen Therapy Documentation", "item": [ { "linkId": "1", "text": "Patient diagnosis", "type": "choice", "answerValueSet": "http://example.org/fhir/ValueSet/oxygen-diagnoses" } ] } }, { "fullUrl": "http://example.org/fhir/Library/oxygen-prepopulation", "resource": { "resourceType": "Library", "id": "oxygen-prepopulation", "url": "http://example.org/fhir/Library/oxygen-prepopulation", "version": "1.0", "type": { "coding": [{ "system": "http://terminology.hl7.org/CodeSystem/library-type", "code": "logic-library" }] }, "content": [{ "contentType": "text/cql", "data": "bGlicmFyeSBPeHlnZW5QcmVwb3B1bGF0aW9u..." }] } }, { "fullUrl": "http://example.org/fhir/ValueSet/oxygen-diagnoses", "resource": { "resourceType": "ValueSet", "id": "oxygen-diagnoses", "url": "http://example.org/fhir/ValueSet/oxygen-diagnoses", "status": "active", "expansion": { "timestamp": "2024-03-15T10:30:00Z", "contains": [ { "system": "http://hl7.org/fhir/sid/icd-10", "code": "J44.0", "display": "COPD with acute lower respiratory infection" }, { "system": "http://hl7.org/fhir/sid/icd-10", "code": "J96.01", "display": "Acute respiratory failure with hypoxia" } ] } } }, { "fullUrl": "http://example.org/fhir/QuestionnaireResponse/example-prepopulated", "resource": { "resourceType": "QuestionnaireResponse", "id": "example-prepopulated", "questionnaire": "http://example.org/fhir/Questionnaire/home-oxygen-therapy|2.0", "status": "in-progress", "subject": { "reference": "Patient/example-patient" }, "basedOn": [{ "reference": "ServiceRequest/example-service-request" }], "item": [ { "linkId": "1", "text": "Patient diagnosis", "answer": [{ "valueCoding": { "system": "http://hl7.org/fhir/sid/icd-10", "code": "J44.0", "display": "COPD with acute lower respiratory infection" } }] } ] } } ] } }, { "name": "Outcome", "resource": { "resourceType": "OperationOutcome", "issue": [{ "severity": "information", "code": "informational", "details": { "text": "Successfully retrieved questionnaire package" } }] } } ] }
Operation workflow
How HealthLake Processes Your Request
When you call $questionnaire-package, HealthLake performs the following steps:
-
Identify Patient & Payer: Extracts the patient and insurance organization from your
coverageparameter. -
Find the Right Questionnaire:
-
With
questionnaireparameter: Uses the canonical URL you provided -
With
orderparameter: Matches the order code (CPT/HCPCS/LOINC) and payer to find the appropriate questionnaire
-
-
Gather Dependencies: Automatically retrieves everything needed to render the questionnaire:
-
CQL Libraries - Logic for pre-population and conditional questions
-
ValueSets - Answer choices (automatically expanded if <40 options)
-
QuestionnaireResponse - Any existing in-progress or completed responses
-
-
Package Everything Together:
-
Bundles all resources (each resource included only once)
-
Filters by
changedSincetimestamp if provided -
Adds warnings to
Outcomeif any resources are missing
-
Result: A complete, self-contained package ready for rendering.
Error responses
400 Bad Request
Returned when request validation fails.
{ "resourceType": "OperationOutcome", "issue": [{ "severity": "error", "code": "required", "details": { "text": "At least one of 'questionnaire' or 'order' must be provided along with 'coverage'" } }] }
424 Failed Dependency
Returned when a dependent resource cannot be retrieved.
{ "resourceType": "OperationOutcome", "issue": [{ "severity": "warning", "code": "not-found", "details": { "text": "Referenced Library 'http://example.org/fhir/Library/missing-library' could not be retrieved" } }] }
401 Unauthorized
Returned when authentication credentials are missing or invalid.
403 Forbidden
Returned when the authenticated user lacks permission to access the requested resources.
406 Not Acceptable
Returned when the requested content type cannot be provided.
409 Conflict
Returned when there's a version or concurrency conflict.
410 Gone
Returned when the requested resource has been permanently deleted.
429 Too Many Requests
Returned when rate limits are exceeded.
500 Internal Server Error
Returned when an unexpected server error occurs.
501 Not Implemented
Returned when the requested operation is not yet implemented.
Validation rules
Input validation
-
coverageparameter is required (1..* cardinality) -
At least one of
questionnaireorordermust be provided -
All Coverage resources must be valid FHIR resources
-
All Order resources must be valid FHIR resources
-
Canonical URLs must be properly formatted
-
changedSincemust be a valid ISO 8601 dateTime
QuestionnaireResponse validation
-
statusmust be appropriate (in-progress,completed,amended) -
Structure must match the referenced Questionnaire
-
basedOnmust reference valid Order resources -
subjectmust reference valid Patient resources
Resource deduplication
-
Each resource appears only once in the bundle
-
Exception: Different versions of the same resource may both be included
-
Resources are identified by their canonical URL and version
Performance specifications
| Metric | Specification |
|---|---|
| Resource Count Limit | 500 resources per Bundle |
| Bundle Size Limit | 5 MB maximum |
Required permissions
To use the $questionnaire-package operation, ensure your IAM role has:
-
healthlake:QuestionnairePackage- To call the operation -
healthlake:ReadResource- To retrieve Questionnaire and dependent resources -
healthlake:SearchWithPost- To search for QuestionnaireResponse and related resources
SMART on FHIR Scopes
Minimum required scopes:
-
SMART v1:
user/Questionnaire.read user/Library.read user/ValueSet.read user/QuestionnaireResponse.read -
SMART v2:
user/Questionnaire.rs user/Library.rs user/ValueSet.rs user/QuestionnaireResponse.rs
Important implementation notes
Resource retrieval strategy
Questionnaire Identification Priority:
-
Canonical URL (if
questionnaireparameter provided) - Highest priority -
Order Analysis (if
orderparameter provided):-
Match order codes (CPT, HCPCS, LOINC) to payer medical policies
-
Use coverage payor to filter payer-specific questionnaires
-
Consider reason codes for additional context
-
Dependency resolution
CQL Libraries:
-
Retrieved via the
cqf-libraryextension on Questionnaire resources -
Recursively fetches dependent libraries through
Library.relatedArtifactwith typedepends-on -
All library dependencies are included in the package
ValueSets:
-
Automatically expanded if they contain fewer than 40 concepts
-
Larger ValueSets are included without expansion
-
ValueSets referenced in both Questionnaire and Library resources are included
QuestionnaireResponse pre-population
The operation may return a QuestionnaireResponse with pre-populated data when:
-
An existing in-progress or completed response is found
-
CQL logic in associated Libraries can extract data from patient records
-
The response is linked to the relevant order and coverage
Search Criteria for QuestionnaireResponse:
| Search Parameter | FHIR Path | Description |
|---|---|---|
based-on |
QuestionnaireResponse.basedOn |
Links to ServiceRequest or CarePlan |
patient |
QuestionnaireResponse.subject |
The patient who is the subject |
questionnaire |
QuestionnaireResponse.questionnaire |
The questionnaire being answered |
Changed resources filtering
When the changedSince parameter is provided:
-
Only resources modified after the specified timestamp are included
-
If no resources have changed, returns
200 OKwith an empty package -
Useful for incremental updates and caching strategies
-
Timestamp comparison uses resource
meta.lastUpdatedfield
Multiple package bundles
The operation may return multiple Package Bundles when:
-
Multiple questionnaires are requested via canonical URLs
-
Multiple orders require different questionnaires
-
Different versions of the same questionnaire are applicable
Each Package Bundle is self-contained with all necessary dependencies.
Common use cases
Use Case 1: Prior Authorization Documentation
Scenario: A provider needs to collect documentation for a home oxygen therapy prior authorization.
{ "resourceType": "Parameters", "parameter": [ { "name": "coverage", "resource": { /* Patient's insurance coverage */ } }, { "name": "order", "resource": { "resourceType": "ServiceRequest", "code": { "coding": [{ "system": "http://www.ama-assn.org/go/cpt", "code": "94660" }] } } } ] }
Result: Returns a package with the oxygen therapy questionnaire, pre-populated with patient vitals and diagnosis codes from the EHR.
Use Case 2: Retrieve Specific Questionnaire Version
Scenario: A provider needs a specific version of a questionnaire for compliance.
{ "resourceType": "Parameters", "parameter": [ { "name": "coverage", "resource": { /* Coverage resource */ } }, { "name": "questionnaire", "valueCanonical": "http://example.org/fhir/Questionnaire/dme-request|3.1.0" } ] }
Result: Returns exactly version 3.1.0 of the DME request questionnaire with all dependencies.
Use Case 3: Check for Updates
Scenario: A provider wants to check if any questionnaire resources have been updated since last retrieval.
{ "resourceType": "Parameters", "parameter": [ { "name": "coverage", "resource": { /* Coverage resource */ } }, { "name": "questionnaire", "valueCanonical": "http://example.org/fhir/Questionnaire/medication-request" }, { "name": "changedSince", "valueDateTime": "2024-03-01T00:00:00Z" } ] }
Result: Returns only resources that have been modified after March 1, 2024, or an empty package if nothing changed.
Use Case 4: Multiple Orders
Scenario: A provider submits multiple service requests that may require different questionnaires.
{ "resourceType": "Parameters", "parameter": [ { "name": "coverage", "resource": { /* Coverage resource */ } }, { "name": "order", "resource": { /* ServiceRequest for imaging */ } }, { "name": "order", "resource": { /* ServiceRequest for DME */ } } ] }
Result: Returns multiple Package Bundles, one for each applicable questionnaire.
Integration with Other Da Vinci IGs
Coverage Requirements Discovery (CRD)
Workflow Integration:
-
Provider orders a service in their EHR
-
CRD hook fires, checking coverage requirements
-
Payer responds indicating documentation is needed
-
Provider calls
$questionnaire-packageto retrieve the documentation form -
Provider completes the questionnaire
-
Documentation is submitted via PAS or CDex
Prior Authorization Support (PAS)
Workflow Integration:
-
Use
$questionnaire-packageto retrieve documentation requirements -
Complete the QuestionnaireResponse with required clinical data
-
Submit the prior authorization using
Claim/$submitwith the completed QuestionnaireResponse -
Check status using
Claim/$inquire
Clinical Data Exchange (CDex)
Workflow Integration:
-
Payer requests additional documentation for a claim
-
Provider uses
$questionnaire-packageto retrieve the structured data collection form -
Provider completes the QuestionnaireResponse
-
Documentation is submitted to payer via CDex attachment workflow
Troubleshooting guide
Issue: No Questionnaire Returned
Possible Causes:
-
Canonical URL doesn't match any Questionnaire in the data store
-
Order code doesn't map to any questionnaire in payer's medical policy
-
Coverage payor doesn't have associated questionnaires
Solutions:
-
Verify the canonical URL is correct and the Questionnaire exists
-
Check that order codes (CPT/HCPCS) are correctly specified
-
Confirm the payor organization has questionnaires configured
Issue: Missing Dependencies in Package
Possible Causes:
-
Referenced Library or ValueSet doesn't exist in the data store
-
Library references are broken or incorrect
-
ValueSet expansion failed
Solutions:
-
Check the
Outcomeparameter for warnings about missing resources -
Verify all referenced resources exist in your data store
-
Ensure ValueSet URLs are correct and resolvable
Issue: Empty Package with changedSince
Possible Causes:
-
This is expected behavior - no resources have been modified since the specified timestamp
Solutions:
-
Use the cached version of the package
-
Remove
changedSinceparameter to retrieve the full package
Issue: QuestionnaireResponse Not Pre-populated
Possible Causes:
-
No existing QuestionnaireResponse found
-
CQL Library logic couldn't extract required data
-
Patient data is missing or incomplete
Solutions:
-
This may be expected - not all questionnaires have pre-population logic
-
Check that patient data exists in the data store
-
Review CQL Library logic for data extraction requirements
Best practices
1. Use Canonical URLs with Versions
Always specify version numbers when requesting specific questionnaires:
{ "name": "questionnaire", "valueCanonical": "http://example.org/fhir/Questionnaire/dme|2.1.0" }
Why: Ensures consistency and prevents unexpected changes when questionnaires are updated.
2. Leverage changedSince for Performance
For frequently accessed questionnaires, use changedSince to minimize data transfer:
{ "name": "changedSince", "valueDateTime": "2024-03-10T15:30:00Z" }
Why: Reduces latency and bandwidth usage by retrieving only updated resources.
3. Include Complete Coverage Information
Provide comprehensive coverage details to ensure correct questionnaire selection:
{ "name": "coverage", "resource": { "resourceType": "Coverage", "beneficiary": { "reference": "Patient/123" }, "payor": [{ "reference": "Organization/payer-abc" }], "class": [{ /* Group/plan information */ }] } }
Why: Helps HealthLake identify payer-specific questionnaires and requirements.
Related operations
-
Claim/$submit- Submit prior authorization requests with completed documentation -
Claim/$inquire- Check status of submitted prior authorizations -
ValueSet/$expand- Expand ValueSets for answer choices