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

medibloc-merklizer

v0.1.0

Published

Convert healthcare data standards to Merkle Patricia tree

Downloads

5

Readme

Merklizer

Merklizer is a JavaScript package for converting healthcare data to Merkle Patricia tree.
Merklizer provides consistent conversion between various medical data format standards. (Currently, support DICOM to FHIR only.)

Key Features (version 0.2.1)

Todo

  • Auto-generate Protocol buffers
    • Support Base Resources in HL7 FHIR STU3
  • Convert DICOM image to FHIR Resource
    • Support to involved all known meta-data in DICOM file

Dependencies

protoc 3.6.0

npm packages

Installation

npm install medibloc/merklizer

Usage

FHIR Resource to Merkle Patricia tree

import { utils, fhir, merkle } from 'merklizer';

// let resource = OBJECT_OF_FHIR_RESOURCE;
let plain = fhir.filter(resource); // returns filtered object
let flat = utils.flat(plain); // returns flatted object
let arr = utils.objectToArray(flat); // returns array
merkle.createTrie(arr, (e,r) => {
  let trie = r;
  merkle.proveTrie(trie, arr, (e,r) => {
    let trie = r;
  }
}

DICOM to Merkle Patricia tree

import { utils, dicom, fhir, merkle } from 'merklizer';

// let dicomArray = UINT8ARRAY_OF_DICOM
let media= dicom.createMedia(dicomArray); // returns media object
let plain = fhir.filter(media); // returns filtered object
let flat = utils.flat(plain); // returns flatted object
let arr = utils.objectToArray(flat); // returns array
merkle.createTrie(arr, (e,r) => {
  let trie = r;
  merkle.proveTrie(trie, arr, (e,r) => {
    let trie = r;
  }
}

API Reference

| Components | Descriptions |------------|----------------------------------- | fhir | HL7 FHIR related | dicom | DICOM related | merkle | Merkle Patricia tree related | utils | extra functions to deal with object

fhir.filter

An object is processed as defined MediBloc FHIR Protocol buffers

Parameters

  • resource [Object] An JSON typed FHIR Resource

Returns

  • filter [Object] A filtered FHIR Resource

Examples

const resource = {
  resourceType: 'Media',
  type: { value: 1 },
  content: {
    data: { value: '' },
  },
};
let filtered = fhir.filter(resource);

dicom.createMedia

Transform DICOM to Media Resource

Parameters

  • dicomArray [Uint8Array] A Uint8Array typed DICOM

Returns

  • media [Object] An Object of Media Resource

Examples

const dicomArray = new Uint8Array(buffer);
let media = dicom.createMedia(dicomArray);

merkle.createTrie

Create trie using an array of Resource components

Parameters

  • items [Array] An array, which is composed of key and value
  • cb [Function] A callback Function (arguments {Error}e, {Trie}r)

Examples

merkle.createTrie(items, cb);

merkle.proveTrie

Prove trie using an array of Resource components that is used to create the trie

Parameters

  • trie [Trie] A trie to prove
  • items [Array] An array, which is composed of key and value
  • cb [Function] A callback Function (arguments {Error}e, {Trie}r)

Examples

merkle.proveTrie(trie, items, cb);

utils.flat

Flat object's depth

Parameters

  • obj [Object] An object, which is composed of key and value

Returns

  • flat [Object] A flatten object

Examples

let obj = {
  key1: {
    keyA: 'valueI'
  },
  key2: {
    keyB: 'valueII'
  },
  key3: { a: { b: { c: 2 } } },
};
let flatted = utils.flat(obj);

utils.objectToArray

Transform object to array

Parameters

  • obj [Object] An object

Returns

  • arr [Array] An array

Examples

let obj = {
  name: 'Bob',
  email: '[email protected]',
};
let array = utils.objectToArray(obj);

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

Copyright 2018 MediBloc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.