Skip to content

Commit

Permalink
add "Files & Links" tab of the Patient View to the Study View (#10467)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelliney committed Aug 19, 2024
1 parent 9ca3198 commit c9cedb7
Show file tree
Hide file tree
Showing 5 changed files with 430 additions and 16 deletions.
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
37 changes: 37 additions & 0 deletions src/pages/studyView/StudyViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5784,6 +5784,43 @@ 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 samples = this.samples.result!;
const ret: { [sampleId: string]: ResourceData[] } = {};
const promises = [];
for (const sample of samples) {
for (const resource of sampleResourceDefinitions) {
promises.push(
internalClient
.getAllResourceDataOfSampleInStudyUsingGET({
sampleId: sample.sampleId,
studyId: sample.studyId, // TODO:
resourceId: resource.resourceId,
projection: 'DETAILED',
})
.then(data => {
ret[sample.sampleId] =
ret[sample.sampleId] || [];
ret[sample.sampleId].push(...data);
})
);
}
}
return Promise.all(promises).then(() => ret);
},
});

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

0 comments on commit c9cedb7

Please sign in to comment.