import * as React from 'react'; import { fromPairs } from 'lodash'; import { OverlayTrigger, Popover } from 'react-bootstrap'; import ClinicalInformationPatientTable from '../clinicalInformation/ClinicalInformationPatientTable'; import { getSpanElements } from '../clinicalInformation/lib/clinicalAttributesUtil.js'; import { DefaultTooltip, placeArrowBottomLeft, } from 'cbioportal-frontend-commons'; import SampleManager from '../SampleManager'; export type IPatientHeaderProps = { patient: any; studyId: string; sampleManager?: SampleManager | null; handlePatientClick: any; darwinUrl?: string; }; export default class PatientHeader extends React.Component< IPatientHeaderProps, {} > { public render() { return (
{this.props.patient && this.getOverlayTriggerPatient( this.props.patient, this.props.studyId, this.props.sampleManager )} {this.getDarwinUrl(this.props.darwinUrl)}
); } private getDarwinUrl(darwinUrl: string | null | undefined) { // use JSP injected Darwin URL window.frontendConfig.darwinAccessUrl // TODO: use internal API service instead, once this exists if (darwinUrl !== undefined && darwinUrl !== null && darwinUrl !== '') { // add link to darwin let darwinImgSrc = require('./images/darwin_logo.png'); return ( ); } else { return null; } } private getPopoverPatient(patient: any) { return ( patient && (
{patient.id}
) ); } private getOverlayTriggerPatient( patient: any, studyId: string, sampleManager?: SampleManager | null ) { const clinicalDataLegacy = fromPairs( patient.clinicalData.map((x: any) => [ x.clinicalAttributeId, x.value, ]) ); // get common clinical attributes in all samples if (sampleManager) { Object.keys( sampleManager.commonClinicalDataLegacyCleanAndDerived ).forEach((attr: string) => { clinicalDataLegacy[attr] = sampleManager.commonClinicalDataLegacyCleanAndDerived[attr]; }); } return ( patient && ( } destroyTooltipOnHide={true} onPopupAlign={placeArrowBottomLeft} > this.props.handlePatientClick(patient.id) } > {patient.id} {getSpanElements(clinicalDataLegacy)} ) ); } }