@@ -69,67 +69,61 @@ export class NewTemplateComponent {
6969 meldedTemplate = false ;
7070 mendelianTemplate = false ;
7171
72- diseaseA = signal < CohortEntry | null > ( null ) ;
73- diseaseB = signal < CohortEntry | null > ( null ) ;
74- diseaseDataA = computed < DiseaseData | null > ( ( ) => {
75- const d = this . diseaseA ( ) ;
76- if ( ! d ) return null ;
77- else return toDiseaseData ( d ) ;
72+ diseases = signal < CohortEntry [ ] > ( [ ] ) ;
73+ diseasesData = computed < DiseaseData [ ] > ( ( ) =>
74+ this . diseases ( ) . map ( d => toDiseaseData ( d ) )
75+ ) ;
76+ mendelianDisease = computed < DiseaseData | null > ( ( ) => {
77+ const list = this . diseasesData ( ) ;
78+ return list . length > 0 ? list [ 0 ] : null ;
7879 } ) ;
79- diseaseDataB = computed < DiseaseData | null > ( ( ) => {
80- const d = this . diseaseB ( ) ;
81- if ( ! d ) return null ;
82- else return toDiseaseData ( d ) ;
80+ cohortAcronym = computed ( ( ) => {
81+ const currentDiseases = this . diseases ( ) ;
82+ if ( currentDiseases . length === 0 ) return '' ;
83+
84+ return currentDiseases
85+ . map ( d => `${ d . symbol } _${ d . cohortAcronym } ` )
86+ . join ( "_" ) ;
8387 } ) ;
88+
8489 thisCohortType = signal < CohortType | null > ( null ) ;
8590 pendingCohort = signal < CohortData | null > ( null ) ;
8691 showSuccessMessage = signal < boolean > ( false ) ;
8792
8893
89-
90-
91-
9294 async melded ( ) : Promise < void > {
93- this . mendelianTemplate = false ;
94- this . meldedTemplate = true ;
95- this . digenicTemplate = false ;
96- this . resetCohort ( ) ;
97- const first = this . dialog . open ( CohortDialogComponent , {
98- width : '450px' ,
99- height : '550px' ,
100- data : { title : 'Enter Disease A Info' }
101- } ) ;
102- if ( ! first ) return ;
103- const rawValueA = await firstValueFrom ( first . afterClosed ( ) ) ;
104- if ( rawValueA ) {
105- const entryA : CohortEntry = {
106- ...rawValueA ,
107- geneTranscriptList : [ ] // Ensure the optional list is initialized if needed
108- } ;
109- this . diseaseA . set ( entryA ) ;
110- } else {
111- this . notificationService . showError ( "Could not retrieve disease A" ) ;
112- return ;
95+ this . resetCohort ( ) ;
96+ this . mendelianTemplate = false ;
97+ this . meldedTemplate = true ;
98+ this . digenicTemplate = false ;
99+ const tempDiseases : CohortEntry [ ] = [ ] ;
100+ let shouldContinue = true ;
101+ while ( shouldContinue ) {
102+ const dialogRef = this . dialog . open ( CohortDialogComponent , {
103+ width : '450px' ,
104+ height : '700px' ,
105+ data : {
106+ title : `Enter disease #${ tempDiseases . length + 1 } Info` ,
107+ isMelded : true
108+ }
109+ } ) ;
110+ const result = await firstValueFrom ( dialogRef . afterClosed ( ) ) ;
111+ if ( ! result ) {
112+ shouldContinue = false ;
113+ if ( tempDiseases . length < 2 ) this . resetCohort ( ) ;
113114 }
114-
115- const second = await this . dialog . open ( CohortDialogComponent , {
116- width : '450px' ,
117- height : '550px' ,
118- data : { title : 'Enter Disease B Info' }
119- } ) ;
120- if ( ! second ) return ;
121- const rawValueB = await firstValueFrom ( second . afterClosed ( ) ) ;
122- if ( rawValueB ) {
123- const entryB : CohortEntry = {
124- ...rawValueB ,
125- geneTranscriptList : [ ]
126- } ;
127- this . diseaseB . set ( entryB ) ;
128- } else {
129- this . notificationService . showError ( "Could not retrieve disease B" ) ;
130- return ;
115+ if ( result ) {
116+ tempDiseases . push ( { ...result . entry , geneTranscriptList : [ ] } ) ;
117+ shouldContinue = result . keepGoing ;
131118 }
132- this . createMeldedTemplate ( ) ;
119+ }
120+ if ( tempDiseases . length >= 2 ) {
121+ this . diseases . set ( tempDiseases ) ;
122+ this . createMeldedTemplate ( ) ;
123+ } else {
124+ this . notificationService . showError ( "Could not get >=2 diseases for melded cohort" ) ;
125+ this . resetCohort ( ) ;
126+ }
133127 }
134128
135129 async digenic ( ) : Promise < void > {
@@ -138,7 +132,7 @@ export class NewTemplateComponent {
138132 this . digenicTemplate = true ;
139133 const dialogRef = this . dialog . open ( CohortDialogComponent , {
140134 width : '450px' ,
141- height : '550px ' ,
135+ height : '700px ' ,
142136 data : { title : 'Create Digenic Cohort' , mode : 'digenic' }
143137 } ) ;
144138 const result = await firstValueFrom ( dialogRef . afterClosed ( ) ) ;
@@ -155,7 +149,7 @@ async mendelian(): Promise<void> {
155149
156150 const dialogRef = this . dialog . open ( CohortDialogComponent , {
157151 width : '450px' ,
158- height : '650px ' ,
152+ height : '700px ' ,
159153 data : { title : 'Create Mendelian Cohort' , mode : 'mendelian' }
160154 } ) ;
161155 const rawValue = await firstValueFrom ( dialogRef . afterClosed ( ) ) ;
@@ -165,10 +159,10 @@ async mendelian(): Promise<void> {
165159 }
166160 if ( rawValue ) {
167161 const entryA : CohortEntry = {
168- ...rawValue ,
162+ ...rawValue . entry ,
169163 geneTranscriptList : [ ]
170164 } ;
171- this . diseaseA . set ( entryA ) ;
165+ this . diseases . set ( [ entryA ] ) ;
172166 } else {
173167 this . notificationService . showError ( "Could not retrieve disease" ) ;
174168 return ;
@@ -178,43 +172,32 @@ async mendelian(): Promise<void> {
178172}
179173
180174 private async createMeldedTemplate ( ) : Promise < void > {
181- const diseaseA = this . diseaseA ( ) ;
182- const diseaseB = this . diseaseB ( ) ;
183- if ( ! diseaseA ) {
184- this . notificationService . showError ( "Could not retrieve disease A data for melded template" ) ;
185- return ;
186- }
187- if ( ! diseaseB ) {
188- this . notificationService . showError ( "Could not retrieve disease B data for melded template" ) ;
175+ const currentDiseases = this . diseases ( ) ;
176+ if ( currentDiseases . length < 2 ) {
177+ this . notificationService . showError ( `Only ${ currentDiseases . length } diseases but need at least 2 for melded cohort` ) ;
189178 return ;
190179 }
191-
192- const acronymA = diseaseA . cohortAcronym ;
193- const acronymB = diseaseB . cohortAcronym ;
194- const geneA = diseaseA . symbol ;
195- const geneB = diseaseB . symbol ;
196- const acronym = `${ geneA } _${ acronymA } _${ geneB } _${ acronymB } ` ;
197- const cohort = await this . configService . createNewMeldedTemplate ( toDiseaseData ( diseaseA ) , toDiseaseData ( diseaseB ) , acronym ) ;
198- this . resetCohort ( ) ;
199- this . pendingCohort . set ( cohort ) ;
200- this . thisCohortType . set ( "melded" ) ;
180+
181+
182+ const cohort = await this . configService . createNewMeldedTemplate ( this . diseasesData ( ) , this . cohortAcronym ( ) ) ;
183+ this . resetCohort ( ) ;
184+ this . pendingCohort . set ( cohort ) ;
185+ this . thisCohortType . set ( "melded" ) ;
201186 }
202187
203188private async createMendelianTemplate ( ) : Promise < void > {
204189 this . etl_service . clearEtlDto ( ) ;
205- const diseaseA = this . diseaseA ( ) ;
206- if ( ! diseaseA ) {
207- this . notificationService . showError ( "Could not retrieve disease for Mendelian" ) ;
190+ const diseases = this . diseases ( ) ;
191+ if ( diseases . length != 1 ) {
192+ this . notificationService . showError ( `Expected to get one disease for Mendelian cohort, but got ${ diseases . length } ` ) ;
208193 return ;
209194 }
210- const acronym = diseaseA . cohortAcronym ;
211- const gene = diseaseA . symbol ;
212- const fullAcronym = `${ gene } _${ acronym } ` ;
195+ const disease = diseases [ 0 ] ;
213196 const ctype : CohortType = "mendelian" ;
214197 const template = await this . configService . createNewTemplate (
215- toDiseaseData ( diseaseA ) ,
198+ toDiseaseData ( disease ) ,
216199 ctype ,
217- fullAcronym
200+ this . cohortAcronym ( )
218201 ) ;
219202 this . resetCohort ( ) ;
220203 this . pendingCohort . set ( template ) ;
0 commit comments