Help with multiple events per user on Same day query

  • 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:EncounterIDEncountertype:

    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:-)

  • 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:EncounterIDEncountertype:

    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

  • 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:-)

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply