cda-schematron-validator 1.1.12 → 2.0.0-preview.2
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/LICENSE.md +9 -9
- package/README.md +222 -243
- package/bin/cda-validate.js +36 -0
- package/docs/api.md +134 -0
- package/docs/architecture.md +102 -0
- package/docs/coverage.md +124 -0
- package/docs/deployment.md +126 -0
- package/docs/history.md +245 -0
- package/docs/legacy-api.md +70 -0
- package/docs/terminology.md +75 -0
- package/lib/checkIfFileOrPath.js +27 -28
- package/lib/checkRule.js +97 -98
- package/lib/createClient.js +35 -0
- package/lib/getAssertionObject.js +23 -23
- package/lib/getErrorsAndWarnings.js +41 -41
- package/lib/getFailedAssertions.js +24 -25
- package/lib/getIgnored.js +27 -27
- package/lib/getResults.js +22 -22
- package/lib/getReturnObject.js +20 -20
- package/lib/getSchematronMap.js +34 -31
- package/lib/getSelectXmlChunk.js +27 -27
- package/lib/includeExternalDocument.js +113 -107
- package/lib/initializeProcess.js +34 -40
- package/lib/parseSchematron.js +122 -122
- package/lib/processFailedAssertions.js +17 -17
- package/lib/processRules.js +20 -20
- package/lib/processRulesAsync.js +18 -30
- package/lib/testAssertion.js +74 -74
- package/package.json +67 -59
- package/validateAsync.js +103 -117
- package/validateSync.js +51 -55
- package/validator.d.ts +89 -0
- package/validator.js +17 -16
- package/.eslintrc.js +0 -30
- package/.github/workflows/codeql-analysis.yml +0 -70
- package/.husky/pre-commit +0 -5
- package/.jshintrc +0 -96
- package/.vscode/launch.json +0 -37
- package/Gruntfile.js +0 -28
- package/SECURITY.md +0 -21
- package/test/CDAR2_IG_CCDA_CLINNOTES_R1_DSTU2.1_2015AUG_Vol2_2019JUNwith_errata.sch +0 -71
- package/test/VitalSigns.xml +0 -856
- package/test/async.test.js +0 -124
- package/test/asyncFileList.test.js +0 -61
- package/test/test.sch +0 -47
- package/test/test.xml +0 -80
- package/test/tests.js +0 -140
- package/test/vitalSigns.test.js +0 -34
- package/test/voc.xml +0 -44
package/test/async.test.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const expect = require('chai').expect;
|
|
3
|
-
|
|
4
|
-
const validator = require('../validator');
|
|
5
|
-
|
|
6
|
-
// Which xml file to test
|
|
7
|
-
const xmlPath = './test/test.xml';
|
|
8
|
-
// Which schematron to test against
|
|
9
|
-
const schematronPath = './test/test.sch';
|
|
10
|
-
|
|
11
|
-
const xml = fs.readFileSync(xmlPath, 'utf-8').toString();
|
|
12
|
-
const schematron = fs.readFileSync(schematronPath, 'utf-8').toString();
|
|
13
|
-
|
|
14
|
-
describe('Async validator should', function() {
|
|
15
|
-
let results;
|
|
16
|
-
it('return results', async function() {
|
|
17
|
-
results = await validator.validateAsync(xml, schematron, { includeWarnings: true });
|
|
18
|
-
expect(results).to.be.an('object');
|
|
19
|
-
});
|
|
20
|
-
it('return errorCount', function() {
|
|
21
|
-
expect(results.errorCount).to.be.a('number');
|
|
22
|
-
});
|
|
23
|
-
it('return warningCount', function() {
|
|
24
|
-
expect(results.warningCount).to.be.a('number');
|
|
25
|
-
});
|
|
26
|
-
it('return ignoredCount', function() {
|
|
27
|
-
expect(results.ignoredCount).to.be.a('number');
|
|
28
|
-
});
|
|
29
|
-
it('return errors array', function() {
|
|
30
|
-
expect(results.errors).to.be.a('array');
|
|
31
|
-
});
|
|
32
|
-
it('return warnings array', function() {
|
|
33
|
-
expect(results.warnings).to.be.a('array');
|
|
34
|
-
});
|
|
35
|
-
it('return ignored array', function() {
|
|
36
|
-
expect(results.ignored).to.be.a('array');
|
|
37
|
-
});
|
|
38
|
-
it('return matching errorCount', function() {
|
|
39
|
-
expect(results.errorCount).to.be.equal(results.errors.length);
|
|
40
|
-
});
|
|
41
|
-
it('return matching warningCount', function() {
|
|
42
|
-
expect(results.warningCount).to.be.equal(results.warnings.length);
|
|
43
|
-
});
|
|
44
|
-
it('return matching ignoredCount', function() {
|
|
45
|
-
expect(results.ignoredCount).to.be.equal(results.ignored.length);
|
|
46
|
-
});
|
|
47
|
-
it('return correct number of errors', function() {
|
|
48
|
-
expect(results.errorCount).to.be.equal(16);
|
|
49
|
-
});
|
|
50
|
-
it('return correct number of warnings', function() {
|
|
51
|
-
expect(results.warningCount).to.be.equal(15);
|
|
52
|
-
});
|
|
53
|
-
it('return correct number of ignored', function() {
|
|
54
|
-
expect(results.ignoredCount).to.be.equal(1);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('return similar results without warnings', async function() {
|
|
58
|
-
results = await validator.validateAsync(xml, schematron);
|
|
59
|
-
expect(results).to.be.an('object');
|
|
60
|
-
expect(results.errorCount).to.be.a('number');
|
|
61
|
-
expect(results.warningCount).to.be.a('number');
|
|
62
|
-
expect(results.ignoredCount).to.be.a('number');
|
|
63
|
-
expect(results.errors).to.be.a('array');
|
|
64
|
-
expect(results.warnings).to.be.a('array');
|
|
65
|
-
expect(results.ignored).to.be.a('array');
|
|
66
|
-
expect(results.errorCount).to.be.equal(results.errors.length);
|
|
67
|
-
expect(results.warningCount).to.be.equal(results.warnings.length);
|
|
68
|
-
expect(results.ignoredCount).to.be.equal(results.ignored.length);
|
|
69
|
-
expect(results.errorCount).to.be.equal(16);
|
|
70
|
-
expect(results.warningCount).to.be.equal(0);
|
|
71
|
-
expect(results.ignoredCount).to.be.equal(1);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('return similar results given xml filepath', async function() {
|
|
75
|
-
results = await validator.validateAsync(xmlPath, schematron, { includeWarnings: true });
|
|
76
|
-
expect(results).to.be.an('object');
|
|
77
|
-
expect(results.errorCount).to.be.a('number');
|
|
78
|
-
expect(results.warningCount).to.be.a('number');
|
|
79
|
-
expect(results.ignoredCount).to.be.a('number');
|
|
80
|
-
expect(results.errors).to.be.a('array');
|
|
81
|
-
expect(results.warnings).to.be.a('array');
|
|
82
|
-
expect(results.ignored).to.be.a('array');
|
|
83
|
-
expect(results.errorCount).to.be.equal(results.errors.length);
|
|
84
|
-
expect(results.warningCount).to.be.equal(results.warnings.length);
|
|
85
|
-
expect(results.ignoredCount).to.be.equal(results.ignored.length);
|
|
86
|
-
expect(results.errorCount).to.be.equal(16);
|
|
87
|
-
expect(results.warningCount).to.be.equal(15);
|
|
88
|
-
expect(results.ignoredCount).to.be.equal(1);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('return similar results given schematron filepath', async function() {
|
|
92
|
-
results = await validator.validateAsync(xml, schematronPath, { includeWarnings: true });
|
|
93
|
-
expect(results).to.be.an('object');
|
|
94
|
-
expect(results.errorCount).to.be.a('number');
|
|
95
|
-
expect(results.warningCount).to.be.a('number');
|
|
96
|
-
expect(results.ignoredCount).to.be.a('number');
|
|
97
|
-
expect(results.errors).to.be.a('array');
|
|
98
|
-
expect(results.warnings).to.be.a('array');
|
|
99
|
-
expect(results.ignored).to.be.a('array');
|
|
100
|
-
expect(results.errorCount).to.be.equal(results.errors.length);
|
|
101
|
-
expect(results.warningCount).to.be.equal(results.warnings.length);
|
|
102
|
-
expect(results.ignoredCount).to.be.equal(results.ignored.length);
|
|
103
|
-
expect(results.errorCount).to.be.equal(16);
|
|
104
|
-
expect(results.warningCount).to.be.equal(15);
|
|
105
|
-
expect(results.ignoredCount).to.be.equal(1);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('return similar results given xml filepath and schematron filepath', async function() {
|
|
109
|
-
results = await validator.validateAsync(xmlPath, schematronPath, { includeWarnings: true });
|
|
110
|
-
expect(results).to.be.an('object');
|
|
111
|
-
expect(results.errorCount).to.be.a('number');
|
|
112
|
-
expect(results.warningCount).to.be.a('number');
|
|
113
|
-
expect(results.ignoredCount).to.be.a('number');
|
|
114
|
-
expect(results.errors).to.be.a('array');
|
|
115
|
-
expect(results.warnings).to.be.a('array');
|
|
116
|
-
expect(results.ignored).to.be.a('array');
|
|
117
|
-
expect(results.errorCount).to.be.equal(results.errors.length);
|
|
118
|
-
expect(results.warningCount).to.be.equal(results.warnings.length);
|
|
119
|
-
expect(results.ignoredCount).to.be.equal(results.ignored.length);
|
|
120
|
-
expect(results.errorCount).to.be.equal(16);
|
|
121
|
-
expect(results.warningCount).to.be.equal(15);
|
|
122
|
-
expect(results.ignoredCount).to.be.equal(1);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const expect = require('chai').expect;
|
|
3
|
-
|
|
4
|
-
const validator = require('../validator');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
|
|
7
|
-
// Which xml file to test
|
|
8
|
-
const xmlPath = path.resolve(__dirname, './vitalSigns.xml');
|
|
9
|
-
// Which schematron to test against
|
|
10
|
-
const schematronPath = path.resolve(__dirname, './CDAR2_IG_CCDA_CLINNOTES_R1_DSTU2.1_2015AUG_Vol2_2019JUNwith_errata.sch');
|
|
11
|
-
|
|
12
|
-
const xml = fs.readFileSync(xmlPath, 'utf-8').toString();
|
|
13
|
-
const schematron = fs.readFileSync(schematronPath, 'utf-8').toString();
|
|
14
|
-
const options = {
|
|
15
|
-
resourceDir: path.resolve(__dirname, './'),
|
|
16
|
-
includeWarnings: true
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
describe('Async file list schematron validation should', function() {
|
|
20
|
-
let results;
|
|
21
|
-
it('return results', async function() {
|
|
22
|
-
results = await validator.validateFileListAsync([xml, xml], schematron, options);
|
|
23
|
-
expect(results.length).to.be.equal(2);
|
|
24
|
-
expect([0, 1]).includes(results[0].fileIndex);
|
|
25
|
-
expect([0, 1]).includes(results[1].fileIndex);
|
|
26
|
-
});
|
|
27
|
-
it('return correct number of errors', function() {
|
|
28
|
-
expect(results[0].errorCount).to.be.equal(1);
|
|
29
|
-
expect(results[1].errorCount).to.be.equal(1);
|
|
30
|
-
});
|
|
31
|
-
it('return correct number of warnings', function() {
|
|
32
|
-
expect(results[0].warningCount).to.be.equal(6);
|
|
33
|
-
expect(results[1].warningCount).to.be.equal(6);
|
|
34
|
-
});
|
|
35
|
-
it('return correct number of ignored', function() {
|
|
36
|
-
expect(results[0].ignoredCount).to.be.equal(0);
|
|
37
|
-
expect(results[1].ignoredCount).to.be.equal(0);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
describe('Async xml data object schematron validation should', function() {
|
|
42
|
-
let results;
|
|
43
|
-
it('return results', async function() {
|
|
44
|
-
results = await validator.validateFileObjectAsync({file_one: xml, file_two: xml}, schematron, options);
|
|
45
|
-
expect(results.length).to.be.equal(2);
|
|
46
|
-
expect(['file_one', 'file_two']).includes(results[0].fileInfo);
|
|
47
|
-
expect(['file_one', 'file_two']).includes(results[1].fileInfo);
|
|
48
|
-
});
|
|
49
|
-
it('return correct number of errors', function() {
|
|
50
|
-
expect(results[0].errorCount).to.be.equal(1);
|
|
51
|
-
expect(results[1].errorCount).to.be.equal(1);
|
|
52
|
-
});
|
|
53
|
-
it('return correct number of warnings', function() {
|
|
54
|
-
expect(results[0].warningCount).to.be.equal(6);
|
|
55
|
-
expect(results[1].warningCount).to.be.equal(6);
|
|
56
|
-
});
|
|
57
|
-
it('return correct number of ignored', function() {
|
|
58
|
-
expect(results[0].ignoredCount).to.be.equal(0);
|
|
59
|
-
expect(results[1].ignoredCount).to.be.equal(0);
|
|
60
|
-
});
|
|
61
|
-
});
|
package/test/test.sch
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<sch:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sch="http://purl.oclc.org/dsdl/schematron">
|
|
3
|
-
<sch:ns prefix="dh" uri="urn:dh" />
|
|
4
|
-
<sch:phase id="errors">
|
|
5
|
-
<sch:active pattern="A" />
|
|
6
|
-
<sch:active pattern="B" />
|
|
7
|
-
<sch:active pattern="C" />
|
|
8
|
-
<sch:active pattern="E" />
|
|
9
|
-
</sch:phase>
|
|
10
|
-
<sch:phase id="warnings">
|
|
11
|
-
<sch:active pattern="D" />
|
|
12
|
-
</sch:phase>
|
|
13
|
-
<sch:pattern id="A">
|
|
14
|
-
<sch:rule id="A-rule" context="dh:test[@root='A']">
|
|
15
|
-
<sch:assert id="A-assert" test="count(dh:element)=1">Should only have one element</sch:assert>
|
|
16
|
-
</sch:rule>
|
|
17
|
-
</sch:pattern>
|
|
18
|
-
<sch:pattern id="B">
|
|
19
|
-
<sch:rule id="B-rule-1" context="dh:test[@root]">
|
|
20
|
-
<sch:assert id="B-assert-2" test="count(dh:element)=1">Each section should have 1 element</sch:assert>
|
|
21
|
-
</sch:rule>
|
|
22
|
-
<sch:rule id="B-rule-2">
|
|
23
|
-
<sch:assert id="B-assert-1" test="count(//dh:element)=18">Should have 18 elements total element</sch:assert>
|
|
24
|
-
</sch:rule>
|
|
25
|
-
</sch:pattern>
|
|
26
|
-
<sch:pattern id="C">
|
|
27
|
-
<sch:rule id="C-rule-1">
|
|
28
|
-
<sch:assert id="C-assert-1" test="//dh:element[@attribute]">Each element should have the attribute attribute</sch:assert>
|
|
29
|
-
</sch:rule>
|
|
30
|
-
<sch:rule id="C-rule-2" context="dh:test[@root]">
|
|
31
|
-
<sch:assert id="C-assert-2" test="dh:element[@attribute]">Each element should have the attribute attribute</sch:assert>
|
|
32
|
-
</sch:rule>
|
|
33
|
-
</sch:pattern>
|
|
34
|
-
<sch:pattern id="D">
|
|
35
|
-
<sch:rule id="D-rule-1">
|
|
36
|
-
<sch:assert id="D-assert-1" test="//dh:element[count(dh:child)=1]">Each element should have the attribute attribute</sch:assert>
|
|
37
|
-
</sch:rule>
|
|
38
|
-
<sch:rule id="D-rule-2" context="dh:test[@root]">
|
|
39
|
-
<sch:assert id="D-assert-2" test="dh:element[count(dh:child)=1]">Each element should have the attribute attribute</sch:assert>
|
|
40
|
-
</sch:rule>
|
|
41
|
-
</sch:pattern>
|
|
42
|
-
<sch:pattern id="E">
|
|
43
|
-
<sch:rule id="E-rule-1">
|
|
44
|
-
<sch:assert id="E-assert-1" test="not (dh:element[count(dh:child)=1])">This is an invalid test</sch:assert>
|
|
45
|
-
</sch:rule>
|
|
46
|
-
</sch:pattern>
|
|
47
|
-
</sch:schema>
|
package/test/test.xml
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
<xml xmlns="urn:dh">
|
|
2
|
-
<!-- count of elements -->
|
|
3
|
-
<test root="A">
|
|
4
|
-
<element>true</element>
|
|
5
|
-
</test>
|
|
6
|
-
<test root="A">
|
|
7
|
-
<element>false</element>
|
|
8
|
-
<element>false</element>
|
|
9
|
-
</test>
|
|
10
|
-
<!-- attibute equivalence -->
|
|
11
|
-
<test root="B">
|
|
12
|
-
<element atttribute="ok">true</element>
|
|
13
|
-
</test>
|
|
14
|
-
<test root="B">
|
|
15
|
-
<element atttribute="notok">false</element>
|
|
16
|
-
</test>
|
|
17
|
-
<!-- child presence -->
|
|
18
|
-
<test root="C">
|
|
19
|
-
<element>
|
|
20
|
-
<child>true</child>
|
|
21
|
-
</element>
|
|
22
|
-
</test>
|
|
23
|
-
<test root="C">
|
|
24
|
-
<element>
|
|
25
|
-
<notchild>false</notchild>
|
|
26
|
-
</element>
|
|
27
|
-
</test>
|
|
28
|
-
<!-- conditional child presence -->
|
|
29
|
-
<test root="D">
|
|
30
|
-
<element attribute="needChild">
|
|
31
|
-
<child>true</child>
|
|
32
|
-
</element>
|
|
33
|
-
</test>
|
|
34
|
-
<test root="D">
|
|
35
|
-
<element attribute="needNoChild">true</element>
|
|
36
|
-
</test>
|
|
37
|
-
<test root="D">
|
|
38
|
-
<element attribute="needChild">false</element>
|
|
39
|
-
</test>
|
|
40
|
-
<!-- OR presence -->
|
|
41
|
-
<test root="E">
|
|
42
|
-
<element>
|
|
43
|
-
<firstChild>true</firstChild>
|
|
44
|
-
</element>
|
|
45
|
-
</test>
|
|
46
|
-
<test root="E">
|
|
47
|
-
<element>
|
|
48
|
-
<secondChild>true</secondChild>
|
|
49
|
-
</element>
|
|
50
|
-
</test>
|
|
51
|
-
<test root="E">
|
|
52
|
-
<element>
|
|
53
|
-
<notChild>false</notChild>
|
|
54
|
-
</element>
|
|
55
|
-
</test>
|
|
56
|
-
<!-- AND presence -->
|
|
57
|
-
<test root="F">
|
|
58
|
-
<element>
|
|
59
|
-
<firstChild>true</firstChild>
|
|
60
|
-
<secondChild>true</secondChild>
|
|
61
|
-
</element>
|
|
62
|
-
</test>
|
|
63
|
-
<test root="F">
|
|
64
|
-
<element>
|
|
65
|
-
<secondChild>false</secondChild>
|
|
66
|
-
</element>
|
|
67
|
-
</test>
|
|
68
|
-
<test root="F">
|
|
69
|
-
<element>
|
|
70
|
-
<notChild>false</notChild>
|
|
71
|
-
</element>
|
|
72
|
-
</test>
|
|
73
|
-
<!-- Element value -->
|
|
74
|
-
<test root="G">
|
|
75
|
-
<element>true</element>
|
|
76
|
-
</test>
|
|
77
|
-
<test root="G">
|
|
78
|
-
<element>false</element>
|
|
79
|
-
</test>
|
|
80
|
-
</xml>
|
package/test/tests.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const expect = require('chai').expect;
|
|
3
|
-
|
|
4
|
-
const validator = require('../validator');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
// Which xml file to test
|
|
7
|
-
const xmlPath = path.resolve(__dirname, './test.xml');
|
|
8
|
-
// Which schematron to test against
|
|
9
|
-
const schematronPath = path.resolve(__dirname, './test.sch');
|
|
10
|
-
const xml = fs.readFileSync(xmlPath, 'utf-8').toString();
|
|
11
|
-
const schematron = fs.readFileSync(schematronPath, 'utf-8').toString();
|
|
12
|
-
|
|
13
|
-
describe('Classic validator should', function() {
|
|
14
|
-
let results;
|
|
15
|
-
it('return results', function(done) {
|
|
16
|
-
results = validator.validate(xml, schematron, { includeWarnings: true });
|
|
17
|
-
expect(results).to.be.an('object');
|
|
18
|
-
done();
|
|
19
|
-
});
|
|
20
|
-
it('return errorCount', function(done) {
|
|
21
|
-
expect(results.errorCount).to.be.a('number');
|
|
22
|
-
done();
|
|
23
|
-
});
|
|
24
|
-
it('return warningCount', function(done) {
|
|
25
|
-
expect(results.warningCount).to.be.a('number');
|
|
26
|
-
done();
|
|
27
|
-
});
|
|
28
|
-
it('return ignoredCount', function(done) {
|
|
29
|
-
expect(results.ignoredCount).to.be.a('number');
|
|
30
|
-
done();
|
|
31
|
-
});
|
|
32
|
-
it('return errors array', function(done) {
|
|
33
|
-
expect(results.errors).to.be.a('array');
|
|
34
|
-
done();
|
|
35
|
-
});
|
|
36
|
-
it('return warnings array', function(done) {
|
|
37
|
-
expect(results.warnings).to.be.a('array');
|
|
38
|
-
done();
|
|
39
|
-
});
|
|
40
|
-
it('return ignored array', function(done) {
|
|
41
|
-
expect(results.ignored).to.be.a('array');
|
|
42
|
-
done();
|
|
43
|
-
});
|
|
44
|
-
it('return matching errorCount', function(done) {
|
|
45
|
-
expect(results.errorCount).to.be.equal(results.errors.length);
|
|
46
|
-
done();
|
|
47
|
-
});
|
|
48
|
-
it('return matching warningCount', function(done) {
|
|
49
|
-
expect(results.warningCount).to.be.equal(results.warnings.length);
|
|
50
|
-
done();
|
|
51
|
-
});
|
|
52
|
-
it('return matching ignoredCount', function(done) {
|
|
53
|
-
expect(results.ignoredCount).to.be.equal(results.ignored.length);
|
|
54
|
-
done();
|
|
55
|
-
});
|
|
56
|
-
it('return correct number of errors', function(done) {
|
|
57
|
-
expect(results.errorCount).to.be.equal(16);
|
|
58
|
-
done();
|
|
59
|
-
});
|
|
60
|
-
it('return correct number of warnings', function(done) {
|
|
61
|
-
expect(results.warningCount).to.be.equal(15);
|
|
62
|
-
done();
|
|
63
|
-
});
|
|
64
|
-
it('return correct number of ignored', function(done) {
|
|
65
|
-
expect(results.ignoredCount).to.be.equal(1);
|
|
66
|
-
done();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('return similar results without warnings', function(done) {
|
|
70
|
-
results = validator.validate(xml, schematron);
|
|
71
|
-
expect(results).to.be.an('object');
|
|
72
|
-
expect(results.errorCount).to.be.a('number');
|
|
73
|
-
expect(results.warningCount).to.be.a('number');
|
|
74
|
-
expect(results.ignoredCount).to.be.a('number');
|
|
75
|
-
expect(results.errors).to.be.a('array');
|
|
76
|
-
expect(results.warnings).to.be.a('array');
|
|
77
|
-
expect(results.ignored).to.be.a('array');
|
|
78
|
-
expect(results.errorCount).to.be.equal(results.errors.length);
|
|
79
|
-
expect(results.warningCount).to.be.equal(results.warnings.length);
|
|
80
|
-
expect(results.ignoredCount).to.be.equal(results.ignored.length);
|
|
81
|
-
expect(results.errorCount).to.be.equal(16);
|
|
82
|
-
expect(results.warningCount).to.be.equal(0);
|
|
83
|
-
expect(results.ignoredCount).to.be.equal(1);
|
|
84
|
-
done();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('return similar results given xml filepath', function(done) {
|
|
88
|
-
results = validator.validate(xmlPath, schematron, { includeWarnings: true });
|
|
89
|
-
expect(results).to.be.an('object');
|
|
90
|
-
expect(results.errorCount).to.be.a('number');
|
|
91
|
-
expect(results.warningCount).to.be.a('number');
|
|
92
|
-
expect(results.ignoredCount).to.be.a('number');
|
|
93
|
-
expect(results.errors).to.be.a('array');
|
|
94
|
-
expect(results.warnings).to.be.a('array');
|
|
95
|
-
expect(results.ignored).to.be.a('array');
|
|
96
|
-
expect(results.errorCount).to.be.equal(results.errors.length);
|
|
97
|
-
expect(results.warningCount).to.be.equal(results.warnings.length);
|
|
98
|
-
expect(results.ignoredCount).to.be.equal(results.ignored.length);
|
|
99
|
-
expect(results.errorCount).to.be.equal(16);
|
|
100
|
-
expect(results.warningCount).to.be.equal(15);
|
|
101
|
-
expect(results.ignoredCount).to.be.equal(1);
|
|
102
|
-
done();
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('return similar results given schematron filepath', function(done) {
|
|
106
|
-
results = validator.validate(xml, schematronPath, { includeWarnings: true });
|
|
107
|
-
expect(results).to.be.an('object');
|
|
108
|
-
expect(results.errorCount).to.be.a('number');
|
|
109
|
-
expect(results.warningCount).to.be.a('number');
|
|
110
|
-
expect(results.ignoredCount).to.be.a('number');
|
|
111
|
-
expect(results.errors).to.be.a('array');
|
|
112
|
-
expect(results.warnings).to.be.a('array');
|
|
113
|
-
expect(results.ignored).to.be.a('array');
|
|
114
|
-
expect(results.errorCount).to.be.equal(results.errors.length);
|
|
115
|
-
expect(results.warningCount).to.be.equal(results.warnings.length);
|
|
116
|
-
expect(results.ignoredCount).to.be.equal(results.ignored.length);
|
|
117
|
-
expect(results.errorCount).to.be.equal(16);
|
|
118
|
-
expect(results.warningCount).to.be.equal(15);
|
|
119
|
-
expect(results.ignoredCount).to.be.equal(1);
|
|
120
|
-
done();
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('return similar results given xml filepath and schematron filepath', function(done) {
|
|
124
|
-
results = validator.validate(xmlPath, schematronPath, { includeWarnings: true });
|
|
125
|
-
expect(results).to.be.an('object');
|
|
126
|
-
expect(results.errorCount).to.be.a('number');
|
|
127
|
-
expect(results.warningCount).to.be.a('number');
|
|
128
|
-
expect(results.ignoredCount).to.be.a('number');
|
|
129
|
-
expect(results.errors).to.be.a('array');
|
|
130
|
-
expect(results.warnings).to.be.a('array');
|
|
131
|
-
expect(results.ignored).to.be.a('array');
|
|
132
|
-
expect(results.errorCount).to.be.equal(results.errors.length);
|
|
133
|
-
expect(results.warningCount).to.be.equal(results.warnings.length);
|
|
134
|
-
expect(results.ignoredCount).to.be.equal(results.ignored.length);
|
|
135
|
-
expect(results.errorCount).to.be.equal(16);
|
|
136
|
-
expect(results.warningCount).to.be.equal(15);
|
|
137
|
-
expect(results.ignoredCount).to.be.equal(1);
|
|
138
|
-
done();
|
|
139
|
-
});
|
|
140
|
-
});
|
package/test/vitalSigns.test.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const expect = require('chai').expect;
|
|
3
|
-
|
|
4
|
-
const validator = require('../validator');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
|
|
7
|
-
// Which xml file to test
|
|
8
|
-
const xmlPath = path.resolve(__dirname, './vitalSigns.xml');
|
|
9
|
-
// Which schematron to test against
|
|
10
|
-
const schematronPath = path.resolve(__dirname, './CDAR2_IG_CCDA_CLINNOTES_R1_DSTU2.1_2015AUG_Vol2_2019JUNwith_errata.sch');
|
|
11
|
-
|
|
12
|
-
const xml = fs.readFileSync(xmlPath, 'utf-8').toString();
|
|
13
|
-
const schematron = fs.readFileSync(schematronPath, 'utf-8').toString();
|
|
14
|
-
const options = {
|
|
15
|
-
resourceDir: path.resolve(__dirname, './'),
|
|
16
|
-
includeWarnings: true
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
describe('Vital Sign async schematron validation should', function() {
|
|
20
|
-
let results;
|
|
21
|
-
it('return results', async function() {
|
|
22
|
-
results = await validator.validateAsync(xml, schematron, options);
|
|
23
|
-
expect(results).to.be.an('object');
|
|
24
|
-
});
|
|
25
|
-
it('return correct number of errors', function() {
|
|
26
|
-
expect(results.errorCount).to.be.equal(1);
|
|
27
|
-
});
|
|
28
|
-
it('return correct number of warnings', function() {
|
|
29
|
-
expect(results.warningCount).to.be.equal(6);
|
|
30
|
-
});
|
|
31
|
-
it('return correct number of ignored', function() {
|
|
32
|
-
expect(results.ignoredCount).to.be.equal(0);
|
|
33
|
-
});
|
|
34
|
-
});
|
package/test/voc.xml
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<systems xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.lantanagroup.com/voc">
|
|
3
|
-
<system valueSetOid="2.16.840.1.113883.11.20.9.36" valueSetName="Pressure Point ">
|
|
4
|
-
<code value="43631005" displayName="occipital region structure" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
5
|
-
<code value="23747009" displayName="skin structure of chin" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
6
|
-
<code value="91774008" displayName="structure of right shoulder" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
7
|
-
<code value="7874003" displayName="structure of scapular region of back; 272741003 = laterality; 24028007 = right (qualifier value)" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
8
|
-
<code value="368149001" displayName="right elbow region structure" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
9
|
-
<code value="368148009" displayName=" left elbow region structure" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
10
|
-
<code value="87141009" displayName="sacral vertebra structure" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
11
|
-
<code value="122495006" displayName="thoracic spine structure" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
12
|
-
<code value="122496007" displayName=" lumbar spine structure" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
13
|
-
<code value="287579007" displayName="right hip region structure" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
14
|
-
<code value="387679003" displayName="left hip region structure" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
15
|
-
<code value="396993003" displayName="right posterior iliac crest" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
16
|
-
<code value="396994009" displayName="left posterior iliac crest" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
17
|
-
<code value="46862004" displayName="buttock structure;272741003 = laterality;7771000 = left" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
18
|
-
<code value="6757004" displayName="structure of right knee" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
19
|
-
<code value="82169009" displayName="structure of left knee" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
20
|
-
<code value="76853006" displayName="heel structure; 272741003 = laterality; 24028007 = right " codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
21
|
-
<code value="182304008" displayName="medial aspect of ankle; 272741003 = laterality; 24028007 = right" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
22
|
-
<code value="182305009" displayName="lateral aspect of ankle; 272741003 = laterality; 24028007 = right" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
23
|
-
<code value="43631005" displayName="occipital region structure" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
24
|
-
<code value="23747009" displayName="skin structure of chin" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
25
|
-
<code value="91774008" displayName="structure of right shoulder" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
26
|
-
<code value="7874003" displayName="structure of scapular region of back; 272741003 = laterality; 24028007 = right (qualifier value)" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
27
|
-
<code value="368149001" displayName="right elbow region structure" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
28
|
-
<code value="368148009" displayName=" left elbow region structure" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
29
|
-
<code value="87141009" displayName="sacral vertebra structure" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
30
|
-
<code value="122495006" displayName="thoracic spine structure" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
31
|
-
<code value="122496007" displayName=" lumbar spine structure" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
32
|
-
<code value="287579007" displayName="right hip region structure" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
33
|
-
<code value="387679003" displayName="left hip region structure" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
34
|
-
<code value="396993003" displayName="right posterior iliac crest" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
35
|
-
<code value="396994009" displayName="left posterior iliac crest" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
36
|
-
<code value="46862004" displayName="buttock structure;272741003 = laterality;7771000 = left" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
37
|
-
<code value="6757004" displayName="structure of right knee" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
38
|
-
<code value="82169009" displayName="structure of left knee" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
39
|
-
<code value="76853006" displayName="heel structure; 272741003 = laterality; 24028007 = right " codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
40
|
-
<code value="182304008" displayName="medial aspect of ankle; 272741003 = laterality; 7771000 = left" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
41
|
-
<code value="182305009" displayName="lateral aspect of ankle; 272741003 = laterality;7771000 = left" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
42
|
-
<code value="6685009" displayName="structure of right ankle" codeSystemName="SNOMED CT" codeSystem="2.16.840.1.113883.6.96" />
|
|
43
|
-
</system>
|
|
44
|
-
</systems>
|