Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Help with multiple events per user on Same day query Expand / Collapse
Author
Message
Posted Thursday, December 5, 2013 7:57 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 1:28 AM
Points: 194, Visits: 1,148
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
Post #1520098
Posted Friday, December 6, 2013 8:49 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 10:28 AM
Points: 1,387, Visits: 1,843
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

Post #1520624
Posted Friday, December 6, 2013 9:32 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 1:28 AM
Points: 194, Visits: 1,148
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
Post #1520642
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse