And to get even more accurate, use this one
SELECT dbo.PERSON.*
FROM dbo.PERSON INNER JOIN
dbo.[DOCUMENT] ON dbo.PERSON.PID = dbo.[DOCUMENT].PID
WHERE (dbo.[DOCUMENT].VISDOCID IN (SELECT MIN(VISDOCID) FROM DOCUMENT WHERE PID = dbo.PERSON.PID)) AND dbo.Convert_ID_to_date(CLINICALDATE) BETWEEN '9/1/2012' AND '9/28/2012'
This will bypass NULL db_created dates and use the clinical date that was give to the document when it was created.
So I recommend creating a view with the above code, and then building your crystal report off of this.
Here's my revamped report doing what the above select does without creating a view.
Which would you think would be more accurate to use PERSON.VISDOCID or DOCUMENT.VISDOCID? What do you think the difference would be if I used PERSON vs DOCUMENT table as far as finding the most accurate data for NEW patients?
DOCVIS, cause the PERSON VIS Doesnt always get updated, and I believe that is the latest Visit Doc ID for that patient.
jjordet said:
You'll miss any new patients where the first document was discarded with the above select. Here's a report that will check the first 3 VISDOCIDs.
How did you upload the .rpt file to the forum? I only see upload image or media options.