Skip to main content

A library with helper functions for the Smart Hospital Information Platform (SHIP)

Project description

Shippy

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

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

ume_shippy-0.0.9.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ume_shippy-0.0.9-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file ume_shippy-0.0.9.tar.gz.

File metadata

  • Download URL: ume_shippy-0.0.9.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for ume_shippy-0.0.9.tar.gz
Algorithm Hash digest
SHA256 ec811f367337d081cfffbeb3d5c00926ace8fd580905a6416c10be1efe83a17e
MD5 9e327737ffbfcbaa60b21163dee5a1ed
BLAKE2b-256 f885f18f4eefc864a01aa4ed8e4f9ed931f406c14fb204a787989fdc3c238e53

See more details on using hashes here.

File details

Details for the file ume_shippy-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: ume_shippy-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for ume_shippy-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 a062459892514e542b390d237fa8f9e4a4139edca010c48a9719b8bcc6b6f9a6
MD5 1340fff27d0bef647855f2613955e452
BLAKE2b-256 a00ab346594042b4b783822faea23e7910a418466433e2543825424a8d1ef133

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