USE Radiology GO create PROCEDURE [dbo].[spRadio_CheckPending_AllSecs] AS ------ modified by cynthia (to ensure that all requested items exist in build_file------- select count(*) as TotalPending from STATION..tbNurseCommunicationFile A inner join Radiology..tbBillExamListing B ON (A.RevenueID = B.Revenueid) and (A.ItemID = B.ItemID) inner join ( select IdNum, BillingDate from Patient_Data..tbPatient P where P.BillingDate is NULL union all select IdNum, BillingDate from Patient_Data..tbOutPatient P where P.BillingDate is NULL and isnull(P.OPDStatus,'') <> 'R') P on A.IdNum = P.IdNum where A.Revenueid in ('XR','CT','US','MI','MS','MM','MG','NU','PG','WC','O1') and isnull(A.RecordStatus,'') = '' GO