@@ -87,6 +87,52 @@ interface ICancerType {
87
87
tumorForm : 'SOLID' | 'LIQUID' | 'MIXED' ;
88
88
}
89
89
90
+ interface IRule {
91
+ id : number ;
92
+ entity : string ;
93
+ rule : string ;
94
+ name : string | null ;
95
+ association : IAssociation | null ;
96
+ }
97
+
98
+ interface IAssociation {
99
+ id : number ;
100
+ name : string | null ;
101
+ rules : IRule [ ] | null ;
102
+ alterations : IAlteration [ ] | null ;
103
+ cancerTypes : ICancerType [ ] | null ;
104
+ drugs : IDrug [ ] | null ;
105
+ fdaSubmissions : IFdaSubmission [ ] | null ;
106
+ }
107
+
108
+ interface IDrug {
109
+ id : number ;
110
+ uuid : string ;
111
+ name : string ;
112
+ associations : IAssociation [ ] | null ;
113
+ }
114
+
115
+ interface IAlteration {
116
+ id : number ;
117
+ name : string ;
118
+ alteration : string ;
119
+ proteinChange : string ;
120
+ start : number | null ;
121
+ end : number | null ;
122
+ refResidues : string | null ;
123
+ variantResidues : string | null ;
124
+ genes : IGene [ ] | null ;
125
+ associations : IAssociation [ ] | null ;
126
+ }
127
+
128
+ interface IGene {
129
+ id : number ;
130
+ entrezGeneId : number ;
131
+ hugoSymbol : string ;
132
+ hgncId : string | null ;
133
+ alterations : IAlteration [ ] | null ;
134
+ }
135
+
90
136
type SelectOption = {
91
137
value : string ;
92
138
label : string ;
@@ -99,6 +145,27 @@ const referenceColumnInfo = (
99
145
</ div >
100
146
) ;
101
147
148
+ const getDrugName = ( drugs : IDrug [ ] , rules : IRule [ ] ) => {
149
+ // Create a map of drug ids to drug names for quick lookup
150
+ const drugMap = new Map ( ) ;
151
+ drugs . forEach ( ( drug : any ) => {
152
+ drugMap . set ( drug . id , drug . name ) ;
153
+ } ) ;
154
+
155
+ const drugRule = rules . filter ( ( rule : IRule ) => rule . entity === 'DRUG' ) [ 0 ] ;
156
+
157
+ if ( ! drugRule ) {
158
+ return drugs [ 0 ] . name ;
159
+ }
160
+ return drugRule . rule
161
+ . split ( / ( [ + , ] ) / )
162
+ . map ( ( part : any ) => {
163
+ const id = parseInt ( part , 10 ) ;
164
+ return isNaN ( id ) ? part : drugMap . get ( id ) || part ;
165
+ } )
166
+ . join ( '' ) ;
167
+ } ;
168
+
102
169
const parseCDx = ( ) => {
103
170
const parsedCompanionDiagnosticDevices : ICompanionDiagnosticDevice [ ] = [ ] ;
104
171
for ( const cdx of companionDiagnosticDevices ) {
@@ -131,18 +198,8 @@ const parseCDx = () => {
131
198
) . map ( ( gene : any ) => ( {
132
199
gene,
133
200
alterations : uniq ( assoc . alterations . map ( ( a : any ) => a . name ) ) . sort ( ) ,
134
- drugs : assoc . treatments
135
- . map ( ( treatment : any ) =>
136
- treatment . drugs . map ( ( drug : any ) => drug . name ) . join ( ' + ' )
137
- )
138
- . join ( ', ' ) ,
139
- cancerTypes : assoc . associationCancerTypes . reduce (
140
- ( ctAcc : any [ ] , act : any ) => {
141
- ctAcc . push ( act . cancerType ) ;
142
- return ctAcc ;
143
- } ,
144
- [ ]
145
- ) ,
201
+ drugs : getDrugName ( assoc . drugs , assoc . rules ) ,
202
+ cancerTypes : assoc . cancerTypes ,
146
203
fdaSubmissions : assoc . fdaSubmissions ,
147
204
} ) ) ;
148
205
} )
0 commit comments