|
190 | 190 | ced.cancer_study_identifier AS cancer_study_identifier |
191 | 191 | FROM clinical_event_derived ced |
192 | 192 | <where> |
| 193 | + <if test="studyViewFilterContext.customDataFilterCancerStudies != null and !studyViewFilterContext.customDataFilterCancerStudies.isEmpty()"> |
| 194 | + cancer_study_identifier IN |
| 195 | + <foreach item="studyId" collection="studyViewFilterContext.customDataFilterCancerStudies" open="(" separator="," close=")"> |
| 196 | + #{studyId} |
| 197 | + </foreach> |
| 198 | + AND |
| 199 | + </if> |
193 | 200 | key = 'SAMPLE_ID' |
194 | 201 | AND (event_type ILIKE 'Sample Acquisition' OR event_type ILIKE 'SPECIMEN') |
195 | 202 | </where> |
|
202 | 209 | value AS treatment, |
203 | 210 | argMin(start_date, start_date) AS treatment_time_taken |
204 | 211 | FROM clinical_event_derived |
205 | | - WHERE lower(event_type) = 'treatment' |
206 | | - AND key = 'AGENT' |
| 212 | + WHERE |
| 213 | + <if test="studyViewFilterContext.customDataFilterCancerStudies != null and !studyViewFilterContext.customDataFilterCancerStudies.isEmpty()"> |
| 214 | + cancer_study_identifier IN |
| 215 | + <foreach item="studyId" collection="studyViewFilterContext.customDataFilterCancerStudies" open="(" separator="," close=")"> |
| 216 | + #{studyId} |
| 217 | + </foreach> |
| 218 | + AND |
| 219 | + </if> |
| 220 | + lower(event_type) = 'treatment' |
| 221 | + AND key = 'AGENT' |
207 | 222 | GROUP BY patient_unique_id, value |
208 | 223 | ) ced_inner ON ced_inner.patient_unique_id = ced.patient_unique_id |
209 | 224 | <where> |
|
232 | 247 | SELECT patient_unique_id |
233 | 248 | FROM clinical_event_derived |
234 | 249 | <where> |
235 | | - <foreach item="dataFilterValue" collection="clinicalEventFilter.values" open="(" separator=") OR (" close=")"> |
| 250 | + <if test="studyViewFilterContext.customDataFilterCancerStudies != null and !studyViewFilterContext.customDataFilterCancerStudies.isEmpty()"> |
| 251 | + cancer_study_identifier IN |
| 252 | + <foreach item="studyId" collection="studyViewFilterContext.customDataFilterCancerStudies" open="(" separator="," close=")"> |
| 253 | + #{studyId} |
| 254 | + </foreach> |
| 255 | + AND |
| 256 | + </if> |
| 257 | + <foreach item="dataFilterValue" collection="clinicalEventFilter.values" open="((" separator=") OR (" close="))"> |
236 | 258 | event_type = #{dataFilterValue.value} |
237 | 259 | </foreach> |
238 | 260 | </where> |
|
250 | 272 | SELECT patient_unique_id |
251 | 273 | FROM clinical_event_derived |
252 | 274 | <where> |
253 | | - <foreach item="patientTreatmentFilter" collection="andedPatientTreatmentFilters.getFilters()" open="(" |
254 | | - separator=") OR (" |
255 | | - close=")"> lower(event_type) = 'treatment' |
| 275 | + <if test="studyViewFilterContext.customDataFilterCancerStudies != null and !studyViewFilterContext.customDataFilterCancerStudies.isEmpty()"> |
| 276 | + cancer_study_identifier IN |
| 277 | + <foreach item="studyId" collection="studyViewFilterContext.customDataFilterCancerStudies" open="(" separator="," close=")"> |
| 278 | + #{studyId} |
| 279 | + </foreach> |
| 280 | + AND |
| 281 | + </if> |
| 282 | + <foreach |
| 283 | + item="patientTreatmentFilter" |
| 284 | + collection="andedPatientTreatmentFilters.getFilters()" |
| 285 | + open="((" separator=") OR (" close="))" |
| 286 | + > |
| 287 | + lower(event_type) = 'treatment' |
256 | 288 | AND key = 'AGENT' |
257 | 289 | AND value = #{patientTreatmentFilter.treatment} |
258 | 290 | </foreach> |
|
0 commit comments