Context
This ticket tracks the follow-up work needed for the setValue effect on the
feature/add-fhir-requirements branch.
Problem Statement
The current setValue implementation mixes two separate concerns:
- When the rule should fire.
- What value should be assigned when it does fire.
That design works for simple expression-based cases, but it breaks down for:
- Conditional set-value rules where a non-expression condition gates the rule.
- Selection fields where the target value should be an
optionId, not a free-form expression.
- FHIR import mapping, where
initialExpression / related inputs should round-trip into a more explicit setValue payload.
Proposed Solution
Add a dedicated setValue payload to each rule instead of encoding the value source inside the condition list.
Suggested shape:
type SetValuePayload =
| { type: 'expression'; expression: string }
| { type: 'option'; optionId: string };
interface Rule {
effect: EffectType;
conditions: Condition[];
setValue?: SetValuePayload;
}
Implementation Checklist
Success Criteria
- A field can use a field-based condition gate and still resolve a separate computed value
- Selection fields can be driven by an
optionId payload instead of a free-form expression
- Existing expression-based
setValue rules continue to work
- FHIR import/export behavior preserves the intent of
initialExpression style rules
Related Files
packages/core/src/lib/types.ts
packages/core/src/lib/logic/resolve.ts
packages/core/src/lib/field-component-props.ts
packages/builder/src/lib/components/edit-panel/LogicEditor.tsx
packages/adapters/src/fhir/fhir-adapter.ts
Context
This ticket tracks the follow-up work needed for the
setValueeffect on thefeature/add-fhir-requirementsbranch.Problem Statement
The current
setValueimplementation mixes two separate concerns:That design works for simple expression-based cases, but it breaks down for:
optionId, not a free-form expression.initialExpression/ related inputs should round-trip into a more explicitsetValuepayload.Proposed Solution
Add a dedicated
setValuepayload to each rule instead of encoding the value source inside the condition list.Suggested shape:
Implementation Checklist
packages/core/src/lib/types.tsto addSetValuePayloadandsetValue?onRulepackages/core/src/lib/logic/resolve.tssoresolveSetValue()readsrule.setValuefirstpackages/builder/src/lib/components/edit-panel/LogicEditor.tsxto expose the right authoring UI per field typepackages/adapters/src/fhir/fhir-adapter.tsso imported FHIR expressions map into the newsetValueshaperesolveSetValue()and rule hydrationSuccess Criteria
optionIdpayload instead of a free-form expressionsetValuerules continue to workinitialExpressionstyle rulesRelated Files
packages/core/src/lib/types.tspackages/core/src/lib/logic/resolve.tspackages/core/src/lib/field-component-props.tspackages/builder/src/lib/components/edit-panel/LogicEditor.tsxpackages/adapters/src/fhir/fhir-adapter.ts