A python microservice to deidentify fhir resources - made with CherryPy
GET /health— returns status 200 (healthy) or 503 (unhealthy).POST /deidentify/:id— The deidentifier Payload:
{
transaction_id: "The caller's transaction id",
fhir_source: "The source url for Patient/:id/$everything",
source_token: "The source bearer token",
fhir_target: "The target url - where the clone is to be sent",
target_token: "The target bearer token",
id: "The id of the patient to be cloned",
deid: true | false,
}
If deid is false then the clone is not modified during the operation. Otherwise the $everything Bundle is modified according to the instructions in the configuration
Deidentification is accomplished globally (i.e. on every resource) and on a per-resource basis using simple configuration.
Configuration recognizes the following actions:
- erase - completely remove a field from the input Bundle
- replace - replace a field with a literal value or values
- randomize - randomize the input value based upon parameters (e.g. replace the birthDate with a random date from -15 to +15 days of the original)
- merge - use list comprehension to selectively modify the input field
See config.yaml for examples
- Install build tools
pip install build- Build the wheel
python -m buildThe .whl file will be created in the dist/ directory.
- Install dependencies
pip install -r requirements.txt- Run the app
python py_de_id/pydeid.pyThe app will be available at http://127.0.0.1:5000/.
- GET /health
curl -i http://127.0.0.1:5000/health- POST /deidentify/123-xyz
curl -X POST http://127.0.0.1:5000/deidentify/123-zyz \
-H "Content-Type: application/json" \
-d '{"source_url":"http://consumer:8103/fhir/R4","source_token":"example-token","target_url":"http://customer:8103/fhir/R4","target_token":"example-token","patient_id":"123-xyz","deid":true}'
To run the tests, first ensure you have pytest installed:
pip install pytestThen run:
pytest