A library with helper functions for the Smart Hospital Information Platform (SHIP)
Project description
Shippy is a Python library designed to simplify interactions with the Smart Hospital Information Platform (SHIP), providing utilities for handling authentication, HTTP requests, and managing custom models. It includes a range of features such as token management, HTTP error handling, and FHIR client utilities.
Features
- Authentication Utilities: Functions for token management and authentication (
auth.py). - HTTP Client: HTTP utilities for common SHIP tasks (
http.py). - Custom Models: Use KITE inferencing
KITEModel(kite.py). - FHIR Client: Simplified interaction with FHIR servers (
fhirclient.py).
Installation
You can install shippy via pip:
pip install ume-shippy
Usage
Authentication
Manage tokens and cookies easily.
from aihttp.web import BaseRequest
from shippy.auth import get_ship_token
# Example: Extract token from request headers
token = get_ship_token(request)
print(token)
HTTP Utilities
Perform GET and POST requests with detailed error handling.
from shippy.auth import get_ship_token
from shippy.http import download_file
# download file from url to tmpdir
cookies = get_ship_token(request, as_cookie=True)
url = "http://example.com/file.zip"
with tempfile.TemporaryDirectory() as tmpdirname:
file_path = download_file(url, tmpdirname, cookies=cookies)
Custom Models
Work with predefined models such as KITEModel.
from shippy.kite import KITEModel
model = KITEModel()
system_prompts = ["Du bist ein hilfreicher Assistent, der präzise Antworten auf medizinische Fragen gibt."]
user_prompts = ["Ich habe Kopfschmerzen.", "Was könnten mögliche Ursachen sein?"]
response = model.generate_response(system_prompts, user_prompts)
print(response)
FHIR Client
Simplify interactions with FHIR servers.
from shippy.fhirclient import FHIRClient
# Initialize FHIR client
client = FHIRClient(fhir_server="http://example.fhir.server", auth_token="your_token")
resource = await client.resource("Patient", "123")
print(resource)
Modules
auth.py
get_host: Get the hostname from a URL.is_subdomain: Check if the given URL is a subdomain of one of our hosts.get_ship_token: Get the ship token from the request headers.get_ship_token_from_response: Get the ship token from the response Set-Cookie headers.may_forward_ship_token: Check if we are allowed to forward the ship token to the destination URL.
http.py
get_text_file: Asynchronously download a text file from a URL and return its content as a string.download_file: Asynchronously download a file from a URL and save it to the specified directory.
kite.py
KITEModel: A custom model for using KITE inferencing services.
fhirclient.py
FHIRClient: Simplifies FHIR server interactions.
Contributing
Contributions are welcome! Please submit issues or pull requests to the GitHub repository.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Authors
- Felix Nensa (felix.nensa@uk-essen.de)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ume_shippy-0.0.11.tar.gz.
File metadata
- Download URL: ume_shippy-0.0.11.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/24.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c2c4af9a77bc0244ef7e5d60d0c94e5533cd4c5b9c694f2c4a99f05c975966f
|
|
| MD5 |
300cfe8405dbe62f8a77998cae26a633
|
|
| BLAKE2b-256 |
dda0a294fc2c489b25847a37c34676645584e00855064e8ad9cebb4d4fa18a85
|
File details
Details for the file ume_shippy-0.0.11-py3-none-any.whl.
File metadata
- Download URL: ume_shippy-0.0.11-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/24.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b52fceee07917eeb3757b13b65d30568c1dc85ba39dcd04a5663ce58c7257d0d
|
|
| MD5 |
1b5a9db937302564c674556e1d6cff3f
|
|
| BLAKE2b-256 |
dcb3601b24045ea3acdba307b3ab15cbb73583bd09f19abff4491ddcd2570efb
|