forked from Jimyung6642/CDM_v5.3.1_to_v6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPERSON.sql
49 lines (46 loc) · 1.18 KB
/
PERSON.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
select
person_id,
gender_concept_id,
year_of_birth,
month_of_birth,
day_of_birth,
convert(datetime, year_of_birth) as birth_datetime,
convert(datetime, NULL) as death_datetime,
race_concept_id,
ethnicity_concept_id,
location_id,
provider_id,
care_site_id,
person_source_value,
gender_source_value,
gender_source_concept_id,
race_source_value,
race_source_concept_id,
ethnicity_source_value,
ethnicity_source_concept_id
into @DatabaseSchemaCDMVersion6.person
from @DatabaseSchemaCDMVersion5.PERSON
where person_id not in (select person_id from @DatabaseSchemaCDMVersion5.DEATH)
Insert into @DatabaseSchemaCDMVersion6.dbo.person
select
a.person_id,
gender_concept_id,
year_of_birth,
month_of_birth,
day_of_birth,
convert(datetime, year_of_birth) as birth_datetime,
convert(datetime, death_date) as death_datetime,
race_concept_id,
ethnicity_concept_id,
location_id,
provider_id,
care_site_id,
person_source_value,
gender_source_value,
gender_source_concept_id,
race_source_value,
race_source_concept_id,
ethnicity_source_value,
ethnicity_source_concept_id
from @DatabaseSchemaCDMVersion5.PERSON a, @DatabaseSchemaCDMVersion5.DEATH b
where a.person_id=b.person_id