OHDSI Home | Forums | Wiki | Github

Drug exposure on specific visit

Hello - Looking for suggestions regarding best practices for constructing an OHDSI Atlas query that subsets a patient cohort with a specific diagnosis by a specific drug exposures. I am counting the number of daily ED patient encounters with a diagnosis of asthma. I would like to only include those patients who received an asthma medication on that ED visit. To that end, I created the following query which (a) selects all patients with a visit occurrence of an ED visit, (b) reduces this population to only those patients who received an asthma diagnosis on that visit, and © reduces this population further to only those patients who received an asthma diagnosis AND received asthma medications on that same ED visit. The critical part of this (because I am simply looking at #s of visits per day) is that my date offset exit criteria is

Date Offset Exit Criteria
This cohort defintion end date will be the index event’s start date plus 0 days

So that people can enter and exit the cohort repeatedly (i.e. multiple ED visits on different days by the same person count as multiple visits).

However, I am wondering if this date offset of 0 days is interfering with the drug exposure inclusion criteria. When I run the query on my home database without the drug exposure criteria, I have 268K visits from 98K unique people. When I run the query with the drug exposure criteria using “Drug exposure: restrict to same visit occurrence”, I lose almost 260K visits.

Because we previous discussions indicated that the visit_occurrence_id is an optional field in the drug exposure table, I then ran the query with drug exposure criteria using “+/- 7 days from event index date and ending at any time” and still lose ~200K visits.

I am wondering if this is due to my cohort exit offset being set to 0 days (which I am using to ensure that I catch repeat visits for asthma by the same person).

Any suggestions for reshaping this query using the Atlas Web API? Thanks!

Chris

Hello,
Setting a date offset exit criteria to 0 days will not allow you to have multiple episodes in a single day. It is a rule that the final cohort episodes do not overlap, and so having each visit represented by a single cohort episode is not allowed.

However, all is not lost. You can use the Cohort Inclusion rules to gather statistics about each initial event (your ED Visits) :
Rule 1: asthma diagnosis during same visit
Rule 2: asthma diagnosis during same visit AND asthma medication during same visit.

This will show up on the cohort generation tab, clicking on the ‘View Reports’ button. You will see the total number of ED Visits as the “Total” count, and then the number of events satisfying each inclusion rule under the inclusion rule report.

You can’t use the ‘record count’ or ‘person count’ results in the cohort summary report since those are episodes, which will not help you here.

Thanks @Chris_Knoll, the problem is that Rule 2 using “restrict to same visit” eliminates far too many people because the drug_exposure table has NULLs for visit_occurrence_ids on most patients. Which leads me to a structural question. The way I have been creating my web queries is:

  • Initial Event Cohort: Visit Occurrence of ED Visit limited to “all events per person”
  • From among initial events: having at least 1 condition occurrence of Asthma “restricted to same visit occurrence”

This query seems to work as I get a visit count that appears appropriate, and the condition_occurrence table has visit_occurrence_ids for almost all patients. (See Cohort#1769235 on ohdsi.org/atlas)

I then added a nested criteria to the asthma condition occurrence

  • Drug exposure of asthma medications

This query does not seem to work (See Cohort #1769236 on ohdsi.org/atlas)

Is this the correct query structure? I’m wondering if instead of nesting, I should be using the “Additional Qualifying Inclusion Criteria”? Or should I be switching the order of the criteria from ED Visit -> subset on Asthma Dx in ED -> subset on Asthma Dx in ED w/Asthma Meds on that visit to something different?

Again, thanks for your advice!

Nesting the criteria lets you look for the medications relative to the diagnosis of asthma. But, in the end, you’re looking for the visit, diagnosis and drug exposure all at the same visit occurrence (which means they all share the same visit_occurrence_id). So, you can change your cohort from:

ER Visit with:
    Asthma Dx with:
      medication 
      at same visit as asthma
    at same visit as ER Visit

to:

  ER Visit with:
    asthma at same visit as ER Visit
    and medication at same visit as ER

But you need to get rid of looking at the same visits for drugs, it doesn’t really have to be tied to the same visit, does it? Maybe a prescription is written and filled later?

So, do it this way:

ER Visit with:
  Asthma Dx with:
    Asthma Medication within 7d before and 7d after diagnosis (but not at same visit as asthma)
  at same visit as ER visit.

The idea is that you’ll only accept the Asthma diagnosis to keep your ER visit unless you see Asthma medication somewhere within 7d before the diagnosis date and 7d after the diagnosis date. This 14 day window is completely arbitrary. Sometimes records can be flaky that the prescription might have a date that precedes the actual diagnosis. But, if you are confident about your dates, and instead you’d look forward up to 7d to find an asthma medication script, then change it to:

ER Visit with:
  Asthma Dx with:
    Asthma Medication within 0d before and 7d after diagnosis (but not required at same visit as asthma)
  at same visit as ER visit.

-Chris

Additionally:

You have the second ‘limit initial events’ set to ‘earliest event per person.’ This means that after you find all the ER visits, you check to see if it has the appropriate asthma diagnosis (ie: the diagnosis with a corresponding medication). However, you then limit the remaining initial events to ‘earliest event per person’.

Change all those ‘limit events’ to ‘all events per person’.

-Chris

@Chris_Knoll Thank you! Will try these out.

So it turns out that both our condition_occurrence and drug_exposure tables have a significant number of NULLs for visit_occurrence_id so it’s not possible to use visit_occurrence_id as either a join key or a select criteria in our queries. A few questions:

  • Is visit_occurrence_id an “optional” field in the condition_occurrence table in the same way that is an “optional” field in the drug_exposure table?
  • Would an appropriate work-around be to search for condition_occurrence_date <= visit_end_date? This seems like it should capture all people who received asthma diagnoses in the past.
  • If I instead used (visit_start_date <= condition_occurrence_date <= visit_end_date), I assume that I will miss those patients who present to the ED with a prior diagnosis of asthma but don’t have that diagnosis entered by the physician for that particular ED visit?
  • Are the condition_occurrence_ids built on primary and secondary ICD-9/10 codes and is there any way of distinguishing whether this was a “primary” or “secondary” diagnosis code?

Thanks!

Hi @Swammer

The visit_occurrence_id is nullable in the condition_occurrence table, and therefore it is optional.

If you said condition_occurrecne_date <= visit_end date, that is basically saying ‘condition_occurrence_date starts between all days before to 0 days before the visit end date’, which would find all those condition occurrences in the past. If you are looking for something relatively recent to the visit, why not say ‘condition_occurrence_date starts between 7 days before to 0 days before the visit end date’? Then, it doesn’t matter which visit the diagnosis occured in, just that it was relatively close to the visit end (or you could say visit start).

If you said visit start <= condition_start_date <= visit_end_date, you’d effectively be looking for the condition within a visit date range, and that’s not confined to the same visit. If you think that the prior diagnosis might be identified at an earlier, visit on a different date, then you can say:
condition_occurrence starts between 5d before visit start date and condition_occurrence starts between 5d after visit end date. That will look 5d before and after your ED visit for the condition occurrence. No join to the visit occurrence table is done in this case, we’re just looking for dates close together.

condition_occurrence_ids are usually just auto-numbered values that don’t reflect any specific data in the record. You can tell if a diagnosis is primary or secondary using the ‘condtion_type_concept_id’. There should be concepts there that talk about primary vs. secondary diagnosis.

t