Search in sources :

Example 1 with ChartInfo

use of org.pmiops.workbench.model.ChartInfo in project workbench by all-of-us.

the class CohortBuilderController method getChartInfo.

@Override
public ResponseEntity<ChartInfoListResponse> getChartInfo(Long cdrVersionId, SearchRequest request) {
    CdrVersionContext.setCdrVersion(cdrVersionDao.findOne(cdrVersionId));
    ChartInfoListResponse response = new ChartInfoListResponse();
    QueryJobConfiguration qjc = bigQueryService.filterBigQueryConfig(participantCounter.buildChartInfoCounterQuery(new ParticipantCriteria(request)));
    QueryResult result = bigQueryService.executeQuery(qjc);
    Map<String, Integer> rm = bigQueryService.getResultMapper(result);
    for (List<FieldValue> row : result.iterateAll()) {
        response.addItemsItem(new ChartInfo().gender(bigQueryService.getString(row, rm.get("gender"))).race(bigQueryService.getString(row, rm.get("race"))).ageRange(bigQueryService.getString(row, rm.get("ageRange"))).count(bigQueryService.getLong(row, rm.get("count"))));
    }
    return ResponseEntity.ok(response);
}
Also used : ChartInfo(org.pmiops.workbench.model.ChartInfo) QueryResult(com.google.cloud.bigquery.QueryResult) ChartInfoListResponse(org.pmiops.workbench.model.ChartInfoListResponse) ParticipantCriteria(org.pmiops.workbench.cohortbuilder.ParticipantCriteria) FieldValue(com.google.cloud.bigquery.FieldValue) QueryJobConfiguration(com.google.cloud.bigquery.QueryJobConfiguration)

Aggregations

FieldValue (com.google.cloud.bigquery.FieldValue)1 QueryJobConfiguration (com.google.cloud.bigquery.QueryJobConfiguration)1 QueryResult (com.google.cloud.bigquery.QueryResult)1 ParticipantCriteria (org.pmiops.workbench.cohortbuilder.ParticipantCriteria)1 ChartInfo (org.pmiops.workbench.model.ChartInfo)1 ChartInfoListResponse (org.pmiops.workbench.model.ChartInfoListResponse)1