Skip to content

Commit

Permalink
add autofill for samples
Browse files Browse the repository at this point in the history
  • Loading branch information
nr23730 committed Aug 23, 2024
1 parent cb06505 commit 18061b1
Showing 1 changed file with 58 additions and 13 deletions.
71 changes: 58 additions & 13 deletions src/pages/patientView/therapyRecommendation/MtbTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ export default class MtbTable extends React.Component<IMtbProps, IMtbState> {
)!.samples = newSamples;
this.setState({ mtbs: newMtbs });
}}
value={mtb.samples.map(sampleId => ({
label: sampleId,
value: sampleId,
}))}
/>
<span className={styles.edit}>
<Button
Expand Down Expand Up @@ -393,15 +397,29 @@ export default class MtbTable extends React.Component<IMtbProps, IMtbState> {
therapyRecommendationToDelete.id
);
const newMtbs = this.state.mtbs.slice();
newMtbs.find(
x => x.id === mtbId
)!.therapyRecommendations = newMtbs
let m = newMtbs.find(x => x.id === mtbId)!;
m.therapyRecommendations = newMtbs
.find(x => x.id === mtbId)!
.therapyRecommendations.filter(
(therapyRecommendation: ITherapyRecommendation) =>
therapyRecommendationToDelete.id !==
therapyRecommendation.id
);
m.samples = [];
m.therapyRecommendations.forEach(y => {
y.reasoning.clinicalData?.forEach(c => {
if (!m.samples.includes(c.sampleId!)) {
m.samples.push(c.sampleId!);
}
});
y.reasoning.geneticAlterations?.forEach(g => {
g.sampleIds!.forEach(s => {
if (!m.samples.includes(s)) {
m.samples.push(s);
}
});
});
});
this.setState({ mtbs: newMtbs });
return true;
};
Expand Down Expand Up @@ -439,17 +457,44 @@ export default class MtbTable extends React.Component<IMtbProps, IMtbState> {
);
const newMtbs = this.state.mtbs.slice();
if (index === -1) {
newMtbs
.find(x => x.id === mtbId)!
.therapyRecommendations.unshift(therapyRecommendationToAdd);
let y = newMtbs.find(x => x.id === mtbId)!;
y.therapyRecommendations.unshift(therapyRecommendationToAdd);

therapyRecommendationToAdd.reasoning.clinicalData?.forEach(c => {
if (!y.samples.includes(c.sampleId!)) {
y.samples.push(c.sampleId!);
}
});
therapyRecommendationToAdd.reasoning.geneticAlterations?.forEach(
g => {
g.sampleIds!.forEach(s => {
if (!y.samples.includes(s)) {
y.samples.push(s);
}
});
}
);
} else {
newMtbs
.find(x => x.id === mtbId)!
.therapyRecommendations.splice(
index,
0,
therapyRecommendationToAdd
);
let y = newMtbs.find(x => x.id === mtbId)!;
y.therapyRecommendations.splice(
index,
0,
therapyRecommendationToAdd
);
therapyRecommendationToAdd.reasoning.clinicalData?.forEach(c => {
if (!y.samples.includes(c.sampleId!)) {
y.samples.push(c.sampleId!);
}
});
therapyRecommendationToAdd.reasoning.geneticAlterations?.forEach(
g => {
g.sampleIds!.forEach(s => {
if (!y.samples.includes(s)) {
y.samples.push(s);
}
});
}
);
}
this.setState({ mtbs: newMtbs });
return true;
Expand Down

0 comments on commit 18061b1

Please sign in to comment.