Part 5: Putting Queries to the Test

Purpose

This is the fifth article in a series about how to write ESSENCE free-text queries. Free-text coding in ESSENCE, which is accessible to all users, follows distinct patterns. Learning to read these patterns allows users to take queries from many places and repurpose them to suit their unique needs. Syndromic surveillance depends heavily on sharing methods, and practitioners must understand the language.

Free Text Coding blue fractal with white text

Introduction

Please see Part 1: Wildcards for background information about the search criteria for ESSENCE free-text queries, which are built around Boolean logical operators and regular expressions.

Parts 1 through 4 of this series cover basic and complex query notation, including the use of carets; underscores and brackets; "AND", "OR", and "ANDNOT" statements; and the parentheses that can be used to group these statements together.

During the series, we have also referenced a sample set of hypothetical chief complaints (CCs) and a desire to create a query for fall-related injuries. Now that we have all the query language at our fingertips, here's some expert guidance on how to develop a query that includes the intended visits and excludes the false positive CCs.

A starter fall-related injury query

Let's assume the following chief complaints (used in Parts 1–4) and a desire to create a query for fall-related injuries.

  1. Fall
  2. Fell getting out of car
  3. Left arm injury; Fall
  4. Falling out with friends; Suicidal
  5. Feels crestfallen
  6. Patient brought in after falling on face
  7. Fall; Left wrist injury
  8. Feels congested; Allergies

You may reasonably assume the boldfaced CCs 1, 2, 3, 6, and 7 are the intended cases and 4, 5, and 8 are false positives.

Here's a table that describes what we've learned about fall-related queries:

Fall-related Query Examples
Code Description
  1. First, we see that our Chief Complaints (CCs) contain two indicators of falls: the terms “Fall” and “Fell.”
^Fall^,OR,^Fell^ This query picks up CCs 1, 2, 3, 4, 5, 6, and 7. This captures all intended visits but also captures the false positive terms for “Falling out with friends” and “Feeling crestfallen.”
  1. To exclude unintended visits, let’s start with the term “Crestfall.” There are multiple ways to do this, but here are two common options:
^Fall^,ANDNOT,^Crestfallen^,OR,^Fell^ We can negate the false positive term directly. This returns CCs 1, 2, 3, 4, 6, and 7.
^ Fall^,OR,Fall^,or,Fell^ Or, we can be specific with our inclusion term. This code specifies that the term starts with the word (or CC) and returns CCs 1, 2, 3, 4, 6, and 7.
  1. Now, the only false positive that remains is CC 4, “Falling out with friends.” Adding a negation for “Falling” would probably have unintended consequences in real data and negate the true positive of CC 6 in our examples. There isn’t a great solution to exclude CC 4. Here are some examples and the pros and cons of each:
(,^Fall^,ANDNOT,^Crestfallen^,),AND,
(,^Injur^,OR,^Face^,or,^Wrist^,or,^Ankle^
,or,^Broke^,or,^Hurt^,or,^Lacer^,or,^Hit^
,or,^Head^,),OR,^Fell^
We can require that “Fall” coincide with an injury term. The code shown returns CCs 3, 6, and 7. This excludes CC 4 but also excludes the likely true positive CCs 1 and 2. Also, this query depends heavily on the user’s ability to cover all injury descriptions that can result from a fall, which could get prohibitively long.
^Fall^,ANDNOT,(,^Crestfallen^,OR,^Falling
out with^,),OR,^Fell^
The query can negate the text string specific to CC 4. The more specific your negation term becomes, the more likely it won’t apply across broad real-life data or negate similar false positives. Coding very specific negations can be used to negate especially troublesome false positives. The code to the left has a very specific negation to exclude troublesome CC 4 and returns CCs 1, 2, 3, 6 and 7.
^Fall^,ANDNOT,
(,^Crestfallen^,OR,^Suicid^,),OR,^Fell^
The query can negate based on how CC 4 relates to suicide ideation. However, that raises the question of how many times fall-related injuries occur alongside mentions of suicide ideation. This query returns CCs 1, 2, 3, 6, and 7.

So, that makes our final query on our hypothetical CCs either:

  • ^Fall^,ANDNOT,(,^Crestfallen^,OR,^Falling out with^,),OR,^Fell^
  • ^Fall^,ANDNOT,(,^Crestfallen^,OR,^Suicid^,),OR,^Fell^

Both queries are concise and accurate, but will they work with real-life data? The Chief Complaint Query Validation (CCQV) dataset in NSSP–ESSENCE is the logical (and best) place to start when creating a query that will be used nationwide. But for most situations, a user's local or regional data will suffice. For the next steps, we will use just the query ^Fall^,ANDNOT,(,^Crestfallen^,OR,^Falling out with^,),OR,^Fell^.

Fall-related injuries are common in emergency department data. The existing ESSENCE fall subsyndrome pulls these visits reliably, but we can also run our new syndrome and see how it performs on real-life data. Running the above query in CCQV data where HasBeenE=Yes (roughly limiting it to emergency care) returns just under 80,000 visits per week. Moving forward to see how our query works with a broader dataset, we will focus on just MMWR week 22, 2019. Contrary to this example that uses a single week's data, anyone validating a query should do so across multiple weeks to ensure that coverage includes a broad range of CC variations.

The official return of our query for MMWR week 22 is 79,604 visits. We can let ESSENCE take a random sample of these visits in the Data Details page to review. After reviewing these visits, our query seems to be performing quite well. False positives immediately noted are: Chief Complaints about assorted medical devices that "fall out" and items that fall or fell onto the patient.

Because we are looking for false positives, we can further refine the data we have to review by removing likely true positive visits. One method is to remove those that have relevant CCs and also have discharge diagnoses (DDs) related to our intended records. We can do this by putting the original query in parentheses and then linking to relevant DD codes with an "ANDNOT" statement. Although the methodology for picking DD codes is beyond the scope of this article, a quick ICD-10 negation of visits coded with a W00-W19 ICD-10 code covering slipping, tripping, stumbling, and falls will allow us to remove many true positives.

Our code to remove DD-positive visits, which we'll run in the CCDD field, is shown below. Note the use of brackets to cover this wide range of "W" codes with a single free-text term:

  • (,^Fall^,ANDNOT,(,^Crestfallen^,OR,^Falling out with^,),OR,^Fell^,),ANDNOT,(,^[;/ ]W[01][0-9]^,)

This query returns 53,676 visits for MMWR week 22. A review of the returns shows, once again, only a few false positives.

Code can be written to further isolate potential false positives, making it easier for users to quickly review and look for trends in terms to negate in the final query. For example, if a user has some knowledge of medical devices that can potentially "fall out," these devices can be listed in a query and thereby isolated. To do this, group the medical device terms within parentheses and then use an "AND" statement to link the parenthetical statement to the original query before the "ANDNOT" statement of diagnosis codes:

  • (,(,^Fall ^,ANDNOT,(,^Crestfallen^,OR,^Falling out with^,),OR,^Fell^,),AND,(,^Tube^,OR,^Cath^,OR,^Monitor^,OR,^Stitch^,),),ANDNOT,(,^[;/ ]W[01][0-9]^,)

Note: This query returns 200 visits in MMWR week 22. Of these, at least 20 are visits where the fall event dislodged the medical device and caused it to "Fall out." "ANDNOT" statements looking for false positives can have surprising and unintended consequences.

Try it out!

Try to negate cases where an item falls/fell onto the patient. With each negation, think about its consequences. For example, dressers can fall on people, but people can also fall off dressers.

Will the ANDNOT string (,^Dresser f[ea]ll^,) work for this? See what you're negating with the code:

  • (,(,^Fall^,ANDNOT,(,^Crestfallen^,OR,^Falling out with^,),OR,^Fell^,),AND,(,^Dresser f[ea]ll^,),),ANDNOT,(,^[;/

Complex query examples

Here are some complex queries that use different free-text language techniques quite well.

Notice in the highlighted portion of the new CDC Medication Refill v1 CCDD Category how an "ANDNOT" statement is nested within the first group of inclusion terms, which, in turn, are linked to another group of inclusion terms. By nesting the "ANDNOT" statement within the inclusion terms, the coder can be specific with the negations. Here, only the specific false positives pulled by the ^o2^ term are negated. This way, you only apply negations to terms where needed.

  • (,(,^tank^,or,^oxygen^,or,^o2^,ANDNOT,(,^O2[0-9]^,),or,^medication^,or,^script^,or,^pill^,or,^prescription^,or,^medicine^,),AND,(,^refil^,or,^supplemental^,or,^empty^,or,^need^,or,^out of^,or,^request^,),),or,(,^[;/ ]z76.0^,or,^[;/ ]z760^,or,^[;/ ]V68.1^or,^[;/ ]V681^,or,^[;/ ]182918009^,)

Shown below is the "Rabies and Animal Bites – Florida Department of Health" query, which is posted in the Syndromic Definition Library (SDL) in the Knowledge Repository (https://knowledgerepository.syndromicsurveillance.org/rabies-and-animal-bites-florida-department-health):

  • (,^rabie^,or,^rabbie^,or,^bitten^,or,^bite^,or,bit ^,or,^ bit,or,^ bit ^,),andnot,(,^bug^,or,^ant^,or,^child^,or,^insect^,or,^flea^,or,^person^,or,^human^,or,^snake^,or,^caterpil^,or,^pygmy rattler^,or,^something^,or,^spider^,or,^wasp^,or,^mosquito^,or,^tick^,or,^fish^,or,^recluse^,)

A notable feature of this rabies query is the concept that instead of being more specific with inclusion terms, coders chose to exclude visits where the biter was mentioned AND is not a likely carrier of rabies. This works great since a query for ^Bite^ alone will pull in insects, reptiles, amphibians, and children and a query for ^Bite^,AND,(,^Cat^,or,^Dog^,or,^etc.......^,) will exclude unattributed bites and fail to bring them to an epidemiologist or other decision-maker's attention.

The CSTE Cold-Related Illness query posted to the SDL serves as another excellent example of key query methods (https://knowledgerepository.syndromicsurveillance.org/cold-related-illness-cste).

Notice how the ICD-9 code starting with 991 uses the bracketed list [;/ ] at the start to ensure the number segment starts the code. This is followed by an underscore to specify anything can fall in that place, but that place must be filled, and then ends with another bracketed list [;/ ] to specify the end of the code. The bracket at the end ensures that numbers longer than 4 digits won't be pulled by this query.

This query also does a nice job negating historic frostbite and cold exposure injuries since frostbite patients are likely candidates for repeat ED visits for bandage changes, infection, swelling, and other issues. Notice in particular the use of ...^[TX]__.__XD^,or,^[TX]____XD^... to negate any injury or external cause code that has a "D" at the end indicating subsequent encounters.

  • (,^cold exp^,or,^cold-exp^,or,^env exp^,or,^environmental exp^,or,^exp to env^,or,^exposure to env^,or,^exp to cold^,or,^exposure to cold^,or,^cold exposure^,or,^coldexposue^,or,^out in the cold^,or,^f[ro][ro]stbit^,or,^f[ro][ro]st bit^,or,^f[ro][ro]stnip^,or,^f[ro][ro]st nip^,or,^f[ro][ro]st ni^,or,^hypothe^,),or,(,^froze^,and,(,^hand^,or,^finger^,or,^thumb^,),),ANDNOT,(,^Meat^,or,^burger^,or,^pork^,or,^wart^,or,^growth^,or,^food^,or,^knife^,or,^shoulder^,or,^turkey^,or,^knee^,),or,(,^froze^,and,(,^Feet^,or,^foot^,or,^toe^,),ANDNOT,(,^Meat^,or,^burger^,or,^pork^,or,^wart^,or,^growth^,or,^food^,or,^knife^,or,^shoulder^,or,^turkey^,or,^knee^,),),or,(,^[;/ ]x31^,or,^[;/ ]t68^,or,^[;/ ]t69^,or,^[;/ ]t33^,or,^[;/ ]t34^,or,^[;/ ]991._[;/ ]^,or,^[;/ ]991_[;/ ]^,or,^[;/ ]E901.[089]^,or,^[;/ ]E988.3^,or,^[;/ ]E901[089]^,or,^[;/ ]E9883^,),andnot,(,^recheck^,or^re-check^,or,^history of frostbite^,or,^historyfrostbite^,or,^dressingchang^,or,^chest^,or,^congestion^,or,^cough^,or, ^infection^,or,^[;/ ]w93^,or,^[;/]r68.0^,or,^[;/]r680^,or,^[;/ ]e901.1^,or,^[;/ ]780.65^,or,^[;/ ]e9011^,or,^[;/ ]78065[;/ ]^,or,^[TX]__.__XD^,or,^[TX]____XD^,)

We thank Senior Data Analyst Zachary Stein for volunteering to write a series of articles about free-text coding. Stein does epidemiological work to support NSSP efforts and is an active participant in our NSSP Community of Practice (CoP). He initially wrote about free-text coding as an entry on the NSSP-CoP Syndrome Definition Committee forum. The forum generated considerable interest, inspiring this series. Stein acknowledges input provided by others who contributed to the forum post.