Install and Run Atlas

Atlas Installation Overview

Installing Atlas consists of the following steps.

Install Prerequisites

More information regarding version details etc. for fhir-to-omop dependencies can be found on the Start Here page.
The following is required for Atlas.

Install Atlas Overview

The following steps are taken to install and run Atlas. Each of these steps are described in detail below.

Install Atlas

The following steps detail how to install Atlas after the initial prerequisites have been installed.

fhir-to-omop: Download and Configure the fhir-to-omop Standalone Application

Download the latest version of the fhir-to-omop.zip file from the releases page.

After unzipping this file you should see something similar to what is shown below.

The following parameters need to be set in the app.paramters file of the fhir-to-omop tool. Set these parameters as appropriate to your configuration.
# ---
# Atlas Stuff
# ---

# bootstrap connection for atlas postgres
postgresBootstrapUrl=jdbc:postgresql://localhost:5432
postgresBootstrapUid=postgres
postgresBootstrapPwd=stripedbass

# users for atlas postgres 
ohdsiAdminUserUid=ohdsi_admin_user
ohdsiAdminUserPwd=stripedbass
ohdsiAdminUid=ohdsi_admin
ohdsiAdminPwd=stripedbass
ohdsiAppUserUid=ohdsi_app_user
ohdsiAppUserPwd=stripedbass
ohdsiAppUid=ohdsi_app
ohdsiAppPwd=stripedbass

# atlas database name
ohdsiDbName=OHDSI
ohdsiDbOwner=ohdsi_admin

# atlas data source
atlasDataSourceName=Localhost CDM
atlasDataSourceKey=MY_CDM
atlasCdm=synthea_micro.dbo
atlasResults=synthea_micro_achilles_results.dbo
atlasTemp=synthea_micro_achilles_temp.dbo
atlasCdmUrl=jdbc:sqlserver://localhost:1433;encrypt=false;databaseName=synthea_micro;user=synthea_micro;password=Sneaker01

CDM: Create an OMOP/CDM instance

Prior to installing Atlas you will need to have an instance of the OMOP/CDM database up and running. If you do not already have this, the fhir-to-omop tools can be used to create an OMOP/CDM instance and populate it with data. This process is described here: The fhir-to-omop Standalone Application

PostgreSql Objects: Create PostgreSql and MS Sql Server Atlas Objects

A number of users, the OHDSI database, and the webapi schema need to be created in PostgreSql for the Atlas application. A number of databases and tables are also created in the MS SqlServer by this script that are required by Atlas. These database objects can be created by running the "fhir-to-omop atlas" tool. One of the scripts run by this proces is the script generated using the tool built into Atlas (as described in the "Results Schema Setup" section of the CDM Configuration document):
http://<server:port>/WebAPI/ddl/results?dialect=<your_cdm_database_dialect>&schema=<your_results_schema>&vocabSchema=<your_vocab_schema>&tempSchema=<your_temp_schema>&initConceptHierarchy=true 
This "fhir-to-omop atlas" tool can be run from the cmd line as shown below.


Full output from a run is shown below.
D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\fhir-to-omop\target\fhir-to-omop>fhir-to-omop.bat atlas


# ----------------------------------------
#
# running fhir to omop
#
# ----------------------------------------

Working Directory: D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\fhir-to-omop\target\fhir-to-omop
Welcome to fhir-to-omop
20:13:02,423 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
20:13:02,424 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
20:13:02,424 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/D:/_WORKSPACES/_ECLIPSE_WORKSPACE/workspace/fhir-to-omop/target/fhir-to-omop/fhir-to-omop.jar!/logback.xml]
20:13:02,424 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs multiple times on the classpath.
20:13:02,424 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/D:/_WORKSPACES/_ECLIPSE_WORKSPACE/workspace/fhir-to-omop/target/fhir-to-omop/fhir-to-omop.jar!/logback.xml]
20:13:02,424 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/D:/_WORKSPACES/_ECLIPSE_WORKSPACE/workspace/fhir-to-omop/target/fhir-to-omop/lib/thread-tool-0.0.2.jar!/logback.xml]
20:13:02,434 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@e45f292 - URL [jar:file:/D:/_WORKSPACES/_ECLIPSE_WORKSPACE/workspace/fhir-to-omop/target/fhir-to-omop/fhir-to-omop.jar!/logback.xml] is not of type file
20:13:02,503 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
20:13:02,503 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
20:13:02,507 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
20:13:02,510 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
20:13:02,538 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [ch.qos.logback] to ERROR
20:13:02,538 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [ca.uhn.fhir] to ERROR
20:13:02,538 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
20:13:02,538 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
20:13:02,538 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
20:13:02,539 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@5f2108b5 - Registering current configuration as safe fallback point

Getting config file from: D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\fhir-to-omop\target\fhir-to-omop
------------
app.properties:
D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\fhir-to-omop\target\fhir-to-omop\app.properties
Exists: true
InputStream: java.io.FileInputStream@1e397ed7
------------
2022-05-27 20:13:02,551 20:13:02.551 [main] INFO  (InstallAtlasDependencies.java:25) - Installing Atlas Dependencies...
2022-05-27 20:13:02,552 20:13:02.552 [main] INFO  (InstallAtlasDependencies.java:27) - Burning Atlas to the ground...
2022-05-27 20:13:02,553 20:13:02.553 [main] INFO  (BurnAtlasToTheGround.java:24) - Burning Atlas to the ground...
2022-05-27 20:13:02,553 20:13:02.553 [main] INFO  (PostgresDatabaseConnectionFactory.java:21) - Getting connection for url:
jdbc:postgresql://localhost:5433/postgres?user=postgres&password=stripedbass
2022-05-27 20:13:02,745 20:13:02.745 [main] INFO  (BurnAtlasToTheGround.java:29) - Dropping database...
2022-05-27 20:13:02,957 20:13:02.957 [main] INFO  (BurnAtlasToTheGround.java:33) - Dropping other postgres objects...
-- Role: ohdsi_admin
DROP ROLE IF EXISTS ohdsi_admin

-- Role: ohdsi_admin_user
DROP ROLE IF EXISTS ohdsi_admin_user

-- Role: ohdsi_app
DROP ROLE IF EXISTS ohdsi_app

-- Role: ohdsi_app_user
DROP ROLE IF EXISTS ohdsi_app_user

2022-05-27 20:13:02,962 20:13:02.962 [main] INFO  (BurnAtlasToTheGround.java:39) - Done burning Atlas to the ground.
2022-05-27 20:13:02,963 20:13:02.963 [main] INFO  (InstallAtlasDependencies.java:30) - Creating PostgreSql users for Atlas...
2022-05-27 20:13:02,963 20:13:02.963 [main] INFO  (PostgresDatabaseConnectionFactory.java:21) - Getting connection for url:
jdbc:postgresql://localhost:5433/postgres?user=postgres&password=stripedbass
2022-05-27 20:13:02,984 20:13:02.984 [main] INFO  (AtlasInstallInitPostgresCreateUsers.java:24) - getting sql script...
2022-05-27 20:13:02,984 20:13:02.984 [main] INFO  (AtlasInstallInitPostgresCreateUsers.java:26) - executing script...
-- * * *
--
-- sql script to initiate postgresql
--
-- * * *
-- Role: ohdsi_admin
DROP ROLE IF EXISTS ohdsi_admin

CREATE ROLE ohdsi_admin WITH
  LOGIN
  NOSUPERUSER
  INHERIT
  NOCREATEDB
  NOCREATEROLE
  NOREPLICATION
  PASSWORD 'stripedbass'

-- Role: ohdsi_admin_user
DROP ROLE IF EXISTS ohdsi_admin_user

CREATE ROLE ohdsi_admin_user WITH
  LOGIN
  SUPERUSER
  INHERIT
  CREATEDB
  CREATEROLE
  REPLICATION
  PASSWORD 'stripedbass'

-- Role: ohdsi_app
DROP ROLE IF EXISTS ohdsi_app

CREATE ROLE ohdsi_app WITH
  LOGIN
  NOSUPERUSER
  INHERIT
  NOCREATEDB
  NOCREATEROLE
  NOREPLICATION
  PASSWORD 'stripedbass'

-- Role: ohdsi_app_user
DROP ROLE IF EXISTS ohdsi_app_user

CREATE ROLE ohdsi_app_user WITH
  LOGIN
  NOSUPERUSER
  INHERIT
  NOCREATEDB
  NOCREATEROLE
  NOREPLICATION
  PASSWORD 'stripedbass'

GRANT ohdsi_app TO ohdsi_app_user

COMMENT ON ROLE ohdsi_app_user IS 'Application user account for OHDSI applications'

2022-05-27 20:13:02,993 20:13:02.993 [main] INFO  (AtlasInstallInitPostgresCreateUsers.java:28) - Done with init postgres users for Atlas.
2022-05-27 20:13:02,993 20:13:02.993 [main] INFO  (InstallAtlasDependencies.java:33) - Creating OHDSI database for Atlas...
2022-05-27 20:13:02,993 20:13:02.993 [main] INFO  (PostgresDatabaseConnectionFactory.java:21) - Getting connection for url:
jdbc:postgresql://localhost:5433/postgres?user=postgres&password=stripedbass
2022-05-27 20:13:03,124 20:13:03.124 [main] INFO  (AtlasInstallCreateDatabase.java:30) - getting sql string for drop...
2022-05-27 20:13:03,125 20:13:03.125 [main] INFO  (AtlasInstallCreateDatabase.java:32) - doing drop...
2022-05-27 20:13:03,126 20:13:03.126 [main] INFO  (AtlasInstallCreateDatabase.java:35) - getting sql string for create...
2022-05-27 20:13:03,126 20:13:03.126 [main] INFO  (AtlasInstallCreateDatabase.java:37) - creating database...
2022-05-27 20:13:03,577 20:13:03.577 [main] INFO  (AtlasInstallCreateDatabase.java:40) - getting sql string for create...
2022-05-27 20:13:03,577 20:13:03.577 [main] INFO  (AtlasInstallCreateDatabase.java:42) - doing updates for database...
2022-05-27 20:13:03,580 20:13:03.580 [main] INFO  (AtlasInstallCreateDatabase.java:45) - Done creating postgres database for Atlas.
2022-05-27 20:13:03,581 20:13:03.581 [main] INFO  (AtlasInstallCreateDatabase.java:46) - Done.
2022-05-27 20:13:03,581 20:13:03.581 [main] INFO  (InstallAtlasDependencies.java:36) - Creating schema for Atlas...
2022-05-27 20:13:03,581 20:13:03.581 [main] INFO  (PostgresDatabaseConnectionFactory.java:38) - Getting connection for url:
jdbc:postgresql://localhost:5433/OHDSI?user=postgres&password=stripedbass
2022-05-27 20:13:03,606 20:13:03.606 [main] INFO  (AtlasInstallCreateWebApiSchema.java:24) - getting sql script...
2022-05-27 20:13:03,607 20:13:03.607 [main] INFO  (AtlasInstallCreateWebApiSchema.java:26) - executing script...
DROP SCHEMA IF EXISTS webapi

CREATE SCHEMA IF NOT EXISTS webapi
    AUTHORIZATION ohdsi_admin

COMMENT ON SCHEMA webapi
    IS 'Schema containing tables to support WebAPI functionality'

GRANT USAGE ON SCHEMA webapi TO PUBLIC

GRANT ALL ON SCHEMA webapi TO ohdsi_admin

GRANT ALL ON SCHEMA webapi TO ohdsi_admin_user

GRANT USAGE ON SCHEMA webapi TO ohdsi_app

ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA webapi
GRANT ALL ON TABLES TO ohdsi_admin_user

ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA webapi
GRANT INSERT, SELECT, UPDATE, DELETE, REFERENCES, TRIGGER ON TABLES TO ohdsi_app

ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA webapi
GRANT USAGE, SELECT ON SEQUENCES TO ohdsi_app

ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA webapi
GRANT EXECUTE ON FUNCTIONS TO ohdsi_app

ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA webapi
GRANT USAGE ON TYPES TO ohdsi_app

2022-05-27 20:13:03,616 20:13:03.616 [main] INFO  (AtlasInstallCreateWebApiSchema.java:28) - Done creating webapi schema.
2022-05-27 20:13:03,616 20:13:03.616 [main] INFO  (AtlasInstallCreateWebApiSchema.java:29) - Done.
2022-05-27 20:13:03,616 20:13:03.616 [main] INFO  (InstallAtlasDependencies.java:38) - Done installing Atlas Postgres dependencies.
2022-05-27 20:13:03,617 20:13:03.617 [main] INFO  (CreateAtlasSqlServerDependencies.java:19) - Starting main...
2022-05-27 20:13:04,136 20:13:04.136 [main] INFO  (CreateAtlasSqlServerDependencies.java:38) -



------------------------------------------------
*
* INITIALIZING ACHILLES
*
------------------------------------------------



2022-05-27 20:13:04,144 20:13:04.144 [main] INFO  (CreateAtlasSqlServerDependencies.java:49) - EXECUTING SQL SCRIPT:
-----------------------------------------------

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort
(
        COHORT_DEFINITION_ID int NOT NULL,
        SUBJECT_ID bigint NOT NULL,
        cohort_start_date date NOT NULL,
        cohort_end_date date NOT NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_censor_stats;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_censor_stats', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_censor_stats(
  cohort_definition_id int NOT NULL,
  lost_count BIGINT NOT NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_inclusion;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_inclusion', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_inclusion(
  cohort_definition_id int NOT NULL,
  design_hash int NULL,
  rule_sequence int NOT NULL,
  name varchar(255) NULL,
  description varchar(1000) NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_inclusion_result;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_inclusion_result', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_inclusion_result(
  cohort_definition_id int NOT NULL,
  mode_id int NOT NULL,
  inclusion_rule_mask bigint NOT NULL,
  person_count bigint NOT NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_inclusion_stats;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_inclusion_stats', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_inclusion_stats(
  cohort_definition_id int NOT NULL,
  rule_sequence int NOT NULL,
  mode_id int NOT NULL,
  person_count bigint NOT NULL,
  gain_count bigint NOT NULL,
  person_total bigint NOT NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_summary_stats;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_summary_stats', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_summary_stats(
  cohort_definition_id int NOT NULL,
  mode_id int NOT NULL,
  base_count bigint NOT NULL,
  final_count bigint NOT NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_cache;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_cache', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_cache (
        design_hash int NOT NULL,
        SUBJECT_ID bigint NOT NULL,
        cohort_start_date date NOT NULL,
        cohort_end_date date NOT NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_censor_stats_cache;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_censor_stats_cache', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_censor_stats_cache (
  design_hash int NOT NULL,
  lost_count BIGINT NOT NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_inclusion_result_cache;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_inclusion_result_cache', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_inclusion_result_cache (
  design_hash int NOT NULL,
  mode_id int NOT NULL,
  inclusion_rule_mask bigint NOT NULL,
  person_count bigint NOT NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_inclusion_stats_cache;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_inclusion_stats_cache', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_inclusion_stats_cache (
  design_hash int NOT NULL,
  rule_sequence int NOT NULL,
  mode_id int NOT NULL,
  person_count bigint NOT NULL,
  gain_count bigint NOT NULL,
  person_total bigint NOT NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_summary_stats_cache;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_summary_stats_cache', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_summary_stats_cache (
  design_hash int NOT NULL,
  mode_id int NOT NULL,
  base_count bigint NOT NULL,
  final_count bigint NOT NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.feas_study_inclusion_stats;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.feas_study_inclusion_stats', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.feas_study_inclusion_stats(
  study_id int NOT NULL,
  rule_sequence int NOT NULL,
  name varchar(255) NOT NULL,
  person_count bigint NOT NULL,
  gain_count bigint NOT NULL,
  person_total bigint NOT NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.feas_study_index_stats;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.feas_study_index_stats', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.feas_study_index_stats(
  study_id int NOT NULL,
  person_count bigint NOT NULL,
  match_count bigint NOT NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.feas_study_result;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.feas_study_result', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.feas_study_result(
  study_id int NOT NULL,
  inclusion_rule_mask bigint NOT NULL,
  person_count bigint NOT NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.heracles_analysis;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.heracles_analysis', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.heracles_analysis
(
        analysis_id int,
        analysis_name varchar(255),
        stratum_1_name varchar(255),
        stratum_2_name varchar(255),
        stratum_3_name varchar(255),
        stratum_4_name varchar(255),
        stratum_5_name varchar(255),
        analysis_type varchar(255)
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.HERACLES_HEEL_results;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.HERACLES_HEEL_results', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.HERACLES_HEEL_results
(
  cohort_definition_id int,
  analysis_id INT,
  HERACLES_HEEL_warning VARCHAR(255)
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.heracles_results;
--HINT PARTITION(cohort_definition_id int)
--HINT BUCKET(analysis_id, 64)
IF OBJECT_ID('synthea_micro_achilles_results.dbo.heracles_results', 'U') IS NULL
create table synthea_micro_achilles_results.dbo.heracles_results
(
        cohort_definition_id int,
        analysis_id int,
        stratum_1 varchar(255),
        stratum_2 varchar(255),
        stratum_3 varchar(255),
        stratum_4 varchar(255),
        stratum_5 varchar(255),
        count_value bigint,
        last_update_time datetime DEFAULT GETDATE()
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.heracles_results_dist;
--HINT PARTITION(cohort_definition_id int)
--HINT BUCKET(analysis_id, 64)
IF OBJECT_ID('synthea_micro_achilles_results.dbo.heracles_results_dist', 'U') IS NULL
create table synthea_micro_achilles_results.dbo.heracles_results_dist
(
        cohort_definition_id int,
        analysis_id int,
        stratum_1 varchar(255),
        stratum_2 varchar(255),
        stratum_3 varchar(255),
        stratum_4 varchar(255),
        stratum_5 varchar(255),
        count_value bigint,
        min_value float,
        max_value float,
        avg_value float,
        stdev_value float,
        median_value float,
        p10_value float,
        p25_value float,
        p75_value float,
        p90_value float,
        last_update_time datetime DEFAULT GETDATE()
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.heracles_periods;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.heracles_periods', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.heracles_periods
(
        period_id int,
  period_order int,
        period_name varchar(255),
  period_type varchar(50),
        period_start_date date,
        period_end_date date
);

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_sample_element;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_sample_element', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_sample_element(
    cohort_sample_id int NOT NULL,
    rank_value int NOT NULL,
    person_id bigint NOT NULL,
    age int,
    gender_concept_id int
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.ir_analysis_dist;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.ir_analysis_dist', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.ir_analysis_dist (
  analysis_id int NOT NULL,
  target_id int NOT NULL,
  outcome_id int NOT NULL,
  strata_sequence int NULL,
  dist_type int NOT NULL,
  total bigint NOT NULL,
  avg_value float NOT NULL,
  std_dev float NOT NULL,
  min_value int NOT NULL,
  p10_value int NOT NULL,
  p25_value int NOT NULL,
  median_value int NOT NULL,
  p75_value int NOT NULL,
  p90_value int NOT NULL,
  max_value int NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.ir_analysis_result;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.ir_analysis_result', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.ir_analysis_result(
  analysis_id int NOT NULL,
  target_id int NOT NULL,
  outcome_id int NOT NULL,
  strata_mask bigint NOT NULL,
  person_count bigint NOT NULL,
  time_at_risk bigint NOT NULL,
  cases bigint NOT NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.ir_analysis_strata_stats;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.ir_analysis_strata_stats', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.ir_analysis_strata_stats(
  analysis_id int NOT NULL,
  target_id int NOT NULL,
  outcome_id int NOT NULL,
  strata_sequence int NOT NULL,
  person_count bigint NOT NULL,
  time_at_risk bigint NOT NULL,
  cases bigint NOT NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.ir_strata;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.ir_strata', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.ir_strata(
  analysis_id int NOT NULL,
  strata_sequence int NOT NULL,
  name varchar(255) NULL,
  description varchar(1000) NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cc_results;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.cc_results', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cc_results
(
  type VARCHAR(255) NOT NULL,
  fa_type VARCHAR(255) NOT NULL,
  cc_generation_id BIGINT NOT NULL,
  analysis_id INTEGER,
  analysis_name VARCHAR(1000),
  covariate_id BIGINT,
  covariate_name VARCHAR(1000),
  strata_id BIGINT,
  strata_name VARCHAR(1000),
  time_window VARCHAR(255),
  concept_id INTEGER NOT NULL,
  count_value BIGINT,
  avg_value DOUBLE PRECISION,
  stdev_value DOUBLE PRECISION,
  min_value DOUBLE PRECISION,
  p10_value DOUBLE PRECISION,
  p25_value DOUBLE PRECISION,
  median_value DOUBLE PRECISION,
  p75_value DOUBLE PRECISION,
  p90_value DOUBLE PRECISION,
  max_value DOUBLE PRECISION,
  cohort_definition_id BIGINT,
  aggregate_id INTEGER,
  aggregate_name VARCHAR(1000),
  missing_means_zero INTEGER
);

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.pathway_analysis_codes;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.pathway_analysis_codes', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.pathway_analysis_codes
(
        pathway_analysis_generation_id BIGINT NOT NULL,
        code BIGINT NOT NULL,
        name VARCHAR(2000) NOT NULL,
        is_combo int NOT NULL
);

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.pathway_analysis_events;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.pathway_analysis_events', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.pathway_analysis_events
(
        pathway_analysis_generation_id BIGINT NOT NULL,
        target_cohort_id INTEGER NOT NULL,
        combo_id BIGINT NOT NULL,
        subject_id BIGINT NOT NULL,
        ordinal INTEGER,
        cohort_start_date DATETIME NOT NULL,
        cohort_end_date DATETIME NOT NULL
);


DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.pathway_analysis_paths;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.pathway_analysis_paths', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.pathway_analysis_paths
(
        pathway_analysis_generation_id BIGINT NOT NULL,
  target_cohort_id INTEGER NOT NULL,
  step_1 BIGINT,
  step_2 BIGINT,
  step_3 BIGINT,
  step_4 BIGINT,
  step_5 BIGINT,
  step_6 BIGINT,
  step_7 BIGINT,
  step_8 BIGINT,
  step_9 BIGINT,
  step_10 BIGINT,
  count_value BIGINT NOT NULL
);

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.pathway_analysis_stats;
IF OBJECT_ID('synthea_micro_achilles_results.dbo.pathway_analysis_stats', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.pathway_analysis_stats
(
  pathway_analysis_generation_id BIGINT NOT NULL,
  target_cohort_id INTEGER NOT NULL,
  target_cohort_count BIGINT NOT NULL,
  pathways_count BIGINT NOT NULL
);



/*********************************************************************/
/***** Create hierarchy lookup table for the treemap hierarchies *****/
/*********************************************************************/

IF OBJECT_ID('synthea_micro_achilles_results.dbo.concept_hierarchy', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.concept_hierarchy
(
  concept_id             INT,
  concept_name           VARCHAR(400),
  treemap                VARCHAR(20),
  concept_hierarchy_type VARCHAR(20),
  level1_concept_name    VARCHAR(255),
  level2_concept_name    VARCHAR(255),
  level3_concept_name    VARCHAR(255),
  level4_concept_name    VARCHAR(255)
);


/***********************************************************/
/***** Populate the hierarchy lookup table per treemap *****/
/***********************************************************/
TRUNCATE TABLE synthea_micro_achilles_results.dbo.concept_hierarchy;

/********** CONDITION/CONDITION_ERA **********/
INSERT INTO synthea_micro_achilles_results.dbo.concept_hierarchy
        (concept_id, concept_name, treemap, concept_hierarchy_type, level1_concept_name, level2_concept_name, level3_concept_name, level4_concept_name)
SELECT
        snomed.concept_id,
  snomed.concept_name AS concept_name,
        CAST('Condition' AS VARCHAR(20)) AS treemap,
        CAST(NULL AS VARCHAR(20)) as concept_hierarchy_type,
        pt_to_hlt.pt_concept_name as level1_concept_name,
        hlt_to_hlgt.hlt_concept_name as level2_concept_name,
        hlgt_to_soc.hlgt_concept_name as level3_concept_name,
        soc.concept_name AS level4_concept_name
FROM (
        SELECT
                concept_id,
                concept_name
        FROM synthea_micro.dbo.concept
        WHERE domain_id = 'Condition'
) snomed
LEFT JOIN (
        SELECT
                c1.concept_id      AS snomed_concept_id,
                max(c2.concept_id) AS pt_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.domain_id = 'Condition'
                AND ca1.min_levels_of_separation = 1
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'MedDRA'
        GROUP BY c1.concept_id
) snomed_to_pt ON snomed.concept_id = snomed_to_pt.snomed_concept_id
LEFT JOIN (
        SELECT
                c1.concept_id      AS pt_concept_id,
                c1.concept_name    AS pt_concept_name,
                max(c2.concept_id) AS hlt_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.vocabulary_id = 'MedDRA'
                AND ca1.min_levels_of_separation = 1
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'MedDRA'
        GROUP BY c1.concept_id, c1.concept_name
) pt_to_hlt ON snomed_to_pt.pt_concept_id = pt_to_hlt.pt_concept_id
LEFT JOIN (
        SELECT
                c1.concept_id      AS hlt_concept_id,
                c1.concept_name    AS hlt_concept_name,
                max(c2.concept_id) AS hlgt_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.vocabulary_id = 'MedDRA'
                AND ca1.min_levels_of_separation = 1
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'MedDRA'
        GROUP BY c1.concept_id, c1.concept_name
) hlt_to_hlgt ON pt_to_hlt.hlt_concept_id = hlt_to_hlgt.hlt_concept_id
LEFT JOIN (
        SELECT
                c1.concept_id      AS hlgt_concept_id,
                c1.concept_name    AS hlgt_concept_name,
                max(c2.concept_id) AS soc_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.vocabulary_id = 'MedDRA'
                AND ca1.min_levels_of_separation = 1
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'MedDRA'
        GROUP BY c1.concept_id, c1.concept_name
) hlgt_to_soc ON hlt_to_hlgt.hlgt_concept_id = hlgt_to_soc.hlgt_concept_id
LEFT JOIN synthea_micro.dbo.concept soc ON hlgt_to_soc.soc_concept_id = soc.concept_id;


/********** DRUG **********/
INSERT INTO synthea_micro_achilles_results.dbo.concept_hierarchy
        (concept_id, concept_name, treemap, concept_hierarchy_type, level1_concept_name, level2_concept_name, level3_concept_name, level4_concept_name)
SELECT
        rxnorm.concept_id,
        rxnorm.concept_name AS concept_name,
        CAST('Drug' AS VARCHAR(20)) AS treemap,
        CAST(NULL AS VARCHAR(20)) as concept_hierarchy_type,
        rxnorm.rxnorm_ingredient_concept_name as level1_concept_name,
        atc5_to_atc3.atc5_concept_name as level2_concept_name,
        atc3_to_atc1.atc3_concept_name as level3_concept_name,
        atc1.concept_name AS level4_concept_name
FROM (
        SELECT
                c1.concept_id,
                c1.concept_name,
                c2.concept_id   AS rxnorm_ingredient_concept_id,
                c2.concept_name AS RxNorm_ingredient_concept_name
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.domain_id = 'Drug'
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.domain_id = 'Drug'
                AND c2.concept_class_id = 'Ingredient'
) rxnorm
LEFT JOIN (
        SELECT
                c1.concept_id      AS rxnorm_ingredient_concept_id,
                max(c2.concept_id) AS atc5_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.domain_id = 'Drug'
                AND c1.concept_class_id = 'Ingredient'
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'ATC'
                AND c2.concept_class_id = 'ATC 4th'
        GROUP BY c1.concept_id
) rxnorm_to_atc5 ON rxnorm.rxnorm_ingredient_concept_id = rxnorm_to_atc5.rxnorm_ingredient_concept_id
LEFT JOIN (
        SELECT
                c1.concept_id      AS atc5_concept_id,
                c1.concept_name    AS atc5_concept_name,
                max(c2.concept_id) AS atc3_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.vocabulary_id = 'ATC'
                AND c1.concept_class_id = 'ATC 4th'
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'ATC'
                AND c2.concept_class_id = 'ATC 2nd'
        GROUP BY c1.concept_id, c1.concept_name
) atc5_to_atc3 ON rxnorm_to_atc5.atc5_concept_id = atc5_to_atc3.atc5_concept_id
LEFT JOIN (
        SELECT
                c1.concept_id      AS atc3_concept_id,
                c1.concept_name    AS atc3_concept_name,
                max(c2.concept_id) AS atc1_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.vocabulary_id = 'ATC'
                AND c1.concept_class_id = 'ATC 2nd'
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'ATC'
                AND c2.concept_class_id = 'ATC 1st'
        GROUP BY c1.concept_id, c1.concept_name
) atc3_to_atc1 ON atc5_to_atc3.atc3_concept_id = atc3_to_atc1.atc3_concept_id
LEFT JOIN synthea_micro.dbo.concept atc1 ON atc3_to_atc1.atc1_concept_id = atc1.concept_id;


/********** DRUG_ERA **********/
INSERT INTO synthea_micro_achilles_results.dbo.concept_hierarchy
        (concept_id, concept_name, treemap, concept_hierarchy_type, level1_concept_name, level2_concept_name, level3_concept_name, level4_concept_name)
SELECT
        rxnorm.rxnorm_ingredient_concept_id as concept_id,
        rxnorm.rxnorm_ingredient_concept_name as concept_name,
        CAST('Drug Era' AS VARCHAR(20)) AS treemap,
        CAST(NULL AS VARCHAR(20)) as concept_hierarchy_type,
        atc5_to_atc3.atc5_concept_name as level1_concept_name,
        atc3_to_atc1.atc3_concept_name as level2_concept_name,
        atc1.concept_name AS level3_concept_name,
        CAST(NULL AS VARCHAR(255)) as level4_concept_name
FROM (
        SELECT
                c2.concept_id   AS rxnorm_ingredient_concept_id,
                c2.concept_name AS RxNorm_ingredient_concept_name
        FROM synthea_micro.dbo.concept c2
        WHERE c2.domain_id = 'Drug'
                AND c2.concept_class_id = 'Ingredient'
) rxnorm
LEFT JOIN (
        SELECT
                c1.concept_id      AS rxnorm_ingredient_concept_id,
                max(c2.concept_id) AS atc5_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.domain_id = 'Drug'
                AND c1.concept_class_id = 'Ingredient'
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'ATC'
                AND c2.concept_class_id = 'ATC 4th'
        GROUP BY c1.concept_id
) rxnorm_to_atc5 ON rxnorm.rxnorm_ingredient_concept_id = rxnorm_to_atc5.rxnorm_ingredient_concept_id
LEFT JOIN (
        SELECT
                c1.concept_id      AS atc5_concept_id,
                c1.concept_name    AS atc5_concept_name,
                max(c2.concept_id) AS atc3_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.vocabulary_id = 'ATC'
                AND c1.concept_class_id = 'ATC 4th'
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'ATC'
                AND c2.concept_class_id = 'ATC 2nd'
        GROUP BY c1.concept_id, c1.concept_name
) atc5_to_atc3 ON rxnorm_to_atc5.atc5_concept_id = atc5_to_atc3.atc5_concept_id
LEFT JOIN (
        SELECT
                c1.concept_id      AS atc3_concept_id,
                c1.concept_name    AS atc3_concept_name,
                max(c2.concept_id) AS atc1_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.vocabulary_id = 'ATC'
                AND c1.concept_class_id = 'ATC 2nd'
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'ATC'
                AND c2.concept_class_id = 'ATC 1st'
        GROUP BY c1.concept_id, c1.concept_name
) atc3_to_atc1 ON atc5_to_atc3.atc3_concept_id = atc3_to_atc1.atc3_concept_id
LEFT JOIN synthea_micro.dbo.concept atc1 ON atc3_to_atc1.atc1_concept_id = atc1.concept_id;


/********** MEASUREMENT **********/
INSERT INTO synthea_micro_achilles_results.dbo.concept_hierarchy
        (concept_id, concept_name, treemap, concept_hierarchy_type, level1_concept_name, level2_concept_name, level3_concept_name, level4_concept_name)
SELECT
        m.concept_id,
        m.concept_name AS concept_name,
        CAST('Measurement' AS VARCHAR(20)) AS treemap,
        CAST(NULL AS VARCHAR(20)) as concept_hierarchy_type,
        CAST(max(c1.concept_name) AS VARCHAR(255)) AS level1_concept_name,
        CAST(max(c2.concept_name) AS VARCHAR(255)) AS level2_concept_name,
        CAST(max(c3.concept_name) AS VARCHAR(255)) AS level3_concept_name,
        CAST(NULL AS VARCHAR(255)) as level4_concept_name
FROM (
        SELECT DISTINCT
                concept_id,
                concept_name
        FROM synthea_micro.dbo.concept c
        WHERE domain_id = 'Measurement'
) m
LEFT JOIN synthea_micro.dbo.concept_ancestor ca1 ON M.concept_id = ca1.DESCENDANT_CONCEPT_ID AND ca1.min_levels_of_separation = 1
LEFT JOIN synthea_micro.dbo.concept c1 ON ca1.ANCESTOR_CONCEPT_ID = c1.concept_id
LEFT JOIN synthea_micro.dbo.concept_ancestor ca2 ON c1.concept_id = ca2.DESCENDANT_CONCEPT_ID AND ca2.min_levels_of_separation = 1
LEFT JOIN synthea_micro.dbo.concept c2 ON ca2.ANCESTOR_CONCEPT_ID = c2.concept_id
LEFT JOIN synthea_micro.dbo.concept_ancestor ca3 ON c2.concept_id = ca3.DESCENDANT_CONCEPT_ID AND ca3.min_levels_of_separation = 1
LEFT JOIN synthea_micro.dbo.concept c3 ON ca3.ANCESTOR_CONCEPT_ID = c3.concept_id
GROUP BY M.concept_id, M.concept_name;


/********** OBSERVATION **********/
INSERT INTO synthea_micro_achilles_results.dbo.concept_hierarchy
        (concept_id, concept_name, treemap, concept_hierarchy_type, level1_concept_name, level2_concept_name, level3_concept_name, level4_concept_name)
SELECT
        obs.concept_id,
        obs.concept_name AS concept_name,
        CAST('Observation' AS VARCHAR(20)) AS treemap,
        CAST(NULL AS VARCHAR(20)) as concept_hierarchy_type,
        CAST(max(c1.concept_name) AS VARCHAR(255)) AS level1_concept_name,
        CAST(max(c2.concept_name) AS VARCHAR(255)) AS level2_concept_name,
        CAST(max(c3.concept_name) AS VARCHAR(255)) AS level3_concept_name,
        CAST(NULL AS VARCHAR(255)) as level4_concept_name
FROM (
        SELECT
                concept_id,
                concept_name
        FROM synthea_micro.dbo.concept
        WHERE domain_id = 'Observation'
) obs
LEFT JOIN synthea_micro.dbo.concept_ancestor ca1 ON obs.concept_id = ca1.DESCENDANT_CONCEPT_ID AND ca1.min_levels_of_separation = 1
LEFT JOIN synthea_micro.dbo.concept c1 ON ca1.ANCESTOR_CONCEPT_ID = c1.concept_id
LEFT JOIN synthea_micro.dbo.concept_ancestor ca2 ON c1.concept_id = ca2.DESCENDANT_CONCEPT_ID AND ca2.min_levels_of_separation = 1
LEFT JOIN synthea_micro.dbo.concept c2 ON ca2.ANCESTOR_CONCEPT_ID = c2.concept_id
LEFT JOIN synthea_micro.dbo.concept_ancestor ca3 ON c2.concept_id = ca3.DESCENDANT_CONCEPT_ID AND ca3.min_levels_of_separation = 1
LEFT JOIN synthea_micro.dbo.concept c3 ON ca3.ANCESTOR_CONCEPT_ID = c3.concept_id
GROUP BY obs.concept_id, obs.concept_name;


/********** PROCEDURE **********/
INSERT INTO synthea_micro_achilles_results.dbo.concept_hierarchy
        (concept_id, concept_name, treemap, concept_hierarchy_type, level1_concept_name, level2_concept_name, level3_concept_name, level4_concept_name)
SELECT
        procs.concept_id,
        CAST(procs.proc_concept_name AS VARCHAR(400)) AS concept_name,
        CAST('Procedure' AS VARCHAR(20)) AS treemap,
        CAST(NULL AS VARCHAR(20)) as concept_hierarchy_type,
        CAST(max(proc_hierarchy.os3_concept_name) AS VARCHAR(255)) AS level1_concept_name,
        CAST(max(proc_hierarchy.os2_concept_name) AS VARCHAR(255)) AS level2_concept_name,
        CAST(max(proc_hierarchy.os1_concept_name) AS VARCHAR(255)) AS level3_concept_name,
        CAST(NULL AS VARCHAR(255)) as level4_concept_name
FROM
(
        SELECT
                c1.concept_id,
                CONCAT(v1.vocabulary_name, ' ', c1.concept_code, ': ', c1.concept_name) AS proc_concept_name
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.vocabulary v1 ON c1.vocabulary_id = v1.vocabulary_id
        WHERE c1.domain_id = 'Procedure'
) procs
LEFT JOIN (
        SELECT
                ca0.DESCENDANT_CONCEPT_ID,
                max(ca0.ancestor_concept_id) AS ancestor_concept_id
        FROM synthea_micro.dbo.concept_ancestor ca0
        INNER JOIN (
                SELECT DISTINCT c2.concept_id AS os3_concept_id
                FROM synthea_micro.dbo.concept_ancestor ca1
                INNER JOIN synthea_micro.dbo.concept c1 ON ca1.DESCENDANT_CONCEPT_ID = c1.concept_id
                INNER JOIN synthea_micro.dbo.concept_ancestor ca2 ON c1.concept_id = ca2.ANCESTOR_CONCEPT_ID
                INNER JOIN synthea_micro.dbo.concept c2 ON ca2.DESCENDANT_CONCEPT_ID = c2.concept_id
                WHERE ca1.ancestor_concept_id = 4040390
                        AND ca1.Min_LEVELS_OF_SEPARATION = 2
                        AND ca2.MIN_LEVELS_OF_SEPARATION = 1
        ) t1 ON ca0.ANCESTOR_CONCEPT_ID = t1.os3_concept_id
        GROUP BY ca0.descendant_concept_id
) ca1 ON procs.concept_id = ca1.DESCENDANT_CONCEPT_ID
LEFT JOIN (
        SELECT
                proc_by_os1.os1_concept_name,
                proc_by_os2.os2_concept_name,
                proc_by_os3.os3_concept_name,
                proc_by_os3.os3_concept_id
        FROM (
                SELECT
                        DESCENDANT_CONCEPT_ID AS os1_concept_id,
                        concept_name          AS os1_concept_name
                FROM synthea_micro.dbo.concept_ancestor ca1
                INNER JOIN synthea_micro.dbo.concept c1 ON ca1.DESCENDANT_CONCEPT_ID = c1.concept_id
                WHERE ancestor_concept_id = 4040390
                        AND Min_LEVELS_OF_SEPARATION = 1
        ) proc_by_os1
        INNER JOIN (
                SELECT
                        max(c1.CONCEPT_ID) AS os1_concept_id,
                        c2.concept_id      AS os2_concept_id,
                        c2.concept_name    AS os2_concept_name
                FROM synthea_micro.dbo.concept_ancestor ca1
                INNER JOIN synthea_micro.dbo.concept c1 ON ca1.DESCENDANT_CONCEPT_ID = c1.concept_id
                INNER JOIN synthea_micro.dbo.concept_ancestor ca2 ON c1.concept_id = ca2.ANCESTOR_CONCEPT_ID
                INNER JOIN synthea_micro.dbo.concept c2 ON ca2.DESCENDANT_CONCEPT_ID = c2.concept_id
                WHERE ca1.ancestor_concept_id = 4040390
                        AND ca1.Min_LEVELS_OF_SEPARATION = 1
                        AND ca2.MIN_LEVELS_OF_SEPARATION = 1
                GROUP BY c2.concept_id, c2.concept_name
        ) proc_by_os2 ON proc_by_os1.os1_concept_id = proc_by_os2.os1_concept_id
        INNER JOIN (
                SELECT
                        max(c1.CONCEPT_ID) AS os2_concept_id,
                        c2.concept_id      AS os3_concept_id,
                        c2.concept_name    AS os3_concept_name
                FROM synthea_micro.dbo.concept_ancestor ca1
                INNER JOIN synthea_micro.dbo.concept c1 ON ca1.DESCENDANT_CONCEPT_ID = c1.concept_id
                INNER JOIN synthea_micro.dbo.concept_ancestor ca2 ON c1.concept_id = ca2.ANCESTOR_CONCEPT_ID
                INNER JOIN synthea_micro.dbo.concept c2 ON ca2.DESCENDANT_CONCEPT_ID = c2.concept_id
                WHERE ca1.ancestor_concept_id = 4040390
                        AND ca1.Min_LEVELS_OF_SEPARATION = 2
                        AND ca2.MIN_LEVELS_OF_SEPARATION = 1
                GROUP BY c2.concept_id, c2.concept_name
        ) proc_by_os3 ON proc_by_os2.os2_concept_id = proc_by_os3.os2_concept_id
) proc_hierarchy ON ca1.ancestor_concept_id = proc_hierarchy.os3_concept_id
GROUP BY procs.concept_id, procs.proc_concept_name;


-- init heracles_analysis

TRUNCATE TABLE synthea_micro_achilles_results.dbo.heracles_analysis;


insert into synthea_micro_achilles_results.dbo.heracles_analysis
(analysis_id,analysis_name,stratum_1_name,stratum_2_name,stratum_3_name,stratum_4_name,stratum_5_name,analysis_type)
select    0 as analysis_id,
CAST('Source name' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select    1 as analysis_id,
CAST('Number of persons' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select    2 as analysis_id,
CAST('Number of persons by gender' as VARCHAR(255)) as analysis_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select    3 as analysis_id,
CAST('Number of persons by year of birth' as VARCHAR(255)) as analysis_name,
CAST('year_of_birth' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select    4 as analysis_id,
CAST('Number of persons by race' as VARCHAR(255)) as analysis_name,
CAST('race_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select    5 as analysis_id,
CAST('Number of persons by ethnicity' as VARCHAR(255)) as analysis_name,
CAST('ethnicity_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select    7 as analysis_id,
CAST('Number of persons with invalid provider_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select    8 as analysis_id,
CAST('Number of persons with invalid location_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select    9 as analysis_id,
CAST('Number of persons with invalid care_site_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select  101 as analysis_id,
CAST('Number of persons by age, with age at first observation period' as VARCHAR(255)) as analysis_name,
CAST('age' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  102 as analysis_id,
CAST('Number of persons by gender by age, with age at first observation period' as VARCHAR(255)) as analysis_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('age' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  103 as analysis_id,
CAST('Distribution of age at first observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  104 as analysis_id,
CAST('Distribution of age at first observation period by gender' as VARCHAR(255)) as analysis_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  105 as analysis_id,
CAST('Length of observation (days) of first observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  106 as analysis_id,
CAST('Length of observation (days) of first observation period by gender' as VARCHAR(255)) as analysis_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  107 as analysis_id,
CAST('Length of observation (days) of first observation period by age decile' as VARCHAR(255)) as analysis_name,
CAST('age decile' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  108 as analysis_id,
CAST('Number of persons by length of first observation period, in 30d increments' as VARCHAR(255)) as analysis_name,
CAST('Observation period length 30d increments' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  109 as analysis_id,
CAST('Number of persons with continuous observation in each year' as VARCHAR(255)) as analysis_name,
CAST('calendar year' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  110 as analysis_id,
CAST('Number of persons with continuous observation in each month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  111 as analysis_id,
CAST('Number of persons by observation period start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  112 as analysis_id,
CAST('Number of persons by observation period end month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  113 as analysis_id,
CAST('Number of persons by number of observation periods' as VARCHAR(255)) as analysis_name,
CAST('number of observation periods' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  114 as analysis_id,
CAST('Number of persons with observation period before year-of-birth' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  115 as analysis_id,
CAST('Number of persons with observation period end < observation period start' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  116 as analysis_id,
CAST('Number of persons with at least one day of observation in each year by gender and age decile' as VARCHAR(255)) as analysis_name,
CAST('calendar year' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST('age decile' as VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  117 as analysis_id,
CAST('Number of persons with at least one day of observation in each month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  200 as analysis_id,
CAST('Number of persons with at least one visit occurrence, by visit_concept_id' as VARCHAR(255)) as analysis_name,
CAST('visit_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  201 as analysis_id,
CAST('Number of visit occurrence records, by visit_concept_id' as VARCHAR(255)) as analysis_name,
CAST('visit_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  202 as analysis_id,
CAST('Number of persons by visit occurrence start month, by visit_concept_id' as VARCHAR(255)) as analysis_name,
CAST('visit_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar month' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  203 as analysis_id,
CAST('Number of distinct visit occurrence concepts per person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  204 as analysis_id,
CAST('Number of persons with at least one visit occurrence, by visit_concept_id by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('visit_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar year' as VARCHAR(255)) as stratum_2_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_3_name,
CAST('age decile' as VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  206 as analysis_id,
CAST('Distribution of age by visit_concept_id' as VARCHAR(255)) as analysis_name,
CAST('visit_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  207 as analysis_id,
CAST('Number of visit records with invalid person_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  208 as analysis_id,
CAST('Number of visit records outside valid observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  209 as analysis_id,
CAST('Number of visit records with end date < start date' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  210 as analysis_id,
CAST('Number of visit records with invalid care_site_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  211 as analysis_id,
CAST('Distribution of length of stay by visit_concept_id' as VARCHAR(255)) as analysis_name,
CAST('visit_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  220 as analysis_id,
CAST('Number of visit occurrence records by visit occurrence start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  400 as analysis_id,
CAST('Number of persons with at least one condition occurrence, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  401 as analysis_id,
CAST('Number of condition occurrence records, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  402 as analysis_id,
CAST('Number of persons by condition occurrence start month, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar month' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  403 as analysis_id,
CAST('Number of distinct condition occurrence concepts per person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  404 as analysis_id,
CAST('Number of persons with at least one condition occurrence, by condition_concept_id by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar year' as VARCHAR(255)) as stratum_2_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_3_name,
CAST('age decile' as VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  405 as analysis_id,
CAST('Number of condition occurrence records, by condition_concept_id by condition_type_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('condition_type_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  406 as analysis_id,
CAST('Distribution of age by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  409 as analysis_id,
CAST('Number of condition occurrence records with invalid person_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  410 as analysis_id,
CAST('Number of condition occurrence records outside valid observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  411 as analysis_id,
CAST('Number of condition occurrence records with end date < start date' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  412 as analysis_id,
CAST('Number of condition occurrence records with invalid provider_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  413 as analysis_id,
CAST('Number of condition occurrence records with invalid visit_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  420 as analysis_id,
CAST('Number of condition occurrence records by condition occurrence start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  500 as analysis_id,
CAST('Number of persons with death, by cause_of_death_concept_id' as VARCHAR(255)) as analysis_name,
CAST('cause_of_death_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  501 as analysis_id,
CAST('Number of records of death, by cause_of_death_concept_id' as VARCHAR(255)) as analysis_name,
CAST('cause_of_death_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  502 as analysis_id,
CAST('Number of persons by death month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  504 as analysis_id,
CAST('Number of persons with a death, by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('calendar year' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST('age decile' as VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  505 as analysis_id,
CAST('Number of death records, by death_type_concept_id' as VARCHAR(255)) as analysis_name,
CAST('death_type_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  506 as analysis_id,
CAST('Distribution of age at death by gender' as VARCHAR(255)) as analysis_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  509 as analysis_id,
CAST('Number of death records with invalid person_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  510 as analysis_id,
CAST('Number of death records outside valid observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  511 as analysis_id,
CAST('Distribution of time from death to last condition' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  512 as analysis_id,
CAST('Distribution of time from death to last drug' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  513 as analysis_id,
CAST('Distribution of time from death to last visit' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  514 as analysis_id,
CAST('Distribution of time from death to last procedure' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  515 as analysis_id,
CAST('Distribution of time from death to last observation' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  600 as analysis_id,
CAST('Number of persons with at least one procedure occurrence, by procedure_concept_id' as VARCHAR(255)) as analysis_name,
CAST('procedure_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  601 as analysis_id,
CAST('Number of procedure occurrence records, by procedure_concept_id' as VARCHAR(255)) as analysis_name,
CAST('procedure_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  602 as analysis_id,
CAST('Number of persons by procedure occurrence start month, by procedure_concept_id' as VARCHAR(255)) as analysis_name,
CAST('procedure_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar month' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  603 as analysis_id,
CAST('Number of distinct procedure occurrence concepts per person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  604 as analysis_id,
CAST('Number of persons with at least one procedure occurrence, by procedure_concept_id by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('procedure_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar year' as VARCHAR(255)) as stratum_2_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_3_name,
CAST('age decile' as VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  605 as analysis_id,
CAST('Number of procedure occurrence records, by procedure_concept_id by procedure_type_concept_id' as VARCHAR(255)) as analysis_name,
CAST('procedure_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('procedure_type_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  606 as analysis_id,
CAST('Distribution of age by procedure_concept_id' as VARCHAR(255)) as analysis_name,
CAST('procedure_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  609 as analysis_id,
CAST('Number of procedure occurrence records with invalid person_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  610 as analysis_id,
CAST('Number of procedure occurrence records outside valid observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  612 as analysis_id,
CAST('Number of procedure occurrence records with invalid provider_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  613 as analysis_id,
CAST('Number of procedure occurrence records with invalid visit_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  620 as analysis_id,
CAST('Number of procedure occurrence records  by procedure occurrence start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  700 as analysis_id,
CAST('Number of persons with at least one drug exposure, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  701 as analysis_id,
CAST('Number of drug exposure records, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  702 as analysis_id,
CAST('Number of persons by drug exposure start month, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar month' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  703 as analysis_id,
CAST('Number of distinct drug exposure concepts per person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  704 as analysis_id,
CAST('Number of persons with at least one drug exposure, by drug_concept_id by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar year' as VARCHAR(255)) as stratum_2_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_3_name,
CAST('age decile' as VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  705 as analysis_id,
CAST('Number of drug exposure records, by drug_concept_id by drug_type_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('drug_type_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  706 as analysis_id,
CAST('Distribution of age by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  709 as analysis_id,
CAST('Number of drug exposure records with invalid person_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  710 as analysis_id,
CAST('Number of drug exposure records outside valid observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  711 as analysis_id,
CAST('Number of drug exposure records with end date < start date' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  712 as analysis_id,
CAST('Number of drug exposure records with invalid provider_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  713 as analysis_id,
CAST('Number of drug exposure records with invalid visit_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  715 as analysis_id,
CAST('Distribution of days_supply by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  716 as analysis_id,
CAST('Distribution of refills by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  717 as analysis_id,
CAST('Distribution of quantity by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  720 as analysis_id,
CAST('Number of drug exposure records  by drug exposure start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  800 as analysis_id,
CAST('Number of persons with at least one observation occurrence, by observation_concept_id' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  801 as analysis_id,
CAST('Number of observation occurrence records, by observation_concept_id' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  802 as analysis_id,
CAST('Number of persons by observation occurrence start month, by observation_concept_id' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar month' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  803 as analysis_id,
CAST('Number of distinct observation occurrence concepts per person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  804 as analysis_id,
CAST('Number of persons with at least one observation occurrence, by observation_concept_id by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar year' as VARCHAR(255)) as stratum_2_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_3_name,
CAST('age decile' as VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  805 as analysis_id,
CAST('Number of observation occurrence records, by observation_concept_id by observation_type_concept_id' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('observation_type_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  806 as analysis_id,
CAST('Distribution of age by observation_concept_id' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  807 as analysis_id,
CAST('Number of observation occurrence records, by observation_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('unit_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  809 as analysis_id,
CAST('Number of observation records with invalid person_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  810 as analysis_id,
CAST('Number of observation records outside valid observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  812 as analysis_id,
CAST('Number of observation records with invalid provider_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  813 as analysis_id,
CAST('Number of observation records with invalid visit_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  814 as analysis_id,
CAST('Number of observation records with no value (numeric, string, or concept)' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  815 as analysis_id,
CAST('Distribution of numeric values, by observation_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  816 as analysis_id,
CAST('Distribution of low range, by observation_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  817 as analysis_id,
CAST('Distribution of high range, by observation_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  818 as analysis_id,
CAST('Number of observation records below/within/above normal range, by observation_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  820 as analysis_id,
CAST('Number of observation records  by observation start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  900 as analysis_id,
CAST('Number of persons with at least one drug era, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  901 as analysis_id,
CAST('Number of drug era records, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  902 as analysis_id,
CAST('Number of persons by drug era start month, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar month' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  903 as analysis_id,
CAST('Number of distinct drug era concepts per person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  904 as analysis_id,
CAST('Number of persons with at least one drug era, by drug_concept_id by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar year' as VARCHAR(255)) as stratum_2_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_3_name,
CAST('age decile' as VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  906 as analysis_id,
CAST('Distribution of age by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  907 as analysis_id,
CAST('Distribution of drug era length, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  908 as analysis_id,
CAST('Number of drug eras without valid person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  909 as analysis_id,
CAST('Number of drug eras outside valid observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  910 as analysis_id,
CAST('Number of drug eras with end date < start date' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  920 as analysis_id,
CAST('Number of drug era records  by drug era start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select 1000 as analysis_id,
CAST('Number of persons with at least one condition era, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1001 as analysis_id,
CAST('Number of condition era records, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1002 as analysis_id,
CAST('Number of persons by condition era start month, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar month' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1003 as analysis_id,
CAST('Number of distinct condition era concepts per person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1004 as analysis_id,
CAST('Number of persons with at least one condition era, by condition_concept_id by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar year' as VARCHAR(255)) as stratum_2_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_3_name,
CAST('age decile' as VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1006 as analysis_id,
CAST('Distribution of age by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1007 as analysis_id,
CAST('Distribution of condition era length, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1008 as analysis_id,
CAST('Number of condition eras without valid person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1009 as analysis_id,
CAST('Number of condition eras outside valid observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1010 as analysis_id,
CAST('Number of condition eras with end date < start date' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1020 as analysis_id,
CAST('Number of condition era records by condition era start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1100 as analysis_id,
CAST('Number of persons by location 3-digit zip' as VARCHAR(255)) as analysis_name,
CAST('3-digit zip' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('LOCATION' as VARCHAR(255)) as analysis_type
union all
select 1101 as analysis_id,
CAST('Number of persons by location state' as VARCHAR(255)) as analysis_name,
CAST('state' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('LOCATION' as VARCHAR(255)) as analysis_type
union all
select 1200 as analysis_id,
CAST('Number of persons by place of service' as VARCHAR(255)) as analysis_name,
CAST('place_of_service_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CARE_SITE' as VARCHAR(255)) as analysis_type
union all
select 1201 as analysis_id,
CAST('Number of visits by place of service' as VARCHAR(255)) as analysis_name,
CAST('place_of_service_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CARE_SITE' as VARCHAR(255)) as analysis_type
union all
select 1300 as analysis_id,
CAST('Number of persons with at least one measurement occurrence, by measurement_concept_id' as VARCHAR(255)) as analysis_name,
CAST('measurement_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1301 as analysis_id,
CAST('Number of measurement occurrence records, by measurement_concept_id' as VARCHAR(255)) as analysis_name,
CAST('measurement_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1302 as analysis_id,
CAST('Number of persons by measurement occurrence start month, by measurement_concept_id' as VARCHAR(255)) as analysis_name,
CAST('measurement_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar month' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1303 as analysis_id,
CAST('Number of distinct measurement occurrence concepts per person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1304 as analysis_id,
CAST('Number of persons with at least one measurement occurrence, by measurement_concept_id by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('measurement_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar year' as VARCHAR(255)) as stratum_2_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_3_name,
CAST('age decile' as VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1305 as analysis_id,
CAST('Number of measurement occurrence records, by measurement_concept_id by measurement_type_concept_id' as VARCHAR(255)) as analysis_name,
CAST('measurement_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('measurement_type_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1306 as analysis_id,
CAST('Distribution of age by measurement_concept_id' as VARCHAR(255)) as analysis_name,
CAST('measurement_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1307 as analysis_id,
CAST('Number of measurement occurrence records, by measurement_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST('measurement_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('unit_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1309 as analysis_id,
CAST('Number of measurement records with invalid person_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1310 as analysis_id,
CAST('Number of measurement records outside valid measurement period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1312 as analysis_id,
CAST('Number of measurement records with invalid provider_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1313 as analysis_id,
CAST('Number of measurement records with invalid visit_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1314 as analysis_id,
CAST('Number of measurement records with no value (numeric, string, or concept)' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1315 as analysis_id,
CAST('Distribution of numeric values, by measurement_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1316 as analysis_id,
CAST('Distribution of low range, by measurement_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1317 as analysis_id,
CAST('Distribution of high range, by measurement_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1318 as analysis_id,
CAST('Number of measurement records below/within/above normal range, by measurement_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1320 as analysis_id,
CAST('Number of measurement records  by measurement start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1700 as analysis_id,
CAST('Number of records by cohort_definition_id' as VARCHAR(255)) as analysis_name,
CAST('cohort_definition_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT' as VARCHAR(255)) as analysis_type
union all
select 1701 as analysis_id,
CAST('Number of records with cohort end date < cohort start date' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT' as VARCHAR(255)) as analysis_type
union all
select 1800 as analysis_id,
CAST('Number of persons by age, with age at cohort start' as VARCHAR(255)) as analysis_name,
CAST('age' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1801 as analysis_id,
CAST('Distribution of age at cohort start' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1802 as analysis_id,
CAST('Distribution of age at cohort start by gender' as VARCHAR(255)) as analysis_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1803 as analysis_id,
CAST('Distribution of age at cohort start by cohort start year' as VARCHAR(255)) as analysis_name,
CAST('calendar year' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1804 as analysis_id,
CAST('Number of persons by duration from cohort start to cohort end, in 30d increments' as VARCHAR(255)) as analysis_name,
CAST('Cohort period length 30d increments' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1805 as analysis_id,
CAST('Number of persons by duration from observation start to cohort start, in 30d increments' as VARCHAR(255)) as analysis_name,
CAST('Baseline period length 30d increments' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1806 as analysis_id,
CAST('Number of persons by duration from cohort start to observation end, in 30d increments' as VARCHAR(255)) as analysis_name,
CAST('Follow-up period length 30d increments' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1807 as analysis_id,
CAST('Number of persons by duration from cohort end to observation end, in 30d increments' as VARCHAR(255)) as analysis_name,
CAST('Post-cohort period length 30d increments' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1808 as analysis_id,
CAST('Distribution of duration (days) from cohort start to cohort end' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1809 as analysis_id,
CAST('Distribution of duration (days) from cohort start to cohort end, by gender' as VARCHAR(255)) as analysis_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1810 as analysis_id,
CAST('Distribution of duration (days) from cohort start to cohort end, by age decile' as VARCHAR(255)) as analysis_name,
CAST('age decile' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1811 as analysis_id,
CAST('Distribution of duration (days) from observation start to cohort start' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1812 as analysis_id,
CAST('Distribution of duration (days) from cohort start to observation end' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1813 as analysis_id,
CAST('Distribution of duration (days) from cohort end to observation end' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1814 as analysis_id,
CAST('Number of persons by cohort start year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('calendar year' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST('age decile' as VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1815 as analysis_id,
CAST('Number of persons by cohort start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1816 as analysis_id,
CAST('Number of persons by number of cohort periods' as VARCHAR(255)) as analysis_name,
CAST('number of cohort periods' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1820 as analysis_id,
CAST('Number of persons by duration from cohort start to first occurrence of condition occurrence, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1821 as analysis_id,
CAST('Number of events by duration from cohort start to all occurrences of condition occurrence, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1830 as analysis_id,
CAST('Number of persons by duration from cohort start to first occurrence of procedure occurrence, by procedure_concept_id' as VARCHAR(255)) as analysis_name,
CAST('procedure_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1831 as analysis_id,
CAST('Number of events by duration from cohort start to all occurrences of procedure occurrence, by procedure_concept_id' as VARCHAR(255)) as analysis_name,
CAST('procedure_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1840 as analysis_id,
CAST('Number of persons by duration from cohort start to first occurrence of drug exposure, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1841 as analysis_id,
CAST('Number of events by duration from cohort start to all occurrences of drug exposure, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1850 as analysis_id,
CAST('Number of persons by duration from cohort start to first occurrence of observation, by observation_concept_id' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1851 as analysis_id,
CAST('Number of events by duration from cohort start to all occurrences of observation, by observation_concept_id' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1860 as analysis_id,
CAST('Number of persons by duration from cohort start to first occurrence of condition era, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1861 as analysis_id,
CAST('Number of events by duration from cohort start to all occurrences of condition era, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1870 as analysis_id,
CAST('Number of persons by duration from cohort start to first occurrence of drug era, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1871 as analysis_id,
CAST('Number of events by duration from cohort start to all occurrences of drug era, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 4000 as analysis_id,
CAST('Distribution of observation period days by period_id in the 365 days prior to first cohort_start_date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4001 as analysis_id,
CAST('Number of subjects with visits by period_id, by visit_concept_id, by visit_type_concept_id in the 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4002 as analysis_id,
CAST('Distribution of number of visit occurrence records per subject by period_id, by visit_concept_id, by visit_type_concept_id in 365d prior to cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4003 as analysis_id,
CAST('Distribution of number of visit dates per subject by period_id, by visit_concept_id, by visit_type_concept_id in 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4003 as analysis_id,
CAST('Distribution of number of visit dates per subject by period_id, by visit_concept_id, by visit_type_concept_id in 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4004 as analysis_id,
CAST('Distribution of number of care_site+visit dates per subject by period_id, by visit_concept_id, by visit_type_concept_id in 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4005 as analysis_id,
CAST('Distribution of length of stay for inpatient visits per subject by period_id, by visit_concept_id, by visit_type_concept_id in the 365 days prior to first cohort_start_date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4006 as analysis_id,
CAST('Distribution of observation period days per subject, by period_id during cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4007 as analysis_id,
CAST('Number of subjects with visits by period_id, by visit_concept_id, by visit_type_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4008 as analysis_id,
CAST('Distribution of number of visit occurrence records per subject by period_id, by visit_concept_id, by visit_type_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4009 as analysis_id,
CAST('Distribution of number of visit dates per subject by period_id, by visit_concept_id, by visit_type_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4010 as analysis_id,
CAST('Distribution of number of care_site+visit dates per subject by period_id, by visit_concept_id, by visit_type_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4011 as analysis_id,
CAST('Distribution of length of stay for inpatient visits per subject by period_id, by visit_concept_id, by visit_type_concept_id during cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4012 as analysis_id,
CAST('Number of subjects with Drug Exposure by period_id, by drug_concept_id, by drug_type_concept_id in the 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4013 as analysis_id,
CAST('Distribution of number of Drug Exposure records per subject, by period_id, by drug_concept_id in 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4014 as analysis_id,
CAST('Distribution of greater than 0 drug day supply per subject by period_id, by drug_concept_id in the 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4015 as analysis_id,
CAST('Distribution of greater than 0 drug quantity per subject by period_id, by drug_concept_id in the 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4016 as analysis_id,
CAST('Number of subjects with Drug Exposure by period_id, by drug_concept_id, by drug_type_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4017 as analysis_id,
CAST('Distribution of number of Drug Exposure records per subject, by period_id, by drug_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4018 as analysis_id,
CAST('Distribution of greater than 0 drug day supply per subject by period_id, by drug_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4019 as analysis_id,
CAST('Distribution of greater than 0 drug quantity per subject by period_id, by drug_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4020 as analysis_id,
CAST('Distribution of greater than 0 US$ cost per subject by period_id, by visit_concept_id, by visit_type_concept_id, by cost_concept_id, by cost_type_concept_id in the 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4021 as analysis_id,
CAST('Distribution of greater than 0 US$ cost per subject by period_id, by visit_concept_id, by visit_type_concept_id, by cost_concept_id, by cost_type_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4022 as analysis_id,
CAST('Distribution of greater than 0 US$ cost per subject by period_id, by drug_concept_id, by drug_type_concept_id, by cost_concept_id, by cost_type_concept_id in the 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4023 as analysis_id,
CAST('Distribution of greater than 0 US$ cost per subject by period_id, by drug_concept_id, by drug_type_concept_id, by cost_concept_id, by cost_type_concept_id, by cost_type_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
;


select digits.n  into #digits
FROM (
       select 0 as n union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9
) digits;


SELECT
        y1.n + (10*y10.n) + (100*y100.n) + (1000*y1000.n) AS d_years,
        mths.n as d_months
into #generate_dates
FROM
#digits y1,
#digits y10,
(select 0 n union all select 1 union all select 9) y100,
(select 1 n union all select 2) y1000,
(select 1 n union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9 union all select 10 union all select 11 union all select 12) mths
        where y1.n + (10*y10.n) + (100*y100.n) + (1000*y1000.n) >= 1900 and y1.n + (10*y10.n) + (100*y100.n) + (1000*y1000.n) < 2100
;


select DATEFROMPARTS(d_years, d_months,01) as generated_date
into #yearly_dates
from #generate_dates
where d_months = 1
;


SELECT DATEFROMPARTS(d_years, d_months, 01) as generated_date
into #monthly_dates
from #generate_dates
;


select dateadd(d, (7 * seq.rn), DATEFROMPARTS(1900,1,7)) as generated_date -- first sunday in 1900
into #weekly_dates
from (
        select  d1.n + (10 * d10.n) + (100 * d100.n) + (1000 * d1000.n) as rn
        from #digits d1, #digits d10, #digits d100, #digits d1000
) seq;


SELECT DATEFROMPARTS(d_years, d_months, 1) as generated_date
into #quarterly_dates
        from #generate_dates
        where d_months in (1,4,7,10)
;


-- monthly dates
select *
into #temp_period
from (
select CAST('Monthly' AS VARCHAR(255)) as period_name
  , 1 as period_order
  , CAST( 'mm' AS VARCHAR(50)) as period_type
  , md.generated_date as period_start_date
  , dateadd(mm,1,md.generated_date) as period_end_date
from #monthly_dates md

UNION ALL
select CAST('Weekly' AS VARCHAR(255)) as period_name
  , 2 as period_order
  , CAST('ww' AS VARCHAR(50)) as period_type
  , wd.generated_date as period_start_date
  , dateadd(d, 7, wd.generated_date) as period_end_date
from #weekly_dates wd
where wd.generated_date >= DATEFROMPARTS(1900,1,1) and wd.generated_date < DATEFROMPARTS(2100,1,1)

UNION ALL
select CAST('Quarterly' AS VARCHAR(255)) as period_name
  , 3 as period_order
  , CAST('qq' AS VARCHAR(50)) as period_type
  , qd.generated_date as period_start_date
  , dateadd(mm,3,qd.generated_date) as period_end_date
from #quarterly_dates qd

UNION ALL
select CAST('Yearly' AS VARCHAR(255)) as period_name
  , 4 as period_order
  , CAST('yy' AS VARCHAR(50)) as period_type
  , yd.generated_date as period_start_date
  , dateadd(yy,1,yd.generated_date) as period_end_date
from #yearly_dates yd

-- ADD UNION ALLs for additional period definitions
) monthlyDates;


TRUNCATE TABLE synthea_micro_achilles_results.dbo.heracles_periods;


INSERT INTO synthea_micro_achilles_results.dbo.heracles_periods (period_id, period_name, period_order, period_type, period_start_date, period_end_date)
select CAST(row_number() over (order by period_order, period_start_date) AS INT) as period_id
                        , period_name, period_order, period_type, period_start_date, period_end_date
from #temp_period;


truncate table #digits;

drop table #digits;


truncate table #generate_dates;

drop table #generate_dates;


truncate table #yearly_dates;

drop table #yearly_dates;


truncate table #quarterly_dates;

drop table #quarterly_dates;


truncate table #monthly_dates;

drop table #monthly_dates;


truncate table #weekly_dates;

drop table #weekly_dates;


TRUNCATE TABLE #temp_period;

DROP TABLE #temp_period;



CREATE INDEX HRD_IDX_COHORT_DEF_ID ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS_DIST (cohort_definition_id);

CREATE INDEX HRD_IDX_COHORT_ID_ANALYSIS_ID ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS_DIST (cohort_definition_id, analysis_id);

CREATE INDEX HRD_IDX_COHORT_DEF_ID_DT ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS_DIST (cohort_definition_id, last_update_time);

CREATE INDEX HRD_IDX_COHORT_ID_FIRST_RES ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS_DIST (cohort_definition_id, analysis_id, count_value, stratum_1);

CREATE INDEX HR_IDX_COHORT_DEF_ID ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS (cohort_definition_id);

CREATE INDEX HR_IDX_COHORT_ID_ANALYSIS_ID ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS (cohort_definition_id, analysis_id);

CREATE INDEX HR_IDX_COHORT_ANALYSIS_CONCEPT ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS (cohort_definition_id, analysis_id) WHERE stratum_2 <> '';

CREATE INDEX HR_IDX_COHORT_DEF_ID_DT ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS (cohort_definition_id, last_update_time);

CREATE INDEX HR_IDX_COHORT_ID_FIRST_RES ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS (cohort_definition_id, analysis_id, count_value, stratum_1);

CREATE INDEX HH_IDX_COHORT_ID_ANALYSIS_ID ON synthea_micro_achilles_results.dbo.HERACLES_HEEL_RESULTS (cohort_definition_id, analysis_id);


CREATE INDEX idx_heracles_periods_startdate ON synthea_micro_achilles_results.dbo.heracles_periods (period_start_date);

CREATE INDEX idx_heracles_periods_end_date ON synthea_micro_achilles_results.dbo.heracles_periods (period_end_date);


CREATE INDEX idx_cohort_sample_element_rank ON synthea_micro_achilles_results.dbo.cohort_sample_element (cohort_sample_id, rank_value);

CREATE INDEX idx_pathway_events_combo_id ON synthea_micro_achilles_results.dbo.pathway_analysis_events (combo_id);
-----------------------------------------------
DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort

IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort
(
        COHORT_DEFINITION_ID int NOT NULL,
        SUBJECT_ID bigint NOT NULL,
        cohort_start_date date NOT NULL,
        cohort_end_date date NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_censor_stats

IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_censor_stats', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_censor_stats(
  cohort_definition_id int NOT NULL,
  lost_count BIGINT NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_inclusion

IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_inclusion', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_inclusion(
  cohort_definition_id int NOT NULL,
  design_hash int NULL,
  rule_sequence int NOT NULL,
  name varchar(255) NULL,
  description varchar(1000) NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_inclusion_result

IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_inclusion_result', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_inclusion_result(
  cohort_definition_id int NOT NULL,
  mode_id int NOT NULL,
  inclusion_rule_mask bigint NOT NULL,
  person_count bigint NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_inclusion_stats

IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_inclusion_stats', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_inclusion_stats(
  cohort_definition_id int NOT NULL,
  rule_sequence int NOT NULL,
  mode_id int NOT NULL,
  person_count bigint NOT NULL,
  gain_count bigint NOT NULL,
  person_total bigint NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_summary_stats

IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_summary_stats', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_summary_stats(
  cohort_definition_id int NOT NULL,
  mode_id int NOT NULL,
  base_count bigint NOT NULL,
  final_count bigint NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_cache

IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_cache', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_cache (
        design_hash int NOT NULL,
        SUBJECT_ID bigint NOT NULL,
        cohort_start_date date NOT NULL,
        cohort_end_date date NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_censor_stats_cache

IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_censor_stats_cache', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_censor_stats_cache (
  design_hash int NOT NULL,
  lost_count BIGINT NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_inclusion_result_cache

IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_inclusion_result_cache', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_inclusion_result_cache (
  design_hash int NOT NULL,
  mode_id int NOT NULL,
  inclusion_rule_mask bigint NOT NULL,
  person_count bigint NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_inclusion_stats_cache

IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_inclusion_stats_cache', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_inclusion_stats_cache (
  design_hash int NOT NULL,
  rule_sequence int NOT NULL,
  mode_id int NOT NULL,
  person_count bigint NOT NULL,
  gain_count bigint NOT NULL,
  person_total bigint NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_summary_stats_cache

IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_summary_stats_cache', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_summary_stats_cache (
  design_hash int NOT NULL,
  mode_id int NOT NULL,
  base_count bigint NOT NULL,
  final_count bigint NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.feas_study_inclusion_stats

IF OBJECT_ID('synthea_micro_achilles_results.dbo.feas_study_inclusion_stats', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.feas_study_inclusion_stats(
  study_id int NOT NULL,
  rule_sequence int NOT NULL,
  name varchar(255) NOT NULL,
  person_count bigint NOT NULL,
  gain_count bigint NOT NULL,
  person_total bigint NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.feas_study_index_stats

IF OBJECT_ID('synthea_micro_achilles_results.dbo.feas_study_index_stats', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.feas_study_index_stats(
  study_id int NOT NULL,
  person_count bigint NOT NULL,
  match_count bigint NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.feas_study_result

IF OBJECT_ID('synthea_micro_achilles_results.dbo.feas_study_result', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.feas_study_result(
  study_id int NOT NULL,
  inclusion_rule_mask bigint NOT NULL,
  person_count bigint NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.heracles_analysis

IF OBJECT_ID('synthea_micro_achilles_results.dbo.heracles_analysis', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.heracles_analysis
(
        analysis_id int,
        analysis_name varchar(255),
        stratum_1_name varchar(255),
        stratum_2_name varchar(255),
        stratum_3_name varchar(255),
        stratum_4_name varchar(255),
        stratum_5_name varchar(255),
        analysis_type varchar(255)
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.HERACLES_HEEL_results

IF OBJECT_ID('synthea_micro_achilles_results.dbo.HERACLES_HEEL_results', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.HERACLES_HEEL_results
(
  cohort_definition_id int,
  analysis_id INT,
  HERACLES_HEEL_warning VARCHAR(255)
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.heracles_results

--HINT PARTITION(cohort_definition_id int)
--HINT BUCKET(analysis_id, 64)
IF OBJECT_ID('synthea_micro_achilles_results.dbo.heracles_results', 'U') IS NULL
create table synthea_micro_achilles_results.dbo.heracles_results
(
        cohort_definition_id int,
        analysis_id int,
        stratum_1 varchar(255),
        stratum_2 varchar(255),
        stratum_3 varchar(255),
        stratum_4 varchar(255),
        stratum_5 varchar(255),
        count_value bigint,
        last_update_time datetime DEFAULT GETDATE()
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.heracles_results_dist

--HINT PARTITION(cohort_definition_id int)
--HINT BUCKET(analysis_id, 64)
IF OBJECT_ID('synthea_micro_achilles_results.dbo.heracles_results_dist', 'U') IS NULL
create table synthea_micro_achilles_results.dbo.heracles_results_dist
(
        cohort_definition_id int,
        analysis_id int,
        stratum_1 varchar(255),
        stratum_2 varchar(255),
        stratum_3 varchar(255),
        stratum_4 varchar(255),
        stratum_5 varchar(255),
        count_value bigint,
        min_value float,
        max_value float,
        avg_value float,
        stdev_value float,
        median_value float,
        p10_value float,
        p25_value float,
        p75_value float,
        p90_value float,
        last_update_time datetime DEFAULT GETDATE()
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.heracles_periods

IF OBJECT_ID('synthea_micro_achilles_results.dbo.heracles_periods', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.heracles_periods
(
        period_id int,
  period_order int,
        period_name varchar(255),
  period_type varchar(50),
        period_start_date date,
        period_end_date date
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cohort_sample_element

IF OBJECT_ID('synthea_micro_achilles_results.dbo.cohort_sample_element', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cohort_sample_element(
    cohort_sample_id int NOT NULL,
    rank_value int NOT NULL,
    person_id bigint NOT NULL,
    age int,
    gender_concept_id int
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.ir_analysis_dist

IF OBJECT_ID('synthea_micro_achilles_results.dbo.ir_analysis_dist', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.ir_analysis_dist (
  analysis_id int NOT NULL,
  target_id int NOT NULL,
  outcome_id int NOT NULL,
  strata_sequence int NULL,
  dist_type int NOT NULL,
  total bigint NOT NULL,
  avg_value float NOT NULL,
  std_dev float NOT NULL,
  min_value int NOT NULL,
  p10_value int NOT NULL,
  p25_value int NOT NULL,
  median_value int NOT NULL,
  p75_value int NOT NULL,
  p90_value int NOT NULL,
  max_value int NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.ir_analysis_result

IF OBJECT_ID('synthea_micro_achilles_results.dbo.ir_analysis_result', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.ir_analysis_result(
  analysis_id int NOT NULL,
  target_id int NOT NULL,
  outcome_id int NOT NULL,
  strata_mask bigint NOT NULL,
  person_count bigint NOT NULL,
  time_at_risk bigint NOT NULL,
  cases bigint NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.ir_analysis_strata_stats

IF OBJECT_ID('synthea_micro_achilles_results.dbo.ir_analysis_strata_stats', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.ir_analysis_strata_stats(
  analysis_id int NOT NULL,
  target_id int NOT NULL,
  outcome_id int NOT NULL,
  strata_sequence int NOT NULL,
  person_count bigint NOT NULL,
  time_at_risk bigint NOT NULL,
  cases bigint NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.ir_strata

IF OBJECT_ID('synthea_micro_achilles_results.dbo.ir_strata', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.ir_strata(
  analysis_id int NOT NULL,
  strata_sequence int NOT NULL,
  name varchar(255) NULL,
  description varchar(1000) NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.cc_results

IF OBJECT_ID('synthea_micro_achilles_results.dbo.cc_results', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.cc_results
(
  type VARCHAR(255) NOT NULL,
  fa_type VARCHAR(255) NOT NULL,
  cc_generation_id BIGINT NOT NULL,
  analysis_id INTEGER,
  analysis_name VARCHAR(1000),
  covariate_id BIGINT,
  covariate_name VARCHAR(1000),
  strata_id BIGINT,
  strata_name VARCHAR(1000),
  time_window VARCHAR(255),
  concept_id INTEGER NOT NULL,
  count_value BIGINT,
  avg_value DOUBLE PRECISION,
  stdev_value DOUBLE PRECISION,
  min_value DOUBLE PRECISION,
  p10_value DOUBLE PRECISION,
  p25_value DOUBLE PRECISION,
  median_value DOUBLE PRECISION,
  p75_value DOUBLE PRECISION,
  p90_value DOUBLE PRECISION,
  max_value DOUBLE PRECISION,
  cohort_definition_id BIGINT,
  aggregate_id INTEGER,
  aggregate_name VARCHAR(1000),
  missing_means_zero INTEGER
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.pathway_analysis_codes

IF OBJECT_ID('synthea_micro_achilles_results.dbo.pathway_analysis_codes', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.pathway_analysis_codes
(
        pathway_analysis_generation_id BIGINT NOT NULL,
        code BIGINT NOT NULL,
        name VARCHAR(2000) NOT NULL,
        is_combo int NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.pathway_analysis_events

IF OBJECT_ID('synthea_micro_achilles_results.dbo.pathway_analysis_events', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.pathway_analysis_events
(
        pathway_analysis_generation_id BIGINT NOT NULL,
        target_cohort_id INTEGER NOT NULL,
        combo_id BIGINT NOT NULL,
        subject_id BIGINT NOT NULL,
        ordinal INTEGER,
        cohort_start_date DATETIME NOT NULL,
        cohort_end_date DATETIME NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.pathway_analysis_paths

IF OBJECT_ID('synthea_micro_achilles_results.dbo.pathway_analysis_paths', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.pathway_analysis_paths
(
        pathway_analysis_generation_id BIGINT NOT NULL,
  target_cohort_id INTEGER NOT NULL,
  step_1 BIGINT,
  step_2 BIGINT,
  step_3 BIGINT,
  step_4 BIGINT,
  step_5 BIGINT,
  step_6 BIGINT,
  step_7 BIGINT,
  step_8 BIGINT,
  step_9 BIGINT,
  step_10 BIGINT,
  count_value BIGINT NOT NULL
)

DROP TABLE IF EXISTS synthea_micro_achilles_results.dbo.pathway_analysis_stats

IF OBJECT_ID('synthea_micro_achilles_results.dbo.pathway_analysis_stats', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.pathway_analysis_stats
(
  pathway_analysis_generation_id BIGINT NOT NULL,
  target_cohort_id INTEGER NOT NULL,
  target_cohort_count BIGINT NOT NULL,
  pathways_count BIGINT NOT NULL
)

/*********************************************************************/
/***** Create hierarchy lookup table for the treemap hierarchies *****/
/*********************************************************************/
IF OBJECT_ID('synthea_micro_achilles_results.dbo.concept_hierarchy', 'U') IS NULL
CREATE TABLE synthea_micro_achilles_results.dbo.concept_hierarchy
(
  concept_id             INT,
  concept_name           VARCHAR(400),
  treemap                VARCHAR(20),
  concept_hierarchy_type VARCHAR(20),
  level1_concept_name    VARCHAR(255),
  level2_concept_name    VARCHAR(255),
  level3_concept_name    VARCHAR(255),
  level4_concept_name    VARCHAR(255)
)

/***********************************************************/
/***** Populate the hierarchy lookup table per treemap *****/
/***********************************************************/
TRUNCATE TABLE synthea_micro_achilles_results.dbo.concept_hierarchy

/********** CONDITION/CONDITION_ERA **********/
INSERT INTO synthea_micro_achilles_results.dbo.concept_hierarchy
        (concept_id, concept_name, treemap, concept_hierarchy_type, level1_concept_name, level2_concept_name, level3_concept_name, level4_concept_name)
SELECT
        snomed.concept_id,
  snomed.concept_name AS concept_name,
        CAST('Condition' AS VARCHAR(20)) AS treemap,
        CAST(NULL AS VARCHAR(20)) as concept_hierarchy_type,
        pt_to_hlt.pt_concept_name as level1_concept_name,
        hlt_to_hlgt.hlt_concept_name as level2_concept_name,
        hlgt_to_soc.hlgt_concept_name as level3_concept_name,
        soc.concept_name AS level4_concept_name
FROM (
        SELECT
                concept_id,
                concept_name
        FROM synthea_micro.dbo.concept
        WHERE domain_id = 'Condition'
) snomed
LEFT JOIN (
        SELECT
                c1.concept_id      AS snomed_concept_id,
                max(c2.concept_id) AS pt_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.domain_id = 'Condition'
                AND ca1.min_levels_of_separation = 1
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'MedDRA'
        GROUP BY c1.concept_id
) snomed_to_pt ON snomed.concept_id = snomed_to_pt.snomed_concept_id
LEFT JOIN (
        SELECT
                c1.concept_id      AS pt_concept_id,
                c1.concept_name    AS pt_concept_name,
                max(c2.concept_id) AS hlt_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.vocabulary_id = 'MedDRA'
                AND ca1.min_levels_of_separation = 1
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'MedDRA'
        GROUP BY c1.concept_id, c1.concept_name
) pt_to_hlt ON snomed_to_pt.pt_concept_id = pt_to_hlt.pt_concept_id
LEFT JOIN (
        SELECT
                c1.concept_id      AS hlt_concept_id,
                c1.concept_name    AS hlt_concept_name,
                max(c2.concept_id) AS hlgt_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.vocabulary_id = 'MedDRA'
                AND ca1.min_levels_of_separation = 1
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'MedDRA'
        GROUP BY c1.concept_id, c1.concept_name
) hlt_to_hlgt ON pt_to_hlt.hlt_concept_id = hlt_to_hlgt.hlt_concept_id
LEFT JOIN (
        SELECT
                c1.concept_id      AS hlgt_concept_id,
                c1.concept_name    AS hlgt_concept_name,
                max(c2.concept_id) AS soc_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.vocabulary_id = 'MedDRA'
                AND ca1.min_levels_of_separation = 1
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'MedDRA'
        GROUP BY c1.concept_id, c1.concept_name
) hlgt_to_soc ON hlt_to_hlgt.hlgt_concept_id = hlgt_to_soc.hlgt_concept_id
LEFT JOIN synthea_micro.dbo.concept soc ON hlgt_to_soc.soc_concept_id = soc.concept_id

/********** DRUG **********/
INSERT INTO synthea_micro_achilles_results.dbo.concept_hierarchy
        (concept_id, concept_name, treemap, concept_hierarchy_type, level1_concept_name, level2_concept_name, level3_concept_name, level4_concept_name)
SELECT
        rxnorm.concept_id,
        rxnorm.concept_name AS concept_name,
        CAST('Drug' AS VARCHAR(20)) AS treemap,
        CAST(NULL AS VARCHAR(20)) as concept_hierarchy_type,
        rxnorm.rxnorm_ingredient_concept_name as level1_concept_name,
        atc5_to_atc3.atc5_concept_name as level2_concept_name,
        atc3_to_atc1.atc3_concept_name as level3_concept_name,
        atc1.concept_name AS level4_concept_name
FROM (
        SELECT
                c1.concept_id,
                c1.concept_name,
                c2.concept_id   AS rxnorm_ingredient_concept_id,
                c2.concept_name AS RxNorm_ingredient_concept_name
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.domain_id = 'Drug'
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.domain_id = 'Drug'
                AND c2.concept_class_id = 'Ingredient'
) rxnorm
LEFT JOIN (
        SELECT
                c1.concept_id      AS rxnorm_ingredient_concept_id,
                max(c2.concept_id) AS atc5_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.domain_id = 'Drug'
                AND c1.concept_class_id = 'Ingredient'
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'ATC'
                AND c2.concept_class_id = 'ATC 4th'
        GROUP BY c1.concept_id
) rxnorm_to_atc5 ON rxnorm.rxnorm_ingredient_concept_id = rxnorm_to_atc5.rxnorm_ingredient_concept_id
LEFT JOIN (
        SELECT
                c1.concept_id      AS atc5_concept_id,
                c1.concept_name    AS atc5_concept_name,
                max(c2.concept_id) AS atc3_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.vocabulary_id = 'ATC'
                AND c1.concept_class_id = 'ATC 4th'
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'ATC'
                AND c2.concept_class_id = 'ATC 2nd'
        GROUP BY c1.concept_id, c1.concept_name
) atc5_to_atc3 ON rxnorm_to_atc5.atc5_concept_id = atc5_to_atc3.atc5_concept_id
LEFT JOIN (
        SELECT
                c1.concept_id      AS atc3_concept_id,
                c1.concept_name    AS atc3_concept_name,
                max(c2.concept_id) AS atc1_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.vocabulary_id = 'ATC'
                AND c1.concept_class_id = 'ATC 2nd'
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'ATC'
                AND c2.concept_class_id = 'ATC 1st'
        GROUP BY c1.concept_id, c1.concept_name
) atc3_to_atc1 ON atc5_to_atc3.atc3_concept_id = atc3_to_atc1.atc3_concept_id
LEFT JOIN synthea_micro.dbo.concept atc1 ON atc3_to_atc1.atc1_concept_id = atc1.concept_id

/********** DRUG_ERA **********/
INSERT INTO synthea_micro_achilles_results.dbo.concept_hierarchy
        (concept_id, concept_name, treemap, concept_hierarchy_type, level1_concept_name, level2_concept_name, level3_concept_name, level4_concept_name)
SELECT
        rxnorm.rxnorm_ingredient_concept_id as concept_id,
        rxnorm.rxnorm_ingredient_concept_name as concept_name,
        CAST('Drug Era' AS VARCHAR(20)) AS treemap,
        CAST(NULL AS VARCHAR(20)) as concept_hierarchy_type,
        atc5_to_atc3.atc5_concept_name as level1_concept_name,
        atc3_to_atc1.atc3_concept_name as level2_concept_name,
        atc1.concept_name AS level3_concept_name,
        CAST(NULL AS VARCHAR(255)) as level4_concept_name
FROM (
        SELECT
                c2.concept_id   AS rxnorm_ingredient_concept_id,
                c2.concept_name AS RxNorm_ingredient_concept_name
        FROM synthea_micro.dbo.concept c2
        WHERE c2.domain_id = 'Drug'
                AND c2.concept_class_id = 'Ingredient'
) rxnorm
LEFT JOIN (
        SELECT
                c1.concept_id      AS rxnorm_ingredient_concept_id,
                max(c2.concept_id) AS atc5_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.domain_id = 'Drug'
                AND c1.concept_class_id = 'Ingredient'
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'ATC'
                AND c2.concept_class_id = 'ATC 4th'
        GROUP BY c1.concept_id
) rxnorm_to_atc5 ON rxnorm.rxnorm_ingredient_concept_id = rxnorm_to_atc5.rxnorm_ingredient_concept_id
LEFT JOIN (
        SELECT
                c1.concept_id      AS atc5_concept_id,
                c1.concept_name    AS atc5_concept_name,
                max(c2.concept_id) AS atc3_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.vocabulary_id = 'ATC'
                AND c1.concept_class_id = 'ATC 4th'
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'ATC'
                AND c2.concept_class_id = 'ATC 2nd'
        GROUP BY c1.concept_id, c1.concept_name
) atc5_to_atc3 ON rxnorm_to_atc5.atc5_concept_id = atc5_to_atc3.atc5_concept_id
LEFT JOIN (
        SELECT
                c1.concept_id      AS atc3_concept_id,
                c1.concept_name    AS atc3_concept_name,
                max(c2.concept_id) AS atc1_concept_id
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.concept_ancestor ca1 ON c1.concept_id = ca1.descendant_concept_id
                AND c1.vocabulary_id = 'ATC'
                AND c1.concept_class_id = 'ATC 2nd'
        INNER JOIN synthea_micro.dbo.concept c2 ON ca1.ancestor_concept_id = c2.concept_id
                AND c2.vocabulary_id = 'ATC'
                AND c2.concept_class_id = 'ATC 1st'
        GROUP BY c1.concept_id, c1.concept_name
) atc3_to_atc1 ON atc5_to_atc3.atc3_concept_id = atc3_to_atc1.atc3_concept_id
LEFT JOIN synthea_micro.dbo.concept atc1 ON atc3_to_atc1.atc1_concept_id = atc1.concept_id

/********** MEASUREMENT **********/
INSERT INTO synthea_micro_achilles_results.dbo.concept_hierarchy
        (concept_id, concept_name, treemap, concept_hierarchy_type, level1_concept_name, level2_concept_name, level3_concept_name, level4_concept_name)
SELECT
        m.concept_id,
        m.concept_name AS concept_name,
        CAST('Measurement' AS VARCHAR(20)) AS treemap,
        CAST(NULL AS VARCHAR(20)) as concept_hierarchy_type,
        CAST(max(c1.concept_name) AS VARCHAR(255)) AS level1_concept_name,
        CAST(max(c2.concept_name) AS VARCHAR(255)) AS level2_concept_name,
        CAST(max(c3.concept_name) AS VARCHAR(255)) AS level3_concept_name,
        CAST(NULL AS VARCHAR(255)) as level4_concept_name
FROM (
        SELECT DISTINCT
                concept_id,
                concept_name
        FROM synthea_micro.dbo.concept c
        WHERE domain_id = 'Measurement'
) m
LEFT JOIN synthea_micro.dbo.concept_ancestor ca1 ON M.concept_id = ca1.DESCENDANT_CONCEPT_ID AND ca1.min_levels_of_separation = 1
LEFT JOIN synthea_micro.dbo.concept c1 ON ca1.ANCESTOR_CONCEPT_ID = c1.concept_id
LEFT JOIN synthea_micro.dbo.concept_ancestor ca2 ON c1.concept_id = ca2.DESCENDANT_CONCEPT_ID AND ca2.min_levels_of_separation = 1
LEFT JOIN synthea_micro.dbo.concept c2 ON ca2.ANCESTOR_CONCEPT_ID = c2.concept_id
LEFT JOIN synthea_micro.dbo.concept_ancestor ca3 ON c2.concept_id = ca3.DESCENDANT_CONCEPT_ID AND ca3.min_levels_of_separation = 1
LEFT JOIN synthea_micro.dbo.concept c3 ON ca3.ANCESTOR_CONCEPT_ID = c3.concept_id
GROUP BY M.concept_id, M.concept_name

/********** OBSERVATION **********/
INSERT INTO synthea_micro_achilles_results.dbo.concept_hierarchy
        (concept_id, concept_name, treemap, concept_hierarchy_type, level1_concept_name, level2_concept_name, level3_concept_name, level4_concept_name)
SELECT
        obs.concept_id,
        obs.concept_name AS concept_name,
        CAST('Observation' AS VARCHAR(20)) AS treemap,
        CAST(NULL AS VARCHAR(20)) as concept_hierarchy_type,
        CAST(max(c1.concept_name) AS VARCHAR(255)) AS level1_concept_name,
        CAST(max(c2.concept_name) AS VARCHAR(255)) AS level2_concept_name,
        CAST(max(c3.concept_name) AS VARCHAR(255)) AS level3_concept_name,
        CAST(NULL AS VARCHAR(255)) as level4_concept_name
FROM (
        SELECT
                concept_id,
                concept_name
        FROM synthea_micro.dbo.concept
        WHERE domain_id = 'Observation'
) obs
LEFT JOIN synthea_micro.dbo.concept_ancestor ca1 ON obs.concept_id = ca1.DESCENDANT_CONCEPT_ID AND ca1.min_levels_of_separation = 1
LEFT JOIN synthea_micro.dbo.concept c1 ON ca1.ANCESTOR_CONCEPT_ID = c1.concept_id
LEFT JOIN synthea_micro.dbo.concept_ancestor ca2 ON c1.concept_id = ca2.DESCENDANT_CONCEPT_ID AND ca2.min_levels_of_separation = 1
LEFT JOIN synthea_micro.dbo.concept c2 ON ca2.ANCESTOR_CONCEPT_ID = c2.concept_id
LEFT JOIN synthea_micro.dbo.concept_ancestor ca3 ON c2.concept_id = ca3.DESCENDANT_CONCEPT_ID AND ca3.min_levels_of_separation = 1
LEFT JOIN synthea_micro.dbo.concept c3 ON ca3.ANCESTOR_CONCEPT_ID = c3.concept_id
GROUP BY obs.concept_id, obs.concept_name

/********** PROCEDURE **********/
INSERT INTO synthea_micro_achilles_results.dbo.concept_hierarchy
        (concept_id, concept_name, treemap, concept_hierarchy_type, level1_concept_name, level2_concept_name, level3_concept_name, level4_concept_name)
SELECT
        procs.concept_id,
        CAST(procs.proc_concept_name AS VARCHAR(400)) AS concept_name,
        CAST('Procedure' AS VARCHAR(20)) AS treemap,
        CAST(NULL AS VARCHAR(20)) as concept_hierarchy_type,
        CAST(max(proc_hierarchy.os3_concept_name) AS VARCHAR(255)) AS level1_concept_name,
        CAST(max(proc_hierarchy.os2_concept_name) AS VARCHAR(255)) AS level2_concept_name,
        CAST(max(proc_hierarchy.os1_concept_name) AS VARCHAR(255)) AS level3_concept_name,
        CAST(NULL AS VARCHAR(255)) as level4_concept_name
FROM
(
        SELECT
                c1.concept_id,
                CONCAT(v1.vocabulary_name, ' ', c1.concept_code, ': ', c1.concept_name) AS proc_concept_name
        FROM synthea_micro.dbo.concept c1
        INNER JOIN synthea_micro.dbo.vocabulary v1 ON c1.vocabulary_id = v1.vocabulary_id
        WHERE c1.domain_id = 'Procedure'
) procs
LEFT JOIN (
        SELECT
                ca0.DESCENDANT_CONCEPT_ID,
                max(ca0.ancestor_concept_id) AS ancestor_concept_id
        FROM synthea_micro.dbo.concept_ancestor ca0
        INNER JOIN (
                SELECT DISTINCT c2.concept_id AS os3_concept_id
                FROM synthea_micro.dbo.concept_ancestor ca1
                INNER JOIN synthea_micro.dbo.concept c1 ON ca1.DESCENDANT_CONCEPT_ID = c1.concept_id
                INNER JOIN synthea_micro.dbo.concept_ancestor ca2 ON c1.concept_id = ca2.ANCESTOR_CONCEPT_ID
                INNER JOIN synthea_micro.dbo.concept c2 ON ca2.DESCENDANT_CONCEPT_ID = c2.concept_id
                WHERE ca1.ancestor_concept_id = 4040390
                        AND ca1.Min_LEVELS_OF_SEPARATION = 2
                        AND ca2.MIN_LEVELS_OF_SEPARATION = 1
        ) t1 ON ca0.ANCESTOR_CONCEPT_ID = t1.os3_concept_id
        GROUP BY ca0.descendant_concept_id
) ca1 ON procs.concept_id = ca1.DESCENDANT_CONCEPT_ID
LEFT JOIN (
        SELECT
                proc_by_os1.os1_concept_name,
                proc_by_os2.os2_concept_name,
                proc_by_os3.os3_concept_name,
                proc_by_os3.os3_concept_id
        FROM (
                SELECT
                        DESCENDANT_CONCEPT_ID AS os1_concept_id,
                        concept_name          AS os1_concept_name
                FROM synthea_micro.dbo.concept_ancestor ca1
                INNER JOIN synthea_micro.dbo.concept c1 ON ca1.DESCENDANT_CONCEPT_ID = c1.concept_id
                WHERE ancestor_concept_id = 4040390
                        AND Min_LEVELS_OF_SEPARATION = 1
        ) proc_by_os1
        INNER JOIN (
                SELECT
                        max(c1.CONCEPT_ID) AS os1_concept_id,
                        c2.concept_id      AS os2_concept_id,
                        c2.concept_name    AS os2_concept_name
                FROM synthea_micro.dbo.concept_ancestor ca1
                INNER JOIN synthea_micro.dbo.concept c1 ON ca1.DESCENDANT_CONCEPT_ID = c1.concept_id
                INNER JOIN synthea_micro.dbo.concept_ancestor ca2 ON c1.concept_id = ca2.ANCESTOR_CONCEPT_ID
                INNER JOIN synthea_micro.dbo.concept c2 ON ca2.DESCENDANT_CONCEPT_ID = c2.concept_id
                WHERE ca1.ancestor_concept_id = 4040390
                        AND ca1.Min_LEVELS_OF_SEPARATION = 1
                        AND ca2.MIN_LEVELS_OF_SEPARATION = 1
                GROUP BY c2.concept_id, c2.concept_name
        ) proc_by_os2 ON proc_by_os1.os1_concept_id = proc_by_os2.os1_concept_id
        INNER JOIN (
                SELECT
                        max(c1.CONCEPT_ID) AS os2_concept_id,
                        c2.concept_id      AS os3_concept_id,
                        c2.concept_name    AS os3_concept_name
                FROM synthea_micro.dbo.concept_ancestor ca1
                INNER JOIN synthea_micro.dbo.concept c1 ON ca1.DESCENDANT_CONCEPT_ID = c1.concept_id
                INNER JOIN synthea_micro.dbo.concept_ancestor ca2 ON c1.concept_id = ca2.ANCESTOR_CONCEPT_ID
                INNER JOIN synthea_micro.dbo.concept c2 ON ca2.DESCENDANT_CONCEPT_ID = c2.concept_id
                WHERE ca1.ancestor_concept_id = 4040390
                        AND ca1.Min_LEVELS_OF_SEPARATION = 2
                        AND ca2.MIN_LEVELS_OF_SEPARATION = 1
                GROUP BY c2.concept_id, c2.concept_name
        ) proc_by_os3 ON proc_by_os2.os2_concept_id = proc_by_os3.os2_concept_id
) proc_hierarchy ON ca1.ancestor_concept_id = proc_hierarchy.os3_concept_id
GROUP BY procs.concept_id, procs.proc_concept_name

-- init heracles_analysis
TRUNCATE TABLE synthea_micro_achilles_results.dbo.heracles_analysis

insert into synthea_micro_achilles_results.dbo.heracles_analysis
(analysis_id,analysis_name,stratum_1_name,stratum_2_name,stratum_3_name,stratum_4_name,stratum_5_name,analysis_type)
select    0 as analysis_id,
CAST('Source name' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select    1 as analysis_id,
CAST('Number of persons' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select    2 as analysis_id,
CAST('Number of persons by gender' as VARCHAR(255)) as analysis_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select    3 as analysis_id,
CAST('Number of persons by year of birth' as VARCHAR(255)) as analysis_name,
CAST('year_of_birth' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select    4 as analysis_id,
CAST('Number of persons by race' as VARCHAR(255)) as analysis_name,
CAST('race_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select    5 as analysis_id,
CAST('Number of persons by ethnicity' as VARCHAR(255)) as analysis_name,
CAST('ethnicity_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select    7 as analysis_id,
CAST('Number of persons with invalid provider_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select    8 as analysis_id,
CAST('Number of persons with invalid location_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select    9 as analysis_id,
CAST('Number of persons with invalid care_site_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PERSON' as VARCHAR(255)) as analysis_type
union all
select  101 as analysis_id,
CAST('Number of persons by age, with age at first observation period' as VARCHAR(255)) as analysis_name,
CAST('age' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  102 as analysis_id,
CAST('Number of persons by gender by age, with age at first observation period' as VARCHAR(255)) as analysis_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('age' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  103 as analysis_id,
CAST('Distribution of age at first observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  104 as analysis_id,
CAST('Distribution of age at first observation period by gender' as VARCHAR(255)) as analysis_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  105 as analysis_id,
CAST('Length of observation (days) of first observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  106 as analysis_id,
CAST('Length of observation (days) of first observation period by gender' as VARCHAR(255)) as analysis_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  107 as analysis_id,
CAST('Length of observation (days) of first observation period by age decile' as VARCHAR(255)) as analysis_name,
CAST('age decile' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  108 as analysis_id,
CAST('Number of persons by length of first observation period, in 30d increments' as VARCHAR(255)) as analysis_name,
CAST('Observation period length 30d increments' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  109 as analysis_id,
CAST('Number of persons with continuous observation in each year' as VARCHAR(255)) as analysis_name,
CAST('calendar year' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  110 as analysis_id,
CAST('Number of persons with continuous observation in each month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  111 as analysis_id,
CAST('Number of persons by observation period start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  112 as analysis_id,
CAST('Number of persons by observation period end month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  113 as analysis_id,
CAST('Number of persons by number of observation periods' as VARCHAR(255)) as analysis_name,
CAST('number of observation periods' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  114 as analysis_id,
CAST('Number of persons with observation period before year-of-birth' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  115 as analysis_id,
CAST('Number of persons with observation period end < observation period start' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  116 as analysis_id,
CAST('Number of persons with at least one day of observation in each year by gender and age decile' as VARCHAR(255)) as analysis_name,
CAST('calendar year' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST('age decile' as VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  117 as analysis_id,
CAST('Number of persons with at least one day of observation in each month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  200 as analysis_id,
CAST('Number of persons with at least one visit occurrence, by visit_concept_id' as VARCHAR(255)) as analysis_name,
CAST('visit_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  201 as analysis_id,
CAST('Number of visit occurrence records, by visit_concept_id' as VARCHAR(255)) as analysis_name,
CAST('visit_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  202 as analysis_id,
CAST('Number of persons by visit occurrence start month, by visit_concept_id' as VARCHAR(255)) as analysis_name,
CAST('visit_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar month' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  203 as analysis_id,
CAST('Number of distinct visit occurrence concepts per person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  204 as analysis_id,
CAST('Number of persons with at least one visit occurrence, by visit_concept_id by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('visit_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar year' as VARCHAR(255)) as stratum_2_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_3_name,
CAST('age decile' as VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  206 as analysis_id,
CAST('Distribution of age by visit_concept_id' as VARCHAR(255)) as analysis_name,
CAST('visit_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  207 as analysis_id,
CAST('Number of visit records with invalid person_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  208 as analysis_id,
CAST('Number of visit records outside valid observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  209 as analysis_id,
CAST('Number of visit records with end date < start date' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  210 as analysis_id,
CAST('Number of visit records with invalid care_site_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  211 as analysis_id,
CAST('Distribution of length of stay by visit_concept_id' as VARCHAR(255)) as analysis_name,
CAST('visit_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  220 as analysis_id,
CAST('Number of visit occurrence records by visit occurrence start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('VISITS' as VARCHAR(255)) as analysis_type
union all
select  400 as analysis_id,
CAST('Number of persons with at least one condition occurrence, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  401 as analysis_id,
CAST('Number of condition occurrence records, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  402 as analysis_id,
CAST('Number of persons by condition occurrence start month, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar month' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  403 as analysis_id,
CAST('Number of distinct condition occurrence concepts per person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  404 as analysis_id,
CAST('Number of persons with at least one condition occurrence, by condition_concept_id by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar year' as VARCHAR(255)) as stratum_2_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_3_name,
CAST('age decile' as VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  405 as analysis_id,
CAST('Number of condition occurrence records, by condition_concept_id by condition_type_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('condition_type_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  406 as analysis_id,
CAST('Distribution of age by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  409 as analysis_id,
CAST('Number of condition occurrence records with invalid person_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  410 as analysis_id,
CAST('Number of condition occurrence records outside valid observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  411 as analysis_id,
CAST('Number of condition occurrence records with end date < start date' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  412 as analysis_id,
CAST('Number of condition occurrence records with invalid provider_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  413 as analysis_id,
CAST('Number of condition occurrence records with invalid visit_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  420 as analysis_id,
CAST('Number of condition occurrence records by condition occurrence start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION' as VARCHAR(255)) as analysis_type
union all
select  500 as analysis_id,
CAST('Number of persons with death, by cause_of_death_concept_id' as VARCHAR(255)) as analysis_name,
CAST('cause_of_death_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  501 as analysis_id,
CAST('Number of records of death, by cause_of_death_concept_id' as VARCHAR(255)) as analysis_name,
CAST('cause_of_death_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  502 as analysis_id,
CAST('Number of persons by death month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  504 as analysis_id,
CAST('Number of persons with a death, by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('calendar year' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST('age decile' as VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  505 as analysis_id,
CAST('Number of death records, by death_type_concept_id' as VARCHAR(255)) as analysis_name,
CAST('death_type_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  506 as analysis_id,
CAST('Distribution of age at death by gender' as VARCHAR(255)) as analysis_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  509 as analysis_id,
CAST('Number of death records with invalid person_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  510 as analysis_id,
CAST('Number of death records outside valid observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  511 as analysis_id,
CAST('Distribution of time from death to last condition' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  512 as analysis_id,
CAST('Distribution of time from death to last drug' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  513 as analysis_id,
CAST('Distribution of time from death to last visit' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  514 as analysis_id,
CAST('Distribution of time from death to last procedure' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  515 as analysis_id,
CAST('Distribution of time from death to last observation' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DEATH' as VARCHAR(255)) as analysis_type
union all
select  600 as analysis_id,
CAST('Number of persons with at least one procedure occurrence, by procedure_concept_id' as VARCHAR(255)) as analysis_name,
CAST('procedure_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  601 as analysis_id,
CAST('Number of procedure occurrence records, by procedure_concept_id' as VARCHAR(255)) as analysis_name,
CAST('procedure_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  602 as analysis_id,
CAST('Number of persons by procedure occurrence start month, by procedure_concept_id' as VARCHAR(255)) as analysis_name,
CAST('procedure_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar month' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  603 as analysis_id,
CAST('Number of distinct procedure occurrence concepts per person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  604 as analysis_id,
CAST('Number of persons with at least one procedure occurrence, by procedure_concept_id by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('procedure_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar year' as VARCHAR(255)) as stratum_2_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_3_name,
CAST('age decile' as VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  605 as analysis_id,
CAST('Number of procedure occurrence records, by procedure_concept_id by procedure_type_concept_id' as VARCHAR(255)) as analysis_name,
CAST('procedure_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('procedure_type_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  606 as analysis_id,
CAST('Distribution of age by procedure_concept_id' as VARCHAR(255)) as analysis_name,
CAST('procedure_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  609 as analysis_id,
CAST('Number of procedure occurrence records with invalid person_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  610 as analysis_id,
CAST('Number of procedure occurrence records outside valid observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  612 as analysis_id,
CAST('Number of procedure occurrence records with invalid provider_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  613 as analysis_id,
CAST('Number of procedure occurrence records with invalid visit_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  620 as analysis_id,
CAST('Number of procedure occurrence records  by procedure occurrence start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('PROCEDURE' as VARCHAR(255)) as analysis_type
union all
select  700 as analysis_id,
CAST('Number of persons with at least one drug exposure, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  701 as analysis_id,
CAST('Number of drug exposure records, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  702 as analysis_id,
CAST('Number of persons by drug exposure start month, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar month' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  703 as analysis_id,
CAST('Number of distinct drug exposure concepts per person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  704 as analysis_id,
CAST('Number of persons with at least one drug exposure, by drug_concept_id by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar year' as VARCHAR(255)) as stratum_2_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_3_name,
CAST('age decile' as VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  705 as analysis_id,
CAST('Number of drug exposure records, by drug_concept_id by drug_type_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('drug_type_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  706 as analysis_id,
CAST('Distribution of age by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  709 as analysis_id,
CAST('Number of drug exposure records with invalid person_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  710 as analysis_id,
CAST('Number of drug exposure records outside valid observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  711 as analysis_id,
CAST('Number of drug exposure records with end date < start date' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  712 as analysis_id,
CAST('Number of drug exposure records with invalid provider_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  713 as analysis_id,
CAST('Number of drug exposure records with invalid visit_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  715 as analysis_id,
CAST('Distribution of days_supply by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  716 as analysis_id,
CAST('Distribution of refills by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  717 as analysis_id,
CAST('Distribution of quantity by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  720 as analysis_id,
CAST('Number of drug exposure records  by drug exposure start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG' as VARCHAR(255)) as analysis_type
union all
select  800 as analysis_id,
CAST('Number of persons with at least one observation occurrence, by observation_concept_id' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  801 as analysis_id,
CAST('Number of observation occurrence records, by observation_concept_id' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  802 as analysis_id,
CAST('Number of persons by observation occurrence start month, by observation_concept_id' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar month' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  803 as analysis_id,
CAST('Number of distinct observation occurrence concepts per person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  804 as analysis_id,
CAST('Number of persons with at least one observation occurrence, by observation_concept_id by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar year' as VARCHAR(255)) as stratum_2_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_3_name,
CAST('age decile' as VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  805 as analysis_id,
CAST('Number of observation occurrence records, by observation_concept_id by observation_type_concept_id' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('observation_type_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  806 as analysis_id,
CAST('Distribution of age by observation_concept_id' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  807 as analysis_id,
CAST('Number of observation occurrence records, by observation_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('unit_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  809 as analysis_id,
CAST('Number of observation records with invalid person_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  810 as analysis_id,
CAST('Number of observation records outside valid observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  812 as analysis_id,
CAST('Number of observation records with invalid provider_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  813 as analysis_id,
CAST('Number of observation records with invalid visit_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  814 as analysis_id,
CAST('Number of observation records with no value (numeric, string, or concept)' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  815 as analysis_id,
CAST('Distribution of numeric values, by observation_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  816 as analysis_id,
CAST('Distribution of low range, by observation_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  817 as analysis_id,
CAST('Distribution of high range, by observation_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  818 as analysis_id,
CAST('Number of observation records below/within/above normal range, by observation_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  820 as analysis_id,
CAST('Number of observation records  by observation start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('OBSERVATION' as VARCHAR(255)) as analysis_type
union all
select  900 as analysis_id,
CAST('Number of persons with at least one drug era, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  901 as analysis_id,
CAST('Number of drug era records, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  902 as analysis_id,
CAST('Number of persons by drug era start month, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar month' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  903 as analysis_id,
CAST('Number of distinct drug era concepts per person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  904 as analysis_id,
CAST('Number of persons with at least one drug era, by drug_concept_id by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar year' as VARCHAR(255)) as stratum_2_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_3_name,
CAST('age decile' as VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  906 as analysis_id,
CAST('Distribution of age by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  907 as analysis_id,
CAST('Distribution of drug era length, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  908 as analysis_id,
CAST('Number of drug eras without valid person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  909 as analysis_id,
CAST('Number of drug eras outside valid observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  910 as analysis_id,
CAST('Number of drug eras with end date < start date' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select  920 as analysis_id,
CAST('Number of drug era records  by drug era start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('DRUG_ERA' as VARCHAR(255)) as analysis_type
union all
select 1000 as analysis_id,
CAST('Number of persons with at least one condition era, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1001 as analysis_id,
CAST('Number of condition era records, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1002 as analysis_id,
CAST('Number of persons by condition era start month, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar month' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1003 as analysis_id,
CAST('Number of distinct condition era concepts per person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1004 as analysis_id,
CAST('Number of persons with at least one condition era, by condition_concept_id by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar year' as VARCHAR(255)) as stratum_2_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_3_name,
CAST('age decile' as VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1006 as analysis_id,
CAST('Distribution of age by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1007 as analysis_id,
CAST('Distribution of condition era length, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1008 as analysis_id,
CAST('Number of condition eras without valid person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1009 as analysis_id,
CAST('Number of condition eras outside valid observation period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1010 as analysis_id,
CAST('Number of condition eras with end date < start date' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1020 as analysis_id,
CAST('Number of condition era records by condition era start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CONDITION_ERA' as VARCHAR(255)) as analysis_type
union all
select 1100 as analysis_id,
CAST('Number of persons by location 3-digit zip' as VARCHAR(255)) as analysis_name,
CAST('3-digit zip' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('LOCATION' as VARCHAR(255)) as analysis_type
union all
select 1101 as analysis_id,
CAST('Number of persons by location state' as VARCHAR(255)) as analysis_name,
CAST('state' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('LOCATION' as VARCHAR(255)) as analysis_type
union all
select 1200 as analysis_id,
CAST('Number of persons by place of service' as VARCHAR(255)) as analysis_name,
CAST('place_of_service_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CARE_SITE' as VARCHAR(255)) as analysis_type
union all
select 1201 as analysis_id,
CAST('Number of visits by place of service' as VARCHAR(255)) as analysis_name,
CAST('place_of_service_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('CARE_SITE' as VARCHAR(255)) as analysis_type
union all
select 1300 as analysis_id,
CAST('Number of persons with at least one measurement occurrence, by measurement_concept_id' as VARCHAR(255)) as analysis_name,
CAST('measurement_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1301 as analysis_id,
CAST('Number of measurement occurrence records, by measurement_concept_id' as VARCHAR(255)) as analysis_name,
CAST('measurement_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1302 as analysis_id,
CAST('Number of persons by measurement occurrence start month, by measurement_concept_id' as VARCHAR(255)) as analysis_name,
CAST('measurement_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar month' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1303 as analysis_id,
CAST('Number of distinct measurement occurrence concepts per person' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1304 as analysis_id,
CAST('Number of persons with at least one measurement occurrence, by measurement_concept_id by calendar year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('measurement_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('calendar year' as VARCHAR(255)) as stratum_2_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_3_name,
CAST('age decile' as VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1305 as analysis_id,
CAST('Number of measurement occurrence records, by measurement_concept_id by measurement_type_concept_id' as VARCHAR(255)) as analysis_name,
CAST('measurement_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('measurement_type_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1306 as analysis_id,
CAST('Distribution of age by measurement_concept_id' as VARCHAR(255)) as analysis_name,
CAST('measurement_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1307 as analysis_id,
CAST('Number of measurement occurrence records, by measurement_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST('measurement_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('unit_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1309 as analysis_id,
CAST('Number of measurement records with invalid person_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1310 as analysis_id,
CAST('Number of measurement records outside valid measurement period' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1312 as analysis_id,
CAST('Number of measurement records with invalid provider_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1313 as analysis_id,
CAST('Number of measurement records with invalid visit_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1314 as analysis_id,
CAST('Number of measurement records with no value (numeric, string, or concept)' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1315 as analysis_id,
CAST('Distribution of numeric values, by measurement_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1316 as analysis_id,
CAST('Distribution of low range, by measurement_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1317 as analysis_id,
CAST('Distribution of high range, by measurement_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1318 as analysis_id,
CAST('Number of measurement records below/within/above normal range, by measurement_concept_id and unit_concept_id' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1320 as analysis_id,
CAST('Number of measurement records  by measurement start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('MEASUREMENT' as VARCHAR(255)) as analysis_type
union all
select 1700 as analysis_id,
CAST('Number of records by cohort_definition_id' as VARCHAR(255)) as analysis_name,
CAST('cohort_definition_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT' as VARCHAR(255)) as analysis_type
union all
select 1701 as analysis_id,
CAST('Number of records with cohort end date < cohort start date' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT' as VARCHAR(255)) as analysis_type
union all
select 1800 as analysis_id,
CAST('Number of persons by age, with age at cohort start' as VARCHAR(255)) as analysis_name,
CAST('age' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1801 as analysis_id,
CAST('Distribution of age at cohort start' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1802 as analysis_id,
CAST('Distribution of age at cohort start by gender' as VARCHAR(255)) as analysis_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1803 as analysis_id,
CAST('Distribution of age at cohort start by cohort start year' as VARCHAR(255)) as analysis_name,
CAST('calendar year' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1804 as analysis_id,
CAST('Number of persons by duration from cohort start to cohort end, in 30d increments' as VARCHAR(255)) as analysis_name,
CAST('Cohort period length 30d increments' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1805 as analysis_id,
CAST('Number of persons by duration from observation start to cohort start, in 30d increments' as VARCHAR(255)) as analysis_name,
CAST('Baseline period length 30d increments' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1806 as analysis_id,
CAST('Number of persons by duration from cohort start to observation end, in 30d increments' as VARCHAR(255)) as analysis_name,
CAST('Follow-up period length 30d increments' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1807 as analysis_id,
CAST('Number of persons by duration from cohort end to observation end, in 30d increments' as VARCHAR(255)) as analysis_name,
CAST('Post-cohort period length 30d increments' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1808 as analysis_id,
CAST('Distribution of duration (days) from cohort start to cohort end' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1809 as analysis_id,
CAST('Distribution of duration (days) from cohort start to cohort end, by gender' as VARCHAR(255)) as analysis_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1810 as analysis_id,
CAST('Distribution of duration (days) from cohort start to cohort end, by age decile' as VARCHAR(255)) as analysis_name,
CAST('age decile' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1811 as analysis_id,
CAST('Distribution of duration (days) from observation start to cohort start' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1812 as analysis_id,
CAST('Distribution of duration (days) from cohort start to observation end' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1813 as analysis_id,
CAST('Distribution of duration (days) from cohort end to observation end' as VARCHAR(255)) as analysis_name,
CAST(NULL AS VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1814 as analysis_id,
CAST('Number of persons by cohort start year by gender by age decile' as VARCHAR(255)) as analysis_name,
CAST('calendar year' as VARCHAR(255)) as stratum_1_name,
CAST('gender_concept_id' as VARCHAR(255)) as stratum_2_name,
CAST('age decile' as VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1815 as analysis_id,
CAST('Number of persons by cohort start month' as VARCHAR(255)) as analysis_name,
CAST('calendar month' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1816 as analysis_id,
CAST('Number of persons by number of cohort periods' as VARCHAR(255)) as analysis_name,
CAST('number of cohort periods' as VARCHAR(255)) as stratum_1_name,
CAST(NULL AS VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1820 as analysis_id,
CAST('Number of persons by duration from cohort start to first occurrence of condition occurrence, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1821 as analysis_id,
CAST('Number of events by duration from cohort start to all occurrences of condition occurrence, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1830 as analysis_id,
CAST('Number of persons by duration from cohort start to first occurrence of procedure occurrence, by procedure_concept_id' as VARCHAR(255)) as analysis_name,
CAST('procedure_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1831 as analysis_id,
CAST('Number of events by duration from cohort start to all occurrences of procedure occurrence, by procedure_concept_id' as VARCHAR(255)) as analysis_name,
CAST('procedure_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1840 as analysis_id,
CAST('Number of persons by duration from cohort start to first occurrence of drug exposure, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1841 as analysis_id,
CAST('Number of events by duration from cohort start to all occurrences of drug exposure, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1850 as analysis_id,
CAST('Number of persons by duration from cohort start to first occurrence of observation, by observation_concept_id' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1851 as analysis_id,
CAST('Number of events by duration from cohort start to all occurrences of observation, by observation_concept_id' as VARCHAR(255)) as analysis_name,
CAST('observation_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1860 as analysis_id,
CAST('Number of persons by duration from cohort start to first occurrence of condition era, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1861 as analysis_id,
CAST('Number of events by duration from cohort start to all occurrences of condition era, by condition_concept_id' as VARCHAR(255)) as analysis_name,
CAST('condition_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1870 as analysis_id,
CAST('Number of persons by duration from cohort start to first occurrence of drug era, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 1871 as analysis_id,
CAST('Number of events by duration from cohort start to all occurrences of drug era, by drug_concept_id' as VARCHAR(255)) as analysis_name,
CAST('drug_concept_id' as VARCHAR(255)) as stratum_1_name,
CAST('time-to-event 30d increments' as VARCHAR(255)) as stratum_2_name,
CAST(NULL AS VARCHAR(255)) as stratum_3_name,
CAST(NULL AS VARCHAR(255)) as stratum_4_name,
CAST(NULL AS VARCHAR(255)) as stratum_5_name,
CAST('COHORT_SPECIFIC_ANALYSES' as VARCHAR(255)) as analysis_type
union all
select 4000 as analysis_id,
CAST('Distribution of observation period days by period_id in the 365 days prior to first cohort_start_date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4001 as analysis_id,
CAST('Number of subjects with visits by period_id, by visit_concept_id, by visit_type_concept_id in the 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4002 as analysis_id,
CAST('Distribution of number of visit occurrence records per subject by period_id, by visit_concept_id, by visit_type_concept_id in 365d prior to cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4003 as analysis_id,
CAST('Distribution of number of visit dates per subject by period_id, by visit_concept_id, by visit_type_concept_id in 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4003 as analysis_id,
CAST('Distribution of number of visit dates per subject by period_id, by visit_concept_id, by visit_type_concept_id in 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4004 as analysis_id,
CAST('Distribution of number of care_site+visit dates per subject by period_id, by visit_concept_id, by visit_type_concept_id in 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4005 as analysis_id,
CAST('Distribution of length of stay for inpatient visits per subject by period_id, by visit_concept_id, by visit_type_concept_id in the 365 days prior to first cohort_start_date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4006 as analysis_id,
CAST('Distribution of observation period days per subject, by period_id during cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4007 as analysis_id,
CAST('Number of subjects with visits by period_id, by visit_concept_id, by visit_type_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4008 as analysis_id,
CAST('Distribution of number of visit occurrence records per subject by period_id, by visit_concept_id, by visit_type_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4009 as analysis_id,
CAST('Distribution of number of visit dates per subject by period_id, by visit_concept_id, by visit_type_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4010 as analysis_id,
CAST('Distribution of number of care_site+visit dates per subject by period_id, by visit_concept_id, by visit_type_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4011 as analysis_id,
CAST('Distribution of length of stay for inpatient visits per subject by period_id, by visit_concept_id, by visit_type_concept_id during cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4012 as analysis_id,
CAST('Number of subjects with Drug Exposure by period_id, by drug_concept_id, by drug_type_concept_id in the 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4013 as analysis_id,
CAST('Distribution of number of Drug Exposure records per subject, by period_id, by drug_concept_id in 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4014 as analysis_id,
CAST('Distribution of greater than 0 drug day supply per subject by period_id, by drug_concept_id in the 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4015 as analysis_id,
CAST('Distribution of greater than 0 drug quantity per subject by period_id, by drug_concept_id in the 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4016 as analysis_id,
CAST('Number of subjects with Drug Exposure by period_id, by drug_concept_id, by drug_type_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4017 as analysis_id,
CAST('Distribution of number of Drug Exposure records per subject, by period_id, by drug_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4018 as analysis_id,
CAST('Distribution of greater than 0 drug day supply per subject by period_id, by drug_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4019 as analysis_id,
CAST('Distribution of greater than 0 drug quantity per subject by period_id, by drug_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4020 as analysis_id,
CAST('Distribution of greater than 0 US$ cost per subject by period_id, by visit_concept_id, by visit_type_concept_id, by cost_concept_id, by cost_type_concept_id in the 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4021 as analysis_id,
CAST('Distribution of greater than 0 US$ cost per subject by period_id, by visit_concept_id, by visit_type_concept_id, by cost_concept_id, by cost_type_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4022 as analysis_id,
CAST('Distribution of greater than 0 US$ cost per subject by period_id, by drug_concept_id, by drug_type_concept_id, by cost_concept_id, by cost_type_concept_id in the 365d prior to first cohort start date' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type
union all
select 4023 as analysis_id,
CAST('Distribution of greater than 0 US$ cost per subject by period_id, by drug_concept_id, by drug_type_concept_id, by cost_concept_id, by cost_type_concept_id, by cost_type_concept_id during the cohort period' as VARCHAR(255)) as analysis_name,
NULL as stratum_1_name,
NULL as stratum_2_name,
NULL as stratum_3_name,
NULL as stratum_4_name,
NULL as stratum_5_name,
CAST('HEALTHCARE_UTILIZATION' as VARCHAR(255)) as analysis_type


select digits.n  into #digits
FROM (
       select 0 as n union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9
) digits

SELECT
        y1.n + (10*y10.n) + (100*y100.n) + (1000*y1000.n) AS d_years,
        mths.n as d_months
into #generate_dates
FROM
#digits y1,
#digits y10,
(select 0 n union all select 1 union all select 9) y100,
(select 1 n union all select 2) y1000,
(select 1 n union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9 union all select 10 union all select 11 union all select 12) mths
        where y1.n + (10*y10.n) + (100*y100.n) + (1000*y1000.n) >= 1900 and y1.n + (10*y10.n) + (100*y100.n) + (1000*y1000.n) < 2100


select DATEFROMPARTS(d_years, d_months,01) as generated_date
into #yearly_dates
from #generate_dates
where d_months = 1


SELECT DATEFROMPARTS(d_years, d_months, 01) as generated_date
into #monthly_dates
from #generate_dates


select dateadd(d, (7 * seq.rn), DATEFROMPARTS(1900,1,7)) as generated_date -- first sunday in 1900
into #weekly_dates
from (
        select  d1.n + (10 * d10.n) + (100 * d100.n) + (1000 * d1000.n) as rn
        from #digits d1, #digits d10, #digits d100, #digits d1000
) seq

SELECT DATEFROMPARTS(d_years, d_months, 1) as generated_date
into #quarterly_dates
        from #generate_dates
        where d_months in (1,4,7,10)


-- monthly dates
-- ADD UNION ALLs for additional period definitions
select *
into #temp_period
from (
select CAST('Monthly' AS VARCHAR(255)) as period_name
  , 1 as period_order
  , CAST( 'mm' AS VARCHAR(50)) as period_type
  , md.generated_date as period_start_date
  , dateadd(mm,1,md.generated_date) as period_end_date
from #monthly_dates md
UNION ALL
select CAST('Weekly' AS VARCHAR(255)) as period_name
  , 2 as period_order
  , CAST('ww' AS VARCHAR(50)) as period_type
  , wd.generated_date as period_start_date
  , dateadd(d, 7, wd.generated_date) as period_end_date
from #weekly_dates wd
where wd.generated_date >= DATEFROMPARTS(1900,1,1) and wd.generated_date < DATEFROMPARTS(2100,1,1)
UNION ALL
select CAST('Quarterly' AS VARCHAR(255)) as period_name
  , 3 as period_order
  , CAST('qq' AS VARCHAR(50)) as period_type
  , qd.generated_date as period_start_date
  , dateadd(mm,3,qd.generated_date) as period_end_date
from #quarterly_dates qd
UNION ALL
select CAST('Yearly' AS VARCHAR(255)) as period_name
  , 4 as period_order
  , CAST('yy' AS VARCHAR(50)) as period_type
  , yd.generated_date as period_start_date
  , dateadd(yy,1,yd.generated_date) as period_end_date
from #yearly_dates yd
) monthlyDates

TRUNCATE TABLE synthea_micro_achilles_results.dbo.heracles_periods

INSERT INTO synthea_micro_achilles_results.dbo.heracles_periods (period_id, period_name, period_order, period_type, period_start_date, period_end_date)
select CAST(row_number() over (order by period_order, period_start_date) AS INT) as period_id
                        , period_name, period_order, period_type, period_start_date, period_end_date
from #temp_period

truncate table #digits

drop table #digits

truncate table #generate_dates

drop table #generate_dates

truncate table #yearly_dates

drop table #yearly_dates

truncate table #quarterly_dates

drop table #quarterly_dates

truncate table #monthly_dates

drop table #monthly_dates

truncate table #weekly_dates

drop table #weekly_dates

TRUNCATE TABLE #temp_period

DROP TABLE #temp_period

CREATE INDEX HRD_IDX_COHORT_DEF_ID ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS_DIST (cohort_definition_id)

CREATE INDEX HRD_IDX_COHORT_ID_ANALYSIS_ID ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS_DIST (cohort_definition_id, analysis_id)

CREATE INDEX HRD_IDX_COHORT_DEF_ID_DT ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS_DIST (cohort_definition_id, last_update_time)

CREATE INDEX HRD_IDX_COHORT_ID_FIRST_RES ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS_DIST (cohort_definition_id, analysis_id, count_value, stratum_1)

CREATE INDEX HR_IDX_COHORT_DEF_ID ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS (cohort_definition_id)

CREATE INDEX HR_IDX_COHORT_ID_ANALYSIS_ID ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS (cohort_definition_id, analysis_id)

CREATE INDEX HR_IDX_COHORT_ANALYSIS_CONCEPT ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS (cohort_definition_id, analysis_id) WHERE stratum_2 <> ''

CREATE INDEX HR_IDX_COHORT_DEF_ID_DT ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS (cohort_definition_id, last_update_time)

CREATE INDEX HR_IDX_COHORT_ID_FIRST_RES ON synthea_micro_achilles_results.dbo.HERACLES_RESULTS (cohort_definition_id, analysis_id, count_value, stratum_1)

CREATE INDEX HH_IDX_COHORT_ID_ANALYSIS_ID ON synthea_micro_achilles_results.dbo.HERACLES_HEEL_RESULTS (cohort_definition_id, analysis_id)

CREATE INDEX idx_heracles_periods_startdate ON synthea_micro_achilles_results.dbo.heracles_periods (period_start_date)

CREATE INDEX idx_heracles_periods_end_date ON synthea_micro_achilles_results.dbo.heracles_periods (period_end_date)

CREATE INDEX idx_cohort_sample_element_rank ON synthea_micro_achilles_results.dbo.cohort_sample_element (cohort_sample_id, rank_value)

CREATE INDEX idx_pathway_events_combo_id ON synthea_micro_achilles_results.dbo.pathway_analysis_events (combo_id)

2022-05-27 20:13:27,533 20:13:27.533 [main] INFO  (OmopDatabaseConnectionFactory.java:84) - OPEN CONNECTIONS: 0
2022-05-27 20:13:27,534 20:13:27.534 [main] INFO  (CreateAtlasSqlServerDependencies.java:26) - Done.
2022-05-27 20:13:27,534 20:13:27.534 [main] INFO  (InstallAtlasDependencies.java:21) - Done.


Done.



D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\fhir-to-omop\target\fhir-to-omop>

After the run has completed, you should see something like the following in PostgreSql (using pgAdmin4)

After the run has completed, you should see an _achilles_results and _achilles_temp databases for your original OMOP/CDM database. In this case, or original database was synthea_micro and synthea_micro_achilles_results and synthea_micro_achilles_temp were created by the tool.

Note also, the _achilles_results database has been populated with a number of tables.

PostgreSql Server: Create PostgreSql Server

The PostgreSql Server needs to be created manually using pgAdmin 4. To create the PostgreSql Server, open pgAdmin 4, Select Servers->Register->Server... and then fill out the information as shown below.


Enter the following values:

After the server has been created, you should be able to see it as shown below.

Deploy WebAPI: Download, Build, and Deploy the WebAPI Application

This section will walk through the process to download, build, and deploy the WebAPI application to Tomcat. The first time the WebAPI application is deployed, the tables required for the creation of the Atlas Datasource records will be created.

Download the WebAPI Application

Use Git to clone and checkout the latest version of WebAPI as shown below.
git clone https://github.com/OHDSI/WebAPI
cd WebAPI
git checkout v2.11.0
Screen shot of checkout of WebAPI application.

Configure the WebAPI Application

The WebAPI application is configured using a settings.xml file. Create the settings.xml file by doing the following.

      <datasource.url>jdbc:postgresql://localhost:5432/OHDSI</datasource.url>
      <datasource.username>ohdsi_admin_user</datasource.username>
      <datasource.password>stripedbass</datasource.password>
      ...
      <flyway.datasource.password>stripedbass</flyway.datasource.password>
      


Build the WebAPI Application

Run the following cmd line command from the root WebAPI directory to use Maven to build the WebAPI application.

mvn clean package -DskipUnitTests -DskipITtests -s WebAPIConfig/settings.xml -P webapi-postgresql


Sample output from a build is shown below.

D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\WebAPI>mvn clean package -DskipUnitTests -DskipITtests -s WebAPIConfig/settings.xml -P webapi-postgresql
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< org.ohdsi:WebAPI >--------------------------
[INFO] Building WebAPI 2.11.0
[INFO] --------------------------------[ war ]---------------------------------
Downloading from ohdsi: https://repo.ohdsi.org/nexus/content/groups/public/net/minidev/json-smart/maven-metadata.xml
Downloading from central: https://repo.maven.apache.org/maven2/net/minidev/json-smart/maven-metadata.xml
Downloaded from central: https://repo.maven.apache.org/maven2/net/minidev/json-smart/maven-metadata.xml (1.2 kB at 1.1 kB/s)
Downloaded from ohdsi: https://repo.ohdsi.org/nexus/content/groups/public/net/minidev/json-smart/maven-metadata.xml (1.2 kB at 1.1 kB/s)
Downloading from sonatype-nexus-snapshots: https://oss.sonatype.org/content/repositories/snapshots/net/minidev/json-smart/maven-metadata.xml
[WARNING] The artifact org.apache.commons:commons-io:jar:1.3.2 has been relocated to commons-io:commons-io:jar:1.3.2: https://issues.sonatype.org/browse/MVNCENTRAL-244
Downloading from ohdsi: https://repo.ohdsi.org/nexus/content/groups/public/org/ohdsi/standardized-analysis-specs/1.2.1-SNAPSHOT/maven-metadata.xml
Downloading from maven-default-http-blocker: http://0.0.0.0/org/ohdsi/standardized-analysis-specs/1.2.1-SNAPSHOT/maven-metadata.xml
Downloaded from ohdsi: https://repo.ohdsi.org/nexus/content/groups/public/org/ohdsi/standardized-analysis-specs/1.2.1-SNAPSHOT/maven-metadata.xml (786 B at 12 kB/s)
[WARNING] Could not transfer metadata org.ohdsi:standardized-analysis-specs:1.2.1-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/): transfer failed for http://0.0.0.0/org/ohdsi/standardized-analysis-specs/1.2.1-SNAPSHOT/maven-metadata.xml
[WARNING] org.ohdsi:standardized-analysis-specs:1.2.1-SNAPSHOT/maven-metadata.xmlfailed to transfer from http://0.0.0.0/ during a previous attempt. This failure was cached in the local repository and resolution will not be reattempted until the update interval of maven-default-http-blocker has elapsed or updates are forced. Original error: Could not transfer metadata org.ohdsi:standardized-analysis-specs:1.2.1-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/): transfer failed for http://0.0.0.0/org/ohdsi/standardized-analysis-specs/1.2.1-SNAPSHOT/maven-metadata.xml
Downloading from ohdsi: https://repo.ohdsi.org/nexus/content/groups/public/org/ohdsi/standardized-analysis-utils/1.2.1-SNAPSHOT/maven-metadata.xml
Downloading from maven-default-http-blocker: http://0.0.0.0/org/ohdsi/standardized-analysis-utils/1.2.1-SNAPSHOT/maven-metadata.xml
Downloaded from ohdsi: https://repo.ohdsi.org/nexus/content/groups/public/org/ohdsi/standardized-analysis-utils/1.2.1-SNAPSHOT/maven-metadata.xml (786 B at 11 kB/s)
[WARNING] Could not transfer metadata org.ohdsi:standardized-analysis-utils:1.2.1-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/): transfer failed for http://0.0.0.0/org/ohdsi/standardized-analysis-utils/1.2.1-SNAPSHOT/maven-metadata.xml
[WARNING] org.ohdsi:standardized-analysis-utils:1.2.1-SNAPSHOT/maven-metadata.xmlfailed to transfer from http://0.0.0.0/ during a previous attempt. This failure was cached in the local repository and resolution will not be reattempted until the update interval of maven-default-http-blocker has elapsed or updates are forced. Original error: Could not transfer metadata org.ohdsi:standardized-analysis-utils:1.2.1-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/): transfer failed for http://0.0.0.0/org/ohdsi/standardized-analysis-utils/1.2.1-SNAPSHOT/maven-metadata.xml
Downloading from ohdsi: https://repo.ohdsi.org/nexus/content/groups/public/com/odysseusinc/arachne/arachne-common-utils/1.16.2-SNAPSHOT/maven-metadata.xml
Downloading from maven-default-http-blocker: http://0.0.0.0/com/odysseusinc/arachne/arachne-common-utils/1.16.2-SNAPSHOT/maven-metadata.xml
Downloaded from ohdsi: https://repo.ohdsi.org/nexus/content/groups/public/com/odysseusinc/arachne/arachne-common-utils/1.16.2-SNAPSHOT/maven-metadata.xml (799 B at 10 kB/s)
[WARNING] Could not transfer metadata com.odysseusinc.arachne:arachne-common-utils:1.16.2-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/): transfer failed for http://0.0.0.0/com/odysseusinc/arachne/arachne-common-utils/1.16.2-SNAPSHOT/maven-metadata.xml
[WARNING] com.odysseusinc.arachne:arachne-common-utils:1.16.2-SNAPSHOT/maven-metadata.xmlfailed to transfer from http://0.0.0.0/ during a previous attempt. This failure was cached in the local repository and resolution will not be reattempted until the update interval of maven-default-http-blocker has elapsed or updates are forced. Original error: Could not transfer metadata com.odysseusinc.arachne:arachne-common-utils:1.16.2-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/): transfer failed for http://0.0.0.0/com/odysseusinc/arachne/arachne-common-utils/1.16.2-SNAPSHOT/maven-metadata.xml
Downloading from ohdsi: https://repo.ohdsi.org/nexus/content/groups/public/com/odysseusinc/arachne/arachne-commons-bundle/1.16.2-SNAPSHOT/maven-metadata.xml
Downloading from maven-default-http-blocker: http://0.0.0.0/com/odysseusinc/arachne/arachne-commons-bundle/1.16.2-SNAPSHOT/maven-metadata.xml
Downloaded from ohdsi: https://repo.ohdsi.org/nexus/content/groups/public/com/odysseusinc/arachne/arachne-commons-bundle/1.16.2-SNAPSHOT/maven-metadata.xml (626 B at 8.8 kB/s)
[WARNING] Could not transfer metadata com.odysseusinc.arachne:arachne-commons-bundle:1.16.2-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/): transfer failed for http://0.0.0.0/com/odysseusinc/arachne/arachne-commons-bundle/1.16.2-SNAPSHOT/maven-metadata.xml
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ WebAPI ---
[INFO]
[INFO] --- git-commit-id-plugin:4.0.0:revision (default) @ WebAPI ---
[INFO]
[INFO] --- gmaven-plugin:1.5:execute (add-git-branch-info) @ WebAPI ---
[WARNING] The artifact xml-apis:xml-apis:jar:2.0.2 has been relocated to xml-apis:xml-apis:jar:1.0.b2
[INFO]
[INFO] --- spring-boot-maven-plugin:1.5.22.RELEASE:build-info (default) @ WebAPI ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ WebAPI ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] Copying 1219 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ WebAPI ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1103 source files to D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\WebAPI\target\classes
[WARNING] /D:/_WORKSPACES/_ECLIPSE_WORKSPACE/workspace/WebAPI/src/main/java/org/ohdsi/webapi/shiro/realms/LdapRealm.java: Some input files use or override a deprecated API.
[WARNING] /D:/_WORKSPACES/_ECLIPSE_WORKSPACE/workspace/WebAPI/src/main/java/org/ohdsi/webapi/shiro/realms/LdapRealm.java: Recompile with -Xlint:deprecation for details.
[WARNING] /D:/_WORKSPACES/_ECLIPSE_WORKSPACE/workspace/WebAPI/src/main/java/org/ohdsi/webapi/feanalysis/domain/FeAnalysisWithCriteriaEntity.java: Some input files use unchecked or unsafe operations.
[WARNING] /D:/_WORKSPACES/_ECLIPSE_WORKSPACE/workspace/WebAPI/src/main/java/org/ohdsi/webapi/feanalysis/domain/FeAnalysisWithCriteriaEntity.java: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ WebAPI ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 84 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ WebAPI ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 64 source files to D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\WebAPI\target\test-classes
[WARNING] /D:/_WORKSPACES/_ECLIPSE_WORKSPACE/workspace/WebAPI/src/test/java/org/ohdsi/webapi/cdmresults/cache/CDMResultsCacheTest.java: D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\WebAPI\src\test\java\org\ohdsi\webapi\cdmresults\cache\CDMResultsCacheTest.java uses unchecked or unsafe operations.
[WARNING] /D:/_WORKSPACES/_ECLIPSE_WORKSPACE/workspace/WebAPI/src/test/java/org/ohdsi/webapi/cdmresults/cache/CDMResultsCacheTest.java: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ WebAPI ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-failsafe-plugin:2.18.1:integration-test (default) @ WebAPI ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:3.3.1:war (default-war) @ WebAPI ---
[INFO] Packaging webapp
[INFO] Assembling webapp [WebAPI] in [D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\WebAPI\target\WebAPI]
[INFO] Processing war project
[INFO] Copying webapp resources [D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\WebAPI\src\main\webapp]
[INFO] Building war: D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\WebAPI\target\WebAPI.war
[INFO] Packaging classes
[INFO] Building jar: D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\WebAPI\target\WebAPI-classes.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.5.22.RELEASE:repackage (default) @ WebAPI ---
[INFO]
[INFO] --- miredot-plugin:2.2:restdoc (default) @ WebAPI ---
[WARNING] Rest Framework not explicitly set, using JAX-RS by default.
[INFO] Building reflective model of API and reading annotations...
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[class org.springframework.jdbc.CannotGetJdbcConnectionException], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[class java.lang.Exception], dontRollbackOn=[class org.springframework.dao.EmptyResultDataAccessException])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.annotation.PostConstruct()
[INFO] Unknown annotation on service method: skipped @org.ohdsi.webapi.achilles.aspect.AchillesCache(value=datadensity)
[INFO] Unknown annotation on service method: skipped @org.ohdsi.webapi.achilles.aspect.AchillesCache(value=person)
[INFO] Unknown annotation on service method: skipped @org.ohdsi.webapi.achilles.aspect.AchillesCache(value=death)
[INFO] Unknown annotation on service method: skipped @org.springframework.scheduling.annotation.Scheduled(cron=${cdm.cache.cron.expression}, fixedRateString=, zone=, fixedDelay=-1, initialDelayString=, fixedRate=-1, initialDelay=-1, fixedDelayString=)
[INFO] Unknown annotation on service method: skipped @org.ohdsi.webapi.achilles.aspect.AchillesCache(value=observationperiod)
[INFO] Unknown annotation on service method: skipped @org.ohdsi.webapi.achilles.aspect.AchillesCache(value=achillesHeel)
[INFO] Unknown annotation on service method: skipped @org.ohdsi.webapi.achilles.aspect.AchillesCache(value=treemap)
[INFO] Unknown annotation on service method: skipped @org.ohdsi.webapi.achilles.aspect.AchillesCache(value=drilldown)
[INFO] Unknown annotation on service method: skipped @org.ohdsi.webapi.achilles.aspect.AchillesCache(value=dashboard)
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[WARNING] When JsonTypeInfo.use is different from CLASS the JsonSubTypes annotation must als be present. Involved class: org.ohdsi.analysis.prediction.design.ModelSettings
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=true, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=true, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=true, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.ohdsi.webapi.shiro.annotations.DataSourceAccess()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=true, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @org.ohdsi.webapi.shiro.annotations.SourceKey()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.ohdsi.webapi.shiro.annotations.DataSourceAccess()
[INFO] Unknown annotation on field of BeanParam class: skipped @org.ohdsi.webapi.shiro.annotations.SourceKey()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @javax.annotation.PostConstruct()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on field of BeanParam class: skipped @javax.ws.rs.core.Context()
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=true, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=true, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackForClassName=[], noRollbackFor=[], value=, timeout=-1, rollbackFor=[])
[INFO] Built.
[INFO] Reading javadoc comments from sourcefiles...
[INFO] Read.
[INFO] Merging reflective and javadoc models...
[INFO] Merged.
[INFO] Performing issue analysis...
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: POST /cohortdefinition/printfriendly/cohort
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: GET /cohortdefinition/{id}/copy
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: GET /cohort-characterization/design
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: GET /cohort-characterization/generation/{generationId}/design
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: PUT /cohortdefinition/{id}/version/{version}/createAsset
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: POST /pathway-analysis/import
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: PUT /cohortdefinition/{id}
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: GET /cohortresults/{sourceKey}/{id}/summarydata
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: POST /cohortdefinition/sql
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: PUT /cohort-characterization/{id}
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: GET /prediction/{id}/export
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: POST /cohortdefinition/checkV2
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: POST /ir/sql
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: GET /cohort-characterization/{id}/version/{version}
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: POST /cohort-characterization/check
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: POST /cohort-characterization/{id}
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: GET /cohortresults/{sourceKey}/{id}/summaryanalyses
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: POST /prediction/import
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: GET /cohortanalysis/{id}/summary
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: GET /cohort-characterization/{id}/design
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: POST /cohort-characterization/
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: POST /cohort-characterization/import
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: POST /cohortdefinition/check
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: POST /cohortdefinition/
[INFO] The response or body payload of following rest-endpoint is very large and may therefore take very long to render: PUT /cohort-characterization/{id}/version/{version}/createAsset
[INFO] Analysis done.
[INFO] Constructing Html documentation
[INFO] Your html documentation was generated in D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\WebAPI\target\miredot
[INFO] MireDot: Completed
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  42.801 s
[INFO] Finished at: 2022-05-27T22:47:14-04:00
[INFO] ------------------------------------------------------------------------

D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\WebAPI>

Install and Configure Apache Tomcat 8

Download Apache Tomcat

Apache Tomcat can be downlaoded from https://tomcat.apache.org/download-80.cgi. Older versions are available in the archive. The install of Atlas documented here was implemented and testing using Tomcat 8.5.78. Install Tomcat by extracting the contents of the zip file (here the extracted file was renamed to apache).


Two modifications need to be made to Tomcat to enable the deployment of Atlas.

Create an Admin User

Navigate to and open apache/conf/tomcat-users.xml.


Add the following lines to the <tomcat-users> section.
  <role rolename="manager-gui"/>
  <user username="tomcat" password="mypassword" roles="manager-gui"/>

Increase multi-part Upload Size

Navigate to and open apache/webapps/manage/WEB-INF/web.xml.


Change the following lines to read as shown below (we are increasing the size by a factor of 10). These lines are towards the beginning of the file.
    <multipart-config>
      <!-- 50MB max -->
      <max-file-size>524288000</max-file-size>
      <max-request-size>524288000</max-request-size>
      <file-size-threshold>0</file-size-threshold>
    </multipart-config>

Start Tomcat and Deploy the WebAPI Application

Start Tomcat

Start Tomcat by navigating to apache/bin and execute the following
catalina.bat start
This will launch the Apache Tomcat server in a new cmd window. Note, to stop Tomcat execute the following
catalina.bat stop

Deploy the WebAPI Application

Open the Tomcat Web Application Manager in a browser window using
http://localhost:8080/manager/html


Scroll down to the "WAR file to deploy" section. Select "Choose File" and navigate to the war file created by the Maven (MVN) build. The war file will be in the WebAPI/target folder. After selecting the war file, select "Deploy" to deploy the WebAPI application.

Select the war file in WebAPI/target as shown below

Note, after deploying the WebAPI for the first time, the source and source_daimon tables will be created in PostgreSql.


PostgreSql Data Source: Run the Create Atlas Datasource Script (atlas2) from the fhir-to-omop Tool

Now that the source and source_daimon tables exist, the script to create the Atlas data sources can be run. This script can be run using the fhir-to-omop tool as shown below.
fhir-to-omop>fhir-to-omop.bat atlas2


Output from a typical run is shown below.

D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\fhir-to-omop\target\fhir-to-omop>fhir-to-omop.bat atlas2


# ----------------------------------------
#
# running fhir to omop
#
# ----------------------------------------

Working Directory: D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\fhir-to-omop\target\fhir-to-omop
Welcome to fhir-to-omop
10:43:55,162 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
10:43:55,162 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
10:43:55,162 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/D:/_WORKSPACES/_ECLIPSE_WORKSPACE/workspace/fhir-to-omop/target/fhir-to-omop/fhir-to-omop.jar!/logback.xml]
10:43:55,162 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs multiple times on the classpath.
10:43:55,162 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/D:/_WORKSPACES/_ECLIPSE_WORKSPACE/workspace/fhir-to-omop/target/fhir-to-omop/fhir-to-omop.jar!/logback.xml]
10:43:55,162 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/D:/_WORKSPACES/_ECLIPSE_WORKSPACE/workspace/fhir-to-omop/target/fhir-to-omop/lib/thread-tool-0.0.2.jar!/logback.xml]
10:43:55,172 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@e45f292 - URL [jar:file:/D:/_WORKSPACES/_ECLIPSE_WORKSPACE/workspace/fhir-to-omop/target/fhir-to-omop/fhir-to-omop.jar!/logback.xml] is not of type file
10:43:55,242 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
10:43:55,243 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
10:43:55,247 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
10:43:55,250 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
10:43:55,277 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [ch.qos.logback] to ERROR
10:43:55,277 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [ca.uhn.fhir] to ERROR
10:43:55,277 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
10:43:55,277 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
10:43:55,277 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
10:43:55,278 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@5f2108b5 - Registering current configuration as safe fallback point

Getting config file from: D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\fhir-to-omop\target\fhir-to-omop
------------
app.properties:
D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\fhir-to-omop\target\fhir-to-omop\app.properties
Exists: true
InputStream: java.io.FileInputStream@1e397ed7
------------
2022-05-28 10:43:55,290 10:43:55.290 [main] INFO  (PostgresDatabaseConnectionFactory.java:38) - Getting connection for url:
jdbc:postgresql://localhost:5433/OHDSI?user=postgres&password=stripedbass
2022-05-28 10:43:55,483 10:43:55.483 [main] INFO  (InstallAtlasDatasource.java:26) - Deleting from webapi.source_daimon
2022-05-28 10:43:55,490 10:43:55.490 [main] INFO  (InstallAtlasDatasource.java:30) - Deleting from webapi.source
2022-05-28 10:43:55,491 10:43:55.491 [main] INFO  (InstallAtlasDatasource.java:34) - getting sql script...
2022-05-28 10:43:55,492 10:43:55.492 [main] INFO  (InstallAtlasDatasource.java:36) - executing script...
INSERT INTO webapi.source (source_id, source_name, source_key, source_connection, source_dialect)
SELECT nextval('webapi.source_sequence'), 'Localhost CDM', 'MY_CDM', 'jdbc:sqlserver://localhost:1433;encrypt=false;databaseName=synthea_micro;user=synthea_micro;password=Sneaker01', 'sql server'

INSERT INTO webapi.source_daimon (source_daimon_id, source_id, daimon_type, table_qualifier, priority)
SELECT nextval('webapi.source_daimon_sequence'), source_id, 0, 'synthea_micro', 0
FROM webapi.source
WHERE source_key = 'MY_CDM'


INSERT INTO webapi.source_daimon (source_daimon_id, source_id, daimon_type, table_qualifier, priority)
SELECT nextval('webapi.source_daimon_sequence'), source_id, 1, 'synthea_micro.dbo', 1
FROM webapi.source
WHERE source_key = 'MY_CDM'


INSERT INTO webapi.source_daimon (source_daimon_id, source_id, daimon_type, table_qualifier, priority)
SELECT nextval('webapi.source_daimon_sequence'), source_id, 2, 'synthea_micro_achilles_results.dbo', 1
FROM webapi.source
WHERE source_key = 'MY_CDM'


INSERT INTO webapi.source_daimon (source_daimon_id, source_id, daimon_type, table_qualifier, priority)
SELECT nextval('webapi.source_daimon_sequence'), source_id, 5, 'synthea_micro_achilles_temp.dbo', 0
FROM webapi.source
WHERE source_key = 'MY_CDM'


2022-05-28 10:43:55,499 10:43:55.499 [main] INFO  (InstallAtlasDatasource.java:41) - Done creating data source.


Done.



D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\fhir-to-omop\target\fhir-to-omop>

Run Achilles: Run the Achilles Scripts

Now that all of our data tables have been created, we can run Achilles to populate the Achilles (Data Source) tables. Data from these tables are used to populate the reports in the "Data Sources" section of Atlas.

To install and run Achilles run the following scripts.

Edit the init-params-achilles.r script to use your settings. Run each of these scripts from RStudio. The install-achilles.r script only needs to be run once. The other scripts can be run each time the data need to be refreshed.

Deploy Atlas: Download and Deploy Atlas to Apache Tomcat

Clone and Checkout Atlas from Github

Deploying Atlas from this point consists of downloading Atlas from Github, running the npm builder, and then copying the Atlas project to the Tomcat webapps folder and renameing it to "atlas" (lower case "a") as described below. More information on installing Atlas can be found here.

Clone and Checkout Atlas

Clone and checkout Atlas from Github by running the following commads from a cmd prompt as shown below.
https://github.com/OHDSI/Atlas
cd Atlas
git checkout v2.11.0

Run the NPM build for Atlas

The NPM build can now be run by executing the following from the Atlas directory that was created by cloning the application from Github.
npm run build
Full output from a sample run is shown below.

D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\Atlas>npm run build

> atlas@2.11.0 build
> npm run prep && npm run build:dev


> atlas@2.11.0 prep
> npm i && npm run clean && npm run genversion

npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated @babel/polyfill@7.12.1:  This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
npm WARN deprecated core-js@2.6.12: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.

added 377 packages, and audited 378 packages in 26s

22 packages are looking for funding
  run `npm fund` for details

2 moderate severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

> atlas@2.11.0 clean
> rimraf ./js/assets/bundle && rimraf ./js/assets/fonts && rimraf ./js/assets/images


> atlas@2.11.0 genversion
> genversion -s js/version/version.js && r_js -convert js/version js/ && rimraf js/version


> atlas@2.11.0 build:dev
> node build/optimize.js && npm run compress

[BABEL] Note: The code generator has deoptimised the styling of undefined as it exceeds the max of 500KB.
[BABEL] Note: The code generator has deoptimised the styling of undefined as it exceeds the max of 500KB.

> atlas@2.11.0 compress
> terser ./js/assets/bundle/bundle.js -o ./js/assets/bundle/bundle.js -c --source-map

npm notice
npm notice New minor version of npm available! 8.3.1 -> 8.11.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.11.0
npm notice Run npm install -g npm@8.11.0 to update!
npm notice

D:\_WORKSPACES\_ECLIPSE_WORKSPACE\workspace\Atlas>

Deploy Atlas to Tomcat

Stop and restart Tomcat if it is currently running. Copy the entire Atlas folder to apache/webapps.

Copy this dir:


To this dir (rename Atlas to atlas):


Restart Tomcat (note, in v2.11.0 there is a bug that causes an exception regarding not finding an achilles_heel_results table). This exception can be ignored.
catalina.bat start
Open a broser and navigate to the application, select Data Sources, Select your Data Source, Select the "Person" report.
http://localhost:8080/atlas
The data from your CDM should be represented in this report. This is what the report looks like for our synthea_micro data set.