hasklepias-core-0.30.3: Domain-aware tools and types for constructing epidemiological cohorts
Copyright(c) Target RWE 2023
LicenseBSD3
Maintainerbbrown@targetrwe.com ljackman@targetrwe.com dpritchard@targetrwe.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cohort.Cohort

Description

 
Synopsis

Documentation

data CohortSpec t m a Source #

A container for all logic needed to construct a cohort. The provided functions will be run on subject-level data, subject-by-subject. Logic will be executed as part of a CohortApp pipeline. The type CohortApp itself is not exported, but the user will create such a pipeline via the exported cohortMain.

Note runVariables must construct *all* output variables. For a more detailed explanation of the cohort-building pipeline, see the Hasklepias module documentation from `hasklepias-main`.

Constructors

MkCohortSpec 

Fields

  • runIndices :: NonEmpty (Event t m a) -> IndexSet a

    Constructs the set of index times, of type Interval a, for a given subject based on the full list of subject data in the NonEmpty input list of Event t m a.

  • runCriteria :: NonEmpty (Event t m a) -> Interval a -> Criteria

    Constructs a non-empty list of inclusion / exclusion criteria for a single subject, relative to a particular index time. There will be one Criteria value for each subject and element of IndexSet a.

  • runVariables :: NonEmpty (Event t m a) -> Interval a -> VariableRow

    Construct all output variables for the provided subject data, with respect to a particular index time.

type CohortSpecMap t m a = Map Text (CohortSpec t m a) Source #

Container for CohortSpec for different cohorts, as given by the Text keys.

newtype SubjId Source #

Wrapper for a Text subject identifier. The wrapper allows us to guarantee certain properties for subject identifiers, instead of allowing arbitrary Text.

Constructors

MkSubjId Text 

Instances

Instances details
ToJSON SubjId Source # 
Instance details

Defined in Cohort.Cohort

Methods

toJSON :: SubjId -> Value

toEncoding :: SubjId -> Encoding

toJSONList :: [SubjId] -> Value

toEncodingList :: [SubjId] -> Encoding

Generic SubjId Source # 
Instance details

Defined in Cohort.Cohort

Associated Types

type Rep SubjId :: Type -> Type #

Methods

from :: SubjId -> Rep SubjId x #

to :: Rep SubjId x -> SubjId #

Show SubjId Source # 
Instance details

Defined in Cohort.Cohort

Eq SubjId Source # 
Instance details

Defined in Cohort.Cohort

Methods

(==) :: SubjId -> SubjId -> Bool #

(/=) :: SubjId -> SubjId -> Bool #

Ord SubjId Source # 
Instance details

Defined in Cohort.Cohort

type Rep SubjId Source # 
Instance details

Defined in Cohort.Cohort

type Rep SubjId = D1 ('MetaData "SubjId" "Cohort.Cohort" "hasklepias-core-0.30.3-inplace" 'True) (C1 ('MetaCons "MkSubjId" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

data Subject t m a Source #

Subject-level data. The API via CohortSpec allows programmers to manipulate contents of subjData only, not subjId. Attempting to process a Subject without any events is ill-defined, hence the use of NonEmpty.

Constructors

MkSubject 

Fields

Instances

Instances details
(Show t, Show m, Show a, Ord a) => Show (Subject t m a) Source # 
Instance details

Defined in Cohort.Cohort

Methods

showsPrec :: Int -> Subject t m a -> ShowS #

show :: Subject t m a -> String #

showList :: [Subject t m a] -> ShowS #

(Eq a, Eq t, Eq m) => Eq (Subject t m a) Source # 
Instance details

Defined in Cohort.Cohort

Methods

(==) :: Subject t m a -> Subject t m a -> Bool #

(/=) :: Subject t m a -> Subject t m a -> Bool #

data AttritionStatus Source #

Internal. Status used for final inclusion/exclusion and the key of attritionByStatus. An observational unit can have multiple Exclude values but only be associated with a single ExcludeBY.

Constructors

Included 
ExcludedBy Text 

Instances

Instances details
ToJSON AttritionStatus Source # 
Instance details

Defined in Cohort.Cohort

Methods

toJSON :: AttritionStatus -> Value

toEncoding :: AttritionStatus -> Encoding

toJSONList :: [AttritionStatus] -> Value

toEncodingList :: [AttritionStatus] -> Encoding

ToJSONKey AttritionStatus Source # 
Instance details

Defined in Cohort.Cohort

Methods

toJSONKey :: ToJSONKeyFunction AttritionStatus

toJSONKeyList :: ToJSONKeyFunction [AttritionStatus]

Generic AttritionStatus Source # 
Instance details

Defined in Cohort.Cohort

Associated Types

type Rep AttritionStatus :: Type -> Type #

Show AttritionStatus Source # 
Instance details

Defined in Cohort.Cohort

Eq AttritionStatus Source # 
Instance details

Defined in Cohort.Cohort

Ord AttritionStatus Source # 
Instance details

Defined in Cohort.Cohort

type Rep AttritionStatus Source # 
Instance details

Defined in Cohort.Cohort

type Rep AttritionStatus = D1 ('MetaData "AttritionStatus" "Cohort.Cohort" "hasklepias-core-0.30.3-inplace" 'False) (C1 ('MetaCons "Included" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ExcludedBy" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

data AttritionInfo Source #

Container for accumulated inclusion/exclusion counts.

Instances

Instances details
ToJSON AttritionInfo Source # 
Instance details

Defined in Cohort.Cohort

Methods

toJSON :: AttritionInfo -> Value

toEncoding :: AttritionInfo -> Encoding

toJSONList :: [AttritionInfo] -> Value

toEncodingList :: [AttritionInfo] -> Encoding

Generic AttritionInfo Source # 
Instance details

Defined in Cohort.Cohort

Associated Types

type Rep AttritionInfo :: Type -> Type #

Show AttritionInfo Source # 
Instance details

Defined in Cohort.Cohort

Eq AttritionInfo Source # 
Instance details

Defined in Cohort.Cohort

type Rep AttritionInfo Source # 
Instance details

Defined in Cohort.Cohort

type Rep AttritionInfo = D1 ('MetaData "AttritionInfo" "Cohort.Cohort" "hasklepias-core-0.30.3-inplace" 'False) (C1 ('MetaCons "MkAttritionInfo" 'PrefixI 'True) (S1 ('MetaSel ('Just "subjectsProcessed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: (S1 ('MetaSel ('Just "unitsProcessed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "attritionByStatus") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map AttritionStatus Int)))))

data ObsId a Source #

Identifier for the unit element of a Cohort, ObsUnit. fromSubjId should refer to the subjId of the Subject from which an ObsUnit was constructed. There should be one ObsId, and hence one ObsUnit, per pair formed from a given Subject and each element of the subject's IndexSet. indexTime gives the element of IndexSet associated with this ObsUnit.

Constructors

MkObsId 

Fields

Instances

Instances details
ToJSON a => ToJSON (ObsId a) Source # 
Instance details

Defined in Cohort.Cohort

Methods

toJSON :: ObsId a -> Value

toEncoding :: ObsId a -> Encoding

toJSONList :: [ObsId a] -> Value

toEncodingList :: [ObsId a] -> Encoding

Generic (ObsId a) Source # 
Instance details

Defined in Cohort.Cohort

Associated Types

type Rep (ObsId a) :: Type -> Type #

Methods

from :: ObsId a -> Rep (ObsId a) x #

to :: Rep (ObsId a) x -> ObsId a #

(Show a, Ord a) => Show (ObsId a) Source # 
Instance details

Defined in Cohort.Cohort

Methods

showsPrec :: Int -> ObsId a -> ShowS #

show :: ObsId a -> String #

showList :: [ObsId a] -> ShowS #

Eq a => Eq (ObsId a) Source # 
Instance details

Defined in Cohort.Cohort

Methods

(==) :: ObsId a -> ObsId a -> Bool #

(/=) :: ObsId a -> ObsId a -> Bool #

Ord a => Ord (ObsId a) Source # 
Instance details

Defined in Cohort.Cohort

Methods

compare :: ObsId a -> ObsId a -> Ordering #

(<) :: ObsId a -> ObsId a -> Bool #

(<=) :: ObsId a -> ObsId a -> Bool #

(>) :: ObsId a -> ObsId a -> Bool #

(>=) :: ObsId a -> ObsId a -> Bool #

max :: ObsId a -> ObsId a -> ObsId a #

min :: ObsId a -> ObsId a -> ObsId a #

type Rep (ObsId a) Source # 
Instance details

Defined in Cohort.Cohort

type Rep (ObsId a) = D1 ('MetaData "ObsId" "Cohort.Cohort" "hasklepias-core-0.30.3-inplace" 'False) (C1 ('MetaCons "MkObsId" 'PrefixI 'True) (S1 ('MetaSel ('Just "fromSubjId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SubjId) :*: S1 ('MetaSel ('Just "indexTime") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Interval a))))

data ObsUnit a Source #

There should be one ObsUnit per pair formed from a given Subject and each element of the subject's IndexSet.

Constructors

MkObsUnit 

Fields

Instances

Instances details
(Show a, Ord a) => Show (ObsUnit a) Source # 
Instance details

Defined in Cohort.Cohort

Methods

showsPrec :: Int -> ObsUnit a -> ShowS #

show :: ObsUnit a -> String #

showList :: [ObsUnit a] -> ShowS #

data EvaluatedSubject a Source #

Internal type to hold the result of Cohort.Core.evaluateSubj. It should not be used for any other purpose.

Constructors

SNoIndex SubjId

Subject had no index. These contribute to the subjectsProcessed count but are silently dropped.

SUnits (SUnitData a) 

Instances

Instances details
(Show a, Ord a) => Show (EvaluatedSubject a) Source # 
Instance details

Defined in Cohort.Cohort

data SUnitData a Source #

Internal. Holds data for SUnits.

Constructors

MkSUnitData 

Fields

  • excludeUnits :: [(ObsId a, Text)]

    Observational units that are to be excluded from the cohort. Only ObsId is retained since no obsData is to be computed. The Text should be the statusLabel field's value of Criterion.

  • includeUnits :: [ObsUnit a]

    Observational units to be included in the cohort, on which runVariables is to be computed.

  • attritionSubj :: AttritionInfo

    Subject-level attrition, to allow computing attritionInfo as each subject is processed.

Instances

Instances details
(Show a, Ord a) => Show (SUnitData a) Source # 
Instance details

Defined in Cohort.Cohort

data Cohort a Source #

Accumulated data from a single list of subjects, processed according to the logic provided in a CohortSpec. It is the output type of evalCohort and should be produced nowhere else.

Constructors

MkCohort 

Instances

Instances details
(Show a, Ord a) => Show (Cohort a) Source # 
Instance details

Defined in Cohort.Cohort

Methods

showsPrec :: Int -> Cohort a -> ShowS #

show :: Cohort a -> String #

showList :: [Cohort a] -> ShowS #

eventsToSubject :: [(Text, Event t m a)] -> [Subject t m a] Source #

Accumulate [(Text, Event t m a)] into [Subject t m a]. The former is the 'flat' output format produced in EventDataTheory.parseEventLinesL'.

incrementAttritionForUnit :: AttritionStatus -> AttritionInfo -> AttritionInfo Source #

Internal. Increment AttritionInfo with a single unit's information. Does not alter subjectsProcessed.

combineAttrition :: AttritionInfo -> AttritionInfo -> AttritionInfo Source #

Combine two AttritionInfo values by summing the counts, and taking the union of attritionByStatus, summing values for shared keys.