From 1d151f83d68a8f2d8bd7c0fd559032b0a3bb3a9d Mon Sep 17 00:00:00 2001 From: bbimber Date: Fri, 23 Jul 2021 09:46:55 -0700 Subject: [PATCH] Update EHR MHC query to point to new aggregated data --- .../sequenceanalysis/MHC_Data_Unified.sql | 60 +++---------------- 1 file changed, 7 insertions(+), 53 deletions(-) diff --git a/onprc_reports/resources/queries/sequenceanalysis/MHC_Data_Unified.sql b/onprc_reports/resources/queries/sequenceanalysis/MHC_Data_Unified.sql index 623d4dc06..61902e571 100644 --- a/onprc_reports/resources/queries/sequenceanalysis/MHC_Data_Unified.sql +++ b/onprc_reports/resources/queries/sequenceanalysis/MHC_Data_Unified.sql @@ -1,57 +1,11 @@ SELECT - s.subjectId as Id, - s.allele, - --s.primerPairs, - s.shortName, - s.totalRecords as testsPerformed, - s.status as result, - cast('SSP' as varchar) as type -FROM assay.SSP_assay.SSP.SSP_Summary s -WHERE s.subjectId is not null - -UNION ALL - -SELECT - a.subjectId as Id, - a.marker as allele, + t.subjectId as Id, + t.marker as allele, null as shortName, - count(*) as totalTests, - cast('POS' as varchar) as result, - cast('SBT' as varchar) as type - -FROM assay.GenotypeAssay.Genotype.Data a -WHERE a.run.assayType = 'SBT' -GROUP BY a.subjectid, a.marker - -UNION ALL - -SELECT - DISTINCT s.subjectId as Id, - p.ref_nt_name as allele, - null as shortName, - 1 as totalTests, - cast('NEG' as varchar) as result, - cast('SBT' as varchar) as type - ---we want any IDs with SBT data, but lacking data for these special-cased markers -FROM genotypeassays.primer_pairs p -FULL JOIN (SELECT DISTINCT subjectId FROM assay.GenotypeAssay.Genotype.Data s WHERE s.run.assayType = 'SBT') s ON (1=1) -LEFT JOIN assay.GenotypeAssay.Genotype.Data a ON (a.run.assayType = 'SBT' AND p.ref_nt_name = a.marker AND a.subjectid = s.subjectid) -WHERE a.rowid IS NULL AND (p.ref_nt_name LIKE 'Mamu-A%' OR p.ref_nt_name LIKE 'Mamu-B%') + sum(t.totalTests) as totalTests, + t.result, + GROUP_CONCAT(distinct t.assaytype) as type --- NOTE: eventually this will be the only source of data. However, disable for now so that we can populate this --- table on the production server without polluting the results people see. --- UNION ALL --- --- SELECT --- --- t.subjectId as Id, --- t.marker as allele, --- null as shortName, --- count(*) as totalTests, --- t.result, --- GROUP_CONCAT(distinct t.assaytype) as type --- --- FROM geneticscore.mhc_data t --- GROUP BY t.subjectid, t.marker, t.result \ No newline at end of file +FROM geneticscore.mhc_data t +GROUP BY t.subjectid, t.marker, t.result