Moving this topic to its own thread (out of FOSS thread)
Is anyone having success with ChatGPT and OMOP?
I was impressed with the quality of code for questions such as:
Write a SQL query against the OHDSI CDM to build a cohort of patients with new onset diabetes
Write a SQL query against the OHDSI CDM to calculate the numerator and denominator for the HEDIS measure for Comprehensive Diabetes Care
In general, the SQL was completely accurate or only slightly off. The codes, on the other hand, were spotty. For the first one, it knew to use a code for HbA1c. For the others, it guessed wrong. This is still an accelerator, because it is easy to use Atlas to find the right set of concept codes and paste them in.
I expect that with custom ChatGPT/LLM training and/or an integration that calls the Phoebe API to get a more appropriate set of codes, it may be possible to prototype some queries via LLM prompts.
Just being a little more specific with the query produces more detailed results:
Write a SQL query against the OHDSI CDM to build a cohort of patients with new onset diabetes. Identify and include relevant clinical concepts and their OMOP concept IDs, include them in the query, and document the concepts with their names in a comment
-- Cohort definition: Patients with new onset diabetes
SELECT DISTINCT
c.person_id
FROM
-- Include all condition occurrences of diabetes
condition_occurrence c
WHERE
-- Limit to diabetes diagnosis
c.condition_concept_id IN (
-- Relevant clinical concepts for diabetes diagnosis:
31967, -- Diabetes mellitus type 1
36684827, -- Diabetes mellitus type 1 in remission
31968, -- Diabetes mellitus type 2
4304378, -- New onset diabetes mellitus
45766052, -- Drug-induced diabetes mellitus
4248645, -- Secondary diabetes mellitus
433013, -- Diabetes insipidus
4304377, -- Unspecified diabetes mellitus
435311, -- Hyperosmolar hyperglycemic nonketotic syndrome
443452, -- Diabetic ketoacidosis
45757462, -- Diabetic foot ulcer
45766622, -- Diabetic retinopathy
45766623, -- Diabetic nephropathy
45757464, -- Diabetic neuropathy
45766625 -- Diabetes mellitus unspecified complication
)
AND NOT EXISTS (
-- Exclude patients with any diabetes diagnosis prior to a 365-day lookback period
SELECT
1
FROM
condition_occurrence c2
WHERE
c2.person_id = c.person_id
AND c2.condition_concept_id IN (
31967, -- Diabetes mellitus type 1
36684827, -- Diabetes mellitus type 1 in remission
31968, -- Diabetes mellitus type 2
4304378, -- New onset diabetes mellitus
45766052, -- Drug-induced diabetes mellitus
4248645, -- Secondary diabetes mellitus
433013, -- Diabetes insipidus
4304377, -- Unspecified diabetes mellitus
435311, -- Hyperosmolar hyperglycemic nonketotic syndrome
443452, -- Diabetic ketoacidosis
45757462, -- Diabetic foot ulcer
45766622, -- Diabetic retinopathy
45766623, -- Diabetic nephropathy
45757464, -- Diabetic neuropathy
45766625 -- Diabetes mellitus unspecified complication
)
AND c2.condition_start_date < c.condition_start_date - INTERVAL '365' DAY
);