How to use fhir - 8 common examples

To help you get started, we’ve selected a few fhir examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jembi / hearth / lib / server.js View on Github external
const acceptedJSONContentTypes = ['application/json+fhir', 'application/fhir+json', 'application/json', 'text/json']
const acceptedXMLContentTypes = ['application/xml+fhir', 'application/fhir+xml', 'application/xml', 'text/xml']

process.title = 'Hearth'

let fhir = null
switch (config.getConf('server:fhirVersion')) {
  case 'dstu1':
    fhir = new FHIR(FHIR.DSTU1)
    break
  case 'dstu2':
    fhir = new FHIR(FHIR.DSTU2)
    break
  case 'stu3':
    fhir = new FHIR(FHIR.STU3)
    break
}

if (config.getConf('createIndexes')) {
  matchingIndexes.createMatchingIndexes((err) => {
    if (err) {
      logger.error(err)
    }
    logger.info('Matching Indexes created')
  })
}

moduleLoader.loadModules()
const fhirResources = moduleLoader.getLoadedModules()

// Load validation profiles
github jembi / hearth / test / content-negotiation.js View on Github external
server.start((err) => {
      t.error(err)

      const pat = _.cloneDeep(require('./resources/Patient-1.json'))
      delete pat.id

      const fhir = new FHIR(FHIR.DSTU2)
      const patientXML = fhir.JsonToXml(JSON.stringify(pat))

      const updatedHeaders = _.assign({ 'accept': ['application/xml', 'application/xml+fhir'], 'Content-Type': 'application/xml' }, headers)

      request.post({
        url: 'http://localhost:3447/fhir/Patient',
        headers: updatedHeaders,
        body: patientXML
      }, (err, res, body) => {
        t.error(err)
        t.equal(res.statusCode, 201, 'response status code should be 201')

        t.ok(res.headers['location'], 'should have a location header set')
        t.match(res.headers['location'], /\/fhir\/Patient\/[\w-]+\/_history\/[\w-]+/, 'should return a location with both id and vid present')

        const c = db.collection('Patient')
github jembi / hearth / lib / plugins / validator.js View on Github external
*/

'use strict'

const FHIR = require('fhir')
const config = require('../config')

const profileLoader = require('../fhir/profile-loader')()

let fhir = null
switch (config.getConf('server:fhirVersion')) {
  case 'dstu1':
    fhir = new FHIR(FHIR.DSTU1)
    break
  case 'dstu2':
    fhir = new FHIR(FHIR.DSTU2)
    break
  case 'stu3':
    fhir = new FHIR(FHIR.STU3)
    break
}

module.exports = () => {
  return {
    hooks: {
      before: [
        {
          resourceType: '*',
          interactions: [ 'create', 'update' ],
          userType: '*',
          function: (interaction, ctx, resourceType, resource, callback) => {
            if (!config.getConf('validation:enabled')) {
github jembi / hearth / lib / server.js View on Github external
const matchingIndexes = require('../scripts/matching-indexes')(mongo)
const moduleLoader = require('./fhir/module-loader')(mongo)
const profileLoader = require('./fhir/profile-loader')()

const acceptedJSONContentTypes = ['application/json+fhir', 'application/fhir+json', 'application/json', 'text/json']
const acceptedXMLContentTypes = ['application/xml+fhir', 'application/fhir+xml', 'application/xml', 'text/xml']

process.title = 'Hearth'

let fhir = null
switch (config.getConf('server:fhirVersion')) {
  case 'dstu1':
    fhir = new FHIR(FHIR.DSTU1)
    break
  case 'dstu2':
    fhir = new FHIR(FHIR.DSTU2)
    break
  case 'stu3':
    fhir = new FHIR(FHIR.STU3)
    break
}

if (config.getConf('createIndexes')) {
  matchingIndexes.createMatchingIndexes((err) => {
    if (err) {
      logger.error(err)
    }
    logger.info('Matching Indexes created')
  })
}

moduleLoader.loadModules()
github jembi / hearth / lib / server.js View on Github external
const fhirCommon = require('./fhir/common')(mongo)
const hooks = require('./fhir/hooks')()
const matchingQueue = require('./matching-queue/matching-queue')(mongo)
const matchingIndexes = require('../scripts/matching-indexes')(mongo)
const moduleLoader = require('./fhir/module-loader')(mongo)
const profileLoader = require('./fhir/profile-loader')()

const acceptedJSONContentTypes = ['application/json+fhir', 'application/fhir+json', 'application/json', 'text/json']
const acceptedXMLContentTypes = ['application/xml+fhir', 'application/fhir+xml', 'application/xml', 'text/xml']

process.title = 'Hearth'

let fhir = null
switch (config.getConf('server:fhirVersion')) {
  case 'dstu1':
    fhir = new FHIR(FHIR.DSTU1)
    break
  case 'dstu2':
    fhir = new FHIR(FHIR.DSTU2)
    break
  case 'stu3':
    fhir = new FHIR(FHIR.STU3)
    break
}

if (config.getConf('createIndexes')) {
  matchingIndexes.createMatchingIndexes((err) => {
    if (err) {
      logger.error(err)
    }
    logger.info('Matching Indexes created')
  })
github jembi / hearth / lib / plugins / validator.js View on Github external
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict'

const FHIR = require('fhir')
const config = require('../config')

const profileLoader = require('../fhir/profile-loader')()

let fhir = null
switch (config.getConf('server:fhirVersion')) {
  case 'dstu1':
    fhir = new FHIR(FHIR.DSTU1)
    break
  case 'dstu2':
    fhir = new FHIR(FHIR.DSTU2)
    break
  case 'stu3':
    fhir = new FHIR(FHIR.STU3)
    break
}

module.exports = () => {
  return {
    hooks: {
      before: [
        {
          resourceType: '*',
          interactions: [ 'create', 'update' ],
github jembi / hearth / lib / plugins / validator.js View on Github external
const FHIR = require('fhir')
const config = require('../config')

const profileLoader = require('../fhir/profile-loader')()

let fhir = null
switch (config.getConf('server:fhirVersion')) {
  case 'dstu1':
    fhir = new FHIR(FHIR.DSTU1)
    break
  case 'dstu2':
    fhir = new FHIR(FHIR.DSTU2)
    break
  case 'stu3':
    fhir = new FHIR(FHIR.STU3)
    break
}

module.exports = () => {
  return {
    hooks: {
      before: [
        {
          resourceType: '*',
          interactions: [ 'create', 'update' ],
          userType: '*',
          function: (interaction, ctx, resourceType, resource, callback) => {
            if (!config.getConf('validation:enabled')) {
              return callback(null, null)
            }
github hms-dbmi / halyos / src / services / fhir / FhirActions.js View on Github external
return (dispatch, getState) => {
    dispatch(requestAllObs(patientID));
    const baseUrl = getURL();

    var mkFhir = require('fhir.js');
    var client = mkFhir({
      baseUrl: getInsecureURL()
    });

    //sort by code
    client
      .fetchAll({type: 'Observation', query: {'subject':patientID, '$sort': [['code','asc']]}})
      .then(function(res){
        var bundle = res;
        let currObsIdx = 0;
        let currObs = bundle[currObsIdx].code.coding[0].code;

        if(!bundle){
          return Promise.resolve();
        }
        var allObsList = [];

fhir

Library that assists in handling FHIR resources. Supports serialization between JSON and XML, validation and FhirPath evaluation.

Apache-2.0
Latest version published 9 months ago

Package Health Score

67 / 100
Full package analysis