/****************************************************************************************** Getting Messy with SQL Reporting: Preventive Breast Imaging RCHC Analytics Academy: 5/12/2022 Created by: Nicholas Alonzo (nicholas@diversifyds.org) Description: Hands-on code-along script to work with preventive breast imaging demo tables *******************************************************************************************/ -- STEP 1: Define the base population -- STEP 2: JOIN external breast imaging data with base population -- STEP 3: Match notes patterns with regular expressions and extract with SUBSTRING() /****************************************************************************************** | SUBSTRING(): Returns a matched pattern OR a captured group in matched pattern | |-----------------------------------------------------------------------------------------| | Characters | Description | |-------------|---------------------------------------------------------------------------| | . | any single character | | \d | Match a digit (0-9) | | \w | Match an alphanumeric (a-z, 0-9) character including _ | | \s | Match a space character | | \y | Match the beginning or end of a sequence of words or numbers | | | | Match the pattern on the left OR right | | ( ) | Group items into one logical unit or capture pattern to extract | | * | 0 or more matches of the previous item | | + | 1 or more matches of the previous item | | ? | 0 or 1 matches of the previous item | | {m} | Exactly m (number) matches of the previous item | | {m, } | Exactly m (number) matches or more of the previous item | | {m, n} | Exactly m (number) matches up to n (number) matches of the previous item | | ^ | Match at the beginning, used at the beginning of the pattern | | $ | Match at the end, used at the end of a pattern | ******************************************************************************************/ -- testing regular expressions with SUBSTRING() recap SELECT SUBSTRING('This is a date 4/12/2022', ''); SELECT SUBSTRING('This is another date 4/12/22', ''); -- STEP 4: Combine internal and external breast imaging data -- STEP 5: Final select statement -- STEP 6: What else is left to do?