Skip to content

Commit

Permalink
Merge pull request #792 from inodb/path-use-symoblic-links
Browse files Browse the repository at this point in the history
Use symbolic links for getting pathology reports

Former-commit-id: e1246f3
  • Loading branch information
inodb authored Dec 8, 2017
2 parents bb86a4b + 7972406 commit 68bd240
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
25 changes: 17 additions & 8 deletions src/pages/patientView/clinicalInformation/PatientViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,23 @@ export class PatientViewPageStore {

readonly pathologyReport = remoteData({
await: () => [this.derivedPatientId],
invoke: async() => {

let resp: any = await request.get(`https://api.github.com/search/code?q=${this.patientId}+extension:pdf+in:path+repo:cBioPortal/datahub`);

const parsedResp: any = JSON.parse(resp.text);

return handlePathologyReportCheckResponse(this.patientId, parsedResp);

invoke: () => {
const pathLinkUrl = "https://raw.githubusercontent.com/inodb/datahub/a0d36d77b242e32cda3175127de73805b028f595/tcga/pathology_reports/symlink_by_patient";
const rawPdfUrl = "https://github.com/cBioPortal/datahub/raw/master/tcga/pathology_reports";
const reports: PathologyReportPDF[] = [];

// keep checking if patient has more reports recursively
function getPathologyReport(patientId:string, i:number):any {
return request.get(`${pathLinkUrl}/${patientId}.${i}`).then(function(resp){
// add report
let pdfName: string = resp.text.split('/')[1];
reports.push({name: `${pdfName}`, url: `${rawPdfUrl}/${pdfName}`});
// check if patient has more reports
return getPathologyReport(patientId, i+1);
}, () => reports);
}

return getPathologyReport(this.patientId, 0);
},
onError: (err: Error) => {
// fail silently
Expand Down
12 changes: 7 additions & 5 deletions src/pages/patientView/pathologyReport/PathologyReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {PathologyReportPDF} from "../clinicalInformation/PatientViewPageStore";
import { If, Then, Else } from 'react-if';
import * as _ from 'lodash';
import IFrameLoader from "../../../shared/components/iframeLoader/IFrameLoader";
import {observer} from "mobx-react";

export type IPathologyReportProps = {

Expand All @@ -12,6 +13,7 @@ export type IPathologyReportProps = {
}


@observer
export default class PathologyReport extends React.Component<IPathologyReportProps,{ pdfUrl:string; }> {

pdfSelectList:any;
Expand All @@ -21,15 +23,15 @@ export default class PathologyReport extends React.Component<IPathologyReportPro

super();

this.state = { pdfUrl: this.buildPDFUrl(props.pdfs[0].name) }
this.state = { pdfUrl: this.buildPDFUrl(props.pdfs[0].url) }

this.handleSelection = this.handleSelection.bind(this);

}

buildPDFUrl(name: string):string {
buildPDFUrl(url: string):string {

return `https://drive.google.com/viewerng/viewer?url=https://github.com/cBioPortal/datahub/raw/master/tcga/pathology_reports/${name}?pid=explorer&efh=false&a=v&chrome=false&embedded=true`;
return `https://drive.google.com/viewerng/viewer?url=${url}?pid=explorer&efh=false&a=v&chrome=false&embedded=true`;

}

Expand All @@ -47,7 +49,7 @@ export default class PathologyReport extends React.Component<IPathologyReportPro

<If condition={this.props.pdfs.length > 1}>
<select ref={(el)=>this.pdfSelectList = el} style={{ marginBottom:15 }} onChange={ this.handleSelection }>{ _.map(this.props.pdfs, (pdf: PathologyReportPDF)=>
<option value={pdf.name}>{pdf.name}</option>) }
<option value={pdf.url}>{pdf.name}</option>) }
</select>
</If>

Expand All @@ -60,4 +62,4 @@ export default class PathologyReport extends React.Component<IPathologyReportPro



}
}

0 comments on commit 68bd240

Please sign in to comment.