Skip to content

Commit

Permalink
Fixed issues found during review
Browse files Browse the repository at this point in the history
LF-2386
  • Loading branch information
yuriy-sedinkin committed Aug 31, 2022
1 parent 8a5382a commit 7b89426
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,33 @@ handling is added, so they are kept seperate from the main FHIRPath file.)
These will define additional global variables like "fhirpath_dstu2_model",
"fhirpath_stu3_model" or "fhirpath_r4_model".

## Usage
## API Usage

Evaluating FHIRPath
API: evaluate(resourceObject, fhirPathExpression, environment, model, options)
Note: The resource will be modified by this function to add type information.
Evaluating FHIRPath:

```js
evaluate(resourceObject, fhirPathExpression, environment, model, options);
```

Note: The resource will be modified by this function to add type information.

Basic example:

```js
fhirpath.evaluate({"resourceType": "Patient", ...}, 'Patient.name.given');
```

Environment variables can be passed in as third argument as a hash of name/value
pairs:

```
```js
fhirpath.evaluate({}, '%a - 1', {a: 5});
```

To include FHIR model data (for support of choice types), pass in the model data
object as the fourth argument:

```
```js
fhirpath.evaluate({"resourceType": "Observation", "valueString": "green"},
'Observation.value', null, fhirpath_r4_model);
```
Expand All @@ -71,7 +77,7 @@ base - the path in the resource that represents the partial resource being used
as the context,
expression - fhirpath expression relative to base.

```
```js
fhirpath.evaluate({ "answer": { "valueQuantity": ...}},
{ "base": "QuestionnaireResponse.item",
"expression": "answer.value = 2 year"},
Expand All @@ -80,7 +86,7 @@ fhirpath.evaluate({ "answer": { "valueQuantity": ...}},

Precompiling fhirpath - result can be reused against multiple resources:

```
```js
const path = fhirpath.compile('Patient.name.given', fhirpath_r4_model);
var res = path({"resourceType": "Patient", ...}, {a: 5, ...});
```
Expand All @@ -91,7 +97,7 @@ base - the path in the resource that represents the partial resource being used
as the context,
expression - fhirpath expression relative to base.

```
```js
const path = fhirpath.compile({ "base": "QuestionnaireResponse.item",
"expression": "answer.value = 2 year"},
fhirpath_r4_model);
Expand All @@ -105,15 +111,15 @@ result of evaluation as a context variable for another FHIRpath expression,
it would be best to preserve the internal data types. To do this you can use
the option "resolveInternalTypes" = false:
```
```js
const contextVariable = fhirpath.evaluate(
resource, expression, context, model, {resolveInternalTypes: false}
);
```
This option may also be passed to compile function:
```
```js
const path = fhirpath.compile(
expression, model, {resolveInternalTypes: false}
);
Expand All @@ -122,7 +128,7 @@ const path = fhirpath.compile(
If at some point you decide to convert all values which have internal types to
standard JavaScript types you can use the special function "resolveInternalTypes":
```
```js
const res = fhirpath.resolveInternalTypes(value);
```
Expand Down Expand Up @@ -255,7 +261,7 @@ the root of the project directory, and then run "npm run generateParser".
### Building the demo page
```
```sh
npm install && npm run build
cd demo
npm install && npm run build && npm run start
Expand Down

0 comments on commit 7b89426

Please sign in to comment.