Skip to content

Commit

Permalink
Rfc80/update open api annotation for sampleTreatment Endpoint (#10929)
Browse files Browse the repository at this point in the history
* Fix Sample Treatment Endpoint

* Fix Sample ID only StudyView Filter
  • Loading branch information
haynescd authored Aug 6, 2024
1 parent bf71f1b commit d62c6e5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

import java.util.Collection;

public record SampleTreatmentReport(int totalSampleCount, Collection<SampleTreatment> treatments) {
public record SampleTreatmentReport(int totalSamples, Collection<SampleTreatmentRow> treatments) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

import org.cbioportal.model.PatientTreatmentReport;
import org.cbioportal.model.SampleTreatmentReport;
import org.cbioportal.model.SampleTreatmentRow;
import org.cbioportal.model.TemporalRelation;
import org.cbioportal.persistence.StudyViewRepository;
import org.cbioportal.web.parameter.StudyViewFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;
import java.util.stream.Stream;

@Service
public class TreatmentCountReportServiceImpl implements TreatmentCountReportService {

Expand All @@ -26,7 +31,13 @@ public PatientTreatmentReport getPatientTreatmentReport(StudyViewFilter studyVie

@Override
public SampleTreatmentReport getSampleTreatmentReport(StudyViewFilter studyViewFilter) {
var sampleTreatments = studyViewRepository.getSampleTreatments(studyViewFilter);
var sampleTreatments = studyViewRepository.getSampleTreatments(studyViewFilter)
.stream()
.flatMap(sampleTreatment ->
Stream.of(new SampleTreatmentRow(TemporalRelation.Pre, sampleTreatment.treatment(), sampleTreatment.preSampleCount(), Set.of()),
new SampleTreatmentRow(TemporalRelation.Post, sampleTreatment.treatment(), sampleTreatment.postSampleCount(), Set.of() ))
)
.toList();
var totalSampleTreatmentCount = studyViewRepository.getTotalSampleTreatmentCount(studyViewFilter);
return new SampleTreatmentReport(totalSampleTreatmentCount, sampleTreatments);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.cbioportal.model.DensityPlotData;
import org.cbioportal.model.GenomicDataCount;
import org.cbioportal.model.PatientTreatmentReport;
import org.cbioportal.model.PatientTreatmentRow;
import org.cbioportal.model.Sample;
import org.cbioportal.model.SampleTreatmentReport;
import org.cbioportal.service.ClinicalDataDensityPlotService;
Expand Down Expand Up @@ -397,8 +396,8 @@ public ResponseEntity<PatientTreatmentReport> fetchPatientTreatmentCounts(
@PreAuthorize("hasPermission(#involvedCancerStudies, 'Collection<CancerStudyId>', T(org.cbioportal.utils.security.AccessLevel).READ)")
@PostMapping(value = "/column-store/treatments/sample-counts/fetch", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiResponse(responseCode = "200", description = "OK",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = PatientTreatmentRow.class))))
public ResponseEntity<SampleTreatmentReport> getSampleTreatmentCounts(
content = @Content(schema = @Schema(implementation = SampleTreatmentReport.class)))
public ResponseEntity<SampleTreatmentReport> fetchSampleTreatmentCounts(
@Parameter(required = false )
@RequestParam(name = "tier", required = false, defaultValue = "Agent")
ClinicalEventKeyCode tier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,11 +502,11 @@
</sql>

<sql id="applyStudyViewFilterUsingSampleId">
sample_unique_id IN ( <include refid="sampleUniqueIdsFromStudyViewFilter"/>)
<if test="applyPatientIdFilters == true">
INTERSECT
<include refid="getSampleIdsFromPatientIds"/>
</if>
sample_unique_id IN (<include refid="sampleUniqueIdsFromStudyViewFilter"/>
<if test="applyPatientIdFilters == true">
INTERSECT <include refid="getSampleIdsFromPatientIds"/>
</if>
)
</sql>

<sql id="getSampleIdsFromPatientIds">
Expand Down

0 comments on commit d62c6e5

Please sign in to comment.