Skip to content

Commit

Permalink
Merge pull request #52 in LFOR/fhirpath.js from feature/LF-2586/add-v…
Browse files Browse the repository at this point in the history
…ersion-R5-support to master

* commit 'abadcceedd68770958130401590a9c3261494339':
  npm audit fix
  Updated version in package-lock.json
  Minor changes
  LInux case sensitivity on the output parameter in the upgrade guidance
  Include additional guidance on the version upgrade process
  Update the package version and changelog
  Missed including the min.r5.js file from the build step
  Unit test the R5 Observation model and various other updates to support building the content also.
  #137 Add support for FHIR R5
  • Loading branch information
yuriy-sedinkin committed Apr 27, 2023
2 parents 905f0a5 + abadcce commit 2ce3e8d
Show file tree
Hide file tree
Showing 19 changed files with 13,173 additions and 4,030 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/).

## [3.4.0] - 2023-04-26
### Added
- support for FHIR R5 publication.

## [3.3.2] - 2023-03-29
### Fixed
- toQuantity() now works with subclasses of Quantity.
Expand Down
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,39 @@ npm install && npm run build && npm run start
open browser on localhost:8080
### Updating the FHIR module on a FHIR release
* Download the FHIR StructureDefinitions (into the `fhir-context` directory - *don't check these in*)
```
> wget http://hl7.org/fhir/profiles-types.json -O profiles-types.json
> wget http://hl7.org/fhir/profiles-others.json -O profiles-others.json
> wget http://hl7.org/fhir/profiles-resources.json -O profiles-resources.json
```
* Create the new folder for the version you are importing
```
> mkdir r5
```
* Run the script `` with NodeJS
```
> node ./extract-model-info.js --outputDir r5 --fhirDefDir .
```
* Compare the output files in the new folder to those of the last release
(looking for issues that might be due to changes in the StructureDefinition format)
* Copy the `index.js` file from the last release into the new folder
```
> cp ../r4/index.js r5
```
* Update the `/index.d.ts` file to include the new module as an export
``` js
declare module "fhirpath/fhir-context/r5" {
export const {
choiceTypePaths,
pathsDefinedElsewhere,
type2Parent,
path2Type
}: Model;
}
```
## Credits
This implemention of the FHIRPath specification was developed as a joint project
between the U.S. National Library of Medicine (NLM) and Health Samurai, and was
Expand Down
4 changes: 2 additions & 2 deletions bin/fhirpath
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ options.option('-e, --expression <expr>', 'FHIRPath expression.');
options.option('-f, --resourceFile <path name>', 'A file containing the JSON resource or part of it, if basePath is passed.');
options.option('-r, --resourceJSON <JSON>', 'JSON resource or part of it, if basePath is passed.');
options.option('-v, --variables <JSON>', 'JSON hash of variables.');
options.option('-m, --model <dstu2 | stu3 | r4>', 'Include FHIR model data.');
options.option('-m, --model <dstu2 | stu3 | r4 | r5>', 'Include FHIR model data.');
options.parse(process.argv);

// this cli util is part of public interface of fhirpath
Expand Down Expand Up @@ -42,7 +42,7 @@ else {
let resource = JSON.parse(resourceJSON);
let model;
if (options.model) {
let supportedVersions = ['dstu2', 'stu3', 'r4'];
let supportedVersions = ['dstu2', 'stu3', 'r4', 'r5'];
if (supportedVersions.indexOf(options.model) < 0)
throw new Error('FHIR model must be one of '+supportedVersions);
model = require('../fhir-context/'+options.model);
Expand Down
3 changes: 3 additions & 0 deletions browser-build/test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
<textarea id="result"></textarea>
<br>
FHIR model:
<input id="r5" name="model" type="radio" value="r5" onclick="evaluateFP()"> R5
<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.r5.min.js"></script>
<script src="../fhirpath.r4.min.js"></script>
<script src="../fhirpath.stu3.min.js"></script>
<script src="../fhirpath.dstu2.min.js"></script>
Expand All @@ -39,6 +41,7 @@
var modelChoices = document.getElementsByName('model');
var model;
var models = {
r5: fhirpath_r5_model,
r4: fhirpath_r4_model,
stu3: fhirpath_stu3_model,
dstu2: fhirpath_dstu2_model
Expand Down
2 changes: 1 addition & 1 deletion browser-build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ config.plugins = [
module.exports.push(config);

// FHIR model files
for (let fhirVers of ['dstu2', 'stu3', 'r4']) {
for (let fhirVers of ['dstu2', 'stu3', 'r4', 'r5']) {
config = makeBaseConfig();
config.entry = '../fhir-context/'+fhirVers+'/index';
config.output.filename = './fhirpath.'+fhirVers+'.min.js';
Expand Down
4 changes: 2 additions & 2 deletions converter/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const castValue = (value, type) => mapper[type](value);
/**
* Converts Object representing test cases from XML to Object that can be serialized to YAML
* @param {Object} node - result of xml2js.parseString
* @param {string} model - model name, e.g. 'r4','stu3', 'dstu2'
* @param {string} model - model name, e.g. 'r5', 'r4','stu3', 'dstu2'
* @return {Object}
*/
const transform = (node, model = null) => {
Expand Down Expand Up @@ -127,7 +127,7 @@ module.exports = {
/**
* Serializes an XML test cases to YAML
* @param {string} xmlData
* @param {string} model - model name, e.g. 'r4','stu3', 'dstu2'
* @param {string} model - model name, e.g. 'r5', 'r4','stu3', 'dstu2'
* @returns {string}
*/
testsXmlStringToYamlString: async (xmlData, model) => {
Expand Down
2 changes: 1 addition & 1 deletion converter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
* Converts XML test cases to the YAML format
* @param {string} from - path to XML file
* @param {string} to - path to YAML file
* @param {string} model - model name, e.g. 'r4','stu3', 'dstu2'
* @param {string} model - model name, e.g. 'r5', 'r4','stu3', 'dstu2'
*/
testsXmlFileToYamlFile: async (from, to, model) => {
const xmlData = await readFile(from);
Expand Down
2 changes: 1 addition & 1 deletion fhir-context/extract-model-info.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Takes a directory of JSON FHIR definitions (DSTU2, STU3 or R4) and extracts the information
// Takes a directory of JSON FHIR definitions (DSTU2, STU3, R4 or R5) and extracts the information
// about "choice types" (polymorphic fields).

const path = require('path');
Expand Down
Loading

0 comments on commit 2ce3e8d

Please sign in to comment.