Adding a UCUM 'mo' or 'a' to a Date or DateTime returns a value instead of an error

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

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript
Domain
backend

Research direction

The bug is in how cql-execution adds and subtracts definite-duration UCUM units ('mo', 'a') to Date and DateTime values; the spec requires an error there while 'wk' is allowed. Start by finding the date/time Add and Subtract implementations in the library's source and the Quantity-to-duration conversion they call, then reproduce the three table rows in a small script. Done when the 'mo' and 'a' cases throw an error and 'wk' still returns the expected date, with tests covering both.

Written by the indexing model from the issue text.

Description

Summary

Add for date and time values (1.5.3 and 2.0):

However, to avoid the potential confusion of calendar-based date and time arithmetic with definite-duration date and time arithmetic, it is an error to attempt to add a definite-duration time-valued unit above days (and weeks), a calendar duration must be used.

UCUM 'mo' and 'a' are definite-duration units. The calendar units are month and year. Subtract says the same.

Expression cql-execution Spec Java engine 5.8.0
@2014-01-01 + 1 'mo' @2014-02-01 error error
@2014-01-01T10:00 + 1 'a' @2015-01-01T10:00 error error
@2014-01-01 + 1 'wk' @2014-01-08 @2014-01-08 (allowed)

Environment

cql-execution master e8096c6, through test-server (the build has two unrelated Quantity modulo commits on top). The Java engine column is HAPI FHIR 9.0.0 with clinical-reasoning 4.17.0, through $cql.

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.