New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

joi-fhir

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

joi-fhir

Validate FHIR data with Joi

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by80%
Maintainers
2
Weekly downloads
 
Created
Source

joi-fhir -- Work in progress

CircleCI experimental

Node.js utility for validating FHIR resources.

Quick start

Prerequisites

  • Node.js 6+
  • npm
  • Publish permission to joi-fhir on NPM (Only for deployment)

Installing

npm install --save joi-fhir

Examples

const validateFhir = require('joi-fhir');
const Encounter = {
  resourceType: 'Encounter',
  id: 'ENC001',
  ...
}

// Validate any generic FHIR resource
validateFhir(Encounter)
.then((validated) => console.log('Validated encounter', validated))
.catch((error) => console.log('Error validating encounter', error));

// Ensure FHIR resource matches a certain type
validateFhir(Encounter, { resourceType: 'Encounter' })
.then((validated) => console.log('Validated encounter', validated))
.catch((error) => console.log('Error validating encounter', error));

API

This module exports a single Function that accepts a FHIR resource and an options object. The function validates the FHIR resource matches the spec and returns a promise with either the validated/formatted FHIR resource or an error detailing the malformed data.

Definition

validateFhir(resource);

Parameters

ParameterTypeDescription
resourceObjectA FHIR resource

options

ParameterTypeDescriptionDefault
resourceTypeStringIf provided, ensure the resource is of this type. Otherwise, allow any FHIR resourcenone

Examples

Input

encounterA

Data about an encounter.

{
  "resourceType": "Encounter",
  "status": "in-progress",
  "subject": {
    "reference": "Patient/P01"
  },
  "reason": [
    {
      "text": "Laceration to leg"
    }
  ]
}

Invocation

const validateFhir = require('@agilemd/joi-fhir');

return validateFhir(encounter)
.then((validated) => {
  ...
})
.catch((err) => {
  // Handle error
})

Output

validated/formatted Encounter
{
  "id": "31a49ff9-2d10-481c-8720-a1a3e61fa981",
  "resourceType": "Encounter",
  "status": "in-progress",
  "subject": {
    "reference": "Patient/P01"
  },
  "reason": [
    {
      "text": "Laceration to leg"
    }
  ]
}

Development

Install

Clone the source repository, cd into the joi-fhir directory, and install dependencies:

git clone git@github.com:agilemd/joi-fhir.git
cd joi-fhir
npm install

Tests

To run the unit tests:

npm test

Changes must not reduce coverage of statements, branches, and functions. To determine unit test coverage:

npm run coverage

Debug

The debug module is used for runtime logging. Omit the DEBUG environment variable to squelch all logging. Set DEBUG to the desired level (e.g. DEBUG=@agilemd/joi-fhir:SUBMODULE) to restrict logging to a desired service. Or, use DEBUG=* to get all debug output from everywhere, including dependencies.

DEBUG=@agilemd/joi-fhir* npm test

Workflow

  1. Feature development and bug fixing MUST occur on a non-master branch.
  2. All changes SHOULD be submitted to master via a Pull Request.
  3. Pull Requests SHOULD be merged via a merge commit. Local "in-process" commits may be squashed prior to pushing to the remote feature branch.

To enable a git hook that runs npm test prior to pushing, cd into the project repo and run:

touch .git/hooks/pre-push
chmod +x .git/hooks/pre-push
echo "npm test" > .git/hooks/pre-push

Build

This project follows semantic versioning. After committing the latest code to GitHub master, update the version:

npm version [major/minor/patch]

Then push the tag to GitHub and publish this package to npm:

git push origin --tags
npm publish

References

Implementation checklist

This project is a work in progress. Any defined FHIR resource will pass validation; however, only certain resources are fully validated. The table below describes which resources have complete validation and which are in progress

Support legend

IconDescription
:white_check_mark:Completely implemented
:o:Partially implemented
:no_entry_sign:Not yet implemented
Resource TypeSupport
Account:no_entry_sign:
ActivityDefinition:no_entry_sign:
AllergyIntolerance:no_entry_sign:
AdverseEvent:no_entry_sign:
Appointment:no_entry_sign:
AppointmentResponse:no_entry_sign:
AuditEvent:no_entry_sign:
Basic:no_entry_sign:
Binary:no_entry_sign:
BodySite:no_entry_sign:
Bundle:no_entry_sign:
CapabilityStatement:no_entry_sign:
CarePlan:no_entry_sign:
CareTeam:no_entry_sign:
ChargeItem:no_entry_sign:
Claim:no_entry_sign:
ClaimResponse:no_entry_sign:
ClinicalImpression:no_entry_sign:
CodeSystem:no_entry_sign:
Communication:no_entry_sign:
CommunicationRequest:no_entry_sign:
CompartmentDefinition:no_entry_sign:
Composition:no_entry_sign:
ConceptMap:no_entry_sign:
Condition:no_entry_sign:
Consent:no_entry_sign:
Contract:no_entry_sign:
Coverage:no_entry_sign:
DataElement:no_entry_sign:
DetectedIssue:no_entry_sign:
Device:no_entry_sign:
DeviceComponent:no_entry_sign:
DeviceMetric:no_entry_sign:
DeviceRequest:no_entry_sign:
DeviceUseStatement:no_entry_sign:
DiagnosticReport:no_entry_sign:
DocumentManifest:no_entry_sign:
DocumentReference:no_entry_sign:
EligibilityRequest:no_entry_sign:
EligibilityResponse:no_entry_sign:
Encounter:no_entry_sign:
Endpoint:no_entry_sign:
EnrollmentRequest:no_entry_sign:
EnrollmentResponse:no_entry_sign:
EpisodeOfCare:no_entry_sign:
ExpansionProfile:no_entry_sign:
ExplanationOfBenefit:no_entry_sign:
FamilyMemberHistory:no_entry_sign:
Flag:no_entry_sign:
Goal:no_entry_sign:
GraphDefinition:no_entry_sign:
Group:no_entry_sign:
GuidanceResponse:no_entry_sign:
HealthcareService:no_entry_sign:
ImagingManifest:no_entry_sign:
ImagingStudy:no_entry_sign:
Immunization:no_entry_sign:
ImmunizationRecommendation:no_entry_sign:
ImplementationGuide:no_entry_sign:
Library:no_entry_sign:
Linkage:no_entry_sign:
List:no_entry_sign:
Location:no_entry_sign:
Measure:no_entry_sign:
MeasureReport:no_entry_sign:
Media:no_entry_sign:
Medication:no_entry_sign:
MedicationAdministration:no_entry_sign:
MedicationDispense:no_entry_sign:
MedicationStatement:no_entry_sign:
MessageDefinition:no_entry_sign:
MessageHeader:no_entry_sign:
NamingSystem:no_entry_sign:
NutritionOrder:no_entry_sign:
Observation:no_entry_sign:
OperationDefinition:no_entry_sign:
OperationOutcome:no_entry_sign:
Organization:no_entry_sign:
Parameters:no_entry_sign:
Patient:no_entry_sign:
PaymentNotice:no_entry_sign:
PaymentReconciliation:no_entry_sign:
Person:no_entry_sign:
PlanDefinition:no_entry_sign:
Practitioner:no_entry_sign:
PractitionerRole:no_entry_sign:
Procedure:no_entry_sign:
ProcedureRequest:no_entry_sign:
ProcessRequest:no_entry_sign:
ProcessResponse:no_entry_sign:
Provenance:no_entry_sign:
Questionnaire:no_entry_sign:
QuestionnaireResponse:no_entry_sign:
ReferralRequest:no_entry_sign:
RelatedPerson:no_entry_sign:
RequestGroup:no_entry_sign:
ResearchStudy:no_entry_sign:
ResearchSubject:no_entry_sign:
RiskAssessment:no_entry_sign:
Schedule:no_entry_sign:
SearchParameter:no_entry_sign:
Sequence:no_entry_sign:
ServiceDefinition:no_entry_sign:
Slot:no_entry_sign:
Specimen:no_entry_sign:
StructureDefinition:no_entry_sign:
StructureMap:no_entry_sign:
Subscription:no_entry_sign:
Substance:no_entry_sign:
SupplyDelivery:no_entry_sign:
SupplyRequest:no_entry_sign:
Task:no_entry_sign:
TestScript:no_entry_sign:
TestReport:no_entry_sign:
ValueSet:no_entry_sign:
VisionPrescription:no_entry_sign:

FAQs

Package last updated on 18 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc