"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.localAnestheticVariantsList = exports.getLocalVariantLabel = exports.getLocalVariantSubName = void 0;

var _milliseconds = _interopRequireDefault(require("milliseconds"));

var _object = require("./object");

var _formatEpi = require("./format-epi");

var _formatPercent = require("./format-percent");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

const localAnestheticListAsArray = [{
  id: '142440',
  name: 'Lidocaine',
  brandName: 'Xylocaine',
  percent: 0.02,
  halfLife: _milliseconds.default.minutes(120),
  input: 'cartridges',
  variants: [{
    id: '142440|0',
    epi: 0,
    color: '#5A77AC',
    manAbsoluteMax: 300,
    manRatioMax: 4.5
  }, {
    id: '142440|1',
    epi: 50,
    color: '#007D59',
    manAbsoluteMax: 500,
    manRatioMax: 7,
    aapdAbsoluteMax: 300,
    aapdRatioMax: 4.4
  }, {
    id: '142440|2',
    epi: 100,
    color: '#FB0019',
    manAbsoluteMax: 500,
    manRatioMax: 7,
    aapdAbsoluteMax: 300,
    aapdRatioMax: 4.4
  }]
}, {
  id: '2117',
  name: 'Articaine',
  brandName: 'Septocaine',
  percent: 0.04,
  halfLife: _milliseconds.default.minutes(44.4),
  input: 'cartridges',
  variants: [{
    id: '2117|0',
    epi: 100,
    color: '#B28768',
    manAbsoluteMax: null,
    manRatioMax: 7,
    aapdAbsoluteMax: 500,
    aapdRatioMax: 7,
    minAge: 5,
    enableDilute: true,
    ageWarning: 'Manufacturer recommends not using on patients 4 and under.'
  }, {
    id: '2117|1',
    epi: 200,
    color: '#807772',
    manAbsoluteMax: null,
    manRatioMax: 7,
    aapdAbsoluteMax: 500,
    aapdRatioMax: 7,
    minAge: 5,
    enableDilute: true,
    ageWarning: 'Manufacturer recommends not using on patients 4 and under.'
  }]
}, {
  id: '267396',
  name: 'Bupivacaine',
  brandName: 'Marcaine',
  percent: 0.005,
  halfLife: _milliseconds.default.hours(3.5),
  nameForChart: '0.5% Bupiv.',
  input: 'cartridges',
  variants: [{
    id: '267396|0',
    epi: 200,
    color: '#2063A1',
    manAbsoluteMax: 90,
    manRatioMax: 7,
    minAge: 13,
    enableDilute: true,
    ageWarning: 'Extra caution advised for pediatric patients.'
  }]
}, {
  id: '2557',
  name: 'Prilocaine',
  brandName: 'Citanest',
  percent: 0.04,
  halfLife: _milliseconds.default.hours(1.6),
  input: 'cartridges',
  variants: [{
    id: '2557|0',
    epi: 200,
    color: '#FFE95E',
    manAbsoluteMax: 600,
    manRatioMax: 8,
    aapdAbsoluteMax: 400,
    aapdRatioMax: 6
  }, {
    id: '2557|1',
    epi: 0,
    color: '#2B251F',
    manAbsoluteMax: 600,
    manRatioMax: 8,
    aapdAbsoluteMax: 300,
    aapdRatioMax: 6
  }]
}, {
  id: '203185',
  name: 'Mepivacaine',
  brandName: 'Carbocaine',
  percent: 0.03,
  halfLife: _milliseconds.default.hours(1.9),
  input: 'cartridges',
  variants: [{
    id: '203185|0',
    color: '#EFC09B',
    manAbsoluteMax: 400,
    manRatioMax: 6.6,
    aapdAbsoluteMax: 300,
    aapdRatioMax: 4.4
  }, {
    id: '700826|0',
    drugIdOverride: '700826',
    subName: '1:20,000 Levonordefrin',
    nameForChart: 'Mepivacaine',
    unitForChart: 'Levonordefrin',
    percent: 0.02,
    color: '#874C41',
    manAbsoluteMax: 400,
    manRatioMax: 6.6,
    aapdAbsoluteMax: 300,
    aapdRatioMax: 4.4
  }]
}, {
  id: '1726513',
  name: 'Exparel™',
  altName: 'Bupivacaine liposome susp.',
  reminder: 'Never to be injected within 20 minutes of any other kind of non-Bupivacaine local anesthetic, nor is any other local anesthetic to be given 96 hours after Exparel.',
  percent: 0.0133,
  halfLife: _milliseconds.default.hours(24),
  input: 'mg',
  variants: [{
    id: '1726513|0',
    color: '#044F56',
    minAge: 18,
    ageWarning: 'FDA approved for 18+ only.'
  }]
}, {
  id: '1856568',
  name: 'OraVerse™',
  altName: 'Phentolamine Mesylate',
  reminder: 'Should only follow local anesthetics that contain a vasoconstrictor.',
  percent: 0.4 / 1.7 / 1000,
  input: 'cartridges',
  variants: [{
    id: '1856568|0',
    subName: '0.4 mg/1.7 mL',
    color: '#B2EB87',
    minAge: 3,
    noEpiWarning: 'No doses with epinepherine have been recorded. Should only be given after locals with a vasoconstrictor.',
    ageWarning: 'The safety and efficacy of Phentolamine Mesylate has not been established in patients younger than 3 years.',
    // very important!
    skipForToxicity: true
  }]
}];

const getLocalVariantSubName = variant => {
  if (variant.subName) {
    return variant.subName;
  }

  if (variant.epi != null) {
    if (typeof variant.epi === 'number') {
      return (0, _formatEpi.formatEpi)(variant.epi);
    }

    return '(no epi)';
  }
};

exports.getLocalVariantSubName = getLocalVariantSubName;

const getLocalVariantLabel = variant => {
  let fullVariantName = "".concat(variant.name).concat(variant.subName ? ' ' + variant.subName : '');

  if (variant.percent) {
    fullVariantName = "".concat((0, _formatPercent.formatPercent)(variant.percent), " ").concat(fullVariantName);
  }

  return fullVariantName;
};

exports.getLocalVariantLabel = getLocalVariantLabel;
const variantDefaults = {
  epi: 0
};
const localAnestheticVariantsList = localAnestheticListAsArray.reduce((result, drug) => {
  drug.variants.forEach(variant => {
    result.push(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (0, _object.omit)(drug, ['variants'])), {}, {
      rxcui: drug.id
    }, variantDefaults), variant), {}, {
      subName: getLocalVariantSubName(variant)
    }));
  });
  return result;
}, []);
exports.localAnestheticVariantsList = localAnestheticVariantsList;