anchor.diff:              )
           Eventful.AggregateActionBuilder.fullHandler systemConfiguration s withMetadata
   
  -    let stateBuilder = NamedStateBuilder.nullStateBuilder<EmergencyEventMetadata>
  -
  +    type VisitState = {
  +        Registered : bool
  +        CurrentTriageLevel : Option<TriageLevel>
  +        RegistrationTime : Option<DateTime>
  +        DischargeTime : Option<DateTime>
  +    }
  +    with static member Empty = { 
  +            Registered = false
  +            CurrentTriageLevel = None
  +            DischargeTime = None
  +            RegistrationTime = None }
  +
  +    let visitStateBuilder = 
  +        StateBuilder.Empty VisitState.Empty
  +        |> StateBuilder.addHandler (fun s (e:PatientTriagedEvent) ->
  +            { s with CurrentTriageLevel = Some e.TriageLevel })
  +        |> StateBuilder.addHandler (fun s (e:PatientRegisteredEvent) ->
  +            { s with   
  +                 Registered = true
  +                 RegistrationTime = Some e.RegistrationTime })
  +        |> StateBuilder.addHandler (fun s (e:PatientDischargedEvent) ->
  +            { s with DischargeTime = Some e.DischargeTime })
  +        
       let isRegistered = 
           StateBuilder.Empty false
           |> StateBuilder.addHandler (fun s (e:PatientRegisteredEvent) -> true)
  
positive.code:     | Triaged of PatientTriagedEvent
      | Registered of PatientRegisteredEvent
      | PickedUp of PatientPickedUpEvent
      | Discharged of PatientDischaredEvent
  
      let systemConfiguration = { 
          SetSourceMessageId = (fun id metadata -> { metadata with SourceMessageId = id })
          SetMessageId = (fun id metadata -> { metadata with MessageId = id })
      }
  
      let inline simpleHandler s f = 
          let withMetadata = f >> (fun x -> (x, { SourceMessageId = String.Empty; MessageId = Guid.Empty }))
          Eventful.AggregateActionBuilder.simpleHandler systemConfiguration s withMetadata
  
      let inline fullHandler s f =
          let withMetadata a b c =
  
negative.code: type DischargePatientCommand = {
      VisitId : VisitId
      DischargeLocation : DischargeLocation
      DischargeTime : DateTime
  }
  
  type PatientDischargedEvent = {
      VisitId : VisitId
      DischargeLocation : DischargeLocation
      DischargeTime : DateTime
  }
  
  open Eventful.AggregateActionBuilder
  