Skip to content

About

Demo for using Philter with Amazon Transcribe for redacting transcriptions

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

Philter with Audio Transcriptions

The purpose of this repository is to demonstrate a proof-of-concept of how Philter can be used to redacted medical transcriptions generated by a transacription service (i.e. Amazon Transcribe).

Because available samples of medical transcriptions are limited, and because the actual transcription is not the primary focus here, we are using samples of text that has already been transcribed. However, in this repository we provide the plumbing (and architecture ideas) to produce the text transcripts from audio files.

The transcription in transcribe/job-output.json is invented for this demo, including the PII in it. It does not describe a real patient.

Potential AWS Architectures for Redacting Audio Transcriptions

Continuous Transcription Processing

For an environment where new audio narratives are continuously dropped into an S3 bucket and near real-time processing is required:

  1. Put audio narratives in an S3 bucket.
  2. Use a Lambda function to process the audio files and generate transcriptions (which are written back to S3).
  3. Use a Lambda function to process the transcriptions and send them to Philter. Do whatever is required with the redacted text.
[ User/System ]
       |
       v (Upload MP3)
+------------------+
|  S3: Input Bkt   |----(Event: ObjectCreated)----> [ Lambda A: Transcriber ]
+------------------+                                       |
                                                           | (Start Job)
                                                           v
                                                +-----------------------+
                                                |   Amazon Transcribe   |
                                                +-----------+-----------+
                                                            |
       (JSON Output) <--------------------------------------+
             |
             v
+------------------+
| S3: Raw JSON Bkt |----(Event: ObjectCreated)----> [ Lambda B: Redactor ]
+------------------+                                       |
                                                           | (Filter PII)
                                                           v
                                                +-----------------------+
                                                | S3: Final Redacted Bkt|
                                                +-----------------------+

Batch Transcription Processing

For an environment where transcriptions are received in bulk and processed in batches:

  1. Create an AWS Step Functions to process the transcriptions in batches.
  2. Use Amazon EventBridge to trigger the Step Functions when needed (weekly/monthly/etc.).
[ Scheduled Trigger ]
           |
           v
+-----------------------------+
|   Amazon EventBridge        |  <-- Runs once a month
|   (Cron: 0 0 1 * ? *)       |
+--------------+--------------+
               |
               v
+-----------------------------------------------------------+
|                  AWS STEP FUNCTIONS                       |
|  (Distributed Map / Orchestration)                        |
|                                                           |
|  1. List Objects in S3 Input Bucket                       |
|  2. For Each File Found:                                  |
|     +-----------------------------------------------+     |
|     |  [ Choice State ]                             |     |
|     |  Is file extension .mp3? ----(No)----> [Skip] |     |
|     |         |                                     |     |
|     |       (Yes)                                   |     |
|     |         v                                     |     |
|     |  [ Transcribe Task ]                          |     |
|     |  StartTranscriptionJob()                      |     |
|     +---------+-------------------------------------+     |
+---------------|-------------------------------------------+
                |
                v
+------------------------------+      +-------------------------+
|      AMAZON TRANSCRIBE       |      |    AMAZON S3 BUCKETS    |
|                              |      |                         |
|  - Processes MP3s in Batch   +----->| [ Output Bucket ]       |
|  - Manages internal queue    |      | (transcripts.json)      |
+------------------------------+      +-------------------------+

Running the Demo

This demo runs Philter 4.0. Clone this repository:

git clone https://github.com/philterd/philter-transcriptions.git
cd philter-transcriptions

Generate the encryption key and API key Philter needs into .env, which Docker Compose reads:

echo "PHILTER_ENCRYPTION_KEY=$(openssl rand -base64 32)" > .env
echo "PHILTER_BOOTSTRAP_API_KEY=sk_$(openssl rand -hex 16)" >> .env

Start Philter:

docker compose up

Now you can parse the text transcriptions by sending them to Philter. The script loads policies/example_policy.json into Philter the first time it runs:

./redact.sh

The response will look like the following (trimmed for readability):

{
  "filteredText": "I saw the {{{REDACTED-age}}} patient today for follow-up of his type 2 diabetes. His patient ID is {{{REDACTED-ssn}}}. Since his last visit we reduced his evening glargine from 40 units to 32 units after several low readings overnight, and he has stayed on metformin 1000 milligrams twice a day. His fasting glucose readings this week have been between 110 and 140, which is an improvement. He reports no dizziness or night sweats. His feet show no new sores, and sensation is intact. I spoke with his daughter {{{REDACTED-name}}} by phone, and she confirms he is taking his medications as prescribed. We will repeat his A1c in three months and continue the current plan.",
  "explanation": {
    "appliedSpans": [
      {
        "characterStart": 10,
        "characterEnd": 21,
        "filterType": "AGE",
        "confidence": 0.9,
        "text": "72 year old",
        "replacement": "{{{REDACTED-age}}}"
      },
      {
        "characterStart": 92,
        "characterEnd": 101,
        "filterType": "SSN",
        "confidence": 0.9,
        "text": "482019376",
        "replacement": "{{{REDACTED-ssn}}}"
      },
      {
        "characterStart": 495,
        "characterEnd": 500,
        "filterType": "PERSON",
        "confidence": 0.994440094664813,
        "text": "Maria",
        "replacement": "{{{REDACTED-name}}}"
      }
    ]
  },
  "tokens": 115
}

The patient ID is nine digits, so Philter's SSN filter matches it as well as the policy's patient-id pattern, and the SSN label wins. It is redacted either way. If the label matters, drop the ssn filter from the policy.

About

Demo for using Philter with Amazon Transcribe for redacting transcriptions

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages