Ratio Equal compares the quotient instead of the numerator and denominator

未关闭 适合新手
#406 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
62/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
javascript
领域
backend

调研方向

问题出在 src/datatypes/ratio.ts 中的 Ratio.equals,它用分子除以分母,然后比较商。equivalent 会调用它,应保留按商比较的逻辑。请先阅读这两个方法,以及它们在比较分子和分母时应使用的 Quantity 相等性辅助函数。当 1:8 = 2:16 返回 false、1:8 != 2:16 返回 true、1:8 ~ 2:16 仍为 true 时即完成。请在现有 ratio 测试旁边添加测试来确认。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
JavaScript
星标
86
派生
40
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cqframework/cql-execution 的其他 Issue

查看 cqframework/cql-execution 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。