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.2.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.2-py3-none-any.whl (2.0 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: streamlit_fhir_questionnaire-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 d43d2fc5f088c29fc7e15f14bcd4deb387e2ff12caaeb2acfdffe7f1a7a63058
MD5 42ae555d98badc130caa916cea6cc478
BLAKE2b-256 d06acefbb3d42bb8d52fd1f6419e71b0f210b827e47e1cbf0238306310a11d13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamlit_fhir_questionnaire-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 46d68f8c2463e3062ca3ce1a340277c75c88128c5240e8d9452a25bd44341239
MD5 411825baf2ec03258735394b9b1a7abf
BLAKE2b-256 6a2818c9d98fd239a67274a591b2af8c481205461a630da9d630389453ff4092

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