Skip to content

Commit

Permalink
Update OMOPLoader.sql
Browse files Browse the repository at this point in the history
Typos in obs_period
  • Loading branch information
jklann committed Jan 10, 2018
1 parent 4c86be0 commit 79e5164
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions MSSQL/OMOPLoader.sql
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,11 @@ GO
create procedure OMOPObservationPeriod as
begin

INSERT INTO [Observation_Period]([person_id], [observation_perioid_start_date], [observation_period_end_date], [period_type_concept_id] )
INSERT INTO [Observation_Period]([person_id], [observation_period_start_date], [observation_period_end_date], [period_type_concept_id] )
select x.patient_num patid, case when l.patient_num is not null then l.period_start else enr_start end enr_start_date
, case when l.patient_num is not null then l.period_end when enr_end_end>enr_end then enr_end_end else enr_end end enr_end_date
, case when l.patient_num is not null then 44814725 else 44814724 end enr_basis from
(select patient_num, min(start_date) enr_start,max(start_date) enr_end,max(end_date) enr_end_end from i2b2visit where patient_num in (select patid from pmndemographic) group by patient_num) x
(select patient_num, min(start_date) enr_start,max(start_date) enr_end,max(end_date) enr_end_end from i2b2visit where patient_num in (select person_id from person) group by patient_num) x
left outer join i2b2loyalty_patients l on l.patient_num=x.patient_num

end
Expand Down

0 comments on commit 79e5164

Please sign in to comment.