Skip to content

About

HTTP-based service for resolving entity pseudonyms leveraging Master Patient Indices in a privacy-preserving record linkage context.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

GitHub Release Code Coverage License Conventional Commits

FABLE Resolver

The FABLE Resolver is responsible for resolving given pseudonyms to their related personal data by leveraging a Master Patient Index (MPI) service. It is therefore the central service that must be operational at each site wishing to participate in the Privacy-preserving Record Linkage (PPRL) protocol. It encodes personal data into Bloom filters and sends these filters to the FABLE Broker, where matching is executed. Finally, it retrieves matches found for filters submitted by this site from the Broker service. The service itself is powered by FastAPI.

The Resolver's core idea is to be compatible with various MPI services. To this end, it implements a well-defined interface that needs to be adapted to a specific MPI service. As a proof concept, this interface has been implemented for the E-PIX MPI service and the gPAS pseudonymization service from the MOSAIC project by THS Greifswald.

In addition to the service(s) that provide the personal data, the Resolver also requires the following services to be available.

  • FABLE PPRL service which is responsible for performing the transformation and masking of personal data.
  • Redis as a database backend to share state between worker processes.

Deployment

In order to operate the Resolver service, a running instance of the Broker service and an MPI through which pseudonyms are resolvable to real patient data are needed. local-docker-compose.yml provides such a deployment with E-PIX and gPAS to resolve pseudonyms. Therefore, clone the repository first, enter the fable-resolver directory, and start all services with Docker. Technically, you don't need to clone the whole repository. It is only important that the SQL scripts in tests/docker are available, since they are needed for E-PIX's MariaDB container and gPAS's Postgres container.

git clone https://github.com/ul-mds/fable-resolver.git
cd fable-resolver
docker compose -f local-docker-compose.yml up -d

The API of the Resolver service is reachable via http://localhost:8080. See the Configuration section for more details on all available options.

Tip

Note that this deployment is intended for experimentation and playing around only. All services are started with only one worker process to keep the hardware requirements as slim as possible. Moreover, the Broker is usually not meant to be operated alongside a Resolver.

docker-compose-template.yml offers a deployment template which is independent of the Broker, the person-related data and pseudonym providing service(s) deployments. This template is intended as a guideline for use in production setting.

Using the API

The examples provided in this section use the local-docker-compose.yml deployment.

Getting available (metadata) attributes

The idea behind the FABLE Resolver is to support various data providing services. Person data is saved in different schemas based on the connected data provider, so different data providers do not necessarily have to offer the same set of attributes or follow the same naming convention. We divide the offered attributes into two categories: attributes and metadata attributes.

Attributes are the ones that are encoded into Bloom filters, which are then shared with the Broker service. However, they are treated confidentially, since they contain sensitive information about a real-world individual. Metadata attributes, on the other hand, contain information about the internal data model of a person, such as when it was created or last edited. The values of metadata attributes can be reported by the Resolver as plaintext in the metadata section as part of a resolved pseudonym. Information from metadata attributes can be utilized to manually unwind potential transitive inconsistencies that arise when merging results from different Resolver services.

The endpoint /data-source/attributes offers a list of all available attributes.

from fastapi import status
import httpx2
import json


r = httpx2.get("http://localhost:8080/data-source/attributes")

assert r.status_code == status.HTTP_200_OK

print(json.dumps(r.json(), indent=2))
[
  "birth_date",
  "birth_place",
  "civil_status",
  ...
]

The endpoint /data-source/metadata-attributes offers a list of all available metadata attributes.

from fastapi import status
import httpx2
import json


r = httpx2.get("http://localhost:8080/data-source/metadata-attributes")

assert r.status_code == status.HTTP_200_OK

print(json.dumps(r.json(), indent=2))
[
  "person_created",
  "person_last_edited"
]

Registering for a matching session

To register a Resolver as a client, a matching session must first be created at the Broker. In this example, a session with the ID my-session-id has already been created at the Broker. Furthermore, an E-PIX and a gPAS domain named my-domain were created in order to resolve pseudonyms. In addition, a transformation and a masking configuration must be defined for registration. These configurations are stored locally for the specific matching session and are reused to maintain consistent transformation and masking, since pseudonyms can be submitted in batches over multiple requests. The registration endpoint is available on /resolve/register.

Warning

Although different transformation configurations may be required at different sites, the masking configuration should be identical for all participating sites. The software will not verify this, since the masking configuration is treated as secret information and will not leave a Resolver service's site. Therefore, it is the responsibility of the analyst to ensure that the same masking configuration is used across all participating Resolver services.

Metadata attributes can be defined optionally.

Tip

Locally stored configurations are deleted as soon as the matching session is expired or deleted at the Broker.

import httpx2
from fable_model import *
from fastapi import status


r = httpx2.post(
    "http://localhost:8080/resolve/register",
    json=ClientCreationRequest(
        session="my-session-id",
        data_source_domain="my-domain",
        transformation=BaseTransformRequest(
            config=TransformConfig(
                empty_value=EmptyValueHandling.skip,
            ),
            global_transformers=GlobalTransformerConfig(
                after=[NormalizationTransformer()],
            ),
        ),
        masking=BaseMaskRequest(
            config=MaskConfig(
                token_size=2,
                filter=CLKFilter(
                    hash_values=5,
                    filter_size=1_000,
                ),
                hash=HashConfig(
                    function=HashFunction(
                        algorithms=[HashAlgorithm.sha1],
                    ),
                    strategy=DoubleHash(),
                ),
            ),
            attributes=[
                StaticAttributeConfig(attribute_name="first_name"),
                StaticAttributeConfig(attribute_name="last_name"),
                StaticAttributeConfig(attribute_name="birth_date"),
            ],
        ),
        metadata_attributes=[
            MetadataAttribute(name="last_edited", attribute="person_last_edited"),
        ],
    ).model_dump(),
)

assert r.status_code == status.HTTP_201_CREATED

Submitting pseudonyms

Once a Resolver has been registered for a matching session, pseudonyms can be submitted to it via the /resolve endpoint. In this example, a person was created in the E-PIX domain, and the related MPI was given the pseudonym 451141768 inside the gPAS domain. When a pseudonym is submitted, it is resolved and the values of the specified attributes are retrieved. These values are then transformed and masked via the PPRL service, after which the resulting Bloom filters are sent to the matching session at the Broker. If other clients have already sent Bloom filters to this session, the Broker automatically starts the matching process for the currently available filters. Any filters submitted later on are matched against all the other filters from the other clients in a new task.

Tip

The matching can be inherently performed in batched tasks (unless you are the client that submits its filters first) by submitting pseudonyms in multiple requests.

import httpx2
from fable_model import *
from fastapi import status


r = httpx2.put(
    "http://localhost:8080/resolve",
    json=PseudonymsSubmissionRequest(
        session="my-session-id",
        pseudonyms=["451141768"],
    ).model_dump(),
)

assert r.status_code == status.HTTP_202_ACCEPTED

Retrieving results

Results can be retrieved via the /resolve endpoint. For this, a session ID is required. The flag show_unfinished_results, which defaults to False, can be set optionally. If this flag is set to False and the matching process is not yet completed (or there are no new pseudonyms to match at this moment), the service will return an empty list of matches, even if it already found some. In the following example, a second Resolver service is started and accessible at http://localhost:8085. This Resolver is also registered for the matching session my-session-id and another pseudonym 403829738 is submitted for this client.

Tip

If you want to locally run a second instance of the Resolver service, either change REDIS__KEY_PREFIX to a non-default string or connect it to another Redis database or instance.

The example shows that found matches are reported alongside their internal ID, Bloom filter, specified metadata, similarities, aggregated similarity and the reference metadata, which is the metadata of the matching vector from another client. The pseudonym is added to the metadata automatically. Note that last_edited is also part of the metadata, as this was configured during registration.

import httpx2
from fable_model import *
from fastapi import status


r = httpx2.post(
    "http://localhost:8080/resolve",
    json=ResultsFetchingRequest(
        session="my-session-id",
        show_unfinished_results=False,
    ).model_dump(),
)

assert r.status_code == status.HTTP_200_OK

model = PseudonymMatchResponse(**r.json())
print(model.model_dump_json(indent=2))
{
  "finished": true,
  "matches": [
    {
      "vector": {
        "id": "JN10RxbHnNwiUDFxHfyXm8avKhxXZPen4bdxZyhTRi4",
        "value": "YQAAglABCAIAAAkkAAhAAAAIBAEQBBJkAgAAABCAAAAgQGMCAAIEIEAQAEQEICAAEAEAmIwAAAAwEAAEUIhAAACQBAEQYUIAAAABAaEAAAQIECBoEgCQAEAIIgAAIQABACEABAABBAIQAIABgIAgAQAEGEMKDAEQAACAACA=",
        "metadata": [
          {
            "name": "last_edited",
            "value": "2026-12-03T12:13:02+01:00"
          },
          {
            "name": "pseudonym",
            "value": "451141768"
          }
        ]
      },
      "similarities": [
        0.8473282442748091,
        0.9173553719008265
      ],
      "aggregated_similarity": 0.8823418080878178,
      "reference_metadata": [
        {
          "name": "last_edited",
          "value": "2026-12-03T14:42:33+01:00"
        },
        {
          "name": "pseudonym",
          "value": "403829738"
        }
      ]
    }
  ]
}

It is also possible to retrieve the result from the perspective of a different Resolver service. Note that the internal ID and the Bloom filter differ compared to the previous response. Additionally, the metadata and reference metadata are switched.

import httpx2
from fable_model import *
from fastapi import status


r = httpx2.post(
    "http://localhost:8085/resolve",
    json=ResultsFetchingRequest(
        session="my-session-id",
        show_unfinished_results=False,
    ).model_dump(),
)

assert r.status_code == status.HTTP_200_OK

model = PseudonymMatchResponse(**r.json())
print(model.model_dump_json(indent=2))
{
  "finished": true,
  "matches": [
    {
      "vector": {
        "id": "RJgh0dtetcfgQJtJqXRkb9Cwb_jBxg0WygeQJCd5rs8",
        "value": "YQAAglABCAIAAAgkAAhAAAQIBAAQBBZEAgAAABCAAAAgQGMKAAIEIEAQAEQEICAAEAEAmIgAAAAgEAAEAIgAAACQBAEQY0MAAAABAaEBAAQIECBoEgCQAEAIIgAAIUABACEABAAAAAIAAKABgIAgAQAEGEMKDAAQAACAACA=",
        "metadata": [
          {
            "name": "last_edited",
            "value": "2026-12-03T14:42:33+01:00"
          },
          {
            "name": "pseudonym",
            "value": "403829738"
          }
        ]
      },
      "similarities": [
        0.8473282442748091,
        0.9173553719008265
      ],
      "aggregated_similarity": 0.8823418080878178,
      "reference_metadata": [
        {
          "name": "last_edited",
          "value": "2026-12-03T12:13:02+01:00"
        },
        {
          "name": "pseudonym",
          "value": "451141768"
        }
      ]
    }
  ]
}

Configuration

The following table shows all available configuration options. These variables can either be defined in an .env file or in the environment section of the Resolver container defined inside a Docker Compose file.

Environment variable Description Default
PPRL_SERVICE_BASE_URL Base URL for the PPRL service to be able to perform transformations and masking. http://localhost:8080
BROKER_SERVICE_BASE_URL Base URL for the Broker service to manage and perform matching tasks. http://localhost:8081
REDIS__URL URL pointing to Redis for persisting the service's state. redis://localhost:6379/0
REDIS__KEY_PREFIX String that is used as a prefix for all keys that the service creates. fable-resolver
REDIS__MAX_CONNECTIONS_PER_WORKER Limit of the connection pool per worker process. 50
REDIS__CLEANUP_INTERVAL Interval in seconds of the cleanup routine. A key gets deleted if the corresponding session is expired at the Broker and therefore no longer exists. 300
EXPOSE_DOCS If set to true, all FastAPI documentation endpoints are exposed.1) 1
DATA_PROVIDER__SOURCE Identifier for the adapter that connects to the data providing source. -2)
DATA_PROVIDER__EPIX_WSDL_URL3) WSDL URL for the E-PIX service. http://localhost:8082/epix/epixService?wsdl
DATA_PROVIDER__EPIX_MANAGEMENT_WSDL_URL3) WSDL URL for the E-PIX management service. http://localhost:8082/epix/epixManagementService?wsdl
DATA_PROVIDER__GPAS_WSDL_URL3) WSDL URL for the gPAS service. http://localhost:8083/gpas/gpasService?wsdl
DATA_PROVIDER__GPAS_DOMAIN_WSDL_URL3) WSDL URL for the gPAS domain service. http://localhost:8083/gpas/DomainService?wsdl

1) The documentation endpoints are /openapi.json, /docs and /redoc.
2) Depends on the image and therefore has not to be set explicitly.
3) Only relevant if DATA_PROVIDER__SOURCE=mosaic.

Development and running tests

Tests are implemented with pytest. Set up tests by copying .env.example into a new file called .env.test and spin up all necessary containers. Pre-existing environment variables take precedence and will not be overwritten by the contents of .env.test.

cp .env.example .env.test
docker compose -f test/docker-compose.yml up -d

You can execute tests by running pytest tests. Tests will automatically spin up the web API. It is also possible to let pytest spin up all necessary containers automatically using testcontainers.

Tip

Tests will notably take longer when testcontainers are activated since containers will be started and stopped per run.

The following environment variables can be used to configure the setup for running tests.

Environment variable Description Default
PYTEST_USE_TESTCONTAINERS Pytest will use testcontainers, if set to true. 0
PYTEST_PPRL_SERVICE_VERSION1) Tag of the FABLE PPRL service image that will run inside the testcontainer. latest
PYTEST_BROKER_SERVICE_VERSION1) Tag of the FABLE Broker service image that will run inside the testcontainer. latest

1) Only relevant if PYTEST_USE_TESTCONTAINERS=1.

It is also possible to spin up the API via fable-resolver.

License

The FABLE Resolver service is released under the MIT license.

About

HTTP-based service for resolving entity pseudonyms leveraging Master Patient Indices in a privacy-preserving record linkage context.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages