Split packages into platform and extensions

This commit is contained in:
dannyrb committed 2019-07-08 00:41:25 -04:00
1 parent f175d4b96b
commit e8969fba11
992 files changed
+2 -1

No files matched your search

@@ -0,0 +1,44 @@
/**
* Returns the specified element as a dicom attribute group/element.
*
* @param element - The group/element of the element (e.g. '00280009')
* @param [defaultValue] - The value to return if the element is not present
* @returns {*}
*/
export default function getAttribute(element, defaultValue) {
if (!element) {
return defaultValue;
}
// Value is not present if the attribute has a zero length value
if (!element.Value) {
return defaultValue;
}
// Sanity check to make sure we have at least one entry in the array.
if (!element.Value.length) {
return defaultValue;
}
return convertToInt(element.Value);
}
function convertToInt(input) {
function padFour(input) {
var l = input.length;
if (l == 0) return '0000';
if (l == 1) return '000' + input;
if (l == 2) return '00' + input;
if (l == 3) return '0' + input;
return input;
}
var output = '';
for (var i = 0; i < input.length; i++) {
for (var j = 0; j < input[i].length; j++) {
output += padFour(input[i].charCodeAt(j).toString(16));
}
}
return parseInt(output, 16);
}
@@ -0,0 +1,25 @@
// Commenting this out for now since it looks like Rollup is pulling in the
// Node.js version instead of the Browser version of this package
//import { btoa } from 'isomorphic-base64';
import user from '../user';
/**
* Returns the Authorization header as part of an Object.
*
* @returns {Object}
*/
export default function getAuthorizationHeader(server) {
const headers = {};
// Check for OHIF.user since this can also be run on the server
const accessToken = user && user.getAccessToken && user.getAccessToken();
if (server && server.requestOptions && server.requestOptions.auth) {
// HTTP Basic Auth (user:password)
headers.Authorization = `Basic ${btoa(server.requestOptions.auth)}`;
} else if (accessToken) {
headers.Authorization = `Bearer ${accessToken}`;
}
return headers;
}
@@ -0,0 +1,21 @@
export default function getModalities(modality, modalitiesInStudy) {
var modalities = {};
if (modality) {
modalities = modality;
}
if (modalitiesInStudy) {
// Find vr in modalities
if (modalities.vr && modalities.vr === modalitiesInStudy.vr) {
for (var i = 0; i < modalitiesInStudy.Value.length; i++) {
var value = modalitiesInStudy.Value[i];
if (modalities.Value.indexOf(value) === -1) {
modalities.Value.push(value);
}
}
} else {
modalities = modalitiesInStudy;
}
}
return modalities;
}
+26
View File
@@ -0,0 +1,26 @@
/**
* Returns the Alphabetic version of a PN
*
* @param element - The group/element of the element (e.g. '00200013')
* @param [defaultValue] - The default value to return if the element is not found
* @returns {*}
*/
export default function getName(element, defaultValue) {
if (!element) {
return defaultValue;
}
// Value is not present if the attribute has a zero length value
if (!element.Value) {
return defaultValue;
}
// Sanity check to make sure we have at least one entry in the array.
if (!element.Value.length) {
return defaultValue;
}
// Return the Alphabetic component group
if (element.Value[0].Alphabetic) {
return element.Value[0].Alphabetic;
}
// Orthanc does not return PN properly so this is a temporary workaround
return element.Value[0];
}
+21
View File
@@ -0,0 +1,21 @@
/**
* Returns the first string value as a Javascript Number
* @param element - The group/element of the element (e.g. '00200013')
* @param [defaultValue] - The default value to return if the element does not exist
* @returns {*}
*/
export default function getNumber(element, defaultValue) {
if (!element) {
return defaultValue;
}
// Value is not present if the attribute has a zero length value
if (!element.Value) {
return defaultValue;
}
// Sanity check to make sure we have at least one entry in the array.
if (!element.Value.length) {
return defaultValue;
}
return parseFloat(element.Value[0]);
}
+23
View File
@@ -0,0 +1,23 @@
/**
* Returns the specified element as a string. Multi-valued elements will be separated by a backslash
*
* @param element - The group/element of the element (e.g. '00200013')
* @param [defaultValue] - The value to return if the element is not present
* @returns {*}
*/
export default function getString(element, defaultValue) {
if (!element) {
return defaultValue;
}
// Value is not present if the attribute has a zero length value
if (!element.Value) {
return defaultValue;
}
// Sanity check to make sure we have at least one entry in the array.
if (!element.Value.length) {
return defaultValue;
}
// Join the array together separated by backslash
// NOTE: Orthanc does not correctly split values into an array so the join is a no-op
return element.Value.join('\\');
}
+17
View File
@@ -0,0 +1,17 @@
import getAttribute from './getAttribute.js';
import getAuthorizationHeader from './getAuthorizationHeader.js';
import getModalities from './getModalities.js';
import getName from './getName.js';
import getNumber from './getNumber.js';
import getString from './getString.js';
const DICOMWeb = {
getAttribute,
getAuthorizationHeader,
getModalities,
getName,
getNumber,
getString,
};
export default DICOMWeb;