Skip to content

Commit 2ce3e8d

Browse files
Merge pull request #52 in LFOR/fhirpath.js from feature/LF-2586/add-version-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
2 parents 905f0a5 + abadcce commit 2ce3e8d

19 files changed

Lines changed: 13173 additions & 4030 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
This log documents significant changes for each release. This project follows
44
[Semantic Versioning](http://semver.org/).
55

6+
## [3.4.0] - 2023-04-26
7+
### Added
8+
- support for FHIR R5 publication.
9+
610
## [3.3.2] - 2023-03-29
711
### Fixed
812
- toQuantity() now works with subclasses of Quantity.

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,39 @@ npm install && npm run build && npm run start
260260
261261
open browser on localhost:8080
262262
263+
### Updating the FHIR module on a FHIR release
264+
* Download the FHIR StructureDefinitions (into the `fhir-context` directory - *don't check these in*)
265+
```
266+
> wget http://hl7.org/fhir/profiles-types.json -O profiles-types.json
267+
> wget http://hl7.org/fhir/profiles-others.json -O profiles-others.json
268+
> wget http://hl7.org/fhir/profiles-resources.json -O profiles-resources.json
269+
```
270+
* Create the new folder for the version you are importing
271+
```
272+
> mkdir r5
273+
```
274+
* Run the script `` with NodeJS
275+
```
276+
> node ./extract-model-info.js --outputDir r5 --fhirDefDir .
277+
```
278+
* Compare the output files in the new folder to those of the last release
279+
(looking for issues that might be due to changes in the StructureDefinition format)
280+
* Copy the `index.js` file from the last release into the new folder
281+
```
282+
> cp ../r4/index.js r5
283+
```
284+
* Update the `/index.d.ts` file to include the new module as an export
285+
``` js
286+
declare module "fhirpath/fhir-context/r5" {
287+
export const {
288+
choiceTypePaths,
289+
pathsDefinedElsewhere,
290+
type2Parent,
291+
path2Type
292+
}: Model;
293+
}
294+
```
295+
263296
## Credits
264297
This implemention of the FHIRPath specification was developed as a joint project
265298
between the U.S. National Library of Medicine (NLM) and Health Samurai, and was

bin/fhirpath

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ options.option('-e, --expression <expr>', 'FHIRPath expression.');
1010
options.option('-f, --resourceFile <path name>', 'A file containing the JSON resource or part of it, if basePath is passed.');
1111
options.option('-r, --resourceJSON <JSON>', 'JSON resource or part of it, if basePath is passed.');
1212
options.option('-v, --variables <JSON>', 'JSON hash of variables.');
13-
options.option('-m, --model <dstu2 | stu3 | r4>', 'Include FHIR model data.');
13+
options.option('-m, --model <dstu2 | stu3 | r4 | r5>', 'Include FHIR model data.');
1414
options.parse(process.argv);
1515

1616
// this cli util is part of public interface of fhirpath
@@ -42,7 +42,7 @@ else {
4242
let resource = JSON.parse(resourceJSON);
4343
let model;
4444
if (options.model) {
45-
let supportedVersions = ['dstu2', 'stu3', 'r4'];
45+
let supportedVersions = ['dstu2', 'stu3', 'r4', 'r5'];
4646
if (supportedVersions.indexOf(options.model) < 0)
4747
throw new Error('FHIR model must be one of '+supportedVersions);
4848
model = require('../fhir-context/'+options.model);

browser-build/test/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525
<textarea id="result"></textarea>
2626
<br>
2727
FHIR model:
28+
<input id="r5" name="model" type="radio" value="r5" onclick="evaluateFP()"> R5
2829
<input id="r4" name="model" type="radio" value="r4" onclick="evaluateFP()"> R4
2930
<input id="stu3" name="model" type="radio" value="stu3" onclick="evaluateFP()"> STU3
3031
<input id="dstu2" name="model" type="radio" value="dstu2" onclick="evaluateFP()"> DSTU2
3132
<script src="../fhirpath.min.js"></script>
33+
<script src="../fhirpath.r5.min.js"></script>
3234
<script src="../fhirpath.r4.min.js"></script>
3335
<script src="../fhirpath.stu3.min.js"></script>
3436
<script src="../fhirpath.dstu2.min.js"></script>
@@ -39,6 +41,7 @@
3941
var modelChoices = document.getElementsByName('model');
4042
var model;
4143
var models = {
44+
r5: fhirpath_r5_model,
4245
r4: fhirpath_r4_model,
4346
stu3: fhirpath_stu3_model,
4447
dstu2: fhirpath_dstu2_model

browser-build/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ config.plugins = [
6363
module.exports.push(config);
6464

6565
// FHIR model files
66-
for (let fhirVers of ['dstu2', 'stu3', 'r4']) {
66+
for (let fhirVers of ['dstu2', 'stu3', 'r4', 'r5']) {
6767
config = makeBaseConfig();
6868
config.entry = '../fhir-context/'+fhirVers+'/index';
6969
config.output.filename = './fhirpath.'+fhirVers+'.min.js';

converter/converter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const castValue = (value, type) => mapper[type](value);
5757
/**
5858
* Converts Object representing test cases from XML to Object that can be serialized to YAML
5959
* @param {Object} node - result of xml2js.parseString
60-
* @param {string} model - model name, e.g. 'r4','stu3', 'dstu2'
60+
* @param {string} model - model name, e.g. 'r5', 'r4','stu3', 'dstu2'
6161
* @return {Object}
6262
*/
6363
const transform = (node, model = null) => {
@@ -127,7 +127,7 @@ module.exports = {
127127
/**
128128
* Serializes an XML test cases to YAML
129129
* @param {string} xmlData
130-
* @param {string} model - model name, e.g. 'r4','stu3', 'dstu2'
130+
* @param {string} model - model name, e.g. 'r5', 'r4','stu3', 'dstu2'
131131
* @returns {string}
132132
*/
133133
testsXmlStringToYamlString: async (xmlData, model) => {

converter/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222
* Converts XML test cases to the YAML format
2323
* @param {string} from - path to XML file
2424
* @param {string} to - path to YAML file
25-
* @param {string} model - model name, e.g. 'r4','stu3', 'dstu2'
25+
* @param {string} model - model name, e.g. 'r5', 'r4','stu3', 'dstu2'
2626
*/
2727
testsXmlFileToYamlFile: async (from, to, model) => {
2828
const xmlData = await readFile(from);

fhir-context/extract-model-info.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Takes a directory of JSON FHIR definitions (DSTU2, STU3 or R4) and extracts the information
1+
// Takes a directory of JSON FHIR definitions (DSTU2, STU3, R4 or R5) and extracts the information
22
// about "choice types" (polymorphic fields).
33

44
const path = require('path');

0 commit comments

Comments
 (0)