Skip to content

Commit

Permalink
Little Cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
jklann committed Oct 9, 2017
1 parent b2a2e43 commit b2715b3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions MSSQL/OMOPLoader.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------
-- OMOPLoader Script for OMOP v0.1
-- Contributors: Jeff Klann, PhD; Matthew Joss; Aaron Abend; Arturo Torres
-- Contributors: Jeff Klann, PhD; Matthew Joss; Aaron Abend; Arturo Torres; Kevin Embree; Griffin Weber, MD, PhD
-- Transforms i2b2 data mapped to the PCORnet ontology into OMOP format.
-- MSSQL version
--
Expand Down Expand Up @@ -105,10 +105,12 @@ CREATE FUNCTION unit_wt() RETURNS float(10) AS BEGIN
END
GO

----------------------------------------------------------------------------------------------------------------------------------------
-- Update the loyalty cohort filter set - you will need to point this to your local database name
-- This is optional, if you have not run the loyalty cohort it will create an empty view
-- Also set the loyalty cohort time period - this should be dynamic in a future update - right now it can be left alone
-- Filters selected (61511) include: Has age and sex, Has race, Lives in same state as hospital,Has data in the first and last 18 months,Has diagnoses,Is alive,Is not in the bottom 10% of fact count
----------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID('i2b2loyalty_patients')) DROP VIEW i2b2loyalty_patients
GO
DECLARE @SQL as varchar(4000)
Expand Down Expand Up @@ -178,7 +180,6 @@ INSERT INTO [dbo].[PMN_LabNormal]([LAB_NAME], [NORM_RANGE_LOW], [NORM_MODIFIER_L
GO



IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_NAME = 'xpk_condition_occurrence')
Alter table condition_occurrence DROP constraint xpk_condition_occurrence
Go
Expand Down Expand Up @@ -318,7 +319,7 @@ GO

----------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------
-- 1. Demographics
-- Demographics
----------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'OMOPdemographics') AND type in (N'P', N'PC')) DROP PROCEDURE OMOPdemographics
go
Expand Down Expand Up @@ -493,7 +494,7 @@ go

----------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------
-- 2. Encounter - by Jeff Klann and Aaron Abend and Matthew Joss
-- Encounter - by Jeff Klann and Aaron Abend and Matthew Joss
----------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'OMOPencounter') AND type in (N'P', N'PC'))
DROP PROCEDURE OMOPencounter
Expand Down Expand Up @@ -980,12 +981,12 @@ create procedure OMOPclear
as
begin

DELETE FROM person
DELETE FROM visit_occurrence
DELETE FROM condition_occurrence
DELETE FROM drug_exposure
DELETE FROM measurement
DELETE FROM procedure_occurrence
DELETE FROM visit_occurrence
DELETE FROM person

end
go
Expand Down

0 comments on commit b2715b3

Please sign in to comment.