Streamlit component for rendering FHIR Questionnaires and capturing user responses as FHIR QuestionnaireResponses.
Project description
streamlit-fhir-questionnaire
A Streamlit component for rendering FHIR Questionnaires and capturing user responses as FHIR QuestionnaireResponse resources.
Features
- Render interactive FHIR Questionnaires in Streamlit apps
- Capture structured data as FHIR QuestionnaireResponse resources
- Support for various FHIR question types (string, text, decimal, date, coding, etc.)
- Conditional question display with
enableWhenlogic - Real-time streaming mode for progressive response updates
- Built with React and the Tiro Health report renderer
Installation
pip install streamlit-fhir-questionnaire
Quick Start
import streamlit as st
from streamlit_fhir_questionnaire import streamlit_fhir_questionnaire
# Define a FHIR Questionnaire
questionnaire = {
"resourceType": "Questionnaire",
"title": "Patient Information",
"item": [
{
"linkId": "1",
"text": "What is your name?",
"type": "string"
},
{
"linkId": "2",
"text": "What is your date of birth?",
"type": "date"
}
]
}
# Render the questionnaire and capture responses
response = streamlit_fhir_questionnaire(
questionnaire=questionnaire,
key="patient_info"
)
# Display the captured FHIR QuestionnaireResponse
if response:
st.write("FHIR QuestionnaireResponse:", response)
Parameters
- questionnaire (dict, required): A FHIR Questionnaire resource defining the questions
- initial_questionnaire_response (dict, optional): Pre-populate the form with an initial response
- questionnaire_response (dict, optional): Controlled component state for the current response
- key (str, optional): Unique identifier for this component instance
- streaming (bool, optional): Enable streaming mode for real-time updates
Development
Prerequisites
- Python ^3.11
- Node.js and pnpm
- Poetry for Python dependency management
Setup
- Clone the repository
- Install Python dependencies:
poetry install - Set up frontend:
cd streamlit_fhir_questionnaire/frontend pnpm install
Running the Example
poetry run streamlit run streamlit_fhir_questionnaire/example.py
Development Mode
-
Create a
.npmrcfile in thestreamlit_fhir_questionnaire/frontend/directory with your GitHub token://npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN @tiro-health:registry=https://npm.pkg.github.com/ node-linker=hoisted -
Start the frontend dev server:
cd streamlit_fhir_questionnaire/frontend pnpm run dev
-
In
__init__.py, set_RELEASE = Falseto use the dev server -
Run the Streamlit app:
poetry run streamlit run streamlit_fhir_questionnaire/example.py
Building for Production
cd streamlit_fhir_questionnaire/frontend
pnpm build
License
MIT License - Copyright (c) 2018-2021 Streamlit Inc.
Credits
Built by Tiro Health using the @tiro-health/report-renderer library.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streamlit_fhir_questionnaire-0.1.1.tar.gz.
File metadata
- Download URL: streamlit_fhir_questionnaire-0.1.1.tar.gz
- Upload date:
- Size: 239.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8aac1be4143604612a44a252530fd17ac346b7cc0f96cce9693642ddda3ba96
|
|
| MD5 |
4c8cb3e51145f1d2cfba1202a7adeefa
|
|
| BLAKE2b-256 |
a3d39597295ae3a26fe6c07d102d8269c7803b78488f17153c8ff08482637c3b
|
File details
Details for the file streamlit_fhir_questionnaire-0.1.1-py3-none-any.whl.
File metadata
- Download URL: streamlit_fhir_questionnaire-0.1.1-py3-none-any.whl
- Upload date:
- Size: 300.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44bc850d3ad207ecc0119e78fa9136c8924f172974cd344853ce894c91e0a0f0
|
|
| MD5 |
0aa9210fda60eb7fb81d0a83a53fb101
|
|
| BLAKE2b-256 |
9a499b2e4bb461ad4b64c321264b309f39ce63ddcb7781423437e31dc1fe31dd
|