-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #765 from OHDSI/location_export
Location table export to ares
- Loading branch information
Showing
6 changed files
with
101 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
-- 1101 Number of persons by location state | ||
|
||
--HINT DISTRIBUTE_ON_KEY(stratum_1) | ||
select 1101 as analysis_id, | ||
CAST(l1.state AS VARCHAR(255)) as stratum_1, | ||
cast(null as varchar(255)) as stratum_2, cast(null as varchar(255)) as stratum_3, cast(null as varchar(255)) as stratum_4, cast(null as varchar(255)) as stratum_5, | ||
COUNT_BIG(distinct person_id) as count_value | ||
into @scratchDatabaseSchema@schemaDelim@tempAchillesPrefix_1101 | ||
from @cdmDatabaseSchema.person p1 | ||
inner join @cdmDatabaseSchema.location l1 | ||
on p1.location_id = l1.location_id | ||
where p1.location_id is not null | ||
and l1.state is not null | ||
group by l1.state; | ||
SELECT | ||
1101 AS analysis_id, | ||
CAST(l1.state AS VARCHAR(255)) AS stratum_1, | ||
CAST(l1.location_id AS VARCHAR(255)) AS stratum_2, | ||
CAST(NULL AS VARCHAR(255)) AS stratum_3, | ||
CAST(NULL AS VARCHAR(255)) AS stratum_4, | ||
CAST(NULL AS VARCHAR(255)) AS stratum_5, | ||
COUNT_BIG(DISTINCT p1.person_id) AS count_value | ||
INTO @scratchDatabaseSchema@schemaDelim@tempAchillesPrefix_1101 | ||
FROM @cdmDatabaseSchema.person p1 | ||
INNER JOIN @cdmDatabaseSchema.location l1 | ||
ON p1.location_id = l1.location_id | ||
WHERE p1.location_id IS NOT NULL | ||
AND l1.state IS NOT NULL | ||
GROUP BY l1.state, l1.location_id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
-- 1103 Number of care sites by location state | ||
|
||
--HINT DISTRIBUTE_ON_KEY(stratum_1) | ||
select 1103 as analysis_id, | ||
CAST(l1.state AS VARCHAR(255)) as stratum_1, | ||
cast(null as varchar(255)) as stratum_2, cast(null as varchar(255)) as stratum_3, cast(null as varchar(255)) as stratum_4, cast(null as varchar(255)) as stratum_5, | ||
COUNT_BIG(distinct care_site_id) as count_value | ||
into @scratchDatabaseSchema@schemaDelim@tempAchillesPrefix_1103 | ||
from @cdmDatabaseSchema.care_site cs1 | ||
inner join @cdmDatabaseSchema.location l1 | ||
on cs1.location_id = l1.location_id | ||
where cs1.location_id is not null | ||
and l1.state is not null | ||
group by l1.state; | ||
SELECT | ||
1103 AS analysis_id, | ||
CAST(l1.state AS VARCHAR(255)) AS stratum_1, | ||
CAST(cs1.location_id AS VARCHAR(255)) AS stratum_2, | ||
CAST(NULL AS VARCHAR(255)) AS stratum_3, | ||
CAST(NULL AS VARCHAR(255)) AS stratum_4, | ||
CAST(NULL AS VARCHAR(255)) AS stratum_5, | ||
COUNT_BIG(DISTINCT cs1.care_site_id) AS count_value | ||
INTO @scratchDatabaseSchema@schemaDelim@tempAchillesPrefix_1103 | ||
FROM @cdmDatabaseSchema.care_site cs1 | ||
INNER JOIN @cdmDatabaseSchema.location l1 | ||
ON cs1.location_id = l1.location_id | ||
WHERE cs1.location_id IS NOT NULL | ||
AND l1.state IS NOT NULL | ||
GROUP BY l1.state, cs1.location_id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
WITH denom AS ( | ||
SELECT | ||
count_value | ||
FROM | ||
@results_database_schema.achilles_results | ||
WHERE | ||
analysis_id = 1 | ||
) | ||
SELECT | ||
c.analysis_id AS analysis_id, | ||
c.stratum_1 AS location_name, | ||
c.stratum_2 AS location_id, | ||
c.count_value AS count_persons, | ||
1.0 * c.count_value / denom.count_value AS percent_persons | ||
FROM | ||
@results_database_schema.achilles_results c, | ||
denom | ||
WHERE | ||
c.analysis_id BETWEEN 1100 AND 1103; |