Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/webcomponents/clinical/clinical-analysis-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,17 @@ export default class ClinicalAnalysisCreate extends LitElement {
}

// In FAMILY, changing the proband only sets the 'proband.id' field of the clinicalAnalysis object
// We have to add also the disorders list to 'proband.disorders'.
// We need to save the full member object in proband.
if (e.detail.param === "proband.id" && this.clinicalAnalysis.type === "FAMILY") {
// Changing the 'proband.id' means we have to reset the disorder field
delete this.clinicalAnalysis.disorder;
if (this.clinicalAnalysis.proband?.id) {
const proband = this.clinicalAnalysis.family.members.find(member => member.id === this.clinicalAnalysis.proband?.id);
this.clinicalAnalysis.proband.disorders = proband?.disorders || [];
} else if (this.clinicalAnalysis.proband?.disorders) {
// If we have remove the 'proband.id', we have to remove also the 'proband.disorders' field
delete this.clinicalAnalysis.proband.disorders;
this.clinicalAnalysis.proband = UtilsNew.objectClone(proband);
this.clinicalAnalysis.proband.disorders = this.clinicalAnalysis.proband.disorders || [];
} else {
// If we have removed the 'proband.id' field, we have to remove also the full proband object
delete this.clinicalAnalysis.proband;
}
}

Expand Down Expand Up @@ -175,7 +178,7 @@ export default class ClinicalAnalysisCreate extends LitElement {
if (this.clinicalAnalysis.family && this.clinicalAnalysis.family.members) {
for (const member of this.clinicalAnalysis.family.members) {
if (member.disorders && member.disorders.length > 0 && member.father.id && member.mother.id) {
this.clinicalAnalysis.proband = member;
this.clinicalAnalysis.proband = UtilsNew.objectClone(member);
break;
}
}
Expand Down