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

with MainzellisteClient(base_url='http://localhost:8081', api_key='e8KcR1vcOLOTY0lRC7RjnMbdr4ARYIGurhEUZSpbvqU=') 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.0.tar.gz (4.8 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.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mainzelliste_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2a8794b766541e9b65666885382036858ec0f59a710054a77accf7e975eb44b0
MD5 6dcec27771cc75c55ccee1a73d5729cc
BLAKE2b-256 c7239c398174a3495f181c0cf31175043bd3197298e045ad7bc6b0170f520d52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mainzelliste_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d45ae7c7f0984c3359d6a81e00394c703ab093352581f1fa21f6b3f700e3e304
MD5 694fd248b629d58bba85278d1bb0e2da
BLAKE2b-256 d3ab4dc5552df47b6a50be657395b2e8a87703027d4aa4bb50a69d52b3c3c408

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