cda-schematron-validator 2.0.0 → 2.0.1
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.
- package/README.md +32 -1
- package/docs/deployment.md +2 -2
- package/docs/images/validation-findings.jpg +0 -0
- package/docs/images/validation-workspace.jpg +0 -0
- package/docs/legacy-api.md +18 -0
- package/docs/release-2.0.0.md +19 -2
- package/docs/release-2.0.1.md +24 -0
- package/docs/terminology.md +129 -1
- package/lib/getIgnored.js +2 -1
- package/lib/getSchematronMap.js +2 -2
- package/lib/includeExternalDocument.js +2 -2
- package/lib/initializeProcess.js +2 -2
- package/lib/parseXml.js +19 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -14,10 +14,39 @@
|
|
|
14
14
|
|
|
15
15
|
</div>
|
|
16
16
|
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
*The browser workspace in version 2.0.0. The synthetic example intentionally contains errors; no real patient information is shown.*
|
|
20
|
+
|
|
21
|
+
<details>
|
|
22
|
+
<summary><strong>See the validation findings</strong></summary>
|
|
23
|
+
|
|
24
|
+

|
|
25
|
+
|
|
26
|
+
Findings include the validation stage, rule identifier where available, and links to the XML location. Completed stages mean the checks ran; inspect the report status and coverage before treating a document as valid.
|
|
27
|
+
|
|
28
|
+
</details>
|
|
29
|
+
|
|
17
30
|
---
|
|
18
31
|
|
|
19
32
|
> [!NOTE]
|
|
20
|
-
> **Version 2.0.
|
|
33
|
+
> **Version 2.0.1.** The container provides the validation API and browser UI. npm retains legacy APIs plus a typed HTTP client and CLI (Node 22.12+). Install the stable package without a preview tag. The validation scope is pinned XSD/Schematron with reviewed supplements; full FHIR model validation and clinical certification are outside that scope. See [coverage](docs/coverage.md) and the [release notes](https://github.com/priyaranjan-tokachichu/cda-schematron-validator/releases/tag/v2.0.1).
|
|
34
|
+
|
|
35
|
+
The [2.0.1 patch](docs/release-2.0.1.md) fixes malformed-XML handling in the legacy APIs.
|
|
36
|
+
|
|
37
|
+
## Upgrade from version 1
|
|
38
|
+
|
|
39
|
+
Use **Node 22.12.0 or newer**, then explicitly select the latest stable release:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
node --version
|
|
43
|
+
npm install cda-schematron-validator@latest
|
|
44
|
+
npm ls cda-schematron-validator
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Commit the updated `package.json` and lockfile, then run your application's tests. A dependency range such as `^1.1.12` stays on version 1 with ordinary `npm update`; the explicit install above updates that range. Use `npm outdated` to check for newer releases.
|
|
48
|
+
|
|
49
|
+
The seven legacy JavaScript exports remain available, including synchronous and Promise-based validation. They run locally without Docker and remain a partial Schematron interpreter. Correctness fixes can change previously incorrect results. For the modern XSD/Schematron pipeline, run the separate container and use `createClient()` or the CLI; installing npm alone does not start the service. See the [migration guide](docs/legacy-api.md#upgrade-from-version-1), [release notes](docs/release-2.0.0.md) and [terminology setup](docs/terminology.md).
|
|
21
50
|
|
|
22
51
|
<table>
|
|
23
52
|
<tr>
|
|
@@ -97,6 +126,8 @@ Sources are pinned by immutable release URL and SHA-256. The build verifies down
|
|
|
97
126
|
> [!IMPORTANT]
|
|
98
127
|
> **Coverage is explicit.** The original C-CDA 5.0 generation report is preserved, with reviewed replacement checks reported separately. Completion requires a supported document-level template and every applicable check to be determinate. Missing operator data—including NUBC discharge status—produces coverage findings where needed. The scope is pinned CDA XSD and C-CDA Schematron with supplements, not full FHIR StructureDefinition or clinical certification. [See the checks and evidence](docs/coverage.md).
|
|
99
128
|
|
|
129
|
+
**Operator** means you or the administrator running the validator. Terminology is installed separately from the public image. To enable C-CDA 2.1 Schematron, follow the [official vocabulary download and installation steps](docs/terminology.md#get-and-install-the-c-cda-21-vocabulary). See [what was verified locally and how to recreate it](docs/terminology.md#what-was-installed-and-validated-locally).
|
|
130
|
+
|
|
100
131
|
Neither profile certifies clinical accuracy or every terminology requirement. See [standards, provenance, and coverage](docs/architecture.md#standards-and-coverage).
|
|
101
132
|
|
|
102
133
|
## Call the API
|
package/docs/deployment.md
CHANGED
|
@@ -17,7 +17,7 @@ docker compose logs validator
|
|
|
17
17
|
docker compose down
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
The owner-triggered release workflow publishes versioned AMD64/ARM64 images for `ghcr.io/priyaranjan-tokachichu/cda-schematron-validator`, with SBOM and provenance. A merge alone does not publish an image. The versioned stable image is `ghcr.io/priyaranjan-tokachichu/cda-schematron-validator:v2.0.
|
|
20
|
+
The owner-triggered release workflow publishes versioned AMD64/ARM64 images for `ghcr.io/priyaranjan-tokachichu/cda-schematron-validator`, with SBOM and provenance. A merge alone does not publish an image. The versioned stable image is `ghcr.io/priyaranjan-tokachichu/cda-schematron-validator:v2.0.1`. Existing preview images do not acquire the new runtime pins automatically.
|
|
21
21
|
|
|
22
22
|
Run the versioned image directly:
|
|
23
23
|
|
|
@@ -26,7 +26,7 @@ docker run -d --name cda-validator --memory=1536m --cpus=2 \
|
|
|
26
26
|
--read-only --tmpfs /tmp:size=64m,noexec,nosuid \
|
|
27
27
|
--cap-drop=ALL --security-opt=no-new-privileges --pids-limit=128 \
|
|
28
28
|
-p 127.0.0.1:17643:17643 \
|
|
29
|
-
ghcr.io/priyaranjan-tokachichu/cda-schematron-validator:v2.0.
|
|
29
|
+
ghcr.io/priyaranjan-tokachichu/cda-schematron-validator:v2.0.1
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
## Patched Java runtime
|
|
Binary file
|
|
Binary file
|
package/docs/legacy-api.md
CHANGED
|
@@ -7,6 +7,22 @@ The original JavaScript APIs remain local and retain their result shape and sync
|
|
|
7
7
|
> [!IMPORTANT]
|
|
8
8
|
> The legacy implementation is a **partial Schematron interpreter**, with no XSD validation. Installing the modern package does not turn `validate()` into the full service engine. Use `createClient()` for the modern pipeline.
|
|
9
9
|
|
|
10
|
+
## Upgrade from version 1
|
|
11
|
+
|
|
12
|
+
1. Use Node **22.12.0 or newer**. Check your local and CI runtimes with `node --version`.
|
|
13
|
+
2. Install the latest stable package explicitly:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install cda-schematron-validator@latest
|
|
17
|
+
npm ls cda-schematron-validator
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
3. Commit the updated `package.json` and lockfile, then run your application's tests. Existing `^1.x` dependency ranges and lockfiles do not automatically adopt the new major release through `npm update`.
|
|
21
|
+
4. Keep existing legacy calls if you need their synchronous/Promise result contracts. Review the [correctness fixes](#correctness-fixes-in-version-2), which can change previously incorrect validation results.
|
|
22
|
+
5. To use the modern engine, follow [the service migration steps](#move-to-the-modern-pipeline) and [terminology setup](terminology.md). The container is distributed separately; installing npm alone does not provide XSD validation or launch the service.
|
|
23
|
+
|
|
24
|
+
Older integrations that cannot meet the Node requirement can explicitly retain `cda-schematron-validator@1.1.12`. Legacy versions remain downloadable. If npm displays a legacy-version deprecation notice, use this guide to plan the upgrade; the notice does not change your installed dependencies. See the [2.0.0 release notes](release-2.0.0.md).
|
|
25
|
+
|
|
10
26
|
## Exports preserved
|
|
11
27
|
|
|
12
28
|
| Export | Behavior |
|
|
@@ -37,6 +53,8 @@ console.log(result.errorCount, result.errors);
|
|
|
37
53
|
|
|
38
54
|
Legacy calls accept XML/Schematron strings or file paths. `schematron` may be `null` when `options.parsedSchematronMap` is supplied. Unlike the modern service, legacy findings may include XML snippets.
|
|
39
55
|
|
|
56
|
+
**Since 2.0.1:** malformed document or Schematron XML throws a `SyntaxError` in `validate()` and rejects the async/batch Promises. DTD declarations are unsupported and rejected. Malformed external-resource XML is reported as an ignored check with a parsing error. The APIs no longer accept parser-repaired XML as an apparent pass. See the [patch release notes](release-2.0.1.md), including the boundary for caller-parsed DOMs.
|
|
57
|
+
|
|
40
58
|
## Results and options
|
|
41
59
|
|
|
42
60
|
Results retain `errorCount`, `warningCount`, `ignoredCount`, `errors`, `warnings`, and `ignored`. Ignored findings should be reviewed when assessing interpreter coverage; a zero error count does not establish full CDA conformance.
|
package/docs/release-2.0.0.md
CHANGED
|
@@ -20,11 +20,26 @@ The pipeline is **pinned XSD and Schematron with reviewed supplements**. It is n
|
|
|
20
20
|
|
|
21
21
|
## Upgrade requirements
|
|
22
22
|
|
|
23
|
+
To upgrade from version 1, use Node **22.12.0 or newer** and explicitly install the latest stable package:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npm install cda-schematron-validator@latest
|
|
27
|
+
npm ls cda-schematron-validator
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Commit the updated dependency manifest and lockfile, then run your application's tests. Ordinary `npm update` respects an existing `^1.x` range and does not adopt version 2. The [migration guide](legacy-api.md#upgrade-from-version-1) covers preserved APIs, correctness changes and the separate service setup. Legacy versions remain downloadable for integrations that need them. An npm deprecation notice encourages migration without changing installed dependencies.
|
|
31
|
+
|
|
23
32
|
The npm package requires **Node 22.12+**. Local service builds require **JDK 25**; running the container requires no host Java. Existing legacy calls keep their synchronous/Promise contracts but remain a partial Schematron interpreter without XSD validation.
|
|
24
33
|
|
|
25
|
-
|
|
34
|
+
**Operator** means the person or organization running the validator: you locally, or your administrator/IT team in a hosted deployment. **Operator-supplied terminology** means source-publisher vocabulary files that this administrator obtains and installs locally; it does not mean patient data. These files are separate from the public application image and npm package.
|
|
35
|
+
|
|
36
|
+
New containers need a read-only terminology volume. To enable C-CDA 2.1 Schematron, obtain the exact `voc.xml` from the [official HL7 2025SEP archive](https://github.com/HL7/CDA-ccda-2.1/releases/tag/2025SEP), verify and extract it with `python3 scripts/prepare-assets.py`, then install it with the image's `TerminologyTool install-legacy` command. The [step-by-step guide](terminology.md#get-and-install-the-c-cda-21-vocabulary) provides download, installation, startup and validation commands. C-CDA 2.1 XSD checks remain available before installation; the broader C-CDA 5.0 pack is not required to enable its Schematron stage.
|
|
26
37
|
|
|
27
|
-
|
|
38
|
+
CPT/ADA and other source rights are separate from the application license. Download availability, installation and checksum verification do not grant data rights; follow the applicable publisher terms. No data license is granted by installation.
|
|
39
|
+
|
|
40
|
+
The recorded local verification used the pinned C-CDA 2.1 vocabulary and a separate pack of **29 snapshots / 1,013,055 membership entries, 28 active indexes and two grammars**. The pack comprised 21 VSAC snapshots, four public HL7/CDC expansions, one HealthcareServiceLocation expansion and three LOINC/UMLS-derived sets. Sources included UMLS 2026AB, LOINC 2.83, UCUM 2.2 and the November 18, 2026 IANA registries. The files remain local and are not release downloads. The [reproduction guide](terminology.md#recreate-the-broader-local-terminology-setup) links the source publishers, reviewed VSAC counts/hashes, import commands and readiness checks.
|
|
41
|
+
|
|
42
|
+
This was **not all terminology**: NUBC discharge status was absent and remains administrator-supplied. An applicable missing NUBC check prevents completion. Unsupported expressions/modifiers, mismatched editions and indeterminate grammar/timestamp cases also remain incomplete.
|
|
28
43
|
|
|
29
44
|
## Verification
|
|
30
45
|
|
|
@@ -32,6 +47,8 @@ The verified local pack has 29 snapshots / 1,013,055 membership entries, 28 acti
|
|
|
32
47
|
|
|
33
48
|
Six concurrent maximum-size uploads complete in both framing modes with the full local pack on a 1 GiB heap. Health remains available and no retries are needed for admitted uploads. Current [evidence](../reports/coverage-progress.json), [image scan](../reports/security.json) and [HTML report](../reports/architecture.html) record the exact scope and results.
|
|
34
49
|
|
|
50
|
+
A [November 28, 2026 published-image smoke check](../reports/terminology-setup-verification.json) verifies the documented vocabulary install path: C-CDA 2.1 Schematron is skipped before installation and completes afterward (110 rules fired). C-CDA 5.0 also completes its configured pipeline with the local pack on the tested fixture. Both installed-data fixtures are invalid documents with completed coverage; this is not a claim that all documents or all terminology were validated.
|
|
51
|
+
|
|
35
52
|
## Release publication
|
|
36
53
|
|
|
37
54
|
Release publication merges the owner-authorized PR through GitHub, publishes versioned AMD64/ARM64 container artifacts from that commit, publishes npm 2.0.0 with the `latest` tag, then verifies public install, image startup and runtime metadata. Keep immutable preview artifacts intact. npm may require its separate per-publication authentication.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# 2.0.1 patch release
|
|
2
|
+
|
|
3
|
+
The legacy JavaScript APIs now reject malformed XML instead of repairing it and returning an apparent pass. In 2.0.0, `<root><item ok="yes"></root>` could produce a console warning while `validate()` and `validateAsync()` returned zero errors, warnings and ignored checks.
|
|
4
|
+
|
|
5
|
+
## Corrected behavior
|
|
6
|
+
|
|
7
|
+
- `validate()` throws a `SyntaxError` for malformed document or Schematron XML. `validateAsync()`, `validateFileListAsync()` and `validateFileObjectAsync()` reject their Promises.
|
|
8
|
+
- Document XML is checked even when a parsed Schematron map is supplied. Malformed Schematron is not cached.
|
|
9
|
+
- Malformed external vocabulary XML produces an ignored check with an explicit parsing error rather than a result based on a repaired resource. Review `ignoredCount` when using the partial legacy interpreter.
|
|
10
|
+
- DTD declarations are unsupported and rejected in legacy document, Schematron and external-resource XML. Predefined XML entities and character references remain supported.
|
|
11
|
+
- Well-formed inputs retain the existing result shape, synchronous/Promise contracts, namespace handling and finding locations. The modern service validation pipeline is unchanged; its version metadata is updated to 2.0.1.
|
|
12
|
+
|
|
13
|
+
## Upgrade
|
|
14
|
+
|
|
15
|
+
Use Node 22.12.0 or newer:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install cda-schematron-validator@latest
|
|
19
|
+
npm ls cda-schematron-validator
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Handle thrown/rejected parsing errors in legacy integrations. Callers supplying `parseSchematron()` with a DOM must ensure their own parser rejected malformed source; a repaired DOM cannot preserve evidence of every original syntax error.
|
|
23
|
+
|
|
24
|
+
The modern engine remains a separate container, tagged `ghcr.io/priyaranjan-tokachichu/cda-schematron-validator:v2.0.1`. [Terminology installation](terminology.md), coverage limits and the [version 1 migration guide](legacy-api.md#upgrade-from-version-1) still apply.
|
package/docs/terminology.md
CHANGED
|
@@ -1,9 +1,137 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Administrator-supplied terminology
|
|
2
2
|
|
|
3
3
|
[← Coverage inventory](coverage.md) · [Deployment](deployment.md)
|
|
4
4
|
|
|
5
5
|
Version 2.0.0 adds coverage and packaging changes after `2.0.0-preview.2`. Older published images are unchanged. New public images omit the entire mixed-license C-CDA 2.1 `voc.xml`, which contains CPT entries. The service can start and show the UI without it; C-CDA 2.1 schema checks run, and its Schematron stage explicitly reports setup required until an authorized pinned vocabulary is installed. The legacy npm API remains compatible and accepts caller-supplied validation resources.
|
|
6
6
|
|
|
7
|
+
## Who is the operator?
|
|
8
|
+
|
|
9
|
+
**Operator** means the person or organization that runs this validator: you on a personal computer, or the administrator/IT team responsible for a hosted installation. **Operator-supplied terminology** means terminology files that the administrator obtains from the source publisher and installs in the local `terminology` folder. It does not mean patient data, a clinician entering codes, or a separate commercial operator service.
|
|
10
|
+
|
|
11
|
+
The application includes its validation rules and import/install tools. Public npm packages and final container images do not include the separately installed terminology pack. Download access and checksums do not establish permission to use or redistribute the underlying terminology; consult the applicable publisher terms for your deployment.
|
|
12
|
+
|
|
13
|
+
## What was installed and validated locally?
|
|
14
|
+
|
|
15
|
+
The recorded 2.0.0 verification used the pinned C-CDA 2.1 `voc.xml`, plus a local C-CDA 5.0 pack containing **29 snapshots / 1,013,055 membership entries**, **28 active indexes**, and **two grammars** (UCUM and language tags). The pack was assembled from 21 reviewed VSAC exports, four reviewed public HL7/CDC expansions, a HealthcareServiceLocation expansion, and three LOINC/UMLS-derived sets. Source editions include UMLS 2026AB, LOINC 2.83 and the editions listed [below](#prepare-us-core-condition-and-procedure-sets-from-umls).
|
|
16
|
+
|
|
17
|
+
This was **not every terminology set**: NUBC patient discharge status was not installed. The pinned XSD/Schematron stages and reviewed supplements were exercised with local data, including concurrent maximum-size uploads. Individual documents can complete when they do not need missing data; an applicable missing NUBC check, unsupported expression or other indeterminate check prevents completion. Successful engine execution or an HTTP 200 response is not evidence that a document is valid.
|
|
18
|
+
|
|
19
|
+
The recorded automated suite comprised 65 JavaScript, 45 Java and 17 Python tests. Fifteen targeted comparisons against HL7 FHIR Validator used **reference terminology disabled**; they do not prove complete terminology or StructureDefinition equivalence. See the dated [verification evidence](../reports/coverage-progress.json) and [reference comparison](../reports/reference-comparison.json). The local pack is not a downloadable project artifact.
|
|
20
|
+
|
|
21
|
+
A [November 28, 2026 smoke check](../reports/terminology-setup-verification.json) of the published image confirmed that C-CDA 2.1 Schematron is skipped without the vocabulary and completes after installation (110 rules fired on `test/VitalSigns.xml`). Both stages also completed for the C-CDA 5.0 fixture with the local pack. The fixtures reported `invalid` with `validationComplete: true`: all applicable checks completed and found document errors. These are execution checks, not passing-document or clinical certification claims.
|
|
22
|
+
|
|
23
|
+
## Choose your setup
|
|
24
|
+
|
|
25
|
+
| Goal | Data to install | Result |
|
|
26
|
+
| --- | --- | --- |
|
|
27
|
+
| C-CDA 2.1 schema checks | No separate terminology | XSD runs; Schematron reports setup required until its vocabulary is installed. |
|
|
28
|
+
| C-CDA 2.1 XSD and Schematron | The exact pinned HL7 2025SEP `voc.xml` | Both stages can run; terminology coverage remains limited to that upstream snapshot. |
|
|
29
|
+
| Broader C-CDA 5.0 supplements and binding checks | The separate VSAC, HL7/CDC, LOINC/UMLS and grammar pack | Applicable installed checks run; missing NUBC or other required data still prevents completion. |
|
|
30
|
+
|
|
31
|
+
The 29-snapshot C-CDA 5.0 pack is **not a prerequisite** for enabling C-CDA 2.1 Schematron. Start with the next section for that profile.
|
|
32
|
+
|
|
33
|
+
## Get and install the C-CDA 2.1 vocabulary
|
|
34
|
+
|
|
35
|
+
Prerequisites: Git, Python 3 and Docker. No host Java or Node is needed for these commands. After reviewing the source terms applicable to your use, obtain the **2025SEP** archive from the [official HL7 release](https://github.com/HL7/CDA-ccda-2.1/releases/tag/2025SEP). It is named `CDAR2_IG_CCDA_CLINNOTES_R1_DSTU2.1_2025SEP.zip` and contains `voc.xml`. A direct publisher download is available from that release; do not substitute a newer or edited vocabulary for the pinned file.
|
|
36
|
+
|
|
37
|
+
The existing asset preparation command downloads the official pinned archives, checks their SHA-256 values against [the source lock](../profiles/sources.lock.json), and extracts the vocabulary locally:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
git clone https://github.com/priyaranjan-tokachichu/cda-schematron-validator.git
|
|
41
|
+
cd cda-schematron-validator
|
|
42
|
+
python3 scripts/prepare-assets.py
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The required file is now `service/assets/ccda-2.1/voc.xml`. This command prepares all three pinned validation-asset archives; it does **not** download the separate VSAC/UMLS/LOINC pack. The C-CDA 2.1 archive SHA-256 is `9c9a73294fbc4bea2c31e3650184609fa2d8894a848da6240c0916cd1e1c0d23`. If you download the ZIP manually, verify that checksum and extract its `voc.xml`, then use its absolute path in the input mount below.
|
|
46
|
+
|
|
47
|
+
Install into your own terminology folder using the published application image:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
IMAGE=ghcr.io/priyaranjan-tokachichu/cda-schematron-validator:v2.0.0
|
|
51
|
+
docker pull "$IMAGE"
|
|
52
|
+
mkdir -p terminology
|
|
53
|
+
docker run --rm --network none --entrypoint java \
|
|
54
|
+
--user "$(id -u):$(id -g)" \
|
|
55
|
+
-v "$PWD/terminology:/app/terminology" \
|
|
56
|
+
-v "$PWD/service/assets/ccda-2.1/voc.xml:/input/voc.xml:ro" \
|
|
57
|
+
"$IMAGE" -cp /app/app.jar org.cdavalidator.TerminologyTool \
|
|
58
|
+
install-legacy /input/voc.xml
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The installer checks the vocabulary checksum required by the image and writes `terminology/ccda-2.1-voc.xml`. An incorrect edition is rejected. The installation stays local; do not commit or publish the vocabulary or terminology folder.
|
|
62
|
+
|
|
63
|
+
Start the service with that folder mounted read-only:
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
docker run --rm --read-only --tmpfs /tmp:size=64m,noexec,nosuid \
|
|
67
|
+
--memory=1536m -e JAVA_TOOL_OPTIONS=-Xmx1g \
|
|
68
|
+
-p 127.0.0.1:17643:17643 \
|
|
69
|
+
-v "$PWD/terminology:/app/terminology:ro" \
|
|
70
|
+
"$IMAGE"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Use an unused host port if 17643 is occupied, and use that same port in the following commands. In another terminal:
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
curl --fail --silent --show-error http://127.0.0.1:17643/v1/profiles
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
For profile `ccda-2.1`, check `terminologySetup.ready: true`. The `ccda-5.0` inventory can still report missing datasets; installing the legacy vocabulary alone does not make the other profile data-ready. The existing `doctor` command [below](#mount-diagnose-and-run) checks both profiles and can therefore still exit with code 2.
|
|
80
|
+
|
|
81
|
+
Submit a local document with the C-CDA 2.1 profile (run from the repository folder):
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
python3 - <<'PYDOC' > /tmp/ccda-21-request.json
|
|
85
|
+
import json
|
|
86
|
+
from pathlib import Path
|
|
87
|
+
print(json.dumps({"xml": Path("test/VitalSigns.xml").read_text(),
|
|
88
|
+
"profile": "ccda-2.1", "includeWarnings": True}))
|
|
89
|
+
PYDOC
|
|
90
|
+
curl --fail --silent --show-error http://127.0.0.1:17643/v1/validate \
|
|
91
|
+
-H 'Content-Type: application/json' \
|
|
92
|
+
--data-binary @/tmp/ccda-21-request.json
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`test/VitalSigns.xml` is a test fixture, not a guaranteed valid clinical document. Inspect `stages`, `executionComplete`, `validationComplete` and `status`; findings may be expected. Restart the service after changing terminology files.
|
|
96
|
+
|
|
97
|
+
## Recreate the broader local terminology setup
|
|
98
|
+
|
|
99
|
+
Use a checkout containing this guide and its checklists. Obtain restricted source downloads through your own publisher accounts; the project does not distribute the local pack or accept source terms for you.
|
|
100
|
+
|
|
101
|
+
| Component | Where to obtain it | Local preparation |
|
|
102
|
+
| --- | --- | --- |
|
|
103
|
+
| 21 VSAC snapshots | [NLM VSAC](https://vsac.nlm.nih.gov/); search each OID in the [reviewed checklist](../profiles/terminology-svs-checklist.json), select the reviewed expansion and export complete SVS XML | Use `import-svs.py` with that checklist as shown below. Include retired sets referenced by the pinned guide after review. |
|
|
104
|
+
| Four public HL7/CDC expansions and two grammars | Publisher URLs and hashes in [the terminology lock](../profiles/terminology-sources.lock.json) | `python3 scripts/prepare-public-terminology.py --download --grammars --output terminology` |
|
|
105
|
+
| HealthcareServiceLocation union | Obtain a complete FHIR expansion of `http://terminology.hl7.org/ValueSet/v3-HealthcareServiceLocation`, definition version `4.0.0`, from your configured terminology service | Import with the [location checklist](../profiles/terminology-location-checklist.json) and [explicit system mappings](../profiles/terminology-location-systems.json), as shown below. |
|
|
106
|
+
| LOINC document types | [LOINC Complete 2.83](https://loinc.org/downloads/) through your LOINC account | `python3 scripts/import-loinc.py --input /private/path/Loinc_2.83.zip --output terminology` |
|
|
107
|
+
| US Core condition and procedure sets | [NLM UMLS downloads](https://www.nlm.nih.gov/research/umls/licensedcontent/umlsknowledgesources.html): the full **2026AB distribution archive**, plus LOINC Complete 2.83 | Use `import-umls.py` [below](#prepare-us-core-condition-and-procedure-sets-from-umls). Do not substitute a precomputed subset or individual RRF download; archive hashes must match the lock. |
|
|
108
|
+
| NUBC discharge disposition | An authorized source providing the applicable complete, versioned expansion | Use the FHIR importer with your reviewed version, count and OID mappings. This dataset was **not** in the recorded local pack. |
|
|
109
|
+
|
|
110
|
+
For the VSAC export collection:
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
python3 scripts/import-svs.py \
|
|
114
|
+
--input-glob '/private/path/RetrieveMultipleValueSets*.xml' \
|
|
115
|
+
--expected profiles/terminology-svs-checklist.json \
|
|
116
|
+
--output terminology
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The checklist records the actual local counts, source hashes, normalized snapshot hashes and status. Its source-version label was `Latest` in those exports; it is **not an immutable release identifier**. A later export can differ. Counts alone do not establish identical membership: compare the imported snapshot hashes with the checklist for exact reproduction. Review changed editions/counts explicitly instead of editing the checklist merely to force an import to pass. No terminology codes or descriptions are included in these checklists.
|
|
120
|
+
|
|
121
|
+
For the 274-member HealthcareServiceLocation expansion:
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
python3 scripts/import-fhir-terminology.py \
|
|
125
|
+
--input /private/path/healthcare-location.json \
|
|
126
|
+
--expected profiles/terminology-location-checklist.json \
|
|
127
|
+
--systems profiles/terminology-location-systems.json \
|
|
128
|
+
--output terminology
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The two import commands preserve other installed expansions. The public-source preparation command uses the pinned source hashes; if a live grammar registry has changed and the pinned edition is unavailable, it stops rather than silently accepting newer bytes. Use a verified copy of that pinned edition or review and update the lock. After assembling the pack, mount it read-only, run `doctor`, and inspect each profile's missing-data inventory. A 29-snapshot count does not by itself prove matching membership or complete validation coverage.
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
7
135
|
## Licensing and source selection
|
|
8
136
|
|
|
9
137
|
The application’s MIT license does not license terminology data. A user’s CPT license does not automatically grant this project distribution rights. Giving the application away or adding a notice does not replace the required agreement. AMA’s [licensing guidance](https://www.ama-assn.org/practice-management/cpt/cpt-licensing-frequently-asked-questions-faqs) also covers CPT-dependent products, so user-supplied data is not a blanket licensing exemption for the application. No CPT distribution agreement has been established for this project.
|
package/lib/getIgnored.js
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
function getIgnored(assertionObject, assertionInfo, resultInfo) {
|
|
10
|
-
const { type, assertionId, test, simplifiedTest, description
|
|
10
|
+
const { type, assertionId, test, simplifiedTest, description } = assertionObject;
|
|
11
|
+
const errorMessage = assertionObject.results.errorMessage || assertionObject.errorMessage;
|
|
11
12
|
const { patternId, ruleId, context } = assertionInfo;
|
|
12
13
|
const { ignored } = resultInfo;
|
|
13
14
|
const obj = {
|
package/lib/getSchematronMap.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const parseXml = require('./parseXml');
|
|
2
2
|
const crypto = require('crypto');
|
|
3
3
|
const parseSchematron = require('./parseSchematron');
|
|
4
4
|
/**
|
|
@@ -22,7 +22,7 @@ function getSchematronMap(schematron, options = {}) {
|
|
|
22
22
|
}
|
|
23
23
|
// If not in cache
|
|
24
24
|
// Load schematron doc
|
|
25
|
-
const schematronDoc =
|
|
25
|
+
const schematronDoc = parseXml(schematron, 'Schematron XML');
|
|
26
26
|
// Parse schematron
|
|
27
27
|
if (Object.keys(options.parsedMap).length >= 32) {
|
|
28
28
|
delete options.parsedMap[Object.keys(options.parsedMap)[0]];
|
|
@@ -4,7 +4,7 @@ module.exports = modifyTest;
|
|
|
4
4
|
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const xpath = require('xpath');
|
|
7
|
-
const
|
|
7
|
+
const parseXml = require('./parseXml');
|
|
8
8
|
const path = require('path');
|
|
9
9
|
|
|
10
10
|
const loadedExternalDocuments = Object.create(null);
|
|
@@ -60,7 +60,7 @@ function modifyTest(test, resourceDir) {
|
|
|
60
60
|
catch (err) {
|
|
61
61
|
throw new Error('No such file \'' + filepath + '\'');
|
|
62
62
|
}
|
|
63
|
-
externalDoc =
|
|
63
|
+
externalDoc = parseXml(externalXml, 'external resource XML');
|
|
64
64
|
if (Object.keys(loadedExternalDocuments).length >= 32) {
|
|
65
65
|
delete loadedExternalDocuments[Object.keys(loadedExternalDocuments)[0]];
|
|
66
66
|
}
|
package/lib/initializeProcess.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const xpath = require('xpath');
|
|
2
|
-
const
|
|
2
|
+
const parseXml = require('./parseXml');
|
|
3
3
|
const checkIfFileOrPath = require('./checkIfFileOrPath');
|
|
4
4
|
const getSchematronMap = require('./getSchematronMap');
|
|
5
5
|
/**
|
|
@@ -16,7 +16,7 @@ function initializeProcess(xml, schematron, options) {
|
|
|
16
16
|
xml = checkIfFileOrPath(xml);
|
|
17
17
|
if (!options.parsedSchematronMap) schematron = checkIfFileOrPath(schematron);
|
|
18
18
|
// Load xml doc
|
|
19
|
-
options.xmlDoc =
|
|
19
|
+
options.xmlDoc = parseXml(xml, 'XML document');
|
|
20
20
|
// Allowing users to send a parsed schematron map if testing multiple xml files with the same schematron
|
|
21
21
|
options.schematronMap = getSchematronMap(schematron, options);
|
|
22
22
|
// Extract data from parsed schematron object
|
package/lib/parseXml.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { SaxesParser } = require('saxes');
|
|
4
|
+
const { DOMParser } = require('@xmldom/xmldom');
|
|
5
|
+
|
|
6
|
+
// xmldom can repair malformed input and only print a warning. Check the source
|
|
7
|
+
// before building the DOM so recovered documents cannot look like a clean pass.
|
|
8
|
+
module.exports = function parseXml(xml, label) {
|
|
9
|
+
try {
|
|
10
|
+
const parser = new SaxesParser({ xmlns: true });
|
|
11
|
+
parser.on('doctype', () => { throw new Error('DOCTYPE declarations are not supported'); });
|
|
12
|
+
parser.write(xml).close();
|
|
13
|
+
const fail = (message) => { throw new Error(message); };
|
|
14
|
+
return new DOMParser({ locator: {}, errorHandler: { warning: fail, error: fail, fatalError: fail } })
|
|
15
|
+
.parseFromString(xml, 'application/xml');
|
|
16
|
+
} catch (cause) {
|
|
17
|
+
throw new SyntaxError('Invalid ' + label + ': ' + cause.message, { cause });
|
|
18
|
+
}
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cda-schematron-validator",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Self-hosted CDA validation API and UI with pinned HL7 profiles, detailed findings, and a compatible legacy Schematron API.",
|
|
5
5
|
"main": "validator.js",
|
|
6
6
|
"scripts": {
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"homepage": "https://github.com/priyaranjan-tokachichu/cda-schematron-validator#readme",
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@xmldom/xmldom": "0.8.15",
|
|
37
|
+
"saxes": "6.0.0",
|
|
37
38
|
"xpath": "0.0.36"
|
|
38
39
|
},
|
|
39
40
|
"directories": {
|