@@ -140,25 +140,26 @@ const TumourSummaryEdit = ({
140
140
141
141
if ( reportDirty && newReportData ) {
142
142
apiCalls . push ( api . put ( `/reports/${ report . ident } ` , newReportData , { } ) ) ;
143
- } else {
144
- apiCalls . push ( { request : ( ) => null } ) ;
145
143
}
146
144
147
145
if ( mutationBurdenDirty && newMutationBurdenData ) {
148
146
if ( mutationBurden ?. ident ) {
149
147
apiCalls . push ( api . put ( `/reports/${ report . ident } /mutation-burden/${ mutationBurden . ident } ` , newMutationBurdenData , { } ) ) ;
150
148
} else {
151
- // Default role of new mutation burden data for reports with no existing analysis per ClinInfo team
152
- apiCalls . push ( api . post ( `/reports/${ report . ident } /mutation-burden` , { ...newMutationBurdenData , role : 'primary' } , { } ) ) ;
149
+ apiCalls . push ( api . post (
150
+ `/reports/${ report . ident } /mutation-burden` ,
151
+ { ...newMutationBurdenData , role : 'primary' } ,
152
+ { } ,
153
+ ) ) ;
153
154
}
154
- } else {
155
- apiCalls . push ( { request : ( ) => null } ) ;
156
155
}
157
156
158
- if ( tmburMutDirty && newTmburMutData && tmburMutBur ?. ident ) {
159
- apiCalls . push ( api . put ( `/reports/${ report . ident } /tmbur-mutation-burden` , newTmburMutData , { } ) ) ;
160
- } else {
161
- apiCalls . push ( { request : ( ) => null } ) ;
157
+ if ( tmburMutDirty && newTmburMutData ) {
158
+ if ( tmburMutBur ?. ident ) {
159
+ apiCalls . push ( api . put ( `/reports/${ report . ident } /tmbur-mutation-burden` , newTmburMutData , { } ) ) ;
160
+ } else {
161
+ apiCalls . push ( api . post ( `/reports/${ report . ident } /tmbur-mutation-burden` , newTmburMutData , { } ) ) ;
162
+ }
162
163
}
163
164
164
165
callSet = new ApiCallSet ( apiCalls ) ;
@@ -168,19 +169,33 @@ const TumourSummaryEdit = ({
168
169
setIsApiCalling ( false ) ;
169
170
} else {
170
171
try {
171
- const resp = await callSet . request ( ) ;
172
- const tmburMutResp = resp . pop ( ) ;
173
- const primaryBurdenResp = resp . pop ( ) ;
174
- const reportResp = resp . pop ( ) ;
172
+ await callSet . request ( ) ;
173
+
174
+ let microbialResp = null ;
175
+ let tmburMutResp = null ;
176
+ let mutationBurdenResp = null ;
177
+ let reportResp = null ;
175
178
176
179
// Too complicated between delete/update/new, might as well grab updated micb species for report again
177
- const microbialResp = await api . get ( `/reports/${ report . ident } /summary/microbial` ) . request ( ) ;
180
+ if ( microbialDirty ) {
181
+ microbialResp = await api . get ( `/reports/${ report . ident } /summary/microbial` ) . request ( ) ;
182
+ }
183
+ if ( tmburMutDirty ) {
184
+ tmburMutResp = await api . get ( `/reports/${ report . ident } /tmbur-mutation-burden` ) . request ( ) ;
185
+ }
186
+ if ( mutationBurdenDirty ) {
187
+ mutationBurdenResp = await api . get ( `/reports/${ report . ident } /mutation-burden/` ) . request ( ) ;
188
+ }
189
+ if ( reportDirty ) {
190
+ reportResp = await api . get ( `/reports/${ report . ident } ` ) . request ( ) ;
191
+ }
192
+
178
193
snackbar . success ( 'Successfully updated Tumour Summary' ) ;
179
194
onClose (
180
195
true ,
181
196
microbialDirty ? microbialResp : null ,
182
197
reportDirty ? reportResp : null ,
183
- mutationBurdenDirty ? primaryBurdenResp : null ,
198
+ mutationBurdenDirty ? mutationBurdenResp . find ( ( mb ) => mb . role === 'primary' ) : null ,
184
199
tmburMutDirty ? tmburMutResp : null ,
185
200
) ;
186
201
} catch ( callSetError ) {
@@ -365,31 +380,29 @@ const TumourSummaryEdit = ({
365
380
} , [ newMutationBurdenData , handleMutationBurdenChange ] ) ;
366
381
367
382
const tmburMutBurSection = useMemo ( ( ) => {
368
- return (
369
- < >
370
- < TextField
371
- className = "tumour-dialog__text-field"
372
- label = "genomeSnvTmb"
373
- value = { newTmburMutData ?. genomeSnvTmb ?? null }
374
- name = "genomeSnvTmb"
375
- onChange = { handleTmburChange }
376
- variant = "outlined"
377
- fullWidth
378
- type = "number"
379
- />
380
- < TextField
381
- className = "tumour-dialog__text-field"
382
- label = "genomeIndelTmb"
383
- value = { newTmburMutData ?. genomeIndelTmb ?? null }
384
- name = "genomeIndelTmb"
385
- onChange = { handleTmburChange }
386
- variant = "outlined"
387
- fullWidth
388
- type = "number"
389
- />
390
- </ >
391
- ) ;
392
- } , [ newTmburMutData , handleTmburChange ] ) ;
383
+ < >
384
+ < TextField
385
+ className = "tumour-dialog__text-field"
386
+ label = "genomeSnvTmb"
387
+ value = { newTmburMutData ?. genomeSnvTmb ?? 0 }
388
+ name = "genomeSnvTmb"
389
+ onChange = { handleTmburChange }
390
+ variant = "outlined"
391
+ fullWidth
392
+ type = "number"
393
+ />
394
+ < TextField
395
+ className = "tumour-dialog__text-field"
396
+ label = "genomeIndelTmb"
397
+ value = { newTmburMutData ?. genomeIndelTmb ?? 0 }
398
+ name = "genomeIndelTmb"
399
+ onChange = { handleTmburChange }
400
+ variant = "outlined"
401
+ fullWidth
402
+ type = "number"
403
+ />
404
+ </ > ;
405
+ } , [ newTmburMutData ?. genomeSnvTmb , newTmburMutData ?. genomeIndelTmb , handleTmburChange ] ) ;
393
406
394
407
return (
395
408
< Dialog open = { isOpen } >
0 commit comments