Spaces:
Runtime error
Runtime error
Commit ·
910db18
1
Parent(s): 9b5fa7f
chore(docker): remove Dockerfile and related configurations
Browse filesfeat(app): update file type for download files in Gradio interface
feat(run_dev): modify command to run app with uv
feat(huggingface): add app_hf.py for Hugging Face Spaces deployment
docs(readme-hf): enhance documentation for Hugging Face integration
- .github/workflows/deploy-to-huggingface.yml +6 -6
- .github/workflows/github-pages.yml +0 -31
- .huggingface/README.md +61 -1
- Dockerfile +0 -15
- README-HF.md +7 -7
- README.md +40 -99
- app.py +1 -1
- app_hf.py +22 -0
- docs/index.html +0 -51
- pyproject.toml +21 -0
- run_dev.py +2 -2
- samples/sample_webtemplate.json +63 -0
- uv.lock +0 -0
.github/workflows/deploy-to-huggingface.yml
CHANGED
|
@@ -17,21 +17,21 @@ jobs:
|
|
| 17 |
- name: Push to Hugging Face Spaces
|
| 18 |
env:
|
| 19 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 20 |
-
|
| 21 |
-
SPACE_NAME: openEHR2FHIRquestionnaire
|
| 22 |
run: |
|
| 23 |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
| 24 |
git config --global user.name "GitHub Actions"
|
| 25 |
|
| 26 |
-
# Install Hugging Face CLI
|
| 27 |
-
pip install
|
|
|
|
| 28 |
|
| 29 |
# Login to Hugging Face
|
| 30 |
huggingface-cli login --token $HF_TOKEN
|
| 31 |
|
| 32 |
# Prepare the repository for pushing to HF Spaces
|
| 33 |
# If this is the first deployment, create the space
|
| 34 |
-
python -c "from huggingface_hub import HfApi; api = HfApi(); api.create_repo(repo_id='$
|
| 35 |
|
| 36 |
# Push to Hugging Face Spaces
|
| 37 |
-
git push https://oauth2:$HF_TOKEN@huggingface.co/spaces/$
|
|
|
|
| 17 |
- name: Push to Hugging Face Spaces
|
| 18 |
env:
|
| 19 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 20 |
+
SPACE_NAME: cistec/openEHR2FHIRquestionnaire
|
|
|
|
| 21 |
run: |
|
| 22 |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
| 23 |
git config --global user.name "GitHub Actions"
|
| 24 |
|
| 25 |
+
# Install uv and Hugging Face CLI
|
| 26 |
+
pip install uv
|
| 27 |
+
uv pip install huggingface_hub
|
| 28 |
|
| 29 |
# Login to Hugging Face
|
| 30 |
huggingface-cli login --token $HF_TOKEN
|
| 31 |
|
| 32 |
# Prepare the repository for pushing to HF Spaces
|
| 33 |
# If this is the first deployment, create the space
|
| 34 |
+
python -c "from huggingface_hub import HfApi; api = HfApi(); api.create_repo(repo_id='$SPACE_NAME', repo_type='space', space_sdk='gradio')" || echo "Space already exists"
|
| 35 |
|
| 36 |
# Push to Hugging Face Spaces
|
| 37 |
+
git push https://oauth2:$HF_TOKEN@huggingface.co/spaces/$SPACE_NAME main:main -f
|
.github/workflows/github-pages.yml
DELETED
|
@@ -1,31 +0,0 @@
|
|
| 1 |
-
name: Deploy to GitHub Pages
|
| 2 |
-
|
| 3 |
-
on:
|
| 4 |
-
push:
|
| 5 |
-
branches:
|
| 6 |
-
- main
|
| 7 |
-
workflow_dispatch:
|
| 8 |
-
|
| 9 |
-
permissions:
|
| 10 |
-
contents: read
|
| 11 |
-
pages: write
|
| 12 |
-
id-token: write
|
| 13 |
-
|
| 14 |
-
jobs:
|
| 15 |
-
deploy:
|
| 16 |
-
runs-on: ubuntu-latest
|
| 17 |
-
steps:
|
| 18 |
-
- name: Checkout
|
| 19 |
-
uses: actions/checkout@v3
|
| 20 |
-
|
| 21 |
-
- name: Setup Pages
|
| 22 |
-
uses: actions/configure-pages@v3
|
| 23 |
-
|
| 24 |
-
- name: Upload artifact
|
| 25 |
-
uses: actions/upload-pages-artifact@v2
|
| 26 |
-
with:
|
| 27 |
-
path: './docs'
|
| 28 |
-
|
| 29 |
-
- name: Deploy to GitHub Pages
|
| 30 |
-
id: deployment
|
| 31 |
-
uses: actions/deploy-pages@v2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.huggingface/README.md
CHANGED
|
@@ -1 +1,61 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: openEHR to FHIR Questionnaire Converter
|
| 3 |
+
emoji: 📋
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 3.35.2
|
| 8 |
+
app_file: app_hf.py
|
| 9 |
+
pinned: false
|
| 10 |
+
license: mit
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# openEHR to FHIR Questionnaire Converter
|
| 14 |
+
|
| 15 |
+
Convert openEHR web templates to FHIR Questionnaire resources with support for multiple languages and FHIR versions.
|
| 16 |
+
|
| 17 |
+
## Features
|
| 18 |
+
|
| 19 |
+
* Convert openEHR web templates to FHIR Questionnaires
|
| 20 |
+
* Support for multiple languages (en, de, fr, etc.)
|
| 21 |
+
* Support for both FHIR R4 and R5 versions
|
| 22 |
+
* Download converted FHIR Questionnaires as JSON files
|
| 23 |
+
* Sample template available for testing
|
| 24 |
+
|
| 25 |
+
## How to use
|
| 26 |
+
|
| 27 |
+
1. Upload your openEHR web template (JSON file)
|
| 28 |
+
2. Configure the conversion parameters:
|
| 29 |
+
- Languages (comma-separated)
|
| 30 |
+
- FHIR version (R4 or R5)
|
| 31 |
+
- Optional name and publisher attributes
|
| 32 |
+
- Text type handling
|
| 33 |
+
3. Click "Convert to FHIR"
|
| 34 |
+
4. View the resulting FHIR Questionnaire(s) and download them
|
| 35 |
+
|
| 36 |
+
If you don't have a template to test with, click "Load Sample" to use a demonstration template.
|
| 37 |
+
|
| 38 |
+
## Background
|
| 39 |
+
|
| 40 |
+
The openEHR framework is a comprehensive approach to electronic health records that emphasizes interoperability and semantic precision. FHIR (Fast Healthcare Interoperability Resources) is a modern standard for healthcare data exchange.
|
| 41 |
+
|
| 42 |
+
This tool bridges the gap between these standards by converting openEHR templates to FHIR Questionnaires, enabling organizations using openEHR to integrate with FHIR-based systems.
|
| 43 |
+
|
| 44 |
+
## Source code
|
| 45 |
+
|
| 46 |
+
The source code for this tool is available on GitHub: [cistec/openEHR2FHIRquestionnaire](https://github.com/cistec-com/openEHR2FHIRquestionnaire)
|
| 47 |
+
|
| 48 |
+
## Citation
|
| 49 |
+
|
| 50 |
+
```bibtex
|
| 51 |
+
@software{OpenEHR2FHIRQuestionnaire,
|
| 52 |
+
author = {Cistec AG},
|
| 53 |
+
title = {openEHR to FHIR Questionnaire Mapper},
|
| 54 |
+
year = {2025},
|
| 55 |
+
url = {https://github.com/cistec-com/openEHR2FHIRquestionnaire}
|
| 56 |
+
}
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
## License
|
| 60 |
+
|
| 61 |
+
This project is licensed under the MIT License and developed by [Cistec AG](https://cistec.com).
|
Dockerfile
DELETED
|
@@ -1,15 +0,0 @@
|
|
| 1 |
-
FROM python:3.10-slim
|
| 2 |
-
|
| 3 |
-
WORKDIR /app
|
| 4 |
-
|
| 5 |
-
# Install uv
|
| 6 |
-
RUN pip install --no-cache-dir uv
|
| 7 |
-
|
| 8 |
-
COPY requirements.txt .
|
| 9 |
-
RUN uv pip install --no-cache-dir -r requirements.txt
|
| 10 |
-
|
| 11 |
-
COPY . .
|
| 12 |
-
|
| 13 |
-
EXPOSE 7860
|
| 14 |
-
|
| 15 |
-
CMD ["python", "app.py"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README-HF.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
# openEHR to FHIR Questionnaire Converter
|
| 2 |
|
| 3 |
-
This tool allows you to convert openEHR web templates (JSON) to FHIR Questionnaire resources.
|
| 4 |
|
| 5 |
## Features
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
|
| 13 |
## How to use
|
| 14 |
|
|
@@ -31,7 +31,7 @@ This tool bridges the gap between these standards by converting openEHR template
|
|
| 31 |
|
| 32 |
## Source code
|
| 33 |
|
| 34 |
-
The source code for this tool is available on GitHub: [cistec/openEHR2FHIRquestionnaire](https://github.com/cistec/openEHR2FHIRquestionnaire)
|
| 35 |
|
| 36 |
## License
|
| 37 |
|
|
|
|
| 1 |
# openEHR to FHIR Questionnaire Converter
|
| 2 |
|
| 3 |
+
This tool allows you to convert openEHR web templates (JSON) to FHIR Questionnaire resources. This application uses uv for efficient Python package management.
|
| 4 |
|
| 5 |
## Features
|
| 6 |
|
| 7 |
+
* Convert openEHR web templates to FHIR Questionnaires
|
| 8 |
+
* Support for multiple languages (en, de, fr, etc.)
|
| 9 |
+
* Support for both FHIR R4 and R5 versions
|
| 10 |
+
* Download converted FHIR Questionnaires as JSON files
|
| 11 |
+
* Sample template available for testing
|
| 12 |
|
| 13 |
## How to use
|
| 14 |
|
|
|
|
| 31 |
|
| 32 |
## Source code
|
| 33 |
|
| 34 |
+
The source code for this tool is available on GitHub: [cistec/openEHR2FHIRquestionnaire](https://github.com/cistec-com/openEHR2FHIRquestionnaire)
|
| 35 |
|
| 36 |
## License
|
| 37 |
|
README.md
CHANGED
|
@@ -5,23 +5,26 @@ You can generate multiple language variants, in case the respective translation
|
|
| 5 |
|
| 6 |
## Table of Contents
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
- [Contribution](#contribution)
|
| 18 |
-
- [Citation](#citation)
|
| 19 |
|
| 20 |
## Requirements
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
## Usage
|
| 27 |
|
|
@@ -39,101 +42,33 @@ python webtemplate_to_fhir_questionnaire_json.py \
|
|
| 39 |
--text_types <from_annotations|...>
|
| 40 |
```
|
| 41 |
|
|
|
|
|
|
|
| 42 |
### Web Interface (Gradio)
|
| 43 |
|
| 44 |
We've added a web interface using Gradio. To run it locally:
|
| 45 |
|
| 46 |
-
1. Install
|
| 47 |
-
|
| 48 |
-
```bash
|
| 49 |
-
# Install uv if you don't have it
|
| 50 |
-
pip install uv
|
| 51 |
-
|
| 52 |
-
# Install dependencies
|
| 53 |
-
uv pip install -r requirements.txt
|
| 54 |
-
```
|
| 55 |
-
|
| 56 |
-
Alternatively, you can use pip:
|
| 57 |
-
|
| 58 |
-
```bash
|
| 59 |
-
pip install -r requirements.txt
|
| 60 |
-
```
|
| 61 |
|
| 62 |
-
|
| 63 |
|
| 64 |
-
|
| 65 |
-
python app.py
|
| 66 |
-
```
|
| 67 |
-
|
| 68 |
-
3. Open your browser at http://localhost:7860
|
| 69 |
-
|
| 70 |
-
You can also try the hosted version of this tool on Hugging Face Spaces: [openEHR2FHIR Questionnaire Converter](https://huggingface.co/spaces/cistec/openEHR2FHIRquestionnaire)
|
| 71 |
-
|
| 72 |
-
### Docker Container
|
| 73 |
-
|
| 74 |
-
You can also run the web interface using Docker:
|
| 75 |
|
| 76 |
```bash
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
# Run the container
|
| 81 |
-
docker run -p 7860:7860 openehr2fhir
|
| 82 |
```
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
## Local Development and Testing
|
| 87 |
-
|
| 88 |
-
For local development and testing, follow these steps:
|
| 89 |
-
|
| 90 |
-
1. Clone the repository:
|
| 91 |
-
|
| 92 |
-
```bash
|
| 93 |
-
git clone https://github.com/cistec/openEHR2FHIRquestionnaire.git
|
| 94 |
-
cd openEHR2FHIRquestionnaire
|
| 95 |
-
```
|
| 96 |
-
|
| 97 |
-
2. Create and activate a virtual environment (optional but recommended):
|
| 98 |
-
|
| 99 |
-
```bash
|
| 100 |
-
python -m venv .venv
|
| 101 |
-
# On Windows
|
| 102 |
-
.venv\Scripts\activate
|
| 103 |
-
# On macOS/Linux
|
| 104 |
-
source .venv/bin/activate
|
| 105 |
-
```
|
| 106 |
-
|
| 107 |
-
3. Install dependencies using uv:
|
| 108 |
-
|
| 109 |
-
```bash
|
| 110 |
-
pip install uv
|
| 111 |
-
uv pip install -r requirements.txt
|
| 112 |
-
```
|
| 113 |
-
|
| 114 |
-
4. Run the Gradio app with debug mode enabled:
|
| 115 |
-
|
| 116 |
-
```bash
|
| 117 |
-
python app.py
|
| 118 |
-
```
|
| 119 |
-
|
| 120 |
-
The app will automatically reload when you make changes to the code.
|
| 121 |
-
|
| 122 |
-
5. Test the command-line interface:
|
| 123 |
-
|
| 124 |
-
```bash
|
| 125 |
-
python webtemplate_to_fhir_questionnaire_json.py --input samples/sample_webtemplate.json
|
| 126 |
-
```
|
| 127 |
|
| 128 |
-
|
| 129 |
-
```bash
|
| 130 |
-
python webtemplate_to_fhir_questionnaire_json.py --input /path/to/your/webtemplate.json
|
| 131 |
-
```
|
| 132 |
|
| 133 |
### Examples
|
| 134 |
|
| 135 |
```bash
|
| 136 |
-
|
|
|
|
| 137 |
--input path_to_folder/web_template.json \
|
| 138 |
--output questionnaire \
|
| 139 |
--output_folder output_folder_path \
|
|
@@ -145,7 +80,13 @@ python ./webtemplate_to_fhir_questionnaire_json.py \
|
|
| 145 |
```
|
| 146 |
|
| 147 |
```bash
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
```
|
| 150 |
|
| 151 |
### Parameters
|
|
@@ -155,11 +96,11 @@ python ./webtemplate_to_fhir_questionnaire_json.py --input web_template.json
|
|
| 155 |
| --input | Path to the Web Template JSON file to be converted into a FHIR Questionnaire. | Yes | None | |
|
| 156 |
| --output | Base output file name for the generated FHIR Questionnaire. | No | Input file base name. | A timestamp (%Y%m%d\_%H%M) is prepended and the language code appended to the base name. |
|
| 157 |
| --output_folder | Path to the Web Template JSON file to be converted into a FHIR Questionnaire. | No | `.` (current folder) | |
|
| 158 |
-
| --languages | Comma-separated list of language codes (e.g., `en,de`).. | No | `en`
|
| 159 |
-
| --fhir_version | FHIR version to use (either `R4` or `R5`). | No | `R4`
|
| 160 |
| --name | The `name` attribute for the FHIR Questionnaire. | No | Web Template name (without spaces) | |
|
| 161 |
-
| --publisher | The `publisher` attribute for the FHIR Questionnaire. | No | `converter`
|
| 162 |
-
| --text_types | Distinction of `DV_TEXT` mapping to `text` and `string` FHIR types. | No | None | `from_annotations`: Annotated items in the Web Template with `key=text_type` and `value=<string \| text>` are converted to the respective FHIR item type. |
|
| 163 |
|
| 164 |
## License
|
| 165 |
|
|
|
|
| 5 |
|
| 6 |
## Table of Contents
|
| 7 |
|
| 8 |
+
* [Requirements](#requirements)
|
| 9 |
+
* [Usage](#usage)
|
| 10 |
+
+ [Command Line Interface](#command-line-interface)
|
| 11 |
+
+ [Web Interface (Gradio)](#web-interface-gradio)
|
| 12 |
+
* [Examples](#examples)
|
| 13 |
+
* [Parameters](#parameters)
|
| 14 |
+
* [License](#license)
|
| 15 |
+
* [Contribution](#contribution)
|
| 16 |
+
* [Citation](#citation)
|
|
|
|
|
|
|
| 17 |
|
| 18 |
## Requirements
|
| 19 |
|
| 20 |
+
### CLI Version (Core Script)
|
| 21 |
+
|
| 22 |
+
* Python 3.7+ (the core conversion script has no external dependencies)
|
| 23 |
+
|
| 24 |
+
### Web Interface (Gradio)
|
| 25 |
+
|
| 26 |
+
* Python 3.8+ (required by Gradio)
|
| 27 |
+
* Dependencies are managed through pyproject.toml
|
| 28 |
|
| 29 |
## Usage
|
| 30 |
|
|
|
|
| 42 |
--text_types <from_annotations|...>
|
| 43 |
```
|
| 44 |
|
| 45 |
+
Note: Since the CLI script has no external dependencies, it can be run directly with Python without requiring uv.
|
| 46 |
+
|
| 47 |
### Web Interface (Gradio)
|
| 48 |
|
| 49 |
We've added a web interface using Gradio. To run it locally:
|
| 50 |
|
| 51 |
+
1. Install uv if you don't have it:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
+
[UV Installation Guide](https://docs.astral.sh/uv/getting-started/installation/)
|
| 54 |
|
| 55 |
+
2. Create a virtual environment and run the app:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
```bash
|
| 58 |
+
uv venv --python 3.10
|
| 59 |
+
source .venv/bin/activate
|
| 60 |
+
uv run app.py
|
|
|
|
|
|
|
| 61 |
```
|
| 62 |
|
| 63 |
+
3. Open your browser at http://localhost:7860
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
You can also try the hosted version of this tool on Hugging Face Spaces: [openEHR2FHIR Questionnaire Converter](https://huggingface.co/spaces/cistec/openEHR2FHIRquestionnaire)
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
### Examples
|
| 68 |
|
| 69 |
```bash
|
| 70 |
+
# Full example with all parameters
|
| 71 |
+
python webtemplate_to_fhir_questionnaire_json.py \
|
| 72 |
--input path_to_folder/web_template.json \
|
| 73 |
--output questionnaire \
|
| 74 |
--output_folder output_folder_path \
|
|
|
|
| 80 |
```
|
| 81 |
|
| 82 |
```bash
|
| 83 |
+
# Simple example with just input file
|
| 84 |
+
python webtemplate_to_fhir_questionnaire_json.py --input web_template.json
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
```bash
|
| 88 |
+
# Test with sample web template included in the repository
|
| 89 |
+
python webtemplate_to_fhir_questionnaire_json.py --input samples/sample_webtemplate.json
|
| 90 |
```
|
| 91 |
|
| 92 |
### Parameters
|
|
|
|
| 96 |
| --input | Path to the Web Template JSON file to be converted into a FHIR Questionnaire. | Yes | None | |
|
| 97 |
| --output | Base output file name for the generated FHIR Questionnaire. | No | Input file base name. | A timestamp (%Y%m%d\_%H%M) is prepended and the language code appended to the base name. |
|
| 98 |
| --output_folder | Path to the Web Template JSON file to be converted into a FHIR Questionnaire. | No | `.` (current folder) | |
|
| 99 |
+
| --languages | Comma-separated list of language codes (e.g., `en,de` ).. | No | `en` | A separate questionnaire is generated for each language. |
|
| 100 |
+
| --fhir_version | FHIR version to use (either `R4` or `R5` ). | No | `R4` | |
|
| 101 |
| --name | The `name` attribute for the FHIR Questionnaire. | No | Web Template name (without spaces) | |
|
| 102 |
+
| --publisher | The `publisher` attribute for the FHIR Questionnaire. | No | `converter` | |
|
| 103 |
+
| --text_types | Distinction of `DV_TEXT` mapping to `text` and `string` FHIR types. | No | None | `from_annotations` : Annotated items in the Web Template with `key=text_type` and `value=<string \| text>` are converted to the respective FHIR item type. |
|
| 104 |
|
| 105 |
## License
|
| 106 |
|
app.py
CHANGED
|
@@ -107,7 +107,7 @@ def create_gradio_interface():
|
|
| 107 |
|
| 108 |
with gr.Column():
|
| 109 |
output = gr.Markdown(label="Conversion Result")
|
| 110 |
-
download_files = gr.File(label="Download FHIR Questionnaires", file_count="multiple", type="
|
| 111 |
|
| 112 |
convert_btn.click(
|
| 113 |
fn=convert_openehr_to_fhir,
|
|
|
|
| 107 |
|
| 108 |
with gr.Column():
|
| 109 |
output = gr.Markdown(label="Conversion Result")
|
| 110 |
+
download_files = gr.File(label="Download FHIR Questionnaires", file_count="multiple", type="filepath")
|
| 111 |
|
| 112 |
convert_btn.click(
|
| 113 |
fn=convert_openehr_to_fhir,
|
app_hf.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
|
| 4 |
+
# This is a special version of app.py for Hugging Face Spaces deployment
|
| 5 |
+
# It simplifies the launch configuration to work properly on Hugging Face
|
| 6 |
+
|
| 7 |
+
import os
|
| 8 |
+
from app import create_gradio_interface, ensure_sample_dir
|
| 9 |
+
|
| 10 |
+
if __name__ == "__main__":
|
| 11 |
+
# Create sample directory and file when app starts
|
| 12 |
+
ensure_sample_dir()
|
| 13 |
+
|
| 14 |
+
# Create and launch the Gradio interface
|
| 15 |
+
demo = create_gradio_interface()
|
| 16 |
+
|
| 17 |
+
# Launch with Hugging Face Spaces compatible settings
|
| 18 |
+
demo.launch(
|
| 19 |
+
server_name="0.0.0.0", # Listen on all network interfaces
|
| 20 |
+
share=False,
|
| 21 |
+
server_port=7860 # Default port used by Hugging Face Spaces
|
| 22 |
+
)
|
docs/index.html
DELETED
|
@@ -1,51 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8" />
|
| 5 |
-
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
| 6 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
-
<meta
|
| 8 |
-
http-equiv="refresh"
|
| 9 |
-
content="0; url=https://huggingface.co/spaces/cistec/openEHR2FHIRquestionnaire"
|
| 10 |
-
/>
|
| 11 |
-
<title>openEHR to FHIR Questionnaire Converter</title>
|
| 12 |
-
<style>
|
| 13 |
-
body {
|
| 14 |
-
font-family: Arial, sans-serif;
|
| 15 |
-
text-align: center;
|
| 16 |
-
padding: 50px;
|
| 17 |
-
max-width: 800px;
|
| 18 |
-
margin: 0 auto;
|
| 19 |
-
}
|
| 20 |
-
h1 {
|
| 21 |
-
color: #2c3e50;
|
| 22 |
-
}
|
| 23 |
-
p {
|
| 24 |
-
font-size: 18px;
|
| 25 |
-
line-height: 1.5;
|
| 26 |
-
margin-bottom: 20px;
|
| 27 |
-
}
|
| 28 |
-
a {
|
| 29 |
-
display: inline-block;
|
| 30 |
-
background-color: #3498db;
|
| 31 |
-
color: white;
|
| 32 |
-
padding: 10px 20px;
|
| 33 |
-
text-decoration: none;
|
| 34 |
-
border-radius: 5px;
|
| 35 |
-
font-weight: bold;
|
| 36 |
-
margin-top: 20px;
|
| 37 |
-
}
|
| 38 |
-
a:hover {
|
| 39 |
-
background-color: #2980b9;
|
| 40 |
-
}
|
| 41 |
-
</style>
|
| 42 |
-
</head>
|
| 43 |
-
<body>
|
| 44 |
-
<h1>openEHR to FHIR Questionnaire Converter</h1>
|
| 45 |
-
<p>Redirecting to the Hugging Face Spaces app...</p>
|
| 46 |
-
<p>If you are not redirected automatically, click the button below:</p>
|
| 47 |
-
<a href="https://huggingface.co/spaces/cistec/openEHR2FHIRquestionnaire"
|
| 48 |
-
>Go to the App</a
|
| 49 |
-
>
|
| 50 |
-
</body>
|
| 51 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pyproject.toml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "openEHR2FHIRquestionnaire"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
description = "Converts openEHR web templates to FHIR Questionnaire resources"
|
| 5 |
+
readme = "README.md"
|
| 6 |
+
requires-python = ">=3.8"
|
| 7 |
+
license = {file = "LICENSE"}
|
| 8 |
+
authors = [
|
| 9 |
+
{name = "Cistec AG"}
|
| 10 |
+
]
|
| 11 |
+
dependencies = [
|
| 12 |
+
"gradio>=3.35.2",
|
| 13 |
+
"python-dateutil>=2.8.2"
|
| 14 |
+
]
|
| 15 |
+
|
| 16 |
+
[project.urls]
|
| 17 |
+
Homepage = "https://github.com/cistec-com/openEHR2FHIRquestionnaire"
|
| 18 |
+
"Bug Tracker" = "https://github.com/cistec-com/openEHR2FHIRquestionnaire/issues"
|
| 19 |
+
|
| 20 |
+
[tool.uv]
|
| 21 |
+
# UV-specific configuration can be added here if needed
|
run_dev.py
CHANGED
|
@@ -14,9 +14,9 @@ if __name__ == "__main__":
|
|
| 14 |
# Ensure the current directory is in the Python path
|
| 15 |
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 16 |
|
| 17 |
-
# Run the app with debug mode enabled
|
| 18 |
subprocess.run([
|
| 19 |
-
|
| 20 |
"app.py",
|
| 21 |
"--debug",
|
| 22 |
"--port", "7860"
|
|
|
|
| 14 |
# Ensure the current directory is in the Python path
|
| 15 |
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 16 |
|
| 17 |
+
# Run the app with debug mode enabled using uv
|
| 18 |
subprocess.run([
|
| 19 |
+
"uv", "run",
|
| 20 |
"app.py",
|
| 21 |
"--debug",
|
| 22 |
"--port", "7860"
|
samples/sample_webtemplate.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"templateId": "sample_template",
|
| 3 |
+
"tree": {
|
| 4 |
+
"id": "sample_root",
|
| 5 |
+
"name": "Sample Web Template",
|
| 6 |
+
"localizedNames": {
|
| 7 |
+
"en": "Sample Web Template",
|
| 8 |
+
"de": "Beispiel Web-Vorlage"
|
| 9 |
+
},
|
| 10 |
+
"localizedDescriptions": {
|
| 11 |
+
"en": "This is a sample web template for demonstration purposes",
|
| 12 |
+
"de": "Dies ist eine Beispiel-Web-Vorlage zu Demonstrationszwecken"
|
| 13 |
+
},
|
| 14 |
+
"nodeId": "sample_node_id",
|
| 15 |
+
"children": [
|
| 16 |
+
{
|
| 17 |
+
"id": "sample_section",
|
| 18 |
+
"name": "Sample Section",
|
| 19 |
+
"localizedNames": {
|
| 20 |
+
"en": "Sample Section",
|
| 21 |
+
"de": "Beispielabschnitt"
|
| 22 |
+
},
|
| 23 |
+
"rmType": "SECTION",
|
| 24 |
+
"nodeId": "sample_section_id",
|
| 25 |
+
"aqlPath": "/content[openEHR-EHR-SECTION.sample_section.v1]",
|
| 26 |
+
"children": [
|
| 27 |
+
{
|
| 28 |
+
"id": "sample_element",
|
| 29 |
+
"name": "Sample Element",
|
| 30 |
+
"localizedNames": {
|
| 31 |
+
"en": "Sample Element",
|
| 32 |
+
"de": "Beispielelement"
|
| 33 |
+
},
|
| 34 |
+
"rmType": "DV_CODED_TEXT",
|
| 35 |
+
"nodeId": "sample_element_id",
|
| 36 |
+
"aqlPath": "/content[openEHR-EHR-SECTION.sample_section.v1]/items[openEHR-EHR-ELEMENT.sample_element.v1]/value",
|
| 37 |
+
"inputs": [
|
| 38 |
+
{
|
| 39 |
+
"type": "CODED_TEXT",
|
| 40 |
+
"list": [
|
| 41 |
+
{
|
| 42 |
+
"value": "option1",
|
| 43 |
+
"label": {
|
| 44 |
+
"en": "Option 1",
|
| 45 |
+
"de": "Option 1"
|
| 46 |
+
}
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"value": "option2",
|
| 50 |
+
"label": {
|
| 51 |
+
"en": "Option 2",
|
| 52 |
+
"de": "Option 2"
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
]
|
| 56 |
+
}
|
| 57 |
+
]
|
| 58 |
+
}
|
| 59 |
+
]
|
| 60 |
+
}
|
| 61 |
+
]
|
| 62 |
+
}
|
| 63 |
+
}
|
uv.lock
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|