Skip to main content

Client for Mainzelliste, a pseudonymization service.

Project description

mainzelliste-client

Python client for the mainzelliste, a pseudonymization service

Installation

pip install mainzelliste-client

Usage

Basic Example

from mainzelliste_client import MainzellisteClient

example_key = 'e8KcR1vcOLOTY0lRC7RjnMbdr4ARYIGurhEUZSpbvqU='

with MainzellisteClient(base_url='http://localhost:8081', api_key=example_key) as client:
    new_patient_id = client.generate_patient_id('5Yp0E')

print(new_patient_id)  # PQRYHQG0

Setup a test Mainzelliste instance

  1. Go in the tests/docker/ directory
cd tests/docker/
  1. Run the docker compose
docker-compose up -d
  1. Mainzelliste should be at http://localhost:8081/

API Reference

MainzellisteClient

__init__(base_url, api_key, api_version="2.0")

Initialize the Mainzelliste client.

Parameters:

  • base_url (str): Base URL of the Mainzelliste service

  • api_key (str): API key for authentication

  • api_version (str, optional): API version to use (default: "2.0")

generate_patient_id(patient_id)

Generate a new pseudonymized patient ID using the Mainzelliste API. This is the main method for users to pseudonymize patient identifiers.

This method handles the complete workflow: creating a session, generating a token, and adding the patient to get a new pseudonymized ID.

Parameters:

  • patient_id (str): Original patient ID to be pseudonymized

Returns: String containing the new pseudonymized patient ID.

Example:

with MainzellisteClient(base_url='http://localhost:8081', api_key='your-api-key') as client:
    new_id = client.generate_patient_id('patient-123')
    print(f"Pseudonymized ID: {new_id}")

create_session()

Create a new session.

Returns: Dictionary containing session information with a uri field.

create_token(session_id, token_type, idtypes=None, fields=None, ids=None)

Create a token for a session.

Parameters:

  • session_id (str): The session ID

  • token_type (str): Type of token (e.g., "addPatient")

  • idtypes (list, optional): List of ID types to generate (default: ["pid"])

  • fields (dict, optional): Patient fields (default: {})

  • ids (dict, optional): Patient IDs (default: {})

Returns: Dictionary containing token information with a tokenId field.

add_patient(token_id, sureness=True)

Add a patient using a token.

Parameters:

  • token_id (str): The token ID for adding the patient

  • sureness (bool, optional): Whether the data is certain (default: True)

Returns: Dictionary containing patient information.

close()

Close the underlying session.

License

See LICENSE file for details.

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

mainzelliste_client-0.1.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

mainzelliste_client-0.1.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file mainzelliste_client-0.1.1.tar.gz.

File metadata

  • Download URL: mainzelliste_client-0.1.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.3

File hashes

Hashes for mainzelliste_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 814a9b1a04870457cfd85405b58bf1f5741dba4313d9426ed8c5d999c9b8756f
MD5 c571c71be6ece5ed2eff0f2037699a55
BLAKE2b-256 be619c5ae9f2a468da78d145a60f68cfe4b8c94dd1bb2436ffc5ca0aa9349bfa

See more details on using hashes here.

File details

Details for the file mainzelliste_client-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mainzelliste_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 916c4391637825396f547c9eacf0f096f4f567756af6e682cc201fd557489648
MD5 d94cdb00c57baef32343902fd7676b9b
BLAKE2b-256 8dbd372d759cbdde40cb5fdce4cbc3b181bd59383c827ded58454fc284b9851c

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