xkrs_ms/stdiet-ui/src/utils/healthyData.js
2021-03-15 20:53:32 +08:00

644 lines
18 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export const titleArray = [
"一、基础信息",
"二、减脂经历评估",
"三、食品安全评估",
"四、饮食结构评估",
"五、生活习惯评估",
"六、运动习惯评估",
"七、睡眠质量评估",
"八、既往病史/用药史评估",
"九、体检报告"
];
export const condimentArray = [
{ name: "鸡精", value: "1" },
{ name: "耗油", value: "2" },
{ name: "生抽", value: "3" },
{ name: "老抽", value: "4" },
{ name: "香油", value: "5" },
{ name: "浓汤宝", value: "6" },
{ name: "鸡粉", value: "7" },
{ name: "花椒", value: "8" },
{ name: "辣椒油", value: "9" }
];
export const cookingStyleArray = [
{ name: "煎", value: "1" },
{ name: "烤", value: "2" },
{ name: "炸", value: "3" },
{ name: "卤", value: "4" },
{ name: "腌", value: "5" },
{ name: "腊", value: "6" },
{ name: "煲", value: "7" },
{ name: "炒", value: "8" },
{ name: "蒸", value: "9" },
{ name: "刺身", value: "10" },
{ name: "水煮", value: "11" }
];
export const washVegetablesStyleArray = [
{ name: "先切后洗", value: "1" },
{ name: "先洗后切", value: "2" },
{ name: "切后浸泡", value: "3" }
];
export const breakfastTypeArray = [
{ name: "不吃", value: "1" },
{ name: "偶尔吃", value: "2" },
{ name: "每天吃", value: "3" }
];
export const lunchTypeArray = [
{ name: "外卖", value: "1" },
{ name: "自带餐", value: "2" },
{ name: "快餐", value: "3" },
{ name: "餐厅", value: "4" }
];
export const dinnerArray = [
{ name: "餐馆吃", value: "1" },
{ name: "在家吃", value: "2" },
{ name: "丰盛", value: "3" },
{ name: "清淡", value: "4" }
];
export const dietHotAndColdArray = [
{ name: "偏冷食", value: "1" },
{ name: "偏热食", value: "2" },
{ name: "正常", value: "3" }
];
export const dietFlavorArray = [
{ name: "偏油", value: "1" },
{ name: "偏咸", value: "2" },
{ name: "偏辣", value: "3" },
{ name: "偏甜", value: "4" },
{ name: "偏酸", value: "5" },
{ name: "清淡", value: "6" }
];
export const vegetablesRateTypeArray = [
{ name: "每天吃", value: "1" },
{ name: "经常吃", value: "2" },
{ name: "偶尔吃", value: "3" },
{ name: "从不吃", value: "4" }
];
export const fruitsTimeArray = [
{ name: "餐前", value: "1" },
{ name: "餐后", value: "2" },
{ name: "餐间", value: "3" }
];
export const fruitsRateArray = [
{ name: "每天吃", value: "1" },
{ name: "经常吃", value: "2" },
{ name: "偶尔吃", value: "3" },
{ name: "从不吃", value: "4" }
];
export const eatingSpeedArray = [
{ name: "很快", value: "1" },
{ name: "偏快", value: "2" },
{ name: "正常", value: "3" },
{ name: "偏慢", value: "4" },
{ name: "很慢", value: "5" }
];
export const snacksArray = [
{ name: "面包", value: "1" },
{ name: "蛋糕", value: "2" },
{ name: "饼干", value: "3" },
{ name: "冰淇淋", value: "4" },
{ name: "糖果", value: "5" },
{ name: "巧克力", value: "6" },
{ name: "方便面", value: "7" },
{ name: "薯条", value: "8" },
{ name: "肉干", value: "9" },
{ name: "坚果", value: "10" },
{ name: "饮料", value: "11" },
{ name: "果脯", value: "12" },
{ name: "牛奶", value: "13" }
];
export const waterTypeArray = [
{ name: "冰水", value: "1" },
{ name: "温水", value: "2" },
{ name: "常温水", value: "3" }
];
export const waterHabitArray = [
{ name: "均匀地喝", value: "1" },
{ name: "餐前多喝", value: "2" },
{ name: "餐后多喝", value: "3" },
{ name: "餐间多喝", value: "4" },
{ name: "随时喝", value: "5" }
];
export const drinkWineFlagArray = [
{ name: "经常饮酒", value: "1" },
{ name: "不饮酒", value: "2" },
{ name: "偶尔", value: "3" }
];
export const drinkWineClassifyArray = [
{ name: "白酒", value: "1" },
{ name: "红酒", value: "2" },
{ name: "啤酒", value: "3" }
];
export const workTypeArray = [
{ name: "工作时间长", value: "1" },
{ name: "久坐", value: "2" },
{ name: "久站", value: "3" },
{ name: "走动多", value: "4" },
{ name: "强度大", value: "5" },
{ name: "用电脑多", value: "6" },
{ name: "体力工作多", value: "7" }
];
export const defecationTimeArray = [
{ name: "上午", value: "1" },
{ name: "中午", value: "2" },
{ name: "晚上", value: "3" }
];
export const aerobicMotionClassifyArray = [
{ name: "跳绳", value: "1" },
{ name: "跑步", value: "2" },
{ name: "游泳", value: "3" }
];
export const anaerobicMotionClassifyArray = [
{ name: "撸铁", value: "1" },
{ name: "俯卧撑", value: "2" }
];
export const anaerobicAerobicMotionClassifyArray = [
{ name: "拳击", value: "1" },
{ name: "瑜伽", value: "2" }
];
export const motionFieldArray = [
{ name: "居家", value: "1" },
{ name: "健身房", value: "2" },
{ name: "户外", value: "3" },
{ name: "瑜伽馆", value: "4" }
];
export const sleepQualityArray = [
{ name: "好", value: "1" },
{ name: "一般", value: "2" },
{ name: "入睡难", value: "3" },
{ name: "失眠", value: "4" },
{ name: "易醒", value: "5" },
{ name: "多梦", value: "6" }
];
export const familyIllnessHistoryArray = [
{ name: "高血压病", value: "1" },
{ name: "脑卒中", value: "2" },
{ name: "冠心病", value: "3" },
{ name: "外周血管病", value: "4" },
{ name: "心力衰竭", value: "5" },
{ name: "糖尿病", value: "6" },
{ name: "肥胖症", value: "7" },
{ name: "慢性肾脏疾病", value: "8" },
{ name: "骨质疏松", value: "9" },
{ name: "痛风", value: "10" },
{ name: "精神疾病", value: "11" },
{ name: "恶性肿瘤", value: "12" },
{ name: "慢性阻塞性肺病", value: "13" },
{ name: "风湿性免疫性疾病", value: "14" }
];
export const operationHistoryArray = [
{ name: "头颅(含脑)", value: "1" },
{ name: "眼", value: "2" },
{ name: "耳鼻咽喉", value: "3" },
{ name: "颌面部及口腔", value: "4" },
{ name: "颈部或甲状腺", value: "5" },
{ name: "胸部(含肺部)", value: "6" },
{ name: "心脏(含心脏介入)", value: "7" },
{ name: "外周血管", value: "8" },
{ name: "胃肠", value: "9" },
{ name: "肝胆", value: "10" },
{ name: "肾脏", value: "11" },
{ name: "脊柱", value: "12" },
{ name: "四肢及关节", value: "13" },
{ name: "前列腺", value: "14" },
{ name: "妇科", value: "15" },
{ name: "乳腺", value: "16" },
{ name: "膀胱", value: "17" }
];
export const longEatDrugClassifyArray = [
{ name: "降压药", value: "1" },
{ name: "降糖药", value: "2" },
{ name: "降尿酸药", value: "3" },
{ name: "抗心律失常药", value: "4" },
{ name: "缓解哮喘药物", value: "5" },
{ name: "抗压郁药物", value: "6" },
{ name: "雌激素类药物", value: "7" },
{ name: "利尿剂", value: "8" },
{ name: "中草药", value: "9" },
{ name: "避孕药", value: "10" },
{ name: "强的松类药物", value: "11" },
{ name: "镇静剂或安眠药", value: "12" },
{ name: "调值药(降脂药)", value: "13" },
{ name: "解热镇痛药(如布洛芬等)", value: "14" }
];
export const allergenArray = [
{ name: "青霉素", value: "1" },
{ name: "磺胺类", value: "2" },
{ name: "链霉素", value: "3" },
{ name: "头孢类", value: "4" },
{ name: "鸡蛋", value: "5" },
{ name: "牛奶", value: "6" },
{ name: "海鲜", value: "7" },
{ name: "花粉或尘螨", value: "8" },
{ name: "粉尘", value: "9" },
{ name: "洗洁剂", value: "10" },
{ name: "化妆品", value: "11" }
];
export const makeFoodTypeArray = [
{ name: "居家做饭", value: "1" },
{ name: "外卖食堂", value: "2" },
{ name: "居家和外食", value: "3" },
{ name: "国外饮食", value: "4" },
{ name: "运动饮食", value: "5" }
];
export const yesNoDict = { 0: "否", 1: "是" };
export const sexDict = { 0: "男", 1: "女" };
export const positionDict = { 0: "南方", 1: "北方" };
export const makeFoodTypeDict = { 0: "自己做", 1: "外面吃" };
export const makeFoodTasteDict = { 0: "清淡", 1: "重口味" };
export const walkDict = { 0: "久坐多", 1: "走动多" };
export const cookingStyleRateArray = ["煎", "炸", "卤", "腌", "腊", "煲"];
export const cookingStyleRateUnitArray = cookingStyleRateArray.map(() => "次");
export const drinksNumArray = [
"老火汤",
"咖啡",
"浓茶",
"奶茶",
"冷饮",
"碳酸饮料",
"甜饮料",
"鲜榨果汁"
];
export const drinksNumUnitArray = drinksNumArray.map(() => "次");
export const drinkWineAmountArray = ["白酒", "啤酒", "红酒"];
export const drinkWineAmountUnitArray = ["两", "瓶", "毫升"];
export const smokeRateArray = ["每天抽烟", "烟龄", "已戒烟"];
export const smokeRateUnitArray = ["次", "年", "年"];
//需要将数组转成字符串的属性名称,包含对象数组、字符串数组
export const arrayName = [
"condiment",
"cookingStyle",
"cookingStyleRate",
"washVegetablesStyle",
"lunchType",
"dinner",
"dietFlavor",
"snacks",
"waterType",
"waterHabit",
"drinksNum",
"drinkWineClassify",
"drinkWineAmount",
"smokeRate",
"workType",
"defecationTime",
"aerobicMotionClassify",
"anaerobicMotionClassify",
"anaerobicAerobicMotionClassify",
"motionField",
"sleepQuality",
"physicalSignsId",
"moistureDate",
"bloodData",
"familyIllnessHistory",
"operationHistory",
"longEatDrugClassify",
"allergen",
"medicalReport",
"medicalReportName"
];
//需要将数字下标转成中文含义的属性名
export const needAttrName = [
"condiment",
"cookingStyle",
"washVegetablesStyle",
"breakfastType",
"lunchType",
"dinner",
"dietFlavor",
"vegetablesRateType",
"dietHotAndCold",
"fruitsTime",
"fruitsRate",
"eatingSpeed",
"snacks",
"waterType",
"waterHabit",
"drinkWineFlag",
"drinkWineClassify",
"workType",
"defecationTime",
"aerobicMotionClassify",
"anaerobicMotionClassify",
"anaerobicAerobicMotionClassify",
"motionField",
"sleepQuality",
"familyIllnessHistory",
"operationHistory",
"longEatDrugClassify",
"allergen"
];
export const needCombineName = [
"cookingStyleRate",
"drinksNum",
"drinkWineAmount",
"smokeRate"
];
export const yesNoName = [
"constipation",
"staylate",
"motion",
"night",
"weakness",
"rebound",
"crux",
"stayupLateFlag",
"nearOperationFlag",
"longEatDrugFlag",
"allergyFlag",
"smokeFlag",
"secondSmoke",
"sleepDrugFlag"
];
export const dictName = [
"sex",
"position",
"makeFoodType",
"makeFoodTaste",
"walk"
];
export const newLineName = ["bloodData", "moistureDate"];
export const bloodDataArray = [
{ value: "1", name: "1.体质虚弱,免疫力差" },
{ value: "2", name: "2.畏寒肢冷,自汗,头晕耳鸣" },
{ value: "3", name: "3.心悸气短,神疲乏力,气短懒言" },
{ value: "4", name: "4.失眠多梦,健忘,精神恍惚" },
{ value: "5", name: "5.面色淡白或萎黄,皮肤干燥,毛发枯萎" },
{ value: "6", name: "6.女性月经量少,延期或闭经" },
{ value: "7", name: "7.唇甲色淡,舌淡脉虚" }
];
export const moistureDateArray = [
{ value: "1", name: "1.头发爱出油,头一天刚洗头第二天就油油的" },
{ value: "2", name: "2.面部油亮" },
{ value: "3", name: "3.睡觉流口水" },
{ value: "4", name: "4.排便粘稠且多便" },
{ value: "5", name: "5.小肚子大" },
{ value: "6", name: "6.耳内湿" },
{ value: "7", name: "7.头重脚轻" },
{ value: "8", name: "8.头晕没精神,特别疲劳" },
{ value: "9", name: "9.经常感觉很累很困,怎么都睡不够" }
];
const moduleObj = {
condimentArray,
cookingStyleArray,
washVegetablesStyleArray,
breakfastTypeArray,
lunchTypeArray,
dinnerArray,
dietHotAndColdArray,
dietFlavorArray,
vegetablesRateTypeArray,
fruitsTimeArray,
fruitsRateArray,
eatingSpeedArray,
snacksArray,
waterTypeArray,
waterHabitArray,
drinkWineFlagArray,
drinkWineClassifyArray,
workTypeArray,
defecationTimeArray,
aerobicMotionClassifyArray,
anaerobicMotionClassifyArray,
anaerobicAerobicMotionClassifyArray,
motionFieldArray,
sleepQualityArray,
familyIllnessHistoryArray,
operationHistoryArray,
longEatDrugClassifyArray,
allergenArray,
makeFoodTypeArray,
//
cookingStyleRateArray,
cookingStyleRateUnitArray,
drinksNumArray,
drinksNumUnitArray,
drinkWineAmountArray,
drinkWineAmountUnitArray,
smokeRateArray,
smokeRateUnitArray,
//
yesNoDict,
sexDict,
positionDict,
makeFoodTypeDict,
makeFoodTasteDict,
walkDict,
//
bloodDataArray,
moistureDateArray
};
//健康信息处理,将数组转为字符串
export function dealHealthy(customerHealthy) {
customerHealthy.basicBMR = (
(10 * customerHealthy.weight) / 2 +
6.25 * customerHealthy.tall -
5 * customerHealthy.age -
customerHealthy.sex * 161
).toFixed(1);
customerHealthy.notSportHeat = (customerHealthy.basicBMR * 1.3).toFixed(1);
customerHealthy.basicBMR += "千卡";
customerHealthy.notSportHeat += "千卡";
const lowRecProtein = customerHealthy.tall - 105;
customerHealthy.recProtein = `${(lowRecProtein * 0.8).toFixed(1)} - ${(
lowRecProtein * 1.5
).toFixed(1)}`;
needAttrName.forEach(name => {
if (customerHealthy.hasOwnProperty(name)) {
customerHealthy[name] = (String(customerHealthy[name]) || "")
.split(",")
.map(val => {
const tarObj = moduleObj[`${name}Array`].find(
obj => obj.value === val
);
if (tarObj) {
return tarObj.name;
}
return "";
})
.join("");
}
});
needCombineName.forEach(name => {
if (customerHealthy.hasOwnProperty(name)) {
customerHealthy[name] = (String(customerHealthy[name]) || "")
.split(",")
.map((val, idx) => {
return `${moduleObj[`${name}Array`][idx]}${val}${
moduleObj[`${name}UnitArray`][idx]
}`;
})
.join("");
}
});
newLineName.forEach(name => {
if (customerHealthy.hasOwnProperty(name)) {
customerHealthy[name] = (String(customerHealthy[name]) || "")
.split(",")
.map(val => {
const tarObj = moduleObj[`${name}Array`].find(
obj => obj.value === val
);
if (tarObj) {
return tarObj.name;
}
return "";
})
.join("</br>");
}
});
yesNoName.forEach(name => {
if (customerHealthy.hasOwnProperty(name)) {
customerHealthy[name] = yesNoDict[customerHealthy[name]];
}
});
dictName.forEach(name => {
if (customerHealthy.hasOwnProperty(name)) {
customerHealthy[name] = moduleObj[`${name}Dict`][customerHealthy[name]];
}
});
if (customerHealthy.hasOwnProperty("physicalSignsId")) {
const signs = customerHealthy.otherPhysicalSigns
? [customerHealthy.otherPhysicalSigns]
: [];
customerHealthy.signList.forEach(obj => {
signs.push(obj.name);
});
customerHealthy.physicalSigns = signs.join(",");
}
if (customerHealthy.hasOwnProperty("otherLongEatDrugClassify")) {
customerHealthy.longEatDrugClassify += customerHealthy.otherLongEatDrugClassify
? `${customerHealthy.otherLongEatDrugClassify}`
: "";
}
if (customerHealthy.hasOwnProperty("washVegetablesStyle")) {
customerHealthy.washVegetablesStyle += customerHealthy.otherWashVegetablesStyle
? `${customerHealthy.otherWashVegetablesStyle}`
: "";
}
if (customerHealthy.hasOwnProperty("snacks")) {
customerHealthy.snacks += customerHealthy.otherSnacks
? `${customerHealthy.otherSnacks}`
: "";
}
if (customerHealthy.hasOwnProperty("healthProductsWeekRate")) {
customerHealthy.healthProductsWeekRate =
customerHealthy.healthProductsDayRate +
"次/天," +
customerHealthy.healthProductsWeekRate +
"次/周";
}
if (customerHealthy.hasOwnProperty("drinkWineClassify")) {
customerHealthy.drinkWineClassify += customerHealthy.otherWineClassify
? `${customerHealthy.otherWineClassify}`
: "";
}
if (customerHealthy.hasOwnProperty("otherMotionClassify")) {
let motionStr = customerHealthy.aerobicMotionClassify
? `${customerHealthy.aerobicMotionClassify}`
: "";
motionStr += customerHealthy.anaerobicMotionClassify
? `${customerHealthy.anaerobicMotionClassify}`
: "";
motionStr += customerHealthy.anaerobicAerobicMotionClassify
? `${customerHealthy.anaerobicAerobicMotionClassify}`
: "";
motionStr += customerHealthy.otherMotionClassify
? `${customerHealthy.otherMotionClassify}`
: "";
customerHealthy.motion = motionStr;
}
if (customerHealthy.hasOwnProperty("motionField")) {
customerHealthy.motionField += customerHealthy.otherMotionField
? `${customerHealthy.otherMotionField}`
: "";
}
if (customerHealthy.hasOwnProperty("otherOperationHistory")) {
customerHealthy.operationHistory += customerHealthy.otherOperationHistory
? `${customerHealthy.otherOperationHistory}`
: "";
}
if (customerHealthy.hasOwnProperty("defecationNum")) {
customerHealthy.defecationNum += "次/天";
}
if (customerHealthy.hasOwnProperty("motionDuration")) {
customerHealthy.motionDuration += "分钟";
}
if (customerHealthy.hasOwnProperty("tall")) {
customerHealthy.tall += "cm";
}
if (customerHealthy.hasOwnProperty("weight")) {
customerHealthy.weight += "斤";
}
if (customerHealthy.hasOwnProperty("vegetableRate")) {
customerHealthy.vegetableRate += "成";
}
if (customerHealthy.hasOwnProperty("stayupLateWeekNum")) {
customerHealthy.stayupLateWeekNum += "次/周";
}
if (customerHealthy.hasOwnProperty("riceFull")) {
customerHealthy.riceFull += "成";
}
if (customerHealthy.hasOwnProperty("connectTime")) {
customerHealthy.connectTime += "点";
}
if (customerHealthy.hasOwnProperty("sleepTime")) {
customerHealthy.sleepTime += "点";
}
if (customerHealthy.hasOwnProperty("getupTime")) {
customerHealthy.getupTime += "点";
}
if (customerHealthy.hasOwnProperty("signList")) {
customerHealthy.signStr = (customerHealthy.signList || [])
.map(obj => obj.name)
.join("");
}
return customerHealthy;
}