Amazon Comprehend Medical returns values labeled as [FILTERED]. I have a rails 5.2 app and have installed the aws-sdk
gem. I am now trying an API call through the rails console and get a return JSON. But most of the values get returned as [FILTERED]. Any idea what causes this?
I have scoured the AWS documentation but can't seem to find an answer to this.
class Comprehend
require 'aws-sdk-comprehendmedical'
client = Aws::ComprehendMedical::Client.new
resp = client.detect_entities({
text: "45 yr old male with chestpain and SOB BP 120/70", # required
})
puts(resp)
end
This is the result when running this as Comprehend.new in the console.
{
:entities=>[
{
:id=>"[FILTERED]",
:begin_offset=>0,
:end_offset=>2,
:score=>0.9994971752166748,
:text=>"[FILTERED]",
:category=>"PROTECTED_HEALTH_INFORMATION",
:type=>"[FILTERED]",
:traits=>[],
:attributes=>nil
},
{
:id=>"[FILTERED]",
:begin_offset=>20,
:end_offset=>29,
:score=>0.9164832830429077,
:text=>"[FILTERED]",
:category=>"MEDICAL_CONDITION",
:type=>"[FILTERED]",
:traits=>[],
:attributes=>nil
},
{
:id=>"[FILTERED]",
:begin_offset=>34,
:end_offset=>37,
:score=>0.8974254131317139,
:text=>"[FILTERED]",
:category=>"MEDICAL_CONDITION",
:type=>"[FILTERED]",
:traits=>[],
:attributes=>nil
},
{
:id=>"[FILTERED]",
:begin_offset=>38,
:end_offset=>40,
:score=>0.8211551904678345,
:text=>"[FILTERED]",
:category=>"TEST_TREATMENT_PROCEDURE",
:type=>"[FILTERED]",
:traits=>[],
:attributes=>[
{
:type=>"[FILTERED]",
:score=>0.9983691573143005,
:relationship_score=>1.0,
:id=>"[FILTERED]",
:begin_offset=>41,
:end_offset=>47,
:text=>"[FILTERED]",
:traits=>[]
}
]
}
],
:unmapped_attributes=>[],
:pagination_token=>nil
}
This is the intended behavior for sensitive information when printing to the rails console or when being used in logs.
The actual value is there and can be used programmatically, but the aws-sdk has an interesting feature called log filtering that they use to hide sensitive information in logs and the console. Rails has a similar feature you can use, below are links to the rails documentation as well as the code in the aws-sdk ruby gem for filtering sensitive information: