Pro SQL Server 2012 Reporting Services

(sharon) #1

CHAPTER 13  CREATING REPORTS USING REPORT BUILDER 1.0, 2.0, AND 3.0


 Note To make it easier on you with less typing, we have included this query in the source code for this book in
a file called Patient Census Query – Chapter 13.sql. Of course if you really like typing, though, feel free to write the
SQL statement provided in Listing 13-1.

Listing 13-1. Patient Census Query

SELECT
A.PatProgramID
, E.EmployeeID
, E.LastName AS Emp_LastName
, E.FirstName AS Emp_Firstname
, D2.Dscr AS Discipline
, B.BranchName
, P.PatID
, P.LastName AS Pat_LastName
, P.FirstName AS Pat_FirstName
, D.DiagID
, D.Dscr AS Diagnosis
, PD.DiagOnset
, PD.DiagOrder
, A.StartOfCare
, A.DischargeDate
, P.MI
, P.Address1
, P.Address2
, P.City
, P.HomePhone
, P.Zip
, P.State
, P.WorkPhone
, P.DOB
, P.SSN
, P.Sex
, P.RaceID
, P.MaritalStatusID
, EMR.DateEntered
, EMR.Dscr AS EMR_Document
, DS.Dscr AS [Discharge Reason]
, DATEDIFF(dd, A.StartOfCare, A.DischargeDate) + 1 AS [Length of Stay]
FROM
Admissions AS A
INNER JOIN Patient AS P ON A.PatID = P.PatID
INNER JOIN Branch AS B ON B.BranchID = P.OrigBranchID
LEFT OUTER JOIN PatDiag AS PD ON A.PatProgramID = PD.PatProgramID
INNER JOIN Diag AS D ON PD.DiagTblID = D.DiagTblID
LEFT OUTER JOIN Employee AS E ON A.EmployeeTblID = E.EmployeeTblID
LEFT OUTER JOIN Discipline AS D2 ON D2.DisciplineTblID = E.DisciplineTblID
Free download pdf