Guest User

Untitled

a guest
Jul 18th, 2019
51
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Select Distinct P.PatientCode, P.LastName, P.FirstName, P.Matrix, P.DOB,
  2. P.DiagCode1,
  3.  
  4. P.DiagCode2,P.DiagCode3, P.DiagCode4, P.DoctorCode,
  5. R.ProgramCode,P.FacilityCode,
  6. P.DiagCode5,P.DiagCode6, P.DiagCode7, P.DiagCode8,
  7. P.Employed,P.RetiredDate,
  8.  
  9. R.DateFrom, R.DateTo, R.TerminateDate, R.Status, '''' as GroupCreationID
  10. From MdPt0001 P LEFT OUTER JOIN MdPhPtPg R
  11. ON ( P.PatientCode = R.PatientCode )
  12.  
  13. AND ( ( (R.DateFrom <= '4/4/2017' ) or (R.DateFrom <= '18/08/2019') ) And
  14. (R.DateTo >= '4/4/2017' ) And
  15. ( ( R.Status in ( 'A', 'T' ) ) OR (( R.TerminateDate >= '4/4/2017' )
  16. AND ( R.Status <> 'A' ) ) ) )
  17.  
  18.  
  19. Where (P.PATIENTCODE in ( Select Distinct Q.PatientCode From MdPhAt01 Q
  20. Where
  21. ( Q.ServiceDate >= '4/4/2017' )
  22.  
  23. AND ( Q.Attendance= 'Y' ) AND ( Q.ServiceDate <= '18/08/2019' ) AND (
  24. Q.Billed = 'N') OR (Q.Billed is null)))
  25.  
  26.  
  27.  
  28. AND Q.CourseCode in (' + TherapyQuoteString + ')
  29. order by P.LastName, P.FacilityCode
RAW Paste Data