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.)
- Transform FHIR Resources to Merkle tree
- Support Merkle Patricia tree which is described in the Ethereum's Yellow Paper
- Validate FHIR Resources by MediBloc defined FHIR Protocol buffers
- Support STU3
- Convert DICOM image to FHIR Resource
- Support DICOM image to Media Resource
- 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
npm install medibloc/merklizer
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;
}
}
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;
}
}
Components | Descriptions |
---|---|
fhir | HL7 FHIR related |
dicom | DICOM related |
merkle | Merkle Patricia tree related |
utils | extra functions to deal with object |
An object is processed as defined MediBloc FHIR Protocol buffers
-
resource
[Object] An JSON typed FHIR Resource
-
filter
[Object] A filtered FHIR Resource
Examples
const resource = {
resourceType: 'Media',
type: { value: 1 },
content: {
data: { value: '' },
},
};
let filtered = fhir.filter(resource);
Transform DICOM to Media Resource
-
dicomArray
[Uint8Array] A Uint8Array typed DICOM
-
media
[Object] An Object of Media Resource
Examples
const dicomArray = new Uint8Array(buffer);
let media = dicom.createMedia(dicomArray);
Create trie using an array of Resource components
-
items
[Array] An array, which is composed of key and value -
cb
[Function] A callbackFunction
(arguments {Error}e
, {Trie}r
)
Examples
merkle.createTrie(items, cb);
Prove trie using an array of Resource components that is used to create the trie
-
trie
[Trie] A trie to prove -
items
[Array] An array, which is composed of key and value -
cb
[Function] A callbackFunction
(arguments {Error}e
, {Trie}r
)
Examples
merkle.proveTrie(trie, items, cb);
Flat object's depth
-
obj
[Object] An object, which is composed of key and value
-
flat
[Object] A flatten object
Examples
let obj = {
key1: {
keyA: 'valueI'
},
key2: {
keyB: 'valueII'
},
key3: { a: { b: { c: 2 } } },
};
let flatted = utils.flat(obj);
Transform object to array
-
obj
[Object] An object
-
arr
[Array] An array
Examples
let obj = {
name: 'Bob',
email: 'bob@gmail.com',
};
let array = utils.objectToArray(obj);
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.
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.