openehr-rails 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -1
- data/CLAUDE.md +18 -11
- data/docs/design/0.9.x-plan.md +146 -0
- data/docs/reports/0.9.0-log.md +28 -0
- data/docs/reports/0.9.x-log.md +78 -0
- data/lib/openehr_rails/fhir/fsh_generator.rb +9 -32
- data/lib/openehr_rails/fhir/profile_generator.rb +7 -9
- data/lib/openehr_rails/fhir/profile_identity.rb +61 -0
- data/lib/openehr_rails/version.rb +1 -1
- data/lib/openehr_rails.rb +1 -0
- data/spec/fixtures/fsh/{openehr-evaluation-problem-diagnosis-v1.fsh → openehr-problemlist-evaluation-problem-diagnosis-v1.fsh} +3 -3
- data/spec/generators/openehr/fhir_profile/fhir_profile_generator_spec.rb +4 -4
- data/spec/generators/openehr/fhir_profile/remote_fhir_profile_generator_spec.rb +1 -1
- data/spec/openehr_rails/fhir/fsh_generator_spec.rb +15 -15
- data/spec/openehr_rails/fhir/profile_generator_spec.rb +12 -12
- data/spec/openehr_rails/fhir/profile_identity_spec.rb +88 -0
- data/spec/openehr_rails/fhir_instruction_skip_spec.rb +1 -1
- data/spec/openehr_rails/rm/composition_committer_context_spec.rb +16 -10
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9ed0f84c56e26f5ddc27a5e0ee5f0645d00ed9733ab0e1a21c3aeabd84b6bbdf
|
|
4
|
+
data.tar.gz: 964a88f7dd7cf29b3e68ac4275da65606df431e1d02ebce900c317ab67dc4c5b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e1390271d15a1fc2c82106ee61fdb1bea232a2a127d65788144f8b5764b12af420d4c44b108511f1c8d29b4572cbbb6479fcb03a708d275215e58450ba56b0a9
|
|
7
|
+
data.tar.gz: af8768d334a02a6d7963f95d20ffdd5f2659d75ee470a609a88383aed867ac43026a596134954eec8e864c6a0326ee867fd48ca8599616e8a805425c4c844be7
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.10.0] - 2026-11-25
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- **Upgrade note.** FHIR StructureDefinitions are qualified by their template, so two
|
|
14
|
+
templates that use the same archetype with different constraints no longer produce
|
|
15
|
+
the same profile: `id` is `openehr-<template slug>-<archetype slug>` (e.g.
|
|
16
|
+
`openehr-bmi-calculation-observation-height-v2`, was
|
|
17
|
+
`openehr-observation-height-v2`; an id longer than 64 characters keeps a prefix and
|
|
18
|
+
ends in 8 hex digits of its sha256), `url` is
|
|
19
|
+
`urn:openehr:<template_id>:<archetype_id>`, `name` is the id camelized
|
|
20
|
+
(`OpenehrBmiCalculationObservationHeightV2`; the JSON `name` used to be the bare
|
|
21
|
+
concept, `Height`, and disagreed with the FSH `Profile:` name) and `title` names the
|
|
22
|
+
template. Files written by `--fhir` / `openehr:fhir_profile` under
|
|
23
|
+
`app/fhir/profiles/` take the new ids as file names: regenerate them. Anything that
|
|
24
|
+
references a profile by its old id or url must be updated. The constraints inside
|
|
25
|
+
each profile are unchanged (#55, anlage upstream 23).
|
|
26
|
+
- `ProfileGenerator` (JSON) and `FshGenerator` take id, url, name and title from one
|
|
27
|
+
place, `OpenehrRails::Fhir::ProfileIdentity`, so the two outputs cannot disagree
|
|
28
|
+
(#55).
|
|
29
|
+
|
|
30
|
+
### Known limitations
|
|
31
|
+
- FHIR Observation *instance* ids still use the archetype-only slug, so two models
|
|
32
|
+
sharing an archetype can produce the same instance id (#76).
|
|
33
|
+
- With openehr 2.6.0 or later (allowed by the unchanged `~> 2.5`), AQL reaches the
|
|
34
|
+
composition context: `SELECT c/context/start_time/value` and a `WHERE` on it are
|
|
35
|
+
answered, lifting the 0.9.0 limitation below. With openehr 2.5.x it still applies.
|
|
36
|
+
`SELECT c/uid/value` is not answered yet under 2.6.0 (`unsupported path attribute
|
|
37
|
+
"uid"`) (#46).
|
|
38
|
+
|
|
10
39
|
## [0.9.0] - 2026-11-24
|
|
11
40
|
|
|
12
41
|
> **Upgrade note.** Four things change for an existing host app.
|
|
@@ -104,7 +133,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
104
133
|
yet: the openehr AQL path evaluator (2.5.0 included) cannot navigate `EVENT_CONTEXT`
|
|
105
134
|
and raises `unsupported path attribute "start_time"` as soon as a composition has a
|
|
106
135
|
context. The values are stored and rebuilt by `to_rm`; querying them waits for an
|
|
107
|
-
openehr release.
|
|
136
|
+
openehr release. (openehr 2.6.0 lifts this for `start_time`; see 0.10.0.)
|
|
108
137
|
- `context.other_context` is not persisted, and `CanonicalSerializer` does not emit
|
|
109
138
|
`context` yet (#46 stays open for both).
|
|
110
139
|
|
data/CLAUDE.md
CHANGED
|
@@ -67,7 +67,11 @@ matching `release:check` guard is `skoba/openehr-rails#34`.)
|
|
|
67
67
|
moved 4.0.6 -> 4.0.7 (2026-10-12) so a local rebuild at the tag stamps the same
|
|
68
68
|
`rubygems_version` (4.0.20) as `ruby/setup-ruby`'s ruby 4.0 image did for 0.7.1,
|
|
69
69
|
whose `metadata.gz` differed from the local rebuild by that one line
|
|
70
|
-
(`docs/reports/referral-upstream-log.md` R2)
|
|
70
|
+
(`docs/reports/referral-upstream-log.md` R2), and 4.0.7 -> 4.0.10 (2026-11-19,
|
|
71
|
+
PR #56) once CI's `'4.0'` resolved to 4.0.10. Confirm the CI side from a run log
|
|
72
|
+
before moving the pin. For 0.9.0 (ruby 4.0.10 / rubygems 4.0.20 on both sides)
|
|
73
|
+
the local rebuild matched the CI artifact down to the whole-gem sha256
|
|
74
|
+
(`docs/reports/0.9.0-log.md` R9). The cross-check still judges by
|
|
71
75
|
`data.tar.gz`, not the whole-gem sha256: the two toolchains can drift apart again.
|
|
72
76
|
|
|
73
77
|
**Confirm publication by checksum, not by version number.** RubyGems publishes
|
|
@@ -162,7 +166,7 @@ authorized for the task at hand. A matching line is planned for `anlage`'s own
|
|
|
162
166
|
`CLAUDE.md` in a later batch - not yet added there as of this entry. Update
|
|
163
167
|
2026-09-04: added there as 絶対規律 item 9.)
|
|
164
168
|
|
|
165
|
-
## 裁定台帳(2026-11-20
|
|
169
|
+
## 裁定台帳(2026-11-20 導入、2026-11-24 改定)
|
|
166
170
|
|
|
167
171
|
- 統括の裁定の正典は `/home/skoba/src/anlage-ops/rulings.md`
|
|
168
172
|
(非公開リポジトリ `skoba/anlage-ops`)。チャットに貼られた本文は写しで、
|
|
@@ -170,11 +174,13 @@ authorized for the task at hand. A matching line is planned for `anlage`'s own
|
|
|
170
174
|
- 「裁定 R-… を読んで着手」と言われたら、最初に
|
|
171
175
|
`git -C /home/skoba/src/anlage-ops pull --ff-only` を実行し、
|
|
172
176
|
台帳の該当行と本文を読む。読めなければ、着手せずに例外報告
|
|
173
|
-
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
-
|
|
177
|
+
- `rulings.md` は統括だけが書く。セッションは書き換えない
|
|
178
|
+
- 進み具合は `/home/skoba/src/anlage-ops/status/openehr-rails.md` に書く。
|
|
179
|
+
裁定 ID の見出しの下に、日付つきの行を書き足す(着手、PR 番号、SHA、CI run、
|
|
180
|
+
ゲート報告の提出、完了申請)。古い行は消さない。書いたら commit・push する
|
|
181
|
+
- anlage-ops に書いてよいのは、自分のレーンのこの 1 ファイルだけ。
|
|
182
|
+
これは越境ゲートの例外として認められている
|
|
183
|
+
- 完了に進めるのは統括か人間。セッションは完了申請まで
|
|
178
184
|
- 報告とコミットメッセージには裁定 ID を書く(例: `Refs R-20261120-1`)
|
|
179
185
|
- anlage-ops の内容(裁定の本文、ロードマップ)を、このリポジトリのコード、
|
|
180
186
|
Issue、PR、文書に写さない。参照は裁定 ID で行う
|
|
@@ -240,7 +246,7 @@ anlage の `CLAUDE.md`「作業ツリー規律」と同旨。根拠と採らな
|
|
|
240
246
|
- **必ず止まってゲート報告を出す範囲**: 計画書に無い挙動の変更と公開 API の変更。
|
|
241
247
|
gem の追加と未リリースのコードへの依存。データの移行と削除、開発機の設定の変更。
|
|
242
248
|
臨床の判断と人間の入力を待つもの。タグと publish。ほかのリポジトリへの書き込み
|
|
243
|
-
(
|
|
249
|
+
(`anlage-ops` の `status/openehr-rails.md` は除く)
|
|
244
250
|
- **セッションが自分でマージしてよい PR**: 自分で開いた、docs のみの PR と、
|
|
245
251
|
止まらずに進める範囲の実装の PR。条件は、head の CI がすべて green、競合なし、
|
|
246
252
|
1 Issue = 1 PR。マージのあと `master` の CI を確かめ、赤なら次に進まず例外報告。
|
|
@@ -254,8 +260,9 @@ anlage の `CLAUDE.md`「作業ツリー規律」と同旨。根拠と採らな
|
|
|
254
260
|
(タグの時点で `changelog.d/` に断片が残っていないこと)
|
|
255
261
|
- **公開はできた順**: 公開できる中身が `master` にそろったら棚卸しに進む。
|
|
256
262
|
手順は Release convention のとおりで、変えない
|
|
257
|
-
- **報告**: ゲート・バンドル・例外の報告は `docs/reports/` に push
|
|
258
|
-
|
|
263
|
+
- **報告**: ゲート・バンドル・例外の報告は `docs/reports/` に push し、
|
|
264
|
+
`status/openehr-rails.md` に PR 番号と SHA を書き足す(R-20261124-18)。
|
|
265
|
+
次の裁定を待たずに、作業列の次の項目に進む
|
|
259
266
|
- **変えないもの**: TDD(Red の出力を報告に載せる)、合否は CI、実測と推論の区別、
|
|
260
267
|
越境は読み取りだけ、publish は CI artifact だけで `gem push` は人間
|
|
261
268
|
|
|
@@ -331,7 +338,7 @@ This is `openehr-rails`, a Rails engine gem that turns an openEHR Operational Te
|
|
|
331
338
|
|
|
332
339
|
## Development Notes
|
|
333
340
|
|
|
334
|
-
- Ruby 3.3+ required (raised from 3.0 in 2026-08 to track the `openehr` gem dependency dropping Ruby 3.2 support at EOL); CI matrix covers 3.3/3.4/4.0, local dev pinned via `.ruby-version` (currently 4.0.
|
|
341
|
+
- Ruby 3.3+ required (raised from 3.0 in 2026-08 to track the `openehr` gem dependency dropping Ruby 3.2 support at EOL); CI matrix covers 3.3/3.4/4.0, local dev pinned via `.ruby-version` (currently 4.0.10)
|
|
335
342
|
- Rails 7.0+ and Rails 8.x supported (CI matrix: `gemfiles/rails_{7_2,8_0,8_1}.gemfile`; demo app runs on Rails 8.1)
|
|
336
343
|
- URI compatibility workaround implemented for Ruby 3.4
|
|
337
344
|
- `ostruct` is an explicit development dependency — it left Ruby's default gems as of 4.0, and a couple of specs use `OpenStruct` as a lightweight test double
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# 0.9.x の計画(0.9.0 のあとの作業列)
|
|
2
|
+
|
|
3
|
+
裁定 ID: R-20261124-16。状態: **作業列の計画**(R-20261124-8 により、push したらそのまま実装に進む。確認は事後)。
|
|
4
|
+
6(DV_DATE_TIME の部分精度)だけは、列を足す変更なので、その計画を出したところでゲート報告にする。
|
|
5
|
+
|
|
6
|
+
- 基準点: openehr-rails master `7555fb9`(公開版 0.9.0、タグ `v0.9.0` → `2511eec`)。openehr 2.5.0
|
|
7
|
+
- 読んだ他リポジトリ(読み取りのみ): anlage `origin/main` `0993e4c` の `docs/design/rm-attributes-without-inputs.md`
|
|
8
|
+
(承認済み、R-20261124-14)。anlage の `app/`・`lib/` に narrative の実装はまだ無い(`git grep`、0 件)
|
|
9
|
+
- 「実測」はこのリポジトリの作業ツリーで実行または grep したもの。「推論」は根拠を添える
|
|
10
|
+
|
|
11
|
+
## 1. 順序と公開の切れ目
|
|
12
|
+
|
|
13
|
+
| 順 | 項目 | Issue | 待つもの | 版 |
|
|
14
|
+
|---|---|---|---|---|
|
|
15
|
+
| 1 | この計画書と、CLAUDE.md の Ruby の版の記述(作業列 7。docs のみ) | — | なし | — |
|
|
16
|
+
| 2 | FHIR の profile id をテンプレートで修飾する | #55 | なし | **0.9.1**(入ったら棚卸し) |
|
|
17
|
+
| 3a | `Storable`: 埋め込み CLUSTER 配下の field | #61 | なし | 0.9.2 |
|
|
18
|
+
| 3b | `Storable`: SECTION 配下の entry と、同じアーキタイプの entry の繰り返し | #62 | なし | 0.9.2 |
|
|
19
|
+
| 3c | `Storable`: INSTRUCTION(narrative、ACTIVITY) | #69 | なし | 0.9.2 |
|
|
20
|
+
| 4 | gem に入るファイルの整理 | #74 | なし | 0.9.2(または 0.9.1 に間に合えば) |
|
|
21
|
+
| — | DV_TEXT 葉の `CodeableConcept` への写像 | #48 | なし | 3 のあと |
|
|
22
|
+
| — | 条件つき必須の validation | #65 | 3 のあと(entry の単位が決まってから) | 設計を先に |
|
|
23
|
+
| — | `other_context` と `CanonicalSerializer` の `context` | #46 の残り | 3 のあと | 設計を先に |
|
|
24
|
+
| 5 | 再構築した Composition の `archetype_details` | #64 | openehr-ruby#70 の公開 | 公開後 |
|
|
25
|
+
| 6 | DV_DATE_TIME の部分精度 | #63 | openehr-ruby#59 の公開 | **計画でゲート** |
|
|
26
|
+
|
|
27
|
+
- 公開はできた順(R-20261124-8 の 1)。2 が入った時点で 0.9.1 の棚卸しに進む。3 は 3a〜3c がそろってから 0.9.2
|
|
28
|
+
- semver の見込み: 2 は id・url・name が変わるので 0.x の minor 相当だが、裁定(R-20261124-16)が 0.9.1 としている。
|
|
29
|
+
棚卸しで実内容から判定し、patch の範囲を超えるなら版番号を変える前に止まって再裁定を求める(Release convention)
|
|
30
|
+
|
|
31
|
+
## 2. #55: profile id のテンプレートでの修飾
|
|
32
|
+
|
|
33
|
+
### 2.1 いまの状態(実測)
|
|
34
|
+
|
|
35
|
+
- id は `ProfileGenerator#profile_id`(`profile_generator.rb:203`)と `FshGenerator#profile_id`(`fsh_generator.rb:203`)に同じ式が 2 つある。
|
|
36
|
+
どちらもアーキタイプ ID だけから作る
|
|
37
|
+
- JSON の `name` は `entry[:concept].camelize`(`Height`)、FSH の `Profile:` は id から作る(`OpenehrObservationHeightV2`)。
|
|
38
|
+
**JSON と FSH で name が食い違っている**
|
|
39
|
+
- `url` は JSON だけが持つ(`urn:openehr:<archetype_id>`)。FSH は `^url` を書かない(SUSHI の canonical から決まる)
|
|
40
|
+
- 3 つめの同じ式が `ResourceRegistry::Entry#slug`(`resource_registry.rb:16`)にあるが、これは profile id ではなく、
|
|
41
|
+
Observation インスタンスの id(`"#{record.id}-#{slug}"`、`serializer.rb:30`)と、その逆引き(`fhir_controller.rb:98`)に使われる
|
|
42
|
+
|
|
43
|
+
### 2.2 案(R-20261124-7 の問い 5: テンプレートで修飾した id を既定にする)
|
|
44
|
+
|
|
45
|
+
`Fhir::ProfileIdentity`(新設)が、テンプレート ID とアーキタイプ ID から 4 つを返す。両 generator はこれだけを使う。
|
|
46
|
+
|
|
47
|
+
| 項目 | 形 | 例(`bmi_calculation`、height) |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| `id` | `openehr-<テンプレートの slug>-<アーキタイプの slug>`。slug は `parameterize.dasherize`。64 文字を超えたら、先頭 55 文字 + `-` + 全体の sha256 の先頭 8 桁 | `openehr-bmi-calculation-observation-height-v2` |
|
|
50
|
+
| `url` | `urn:openehr:<template_id>:<archetype_id>` | `urn:openehr:bmi_calculation:openEHR-EHR-OBSERVATION.height.v2` |
|
|
51
|
+
| `name` | id の `-` を区切りに camelize(FHIR の name の規則 `[A-Z][A-Za-z0-9_]*`) | `OpenehrBmiCalculationObservationHeightV2` |
|
|
52
|
+
| `title` | `openEHR <concept の humanize> (<template_id>: <archetype_id>)` | `openEHR Height (bmi_calculation: openEHR-EHR-OBSERVATION.height.v2)` |
|
|
53
|
+
|
|
54
|
+
- JSON と FSH の `name` はこれで一致する(FSH の `Profile:` は従来から id 由来なので、FSH 側は「修飾が付く」だけ)
|
|
55
|
+
- アーキタイプだけの id を出すオプションは作らない(使う人がいない。必要になったら足す)
|
|
56
|
+
- `Entry#slug`(インスタンスの id)は変えない。2 つのモデルが同じアーキタイプを使うと、`"1-<slug>"` がモデルをまたいで重なりうる(推論)。
|
|
57
|
+
別の Issue に起票する
|
|
58
|
+
|
|
59
|
+
### 2.3 Red から始める spec の見出し
|
|
60
|
+
|
|
61
|
+
- 「同じアーキタイプを使う 2 テンプレート(`problem_list.opt` と `jp_referral.opt`)の profile id が衝突しない」(JSON・FSH の両方)
|
|
62
|
+
- 「JSON の id・url・name と、FSH の `Id:`・`Profile:` が同じ表から出る」
|
|
63
|
+
- 「id は 64 文字以内で `[A-Za-z0-9\-\.]` だけ。長いテンプレート ID では sha256 の接尾辞で切り詰める」
|
|
64
|
+
- 既存の id・url・name・title を固定している例と golden FSH(`spec/fixtures/fsh/…`)は、新しい形に書き換える(golden のファイル名も id に合わせる)
|
|
65
|
+
- regression pin: 写像の中身(differential、FSH の規則行)は変わらない
|
|
66
|
+
|
|
67
|
+
### 2.4 Upgrade note に書くこと
|
|
68
|
+
|
|
69
|
+
- StructureDefinition の id・url・name・title が変わる。`app/fhir/profiles/<id>.json` のファイル名も変わる(`--fhir` で書き出したものは再生成が要る)
|
|
70
|
+
- 外部から profile の url を参照している場合(インスタンスの `meta.profile` など)は付け替えが要る。このリポジトリの serializer は `meta.profile` を書かない(実測)
|
|
71
|
+
|
|
72
|
+
## 3. `Storable` の書き込み経路(#61・#62・#69)
|
|
73
|
+
|
|
74
|
+
0.9.0 の歯止め(#60)で止めている 3 つの形を、正しく組めるようにする。歯止めは形ごとに外す(1 Issue = 1 PR)。
|
|
75
|
+
|
|
76
|
+
### 3.1 共通: entry の単位
|
|
77
|
+
|
|
78
|
+
- いまは `field[:archetype_id]` で entry をまとめる(`storable.rb` の `rm_content`)。これを、field の path の
|
|
79
|
+
**entry の部分**(先頭から entry ルートの `[archetype_id]` まで)と、entry の何番目の出現か、でまとめる
|
|
80
|
+
- 何番目かは、0.9.0 で足した `instance_index` から決める。`instance_index` を持たない `FIELD_MAP`
|
|
81
|
+
(0.9.0 より前に生成したもの)は、SECTION・埋め込みルート・INSTRUCTION を含むなら歯止めを残し、
|
|
82
|
+
メッセージを「0.9.0 以降で再 scaffold してください」に変える
|
|
83
|
+
|
|
84
|
+
### 3.2 #61 埋め込み CLUSTER
|
|
85
|
+
|
|
86
|
+
- path の埋め込みルートのセグメント(0.9.0 から `[archetype_id]`)を、`_type: CLUSTER`・`archetype_node_id: <archetype_id>`・
|
|
87
|
+
`archetype_details` を持つノードとして組む。0.9.0 より前の path(`[at0000]` 形)は 3.1 の歯止めで止める
|
|
88
|
+
- 同じ path に 2 つのルート(`jp_referral` の organisation ×2)は、`instance_index` で別のノードにする
|
|
89
|
+
- Red: 「`lab_result_report_reduced` のモデルが、OBSERVATION 1 つの中に埋め込み CLUSTER を持つ Composition を保存し、`rm_graph.to_rm` で組み直せる」
|
|
90
|
+
|
|
91
|
+
### 3.3 #62 SECTION
|
|
92
|
+
|
|
93
|
+
- path の entry より前の部分(`/content[SECTION]/items[ENTRY]`)を、`content` 配下の `SECTION` ノード(`archetype_details` つき)と、その `items` として組む
|
|
94
|
+
- 同じアーキタイプの entry の繰り返し(`clinical_synopsis` ×2)は別の entry にする
|
|
95
|
+
- Red: 「`jp_referral` の EVALUATION と OBSERVATION の値を入れたモデルが、`content: [SECTION { items: [...] }]` を保存し、`to_rm` で組み直せる」
|
|
96
|
+
|
|
97
|
+
### 3.4 #69 INSTRUCTION
|
|
98
|
+
|
|
99
|
+
anlage の規則にそろえる(R-20261124-19)。正は anlage の設計書 `docs/design/rm-attributes-without-inputs.md` 6 節「決めたつなぎ方」
|
|
100
|
+
(読んだのは anlage PR #116 の `edbdb18`。実装は同じ PR の `app/lib/opt/composition_builder.rb` の `narrative`・`narrative_value`)。
|
|
101
|
+
|
|
102
|
+
| 属性 | 値の出どころ |
|
|
103
|
+
|---|---|
|
|
104
|
+
| `narrative`(DV_TEXT、必須) | 下の「つなぎ方」 |
|
|
105
|
+
| ACTIVITY の `description` | field の path から組む(いまの `new_rm_node` と同じ) |
|
|
106
|
+
| ACTIVITY の `action_archetype_id`(必須) | OPT の制約(`action_archetype_id` の C_STRING のパターン)。無ければ `/.*/` |
|
|
107
|
+
| ACTIVITY の `timing` | 付けない(RM 1.0.4 で任意) |
|
|
108
|
+
| 入力がひとつも無い INSTRUCTION | 組まない(値の無い field は entry を作らないので、いまの動きのまま) |
|
|
109
|
+
|
|
110
|
+
つなぎ方(anlage の 6 節のとおり):
|
|
111
|
+
|
|
112
|
+
- 対象: INSTRUCTION の配下(activities と protocol、埋め込み CLUSTER の奥も含む)で値が入った要素。空欄は含めない
|
|
113
|
+
- 並び: field の並び(OPT の文書順。`FIELD_MAP` の順)
|
|
114
|
+
- 1 要素は「ラベル: 値」。埋め込みルートの配下の要素は「ルートのテンプレート上の名前/ラベル: 値」(例: 「住所/市区町村: 文京区」)
|
|
115
|
+
- 値: 帳票で見えるとおり。選択肢は表示名(`code_labels`)、数量は「値 単位」、日時は「日付 時刻」(時刻があれば)。そのほかは入力のまま
|
|
116
|
+
- 区切り: 全角のセミコロン「;」。**改行は使えない**(DV_TEXT は改行を持てない。RM の不変条件)。
|
|
117
|
+
この節の初版(`f659d7b`)は改行区切りとしていたが、R-20261124-19 で改めた
|
|
118
|
+
- 生成系は使わない
|
|
119
|
+
|
|
120
|
+
ルートのテンプレート上の名前は、field に新しいキー(`root_label`)として載せる。openehr 2.5.0 はルートごとの用語を持つ
|
|
121
|
+
(openehr-ruby#58、`CArchetypeRoot#term_definitions`)ので、ルートの at0000 の text をそこから取る(推論: 2.5.0 の API。実装の前に実測する)。
|
|
122
|
+
|
|
123
|
+
`action_archetype_id` を `Storable` が知るには、`FieldExtractor` が entry に ACTIVITY ごとの制約を載せる必要がある
|
|
124
|
+
(追加のキー `activities: [{ path:, action_archetype_id: }]`。公開 API の追加なので、changelog に書く)。
|
|
125
|
+
|
|
126
|
+
- Red: 「`jp_referral` の INSTRUCTION に値を入れたモデルが、narrative と ACTIVITY の `action_archetype_id` を持つ Composition を保存し、`to_rm` が近似(0.8.0 の既定値)を使わずに組み直す」
|
|
127
|
+
「narrative は入力された要素だけを文書順に『ラベル: 値』で改行区切りにつないだもの」
|
|
128
|
+
|
|
129
|
+
## 4. #74: gem に入るファイル
|
|
130
|
+
|
|
131
|
+
- 案: `gem.files` を `git ls-files -- lib app config README.md CHANGELOG.md LICENSE openehr-rails.gemspec` にする(`spec/`・`docs/`・`demo_assets/` などを外す)
|
|
132
|
+
- `OpenehrRails::ReleaseCheck` は「追跡されているのに gem.files に無いファイル」を、ファイルの組(sibling pair)についてだけ見る(`release_check.rb:122-133`)。
|
|
133
|
+
外すファイルが組に当たらないかを、実装の前に一覧で確かめる
|
|
134
|
+
- Red: 「ビルドした gem のファイル一覧に `spec/` が無く、`lib/generators/**/templates/` の全ファイルがある」。前後のファイル数と `.gem` の大きさを報告に書く
|
|
135
|
+
- packaging だけなので patch
|
|
136
|
+
|
|
137
|
+
## 5. 上流の公開を待つ 2 件
|
|
138
|
+
|
|
139
|
+
- **#64(`archetype_details`)**: openehr-ruby#70 が公開されたら着手。`RmObjectBuilder` が `Archetyped` を組んで渡す。AQL の `SELECT c/archetype_details/template_id/value` を Red にする
|
|
140
|
+
- **#63(DV_DATE_TIME の部分精度)**: openehr-ruby#59 が公開されたら、列の追加(install の migration テンプレート、既存の導入先には migration が要る)の計画を書いて **ゲート報告**
|
|
141
|
+
|
|
142
|
+
## 6. その他
|
|
143
|
+
|
|
144
|
+
- 作業列 7: CLAUDE.md の Ruby の版の記述を 4.0.10 に直す(この計画書と同じ push)。0.9.0 では、タグでの手元の再ビルド(ruby 4.0.10、rubygems 4.0.20)と
|
|
145
|
+
CI の artifact が gem 全体の sha256 まで一致した(`docs/reports/0.9.0-log.md` R9)
|
|
146
|
+
- `pkg/openehr-rails-0.9.0.gem` は公開を確かめたので、消してよい(人間に頼む)
|
data/docs/reports/0.9.0-log.md
CHANGED
|
@@ -163,3 +163,31 @@
|
|
|
163
163
|
|
|
164
164
|
## 裁定を求める点
|
|
165
165
|
(R1〜R7 で挙げた 4 点は、R-20261124-13 で回答済み。いま裁定を求める点は無い。)
|
|
166
|
+
|
|
167
|
+
## R9 — タグ `v0.9.0` と Release run 【タグ済み。`gem push` は人間、未実施】
|
|
168
|
+
|
|
169
|
+
- #72 は人間がマージした(`2511eec`)。master の CI run 45396747376(11 ジョブ green)を確かめてからタグを打った
|
|
170
|
+
- タグ: 注釈つきタグ `v0.9.0`(タグオブジェクト `22306b7`)→ `2511eecd8b58ca10e4c53ad6c889047a2bd9baad`。
|
|
171
|
+
小林の指示(11/24、チャット)でセッションが打った。`rake release:check` は OK
|
|
172
|
+
- タグの時点の中身(実測): `VERSION = '0.9.0'`、`openehr` `'~> 2.5'`、`changelog.d/` は無し、`CHANGELOG.md` に `[0.9.0] - 2026-11-24`
|
|
173
|
+
- Release run [45397152341](https://github.com/skoba/openehr-rails/actions/runs/45397152341): 12 ジョブ green
|
|
174
|
+
(spec 9、demo smoke、application template smoke、Build gem artifact)。ビルドは ruby 4.0.10
|
|
175
|
+
- sha256 の照合(3 つとも一致): `2437f1c4644e3efd23f80ca760c35055f23d1cf441356a12bc796a5b2da75b2d`
|
|
176
|
+
- Release run の「Record sha256」の出力(`pkg/openehr-rails-0.9.0.gem`)
|
|
177
|
+
- `gh run download 45397152341 -n gem` で取得した artifact(335360 バイト)
|
|
178
|
+
- タグ `v0.9.0` の detached worktree での手元の再ビルド(ruby 4.0.10、rubygems 4.0.20)。
|
|
179
|
+
`data.tar.gz`(`1de3151b…`)と `metadata.gz`(`7cf3e47b…`)も一致
|
|
180
|
+
- このあと: 人間が、Release run の artifact を `gem push` する。公開後、セッションが RubyGems の公開 checksum を上の値と照合して追記する
|
|
181
|
+
|
|
182
|
+
## R10 — 0.9.0 の公開 【完了申請】
|
|
183
|
+
|
|
184
|
+
- `gem push` は人間が行った(11/24)。push したのは `pkg/openehr-rails-0.9.0.gem` で、Release run 45397152341 の artifact を
|
|
185
|
+
`gh run download` で取り直して置いたもの(配置後の sha256 が run の記録と一致することを確かめた)
|
|
186
|
+
- 公開 checksum の照合(一致): `2437f1c4644e3efd23f80ca760c35055f23d1cf441356a12bc796a5b2da75b2d`
|
|
187
|
+
- `/api/v1/gems/openehr-rails.json`: version `0.9.0`、`sha` が上の値、`version_created_at` `2026-11-24T13:10:29.348Z`
|
|
188
|
+
- compact index `index.rubygems.org/info/openehr-rails`: `0.9.0` の行の `checksum:` が上の値
|
|
189
|
+
(最初の取得ではまだ 0.8.0 が末尾で、取り直すと 0.9.0 の行があった。伝播の遅れ)
|
|
190
|
+
- `/api/v1/versions/openehr-rails/latest.json`: `0.9.0`
|
|
191
|
+
- Release run の記録 = artifact = タグでの再ビルド = 公開された gem が、同じ sha256 でそろった
|
|
192
|
+
- 完了申請: タグ `v0.9.0` → `2511eec`、Release run 45397152341、RubyGems 0.9.0(上の checksum)
|
|
193
|
+
- 0.9.1 以降: #55、#48、#61、#62、#69、#63、#64、#65、#74。#46 は `other_context` と serializer の往復で open のまま。Reserve は #35〜#37、#75
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# 0.9.x の作業ログ
|
|
2
|
+
|
|
3
|
+
裁定 ID: R-20261124-16(計画: `docs/design/0.9.x-plan.md`)。進め方は R-20261124-8、台帳の書き方は R-20261124-18。
|
|
4
|
+
「実測」はこのリポジトリの作業ツリーで、Ruby 4.0.10・openehr 2.5.0 に対して実行したもの。
|
|
5
|
+
|
|
6
|
+
## R1 — 計画書と CLAUDE.md(作業列 1・7)【完了】
|
|
7
|
+
|
|
8
|
+
- 計画書 `docs/design/0.9.x-plan.md`: master `f659d7b`(push してそのまま進めた)
|
|
9
|
+
- CLAUDE.md の Ruby の版の記述(4.0.7 → 4.0.10): master `cde4648`。0.9.0 で手元の再ビルドと CI の artifact が gem 全体の sha256 まで一致したことも書いた
|
|
10
|
+
- R-20261124-18 の反映(「裁定台帳」の節の差し替えと、「全開の進め方」の 2 か所): master `42e5400`
|
|
11
|
+
- anlage の設計書(`docs/design/rm-attributes-without-inputs.md`、anlage `origin/main` `0993e4c`)を読んだ。narrative の実装は anlage にまだ無い。
|
|
12
|
+
つなぎ方(改行区切り、値の書き方、空欄は含めない)は計画書 3.4 節で決めた。anlage と同じ規則にするため、統括に中継を頼む(下の「裁定を求める点」2)
|
|
13
|
+
|
|
14
|
+
## R2 — #55: profile id のテンプレートでの修飾 【完了、マージ済み】
|
|
15
|
+
|
|
16
|
+
- PR [#77](https://github.com/skoba/openehr-rails/pull/77)。head `59e8d23`、CI run 45403621037(11 ジョブ green)。
|
|
17
|
+
マージコミット `a99e190`(セッションがマージ)、master の CI run 45404244605(green)
|
|
18
|
+
- Red を確認した spec(`spec/openehr_rails/fhir/profile_identity_spec.rb`、6 例中 6 失敗。空のモジュールを置いて例ごとに確認):
|
|
19
|
+
「qualifies id, url, name and title by the template」「keeps a long id within 64 FHIR id characters, deterministically」
|
|
20
|
+
「gives a FHIR-valid name」「gives them different JSON profile ids, urls and names」(実測: ProblemList と jp_referral の両方が
|
|
21
|
+
`openehr-evaluation-problem-diagnosis-v1`)「gives them different FSH profile ids」
|
|
22
|
+
「makes the JSON id / name and the FSH Id: / Profile: lines agree for every profile」
|
|
23
|
+
- Green: 全 suite 398 例 0 失敗・2 pending、rubocop 121 ファイル違反なし
|
|
24
|
+
- 既存の 37 例は旧い id・url・name・title を固定していたので、新しい契約に書き換えた
|
|
25
|
+
- golden FSH はファイル名を新しい id に改め、生成し直した出力との差は `Profile:`・`Id:`・`Title:` の 3 行だけ(規則の行はバイト一致)。
|
|
26
|
+
sushi での再コンパイルはしていない(開発機に入っておらず、入れると npm と FHIR パッケージのキャッシュを開発機に作るため)
|
|
27
|
+
- 計画と違った点: `template.template_id` は文字列ではなく `TemplateID` だった(`ProfileIdentity.for` の入口で `value` を取る)。
|
|
28
|
+
`FshGenerator` は ActiveSupport の文字列拡張を使わない方針(`0181f7f`)なので、`ProfileIdentity` も plain Ruby にした
|
|
29
|
+
- 起票: #76(Observation のインスタンス id がアーキタイプだけの slug で、2 つのモデルがぶつかる。計画書 2.2 節で約束したもの)
|
|
30
|
+
|
|
31
|
+
## R3 — 0.9.1 の棚卸し(バンドル報告)【版番号で止めている】
|
|
32
|
+
|
|
33
|
+
- 対象: `git diff v0.9.0..master`(master `a99e190`)。15 ファイル、+414 −88
|
|
34
|
+
|
|
35
|
+
| 変更 | Issue / PR | 分類 |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| StructureDefinition の id・url・name・title をテンプレートで修飾。JSON と FSH を 1 か所から出す | #55 / #77 | **公開された出力の識別子が、すべての profile で変わる**(Upgrade note)。0.x の minor 相当 |
|
|
38
|
+
| CLAUDE.md、計画書、報告 | — | 中立 |
|
|
39
|
+
|
|
40
|
+
- `changelog.d/` の断片は 1 件(`55-template-qualified-profile-ids.md`)
|
|
41
|
+
- **semver の判定: minor(0.x)→ 0.10.0 が中身に合う**。0.9.0 では path と name の変更を minor とした。#55 も、既存の id・url・name を参照する利用者には付け替えが要る変更で、不正な出力の修正(#48 のような patch)ではない
|
|
42
|
+
- **裁定(R-20261124-16)は 0.9.1 としている。** Release convention(「指示された版番号が中身と食い違うなら、タグの前に止まって再裁定を求める」)に従い、
|
|
43
|
+
版番号を変えるリリース PR はまだ作っていない
|
|
44
|
+
|
|
45
|
+
## 裁定を求める点
|
|
46
|
+
|
|
47
|
+
1. **次の版番号。** 中身は #55 だけで、判定は minor。0.10.0 で出すか、裁定どおり 0.9.1 で出すか。
|
|
48
|
+
0.9.1 にするなら、その理由(0.x では識別子の変更も patch とする、など)を台帳に書いてほしい。決まればリリース PR を出す
|
|
49
|
+
2. **narrative のつなぎ方の中継。** 計画書 3.4 節の規則(改行区切り、ラベルは field の label、値の書き方、空欄は含めない)を、anlage の書く側にも使ってもらうよう伝えてほしい。
|
|
50
|
+
ルート名の前置(同じラベルが 2 回出る件)は、anlage と合わせて別に決める
|
|
51
|
+
|
|
52
|
+
## R4 — R-20261124-19 への対応 【リリース PR は人間のマージ待ち】
|
|
53
|
+
|
|
54
|
+
- 版番号: **0.10.0**(棚卸しの判定 minor のとおり)。R-20261124-19 により、以後は裁定に版番号が書いてあっても、棚卸しの判定で進める(判定と理由は報告に書く)
|
|
55
|
+
- リリース PR [#78](https://github.com/skoba/openehr-rails/pull/78)。head `a2e95a5`: `VERSION` 0.10.0、`CHANGELOG.md` の `[0.10.0]`(#55 の断片をまとめた)、断片の削除。
|
|
56
|
+
手元: 398 例 0 失敗・2 pending、rubocop 違反なし、コミット後の `rake release:check` OK。**マージとタグは人間**
|
|
57
|
+
- narrative のつなぎ方: 計画書 3.4 節を anlage の規則にそろえた(master `82f2746`)。区切りは「;」、埋め込みルートの配下は「ルート名/ラベル: 値」。
|
|
58
|
+
読んだのは anlage PR #116 の `edbdb18`(設計書 6 節「決めたつなぎ方」と `app/lib/opt/composition_builder.rb` の `narrative`)。
|
|
59
|
+
この時点で anlage の main(`66f3a85`)にはまだ入っていない(`chore/111-remove-field-workarounds` に積まれている)
|
|
60
|
+
- ルート名は field の新しいキー `root_label` にする。openehr 2.5.0 のルートごとの用語(openehr-ruby#58)から取る想定で、実装の前に実測する
|
|
61
|
+
|
|
62
|
+
## R5 — v0.10.0 のタグと Release run の失敗(例外報告)【止めている】
|
|
63
|
+
|
|
64
|
+
- 11/25: #78 のマージ(`2567b06`)の master CI run 45600145778 が green(openehr 2.5.0 で解決)を確かめてから、
|
|
65
|
+
人間の指示でタグ `v0.10.0`(注釈つき、`2567b06` を指す)を打って push した
|
|
66
|
+
- Release run 45600566175 が失敗。spec の 9 ジョブのうち 8 が赤で、`Build gem artifact` は skipped。**artifact は作られておらず、何も公開していない**
|
|
67
|
+
- 原因(実測): **openehr 2.6.0 が 11:01:19 UTC に公開された**。master CI(11:00 前に依存を解決)は 2.5.0、Release run は 2.6.0 で解決した。
|
|
68
|
+
2.6.0 では AQL が EVENT_CONTEXT をたどれるので、#46 の pending `spec/openehr_rails/rm/composition_committer_context_spec.rb:65`
|
|
69
|
+
(`SELECT c/context/start_time/value`)が通ってしまい、"FIXED" として失敗になった。398 例 1 失敗 1 pending
|
|
70
|
+
- 隣の WHERE の例(同ファイル:73)は 2.6.0 でもまだ pending のまま。いまは別の理由で落ちる(`unsupported path attribute "uid" on a ...Composition`)
|
|
71
|
+
- 0.10.0 のコードに不具合はない。上流の修正が入ったことで、spec の期待が古くなった
|
|
72
|
+
|
|
73
|
+
### 決めてほしい点
|
|
74
|
+
|
|
75
|
+
1. タグ `v0.10.0` の扱い。案 A: spec を直す PR(#46 の続き、`:65` の pending を外す)をマージし、そのコミットにタグを打ち直す
|
|
76
|
+
(公開前なのでタグを動かす。push し直しが要る)。案 B: タグはそのまま置いて、修正を 0.10.1 として出す(0.10.0 は公開されないまま欠番になる)
|
|
77
|
+
2. 推奨は案 A。0.10.0 は世に出ておらず、タグを使ったのは失敗した run だけ
|
|
78
|
+
3. openehr の下限を 2.6.0 に上げるかは別件にする(依存を変える PR、人間がマージ)。2.5.0 と 2.6.0 の両方で通るよう、spec の書き方を決める必要がある
|
|
@@ -17,13 +17,14 @@ module OpenehrRails
|
|
|
17
17
|
|
|
18
18
|
def initialize(template)
|
|
19
19
|
@skipped = []
|
|
20
|
+
@template_id = template.template_id
|
|
20
21
|
@entries = OpenehrRails::Opt::FieldExtractor.new(template).entries.select { |entry| supported?(entry) }
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
def to_fsh_files
|
|
24
25
|
@entries.to_h do |entry|
|
|
25
|
-
|
|
26
|
-
[id, build_profile(entry,
|
|
26
|
+
identity = ProfileIdentity.for(@template_id, entry[:archetype_id])
|
|
27
|
+
[identity[:id], build_profile(entry, identity)]
|
|
27
28
|
end
|
|
28
29
|
end
|
|
29
30
|
|
|
@@ -37,11 +38,11 @@ module OpenehrRails
|
|
|
37
38
|
false
|
|
38
39
|
end
|
|
39
40
|
|
|
40
|
-
def build_profile(entry,
|
|
41
|
+
def build_profile(entry, identity)
|
|
41
42
|
resource_type = TypeMap.resource_for_entry(entry[:rm_type])
|
|
42
43
|
lines = alias_rules(entry[:fields])
|
|
43
44
|
lines << '' unless lines.empty?
|
|
44
|
-
lines.concat(metadata(
|
|
45
|
+
lines.concat(metadata(identity, resource_type))
|
|
45
46
|
element_map = TypeMap.element_map_for(entry[:archetype_id])
|
|
46
47
|
if element_map
|
|
47
48
|
lines.concat(mapped_rules(entry, element_map))
|
|
@@ -101,29 +102,16 @@ module OpenehrRails
|
|
|
101
102
|
aliases.uniq.map { |name, uri| "Alias: #{name} = #{uri}" }
|
|
102
103
|
end
|
|
103
104
|
|
|
104
|
-
def metadata(
|
|
105
|
+
def metadata(identity, resource_type)
|
|
105
106
|
[
|
|
106
|
-
"Profile: #{
|
|
107
|
+
"Profile: #{identity[:name]}",
|
|
107
108
|
"Parent: #{resource_type}",
|
|
108
|
-
"Id: #{id}",
|
|
109
|
-
"Title: \"
|
|
109
|
+
"Id: #{identity[:id]}",
|
|
110
|
+
"Title: \"#{identity[:title]}\"",
|
|
110
111
|
''
|
|
111
112
|
]
|
|
112
113
|
end
|
|
113
114
|
|
|
114
|
-
# Plain-Ruby equivalent of ActiveSupport's String#camelize on an
|
|
115
|
-
# underscore-separated input: "foo_bar" -> "FooBar".
|
|
116
|
-
def camelize(str)
|
|
117
|
-
str.split('_').map { |word| word[0].upcase + word[1..].to_s }.join
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
# Plain-Ruby equivalent of ActiveSupport's String#humanize on an
|
|
121
|
-
# already-lowercase, underscore-separated input: "foo_bar" -> "Foo bar".
|
|
122
|
-
def humanize(str)
|
|
123
|
-
spaced = str.tr('_', ' ')
|
|
124
|
-
spaced[0] ? spaced[0].upcase + spaced[1..].to_s.downcase : spaced
|
|
125
|
-
end
|
|
126
|
-
|
|
127
115
|
def code_rules(archetype_id, path = 'code', bindings = [])
|
|
128
116
|
return simple_code_rules(archetype_id, path) if bindings.empty?
|
|
129
117
|
|
|
@@ -199,17 +187,6 @@ module OpenehrRails
|
|
|
199
187
|
def value_set_uri(uri)
|
|
200
188
|
TypeMap.value_set_canonical(uri)
|
|
201
189
|
end
|
|
202
|
-
|
|
203
|
-
def profile_id(archetype_id)
|
|
204
|
-
"openehr-#{parameterize(archetype_id.delete_prefix('openEHR-EHR-'))}"
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
# Plain-Ruby equivalent of ActiveSupport's String#parameterize.dasherize:
|
|
208
|
-
# downcase, collapse every run of non-alphanumeric characters to a
|
|
209
|
-
# single "-", and strip any leading/trailing "-".
|
|
210
|
-
def parameterize(str)
|
|
211
|
-
str.downcase.gsub(/[^a-z0-9]+/, '-').gsub(/\A-+|-+\z/, '')
|
|
212
|
-
end
|
|
213
190
|
end
|
|
214
191
|
end
|
|
215
192
|
end
|
|
@@ -15,7 +15,8 @@ module OpenehrRails
|
|
|
15
15
|
FHIR_VERSION = '5.0.0'
|
|
16
16
|
ARCHETYPE_SYSTEM = 'http://openehr.org/ckm/archetypes'
|
|
17
17
|
UCUM_SYSTEM = 'http://unitsofmeasure.org'
|
|
18
|
-
|
|
18
|
+
# Kept for callers; the canonical url itself comes from ProfileIdentity (#55).
|
|
19
|
+
CANONICAL_BASE = ProfileIdentity::CANONICAL_SCHEME
|
|
19
20
|
|
|
20
21
|
# UnsupportedProfileError per entry that #profiles leaves out, in template
|
|
21
22
|
# order -- the "report" half of skip-and-report (#33). Empty when every
|
|
@@ -48,12 +49,13 @@ module OpenehrRails
|
|
|
48
49
|
|
|
49
50
|
def build_profile(entry)
|
|
50
51
|
resource_type = TypeMap.resource_for_entry(entry[:rm_type])
|
|
52
|
+
identity = ProfileIdentity.for(@template.template_id, entry[:archetype_id])
|
|
51
53
|
{
|
|
52
54
|
resourceType: 'StructureDefinition',
|
|
53
|
-
id:
|
|
54
|
-
url:
|
|
55
|
-
name:
|
|
56
|
-
title:
|
|
55
|
+
id: identity[:id],
|
|
56
|
+
url: identity[:url],
|
|
57
|
+
name: identity[:name],
|
|
58
|
+
title: identity[:title],
|
|
57
59
|
status: 'draft',
|
|
58
60
|
fhirVersion: FHIR_VERSION,
|
|
59
61
|
kind: 'resource',
|
|
@@ -199,10 +201,6 @@ module OpenehrRails
|
|
|
199
201
|
element[:binding][:valueSet] = field[:value_set_uri] if field[:value_set_uri]
|
|
200
202
|
end
|
|
201
203
|
end
|
|
202
|
-
|
|
203
|
-
def profile_id(archetype_id)
|
|
204
|
-
"openehr-#{archetype_id.delete_prefix('openEHR-EHR-').parameterize.dasherize}"
|
|
205
|
-
end
|
|
206
204
|
end
|
|
207
205
|
end
|
|
208
206
|
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'digest'
|
|
4
|
+
require 'erb'
|
|
5
|
+
|
|
6
|
+
module OpenehrRails
|
|
7
|
+
module Fhir
|
|
8
|
+
# The one place a StructureDefinition's id, url, name and title come from
|
|
9
|
+
# (skoba/openehr-rails#55). Both ProfileGenerator (JSON) and FshGenerator
|
|
10
|
+
# use it, so the two outputs cannot disagree, and every value is qualified
|
|
11
|
+
# by the template: two templates that use the same archetype with different
|
|
12
|
+
# constraints get different profiles. Plain Ruby, like FshGenerator (no
|
|
13
|
+
# ActiveSupport string extensions; see 0181f7f).
|
|
14
|
+
module ProfileIdentity
|
|
15
|
+
MAX_ID_LENGTH = 64 # FHIR id: [A-Za-z0-9\-\.]{1,64}
|
|
16
|
+
HASH_LENGTH = 8
|
|
17
|
+
CANONICAL_SCHEME = 'urn:openehr'
|
|
18
|
+
|
|
19
|
+
module_function
|
|
20
|
+
|
|
21
|
+
# template_id may be the parsed template's TemplateID or a String.
|
|
22
|
+
def for(template_id, archetype_id)
|
|
23
|
+
template_id = template_id.value if template_id.respond_to?(:value)
|
|
24
|
+
id = profile_id(template_id, archetype_id)
|
|
25
|
+
{
|
|
26
|
+
id: id,
|
|
27
|
+
url: "#{CANONICAL_SCHEME}:#{ERB::Util.url_encode(template_id)}:#{archetype_id}",
|
|
28
|
+
name: id.split('-').map { |word| word[0].upcase + word[1..] }.join,
|
|
29
|
+
title: "openEHR #{humanize(concept(archetype_id))} (#{template_id}: #{archetype_id})"
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# "openehr-<template slug>-<archetype slug>". Longer than a FHIR id may
|
|
34
|
+
# be, it keeps a prefix and ends in the first characters of the full
|
|
35
|
+
# id's sha256, so it stays unique and stable.
|
|
36
|
+
def profile_id(template_id, archetype_id)
|
|
37
|
+
full = ['openehr', slug(template_id), slug(archetype_id.delete_prefix('openEHR-EHR-'))].join('-')
|
|
38
|
+
return full if full.length <= MAX_ID_LENGTH
|
|
39
|
+
|
|
40
|
+
prefix = full[0, MAX_ID_LENGTH - HASH_LENGTH - 1].sub(/-+\z/, '')
|
|
41
|
+
"#{prefix}-#{Digest::SHA256.hexdigest(full)[0, HASH_LENGTH]}"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# ActiveSupport's parameterize.dasherize on ASCII input: downcase,
|
|
45
|
+
# collapse every run of non-alphanumerics to "-", strip edge dashes.
|
|
46
|
+
def slug(text)
|
|
47
|
+
text.to_s.downcase.gsub(/[^a-z0-9]+/, '-').gsub(/\A-+|-+\z/, '')
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Same rule as Opt::FieldExtractor's entry concept ("problem_diagnosis").
|
|
51
|
+
def concept(archetype_id)
|
|
52
|
+
archetype_id.split('.')[1].to_s.gsub(/[^A-Za-z0-9]+/, '_').gsub(/\A_+|_+\z/, '').downcase
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def humanize(concept)
|
|
56
|
+
spaced = concept.tr('_', ' ')
|
|
57
|
+
spaced.empty? ? spaced : spaced[0].upcase + spaced[1..]
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
data/lib/openehr_rails.rb
CHANGED
|
@@ -32,6 +32,7 @@ require 'openehr_rails/template_importer'
|
|
|
32
32
|
require 'openehr_rails/runtime_scaffolder'
|
|
33
33
|
require 'openehr_rails/fhir/unsupported_profile_error'
|
|
34
34
|
require 'openehr_rails/fhir/type_map'
|
|
35
|
+
require 'openehr_rails/fhir/profile_identity'
|
|
35
36
|
require 'openehr_rails/fhir/profile_generator'
|
|
36
37
|
require 'openehr_rails/fhir/fsh_generator'
|
|
37
38
|
require 'openehr_rails/fhir/resource_registry'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Profile:
|
|
1
|
+
Profile: OpenehrProblemlistEvaluationProblemDiagnosisV1
|
|
2
2
|
Parent: Condition
|
|
3
|
-
Id: openehr-evaluation-problem-diagnosis-v1
|
|
4
|
-
Title: "openEHR Problem diagnosis (openEHR-EHR-EVALUATION.problem_diagnosis.v1)"
|
|
3
|
+
Id: openehr-problemlist-evaluation-problem-diagnosis-v1
|
|
4
|
+
Title: "openEHR Problem diagnosis (ProblemList: openEHR-EHR-EVALUATION.problem_diagnosis.v1)"
|
|
5
5
|
|
|
6
6
|
* category ^slicing.discriminator.type = #pattern
|
|
7
7
|
* category ^slicing.discriminator.path = "$this"
|
|
@@ -18,12 +18,12 @@ module Openehr
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it 'writes a StructureDefinition JSON per entry' do
|
|
21
|
-
expect(file('app/fhir/profiles/openehr-observation-height-v2.json'))
|
|
21
|
+
expect(file('app/fhir/profiles/openehr-bmi-calculation-observation-height-v2.json'))
|
|
22
22
|
.to contain('"resourceType": "StructureDefinition"')
|
|
23
|
-
expect(file('app/fhir/profiles/openehr-observation-height-v2.json'))
|
|
23
|
+
expect(file('app/fhir/profiles/openehr-bmi-calculation-observation-height-v2.json'))
|
|
24
24
|
.to contain('"fhirVersion": "5.0.0"')
|
|
25
|
-
expect(file('app/fhir/profiles/openehr-observation-body-weight-v2.json')).to exist
|
|
26
|
-
expect(file('app/fhir/profiles/openehr-observation-body-mass-index-v2.json')).to exist
|
|
25
|
+
expect(file('app/fhir/profiles/openehr-bmi-calculation-observation-body-weight-v2.json')).to exist
|
|
26
|
+
expect(file('app/fhir/profiles/openehr-bmi-calculation-observation-body-mass-index-v2.json')).to exist
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
|
@@ -21,7 +21,7 @@ module Openehr
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it 'fetches the OPT and writes profiles as usual' do
|
|
24
|
-
expect(file('app/fhir/profiles/openehr-observation-height-v2.json'))
|
|
24
|
+
expect(file('app/fhir/profiles/openehr-bmi-calculation-observation-height-v2.json'))
|
|
25
25
|
.to contain('"resourceType": "StructureDefinition"')
|
|
26
26
|
end
|
|
27
27
|
end
|
|
@@ -15,23 +15,23 @@ describe OpenehrRails::Fhir::FshGenerator do
|
|
|
15
15
|
|
|
16
16
|
it 'builds one FSH profile per OBSERVATION entry' do
|
|
17
17
|
expect(files.keys).to contain_exactly(
|
|
18
|
-
'openehr-observation-height-v2',
|
|
19
|
-
'openehr-observation-body-weight-v2',
|
|
20
|
-
'openehr-observation-body-mass-index-v2'
|
|
18
|
+
'openehr-bmi-calculation-observation-height-v2',
|
|
19
|
+
'openehr-bmi-calculation-observation-body-weight-v2',
|
|
20
|
+
'openehr-bmi-calculation-observation-body-mass-index-v2'
|
|
21
21
|
)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
describe 'the height profile' do
|
|
25
|
-
subject(:fsh) { files.fetch('openehr-observation-height-v2') }
|
|
25
|
+
subject(:fsh) { files.fetch('openehr-bmi-calculation-observation-height-v2') }
|
|
26
26
|
|
|
27
27
|
it 'emits metadata and slices codings by system' do
|
|
28
28
|
expect(fsh).to include(
|
|
29
29
|
"Alias: CKM = http://openehr.org/ckm/archetypes\n",
|
|
30
30
|
"Alias: LOINC = http://loinc.org\n",
|
|
31
|
-
"Profile:
|
|
31
|
+
"Profile: OpenehrBmiCalculationObservationHeightV2\n",
|
|
32
32
|
"Parent: Observation\n",
|
|
33
|
-
"Id: openehr-observation-height-v2\n",
|
|
34
|
-
"Title: \"openEHR Height (openEHR-EHR-OBSERVATION.height.v2)\"\n",
|
|
33
|
+
"Id: openehr-bmi-calculation-observation-height-v2\n",
|
|
34
|
+
"Title: \"openEHR Height (bmi_calculation: openEHR-EHR-OBSERVATION.height.v2)\"\n",
|
|
35
35
|
"* code.coding ^slicing.discriminator.type = #value\n",
|
|
36
36
|
"* code.coding ^slicing.discriminator.path = \"system\"\n",
|
|
37
37
|
"* code.coding ^slicing.rules = #open\n",
|
|
@@ -51,7 +51,7 @@ describe OpenehrRails::Fhir::FshGenerator do
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
describe 'a multi-element entry (body_mass_index)' do
|
|
54
|
-
subject(:fsh) { files.fetch('openehr-observation-body-mass-index-v2') }
|
|
54
|
+
subject(:fsh) { files.fetch('openehr-bmi-calculation-observation-body-mass-index-v2') }
|
|
55
55
|
|
|
56
56
|
it 'slices component by code and constrains each slice value' do
|
|
57
57
|
expect(fsh).to include(
|
|
@@ -91,7 +91,7 @@ describe OpenehrRails::Fhir::FshGenerator do
|
|
|
91
91
|
let(:opt_file) { File.expand_path('../../templates/problem_list.opt', __dir__) }
|
|
92
92
|
|
|
93
93
|
it 'emits a required binding for a C_CODE_REFERENCE constraint' do
|
|
94
|
-
fsh = generator.to_fsh_files.fetch('openehr-evaluation-problem-diagnosis-v1')
|
|
94
|
+
fsh = generator.to_fsh_files.fetch('openehr-problemlist-evaluation-problem-diagnosis-v1')
|
|
95
95
|
|
|
96
96
|
# Since #33 this leaf lands on Condition.code rather than a component
|
|
97
97
|
# slice; the #30 property under test -- an empty local code_list no
|
|
@@ -107,7 +107,7 @@ describe OpenehrRails::Fhir::FshGenerator do
|
|
|
107
107
|
# mapping and its per-element rationale are
|
|
108
108
|
# docs/design/multi-leaf-non-observation-plan.md section 8.
|
|
109
109
|
#
|
|
110
|
-
# Golden provenance: spec/fixtures/fsh/openehr-evaluation-problem-diagnosis-v1.fsh
|
|
110
|
+
# Golden provenance: spec/fixtures/fsh/openehr-problemlist-evaluation-problem-diagnosis-v1.fsh
|
|
111
111
|
# is generated output, not a hand-authored artifact -- it is this generator's
|
|
112
112
|
# expected emission for spec/templates/problem_list.opt, and every rule in it
|
|
113
113
|
# was compiled against hl7.fhir.r5.core#5.0.0 with sushi 3.16.0 (0 Errors)
|
|
@@ -115,14 +115,14 @@ describe OpenehrRails::Fhir::FshGenerator do
|
|
|
115
115
|
# the file must byte-match what the generator produces.
|
|
116
116
|
describe 'a multi-leaf EVALUATION entry (problem_list.opt)' do
|
|
117
117
|
subject(:fsh) do
|
|
118
|
-
generator.to_fsh_files.fetch('openehr-evaluation-problem-diagnosis-v1')
|
|
118
|
+
generator.to_fsh_files.fetch('openehr-problemlist-evaluation-problem-diagnosis-v1')
|
|
119
119
|
end
|
|
120
120
|
|
|
121
121
|
let(:opt_file) do
|
|
122
122
|
File.expand_path('../../templates/problem_list.opt', __dir__)
|
|
123
123
|
end
|
|
124
124
|
let(:golden) do
|
|
125
|
-
File.read(File.expand_path('../../fixtures/fsh/openehr-evaluation-problem-diagnosis-v1.fsh', __dir__))
|
|
125
|
+
File.read(File.expand_path('../../fixtures/fsh/openehr-problemlist-evaluation-problem-diagnosis-v1.fsh', __dir__))
|
|
126
126
|
end
|
|
127
127
|
|
|
128
128
|
it 'matches the golden FSH exactly' do
|
|
@@ -210,7 +210,7 @@ describe OpenehrRails::Fhir::FshGenerator do
|
|
|
210
210
|
end
|
|
211
211
|
|
|
212
212
|
it 'skips the entry and still emits the mapped one' do
|
|
213
|
-
expect(files.keys).to eq(['openehr-evaluation-problem-diagnosis-v1'])
|
|
213
|
+
expect(files.keys).to eq(['openehr-problemlist-evaluation-problem-diagnosis-v1'])
|
|
214
214
|
end
|
|
215
215
|
|
|
216
216
|
it 'reports the skip as an UnsupportedProfileError naming the archetype and resource' do
|
|
@@ -252,7 +252,7 @@ describe OpenehrRails::Fhir::FshGenerator do
|
|
|
252
252
|
end
|
|
253
253
|
|
|
254
254
|
it 'skips the entry instead of constraining value[x] on Condition' do
|
|
255
|
-
expect(files.keys).to eq(['openehr-evaluation-problem-diagnosis-v1'])
|
|
255
|
+
expect(files.keys).to eq(['openehr-problemlist-evaluation-problem-diagnosis-v1'])
|
|
256
256
|
expect(files.values.join).not_to include('value[x]')
|
|
257
257
|
end
|
|
258
258
|
|
|
@@ -292,7 +292,7 @@ describe OpenehrRails::Fhir::FshGenerator do
|
|
|
292
292
|
|
|
293
293
|
it 'emits nothing for them and keeps the real entries' do
|
|
294
294
|
expect(generator.to_fsh_files.keys).to eq(
|
|
295
|
-
%w[openehr-observation-height-v2 openehr-observation-body-weight-v2 openehr-observation-body-mass-index-v2]
|
|
295
|
+
%w[openehr-bmi-calculation-observation-height-v2 openehr-bmi-calculation-observation-body-weight-v2 openehr-bmi-calculation-observation-body-mass-index-v2]
|
|
296
296
|
)
|
|
297
297
|
end
|
|
298
298
|
|
|
@@ -15,14 +15,14 @@ describe OpenehrRails::Fhir::ProfileGenerator do
|
|
|
15
15
|
|
|
16
16
|
it 'builds one StructureDefinition per OBSERVATION entry' do
|
|
17
17
|
expect(profiles.map { |p| p[:id] }).to contain_exactly(
|
|
18
|
-
'openehr-observation-height-v2',
|
|
19
|
-
'openehr-observation-body-weight-v2',
|
|
20
|
-
'openehr-observation-body-mass-index-v2'
|
|
18
|
+
'openehr-bmi-calculation-observation-height-v2',
|
|
19
|
+
'openehr-bmi-calculation-observation-body-weight-v2',
|
|
20
|
+
'openehr-bmi-calculation-observation-body-mass-index-v2'
|
|
21
21
|
)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
describe 'the height profile' do
|
|
25
|
-
subject(:profile) { profiles.find { |p| p[:id] == 'openehr-observation-height-v2' } }
|
|
25
|
+
subject(:profile) { profiles.find { |p| p[:id] == 'openehr-bmi-calculation-observation-height-v2' } }
|
|
26
26
|
|
|
27
27
|
it 'is a FHIR R5 StructureDefinition' do
|
|
28
28
|
expect(profile[:resourceType]).to eq('StructureDefinition')
|
|
@@ -39,7 +39,7 @@ describe OpenehrRails::Fhir::ProfileGenerator do
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it 'carries a stable canonical url' do
|
|
42
|
-
expect(profile[:url]).to eq('urn:openehr:openEHR-EHR-OBSERVATION.height.v2')
|
|
42
|
+
expect(profile[:url]).to eq('urn:openehr:bmi_calculation:openEHR-EHR-OBSERVATION.height.v2')
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it 'fixes Observation.code to the archetype id' do
|
|
@@ -63,7 +63,7 @@ describe OpenehrRails::Fhir::ProfileGenerator do
|
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
describe 'a multi-element entry (body_mass_index)' do
|
|
66
|
-
subject(:profile) { profiles.find { |p| p[:id] == 'openehr-observation-body-mass-index-v2' } }
|
|
66
|
+
subject(:profile) { profiles.find { |p| p[:id] == 'openehr-bmi-calculation-observation-body-mass-index-v2' } }
|
|
67
67
|
|
|
68
68
|
it 'slices Observation.component per element' do
|
|
69
69
|
component_slices = profile.dig(:differential, :element)
|
|
@@ -77,8 +77,8 @@ describe OpenehrRails::Fhir::ProfileGenerator do
|
|
|
77
77
|
describe '#to_json_files' do
|
|
78
78
|
it 'returns id => pretty JSON string' do
|
|
79
79
|
files = generator.to_json_files
|
|
80
|
-
expect(files.keys).to include('openehr-observation-height-v2')
|
|
81
|
-
parsed = JSON.parse(files['openehr-observation-height-v2'])
|
|
80
|
+
expect(files.keys).to include('openehr-bmi-calculation-observation-height-v2')
|
|
81
|
+
parsed = JSON.parse(files['openehr-bmi-calculation-observation-height-v2'])
|
|
82
82
|
expect(parsed['resourceType']).to eq('StructureDefinition')
|
|
83
83
|
end
|
|
84
84
|
end
|
|
@@ -127,7 +127,7 @@ describe OpenehrRails::Fhir::ProfileGenerator do
|
|
|
127
127
|
# from the generated StructureDefinition, which was the issue's own complaint.
|
|
128
128
|
describe 'a multi-leaf EVALUATION entry (problem_list.opt)' do
|
|
129
129
|
subject(:profile) do
|
|
130
|
-
generator.profiles.find { |p| p[:id] == 'openehr-evaluation-problem-diagnosis-v1' }
|
|
130
|
+
generator.profiles.find { |p| p[:id] == 'openehr-problemlist-evaluation-problem-diagnosis-v1' }
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
let(:opt_file) do
|
|
@@ -222,7 +222,7 @@ describe OpenehrRails::Fhir::ProfileGenerator do
|
|
|
222
222
|
end
|
|
223
223
|
|
|
224
224
|
it 'skips the entry and still emits the mapped one' do
|
|
225
|
-
expect(profiles.map { |p| p[:id] }).to eq(['openehr-evaluation-problem-diagnosis-v1'])
|
|
225
|
+
expect(profiles.map { |p| p[:id] }).to eq(['openehr-problemlist-evaluation-problem-diagnosis-v1'])
|
|
226
226
|
end
|
|
227
227
|
|
|
228
228
|
it 'never emits a component element for the skipped resource' do
|
|
@@ -265,7 +265,7 @@ describe OpenehrRails::Fhir::ProfileGenerator do
|
|
|
265
265
|
end
|
|
266
266
|
|
|
267
267
|
it 'skips the entry instead of emitting Condition.value[x]' do
|
|
268
|
-
expect(profiles.map { |p| p[:id] }).to eq(['openehr-evaluation-problem-diagnosis-v1'])
|
|
268
|
+
expect(profiles.map { |p| p[:id] }).to eq(['openehr-problemlist-evaluation-problem-diagnosis-v1'])
|
|
269
269
|
expect(profiles.flat_map { |p| p[:differential][:element] }.map { |e| e[:path] })
|
|
270
270
|
.not_to include('Condition.value[x]')
|
|
271
271
|
end
|
|
@@ -306,7 +306,7 @@ describe OpenehrRails::Fhir::ProfileGenerator do
|
|
|
306
306
|
|
|
307
307
|
it 'emits nothing for them and keeps the real entries' do
|
|
308
308
|
expect(generator.profiles.map { |p| p[:id] }).to eq(
|
|
309
|
-
%w[openehr-observation-height-v2 openehr-observation-body-weight-v2 openehr-observation-body-mass-index-v2]
|
|
309
|
+
%w[openehr-bmi-calculation-observation-height-v2 openehr-bmi-calculation-observation-body-weight-v2 openehr-bmi-calculation-observation-body-mass-index-v2]
|
|
310
310
|
)
|
|
311
311
|
end
|
|
312
312
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'openehr_rails'
|
|
5
|
+
|
|
6
|
+
# Issue #55 (anlage upstream candidate 23): StructureDefinition id / url / name /
|
|
7
|
+
# title are qualified by the template, and both generators take them from one place.
|
|
8
|
+
describe OpenehrRails::Fhir::ProfileIdentity do
|
|
9
|
+
def template_for(relative_path)
|
|
10
|
+
OpenehrRails::Opt.parse(File.expand_path(relative_path, __dir__))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
let(:problem_list) { template_for('../../templates/problem_list.opt') }
|
|
14
|
+
let(:jp_referral) { template_for('../../templates/jp_referral.opt') }
|
|
15
|
+
|
|
16
|
+
describe '.for' do
|
|
17
|
+
subject(:identity) { described_class.for('bmi_calculation', 'openEHR-EHR-OBSERVATION.height.v2') }
|
|
18
|
+
|
|
19
|
+
# enhancement: red before #55 (no such module).
|
|
20
|
+
it 'qualifies id, url, name and title by the template' do
|
|
21
|
+
expect(identity).to eq(
|
|
22
|
+
id: 'openehr-bmi-calculation-observation-height-v2',
|
|
23
|
+
url: 'urn:openehr:bmi_calculation:openEHR-EHR-OBSERVATION.height.v2',
|
|
24
|
+
name: 'OpenehrBmiCalculationObservationHeightV2',
|
|
25
|
+
title: 'openEHR Height (bmi_calculation: openEHR-EHR-OBSERVATION.height.v2)'
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# enhancement: red before #55.
|
|
30
|
+
it 'keeps a long id within 64 FHIR id characters, deterministically' do
|
|
31
|
+
template_id = 'a_very_long_operational_template_identifier_for_testing_limits'
|
|
32
|
+
archetype_id = 'openEHR-EHR-EVALUATION.problem_diagnosis.v1'
|
|
33
|
+
id = described_class.for(template_id, archetype_id)[:id]
|
|
34
|
+
|
|
35
|
+
expect(id.length).to be <= 64
|
|
36
|
+
expect(id).to match(/\A[A-Za-z0-9\-.]+\z/)
|
|
37
|
+
expect(id).to match(/-[0-9a-f]{8}\z/)
|
|
38
|
+
expect(described_class.for(template_id, archetype_id)[:id]).to eq(id)
|
|
39
|
+
expect(described_class.for("#{template_id}_2", archetype_id)[:id]).not_to eq(id)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# enhancement: red before #55.
|
|
43
|
+
it 'gives a FHIR-valid name' do
|
|
44
|
+
expect(identity[:name]).to match(/\A[A-Z][A-Za-z0-9_]*\z/)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe 'two templates sharing an archetype (problem_list, jp_referral)' do
|
|
49
|
+
let(:archetype_id) { 'openEHR-EHR-EVALUATION.problem_diagnosis.v1' }
|
|
50
|
+
|
|
51
|
+
# bug: red before #55 (both were openehr-evaluation-problem-diagnosis-v1).
|
|
52
|
+
it 'gives them different JSON profile ids, urls and names' do
|
|
53
|
+
profiles = [problem_list, jp_referral].map do |template|
|
|
54
|
+
OpenehrRails::Fhir::ProfileGenerator.new(template).profiles.find { |p| p[:url].end_with?(archetype_id) }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
expect(profiles.pluck(:id)).to eq(
|
|
58
|
+
%w[openehr-problemlist-evaluation-problem-diagnosis-v1 openehr-jp-referral-evaluation-problem-diagnosis-v1]
|
|
59
|
+
)
|
|
60
|
+
expect(profiles.pluck(:url).uniq.size).to eq(2)
|
|
61
|
+
expect(profiles.pluck(:name).uniq.size).to eq(2)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# bug: red before #55.
|
|
65
|
+
it 'gives them different FSH profile ids' do
|
|
66
|
+
ids = [problem_list, jp_referral].map { |template| OpenehrRails::Fhir::FshGenerator.new(template).to_fsh_files.keys }
|
|
67
|
+
|
|
68
|
+
expect(ids.flatten).to include('openehr-problemlist-evaluation-problem-diagnosis-v1',
|
|
69
|
+
'openehr-jp-referral-evaluation-problem-diagnosis-v1')
|
|
70
|
+
expect(ids.flatten.uniq.size).to eq(ids.flatten.size)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# enhancement: red before #55 (JSON name was the bare concept, FSH used the id).
|
|
75
|
+
it 'makes the JSON id / name and the FSH Id: / Profile: lines agree for every profile' do
|
|
76
|
+
[problem_list, jp_referral, template_for('../../generators/templates/bmi_calculation.opt')].each do |template|
|
|
77
|
+
json = OpenehrRails::Fhir::ProfileGenerator.new(template).profiles
|
|
78
|
+
fsh = OpenehrRails::Fhir::FshGenerator.new(template).to_fsh_files
|
|
79
|
+
|
|
80
|
+
expect(fsh.keys).to eq(json.map { |p| p[:id] })
|
|
81
|
+
json.each do |profile|
|
|
82
|
+
expect(fsh.fetch(profile[:id])).to start_with(
|
|
83
|
+
"Profile: #{profile[:name]}\nParent: #{profile[:type]}\nId: #{profile[:id]}\nTitle: \"#{profile[:title]}\"\n"
|
|
84
|
+
).or include("\nProfile: #{profile[:name]}\nParent: #{profile[:type]}\nId: #{profile[:id]}\nTitle: \"#{profile[:title]}\"\n")
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -32,7 +32,7 @@ describe OpenehrRails::Fhir do
|
|
|
32
32
|
# regression pin: no ServiceRequest profile is emitted without a mapping row.
|
|
33
33
|
it 'emits no profile for it' do
|
|
34
34
|
expect(emitted_ids.call(generator)).to eq(
|
|
35
|
-
%w[openehr-evaluation-problem-diagnosis-v1 openehr-observation-story-v1]
|
|
35
|
+
%w[openehr-jp-referral-evaluation-problem-diagnosis-v1 openehr-jp-referral-observation-story-v1]
|
|
36
36
|
)
|
|
37
37
|
end
|
|
38
38
|
end
|
|
@@ -35,7 +35,11 @@ describe OpenehrRails::Rm::CompositionCommitter do
|
|
|
35
35
|
}
|
|
36
36
|
end
|
|
37
37
|
let(:from_clause) { 'FROM EHR e CONTAINS COMPOSITION c' }
|
|
38
|
-
|
|
38
|
+
# openehr 2.6.0 can navigate EVENT_CONTEXT in an AQL path; the gemspec still
|
|
39
|
+
# allows ~> 2.5, so the expectations below depend on the resolved version.
|
|
40
|
+
let(:navigates_event_context) { Gem.loaded_specs['openehr'].version >= Gem::Version.new('2.6.0') }
|
|
41
|
+
let(:upstream_event_context) { 'openehr < 2.6.0 cannot navigate EVENT_CONTEXT attributes in an AQL path' }
|
|
42
|
+
let(:upstream_composition_uid) { 'openehr cannot navigate COMPOSITION.uid in an AQL path yet' }
|
|
39
43
|
|
|
40
44
|
def select(path)
|
|
41
45
|
OpenehrRails::Aql::Executor.execute("SELECT #{path} #{from_clause}").rows
|
|
@@ -56,22 +60,24 @@ describe OpenehrRails::Rm::CompositionCommitter do
|
|
|
56
60
|
expect(composition.reload).to have_attributes(setting_code: '232', setting_value: 'secondary medical care')
|
|
57
61
|
end
|
|
58
62
|
|
|
59
|
-
# bug: red before #46 (one row holding nil)
|
|
60
|
-
#
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
#
|
|
64
|
-
# release can navigate EVENT_CONTEXT; this example then fails as "fixed".
|
|
63
|
+
# bug: red before #46 (one row holding nil). With openehr < 2.6.0 the path
|
|
64
|
+
# evaluator still raises `unsupported path attribute "start_time" on a
|
|
65
|
+
# ...EventContext`, so it stays pending there; openehr 2.6.0 navigates
|
|
66
|
+
# EVENT_CONTEXT and the example runs green (v0.10.0 Release run 45600566175
|
|
67
|
+
# resolved 2.6.0 and reported it "FIXED").
|
|
65
68
|
it 'answers SELECT c/context/start_time/value' do
|
|
66
|
-
pending upstream_event_context
|
|
69
|
+
pending upstream_event_context unless navigates_event_context
|
|
67
70
|
described_class.commit(canonical_hash, uid: 'ctx-3')
|
|
68
71
|
|
|
69
72
|
expect(select('c/context/start_time/value')).to eq([['2026-03-15T00:30:00Z']])
|
|
70
73
|
end
|
|
71
74
|
|
|
72
|
-
# bug: red before #46 (0 rows)
|
|
75
|
+
# bug: red before #46 (0 rows). Still pending: with openehr < 2.6.0 for the
|
|
76
|
+
# EVENT_CONTEXT reason above; with 2.6.0 the WHERE clause itself works
|
|
77
|
+
# (measured), but SELECT c/uid/value raises `unsupported path attribute
|
|
78
|
+
# "uid" on a ...Composition` (an openehr-ruby question, not filed from here).
|
|
73
79
|
it 'filters on c/context/start_time/value in WHERE' do
|
|
74
|
-
pending upstream_event_context
|
|
80
|
+
pending(navigates_event_context ? upstream_composition_uid : upstream_event_context)
|
|
75
81
|
described_class.commit(canonical_hash, uid: 'ctx-4')
|
|
76
82
|
query = "SELECT c/uid/value #{from_clause} WHERE c/context/start_time/value > '2026-01-01'"
|
|
77
83
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openehr-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shinji KOBAYASHI
|
|
@@ -251,12 +251,14 @@ files:
|
|
|
251
251
|
- docker/docker-compose.yml
|
|
252
252
|
- docs/backlog.md
|
|
253
253
|
- docs/design/0.9.0-plan.md
|
|
254
|
+
- docs/design/0.9.x-plan.md
|
|
254
255
|
- docs/design/binding-extraction-plan.md
|
|
255
256
|
- docs/design/fix-terminology-scope-plan.md
|
|
256
257
|
- docs/design/fsh-generator-plan.md
|
|
257
258
|
- docs/design/multi-leaf-non-observation-plan.md
|
|
258
259
|
- docs/design/rm-object-builder-section-instruction-plan.md
|
|
259
260
|
- docs/reports/0.9.0-log.md
|
|
261
|
+
- docs/reports/0.9.x-log.md
|
|
260
262
|
- docs/reports/binding-extraction-log.md
|
|
261
263
|
- docs/reports/fsh-generator-log.md
|
|
262
264
|
- docs/reports/institutionalization-log.md
|
|
@@ -295,6 +297,7 @@ files:
|
|
|
295
297
|
- lib/openehr_rails/fhir/deserializer.rb
|
|
296
298
|
- lib/openehr_rails/fhir/fsh_generator.rb
|
|
297
299
|
- lib/openehr_rails/fhir/profile_generator.rb
|
|
300
|
+
- lib/openehr_rails/fhir/profile_identity.rb
|
|
298
301
|
- lib/openehr_rails/fhir/profile_repository.rb
|
|
299
302
|
- lib/openehr_rails/fhir/resource_registry.rb
|
|
300
303
|
- lib/openehr_rails/fhir/serializer.rb
|
|
@@ -333,7 +336,7 @@ files:
|
|
|
333
336
|
- openehr-rails.gemspec
|
|
334
337
|
- script/build_demo.sh
|
|
335
338
|
- script/build_starter.sh
|
|
336
|
-
- spec/fixtures/fsh/openehr-evaluation-problem-diagnosis-v1.fsh
|
|
339
|
+
- spec/fixtures/fsh/openehr-problemlist-evaluation-problem-diagnosis-v1.fsh
|
|
337
340
|
- spec/generators/openehr/fhir_profile/fhir_profile_generator_spec.rb
|
|
338
341
|
- spec/generators/openehr/fhir_profile/remote_fhir_profile_generator_spec.rb
|
|
339
342
|
- spec/generators/openehr/install/install_generator_spec.rb
|
|
@@ -350,6 +353,7 @@ files:
|
|
|
350
353
|
- spec/openehr_rails/authentication_spec.rb
|
|
351
354
|
- spec/openehr_rails/fhir/fsh_generator_spec.rb
|
|
352
355
|
- spec/openehr_rails/fhir/profile_generator_spec.rb
|
|
356
|
+
- spec/openehr_rails/fhir/profile_identity_spec.rb
|
|
353
357
|
- spec/openehr_rails/fhir/serializer_spec.rb
|
|
354
358
|
- spec/openehr_rails/fhir_instruction_skip_spec.rb
|
|
355
359
|
- spec/openehr_rails/naming_spec.rb
|