Skip to content

Commit

Permalink
using fhirpath for evaluation of fhir path
Browse files Browse the repository at this point in the history
  • Loading branch information
ashaban committed Feb 17, 2023
1 parent bac5a14 commit c103ecd
Show file tree
Hide file tree
Showing 7 changed files with 335 additions and 223 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ packaging/ansible/server_cert.pem
packaging/ansible/server_key.pem
server/certificates/server_cert.pem.bak
server/certificates/server_key.pem.bak

# client key/cert examples for ansible
ansible_key.pem
ansible_cert.pem
Expand All @@ -32,4 +31,4 @@ ansible.p12
.DS_Store

# venv
venv/
venv/
142 changes: 0 additions & 142 deletions resources/Relationships/PatientRelationship.json

This file was deleted.

70 changes: 0 additions & 70 deletions server/config/decisionRules.json

This file was deleted.

7 changes: 3 additions & 4 deletions server/lib/esMatching.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ const request = require('request');
const URI = require('urijs');
const async = require('async');
const _ = require('lodash');
const Fhir = require('fhir').Fhir;
const fhirpath = require('fhirpath');
const fhirWrapper = require('./fhir')();
const logger = require('./winston');
const config = require('./config');
const generalMixin = require('./mixins/generalMixin');
const axios = require('axios');
const fhir = new Fhir();

const refreshIndex = (callback) => {
logger.info('Refreshing index ' + config.get('elastic:index'));
Expand Down Expand Up @@ -78,7 +77,7 @@ const buildQuery = (sourceResource, decisionRule) => {
null_handling_both = decisionRule.null_handling_both;
}
let path = rule.espath;
let pathValue = fhir.evaluate(sourceResource, rule.fhirpath);
let pathValue = fhirpath.evaluate(sourceResource, rule.fhirpath);
const values = [];
if (Array.isArray(pathValue) && !(pathValue.length === 1 && pathValue[0] === undefined)) {
if (pathValue.length === 0) {
Expand Down Expand Up @@ -155,7 +154,7 @@ const buildQuery = (sourceResource, decisionRule) => {
const block = decisionRule.filters[filterField];
const term = {};
const path = block.espath;
let pathValue = fhir.evaluate(sourceResource, block.fhirpath);
let pathValue = fhirpath.evaluate(sourceResource, block.fhirpath);
if (Array.isArray(pathValue) && !(pathValue.length === 1 && pathValue[0] === undefined)) {
if (pathValue.length === 0) {
term[path] = '';
Expand Down
8 changes: 3 additions & 5 deletions server/lib/tools/cacheFHIR.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ const axios = require('axios');
const async = require('async');
const URI = require('urijs');
const moment = require('moment');
const fhirpath = require('fhirpath');
const generalMixin = require('../mixins/generalMixin');
const Fhir = require('fhir').Fhir;
const fhirWrapper = require('../fhir')();
const structureDefinition = require('./structureDefinition');
const config = require('../config');
const logger = require('../winston');
const slashes = require('slashes');

const fhir = new Fhir();

const fhirToEsDataType = {
valueString: 'text',
valueBoolean: 'boolean',
Expand Down Expand Up @@ -605,7 +603,7 @@ const fhir2ES = ({
const limits = query.split('=');
const limitParameters = limits[0];
const limitValue = limits[1];
const resourceValue = fhir.evaluate(
const resourceValue = fhirpath.evaluate(
data.resource,
limitParameters
);
Expand Down Expand Up @@ -640,7 +638,7 @@ const fhir2ES = ({
fieldAutogenerated = value;
}
}
const displayData = fhir.evaluate(
const displayData = fhirpath.evaluate(
data.resource,
fieldName
);
Expand Down
Loading

0 comments on commit c103ecd

Please sign in to comment.