Defining cohorts in asclepias
TODO: write intro
For more explanation on the theory behind cohorts, see Theory of Cohorts. |
Defining an Index Set
This example demonstrates:
-
how to create an index set
In this example, index is defined as the first time that a subject was bitten by an Orca (ICD10 codes W56.21/W56.21XA).
defineIndexSet
:: Ord a
=> [Event Text ExampleModel a] (1)
-> IndexSet (Interval a) (2)
defineIndexSet events =
events
|> filterEvents (containsConcepts ["wasBitByOrca"]) (3)
|> headMay (4)
|> fmap getInterval (5)
|> into (6)
1 | The input type for this example is a list of events,
where the concepts are Text ,
the data model is ExampleModel ,
and the interval time is a generic type a . |
2 | The return type is an Indexset of Interval .
The IndexSet type is defined in hasklepias-core
as either Nothing or a set of unique ordered values. |
3 | To determine whether a subject has an index,
we filter to the events tagged with the concept "wasBitByOrca" . |
4 | The headMay function gets the first event,
if one exists.
We’re assuming the input list has already been sorted. |
5 | Then we get the interval, if it exists. |
6 | The into function casts the output from <4> into a IndexSet (Interval a) type. |
Defining Assessment Intervals
This example demonstrates:
-
how to create assessment intervals for baseline and followup
In this example, TODO
bline :: (IntervalSizeable a b) => Interval a -> AssessmentInterval a
bline = makeBaselineMeetsIndex 60
flwup :: (IntervalSizeable a b) => Interval a -> AssessmentInterval a
flwup = makeFollowupStartedByIndex 30
Create a minimal cohort
This examples demonstrates:
Review the cohort building procedures document for complete details on the steps to creating cohort applications. |
Create a cohort with calendar-based indices
This examples demonstrates:
-
specifying cohorts from calendar-based indices
-
using asclepias' cohort module without using its feature module
-
using an empty return type for the cohort data to just compute attrition information
Review the cohort building checklist TODO: create such a document |
Goal
Tha goal in this example is to create a cohort for each quarter of 2017. The cohort should include subjects if they have an enrollment event concurring with the first day of a quarter. For this example,
Decide on the data model
In this example, we use the following data model in our events: TODO
Here we create a type synonym for the the event type in this example
type Evnt = Event Text ExampleModel Day
Create intervals for dates used for indices
indices :: [Interval Day]
indices = map (\(y, m) -> beginervalMoment (fromGregorian y m 1))
(allPairs [2017] [1, 4, 7, 10])
Define criteria
isEnrollmentEvent :: Predicate Evnt
isEnrollmentEvent = Predicate
(\x -> case getFacts (getContext x) of
Enrollment -> True
_ -> False
)
Include the subject if she has an enrollment interval concurring with index.
enrolled :: Interval Day -> [Evnt] -> Status
enrolled i es = includeIf . not . null $ filterEvents
(Predicate (concur i) &&& isEnrollmentEvent)
es
Write Cohort Specification
A cohort is TODO: link to cohort definition
makeIndexRunner :: Interval Day -> [Evnt] -> IndexSet (Interval Day)
makeIndexRunner i _ = makeIndexSet [i]
makeCriteriaRunner :: Interval Day -> [Evnt] -> Criteria
makeCriteriaRunner index events = criteria [criterion "isEnrolled" crit1]
where crit1 = enrolled index events
TODO: we could have done this a different way |