Notifications
Clear all
Topic starter
Does anyone have an SQL query (CPS 10) that will pull patient info with last visit?
Also if it had insurance info that would be a plus.
Posted : July 23, 2012 7:55 am
How's this?
select * from (
select pp.First, pp.Last, pp.Birthdate
, ic.ListName
, pi.GroupId, pi.InsuredId
, pv.Visit
, max(pv.Visit) over (partition by pv.PatientProfileId) as LastVisit
from PatientProfile pp
join PatientVisit pv on pp.PatientProfileId = pv.PatientProfileId
join PatientInsurance pi on pp.PatientProfileId = pi.PatientProfileId
join InsuranceCarriers ic on pi.InsuranceCarriersId = ic.InsuranceCarriersId
where pp.ispatient = 'Y'
and pp.pstatus = 'A'
and pp.First like 'J%'
and pp.Last like 'D%'
and pi.OrderForClaims = 1
and (pi.Inactive is null
or pi.Inactive = 0)
) patList
where Visit = LastVisit
Posted : July 26, 2012 12:44 am
Topic starter
Worked like a champ.
I just added the additional demographic fields I needed.
Thanks again Sarek. You are the GE Master.
Posted : July 26, 2012 2:16 am
