Skip to content

Commit

Permalink
Merge pull request #11 from HL7/fix_now_output_in_demo
Browse files Browse the repository at this point in the history
Fix now output in demo
  • Loading branch information
plynchnlm authored May 16, 2019
2 parents 323d86a + fc721e1 commit cbba9a8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
This log documents significant changes for each release. This project follows
[Semantic Versioning](http://semver.org/).

## [0.12.2] - 2019-05-15
### Fixed
- Corrected output in the demo website for results containing dates and times.
- Cleaned up the error message output for parsing errors.

## [0.12.1] - 2019-05-13
### Fixed
- Updated links to the repository to point to the new location.
Expand Down
4 changes: 3 additions & 1 deletion demo/public/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ body {
display: flex;
flex-direction: row;
}
#input {
#inputWrapper {
flex: 1;
}
#input {
margin-top: 3px;
}

Expand Down
23 changes: 17 additions & 6 deletions demo/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,24 @@ function evaluate(){
try {
var inputType = document.querySelector('input[name="inputType"]:checked').value
var inputText = cm.getValue();
var res = inputType === 'yaml' ? yaml.safeLoad(inputText) : JSON.parse(inputText);
console.log(pathNode.value, res);
var result = fhirpath.evaluate(res, pathNode.value);
outNode.innerHTML = '<pre />';
outNode.childNodes.item(0).textContent = yaml.dump(result);
var expr = pathNode.value;
if (expr.trim() != '') {
var res = inputType === 'yaml' ? yaml.safeLoad(inputText) : JSON.parse(inputText);
console.log(pathNode.value, res);
var result = fhirpath.evaluate(res, expr);
outNode.innerHTML = '<pre />';
// yaml.dump will pick up internal keys, e.g. "asStr" in the FP_Type
// objects (dates and times). Apparently, toString() is not called on the
// objects during yaml.dump, so we take care of that by calling toJSON
// first, parsing that, and then creating the yaml output.
outNode.childNodes.item(0).textContent =
yaml.dump(JSON.parse(JSON.stringify(result)));
}
} catch (e) {
outNode.innerHTML = '<pre style="color: red;" />';

outNode.innerHTML = '<div style="color: red;" />';
var msg = e.toString();
msg.replace(/\n/, '<br>');
outNode.childNodes.item(0).textContent = e.toString();
console.error(e);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fhirpath",
"version": "0.12.1",
"version": "0.12.2",
"description": "A FHIRPath engine",
"main": "src/fhirpath.js",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ var parse = function(path){
let errMsgs = [];
for (let i=0, len=errors.length; i<len; ++i) {
let err = errors[i];
errMsgs.push("rec: "+err[0]+"; sym: "+err[1]+"; line: "+err[2]+"; col: "+
err[3]+"; msg: "+err[4]+"; e: "+err[5]);
let msg = "line: "+err[2]+"; column: "+ err[3]+"; message: "+err[4];
errMsgs.push(msg);
}
var e = new Error(errMsgs.join("\n"));
e.errors = errors;
Expand Down

0 comments on commit cbba9a8

Please sign in to comment.