event-data-theory-0.30.3: event data theory
Copyright(c) Target RWE 2023
LicenseBSD3
Maintainerbbrown@targetrwe.com ljackman@targetrwe.com dpritchard@targetrwe.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

EventDataTheory.EventLines

Description

 
Synopsis

Documentation

data EventLine t m a Source #

At this time, EventLine, FactsLine, and TimeLine are simply wrapper types in order to create FromJSON instances which can be used to marshal data from ndjson.

See event data model docs

Constructors

MkEventLine Value Value Value Value [t] (FactsLine m a) 

Instances

Instances details
(SizedIv (Interval a), Eventable t m a) => TryFrom (EventLine t m a, ParseEventLineOption) (Event t m a) Source #

Try to parse an EventLine into an Event, given an ParseEventLineOption.

Instance details

Defined in EventDataTheory.EventLines

Methods

tryFrom :: (EventLine t m a, ParseEventLineOption) -> Either (TryFromException (EventLine t m a, ParseEventLineOption) (Event t m a)) (Event t m a)

FromJSONEvent t m a => FromJSON (EventLine t m a) Source # 
Instance details

Defined in EventDataTheory.EventLines

Methods

parseJSON :: Value -> Parser (EventLine t m a)

parseJSONList :: Value -> Parser [EventLine t m a]

(ToJSON a, ToJSON t, ToJSON m) => ToJSON (EventLine t m a) Source # 
Instance details

Defined in EventDataTheory.EventLines

Methods

toJSON :: EventLine t m a -> Value

toEncoding :: EventLine t m a -> Encoding

toJSONList :: [EventLine t m a] -> Value

toEncodingList :: [EventLine t m a] -> Encoding

Generic (EventLine t m a) Source # 
Instance details

Defined in EventDataTheory.EventLines

Associated Types

type Rep (EventLine t m a) :: Type -> Type #

Methods

from :: EventLine t m a -> Rep (EventLine t m a) x #

to :: Rep (EventLine t m a) x -> EventLine t m a #

(Show t, Show a, Show m) => Show (EventLine t m a) Source # 
Instance details

Defined in EventDataTheory.EventLines

Methods

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

show :: EventLine t m a -> String #

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

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

Defined in EventDataTheory.EventLines

Methods

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

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

type Rep (EventLine t m a) Source # 
Instance details

Defined in EventDataTheory.EventLines

type EventLineAble t m a b = (Generic m, Typeable m, Typeable t, Typeable a, SizedIv (Interval a)) Source #

A synonym for the basic class constraints needed to create an EventLine.

parseEventLinesL' :: forall m t a b. (Eventable t m a, EventLineAble t m a b, FromJSONEvent t m a) => ParseEventLineOption -> ByteString -> ([LineParseError], [(SubjectID, Event t m a)]) Source #

Parse Event t m a from new-line delimited JSON.

Per the aeson docs, when using this version: This is a strict version of json which avoids building up thunks during parsing; it performs all conversions immediately. Prefer this version if most of the JSON data needs to be accessed.

Returns a pair where the first element is a list of parse errors and the second element is a list of successfully parsed (subjectID, event) pairs.

Note the input must be UTF-8.

eitherDecodeEvent' :: forall m t a b. (Eventable t m a, EventLineAble t m a b, FromJSONEvent t m a) => ParseEventLineOption -> ByteString -> Either String (SubjectID, Event t m a) Source #

Decode a bytestring corresponding to an EventLine into Either String (SubjectID, Event t m a), where the String is an error message on failure and (SubjectID, Event t m a) is the success case.

NOTE: See https://hackage.haskell.org/package/aeson-2.0.3.0/docs/Data-Aeson.html#g:22 for discusson of json vs json'.

decodeEvent' :: forall m t a b. (Eventable t m a, EventLineAble t m a b, FromJSONEvent t m a) => ParseEventLineOption -> ByteString -> Maybe (SubjectID, Event t m a) Source #

Decode a bytestring corresponding to an EventLine into Maybe (SubjectID, Event t m a), where the value is Nothing on failure and Just (SubjectID, Event t m a) on success.

NOTE: See https://hackage.haskell.org/package/aeson-2.0.3.0/docs/Data-Aeson.html#g:22 for discusson of json vs json'.

newtype LineParseError Source #

Contains the line number and error message of any parsing errors.

Instances

Instances details
Generic LineParseError Source # 
Instance details

Defined in EventDataTheory.EventLines

Associated Types

type Rep LineParseError :: Type -> Type #

Show LineParseError Source # 
Instance details

Defined in EventDataTheory.EventLines

Eq LineParseError Source # 
Instance details

Defined in EventDataTheory.EventLines

From (Natural, String) LineParseError Source # 
Instance details

Defined in EventDataTheory.EventLines

type Rep LineParseError Source # 
Instance details

Defined in EventDataTheory.EventLines

type Rep LineParseError = D1 ('MetaData "LineParseError" "EventDataTheory.EventLines" "event-data-theory-0.30.3-inplace" 'True) (C1 ('MetaCons "MkLineParseError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Natural, String))))

data ParseEventLineOption Source #

Options for how an EventLine will be parsed into an Event.

Constructors

AddMomentToEnd

Add a moment to the end of all intervals, so long as one is provided and 'end x >= begin x'. In particular, this option creates a moment-length interval in the case where 'end x == begin x', which otherwise would fail to parse via IntervalAlgebra.parseInterval.

It does not modify intervals for which the provided end is null, which will fail to parse. See FixEnd and AddMomentAndFix.

DoNotModifyTime

Do not modify the TimeLine before trying to parseInterval.

FixEnd

Convert TimeLine with timeEnd as Nothing to moment - length intervals. Otherwise attempt to parse the interval as-is. An important difference with AddMomentToEnd is that cases where timeEnd == timeBegin are unchanged here and will fail to parse.

AddMomentAndFix

Apply fixes from both FixEnd and AddMomentToEnd.

Instances

Instances details
Show ParseEventLineOption Source # 
Instance details

Defined in EventDataTheory.EventLines

(SizedIv (Interval a), Eventable t m a) => TryFrom (EventLine t m a, ParseEventLineOption) (Event t m a) Source #

Try to parse an EventLine into an Event, given an ParseEventLineOption.

Instance details

Defined in EventDataTheory.EventLines

Methods

tryFrom :: (EventLine t m a, ParseEventLineOption) -> Either (TryFromException (EventLine t m a, ParseEventLineOption) (Event t m a)) (Event t m a)

modifyEventLineWithContext :: forall m m' t t' a b. (Eventable t m a, EventLineAble t m a b, FromJSONEvent t m a, Eventable t' m' a, Data m') => ParseEventLineOption -> (Context t m -> Context t' m') -> ByteString -> Either String (EventLine t' m' a) Source #

This function:

The function may fail and return an error message if either the JSON parsing fails or the EventLine -> Event tranformation fails.

This function does not modify the time information in the EventLine, nor any of the first four elements of the EventLine.

See modifyEventLineWithEvent for a function that can also modify the interval.

data FactsLine m a Source #

Constructors

MkFactsLine 

Instances

Instances details
(FromJSON a, FromJSON m) => FromJSON (FactsLine m a) Source # 
Instance details

Defined in EventDataTheory.EventLines

Methods

parseJSON :: Value -> Parser (FactsLine m a)

parseJSONList :: Value -> Parser [FactsLine m a]

(ToJSON a, ToJSON m) => ToJSON (FactsLine m a) Source # 
Instance details

Defined in EventDataTheory.EventLines

Methods

toJSON :: FactsLine m a -> Value

toEncoding :: FactsLine m a -> Encoding

toJSONList :: [FactsLine m a] -> Value

toEncodingList :: [FactsLine m a] -> Encoding

Generic (FactsLine m a) Source # 
Instance details

Defined in EventDataTheory.EventLines

Associated Types

type Rep (FactsLine m a) :: Type -> Type #

Methods

from :: FactsLine m a -> Rep (FactsLine m a) x #

to :: Rep (FactsLine m a) x -> FactsLine m a #

(Show a, Show m) => Show (FactsLine m a) Source # 
Instance details

Defined in EventDataTheory.EventLines

Methods

showsPrec :: Int -> FactsLine m a -> ShowS #

show :: FactsLine m a -> String #

showList :: [FactsLine m a] -> ShowS #

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

Defined in EventDataTheory.EventLines

Methods

(==) :: FactsLine m a -> FactsLine m a -> Bool #

(/=) :: FactsLine m a -> FactsLine m a -> Bool #

type Rep (FactsLine m a) Source # 
Instance details

Defined in EventDataTheory.EventLines

type Rep (FactsLine m a) = D1 ('MetaData "FactsLine" "EventDataTheory.EventLines" "event-data-theory-0.30.3-inplace" 'False) (C1 ('MetaCons "MkFactsLine" 'PrefixI 'True) ((S1 ('MetaSel ('Just "time") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TimeLine a)) :*: S1 ('MetaSel ('Just "facts") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 m)) :*: (S1 ('MetaSel ('Just "patient_id") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SubjectID) :*: (S1 ('MetaSel ('Just "source") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Source)) :*: S1 ('MetaSel ('Just "valid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Bool))))))

data TimeLine a Source #

Constructors

MkTimeLine 

Fields

Instances

Instances details
FromJSON a => FromJSON (TimeLine a) Source # 
Instance details

Defined in EventDataTheory.EventLines

Methods

parseJSON :: Value -> Parser (TimeLine a)

parseJSONList :: Value -> Parser [TimeLine a]

ToJSON a => ToJSON (TimeLine a) Source # 
Instance details

Defined in EventDataTheory.EventLines

Methods

toJSON :: TimeLine a -> Value

toEncoding :: TimeLine a -> Encoding

toJSONList :: [TimeLine a] -> Value

toEncodingList :: [TimeLine a] -> Encoding

Show a => Show (TimeLine a) Source # 
Instance details

Defined in EventDataTheory.EventLines

Methods

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

show :: TimeLine a -> String #

showList :: [TimeLine a] -> ShowS #

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

Defined in EventDataTheory.EventLines

Methods

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

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

Orphan instances

Exception ParseErrorInterval Source # 
Instance details

Methods

toException :: ParseErrorInterval -> SomeException #

fromException :: SomeException -> Maybe ParseErrorInterval #

displayException :: ParseErrorInterval -> String #