Ratio Equal compares the quotient instead of the numerator and denominator
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 62/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript
- Domain
- backend
Research direction
The bug is in Ratio.equals in src/datatypes/ratio.ts, which divides numerator by denominator and compares quotients; equivalent calls it and should keep the quotient comparison. Start by reading those two methods and the Quantity equality helper they should use for numerator and denominator. Done when 1:8 = 2:16 returns false, 1:8 != 2:16 returns true, and 1:8 ~ 2:16 stays true, confirmed by adding tests next to the existing ratio tests.
Written by the indexing model from the issue text.
Description
Summary
1:8 = 2:16 is true, but Equal (1.5.3 and 2.0) says:
For ratios, this means that the numerator and denominator must be the same, using quantity equality semantics.
The spec's own example is define "RatioEqualIsFalse": 1:8 = 2:16. Comparing the quotients is what Equivalent specifies: "For ratios, equivalent means that the numerator and denominator represent the same ratio (e.g. 1:100 ~ 10:1000)".
| Expression | cql-execution | Spec | Java engine 5.8.0 |
|---|---|---|---|
1:8 = 2:16 |
true |
false |
false |
1:8 != 2:16 |
false |
true |
true |
1:8 = 1:8 |
true |
true |
true |
1:8 ~ 2:16 |
true |
true |
true |
Cause
Ratio.equals (src/datatypes/ratio.ts) divides each numerator by its denominator and compares the results, and Ratio.equivalent calls equals. equals should compare numerator with numerator and denominator with denominator, using Quantity equality. equivalent keeps the quotient comparison.
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cqframework/cql-execution
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cqframework/cql-execution#410 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cqframework/cql-execution#407 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
cqframework/cql-execution#414 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
cqframework/cql-execution#413 ·
-
Length throws TypeError when its null operand is not an As expression (e.g. an expression reference)Open
Difficulty 3/5 1-2 days Newbie friendliness 65/100
cqframework/cql-execution#412 ·
All issues in cqframework/cql-execution
Similar issues
-
Mend: dependency security vulnerability
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
ManageIQ/manageiq-ui-service#2259 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
sagemathinc/sagebrush-agent#230 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
electerious/Ackee#411 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
babalae/bettergi-scripts-list#3905 · 1 comment ·
Maintainers usually reply within 1 day