/*! Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: MIT-0 */ import React, {useState} from 'react'; import { useParams } from 'react-router-dom'; import PhiDisplay from './PhiDisplay'; import { useWorkflows } from 'src/hooks/useWorkflows'; import StorageService from 'src/services/storage_services'; import { Table, Stack, Panel, Placeholder, Divider, Message, Loader } from 'rsuite'; import RemindOutlineIcon from '@rsuite/icons/RemindOutline'; const { Column, HeaderCell, Cell } = Table; const CompactHeaderCell = props => ; const defaultColumns = [ { key: 'document', label: 'Redacted Documents', // width: 180, flexGrow: 2, verticalAlign: 'middle' } ]; const PhiTab = () => { const [columnKeys] = useState(defaultColumns.map(column => column.key)); const columns = defaultColumns.filter(column => columnKeys.some(key => key === column.key)); const {wfid} = useParams(); const { data, isError, isFetching } = useWorkflows("workflow-list-exact", wfid); const storage = new StorageService(); const [docUrl, setdocUrl] = useState(undefined); const [phiData, setphiData] = useState(undefined); const [docMime, setdocMime] = useState(undefined) const [phiLoading, setphiLoading] = useState(false); const [selectedDoc, setselectedDoc] = useState(undefined); const CompactCell = props =>{ const weight = (props.rowData.document === selectedDoc)? 'bold': undefined const bgColor = (props.rowData.document === selectedDoc)? '#E1F5FE':undefined; return {props.rowData.document} ; } if(!data['phi_data']['de_identify']){ return Not available}> De-identification is disabled for the documents in this analysis job } if(data['phi_data']['de_identify'] && data['phi_data']['de_identification_status'] === 'processing'){ return De-dentification in progress} vertical/> } if(data['phi_data']['de_identify'] && data['phi_data']['de_identification_status'] === 'failed'){ return

Failed to perform PHI de-identification

} const getPhiData = async(doc_url, phi_data_url, documentName) =>{ let documentUrl, responseJson, documentMime; setphiLoading(true); setselectedDoc(documentName); try { const docurl = await storage.genSignedURL(doc_url, false); const phiurl = await storage.genSignedURL(phi_data_url); documentUrl = docurl?.url || undefined; documentMime = docurl?.contentType || undefined; const phi_url = phiurl?.url || undefined; setdocUrl(documentUrl); setdocMime(documentMime); let response = await fetch(phi_url); responseJson = await response.json(); setphiData(responseJson); setphiLoading(false); } catch (error) { setphiLoading(false); throw error; } } return (
Summary} bordered style={{background: 'white', marginBottom: '10px'}}> }> {/*
Status: {data['phi_data']['status']}
*/}
Total files: {data['phi_data']['totalFiles']}
Files processed: {data['phi_data']['successfulFilesCount']}
Files Un-processed: {data['phi_data']['failedFilesCount']}
Original document retention: {(data['phi_data']['retain_orig_docs'])? "True":"False"}
{ (data)? getPhiData(obj['doc_path'], obj['phi_json'], obj['document'])} > {columns.map(column => { const { key, label, ...rest } = column; return ( {label} ); })}
: }
{ (docUrl && phiData && !phiLoading)? :(phiLoading)?
:<> }
) } export default PhiTab