Skip to content

Instantly share code, notes, and snippets.

@wujekbogdan
Created November 12, 2019 19:27
Show Gist options
  • Save wujekbogdan/c89226d55209a50a914f938b86a29170 to your computer and use it in GitHub Desktop.
Save wujekbogdan/c89226d55209a50a914f938b86a29170 to your computer and use it in GitHub Desktop.
measurements.js
import map from 'lodash/map';
import { MEASUREMENTS_SYMBOLS } from '@/helpers/nutrientSymbols';
import {
MASS_UNIT_KILOGRAM,
MASS_UNIT_POUND,
PERCENTAGE,
LENGTH_UNIT_CENTIMETER,
LENGTH_UNIT_INCH,
QUANTITY_UNIT_MG_DL,
QUANTITY_UNIT_MMOL_L,
FREQUENCY_UNIT_BPM,
PRESSURE_UNIT_MM_GH,
UNITS,
UNITLESS,
} from '@/helpers/units';
export const categories = {
CORE: 'core',
BODY: 'body',
HEALTH: 'health',
};
const { CORE, BODY, HEALTH } = categories;
export const UNITS_PROPERTIES = {
WEIGHT: 'weightUnits',
LENGTH: 'lengthUnits',
GLUCOSE: 'glucoseUnits',
KETONES: 'ketonesUnits',
};
/**
* @typedef {Object} Measurement
* @property {String[]} units
* @property {String} category
* @property {String} type
* @property {String} symbol
* @property {Object} options
* @property {String} measureProperty
* @property {String} unitsProperty
* @property {Boolean} supportsSequence
* @property {Boolean} isEditable
*/
/**
* @type {Object.<String, Measurement>}
*/
export const MEASUREMENTS = {
[MEASUREMENTS_SYMBOLS.SYMBOL_WEIGHT]: {
units: [MASS_UNIT_KILOGRAM, MASS_UNIT_POUND],
category: CORE,
type: 'weight',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_WEIGHT,
options: [],
measureProperty: 'weight',
unitsProperty: UNITS_PROPERTIES.WEIGHT,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_BMI]: {
units: [UNITLESS],
category: CORE,
type: 'bmi',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_BMI,
options: [],
measureProperty: 'bmi',
unitsProperty: null,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_BODY_FAT]: {
units: [PERCENTAGE],
category: CORE,
type: 'bodyFatPct',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_BODY_FAT,
options: [],
measureProperty: 'bodyFatPct',
unitsProperty: null,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_LBM]: {
units: [MASS_UNIT_KILOGRAM, MASS_UNIT_POUND],
category: CORE,
type: 'lbm',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_LBM,
options: [],
measureProperty: 'lbm',
unitsProperty: UNITS_PROPERTIES.WEIGHT,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_WAIST_SIZE]: {
units: [LENGTH_UNIT_CENTIMETER, LENGTH_UNIT_INCH],
category: BODY,
type: 'waistSize',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_WAIST_SIZE,
options: [],
measureProperty: 'waistSize',
unitsProperty: UNITS_PROPERTIES.LENGTH,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_HIP_SIZE]: {
units: [LENGTH_UNIT_CENTIMETER, LENGTH_UNIT_INCH],
category: BODY,
type: 'hipSize',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_HIP_SIZE,
options: [],
measureProperty: 'hipSize',
unitsProperty: UNITS_PROPERTIES.LENGTH,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_CHEST_SIZE]: {
units: [LENGTH_UNIT_CENTIMETER, LENGTH_UNIT_INCH],
category: BODY,
type: 'chestSize',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_CHEST_SIZE,
options: [],
measureProperty: 'chestSize',
unitsProperty: UNITS_PROPERTIES.LENGTH,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_NECK_SIZE]: {
units: [LENGTH_UNIT_CENTIMETER, LENGTH_UNIT_INCH],
category: BODY,
type: 'neckSize',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_NECK_SIZE,
options: [],
measureProperty: 'neckSize',
unitsProperty: UNITS_PROPERTIES.LENGTH,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_ARM_SIZE]: {
units: [LENGTH_UNIT_CENTIMETER, LENGTH_UNIT_INCH],
category: BODY,
type: 'armSize',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_ARM_SIZE,
options: [],
measureProperty: 'armSize',
unitsProperty: UNITS_PROPERTIES.LENGTH,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_FOREARM_SIZE]: {
units: [LENGTH_UNIT_CENTIMETER, LENGTH_UNIT_INCH],
category: BODY,
type: 'forearmSize',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_FOREARM_SIZE,
options: [],
measureProperty: 'forearmSize',
unitsProperty: UNITS_PROPERTIES.LENGTH,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_CALF_SIZE]: {
units: [LENGTH_UNIT_CENTIMETER, LENGTH_UNIT_INCH],
category: BODY,
type: 'calfSize',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_CALF_SIZE,
options: [],
measureProperty: 'calfSize',
unitsProperty: UNITS_PROPERTIES.LENGTH,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_THIGH_SIZE]: {
units: [LENGTH_UNIT_CENTIMETER, LENGTH_UNIT_INCH],
category: BODY,
type: 'thighSize',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_THIGH_SIZE,
options: [],
measureProperty: 'thighSize',
unitsProperty: UNITS_PROPERTIES.LENGTH,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_BLOOD_GLUCOSE]: {
units: [QUANTITY_UNIT_MG_DL, QUANTITY_UNIT_MMOL_L],
category: HEALTH,
type: 'glucose',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_BLOOD_GLUCOSE,
options: [],
measureProperty: 'glucose',
unitsProperty: UNITS_PROPERTIES.GLUCOSE,
supportsSequence: true,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_KETONES]: {
units: [QUANTITY_UNIT_MG_DL, QUANTITY_UNIT_MMOL_L],
category: HEALTH,
type: 'ketones',
measureProperty: 'ketonesMeasured',
unitsProperty: UNITS_PROPERTIES.KETONES,
supportsSequence: true,
isEditable: true,
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_KETONES,
options: UNITS.ketones,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_GKI]: {
units: [],
category: HEALTH,
type: 'GKI',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_GKI,
options: [],
measureProperty: 'GKI',
unitsProperty: null,
supportsSequence: false,
isEditable: false,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_INSULIN]: {
units: [UNITLESS],
category: HEALTH,
type: 'insulin',
measureProperty: 'insulinType',
unitsProperty: null,
supportsSequence: true,
isEditable: true,
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_INSULIN,
options: UNITS.insulin,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_T_CHOLE]: {
units: [QUANTITY_UNIT_MG_DL, QUANTITY_UNIT_MMOL_L],
category: HEALTH,
type: 'tChole',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_T_CHOLE,
options: [],
measureProperty: 'tChole',
unitsProperty: UNITS_PROPERTIES.GLUCOSE,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_LDL]: {
units: [QUANTITY_UNIT_MG_DL, QUANTITY_UNIT_MMOL_L],
category: HEALTH,
type: 'ldl',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_LDL,
options: [],
measureProperty: 'ldl',
unitsProperty: UNITS_PROPERTIES.GLUCOSE,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_HDL]: {
units: [QUANTITY_UNIT_MG_DL, QUANTITY_UNIT_MMOL_L],
category: HEALTH,
type: 'hdl',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_HDL,
options: [],
measureProperty: 'hdl',
unitsProperty: UNITS_PROPERTIES.GLUCOSE,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_TRIG]: {
units: [QUANTITY_UNIT_MG_DL, QUANTITY_UNIT_MMOL_L],
category: HEALTH,
type: 'trig',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_TRIG,
options: [],
measureProperty: 'trig',
unitsProperty: UNITS_PROPERTIES.GLUCOSE,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_HR]: {
units: [FREQUENCY_UNIT_BPM],
category: HEALTH,
type: 'hr',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_HR,
options: [],
measureProperty: 'hr',
unitsProperty: null,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_BP_SYS]: {
units: [PRESSURE_UNIT_MM_GH],
category: HEALTH,
type: 'bpSys',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_BP_SYS,
options: [],
measureProperty: 'bpSys',
unitsProperty: null,
supportsSequence: false,
isEditable: true,
},
[MEASUREMENTS_SYMBOLS.SYMBOL_BP_DIA]: {
units: [PRESSURE_UNIT_MM_GH],
category: HEALTH,
type: 'bpDia',
symbol: MEASUREMENTS_SYMBOLS.SYMBOL_BP_DIA,
options: [],
measureProperty: 'bpDia',
unitsProperty: null,
supportsSequence: false,
isEditable: true,
},
};
export const MEASUREMENT_TYPES = map(MEASUREMENTS, ({ type }) => type);
export const SEQUENCES = {
BEFORE: 'before',
AFTER: 'after',
FASTING: 'fasting',
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment