text: IF OBJECT_ID('testing.cdm_testing_jmdc.test_results', 'U') IS NOT NULL DROP TABLE testing.cdm_testing_jmdc.test_results;
  CREATE TABLE testing.cdm_testing_jmdc.test_results (id INT, description VARCHAR(512), test VARCHAR(256), status VARCHAR(5));
  -- 101: Person id
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 101 AS id, 'Person id' AS description, 'Expect person' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.person WHERE person_id = '101' AND person_source_value = 'M000000101') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 102: Person gender mappings
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 102 AS id, 'Person gender mappings' AS description, 'Expect person' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.person WHERE person_id = '102' AND gender_concept_id = '8507' AND gender_source_value = 'male') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 102 AS id, 'Person gender mappings' AS description, 'Expect person' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.person WHERE person_id = '103' AND gender_concept_id = '8532' AND gender_source_value = 'female') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 103: Person year and month of birth
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 103 AS id, 'Person year and month of birth' AS description, 'Expect person' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.person WHERE person_id = '104' AND year_of_birth = '1975') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 103 AS id, 'Person year and month of birth' AS description, 'Expect person' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.person WHERE person_id = '104' AND month_of_birth = '8') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 201: Observation period person id
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 201 AS id, 'Observation period person id' AS description, 'Expect observation_period' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.observation_period WHERE person_id = '201') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 202: Observation period start date
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 202 AS id, 'Observation period start date' AS description, 'Expect observation_period' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.observation_period WHERE person_id = '202' AND observation_period_start_date = '20100101') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 203: Observation period end date
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 203 AS id, 'Observation period end date' AS description, 'Expect observation_period' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.observation_period WHERE person_id = '203' AND observation_period_end_date = '20141231') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 204: Observation period type
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 204 AS id, 'Observation period type' AS description, 'Expect observation_period' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.observation_period WHERE person_id = '204' AND period_type_concept_id = '44814722') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 301: Care site id
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 301 AS id, 'Care site id' AS description, 'Expect care_site' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.care_site WHERE care_site_id = '10000001' AND care_site_source_value = 'F0000001') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 401: Visit occurrence and person id
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 401 AS id, 'Visit occurrence and person id' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '401' AND person_id = '401') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 402: Visit concept ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 402 AS id, 'Visit concept ID' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '402' AND person_id = '402' AND visit_concept_id = '9202') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 402 AS id, 'Visit concept ID' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '403' AND person_id = '402' AND visit_concept_id = '9201') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 402 AS id, 'Visit concept ID' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '404' AND person_id = '402' AND visit_concept_id = '9201') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 403: Visit start date without other info
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 403 AS id, 'Visit start date without other info' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '406' AND person_id = '403' AND visit_start_date = '2010-02-15') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 404: Visit start date with admission date in month of care
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 404 AS id, 'Visit start date with admission date in month of care' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '407' AND person_id = '404' AND visit_start_date = '2010-02-05') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 405: Visit start date with admission date before month of care
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 405 AS id, 'Visit start date with admission date before month of care' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '408' AND person_id = '405' AND visit_start_date = '2010-02-01') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 406: Visit start date with prescription date
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 406 AS id, 'Visit start date with prescription date' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '409' AND person_id = '406' AND visit_start_date = '2010-02-05') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 407: Visit start date with procedure date
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 407 AS id, 'Visit start date with procedure date' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '410' AND person_id = '407' AND visit_start_date = '2010-02-05') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 408: Visit start date from start of medical care
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 408 AS id, 'Visit start date from start of medical care' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '411' AND person_id = '408' AND visit_start_date = '2010-02-08') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 409: Visit start date when start of medical care before month of care
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 409 AS id, 'Visit start date when start of medical care before month of care' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '412' AND person_id = '409' AND visit_start_date = '2010-02-15') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 410: Visit end date
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 410 AS id, 'Visit end date' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '413' AND person_id = '410' AND visit_end_date = '2010-02-17') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 410 AS id, 'Visit end date' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '414' AND person_id = '410' AND visit_end_date = '2010-04-07') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 410 AS id, 'Visit end date' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '415' AND person_id = '410' AND visit_end_date = '2010-06-03') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 410 AS id, 'Visit end date' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '416' AND person_id = '410' AND visit_end_date = '2010-08-07') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 410 AS id, 'Visit end date' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '417' AND person_id = '410' AND visit_end_date = '2010-10-07') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 410 AS id, 'Visit end date' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '418' AND person_id = '410' AND visit_end_date = '2010-12-07') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 410 AS id, 'Visit end date' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '419' AND person_id = '410' AND visit_end_date = '2011-02-17') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 411: Visit type concept ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 411 AS id, 'Visit type concept ID' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '420' AND person_id = '411' AND visit_type_concept_id = '44818517') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 412: Visit care site ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 412 AS id, 'Visit care site ID' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '421' AND person_id = '412' AND care_site_id = '10000002') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 413: Visit source value
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 413 AS id, 'Visit source value' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '422' AND person_id = '413' AND visit_source_value = 'Outpatient') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 414: Visit start date from multiple start of medical care records
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 414 AS id, 'Visit start date from multiple start of medical care records' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '423' AND person_id = '414' AND visit_start_date = '2010-02-12') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 414 AS id, 'Visit start date from multiple start of medical care records' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '424' AND person_id = '414' AND visit_start_date = '2010-03-08') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 414 AS id, 'Visit start date from multiple start of medical care records' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE visit_occurrence_id = '425' AND person_id = '414' AND visit_start_date = '2010-03-15') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 415: No visit occurrence when claim type is pharmacy
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 415 AS id, 'No visit occurrence when claim type is pharmacy' AS description, 'Expect visit_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.visit_occurrence WHERE person_id = '415') != 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 501: Provider ID from institution
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 501 AS id, 'Provider ID from institution' AS description, 'Expect provider' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.provider WHERE provider_id = '10000003' AND provider_source_value = 'F0000003') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 504: Provider specialty
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 504 AS id, 'Provider specialty' AS description, 'Expect provider' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.provider WHERE specialty_concept_id = '38004451' AND specialty_source_value = 'Cardiology' AND care_site_id = '10000005') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 601: Death person ID from diagnosis
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 601 AS id, 'Death person ID from diagnosis' AS description, 'Expect death' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.death WHERE person_id = '601') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 602: Death person ID from enrollement
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 602 AS id, 'Death person ID from enrollement' AS description, 'Expect death' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.death WHERE person_id = '602') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 603: Death date from diagnosis
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 603 AS id, 'Death date from diagnosis' AS description, 'Expect death' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.death WHERE person_id = '603' AND death_date = '2010-01-03') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 604: Death date from enrollment
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 604 AS id, 'Death date from enrollment' AS description, 'Expect death' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.death WHERE person_id = '604' AND death_date = '2011-12-31') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 605: Death date from multiple diagnoses
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 605 AS id, 'Death date from multiple diagnoses' AS description, 'Expect death' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.death WHERE person_id = '605' AND death_date = '2010-02-03') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 606: Death date from diagnosis and enrollment
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 606 AS id, 'Death date from diagnosis and enrollment' AS description, 'Expect death' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.death WHERE person_id = '606' AND death_date = '2010-01-03') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 607: Death type concept ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 607 AS id, 'Death type concept ID' AS description, 'Expect death' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.death WHERE person_id = '607' AND death_type_concept_id = '38003565') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 607 AS id, 'Death type concept ID' AS description, 'Expect death' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.death WHERE person_id = '608' AND death_type_concept_id = '38003567') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 701: Condition occurrence person ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 701 AS id, 'Condition occurrence person ID' AS description, 'Expect condition_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.condition_occurrence WHERE person_id = '701') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 702: Condition occurrence visit occurrence ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 702 AS id, 'Condition occurrence visit occurrence ID' AS description, 'Expect condition_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.condition_occurrence WHERE visit_occurrence_id = '702') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 703: Condition type concept ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 703 AS id, 'Condition type concept ID' AS description, 'Expect condition_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.condition_occurrence WHERE person_id = '703' AND visit_occurrence_id = '703' AND condition_type_concept_id = '38000215') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 703 AS id, 'Condition type concept ID' AS description, 'Expect condition_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.condition_occurrence WHERE person_id = '703' AND visit_occurrence_id = '704' AND condition_type_concept_id = '38000184') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 703 AS id, 'Condition type concept ID' AS description, 'Expect condition_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.condition_occurrence WHERE person_id = '703' AND visit_occurrence_id = '705' AND condition_type_concept_id = '38000184') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 704: Condition start date from admission date
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 704 AS id, 'Condition start date from admission date' AS description, 'Expect condition_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.condition_occurrence WHERE person_id = '704' AND visit_occurrence_id = '706' AND condition_start_date = '2010-01-01') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 705: Condition start date from claim date
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 705 AS id, 'Condition start date from claim date' AS description, 'Expect condition_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.condition_occurrence WHERE person_id = '705' AND visit_occurrence_id = '707' AND condition_start_date = '2010-02-15') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 706: Condition provider ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 706 AS id, 'Condition provider ID' AS description, 'Expect condition_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.condition_occurrence WHERE person_id = '706' AND visit_occurrence_id = '708' AND provider_id = '10000006') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 707: Condition concept ID and source values
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 707 AS id, 'Condition concept ID and source values' AS description, 'Expect condition_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.condition_occurrence WHERE person_id = '707' AND visit_occurrence_id = '709' AND condition_concept_id = '320128' AND condition_source_value = 'I10-' AND condition_source_concept_id = '45591453') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 708: Condition occurrence that are era-like
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 708 AS id, 'Condition occurrence that are era-like' AS description, 'Expect condition_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.condition_occurrence WHERE person_id = '708' AND condition_type_concept_id = '38000246' AND condition_start_date = '2010-01-05' AND condition_end_date = '2010-02-15') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 709: Condition occurrence that are era-like, start before OP start
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 709 AS id, 'Condition occurrence that are era-like, start before OP start' AS description, 'Expect condition_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.condition_occurrence WHERE person_id = '709' AND condition_type_concept_id = '38000246' AND condition_start_date = '2010-01-01' AND condition_end_date = '2010-02-15') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 710: Condition with suspicion flag
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 710 AS id, 'Condition with suspicion flag' AS description, 'Expect condition_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.condition_occurrence WHERE person_id = '710') != 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 801: Drug exposure person ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 801 AS id, 'Drug exposure person ID' AS description, 'Expect drug_exposure' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.drug_exposure WHERE person_id = '801') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 802: Drug exposure visit occurrence ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 802 AS id, 'Drug exposure visit occurrence ID' AS description, 'Expect drug_exposure' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.drug_exposure WHERE visit_occurrence_id = '802') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 803: Drug exposure type concept ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 803 AS id, 'Drug exposure type concept ID' AS description, 'Expect drug_exposure' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.drug_exposure WHERE visit_occurrence_id = '803' AND person_id = '803' AND drug_type_concept_id = '38000175') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 803 AS id, 'Drug exposure type concept ID' AS description, 'Expect drug_exposure' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.drug_exposure WHERE visit_occurrence_id = '804' AND person_id = '803' AND drug_type_concept_id = '38000180') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 803 AS id, 'Drug exposure type concept ID' AS description, 'Expect drug_exposure' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.drug_exposure WHERE visit_occurrence_id = '805' AND person_id = '803' AND drug_type_concept_id = '38000180') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 803 AS id, 'Drug exposure type concept ID' AS description, 'Expect drug_exposure' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.drug_exposure WHERE visit_occurrence_id = '806' AND person_id = '803' AND drug_type_concept_id = '38000175') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 804: Drug provider from institution ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 804 AS id, 'Drug provider from institution ID' AS description, 'Expect drug_exposure' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.drug_exposure WHERE visit_occurrence_id = '807' AND person_id = '804' AND provider_id = '10000007') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 806: Drug start date from prescription date
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 806 AS id, 'Drug start date from prescription date' AS description, 'Expect drug_exposure' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.drug_exposure WHERE visit_occurrence_id = '809' AND person_id = '806' AND drug_exposure_start_date = '2010-01-05') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 807: Drug start date from visit date
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 807 AS id, 'Drug start date from visit date' AS description, 'Expect drug_exposure' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.drug_exposure WHERE visit_occurrence_id IS NULL AND person_id = '807' AND drug_exposure_start_date = '2010-02-15') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 808: Drug end date
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 808 AS id, 'Drug end date' AS description, 'Expect drug_exposure' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.drug_exposure WHERE visit_occurrence_id = '811' AND person_id = '808' AND drug_exposure_end_date = '2010-01-08') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 808 AS id, 'Drug end date' AS description, 'Expect drug_exposure' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.drug_exposure WHERE visit_occurrence_id = '812' AND person_id = '808' AND drug_exposure_end_date = '2010-06-30') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 809: Drug days supply
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 809 AS id, 'Drug days supply' AS description, 'Expect drug_exposure' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.drug_exposure WHERE visit_occurrence_id = '813' AND person_id = '809' AND days_supply = '3') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 809 AS id, 'Drug days supply' AS description, 'Expect drug_exposure' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.drug_exposure WHERE visit_occurrence_id = '814' AND person_id = '809' AND days_supply = '180') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 810: Drug concept ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 810 AS id, 'Drug concept ID' AS description, 'Expect drug_exposure' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.drug_exposure WHERE visit_occurrence_id = '815' AND person_id = '810' AND drug_concept_id = '1110727' AND drug_source_value = '100000008105') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 811: Drug sig
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 811 AS id, 'Drug sig' AS description, 'Expect drug_exposure' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.drug_exposure WHERE visit_occurrence_id = '816' AND person_id = '811' AND sig = '1 g per day as needed, 20 g total') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 901: Procedure occurrence person ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 901 AS id, 'Procedure occurrence person ID' AS description, 'Expect procedure_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.procedure_occurrence WHERE person_id = '901') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 902: Procedure occurrence visit occurrence ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 902 AS id, 'Procedure occurrence visit occurrence ID' AS description, 'Expect procedure_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.procedure_occurrence WHERE visit_occurrence_id = '902') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 903: Procedure occurrence type concept ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 903 AS id, 'Procedure occurrence type concept ID' AS description, 'Expect procedure_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.procedure_occurrence WHERE visit_occurrence_id = '903' AND person_id = '903' AND procedure_type_concept_id = '38000215') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 903 AS id, 'Procedure occurrence type concept ID' AS description, 'Expect procedure_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.procedure_occurrence WHERE visit_occurrence_id = '904' AND person_id = '903' AND procedure_type_concept_id = '38000184') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 903 AS id, 'Procedure occurrence type concept ID' AS description, 'Expect procedure_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.procedure_occurrence WHERE visit_occurrence_id = '905' AND person_id = '903' AND procedure_type_concept_id = '38000184') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 904: Procedure provider
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 904 AS id, 'Procedure provider' AS description, 'Expect procedure_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.procedure_occurrence WHERE visit_occurrence_id = '907' AND person_id = '904' AND provider_id = '10000008') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 906: Procedure date from procedure date
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 906 AS id, 'Procedure date from procedure date' AS description, 'Expect procedure_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.procedure_occurrence WHERE visit_occurrence_id = '909' AND person_id = '906' AND procedure_date = '2010-01-05') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 907: Procedure date from visit date
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 907 AS id, 'Procedure date from visit date' AS description, 'Expect procedure_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.procedure_occurrence WHERE visit_occurrence_id = '910' AND person_id = '907' AND procedure_date = '2010-02-15') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 908: Procedure concept ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 908 AS id, 'Procedure concept ID' AS description, 'Expect procedure_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.procedure_occurrence WHERE visit_occurrence_id = '911' AND person_id = '908' AND procedure_concept_id = '2007683' AND procedure_source_concept_id = '2007683' AND procedure_source_value = '9394') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 909: Procedure from diagnosis
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 909 AS id, 'Procedure from diagnosis' AS description, 'Expect procedure_occurrence' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.procedure_occurrence WHERE visit_occurrence_id = '912' AND person_id = '909' AND procedure_type_concept_id = '38000215' AND procedure_concept_id = '4085923') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 1001: Measurement person ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1001 AS id, 'Measurement person ID' AS description, 'Expect measurement' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.measurement WHERE person_id = '1001') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 1002: Measurement concept ID and type concept ID
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1002 AS id, 'Measurement concept ID and type concept ID' AS description, 'Expect measurement' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.measurement WHERE person_id = '1002' AND measurement_type_concept_id = '38000277' AND measurement_concept_id = '3038553') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1002 AS id, 'Measurement concept ID and type concept ID' AS description, 'Expect measurement' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.measurement WHERE person_id = '1002' AND measurement_type_concept_id = '38000279' AND measurement_concept_id = '42869419') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 1003: Measurement date
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1003 AS id, 'Measurement date' AS description, 'Expect measurement' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.measurement WHERE person_id = '1003' AND measurement_date = '2010-01-16') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 1004: Measurement value
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1004 AS id, 'Measurement value' AS description, 'Expect measurement' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.measurement WHERE person_id = '1004' AND measurement_concept_id = '3038553' AND value_as_number = '25' AND unit_concept_id = '9531' AND value_source_value = '25.0') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1004 AS id, 'Measurement value' AS description, 'Expect measurement' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.measurement WHERE person_id = '1004' AND measurement_concept_id = '42869419' AND value_as_concept_id = '263654008' AND value_source_value = '1') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1004 AS id, 'Measurement value' AS description, 'Expect measurement' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.measurement WHERE person_id = '1004' AND measurement_concept_id = '3022038' AND value_as_number = '40' AND unit_concept_id = '8840' AND value_source_value = '40') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1004 AS id, 'Measurement value' AS description, 'Expect measurement' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.measurement WHERE person_id = '1004' AND measurement_concept_id = '3003792' AND value_as_number = '20' AND unit_concept_id = '8645' AND value_source_value = '20') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1004 AS id, 'Measurement value' AS description, 'Expect measurement' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.measurement WHERE person_id = '1004' AND measurement_concept_id = '3006923' AND value_as_number = '21' AND unit_concept_id = '8645' AND value_source_value = '21') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 1005: Measurement normal ranges
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1005 AS id, 'Measurement normal ranges' AS description, 'Expect measurement' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.measurement WHERE person_id = '1005' AND measurement_concept_id = '3004249' AND range_low = '60' AND range_high = '300') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1005 AS id, 'Measurement normal ranges' AS description, 'Expect measurement' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.measurement WHERE person_id = '1005' AND measurement_concept_id = '3012888' AND range_low = '30' AND range_high = '150') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 1006: Measurement from diagnosis
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1006 AS id, 'Measurement from diagnosis' AS description, 'Expect measurement' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.measurement WHERE visit_occurrence_id = '1001' AND person_id = '1006' AND measurement_type_concept_id = '38000215' AND measurement_concept_id = '4042243' AND value_as_concept_id = '4181412') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 1101: Observation person ID from diagnosis
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1101 AS id, 'Observation person ID from diagnosis' AS description, 'Expect observation' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.observation WHERE person_id = '1101') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 1102: Observation concept ID from diagnosis
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1102 AS id, 'Observation concept ID from diagnosis' AS description, 'Expect observation' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.observation WHERE person_id = '1102' AND observation_concept_id = '4214956' AND observation_source_concept_id = '45590771') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 1103: Observation value as concept ID from diagnosis
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1103 AS id, 'Observation value as concept ID from diagnosis' AS description, 'Expect observation' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.observation WHERE person_id = '1103' AND observation_concept_id = '4214956' AND value_as_concept_id = '439990') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 1104: Observation visit occurrence ID, provider ID, type concept ID from diagnosis
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1104 AS id, 'Observation visit occurrence ID, provider ID, type concept ID from diagnosis' AS description, 'Expect observation' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.observation WHERE visit_occurrence_id = '1104' AND person_id = '1104' AND observation_type_concept_id = '38000215' AND provider_id = '10000009') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 1105: Observation date from diagnosis with admission date
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1105 AS id, 'Observation date from diagnosis with admission date' AS description, 'Expect observation' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.observation WHERE visit_occurrence_id = '1105' AND person_id = '1105' AND observation_date = '2010-01-01') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 1106: Observation date from diagnosis without admission date
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1106 AS id, 'Observation date from diagnosis without admission date' AS description, 'Expect observation' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.observation WHERE visit_occurrence_id = '1106' AND person_id = '1106' AND observation_date = '2010-01-15') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 1107: Observation from checkup
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1107 AS id, 'Observation from checkup' AS description, 'Expect observation' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.observation WHERE person_id = '1107' AND observation_date = '2010-01-13' AND observation_concept_id = '40764749' AND value_as_concept_id = '4188540') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 1201: Claim cost
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1201 AS id, 'Claim cost' AS description, 'Expect cost' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.cost WHERE cost_event_id = '1201' AND cost_domain_id = 'Visit' AND cost_type_concept_id = '5031' AND currency_concept_id = '44818592' AND total_paid = '1230') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 1202: Procedure cost
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1202 AS id, 'Procedure cost' AS description, 'Expect cost' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.cost WHERE cost_event_id = (SELECT procedure_occurrence_id FROM testing.cdm_testing_jmdc.procedure_occurrence WHERE visit_occurrence_id = '1202' AND person_id = '1202') AND cost_domain_id = 'Procedure' AND cost_type_concept_id = '5032' AND currency_concept_id = '44818592' AND total_charge = '1500') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  -- 1203: Drug cost
  INSERT INTO testing.cdm_testing_jmdc.test_results SELECT 1203 AS id, 'Drug cost' AS description, 'Expect cost' AS test, CASE WHEN (SELECT COUNT(*) FROM testing.cdm_testing_jmdc.cost WHERE cost_event_id = (SELECT drug_exposure_id FROM testing.cdm_testing_jmdc.drug_exposure WHERE visit_occurrence_id = '1203' AND person_id = '1203') AND cost_domain_id = 'Drug' AND cost_type_concept_id = '5032' AND currency_concept_id = '44818592' AND total_charge = '80') = 0 THEN 'FAIL' ELSE 'PASS' END AS status;
  