This was my process after finding treemap.sql
script
ORIGINAL QUERY FROM TREEMAP
SELECT
concept_hierarchy.concept_id,
CONCAT(
isNull(concept_hierarchy.level4_concept_name, 'NA'), '||',
isNull(concept_hierarchy.level3_concept_name, 'NA'), '||',
isNull(concept_hierarchy.level2_concept_name, 'NA'), '||',
isNull(concept_hierarchy.level2_concept_name, 'NA'), '||',
isNull(concept_hierarchy.concept_name, 'NA')
) AS concept_path,
ar1.count_value AS num_persons,
round(1.0 * ar1.count_value / denom.count_value, 5) AS percent_persons,
round(1.0 * ar2.count_value / ar1.count_value, 5) AS records_per_person
FROM (SELECT *
FROM @results_database_schema.achilles_results WHERE analysis_id = 400) ar1
INNER JOIN
(SELECT *
FROM @results_database_schema.achilles_results WHERE analysis_id = 401) ar2
ON ar1.stratum_1 = ar2.stratum_1
INNER JOIN
@results_database_schema.concept_hierarchy concept_hierarchy
ON CAST(CASE WHEN ar1.analysis_id = 400 THEN ar1.stratum_1 ELSE null END AS INT) = concept_hierarchy.concept_id
AND concept_hierarchy.treemap='Condition'
,
(SELECT count_value
FROM @results_database_schema.achilles_results WHERE analysis_id = 1) denom
ORDER BY ar1.count_value DESC
Translated with Sqlrender online using postgresql dialect and substitute the ohdsi sql parameter with the value omop_cdm_results
SELECT
concept_hierarchy.concept_id,
CONCAT(
COALESCE(concept_hierarchy.level4_concept_name,'NA'), '||',
COALESCE(concept_hierarchy.level3_concept_name,'NA'), '||',
COALESCE(concept_hierarchy.level2_concept_name,'NA'), '||',
COALESCE(concept_hierarchy.level2_concept_name,'NA'), '||',
COALESCE(concept_hierarchy.concept_name,'NA')
) AS concept_path,
ar1.count_value AS num_persons,
ROUND(CAST(1.0 * ar1.count_value / denom.count_value AS NUMERIC),5) AS percent_persons,
ROUND(CAST(1.0 * ar2.count_value / ar1.count_value AS NUMERIC),5) AS records_per_person
FROM (SELECT *
FROM omop_cdm_results.achilles_results WHERE analysis_id = 400) ar1
INNER JOIN
(SELECT *
FROM omop_cdm_results.achilles_results WHERE analysis_id = 401) ar2
ON ar1.stratum_1 = ar2.stratum_1
INNER JOIN
omop_cdm_results.concept_hierarchy concept_hierarchy
ON CAST(CASE WHEN ar1.analysis_id = 400 THEN ar1.stratum_1 ELSE null END AS INT) = concept_hierarchy.concept_id
AND concept_hierarchy.treemap='Condition'
,
(SELECT count_value
FROM omop_cdm_results.achilles_results WHERE analysis_id = 1) denom
ORDER BY ar1.count_value DESC
After executing it,
i got a table with 12 rows filled up of concepts, num_persons
column, percentage and records per person. Although this WebAPI endpoint /WebAPI/cdmresults/{resource}/condition
still remains returning empty set.
I have checked code execution trace and it leads to me the most probably issue is table qualifiers
are wrong.
So I decided to check the table qualifiers
looking this WebAPI endpoint /WebAPI/source/connection/{source}
Could you see any issue in my table qualifiers
?
@Chris_Knoll Thank you in advance.