When teams need structured data capture with Questionnaires on HAPI FHIR
A clinical or operational team needs intake or assessment forms whose answers are coded and queryable, not stored as free text in a note. In FHIR, the form itself is a Questionnaire resource: a definition that lists each item, its data type, its answer options, and any conditional logic that shows or hides questions. Each completed form is a QuestionnaireResponse resource that points back to the Questionnaire it answers and records the values a patient, clinician or staff member entered. When the answers need to be counted, reported or acted on later, this pair is the usual starting point, because each answer sits in a defined place in the resource rather than inside a document.
A HAPI FHIR JPA server stores both kinds of resource in its database like any other FHIR resource, so Questionnaires and QuestionnaireResponses can be created, read, updated and searched through the standard REST API. The harder question is which Questionnaire-related operations the version you deploy actually implements, such as form population, response extraction or questionnaire assembly. Support for these operations is not the same across HAPI FHIR releases or FHIR versions, so confirm the operations against the version notes and the server's capability statement before you design a workflow around them. Check this with a test server, not only with the documentation.
Before building forms, decide who authors Questionnaires, how they are versioned, and whether each QuestionnaireResponse will reference a specific Questionnaire version. Also decide which fields must be validated on write, and who can read responses under your access model, since intake forms often hold sensitive data. A small set of representative forms, loaded into a non-production server and completed by real users, will show gaps in the item design and in the server's behavior before the forms reach patients or staff.
How a Questionnaire moves from definition to stored response
The flow starts with a form author publishing a Questionnaire to the HAPI FHIR JPA server, which stores it as a FHIR resource. A front end or EHR fetches that definition and renders it for the respondent, and the trust boundary sits between the browser or EHR and the server. The respondent's answers return as a QuestionnaireResponse, which passes the authentication and audit interceptors before the server validates it and writes it to the relational database. Downstream readers then query the stored response through the same API, so check that authorization applies to those reads as well as to writes.
Questionnaire and QuestionnaireResponse flow across the form front end, the server and the database.
Configuration choices for Questionnaire capture on HAPI FHIR
This table compares the five decisions that shape a Questionnaire build: FHIR version, where definitions live, how forms are rendered, response validation and partition layout. Read each row for when an option fits and what it costs in effort or flexibility, then decide which combination matches your data governance and team skills.
| Decision | Option | Trade-off | When to choose it |
|---|---|---|---|
| FHIR version | R4 or R4B | Widest set of existing Questionnaire tooling and examples; confirm feature coverage for your form logic in the JPA server docs. | Your form engine, IGs or partner systems already target R4 or R4B. |
| FHIR version | R5 or DSTU3 | Newer or older resource definitions; fewer off-the-shelf examples and client libraries to reuse. | You need a specific R5 capability or must interoperate with DSTU3 systems. Confirm the version your JPA server release supports. |
| Definition authoring | Authored in files and loaded at deploy | Versioned in Git with code review, but changes need a release or reload step. | Forms change slowly and clinical or compliance teams want diffs and approvals. |
| Definition authoring | Authored and edited through the server API | Faster iteration, but requires strict versioning rules and an audit trail of who changed what. | Forms are maintained by an informatics team that changes them often and can follow a controlled promotion process. |
| Form rendering | Server-side population of responses | Keeps logic close to data and reduces client complexity, but adds server load and needs careful $populate design. | Pre-filled intake from existing records is required and the rendering client is simple. |
| Form rendering | Separate form engine on the client | Richer user experience and clearer ownership of UI, but the engine's Questionnaire support must be confirmed and tested. | Front-end teams own the experience and you can verify engine compatibility with your chosen FHIR version. |
| Response validation | Validate against a base profile only | Lower effort; structural errors are caught, but local rules such as required extensions may pass unchecked. | Early pilots or low-risk intake where data quality rules are still being agreed. |
| Response validation | Validate against a custom or IG profile | Stronger data quality and easier assessor review, but profile authoring and maintenance add recurring effort. | Captured data feeds measures, reports or downstream clinical systems that expect a defined structure. |
| Partition layout | Single partition | Simplest setup and queries; weaker separation between organizations, regions or data sources. | One organization or one data domain with a single access model. |
| Partition layout | Partitioned data separation | Supports tenant or regional separation through partitions, but adds configuration, access rules and testing for each partition. | Several organizations, regions or data sources must be kept apart and your team can manage partition-aware access control. |
Setup sequence for a Questionnaire intake form
This sequence takes a HAPI FHIR JPA server from a version-checked install to a Questionnaire that accepts, stores and returns intake responses under non-admin access. Each step closes with a check that the team can record before moving on.
Confirm Java and server version requirements
The platform or integration lead checks the HAPI FHIR version against the versions page before anything is installed. The version you select must match the JDK you run, so confirm the JDK requirement for that release and record both values in the build ticket. For example, HAPI FHIR 8.2.0 requires JDK 17, but your target release may differ, so confirm it on the page. Done means the version and JDK are written down and the JDK is installed on the build host.
Deploy the JPA server starter with PostgreSQL
The platform engineer deploys the hapi-fhir-jpaserver-starter using a supported production database, either PostgreSQL or Microsoft SQL Server. Do not use MySQL, and do not leave the default embedded H2 database in place for anything beyond a local test. Choose a deployment method your team already runs, such as the hapiproject/hapi Docker image, a Helm chart on Kubernetes, or a WAR on an application server. Done means the server starts, connects to the database and answers a metadata request at its base URL.
Verify the server and capability statement
The platform engineer requests the server capability statement and confirms that the FHIR version and the Questionnaire and QuestionnaireResponse resource types are listed as supported. The check also confirms that the server is running the release you chose in the first step. If the resource types are missing or the version differs, stop and correct the configuration before loading any content. Done means the capability statement is saved with the build record.
Load the intake Questionnaire
The forms or clinical informatics lead, working with the platform engineer, creates the Questionnaire resource and uploads it to the server with a stable canonical URL and version. Validate the resource against the FHIR specification for your target version before upload so structural errors are caught early. Done means the server returns the Questionnaire on read, and a validation result with no errors is saved with the build record.
Submit and store a test QuestionnaireResponse
A tester submits a QuestionnaireResponse that references the loaded Questionnaire by its canonical URL, using realistic but synthetic test data that contains no patient information. Confirm the server accepts the resource and returns a server-assigned ID. Then read the stored resource back by ID and compare every answer against the submitted payload. Done means the read-back matches the input exactly, including nested items and answer types.
Check search parameters on stored responses
The tester runs searches on QuestionnaireResponse using the parameters your reporting and retrieval needs depend on, such as the questionnaire reference, status and subject. Confirm each search returns the test resource and that the expected result counts match. Check the supported search parameters in the server's capability statement, because they vary by version and configuration. Done means each required search returns the expected result, and any missing parameter is logged as a configuration item.
Test access under a non-admin account
The security engineer creates a non-admin user through the identity provider the server uses and repeats the submit, read and search steps. Confirm the user can perform only the operations their role allows and cannot read responses outside their scope. HAPI FHIR provides building blocks for authorization, but it does not supply a complete security layer, so this test must be run on your configuration. Done means the access results are recorded and any unexpected access is fixed and retested before the form is released.
Storing captured data and deciding where it lives
The first decision is whether captured answers stay as QuestionnaireResponse resources or get extracted into other resource types. On a HAPI FHIR JPA server, a QuestionnaireResponse is stored as a FHIR resource in the same database as Patient, Encounter and Observation resources, so it can be searched, versioned and referenced like any other resource. Each response should carry a reference to the Questionnaire it answered, the subject it describes and, where the form was filled in during a visit, the encounter. Those references are what let other FHIR clients, and measure logic written in CQL, find the answers later. Confirm with your team which Questionnaire version each response points to, because a response that references an unversioned Questionnaire can become hard to interpret after the form is revised.
Extraction is the step that turns free-form answers into Observation, Condition or other resources that quality measures and decision support already consume. It needs a mapping from question items to target resource types and codes, and that mapping is work your team designs, owns and tests. Extraction tooling is not something this topic assumes is ready out of the box: confirm with the vendor documentation for your HAPI FHIR version which extraction approach, if any, you will use, and test its output against your measure and CDS logic before relying on it. Keep the raw QuestionnaireResponse even when you extract, so that a mapping error can be traced back to the answer the patient actually gave.
Partitioning is the second placement decision. According to the HAPI FHIR partitioning documentation, the JPA server places each resource in a partition, and partitions can support multitenancy, separation of data sources or grouping by region. Decide early whether intake forms from different clinics, regions or source systems need that separation, because partition choices shape how data is stored and queried. Ask your HAPI FHIR partner or internal team to document how partition assignment is set for QuestionnaireResponse resources, and test that a search from one tenant cannot return another tenant's responses. Access rules still have to be built separately, since partitioning organizes data but does not replace the authorization controls described in the security documentation.
What goes wrong with structured forms in production
Structured forms look simple until they hold live clinical or intake data. The risks below share a root cause: a Questionnaire is a versioned contract between the form, the stored answers and every system that reads them, so a change in one place quietly breaks the others.
Questionnaire versions drifting from responses
A QuestionnaireResponse points to the canonical Questionnaire version it was completed against, but edits to the form can leave older answers pointing at a version whose items no longer match. Check whether your intake client sends the versioned canonical URL on every submission. Prevent drift by publishing a new version for each change, never editing a published one in place, and recording the version in your release notes.
HAPI JPA server docsFree text replacing coded choices
When a question lacks a bounded answer option set, staff type values such as "diabetic" or "DM2" that cannot be counted or matched to a value set. Watch for high rates of free-text answers on items that should be coded. Prevent this by binding choice items to a ValueSet your terminology team maintains, and by using answerOption or answerValueSet definitions instead of open string items wherever the answer is a category.
Responses failing validation after a change
A response valid under version 1 may fail once a required item, answer option or enableWhen rule is added in version 2. Old records then cannot be re-validated or edited without errors, which blocks corrections. Before publishing, run existing sample responses through the validator against the new Questionnaire, and decide in advance whether older responses are migrated, flagged or left as they were.
Missing or inconsistent search parameters
Teams often find that a clinician cannot locate the responses they need because the subject, encounter or authored date is not indexed the way their queries expect. Test the exact searches your workflows run against a seeded server, including chained and date-range queries. Confirm which search parameters your HAPI version supports for QuestionnaireResponse and add custom search parameters only after checking the server's search configuration.
Duplicate submissions from retries
Mobile apps and portals often resend a form after a timeout, which creates two QuestionnaireResponse resources for one visit. Reports then double count assessments and downstream CDS sees conflicting answers. Prevent this by sending conditional creates keyed on a business identifier, by setting the identifier from the client when the form opens, and by testing the submit path with a forced timeout before go-live.
Staff unable to find the right form
Forms that are published but not linked to the right workflow, or that carry unclear titles and status values, get bypassed and answered on paper or in a different tool. Check that every active Questionnaire has a clear name, a status of active only when it is approved, and an owner listed in your catalog. Review the list of forms in use each quarter and retire drafts so staff see one current version.
What buyers ask before hiring help with Questionnaire capture
What drives the cost of a Questionnaire capture project on HAPI FHIR?
The main drivers are the number of forms, how many versions each form needs, how complex the validation and conditional logic is, and how much the forms must connect to systems you already run. A single intake form with a few answers that writes to the server is a very different job from twenty assessment forms with branching rules, calculated fields, terminology bindings and an existing EHR or identity provider on the other side. Cost is mostly people time: clinical content work, form authoring, integration, testing and handover. No price is stated here. Ask any partner for a quote built from a written list of forms, the rendering front end you expect, the validation rules, and each integration point, with deliverables and acceptance tests named for each item.
How long does a first Questionnaire take to design and verify?
The time depends less on the server than on how quickly clinical owners settle the content. Design covers the item list, answer options, skip logic, required fields and how each answer maps to stored data. Verification covers rendering in the client you use, checking that every QuestionnaireResponse validates against the Questionnaire, and confirming the stored data is what clinicians and downstream reports expect. No duration is stated in the sources for this work. Ask a partner to break the estimate into content sign-off, build, test and go-live steps, and to state which of those depend on your reviewers' availability.
What must our organization supply before a Questionnaire project starts?
Four groups of inputs usually decide whether the project moves at the planned pace:
Can our internal team build Questionnaires on HAPI FHIR without outside help?
Yes, if your team already runs FHIR APIs and has someone who can author and test the forms. HAPI FHIR is an Apache Software License 2.0 Java API, and the JPA server gives you the REST endpoints that store Questionnaire and QuestionnaireResponse resources. What is often missing internally is clinical content authoring, FHIR validation know-how, and a front end that renders the forms correctly for users. Many teams split the work: they keep content ownership and day-to-day operations in house and bring in a partner for the initial design, integration or testing. Decide that split by listing skills you have today against the work above, rather than by team size.
Which costs are one-time and which recur after go-live?
One-time costs include form design, content sign-off, initial build, integration work, and acceptance testing. Recurring costs include running the server and database, applying HAPI FHIR version upgrades, updating forms when clinical content changes, reviewing validation after upgrades, and keeping backups and monitoring working. Ask a partner to separate these in the quote, and to say whether ongoing support is a fixed retainer or billed per change. DeployOpen offers ongoing support, upgrades and continuous testing as retainers, and most engagements are fixed-scope with scope, deliverables and timelines agreed in writing before work starts.
How do Questionnaire responses get stored, and who can read them?
The JPA server stores QuestionnaireResponse resources in the database you configure, and access follows the security layer you put in front of it. HAPI FHIR does not provide a single one-size-fits-all security layer. It offers building blocks such as authentication interceptors, the AuthorizationInterceptor, consent and search narrowing interceptors, CORS support and BALP audit logging. Decide early which roles can create, read and export responses, how patient-level access is enforced, and where audit records go. Confirm the exact behavior of each interceptor against the version you deploy, since the controls are assembled rather than turned on by default.
Do we need a separate database or partition for Questionnaire data?
Not always, but the choice should be made before data arrives. The JPA server supports PostgreSQL and Microsoft SQL Server for production, and does not support MySQL. Partitioning places each resource in a partition, which can separate tenants, data sources or regions. If different business units or sites will capture forms under different rules, plan partitions and access controls together so one unit cannot read another's responses. Ask a partner to document the database engine, schema approach, storage sizing, and whether partitioning is needed, and confirm these choices against the HAPI FHIR version you will run.
Security and audit controls around QuestionnaireResponse data
HAPI FHIR gives you building blocks for protecting questionnaire data but no complete security layer, so the operator designs the rules that decide who can create, read and search each response. The cards below cover the access decisions, consent, browser settings, audit trail and data-at-rest protection you need to review before intake forms hold real patient information.
Authorization on create, read and search
Every QuestionnaireResponse needs rules for who may create, read, update and search it. Map each role, such as patient, clinician, intake staff and integration account, to the resource types and operations it needs. Use the AuthorizationInterceptor to enforce those rules on the server rather than in the form client, since browser code can be changed by anyone. Check that the rules also cover $populate requests and bundle transactions, which can create responses indirectly. Confirm with your security team which roles may see completed assessments.
Search narrowing for responses
Search narrowing limits what a caller gets back from a query, so a patient-facing user only sees responses linked to their own subject. Without it, a broad search such as a query by questionnaire name could expose other people's answers even when direct reads are blocked. Test common search parameters such as subject, questionnaire, status and authored, and try combinations that a user should not be able to run. Record which parameters are allowed for each role before go-live.
Consent handling
Some intake answers, such as mental health, substance use or reproductive health questions, may need stricter consent than the form as a whole. Decide whether consent is recorded as a separate resource, as a field in the response, or as a rule in your interceptor, and document how a withdrawal is applied to stored responses. The consent interceptor building block can hide or restrict data based on a consent decision. Confirm with your privacy office which questions carry extra conditions and who reviews them.
CORS settings for browser forms
Forms that run in a browser call the server from another origin, so CORS must allow the form site and nothing broader. A wildcard origin on a server that accepts patient data lets any website submit or read requests made by a logged-in user's browser. List exact origins, limit allowed methods to those the form uses, and restrict headers that carry tokens. Test a request from an unlisted origin and confirm it fails. Check the CORS support documentation for the version you run.
BALP audit logging
The BALP audit logging building block records who accessed which FHIR resource and when, which is the record your auditors will ask for after a disclosure question. Turn it on for QuestionnaireResponse reads and searches as well as writes, since viewing a completed assessment is also access. Decide where audit events are sent, how long they are kept, and who can read them, and make sure the audit store is not writable by the same accounts that handle patient data. Confirm the audit fields match your retention and review policy.
Database and backup protection
Completed responses live in the relational database behind the JPA server, and every backup copies them. Encrypt the database and backup storage, restrict who can connect to the database directly so that application controls cannot be bypassed, and set backup retention and restore testing as part of the security plan. A restored backup can reintroduce answers that were later withdrawn, so include consent withdrawal in the restore procedure. Ask your database team to confirm encryption, access and backup retention settings in your environment.
Operating captured data over the form lifecycle
Once a Questionnaire is live, the hardest operational decisions concern the responses already stored, not the form itself. Before you publish a new version, decide how each response stays tied to the Questionnaire version it was captured under. A QuestionnaireResponse references its Questionnaire by canonical URL and version, so a response captured under version 1 should still display and validate against version 1 after version 2 is published. Record that rule in your form governance: who approves a new version, how the version and status fields change, and whether clinicians can keep working from a draft. Test the rule with a sample response from each prior version, because a reporting query or downstream integration that assumes only the latest form will break quietly.
Retiring a form is a data decision as much as a catalog change. Setting a Questionnaire to retired may hide it from new use, but the stored responses are clinical or operational records with their own retention obligations, and they must remain readable for as long as those obligations run. Confirm with your records and compliance owners how long responses are kept, who can still read them, and whether consumers such as measure or care gap reports still need the retired form's answer structure. Stopping the form in the front end is not the same as removing its data, and you should not delete Questionnaire resources that responses still reference without a documented plan.
The database behind the server holds every response, so it belongs in your backup and restore plan from the first day of use. Back up the relational database on a schedule you can justify, and rehearse a restore that brings back both the resources and the search indexes the server relies on. Your upgrade plan should also include a test against a copy of production data: restore a recent backup into a non-production environment, start the target HAPI FHIR version there, and confirm that stored QuestionnaireResponses are still readable and searchable, and that new submissions validate as expected. Use the separate HAPI FHIR upgrade topic for version-by-version steps and the HAPI FHIR monitoring and operations topic for backup routines, reindexing and health checks that support this testing.
Limits to confirm in your environment before committing
Each item below is a claim a team often assumes and should test instead. They connect because a Questionnaire form only works end to end when the HAPI version, FHIR version, auth model, database and downstream consumers all agree.
Questionnaire operations in your HAPI version
Confirm which Questionnaire and QuestionnaireResponse operations, search parameters and validation behaviors the HAPI version you pick implements, including how it handles $questionnaire-populate-style requests and whether it validates answers against the Questionnaire on write. Check the release notes for the exact version rather than relying on general FHIR support. Run a short test with your own form definitions and malformed responses before you design around any behavior. Confirm this against the release notes for your chosen version, not against the server's general FHIR capability statement.
FHIR version required by partners
Confirm which FHIR release your clinical partners, payers and form vendors require, because Questionnaire and QuestionnaireResponse structures differ between releases. The JPA server documentation covers DSTU2, DSTU3, R4, R4B and R5, so a mismatch is possible if one partner expects R5 and another expects R4. Ask each partner for the exact release and any implementation guide they profile against. Record the answer in the form specification before any mapping work starts.
JPA server introductionFront end access under your auth model
Confirm that the form front end can create, read and update QuestionnaireResponse resources under the authentication model you chose. HAPI does not provide one complete security layer. It offers authentication interceptors, the AuthorizationInterceptor, CORS support and audit logging, so the form application must receive a token that the server accepts and the browser must pass CORS checks. Test a full cycle with a real user role, including denied writes to other patients' responses, before you commit to the design.
HAPI security docsForm size and response volume on your database
Confirm how large Questionnaires and high response volumes perform on the database you select. The starter defaults to an embedded H2 database and supports PostgreSQL and Microsoft SQL Server for production, and it does not support MySQL. Load a realistic number of nested items and responses into a staging database, then measure write latency, search latency and storage growth. Ask your DBA to review index and storage settings, since these results decide whether the database choice holds.
JPA starter repositoryDownstream measure and CDS consumers
Confirm whether any CQL library, measure or CDS Hooks service will read the stored responses, and whether those consumers are in scope now. If they are, the Questionnaire item linkIds, answer types and value sets must match what the logic expects, which is easy to break when forms change. Ask the team that owns each consumer to list the exact elements it reads and to sign off on any change to the form. Treat a form revision without that review as a breaking change for the consumer.
Retention and partition layout for responses
Confirm how long captured responses must be kept, who may read them and whether they must sit in a separate partition. HAPI JPA partitioning places resources in partitions that can support multitenancy, separate data sources or group data by region. Ask your privacy and records teams to define retention and access rules first, then confirm with the platform team that the chosen partition layout can enforce them. Changing partition design after data is loaded is costly, so settle it before the first production form goes live.
Partitioning docsHow DeployOpen scopes and delivers Questionnaire capture on HAPI FHIR
DeployOpen approaches Questionnaire capture on HAPI FHIR as a written scope before any build starts. We plan, implement, customize, integrate, harden, back up, document and support self-hosted open-source platforms inside your own cloud accounts, data centers or air-gapped networks, so the intake and assessment data stays where your compliance team can review it.
How we scope
- We agree the Questionnaire inventory, its response fields and who completes each form in writing before work starts.
- The written scope names the HAPI FHIR JPA server version, the database and the hosting model that the capture work depends on.
- Engagements are fixed-scope, with deliverables and timelines confirmed in writing, and ongoing support is available as a retainer.
How we build
- We configure Questionnaire and QuestionnaireResponse resources and the server settings that store and search captured data.
- We set authorization, audit logging and search narrowing around the server, since HAPI FHIR offers building blocks rather than one security layer.
- We test sample completed forms against the agreed field list and record each result before the build is accepted.
How we hand over
- We document the Questionnaire definitions, version history, deployment steps and the data model used for stored responses.
- We deliver a verification record showing which capture paths were tested, which were not, and what remains open.
- We walk your engineers through operating the server, including how to publish a changed Questionnaire without disrupting stored responses.
How we support
- Support covers upgrades, patching and reviews of Questionnaire changes, scoped as a retainer alongside your environment.
- We can rerun tests after HAPI FHIR upgrades, so you can confirm that capture still behaves as documented before you adopt a new version.
- Ask us to confirm which support hours, response expectations and upgrade windows apply before you sign the written scope.

