-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathexample3.js
41 lines (24 loc) · 1.22 KB
/
example3.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
var validator = require("../index.js").validator;
//var bb = JSON.parse(fs.readFileSync(__dirname + '/CCD1.json', 'utf8'));
//var data = fs.readFileSync("CCD_1.xml").toString();
var bb = require("../index.js");
var fs = require("fs");
var data = fs.readFileSync("CCD_1.xml").toString();
var result = bb.parseString(data);
fs.writeFileSync("example3.json", JSON.stringify(result, null, 4));
console.log(JSON.stringify(result.data.social_history, null, 4));
var val = validator.validateDocumentModel(result);
console.log(val);
console.log(JSON.stringify(validator.getLastError(),null,4));
//console.log("date type: ",typeof result.data.vitals[3].date[0].date);
//console.log(JSON.stringify(result.data.vitals[3].date[0].date));
data = fs.readFileSync("example3_mod.json").toString();
result = JSON.parse(data);
val = validator.validateDocumentModel(result);
console.log(val);
//console.log(JSON.stringify(validator.getLastError(),null,4));
//console.log("date type: ",typeof result.data.vitals[3].date[0].date);
//console.log(JSON.stringify(result.data.vitals[3].date[0].date));
val = validator.validateSectionObj(result.data.allergies[0], 'allergy');
console.log(val);
//console.log(JSON.stringify(validator.getLastError(),null,4));