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

Compile CQL to ELM in the SDK #1365

Closed
vitorpamplona opened this issue May 5, 2022 · 1 comment
Closed

Compile CQL to ELM in the SDK #1365

vitorpamplona opened this issue May 5, 2022 · 1 comment
Assignees
Labels
effort:large Large effort - 5 to 10 days P2 Medium priority issue type:enhancement New feature or request

Comments

@vitorpamplona
Copy link
Collaborator

vitorpamplona commented May 5, 2022

Is your feature request related to a problem? Please describe.

PlanDefinitions can include CQL expressions directly. Those expressions need to be compiled to ELM before running on the device.

Here's a valid Action (subcomponent of PlanDefinition) extracted from EmCare as an example:

{
    "id": "EmCareDT02",
    "description": "Register the child in the encounter",
    "trigger": [
        {
            "type": "named-event",
            "name": "q.EmCareB.Registration.P"
        }
    ],
    "condition": [
        {
            "kind": "applicability",
            "expression": {
                "language": "text/cql-expression",
                "expression": "now() -  5 years > %subject.BirthDate"
            }
        }
    ]
}

The SDK must be able to solve now() - 5 years > %subject.BirthDate.

As another example, the current RuleFilters test case includes a PlanDefinition with a CQL function call:

"condition": [ {
  "kind": "applicability",
  "expression": {
    "description": "Filterable",
    "language": "text/cql.name",
    "expression": "IsReportable"
  }
} ],

The text on expression must be placed inside a CQL library, compiled, and run to execute the IsReportable function.

As a third example, the current RuleFilters test case includes start and stop conditions as CQL:

"condition": [ {
  "kind": "start",
  "expression": {
    "description": "Encounter is active.",
    "language": "text/cql",
    "expression": "encounter.period.start != null and encounter.period.end = null"
  }
}, {
  "kind": "stop",
  "expression": {
    "description": "Encounter is closed.",
    "language": "text/cql",
    "expression": "encounter.period.end != null"
  }
} ]

Again, the text on expression must be placed inside a CQL library, compiled, and run to execute the start and stop conditions.

Describe the solution you'd like

The ideal solution would extract the existing compilation technique from the CQL Translator (PR 748) and expose it to the SDK, through the CQL Evaluator. The solution must also be able to read ModelInfos with Jackson's XML Mapper as opposed to the JAXB unmarshalling, which is awaiting a solution for issue #525

Describe alternatives you've considered

Until now, the SDK was expected to deal with already compiled expressions only, represented as ELM/JSON libraries. This requires the SDK to use a server to compile ELM when uncompiled CQL is present in PlanDefinitions. I don't think that solution is feasible in practice.

Additional context
This is related to issues: #1334, #915, #1055, #656 and #718.

Would you like to work on the issue?
Yes

@vitorpamplona
Copy link
Collaborator Author

Fixed on #1603

Repository owner moved this from In Progress to Complete in Android FHIR SDK Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort:large Large effort - 5 to 10 days P2 Medium priority issue type:enhancement New feature or request
Projects
Status: Complete
Development

Successfully merging a pull request may close this issue.

3 participants