Skip to content

Commit

Permalink
DIXON-3 => R21 project: get back heel into WebAPI/Atlas. (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
chen-regen authored and anthonysena committed Jun 19, 2017
1 parent 70b536b commit b3e8639
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions src/main/java/org/ohdsi/webapi/service/CohortResultsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.ohdsi.webapi.cohortanalysis.CohortAnalysis;
import org.ohdsi.webapi.cohortanalysis.CohortAnalysisTask;
import org.ohdsi.webapi.cohortanalysis.CohortSummary;
import org.ohdsi.webapi.cohortresults.CohortAttribute;
import org.ohdsi.webapi.cohortresults.CohortBreakdown;
import org.ohdsi.webapi.cohortresults.CohortConditionDrilldown;
import org.ohdsi.webapi.cohortresults.CohortConditionEraDrilldown;
Expand Down Expand Up @@ -1564,6 +1565,37 @@ public List<PredictorResult> getExposureOutcomeCohortPredictors(@PathParam("sour
return results;
}

/**
* Returns heracles heel results (data quality issues) for the given cohort
* definition id
*
* @param id cohort definition id
* @return List<CohortAttribute>
*/
@GET
@Path("{sourceKey}/{id}/heraclesheel")
@Produces(MediaType.APPLICATION_JSON)
public List<CohortAttribute> getHeraclesHeel(@PathParam("id") final int id,
@PathParam("sourceKey") final String sourceKey,
@DefaultValue("false") @QueryParam("refresh") boolean refresh) {
List<CohortAttribute> attrs = new ArrayList<CohortAttribute>();
Source source = getSourceRepository().findBySourceKey(sourceKey);
final String key = CohortResultsAnalysisRunner.HERACLES_HEEL;
VisualizationData data = refresh ? null : this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(id, source.getSourceId(), key);

if (refresh || data == null) {
attrs = this.queryRunner.getHeraclesHeel(this.getSourceJdbcTemplate(source), id, source, true);
} else {
try {
attrs = mapper.readValue(data.getData(), new TypeReference<List<CohortAttribute>>(){});
} catch (Exception e) {
log.error(e);
}
}

return attrs;
}

private String JoinArray(final String[] array) {
String result = "";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select analysis_id as ATTRIBUTE_NAME, HERACLES_HEEL_warning as ATTRIBUTE_VALUE
from HERACLES_HEEL_results
from @ohdsi_database_schema.HERACLES_HEEL_results
where cohort_definition_id in (@cohortDefinitionId)
order by case when left(HERACLES_HEEL_warning,5) = 'Error' then 1 else 2 end, analysis_id

0 comments on commit b3e8639

Please sign in to comment.