select a.* from
(
select b.encountercode, patient.patientid, practicepatientid, practiceaccountid, client.clientcode, practice.practicecode, practicename, patientfname, patientlname, patientdob, dbo.ufn_getSSN(patient.accountid) as patientssn, patientgender, patient.accountid, accountstatuscode, accountstatuscode2, patientadminstatuscode, patientfinancialstatuscode
, ( (case when account.practiceaccountid like ('%Johnson%') then 1 else 0 end) + (case when patient.patientlname like ('%Johnson%') then 1 else 0 end) + (case when patient.patientfname like ('%Johnson%') then 1 else 0 end) + (case when account.accountid like ('%Johnson%') then 1 else 0 end) + (case when b.encountercode like ('%Johnson%') then 1 else 0 end) ) as hits from
account (nolock)
join patient (nolock) on patient.accountid = account.accountid
join practice (nolock) on account.practiceid = practice.PracticeID
join client (nolock) on practice.clientid = client.clientid
LEFT JOIN (SELECT TOP 1 ChargeGroup.AccountID, ChargeGroup.encountercode FROM ChargeGroup (nolock)
where
ChargeGroup.encountercode='Johnson'
AND
ChargeGroup.clientcode='AIRCARE') b
ON Account.AccountID=b.AccountID
where client.clientcode in('AIRCARE','ALLEN','AMG','BCMH','BBGH','CMI','DALE','DHDC','DCC','DMH','ECH','FCH','GAH','DEMO','HRMC','DSCHD','DSCHD2','HOUCOHO','LMCH','MCGH','SDP','MERCY','OVSH','PF','PCMG','RCC','SMC','SMH','TONC','TRAD','TPS','TTT','00077793111','UGH','URMC','UTH','UTS','CPAP','CPAPNew','WCH','WMC')
) a
where hits > 0
order by hits desc, patientlname asc
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.