Simple Export of Basic Patient Information

I need to export the following fields in Excel or .csv format:

Last name, first name, address (all fields), primary phone, email (optional), DOB, sex, primary provider, diagnosis, primary insurance carrier, insured ID#


Instead of going directly to CSV, we recommend exporting in HTML format instead. You can do a quick check on the results by just double-clicking the file (in this example, the results are saved in the file name MYEXPORT.HTML in the SOS folder). You can then open the file in Excel by starting Excel and using File > Open, being careful to select the appropriate file type. In Excel 2013 the type is “All Web Pages”. The results will appear with each data element in its own column and a heading at the top of each column. At that point, you can manipulate the data as you like and save as CSV or any other format supported by Excel.


Here is the query, including the OUTPUT line that saves the results as an HTML file. Note that the WHERE clause filters the results to include only patients in dataset 101 (licnum = 101), who appear in the Active Patient List (flag = 0), and who have not been discharged (discharge date IS NULL). You can change or remove any of these filters as needed, or add new ones.

  ,(a.phone1area+'-'+a.phone1) AS phone
  ,b.provlname+', '+b.provfname AS primary_provider
  ,c.payorname AS primary_insurance
  ,c.insdid AS insured_id
  sos.rv_patients a
  JOIN sos.providers b ON a.priprvcode = b.provcode
  JOIN sos.rv_policies c ON a.ptnum = c.ptnum
  JOIN sos.dx d ON a.dx1=d.dxnum
  a.licnum = 101
  AND b.licnum = 101
  AND a.flag = 0
  AND a.dischargedate IS NULL
  AND c.inspos = 1
OUTPUT TO c:\sos\myexport.html FORMAT html

Leave a Reply

Your email address will not be published. Required fields are marked *

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.