Allow uncertainty arguments for various type casting operations

Open
#225 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript
Domain
backend

Research direction

Start by reviewing the CQL-to-ELM translator behavior that inserts ToDecimal calls with uncertainties, then compare the listed ToBoolean, ToDate, ToDateTime, ToQuantity, and ToInteger cases with the specification. Done means the supported conversions and their uncertainty behavior are defined and verified without extending ToString.

Written by the indexing model from the issue text.

Description

This is an interesting one. Looking at the spec, ToDecimal only accepts a Boolean or a String, neither of which can be expressed as an uncertainty. But I see that the test cases you created cause the CQL-to-ELM translator to automatically insert a ToDecimal call, passing in an uncertainty -- so it seems the translator may invoke things technically not in the spec!

I guess we probably should support something like this for some of the other ToXXX functions, particularly those that can take an argument that can be represented by an Uncertainty. That would be:

ToBoolean(argument Decimal) Boolean
ToBoolean(argument Integer) Boolean
ToDate(argument DateTime) Date
ToDateTime(argument Date) DateTime
ToQuantity(argument Decimal) Quantity
ToQuantity(argument Integer) Quantity

I think I would also add ToInteger, because I think the translator maybe would use something like that to try to convert a Decimal to an Integer.

I left toString off the list because the spec does not define how to translate and uncertainty to a String and it also says that the string must be "round-trippable" back to its original type.

All the said, I think it's outside the scope of this task. So I'd suggest we create another bug to track it.

Originally posted by @cmoesel in https://github.com/cqframework/cql-execution/pull/222#discussion_r577873597

Dominant language
JavaScript
Stars
86
Forks
40
PR merge metrics
No merged PRs in 30d

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cqframework/cql-execution

All issues in cqframework/cql-execution

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.