Forum Discussion

Christopher Bolduc's avatar
Christopher Bolduc
Copper Contributor
Aug 03, 2018

Search criteria in a field to evaluate if an event happened within 30 days pre and post

Hi:

I've found myself needing this formula on more than one occasion, have thought about it extensively, and appreciate any help I can get.

NOTES:

  • 1 MRN can have multiple encounters; below are two examples.
  • The goal is to evaluate at the MRN level and place an indicator in a separate column that flags to me that the MRN qualifies as meeting the Criteria.  I don't need to necessarily know which lines within the MRN are the qualifiers (thought that would be a bonus), I just need to know that the MRN qualifies in general as meeting the criteria.
  • Criteria: Within a given MRN, was an administered chemotherapy CPT given both Within 30 days prior to the office visit CPT AND Within 30 days after the office visit CPT.
  • In example 1 below, MRN 123456 meets the criteria because chemo was administered 15 days before  (on 2/18/17) and 25 days after (3/30/17) of the office visit on 3/5/17.  Example 2 doesn't qualify since no combination of office visits and administered chemo happen with 30 days before or within 30 days after an office visit.
 MRNENCOUNTERSERVICE DATECPTCPT DescriptionIndicator
Example 1123456345612346/7/201751720Administered Chemo 
 123456456879223/5/201799201Office Visit 10 MinutesY
 123456345612343/30/201796420Administered ChemoY
 123456745310212/18/201796423Administered ChemoY
 123456478926437/17/201799214Office visit 25 MinutesY
 123456357159558/31/201796459Administered ChemoY
Example 2789100411351223/4/201799215Office visit 40 MinutesN
 789100211221221/23/201796401Administered ChemoN
 789100315555557/1/201799205Office visit 60 MinutesN
 789100645882914/13/201796440Administered ChemoN
 789100876543291/13/201796549Administered ChemoN
 789100789564899/19/201799212Office visit 10 MinutesN

 

Thanks,

Chris

3 Replies

  • Philip West's avatar
    Philip West
    Steel Contributor

    I /think/ this is what you want.. I've used a cpl IFs and a couple COUNTIFSs to at least tell you if the criteria is met.. the formula looks like this:

    (I used a table so the formula is also table references)

     

    =IF(LEFT([@[CPT Description]],2) = "Of",
    IF(
    AND((COUNTIFS([MRN],[@MRN],[SERVICE DATE],">"&[@[SERVICE DATE]]-30,[SERVICE DATE],"<"&[@[SERVICE DATE]],[CPT Description],"=Administered Chemo")),
    (COUNTIFS([MRN],[@MRN],[SERVICE DATE],"<"&[@[SERVICE DATE]]+30,[SERVICE DATE],">"&[@[SERVICE DATE]],[CPT Description],"=Administered Chemo"))),
    TRUE,FALSE),
    "")

     

    It works something like.. if the description is an office visit - ie it starts with the letters 'Of' - then carry on, else leave the cell blank. I did this as from your description it sounded like you were only interested in pre/post office visits so I thought this was neater. Just be aware that this formula is looking for the CPT description to either start 'Office' or be 'Administered Chemo'.

     

    If it is a visit then we are into another IF. This time we check to see if both of our COUNTIFS statements are larger than 0. The first COUNTIFS checks that MRN is the same as the row we are interested in, then that the service date is greater than the visit date - 30, then it checks that it is less than the visit date and finally that the description is 'Administered Chemo'. If this counts anything other than 0, we must have at least one Chemo appointment that meets the criteria.

     

    Then the second COUNTIFS does the same thing but this time for service date is less than + 30 days.

     

    If both conditions are meet then it returns True and your criteria are met, if it returns False then one or other criteria were not met.

     

    I'm attaching my copy of the spreadsheet I was working on. I've added some extra columns that you can just delete as you see fit. They are:

     

    '30 days before' - This is just the COUNTIFS for the before date on its own to make it easier to understand

    '30 days after' - same as above but for after

    'Indicator' - the combined formula as described above

    'Indicator 2' - an alternative version of the formula that doesn't check the type of CPT. ie in this COUNTIFS we no longer care if it was an office visit or a chemo visit, as long as they were seen within the pre/post 30day criteria. (i wasn't sure which was right)

     

    On your example you have a Y next to the 17/7/18 visit, but unless I'm being a bit daft, and none of the above works, that should be false. There isn't a chemo session within 30days either before or after.

     

    Hopefully that works for you.

    • Christopher Bolduc's avatar
      Christopher Bolduc
      Copper Contributor

      Thanks, Phillip!  I appreciate your patience while I looked into this.  I do believe this is working.  I understand you used a table so the formula is a table reference, which is the only way I could get this to work.  I also understand that the formula is looking for the CPT description to start with "Office" or "Administered Chemo." 

       

      Question: Since the example provided was a short sample size, I wanted to confirm whether the resulting value will be the number of qualified instances that meet the condition, correct?  The resulting value can be something other than "0" or "1," right?

       

      Also, much of what we do is based on values as opposed to descriptions.  For future application of this formula, if CPTs 99201-99205 and 99211-99215 are office visits, and 96401-96549 are administered chemo, how would the formula have to be altered to incorporate the vlookup(s)?

       

      Thanks so much for your help on this; I was wracking my brain on this one.

       

      Best,

      Chris

      • Philip West's avatar
        Philip West
        Steel Contributor

        Hia,

        I'm glad that we are making progress :)

         

        Yes, the formula is counting the number of occurrences before and after that meet the criteria, so anything more than 0 is a match. The two columns that show the counting are only there so you can see more easily what is happening in larger the formula. You can delete them if you like, they aren't needed.

         

        So Indicator and Indicator 2 are basically the same thing, they differ in that Indicator 2 doesn't care what sort of visit happened in the 30days, any entry in your table will do. Indicator makes a distinction between an office visit and an chemo session. In your example this was easy as it was just a case of looking for the words 'Administered Chemo'. If in the live version you use something else, then you can just substitute the words Administered Chemo for that something else. So it could be "=96401-96549".

         

        It gets slightly harder if you have several criteria for what might be a chemo visit.

Resources