Skip to content

Commit

Permalink
Add Patient and Sample Resources to Study View (#4961)
Browse files Browse the repository at this point in the history
* add "Files & Links" tab of the Patient View to the Study View (#10467)
  • Loading branch information
Nelliney authored Aug 23, 2024
1 parent b1a387c commit 76e378e
Show file tree
Hide file tree
Showing 6 changed files with 431 additions and 16 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 2 additions & 5 deletions src/pages/studyView/StudyViewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,8 @@ export default class StudyViewPage extends React.Component<
}

@computed get shouldShowResources() {
if (this.store.resourceIdToResourceData.isComplete) {
return _.some(
this.store.resourceIdToResourceData.result,
data => data.length > 0
);
if (this.store.resourceDefinitions.isComplete) {
return this.store.resourceDefinitions.result.length > 0;
} else {
return false;
}
Expand Down
38 changes: 38 additions & 0 deletions src/pages/studyView/StudyViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5784,6 +5784,44 @@ export class StudyViewPageStore
},
});

readonly sampleResourceData = remoteData<{
[sampleId: string]: ResourceData[];
}>({
await: () => [this.resourceDefinitions, this.samples],
invoke: () => {
const sampleResourceDefinitions = this.resourceDefinitions.result!.filter(
d => d.resourceType === 'SAMPLE'
);
if (!sampleResourceDefinitions.length) {
return Promise.resolve({});
}

const res = _(this.samples.result!)
.map(sample =>
sampleResourceDefinitions.map(resource =>
internalClient.getAllResourceDataOfSampleInStudyUsingGET(
{
sampleId: sample.sampleId,
studyId: sample.studyId,
resourceId: resource.resourceId,
projection: 'DETAILED',
}
)
)
)
.flatten()
.value();

return Promise.all(res).then(resData =>
_(resData)
.flatMap()
.groupBy('sampleId')
.mapValues(data => data)
.value()
);
},
});

readonly resourceIdToResourceData = remoteData<{
[resourceId: string]: ResourceData[];
}>({
Expand Down
Loading

0 comments on commit 76e378e

Please sign in to comment.