Sequential functions - ndobb/clinical-trials-seq2seq-annotation GitHub Wiki

seq()

seq() is a wrapper function which should be used for any case where one criterion depends temporally on another.

Arguments -

  1. The "anchor" function representing the first event.
  2. A before(), during(), or after() function represents the next event in the sequence.

Example -

'INC'

'-  Present to Stanford Emergency Department as a trauma with a major operative 
    lower extremity injury'

'-  enc() to loc(hosp("Stanford Emergency Department")) as a obs("trauma") with a 
    mod("major operative lower extremity") obs("injury")'

seq(
    enc()
        .loc(hosp("Stanford Emergency Department")),
    during(
        obs("trauma")
    ),
    during(
        obs("injury")
            .mod("major operative lower extremity")
    )
)

after()

after() represents an event which follows its preceding argument inside a seq() function.

Arguments -

  1. A function.

Example -

'EXC'

'patients referred to other hospital within 30 days after admission'

'patients enc(REFERRAL) to other hosp("hospital") 
 eq(op(LTEQ), temporal_unit(DAY), val("30") after enc(INPATIENT)'

seq(
    enc(INPATIENT),
    after(
        enc(REFERRAL)
            .loc(hosp("hospital")),
        eq(op(LTEQ), temporal_unit(DAY), val("30"))
    )
)

before()

before() represents an event which occurs before the previous argument inside a seq() function.

Arguments -

  1. A function.

Example -

'EXC'

'-  pre - operative opioid usage within the last six months'

'-  pre - proc("operative") drug("opioid") usage 
    eq(op(LTEQ), temporal_per(PAST), val("six"), temporal_unit(MONTH))'

seq(
    drug("opioid")
        .temporality(
            eq(op(LTEQ), temporal_per(PAST), val("six"), temporal_unit(MONTH))
        ),
    before( 
        proc("operative") 
    )
)

during()

during() represents an event which occurs at the same time or in the same encounter as the previous argument inside a seq() function.

Arguments -

  1. A function.

Example -

'EXC'

'-  history of medication for PE treatment at the time of first admission'

'-  eq(temporal_per(PAST)) of drug() for cond("PE") treatment at the time 
    of eq(temporal_rec(FIRST_TIME)) enc(INPATIENT)'

seq(
    drug()
        .temporality(
            eq(temporal_per(PAST))
        )
        .for(
            cond("PE")
        ),
    during(
        enc(INPATIENT)
            .temporality(
                eq(temporal_rec(FIRST_TIME))
            )
    )
)