Giter Club home page Giter Club logo

fhir-validator-js's Introduction

Javascript FHIR Validator

A javascript FHIR (www.hl7.org/fhir/) validator for use with json or strings that conform to the FHIR 3 standard.

Usage

Node

var fhir = require('fhir-validator'),
	resource,
	result;

// Your resource to validate (as json or a string)
resource = {
	resourceType: 'Medication',
	invalidProperty: 'This property is invalid for medications'
};

// Run the validation on the resource
result = fhir.validate(resource);

// Use the validation result
if(result.errors.length > 0) {
	throw { errors: result.errors, message: 'The given resource is invalid. There were ' + result.errors.length + ' errors.' };
}

fhir-validator-js's People

Contributors

arrian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fhir-validator-js's Issues

$ref properties should not be extended

Running fhir-validator outputs quite a lot of warnings like this one:

$ref: all keywords used in schema at path "#/properties/district". It will change in the next major version, see issue #260. Use option { extendRefs: true } to keep current behaviour

The cause is that extra properties in JSON reference objects are supposed to be ignored. I.e. pattern is incorrectly placed here:

{ "district": {"$ref":"#/types/string","pattern":"[^s]+([s]+[^s]+)*"} }

See ajv-validator/ajv#260.

Complex elements support extensions

The FHIR standard states that complex elements can have extensions, here:

Extensions are represented in a JSON array of objects named "extension".

Right now, using a valid extension for complex elements throws this error:

    dataPath: '.address[0]',
    schemaPath: '#/additionalProperties',
    params: { additionalProperty: 'extension' },
    message: 'should NOT have additional properties' } ]

For this sample Patient data:

   "resourceType":"Patient",
   "id":"example",
   "address":[
      {
         "use":"home",
         "type":"both",
         "text":"534 Erewhon St PeasantVille, Rainbow, Vic  3999",
         "line":[
            "534 Erewhon St"
         ],
         "extension":[
            {
               "url":"/StructureDefinition/example-extension-1",
               "valueString":"data to save"
            }
         ]
      }
   ]
}

This is throwing false positives.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.