     @expression = build(json.expression)
 
   exec: (ctx) ->
-    @expression.exec(ctx)
+    value = @expression.exec(ctx)
+    ctx.rootContext().set @name,value
+    value
 
 class ExpressionRef extends Expression
   constructor: (json) ->

    @name = json.name

  exec: (ctx) ->
    ctx.get(@name)?.exec(ctx)

# Parameters


    while p = ctx.currentPatient()
      patient_ctx = ctx.childContext({"PATIENT" : p})
      for key,expr of @expressions when expr.context is "PATIENT"
        r.recordPatientResult(patient_ctx.currentPatient().id, key, expr.exec(patient_ctx))
      ctx.nextPatient()
    r
