/*!
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
*/
import React, {useState, useEffect} from 'react';
import { Grid, Row, Col, Table, Toggle, Stack, Panel, IconButton } from 'rsuite';
import FileDownloadIcon from '@rsuite/icons/FileDownload';
const { Column, HeaderCell, Cell } = Table;
const CompactHeaderCell = props => ;
const defaultColumns = [
{
key: 'entity',
label: 'Entity',
flexGrow: 3,
verticalAlign: 'middle'
},
{
key: 'entity_type',
label: 'Entity Type',
flexGrow: 1,
verticalAlign: 'middle'
},
{
key: 'score',
label: 'Confidence',
flexGrow: 1,
verticalAlign: 'middle'
}
];
const PhiDisplay = ({docUrl, phiData, mimeType, docName}) => {
const [columnKeys] = useState(defaultColumns.map(column => column.key));
const columns = defaultColumns.filter(column => columnKeys.some(key => key === column.key));
const [data, setdata] = useState(undefined)
const [docURL, setdocURL] = useState(undefined)
const [maskData, setmaskData] = useState(true);
useEffect(() => {
const entities = phiData["Entities"];
const dataset = [];
for(const entity of entities){
let ent = {};
ent["entity"] = entity["Text"];
ent["entity_type"] = entity["Type"];
ent["score"] = parseInt(entity["Score"].toPrecision(2) * 100,10)+"%";
dataset.push(ent)
}
setdata(dataset);
setdocURL(docUrl);
}, [phiData, docUrl])
const CompactCell = props => {
if(props.dataKey === 'entity'){
return
{
(maskData)?
"X".repeat(props.rowData.entity.length)
:{props.rowData.entity}
}
| ;
}
if(props.dataKey === 'entity_type'){
return
{props.rowData.entity_type}
| ;
}
if(props.dataKey === 'score'){
return
{props.rowData.score}
| ;
}
return | ;
}
return (
Displaying document: {docName}
{
(mimeType === "image/tiff")?
TIF file cannot be viewed in the browser. Please download to view.
}>Download file
:
}
{
(data)&&
Protected Health Information (PHI) de-identification standard
Section 164.514(a) of the HIPAA Privacy Rule provides the standard for de-identification of protected health information. Under this standard, health information is not individually identifiable if it does not identify an individual and if the covered entity has no reasonable basis to believe it can be used to identify an individual.
{
(maskData)? "Un-mask PHI":"Mask PHI"
}
{columns.map(column => {
const { key, label, ...rest } = column;
return (
{label}
);
})}
}
)
}
export default PhiDisplay