beda-software / fhir-emr

EMR based on FHIR
MIT License
74 stars 30 forks source link

Creating a dynamic text is not possible #321

Open mlaletina95 opened 1 month ago

mlaletina95 commented 1 month ago

Some questions contain placeholders that rely on the user's previous answers.

For example:

Currently it's impossible to make item.text dynamic.

mlaletina95 commented 1 month ago

It would be helpful if this extension https://build.fhir.org/ig/HL7/sdc/examples.html#using-text-and-cqf-expression is implemented.

atuonufure commented 2 weeks ago

image

atuonufure commented 2 weeks ago

Example

  - text: What is your favorite beverage to drink?
    type: string
    linkId: beverageType

  - type: display
    linkId: result
    cqfExpression:
      language: text/fhirpath
      expression: >-
        'Your favorite drink: ' + %QuestionnaireResponse.item.where(linkId='beverageType').answer.value.string
ruscoder commented 1 week ago

The example is wrong. According to the specification it should be:

item:
  - text: Default text
    _text:
      extension:
        - url: http://hl7.org/fhir/StructureDefinition/cqf-expression
          valueExpression:
            language: text/fhirpath
            expression: >-
              'Your favorite drink: ' + %QuestionnaireResponse.item.where(linkId='beverageType').answer.value.string

or in first class extension format:

item:
  - text: Default text
    _text:
      cqfExpression:
        language: text/fhirpath
        expression: >-
          'Your favorite drink: ' + %QuestionnaireResponse.item.where(linkId='beverageType').answer.value.string

Examples of aidbox manifest using Attributes for first class extension (it's necessary for FHIR conversion)

            "Questionnaire.item._text": {
                "path": ["item", "_text"],
                "resource": {"resourceType": "Entity", "id": "Questionnaire"},
            }, 
            "Questionnaire.item._text.extension": {
                "path": ["item", "_text", "extension"],
                "resource": {"resourceType": "Entity", "id": "Questionnaire"},
                "type": {"resourceType": "Entity", "id": "Extension"},
                "isCollection": True,
            }, 
            "Questionnaire.item._text.cqfExpression": {
                "path": ["item", "_text", "cqfExpression"],
                "resource": {"resourceType": "Entity", "id": "Questionnaire"},
                "type": {"resourceType": "Entity", "id": "Expression"},
                "description": "An expression that, when evaluated, provides the value for the element on which it appears.

",
                "extensionUrl": "http://hl7.org/fhir/StructureDefinition/cqf-expression",
            },