Skip to main content

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 enableWhen logic
  • 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

  1. Clone the repository
  2. Install Python dependencies: poetry install
  3. Set up frontend:
    cd streamlit_fhir_questionnaire/frontend
    pnpm install
    

Running the Example

poetry run streamlit run streamlit_fhir_questionnaire/example.py

Development Mode

  1. Create a .npmrc file in the streamlit_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
    
  2. Start the frontend dev server:

    cd streamlit_fhir_questionnaire/frontend
    pnpm run dev
    
  3. In __init__.py, set _RELEASE = False to use the dev server

  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_fhir_questionnaire-0.1.1.tar.gz (239.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_fhir_questionnaire-0.1.1-py3-none-any.whl (300.7 kB view details)

Uploaded Python 3

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

Hashes for streamlit_fhir_questionnaire-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d8aac1be4143604612a44a252530fd17ac346b7cc0f96cce9693642ddda3ba96
MD5 4c8cb3e51145f1d2cfba1202a7adeefa
BLAKE2b-256 a3d39597295ae3a26fe6c07d102d8269c7803b78488f17153c8ff08482637c3b

See more details on using hashes here.

File details

Details for the file streamlit_fhir_questionnaire-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_fhir_questionnaire-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 44bc850d3ad207ecc0119e78fa9136c8924f172974cd344853ce894c91e0a0f0
MD5 0aa9210fda60eb7fb81d0a83a53fb101
BLAKE2b-256 9a499b2e4bb461ad4b64c321264b309f39ce63ddcb7781423437e31dc1fe31dd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page