EHDEN / CdmInspection

R Package to support quality control inspection of an OMOP-CDM instance
Apache License 2.0
11 stars 16 forks source link

Executing sql server check mapping_completeness.sql fails when all values in the column value_as_concept_id are NULL #102

Closed PieterMaertens closed 7 months ago

PieterMaertens commented 1 year ago

When executing the sql server check mapping_completeness.sql inside the R function cdmInspection I get following error: No column name was specified for column 1 of 'T'. The observation table I use does have a lot of records but the column "value_as_concept_id" is always NULL.

select 'Observation value', count_big(*),
      sum(is_mapped),
      100.0*sum(is_mapped) / count_big(*),
      sum(num_records),
      sum(case when is_mapped > 0 then num_records else 0 end),
      100.0*sum(case when is_mapped > 0 then num_records else 0 end)/sum(num_records)
from
(
   select '', case when value_as_concept_id > 0 then 1 else 0 end as is_mapped, count_big(*) as num_records
   from @cdmDatabaseSchema.observation
   where value_as_concept_id IS NOT NULL
   group by case when value_as_concept_id > 0 then 1 else 0 end
) T
sampo-tays commented 12 months ago

For me, this analysis also fails even though the column "value_as_concept_id" is not NULL. Not sure if relevant, but the 'Observation value' section differs from all other analyses in mapping_completeness.sql in a couple of ways: '' instead of field name (observation_source_value?), and "observation_source_value" not included in the group by statement.