diff --git a/DESCRIPTION b/DESCRIPTION index c9c4c371..07785f00 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: PhenotypeLibrary Type: Package Title: The OHDSI Phenotype Library -Version: 3.27.0 +Version: 3.28.0 Date: 2023-10-09 Author: Gowtham Rao [aut, cre] Maintainer: Gowtham Rao diff --git a/NEWS.md b/NEWS.md index d474a0fb..3229181b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,28 @@ +PhenotypeLibrary 3.28.0 +====================== +Accepted Cohorts: No cohorts were accepted in this release. + +New Cohorts: 18 were added. + + 1117: [P] Pulmonary fibrosis + 1118: [P] History of Bladder cancer + 1119: [P] Chronic obstructive pulmonary disease (COPD) + 1120: [P] Chronic Interstitial lung disease (ILD) + 1128: [P] Lung Nodule + 1129: [P] Lung Nodule - solitary + 1130: [P] Lung Nodule - multiple + 1131: [P] Lung Mass (not acute, necrotic, atlectatic, abscess, fibrosis) + 1132: [P] Lung Lesion (not acute, necrotic, atlectatic, abscess, fibrosis) + 1133: [P] Non Small Cell Lung Cancer as lung cancer without small cell + 1134: [P] Lung Cancer (primary maliganancy) + 1135: [P] Small Cell Lung Cancer + 1136: [P] Non Small Cell Lung Cancer + 1137: [P] Hoarseness + 1138: [P] Bone Pain + 1139: [P] Weight loss + 1216: [P] Primary Lung Cancer, 2nd dx 365 d after, excl SCLC signs all d before 1y after + 1217: [P] Primary Lung Cancer, excl SCLC signs all d before 1y after + PhenotypeLibrary 3.27.0 ====================== Accepted Cohorts: No cohorts were accepted in this release. diff --git a/docs/404.html b/docs/404.html index a412890c..bdb3f359 100644 --- a/docs/404.html +++ b/docs/404.html @@ -32,7 +32,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/articles/CohortDefinitionSubmissionRequirements.html b/docs/articles/CohortDefinitionSubmissionRequirements.html index b6d50990..38818926 100644 --- a/docs/articles/CohortDefinitionSubmissionRequirements.html +++ b/docs/articles/CohortDefinitionSubmissionRequirements.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/articles/CohortDefinitionsInOhdsiPhenotypeLibrary.html b/docs/articles/CohortDefinitionsInOhdsiPhenotypeLibrary.html index e0c07e83..7a06e301 100644 --- a/docs/articles/CohortDefinitionsInOhdsiPhenotypeLibrary.html +++ b/docs/articles/CohortDefinitionsInOhdsiPhenotypeLibrary.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 @@ -150,8 +150,8 @@

2023-10-09

window.URL.revokeObjectURL(url); }); }); -
- +
+ @@ -132,8 +132,8 @@

2023-10-09

-
- +
+ diff --git a/docs/articles/GuidanceOnCohortDefinitionSetRObject.html b/docs/articles/GuidanceOnCohortDefinitionSetRObject.html index 5989b4e7..91414b3f 100644 --- a/docs/articles/GuidanceOnCohortDefinitionSetRObject.html +++ b/docs/articles/GuidanceOnCohortDefinitionSetRObject.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/articles/GuidanceOnLiteratureReview.html b/docs/articles/GuidanceOnLiteratureReview.html index 78292c85..b22cf9fb 100644 --- a/docs/articles/GuidanceOnLiteratureReview.html +++ b/docs/articles/GuidanceOnLiteratureReview.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/articles/GuidanceOnPerformingPeerReview.html b/docs/articles/GuidanceOnPerformingPeerReview.html index 3870f9fe..4a9a514c 100644 --- a/docs/articles/GuidanceOnPerformingPeerReview.html +++ b/docs/articles/GuidanceOnPerformingPeerReview.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/articles/GuidanceOnWritingAnEvaluationReport.html b/docs/articles/GuidanceOnWritingAnEvaluationReport.html index 6d41a322..c45ddc32 100644 --- a/docs/articles/GuidanceOnWritingAnEvaluationReport.html +++ b/docs/articles/GuidanceOnWritingAnEvaluationReport.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/articles/GuidanceOnWritingCohortDefinitionLogicDescription.html b/docs/articles/GuidanceOnWritingCohortDefinitionLogicDescription.html index aa10eb67..2aa49c83 100644 --- a/docs/articles/GuidanceOnWritingCohortDefinitionLogicDescription.html +++ b/docs/articles/GuidanceOnWritingCohortDefinitionLogicDescription.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/articles/HowToUsePhenotypeLibraryRPackage.html b/docs/articles/HowToUsePhenotypeLibraryRPackage.html index de7e3e41..e453a20c 100644 --- a/docs/articles/HowToUsePhenotypeLibraryRPackage.html +++ b/docs/articles/HowToUsePhenotypeLibraryRPackage.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 @@ -151,7 +151,7 @@

Retrieval
 PhenotypeLibrary::getPhenotypeLog()
-
#> # A tibble: 540 x 81
+
#> # A tibble: 558 x 81
 #>    cohortId cohortName        cohortNameAtlas cohortNameFormatted cohortNameLong
 #>       <dbl> <chr>             <chr>           <chr>               <chr>         
 #>  1        3 Cough or Sputum   [P] Cough or S~ Cough or Sputum     Cough or Sput~
@@ -164,7 +164,7 @@ 

Retrieval#> 8 10 Nausea or Vomiti~ [P] Nausea or ~ Nausea or Vomiting Nausea or Vom~ #> 9 11 Malaise and or f~ [P] Malaise an~ Malaise and or fat~ Malaise and o~ #> 10 12 Rhinitis or comm~ [P] Rhinitis o~ Rhinitis or common~ Rhinitis or c~ -#> # i 530 more rows +#> # i 548 more rows #> # i 76 more variables: librarian <chr>, status <chr>, addedVersion <chr>, #> # logicDescription <chr>, hashTag <chr>, isCirceJson <dbl>, #> # contributors <chr>, contributorOrcIds <chr>, diff --git a/docs/articles/ReservedWordsWithSpecialMeaningToPhenotypers.html b/docs/articles/ReservedWordsWithSpecialMeaningToPhenotypers.html index 62488f7a..9d6548fc 100644 --- a/docs/articles/ReservedWordsWithSpecialMeaningToPhenotypers.html +++ b/docs/articles/ReservedWordsWithSpecialMeaningToPhenotypers.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/articles/SubmittedCohortDefinitions.html b/docs/articles/SubmittedCohortDefinitions.html index dab42e71..c1103aca 100644 --- a/docs/articles/SubmittedCohortDefinitions.html +++ b/docs/articles/SubmittedCohortDefinitions.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/articles/ValidityChecksForCohortDefinitions.html b/docs/articles/ValidityChecksForCohortDefinitions.html index 6d40167e..651daa6d 100644 --- a/docs/articles/ValidityChecksForCohortDefinitions.html +++ b/docs/articles/ValidityChecksForCohortDefinitions.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/articles/index.html b/docs/articles/index.html index 7d7c6cb4..f6bd0257 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -17,7 +17,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/authors.html b/docs/authors.html index f64cac8f..26535b3e 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -17,7 +17,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/index.html b/docs/index.html index 3d111917..e63b59c9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/news/index.html b/docs/news/index.html index 2ad0f14e..66db6d51 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -17,7 +17,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 @@ -96,6 +96,29 @@

Changelog

Source: NEWS.md +
+ +

Accepted Cohorts: No cohorts were accepted in this release.

+

New Cohorts: 18 were added.

+
1117: [P] Pulmonary fibrosis
+1118: [P] History of Bladder cancer
+1119: [P] Chronic obstructive pulmonary disease (COPD)
+1120: [P] Chronic Interstitial lung disease (ILD)
+1128: [P] Lung Nodule
+1129: [P] Lung Nodule - solitary
+1130: [P] Lung Nodule - multiple
+1131: [P] Lung Mass (not acute, necrotic, atlectatic, abscess, fibrosis)
+1132: [P] Lung Lesion (not acute, necrotic, atlectatic, abscess, fibrosis)
+1133: [P] Non Small Cell Lung Cancer as lung cancer without small cell
+1134: [P] Lung Cancer (primary maliganancy)
+1135: [P] Small Cell Lung Cancer
+1136: [P] Non Small Cell Lung Cancer
+1137: [P] Hoarseness
+1138: [P] Bone Pain
+1139: [P] Weight loss
+1216: [P] Primary Lung Cancer, 2nd dx 365 d after, excl SCLC signs all d before 1y after
+1217: [P] Primary Lung Cancer, excl SCLC signs all d before 1y after
+

Accepted Cohorts: No cohorts were accepted in this release.

@@ -105,421 +128,421 @@

Accepted Cohorts: No cohorts were accepted in this release.

New Cohorts: 64 were added. These Cohorts are part of the prediction study and contributed by Jenna Reps

-
1152: Deep Vein Thrombosis DVT 10
-1153: Seizure 10
-1154: Heart failure 10
-1155: Non-hemorrhagic Stroke 10
-1156: Hemorrhagic stroke 10
-1157: peripheral vascular disease 10
-1158: Aspirin 10
-1159: Angina 10
-1160: Atrial Fibrillation 10
-1161: Major depressive disorder with NO occurrence of certain psychiatric disorder 10
-1162: Coronary artery disease (CAD) 10
-1163: Acute Kidney Injury 10
-1164: Asthma 10
-1165: Alcoholism 10
-1166: Smoking 10
-1167: sleep apnea 10
-1168: skin ulcer 10
-1169: Chronic hepatitis 10
-1170: hyperlipidemia 10
-1171: hypothyroidism 10
-1172: Heart valve disorder 10
-1173: Low back pain 10
-1174: neuropathy 10
-1175: Psychotic disorder 10
-1176: Sepsis 10
-1177: Acute Respiratory failure 10
-1178: Gastroesophageal reflux disease 10
-1179: obesity 10
-1180: Inflammatory Bowel Disease 10
-1181: STEROIDS 10
-1182: Opioids 10
-1183: ANTIEPILEPTICS 10
-1184: Osteoarthritis 10
-1185: Osteoporosis 10
-1186: Urinary tract infectious 10
-1187: acetaminophen exposure 10
-1188: Anemia 10
-1189: Anxiety 10
-1190: HORMONAL CONTRACEPTIVES 10
-1191: Chronic kidney disease or end stage renal disease 10
-1192: Chronic obstructive pulmonary disease (COPD) 10
-1193: Type 1 diabetes and no prior specific nonT1DM diabetes 10
-1194: Type 2 Diabetes Mellitus with no type 1 or secondary DM 10
-1195: Dyspnea 10
-1196: Edema 10
-1197: Acute gastrointestinal bleeding 10
-1198: Hypertension 10
-1199: Pneumonia 10
-1200: Rheumatoid Arthritis 10
-1201: Antibiotics Aminoglycosides 10
-1202: Antibiotics Carbapenems 10
-1203: Antibiotics Cephalosporins 10
-1204: Antibiotics Fluoroquinolones 10
-1205: Antibiotics Glycopeptides and lipoglycopeptides 10
-1206: Antibiotics Macrolides 10
-1207: Antibiotics Monobactams 10
-1208: Antibiotics Oxazolidinones 10
-1209: Antibiotics Penicillins 10
-1210: Antibiotics Polypeptides 10
-1211: Antibiotics Rifamycins 10
-1212: Antibiotics Sulfonamides 10
-1213: Antibiotics Streptogramins 10
-1214: Antibiotics Tetracyclines 10
-1215: Any cancer (excl. prostate cancer and benign cancer) 10
+
1152: Deep Vein Thrombosis DVT 10
+1153: Seizure 10
+1154: Heart failure 10
+1155: Non-hemorrhagic Stroke 10
+1156: Hemorrhagic stroke 10
+1157: peripheral vascular disease 10
+1158: Aspirin 10
+1159: Angina 10
+1160: Atrial Fibrillation 10
+1161: Major depressive disorder with NO occurrence of certain psychiatric disorder 10
+1162: Coronary artery disease (CAD) 10
+1163: Acute Kidney Injury 10
+1164: Asthma 10
+1165: Alcoholism 10
+1166: Smoking 10
+1167: sleep apnea 10
+1168: skin ulcer 10
+1169: Chronic hepatitis 10
+1170: hyperlipidemia 10
+1171: hypothyroidism 10
+1172: Heart valve disorder 10
+1173: Low back pain 10
+1174: neuropathy 10
+1175: Psychotic disorder 10
+1176: Sepsis 10
+1177: Acute Respiratory failure 10
+1178: Gastroesophageal reflux disease 10
+1179: obesity 10
+1180: Inflammatory Bowel Disease 10
+1181: STEROIDS 10
+1182: Opioids 10
+1183: ANTIEPILEPTICS 10
+1184: Osteoarthritis 10
+1185: Osteoporosis 10
+1186: Urinary tract infectious 10
+1187: acetaminophen exposure 10
+1188: Anemia 10
+1189: Anxiety 10
+1190: HORMONAL CONTRACEPTIVES 10
+1191: Chronic kidney disease or end stage renal disease 10
+1192: Chronic obstructive pulmonary disease (COPD) 10
+1193: Type 1 diabetes and no prior specific nonT1DM diabetes 10
+1194: Type 2 Diabetes Mellitus with no type 1 or secondary DM 10
+1195: Dyspnea 10
+1196: Edema 10
+1197: Acute gastrointestinal bleeding 10
+1198: Hypertension 10
+1199: Pneumonia 10
+1200: Rheumatoid Arthritis 10
+1201: Antibiotics Aminoglycosides 10
+1202: Antibiotics Carbapenems 10
+1203: Antibiotics Cephalosporins 10
+1204: Antibiotics Fluoroquinolones 10
+1205: Antibiotics Glycopeptides and lipoglycopeptides 10
+1206: Antibiotics Macrolides 10
+1207: Antibiotics Monobactams 10
+1208: Antibiotics Oxazolidinones 10
+1209: Antibiotics Penicillins 10
+1210: Antibiotics Polypeptides 10
+1211: Antibiotics Rifamycins 10
+1212: Antibiotics Sulfonamides 10
+1213: Antibiotics Streptogramins 10
+1214: Antibiotics Tetracyclines 10
+1215: Any cancer (excl. prostate cancer and benign cancer) 10

Accepted Cohorts: No cohorts were accepted in this release.

New Cohorts: 2 were added.

-
1150: Emergency room only or Emergency room and inpatient visits (0Pe, 0Era)
-1151: [P] Autism
+
1150: Emergency room only or Emergency room and inpatient visits (0Pe, 0Era)
+1151: [P] Autism

Following cohorts were hidden: 325 were added. To retrieve use PhenotypeLibrary::getPhenotypeLog(showHidden = TRUE).

-
2: [W] COVID-19 diagnosis or SARS-CoV-2 test (1pos)
-15: [P][R] Exposure to viral disease 
-16: [W] Exposure to SARS-Cov 2 and coronavirus
-17: [P][R] Exposure to SARS-CoV-2 
-18: [P][R] Multisystem inflammatory syndrome (MIS) 
-22: [W] SARS-CoV-2 testing
-29: [W] Autoimmune condition (FP)
-35: [W] Chronic kidney disease (FP)
-39: [W] End stage renal disease (FP)
-41: [W] Chronic kidney disease broad (FP)
-42: [W] End stage renal disease broad (FP)
-44: [P][R] COVID-19 
-45: [W] COVID-19 diagnosis with SARS-Cov-2 test (-3d to 3d)
-46: [W] COVID-19 diagnosis and SARS-CoV-2 test (1pos) within 3d
-47: [W] COVID-19 diagnosis and SARS-CoV-2 test (1pos) (0neg) within 3d
-48: [W] COVID-19 diagnosis and SARS-CoV-2 test (0pos upto 3d, 1neg within 3d)
-51: [W] SARS-CoV-2 test positive result
-52: [W] SARS-CoV-2 test negative result
-53: [W] SARS-CoV-2 test positive or negative result - keep persons with positive
-57: [P][R] Bleeding 
-59: [W] COVID-19 diagnosis with no SARS-CoV-2 test
-60: [W] SARS-CoV-2 test positive and negative result
-62: [P][R] Seizure related finding 
-65: [W] Acute pancreatitis with inpatient admission
-66: [W] Acute renal failure with inpatient admission
-67: [W] Hepatic failure with inpatient admission
-68: [W] Heart failure with inpatient admission
-69: [W] Angioedema with inpatient admission
-86: [W] SARS-CoV-2 test positive or negative result
-87: [W] SARS-CoV-2 test
-100: [P][R] Alzheimer's disease
-189: [P][R] Right upper quadrant pain 
-190: [P][R] Swollen abdomen 
-226: [P][R] Drug reaction with eosinophilia and systemic symptoms 
-231: [P][R] Erythema multiforme 
-238: [P][R] Optic neuritis 
-241: [P][R] Urticaria 
-327: [P][R] Pharyngitis 
-330: [P][R] Abdominal bloating 
-339: [P][R] Low blood pressure 
-342: [P][R] Urinary incontinence
-348: [P][R] Blood in urine 
-350: [P][R] Hemoptysis
-352: [P][R] Inflamed tonsils 
-353: [P][R] Conjunctivitis 
-357: [P][R] Pulmonary edema 
-361: [P][R] Restless legs 
-363: [P][R] Joint stiffness 
-364: [P][R] Sleep disorder 
-368: [P][R] Sinusitis 
-369: [P][R] Allergic condition 
-374: [P][R] Drug dependence 
-376: [P][R] Bleeding skin 
-377: [P][R] Petechiae 
-378: [P][R] Purpuric disorder 
-380: [P][R] Jaundice 
-384: [P][R] Contact dermatitis 
-385: [P][R] Intertrigo 
-386: [P][R] Seborrheic dermatitis 
-387: [P][R] Photodermatitis 
-388: [P][R] Peripheral neuritis 
-396: [P][R] Osteoarthritis 
-397: [P][R] Hyperplasia of prostate 
-399: [P][R] Urolithiasis 
-400: [P][R] Malignant tumor of prostate 
-406: [P][R] Intellectual disability 
-407: [P][R] Hemorrhoids 
-415: [P][R] Erythema of skin 
-444: [P][R] Neck pain
-445: [P][R] Hypoglycemia
-446: [P][R] Eosinophilic esophagitis
-447: [P][R] Esophagitis
-448: [P][R] Dysphagia
-449: [P][R] Nausea
-450: [P][R] Constipation
-451: [P][R] Myasthenia gravis
-452: [P][R] Joint pain
-453: [P][R] Osteoarthritis
-454: [P][R] Dermatomyositis
-455: [P][R] Fetal growth restriction
-456: [P][R] Osteoporosis
-457: [P][R] Rheumatoid arthritis
-458: [P][R] Ulcerative colitis
-459: [P][R] Urinary tract infectious disease
-460: [P][R] Psoriasis with arthropathy
-461: [P][R] Erythema multiforme
-462: [P][R] Lichen planus
-463: [P][R] Sepsis
-464: [P][R] Myelofibrosis
-465: [P][R] Thyroiditis
-466: [P][R] Atopic dermatitis
-467: [P][R] Systemic sclerosis
-468: [P][R] Pityriasis rubra pilaris
-469: [P][R] Jaundice
-470: [P][R] Chronic lymphoid leukemia, disease
-471: [P][R] Vitiligo
-472: [P][R] Myelodysplastic syndrome (clinical)
-473: [P][R] Acute transverse myelitis
-474: [P][R] Pemphigoid
-475: [P][R] Psoriasis
-476: [P][R] Acute myeloid leukemia, disease
-477: [P][R] Hypothyroidism
-478: [P][R] Malignant melanoma of skin
-479: [P][R] Chilblains
-480: [P][R] Alopecia areata
-481: [P][R] Renal failure syndrome
-482: [P][R] Gastrointestinal hemorrhage
-483: [P][R] Biliary cirrhosis
-484: [P][R] End-stage renal disease
-485: [P][R] Low back pain
-486: [P][R] Premature rupture of membranes
-487: [P][R] Celiac disease
-488: [P][R] Diarrhea
-489: [P][R] Acute renal failure syndrome
-490: [P][R] Viral hepatitis C
-491: [P][R] Malignant tumor of urinary bladder
-492: [P][R] Cardiogenic shock
-493: [P][R] Malignant tumor of cervix
-494: [P][R] Primary malignant neoplasm of kidney
-495: [P][R] Acute pancreatitis
-496: [P][R] Abdominal pain
-497: [P][R] Autoimmune hepatitis
-498: [P][R] Toxic shock syndrome
-499: [P][R] Type 1 diabetes mellitus
-500: [P][R] Gastritis
-501: [P][R] Crohn's disease
-502: [P][R] Kidney stone
-503: [P][R] Type 2 diabetes mellitus
-504: [P][R] Sj?gren's syndrome
-505: [P][R] Cough
-506: [P][R] Chronic obstructive lung disease
-507: [P][R] Pneumonia
-508: [P][R] Allergic rhinitis
-509: [P][R] Systemic lupus erythematosus
-510: [P][R] Acute myocardial infarction
-511: [P][R] Dyspnea
-512: [P][R] Thromboangiitis obliterans
-513: [P][R] Atrial fibrillation
-514: [P][R] Granulomatosis with polyangiitis
-515: [P][R] Sleep apnea
-516: [P][R] Thrombotic microangiopathy
-517: [P][R] Acute febrile mucocutaneous lymph node syndrome
-518: [P][R] Myocarditis
-519: [P][R] Heart failure
-520: [P][R] Hypertensive disorder
-521: [P][R] Asthma
-522: [P][R] Coronary arteriosclerosis
-523: [P][R] Arteriosclerotic vascular disease
-524: [P][R] Migraine
-525: [P][R] Gastroesophageal reflux disease
-526: [P][R] Orthostatic hypotension
-527: [P][R] Acute respiratory failure
-528: [P][R] Polyarteritis nodosa
-529: [P][R] Cardiac arrest
-530: [P][R] Peripheral vascular disease
-531: [P][R] Angina pectoris
-532: [P][R] Heart disease
-533: [P][R] Otitis media
-534: [P][R] Transient cerebral ischemia
-535: [P][R] Acute disseminated encephalomyelitis
-536: [P][R] Age related macular degeneration
-537: [P][R] Sensorineural hearing loss
-538: [P][R] Paralytic syndrome
-539: [P][R] Multiple sclerosis
-540: [P][R] Optic neuritis
-541: [P][R] Idiopathic peripheral neuropathy
-542: [P][R] Cerebral hemorrhage
-543: [P][R] Seizure
-544: [P][R] Encephalitis
-545: [P][R] Headache
-546: [P][R] Retinal detachment
-547: [P][R] Retinal disorder
-549: [P][R] Epilepsy
-550: [P][R] Chronic inflammatory demyelinating polyradiculoneuropathy
-551: [P][R] Microcephaly
-552: [P][R] Parkinson's disease
-553: [P][R] Cerebrovascular accident
-554: [P][R] Cerebrovascular disease
-555: [P][R] Blood coagulation disorder
-556: [P][R] Amyloidosis
-557: [P][R] Angioedema
-558: [P][R] Hyperlipidemia
-559: [P][R] Thrombocytopenic disorder
-560: [P][R] Pancytopenia
-561: [P][R] Myasthenic syndrome due to another disorder
-562: [P][R] Edema
-563: [P][R] Obesity
-564: [P][R] Hidradenitis
-565: [P][R] Tuberculosis
-566: [P][R] Kaposi's sarcoma (clinical)
-567: [P][R] B-cell lymphoma (clinical)
-568: [P][R] Hyperkalemia
-569: [P][R] Systemic inflammatory response syndrome
-570: [P][R] Leukopenia
-571: [P][R] Schizophrenia
-572: [P][R] Psychotic disorder
-573: [P][R] Chronic pain
-574: [P][R] Narcolepsy
-575: [P][R] Behcet's syndrome
-576: [P][R] Bipolar disorder
-577: [P][R] Posttraumatic stress disorder
-578: [P][R] Insomnia
-579: [P][R] Ankylosing spondylitis
-580: [P][R] Respiratory syncytial virus infection
-581: [P][R] Multiple myeloma
-582: [P][R] Bleeding
-583: [P][R] Glaucoma
-584: [P][R] Fever
-585: [P][R] Hypokalemia
-586: [P][R] Opioid dependence
-587: [P][R] Opioid abuse
-588: [P][R] Attention deficit hyperactivity disorder
-589: [P][R] Pre-eclampsia
-590: [P][R] Human immunodeficiency virus infection
-591: [P][R] Autism spectrum disorder
-592: [P][R] Anemia
-593: [P][R] Paralysis
-594: [P][R] Depressive disorder
-595: [P][R] Pulmonary embolism
-596: [P][R] Gout
-597: [P][R] Takayasu's disease
-598: [P][R] Methicillin resistant Staphylococcus aureus infection
-599: [P][R] Anaphylaxis
-600: [P][R] Open-angle glaucoma
-601: [P][R] Vomiting
-602: [P][R] Anxiety
-603: [P][R] Human papilloma virus infection
-604: [P][R] Cranial nerve disorder
-605: [P][R] Muscle pain
-606: [P][R] Stillbirth
-607: [P][R] Malignant tumor of stomach
-608: [P][R] Malignant neoplastic disease
-609: [P][R] Cerebral infarction
-610: [P][R] Eclampsia
-611: [P][R] Diabetic ketoacidosis
-612: [P][R] Acute tubular necrosis
-613: [P][R] Tachycardia
-614: [P][R] Venous thrombosis
-615: [P][R] Herpes simplex
-616: [P][R] Acute arthritis
-617: [P][R] Monoclonal gammopathy (clinical)
-618: [P][R] Pulmonary arterial hypertension
-619: [P][R] Gestational diabetes mellitus
-620: [P][R] Uveitis
-621: [P][R] Renal impairment
-622: [P][R] Non-Hodgkin's lymphoma (clinical)
-623: [P][R] Motor neuropathy with multiple conduction block
-624: [P][R] Primary sclerosing cholangitis
-625: [P][R] Pustular psoriasis
-626: [P][R] Cirrhosis of liver
-627: [P][R] Miscarriage
-628: [P][R] Fisher's syndrome
-629: [P][R] Inflammatory bowel disease
-630: [P][R] Facial palsy
-631: [P][R] Livebirth
-632: [P][R] Antiphospholipid syndrome
-633: [P][R] Waldenstr?m macroglobulinemia
-634: [P][R] Immunoglobulin A vasculitis
-635: [P][R] Ventricular tachycardia
-636: [P][R] Malignant tumor of breast
-637: [P][R] Peripheral ischemia
-638: [P][R] Neoplasm of thyroid gland
-639: [P][R] Deep venous thrombosis
-640: [P][R] Vasculitis
-641: [P][R] Pericarditis
-642: [P][R] Immune reconstitution syndrome
-643: [P][R] Follicular non-Hodgkin's lymphoma
-644: [P][R] Malignant tumor of prostate
-645: [P][R] Guillain-Barr? syndrome
-646: [P][R] Bradycardia
-647: [P][R] Retinopathy due to diabetes mellitus
-648: [P][R] Malignant tumor of colon
-649: [P][R] Malignant tumor of esophagus
-650: [P][R] Malignant tumor of ovary
-651: [P][R] Dementia
-652: [P][R] Vasculitis of the skin
-653: [P][R] Loss of sense of smell
-654: [P][R] Ischemic heart disease
-655: [P][R] Aseptic meningitis
-656: [P][R] Fatigue
-657: [P][R] Paresthesia
-658: [P][R] Hepatic failure
-659: [P][R] Malignant neoplasm of liver
-660: [P][R] Juvenile rheumatoid arthritis
-661: [P][R] Respiratory failure
-662: [P][R] Diverticulitis of large intestine
-663: [P][R] Influenza
-664: [P][R] Malaise
-665: [P][R] Suicidal thoughts
-666: [P][R] Type B viral hepatitis
-667: [P][R] Guttate psoriasis
-668: [P][R] SLE glomerulonephritis syndrome
-669: [P][R] Schizoaffective disorder
-670: [P][R] Temporal arteritis
-671: [P][R] Pregnant
-672: [P][R] Sense of smell impaired
-673: [P][R] Primary malignant neoplasm of respiratory tract
-674: [P][R] Degeneration of retina
-675: [P][R] Pulmonary hypertension
-676: [P][R] Necrosis of artery
-677: [P][R] Preterm labor with preterm delivery
-678: [P][R] COVID-19
-679: [P][R] Takotsubo cardiomyopathy
-680: [P][R] Mantle cell lymphoma
-681: [P][R] Malignant neoplasm of anorectum
-682: [P][R] Marginal zone lymphoma
-683: [P][R] Antineutrophil cytoplasmic antibody positive vasculitis
-684: [P][R] Sensory disorder of smell and/or taste
-685: [P][R] Cardiac arrhythmia
-686: [P][R] Fracture of bone of hip region
-687: [P][R] Chronic kidney disease
-688: [P][R] Death
-689: [P][R] Newborn death
-690: [P][R] Suicide
-695: [P][R] Optic nerve glioma
-696: [P][R] Neurofibromatosis type 2
-697: [P][R] Neurofibromatosis type 1
-698: [P][R] Neurofibromatosis syndrome
-699: [P][R] Major Depressive Disorder
-701: [P][R] Ascites
-709: [P][R] Chronic liver disease
-711: [P][R] Transplanted liver present
-714: [P][R] Endometriosis (clinical)
-794: [W] Hemorrhage of digestive system
+
2: [W] COVID-19 diagnosis or SARS-CoV-2 test (1pos)
+15: [P][R] Exposure to viral disease 
+16: [W] Exposure to SARS-Cov 2 and coronavirus
+17: [P][R] Exposure to SARS-CoV-2 
+18: [P][R] Multisystem inflammatory syndrome (MIS) 
+22: [W] SARS-CoV-2 testing
+29: [W] Autoimmune condition (FP)
+35: [W] Chronic kidney disease (FP)
+39: [W] End stage renal disease (FP)
+41: [W] Chronic kidney disease broad (FP)
+42: [W] End stage renal disease broad (FP)
+44: [P][R] COVID-19 
+45: [W] COVID-19 diagnosis with SARS-Cov-2 test (-3d to 3d)
+46: [W] COVID-19 diagnosis and SARS-CoV-2 test (1pos) within 3d
+47: [W] COVID-19 diagnosis and SARS-CoV-2 test (1pos) (0neg) within 3d
+48: [W] COVID-19 diagnosis and SARS-CoV-2 test (0pos upto 3d, 1neg within 3d)
+51: [W] SARS-CoV-2 test positive result
+52: [W] SARS-CoV-2 test negative result
+53: [W] SARS-CoV-2 test positive or negative result - keep persons with positive
+57: [P][R] Bleeding 
+59: [W] COVID-19 diagnosis with no SARS-CoV-2 test
+60: [W] SARS-CoV-2 test positive and negative result
+62: [P][R] Seizure related finding 
+65: [W] Acute pancreatitis with inpatient admission
+66: [W] Acute renal failure with inpatient admission
+67: [W] Hepatic failure with inpatient admission
+68: [W] Heart failure with inpatient admission
+69: [W] Angioedema with inpatient admission
+86: [W] SARS-CoV-2 test positive or negative result
+87: [W] SARS-CoV-2 test
+100: [P][R] Alzheimer's disease
+189: [P][R] Right upper quadrant pain 
+190: [P][R] Swollen abdomen 
+226: [P][R] Drug reaction with eosinophilia and systemic symptoms 
+231: [P][R] Erythema multiforme 
+238: [P][R] Optic neuritis 
+241: [P][R] Urticaria 
+327: [P][R] Pharyngitis 
+330: [P][R] Abdominal bloating 
+339: [P][R] Low blood pressure 
+342: [P][R] Urinary incontinence
+348: [P][R] Blood in urine 
+350: [P][R] Hemoptysis
+352: [P][R] Inflamed tonsils 
+353: [P][R] Conjunctivitis 
+357: [P][R] Pulmonary edema 
+361: [P][R] Restless legs 
+363: [P][R] Joint stiffness 
+364: [P][R] Sleep disorder 
+368: [P][R] Sinusitis 
+369: [P][R] Allergic condition 
+374: [P][R] Drug dependence 
+376: [P][R] Bleeding skin 
+377: [P][R] Petechiae 
+378: [P][R] Purpuric disorder 
+380: [P][R] Jaundice 
+384: [P][R] Contact dermatitis 
+385: [P][R] Intertrigo 
+386: [P][R] Seborrheic dermatitis 
+387: [P][R] Photodermatitis 
+388: [P][R] Peripheral neuritis 
+396: [P][R] Osteoarthritis 
+397: [P][R] Hyperplasia of prostate 
+399: [P][R] Urolithiasis 
+400: [P][R] Malignant tumor of prostate 
+406: [P][R] Intellectual disability 
+407: [P][R] Hemorrhoids 
+415: [P][R] Erythema of skin 
+444: [P][R] Neck pain
+445: [P][R] Hypoglycemia
+446: [P][R] Eosinophilic esophagitis
+447: [P][R] Esophagitis
+448: [P][R] Dysphagia
+449: [P][R] Nausea
+450: [P][R] Constipation
+451: [P][R] Myasthenia gravis
+452: [P][R] Joint pain
+453: [P][R] Osteoarthritis
+454: [P][R] Dermatomyositis
+455: [P][R] Fetal growth restriction
+456: [P][R] Osteoporosis
+457: [P][R] Rheumatoid arthritis
+458: [P][R] Ulcerative colitis
+459: [P][R] Urinary tract infectious disease
+460: [P][R] Psoriasis with arthropathy
+461: [P][R] Erythema multiforme
+462: [P][R] Lichen planus
+463: [P][R] Sepsis
+464: [P][R] Myelofibrosis
+465: [P][R] Thyroiditis
+466: [P][R] Atopic dermatitis
+467: [P][R] Systemic sclerosis
+468: [P][R] Pityriasis rubra pilaris
+469: [P][R] Jaundice
+470: [P][R] Chronic lymphoid leukemia, disease
+471: [P][R] Vitiligo
+472: [P][R] Myelodysplastic syndrome (clinical)
+473: [P][R] Acute transverse myelitis
+474: [P][R] Pemphigoid
+475: [P][R] Psoriasis
+476: [P][R] Acute myeloid leukemia, disease
+477: [P][R] Hypothyroidism
+478: [P][R] Malignant melanoma of skin
+479: [P][R] Chilblains
+480: [P][R] Alopecia areata
+481: [P][R] Renal failure syndrome
+482: [P][R] Gastrointestinal hemorrhage
+483: [P][R] Biliary cirrhosis
+484: [P][R] End-stage renal disease
+485: [P][R] Low back pain
+486: [P][R] Premature rupture of membranes
+487: [P][R] Celiac disease
+488: [P][R] Diarrhea
+489: [P][R] Acute renal failure syndrome
+490: [P][R] Viral hepatitis C
+491: [P][R] Malignant tumor of urinary bladder
+492: [P][R] Cardiogenic shock
+493: [P][R] Malignant tumor of cervix
+494: [P][R] Primary malignant neoplasm of kidney
+495: [P][R] Acute pancreatitis
+496: [P][R] Abdominal pain
+497: [P][R] Autoimmune hepatitis
+498: [P][R] Toxic shock syndrome
+499: [P][R] Type 1 diabetes mellitus
+500: [P][R] Gastritis
+501: [P][R] Crohn's disease
+502: [P][R] Kidney stone
+503: [P][R] Type 2 diabetes mellitus
+504: [P][R] Sj?gren's syndrome
+505: [P][R] Cough
+506: [P][R] Chronic obstructive lung disease
+507: [P][R] Pneumonia
+508: [P][R] Allergic rhinitis
+509: [P][R] Systemic lupus erythematosus
+510: [P][R] Acute myocardial infarction
+511: [P][R] Dyspnea
+512: [P][R] Thromboangiitis obliterans
+513: [P][R] Atrial fibrillation
+514: [P][R] Granulomatosis with polyangiitis
+515: [P][R] Sleep apnea
+516: [P][R] Thrombotic microangiopathy
+517: [P][R] Acute febrile mucocutaneous lymph node syndrome
+518: [P][R] Myocarditis
+519: [P][R] Heart failure
+520: [P][R] Hypertensive disorder
+521: [P][R] Asthma
+522: [P][R] Coronary arteriosclerosis
+523: [P][R] Arteriosclerotic vascular disease
+524: [P][R] Migraine
+525: [P][R] Gastroesophageal reflux disease
+526: [P][R] Orthostatic hypotension
+527: [P][R] Acute respiratory failure
+528: [P][R] Polyarteritis nodosa
+529: [P][R] Cardiac arrest
+530: [P][R] Peripheral vascular disease
+531: [P][R] Angina pectoris
+532: [P][R] Heart disease
+533: [P][R] Otitis media
+534: [P][R] Transient cerebral ischemia
+535: [P][R] Acute disseminated encephalomyelitis
+536: [P][R] Age related macular degeneration
+537: [P][R] Sensorineural hearing loss
+538: [P][R] Paralytic syndrome
+539: [P][R] Multiple sclerosis
+540: [P][R] Optic neuritis
+541: [P][R] Idiopathic peripheral neuropathy
+542: [P][R] Cerebral hemorrhage
+543: [P][R] Seizure
+544: [P][R] Encephalitis
+545: [P][R] Headache
+546: [P][R] Retinal detachment
+547: [P][R] Retinal disorder
+549: [P][R] Epilepsy
+550: [P][R] Chronic inflammatory demyelinating polyradiculoneuropathy
+551: [P][R] Microcephaly
+552: [P][R] Parkinson's disease
+553: [P][R] Cerebrovascular accident
+554: [P][R] Cerebrovascular disease
+555: [P][R] Blood coagulation disorder
+556: [P][R] Amyloidosis
+557: [P][R] Angioedema
+558: [P][R] Hyperlipidemia
+559: [P][R] Thrombocytopenic disorder
+560: [P][R] Pancytopenia
+561: [P][R] Myasthenic syndrome due to another disorder
+562: [P][R] Edema
+563: [P][R] Obesity
+564: [P][R] Hidradenitis
+565: [P][R] Tuberculosis
+566: [P][R] Kaposi's sarcoma (clinical)
+567: [P][R] B-cell lymphoma (clinical)
+568: [P][R] Hyperkalemia
+569: [P][R] Systemic inflammatory response syndrome
+570: [P][R] Leukopenia
+571: [P][R] Schizophrenia
+572: [P][R] Psychotic disorder
+573: [P][R] Chronic pain
+574: [P][R] Narcolepsy
+575: [P][R] Behcet's syndrome
+576: [P][R] Bipolar disorder
+577: [P][R] Posttraumatic stress disorder
+578: [P][R] Insomnia
+579: [P][R] Ankylosing spondylitis
+580: [P][R] Respiratory syncytial virus infection
+581: [P][R] Multiple myeloma
+582: [P][R] Bleeding
+583: [P][R] Glaucoma
+584: [P][R] Fever
+585: [P][R] Hypokalemia
+586: [P][R] Opioid dependence
+587: [P][R] Opioid abuse
+588: [P][R] Attention deficit hyperactivity disorder
+589: [P][R] Pre-eclampsia
+590: [P][R] Human immunodeficiency virus infection
+591: [P][R] Autism spectrum disorder
+592: [P][R] Anemia
+593: [P][R] Paralysis
+594: [P][R] Depressive disorder
+595: [P][R] Pulmonary embolism
+596: [P][R] Gout
+597: [P][R] Takayasu's disease
+598: [P][R] Methicillin resistant Staphylococcus aureus infection
+599: [P][R] Anaphylaxis
+600: [P][R] Open-angle glaucoma
+601: [P][R] Vomiting
+602: [P][R] Anxiety
+603: [P][R] Human papilloma virus infection
+604: [P][R] Cranial nerve disorder
+605: [P][R] Muscle pain
+606: [P][R] Stillbirth
+607: [P][R] Malignant tumor of stomach
+608: [P][R] Malignant neoplastic disease
+609: [P][R] Cerebral infarction
+610: [P][R] Eclampsia
+611: [P][R] Diabetic ketoacidosis
+612: [P][R] Acute tubular necrosis
+613: [P][R] Tachycardia
+614: [P][R] Venous thrombosis
+615: [P][R] Herpes simplex
+616: [P][R] Acute arthritis
+617: [P][R] Monoclonal gammopathy (clinical)
+618: [P][R] Pulmonary arterial hypertension
+619: [P][R] Gestational diabetes mellitus
+620: [P][R] Uveitis
+621: [P][R] Renal impairment
+622: [P][R] Non-Hodgkin's lymphoma (clinical)
+623: [P][R] Motor neuropathy with multiple conduction block
+624: [P][R] Primary sclerosing cholangitis
+625: [P][R] Pustular psoriasis
+626: [P][R] Cirrhosis of liver
+627: [P][R] Miscarriage
+628: [P][R] Fisher's syndrome
+629: [P][R] Inflammatory bowel disease
+630: [P][R] Facial palsy
+631: [P][R] Livebirth
+632: [P][R] Antiphospholipid syndrome
+633: [P][R] Waldenstr?m macroglobulinemia
+634: [P][R] Immunoglobulin A vasculitis
+635: [P][R] Ventricular tachycardia
+636: [P][R] Malignant tumor of breast
+637: [P][R] Peripheral ischemia
+638: [P][R] Neoplasm of thyroid gland
+639: [P][R] Deep venous thrombosis
+640: [P][R] Vasculitis
+641: [P][R] Pericarditis
+642: [P][R] Immune reconstitution syndrome
+643: [P][R] Follicular non-Hodgkin's lymphoma
+644: [P][R] Malignant tumor of prostate
+645: [P][R] Guillain-Barr? syndrome
+646: [P][R] Bradycardia
+647: [P][R] Retinopathy due to diabetes mellitus
+648: [P][R] Malignant tumor of colon
+649: [P][R] Malignant tumor of esophagus
+650: [P][R] Malignant tumor of ovary
+651: [P][R] Dementia
+652: [P][R] Vasculitis of the skin
+653: [P][R] Loss of sense of smell
+654: [P][R] Ischemic heart disease
+655: [P][R] Aseptic meningitis
+656: [P][R] Fatigue
+657: [P][R] Paresthesia
+658: [P][R] Hepatic failure
+659: [P][R] Malignant neoplasm of liver
+660: [P][R] Juvenile rheumatoid arthritis
+661: [P][R] Respiratory failure
+662: [P][R] Diverticulitis of large intestine
+663: [P][R] Influenza
+664: [P][R] Malaise
+665: [P][R] Suicidal thoughts
+666: [P][R] Type B viral hepatitis
+667: [P][R] Guttate psoriasis
+668: [P][R] SLE glomerulonephritis syndrome
+669: [P][R] Schizoaffective disorder
+670: [P][R] Temporal arteritis
+671: [P][R] Pregnant
+672: [P][R] Sense of smell impaired
+673: [P][R] Primary malignant neoplasm of respiratory tract
+674: [P][R] Degeneration of retina
+675: [P][R] Pulmonary hypertension
+676: [P][R] Necrosis of artery
+677: [P][R] Preterm labor with preterm delivery
+678: [P][R] COVID-19
+679: [P][R] Takotsubo cardiomyopathy
+680: [P][R] Mantle cell lymphoma
+681: [P][R] Malignant neoplasm of anorectum
+682: [P][R] Marginal zone lymphoma
+683: [P][R] Antineutrophil cytoplasmic antibody positive vasculitis
+684: [P][R] Sensory disorder of smell and/or taste
+685: [P][R] Cardiac arrhythmia
+686: [P][R] Fracture of bone of hip region
+687: [P][R] Chronic kidney disease
+688: [P][R] Death
+689: [P][R] Newborn death
+690: [P][R] Suicide
+695: [P][R] Optic nerve glioma
+696: [P][R] Neurofibromatosis type 2
+697: [P][R] Neurofibromatosis type 1
+698: [P][R] Neurofibromatosis syndrome
+699: [P][R] Major Depressive Disorder
+701: [P][R] Ascites
+709: [P][R] Chronic liver disease
+711: [P][R] Transplanted liver present
+714: [P][R] Endometriosis (clinical)
+794: [W] Hemorrhage of digestive system

Accepted Cohorts: No cohorts were accepted in this release.

New Cohorts: 14 were added.

-
1093: [P] Abdominal Aoritc Aneurysm repair - post op new Afib (any)
-1094: [P] Lower Extremity Bypass - post op new Afib (any)
-1095: [P] Carotid Endarterectomy - post op new Afib (any)
-1096: [P] Lung Resection - post op new Afib (any)
-1097: [P] Esophagectomy - post op new Afib (any)
-1098: [P] Pancreatectomy - post op new Afib (any)
-1099: [P] Colectomy - post op new Afib (any)
-1100: [P] Cystectomy - post op new Afib (any)
-1101: [P] Nephrectomy - post op new Afib (any)
-1102: [P] Coronary Artery Bypass Graft Surgery - post op new Afib (any)
-1103: [P] Aortic or Mitral Valve Repair or Replacement - post op new Afib (any)
-1104: [P] RBC Transfusion (adult relevant, no auto 1yr clean window)
-1105: [P] Clostridium difficile - first episode
-1106: [P] Non-Emergent Major Non Cardiac Surgery no prior Opioid
+
1093: [P] Abdominal Aoritc Aneurysm repair - post op new Afib (any)
+1094: [P] Lower Extremity Bypass - post op new Afib (any)
+1095: [P] Carotid Endarterectomy - post op new Afib (any)
+1096: [P] Lung Resection - post op new Afib (any)
+1097: [P] Esophagectomy - post op new Afib (any)
+1098: [P] Pancreatectomy - post op new Afib (any)
+1099: [P] Colectomy - post op new Afib (any)
+1100: [P] Cystectomy - post op new Afib (any)
+1101: [P] Nephrectomy - post op new Afib (any)
+1102: [P] Coronary Artery Bypass Graft Surgery - post op new Afib (any)
+1103: [P] Aortic or Mitral Valve Repair or Replacement - post op new Afib (any)
+1104: [P] RBC Transfusion (adult relevant, no auto 1yr clean window)
+1105: [P] Clostridium difficile - first episode
+1106: [P] Non-Emergent Major Non Cardiac Surgery no prior Opioid
@@ -547,343 +570,343 @@

Accepted Cohorts: No cohorts were accepted in this release.

New Cohorts: 20 were added.

-
1072: [P] CMV Anterior Uveitis
-1073: [P] Serious Infection, opportunistic infections and other infections of interest event
-1074: [P] Serious Infection
-1075: [P] FDA AESI Narcolepsy
-1076: [P] FDA AESI Anaphylaxis
-1077: [P] FDA AESI Anaphylaxis v2
-1078: [P] FDA AESI Bells Palsy
-1079: [P] FDA AESI Encephalomyelitis
-1080: [P] FDA AESI Guillain Barre Syndrome
-1081: [P] FDA AESI Acute Myocardial Infarction
-1082: [P] FDA AESI Myocarditis Pericarditis
-1083: [P] FDA AESI Immune Thrombocytopenia (ITP)
-1084: [P] FDA AESI Disseminated Intravascular Coagulation
-1085: [P] FDA AESI Appendicitis
-1086: [P] FDA AESI Transverse Myelitis
-1087: [P] FDA AESI Hemorrhagic Stroke
-1088: [P] FDA AESI Deep Vein Thrombosis (DVT)
-1089: [P] FDA AESI Non-hemorrhagic Stroke
-1090: [P] FDA AESI Pulmonary Embolism
-1091: [P] FDA AESI Thrombosis with Thrombocytopenia (TWT)
+
1072: [P] CMV Anterior Uveitis
+1073: [P] Serious Infection, opportunistic infections and other infections of interest event
+1074: [P] Serious Infection
+1075: [P] FDA AESI Narcolepsy
+1076: [P] FDA AESI Anaphylaxis
+1077: [P] FDA AESI Anaphylaxis v2
+1078: [P] FDA AESI Bells Palsy
+1079: [P] FDA AESI Encephalomyelitis
+1080: [P] FDA AESI Guillain Barre Syndrome
+1081: [P] FDA AESI Acute Myocardial Infarction
+1082: [P] FDA AESI Myocarditis Pericarditis
+1083: [P] FDA AESI Immune Thrombocytopenia (ITP)
+1084: [P] FDA AESI Disseminated Intravascular Coagulation
+1085: [P] FDA AESI Appendicitis
+1086: [P] FDA AESI Transverse Myelitis
+1087: [P] FDA AESI Hemorrhagic Stroke
+1088: [P] FDA AESI Deep Vein Thrombosis (DVT)
+1089: [P] FDA AESI Non-hemorrhagic Stroke
+1090: [P] FDA AESI Pulmonary Embolism
+1091: [P] FDA AESI Thrombosis with Thrombocytopenia (TWT)

Accepted Cohorts: No cohorts were accepted in this release.

New Cohorts: 37 were added.

-
1035: [P] New users of Thiazide diuretics
-1036: [P] New users of Beta blockers
-1037: [P] New users of SGLT2 inhibitor
-1038: [P] New users of GLP-1 receptor antagonists
-1039: [P] New users of DPP-4 inhibitors
-1040: [P] New users of Tumor Necrosis Factor alpha (TNFa) inhibitors
-1041: [P] New users of JAK inhibitors
-1042: [P] New users of IL-23 inhibitors
-1043: [P] New users of Fluoroquinolone systemic
-1044: [P] New users of Cephalosporin systemetic
-1045: [P] New users of Trimethoprim systemetic
-1046: [P] New users of Thiazide diuretics nested in essential hypertension
-1047: [P] New users of dihydropyridine calcium channel blockers nested in essential hypertension
-1048: [P] New users of dihydropyridine calcium channel blockers
-1049: [P] New users of Beta blockers nested in essential hypertension
-1050: [P] New users of Beta blockers nested in Left Heart Failure
-1051: [P] New users of SGLT2 inhibitor nested in Left Heart Failure
-1052: [P] New users of Beta blockers nested in Acute Myocardial Infarction
-1053: [P] New users of GLP-1 receptor antagonists nested in Type 2 diabetes mellitus
-1054: [P] New users of SGLT2 inhibitor nested in Type 2 diabetes mellitus
-1055: [P] New users of DPP-4 inhibitors nested in Type 2 diabetes mellitus
-1056: [P] New users of GLP-1 receptor antagonists nested in obesity
-1057: [P] New users of IL-23 inhibitors nested in Plaque psoriasis
-1058: [P] New users of Tumor Necrosis Factor alpha (TNFa) inhibitors nested in Plaque psoriasis
-1059: [P] New users of Tumor Necrosis Factor alpha (TNFa) inhibitors nested in Psoriatic Arthritis
-1060: [P] New users of Fluoroquinolone systemic nested in Urinary Tract Infection
-1061: [P] New users of Cephalosporin systemetic nested in Urinary Tract Infection
-1062: [P] New users of Trimethoprim systemetic nested in Urinary Tract Infection
-1063: [P] New users of Fluoroquinolone systemic nested in Acute Typical Pneumonia
-1064: [P] New users of Cephalosporin systemetic nested in Acute Typical Pneumonia
-1065: [P] New users of Trimethoprim systemetic nested in Acute Typical Pneumonia
-1066: [P] New users of Tumor Necrosis Factor alpha (TNFa) inhibitors nested in Rheumatoid arthritis
-1067: [P] New users of JAK inhibitors nested in Ulcerative colitis
-1068: [P] New users of Tumor Necrosis Factor alpha (TNFa) inhibitors nested in Ulcerative colitis
-1069: [P] New users of Tumor Necrosis Factor alpha (TNFa) inhibitors nested in Crohns disease
-1070: [P] New users of JAK inhibitors nested in Rheumatoid arthritis
-1071: [P] persons at risk at start of year 2012-2022 with 365d prior observation
+
1035: [P] New users of Thiazide diuretics
+1036: [P] New users of Beta blockers
+1037: [P] New users of SGLT2 inhibitor
+1038: [P] New users of GLP-1 receptor antagonists
+1039: [P] New users of DPP-4 inhibitors
+1040: [P] New users of Tumor Necrosis Factor alpha (TNFa) inhibitors
+1041: [P] New users of JAK inhibitors
+1042: [P] New users of IL-23 inhibitors
+1043: [P] New users of Fluoroquinolone systemic
+1044: [P] New users of Cephalosporin systemetic
+1045: [P] New users of Trimethoprim systemetic
+1046: [P] New users of Thiazide diuretics nested in essential hypertension
+1047: [P] New users of dihydropyridine calcium channel blockers nested in essential hypertension
+1048: [P] New users of dihydropyridine calcium channel blockers
+1049: [P] New users of Beta blockers nested in essential hypertension
+1050: [P] New users of Beta blockers nested in Left Heart Failure
+1051: [P] New users of SGLT2 inhibitor nested in Left Heart Failure
+1052: [P] New users of Beta blockers nested in Acute Myocardial Infarction
+1053: [P] New users of GLP-1 receptor antagonists nested in Type 2 diabetes mellitus
+1054: [P] New users of SGLT2 inhibitor nested in Type 2 diabetes mellitus
+1055: [P] New users of DPP-4 inhibitors nested in Type 2 diabetes mellitus
+1056: [P] New users of GLP-1 receptor antagonists nested in obesity
+1057: [P] New users of IL-23 inhibitors nested in Plaque psoriasis
+1058: [P] New users of Tumor Necrosis Factor alpha (TNFa) inhibitors nested in Plaque psoriasis
+1059: [P] New users of Tumor Necrosis Factor alpha (TNFa) inhibitors nested in Psoriatic Arthritis
+1060: [P] New users of Fluoroquinolone systemic nested in Urinary Tract Infection
+1061: [P] New users of Cephalosporin systemetic nested in Urinary Tract Infection
+1062: [P] New users of Trimethoprim systemetic nested in Urinary Tract Infection
+1063: [P] New users of Fluoroquinolone systemic nested in Acute Typical Pneumonia
+1064: [P] New users of Cephalosporin systemetic nested in Acute Typical Pneumonia
+1065: [P] New users of Trimethoprim systemetic nested in Acute Typical Pneumonia
+1066: [P] New users of Tumor Necrosis Factor alpha (TNFa) inhibitors nested in Rheumatoid arthritis
+1067: [P] New users of JAK inhibitors nested in Ulcerative colitis
+1068: [P] New users of Tumor Necrosis Factor alpha (TNFa) inhibitors nested in Ulcerative colitis
+1069: [P] New users of Tumor Necrosis Factor alpha (TNFa) inhibitors nested in Crohns disease
+1070: [P] New users of JAK inhibitors nested in Rheumatoid arthritis
+1071: [P] persons at risk at start of year 2012-2022 with 365d prior observation

This release includes the bulk of the cohorts submitted to the OHDSI PhenotypeLibrary in the month of September 2023, as part of the push for HowOften.

Accepted Cohorts: No cohorts were accepted in this release.

New Cohorts: 252 were added.

-
311: [P] Parasomnia
-742: [P] Parasomnia or Sleep dysfunction with arousal disturbance
-743: [P] Diabetic ketoacidosis IP-ER (SNOMED concept)
-744: [P] Pulmonary Hypertension
-745: [P] Inflammatory Bowel Disease
-746: [P] Chronic Thromboembolic Pulmonary Hypertension
-747: [P] Pulmonary Arterial Hypertension
-748: [P] Psoriatic arthritis
-749: [P] Plaque Psoriasis
-750: [P] Pulmonary hypertension associated with left heart disease (WHO Group 2)
-751: [P] Pulmonary hypertension associated with lung diseases and or hypoxia (WHO Group 3)
-752: [P] Firearm Accidents (FA)
-753: [P] Motor Vehicle Accidents (MVA)
-754: [P] Down Syndrome
-755: [P] Non-infectious uveitis and iridocyclitis
-756: [P] Cystic Fibrosis
-757: [P] Concomitant TNF - alpha Inhibitors and IL23 Inhibitors - GE 30D overlap
-759: [P] Concomitant TNF - alpha Inhibitors and IL12_23 Inhibitors - GE 30D overlap
-760: [P] Concomitant IL 23 Inhibitors and IL12_23 Inhibitors - GE 30D overlap
-761: [P] Pulmonary arterial hypertension with Prior Left Heart or Vice Versa
-762: [P] Endothelin receptor antagonists
-763: [P] Phosphodiesterase 5 inhibitors and guanylate cyclase stimulators
-764: [P] Prostacyclin analogues and prostacyclin receptor agonists
-765: [P] Earliest event of Left Heart Failure
-766: [P] Earliest event of Right Heart Failure
-767: [P] Earliest event of Sarcoidosis
-768: [P] Earliest event of Sickle Cell Anemia
-769: [P] Scleroderma, first occurrence
-770: [P] Essential Hypertension, first occurrence
-771: [P] Pulmonary Hypertension (Group 2 Left heart disease, encompassing)
-772: [P] Pulmonary Hypertension (Group 3 Chronic lung disease, encompassing)
-773: [P] Congenital Heart Disease
-774: [P] Portal Hypertension, first occurrence
-775: [P] First Inflammatory Bowel Disease
-776: [P] Antisynthetase syndrome
-777: [P] Mixed connective tissue disease
-778: [P] Undifferentiated connective tissue disease
-779: [P] Overlap syndrome
-780: [P] Raynaud?s disease or Raynaud's phenomenon
-781: [P] Antiphospholipid syndrome
-782: [P] CTEPH Prevalent (with Echo or RHC) with 2nd dx code 31-365 days after first dx
-783: [P] Pulmonary endarterectomy
-784: [P] Balloon Pulmonary Angioplasty
-785: [P] Skin Burns
-786: [P] Non-small cell lung cancer (NSCLC)
-787: [P] Lung cancer
-788: [P] Breast cancer
-789: [P] Glioblastoma multiforme (GBM)
-790: [P] Colorectal Cancer
-791: [P] Multiple Myeloma
-792: [P] Metastatic Hormone-Sensitive Prostate Cancer Synchronous
-793: [P] Metastatic Hormone-Sensitive Prostate Cancer Metachronus
-794: COPY OF [P][R] Bleeding
-795: [P] Antineoplastic drugs against colorectal cancer
-796: [P] Potential curative surgery for colorectal cancer
-797: [P] Radiotherapy against colorectal cancer
-798: [P] Primary adenocarcinoma of the colon or rectum
-802: [P] Acute Respiratory Failure 2
-803: [P] Fascial dehiscence and evisceration
-804: [P] Anastomotic leak or dehiscence
-805: [P] Intestinal obstruction (broad)
-806: [P] Intraabdominal abscess
-807: [P] Perioperative aspiration
-808: [P] Postoperative hemorrhage
-809: [P] Surgical wound infection (narrow)
-810: [P] Distant metastasis following colorectal cancer (wide)
-811: [P] Local recurrence after colorectal cancer
-812: [P] Primary adenocarcinoma of the colon or rectum, MSI-H or dMMR, no surgery or oncological treatment
-813: [P] Primary adenocarcinoma of the colon or rectum treated with potentially curative surgery
-814: [P] Primary adenocarcinoma of the colon or rectum, no curative intended surgery and oncological treatment
-817: [P] Primary adenocarcinoma of the colon or rectum, no curative intended surgery and oncological treatment2
-818: [P] Primary adenocarcinoma of the colon or rectum, MSI-L, MSI-indeterminate, MSS or pMMR
-819: [P] Primary adenocarcinoma of the colon or rectum, MSI-L, MSI-indeterminate, MSS or pMMR, treated with curative intended surgery
-820: [P] Primary adenocarcinoma of the colon or rectum, MSI-L, MSI-indeterminate, MSS or pMMR, oncological treatment, no curative surgery
-821: [P] Primary adenocarcinoma of the colon or rectum, MSI-L, MSI-indeterminate, MSS or pMMR, no surgery or oncological treatment
-822: [P] Primary adenocarcinoma of colon or rectum, MSI-H or dMMR, surgical treatment
-823: [P] Primary adenocarcinoma of colon or rectum, MSI-H or dMMR, oncological treatment no surgery
-824: [P] Primary adenocarcinoma of colon or rectum,  MSI-H or dMMR
-825: [P] Primary adenocarcinoma of colon
-826: [P] Primary adenocarcinoma of colon, no surgery or oncological treatment
-827: [P] Primary adenocarcinoma of colon surgical treatment
-828: [P] Primary adenocarcinoma of colon oncological treatment, no surgery
-829: [P] Primary adenocarcinoma of colon, MSI-L, MSI-indeterminate, MSS or pMMR
-830: [P] Primary adenocarcinoma of colon, MSI-L, MSI-indeterminate, MSS or pMMR, surgically treated
-831: [P] Primary adenocarcinoma of colon MSI-L, MSI-indeterminate, MSS or pMMR, oncological treatment, no surgery
-832: [P] Primary adenocarcinoma of colon MSI-L, MSI-indeterminate, MSS or pMMR, no surgery or oncological treatment
-833: [P] Primary adenocarcinoma of colon MSI-H or dMMR
-834: [P] Primary adenocarcinoma of colon MSI-H or dMMR, surgical treatment
-835: [P] Primary adenocarcinoma of colon MSI-H or dMMR, oncological treatment, no surgery
-836: [P] Primary adenocarcinoma of colon MSI-H or dMMR, no surgery or oncological treatment
-837: [P] Primary adenocarcinoma of rectum
-838: [P] Primary adenocarcinoma of rectum MSI-H or dMMR
-839: [P] Primary adenocarcinoma of rectum, MSI-H or dMMR, no surgery or oncological treatment
-840: [P] Primary adenocarcinoma of rectum MSI-H or dMMR, oncological treatment, no surgery
-841: [P] Primary adenocarcinoma of rectum, MSI-H or dMMR, surgical treatment
-842: [P] Primary adenocarcinoma of rectum, MSI-L, MSI-indeterminate, MSS or pMMR
-843: [P] Primary adenocarcinoma of rectum MSI-L, MSI-indeterminate, MSS or pMMR, oncological treatment,  no surgery
-844: [P] Primary adenocarcinoma of rectum MSI-L, MSI-indeterminate, MSS or pMMR, no surgery and no oncological treatment
-845: [P] Primary adenocarcinoma of rectum MSI-L, MSI-indeterminate, MSS or pMMR, treated with potentially curative surgery
-846: [P] Primary adenocarcinoma of rectum oncological treatment, no surgery
-847: [P] Primary adenocarcinoma of rectum surgical treatment
-848: [P] Primary adenocarcinoma of rectum, no surgery or oncological treatment
-850: [P] Intestinal obstruction (broad 2)
-851: [P] Intraabdominal obstruction (broad)
-852: [P] Surgical wound infection (broad)
-854: [P] Distant metastasis following colorectal cancer (medium)
-855: [P] Distant metastasis following colorectal cancer (narrow)
-856: [P] Earliest event of Migraine, including history of migraine
-857: [P] Earliest event of Migraine
-858: [P] Earliest event of Rheumatoid Arthritis
-859: [P] Earliest event of Crohns disease
-860: [P] Earliest event of Ulcerative colitis
-861: [P] Earliest event of Urinary tract infections (UTI)
-862: [P] Earliest event of Alzheimer's disease derived from Imfeld, 2
-863: [P] Cognitive impairment, incident
-864: [P] Earliest event of Dementia
-865: [P] Non-Emergent Major Non Cardiac Surgery
-866: [P] AAA repair
-867: [P] Lower Extremity Bypass
-868: [P] Carotid Endarterectomy
-869: [P] Lung Resection
-870: [P] Esophagectomy
-871: [P] Pancreatectomy
-872: [P] Colectomy
-873: [P] Cystectomy
-874: [P] Nephrectomy
-875: [P] Coronary Artery Bypass Graft Surgery
-876: [P] Aortic or Mitral Valve Repair or Replacement
-877: [P] Non-Emergent MNCS (age 18 or greater), post op Afib (parox)
-878: [P] Non-Emergent MNCS (age 18 or greater), post op Afib (any)
-879: Cxxx Endometriosis indexed on procedure with two or more diagnosis among females 15 to 49
-881: [P] Acute myocardial infarction
-882: [P] Decreased libido
-884: [P] Diarrhea2
-888: [P] Gastrointestinal bleeding
-889: [P] Hyponatremia
-890: [P] Hypotension
-891: [P] Nausea
-892: [P] Stroke
-893: [P] Vertigo
-894: [P] Abdominal pain
-895: [P] Abnormal weight gain
-896: [P] Abnormal weight loss
-898: [P] Acute renal failure
-899: [P] All-cause mortality
-900: [P] Anaphylactoid reaction
-901: [P] Anemia
-907: [P] All-cause mortality2
-910: [P] Anaphylactoid reaction2
-913: [P] Anemia2
-916: [P] Angioedema2
-917: [P] Anxiety
-918: [P] Bradycardia
-919: [P] Cardiac arrhythmia
-920: [P] Cardiovascular disease
-921: [P] Cardiovascular-related mortality
-922: [P] Chest pain or angina
-923: [P] Kidney disease
-924: [P] Coronary heart disease
-925: [P] Cough
-927: [P] Dementia2
-928: [P] Depression2
-929: [P] Edema2
-930: [P] End stage renal disease2
-931: [P] Fall2
-932: [P] Gout2
-933: [P] Headache2
-934: [P] Heart failure2
-935: [P] Hemorrhagic stroke2
-936: [P] Hepatic failure2
-937: [P] Hospitalization with heart failure2
-938: [P] Hospitalization with heart failure
-939: [P] Hospitalization with preinfarction syndrome
-940: [P] Hyperkalemia
-941: [P] Hypokalemia
-942: [P] Hypomagnesemia
-943: [P] Impotence
-944: [P] Ischemic stroke
-945: [P] Malignant neoplasm
-946: [P] Measured renal dysfunction
-947: [P] Neutropenia or agranulocytosis
-948: [P] Rash
-950: [P] Rhabdomyolysis2
-953: [P] Sudden cardiac death
-954: [P] Syncope
-955: [P] Thrombocytopenia
-956: [P] Transient ischemic attack
-957: [P] Type 2 diabetes mellitus
-958: [P] Syncope3
-959: [P] Thrombocytopenia3
-960: [P] Transient ischemic attack3
-961: [P] Type 2 diabetes mellitus3
-963: [P] Vomiting
-964: [P] Chronic kidney disease
-965: [P] 3-point MACE
-967: [P] 4-point MACE
-969: [P] Acute myocardial infarction2
-970: [P] 4-point MACE2
-975: [P] Acute renal failure2
-976: [P] Glycemic control2
-979: [P] Hospitalization with heart failure3
-980: [P] Revascularization
-982: [P] Stroke2
-983: [P] Sudden cardiac death2
-984: [P] Abnormal weight gain2
-985: [P] Abnormal weight loss2
-986: [P] Acute pancreatitis2
-988: [P] All-cause mortality3
-989: [P] Bladder cancer3
-990: [P] Bone fracture3
-991: [P] Breast cancer3
-992: [P] Diabetic ketoacidosis3
-993: [P] Diarrhea3
-994: [P] Genitourinary infection3
-995: [P] Hyperkalemia3
-996: [P] Hypoglycemia3
-997: [P] Hypotension3
-998: [P] Joint pain3
-999: [P] Lower extremity amputation3
-1000: [P] Nausea3
-1001: [P] Peripheral edema3
-1002: [P] Photosensitivity3
-1003: [P] Renal cancer3
-1004: [P] Thyroid tumor3
-1005: [P] Venous thromboembolism3
-1006: [P] Vomiting3
-1007: [P] Earliest event of Epilepsy
-1009: [P] Earliest event of Treatment resistant depression (TRD)
-1010: [P] Earliest event of Chronic Graft Versus Host Disease (GVHD)
-1011: [P] Earliest event of Marginal zone lymphoma
-1012: [P] Earliest event of Waldenstrom macroglobulinemia
-1013: [P] Earliest event of Ankylosing Spondylitis
-1015: [P] Earliest event of Pulmonary arterial hypertension (PAH)2
-1016: [P] Earliest event of Polyarticular juvenile idiopathic arthritis (JIA)
-1017: [P] Earliest event of Neonatal Thrombocytopenia (NT), less than 1 year old
-1018: [P] Earliest event of Warm Autoimmune Hemolytic Anemia (wAIHA), occurring on or after October 2020
-1019: [P] All events of Hemolytic Disease Fetus and Newborn (HDFN), RhD type, with a pregnancy episode
-1020: [P] Earliest event of Major depressive disorder, with NO occurrence of certain psychiatric disorder
-1021: [P] Earliest event of Myasthenia Gravis, inpatient, 2nd diagnosis or treatment, age gte 18
-1022: [P] Earliest event of Depressive and Sleep Disorder
-1023: [P] Earliest Event of Depressive Disorder with Suicidal Ideation or Attempt Prevalent
-1024: [P] Earliest Event of Depressive Disorder with Anhedonia
-1025: [P] First event of Attention-deficit hyperactivity (ADHD) disorder or procedure
-1026: [P] Earliest Event of Multiple Sclerosis
-1027: [P] Earliest event of Chronic Leukocytic Leukemia
-1028: [P] Earliest event of Urothelial carcinoma
-1029: [P] Earliest event of Mantle Cell Lymphoma
-1030: [P] Earliest event of Prostate cancer, among adult males
-1031: [P] Earliest event of Coronary artery disease (CAD)
-1032: [P] Earliest event of Type 2 Diabetes Mellitus (DM), with no type 1 or secondary DM
-1033: [P] Earliest event of Human Immunodeficiency Virus I (HIV), with treatment, lab or 2nd diagnosis
-1034: [P] All events of Respiratory syncytial virus infection, with 30 days washout
+
311: [P] Parasomnia
+742: [P] Parasomnia or Sleep dysfunction with arousal disturbance
+743: [P] Diabetic ketoacidosis IP-ER (SNOMED concept)
+744: [P] Pulmonary Hypertension
+745: [P] Inflammatory Bowel Disease
+746: [P] Chronic Thromboembolic Pulmonary Hypertension
+747: [P] Pulmonary Arterial Hypertension
+748: [P] Psoriatic arthritis
+749: [P] Plaque Psoriasis
+750: [P] Pulmonary hypertension associated with left heart disease (WHO Group 2)
+751: [P] Pulmonary hypertension associated with lung diseases and or hypoxia (WHO Group 3)
+752: [P] Firearm Accidents (FA)
+753: [P] Motor Vehicle Accidents (MVA)
+754: [P] Down Syndrome
+755: [P] Non-infectious uveitis and iridocyclitis
+756: [P] Cystic Fibrosis
+757: [P] Concomitant TNF - alpha Inhibitors and IL23 Inhibitors - GE 30D overlap
+759: [P] Concomitant TNF - alpha Inhibitors and IL12_23 Inhibitors - GE 30D overlap
+760: [P] Concomitant IL 23 Inhibitors and IL12_23 Inhibitors - GE 30D overlap
+761: [P] Pulmonary arterial hypertension with Prior Left Heart or Vice Versa
+762: [P] Endothelin receptor antagonists
+763: [P] Phosphodiesterase 5 inhibitors and guanylate cyclase stimulators
+764: [P] Prostacyclin analogues and prostacyclin receptor agonists
+765: [P] Earliest event of Left Heart Failure
+766: [P] Earliest event of Right Heart Failure
+767: [P] Earliest event of Sarcoidosis
+768: [P] Earliest event of Sickle Cell Anemia
+769: [P] Scleroderma, first occurrence
+770: [P] Essential Hypertension, first occurrence
+771: [P] Pulmonary Hypertension (Group 2 Left heart disease, encompassing)
+772: [P] Pulmonary Hypertension (Group 3 Chronic lung disease, encompassing)
+773: [P] Congenital Heart Disease
+774: [P] Portal Hypertension, first occurrence
+775: [P] First Inflammatory Bowel Disease
+776: [P] Antisynthetase syndrome
+777: [P] Mixed connective tissue disease
+778: [P] Undifferentiated connective tissue disease
+779: [P] Overlap syndrome
+780: [P] Raynaud?s disease or Raynaud's phenomenon
+781: [P] Antiphospholipid syndrome
+782: [P] CTEPH Prevalent (with Echo or RHC) with 2nd dx code 31-365 days after first dx
+783: [P] Pulmonary endarterectomy
+784: [P] Balloon Pulmonary Angioplasty
+785: [P] Skin Burns
+786: [P] Non-small cell lung cancer (NSCLC)
+787: [P] Lung cancer
+788: [P] Breast cancer
+789: [P] Glioblastoma multiforme (GBM)
+790: [P] Colorectal Cancer
+791: [P] Multiple Myeloma
+792: [P] Metastatic Hormone-Sensitive Prostate Cancer Synchronous
+793: [P] Metastatic Hormone-Sensitive Prostate Cancer Metachronus
+794: COPY OF [P][R] Bleeding
+795: [P] Antineoplastic drugs against colorectal cancer
+796: [P] Potential curative surgery for colorectal cancer
+797: [P] Radiotherapy against colorectal cancer
+798: [P] Primary adenocarcinoma of the colon or rectum
+802: [P] Acute Respiratory Failure 2
+803: [P] Fascial dehiscence and evisceration
+804: [P] Anastomotic leak or dehiscence
+805: [P] Intestinal obstruction (broad)
+806: [P] Intraabdominal abscess
+807: [P] Perioperative aspiration
+808: [P] Postoperative hemorrhage
+809: [P] Surgical wound infection (narrow)
+810: [P] Distant metastasis following colorectal cancer (wide)
+811: [P] Local recurrence after colorectal cancer
+812: [P] Primary adenocarcinoma of the colon or rectum, MSI-H or dMMR, no surgery or oncological treatment
+813: [P] Primary adenocarcinoma of the colon or rectum treated with potentially curative surgery
+814: [P] Primary adenocarcinoma of the colon or rectum, no curative intended surgery and oncological treatment
+817: [P] Primary adenocarcinoma of the colon or rectum, no curative intended surgery and oncological treatment2
+818: [P] Primary adenocarcinoma of the colon or rectum, MSI-L, MSI-indeterminate, MSS or pMMR
+819: [P] Primary adenocarcinoma of the colon or rectum, MSI-L, MSI-indeterminate, MSS or pMMR, treated with curative intended surgery
+820: [P] Primary adenocarcinoma of the colon or rectum, MSI-L, MSI-indeterminate, MSS or pMMR, oncological treatment, no curative surgery
+821: [P] Primary adenocarcinoma of the colon or rectum, MSI-L, MSI-indeterminate, MSS or pMMR, no surgery or oncological treatment
+822: [P] Primary adenocarcinoma of colon or rectum, MSI-H or dMMR, surgical treatment
+823: [P] Primary adenocarcinoma of colon or rectum, MSI-H or dMMR, oncological treatment no surgery
+824: [P] Primary adenocarcinoma of colon or rectum,  MSI-H or dMMR
+825: [P] Primary adenocarcinoma of colon
+826: [P] Primary adenocarcinoma of colon, no surgery or oncological treatment
+827: [P] Primary adenocarcinoma of colon surgical treatment
+828: [P] Primary adenocarcinoma of colon oncological treatment, no surgery
+829: [P] Primary adenocarcinoma of colon, MSI-L, MSI-indeterminate, MSS or pMMR
+830: [P] Primary adenocarcinoma of colon, MSI-L, MSI-indeterminate, MSS or pMMR, surgically treated
+831: [P] Primary adenocarcinoma of colon MSI-L, MSI-indeterminate, MSS or pMMR, oncological treatment, no surgery
+832: [P] Primary adenocarcinoma of colon MSI-L, MSI-indeterminate, MSS or pMMR, no surgery or oncological treatment
+833: [P] Primary adenocarcinoma of colon MSI-H or dMMR
+834: [P] Primary adenocarcinoma of colon MSI-H or dMMR, surgical treatment
+835: [P] Primary adenocarcinoma of colon MSI-H or dMMR, oncological treatment, no surgery
+836: [P] Primary adenocarcinoma of colon MSI-H or dMMR, no surgery or oncological treatment
+837: [P] Primary adenocarcinoma of rectum
+838: [P] Primary adenocarcinoma of rectum MSI-H or dMMR
+839: [P] Primary adenocarcinoma of rectum, MSI-H or dMMR, no surgery or oncological treatment
+840: [P] Primary adenocarcinoma of rectum MSI-H or dMMR, oncological treatment, no surgery
+841: [P] Primary adenocarcinoma of rectum, MSI-H or dMMR, surgical treatment
+842: [P] Primary adenocarcinoma of rectum, MSI-L, MSI-indeterminate, MSS or pMMR
+843: [P] Primary adenocarcinoma of rectum MSI-L, MSI-indeterminate, MSS or pMMR, oncological treatment,  no surgery
+844: [P] Primary adenocarcinoma of rectum MSI-L, MSI-indeterminate, MSS or pMMR, no surgery and no oncological treatment
+845: [P] Primary adenocarcinoma of rectum MSI-L, MSI-indeterminate, MSS or pMMR, treated with potentially curative surgery
+846: [P] Primary adenocarcinoma of rectum oncological treatment, no surgery
+847: [P] Primary adenocarcinoma of rectum surgical treatment
+848: [P] Primary adenocarcinoma of rectum, no surgery or oncological treatment
+850: [P] Intestinal obstruction (broad 2)
+851: [P] Intraabdominal obstruction (broad)
+852: [P] Surgical wound infection (broad)
+854: [P] Distant metastasis following colorectal cancer (medium)
+855: [P] Distant metastasis following colorectal cancer (narrow)
+856: [P] Earliest event of Migraine, including history of migraine
+857: [P] Earliest event of Migraine
+858: [P] Earliest event of Rheumatoid Arthritis
+859: [P] Earliest event of Crohns disease
+860: [P] Earliest event of Ulcerative colitis
+861: [P] Earliest event of Urinary tract infections (UTI)
+862: [P] Earliest event of Alzheimer's disease derived from Imfeld, 2
+863: [P] Cognitive impairment, incident
+864: [P] Earliest event of Dementia
+865: [P] Non-Emergent Major Non Cardiac Surgery
+866: [P] AAA repair
+867: [P] Lower Extremity Bypass
+868: [P] Carotid Endarterectomy
+869: [P] Lung Resection
+870: [P] Esophagectomy
+871: [P] Pancreatectomy
+872: [P] Colectomy
+873: [P] Cystectomy
+874: [P] Nephrectomy
+875: [P] Coronary Artery Bypass Graft Surgery
+876: [P] Aortic or Mitral Valve Repair or Replacement
+877: [P] Non-Emergent MNCS (age 18 or greater), post op Afib (parox)
+878: [P] Non-Emergent MNCS (age 18 or greater), post op Afib (any)
+879: Cxxx Endometriosis indexed on procedure with two or more diagnosis among females 15 to 49
+881: [P] Acute myocardial infarction
+882: [P] Decreased libido
+884: [P] Diarrhea2
+888: [P] Gastrointestinal bleeding
+889: [P] Hyponatremia
+890: [P] Hypotension
+891: [P] Nausea
+892: [P] Stroke
+893: [P] Vertigo
+894: [P] Abdominal pain
+895: [P] Abnormal weight gain
+896: [P] Abnormal weight loss
+898: [P] Acute renal failure
+899: [P] All-cause mortality
+900: [P] Anaphylactoid reaction
+901: [P] Anemia
+907: [P] All-cause mortality2
+910: [P] Anaphylactoid reaction2
+913: [P] Anemia2
+916: [P] Angioedema2
+917: [P] Anxiety
+918: [P] Bradycardia
+919: [P] Cardiac arrhythmia
+920: [P] Cardiovascular disease
+921: [P] Cardiovascular-related mortality
+922: [P] Chest pain or angina
+923: [P] Kidney disease
+924: [P] Coronary heart disease
+925: [P] Cough
+927: [P] Dementia2
+928: [P] Depression2
+929: [P] Edema2
+930: [P] End stage renal disease2
+931: [P] Fall2
+932: [P] Gout2
+933: [P] Headache2
+934: [P] Heart failure2
+935: [P] Hemorrhagic stroke2
+936: [P] Hepatic failure2
+937: [P] Hospitalization with heart failure2
+938: [P] Hospitalization with heart failure
+939: [P] Hospitalization with preinfarction syndrome
+940: [P] Hyperkalemia
+941: [P] Hypokalemia
+942: [P] Hypomagnesemia
+943: [P] Impotence
+944: [P] Ischemic stroke
+945: [P] Malignant neoplasm
+946: [P] Measured renal dysfunction
+947: [P] Neutropenia or agranulocytosis
+948: [P] Rash
+950: [P] Rhabdomyolysis2
+953: [P] Sudden cardiac death
+954: [P] Syncope
+955: [P] Thrombocytopenia
+956: [P] Transient ischemic attack
+957: [P] Type 2 diabetes mellitus
+958: [P] Syncope3
+959: [P] Thrombocytopenia3
+960: [P] Transient ischemic attack3
+961: [P] Type 2 diabetes mellitus3
+963: [P] Vomiting
+964: [P] Chronic kidney disease
+965: [P] 3-point MACE
+967: [P] 4-point MACE
+969: [P] Acute myocardial infarction2
+970: [P] 4-point MACE2
+975: [P] Acute renal failure2
+976: [P] Glycemic control2
+979: [P] Hospitalization with heart failure3
+980: [P] Revascularization
+982: [P] Stroke2
+983: [P] Sudden cardiac death2
+984: [P] Abnormal weight gain2
+985: [P] Abnormal weight loss2
+986: [P] Acute pancreatitis2
+988: [P] All-cause mortality3
+989: [P] Bladder cancer3
+990: [P] Bone fracture3
+991: [P] Breast cancer3
+992: [P] Diabetic ketoacidosis3
+993: [P] Diarrhea3
+994: [P] Genitourinary infection3
+995: [P] Hyperkalemia3
+996: [P] Hypoglycemia3
+997: [P] Hypotension3
+998: [P] Joint pain3
+999: [P] Lower extremity amputation3
+1000: [P] Nausea3
+1001: [P] Peripheral edema3
+1002: [P] Photosensitivity3
+1003: [P] Renal cancer3
+1004: [P] Thyroid tumor3
+1005: [P] Venous thromboembolism3
+1006: [P] Vomiting3
+1007: [P] Earliest event of Epilepsy
+1009: [P] Earliest event of Treatment resistant depression (TRD)
+1010: [P] Earliest event of Chronic Graft Versus Host Disease (GVHD)
+1011: [P] Earliest event of Marginal zone lymphoma
+1012: [P] Earliest event of Waldenstrom macroglobulinemia
+1013: [P] Earliest event of Ankylosing Spondylitis
+1015: [P] Earliest event of Pulmonary arterial hypertension (PAH)2
+1016: [P] Earliest event of Polyarticular juvenile idiopathic arthritis (JIA)
+1017: [P] Earliest event of Neonatal Thrombocytopenia (NT), less than 1 year old
+1018: [P] Earliest event of Warm Autoimmune Hemolytic Anemia (wAIHA), occurring on or after October 2020
+1019: [P] All events of Hemolytic Disease Fetus and Newborn (HDFN), RhD type, with a pregnancy episode
+1020: [P] Earliest event of Major depressive disorder, with NO occurrence of certain psychiatric disorder
+1021: [P] Earliest event of Myasthenia Gravis, inpatient, 2nd diagnosis or treatment, age gte 18
+1022: [P] Earliest event of Depressive and Sleep Disorder
+1023: [P] Earliest Event of Depressive Disorder with Suicidal Ideation or Attempt Prevalent
+1024: [P] Earliest Event of Depressive Disorder with Anhedonia
+1025: [P] First event of Attention-deficit hyperactivity (ADHD) disorder or procedure
+1026: [P] Earliest Event of Multiple Sclerosis
+1027: [P] Earliest event of Chronic Leukocytic Leukemia
+1028: [P] Earliest event of Urothelial carcinoma
+1029: [P] Earliest event of Mantle Cell Lymphoma
+1030: [P] Earliest event of Prostate cancer, among adult males
+1031: [P] Earliest event of Coronary artery disease (CAD)
+1032: [P] Earliest event of Type 2 Diabetes Mellitus (DM), with no type 1 or secondary DM
+1033: [P] Earliest event of Human Immunodeficiency Virus I (HIV), with treatment, lab or 2nd diagnosis
+1034: [P] All events of Respiratory syncytial virus infection, with 30 days washout

This release is a clean up of files and cohorts before adding cohorts from HowOften. getPhenotypeLog() now gives additional information about a cohort. These are programmatically derived from Circe model compatible cohort json.

-
censorWindowStartDate   censorWindowEndDate collapseSettingsType    
-collapseEraPad  exitStrategy    exitDateOffSetField exitDateOffSet  
-numberOfInclusionRules  qualifyingLimitType primaryCriteriaLimit    
-numberOfCohortEntryEvents   numberOfDomainsInEntryEvents    
-domainsInEntryEvents    continousObservationWindowPrior 
-continousObservationWindowPost  numberOfConceptSets 
-demographicCriteria demographicCriteriaAge  demographicCriteriaGender   
-useOfObservationPeriodInclusionRule restrictedByVisit   
-domainConditionOccurrence   domainMeasurement   domainObservation   
-domainVisitOccurrence   domainDeath domainDrugExposure  
-criteriaAgePrimaryCriteria  domainDeviceExposure    
-domainProcedureOccurrence   criteriaAgeInclusionRules   
-criteriaGenderPrimaryCriteria   criteriaGenderInclusionRules
+
censorWindowStartDate   censorWindowEndDate collapseSettingsType    
+collapseEraPad  exitStrategy    exitDateOffSetField exitDateOffSet  
+numberOfInclusionRules  qualifyingLimitType primaryCriteriaLimit    
+numberOfCohortEntryEvents   numberOfDomainsInEntryEvents    
+domainsInEntryEvents    continousObservationWindowPrior 
+continousObservationWindowPost  numberOfConceptSets 
+demographicCriteria demographicCriteriaAge  demographicCriteriaGender   
+useOfObservationPeriodInclusionRule restrictedByVisit   
+domainConditionOccurrence   domainMeasurement   domainObservation   
+domainVisitOccurrence   domainDeath domainDrugExposure  
+criteriaAgePrimaryCriteria  domainDeviceExposure    
+domainProcedureOccurrence   criteriaAgeInclusionRules   
+criteriaGenderPrimaryCriteria   criteriaGenderInclusionRules

Accepted Cohorts: No cohorts were accepted in this release.

New Cohorts: No new cohorts were added in this release.

@@ -895,45 +918,45 @@

Accepted Cohorts: No cohorts were accepted in this release.

New Cohorts: 39 were added.

-
701: [P][R] Ascites
-702: [P] Alanine aminotransferase (ALT) elevated
-703: [P] Aspartate aminotransferase (AST) elevated
-705: [P] Total Bilirubin elevated
-706: [P] Prothrombin time (PT) elevated
-707: Inpatient Hospitalization (0Pe, 1Era)
-708: [P] International normalized ratio (INR) elevated
-709: [P][R] Chronic liver disease
-710: [P] Cirrhosis of liver or its sequela
-711: [P][R] Transplanted liver present
-712: [P] Viral hepatitis including history of
-713: [P] Alcoholic hepatitis or alcohol liver disorder
-714: [P][R] Endometriosis (clinical)
-715: [P] Hepatic fibrosis
-716: [P] Acute Hepatic Injury
-717: [P] Portal hypertension or esophageal varices
-719: [P] Acute Hepatic Injury or jaundice while inpatient with no cooccurring certain liver disease
-720: [P] Aplastic Anemia
-721: [P] Sudden New Onset Blindness
-722: [P] Endometriosis indexed on procedure with two or more diagnosis among females 15 to 49
-723: [P] First Acute Hepatic Failure with no known severe liver disease
-724: [P] First Acute Hepatic Failure with no known liver disease
-725: [P] All events of Acute Kidney Injury (AKI), with a washout period of 30 days
-726: [P] All events of Anaphylaxis, Mini-Sentinel
-727: [P] All events of Angioedema, with a washout period of 180 days
-728: [P] Autoimmune hemolytic anemia events not including evans syndrome
-729: [P] Autoimmune hepatitis, with a washout period of 365 days
-730: [P] Acute pancreatitis, indexed on visit with NO chronic or hereditary pancreatitis
-731: [P] Sudden Hearing Loss, No congenital anomaly or middle or inner ear conditions
-732: [P] Severe Cutaneous Adverse Reaction (SCAR = SJS+TEN+DRESS) with clean window
-733: [P] Drug Rash with Eosinophilia and Systemic Symptoms (DRESS) with clean window
-734: [P] Drug Rash with Eosinophilia and Systemic Symptoms (DRESS)
-735: [P] Acute Liver Injury indexed on diagnosis or symptoms with no chronic hepatic failure
-736: [P] Acute Liver Injury NO viral, alcoholic, chronic hepatic failure
-737: [P] Neutropenic Fever, Inpatient or ER, indexed on fever or Infection, 90 days era
-738: [P] Autoimmune hemolytic anemia
-739: [P] All events of Isolated Immune Thrombocytopenia (ITP), with a washout period of 365 days
-740: [P] Earliest event of Pulmonary arterial hypertension (PAH)
-741: [P] Earliest event of Thrombotic microangiopathy (TMA) or Microangiopathic hemolytic anemia (MAHA)
+
701: [P][R] Ascites
+702: [P] Alanine aminotransferase (ALT) elevated
+703: [P] Aspartate aminotransferase (AST) elevated
+705: [P] Total Bilirubin elevated
+706: [P] Prothrombin time (PT) elevated
+707: Inpatient Hospitalization (0Pe, 1Era)
+708: [P] International normalized ratio (INR) elevated
+709: [P][R] Chronic liver disease
+710: [P] Cirrhosis of liver or its sequela
+711: [P][R] Transplanted liver present
+712: [P] Viral hepatitis including history of
+713: [P] Alcoholic hepatitis or alcohol liver disorder
+714: [P][R] Endometriosis (clinical)
+715: [P] Hepatic fibrosis
+716: [P] Acute Hepatic Injury
+717: [P] Portal hypertension or esophageal varices
+719: [P] Acute Hepatic Injury or jaundice while inpatient with no cooccurring certain liver disease
+720: [P] Aplastic Anemia
+721: [P] Sudden New Onset Blindness
+722: [P] Endometriosis indexed on procedure with two or more diagnosis among females 15 to 49
+723: [P] First Acute Hepatic Failure with no known severe liver disease
+724: [P] First Acute Hepatic Failure with no known liver disease
+725: [P] All events of Acute Kidney Injury (AKI), with a washout period of 30 days
+726: [P] All events of Anaphylaxis, Mini-Sentinel
+727: [P] All events of Angioedema, with a washout period of 180 days
+728: [P] Autoimmune hemolytic anemia events not including evans syndrome
+729: [P] Autoimmune hepatitis, with a washout period of 365 days
+730: [P] Acute pancreatitis, indexed on visit with NO chronic or hereditary pancreatitis
+731: [P] Sudden Hearing Loss, No congenital anomaly or middle or inner ear conditions
+732: [P] Severe Cutaneous Adverse Reaction (SCAR = SJS+TEN+DRESS) with clean window
+733: [P] Drug Rash with Eosinophilia and Systemic Symptoms (DRESS) with clean window
+734: [P] Drug Rash with Eosinophilia and Systemic Symptoms (DRESS)
+735: [P] Acute Liver Injury indexed on diagnosis or symptoms with no chronic hepatic failure
+736: [P] Acute Liver Injury NO viral, alcoholic, chronic hepatic failure
+737: [P] Neutropenic Fever, Inpatient or ER, indexed on fever or Infection, 90 days era
+738: [P] Autoimmune hemolytic anemia
+739: [P] All events of Isolated Immune Thrombocytopenia (ITP), with a washout period of 365 days
+740: [P] Earliest event of Pulmonary arterial hypertension (PAH)
+741: [P] Earliest event of Thrombotic microangiopathy (TMA) or Microangiopathic hemolytic anemia (MAHA)
@@ -945,706 +968,706 @@

Accepted Cohorts: No cohorts were accepted in this release.

New Cohorts: 7 were added.

-
410: [P] Acute Urinary tract infections UTI (1Pe, 30Era)
-411: [P] Sepsis or Septic Shock (1Pe, 7Era)
-412: Transverse myelitis indexed on diagnosis (1Ps, 0Era, 365W)
-414: [P] Acute Skin Eruption symptoms (1Pe, 7Era)
-415: [P] Skin Erythema (1Pe, 7Era)
-416: [P] Skin Rash (1Pe, 7Era)
-417: [P] Acute gastrointestinal bleeding events (7Pe, 30Era)
+
410: [P] Acute Urinary tract infections UTI (1Pe, 30Era)
+411: [P] Sepsis or Septic Shock (1Pe, 7Era)
+412: Transverse myelitis indexed on diagnosis (1Ps, 0Era, 365W)
+414: [P] Acute Skin Eruption symptoms (1Pe, 7Era)
+415: [P] Skin Erythema (1Pe, 7Era)
+416: [P] Skin Rash (1Pe, 7Era)
+417: [P] Acute gastrointestinal bleeding events (7Pe, 30Era)

Accepted Cohorts: No cohorts were accepted in this release.

New Cohorts: 44 were added.

-
363: [P] Joint Stiffness (3Pe, 7Era)
-364: [P] Sleep disorder (3Pe, 7Era)
-365: [P] Dysuria (3Pe, 7Era)
-366: [P] Streptococcal throat infection (14Pe, 30Era)
-367: [P] Allergic Rhinitis (14Pe, 30Era)
-368: [P] Sinusitis (7Pe, 30Era)
-369: [P] Allergic condition (14Pe, 30Era)
-370: [P] Allergic disorder (14Pe, 30Era)
-371: [P] Claudication Pain (365Pe, 365Era)
-372: [P] Otitis media (3Pe, 30Era)
-373: [P] Iron deficiency Anemia (365Pe, 365Era)
-374: [P] Drug Dependence Disorder (30Pe, 365Era)
-375: [P] Gall stone disorder (30Pe, 365Era)
-376: [P] Skin Bleeding (1Pe, 7Era)
-377: [P] Skin Petechiae (1Pe, 7Era)
-378: [P] Skin Purpura (1Pe, 7Era)
-379: [P] Ecchymosis (1Pe, 7Era)
-380: [P] Jaundice (1Pe, 7Era)
-381: [P] Skin Itching  (1Pe, 7Era)
-382: [P] Prurititc Rash (1Pe, 7Era)
-383: [P] Eczematous Atopic Dermatitis and non hyperkeratotic dermatosis (1Pe, 365Era)
-384: [P] Contact Dermatitis (14Pe, 60Era)
-385: [P] Intertrigo (14Pe, 60Era)
-386: [P] Seborrheic dermatitis (14Pe, 60Era)
-387: [P] Photodermatitis (14Pe, 60Era)
-388: [P] Peripheral Neuritis (FP)
-389: [P] Peripheral Neuropathy or Neuritits (FP)
-391: [P] Hearing Loss (30Pe, 365Era)
-392: [P] Otalgia or Otitis (3Pe, 30Era)
-393: [P] Low Back Pain or Injury (3Pe, 7Era)
-394: [P] Gastroesophageal reflux disease (365Pe, 365Era)
-395: [P] Dysmenorrhea (90Pe, 365Era)
-396: [P] Osteoarthritis (FP)
-397: [P] Benign Prostatic Hyperplasia (FP)
-398: [P] Bladder Outflow Obstruction (0Pe, 180Era)
-399: [P] Kidney Stone (1Pe, 30Era)
-400: [P] Prostate Cancer among adult males (FP)
-401: [P] Uterine Fibroids (FP)
-402: [P] Ventilatory assist for respiratory findings with Acute Respiratory Failure (0Pe, 0Era)
-403: [P] Acute Respiratory Failure in inpatient or Emergency room (0Pe, 0Era)
-404: [P] Ventricular Tachycardia, in an Inpatient or Emergency room setting (1Pe, 7Era)
-405: [P] Atrial Fibrillation or Flutter (1Pe, 365Era)
-406: [P] Intellectual Disability (FP)
-407: [P] Hemorrhoids (1Pe, 30Era)
+
363: [P] Joint Stiffness (3Pe, 7Era)
+364: [P] Sleep disorder (3Pe, 7Era)
+365: [P] Dysuria (3Pe, 7Era)
+366: [P] Streptococcal throat infection (14Pe, 30Era)
+367: [P] Allergic Rhinitis (14Pe, 30Era)
+368: [P] Sinusitis (7Pe, 30Era)
+369: [P] Allergic condition (14Pe, 30Era)
+370: [P] Allergic disorder (14Pe, 30Era)
+371: [P] Claudication Pain (365Pe, 365Era)
+372: [P] Otitis media (3Pe, 30Era)
+373: [P] Iron deficiency Anemia (365Pe, 365Era)
+374: [P] Drug Dependence Disorder (30Pe, 365Era)
+375: [P] Gall stone disorder (30Pe, 365Era)
+376: [P] Skin Bleeding (1Pe, 7Era)
+377: [P] Skin Petechiae (1Pe, 7Era)
+378: [P] Skin Purpura (1Pe, 7Era)
+379: [P] Ecchymosis (1Pe, 7Era)
+380: [P] Jaundice (1Pe, 7Era)
+381: [P] Skin Itching  (1Pe, 7Era)
+382: [P] Prurititc Rash (1Pe, 7Era)
+383: [P] Eczematous Atopic Dermatitis and non hyperkeratotic dermatosis (1Pe, 365Era)
+384: [P] Contact Dermatitis (14Pe, 60Era)
+385: [P] Intertrigo (14Pe, 60Era)
+386: [P] Seborrheic dermatitis (14Pe, 60Era)
+387: [P] Photodermatitis (14Pe, 60Era)
+388: [P] Peripheral Neuritis (FP)
+389: [P] Peripheral Neuropathy or Neuritits (FP)
+391: [P] Hearing Loss (30Pe, 365Era)
+392: [P] Otalgia or Otitis (3Pe, 30Era)
+393: [P] Low Back Pain or Injury (3Pe, 7Era)
+394: [P] Gastroesophageal reflux disease (365Pe, 365Era)
+395: [P] Dysmenorrhea (90Pe, 365Era)
+396: [P] Osteoarthritis (FP)
+397: [P] Benign Prostatic Hyperplasia (FP)
+398: [P] Bladder Outflow Obstruction (0Pe, 180Era)
+399: [P] Kidney Stone (1Pe, 30Era)
+400: [P] Prostate Cancer among adult males (FP)
+401: [P] Uterine Fibroids (FP)
+402: [P] Ventilatory assist for respiratory findings with Acute Respiratory Failure (0Pe, 0Era)
+403: [P] Acute Respiratory Failure in inpatient or Emergency room (0Pe, 0Era)
+404: [P] Ventricular Tachycardia, in an Inpatient or Emergency room setting (1Pe, 7Era)
+405: [P] Atrial Fibrillation or Flutter (1Pe, 365Era)
+406: [P] Intellectual Disability (FP)
+407: [P] Hemorrhoids (1Pe, 30Era)

Accepted Cohorts: 5 cohorts were accepted in this release.

-
304: Neurofibromatosis type 1 (FP)
-305: Neurofibromatosis type 1 without Type 2 (FP)
-306: Optical pathway glioma and neurofibromatosis (FP)
-307: Optical pathway glioma or non malignant neoplasm of optic nerve w neurofibromatosis (FP)
-308: Optical pathway glioma with MRI imaging and ophthalmology visits Neurofibromatosis (FP)
+
304: Neurofibromatosis type 1 (FP)
+305: Neurofibromatosis type 1 without Type 2 (FP)
+306: Optical pathway glioma and neurofibromatosis (FP)
+307: Optical pathway glioma or non malignant neoplasm of optic nerve w neurofibromatosis (FP)
+308: Optical pathway glioma with MRI imaging and ophthalmology visits Neurofibromatosis (FP)

New Cohorts: 7 were added.

-
361: [P] Restless Leg Syndrome (FP)
-362: [P] Acute Kidney Injury AKI (7Pe, 30W)
+
361: [P] Restless Leg Syndrome (FP)
+362: [P] Acute Kidney Injury AKI (7Pe, 30W)

Accepted Cohorts: No cohorts were accepted in this release.

New Cohorts: 13 were added.

-
348: [P] Hematuria (7Pe, 30Era)
-349: [P] Lower gastrointestinal bleeding events (7Pe, 30Era)
-350: [P] Hemoptysis (7Pe, 30Era)
-351: [P] Nasal Polyp (365Pe, 365Era)
-352: [P] Inflamed Tonsil (7Pe, 30Era)
-353: [P] Conjunctivitis (3Pe, 7Era)
-354: [P] Nasal Congestion or Rhinitis or Common Cold (3Pe, 7Era)
-355: [P] Laryngitis (3Pe, 7Era)
-356: [P] Epistaxis (3Pe, 7Era)
-357: [P] Pulmonary Edema (3Pe, 30Era)
-358: [P] Acute Respiratory Failure among persons with no chronic respiratory failure (3Pe, 30Era)
-359: [P] Acute Respiratory Failure (3Pe, 30Era)
-360: [P] Pleural Effusion (3Pe, 30Era)
+
348: [P] Hematuria (7Pe, 30Era)
+349: [P] Lower gastrointestinal bleeding events (7Pe, 30Era)
+350: [P] Hemoptysis (7Pe, 30Era)
+351: [P] Nasal Polyp (365Pe, 365Era)
+352: [P] Inflamed Tonsil (7Pe, 30Era)
+353: [P] Conjunctivitis (3Pe, 7Era)
+354: [P] Nasal Congestion or Rhinitis or Common Cold (3Pe, 7Era)
+355: [P] Laryngitis (3Pe, 7Era)
+356: [P] Epistaxis (3Pe, 7Era)
+357: [P] Pulmonary Edema (3Pe, 30Era)
+358: [P] Acute Respiratory Failure among persons with no chronic respiratory failure (3Pe, 30Era)
+359: [P] Acute Respiratory Failure (3Pe, 30Era)
+360: [P] Pleural Effusion (3Pe, 30Era)

Accepted Cohorts: 2 were accepted. 234: Appendicitis (1Pe, 180Era) 213: Acquired Neutropenia or unspecified leukopenia (21Pe, 365Era)

New Cohorts: 9 were added.

-
339: [P] Hypotension (1Pe, 3Era)
-340: [P] Hives, Erythema, Eruption, Urticaria (1Pe, 7Era)
-341: [P] Loss of mentation including coma, loss of consciousness, altered consciousness (1Pe, 3Era)
-342: [P] Urinary Incontinence (1Pe, 3Era)
-343: [P] Fecal Incontinence (1Pe, 3Era)
-344: [P] Doctors office or clinic visit without other overlapping visits (0Pe, 0Era)
-345: [P] Doctors office or clinic visit (0Pe, 0Era)
-346: [P] Non urgent outpatient visit without overlapping inpatient or emergency visit (0Pe, 0Era)
-347: [P] Ambulance utilization (0Pe, 0Era)
+
339: [P] Hypotension (1Pe, 3Era)
+340: [P] Hives, Erythema, Eruption, Urticaria (1Pe, 7Era)
+341: [P] Loss of mentation including coma, loss of consciousness, altered consciousness (1Pe, 3Era)
+342: [P] Urinary Incontinence (1Pe, 3Era)
+343: [P] Fecal Incontinence (1Pe, 3Era)
+344: [P] Doctors office or clinic visit without other overlapping visits (0Pe, 0Era)
+345: [P] Doctors office or clinic visit (0Pe, 0Era)
+346: [P] Non urgent outpatient visit without overlapping inpatient or emergency visit (0Pe, 0Era)
+347: [P] Ambulance utilization (0Pe, 0Era)

Accepted Cohorts: The following cohorts were added

-
119: Systemic lupus erythematosus indexed on signs, symptoms, treatment or diagnosis (FP)
-296: Transverse myelitis or symptoms indexed on symptoms or diagnosis (180Pe, 180Era)
+
119: Systemic lupus erythematosus indexed on signs, symptoms, treatment or diagnosis (FP)
+296: Transverse myelitis or symptoms indexed on symptoms or diagnosis (180Pe, 180Era)

New Cohorts: 17 were added.

-
142: [P] Earliest event of ST elevated myocardial infarction (7P, 1E)
-192: [P] Skin or mucosal bleeding events (1Pe, 7Era)
-298: [P] Urinary bleed events in persons without renal glomerular disease (30Pe, 7Era)
-299: [P] Acute gastrointestinal bleeding events (7Pe, 30Era)
-300: [P] Heavy menstrual bleeding (menorrhagia) events (60Pe, 180Era)
-318: [P] All events of Acute Hepatic Failure in persons without chronic hepatic failure (90Pe, 365Era)
-324: [P] Pain (3Pe, 7Era)
-325: [P] Inpatient Hospitalization By Site of care or type of service (0Pe, 1Era)
-327: [P] Pharyngitis (3Pe, 7Era)
-328: [P] Wheezing (3Pe, 30Era)
-329: [P] Pneumonitis and lung infections (14Pe, 30Era)
-330: [P] Abdominal Bloating (1Pe, 7Era)
-331: [P] Encephalopathy (1Pe, 14Era)
-332: [P] Pain or ache that is Chronic (3Pe, 180Era)
-333: [P] Alcohol Use Disorder (365Pe, 365Era)
-334: [P] Asthma (FP)
-335: [P] Anxiety or Fear (3Pe, 30Era)
+
142: [P] Earliest event of ST elevated myocardial infarction (7P, 1E)
+192: [P] Skin or mucosal bleeding events (1Pe, 7Era)
+298: [P] Urinary bleed events in persons without renal glomerular disease (30Pe, 7Era)
+299: [P] Acute gastrointestinal bleeding events (7Pe, 30Era)
+300: [P] Heavy menstrual bleeding (menorrhagia) events (60Pe, 180Era)
+318: [P] All events of Acute Hepatic Failure in persons without chronic hepatic failure (90Pe, 365Era)
+324: [P] Pain (3Pe, 7Era)
+325: [P] Inpatient Hospitalization By Site of care or type of service (0Pe, 1Era)
+327: [P] Pharyngitis (3Pe, 7Era)
+328: [P] Wheezing (3Pe, 30Era)
+329: [P] Pneumonitis and lung infections (14Pe, 30Era)
+330: [P] Abdominal Bloating (1Pe, 7Era)
+331: [P] Encephalopathy (1Pe, 14Era)
+332: [P] Pain or ache that is Chronic (3Pe, 180Era)
+333: [P] Alcohol Use Disorder (365Pe, 365Era)
+334: [P] Asthma (FP)
+335: [P] Anxiety or Fear (3Pe, 30Era)

Deprecated Cohorts: No new cohorts were added in this release.

New Cohorts: 19 were added.

-
134: [P] Persons with Attention Deficit Hyperactivity Disorder (FP)
-278: [P] Pain that is Non Chronic, Non Generalized (3Pe, 7Era)
-279: [P] Low Back Pain (30Pe, 180Era)
-280: [P] Abdominal Pain (3Pe, 7Era)
-281: [P] Epigastric Pain (3Pe, 7Era)
-282: [P] Joint Pain (3Pe, 30Era)
-283: [P] Prostatitis (180Pe, 365Era)
-284: [P] Myocarditis or Pericarditis (30Pe, 90Era)
-285: [P] Myocarditis or Pericarditis Not due to infections (30Pe, 90Era)
-287: [P] Transverse myelitis includes Myelitis Unspecified and neuromyelitis optica (90Pe, 365Era)
-288: [P] Type 2 Diabetes Mellitus indexed on diagnosis, treatment or lab results (FP)
-289: [P] Presence Of Cardiac Arrhythmia (3Pe, 60Era)
-290: [P] Thyroiditis indexed on diagnosis or treatment without (FP)
-291: [P] Gynecomastia, indexed on diagnosis, procedure or symptoms (FP)
-292: [P] Hepatic Failure (365Pe, 365Era)
-293: [P] Acute Hepatic Injury with no chronic hepatic failure (180Pe, 180Era)
-294: [P] Acute Hepatic Injury with no pre-existing liver disease (180Pe, 180Era)
-295: [P] Acute Hepatic Failure in persons with no pre-existing liver disease (365Pe, 365Era)
-296: Transverse myelitis or symptoms indexed on symptoms or diagnosis (180Pe, 180Era)
+
134: [P] Persons with Attention Deficit Hyperactivity Disorder (FP)
+278: [P] Pain that is Non Chronic, Non Generalized (3Pe, 7Era)
+279: [P] Low Back Pain (30Pe, 180Era)
+280: [P] Abdominal Pain (3Pe, 7Era)
+281: [P] Epigastric Pain (3Pe, 7Era)
+282: [P] Joint Pain (3Pe, 30Era)
+283: [P] Prostatitis (180Pe, 365Era)
+284: [P] Myocarditis or Pericarditis (30Pe, 90Era)
+285: [P] Myocarditis or Pericarditis Not due to infections (30Pe, 90Era)
+287: [P] Transverse myelitis includes Myelitis Unspecified and neuromyelitis optica (90Pe, 365Era)
+288: [P] Type 2 Diabetes Mellitus indexed on diagnosis, treatment or lab results (FP)
+289: [P] Presence Of Cardiac Arrhythmia (3Pe, 60Era)
+290: [P] Thyroiditis indexed on diagnosis or treatment without (FP)
+291: [P] Gynecomastia, indexed on diagnosis, procedure or symptoms (FP)
+292: [P] Hepatic Failure (365Pe, 365Era)
+293: [P] Acute Hepatic Injury with no chronic hepatic failure (180Pe, 180Era)
+294: [P] Acute Hepatic Injury with no pre-existing liver disease (180Pe, 180Era)
+295: [P] Acute Hepatic Failure in persons with no pre-existing liver disease (365Pe, 365Era)
+296: Transverse myelitis or symptoms indexed on symptoms or diagnosis (180Pe, 180Era)

Deprecated Cohorts: No new cohorts were added in this release.

Accepted Cohorts: The following cohorts were added

-
269: Acute Kidney Injury AKI (7Pe, 30W)
+
269: Acute Kidney Injury AKI (7Pe, 30W)

Discussed https://forums.ohdsi.org/t/phenotype-phebruary-day-29-acute-kidney-injury/16067 and peer reviewed by Azza Shoaibi and accepted after modifications. See recording dated August 12th 2022

New Cohorts: 2 were added.

-
276: [P] Sudden Vision Loss (1Pe, 0Era, 365W)
-277: [P] Sudden Hearing Loss (1Pe, 0Era, 365W)
+
276: [P] Sudden Vision Loss (1Pe, 0Era, 365W)
+277: [P] Sudden Hearing Loss (1Pe, 0Era, 365W)

Deprecated Cohorts: No new cohorts were added in this release.

Accepted Cohorts: The following cohorts were added

-
63: Transverse myelitis or symptoms (1Ps, 0Era, 365W)
+
63: Transverse myelitis or symptoms (1Ps, 0Era, 365W)

Deprecated Cohorts: No new cohorts were added in this release.

Modified Cohorts: several symptom and sign based cohorts were updated to support discussion https://forums.ohdsi.org/t/phenotype-submission-symptoms-and-signs/17895

New Cohorts: 2 were added.

-
270: [P] Hemolytic Anemia (7Pe, 0Era, 365W)
-271: [P] Hemolytic Anemia Intra corpuscular (FP)
+
270: [P] Hemolytic Anemia (7Pe, 0Era, 365W)
+271: [P] Hemolytic Anemia Intra corpuscular (FP)

Deprecated Cohorts: No new cohorts were added in this release.

Modified Cohorts: 0 were modified.

New Cohorts: 11 were added.

-
258: [P] Anaphylaxis or Anaphylactic shock events (1Pe, 0Era, 30W)
-259: [P] Anaphylaxis all cause (1Pe, 0Era, 30W)
-260: [P] ST elevated myocardial infarction with inpatient admission (7Pe, 180Era)
-261: [P] Non ST elevated myocardial infarction with inpatient admission (7Pe, 180Era)
-262: [P] Unstable Angina with inpatient admission (7Pe, 180Era)
-263: [P] Unstable Angina OR NSTEMI with inpatient admission (7Pe, 180Era)
-264: [P] Acute Hepatic Failure in persons with liver disease (90Pe, 180W)
-265: [P] Drug Induced Acute Hepatic Failure (90Pe, 180W)
-267: [P] Acute Kidney Injury AKI, in persons with chronic kidney disease (7Pe, 30W)
-268: [P] Acute Kidney Injury AKI, in persons with NO chronic kidney disease (7Pe, 30W)
-269: [P] Acute Kidney Injury (AKI) (7Pe, 30W)
+
258: [P] Anaphylaxis or Anaphylactic shock events (1Pe, 0Era, 30W)
+259: [P] Anaphylaxis all cause (1Pe, 0Era, 30W)
+260: [P] ST elevated myocardial infarction with inpatient admission (7Pe, 180Era)
+261: [P] Non ST elevated myocardial infarction with inpatient admission (7Pe, 180Era)
+262: [P] Unstable Angina with inpatient admission (7Pe, 180Era)
+263: [P] Unstable Angina OR NSTEMI with inpatient admission (7Pe, 180Era)
+264: [P] Acute Hepatic Failure in persons with liver disease (90Pe, 180W)
+265: [P] Drug Induced Acute Hepatic Failure (90Pe, 180W)
+267: [P] Acute Kidney Injury AKI, in persons with chronic kidney disease (7Pe, 30W)
+268: [P] Acute Kidney Injury AKI, in persons with NO chronic kidney disease (7Pe, 30W)
+269: [P] Acute Kidney Injury (AKI) (7Pe, 30W)

Deprecated Cohorts: No new cohorts were added in this release.

Modified Cohorts: 3 were modified.

-
71: [P] Acute myocardial infarction with inpatient admission (7Pe, 180Era)
-221: [P] Anaphylaxis Non Environmental exposure related (1Pe, 0Era, 30W)
-234: [P] Appendicitis (1Pe, 0Era, 365W)
+
71: [P] Acute myocardial infarction with inpatient admission (7Pe, 180Era)
+221: [P] Anaphylaxis Non Environmental exposure related (1Pe, 0Era, 30W)
+234: [P] Appendicitis (1Pe, 0Era, 365W)

Accepted Cohort: 3 cohorts were accepted. cohortId 23, 24 and 25 were considered accepted to the OHDSI Phenotype Library. This cohort is deemed validated as it represents a convention and thus do not need to go through peer review process.

-
23: Inpatient Hospitalization (1Pe, 0Era)
-24: Emergency room visits (0Pe, 0Era)
-25: All cause mortality
+
23: Inpatient Hospitalization (1Pe, 0Era)
+24: Emergency room visits (0Pe, 0Era)
+25: All cause mortality

New Cohorts: 8 were added.

-
100: [P] Alzheimer's disease
-119: [P] Systemic lupus erythematosus (FP)
-251: [P] Acute pancreatitis (7Pe, 0Era, 365W)
-253: [P] Drug Induced Acute pancreatitis (7Pe, 365W)
-254: [P] Drug Resistant Epilepsy
-255: [P] Alzheimer's disease (based on Imfeld, 2013)
-256: [P] Facial Palsy lower motor neuron including Bells Palsy (180Pe, 0Era, 183W)
-257: [P] Emergency room visits or code (0Pe, 0Era)
+
100: [P] Alzheimer's disease
+119: [P] Systemic lupus erythematosus (FP)
+251: [P] Acute pancreatitis (7Pe, 0Era, 365W)
+253: [P] Drug Induced Acute pancreatitis (7Pe, 365W)
+254: [P] Drug Resistant Epilepsy
+255: [P] Alzheimer's disease (based on Imfeld, 2013)
+256: [P] Facial Palsy lower motor neuron including Bells Palsy (180Pe, 0Era, 183W)
+257: [P] Emergency room visits or code (0Pe, 0Era)

Deprecated Cohorts: No cohorts were added in this release.

Modified Cohorts: 136 were modified. Several cohorts were changed from [P] to [W] i.e. were withdrawn from peer review consideration. Some of the cohorts in [P] pending peer review status were modified by the contributor. The changes includes cohort name changes and cohort specification changes. No accepted cohorts were modified.

-
2: [W] COVID-19 diagnosis or SARS-CoV-2 test (1pos) (3Ps, 7Era)
-3: [P] Cough (3Ps, 30Era)
-4: [P] Diarrhea (7Ps, 30Era)
-5: [P] Dyspnea (14Pe, 30Era)
-6: [P] Fever (3Pe, 30Era)
-7: [P] Headache, Migraine or related Neurologic pain (7Pe, 30Era)
-8: [P] Anosmia OR Hyposmia OR Dysgeusia (7Ps, 180Era)
-9: [P] Sore throat (7Pe, 30Era)
-10: [P] Nausea or Vomiting (3Pe, 30Era)
-11: [P] Malaise or fatigue (3P, 30Era)
-12: [P] Rhinitis or common cold (7P, 30Era)
-13: [P] Myalgia (not explained by injury, ischemia or systemic inflammation) (3Pe, 30Era)
-14: [P] Myalgia (3Pe, 30Era)
-15: [W] Exposure to Viral Disease (7Pe, 30Era)
-16: [W] Exposure to SARS-Cov 2 and coronavirus (7Pe, 30Era)
-17: [W] Exposure to SARS-Cov 2 (7Pe, 30Era)
-18: [P] Multiple Inflammatory Syndrome (30Pe, 30Era)
-19: [P] Acute Typical Pneumonia (14Pe, 30Era)
-20: [P] Bronchitis (14Pe, 90Era)
-21: [P] Acute respiratory distress syndrome (ARDS) or Acute Respiratory Failure (3Pe, 30Era)
-22: [W] SARS-CoV-2 testing (1Ps, 0Era)
-26: [P] Asthma or Chronic obstructive pulmonary disease (COPD) (FP)
-27: [P] Asthma without COPD (FP)
-28: [P] Chronic obstructive pulmonary disease (COPD) without asthma (FP)
-29: [W] Autoimmune condition (FP)
-30: [P] Tuberculosis (FP)
-31: [P] Malignant neoplasm excluding non-melanoma skin cancer (FP)
-32: [P] Obesity (FP)
-33: [P] Dementia (FP)
-34: [P] Hypertensive disorder or hypertensive complications (FP)
-35: [W] Chronic kidney disease (FP)
-36: [P] Human immunodeficiency virus (not HIV2) infection (FP)
-37: [P] Hepatitis C (FP)
-38: [P] Heart disease (FP)
-39: [W] End stage renal disease (FP)
-40: [P] Diabetes Mellitus Type 2 (FP)
-41: [W] Chronic kidney disease broad (FP)
-42: [W] End stage renal disease broad (FP)
-43: [P] Respiratory or pulmonary tuberculosis (FP)
-44: [W] COVID-19 diagnosis (3Pe, 7Era)
-45: [W] COVID-19 diagnosis with SARS-Cov-2 test (-3d to 3d) (3Pe, 21Era)
-46: [W] COVID-19 diagnosis and SARS-CoV-2 test (1pos) within 3d (3Pe, 21Era)
-47: [W] COVID-19 diagnosis and SARS-CoV-2 test (1pos) (0neg) within 3d (3Pe, 21Era)
-48: [W] COVID-19 diagnosis and SARS-CoV-2 test (0pos upto 3d, 1neg within 3d) (3Pe, 7Era)
-51: [W] SARS-CoV-2 test positive result (0Ps, 0Era)
-52: [W] SARS-CoV-2 test negative result (0Ps, 0Era)
-53: [W] SARS-CoV-2 test positive or negative result - keep persons with positive (0Ps, 0Era)
-54: [P] Febrile seizure (1Pe, 0Era, 42W)
-55: [W] COVID-19 diagnosis or SARS-CoV-2 test (1pos) (3Ps, 21Era)
-56: [P] SARS-CoV-2 test (1pos) or COVID-19 diagnosis with (0 neg -3d to 3d) (3Ps, 21Era)
-57: [P] Bleeding (1Pe, 0Era, 30W)
-58: [W] SARS-CoV-2 test positive result (3Ps, 21Era)
-59: [W] COVID-19 diagnosis with no SARS-CoV-2 test (3Ps, 21Era)
-60: [W] SARS-CoV-2 test positive and negative result (0Ps, 0Era)
-61: [P] Bradycardia or heart block with inpatient admission (1Pe, 30Era)
-62: [P] Generalized Seizure (1Pe, 0Era, 42W)
-63: [P] Transverse myelitis or symptoms (1Ps, 0Era, 365W)
-64: [W] Flu-like symptoms fever, cough, malaise, fatigue, dyspnea, myalgia (3P, 30Era)
-65: [W] Acute pancreatitis with inpatient admission (3Pe, 30Era)
-66: [W] Acute renal failure with inpatient admission (3Pe, 30Era)
-67: [W] Hepatic failure with inpatient admission (3Pe, 30Era)
-68: [W] Heart failure with inpatient admission (3Pe, 30Era)
-69: [W] Angioedema with inpatient admission (7Ps, 30Era)
-70: [P] Stroke (ischemic or hemorrhagic) with inpatient admission (7Ps, 30Era)
-71: [P] Acute myocardial infarction with inpatient admission (7Ps, 180Era)
-72: [P] Influenza diagnosis or positive test result (7Pe, 90Era)
-73: [W] Pregnancy (270P, 0Era)
-74: [P] Hemorrhagic stroke (intracerebral bleeding) with inpatient admission (7Ps, 180Era)
-75: [P] Ischemic stroke with inpatient admission (7Ps, 180Era)
-76: [P] Transient ischemic attack with inpatient admission (7Ps, 30Era)
-77: [P] Gastrointestinal bleeding with inpatient admission (7Ps, 30Era)
-78: [P] Cardiac arrhythmia with inpatient admission (1Pe, 30Era)
-79: [P] Dialysis with inpatient admission (1Ps, 7Era)
-80: [P] Extracorporeal Membrane Oxygenation with inpatient admission (1Pe, 30Era)
-81: [P] Cesarean section (7Pe, 180Era)
-82: [P] Intensive services during hospitalization (1Ps, 30Era)
-84: [P] SARS-CoV-2 test (1pos) or COVID-19 diagnosis with (1pos or 0 neg 0d to 3d) (3Ps, 180Era)
-85: [P] SARS-CoV-2 test (1pos) or COVID-19 diagnosis with (1pos or 0 neg 0d to 3d) (3Ps, 21Era)
-86: [W] SARS-CoV-2 test positive or negative result (0Ps, 0Era)
-87: [W] SARS-CoV-2 test (1Ps, 0Era)
-95: [P] Delirium (FP)
-123: [W] First event of Suicide attempt, including injuries and poisonings with undetermined, 365 days
-189: [P] Right Upper Quadrant Pain (Pe1, 0Era, 14W)
-190: [P] Abdominal Distension (Pe1, 0Era, 14W)
-191: [P] Fatigue, Malaise, Lethargy, Anorexia (Pe1, 0Era, 14W)
-192: [P] Nausea or Vomiting (Pe1, 0Era, 7W)
-193: [P] Jaundice or Itching (Pe1, 0Era, 14W)
-194: [P] Encephalopathy or its presentations (Pe1, 0Era, 30W)
-195: [P] Urothelial bladder cancer (FP)
-197: [P] Coronary Artery Disease from vessel disease to ischemic injury (FP)
-205: [W] Acute pancreatitis (7Pe, 0Era, 365W)
-206: [W] Drug Induced Acute pancreatitis (7Pe, 365W)
-207: [P] Acquired Pure Red Cell Aplasia
-208: [P] Neutropenic Fever (3Pe, 30Era)
-209: [P] Hemolytic Anemia, Extra corpuscular Acquired - G6PD deficiency excluded (7Pe, 0Era, 365W)
-210: [P] Hemolytic Anemia, Extra corpuscular Acquired (7Pe, 0Era, 365W)
-211: [P] Pancytopenia, Acquired
-213: [P] Acquired Neutropenia or unspecified leukopenia (21Pe, 365Era)
-214: [P] Acquired Isolated Neutropenia or unspecified leukopenia (21Pe, 365Era)
-215: [P] Isolated Immune Thrombocytopenia (180Pe, 365Era)
-216: [P] Isolated Immune Thrombocytopenia in absence of common thrombocytopenia causes (180Pe, 365Era)
-217: [P] Thrombotic microangiopathy (TMA) or Microangiopathic hemolytic anemia (MAHA)
-218: [P] Rhabdomyolysis (3Pe, 0Era, 180W)
-219: [P] Sudden Cardiac arrest or cardiac death
-220: [P] Angioedema (3Pe, 0Era, 180W)
-221: [P] Anaphylaxis Non Environmental exposure related (1Pe, 0Era, 180W)
-222: [P] Stevens-Johnson syndrome, toxic epidermal necrolysis spectrum
-223: [P] Posterior reversible encephalopathy syndrome PRES (FP)
-224: [P] Long QT Syndrome or QT prolonged (Acquired)
-225: [P] Drug-induced Lupus (180Pe, 0Era, 365W)
-226: [P] Drug Rash with Eosinophilia and Systemic Symptoms DRESS (1Pe, 0Era, 365W)
-227: [P] Severe Cutaneous Adverse Reaction SCAR (SJS+TEN+DRESS+EM) (3Pe, 0Era, 365W)
-228: [P] Severe Cutaneous Adverse Reaction SCAR (SJS+TEN+DRESS) (3Pe, 0Era, 365W)
-229: [P] Progressive multifocal leukoencephalopathy
-230: [P] Autoimmune hepatitis (1Pe, 0Era, 365W)
-231: [P] Erythema multiforme (3Pe, 0Era, 365W)
-232: [P] Paresthesia (3Pe, 0Era, 365W)
-233: [P] Hemorrhagic stroke (1Pe, 0Era, 180W)
-234: [P] Appendicitis (1Pe, 0Era, 365W)
-235: [P] Guillain Barre syndrome (180Pe, FP)
-236: [P] Idiopathic Peripheral Neuropathy (1Pe, 0Era, 365W)
-237: [P] Kawasaki disease (1Pe, 0Era, 365W)
-238: [P] Optic Neuritis (7Pe, 0Era, 365W)
-239: [P] Narcolepsy events (1Pe, 0Era, 365W)
-240: [P] Muscle weakness or monoplegia (1Pe, 0Era, 365W)
-241: [P] Urticaria (1Pe, 0Era, 30W)
-243: [P] Tinnitus (1Pe, 0Era, 365W)
-244: [P] Dizziness (1Pe, 0Era, 180W)
-245: [P] Hepatic Thrombosis (90Pe, 0Era)
-246: [P] Portal vein thrombosis (90Pe, 0Era)
-247: [P] Deep Vein Thrombosis DVT (90Pe, 0Era)
-248: [P] Disseminated intravascular coagulation DIC (1Pe, 0Era, 365W)
-249: [P] Ischemic (Non-hemorrhagic) Stroke (1Pe, 0Era, 365W)
-
-
- -

New Cohorts: 43 were added. 205: [P] Acute pancreatitis (7Pe, 0Era, 365W) 206: [P] Drug Induced Acute pancreatitis (7Pe, 365W) 207: [P] Acquired Pure Red Cell Aplasia 208: [P] Neutropenic Fever (3Pe, 30Era) 209: [P] Hemolytic Anemia, Extra corpuscular Acquired - G6PD deficiency excluded (7Pe, 0Era, 365W) 210: [P] Hemolytic Anemia, Extra corpuscular Acquired (7Pe, 0Era, 365W) 211: [P] Pancytopenia, Acquired 213: [P] Acquired Neutropenia or unspecified leukopenia (21Pe, 365Era) 214: [P] Acquired Isolated Neutropenia or unspecified leukopenia (21Pe, 365Era) 215: [P] Isolated Immune Thrombocytopenia (180Pe, 365Era) 216: [P] Isolated Immune Thrombocytopenia in absence of common thrombocytopenia causes (180Pe, 365Era) 217: [P] Thrombotic microangiopathy or Microangiopathic hemolytic anemia 218: [P] Rhabdomyolysis (3Pe, 0Era, 180W) 219: [P] Sudden Cardiac arrest or cardiac death 220: [P] Angioedema (3Pe, 0Era, 180W) 221: [P] Anaphylaxis Non Environmental exposure related (1Pe, 0Era, 180W) 222: [P] Stevens-Johnson syndrome, toxic epidermal necrolysis spectrum 223: [P] Posterior reversible encephalopathy syndrome (PRES) 224: [P] Long QT Syndrome or QT prolonged (Acquired) 225: [P] Drug-induced Lupus (7Pe, 0Era, 365W) 226: [P] Drug Rash with Eosinophilia and Systemic Symptoms DRESS (1Pe, 0Era, 365W) 227: [P] Severe Cutaneous Adverse Reaction SCAR (SJS+TEN+DRESS+EM) (3Pe, 0Era, 365W) 228: [P] Severe Cutaneous Adverse Reaction SCAR (SJS+TEN+DRESS) (3Pe, 0Era, 365W) 229: [P] Progressive multifocal leukoencephalopathy 230: [P] Autoimmune hepatitis (1Pe, 0Era, 365W) 231: [P] Erythema multiforme (3Pe, 0Era, 365W) 232: [P] Paresthesia (3Pe, 0Era, 365W) 233: [P] Hemorrhagic stroke (1Pe, 0Era, 180W) 234: [P] Appendicitis (1Pe, 0Era, 365W) 235: [P] Guillain Barre syndrome (1Pe, 0Era, 365W) 236: [P] Idiopathic Peripheral Neuropathy (1Pe, 0Era, 365W) 237: [P] Kawasaki disease (1Pe, 0Era, 365W) 238: [P] Optic Neuritis (7Pe, 0Era, 365W) 239: [P] Narcolepsy events (1Pe, 0Era, 365W) 240: [P] Muscle weakness or monoplegia (1Pe, 0Era, 365W) 241: [P] Urticaria (1Pe, 0Era, 365W) 243: [P] Tinnitus (1Pe, 0Era, 365W) 244: [P] Dizziness (1Pe, 0Era, 365W) 245: [P] Hepatic Thrombosis (1Pe, 0Era, 365W) 246: [P] Portal vein thrombosis (1Pe, 0Era, 365W) 247: [P] Deep Vein Thrombosis DVT (1Pe, 0Era, 365W) 248: [P] Disseminated intravascular coagulation DIC (1Pe, 0Era, 365W) 249: [P] Ischemic (Non-hemorrhagic) Stroke (1Pe, 0Era, 365W) Deprecated Cohorts: No new cohorts were added in this release. Modified Cohorts: No cohorts were modified in this release.

-
-
- -

New Cohorts: No new cohorts were added in this release.

-

Modified Cohorts: 85 were modified. These are only name modifications. These cohorts have not undergone Peer review process. They are not considered accepted. However, because of grandfathered status (i.e. these cohorts existed in Phenotype Library prior to version 3.0, results for these cohorts are computed as part of PhenotypeLibraryDiagnostics study package - unless withdrawn). The Cohort JSON specifications were not changed.

-
2: [P] COVID-19 diagnosis or SARS-CoV-2 test (1pos) (3Ps, 7Era)
+
2: [W] COVID-19 diagnosis or SARS-CoV-2 test (1pos) (3Ps, 7Era)
 3: [P] Cough (3Ps, 30Era)
 4: [P] Diarrhea (7Ps, 30Era)
 5: [P] Dyspnea (14Pe, 30Era)
 6: [P] Fever (3Pe, 30Era)
-7: [P]Headache, Migraine, Neurologic pain (7Pe, 30Era)
+7: [P] Headache, Migraine or related Neurologic pain (7Pe, 30Era)
 8: [P] Anosmia OR Hyposmia OR Dysgeusia (7Ps, 180Era)
 9: [P] Sore throat (7Pe, 30Era)
 10: [P] Nausea or Vomiting (3Pe, 30Era)
 11: [P] Malaise or fatigue (3P, 30Era)
 12: [P] Rhinitis or common cold (7P, 30Era)
-13: [P] Myalgia (not including secondary causes) (3Pe, 30Era)
+13: [P] Myalgia (not explained by injury, ischemia or systemic inflammation) (3Pe, 30Era)
 14: [P] Myalgia (3Pe, 30Era)
-15: [P] Exposure to Viral Disease (7Pe, 30Era)
-16: [P] Exposure to SARS-Cov 2 and coronavirus (7Pe, 30Era)
-17: [P] Exposure to SARS-Cov 2 (7Pe, 30Era)
+15: [W] Exposure to Viral Disease (7Pe, 30Era)
+16: [W] Exposure to SARS-Cov 2 and coronavirus (7Pe, 30Era)
+17: [W] Exposure to SARS-Cov 2 (7Pe, 30Era)
 18: [P] Multiple Inflammatory Syndrome (30Pe, 30Era)
-19: [P] Pneumonia (14Pe, 30Era)
+19: [P] Acute Typical Pneumonia (14Pe, 30Era)
 20: [P] Bronchitis (14Pe, 90Era)
 21: [P] Acute respiratory distress syndrome (ARDS) or Acute Respiratory Failure (3Pe, 30Era)
-22: [P] SARS-CoV-2 testing (1Ps, 0Era)
-23: [P] Hospitalization (1Pe, 30Era)
-24: [P] Emergency room visits (0Pe, 0Era)
-25: [P] All cause mortality
-26: [P] Asthma or Chronic obstructive pulmonary disease (COPD) (FP)
-27: [P] Asthma without COPD (FP)
-28: [P] Chronic obstructive pulmonary disease (COPD) without asthma (FP)
-30: [P] Tuberculosis (FP)
-31: [P] Malignant neoplasm excluding non-melanoma skin cancer (FP)
-32: [P] Obesity (FP)
-33: [P] Dementia (FP)
-34: [P] Hypertension (FP)
-36: [P] Human immunodeficiency virus infection (FP)
-37: [P] Hepatitis C (FP)
-38: [P] Heart disease (FP)
+22: [W] SARS-CoV-2 testing (1Ps, 0Era)
+26: [P] Asthma or Chronic obstructive pulmonary disease (COPD) (FP)
+27: [P] Asthma without COPD (FP)
+28: [P] Chronic obstructive pulmonary disease (COPD) without asthma (FP)
+29: [W] Autoimmune condition (FP)
+30: [P] Tuberculosis (FP)
+31: [P] Malignant neoplasm excluding non-melanoma skin cancer (FP)
+32: [P] Obesity (FP)
+33: [P] Dementia (FP)
+34: [P] Hypertensive disorder or hypertensive complications (FP)
+35: [W] Chronic kidney disease (FP)
+36: [P] Human immunodeficiency virus (not HIV2) infection (FP)
+37: [P] Hepatitis C (FP)
+38: [P] Heart disease (FP)
+39: [W] End stage renal disease (FP)
 40: [P] Diabetes Mellitus Type 2 (FP)
-43: [P] Tuberculosis broad (FP)
-45: [P] COVID-19 diagnosis with SARS-Cov-2 test (-3d to 3d) (3Pe, 21Era)
-46: [P] COVID-19 diagnosis and SARS-CoV-2 test (1pos) within 3d (3Pe, 21Era)
-47: [P] COVID-19 diagnosis and SARS-CoV-2 test (1pos) (0neg) within 3d (3Pe, 21Era)
-48: [P] COVID-19 diagnosis and SARS-CoV-2 test (0pos upto 3d, 1neg within 3d) (3Pe, 7Era)
-51: [P] SARS-CoV-2 test positive result (0Ps, 0Era)
-52: [P] SARS-CoV-2 test negative result (0Ps, 0Era)
-53: [P] SARS-CoV-2 test positive or negative result - keep persons with positive (0Ps, 0Era)
-54: [P] Febrile seizure (1Ps, 0Era)
-55: [P] COVID-19 diagnosis or SARS-CoV-2 test (1pos) (3Ps, 21Era)
-56: [P] SARS-CoV-2 test (1pos) or COVID-19 diagnosis with (0 neg -3d to 3d) (3Ps, 21Era)
-57: [P] Bleeding (1Ps, 30Era)
-58: [P] SARS-CoV-2 test positive result (3Ps, 21Era)
-59: [P] COVID-19 diagnosis with no SARS-CoV-2 test (3Ps, 21Era)
-60: [P] SARS-CoV-2 test positive and negative result (0Ps, 0Era)
-61: [P] Bradycardia or heart block with inpatient admission (1Pe, 30Era)
-62: [P] Generalized Seizure (1Ps, 0Era)
-63: [P] Transverse myelitis (or symptoms with transverse myelitis) 365dWO (1Ps, 0Era)
-64: [P] Flu-like symptoms (3P, 30Era)
-65: [P] Acute pancreatitis with inpatient admission (3Pe, 30Era)
-66: [P] Acute renal failure with inpatient admission (3Pe, 30Era)
-67: [P] Hepatic failure with inpatient admission (3Pe, 30Era)
-68: [P] Heart failure with inpatient admission (3Pe, 30Era)
-69: [P] Angioedema with inpatient admission (7Ps, 30Era)
-70: [P] Stroke (ischemic or hemorrhagic) with inpatient admission (7Ps, 30Era)
-71: [P] Acute myocardial infarction with inpatient admission (7Ps, 180Era)
-72: [P] Influenza (narrow) (7Pe, 90Era)
-74: [P] Hemorrhagic stroke (intracerebral bleeding) with inpatient admission (7Ps, 180Era)
-75: [P] Ischemic stroke with inpatient admission (7Ps, 180Era)
-76: [P] Transient ischemic attack with inpatient admission (7Ps, 30Era)
-77: [P] Gastrointestinal bleeding with inpatient admission (7Ps, 30Era)
-78: [P] Cardiac arrhythmia with inpatient admission (1Pe, 30Era)
-79: [P] Dialysis with inpatient admission (1Ps, 7Era)
-80: [P] Extracorporeal Membrane Oxygenation with inpatient admission (1Ps, 30Era)
-81: [P] Cesarean section (7Pe, 180Era)
-82: [P] Intensive services during hospitalization (1Ps, 30Era)
-84: [P] SARS-CoV-2 test (1pos) or COVID-19 diagnosis with (1pos or 0 neg 0d to 3d) (3Ps, 180Era)
-85: [P] SARS-CoV-2 test (1pos) or COVID-19 diagnosis with (1pos or 0 neg 0d to 3d) (3Ps, 21Era)
-86: [P] SARS-CoV-2 test positive or negative result (0Ps, 0Era)
-87: [P] SARS-CoV-2 test (1Ps, 0Era)
-95: [P] Delirium (FP)
-189: [P] Right Upper Quadrant Pain (Pe1, 3Era)
-190: [P] Abdominal Distension (Pe1, 7Era)
-191: [P] Fatigue, Malaise, Lethargy, Anorexia (Pe1, 1Era)
-192: [P] Nausea or Vomiting (Pe1, 7Era)
-193: [P] Jaundice or Itching (Pe1, 7Era)
-194: [P] Encephalopathy or its presentations (Pe1, 7Era)
-195: [P] Urothelial bladder cancer (FP)
-197: [P] Coronary Artery Disease from vessel disease to ischemic injury (FP)
+41: [W] Chronic kidney disease broad (FP) +42: [W] End stage renal disease broad (FP) +43: [P] Respiratory or pulmonary tuberculosis (FP) +44: [W] COVID-19 diagnosis (3Pe, 7Era) +45: [W] COVID-19 diagnosis with SARS-Cov-2 test (-3d to 3d) (3Pe, 21Era) +46: [W] COVID-19 diagnosis and SARS-CoV-2 test (1pos) within 3d (3Pe, 21Era) +47: [W] COVID-19 diagnosis and SARS-CoV-2 test (1pos) (0neg) within 3d (3Pe, 21Era) +48: [W] COVID-19 diagnosis and SARS-CoV-2 test (0pos upto 3d, 1neg within 3d) (3Pe, 7Era) +51: [W] SARS-CoV-2 test positive result (0Ps, 0Era) +52: [W] SARS-CoV-2 test negative result (0Ps, 0Era) +53: [W] SARS-CoV-2 test positive or negative result - keep persons with positive (0Ps, 0Era) +54: [P] Febrile seizure (1Pe, 0Era, 42W) +55: [W] COVID-19 diagnosis or SARS-CoV-2 test (1pos) (3Ps, 21Era) +56: [P] SARS-CoV-2 test (1pos) or COVID-19 diagnosis with (0 neg -3d to 3d) (3Ps, 21Era) +57: [P] Bleeding (1Pe, 0Era, 30W) +58: [W] SARS-CoV-2 test positive result (3Ps, 21Era) +59: [W] COVID-19 diagnosis with no SARS-CoV-2 test (3Ps, 21Era) +60: [W] SARS-CoV-2 test positive and negative result (0Ps, 0Era) +61: [P] Bradycardia or heart block with inpatient admission (1Pe, 30Era) +62: [P] Generalized Seizure (1Pe, 0Era, 42W) +63: [P] Transverse myelitis or symptoms (1Ps, 0Era, 365W) +64: [W] Flu-like symptoms fever, cough, malaise, fatigue, dyspnea, myalgia (3P, 30Era) +65: [W] Acute pancreatitis with inpatient admission (3Pe, 30Era) +66: [W] Acute renal failure with inpatient admission (3Pe, 30Era) +67: [W] Hepatic failure with inpatient admission (3Pe, 30Era) +68: [W] Heart failure with inpatient admission (3Pe, 30Era) +69: [W] Angioedema with inpatient admission (7Ps, 30Era) +70: [P] Stroke (ischemic or hemorrhagic) with inpatient admission (7Ps, 30Era) +71: [P] Acute myocardial infarction with inpatient admission (7Ps, 180Era) +72: [P] Influenza diagnosis or positive test result (7Pe, 90Era) +73: [W] Pregnancy (270P, 0Era) +74: [P] Hemorrhagic stroke (intracerebral bleeding) with inpatient admission (7Ps, 180Era) +75: [P] Ischemic stroke with inpatient admission (7Ps, 180Era) +76: [P] Transient ischemic attack with inpatient admission (7Ps, 30Era) +77: [P] Gastrointestinal bleeding with inpatient admission (7Ps, 30Era) +78: [P] Cardiac arrhythmia with inpatient admission (1Pe, 30Era) +79: [P] Dialysis with inpatient admission (1Ps, 7Era) +80: [P] Extracorporeal Membrane Oxygenation with inpatient admission (1Pe, 30Era) +81: [P] Cesarean section (7Pe, 180Era) +82: [P] Intensive services during hospitalization (1Ps, 30Era) +84: [P] SARS-CoV-2 test (1pos) or COVID-19 diagnosis with (1pos or 0 neg 0d to 3d) (3Ps, 180Era) +85: [P] SARS-CoV-2 test (1pos) or COVID-19 diagnosis with (1pos or 0 neg 0d to 3d) (3Ps, 21Era) +86: [W] SARS-CoV-2 test positive or negative result (0Ps, 0Era) +87: [W] SARS-CoV-2 test (1Ps, 0Era) +95: [P] Delirium (FP) +123: [W] First event of Suicide attempt, including injuries and poisonings with undetermined, 365 days +189: [P] Right Upper Quadrant Pain (Pe1, 0Era, 14W) +190: [P] Abdominal Distension (Pe1, 0Era, 14W) +191: [P] Fatigue, Malaise, Lethargy, Anorexia (Pe1, 0Era, 14W) +192: [P] Nausea or Vomiting (Pe1, 0Era, 7W) +193: [P] Jaundice or Itching (Pe1, 0Era, 14W) +194: [P] Encephalopathy or its presentations (Pe1, 0Era, 30W) +195: [P] Urothelial bladder cancer (FP) +197: [P] Coronary Artery Disease from vessel disease to ischemic injury (FP) +205: [W] Acute pancreatitis (7Pe, 0Era, 365W) +206: [W] Drug Induced Acute pancreatitis (7Pe, 365W) +207: [P] Acquired Pure Red Cell Aplasia +208: [P] Neutropenic Fever (3Pe, 30Era) +209: [P] Hemolytic Anemia, Extra corpuscular Acquired - G6PD deficiency excluded (7Pe, 0Era, 365W) +210: [P] Hemolytic Anemia, Extra corpuscular Acquired (7Pe, 0Era, 365W) +211: [P] Pancytopenia, Acquired +213: [P] Acquired Neutropenia or unspecified leukopenia (21Pe, 365Era) +214: [P] Acquired Isolated Neutropenia or unspecified leukopenia (21Pe, 365Era) +215: [P] Isolated Immune Thrombocytopenia (180Pe, 365Era) +216: [P] Isolated Immune Thrombocytopenia in absence of common thrombocytopenia causes (180Pe, 365Era) +217: [P] Thrombotic microangiopathy (TMA) or Microangiopathic hemolytic anemia (MAHA) +218: [P] Rhabdomyolysis (3Pe, 0Era, 180W) +219: [P] Sudden Cardiac arrest or cardiac death +220: [P] Angioedema (3Pe, 0Era, 180W) +221: [P] Anaphylaxis Non Environmental exposure related (1Pe, 0Era, 180W) +222: [P] Stevens-Johnson syndrome, toxic epidermal necrolysis spectrum +223: [P] Posterior reversible encephalopathy syndrome PRES (FP) +224: [P] Long QT Syndrome or QT prolonged (Acquired) +225: [P] Drug-induced Lupus (180Pe, 0Era, 365W) +226: [P] Drug Rash with Eosinophilia and Systemic Symptoms DRESS (1Pe, 0Era, 365W) +227: [P] Severe Cutaneous Adverse Reaction SCAR (SJS+TEN+DRESS+EM) (3Pe, 0Era, 365W) +228: [P] Severe Cutaneous Adverse Reaction SCAR (SJS+TEN+DRESS) (3Pe, 0Era, 365W) +229: [P] Progressive multifocal leukoencephalopathy +230: [P] Autoimmune hepatitis (1Pe, 0Era, 365W) +231: [P] Erythema multiforme (3Pe, 0Era, 365W) +232: [P] Paresthesia (3Pe, 0Era, 365W) +233: [P] Hemorrhagic stroke (1Pe, 0Era, 180W) +234: [P] Appendicitis (1Pe, 0Era, 365W) +235: [P] Guillain Barre syndrome (180Pe, FP) +236: [P] Idiopathic Peripheral Neuropathy (1Pe, 0Era, 365W) +237: [P] Kawasaki disease (1Pe, 0Era, 365W) +238: [P] Optic Neuritis (7Pe, 0Era, 365W) +239: [P] Narcolepsy events (1Pe, 0Era, 365W) +240: [P] Muscle weakness or monoplegia (1Pe, 0Era, 365W) +241: [P] Urticaria (1Pe, 0Era, 30W) +243: [P] Tinnitus (1Pe, 0Era, 365W) +244: [P] Dizziness (1Pe, 0Era, 180W) +245: [P] Hepatic Thrombosis (90Pe, 0Era) +246: [P] Portal vein thrombosis (90Pe, 0Era) +247: [P] Deep Vein Thrombosis DVT (90Pe, 0Era) +248: [P] Disseminated intravascular coagulation DIC (1Pe, 0Era, 365W) +249: [P] Ischemic (Non-hemorrhagic) Stroke (1Pe, 0Era, 365W)
+
+
+ +

New Cohorts: 43 were added. 205: [P] Acute pancreatitis (7Pe, 0Era, 365W) 206: [P] Drug Induced Acute pancreatitis (7Pe, 365W) 207: [P] Acquired Pure Red Cell Aplasia 208: [P] Neutropenic Fever (3Pe, 30Era) 209: [P] Hemolytic Anemia, Extra corpuscular Acquired - G6PD deficiency excluded (7Pe, 0Era, 365W) 210: [P] Hemolytic Anemia, Extra corpuscular Acquired (7Pe, 0Era, 365W) 211: [P] Pancytopenia, Acquired 213: [P] Acquired Neutropenia or unspecified leukopenia (21Pe, 365Era) 214: [P] Acquired Isolated Neutropenia or unspecified leukopenia (21Pe, 365Era) 215: [P] Isolated Immune Thrombocytopenia (180Pe, 365Era) 216: [P] Isolated Immune Thrombocytopenia in absence of common thrombocytopenia causes (180Pe, 365Era) 217: [P] Thrombotic microangiopathy or Microangiopathic hemolytic anemia 218: [P] Rhabdomyolysis (3Pe, 0Era, 180W) 219: [P] Sudden Cardiac arrest or cardiac death 220: [P] Angioedema (3Pe, 0Era, 180W) 221: [P] Anaphylaxis Non Environmental exposure related (1Pe, 0Era, 180W) 222: [P] Stevens-Johnson syndrome, toxic epidermal necrolysis spectrum 223: [P] Posterior reversible encephalopathy syndrome (PRES) 224: [P] Long QT Syndrome or QT prolonged (Acquired) 225: [P] Drug-induced Lupus (7Pe, 0Era, 365W) 226: [P] Drug Rash with Eosinophilia and Systemic Symptoms DRESS (1Pe, 0Era, 365W) 227: [P] Severe Cutaneous Adverse Reaction SCAR (SJS+TEN+DRESS+EM) (3Pe, 0Era, 365W) 228: [P] Severe Cutaneous Adverse Reaction SCAR (SJS+TEN+DRESS) (3Pe, 0Era, 365W) 229: [P] Progressive multifocal leukoencephalopathy 230: [P] Autoimmune hepatitis (1Pe, 0Era, 365W) 231: [P] Erythema multiforme (3Pe, 0Era, 365W) 232: [P] Paresthesia (3Pe, 0Era, 365W) 233: [P] Hemorrhagic stroke (1Pe, 0Era, 180W) 234: [P] Appendicitis (1Pe, 0Era, 365W) 235: [P] Guillain Barre syndrome (1Pe, 0Era, 365W) 236: [P] Idiopathic Peripheral Neuropathy (1Pe, 0Era, 365W) 237: [P] Kawasaki disease (1Pe, 0Era, 365W) 238: [P] Optic Neuritis (7Pe, 0Era, 365W) 239: [P] Narcolepsy events (1Pe, 0Era, 365W) 240: [P] Muscle weakness or monoplegia (1Pe, 0Era, 365W) 241: [P] Urticaria (1Pe, 0Era, 365W) 243: [P] Tinnitus (1Pe, 0Era, 365W) 244: [P] Dizziness (1Pe, 0Era, 365W) 245: [P] Hepatic Thrombosis (1Pe, 0Era, 365W) 246: [P] Portal vein thrombosis (1Pe, 0Era, 365W) 247: [P] Deep Vein Thrombosis DVT (1Pe, 0Era, 365W) 248: [P] Disseminated intravascular coagulation DIC (1Pe, 0Era, 365W) 249: [P] Ischemic (Non-hemorrhagic) Stroke (1Pe, 0Era, 365W) Deprecated Cohorts: No new cohorts were added in this release. Modified Cohorts: No cohorts were modified in this release.

+
+
+ +

New Cohorts: No new cohorts were added in this release.

+

Modified Cohorts: 85 were modified. These are only name modifications. These cohorts have not undergone Peer review process. They are not considered accepted. However, because of grandfathered status (i.e. these cohorts existed in Phenotype Library prior to version 3.0, results for these cohorts are computed as part of PhenotypeLibraryDiagnostics study package - unless withdrawn). The Cohort JSON specifications were not changed.

+
2: [P] COVID-19 diagnosis or SARS-CoV-2 test (1pos) (3Ps, 7Era)
+3: [P] Cough (3Ps, 30Era)
+4: [P] Diarrhea (7Ps, 30Era)
+5: [P] Dyspnea (14Pe, 30Era)
+6: [P] Fever (3Pe, 30Era)
+7: [P]Headache, Migraine, Neurologic pain (7Pe, 30Era)
+8: [P] Anosmia OR Hyposmia OR Dysgeusia (7Ps, 180Era)
+9: [P] Sore throat (7Pe, 30Era)
+10: [P] Nausea or Vomiting (3Pe, 30Era)
+11: [P] Malaise or fatigue (3P, 30Era)
+12: [P] Rhinitis or common cold (7P, 30Era)
+13: [P] Myalgia (not including secondary causes) (3Pe, 30Era)
+14: [P] Myalgia (3Pe, 30Era)
+15: [P] Exposure to Viral Disease (7Pe, 30Era)
+16: [P] Exposure to SARS-Cov 2 and coronavirus (7Pe, 30Era)
+17: [P] Exposure to SARS-Cov 2 (7Pe, 30Era)
+18: [P] Multiple Inflammatory Syndrome (30Pe, 30Era)
+19: [P] Pneumonia (14Pe, 30Era)
+20: [P] Bronchitis (14Pe, 90Era)
+21: [P] Acute respiratory distress syndrome (ARDS) or Acute Respiratory Failure (3Pe, 30Era)
+22: [P] SARS-CoV-2 testing (1Ps, 0Era)
+23: [P] Hospitalization (1Pe, 30Era)
+24: [P] Emergency room visits (0Pe, 0Era)
+25: [P] All cause mortality
+26: [P] Asthma or Chronic obstructive pulmonary disease (COPD) (FP)
+27: [P] Asthma without COPD (FP)
+28: [P] Chronic obstructive pulmonary disease (COPD) without asthma (FP)
+30: [P] Tuberculosis (FP)
+31: [P] Malignant neoplasm excluding non-melanoma skin cancer (FP)
+32: [P] Obesity (FP)
+33: [P] Dementia (FP)
+34: [P] Hypertension (FP)
+36: [P] Human immunodeficiency virus infection (FP)
+37: [P] Hepatitis C (FP)
+38: [P] Heart disease (FP)
+40: [P] Diabetes Mellitus Type 2 (FP)
+43: [P] Tuberculosis broad (FP)
+45: [P] COVID-19 diagnosis with SARS-Cov-2 test (-3d to 3d) (3Pe, 21Era)
+46: [P] COVID-19 diagnosis and SARS-CoV-2 test (1pos) within 3d (3Pe, 21Era)
+47: [P] COVID-19 diagnosis and SARS-CoV-2 test (1pos) (0neg) within 3d (3Pe, 21Era)
+48: [P] COVID-19 diagnosis and SARS-CoV-2 test (0pos upto 3d, 1neg within 3d) (3Pe, 7Era)
+51: [P] SARS-CoV-2 test positive result (0Ps, 0Era)
+52: [P] SARS-CoV-2 test negative result (0Ps, 0Era)
+53: [P] SARS-CoV-2 test positive or negative result - keep persons with positive (0Ps, 0Era)
+54: [P] Febrile seizure (1Ps, 0Era)
+55: [P] COVID-19 diagnosis or SARS-CoV-2 test (1pos) (3Ps, 21Era)
+56: [P] SARS-CoV-2 test (1pos) or COVID-19 diagnosis with (0 neg -3d to 3d) (3Ps, 21Era)
+57: [P] Bleeding (1Ps, 30Era)
+58: [P] SARS-CoV-2 test positive result (3Ps, 21Era)
+59: [P] COVID-19 diagnosis with no SARS-CoV-2 test (3Ps, 21Era)
+60: [P] SARS-CoV-2 test positive and negative result (0Ps, 0Era)
+61: [P] Bradycardia or heart block with inpatient admission (1Pe, 30Era)
+62: [P] Generalized Seizure (1Ps, 0Era)
+63: [P] Transverse myelitis (or symptoms with transverse myelitis) 365dWO (1Ps, 0Era)
+64: [P] Flu-like symptoms (3P, 30Era)
+65: [P] Acute pancreatitis with inpatient admission (3Pe, 30Era)
+66: [P] Acute renal failure with inpatient admission (3Pe, 30Era)
+67: [P] Hepatic failure with inpatient admission (3Pe, 30Era)
+68: [P] Heart failure with inpatient admission (3Pe, 30Era)
+69: [P] Angioedema with inpatient admission (7Ps, 30Era)
+70: [P] Stroke (ischemic or hemorrhagic) with inpatient admission (7Ps, 30Era)
+71: [P] Acute myocardial infarction with inpatient admission (7Ps, 180Era)
+72: [P] Influenza (narrow) (7Pe, 90Era)
+74: [P] Hemorrhagic stroke (intracerebral bleeding) with inpatient admission (7Ps, 180Era)
+75: [P] Ischemic stroke with inpatient admission (7Ps, 180Era)
+76: [P] Transient ischemic attack with inpatient admission (7Ps, 30Era)
+77: [P] Gastrointestinal bleeding with inpatient admission (7Ps, 30Era)
+78: [P] Cardiac arrhythmia with inpatient admission (1Pe, 30Era)
+79: [P] Dialysis with inpatient admission (1Ps, 7Era)
+80: [P] Extracorporeal Membrane Oxygenation with inpatient admission (1Ps, 30Era)
+81: [P] Cesarean section (7Pe, 180Era)
+82: [P] Intensive services during hospitalization (1Ps, 30Era)
+84: [P] SARS-CoV-2 test (1pos) or COVID-19 diagnosis with (1pos or 0 neg 0d to 3d) (3Ps, 180Era)
+85: [P] SARS-CoV-2 test (1pos) or COVID-19 diagnosis with (1pos or 0 neg 0d to 3d) (3Ps, 21Era)
+86: [P] SARS-CoV-2 test positive or negative result (0Ps, 0Era)
+87: [P] SARS-CoV-2 test (1Ps, 0Era)
+95: [P] Delirium (FP)
+189: [P] Right Upper Quadrant Pain (Pe1, 3Era)
+190: [P] Abdominal Distension (Pe1, 7Era)
+191: [P] Fatigue, Malaise, Lethargy, Anorexia (Pe1, 1Era)
+192: [P] Nausea or Vomiting (Pe1, 7Era)
+193: [P] Jaundice or Itching (Pe1, 7Era)
+194: [P] Encephalopathy or its presentations (Pe1, 7Era)
+195: [P] Urothelial bladder cancer (FP)
+197: [P] Coronary Artery Disease from vessel disease to ischemic injury (FP)

Withdrawn Cohorts: 13 were withdrawn prior to peer review. These cohorts have not undergone Peer review process. They are not considered accepted. It has been withdrawn prior to peer review. The Cohort JSON specifications were not changed. 29: [W] Autoimmune condition (FP) 35: [W] Chronic kidney disease (FP) 39: [W] End stage renal disease (FP) 41: [W] Chronic kidney disease broad (FP) 42: [W] End stage renal disease broad (FP) 44: [W] COVID-19 diagnosis (3Pe, 7Era) 73: [W] Pregnancy (270P, 0Era) 123: [W] First event of Suicide attempt, including injuries and poisonings with undetermined, 365 days 196: [W] Rheumatoid arthritis (FP) 198: [W] Crohns disease (FP) 199: [W] Major Depressive Disorder (FP) 200: [W] Plaque psoriasis (FP) 201: [W] Ulcerative colitis (FP)

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index cc5c2791..ef7a83fc 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -15,5 +15,5 @@ articles: ReservedWordsWithSpecialMeaningToPhenotypers: ReservedWordsWithSpecialMeaningToPhenotypers.html SubmittedCohortDefinitions: SubmittedCohortDefinitions.html ValidityChecksForCohortDefinitions: ValidityChecksForCohortDefinitions.html -last_built: 2023-10-09T17:51Z +last_built: 2023-10-09T19:47Z diff --git a/docs/reference/PhenotypeLibrary-package.html b/docs/reference/PhenotypeLibrary-package.html index d2c1ebea..43a5bfdd 100644 --- a/docs/reference/PhenotypeLibrary-package.html +++ b/docs/reference/PhenotypeLibrary-package.html @@ -17,7 +17,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0
diff --git a/docs/reference/getPhenotypeLog.html b/docs/reference/getPhenotypeLog.html index 1073bb85..5a3c8161 100644 --- a/docs/reference/getPhenotypeLog.html +++ b/docs/reference/getPhenotypeLog.html @@ -17,7 +17,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/reference/getPlCohortDefinitionSet.html b/docs/reference/getPlCohortDefinitionSet.html index 787e9c14..f30f29c7 100644 --- a/docs/reference/getPlCohortDefinitionSet.html +++ b/docs/reference/getPlCohortDefinitionSet.html @@ -17,7 +17,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/reference/getPlConceptDefinitionSet.html b/docs/reference/getPlConceptDefinitionSet.html index 20be8d29..0d500038 100644 --- a/docs/reference/getPlConceptDefinitionSet.html +++ b/docs/reference/getPlConceptDefinitionSet.html @@ -17,7 +17,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/reference/index.html b/docs/reference/index.html index a5e4f8ee..58a5fdd9 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -17,7 +17,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 diff --git a/docs/reference/listPhenotypes.html b/docs/reference/listPhenotypes.html index 54b06753..7fc2ed2a 100644 --- a/docs/reference/listPhenotypes.html +++ b/docs/reference/listPhenotypes.html @@ -17,7 +17,7 @@ PhenotypeLibrary - 3.27.0 + 3.28.0 @@ -117,7 +117,7 @@

Value

Examples

listPhenotypes()
 #> Warning: listPhenotypes is deprecated. use getPhenotypeLog
-#> # A tibble: 540 x 81
+#> # A tibble: 558 x 81
 #>    cohortId cohortName        cohortNameAtlas cohortNameFormatted cohortNameLong
 #>       <dbl> <chr>             <chr>           <chr>               <chr>         
 #>  1        3 Cough or Sputum   [P] Cough or S~ Cough or Sputum     Cough or Sput~
@@ -130,7 +130,7 @@ 

Examples

#> 8 10 Nausea or Vomiti~ [P] Nausea or ~ Nausea or Vomiting Nausea or Vom~ #> 9 11 Malaise and or f~ [P] Malaise an~ Malaise and or fat~ Malaise and o~ #> 10 12 Rhinitis or comm~ [P] Rhinitis o~ Rhinitis or common~ Rhinitis or c~ -#> # i 530 more rows +#> # i 548 more rows #> # i 76 more variables: librarian <chr>, status <chr>, addedVersion <chr>, #> # logicDescription <chr>, hashTag <chr>, isCirceJson <dbl>, #> # contributors <chr>, contributorOrcIds <chr>, diff --git a/extras/PhenotypeLibrary.pdf b/extras/PhenotypeLibrary.pdf index fe1e2086..ab0a2159 100644 Binary files a/extras/PhenotypeLibrary.pdf and b/extras/PhenotypeLibrary.pdf differ diff --git a/inst/Cohorts.csv b/inst/Cohorts.csv index f48c8cda..498cbfd4 100644 --- a/inst/Cohorts.csv +++ b/inst/Cohorts.csv @@ -588,7 +588,7 @@ 759,"[P] Concomitant TNF - alpha Inhibitors and IL12_23 Inhibitors - GE 30D overlap","Concomitant TNF - alpha Inhibitors and IL12 23 Inhibitors - GE 30D overlap","Concomitant TNF - alpha Inhibitors and IL23 Inhibitors - GE 30D overlap","rao@ohdsi.org","Pending peer review","","Concomitant TNF - alpha Inhibitors and IL23 Inhibitors - GE 30D overlap","#epi1073",1,"'Joel Swerdel','Eva-maria Didden'","'0000-0001-9491-2737','0000-0001-7401-8877'","'OHDSI'","","","255848, 4318404","","2023-09-16","2023-09-20",,"",,0,,,"ERA",0,"end of continuous observation",,,0,"First",FALSE,"All","First",2,1,"DrugEra",0,0,3,1,0,0,0,0,0,,,0,,,,,,,,,,,,,,,,,,,1,,,,,,,,, 760,"[P] Concomitant IL 23 Inhibitors and IL12_23 Inhibitors - GE 30D overlap","Concomitant IL 23 Inhibitors and IL12 23 Inhibitors - GE 30D overlap","Concomitant IL 23 Inhibitors and IL12_23 Inhibitors - GE 30D overlap","rao@ohdsi.org","Pending peer review","","Concomitant IL 23 Inhibitors and IL12_23 Inhibitors - GE 30D overlap","#epi1073",1,"'Joel Swerdel','Eva-maria Didden'","'0000-0001-9491-2737','0000-0001-7401-8877'","'OHDSI'","","","256451, 260139","https://forums.ohdsi.org/t/17895","2023-09-16","2023-09-20",,"",,0,,,"ERA",0,"end of continuous observation",,,0,"First",FALSE,"All","First",2,1,"DrugEra",0,0,3,1,0,0,0,0,0,,,0,,,,,,,,,,,,,,,,,,,1,,,,,,,,, 761,"[P] Pulmonary arterial hypertension with Prior Left Heart or Vice Versa","Pulmonary arterial hypertension with Prior Left Heart or Vice Versa","Pulmonary arterial hypertension with Prior Left Heart or Vice Versa","rao@ohdsi.org","Pending peer review","","Index date of either PAH or left heart disease whichever comes last","#epi1073",1,"'Joel Swerdel','Eva-maria Didden'","'0000-0001-9491-2737','0000-0001-7401-8877'","","","","319049","","2023-09-16","2023-09-20",,"",,0,,,"ERA",0,"end of continuous observation",,,0,"First",FALSE,"All","All",2,1,"ConditionOccurrence",0,0,4,1,0,0,0,0,0,1,,0,,,,,,,,1,,,,,,,,,,,,,,,,,,,, -762,"[P] Endothelin receptor antagonists","Endothelin receptor antagonists","Endothelin receptor antagonists","rao@ohdsi.org","Pending peer review","","First exposure of Endothelin receptor antagonists","#epi1073",1,"'Joel Swerdel','Eva-maria Didden'","'0000-0001-9491-2737','0000-0001-7401-8877'","","","","","","2023-09-16","2023-09-20",,"",,0,,,"ERA",0,"end of continuous observation",,,0,"First",FALSE,"All","First",1,1,"ConditionOccurrence",0,0,1,0,0,0,0,0,0,1,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,, +762,"[P] Endothelin receptor antagonists","Endothelin receptor antagonists","Endothelin receptor antagonists","rao@ohdsi.org","Pending peer review","","First exposure of Endothelin receptor antagonists","#epi1073",1,"'Joel Swerdel','Eva-maria Didden'","'0000-0001-9491-2737','0000-0001-7401-8877'","","","","","","2023-09-16","2023-10-09",,"","joel reporte he made an error in cohort. used condition domain for drug",0,,,"ERA",0,"end of continuous observation",,,0,"First",FALSE,"All","First",1,1,"DrugExposure",0,0,1,0,0,0,0,0,0,,,0,,,,1,,,,,,,,,,,,,,,,,,,,,,,, 763,"[P] Phosphodiesterase 5 inhibitors and guanylate cyclase stimulators","Phosphodiesterase 5 inhibitors and guanylate cyclase stimulators","Phosphodiesterase 5 inhibitors and guanylate cyclase stimulators","rao@ohdsi.org","Pending peer review","","First exposure of Phosphodiesterase 5 inhibitors and guanylate cyclase stimulators","#epi1073",1,"'Joel Swerdel','Eva-maria Didden'","'0000-0001-9491-2737','0000-0001-7401-8877'","'OHDSI'","","","","","2023-09-16","2023-09-20",,"",,0,,,"ERA",0,"end of continuous observation",,,0,"First",FALSE,"All","First",1,1,"DrugExposure",0,0,1,0,0,0,0,0,0,,,0,,,,1,,,,,,,,,,,,,,,,,,,,,,,, 764,"[P] Prostacyclin analogues and prostacyclin receptor agonists","Prostacyclin analogues and prostacyclin receptor agonists","Prostacyclin analogues and prostacyclin receptor agonists","rao@ohdsi.org","Pending peer review","","First exposure of Prostacyclin analogues and prostacyclin receptor agonists","#epi1073",1,"'Joel Swerdel','Eva-maria Didden'","'0000-0001-9491-2737','0000-0001-7401-8877'","'OHDSI'","","","","","2023-09-16","2023-09-20",,"",,0,,,"ERA",0,"end of continuous observation",,,0,"First",FALSE,"All","First",1,1,"DrugExposure",0,0,1,0,0,0,0,0,0,,,0,,,,1,,,,,,,,,,,,,,,,,,,,,,,, 765,"[P] Earliest event of Left Heart Failure","Earliest event of Left Heart Failure","Left Heart Failure","rao@ohdsi.org","Pending peer review","","First occurrence of Left Heart Failure","#epi1073",1,"'Joel Swerdel','Eva-maria Didden'","'0000-0001-9491-2737','0000-0001-7401-8877'","'OHDSI'","","","","","2023-09-16","2023-09-20",,"",,0,,,"ERA",0,"end of continuous observation",,,0,"First",FALSE,"All","First",1,1,"ConditionOccurrence",0,0,1,0,0,0,0,0,0,1,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,, @@ -871,6 +871,22 @@ 1104,"[P] RBC Transfusion (adult relevant, no auto 1yr clean window)","RBC Transfusion (adult relevant, no auto 1yr clean window)","RBC Transfusion (adult relevant, no auto 1yr clean window)","rao@ohdsi.org","Pending peer review","","RBC transfusion with no prior transfusion","#Surgery, #WorkGroup",1,"Evan Minty","0000-0003-4631-9992","'OHDSI'","","","",,"2023-09-25","2023-09-25",,"",,0,,,"ERA",0,"end of continuous observation",,,1,"First",FALSE,"All","First",1,1,"ProcedureOccurrence",0,0,2,1,0,0,0,0,0,,,0,,,,,,,1,,,,,,,,,,,,,,,,,,,,, 1105,"[P] Clostridium difficile - first episode","Clostridium difficile - first episode","Clostridium difficile - first episode","rao@ohdsi.org","Pending peer review","","Clostridium difficile with no history of clostridium difficle","#Surgery, #WorkGroup",1,"Evan Minty","0000-0003-4631-9992","'OHDSI'","","","4307981",,"2023-09-25","2023-10-04",,"",,0,,,"ERA",0,"end of continuous observation",,,2,"First",FALSE,"All","First",2,2,"ConditionOccurrence, Measurement",0,0,2,1,0,0,0,0,0,1,1,0,,,,,,,,,,,,,,,,,,,,,,,,,,,, 1106,"[P] Non-Emergent Major Non Cardiac Surgery no prior Opioid","Non-Emergent Major Non Cardiac Surgery no prior Opioid","Non-Emergent Major Non Cardiac Surgery no prior Opioid","rao@ohdsi.org","Pending peer review","","Persons having any of major non cardiac surgery","#Surgery, #WorkGroup",1,"Evan Minty","0000-0003-4631-9992","'OHDSI'","","","","","2023-09-25","2023-10-05",,"",,0,,,"ERA",0,"end of continuous observation",,,3,"First",FALSE,"All","First",35,1,"ProcedureOccurrence",0,0,38,1,1,0,0,1,0,,,0,,,,,,,1,,1,,,,,,,,,,,,,,,,,,, +1117,"[P] Pulmonary fibrosis","Pulmonary fibrosis","Pulmonary fibrosis","rao@ohdsi.org","Pending peer review","","all events of Pulmonary Fibrosis. Persons exit on cohort end date","#Condition, #respiratory, #lung",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","4197819","","2023-09-28","2023-10-09",,"",,0,,,"ERA",0,"end of continuous observation",,,0,"First",FALSE,"All","First",1,1,"ConditionOccurrence",0,0,1,0,0,0,0,0,0,1,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1118,"[P] History of Bladder cancer","History of Bladder cancer","Bladder cancer including history","rao@ohdsi.org","Pending","","Earliest known occurrence of bladder cancer","",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","197508","","2023-09-28","2023-10-09",,"",,0,,,"ERA",0,"end of continuous observation",,,0,"First",FALSE,"All","All",1,1,"ConditionOccurrence",0,0,1,0,0,0,0,0,0,1,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1119,"[P] Chronic obstructive pulmonary disease (COPD)","Chronic obstructive pulmonary disease (COPD)","Chronic obstructive pulmonary disease (COPD)","rao@ohdsi.org","Pending peer review","","Earliest of COPD diagnosis","#respiratory, #lung",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","255573","","2023-09-28","2023-10-09",,"",,0,,,"ERA",0,"end of continuous observation",,,0,"First",FALSE,"All","First",1,1,"ConditionOccurrence",0,0,1,0,0,0,0,0,0,1,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1120,"[P] Chronic Interstitial lung disease (ILD)","Chronic Interstitial lung disease (ILD)","Chronic Interstitial lung disease (ILD) not including Acute Respiratory Distress Syndrome","rao@ohdsi.org","Pending peer review","","Events of Chronic Interstitial lung disease (ILD) not including Acute Respiratory Distress Syndrome","#respiratory, #lung",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","4119786","","2023-09-28","2023-10-09",,"",,0,,,"ERA",0,"fixed duration relative to initial event","EndDate",365,0,"All",FALSE,"All","All",1,1,"ConditionOccurrence",0,0,1,0,0,0,0,0,0,1,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1128,"[P] Lung Nodule","Lung Nodule","Lung Nodule","rao@ohdsi.org","Pending peer review","","Events of Lung Nodule","#respiratory, #lung",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","37206719","","2023-09-28","2023-10-09",,"",,0,,,"ERA",0,"fixed duration relative to initial event","EndDate",730,0,"All",FALSE,"All","All",1,1,"ConditionOccurrence",0,0,1,0,0,0,0,0,0,1,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1129,"[P] Lung Nodule - solitary","Lung Nodule - solitary","Lung Nodule - solitary","rao@ohdsi.org","Pending peer review","","Events of Lung Nodule - solitary","#respiratory, #lung",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","37206719,4142875","","2023-09-28","2023-10-09",,"",,0,,,"ERA",0,"fixed duration relative to initial event","EndDate",730,1,"All",FALSE,"All","All",1,1,"ConditionOccurrence",0,0,3,1,0,0,0,0,0,1,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1130,"[P] Lung Nodule - multiple","Lung Nodule - multiple","Lung Nodule - multiple","rao@ohdsi.org","Pending peer review","","Events of Lung Nodule - multiple","#respiratory, #lung",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","37206719,40482871","","2023-09-28","2023-10-09",,"",,0,,,"ERA",0,"fixed duration relative to initial event","EndDate",730,1,"All",FALSE,"All","All",1,1,"ConditionOccurrence",0,0,3,1,0,0,0,0,0,1,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1131,"[P] Lung Mass (not acute, necrotic, atlectatic, abscess, fibrosis)","Lung Mass (not acute, necrotic, atlectatic, abscess, fibrosis)","Lung Mass (not acute, necrotic, atlectatic, abscess, fibrosis)","rao@ohdsi.org","Pending peer review","","Events of Lung Mass (not acute, necrotic, atlectatic, abscess, fibrosis)","#respiratory, #lung",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","37206719","","2023-09-28","2023-10-09",,"",,0,,,"ERA",0,"fixed duration relative to initial event","EndDate",730,0,"All",FALSE,"All","All",1,1,"ConditionOccurrence",0,0,1,0,0,0,0,0,0,1,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1132,"[P] Lung Lesion (not acute, necrotic, atlectatic, abscess, fibrosis)","Lung Lesion (not acute, necrotic, atlectatic, abscess, fibrosis)","Lung Lesion that is not acute, necrotic, atlectatic, abscess, fibrosis","rao@ohdsi.org","Pending peer review","","Events of Lung Lesion that is not acute, necrotic, atlectatic, abscess, fibrosis","#respiratory, #lung",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","4116778,37206719","","2023-09-28","2023-10-09",,"",,0,,,"ERA",0,"fixed duration relative to initial event","EndDate",730,0,"All",FALSE,"All","All",1,1,"ConditionOccurrence",0,0,1,0,0,0,0,0,0,1,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1133,"[P] Non Small Cell Lung Cancer as lung cancer without small cell","Non Small Cell Lung Cancer as lung cancer without small cell","Non Small Cell Lung Cancer","rao@ohdsi.org","Pending peer review","","Events of Non Small Cell Lung Cancer defined as lung cancer without small cell","#respiratory, #lung",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","37206719","","2023-09-28","2023-10-09",,"",,0,,,"ERA",0,"fixed duration relative to initial event","EndDate",730,0,"All",FALSE,"All","All",1,1,"ConditionOccurrence",0,0,1,0,0,0,0,0,0,1,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1134,"[P] Lung Cancer (primary maliganancy)","Lung Cancer (primary maliganancy)","Non Small Cell Lung Cancer","rao@ohdsi.org","Pending peer review","","Events of Non Small Cell Lung Cancer defined as lung cancer without small cell","#respiratory, #lung",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","37206719","","2023-09-28","2023-10-09",,"",,0,,,"ERA",0,"fixed duration relative to initial event","EndDate",180,0,"All",FALSE,"All","All",1,1,"ConditionOccurrence",0,0,1,0,0,0,0,0,0,1,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1135,"[P] Small Cell Lung Cancer","Small Cell Lung Cancer","Small Cell Lung Cancer","rao@ohdsi.org","Pending peer review","","Events of Small Cell Lung Cancer","#respiratory, #lung",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","37206719","","2023-09-28","2023-10-09",,"",,0,,,"ERA",0,"fixed duration relative to initial event","EndDate",180,0,"All",FALSE,"All","All",1,1,"ConditionOccurrence",0,0,1,0,0,0,0,0,0,1,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1136,"[P] Non Small Cell Lung Cancer","Non Small Cell Lung Cancer","Non Small Cell Lung Cancer","rao@ohdsi.org","Pending peer review","","Events of Non Small Cell Lung Cancer defined as lung cancer without small cell","#respiratory, #lung",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","37206719,4115276","","2023-09-28","2023-10-09",,"",,0,,,"ERA",0,"fixed duration relative to initial event","EndDate",180,0,"All",FALSE,"All","All",1,1,"ConditionOccurrence",0,0,1,0,0,0,0,0,0,1,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1137,"[P] Hoarseness","Hoarseness","Hoarseness","rao@ohdsi.org","Pending peer review","","All events of Hoarseness","#Symptoms, #respiratory, #lung",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","312437, 4041664","https://forums.ohdsi.org/t/17895","2023-09-28","2023-10-09",,"",,0,,,"ERA",0,"fixed duration relative to initial event","EndDate",14,0,"All",FALSE,"All","All",1,1,"ConditionOccurrence",0,0,1,0,0,0,0,0,0,1,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1138,"[P] Bone Pain","Bone Pain","Bone Pain","rao@ohdsi.org","Pending peer review","","All events of Bone Pain","#Symptom",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","4129418","https://forums.ohdsi.org/t/17895","2023-09-28","2023-10-09",,"",,0,,,"ERA",0,"fixed duration relative to initial event","EndDate",14,0,"All",FALSE,"All","All",2,1,"ConditionOccurrence",0,0,3,1,0,0,0,0,0,1,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1139,"[P] Weight loss","Weight loss","Weight loss","rao@ohdsi.org","Pending peer review","","All events of Weight loss","#Symptoms",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","4177176,435928","https://forums.ohdsi.org/t/17895","2023-09-28","2023-10-09",,"",,0,,,"ERA",0,"fixed duration relative to initial event","EndDate",14,0,"All",FALSE,"All","All",1,1,"ConditionOccurrence",0,0,1,0,0,0,0,0,0,1,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,, 1150,"Emergency room only or Emergency room and inpatient visits (0Pe, 0Era)","Emergency room only or Emergency room and inpatient visits (0Pe, 0Era)","Emergency room visits (0Pe, 0Era)","rao@ohdsi.org","Accepted","3.4.0","All events of Emergency Room visits or Emergency room or inpatient visit. This cohort is deemed validated as it represents data convention and did not need to go thru peer review process","#standard, #Visits",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","","","2023-10-04","2023-10-04",,"",,0,,,"ERA",0,"fixed duration relative to initial event","EndDate",0,0,"All",FALSE,"All","All",1,1,"VisitOccurrence",0,0,1,0,0,0,0,0,0,,,1,,1,,,,,,,,,,,,,,,,,,,,,,,,,, 1151,"[P] Autism","Autism","Autism","rao@ohdsi.org","Pending peer review","","","#autism",1,"Gowtham A. Rao","'0000-0002-4949-7236'","'OHDSI'","","","439776","","2023-10-05","2023-10-05",,"",,0,,,"ERA",0,"end of continuous observation",,,0,"First",FALSE,"All","First",1,1,"ConditionOccurrence",0,0,1,0,0,0,0,0,0,1,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,, 1152,"[P] Deep Vein Thrombosis DVT 10","Deep Vein Thrombosis DVT 10","Deep Vein Thrombosis DVT","rao@ohdsi.org","Prediction","","All events of Deep Vein Thrombosis (DVT), indexed on a condition occurrence of Deep Vein Thrombosis (DVT). Requiring a clean window of 30 days, cohort exit is 1 day after start date.","#Prediction",1,"'Jenna Reps'","'0000-0002-2970-0778'","'Johnson and Johnson', 'OHDSI'","","","4133004",,"2023-10-09","2023-10-09",,"","Prediction phenotypes",0,,,"ERA",0,"fixed duration relative to initial event","StartDate",1,1,"All",FALSE,"All","All",1,1,"ConditionOccurrence",0,0,1,1,0,0,0,0,0,1,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,, @@ -937,3 +953,5 @@ 1213,"[P] Antibiotics Streptogramins 10","Antibiotics Streptogramins 10","Antibiotics Streptogramins","rao@ohdsi.org","Prediction","","any Antibiotics Streptogramins with 30 day persistence","#Prediction",1,"'Jenna Reps'","'0000-0002-2970-0778'","'Johnson and Johnson', 'OHDSI'","","","1789517",,"2023-10-09","2023-10-09",,"","Prediction phenotypes",0,,,"ERA",0,"end of continuous drug exposure",,,0,"All",FALSE,"All","All",1,1,"DrugExposure",0,0,1,0,0,0,0,0,0,,,1,,,,1,,,,,,,,,,,,,,,,,,3,30,0,,,, 1214,"[P] Antibiotics Tetracyclines 10","Antibiotics Tetracyclines 10","Antibiotics Tetracyclines","rao@ohdsi.org","Prediction","","any Antibiotics Tetracyclines with 30 day persistence","#Prediction",1,"'Jenna Reps'","'0000-0002-2970-0778'","'Johnson and Johnson', 'OHDSI'","","","1738521",,"2023-10-09","2023-10-09",,"","Prediction phenotypes",0,,,"ERA",0,"end of continuous drug exposure",,,0,"All",FALSE,"All","All",1,1,"DrugExposure",0,0,1,0,0,0,0,0,0,,,1,,,,1,,,,,,,,,,,,,,,,,,4,30,0,,,, 1215,"[P] Any cancer (excl. prostate cancer and benign cancer) 10","Any cancer (excl. prostate cancer and benign cancer) 10","Any cancer (excl. prostate cancer and benign cancer)","rao@ohdsi.org","Prediction","","First cancer (excluding prostate and benign) continues until end of observation","#Prediction",1,"'Jenna Reps'","'0000-0002-2970-0778'","'Johnson and Johnson', 'OHDSI'","","","438112",,"2023-10-09","2023-10-09",,"","Prediction phenotypes",0,,,"ERA",0,"end of continuous observation",,,0,"First",FALSE,"All","First",4,3,"ConditionOccurrence, Measurement, Observation",0,0,1,0,0,0,0,0,0,1,1,0,1,,,,,,,,,,,,,,,,,,,,,,,,,,,1 +1216,"[P] Primary Lung Cancer, 2nd dx 365 d after, excl SCLC signs all d before 1y after","Primary Lung Cancer, 2nd dx 365 d after, excl SCLC signs all d before 1y after","Non Small Cell Lung Cancer","rao@ohdsi.org","Pending peer review","","Events of primary lung cancer, second diagnosis within 365 days after, exclude small cell lung cancer","#respiratory, #lung",1,"'Dmytro Dymshyts', 'Gowtham A. Rao', 'Nathan Hall'","'','0000-0002-4949-7236'","'OHDSI'","","","37206719","","2023-10-09","2023-10-09",,"",,0,,,"ERA",0,"end of continuous observation",,,5,"All",FALSE,"All","First",1,1,"ConditionOccurrence",0,0,5,1,0,0,0,0,0,1,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,, +1217,"[P] Primary Lung Cancer, excl SCLC signs all d before 1y after","Primary Lung Cancer, excl SCLC signs all d before 1y after","Non Small Cell Lung Cancer","rao@ohdsi.org","Pending peer review","","Events of primary lung cancer, exclude small cell lung cancer","#respiratory, #lung",1,"'Dmytro Dymshyts', 'Gowtham A. Rao', 'Nathan Hall'","'','0000-0002-4949-7236'","'OHDSI'","","","37206719","","2023-10-09","2023-10-09",,"",,0,,,"ERA",0,"end of continuous observation",,,4,"First",FALSE,"All","First",1,1,"ConditionOccurrence",0,0,5,1,0,0,0,0,0,1,,0,,,,,,,,1,,,,,,,,,,,,,,,,,,,, diff --git a/inst/ConceptSetsInCohortDefinition.RDS b/inst/ConceptSetsInCohortDefinition.RDS index de9b4720..aa2205fd 100644 Binary files a/inst/ConceptSetsInCohortDefinition.RDS and b/inst/ConceptSetsInCohortDefinition.RDS differ diff --git a/inst/OrcidLog.csv b/inst/OrcidLog.csv index c972cdba..49107f2f 100644 --- a/inst/OrcidLog.csv +++ b/inst/OrcidLog.csv @@ -11,7 +11,7 @@ "0000-0002-0847-6682","Anna","Ostropolets","",24,0 "0000-0002-2970-0778","Jenna","Reps","",64,0 "0000-0002-4243-155X","Asieh","Golozar","",8,0 -"0000-0002-4949-7236","Gowtham","Rao","",530,14 +"0000-0002-4949-7236","Gowtham","Rao","",548,14 "0000-0002-6976-2594","Azza","Shoaibi","",67,0 "0000-0002-9612-5697","Brian","Toy","",1,0 "0000-0003-0755-5191","James","Weaver","",2,0 diff --git a/inst/cohorts/1117.json b/inst/cohorts/1117.json new file mode 100644 index 00000000..9a0590f4 --- /dev/null +++ b/inst/cohorts/1117.json @@ -0,0 +1,60 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 0, + "ConditionTypeExclude" : false + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "First" + } + }, + "ConceptSets" : [ + { + "id" : 0, + "name" : "Fibrosis of lung", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 4197819, + "CONCEPT_NAME" : "Fibrosis of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "51615001", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "First" + }, + "InclusionRules" : [], + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1118.json b/inst/cohorts/1118.json new file mode 100644 index 00000000..6060d9b0 --- /dev/null +++ b/inst/cohorts/1118.json @@ -0,0 +1,60 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 0, + "ConditionTypeExclude" : false + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "First" + } + }, + "ConceptSets" : [ + { + "id" : 0, + "name" : "Bladder cancer", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 197508, + "CONCEPT_NAME" : "Malignant tumor of urinary bladder", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "399326009", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "All" + }, + "InclusionRules" : [], + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1119.json b/inst/cohorts/1119.json new file mode 100644 index 00000000..59c8ccb5 --- /dev/null +++ b/inst/cohorts/1119.json @@ -0,0 +1,77 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 0, + "ConditionTypeExclude" : false + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "First" + } + }, + "ConceptSets" : [ + { + "id" : 0, + "name" : " Chronic obstructive lung disease", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 255573, + "CONCEPT_NAME" : "Chronic obstructive lung disease", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "13645005", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 258780, + "CONCEPT_NAME" : "Emphysematous bronchitis", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "185086009", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "First" + }, + "InclusionRules" : [], + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1120.json b/inst/cohorts/1120.json new file mode 100644 index 00000000..ee6031fa --- /dev/null +++ b/inst/cohorts/1120.json @@ -0,0 +1,134 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 0, + "ConditionTypeExclude" : false + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "All" + } + }, + "ConceptSets" : [ + { + "id" : 0, + "name" : " Interstitial lung disease (ILD) not including Acute Respiratory Distress Syndrome", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 4119786, + "CONCEPT_NAME" : "Interstitial lung disease", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "233703007", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4195694, + "CONCEPT_NAME" : "Acute respiratory distress syndrome", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "67782005", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 438791, + "CONCEPT_NAME" : "Pulmonary congestion and hypostasis", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "196115007", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 258180, + "CONCEPT_NAME" : "Pneumonia due to Gram negative bacteria", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "430395005", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4006969, + "CONCEPT_NAME" : "Acute respiratory disease", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "111273006", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "All" + }, + "InclusionRules" : [], + "EndStrategy" : { + "DateOffset" : { + "DateField" : "EndDate", + "Offset" : 365 + } + }, + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1128.json b/inst/cohorts/1128.json new file mode 100644 index 00000000..36a34c60 --- /dev/null +++ b/inst/cohorts/1128.json @@ -0,0 +1,83 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 0, + "ConditionTypeExclude" : false + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "All" + } + }, + "ConceptSets" : [ + { + "id" : 0, + "name" : "Nodule of lung", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 37206719, + "CONCEPT_NAME" : "Nodule of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "786838002", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4203096, + "CONCEPT_NAME" : "Lung mass", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "309529002", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : false, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "All" + }, + "InclusionRules" : [], + "EndStrategy" : { + "DateOffset" : { + "DateField" : "EndDate", + "Offset" : 730 + } + }, + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1129.json b/inst/cohorts/1129.json new file mode 100644 index 00000000..800601f5 --- /dev/null +++ b/inst/cohorts/1129.json @@ -0,0 +1,198 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 0, + "ConditionTypeExclude" : false + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "All" + } + }, + "ConceptSets" : [ + { + "id" : 0, + "name" : "Nodule of lung", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 37206719, + "CONCEPT_NAME" : "Nodule of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "786838002", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4203096, + "CONCEPT_NAME" : "Lung mass", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "309529002", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : false, + "includeMapped" : false + } + ] + } + }, + { + "id" : 1, + "name" : "Solitary Nodule of Lung", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 4142875, + "CONCEPT_NAME" : "Solitary nodule of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "427359005", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + }, + { + "id" : 2, + "name" : "Single lesion", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 4114805, + "CONCEPT_NAME" : "Single lesion", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "300580009", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "All" + }, + "InclusionRules" : [ + { + "name" : "Soiltary Lung Nodule", + "expression" : { + "Type" : "ANY", + "CriteriaList" : [ + { + "Criteria" : { + "ConditionOccurrence" : { + "CodesetId" : 1, + "ConditionTypeExclude" : false + } + }, + "StartWindow" : { + "Start" : { + "Days" : 0, + "Coeff" : 1 + }, + "End" : { + "Days" : 30, + "Coeff" : 1 + }, + "UseIndexEnd" : false, + "UseEventEnd" : false + }, + "RestrictVisit" : false, + "IgnoreObservationPeriod" : false, + "Occurrence" : { + "Type" : 2, + "Count" : 1, + "IsDistinct" : false + } + }, + { + "Criteria" : { + "ConditionOccurrence" : { + "CodesetId" : 2, + "ConditionTypeExclude" : false + } + }, + "StartWindow" : { + "Start" : { + "Days" : 0, + "Coeff" : -1 + }, + "End" : { + "Days" : 0, + "Coeff" : 1 + }, + "UseIndexEnd" : false, + "UseEventEnd" : false + }, + "RestrictVisit" : false, + "IgnoreObservationPeriod" : false, + "Occurrence" : { + "Type" : 2, + "Count" : 1, + "IsDistinct" : false + } + } + ], + "DemographicCriteriaList" : [], + "Groups" : [] + } + } + ], + "EndStrategy" : { + "DateOffset" : { + "DateField" : "EndDate", + "Offset" : 730 + } + }, + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1130.json b/inst/cohorts/1130.json new file mode 100644 index 00000000..b7f87dc1 --- /dev/null +++ b/inst/cohorts/1130.json @@ -0,0 +1,198 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 0, + "ConditionTypeExclude" : false + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "All" + } + }, + "ConceptSets" : [ + { + "id" : 0, + "name" : "Nodule of lung", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 37206719, + "CONCEPT_NAME" : "Nodule of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "786838002", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4203096, + "CONCEPT_NAME" : "Lung mass", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "309529002", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : false, + "includeMapped" : false + } + ] + } + }, + { + "id" : 1, + "name" : "Multiple nodules of lung", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 40482871, + "CONCEPT_NAME" : "Multiple nodules of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "445249002", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + }, + { + "id" : 2, + "name" : "Multiple lesions", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 4104316, + "CONCEPT_NAME" : "Multiple lesions", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "300582001", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "All" + }, + "InclusionRules" : [ + { + "name" : "Multiple Lung Nodule", + "expression" : { + "Type" : "ANY", + "CriteriaList" : [ + { + "Criteria" : { + "ConditionOccurrence" : { + "CodesetId" : 1, + "ConditionTypeExclude" : false + } + }, + "StartWindow" : { + "Start" : { + "Days" : 0, + "Coeff" : 1 + }, + "End" : { + "Days" : 30, + "Coeff" : 1 + }, + "UseIndexEnd" : false, + "UseEventEnd" : false + }, + "RestrictVisit" : false, + "IgnoreObservationPeriod" : false, + "Occurrence" : { + "Type" : 2, + "Count" : 1, + "IsDistinct" : false + } + }, + { + "Criteria" : { + "ConditionOccurrence" : { + "CodesetId" : 2, + "ConditionTypeExclude" : false + } + }, + "StartWindow" : { + "Start" : { + "Days" : 0, + "Coeff" : -1 + }, + "End" : { + "Days" : 0, + "Coeff" : 1 + }, + "UseIndexEnd" : false, + "UseEventEnd" : false + }, + "RestrictVisit" : false, + "IgnoreObservationPeriod" : false, + "Occurrence" : { + "Type" : 2, + "Count" : 1, + "IsDistinct" : false + } + } + ], + "DemographicCriteriaList" : [], + "Groups" : [] + } + } + ], + "EndStrategy" : { + "DateOffset" : { + "DateField" : "EndDate", + "Offset" : 730 + } + }, + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1131.json b/inst/cohorts/1131.json new file mode 100644 index 00000000..ba2f6131 --- /dev/null +++ b/inst/cohorts/1131.json @@ -0,0 +1,168 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 0, + "ConditionTypeExclude" : false + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "All" + } + }, + "ConceptSets" : [ + { + "id" : 0, + "name" : "Lung mass", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 4006969, + "CONCEPT_NAME" : "Acute respiratory disease", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "111273006", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 261880, + "CONCEPT_NAME" : "Atelectasis", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "46621007", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4197819, + "CONCEPT_NAME" : "Fibrosis of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "51615001", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4324261, + "CONCEPT_NAME" : "Pulmonary necrosis", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "7159003", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 257010, + "CONCEPT_NAME" : "Abscess of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "73452002", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 46269691, + "CONCEPT_NAME" : "Pulmonary granuloma", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "101401000119103", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4203096, + "CONCEPT_NAME" : "Lung mass", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "309529002", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "All" + }, + "InclusionRules" : [], + "EndStrategy" : { + "DateOffset" : { + "DateField" : "EndDate", + "Offset" : 730 + } + }, + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1132.json b/inst/cohorts/1132.json new file mode 100644 index 00000000..ab908a81 --- /dev/null +++ b/inst/cohorts/1132.json @@ -0,0 +1,168 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 0, + "ConditionTypeExclude" : false + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "All" + } + }, + "ConceptSets" : [ + { + "id" : 0, + "name" : "Lung Lesion (not acute, necrotic, atlectatic, abscess, fibrosis)", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 4116778, + "CONCEPT_NAME" : "Lesion of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "301232003", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4006969, + "CONCEPT_NAME" : "Acute respiratory disease", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "111273006", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 261880, + "CONCEPT_NAME" : "Atelectasis", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "46621007", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4197819, + "CONCEPT_NAME" : "Fibrosis of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "51615001", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4324261, + "CONCEPT_NAME" : "Pulmonary necrosis", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "7159003", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 257010, + "CONCEPT_NAME" : "Abscess of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "73452002", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 46269691, + "CONCEPT_NAME" : "Pulmonary granuloma", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "101401000119103", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "All" + }, + "InclusionRules" : [], + "EndStrategy" : { + "DateOffset" : { + "DateField" : "EndDate", + "Offset" : 730 + } + }, + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1133.json b/inst/cohorts/1133.json new file mode 100644 index 00000000..4bcbf980 --- /dev/null +++ b/inst/cohorts/1133.json @@ -0,0 +1,338 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 0, + "ConditionTypeExclude" : false + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "All" + } + }, + "ConceptSets" : [ + { + "id" : 0, + "name" : "Non Small Cell Lung Cancer defined as lung cancer without small cell", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 36684857, + "CONCEPT_NAME" : "Metastatic non-small cell lung cancer", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "457721000124104", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 443388, + "CONCEPT_NAME" : "Malignant tumor of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "363358000", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 255507, + "CONCEPT_NAME" : "Carcinoma in situ of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "92649001", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 36530069, + "CONCEPT_NAME" : "Mucin-producing adenocarcinoma of overlapping lesion of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "8481/3-C34.8", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "ICDO3", + "CONCEPT_CLASS_ID" : "ICDO Condition" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4311499, + "CONCEPT_NAME" : "Primary malignant neoplasm of respiratory tract", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "93986008", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 45890780, + "CONCEPT_NAME" : "Primary non-small cell lung cancer biopsy and cytology specimen report documents classification into specific histologic type or classified as nsclc-nos with an explanation", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "G9418", + "DOMAIN_ID" : "Observation", + "VOCABULARY_ID" : "HCPCS", + "CONCEPT_CLASS_ID" : "HCPCS" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 443399, + "CONCEPT_NAME" : "Malignant tumor of bronchus", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "363493006", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4115276, + "CONCEPT_NAME" : "Non-small cell lung cancer", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "254637007", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 252840, + "CONCEPT_NAME" : "Primary malignant neoplasm of upper respiratory tract", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "94118008", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 254591, + "CONCEPT_NAME" : "Secondary malignant neoplasm of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "94391008", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4177112, + "CONCEPT_NAME" : "Malignant tumor of trachea", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "363432004", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 254583, + "CONCEPT_NAME" : "Kaposi's sarcoma of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "109390005", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 432571, + "CONCEPT_NAME" : "Malignant lymphoma", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "118600007", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 36712771, + "CONCEPT_NAME" : "Small cell carcinoma", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "11010461000119101", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4147164, + "CONCEPT_NAME" : "Malignant tumor of lymphoid hemopoietic and related tissue", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "269475001", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 434300, + "CONCEPT_NAME" : "Neuroendocrine tumor", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "255046005", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4110591, + "CONCEPT_NAME" : "Small cell carcinoma of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "254632001", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "All" + }, + "InclusionRules" : [], + "EndStrategy" : { + "DateOffset" : { + "DateField" : "EndDate", + "Offset" : 730 + } + }, + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1134.json b/inst/cohorts/1134.json new file mode 100644 index 00000000..4294421c --- /dev/null +++ b/inst/cohorts/1134.json @@ -0,0 +1,287 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 0, + "ConditionTypeExclude" : false + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "All" + } + }, + "ConceptSets" : [ + { + "id" : 0, + "name" : "Lung Cancer", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 36684857, + "CONCEPT_NAME" : "Metastatic non-small cell lung cancer", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "457721000124104", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 443388, + "CONCEPT_NAME" : "Malignant tumor of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "363358000", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 255507, + "CONCEPT_NAME" : "Carcinoma in situ of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "92649001", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 36530069, + "CONCEPT_NAME" : "Mucin-producing adenocarcinoma of overlapping lesion of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "8481/3-C34.8", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "ICDO3", + "CONCEPT_CLASS_ID" : "ICDO Condition" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4311499, + "CONCEPT_NAME" : "Primary malignant neoplasm of respiratory tract", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "93986008", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 45890780, + "CONCEPT_NAME" : "Primary non-small cell lung cancer biopsy and cytology specimen report documents classification into specific histologic type or classified as nsclc-nos with an explanation", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "G9418", + "DOMAIN_ID" : "Observation", + "VOCABULARY_ID" : "HCPCS", + "CONCEPT_CLASS_ID" : "HCPCS" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 443399, + "CONCEPT_NAME" : "Malignant tumor of bronchus", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "363493006", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 252840, + "CONCEPT_NAME" : "Primary malignant neoplasm of upper respiratory tract", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "94118008", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 254591, + "CONCEPT_NAME" : "Secondary malignant neoplasm of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "94391008", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4177112, + "CONCEPT_NAME" : "Malignant tumor of trachea", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "363432004", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 254583, + "CONCEPT_NAME" : "Kaposi's sarcoma of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "109390005", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 432571, + "CONCEPT_NAME" : "Malignant lymphoma", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "118600007", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4147164, + "CONCEPT_NAME" : "Malignant tumor of lymphoid hemopoietic and related tissue", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "269475001", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 434300, + "CONCEPT_NAME" : "Neuroendocrine tumor", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "255046005", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "All" + }, + "InclusionRules" : [], + "EndStrategy" : { + "DateOffset" : { + "DateField" : "EndDate", + "Offset" : 180 + } + }, + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1135.json b/inst/cohorts/1135.json new file mode 100644 index 00000000..233ccc97 --- /dev/null +++ b/inst/cohorts/1135.json @@ -0,0 +1,134 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 0, + "ConditionTypeExclude" : false + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "All" + } + }, + "ConceptSets" : [ + { + "id" : 0, + "name" : "Small Cell Lung Cancer defined as lung cancer without small cell", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 36712771, + "CONCEPT_NAME" : "Small cell carcinoma", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "11010461000119101", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : false, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 254591, + "CONCEPT_NAME" : "Secondary malignant neoplasm of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "94391008", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 252840, + "CONCEPT_NAME" : "Primary malignant neoplasm of upper respiratory tract", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "94118008", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 200962, + "CONCEPT_NAME" : "Primary malignant neoplasm of prostate", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "93974005", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4110591, + "CONCEPT_NAME" : "Small cell carcinoma of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "254632001", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "All" + }, + "InclusionRules" : [], + "EndStrategy" : { + "DateOffset" : { + "DateField" : "EndDate", + "Offset" : 180 + } + }, + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1136.json b/inst/cohorts/1136.json new file mode 100644 index 00000000..4d6fa11e --- /dev/null +++ b/inst/cohorts/1136.json @@ -0,0 +1,151 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 0, + "ConditionTypeExclude" : false + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "All" + } + }, + "ConceptSets" : [ + { + "id" : 0, + "name" : "Non Small Cell Lung Cancer defined as lung cancer without small cell", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 36684857, + "CONCEPT_NAME" : "Metastatic non-small cell lung cancer", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "457721000124104", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 45890780, + "CONCEPT_NAME" : "Primary non-small cell lung cancer biopsy and cytology specimen report documents classification into specific histologic type or classified as nsclc-nos with an explanation", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "G9418", + "DOMAIN_ID" : "Observation", + "VOCABULARY_ID" : "HCPCS", + "CONCEPT_CLASS_ID" : "HCPCS" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4115276, + "CONCEPT_NAME" : "Non-small cell lung cancer", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "254637007", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4177112, + "CONCEPT_NAME" : "Malignant tumor of trachea", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "363432004", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 254583, + "CONCEPT_NAME" : "Kaposi's sarcoma of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "109390005", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4147164, + "CONCEPT_NAME" : "Malignant tumor of lymphoid hemopoietic and related tissue", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "269475001", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "All" + }, + "InclusionRules" : [], + "EndStrategy" : { + "DateOffset" : { + "DateField" : "EndDate", + "Offset" : 180 + } + }, + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1137.json b/inst/cohorts/1137.json new file mode 100644 index 00000000..4706ad2a --- /dev/null +++ b/inst/cohorts/1137.json @@ -0,0 +1,66 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 0, + "ConditionTypeExclude" : false + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "All" + } + }, + "ConceptSets" : [ + { + "id" : 0, + "name" : "Hoarse", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 4177176, + "CONCEPT_NAME" : "Hoarse", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "50219008", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "All" + }, + "InclusionRules" : [], + "EndStrategy" : { + "DateOffset" : { + "DateField" : "EndDate", + "Offset" : 14 + } + }, + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1138.json b/inst/cohorts/1138.json new file mode 100644 index 00000000..86b38a68 --- /dev/null +++ b/inst/cohorts/1138.json @@ -0,0 +1,156 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 0, + "ConditionTypeExclude" : false + } + }, + { + "ConditionOccurrence" : { + "CorrelatedCriteria" : { + "Type" : "ALL", + "CriteriaList" : [ + { + "Criteria" : { + "ConditionOccurrence" : { + "CodesetId" : 2, + "ConditionTypeExclude" : false + } + }, + "StartWindow" : { + "Start" : { + "Days" : 0, + "Coeff" : -1 + }, + "End" : { + "Days" : 0, + "Coeff" : 1 + }, + "UseIndexEnd" : false, + "UseEventEnd" : false + }, + "RestrictVisit" : false, + "IgnoreObservationPeriod" : false, + "Occurrence" : { + "Type" : 2, + "Count" : 1, + "IsDistinct" : false + } + } + ], + "DemographicCriteriaList" : [], + "Groups" : [] + }, + "CodesetId" : 1, + "ConditionTypeExclude" : false + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "All" + } + }, + "ConceptSets" : [ + { + "id" : 0, + "name" : "Bone Pain", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 4129418, + "CONCEPT_NAME" : "Bone pain", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "12584003", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + }, + { + "id" : 1, + "name" : "Bone finding", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 4042505, + "CONCEPT_NAME" : "Bone finding", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "118953000", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + }, + { + "id" : 2, + "name" : "Pain finding at anatomical site", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 4132926, + "CONCEPT_NAME" : "Pain finding at anatomical site", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "279001004", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "All" + }, + "InclusionRules" : [], + "EndStrategy" : { + "DateOffset" : { + "DateField" : "EndDate", + "Offset" : 14 + } + }, + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1139.json b/inst/cohorts/1139.json new file mode 100644 index 00000000..7c7f946e --- /dev/null +++ b/inst/cohorts/1139.json @@ -0,0 +1,66 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 0, + "ConditionTypeExclude" : false + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "All" + } + }, + "ConceptSets" : [ + { + "id" : 0, + "name" : "Weight loss", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 4229881, + "CONCEPT_NAME" : "Weight loss", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "89362005", + "DOMAIN_ID" : "Observation", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "All" + }, + "InclusionRules" : [], + "EndStrategy" : { + "DateOffset" : { + "DateField" : "EndDate", + "Offset" : 14 + } + }, + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1216.json b/inst/cohorts/1216.json new file mode 100644 index 00000000..fc1b9889 --- /dev/null +++ b/inst/cohorts/1216.json @@ -0,0 +1,682 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 2, + "ConditionTypeExclude" : true + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "All" + } + }, + "ConceptSets" : [ + { + "id" : 2, + "name" : "Primary Lung Cancer", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 36617886, + "CONCEPT_NAME" : "Lung cancer metastatic", + "STANDARD_CONCEPT" : "C", + "STANDARD_CONCEPT_CAPTION" : "Classification", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "10050017", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "MedDRA", + "CONCEPT_CLASS_ID" : "PT" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4157333, + "CONCEPT_NAME" : "Malignant neoplasm of main bronchus", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "372065009", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4128888, + "CONCEPT_NAME" : "Neoplasm of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "126713003", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 254591, + "CONCEPT_NAME" : "Secondary malignant neoplasm of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "94391008", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4248073, + "CONCEPT_NAME" : "Secondary malignant neoplasm of main bronchus", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "94399005", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 443388, + "CONCEPT_NAME" : "Malignant tumor of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "363358000", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4242353, + "CONCEPT_NAME" : "Benign neoplasm of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "92196005", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4311499, + "CONCEPT_NAME" : "Primary malignant neoplasm of respiratory tract", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "93986008", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : false, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 46270492, + "CONCEPT_NAME" : "Adult pulmonary Langerhans cell histiocytosis", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "328611000119105", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 254583, + "CONCEPT_NAME" : "Kaposi's sarcoma of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "109390005", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4174275, + "CONCEPT_NAME" : "Pulmonary lymphangioleiomyomatosis", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "277844007", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + }, + { + "id" : 3, + "name" : "SCLC only drugs", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 36850058, + "CONCEPT_NAME" : "BELOTECAN", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "OMOP5167674", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm Extension", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 19015523, + "CONCEPT_NAME" : "bendamustine", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "134547", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 1344354, + "CONCEPT_NAME" : "epirubicin", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "3995", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 19078187, + "CONCEPT_NAME" : "ifosfamide", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "5657", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 1146139, + "CONCEPT_NAME" : "lurbinectedin", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "2374729", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 1336539, + "CONCEPT_NAME" : "sunitinib", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "357977", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 1341149, + "CONCEPT_NAME" : "temozolomide", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "37776", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 1378509, + "CONCEPT_NAME" : "topotecan", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "57308", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 1503501, + "CONCEPT_NAME" : "lanreotide", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "68092", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + }, + { + "id" : 4, + "name" : "SCLC condition", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 4110591, + "CONCEPT_NAME" : "Small cell carcinoma of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "254632001", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + }, + { + "id" : 5, + "name" : "SCLC observations", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 2618003, + "CONCEPT_NAME" : "Oncology; disease status; small cell lung cancer, limited to small cell and combined small cell/non-small cell; extensive stage at diagnosis, metastatic, locally recurrent, or progressive (for use in a medicare-approved demonstration project)", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "G9069", + "DOMAIN_ID" : "Observation", + "VOCABULARY_ID" : "HCPCS", + "CONCEPT_CLASS_ID" : "HCPCS" + }, + "isExcluded" : false, + "includeDescendants" : false, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 2618004, + "CONCEPT_NAME" : "Oncology; disease status; small cell lung cancer, limited to small cell and combined small cell/non-small; extent of disease unknown, staging in progress, or not listed (for use in a medicare-approved demonstration project)", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "G9070", + "DOMAIN_ID" : "Observation", + "VOCABULARY_ID" : "HCPCS", + "CONCEPT_CLASS_ID" : "HCPCS" + }, + "isExcluded" : false, + "includeDescendants" : false, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 2618002, + "CONCEPT_NAME" : "Oncology; disease status; limited to small cell and combined small cell/non-small cell; extent of disease initially established as limited with no evidence of disease progression, recurrence, or metastases (for use in a medicare-approved demonstration...", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "G9068", + "DOMAIN_ID" : "Observation", + "VOCABULARY_ID" : "HCPCS", + "CONCEPT_CLASS_ID" : "HCPCS" + }, + "isExcluded" : false, + "includeDescendants" : false, + "includeMapped" : false + } + ] + } + }, + { + "id" : 6, + "name" : "\n\nMalignant neoplasm of upper respiratory tract", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 40493020, + "CONCEPT_NAME" : "Malignant neoplasm of upper respiratory tract", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "449066004", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "First" + }, + "InclusionRules" : [ + { + "name" : "Another neoplasm of lung code within 365 days", + "expression" : { + "Type" : "ALL", + "CriteriaList" : [ + { + "Criteria" : { + "ConditionOccurrence" : { + "CodesetId" : 2, + "ConditionTypeExclude" : false + } + }, + "StartWindow" : { + "Start" : { + "Days" : 1, + "Coeff" : 1 + }, + "End" : { + "Days" : 365, + "Coeff" : 1 + }, + "UseIndexEnd" : false, + "UseEventEnd" : false + }, + "RestrictVisit" : false, + "IgnoreObservationPeriod" : false, + "Occurrence" : { + "Type" : 2, + "Count" : 1, + "IsDistinct" : false + } + } + ], + "DemographicCriteriaList" : [], + "Groups" : [] + } + }, + { + "name" : "SCLC drugs exclusion", + "expression" : { + "Type" : "ALL", + "CriteriaList" : [ + { + "Criteria" : { + "DrugExposure" : { + "CodesetId" : 3, + "DrugTypeExclude" : false + } + }, + "StartWindow" : { + "Start" : { + "Coeff" : -1 + }, + "End" : { + "Days" : 365, + "Coeff" : 1 + }, + "UseIndexEnd" : false, + "UseEventEnd" : false + }, + "RestrictVisit" : false, + "IgnoreObservationPeriod" : false, + "Occurrence" : { + "Type" : 1, + "Count" : 0, + "IsDistinct" : false + } + } + ], + "DemographicCriteriaList" : [], + "Groups" : [] + } + }, + { + "name" : "SCLC diagnosis exclusion ", + "expression" : { + "Type" : "ALL", + "CriteriaList" : [ + { + "Criteria" : { + "ConditionOccurrence" : { + "CodesetId" : 4, + "ConditionTypeExclude" : false + } + }, + "StartWindow" : { + "Start" : { + "Coeff" : -1 + }, + "End" : { + "Days" : 365, + "Coeff" : 1 + }, + "UseIndexEnd" : false, + "UseEventEnd" : false + }, + "RestrictVisit" : false, + "IgnoreObservationPeriod" : false, + "Occurrence" : { + "Type" : 1, + "Count" : 0, + "IsDistinct" : false + } + } + ], + "DemographicCriteriaList" : [], + "Groups" : [] + } + }, + { + "name" : "SCLC observations exclusion", + "expression" : { + "Type" : "ALL", + "CriteriaList" : [ + { + "Criteria" : { + "Observation" : { + "CodesetId" : 5, + "ObservationTypeExclude" : false + } + }, + "StartWindow" : { + "Start" : { + "Coeff" : -1 + }, + "End" : { + "Days" : 365, + "Coeff" : 1 + }, + "UseIndexEnd" : false, + "UseEventEnd" : false + }, + "RestrictVisit" : false, + "IgnoreObservationPeriod" : false, + "Occurrence" : { + "Type" : 1, + "Count" : 0, + "IsDistinct" : false + } + } + ], + "DemographicCriteriaList" : [], + "Groups" : [] + } + }, + { + "name" : "No Upper respiratory tract Neoplasm", + "expression" : { + "Type" : "ALL", + "CriteriaList" : [ + { + "Criteria" : { + "ConditionOccurrence" : { + "CodesetId" : 6, + "ConditionTypeExclude" : false + } + }, + "StartWindow" : { + "Start" : { + "Coeff" : -1 + }, + "End" : { + "Days" : 365, + "Coeff" : 1 + }, + "UseIndexEnd" : false, + "UseEventEnd" : false + }, + "RestrictVisit" : false, + "IgnoreObservationPeriod" : false, + "Occurrence" : { + "Type" : 0, + "Count" : 0, + "IsDistinct" : false + } + } + ], + "DemographicCriteriaList" : [], + "Groups" : [] + } + } + ], + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/1217.json b/inst/cohorts/1217.json new file mode 100644 index 00000000..5cb03c5f --- /dev/null +++ b/inst/cohorts/1217.json @@ -0,0 +1,629 @@ +{ + "cdmVersionRange" : ">=5.0.0", + "PrimaryCriteria" : { + "CriteriaList" : [ + { + "ConditionOccurrence" : { + "CodesetId" : 2, + "First" : true, + "ConditionTypeExclude" : true + } + } + ], + "ObservationWindow" : { + "PriorDays" : 0, + "PostDays" : 0 + }, + "PrimaryCriteriaLimit" : { + "Type" : "First" + } + }, + "ConceptSets" : [ + { + "id" : 2, + "name" : "Primary Lung Cancer", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 4157333, + "CONCEPT_NAME" : "Malignant neoplasm of main bronchus", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "372065009", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4128888, + "CONCEPT_NAME" : "Neoplasm of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "126713003", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 254591, + "CONCEPT_NAME" : "Secondary malignant neoplasm of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "94391008", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4248073, + "CONCEPT_NAME" : "Secondary malignant neoplasm of main bronchus", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "94399005", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 443388, + "CONCEPT_NAME" : "Malignant tumor of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "363358000", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4242353, + "CONCEPT_NAME" : "Benign neoplasm of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "92196005", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4311499, + "CONCEPT_NAME" : "Primary malignant neoplasm of respiratory tract", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "93986008", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : false, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 46270492, + "CONCEPT_NAME" : "Adult pulmonary Langerhans cell histiocytosis", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "328611000119105", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 254583, + "CONCEPT_NAME" : "Kaposi's sarcoma of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "109390005", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 4174275, + "CONCEPT_NAME" : "Pulmonary lymphangioleiomyomatosis", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "277844007", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : true, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + }, + { + "id" : 3, + "name" : "SCLC only drugs", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 36850058, + "CONCEPT_NAME" : "BELOTECAN", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "OMOP5167674", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm Extension", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 19015523, + "CONCEPT_NAME" : "bendamustine", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "134547", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 1344354, + "CONCEPT_NAME" : "epirubicin", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "3995", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 19078187, + "CONCEPT_NAME" : "ifosfamide", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "5657", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 1146139, + "CONCEPT_NAME" : "lurbinectedin", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "2374729", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 1336539, + "CONCEPT_NAME" : "sunitinib", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "357977", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 1341149, + "CONCEPT_NAME" : "temozolomide", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "37776", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 1378509, + "CONCEPT_NAME" : "topotecan", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "57308", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 1503501, + "CONCEPT_NAME" : "lanreotide", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "68092", + "DOMAIN_ID" : "Drug", + "VOCABULARY_ID" : "RxNorm", + "CONCEPT_CLASS_ID" : "Ingredient" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + }, + { + "id" : 4, + "name" : "SCLC condition", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 4110591, + "CONCEPT_NAME" : "Small cell carcinoma of lung", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "254632001", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + }, + { + "id" : 5, + "name" : "SCLC observations", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 2618003, + "CONCEPT_NAME" : "Oncology; disease status; small cell lung cancer, limited to small cell and combined small cell/non-small cell; extensive stage at diagnosis, metastatic, locally recurrent, or progressive (for use in a medicare-approved demonstration project)", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "G9069", + "DOMAIN_ID" : "Observation", + "VOCABULARY_ID" : "HCPCS", + "CONCEPT_CLASS_ID" : "HCPCS" + }, + "isExcluded" : false, + "includeDescendants" : false, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 2618004, + "CONCEPT_NAME" : "Oncology; disease status; small cell lung cancer, limited to small cell and combined small cell/non-small; extent of disease unknown, staging in progress, or not listed (for use in a medicare-approved demonstration project)", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "G9070", + "DOMAIN_ID" : "Observation", + "VOCABULARY_ID" : "HCPCS", + "CONCEPT_CLASS_ID" : "HCPCS" + }, + "isExcluded" : false, + "includeDescendants" : false, + "includeMapped" : false + }, + { + "concept" : { + "CONCEPT_ID" : 2618002, + "CONCEPT_NAME" : "Oncology; disease status; limited to small cell and combined small cell/non-small cell; extent of disease initially established as limited with no evidence of disease progression, recurrence, or metastases (for use in a medicare-approved demonstration...", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "G9068", + "DOMAIN_ID" : "Observation", + "VOCABULARY_ID" : "HCPCS", + "CONCEPT_CLASS_ID" : "HCPCS" + }, + "isExcluded" : false, + "includeDescendants" : false, + "includeMapped" : false + } + ] + } + }, + { + "id" : 6, + "name" : "Malignant neoplasm of upper respiratory tract", + "expression" : { + "items" : [ + { + "concept" : { + "CONCEPT_ID" : 40493020, + "CONCEPT_NAME" : "Malignant neoplasm of upper respiratory tract", + "STANDARD_CONCEPT" : "S", + "STANDARD_CONCEPT_CAPTION" : "Standard", + "INVALID_REASON" : "V", + "INVALID_REASON_CAPTION" : "Valid", + "CONCEPT_CODE" : "449066004", + "DOMAIN_ID" : "Condition", + "VOCABULARY_ID" : "SNOMED", + "CONCEPT_CLASS_ID" : "Clinical Finding" + }, + "isExcluded" : false, + "includeDescendants" : true, + "includeMapped" : false + } + ] + } + } + ], + "QualifiedLimit" : { + "Type" : "First" + }, + "ExpressionLimit" : { + "Type" : "First" + }, + "InclusionRules" : [ + { + "name" : "No Malignant neoplasm of upper respiratory tract", + "expression" : { + "Type" : "ALL", + "CriteriaList" : [ + { + "Criteria" : { + "ConditionOccurrence" : { + "CodesetId" : 6, + "ConditionTypeExclude" : false + } + }, + "StartWindow" : { + "Start" : { + "Coeff" : -1 + }, + "End" : { + "Days" : 365, + "Coeff" : 1 + }, + "UseIndexEnd" : false, + "UseEventEnd" : false + }, + "RestrictVisit" : false, + "IgnoreObservationPeriod" : false, + "Occurrence" : { + "Type" : 1, + "Count" : 0, + "IsDistinct" : false + } + } + ], + "DemographicCriteriaList" : [], + "Groups" : [] + } + }, + { + "name" : "SCLC drugs exclusion", + "expression" : { + "Type" : "ALL", + "CriteriaList" : [ + { + "Criteria" : { + "DrugExposure" : { + "CodesetId" : 3, + "DrugTypeExclude" : false + } + }, + "StartWindow" : { + "Start" : { + "Coeff" : -1 + }, + "End" : { + "Days" : 365, + "Coeff" : 1 + }, + "UseIndexEnd" : false, + "UseEventEnd" : false + }, + "RestrictVisit" : false, + "IgnoreObservationPeriod" : false, + "Occurrence" : { + "Type" : 1, + "Count" : 0, + "IsDistinct" : false + } + } + ], + "DemographicCriteriaList" : [], + "Groups" : [] + } + }, + { + "name" : "SCLC diagnosis exclusion ", + "expression" : { + "Type" : "ALL", + "CriteriaList" : [ + { + "Criteria" : { + "ConditionOccurrence" : { + "CodesetId" : 4, + "ConditionTypeExclude" : false + } + }, + "StartWindow" : { + "Start" : { + "Coeff" : -1 + }, + "End" : { + "Days" : 365, + "Coeff" : 1 + }, + "UseIndexEnd" : false, + "UseEventEnd" : false + }, + "RestrictVisit" : false, + "IgnoreObservationPeriod" : false, + "Occurrence" : { + "Type" : 1, + "Count" : 0, + "IsDistinct" : false + } + } + ], + "DemographicCriteriaList" : [], + "Groups" : [] + } + }, + { + "name" : "SCLC observations exclusion", + "expression" : { + "Type" : "ALL", + "CriteriaList" : [ + { + "Criteria" : { + "Observation" : { + "CodesetId" : 5, + "ObservationTypeExclude" : false + } + }, + "StartWindow" : { + "Start" : { + "Coeff" : -1 + }, + "End" : { + "Days" : 365, + "Coeff" : 1 + }, + "UseIndexEnd" : false, + "UseEventEnd" : false + }, + "RestrictVisit" : false, + "IgnoreObservationPeriod" : false, + "Occurrence" : { + "Type" : 1, + "Count" : 0, + "IsDistinct" : false + } + } + ], + "DemographicCriteriaList" : [], + "Groups" : [] + } + } + ], + "CensoringCriteria" : [], + "CollapseSettings" : { + "CollapseType" : "ERA", + "EraPad" : 0 + }, + "CensorWindow" : {} +} \ No newline at end of file diff --git a/inst/cohorts/762.json b/inst/cohorts/762.json index 4283159d..121d75a1 100644 --- a/inst/cohorts/762.json +++ b/inst/cohorts/762.json @@ -3,9 +3,9 @@ "PrimaryCriteria" : { "CriteriaList" : [ { - "ConditionOccurrence" : { + "DrugExposure" : { "CodesetId" : 0, - "ConditionTypeExclude" : false + "DrugTypeExclude" : false } } ], diff --git a/inst/cohorts/InclusionRules.csv b/inst/cohorts/InclusionRules.csv index 4304314c..38e665c0 100644 --- a/inst/cohorts/InclusionRules.csv +++ b/inst/cohorts/InclusionRules.csv @@ -105,6 +105,8 @@ cohortName,ruleSequence,ruleName,cohortId 1106,0,Age above 18 years,1106 1106,1,Inpatient visit on day of surgery without ER visit immediately on or prior,1106 1106,2,"No prior opioid in last year, up to 30d prior to Sgx",1106 +1129,0,Soiltary Lung Nodule,1129 +1130,0,Multiple Lung Nodule,1130 1152,0,has no events in prior 'clean window' - 365 days,1152 1153,0,has no events in prior 'clean window' - 42 days,1153 1155,0,has no events in prior 'clean window' - 365 days,1155 @@ -129,6 +131,15 @@ cohortName,ruleSequence,ruleName,cohortId 1196,0,30 day washout,1196 1197,0,45 day washout period ,1197 1199,0,180 day washout period,1199 +1216,0,Another neoplasm of lung code within 365 days,1216 +1216,1,SCLC drugs exclusion,1216 +1216,2,SCLC diagnosis exclusion ,1216 +1216,3,SCLC observations exclusion,1216 +1216,4,No Upper respiratory tract Neoplasm,1216 +1217,0,No Malignant neoplasm of upper respiratory tract,1217 +1217,1,SCLC drugs exclusion,1217 +1217,2,SCLC diagnosis exclusion ,1217 +1217,3,SCLC observations exclusion,1217 13,0,"Exclude persons with muscle pain that may be explained by injury, ischemia or chronic systemic inflammation",13 134,0,has at least one condition record of ADHD,134 19,0,Exclude if concomitant non acute pneumonia,19 diff --git a/inst/doc/HowToUsePhenotypeLibraryRPackage.pdf b/inst/doc/HowToUsePhenotypeLibraryRPackage.pdf index 9f8b4e84..9307409b 100644 Binary files a/inst/doc/HowToUsePhenotypeLibraryRPackage.pdf and b/inst/doc/HowToUsePhenotypeLibraryRPackage.pdf differ diff --git a/inst/sql/sql_server/1117.sql b/inst/sql/sql_server/1117.sql new file mode 100644 index 00000000..06a3ef9b --- /dev/null +++ b/inst/sql/sql_server/1117.sql @@ -0,0 +1,311 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 0 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4197819) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4197819) + and c.invalid_reason is null + +) I +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) +) C + + +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P +WHERE P.ordinal = 1 +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +create table #inclusion_events (inclusion_rule_id bigint, + person_id bigint, + event_id bigint +); + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{0 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),0)-1) +} +) Results +WHERE Results.ordinal = 1 +; + + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- By default, cohort exit at the event's op end date +select event_id, person_id, op_end_date as end_date from #included_events + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 0 != 0}?{ + +CREATE TABLE #inclusion_rules (rule_sequence int); + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1118.sql b/inst/sql/sql_server/1118.sql new file mode 100644 index 00000000..50a2d0f6 --- /dev/null +++ b/inst/sql/sql_server/1118.sql @@ -0,0 +1,311 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 0 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (197508) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (197508) + and c.invalid_reason is null + +) I +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) +) C + + +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P +WHERE P.ordinal = 1 +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +create table #inclusion_events (inclusion_rule_id bigint, + person_id bigint, + event_id bigint +); + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{0 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),0)-1) +} +) Results + +; + + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- By default, cohort exit at the event's op end date +select event_id, person_id, op_end_date as end_date from #included_events + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 0 != 0}?{ + +CREATE TABLE #inclusion_rules (rule_sequence int); + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1119.sql b/inst/sql/sql_server/1119.sql new file mode 100644 index 00000000..8c77885c --- /dev/null +++ b/inst/sql/sql_server/1119.sql @@ -0,0 +1,311 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 0 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (255573,258780) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (255573,258780) + and c.invalid_reason is null + +) I +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) +) C + + +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P +WHERE P.ordinal = 1 +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +create table #inclusion_events (inclusion_rule_id bigint, + person_id bigint, + event_id bigint +); + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{0 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),0)-1) +} +) Results +WHERE Results.ordinal = 1 +; + + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- By default, cohort exit at the event's op end date +select event_id, person_id, op_end_date as end_date from #included_events + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 0 != 0}?{ + +CREATE TABLE #inclusion_rules (rule_sequence int); + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1120.sql b/inst/sql/sql_server/1120.sql new file mode 100644 index 00000000..0827e07c --- /dev/null +++ b/inst/sql/sql_server/1120.sql @@ -0,0 +1,331 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 0 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4119786) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4119786) + and c.invalid_reason is null + +) I +LEFT JOIN +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4195694,438791,258180,4006969) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4195694,438791,258180,4006969) + and c.invalid_reason is null + +) E ON I.concept_id = E.concept_id +WHERE E.concept_id is null +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) +) C + + +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P + +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +create table #inclusion_events (inclusion_rule_id bigint, + person_id bigint, + event_id bigint +); + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{0 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),0)-1) +} +) Results + +; + +-- date offset strategy + +select event_id, person_id, + case when DATEADD(day,365,end_date) > op_end_date then op_end_date else DATEADD(day,365,end_date) end as end_date +INTO #strategy_ends +from #included_events; + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- End Date Strategy +SELECT event_id, person_id, end_date from #strategy_ends + + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 0 != 0}?{ + +CREATE TABLE #inclusion_rules (rule_sequence int); + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + +TRUNCATE TABLE #strategy_ends; +DROP TABLE #strategy_ends; + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1128.sql b/inst/sql/sql_server/1128.sql new file mode 100644 index 00000000..b431783a --- /dev/null +++ b/inst/sql/sql_server/1128.sql @@ -0,0 +1,320 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 0 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (37206719,4203096) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (37206719) + and c.invalid_reason is null + +) I +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) +) C + + +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P + +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +create table #inclusion_events (inclusion_rule_id bigint, + person_id bigint, + event_id bigint +); + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{0 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),0)-1) +} +) Results + +; + +-- date offset strategy + +select event_id, person_id, + case when DATEADD(day,730,end_date) > op_end_date then op_end_date else DATEADD(day,730,end_date) end as end_date +INTO #strategy_ends +from #included_events; + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- End Date Strategy +SELECT event_id, person_id, end_date from #strategy_ends + + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 0 != 0}?{ + +CREATE TABLE #inclusion_rules (rule_sequence int); + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + +TRUNCATE TABLE #strategy_ends; +DROP TABLE #strategy_ends; + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1129.sql b/inst/sql/sql_server/1129.sql new file mode 100644 index 00000000..ea790582 --- /dev/null +++ b/inst/sql/sql_server/1129.sql @@ -0,0 +1,423 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 0 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (37206719,4203096) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (37206719) + and c.invalid_reason is null + +) I +) C UNION ALL +SELECT 1 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4142875) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4142875) + and c.invalid_reason is null + +) I +) C UNION ALL +SELECT 2 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4114805) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4114805) + and c.invalid_reason is null + +) I +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) +) C + + +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P + +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +select 0 as inclusion_rule_id, person_id, event_id +INTO #Inclusion_0 +FROM +( + select pe.person_id, pe.event_id + FROM #qualified_events pe + +JOIN ( +-- Begin Criteria Group +select 0 as index_id, person_id, event_id +FROM +( + select E.person_id, E.event_id + FROM #qualified_events E + INNER JOIN + ( + -- Begin Correlated Criteria +select 0 as index_id, cc.person_id, cc.event_id +from (SELECT p.person_id, p.event_id +FROM #qualified_events P +JOIN ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 1) +) C + + +-- End Condition Occurrence Criteria + +) A on A.person_id = P.person_id AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= P.OP_END_DATE AND A.START_DATE >= DATEADD(day,0,P.START_DATE) AND A.START_DATE <= DATEADD(day,30,P.START_DATE) ) cc +GROUP BY cc.person_id, cc.event_id +HAVING COUNT(cc.event_id) >= 1 +-- End Correlated Criteria + +UNION ALL +-- Begin Correlated Criteria +select 1 as index_id, cc.person_id, cc.event_id +from (SELECT p.person_id, p.event_id +FROM #qualified_events P +JOIN ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 2) +) C + + +-- End Condition Occurrence Criteria + +) A on A.person_id = P.person_id AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= P.OP_END_DATE AND A.START_DATE >= DATEADD(day,0,P.START_DATE) AND A.START_DATE <= DATEADD(day,0,P.START_DATE) ) cc +GROUP BY cc.person_id, cc.event_id +HAVING COUNT(cc.event_id) >= 1 +-- End Correlated Criteria + + ) CQ on E.person_id = CQ.person_id and E.event_id = CQ.event_id + GROUP BY E.person_id, E.event_id + HAVING COUNT(index_id) > 0 +) G +-- End Criteria Group +) AC on AC.person_id = pe.person_id AND AC.event_id = pe.event_id +) Results +; + +SELECT inclusion_rule_id, person_id, event_id +INTO #inclusion_events +FROM (select inclusion_rule_id, person_id, event_id from #Inclusion_0) I; +TRUNCATE TABLE #Inclusion_0; +DROP TABLE #Inclusion_0; + + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{1 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),1)-1) +} +) Results + +; + +-- date offset strategy + +select event_id, person_id, + case when DATEADD(day,730,end_date) > op_end_date then op_end_date else DATEADD(day,730,end_date) end as end_date +INTO #strategy_ends +from #included_events; + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- End Date Strategy +SELECT event_id, person_id, end_date from #strategy_ends + + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 1 != 0}?{ + +-- Create a temp table of inclusion rule rows for joining in the inclusion rule impact analysis + +select cast(rule_sequence as int) as rule_sequence +into #inclusion_rules +from ( + SELECT CAST(0 as int) as rule_sequence +) IR; + + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + +TRUNCATE TABLE #strategy_ends; +DROP TABLE #strategy_ends; + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1130.sql b/inst/sql/sql_server/1130.sql new file mode 100644 index 00000000..153adfc8 --- /dev/null +++ b/inst/sql/sql_server/1130.sql @@ -0,0 +1,423 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 0 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (37206719,4203096) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (37206719) + and c.invalid_reason is null + +) I +) C UNION ALL +SELECT 1 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (40482871) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (40482871) + and c.invalid_reason is null + +) I +) C UNION ALL +SELECT 2 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4104316) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4104316) + and c.invalid_reason is null + +) I +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) +) C + + +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P + +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +select 0 as inclusion_rule_id, person_id, event_id +INTO #Inclusion_0 +FROM +( + select pe.person_id, pe.event_id + FROM #qualified_events pe + +JOIN ( +-- Begin Criteria Group +select 0 as index_id, person_id, event_id +FROM +( + select E.person_id, E.event_id + FROM #qualified_events E + INNER JOIN + ( + -- Begin Correlated Criteria +select 0 as index_id, cc.person_id, cc.event_id +from (SELECT p.person_id, p.event_id +FROM #qualified_events P +JOIN ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 1) +) C + + +-- End Condition Occurrence Criteria + +) A on A.person_id = P.person_id AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= P.OP_END_DATE AND A.START_DATE >= DATEADD(day,0,P.START_DATE) AND A.START_DATE <= DATEADD(day,30,P.START_DATE) ) cc +GROUP BY cc.person_id, cc.event_id +HAVING COUNT(cc.event_id) >= 1 +-- End Correlated Criteria + +UNION ALL +-- Begin Correlated Criteria +select 1 as index_id, cc.person_id, cc.event_id +from (SELECT p.person_id, p.event_id +FROM #qualified_events P +JOIN ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 2) +) C + + +-- End Condition Occurrence Criteria + +) A on A.person_id = P.person_id AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= P.OP_END_DATE AND A.START_DATE >= DATEADD(day,0,P.START_DATE) AND A.START_DATE <= DATEADD(day,0,P.START_DATE) ) cc +GROUP BY cc.person_id, cc.event_id +HAVING COUNT(cc.event_id) >= 1 +-- End Correlated Criteria + + ) CQ on E.person_id = CQ.person_id and E.event_id = CQ.event_id + GROUP BY E.person_id, E.event_id + HAVING COUNT(index_id) > 0 +) G +-- End Criteria Group +) AC on AC.person_id = pe.person_id AND AC.event_id = pe.event_id +) Results +; + +SELECT inclusion_rule_id, person_id, event_id +INTO #inclusion_events +FROM (select inclusion_rule_id, person_id, event_id from #Inclusion_0) I; +TRUNCATE TABLE #Inclusion_0; +DROP TABLE #Inclusion_0; + + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{1 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),1)-1) +} +) Results + +; + +-- date offset strategy + +select event_id, person_id, + case when DATEADD(day,730,end_date) > op_end_date then op_end_date else DATEADD(day,730,end_date) end as end_date +INTO #strategy_ends +from #included_events; + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- End Date Strategy +SELECT event_id, person_id, end_date from #strategy_ends + + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 1 != 0}?{ + +-- Create a temp table of inclusion rule rows for joining in the inclusion rule impact analysis + +select cast(rule_sequence as int) as rule_sequence +into #inclusion_rules +from ( + SELECT CAST(0 as int) as rule_sequence +) IR; + + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + +TRUNCATE TABLE #strategy_ends; +DROP TABLE #strategy_ends; + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1131.sql b/inst/sql/sql_server/1131.sql new file mode 100644 index 00000000..6374bd96 --- /dev/null +++ b/inst/sql/sql_server/1131.sql @@ -0,0 +1,331 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 0 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4203096) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4203096) + and c.invalid_reason is null + +) I +LEFT JOIN +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4006969,261880,4197819,4324261,257010,46269691) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4006969,261880,4197819,4324261,257010,46269691) + and c.invalid_reason is null + +) E ON I.concept_id = E.concept_id +WHERE E.concept_id is null +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) +) C + + +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P + +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +create table #inclusion_events (inclusion_rule_id bigint, + person_id bigint, + event_id bigint +); + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{0 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),0)-1) +} +) Results + +; + +-- date offset strategy + +select event_id, person_id, + case when DATEADD(day,730,end_date) > op_end_date then op_end_date else DATEADD(day,730,end_date) end as end_date +INTO #strategy_ends +from #included_events; + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- End Date Strategy +SELECT event_id, person_id, end_date from #strategy_ends + + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 0 != 0}?{ + +CREATE TABLE #inclusion_rules (rule_sequence int); + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + +TRUNCATE TABLE #strategy_ends; +DROP TABLE #strategy_ends; + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1132.sql b/inst/sql/sql_server/1132.sql new file mode 100644 index 00000000..a4336cd0 --- /dev/null +++ b/inst/sql/sql_server/1132.sql @@ -0,0 +1,331 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 0 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4116778) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4116778) + and c.invalid_reason is null + +) I +LEFT JOIN +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4006969,261880,4197819,4324261,257010,46269691) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4006969,261880,4197819,4324261,257010,46269691) + and c.invalid_reason is null + +) E ON I.concept_id = E.concept_id +WHERE E.concept_id is null +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) +) C + + +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P + +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +create table #inclusion_events (inclusion_rule_id bigint, + person_id bigint, + event_id bigint +); + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{0 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),0)-1) +} +) Results + +; + +-- date offset strategy + +select event_id, person_id, + case when DATEADD(day,730,end_date) > op_end_date then op_end_date else DATEADD(day,730,end_date) end as end_date +INTO #strategy_ends +from #included_events; + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- End Date Strategy +SELECT event_id, person_id, end_date from #strategy_ends + + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 0 != 0}?{ + +CREATE TABLE #inclusion_rules (rule_sequence int); + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + +TRUNCATE TABLE #strategy_ends; +DROP TABLE #strategy_ends; + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1133.sql b/inst/sql/sql_server/1133.sql new file mode 100644 index 00000000..920eb72c --- /dev/null +++ b/inst/sql/sql_server/1133.sql @@ -0,0 +1,331 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 0 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (36684857,443388,255507,36530069,4311499,45890780,443399,4115276) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (36684857,443388,255507,36530069,4311499,45890780,443399,4115276) + and c.invalid_reason is null + +) I +LEFT JOIN +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (252840,254591,4177112,254583,432571,36712771,4147164,434300,4110591) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (252840,254591,4177112,254583,432571,36712771,4147164,434300,4110591) + and c.invalid_reason is null + +) E ON I.concept_id = E.concept_id +WHERE E.concept_id is null +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) +) C + + +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P + +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +create table #inclusion_events (inclusion_rule_id bigint, + person_id bigint, + event_id bigint +); + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{0 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),0)-1) +} +) Results + +; + +-- date offset strategy + +select event_id, person_id, + case when DATEADD(day,730,end_date) > op_end_date then op_end_date else DATEADD(day,730,end_date) end as end_date +INTO #strategy_ends +from #included_events; + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- End Date Strategy +SELECT event_id, person_id, end_date from #strategy_ends + + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 0 != 0}?{ + +CREATE TABLE #inclusion_rules (rule_sequence int); + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + +TRUNCATE TABLE #strategy_ends; +DROP TABLE #strategy_ends; + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1134.sql b/inst/sql/sql_server/1134.sql new file mode 100644 index 00000000..77b32f40 --- /dev/null +++ b/inst/sql/sql_server/1134.sql @@ -0,0 +1,331 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 0 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (36684857,443388,255507,36530069,4311499,45890780,443399) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (36684857,443388,255507,36530069,4311499,45890780,443399) + and c.invalid_reason is null + +) I +LEFT JOIN +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (252840,254591,4177112,254583,432571,4147164,434300) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (252840,254591,4177112,254583,432571,4147164,434300) + and c.invalid_reason is null + +) E ON I.concept_id = E.concept_id +WHERE E.concept_id is null +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) +) C + + +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P + +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +create table #inclusion_events (inclusion_rule_id bigint, + person_id bigint, + event_id bigint +); + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{0 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),0)-1) +} +) Results + +; + +-- date offset strategy + +select event_id, person_id, + case when DATEADD(day,180,end_date) > op_end_date then op_end_date else DATEADD(day,180,end_date) end as end_date +INTO #strategy_ends +from #included_events; + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- End Date Strategy +SELECT event_id, person_id, end_date from #strategy_ends + + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 0 != 0}?{ + +CREATE TABLE #inclusion_rules (rule_sequence int); + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + +TRUNCATE TABLE #strategy_ends; +DROP TABLE #strategy_ends; + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1135.sql b/inst/sql/sql_server/1135.sql new file mode 100644 index 00000000..70699b51 --- /dev/null +++ b/inst/sql/sql_server/1135.sql @@ -0,0 +1,326 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 0 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (36712771) + +) I +LEFT JOIN +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (254591,252840,200962,4110591) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (254591,252840,200962,4110591) + and c.invalid_reason is null + +) E ON I.concept_id = E.concept_id +WHERE E.concept_id is null +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) +) C + + +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P + +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +create table #inclusion_events (inclusion_rule_id bigint, + person_id bigint, + event_id bigint +); + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{0 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),0)-1) +} +) Results + +; + +-- date offset strategy + +select event_id, person_id, + case when DATEADD(day,180,end_date) > op_end_date then op_end_date else DATEADD(day,180,end_date) end as end_date +INTO #strategy_ends +from #included_events; + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- End Date Strategy +SELECT event_id, person_id, end_date from #strategy_ends + + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 0 != 0}?{ + +CREATE TABLE #inclusion_rules (rule_sequence int); + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + +TRUNCATE TABLE #strategy_ends; +DROP TABLE #strategy_ends; + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1136.sql b/inst/sql/sql_server/1136.sql new file mode 100644 index 00000000..9181b9ea --- /dev/null +++ b/inst/sql/sql_server/1136.sql @@ -0,0 +1,331 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 0 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (36684857,45890780,4115276) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (36684857,45890780,4115276) + and c.invalid_reason is null + +) I +LEFT JOIN +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4177112,254583,4147164) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4177112,254583,4147164) + and c.invalid_reason is null + +) E ON I.concept_id = E.concept_id +WHERE E.concept_id is null +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) +) C + + +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P + +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +create table #inclusion_events (inclusion_rule_id bigint, + person_id bigint, + event_id bigint +); + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{0 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),0)-1) +} +) Results + +; + +-- date offset strategy + +select event_id, person_id, + case when DATEADD(day,180,end_date) > op_end_date then op_end_date else DATEADD(day,180,end_date) end as end_date +INTO #strategy_ends +from #included_events; + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- End Date Strategy +SELECT event_id, person_id, end_date from #strategy_ends + + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 0 != 0}?{ + +CREATE TABLE #inclusion_rules (rule_sequence int); + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + +TRUNCATE TABLE #strategy_ends; +DROP TABLE #strategy_ends; + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1137.sql b/inst/sql/sql_server/1137.sql new file mode 100644 index 00000000..c00705e6 --- /dev/null +++ b/inst/sql/sql_server/1137.sql @@ -0,0 +1,320 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 0 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4177176) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4177176) + and c.invalid_reason is null + +) I +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) +) C + + +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P + +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +create table #inclusion_events (inclusion_rule_id bigint, + person_id bigint, + event_id bigint +); + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{0 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),0)-1) +} +) Results + +; + +-- date offset strategy + +select event_id, person_id, + case when DATEADD(day,14,end_date) > op_end_date then op_end_date else DATEADD(day,14,end_date) end as end_date +INTO #strategy_ends +from #included_events; + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- End Date Strategy +SELECT event_id, person_id, end_date from #strategy_ends + + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 0 != 0}?{ + +CREATE TABLE #inclusion_rules (rule_sequence int); + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + +TRUNCATE TABLE #strategy_ends; +DROP TABLE #strategy_ends; + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1138.sql b/inst/sql/sql_server/1138.sql new file mode 100644 index 00000000..b3d9c1f0 --- /dev/null +++ b/inst/sql/sql_server/1138.sql @@ -0,0 +1,429 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 0 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4129418) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4129418) + and c.invalid_reason is null + +) I +) C UNION ALL +SELECT 1 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4042505) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4042505) + and c.invalid_reason is null + +) I +) C UNION ALL +SELECT 2 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4132926) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4132926) + and c.invalid_reason is null + +) I +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) +) C + + +-- End Condition Occurrence Criteria + +UNION ALL +select PE.person_id, PE.event_id, PE.start_date, PE.end_date, PE.visit_occurrence_id, PE.sort_date FROM ( +-- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 1) +) C + + +-- End Condition Occurrence Criteria + +) PE +JOIN ( +-- Begin Criteria Group +select 0 as index_id, person_id, event_id +FROM +( + select E.person_id, E.event_id + FROM (SELECT Q.person_id, Q.event_id, Q.start_date, Q.end_date, Q.visit_occurrence_id, OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date +FROM (-- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 1) +) C + + +-- End Condition Occurrence Criteria +) Q +JOIN @cdm_database_schema.OBSERVATION_PERIOD OP on Q.person_id = OP.person_id + and OP.observation_period_start_date <= Q.start_date and OP.observation_period_end_date >= Q.start_date +) E + INNER JOIN + ( + -- Begin Correlated Criteria +select 0 as index_id, cc.person_id, cc.event_id +from (SELECT p.person_id, p.event_id +FROM (SELECT Q.person_id, Q.event_id, Q.start_date, Q.end_date, Q.visit_occurrence_id, OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date +FROM (-- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 1) +) C + + +-- End Condition Occurrence Criteria +) Q +JOIN @cdm_database_schema.OBSERVATION_PERIOD OP on Q.person_id = OP.person_id + and OP.observation_period_start_date <= Q.start_date and OP.observation_period_end_date >= Q.start_date +) P +JOIN ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 2) +) C + + +-- End Condition Occurrence Criteria + +) A on A.person_id = P.person_id AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= P.OP_END_DATE AND A.START_DATE >= DATEADD(day,0,P.START_DATE) AND A.START_DATE <= DATEADD(day,0,P.START_DATE) ) cc +GROUP BY cc.person_id, cc.event_id +HAVING COUNT(cc.event_id) >= 1 +-- End Correlated Criteria + + ) CQ on E.person_id = CQ.person_id and E.event_id = CQ.event_id + GROUP BY E.person_id, E.event_id + HAVING COUNT(index_id) = 1 +) G +-- End Criteria Group +) AC on AC.person_id = pe.person_id and AC.event_id = pe.event_id + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P + +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +create table #inclusion_events (inclusion_rule_id bigint, + person_id bigint, + event_id bigint +); + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{0 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),0)-1) +} +) Results + +; + +-- date offset strategy + +select event_id, person_id, + case when DATEADD(day,14,end_date) > op_end_date then op_end_date else DATEADD(day,14,end_date) end as end_date +INTO #strategy_ends +from #included_events; + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- End Date Strategy +SELECT event_id, person_id, end_date from #strategy_ends + + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 0 != 0}?{ + +CREATE TABLE #inclusion_rules (rule_sequence int); + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + +TRUNCATE TABLE #strategy_ends; +DROP TABLE #strategy_ends; + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1139.sql b/inst/sql/sql_server/1139.sql new file mode 100644 index 00000000..46320631 --- /dev/null +++ b/inst/sql/sql_server/1139.sql @@ -0,0 +1,320 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 0 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4229881) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4229881) + and c.invalid_reason is null + +) I +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) +) C + + +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P + +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +create table #inclusion_events (inclusion_rule_id bigint, + person_id bigint, + event_id bigint +); + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{0 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),0)-1) +} +) Results + +; + +-- date offset strategy + +select event_id, person_id, + case when DATEADD(day,14,end_date) > op_end_date then op_end_date else DATEADD(day,14,end_date) end as end_date +INTO #strategy_ends +from #included_events; + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- End Date Strategy +SELECT event_id, person_id, end_date from #strategy_ends + + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 0 != 0}?{ + +CREATE TABLE #inclusion_rules (rule_sequence int); + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + +TRUNCATE TABLE #strategy_ends; +DROP TABLE #strategy_ends; + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1216.sql b/inst/sql/sql_server/1216.sql new file mode 100644 index 00000000..d47ade5f --- /dev/null +++ b/inst/sql/sql_server/1216.sql @@ -0,0 +1,638 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 2 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4157333,4128888,443388,4311499) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4157333,4128888,443388) + and c.invalid_reason is null + +) I +LEFT JOIN +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (36617886,254591,4248073,4242353,46270492,254583,4174275) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (36617886,254591,4248073,4242353,46270492,254583,4174275) + and c.invalid_reason is null + +) E ON I.concept_id = E.concept_id +WHERE E.concept_id is null +) C UNION ALL +SELECT 3 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (36850058,19015523,1344354,19078187,1146139,1336539,1341149,1378509,1503501) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (36850058,19015523,1344354,19078187,1146139,1336539,1341149,1378509,1503501) + and c.invalid_reason is null + +) I +) C UNION ALL +SELECT 4 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4110591) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4110591) + and c.invalid_reason is null + +) I +) C UNION ALL +SELECT 5 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (2618003,2618004,2618002) + +) I +) C UNION ALL +SELECT 6 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (40493020) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (40493020) + and c.invalid_reason is null + +) I +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 2) +) C + + +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P + +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +select 0 as inclusion_rule_id, person_id, event_id +INTO #Inclusion_0 +FROM +( + select pe.person_id, pe.event_id + FROM #qualified_events pe + +JOIN ( +-- Begin Criteria Group +select 0 as index_id, person_id, event_id +FROM +( + select E.person_id, E.event_id + FROM #qualified_events E + INNER JOIN + ( + -- Begin Correlated Criteria +select 0 as index_id, cc.person_id, cc.event_id +from (SELECT p.person_id, p.event_id +FROM #qualified_events P +JOIN ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 2) +) C + + +-- End Condition Occurrence Criteria + +) A on A.person_id = P.person_id AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= P.OP_END_DATE AND A.START_DATE >= DATEADD(day,1,P.START_DATE) AND A.START_DATE <= DATEADD(day,365,P.START_DATE) ) cc +GROUP BY cc.person_id, cc.event_id +HAVING COUNT(cc.event_id) >= 1 +-- End Correlated Criteria + + ) CQ on E.person_id = CQ.person_id and E.event_id = CQ.event_id + GROUP BY E.person_id, E.event_id + HAVING COUNT(index_id) = 1 +) G +-- End Criteria Group +) AC on AC.person_id = pe.person_id AND AC.event_id = pe.event_id +) Results +; + +select 1 as inclusion_rule_id, person_id, event_id +INTO #Inclusion_1 +FROM +( + select pe.person_id, pe.event_id + FROM #qualified_events pe + +JOIN ( +-- Begin Criteria Group +select 0 as index_id, person_id, event_id +FROM +( + select E.person_id, E.event_id + FROM #qualified_events E + INNER JOIN + ( + -- Begin Correlated Criteria +select 0 as index_id, p.person_id, p.event_id +from #qualified_events p +LEFT JOIN ( +SELECT p.person_id, p.event_id +FROM #qualified_events P +JOIN ( + -- Begin Drug Exposure Criteria +select C.person_id, C.drug_exposure_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id,C.start_date as sort_date +from +( + select de.person_id,de.drug_exposure_id,de.drug_concept_id,de.visit_occurrence_id,days_supply,quantity,refills,de.drug_exposure_start_date as start_date, COALESCE(de.drug_exposure_end_date, DATEADD(day,de.days_supply,de.drug_exposure_start_date), DATEADD(day,1,de.drug_exposure_start_date)) as end_date + FROM @cdm_database_schema.DRUG_EXPOSURE de +JOIN #Codesets cs on (de.drug_concept_id = cs.concept_id and cs.codeset_id = 3) +) C + + +-- End Drug Exposure Criteria + +) A on A.person_id = P.person_id AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= P.OP_END_DATE AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= DATEADD(day,365,P.START_DATE) ) cc on p.person_id = cc.person_id and p.event_id = cc.event_id +GROUP BY p.person_id, p.event_id +HAVING COUNT(cc.event_id) <= 0 +-- End Correlated Criteria + + ) CQ on E.person_id = CQ.person_id and E.event_id = CQ.event_id + GROUP BY E.person_id, E.event_id + HAVING COUNT(index_id) = 1 +) G +-- End Criteria Group +) AC on AC.person_id = pe.person_id AND AC.event_id = pe.event_id +) Results +; + +select 2 as inclusion_rule_id, person_id, event_id +INTO #Inclusion_2 +FROM +( + select pe.person_id, pe.event_id + FROM #qualified_events pe + +JOIN ( +-- Begin Criteria Group +select 0 as index_id, person_id, event_id +FROM +( + select E.person_id, E.event_id + FROM #qualified_events E + INNER JOIN + ( + -- Begin Correlated Criteria +select 0 as index_id, p.person_id, p.event_id +from #qualified_events p +LEFT JOIN ( +SELECT p.person_id, p.event_id +FROM #qualified_events P +JOIN ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 4) +) C + + +-- End Condition Occurrence Criteria + +) A on A.person_id = P.person_id AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= P.OP_END_DATE AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= DATEADD(day,365,P.START_DATE) ) cc on p.person_id = cc.person_id and p.event_id = cc.event_id +GROUP BY p.person_id, p.event_id +HAVING COUNT(cc.event_id) <= 0 +-- End Correlated Criteria + + ) CQ on E.person_id = CQ.person_id and E.event_id = CQ.event_id + GROUP BY E.person_id, E.event_id + HAVING COUNT(index_id) = 1 +) G +-- End Criteria Group +) AC on AC.person_id = pe.person_id AND AC.event_id = pe.event_id +) Results +; + +select 3 as inclusion_rule_id, person_id, event_id +INTO #Inclusion_3 +FROM +( + select pe.person_id, pe.event_id + FROM #qualified_events pe + +JOIN ( +-- Begin Criteria Group +select 0 as index_id, person_id, event_id +FROM +( + select E.person_id, E.event_id + FROM #qualified_events E + INNER JOIN + ( + -- Begin Correlated Criteria +select 0 as index_id, p.person_id, p.event_id +from #qualified_events p +LEFT JOIN ( +SELECT p.person_id, p.event_id +FROM #qualified_events P +JOIN ( + -- Begin Observation Criteria +select C.person_id, C.observation_id as event_id, C.start_date, C.END_DATE, + C.visit_occurrence_id, C.start_date as sort_date +from +( + select o.person_id,o.observation_id,o.observation_concept_id,o.visit_occurrence_id,o.value_as_number,o.observation_date as start_date, DATEADD(day,1,o.observation_date) as end_date + FROM @cdm_database_schema.OBSERVATION o +JOIN #Codesets cs on (o.observation_concept_id = cs.concept_id and cs.codeset_id = 5) +) C + + +-- End Observation Criteria + +) A on A.person_id = P.person_id AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= P.OP_END_DATE AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= DATEADD(day,365,P.START_DATE) ) cc on p.person_id = cc.person_id and p.event_id = cc.event_id +GROUP BY p.person_id, p.event_id +HAVING COUNT(cc.event_id) <= 0 +-- End Correlated Criteria + + ) CQ on E.person_id = CQ.person_id and E.event_id = CQ.event_id + GROUP BY E.person_id, E.event_id + HAVING COUNT(index_id) = 1 +) G +-- End Criteria Group +) AC on AC.person_id = pe.person_id AND AC.event_id = pe.event_id +) Results +; + +select 4 as inclusion_rule_id, person_id, event_id +INTO #Inclusion_4 +FROM +( + select pe.person_id, pe.event_id + FROM #qualified_events pe + +JOIN ( +-- Begin Criteria Group +select 0 as index_id, person_id, event_id +FROM +( + select E.person_id, E.event_id + FROM #qualified_events E + INNER JOIN + ( + -- Begin Correlated Criteria +select 0 as index_id, p.person_id, p.event_id +from #qualified_events p +LEFT JOIN ( +SELECT p.person_id, p.event_id +FROM #qualified_events P +JOIN ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 6) +) C + + +-- End Condition Occurrence Criteria + +) A on A.person_id = P.person_id AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= P.OP_END_DATE AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= DATEADD(day,365,P.START_DATE) ) cc on p.person_id = cc.person_id and p.event_id = cc.event_id +GROUP BY p.person_id, p.event_id +HAVING COUNT(cc.event_id) = 0 +-- End Correlated Criteria + + ) CQ on E.person_id = CQ.person_id and E.event_id = CQ.event_id + GROUP BY E.person_id, E.event_id + HAVING COUNT(index_id) = 1 +) G +-- End Criteria Group +) AC on AC.person_id = pe.person_id AND AC.event_id = pe.event_id +) Results +; + +SELECT inclusion_rule_id, person_id, event_id +INTO #inclusion_events +FROM (select inclusion_rule_id, person_id, event_id from #Inclusion_0 +UNION ALL +select inclusion_rule_id, person_id, event_id from #Inclusion_1 +UNION ALL +select inclusion_rule_id, person_id, event_id from #Inclusion_2 +UNION ALL +select inclusion_rule_id, person_id, event_id from #Inclusion_3 +UNION ALL +select inclusion_rule_id, person_id, event_id from #Inclusion_4) I; +TRUNCATE TABLE #Inclusion_0; +DROP TABLE #Inclusion_0; + +TRUNCATE TABLE #Inclusion_1; +DROP TABLE #Inclusion_1; + +TRUNCATE TABLE #Inclusion_2; +DROP TABLE #Inclusion_2; + +TRUNCATE TABLE #Inclusion_3; +DROP TABLE #Inclusion_3; + +TRUNCATE TABLE #Inclusion_4; +DROP TABLE #Inclusion_4; + + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{5 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),5)-1) +} +) Results +WHERE Results.ordinal = 1 +; + + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- By default, cohort exit at the event's op end date +select event_id, person_id, op_end_date as end_date from #included_events + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 5 != 0}?{ + +-- Create a temp table of inclusion rule rows for joining in the inclusion rule impact analysis + +select cast(rule_sequence as int) as rule_sequence +into #inclusion_rules +from ( + SELECT CAST(0 as int) as rule_sequence UNION ALL SELECT CAST(1 as int) as rule_sequence UNION ALL SELECT CAST(2 as int) as rule_sequence UNION ALL SELECT CAST(3 as int) as rule_sequence UNION ALL SELECT CAST(4 as int) as rule_sequence +) IR; + + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/1217.sql b/inst/sql/sql_server/1217.sql new file mode 100644 index 00000000..b0d64cf3 --- /dev/null +++ b/inst/sql/sql_server/1217.sql @@ -0,0 +1,585 @@ +CREATE TABLE #Codesets ( + codeset_id int NOT NULL, + concept_id bigint NOT NULL +) +; + +INSERT INTO #Codesets (codeset_id, concept_id) +SELECT 2 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4157333,4128888,443388,4311499) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4157333,4128888,443388) + and c.invalid_reason is null + +) I +LEFT JOIN +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (254591,4248073,4242353,46270492,254583,4174275) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (254591,4248073,4242353,46270492,254583,4174275) + and c.invalid_reason is null + +) E ON I.concept_id = E.concept_id +WHERE E.concept_id is null +) C UNION ALL +SELECT 3 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (36850058,19015523,1344354,19078187,1146139,1336539,1341149,1378509,1503501) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (36850058,19015523,1344354,19078187,1146139,1336539,1341149,1378509,1503501) + and c.invalid_reason is null + +) I +) C UNION ALL +SELECT 4 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (4110591) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (4110591) + and c.invalid_reason is null + +) I +) C UNION ALL +SELECT 5 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (2618003,2618004,2618002) + +) I +) C UNION ALL +SELECT 6 as codeset_id, c.concept_id FROM (select distinct I.concept_id FROM +( + select concept_id from @vocabulary_database_schema.CONCEPT where concept_id in (40493020) +UNION select c.concept_id + from @vocabulary_database_schema.CONCEPT c + join @vocabulary_database_schema.CONCEPT_ANCESTOR ca on c.concept_id = ca.descendant_concept_id + and ca.ancestor_concept_id in (40493020) + and c.invalid_reason is null + +) I +) C; + +UPDATE STATISTICS #Codesets; + + +SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, visit_occurrence_id +INTO #qualified_events +FROM +( + select pe.event_id, pe.person_id, pe.start_date, pe.end_date, pe.op_start_date, pe.op_end_date, row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal, cast(pe.visit_occurrence_id as bigint) as visit_occurrence_id + FROM (-- Begin Primary Events +select P.ordinal as event_id, P.person_id, P.start_date, P.end_date, op_start_date, op_end_date, cast(P.visit_occurrence_id as bigint) as visit_occurrence_id +FROM +( + select E.person_id, E.start_date, E.end_date, + row_number() OVER (PARTITION BY E.person_id ORDER BY E.sort_date ASC, E.event_id) ordinal, + OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id + FROM + ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date , row_number() over (PARTITION BY co.person_id ORDER BY co.condition_start_date, co.condition_occurrence_id) as ordinal + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 2) +) C + +WHERE C.ordinal = 1 +-- End Condition Occurrence Criteria + + ) E + JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date + WHERE DATEADD(day,0,OP.OBSERVATION_PERIOD_START_DATE) <= E.START_DATE AND DATEADD(day,0,E.START_DATE) <= OP.OBSERVATION_PERIOD_END_DATE +) P +WHERE P.ordinal = 1 +-- End Primary Events +) pe + +) QE + +; + +--- Inclusion Rule Inserts + +select 0 as inclusion_rule_id, person_id, event_id +INTO #Inclusion_0 +FROM +( + select pe.person_id, pe.event_id + FROM #qualified_events pe + +JOIN ( +-- Begin Criteria Group +select 0 as index_id, person_id, event_id +FROM +( + select E.person_id, E.event_id + FROM #qualified_events E + INNER JOIN + ( + -- Begin Correlated Criteria +select 0 as index_id, p.person_id, p.event_id +from #qualified_events p +LEFT JOIN ( +SELECT p.person_id, p.event_id +FROM #qualified_events P +JOIN ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 6) +) C + + +-- End Condition Occurrence Criteria + +) A on A.person_id = P.person_id AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= P.OP_END_DATE AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= DATEADD(day,365,P.START_DATE) ) cc on p.person_id = cc.person_id and p.event_id = cc.event_id +GROUP BY p.person_id, p.event_id +HAVING COUNT(cc.event_id) <= 0 +-- End Correlated Criteria + + ) CQ on E.person_id = CQ.person_id and E.event_id = CQ.event_id + GROUP BY E.person_id, E.event_id + HAVING COUNT(index_id) = 1 +) G +-- End Criteria Group +) AC on AC.person_id = pe.person_id AND AC.event_id = pe.event_id +) Results +; + +select 1 as inclusion_rule_id, person_id, event_id +INTO #Inclusion_1 +FROM +( + select pe.person_id, pe.event_id + FROM #qualified_events pe + +JOIN ( +-- Begin Criteria Group +select 0 as index_id, person_id, event_id +FROM +( + select E.person_id, E.event_id + FROM #qualified_events E + INNER JOIN + ( + -- Begin Correlated Criteria +select 0 as index_id, p.person_id, p.event_id +from #qualified_events p +LEFT JOIN ( +SELECT p.person_id, p.event_id +FROM #qualified_events P +JOIN ( + -- Begin Drug Exposure Criteria +select C.person_id, C.drug_exposure_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id,C.start_date as sort_date +from +( + select de.person_id,de.drug_exposure_id,de.drug_concept_id,de.visit_occurrence_id,days_supply,quantity,refills,de.drug_exposure_start_date as start_date, COALESCE(de.drug_exposure_end_date, DATEADD(day,de.days_supply,de.drug_exposure_start_date), DATEADD(day,1,de.drug_exposure_start_date)) as end_date + FROM @cdm_database_schema.DRUG_EXPOSURE de +JOIN #Codesets cs on (de.drug_concept_id = cs.concept_id and cs.codeset_id = 3) +) C + + +-- End Drug Exposure Criteria + +) A on A.person_id = P.person_id AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= P.OP_END_DATE AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= DATEADD(day,365,P.START_DATE) ) cc on p.person_id = cc.person_id and p.event_id = cc.event_id +GROUP BY p.person_id, p.event_id +HAVING COUNT(cc.event_id) <= 0 +-- End Correlated Criteria + + ) CQ on E.person_id = CQ.person_id and E.event_id = CQ.event_id + GROUP BY E.person_id, E.event_id + HAVING COUNT(index_id) = 1 +) G +-- End Criteria Group +) AC on AC.person_id = pe.person_id AND AC.event_id = pe.event_id +) Results +; + +select 2 as inclusion_rule_id, person_id, event_id +INTO #Inclusion_2 +FROM +( + select pe.person_id, pe.event_id + FROM #qualified_events pe + +JOIN ( +-- Begin Criteria Group +select 0 as index_id, person_id, event_id +FROM +( + select E.person_id, E.event_id + FROM #qualified_events E + INNER JOIN + ( + -- Begin Correlated Criteria +select 0 as index_id, p.person_id, p.event_id +from #qualified_events p +LEFT JOIN ( +SELECT p.person_id, p.event_id +FROM #qualified_events P +JOIN ( + -- Begin Condition Occurrence Criteria +SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id, C.start_date as sort_date +FROM +( + SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date + FROM @cdm_database_schema.CONDITION_OCCURRENCE co + JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 4) +) C + + +-- End Condition Occurrence Criteria + +) A on A.person_id = P.person_id AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= P.OP_END_DATE AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= DATEADD(day,365,P.START_DATE) ) cc on p.person_id = cc.person_id and p.event_id = cc.event_id +GROUP BY p.person_id, p.event_id +HAVING COUNT(cc.event_id) <= 0 +-- End Correlated Criteria + + ) CQ on E.person_id = CQ.person_id and E.event_id = CQ.event_id + GROUP BY E.person_id, E.event_id + HAVING COUNT(index_id) = 1 +) G +-- End Criteria Group +) AC on AC.person_id = pe.person_id AND AC.event_id = pe.event_id +) Results +; + +select 3 as inclusion_rule_id, person_id, event_id +INTO #Inclusion_3 +FROM +( + select pe.person_id, pe.event_id + FROM #qualified_events pe + +JOIN ( +-- Begin Criteria Group +select 0 as index_id, person_id, event_id +FROM +( + select E.person_id, E.event_id + FROM #qualified_events E + INNER JOIN + ( + -- Begin Correlated Criteria +select 0 as index_id, p.person_id, p.event_id +from #qualified_events p +LEFT JOIN ( +SELECT p.person_id, p.event_id +FROM #qualified_events P +JOIN ( + -- Begin Observation Criteria +select C.person_id, C.observation_id as event_id, C.start_date, C.END_DATE, + C.visit_occurrence_id, C.start_date as sort_date +from +( + select o.person_id,o.observation_id,o.observation_concept_id,o.visit_occurrence_id,o.value_as_number,o.observation_date as start_date, DATEADD(day,1,o.observation_date) as end_date + FROM @cdm_database_schema.OBSERVATION o +JOIN #Codesets cs on (o.observation_concept_id = cs.concept_id and cs.codeset_id = 5) +) C + + +-- End Observation Criteria + +) A on A.person_id = P.person_id AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= P.OP_END_DATE AND A.START_DATE >= P.OP_START_DATE AND A.START_DATE <= DATEADD(day,365,P.START_DATE) ) cc on p.person_id = cc.person_id and p.event_id = cc.event_id +GROUP BY p.person_id, p.event_id +HAVING COUNT(cc.event_id) <= 0 +-- End Correlated Criteria + + ) CQ on E.person_id = CQ.person_id and E.event_id = CQ.event_id + GROUP BY E.person_id, E.event_id + HAVING COUNT(index_id) = 1 +) G +-- End Criteria Group +) AC on AC.person_id = pe.person_id AND AC.event_id = pe.event_id +) Results +; + +SELECT inclusion_rule_id, person_id, event_id +INTO #inclusion_events +FROM (select inclusion_rule_id, person_id, event_id from #Inclusion_0 +UNION ALL +select inclusion_rule_id, person_id, event_id from #Inclusion_1 +UNION ALL +select inclusion_rule_id, person_id, event_id from #Inclusion_2 +UNION ALL +select inclusion_rule_id, person_id, event_id from #Inclusion_3) I; +TRUNCATE TABLE #Inclusion_0; +DROP TABLE #Inclusion_0; + +TRUNCATE TABLE #Inclusion_1; +DROP TABLE #Inclusion_1; + +TRUNCATE TABLE #Inclusion_2; +DROP TABLE #Inclusion_2; + +TRUNCATE TABLE #Inclusion_3; +DROP TABLE #Inclusion_3; + + +select event_id, person_id, start_date, end_date, op_start_date, op_end_date +into #included_events +FROM ( + SELECT event_id, person_id, start_date, end_date, op_start_date, op_end_date, row_number() over (partition by person_id order by start_date ASC) as ordinal + from + ( + select Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date, SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on I.person_id = Q.person_id and I.event_id = Q.event_id + GROUP BY Q.event_id, Q.person_id, Q.start_date, Q.end_date, Q.op_start_date, Q.op_end_date + ) MG -- matching groups +{4 != 0}?{ + -- the matching group with all bits set ( POWER(2,# of inclusion rules) - 1 = inclusion_rule_mask + WHERE (MG.inclusion_rule_mask = POWER(cast(2 as bigint),4)-1) +} +) Results +WHERE Results.ordinal = 1 +; + + + +-- generate cohort periods into #final_cohort +select person_id, start_date, end_date +INTO #cohort_rows +from ( -- first_ends + select F.person_id, F.start_date, F.end_date + FROM ( + select I.event_id, I.person_id, I.start_date, CE.end_date, row_number() over (partition by I.person_id, I.event_id order by CE.end_date) as ordinal + from #included_events I + join ( -- cohort_ends +-- cohort exit dates +-- By default, cohort exit at the event's op end date +select event_id, person_id, op_end_date as end_date from #included_events + ) CE on I.event_id = CE.event_id and I.person_id = CE.person_id and CE.end_date >= I.start_date + ) F + WHERE F.ordinal = 1 +) FE; + +select person_id, min(start_date) as start_date, end_date +into #final_cohort +from ( --cteEnds + SELECT + c.person_id + , c.start_date + , MIN(ed.end_date) AS end_date + FROM #cohort_rows c + JOIN ( -- cteEndDates + SELECT + person_id + , DATEADD(day,-1 * 0, event_date) as end_date + FROM + ( + SELECT + person_id + , event_date + , event_type + , SUM(event_type) OVER (PARTITION BY person_id ORDER BY event_date, event_type ROWS UNBOUNDED PRECEDING) AS interval_status + FROM + ( + SELECT + person_id + , start_date AS event_date + , -1 AS event_type + FROM #cohort_rows + + UNION ALL + + + SELECT + person_id + , DATEADD(day,0,end_date) as end_date + , 1 AS event_type + FROM #cohort_rows + ) RAWDATA + ) e + WHERE interval_status = 0 + ) ed ON c.person_id = ed.person_id AND ed.end_date >= c.start_date + GROUP BY c.person_id, c.start_date +) e +group by person_id, end_date +; + +DELETE FROM @target_database_schema.@target_cohort_table where cohort_definition_id = @target_cohort_id; +INSERT INTO @target_database_schema.@target_cohort_table (cohort_definition_id, subject_id, cohort_start_date, cohort_end_date) +select @target_cohort_id as cohort_definition_id, person_id, start_date, end_date +FROM #final_cohort CO +; + +{1 != 0}?{ +-- BEGIN: Censored Stats + +delete from @results_database_schema.cohort_censor_stats where cohort_definition_id = @target_cohort_id; + +-- END: Censored Stats +} +{1 != 0 & 4 != 0}?{ + +-- Create a temp table of inclusion rule rows for joining in the inclusion rule impact analysis + +select cast(rule_sequence as int) as rule_sequence +into #inclusion_rules +from ( + SELECT CAST(0 as int) as rule_sequence UNION ALL SELECT CAST(1 as int) as rule_sequence UNION ALL SELECT CAST(2 as int) as rule_sequence UNION ALL SELECT CAST(3 as int) as rule_sequence +) IR; + + +-- Find the event that is the 'best match' per person. +-- the 'best match' is defined as the event that satisfies the most inclusion rules. +-- ties are solved by choosing the event that matches the earliest inclusion rule, and then earliest. + +select q.person_id, q.event_id +into #best_events +from #qualified_events Q +join ( + SELECT R.person_id, R.event_id, ROW_NUMBER() OVER (PARTITION BY R.person_id ORDER BY R.rule_count DESC,R.min_rule_id ASC, R.start_date ASC) AS rank_value + FROM ( + SELECT Q.person_id, Q.event_id, COALESCE(COUNT(DISTINCT I.inclusion_rule_id), 0) AS rule_count, COALESCE(MIN(I.inclusion_rule_id), 0) AS min_rule_id, Q.start_date + FROM #qualified_events Q + LEFT JOIN #inclusion_events I ON q.person_id = i.person_id AND q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id, Q.start_date + ) R +) ranked on Q.person_id = ranked.person_id and Q.event_id = ranked.event_id +WHERE ranked.rank_value = 1 +; + +-- modes of generation: (the same tables store the results for the different modes, identified by the mode_id column) +-- 0: all events +-- 1: best event + + +-- BEGIN: Inclusion Impact Analysis - event +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 0 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #qualified_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 0 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #qualified_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #qualified_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 0 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 0; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 0 as mode_id +FROM +(select count_big(event_id) as total from #qualified_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 0 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - event + +-- BEGIN: Inclusion Impact Analysis - person +-- calculte matching group counts +delete from @results_database_schema.cohort_inclusion_result where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_result (cohort_definition_id, inclusion_rule_mask, person_count, mode_id) +select @target_cohort_id as cohort_definition_id, inclusion_rule_mask, count_big(*) as person_count, 1 as mode_id +from +( + select Q.person_id, Q.event_id, CAST(SUM(coalesce(POWER(cast(2 as bigint), I.inclusion_rule_id), 0)) AS bigint) as inclusion_rule_mask + from #best_events Q + LEFT JOIN #inclusion_events I on q.person_id = i.person_id and q.event_id = i.event_id + GROUP BY Q.person_id, Q.event_id +) MG -- matching groups +group by inclusion_rule_mask +; + +-- calculate gain counts +delete from @results_database_schema.cohort_inclusion_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_inclusion_stats (cohort_definition_id, rule_sequence, person_count, gain_count, person_total, mode_id) +select @target_cohort_id as cohort_definition_id, ir.rule_sequence, coalesce(T.person_count, 0) as person_count, coalesce(SR.person_count, 0) gain_count, EventTotal.total, 1 as mode_id +from #inclusion_rules ir +left join +( + select i.inclusion_rule_id, count_big(i.event_id) as person_count + from #best_events Q + JOIN #inclusion_events i on Q.person_id = I.person_id and Q.event_id = i.event_id + group by i.inclusion_rule_id +) T on ir.rule_sequence = T.inclusion_rule_id +CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal +CROSS JOIN (select count_big(event_id) as total from #best_events) EventTotal +LEFT JOIN @results_database_schema.cohort_inclusion_result SR on SR.mode_id = 1 AND SR.cohort_definition_id = @target_cohort_id AND (POWER(cast(2 as bigint),RuleTotal.total_rules) - POWER(cast(2 as bigint),ir.rule_sequence) - 1) = SR.inclusion_rule_mask -- POWER(2,rule count) - POWER(2,rule sequence) - 1 is the mask for 'all except this rule' +; + +-- calculate totals +delete from @results_database_schema.cohort_summary_stats where cohort_definition_id = @target_cohort_id and mode_id = 1; +insert into @results_database_schema.cohort_summary_stats (cohort_definition_id, base_count, final_count, mode_id) +select @target_cohort_id as cohort_definition_id, PC.total as person_count, coalesce(FC.total, 0) as final_count, 1 as mode_id +FROM +(select count_big(event_id) as total from #best_events) PC, +(select sum(sr.person_count) as total + from @results_database_schema.cohort_inclusion_result sr + CROSS JOIN (select count(*) as total_rules from #inclusion_rules) RuleTotal + where sr.mode_id = 1 and sr.cohort_definition_id = @target_cohort_id and sr.inclusion_rule_mask = POWER(cast(2 as bigint),RuleTotal.total_rules)-1 +) FC +; + +-- END: Inclusion Impact Analysis - person + +TRUNCATE TABLE #best_events; +DROP TABLE #best_events; + +TRUNCATE TABLE #inclusion_rules; +DROP TABLE #inclusion_rules; +} + + + +TRUNCATE TABLE #cohort_rows; +DROP TABLE #cohort_rows; + +TRUNCATE TABLE #final_cohort; +DROP TABLE #final_cohort; + +TRUNCATE TABLE #inclusion_events; +DROP TABLE #inclusion_events; + +TRUNCATE TABLE #qualified_events; +DROP TABLE #qualified_events; + +TRUNCATE TABLE #included_events; +DROP TABLE #included_events; + +TRUNCATE TABLE #Codesets; +DROP TABLE #Codesets; diff --git a/inst/sql/sql_server/762.sql b/inst/sql/sql_server/762.sql index 9d1d0661..d17ba81a 100644 --- a/inst/sql/sql_server/762.sql +++ b/inst/sql/sql_server/762.sql @@ -34,18 +34,18 @@ FROM OP.observation_period_start_date as op_start_date, OP.observation_period_end_date as op_end_date, cast(E.visit_occurrence_id as bigint) as visit_occurrence_id FROM ( - -- Begin Condition Occurrence Criteria -SELECT C.person_id, C.condition_occurrence_id as event_id, C.start_date, C.end_date, - C.visit_occurrence_id, C.start_date as sort_date -FROM + -- Begin Drug Exposure Criteria +select C.person_id, C.drug_exposure_id as event_id, C.start_date, C.end_date, + C.visit_occurrence_id,C.start_date as sort_date +from ( - SELECT co.person_id,co.condition_occurrence_id,co.condition_concept_id,co.visit_occurrence_id,co.condition_start_date as start_date, COALESCE(co.condition_end_date, DATEADD(day,1,co.condition_start_date)) as end_date - FROM @cdm_database_schema.CONDITION_OCCURRENCE co - JOIN #Codesets cs on (co.condition_concept_id = cs.concept_id and cs.codeset_id = 0) + select de.person_id,de.drug_exposure_id,de.drug_concept_id,de.visit_occurrence_id,days_supply,quantity,refills,de.drug_exposure_start_date as start_date, COALESCE(de.drug_exposure_end_date, DATEADD(day,de.days_supply,de.drug_exposure_start_date), DATEADD(day,1,de.drug_exposure_start_date)) as end_date + FROM @cdm_database_schema.DRUG_EXPOSURE de +JOIN #Codesets cs on (de.drug_concept_id = cs.concept_id and cs.codeset_id = 0) ) C --- End Condition Occurrence Criteria +-- End Drug Exposure Criteria ) E JOIN @cdm_database_schema.observation_period OP on E.person_id = OP.person_id and E.start_date >= OP.observation_period_start_date and E.start_date <= op.observation_period_end_date