"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.macroToItemArrayBase = exports.macroAirwayLabelMap = exports.macroDrugLabelMap = exports.macroLabelMap = void 0;

var _textFormat = require("./text-format");

/**
 * @type {{
 *   [K in MacroKey]: any
 * }}
 */
const macroLabelMap = {
  recorderName: 'Who is recording data',
  present: 'Who is present',
  userRole: 'Provider Role',
  asaClassification: 'ASA Classification',
  mallampati: 'Mallampati Score',
  weightDistribution: 'Weight Distribution',
  surgeonName: "Surgeon's Name",
  sedationProviderName: "Anesthesia Provider's Name",
  reasonForSedation: 'Reason For Sedation',
  pregnant: {
    label: 'Chance of Pregnancy',
    format: val => val === 'n' ? 'No' : 'Yes'
  },
  breastfeeding: 'Is Breastfeeding',
  breastfeedingInstructionsGiven: 'Gave Instructions Regarding Breastfeeding',
  lastFood: 'When did patient last eat',
  lastDrink: 'When did patient last drink',
  procedureNotes: 'Notes',
  recoveryNotes: 'Recovery Notes',
  preProcedureRiskAssessment: 'Pre-Procedure Risk Assessment',
  calculateDrugWaste: 'Calculate Drug Waste',
  dischargeScoreType: {
    label: 'Discharge Score',
    format: _textFormat.capitalize
  }
};
exports.macroLabelMap = macroLabelMap;
const macroDrugLabelMap = {
  dose: 'Typical First Dose',
  draw: 'Initial Draw',
  route: 'Administration Route',
  unit: 'Unit',
  bolusUnit: 'Bolus Unit'
};
exports.macroDrugLabelMap = macroDrugLabelMap;
const macroAirwayLabelMap = {
  type: 'Type',
  preOx: 'Pre-Ox'
};
exports.macroAirwayLabelMap = macroAirwayLabelMap;

const defaultFormat = val => {
  const type = typeof val;

  if (type === 'boolean') {
    return val ? 'Yes' : 'No';
  }

  return val;
};
/**
 * @param {any} object
 * @param {string} basePath
 * @param {{
 *   [id: string]:
 *     | string
 *     | {
 *         label: string
 *         format: (val: any) => string
 *       }
 * }} def
 * @returns {{ label: string; name: string; value: any; path: string }[]}
 */


const macroToItemArrayBase = (object, basePath, def) => {
  const toReturn = [];

  for (const key in object) {
    const match = def[key];
    const rawValue = object[key];
    toReturn.push({
      name: key,
      path: "".concat(basePath, ".").concat(key),
      value: match && match.format ? match.format(rawValue) : defaultFormat(rawValue),
      label: match && match.label || match || (0, _textFormat.capitalize)(key)
    });
  }

  return toReturn;
};

exports.macroToItemArrayBase = macroToItemArrayBase;