Merge pull request #558 from OHDSI/fix-557

Documentation fix for cdm_source example sql
This commit is contained in:
clairblacketer 2023-05-01 13:40:05 -04:00 committed by GitHub
commit 77831c5326
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 146 additions and 79 deletions

View File

@ -11,9 +11,9 @@
<title>sqlScripts.knit</title>
<title>SQL Scripts</title>
<script src="site_libs/header-attrs-2.16/header-attrs.js"></script>
<script src="site_libs/header-attrs-2.21/header-attrs.js"></script>
<script src="site_libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="site_libs/bootstrap-3.3.5/css/cosmo.min.css" rel="stylesheet" />
@ -35,8 +35,8 @@
<script src="site_libs/navigation-1.1/tabsets.js"></script>
<link href="site_libs/highlightjs-9.12.0/default.css" rel="stylesheet" />
<script src="site_libs/highlightjs-9.12.0/highlight.js"></script>
<link href="site_libs/font-awesome-5.1.0/css/all.css" rel="stylesheet" />
<link href="site_libs/font-awesome-5.1.0/css/v4-shims.css" rel="stylesheet" />
<link href="site_libs/font-awesome-6.2.1/css/all.min.css" rel="stylesheet" />
<link href="site_libs/font-awesome-6.2.1/css/v4-shims.min.css" rel="stylesheet" />
<link rel='shortcut icon' type='image/x-icon' href='favicon.ico' />
<style type="text/css">
@ -185,8 +185,8 @@ $(document).ready(function () {
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before {
content: "";
.tabset-dropdown > .nav-tabs > li.active:before, .tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "\e259";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
@ -194,16 +194,9 @@ $(document).ready(function () {
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "&#xe258;";
border: none;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "";
content: "\e258";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
border: none;
}
.tabset-dropdown > .nav-tabs > li.active {
@ -402,6 +395,9 @@ div.tocify {
<li>
<a href="cdm54Changes.html">Changes from CDM v5.3</a>
</li>
<li>
<a href="cdm54erd.html">Entity Relationships</a>
</li>
</ul>
</li>
</ul>
@ -908,35 +904,69 @@ SELECT * FROM #tmp_de;</code></pre>
<p>The script below is an example for how to fill in the CDM_SOURCE
table. This table is required for the <a
href="https://github.com/OHDSI/DataQualityDashboard">Data Quality
Dashboard</a> package to run. This was taken from the <a
Dashboard</a> package to run.</p>
<div id="v5.3" class="section level4">
<h4>v5.3</h4>
<p>This example was taken from the <a
href="https://github.com/OHDSI/ETL-Synthea">ETL-Synthea</a> package, a
good example on how to write a complete extract-transform-load script
from start to finish, including vocabulary import.</p>
<pre class="sql"><code>insert into @cdm_schema.cdm_source (
cdm_source_name,
cdm_source_abbreviation,
cdm_holder,
source_description,
source_documentation_reference,
cdm_etl_reference,
source_release_date,
cdm_release_date,
cdm_version,
vocabulary_version
<pre class="sql"><code>INSERT INTO @cdm_schema.cdm_source (
cdm_source_name,
cdm_source_abbreviation,
cdm_holder,
source_description,
source_documentation_reference,
cdm_etl_reference,
source_release_date,
cdm_release_date,
cdm_version,
vocabulary_version
)
select
&#39;Synthea synthetic health database&#39;,
&#39;Synthea&#39;,
&#39;OHDSI Community&#39;,
&#39;SyntheaTM is a Synthetic Patient Population Simulator. The goal is to output synthetic, realistic (but not real), patient data and associated health records in a variety of formats.&#39;,
&#39;https://synthetichealth.github.io/synthea/&#39;,
&#39;https://github.com/OHDSI/ETL-Synthea&#39;,
getdate(), -- NB: Set this value to the day the source data was pulled
getdate(),
&#39;v5.3&#39;,
vocabulary_version
from @cdm_schema.vocabulary
where vocabulary_id = &#39;None&#39;;</code></pre>
SELECT
&#39;Synthea synthetic health database&#39;,
&#39;Synthea&#39;,
&#39;OHDSI Community&#39;,
&#39;SyntheaTM is a Synthetic Patient Population Simulator. The goal is to output synthetic, realistic (but not real), patient data and associated health records in a variety of formats.&#39;,
&#39;https://synthetichealth.github.io/synthea/&#39;,
&#39;https://github.com/OHDSI/ETL-Synthea&#39;,
getdate(), -- NB: Set this value to the day the source data was pulled
getdate(),
&#39;v5.3&#39;,
vocabulary_version
FROM @cdm_schema.vocabulary
WHERE vocabulary_id = &#39;None&#39;;</code></pre>
</div>
<div id="v5.4" class="section level4">
<h4>v5.4</h4>
<pre class="sql"><code>INSERT INTO @cdm_schema.cdm_source (
cdm_source_name,
cdm_source_abbreviation,
cdm_holder,
source_description,
source_documentation_reference,
cdm_etl_reference,
source_release_date,
cdm_release_date,
cdm_version,
vocabulary_version,
vocabulary_version_concept_id
)
SELECT
&#39;&lt;your_cdm_source_name&gt;&#39;,
&#39;&lt;your_cdm_source_abbreviation&gt;&#39;,
&#39;&lt;your_cdm_holder&gt;&#39;,
&#39;&lt;your_source_description&gt;&#39;,
&#39;&lt;your_source_documentation_reference&gt;&#39;, -- e.g. link to source data dictionary
&#39;&lt;your_etl_reference&gt;&#39;, -- e.g. link to ETL documentation
&#39;&lt;your_source_release_date&gt;&#39;, -- when the source data was pulled
getdate(), -- or the date of ETL run
&#39;v5.4&#39;,
vocabulary_version,
756265 -- &#39;OMOP CDM Version 5.4.0&#39;
FROM @cdm_schema.vocabulary
WHERE vocabulary_id = &#39;None&#39;;</code></pre>
</div>
</div>
</div>
<div id="bonus-queries" class="section level2">
@ -955,11 +985,11 @@ Details. For more information on how this can be done, please see the <a
href="https://ohdsi.github.io/ETL-LambdaBuilder/Optum%20Clinformatics/Optum_visit_occurrence.html">Optum
Extended ETL documentation</a>.</p>
<pre class="sql"><code>SELECT concept_id, concept_name
FROM concept
LEFT JOIN concept_ancestor
FROM concept
LEFT JOIN concept_ancestor
ON concept_id=descendant_concept_id
AND ancestor_concept_id!=descendant_concept_id
WHERE domain_id=&#39;Visit&#39;
WHERE domain_id=&#39;Visit&#39;
AND standard_concept=&#39;S&#39;
AND ancestor_concept_id IS NULL</code></pre>
</div>

View File

@ -1,4 +1,5 @@
---
title: 'SQL Scripts'
output:
html_document:
toc: TRUE
@ -404,34 +405,70 @@ SELECT * FROM #tmp_de;
### CDM_SOURCE Table
The script below is an example for how to fill in the CDM_SOURCE table. This table is required for the [Data Quality Dashboard](https://github.com/OHDSI/DataQualityDashboard) package to run. This was taken from the [ETL-Synthea](https://github.com/OHDSI/ETL-Synthea) package, a good example on how to write a complete extract-transform-load script from start to finish, including vocabulary import.
The script below is an example for how to fill in the CDM_SOURCE table.
This table is required for the [Data Quality Dashboard](https://github.com/OHDSI/DataQualityDashboard) package to run.
#### v5.3
This example was taken from the [ETL-Synthea](https://github.com/OHDSI/ETL-Synthea) package,
a good example on how to write a complete extract-transform-load script from start to finish, including vocabulary import.
```{sql eval = FALSE, echo = TRUE}
insert into @cdm_schema.cdm_source (
cdm_source_name,
cdm_source_abbreviation,
cdm_holder,
source_description,
source_documentation_reference,
cdm_etl_reference,
source_release_date,
cdm_release_date,
cdm_version,
vocabulary_version
INSERT INTO @cdm_schema.cdm_source (
cdm_source_name,
cdm_source_abbreviation,
cdm_holder,
source_description,
source_documentation_reference,
cdm_etl_reference,
source_release_date,
cdm_release_date,
cdm_version,
vocabulary_version
)
select
'Synthea synthetic health database',
'Synthea',
'OHDSI Community',
'SyntheaTM is a Synthetic Patient Population Simulator. The goal is to output synthetic, realistic (but not real), patient data and associated health records in a variety of formats.',
'https://synthetichealth.github.io/synthea/',
'https://github.com/OHDSI/ETL-Synthea',
getdate(), -- NB: Set this value to the day the source data was pulled
getdate(),
'v5.3',
vocabulary_version
from @cdm_schema.vocabulary
where vocabulary_id = 'None';
SELECT
'Synthea synthetic health database',
'Synthea',
'OHDSI Community',
'SyntheaTM is a Synthetic Patient Population Simulator. The goal is to output synthetic, realistic (but not real), patient data and associated health records in a variety of formats.',
'https://synthetichealth.github.io/synthea/',
'https://github.com/OHDSI/ETL-Synthea',
getdate(), -- NB: Set this value to the day the source data was pulled
getdate(),
'v5.3',
vocabulary_version
FROM @cdm_schema.vocabulary
WHERE vocabulary_id = 'None';
```
#### v5.4
```{sql eval = FALSE, echo = TRUE}
INSERT INTO @cdm_schema.cdm_source (
cdm_source_name,
cdm_source_abbreviation,
cdm_holder,
source_description,
source_documentation_reference,
cdm_etl_reference,
source_release_date,
cdm_release_date,
cdm_version,
vocabulary_version,
vocabulary_version_concept_id
)
SELECT
'<your_cdm_source_name>',
'<your_cdm_source_abbreviation>',
'<your_cdm_holder>',
'<your_source_description>',
'<your_source_documentation_reference>', -- e.g. link to source data dictionary
'<your_etl_reference>', -- e.g. link to ETL documentation
'<your_source_release_date>', -- when the source data was pulled
getdate(), -- or the date of ETL run
'v5.4',
vocabulary_version,
756265 -- 'OMOP CDM Version 5.4.0'
FROM @cdm_schema.vocabulary
WHERE vocabulary_id = 'None';
```
## **Bonus Queries**
@ -442,11 +479,11 @@ The query below will utilize the Visit Concept hierarcy to find the highest-leve
```{sql eval=FALSE, echo=TRUE}
SELECT concept_id, concept_name
FROM concept
LEFT JOIN concept_ancestor
FROM concept
LEFT JOIN concept_ancestor
ON concept_id=descendant_concept_id
AND ancestor_concept_id!=descendant_concept_id
WHERE domain_id='Visit'
WHERE domain_id='Visit'
AND standard_concept='S'
AND ancestor_concept_id IS NULL
```