daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Dec 12th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT DISTINCT a.ServiceLineName [Service Line], a.AdmitDateTime [Admission Date], a.AdmissionStatusDescription, a.PatientInsuranceName [Payer], a.PatientLastName [Last Name], a.PatientFirstName [First Name], p.MRN +'-'+ a.AdmissionID [MRN and Admission #], CAST(ar.ReferralDate as DATE) [Referral Date], CAST(a.InitialReferralDate AS DATE) [Initial Referral Date], CAST(a.SOCDate as DATE) [SOC Date],
  2.  
  3. sg.ServiceLineGroupingName [Branch],
  4.  
  5. f.Name [FacilityName], fm.LastName [Marketer First Name] , fm.FirstName [Marketer Last Name]
  6.  
  7. FROM rpt.AdmissionReferrals ar
  8.  
  9. JOIN rpt.Facilities f ON f.FacilitySID=ar.FacilitySID
  10.  
  11. LEFT JOIN rpt.facilitymarketers fm ON fm.FacilitySID=f.FacilitySID AND  ar.ReferralDate BETWEEN fm.StartDate AND fm.EndDate
  12.  
  13.  JOIN rpt.Admissions a ON a.AdmissionSID=ar.AdmissionSID
  14.  
  15.  JOIN rpt.Patients p ON p.PatientSID=a.PatientSID
  16.  
  17.  JOIN rpt.ServiceLineGroupings sg ON sg.ServiceLineSID=a.ServiceLineSID
  18.  
  19. WHERE sg.ServiceLineGroupingName IN ('Hamden', 'Rocky Hill')
  20.  
  21. AND a.SOCDate != '12/31/9999' AND a.AdmitDateTime != '12/31/9999'
  22.  
  23. AND a.AdmitDateTime >= @StartDate AND a.AdmitDateTime <= @EndDate
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top