Skip to content

Use optional fhirpath.evaluate from QRFContext#45

Open
alexlipovka wants to merge 5 commits intomainfrom
pass-custom-fhirpath-evaluate
Open

Use optional fhirpath.evaluate from QRFContext#45
alexlipovka wants to merge 5 commits intomainfrom
pass-custom-fhirpath-evaluate

Conversation

@alexlipovka
Copy link
Contributor

No description provided.

src/types.ts Outdated
};

export type EvaluateFhirpath = (
fhirData: any,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

evaluate fhirpath should be (context, path, env) => any[]. (pay attention to naming, it's important)

It will make our sdc-qrf model-independent, and we can use it like:

evaluateFhirpath={(context, path, env) => fhirpath(context, path, env, models.r4b, {userInvocationTable: {...}})}

() => getBranchItems(fieldPath, initialContext.questionnaire, initialContext.resource),
[fieldPath, initialContext.questionnaire, initialContext.resource],
);
const { contexts } = useQuestionItemContext({
Copy link
Member

@ruscoder ruscoder Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass evaluateFhirpath also here - this function uses evaluateFHIRPathExpression too

and in resolveTemplateExpr

export function resolveTemplateExpr(
    str: string,
    context: ItemContext,
    path: string,
    evaluateFhirpath,
    returnNullIfUnresolved?: false,
)

and in parseFhirQueryExpression use default evaluateFhirpath

Copy link
Member

@ruscoder ruscoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexlipovka please have a look

@ruscoder
Copy link
Member

@alexlipovka also it will be good to extend isQuestionEnabled with evaluateFhirpath, as well as getEnabledQuestions and removeDIsabledAnswers.
And in QuestionItems pass it from context to getEnabledQuestions

export function parseFhirQueryExpression(
expression: string,
context: ItemContext,
path: string = 'unknown',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add evaluateFhirpath=defaultFhirpathEvaluate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need that default? It internally calls evaluateFHIRPathExpression via resolveTamplateExpr which calls default, when evaluateFhirpath is undefined.

@alexlipovka alexlipovka requested a review from ruscoder March 11, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants