@@ -24,7 +24,7 @@ import useConfirmDialog from '@/hooks/useConfirmDialog';
24
24
import './index.scss' ;
25
25
import { ReportType } from '@/context/ReportContext' ;
26
26
import {
27
- ImmuneType , MicrobialType , MutationBurdenType , TmburType ,
27
+ ImmuneType , MicrobialType , MsiType , MutationBurdenType , TmburType ,
28
28
} from '@/common' ;
29
29
import snackbar from '@/services/SnackbarUtils' ;
30
30
import { getMicbSiteIntegrationStatusLabel } from '@/utils/getMicbSiteIntegrationStatusLabel' ;
@@ -41,6 +41,7 @@ type TumourSummaryEditProps = {
41
41
tCellCd8 : ImmuneType ;
42
42
mutationBurden : MutationBurdenType ;
43
43
tmburMutBur : TmburType ;
44
+ msi ?: MsiType ;
44
45
isOpen : boolean ;
45
46
onEditClose : (
46
47
isSaved : boolean ,
@@ -49,6 +50,7 @@ type TumourSummaryEditProps = {
49
50
newTCellCd8Data ?: ImmuneType ,
50
51
newMutationBurdenData ?: MutationBurdenType ,
51
52
newTmBurMutBurData ?: TmburType ,
53
+ newMsiData ?: MsiType ,
52
54
) => void ;
53
55
} ;
54
56
@@ -61,6 +63,7 @@ const TumourSummaryEdit = ({
61
63
tCellCd8,
62
64
mutationBurden,
63
65
tmburMutBur,
66
+ msi,
64
67
isOpen,
65
68
onEditClose,
66
69
} : TumourSummaryEditProps ) : JSX . Element => {
@@ -72,11 +75,13 @@ const TumourSummaryEdit = ({
72
75
const [ newTCellCd8Data , setNewTCellCd8Data ] = useState < Partial < ImmuneType > > ( null ) ;
73
76
const [ newMutationBurdenData , setNewMutationBurdenData ] = useState < Partial < MutationBurdenType > > ( null ) ;
74
77
const [ newTmburMutData , setNewTmburMutData ] = useState < Partial < TmburType > > ( null ) ;
78
+ const [ newMsiData , setNewMsiData ] = useState < Partial < MsiType > > ( null ) ;
75
79
const [ microbialDirty , setMicrobialDirty ] = useState ( false ) ;
76
80
const [ reportDirty , setReportDirty ] = useState ( false ) ;
77
81
const [ tCellCd8Dirty , setTCellCd8Dirty ] = useState ( false ) ;
78
82
const [ mutationBurdenDirty , setMutationBurdenDirty ] = useState ( false ) ;
79
83
const [ tmburMutDirty , setTmburMutDirty ] = useState ( false ) ;
84
+ const [ msiDirty , setMsiDirty ] = useState ( false ) ;
80
85
const [ isApiCalling , setIsApiCalling ] = useState ( false ) ;
81
86
82
87
useEffect ( ( ) => {
@@ -129,10 +134,19 @@ const TumourSummaryEdit = ({
129
134
adjustedTmb : tmburMutBur . adjustedTmb ,
130
135
adjustedTmbComment : tmburMutBur . adjustedTmbComment ,
131
136
tmbHidden : tmburMutBur . tmbHidden ,
137
+ msiScore : tmburMutBur . msiScore ,
132
138
} ) ;
133
139
}
134
140
} , [ tmburMutBur ] ) ;
135
141
142
+ useEffect ( ( ) => {
143
+ if ( msi ) {
144
+ setNewMsiData ( {
145
+ score : msi . score ,
146
+ } ) ;
147
+ }
148
+ } , [ msi ] ) ;
149
+
136
150
const handleReportChange = useCallback ( ( event : React . ChangeEvent < HTMLInputElement > ) => {
137
151
const { target : { value, name } } = event ;
138
152
setNewReportData ( ( prevVal ) => ( { ...prevVal , [ name ] : value } ) ) ;
@@ -189,6 +203,16 @@ const TumourSummaryEdit = ({
189
203
setTmburMutDirty ( true ) ;
190
204
} , [ ] ) ;
191
205
206
+ const handleMsiScoreChange = useCallback ( ( event : React . ChangeEvent < HTMLInputElement > ) => {
207
+ const { target : { value, name } } = event ;
208
+ setNewMsiData ( ( prevVal ) => ( { ...prevVal , [ name ] : value } ) ) ;
209
+ if ( msi ) {
210
+ setMsiDirty ( true ) ;
211
+ } else if ( tmburMutBur ) {
212
+ setTmburMutDirty ( true ) ;
213
+ }
214
+ } , [ ] ) ;
215
+
192
216
const handleAdjustedTmbCommentChange = useCallback ( ( { target : { value, name } } ) => {
193
217
setNewTmburMutData ( ( tmb ) => ( {
194
218
...tmb ,
@@ -291,6 +315,14 @@ const TumourSummaryEdit = ({
291
315
}
292
316
}
293
317
318
+ if ( msiDirty && newMsiData ) {
319
+ if ( msi ?. ident ) {
320
+ apiCalls . push ( api . put ( `/reports/${ report . ident } /msi/${ msi . ident } ` , newMsiData , { } ) ) ;
321
+ } else {
322
+ apiCalls . push ( api . post ( `/reports/${ report . ident } /msi` , newMsiData , { } ) ) ;
323
+ }
324
+ }
325
+
294
326
callSet = new ApiCallSet ( apiCalls ) ;
295
327
296
328
if ( isSigned ) {
@@ -303,6 +335,7 @@ const TumourSummaryEdit = ({
303
335
let microbialResp = null ;
304
336
let immuneResp = null ;
305
337
let tmburMutResp = null ;
338
+ let msiResp = null ;
306
339
let mutationBurdenResp = null ;
307
340
let reportResp = null ;
308
341
@@ -315,6 +348,9 @@ const TumourSummaryEdit = ({
315
348
if ( tmburMutDirty ) {
316
349
tmburMutResp = await api . get ( `/reports/${ report . ident } /tmbur-mutation-burden` ) . request ( ) ;
317
350
}
351
+ if ( msiDirty ) {
352
+ msiResp = await api . get ( `/reports/${ report . ident } /msi` ) . request ( ) ;
353
+ }
318
354
if ( mutationBurdenDirty ) {
319
355
mutationBurdenResp = await api . get ( `/reports/${ report . ident } /mutation-burden` ) . request ( ) ;
320
356
}
@@ -330,6 +366,7 @@ const TumourSummaryEdit = ({
330
366
tCellCd8Dirty ? immuneResp . find ( ( { cellType } ) => cellType === 'T cells CD8' ) : null ,
331
367
mutationBurdenDirty ? mutationBurdenResp . find ( ( mb ) => mb . role === 'primary' ) : null ,
332
368
tmburMutDirty ? tmburMutResp : null ,
369
+ msiDirty ? msiResp : null ,
333
370
) ;
334
371
} catch ( callSetError ) {
335
372
snackbar . error ( `Error updating Tumour Summary: ${ callSetError ?. message } ` ) ;
@@ -351,13 +388,16 @@ const TumourSummaryEdit = ({
351
388
newMutationBurdenData ,
352
389
tmburMutDirty ,
353
390
newTmburMutData ,
391
+ msiDirty ,
392
+ newMsiData ,
354
393
isSigned ,
355
394
newMicrobialData ,
356
395
microbial ,
357
396
report ?. ident ,
358
397
tCellCd8 ?. ident ,
359
398
mutationBurden ?. ident ,
360
399
tmburMutBur ?. ident ,
400
+ msi ?. ident ,
361
401
showConfirmDialog ,
362
402
onEditClose ,
363
403
] ) ;
@@ -732,6 +772,39 @@ const TumourSummaryEdit = ({
732
772
handleAdjustedTmbVisibleChange ,
733
773
] ) ;
734
774
775
+ const msiSection = useMemo ( ( ) => (
776
+ < >
777
+ { msi &&
778
+ < TextField
779
+ className = "tumour-dialog__number-field"
780
+ label = "MSI Score"
781
+ value = { newMsiData ?. score ?? null }
782
+ name = "score"
783
+ onChange = { handleMsiScoreChange }
784
+ variant = "outlined"
785
+ fullWidth
786
+ type = "number"
787
+ />
788
+ }
789
+ { ! msi && tmburMutBur &&
790
+ < TextField
791
+ className = "tumour-dialog__number-field"
792
+ label = "MSI Score"
793
+ value = { newTmburMutData ?. msiScore ?? null }
794
+ name = "msiScore"
795
+ onChange = { handleMsiScoreChange }
796
+ variant = "outlined"
797
+ fullWidth
798
+ type = "number"
799
+ />
800
+ }
801
+ </ >
802
+ ) , [
803
+ newMsiData ?. score ,
804
+ newTmburMutData ?. msiScore ,
805
+ handleMsiScoreChange ,
806
+ ] ) ;
807
+
735
808
return (
736
809
< Dialog open = { isOpen } >
737
810
< DialogTitle >
@@ -743,6 +816,7 @@ const TumourSummaryEdit = ({
743
816
{ tCellCd8DataSection }
744
817
{ mutBurDataSection }
745
818
{ tmburMutBurSection }
819
+ { msiSection }
746
820
</ DialogContent >
747
821
< DialogActions >
748
822
< Button onClick = { ( ) => handleClose ( false ) } >
0 commit comments