<gh_stars>0
"""Set identifier/pseudonym pairs explicitly without having them generated by PIMS.
This is useful when migrating an existing database to use PIMS

To run this example, make sure you have a PIMS keyfile and have set the
environment variables
PIMS_CLIENT_USER
PIMS_CLIENT_PASSWORD
"""

from pimsclient.client import connect
from pimsclient.swagger import Key

# Create a project connected to a certain PIMS key file
project = connect("https://pims.radboudumc.nl/api", pims_key_file_id=224)


def create_key(pseudonym: str, identity: str, source: str = "PatientID"):
    return Key.init_from_strings(
        pseudonym=pseudonym, identity=identity, identity_source=source
    )


# I have some keys that I want to set
key1 = create_key(pseudonym="pseudo9", identity="value9")
key2 = create_key(pseudonym="pseudo10", identity="value10")
key3 = create_key(
    pseudonym="pseudo_acc123", identity="acc123", source="AccessionNumber"
)

keys = [key1, key2, key3]

project.set_keys(keys)

print(f"Done setting {len(keys)} keys")

"""Set identifier/pseudonym pairs explicitly without having them generated by PIMS.
This is useful when migrating an existing database to use PIMS

To run this example, make sure you have a PIMS keyfile and have set the
environment variables
PIMS_CLIENT_USER
PIMS_CLIENT_PASSWORD
"""

from pimsclient.client import connect
from pimsclient.swagger import Key

# Create a project connected to a certain PIMS key file
project = connect("https://pims.radboudumc.nl/api", pims_key_file_id=224)


def create_key(pseudonym: str, identity: str, source: str = "PatientID"):
    return Key.init_from_strings(
        pseudonym=pseudonym, identity=identity, identity_source=source
    )


# I have some keys that I want to set
key1 = create_key(pseudonym="pseudo9", identity="value9")
key2 = create_key(pseudonym="pseudo10", identity="value10")
key3 = create_key(
    pseudonym="pseudo_acc123", identity="acc123", source="AccessionNumber"
)

keys = [key1, key2, key3]

project.set_keys(keys)

print(f"Done setting {len(keys)} keys")
Set identifier/pseudonym pairs explicitly without having them generated by PIMS. This is useful when migrating an existing database to use PIMS  To run this example, make sure you have a PIMS keyfile and have set the environment variables PIMS_CLIENT_USER PIMS_CLIENT_PASSWORD # Create a project connected to a certain PIMS key file # I have some keys that I want to set