Use this query to find all the patients that were diagnosed with migraines.
SELECT DISTINCT (PATIENT_NUM)
FROM OBSERVATION_FACT
WHERE CONCEPT_CD IN
(SELECT CONCEPT_CD
FROM CONCEPT_DIMENSION
WHERE CONCEPT_PATH LIKE '%Neurologic Disorders (320-389)(346) Migraine%'
)
Use this query to find the ages of all patients that were diagnosed with migraines.
SELECT CONCEPT_CD
FROM OBSERVATION_FACT
WHERE CONCEPT_CD LIKE 'DEM|Age%'
AND PATIENT_NUM IN
(SELECT PATIENT_NUM
FROM OBSERVATION_FACT
WHERE CONCEPT_CD IN
(SELECT CONCEPT_CD
FROM CONCEPT_DIMENSION
WHERE CONCEPT_PATH LIKE '%Neurologic Disorders (320-389)(346) Migraine%'
)
)