Skip to content

Commit 4ea42c2

Browse files
committed
feat(streams): add HDSModelStreams.isContext() helper (plan 53 phase A)
Surfaces the new data-model `role: context` flag at the runtime layer. Returns true iff a stream definition has role === 'context' (i.e. it's a descendant- streamId marker for D3 context-via-substream resolution, not a data-bearing bucket). Unknown streamIds return false — this is a yes/no probe, no throw. Consumers (settings trees, form-section renderers, dashboards) should use this to elide / mute / re-render context streams as metadata rather than as independent input streams. D3 walk-up resolution (forEvent) is unaffected by the flag. 4 new tests [CTXR-P/Q/R/S] in tests/contextResolution.test.js validate against the locally-built data-model pack.json so the flag is sourced from real YAML. Pairs with healthdatasafe/data-model#17 (role: context added to treatment-fertility and procedure-fertility).
1 parent e71501d commit 4ea42c2

3 files changed

Lines changed: 41 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [Unreleased]
4+
5+
### Added (plan 53 phase A — `HDSModelStreams.isContext()` helper)
6+
- `HDSModelStreams#isContext(streamId): boolean` — returns `true` iff the stream's data-model definition carries `role: 'context'` (the D3 descendant-streamId marker flag introduced in `@hds/data-model` Plan 53 Phase A). Unknown streamIds return `false` (no throw).
7+
- Use this to elide / mute / re-render context streams as metadata in settings trees, form-section renderers, and dashboards rather than as data-bearing buckets. Runtime resolution (`itemsDefs.forEvent` walk-up) is unaffected.
8+
- Tests: `[CTXR-P/Q/R/S]` in `tests/contextResolution.test.js`. Validates against the locally-built `data-model/dist/pack.json` so the flag is sourced from real YAML.
9+
310
## [1.0.0] - 2026-05-27
411

512
### Plan 61 Phase C — legacy collector code deleted

tests/contextResolution.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,25 @@ describe('[CTXR] Context-via-substream (Plan 46 D3)', () => {
104104
});
105105
});
106106

107+
describe('isContext() — Plan 53 role: context flag', () => {
108+
it('[CTXR-P] treatment-fertility is flagged as context', () => {
109+
assert.equal(model.streams.isContext('treatment-fertility'), true);
110+
});
111+
112+
it('[CTXR-Q] procedure-fertility is flagged as context', () => {
113+
assert.equal(model.streams.isContext('procedure-fertility'), true);
114+
});
115+
116+
it('[CTXR-R] data-bearing parent streams are not context', () => {
117+
assert.equal(model.streams.isContext('treatment'), false);
118+
assert.equal(model.streams.isContext('procedure'), false);
119+
});
120+
121+
it('[CTXR-S] unknown streamId returns false (no throw)', () => {
122+
assert.equal(model.streams.isContext('no-such-stream'), false);
123+
});
124+
});
125+
107126
describe('legacy multi-streamId resolution still works (no regression)', () => {
108127
it('[CTXR-K] event with multiple streamIds resolves via direct match', () => {
109128
// bridge-athenahealth pattern: streamIds carry both the canonical home

ts/HDSModel/HDSModel-Streams.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,21 @@ export class HDSModelStreams {
7676
return streamData;
7777
}
7878

79+
/**
80+
* True iff the stream exists and its data-model definition carries
81+
* `role: 'context'` — i.e. it's a descendant-streamId marker for the D3
82+
* context-via-substream mechanic, not a data-bearing bucket. Unknown
83+
* streamIds return `false` (no throw — this is a yes/no probe).
84+
*
85+
* Consumers (settings trees, form-section renderers, dashboards) should
86+
* use this to elide / mute / re-render context streams as metadata rather
87+
* than as independent input streams. See Plan 53.
88+
*/
89+
isContext (streamId: string): boolean {
90+
const streamData = this.#modelStreamsById[streamId];
91+
return streamData != null && streamData.role === 'context';
92+
}
93+
7994
/**
8095
* Get all parents id;
8196
*/

0 commit comments

Comments
 (0)