@smile-digital-health/crl 4.123.0 → 5.0.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.
Files changed (31) hide show
  1. package/README.md +16 -37
  2. package/dist/authoring-kit/answerExample.d.ts +4 -0
  3. package/dist/authoring-kit/answerExample.js +47 -0
  4. package/dist/authoring-kit/answerExample.js.map +1 -0
  5. package/dist/authoring-kit/index.js +196 -302
  6. package/dist/authoring-kit/index.js.map +1 -1
  7. package/dist/authoring-kit/quantityExample.d.ts +3 -0
  8. package/dist/authoring-kit/quantityExample.js +15 -0
  9. package/dist/authoring-kit/quantityExample.js.map +1 -0
  10. package/dist/authoring-kit/reference.d.ts +5 -9
  11. package/dist/authoring-kit/reference.js +86 -491
  12. package/dist/authoring-kit/reference.js.map +1 -1
  13. package/dist/authoring-kit/selectionExample.d.ts +10 -0
  14. package/dist/authoring-kit/selectionExample.js +48 -0
  15. package/dist/authoring-kit/selectionExample.js.map +1 -0
  16. package/dist/authoring-kit/sourceOrderExample.d.ts +1 -0
  17. package/dist/authoring-kit/sourceOrderExample.js +13 -0
  18. package/dist/authoring-kit/sourceOrderExample.js.map +1 -0
  19. package/dist/cel/validator/validator.js +3 -2
  20. package/dist/cel/validator/validator.js.map +1 -1
  21. package/dist/cql-emitter/lowerLocalCodes.js +2 -2
  22. package/dist/cql-emitter/lowerLocalCodes.js.map +1 -1
  23. package/dist/dispositions/categories.js +1 -1
  24. package/dist/dispositions/categories.js.map +1 -1
  25. package/dist/mcp/server.js +22 -27
  26. package/dist/mcp/server.js.map +1 -1
  27. package/dist/validator/reductionShapeValidator.js +9 -19
  28. package/dist/validator/reductionShapeValidator.js.map +1 -1
  29. package/dist/validator/useSiteTypeValidator.js +15 -22
  30. package/dist/validator/useSiteTypeValidator.js.map +1 -1
  31. package/package.json +1 -1
package/README.md CHANGED
@@ -6,53 +6,32 @@ Clinical Reasoning Language (CRL) provides a structured way to model clinical de
6
6
 
7
7
  ## Overview
8
8
 
9
- See the [User Guide](./USER_GUIDE.md) for a comprehensive introduction to the CRL language, syntax, and authoring best practices. For the **CLI and MCP tool reference** (emit, validate, the 7 MCP tools — for both CRL and CEL), see [TOOLING.md](./TOOLING.md).
9
+ See the [User Guide](https://github.com/alphora/clinical-reasoning-language/blob/v5.0.0/packages/crl/USER_GUIDE.md) for a comprehensive introduction to the CRL language, syntax, and authoring best practices. For the **CLI and MCP tool reference** (emit, validate, the MCP tools — for both CRL and CEL), see [TOOLING.md](https://github.com/alphora/clinical-reasoning-language/blob/v5.0.0/packages/crl/TOOLING.md).
10
10
 
11
11
  CRL is a domain-specific language designed for expressing clinical practice guidelines in a structured and machine-readable format. The language is implemented in TypeScript and provides a comprehensive set of tools for processing CRL documents.
12
12
 
13
13
  ## Metadata annotations
14
14
 
15
- CRL concepts can carry typed metadata via an `@tag` convention on `meta` lines (e.g. `@description`, `@ke-feedback`, `@kg-concept`) — for descriptions, knowledge-engineer feedback, plain-language logic, external-store hints, and extraction provenance. See the [metadata model](./spec/metadata-model.md) and the canonical [tag registry](./spec/metadata-registry.json). *(Draft: the convention parses today; Validator enforcement is forthcoming.)*
15
+ CRL concepts can carry typed metadata via an `@tag` convention on `meta` lines (e.g. `@description`, `@ke-feedback`, `@kg-concept`) — for descriptions, knowledge-engineer feedback, plain-language logic, external-store hints, and extraction provenance. See the [metadata model](https://github.com/alphora/clinical-reasoning-language/blob/v5.0.0/packages/crl/spec/metadata-model.md) and the canonical [tag registry](https://github.com/alphora/clinical-reasoning-language/blob/v5.0.0/packages/crl/spec/metadata-registry.json). *(Draft: the convention parses today; Validator enforcement is forthcoming.)*
16
16
 
17
17
  ## Installation
18
18
 
19
- This is a private package. To install it, you need:
20
-
21
- 1. An npm account with access to `@smile-digital-health` packages
22
- - Contact your team lead to request access
23
- - You will receive an invitation to join the organization
24
- - Each developer should use their own npm account
25
-
26
- 2. Set up authentication:
27
-
28
- ```bash
29
- # Log in to npm - recommended for individual developers
30
- npm login
31
- ```
32
-
33
- Or create/edit `~/.npmrc` with your personal access token (note the second line is **NOT a comment**):
34
-
35
- ```npmc
36
- @smile-digital-health:registry=https://registry.npmjs.org/
37
- //registry.npmjs.org/:_authToken=YOUR_NPM_TOKEN
38
- ```
39
-
40
- > **Security Note:** Always use your personal npm token. Do not share tokens between team members.
41
-
42
- Once authenticated, install the package:
19
+ The package is publicly available from npm; installation does not require an npm account or token.
43
20
 
44
21
  ```bash
45
- npm install @smile-digital-health/crl
22
+ npm install @smile-digital-health/crl@5.0.0
46
23
  ```
47
24
 
48
- Or add it to your `package.json`:
25
+ For a dependency that accepts compatible CRL5 updates:
49
26
 
50
27
  ```json
51
28
  "dependencies": {
52
- "@smile-digital-health/crl": "^0.6.1"
29
+ "@smile-digital-health/crl": "^5.0.0"
53
30
  }
54
31
  ```
55
32
 
33
+ CRL5 is a breaking language transition. Migrate existing content using the current authoring kit before upgrading; a `^4` dependency does not select5.x. The release notes describe the migration and distinguish changes already shipped in4.123.0.
34
+
56
35
  ### For Package Maintainers
57
36
 
58
37
  #### Publishing to npm
@@ -181,7 +160,7 @@ The FSH-to-CRL transformer converts FHIR Shorthand (FSH) files into Clinical Rea
181
160
  - **Deduplication and Suffixing**: Terminology blocks are unique by identifier and body. If a duplicate identifier is encountered with a different body, a numeric suffix (e.g., `_2`) is added to the identifier. If both identifier and body are the same, the block is not duplicated.
182
161
  - **Extraction Logic**: For `medicationCodeableConcept`, the transformer uses `system`, `code`, and `identifier` from the FSH object. For `dynamicValue.expression.expression` (where `path = "code.coding"`), the transformer uses `system` and `code` from the CQL code expression string and `identifier` from the corresponding description.
183
162
 
184
- For more details, see the [User Guide](./USER_GUIDE.md) and the technical mapping documentation.
163
+ For more details, see the [User Guide](https://github.com/alphora/clinical-reasoning-language/blob/v5.0.0/packages/crl/USER_GUIDE.md) and the technical mapping documentation.
185
164
 
186
165
  ## CLI Tool Usage
187
166
 
@@ -199,7 +178,7 @@ npm run cli:lexer
199
178
 
200
179
  Replace `<module>` with the desired CLI module name (e.g., `lexer`, `parser`, etc.).
201
180
 
202
- ## FHIR Definition Emit (v2.4.0)
181
+ ## FHIR Definition Emit
203
182
 
204
183
  CRL emits CPG-IG-conformant FHIR Definition resources (ValueSet, Library, ActivityDefinition, PlanDefinition) alongside the existing CQL emit.
205
184
 
@@ -207,9 +186,9 @@ CRL emits CPG-IG-conformant FHIR Definition resources (ValueSet, Library, Activi
207
186
  crl-emit --path <root.crl> --out-dir <project-root> --target fhir-def
208
187
  ```
209
188
 
210
- Output lands at `<project-root>/fhir/<ResourceType>/<id>.json`. CQL emit (the existing `--target cql` / default behavior) lands at `<project-root>/cql/<library-name>.cql`. Library content references the CQL file via the relative path `../../cql/<library-name>.cql`.
189
+ Output lands at `<project-root>/src/fhir/<ResourceType>/<id>.json`. CQL emit (the existing `--target cql` / default behavior) lands at `<project-root>/src/cql/<library-name>.cql`. Library content references the CQL file via the relative path `../../cql/<library-name>.cql`.
211
190
 
212
- For semantic rules, layout details, deliberate spec deviations, and the MCP `emit_crl_fhir` tool, see [`USER_GUIDE.md` §"Emitting FHIR Definition resources"](USER_GUIDE.md#emitting-fhir-definition-resources).
191
+ For semantic rules, layout details, deliberate spec deviations, and the MCP `emit_crl` tool, see [`USER_GUIDE.md` §"Emitting FHIR Definition resources"](https://github.com/alphora/clinical-reasoning-language/blob/v5.0.0/packages/crl/USER_GUIDE.md#emitting-fhir-definition-resources).
213
192
 
214
193
  ## API Usage & Reference
215
194
 
@@ -277,7 +256,7 @@ if (result.success) {
277
256
 
278
257
  ### 4. Validation
279
258
 
280
- > ⚠️ **Note:** Validation functionality is not yet implemented. The `validateCRL` function is a placeholder and will likely throw or return an error if used.
259
+ `validateCRL` performs single-file semantic validation. Inspect `success`, `errors` and `warnings`; use the path-based CLI or MCP validator when imports need project context.
281
260
 
282
261
  ```typescript
283
262
  import { validateCRL } from '@smile-digital-health/crl';
@@ -511,7 +490,7 @@ Note: This project uses a custom AST implementation that uses ANTLR's visitor pa
511
490
  >
512
491
  > The authoritative release checklist and instructions are maintained in a single location:
513
492
  >
514
- > **[.github/PULL_REQUEST_TEMPLATE/release.md](../../.github/PULL_REQUEST_TEMPLATE/release.md)**
493
+ > **[.github/PULL_REQUEST_TEMPLATE/release.md](https://github.com/alphora/clinical-reasoning-language/blob/v5.0.0/.github/PULL_REQUEST_TEMPLATE/release.md)**
515
494
  >
516
495
  > Always follow the steps in this file when preparing a new release. This ensures consistency and reduces maintenance overhead. If you need to update the release process, update the PR template only.
517
496
 
@@ -525,7 +504,7 @@ Note: This project uses a custom AST implementation that uses ANTLR's visitor pa
525
504
  - **Generated Files:** Auto-generated files (e.g., ANTLR outputs, grammar-driven types) are ignored by git and should never be edited manually. Always use the provided scripts to regenerate them.
526
505
  - **Documentation:** Keep all documentation referencing the release checklist up-to-date by linking to the PR template.
527
506
 
528
- For more details, see the [release PR template](../../.github/PULL_REQUEST_TEMPLATE/release.md) and the automation scripts in `.github/scripts/`.
507
+ For more details, see the [release PR template](https://github.com/alphora/clinical-reasoning-language/blob/v5.0.0/.github/PULL_REQUEST_TEMPLATE/release.md) and the automation scripts in `.github/scripts/`.
529
508
 
530
509
  ### Error Handling Strategy
531
510
 
@@ -568,7 +547,7 @@ We provide a Visual Studio Code extension for CRL files:
568
547
  - Comment support
569
548
  - Language basics for a better editing experience
570
549
 
571
- For installation instructions and full details, see [crl-vscode/README.md](../crl-vscode/README.md)
550
+ For installation instructions and full details, see [crl-vscode/README.md](https://github.com/alphora/clinical-reasoning-language/blob/v5.0.0/packages/crl-vscode/README.md)
572
551
 
573
552
  ## License
574
553
 
@@ -0,0 +1,4 @@
1
+ export declare const ANSWER_EXAMPLE_BASE = "https://example.org/answers";
2
+ export declare const ANSWER_EXAMPLE_TERMS = "terminology \"Choices\":\n- system is `https://example.org/answers/CodeSystem/p-complaint-answer-codes`.\n- code is `none` display is `None`.\n- system is `urn:standard`.\n- code is `symptom` display is `Symptom`.\n";
3
+ export declare function answerExampleSource(name?: string): string;
4
+ export declare const ANSWER_EXAMPLE_CEL = "library \"Cases\". covers \"P\".\nfact \"Patient\": - name is \"Synthetic\". - birth date is \"1970-01-01\". - defined by \"Patient\".\nfact \"Positive\": - value is \"symptom\". - date is \"2026-09-08\". - defined by \"P\".\"Complaint\".\nfact \"Negative\": - value is \"none\". - date is \"2026-09-08\". - defined by \"P\".\"Complaint\".\ncase \"Positive\": - subject is \"Patient\". - fact is \"Positive\". - result is \"D\" is \"Met\".\ncase \"Negative\": - subject is \"Patient\". - fact is \"Negative\". - result is \"D\" is \"Unmet\".\ncase \"Missing\": - subject is \"Patient\". - result is \"D\" is pause.\n";
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ANSWER_EXAMPLE_CEL = exports.ANSWER_EXAMPLE_TERMS = exports.ANSWER_EXAMPLE_BASE = void 0;
4
+ exports.answerExampleSource = answerExampleSource;
5
+ exports.ANSWER_EXAMPLE_BASE = "https://example.org/answers";
6
+ exports.ANSWER_EXAMPLE_TERMS = `terminology "Choices":
7
+ - system is \`${exports.ANSWER_EXAMPLE_BASE}/CodeSystem/p-complaint-answer-codes\`.
8
+ - code is \`none\` display is \`None\`.
9
+ - system is \`urn:standard\`.
10
+ - code is \`symptom\` display is \`Symptom\`.
11
+ `;
12
+ function answerExampleSource(name = "Complaint") {
13
+ return `library "P".
14
+ concept "${name}":
15
+ - shape is Record.
16
+ - type is Observation.
17
+ - value type is CodeableConcept.
18
+ - code is \`complaint\`.
19
+ - value domain is answer options.
20
+ - shape reduction is most recent.
21
+ - value from is "Shared"."Choices":
22
+ - not qualifying is \`none\`.
23
+ presentation for "${name}":
24
+ - question text is "Which complaint supports this request?".
25
+ - question description is "Select the documented complaint.".
26
+ concept "Qualifies":
27
+ - shape is Record.
28
+ - type is Observation.
29
+ - shape reduction is most recent.
30
+ - value type is boolean.
31
+ - definition is "${name}" in qualifying.
32
+ activity "Met": - request CPGCommunicationRequest. - with \`MET\`.
33
+ activity "Unmet": - request CPGCommunicationRequest. - with \`UNMET\`.
34
+ decision "D": first:
35
+ - when "Qualifies" then recommend activity "Met".
36
+ - otherwise then recommend activity "Unmet".
37
+ `;
38
+ }
39
+ exports.ANSWER_EXAMPLE_CEL = `library "Cases". covers "P".
40
+ fact "Patient": - name is "Synthetic". - birth date is "1970-01-01". - defined by "Patient".
41
+ fact "Positive": - value is "symptom". - date is "2026-09-08". - defined by "P"."Complaint".
42
+ fact "Negative": - value is "none". - date is "2026-09-08". - defined by "P"."Complaint".
43
+ case "Positive": - subject is "Patient". - fact is "Positive". - result is "D" is "Met".
44
+ case "Negative": - subject is "Patient". - fact is "Negative". - result is "D" is "Unmet".
45
+ case "Missing": - subject is "Patient". - result is "D" is pause.
46
+ `;
47
+ //# sourceMappingURL=answerExample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answerExample.js","sourceRoot":"","sources":["../../src/authoring-kit/answerExample.ts"],"names":[],"mappings":";;;AAQA,kDAwBI;AA/BS,QAAA,mBAAmB,GAAG,6BAA6B,CAAC;AACpD,QAAA,oBAAoB,GAAG;gBACpB,2BAAmB;;;;CAIlC,CAAC;AACF,SAAgB,mBAAmB,CAAC,IAAI,GAAG,WAAW;IAAI,OAAO;WACtD,IAAI;;;;;;;;;oBASK,IAAI;;;;;;;;mBAQL,IAAI;;;;;;CAMtB,CAAC;AAAC,CAAC;AAES,QAAA,kBAAkB,GAAG;;;;;;;CAOjC,CAAC"}