-
Notifications
You must be signed in to change notification settings - Fork 11
/
test-case-generator.js
44 lines (40 loc) · 1.26 KB
/
test-case-generator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var fp = require("./index")
var pt = module.exports.pt = {
resourceType: "Patient",
birthDate: "2005",
name:[
{ given:["beve", "ave", "eve"], "family": ["15.9"]},
{ given: ["eve","other"], family: ["other","eve"]},
{ given: ["ever","other"], family: ["aeve","other"]},
{ given: ["a"], family: ["bk"]},
{ given: ["c"], family: ["bk"]},
{ given: ["a"], family: ["c"]},
{ given: ["http://loinc.org"]},
{ given: ["2005"]}
]
}
var examples = module.exports.examples = [
"Patient.name.distinct(given)",
"Patient.name.distinct(family)",
"Patient.name.distinct(given, family)",
"Patient.given",
"Patient.name.where('eve' in given)",
"Patient.name.where(given ~ family)",
"Patient.name.where(given !~ family)",
"Patient.name.where(given = %loinc)",
"Patient.name.where(given=$context.birthDate).given"
]
console.log("fp", Object.keys(fp), typeof fp.evaluate)
if (process.argv.indexOf("--write-all") !== -1) {
let output = examples.map((e)=>({
"start": pt,
"path": e,
"result":{
"parse": fp.parse(e),
"evaluate": fp.evaluate(pt, e)
}
}))
let outfile = "test-case-dump.json"
require('fs').writeFileSync(outfile, JSON.stringify(output, null, 2))
console.log("Wrote tests to file: ", outfile)
}