Do you use or administer OpenEMR? Take the General Satisfaction Survey to help improve the product

SQL Query for a report of the ICD-10 diagnoses, diagnoses description, etc. for a patient

How do I write a SQL query string to do the following:

pid = 100; (The patient’s pid)

PID   ICD-10    ICD-10 DESCR                         ACTIVE?     START        END
100    I10       Essential Hypertension.              Yes         02/17/1985   -
100    E78.5     Hyperlipidemia, unspecified.         No          05/31/2020   6/30/2021
(etc. for all the patient's diagnoses)

Hi @Ralf_Lukner below is the query you can write to get the report for the diagnosis

Select pid,diagnosis,activity,begdate,enddate from lists where pid =100;

1 Like

Thank you for your help, Nilesh!!

I made a slight change to avoid pulling in other parameters from the lists table (such as allergies, medications, etc.). You helped me very much.

A very similar SQL query can be used to retrieve allergy, medication, and other similar information about a patient.

Select pid,diagnosis,title,activity,begdate,enddate from openemr.lists 
    where (pid = 100) and (type = 'medical_problem');
# Produces:
100,ICD10:I10,"Essential Hypertension",1,NULL,NULL
100,ICD10:E78.5,"Hyperlipidemia, unspecified",1,NULL,NULL

@Ralf_Lukner your welcome

1 Like