Skip to content

PharmAccess/fhir-diet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FHIR-Diet

What is it about?

FHIR-Diet is a HL7 FHIR de-identification tool written in python. The tool has been developed by Docunque for the HOSMARTAI open call.

logo_project

How does it work?

The tool accept a FHIR resource as input, and output a de-identified or pseudonymized resource as output. The resource is treated according to the rules written in a configuration file. In such file, the rules are expressed using a match-action principle. The matches are expressed using FHIR Path. The actions can be such redact, cryptohash or the other documented in this file.

architecture logo architecture

For instance, to implement "remove patient's name" it sufficies to create a configuration file like this:

general:
  appname: FHIR-DIET
rules:
  - match: Patient.name
    action: redact

Installing the system

Installing the system is straightforward. Clone this git repository and install the requirements.

git clone https://github.com/docunque/fhir-diet.git
pip install -r requirements.txt

Running the system

The service is provided either through a Command Line Interface (CLI) or through a web service. You can also choose to run the system using Docker.

Web service

To run the FHIR-Diet as web service:

cd app
uvicorn main:app --reload

then open the this link or that link to browse the API. It is now possible to send a resource to the service in a POST request body, through the /process endpoint. You can try it using the swagger API.

Docker

To run the web service as Docker:

docker build . -t fhir-diet
docker run -p 8000:80 fhir-diet

Command Line Interface

To run the FHIR-Diet as CLI you should run cli.py using this syntax:

Usage: cli.py [OPTIONS] RESOURCE_FILENAME [CONFIG_FILENAME]

For example:

python3 cli.py test/sample_fhir_data/simple_patient.json test/config/safe_harbor_redact.yaml

Unit Tests

You can run some test cases in this way:

cd app
python3 -m unittest test.test_deidentify
python3 -m unittest test.test_pseudonymize
python3 -m unittest test.test_processor

Supported actions

De-identification actions

Action Description
cryptohash Use a hash function on the element selected by the FHIR-path query. We implemented SHA3 256 as state of the art.
perturb Change a numerical value introducing a random positive or negative value. We implemented the method for integer, float and date, allowing to introduce a random number of days
redact Remove the element.
substitute Substitute the element with a fixed string, e.g., "ANON"

Pseudonymization actions

Action Description
encrypt Use encryption to encrypt a field identified with FHIR-Path. If the field is complex (e.g., a nested structure or a list), it is converted in JSON and then encrypted. By default we use RSA albeit the encryption scheme is configurable.
ttp_gen_list Generate a csv with a list of data to be pseudonymized.
ttp_pseudonymize Substitute a field with its pseudonym, read by the mapping file (specified in the params with the separator and the header_lines)

De-pseudonymization actions

Action Description
decrypt Decrypt a previously encrypted field.
ttp_depseudonymize Revert a pseudonymization using a mapping file to restore the real values of the field.

Other actions

Action Description
keep keep the element as is.

Acknoledgment

This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 101016834.

LOGO BLACK

© Copyright HL7® logo, FHIR® logo and the flaming fire are registered trademarks owned by Health Level Seven International

"FHIR® is the registered trademark of HL7 and is used with the permission of HL7. Use of the FHIR trademark does not constitute endorsement of this product by HL7"

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.3%
  • Dockerfile 0.7%