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.0.tar.gz (1.9 MB 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.0-py3-none-any.whl (2.0 MB view details)

Uploaded Python 3

File details

Details for the file streamlit_fhir_questionnaire-0.1.0.tar.gz.

File metadata

  • Download URL: streamlit_fhir_questionnaire-0.1.0.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • 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.0.tar.gz
Algorithm Hash digest
SHA256 23ca9745f7233062ca2cd1c447816acb8162041c18561c536a7b2887396bc43d
MD5 b9f0820c71b5e03533dda4440ed4b2c6
BLAKE2b-256 36ea4099f7268b3ce3ba4560de2d2cf39886b4e467e0ede0972c1c72364bdb9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamlit_fhir_questionnaire-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e010ea3087679410ea3d39453ac9917d13dcd94127198eb773b5b199eae5077
MD5 8c0ff70100ca2c14fbab3a1cd4492879
BLAKE2b-256 97e033a6b7afe2508a3d2ee343d3c6044a8b8cc8696031a491d9ba89312f121f

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