Skip to content

Commit

Permalink
Merge pull request #15 in LFOR/fhirpath.js from feature/LF-1493/add-d…
Browse files Browse the repository at this point in the history
…stu2-model-data to master

* commit '16523e3ee42b589d90f906e0b61cd1aedb393b52':
  npm audit fix for demo
  npm audit fix
  fix: stu2 renamed to dstu2
  refactor: browser build test
  Fixes typo in the test name
  Add DSTU2 model data
  • Loading branch information
plynchnlm committed Aug 13, 2020
2 parents d9fb9f5 + 16523e3 commit dcfb113
Show file tree
Hide file tree
Showing 16 changed files with 1,701 additions and 189 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
This log documents significant changes for each release. This project follows
[Semantic Versioning](http://semver.org/).

## [2.4.0] - 2020-08-05
### Added
- Support for DSTU2 model

## [2.3.0] - 2020-06-17
### Added
- Functions: toBoolean(), convertsToBoolean(), convertsToInteger(), convertsToDecimal(), convertsToString(),
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ want to include a second file with the desired FHIR version model data, e.g.
fhirpath.r4.min.js for pulling in the R4 model. (At the moment, those files are
small, but it would not be surprising if they grew as more support for FHIR type
handling is added, so they are kept seperate from the main FHIRPath file.)
These will define additional global variables like "fhirpath_r4_model" or
"fhirpath_stu3_model".
These will define additional global variables like "fhirpath_dstu2_model",
"fhirpath_stu3_model" or "fhirpath_r4_model".

## Usage
```
Expand Down Expand Up @@ -102,7 +102,7 @@ fhirpath --expression '%v + 2' --resourceJSON '{}' --variables '{"v": 5}'
```

FHIR model data can be included via --model and the FHIR release version (in
lower case, e.g., 'stu3' or 'r4').
lower case, e.g., 'dstu2', 'stu3' or 'r4').

```sh
fhirpath --expression 'Observation.value' --resourceJSON '{"resourceType": "Observation", "valueString": "Green"}' --model r4
Expand Down
4 changes: 2 additions & 2 deletions bin/fhirpath
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ options.option('-e, --expression <expr>', 'FHIRPath expression');
options.option('-f, --resourceFile <path name>', 'A file containing the JSON resource.');
options.option('-r, --resourceJSON <JSON>', 'JSON resource.');
options.option('-v, --variables <JSON>', 'JSON hash of variables.');
options.option('-m, --model <stu3 | r4>', 'Include FHIR model data.');
options.option('-m, --model <dstu2 | stu3 | r4>', 'Include FHIR model data.');
options.parse(process.argv);

// this cli util is part of public interface of fhirpath
Expand Down Expand Up @@ -39,7 +39,7 @@ else {
let resource = JSON.parse(resourceJSON);
let model;
if (options.model) {
let supportedVersions = ['stu3', 'r4'];
let supportedVersions = ['dstu2', 'stu3', 'r4'];
if (supportedVersions.indexOf(options.model) < 0)
throw new Error('FHIR model must be one of '+supportedVersions);
model = require('../fhir-context/'+options.model);
Expand Down
9 changes: 8 additions & 1 deletion browser-build/test/protractor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,26 @@
FHIR model:
<input id="r4" name="model" type="radio" value="r4" onclick="evaluateFP()"> R4
<input id="stu3" name="model" type="radio" value="stu3" onclick="evaluateFP()"> STU3
<input id="dstu2" name="model" type="radio" value="dstu2" onclick="evaluateFP()"> DSTU2
<script src="../../fhirpath.min.js"></script>
<script src="../../fhirpath.r4.min.js"></script>
<script src="../../fhirpath.stu3.min.js"></script>
<script src="../../fhirpath.dstu2.min.js"></script>
<script>
function evaluateFP() {
var expr = document.getElementById('expression').value;
var resource = document.getElementById('resource').value;
var modelChoices = document.getElementsByName('model');
var model;
var models = {
r4: fhirpath_r4_model,
stu3: fhirpath_stu3_model,
dstu2: fhirpath_dstu2_model
};

for (var i = 0; i < modelChoices.length; ++i) {
if (modelChoices[i].checked) {
model = modelChoices[i].value === 'r4' ? fhirpath_r4_model : fhirpath_stu3_model;
model = models[modelChoices[i].value];
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion browser-build/test/protractor/spec/browser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Browser build of FHIRPath', function() {
expression.sendKeys('Observation.value');
let result = $('#result');
expect(result.getAttribute('value')).toBe('[]'); // no model yet
for (let fhirVers of ['stu3', 'r4']) {
for (let fhirVers of ['dstu2', 'stu3', 'r4']) {
$('#'+fhirVers).click(); // changes the model used
expect(result.getAttribute('value')).toBe('["green"]');
}
Expand Down
10 changes: 6 additions & 4 deletions browser-build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@ config.entry = '../src/fhirpath';
config.output.filename = './fhirpath.min.js';
config.output.library = 'fhirpath'; // global variable for the library
config.plugins = [
new CopyPlugin([
{ from: '../LICENSE.md', to: '.' }
]),
new CopyPlugin({
patterns: [
{from: '../LICENSE.md', to: '.'}
]
}),
];
module.exports.push(config);

// FHIR model files
for (let fhirVers of ['stu3', 'r4']) {
for (let fhirVers of ['dstu2', 'stu3', 'r4']) {
config = makeBaseConfig();
config.entry = '../fhir-context/'+fhirVers+'/index';
config.output.filename = './fhirpath.'+fhirVers+'.min.js';
Expand Down
77 changes: 30 additions & 47 deletions demo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dcfb113

Please sign in to comment.