Skip to content

Commit

Permalink
deleted 'condition' procedure from loader. Deleted corresponding dele…
Browse files Browse the repository at this point in the history
…te from and execute lines from run script.
  • Loading branch information
matthewjoss committed Jan 18, 2017
1 parent 6db76a4 commit a9f3dd7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 46 deletions.
43 changes: 1 addition & 42 deletions MSSQL/OMOPLoader.sql
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ go
-- new: removed factline cache
-- now ignores facts with a condition modifier
-- 6.1. optimized for temp tables
-- + 3a. Condition, combined within this procedure.
----------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'OMOPdiagnosis') AND type in (N'P', N'PC')) DROP PROCEDURE OMOPdiagnosis
go
Expand Down Expand Up @@ -482,48 +483,6 @@ where (diag.c_fullname not like '\PCORI\DIAGNOSIS\10\%' or
end
go

----------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------
-- 3a. Condition - v6.1 by Jeff Klann, derived from Diagnosis above
-- Notes: in the current version condition_status is imputed from resolve_date (which is derived from end_date)
-- and onset_date is not supported
----------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'OMOPcondition') AND type in (N'P', N'PC')) DROP PROCEDURE OMOPcondition
go

create procedure OMOPcondition as
declare @sqltext nvarchar(4000)
begin

-- Optimized to use a temp table; also removed "distinct" 12/9/15
-- TODO: Could be further optimized to use the same temp table as diagnosis
select patient_num, encounter_num, provider_id, concept_cd, start_date, dxsource.pcori_basecode dxsource, dxsource.c_fullname
into #sourcefact from i2b2fact factline
inner join OMOPencounter enc on enc.patid = factline.patient_num and enc.encounterid = factline.encounter_Num
inner join pcornet_diag dxsource on factline.modifier_cd =dxsource.c_basecode
where dxsource.c_fullname like '\PCORI_MOD\CONDITION_OR_DX\%'

insert into condition_occurrence (person_id, condition_occurrence_id, condition_start_date, condition_end_date, condition_concept_id, condition_type_concept_id, condition_source_value, condition_source_concept_id) --(patid, encounterid, report_date, resolve_date, condition, condition_type, condition_status, condition_source)
select distinct factline.patient_num, min(factline.encounter_num) encounterid, min(factline.start_date) report_date, isnull(max(factline.end_date),null) resolve_date,
substring(diag.omop_basecode,charindex(':',diag.omop_basecode)+1,10), -- jgk bugfix 10/3
substring(diag.c_fullname,18,2) condition_type,
case max(factline.end_date) when null then 'NI' else 'RS' end condition_status, -- Imputed so might not be entirely accurate
isnull(substring(max(dxsource),charindex(':',max(dxsource))+1,2),'NI') condition_source
from i2b2fact factline
inner join pmnENCOUNTER enc on enc.patid = factline.patient_num and enc.encounterid = factline.encounter_Num
inner join pcornet_diag diag on diag.c_basecode = factline.concept_cd
left outer join #sourcefact sf
on factline.patient_num=sf.patient_num
and factline.encounter_num=sf.encounter_num
and factline.provider_id=sf.provider_id
and factline.concept_cd=sf.concept_Cd
and factline.start_date=sf.start_Date
where diag.c_fullname like '\PCORI\DIAGNOSIS\%'
and sf.c_fullname like '\PCORI_MOD\CONDITION_OR_DX\CONDITION_SOURCE\%'
group by factline.patient_num, diag.omop_basecode, diag.c_fullname
end
go

----------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------
-- 4. Procedures - v6 by Aaron Abend and Jeff Klann
Expand Down
4 changes: 0 additions & 4 deletions MSSQL/run.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ delete from condition_occurrence
GO
exec OMOPdiagnosis
GO
delete from pmncondition
GO
exec PCORNetCondition
GO
delete from pmnprocedure
GO
exec PCORNetProcedure
Expand Down

0 comments on commit a9f3dd7

Please sign in to comment.