Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support enableWhenExpression #819

Closed
jingtang10 opened this issue Oct 7, 2021 · 12 comments · Fixed by #1294
Closed

Support enableWhenExpression #819

jingtang10 opened this issue Oct 7, 2021 · 12 comments · Fixed by #1294
Assignees
Labels
effort:small Small effort - 2 days P1 High priority issue type:enhancement New feature or request

Comments

@jingtang10
Copy link
Collaborator

jingtang10 commented Oct 7, 2021

Is your feature request related to a problem? Please describe.
See enableWhenExpression mentioned in http://build.fhir.org/ig/HL7/sdc/expressions.html

Describe the solution you'd like
Probably use fhir path engine to evaluate the expression to assist enablement evaluation.

Describe alternatives you've considered
NA

Additional context
NA

Would you like to work on the issue?
NA

@fredhersch
Copy link
Collaborator

@jingtang10 updated the issue to reference the more recent specification page - http://build.fhir.org/ig/HL7/sdc/expressions.html

@delcroip
Copy link
Collaborator

Hello,
as discuss in the dev call, i'd like to say that this feature is a must have for the EmCare project because the business skip logic cannot rely on "enableWhen" because it allows only OR or AND not a mix of OR and AND unlike the "enableWhenExpression" that is much more flexible

@fredhersch
Copy link
Collaborator

Thanks @delcroip

@kunjan8794 Is this something that the Argusoft team could potentially work on?

cc: @jingtang10

@Tarun-Bhardwaj
Copy link

@prajapati-chirag , is there any progress that you have made on this?
CC: @kunjan8794

@Tarun-Bhardwaj
Copy link

@f-odhiambo , can someone from your team pick this up as part of Sprint 2?
CC: @fredhersch

@fredhersch fredhersch added P1 High priority issue and removed P3 Low priority issue labels Mar 22, 2022
@kunjan8794
Copy link
Collaborator

@fredhersch @jingtang10 the link below has the measurements questionnanire that has some FHIRPath enableWhen expressions.

https://github.com/WorldHealthOrganization/smart-emcare/blob/pyfhirsdc/input/resources/questionnaire/questionnaire-EmCare.B6.Measurements.json

@RaaziaTarique
Copy link
Contributor

RaaziaTarique commented Mar 25, 2022

In order to provide enableWhenExpression support in SDK I am going to extend EnablementEvaluator's evaluate method functionality by adding support for enableWhenExpression using FhirPathEngine
I tried to implement the example present in this link http://build.fhir.org/ig/HL7/sdc/expressions.html. Such as,
"expression": "%resource.repeat(item).where(linkId='4.2.1').answer.value.code ='female' and today().toString().substring(0, 4).toInteger() - %resource.repeat(item).where(linkId='4.2.5').answer.value.toString().substring(0, 4).toInteger() >= 40"
FhirPathEngine is able to evaluate this expression but it is not able to evaluate expression similar to this %EmCare.B6.DE02 = true" one.
@delcroip can you verify if this expression is correct? CC: @ekigamba @fredhersch @Tarun-Bhardwaj @jingtang10 @f-odhiambo

@delcroip
Copy link
Collaborator

delcroip commented Mar 25, 2022

@RaaziaTarique to be honest we are waiting for the support on fhirpath to work on the condition

Fhirpath says that we can use the linkid like %linkid but we might change it to %'linkid',
http://build.fhir.org/ig/HL7/sdc/expressions.html#fhirpath-supplements see %context part

therefore the %EmCare.B6.DE02 = true might need to become %'EmCare.B6.DE02' = true or %'EmCare.B6.DE02'.answer.value = true

@ekigamba
Copy link
Contributor

ekigamba commented Mar 30, 2022

@RaaziaTarique Based on what @delcroip has linked, it seems that we also need to support the following FHIR Path supplements:

  • %resource
  • %context
  • Variables defined in the current item or parent item eg. if a variable was defined as score then this should be accessible later in the same item or descendant/child item as %score
  • %questionnaire
  • %qitem

@delcroip I don't seem to find the spec that defines you example. Could you provide another example. We are also having trouble running it successfully.

@RaaziaTarique Let's see if we can support this and have tests for this since it's deifned under the spec and should be supported. However, I think some of the supplements do not make sense for the enableWhen expression eg. the %qItem and %context. These don't make sense or have a use since you cannot have an enableWhen expression that depends on the current questionnaire response item's value

@ekigamba
Copy link
Contributor

It seems that our current FHIR Path version does not natively support %questionnaireand%qitem. The two are described as extensions and have been adopted as local` FHIRPath extensions..

As per http://build.fhir.org/ig/HL7/sdc/expressions.html#fhirpath-supplements

These extensions have been adopted as 'local' FHIRPath extensions for implementers of this implementation guide. Systems that accept FHIRPath, CQL or FHIRQuery expressions SHOULD support all of these extensions in their FHIRPath implementations:

@RaaziaTarique
Copy link
Contributor

  • FhirPathEngine currently supports %resource and %context and they both work similarly, as %context is pointing to the provided resource however it should point to the current traversed Item which can be the root of the QuestionnaireResponse or QuestionnaireItem . If more supports needed for %context then another issue can be created for it.
  • Right now sdk is not supporting variable expression and we have an active issue related to it Add variable Extension support #1059
    CC: @ekigamba @f-odhiambo @delcroip @Tarun-Bhardwaj @jingtang10

@delcroip
Copy link
Collaborator

Thank @ekigamba, after reading it again it seems that i misunderstood, %context works only for the current linkid, as you said, I didn't found what can define my example. (it would have make the enableWhenExpression much clearer)

I will update to something similar to the structure proposed

%resource.repeat(item).where(linkId='4.2.1').answer.value.code ='female'

br

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort:small Small effort - 2 days P1 High priority issue type:enhancement New feature or request
Projects
Archived in project
9 participants