SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Help with multiple events per user on Same day query


Help with multiple events per user on Same day query

Author
Message
thomashohner
thomashohner
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2522 Visits: 2306
I have to create a report that tells us if a Patient has had a Behavioral Health visit and a Medical Visit on the same day. We need to figure this one out in a emergency as the New Medicaid expansion is telling us we need to bill these visits on a single form if they occur on a single day. We are trying to figure out how many of our clients see a Medical and Behavioral Health provider on the same day. This seems like it would be very easy but i'm stumped right now.

My fields are

Date of Service (Date)

Encounter type (Varchar)

Unique PatientID (Integer)

Unique EncounterID (Integer)

I'm trying to get results that look like this:

Date of Service: PatientID: EncounterID Encountertype:
08/01/13 10 45 BH
08/01/13 10 46 Medical
08/02/13 12 49 BH
08/02/13 12 50 Medical
08/02/13 14 54 BH
08/02/13 14 55 Medical

***SQL born on date Spring 2013:-)
Sqlraider
Sqlraider
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2688 Visits: 2311
thomashohner (12/5/2013)
I have to create a report that tells us if a Patient has had a Behavioral Health visit and a Medical Visit on the same day. We need to figure this one out in a emergency as the New Medicaid expansion is telling us we need to bill these visits on a single form if they occur on a single day. We are trying to figure out how many of our clients see a Medical and Behavioral Health provider on the same day. This seems like it would be very easy but i'm stumped right now.

My fields are

Date of Service (Date)

Encounter type (Varchar)

Unique PatientID (Integer)

Unique EncounterID (Integer)

I'm trying to get results that look like this:

Date of Service: PatientID: EncounterID Encountertype:
08/01/13 10 45 BH
08/01/13 10 46 Medical
08/02/13 12 49 BH
08/02/13 12 50 Medical
08/02/13 14 54 BH
08/02/13 14 55 Medical


Try using Order By.

Select Date of Service, PatientID, EncounterID, Encountertype
from YourTable
Order By Date of Service, PatientID, Encountertype


thomashohner
thomashohner
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2522 Visits: 2306
Thanks so much SQlraider for your reply. One of my friends actual helped me on this and it was something simple I was just having a brain fart. Here is the query that worked. I now know we only had 197 duplicate visits out of 20,000 so we can breathe a little sigh of relief now.

With MedicalCount_CTE

AS
(
Select
u.PatientID,
u.DateOfServiceFrom,
u.EncounterType
From
vwUDSTMP5 u
WHere
u.EncounterType = 'HCPC-Medical' and
u.BillableProviderName Not Like '%RN' AND
u.DateOfServiceFrom >'01/01/13'

),



BHCount_CTE
AS
(
Select
u.PatientID,
u.DateOfServiceFrom,
u.EncounterType
From
vwUDSTMP5 u
WHere
u.EncounterType = 'HCPC-Behavior Health' and
u.BillableProviderName Not Like '%RN' AND
u.DateOfServiceFrom >'01/01/13'

)



Select
c.PatientID,
c.DateOfServiceFrom

From
MedicalCount_CTE c INNER JOIN
BHCount_CTE bh ON bh.PatientID = c.PatientID and bh.DateOfServiceFrom = c.DateOfServiceFrom
order by
c.PatientID,
c.DateOfServiceFrom,
c.EncounterType

***SQL born on date Spring 2013:-)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search