Patients and all ICD-10 Dx Codes in Professional Claim Setup(s)

This is a very simple query that lists all active patients along with all ICD-10 diagnoses in their professional claim setups.

 

SELECT 
  pt.id AS "ID",
  pt.lastname AS "Last Name", 
  pt.firstname AS "First Name",
  pt.dob AS "Date of Birth",
  pt.socsec AS "SSN",
  dx1.dxcode AS "Dx1",
  dx2.dxcode AS "Dx2", 
  dx3.dxcode AS "Dx3", 
  dx4.dxcode AS "Dx4", 
  dx5.dxcode AS "Dx5", 
  dx6.dxcode AS "Dx6", 
  dx7.dxcode AS "Dx7", 
  dx8.dxcode AS "Dx8", 
  dx9.dxcode AS "Dx9",
  dx10.dxcode AS "Dx10",
  dx11.dxcode AS "Dx11",
  dx12.dxcode AS "Dx12" 
FROM 
  patients pt
  JOIN ptcsu on pt.ptnum=ptcsu.ptnum
  LEFT OUTER JOIN dx dx1  on ptcsu.icd10dx1=dx1.dxnum
  LEFT OUTER JOIN dx dx2  on ptcsu.icd10dx2=dx2.dxnum
  LEFT OUTER JOIN dx dx3  on ptcsu.icd10dx3=dx3.dxnum
  LEFT OUTER JOIN dx dx4  on ptcsu.icd10dx4=dx4.dxnum
  LEFT OUTER JOIN dx dx5  on ptcsu.icd10dx5=dx5.dxnum
  LEFT OUTER JOIN dx dx6  on ptcsu.icd10dx6=dx6.dxnum
  LEFT OUTER JOIN dx dx7  on ptcsu.icd10dx7=dx7.dxnum
  LEFT OUTER JOIN dx dx8  on ptcsu.icd10dx8=dx8.dxnum
  LEFT OUTER JOIN dx dx9  on ptcsu.icd10dx9=dx9.dxnum
  LEFT OUTER JOIN dx dx10  on ptcsu.icd10dx10=dx10.dxnum
  LEFT OUTER JOIN dx dx11  on ptcsu.icd10dx11=dx11.dxnum
  LEFT OUTER JOIN dx dx12  on ptcsu.icd10dx12=dx12.dxnum
WHERE 
  pt.flag = 0
ORDER BY 
  lastname,firstname,"ID"

 

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.