-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add basic chart for vital signs observations #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
1c6e032
doc: Add PRD for vital signs chart with openEHR transparency
claude 9a3a19a
feat: Implement vital signs chart with openEHR transparency
claude fce9ddf
fix: Update pulse archetype CKM link to non-deprecated version
claude 78af59d
fix: Correct encounter archetype CKM link
claude c994dc5
feat: Require encounter_id when recording vital signs
claude 8e5db61
feat: Add openEHR template management infrastructure
claude 6ab2b5c
feat: Use IDCR Vital Signs template from Ripple-openEHR
claude a46b042
docs: Update PRD and ADR with actual template implementation
claude 0f05221
build: specify pnpm as the package manager in package.json
platzhersh 0cbc32c
docs: add prisma migrate deploy command to API development instructions
platzhersh 703c8e0
fix: Correct template upload Content-Type and Accept headers
claude 82a1e93
feat: Improve template registration logging
claude 1d3ec29
feat: add basic logging configuration
platzhersh 7bf194d
fix: Update vital signs EHRBase composition structure, archetype vers…
platzhersh f5798c2
chore: Implement vital signs date validation and update EHRBase templ…
platzhersh 4340783
fix: Add checks for `reading.id` before fetching compositions or swit…
platzhersh 58792a6
chore: Add dedicated EHRbase client methods for formatted composition…
platzhersh 378e145
refactor: Standardize datetime usage to be timezone-aware and add a c…
platzhersh deb0158
fix: Robustify vital signs input handling and openEHR metadata panel …
platzhersh 2465817
feat: Add error handling and retry for encounter loading in Record Vi…
platzhersh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| #!/usr/bin/env python3 | ||
| """Upload openEHR templates to EHRBase. | ||
|
|
||
| Usage: | ||
| python scripts/upload_templates.py [--check-only] | ||
|
|
||
| This script uploads all OPT templates from the templates/ directory to EHRBase. | ||
| Run this after starting EHRBase to ensure all required templates are available. | ||
| """ | ||
|
|
||
| import asyncio | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| import httpx | ||
|
|
||
| # Add parent directory to path for imports | ||
| sys.path.insert(0, str(Path(__file__).parent.parent)) | ||
|
|
||
| from src.config import settings | ||
|
|
||
|
|
||
| async def list_templates(client: httpx.AsyncClient) -> list[str]: | ||
| """List existing templates in EHRBase.""" | ||
| response = await client.get("/openehr/v1/definition/template/adl1.4") | ||
| if response.status_code == 200: | ||
| templates = response.json() | ||
| return [t.get("template_id", "") for t in templates] | ||
| return [] | ||
|
|
||
|
|
||
| async def upload_template(client: httpx.AsyncClient, template_path: Path) -> bool: | ||
| """Upload a single template to EHRBase.""" | ||
| template_content = template_path.read_text() | ||
| template_id = template_path.stem # filename without extension | ||
|
|
||
| print(f" Uploading {template_id}...") | ||
|
|
||
| response = await client.post( | ||
| "/openehr/v1/definition/template/adl1.4", | ||
| content=template_content, | ||
| headers={"Content-Type": "application/xml"}, | ||
| ) | ||
|
|
||
| if response.status_code in (200, 201, 204): | ||
| print(f" ✓ {template_id} uploaded successfully") | ||
| return True | ||
| elif response.status_code == 409: | ||
| print(f" ○ {template_id} already exists") | ||
| return True | ||
| else: | ||
| print(f" ✗ {template_id} failed: {response.status_code}") | ||
| try: | ||
| error_detail = response.json() | ||
| print(f" Error: {error_detail}") | ||
| except Exception: | ||
| print(f" Response: {response.text[:500]}") | ||
| return False | ||
|
|
||
|
|
||
| async def main(check_only: bool = False): | ||
| """Upload all templates to EHRBase.""" | ||
| templates_dir = Path(__file__).parent.parent / "templates" | ||
|
|
||
| if not templates_dir.exists(): | ||
| print(f"Templates directory not found: {templates_dir}") | ||
| sys.exit(1) | ||
|
|
||
| template_files = list(templates_dir.glob("*.opt")) | ||
| if not template_files: | ||
| print("No .opt template files found") | ||
| sys.exit(0) | ||
|
|
||
| print(f"Found {len(template_files)} template(s)") | ||
| print(f"EHRBase URL: {settings.ehrbase_url}") | ||
| print() | ||
|
|
||
| auth = None | ||
| if settings.ehrbase_user and settings.ehrbase_password: | ||
| auth = httpx.BasicAuth(settings.ehrbase_user, settings.ehrbase_password) | ||
|
|
||
| async with httpx.AsyncClient(base_url=settings.ehrbase_url, auth=auth) as client: | ||
| # Check EHRBase connectivity | ||
| try: | ||
| response = await client.get("/ehrbase/rest/status") | ||
| if response.status_code != 200: | ||
| print(f"EHRBase not ready: {response.status_code}") | ||
| sys.exit(1) | ||
| print("EHRBase is ready") | ||
| except httpx.ConnectError: | ||
| print("Cannot connect to EHRBase") | ||
| sys.exit(1) | ||
|
|
||
| # List existing templates | ||
| existing = await list_templates(client) | ||
| print(f"Existing templates: {len(existing)}") | ||
| for t in existing: | ||
| print(f" - {t}") | ||
| print() | ||
|
|
||
| if check_only: | ||
| print("Check only mode - not uploading") | ||
| return | ||
|
|
||
| # Upload templates | ||
| print("Uploading templates...") | ||
| success_count = 0 | ||
| for template_path in template_files: | ||
| if await upload_template(client, template_path): | ||
| success_count += 1 | ||
|
|
||
| print() | ||
| print(f"Uploaded {success_count}/{len(template_files)} templates") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| check_only = "--check-only" in sys.argv | ||
| asyncio.run(main(check_only)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.