npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

blue-button

v1.10.2

Published

Blue Button (CCDA, C32, CMS) to JSON Parser.

Downloads

192

Readme

blue-button

Blue Button JavaScript library

NPM

Build Status Coverage Status Dependency Status

blue-button.js

This library provides the following functionality

  • Parse XML documents
  • Sense type of data (CCDA, CMS, C32, etc.)
  • Parse CCDA into JSON representation
    • Parse CCDA elements (sections) into JSON representation
  • Parse C32 into JSON representation
    • Parse C32 elements (sections) into JSON representation
  • Parse CMS into JSON representation
  • Generate JSON object based on data model

Actual implementation of sensing type of data and parsing CCDA and C32 reside in this repository. Implementation of other functionalities reside in

In addition CCDA generation from blue-button JSON objects is available in blue-button-generate.

This library is primarily implemented for node.js and is available via npm. A browser version is also available via bower. The browser version is created using browserify and can be used in the same way that you would use it in node.js.

Usage

Require blue-button module

var bb = require("blue-button")

Load some health data content. Currently CCDA (CCD), C32 and CMS are supported

var data = "some CCDA.xml, C32.xml or CMS.txt here...";

Generate JSON representation of the health data

var doc = bb.parse(data);

parse method senses the type of the health data, parses and converts it into JSON. All types of health data is converted into a common model. Validate doc according to the common model schema

var valid = bb.validator.validateDocumentModel(doc);
if (! valid) {
	throw new Error('failed');
}

Do changes to doc in your application

doc.data.demographics.phone.number = "(555)555-5555";

Create a CCDA (CCD) document that includes your changes

var bbg = require("blue-button-generate")
var modifiedDataCCD = bbg.generateCCD(doc);

Blue Button library converts all types of health data (CCDA, C32, CMS) into a common model. Data model schema and validation implementation can be found in blue-button-model.

API

XML Utilities

Blue Button library provides basic XML parsing and XPath functionality via libxmljs (node.js) and DomParser (browsers). All XML related API methods are inherited from blue-button-xml and available from xml object

var xml = bb.xml;

Parses XML content string into an XML Object which can be used in other API methods. Details of the actual XML object can be found in the documentation of underlying libraries libxmljs (node.js) and DomParser (browsers).

Arguments

  • src - XML content in string.
  • returns - XML Object.

xpath(doc, p, ns)

Finds the XML nodes that are specified by p.

Arguments

  • doc - XML document or any parent XML node inside the document that is found by a previous xpath call.
  • p - A valid XPath string.
  • ns - XML namespace specifications. By default h: urn:hl7-org:v3" and xsi: http://www.w3.org/2001/XMLSchema-instance are used as they are the namespaces used in CCDA.
  • returns - XML object node.

senseString(data)

Senses the type of the string content.

Arguments

  • data - String content for which the type is to be found.
  • returns - A result object. In the case of an error either null is returned or an error is thrown. Result object has the following properties
    • type - A string that identifies the type of the content. Currently can be ccda, c32, cda, xml, cms, va, format-x, json, blue-button.js, va, pdf or unknown.
    • xml - In the case of XML content (ccda, c32, cda, xml) this is set to the parsed XML object.
    • json - In the case of JSON content (blue-button.js, json) this is set to the passed JSON object.

senseXml(data)

Senses the type of an XML object.

Arguments

  • data - XML object for which the type is to be found.
  • returns - A result object. In the case of an error either null is returned or an error is thrown. Result object has the following properties
    • type - A string that identifies the type of the content. Currently can be ccda, c32, cda, xml, unknown.

JSON Generation

This is the primary method in Blue Button library that both senses the type of the input content and generates JSON out of it. Underneath it calls to other sensing and JSON generation methods.

Arguments

  • data - Any string data content. Currently CCDA (CCD), C32 and CMS are supported.
  • options - The following properties are supported
    • component - Specifies a component of CCDA or C32 document; not used for CMS documents. data should only contain content for the component. The following CCDA (CCD) sections are supported: ccda_demographics, ccda_vitals, ccda_medications, ccda_problems, ccda_immunizations, ccda_results, ccda_allergies, ccda_encounters, ccda_procedures, ccda_social_history, ccda_plan_of_care, ccda_payers. The following C32 sections are supported: c32_demographics, c32_vitals, c32_medications, c32_problems, c32_immunizations, c32_results, c32_allergies, c32_encounters, c32_procedures. In addition individual entries in each section can also be specified (ccda_vitals_entry, ccda_medications_entry, ..., c32_vitals_entry, ...).
  • returns - JSON representation of the data.

parseString(data, options)

This is similar to parse but it assumes data to be valid XML.

parseXml(data, options)

This is similar to parse but it assumes data to be an XML object.

parseText(data)

This is similar to parse but it assumes data to be Text (ASCII) and options is not used. Currently only Text content in CMS format is supported.

Examples

See scripts in /example or /test directories that use the above API methods for CCDA, C32 and CMS examples.

Goals

  • Full support of CCDA, C32 and CMS
  • Ability to extend to support other data formats
  • Solid, well-documented JSON-based data model for patient health data
  • Modularity - easy to extend (both parser and data model)
  • Node.js support
  • Browser support
  • Speed of parsing
  • Well tested on entire corpora of CCDA samples from https://github.com/jmandel/sample_ccdas

Future Roadmap

  • Merge back into bluebutton.js repo
  • Refactoring into smaller components (sub-modules)

Contributing

Contributors are welcome. See issues https://github.com/amida-tech/blue-button/issues

Release Notes

See release notes [here] (./RELEASENOTES.md)

License

Licensed under Apache 2.0

Project was influenced by and used some code from:

bluebutton.js library licensed under MIT

Josh Mandel's ccda-to-json library licensed under [Apache 2.0] (https://github.com/jmandel/ccda-to-json/blob/master/LICENSE)