111
This commit is contained in:
@@ -136,10 +136,28 @@ public static class TcmConstitutionRules
|
||||
public static TcmAssessmentResult Read(HealthProfile? profile)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(profile?.TcmResultJson)) return new TcmAssessmentResult();
|
||||
try { return JsonSerializer.Deserialize<TcmAssessmentResult>(profile.TcmResultJson) ?? new TcmAssessmentResult(); }
|
||||
try
|
||||
{
|
||||
var result = JsonSerializer.Deserialize<TcmAssessmentResult>(profile.TcmResultJson) ?? new TcmAssessmentResult();
|
||||
if (result.HasCompleted) result.MusicRecommendation = MusicFor(result.ConstitutionCode);
|
||||
return result;
|
||||
}
|
||||
catch { return new TcmAssessmentResult(); }
|
||||
}
|
||||
|
||||
private static string MusicFor(string constitutionCode) => constitutionCode switch
|
||||
{
|
||||
"balanced" or "yang_deficient" => "自然雨声",
|
||||
"qi_deficient" => "轻音乐",
|
||||
"yin_deficient" => "海浪白噪音",
|
||||
"phlegm_damp" => "规律鸟鸣白噪音",
|
||||
"damp_heat" => "自然流水声",
|
||||
"blood_stasis" => "低频舒缓音乐",
|
||||
"qi_stagnation" => "冥想古琴曲",
|
||||
"special" => "田野风声",
|
||||
_ => "自然雨声"
|
||||
};
|
||||
|
||||
public static TcmAssessmentResult Evaluate(TcmAssessmentInput input)
|
||||
{
|
||||
if (input?.Answers == null) throw Oops.Oh("请完成四诊问卷");
|
||||
@@ -158,17 +176,17 @@ public static class TcmConstitutionRules
|
||||
var notes = (input.Notes ?? new Dictionary<string, string>())
|
||||
.Where(item => new[] { "tongue", "odor", "breath", "pulseNote" }.Contains(item.Key))
|
||||
.ToDictionary(item => item.Key, item => (item.Value ?? "").Trim()[..Math.Min((item.Value ?? "").Trim().Length, 300)]);
|
||||
var (aroma, music, room, humidity, kelvin, fragrance, volume) = primary switch
|
||||
var (aroma, music, room, humidity, kelvin, fragrance) = primary switch
|
||||
{
|
||||
"qi_deficient" => ("清淡木香", "舒缓自然声", "22–25℃", 55, 3000, true, 14),
|
||||
"yang_deficient" => ("温暖木质香", "轻柔慢节奏", "24–26℃", 52, 2700, true, 14),
|
||||
"yin_deficient" => ("淡菊花香", "轻柔海浪声", "21–24℃", 48, 4000, true, 12),
|
||||
"phlegm_damp" => ("清新柑橘香", "舒缓雨声", "22–24℃", 45, 3500, true, 15),
|
||||
"damp_heat" => ("清淡薄荷香", "流水白噪音", "21–24℃", 45, 4000, true, 12),
|
||||
"blood_stasis" => ("淡花木香", "低频舒缓音乐", "23–25℃", 52, 3000, true, 14),
|
||||
"qi_stagnation" => ("清新柑橘香", "轻柔吉他曲", "22–25℃", 51, 3000, true, 14),
|
||||
"special" => ("建议不使用香氛,避免过敏原", "自然风声", "22–25℃", 50, 3500, false, 12),
|
||||
_ => ("淡雅薰衣草香", "自然雨声", "22–25℃", 50, 3000, true, 15)
|
||||
"qi_deficient" => ("清淡木香", "轻音乐", "22–25℃", 55, 3000, true),
|
||||
"yang_deficient" => ("温暖木质香", "自然雨声", "24–26℃", 52, 2700, true),
|
||||
"yin_deficient" => ("淡菊花香", "海浪白噪音", "21–24℃", 48, 4000, true),
|
||||
"phlegm_damp" => ("清新柑橘香", "规律鸟鸣白噪音", "22–24℃", 45, 3500, true),
|
||||
"damp_heat" => ("清淡薄荷香", "自然流水声", "21–24℃", 45, 4000, true),
|
||||
"blood_stasis" => ("淡花木香", "低频舒缓音乐", "23–25℃", 52, 3000, true),
|
||||
"qi_stagnation" => ("清新柑橘香", "冥想古琴曲", "22–25℃", 51, 3000, true),
|
||||
"special" => ("建议不使用香氛,避免过敏原", "田野风声", "22–25℃", 50, 3500, false),
|
||||
_ => ("淡雅薰衣草香", "自然雨声", "22–25℃", 50, 3000, true)
|
||||
};
|
||||
return new TcmAssessmentResult
|
||||
{
|
||||
@@ -191,7 +209,7 @@ public static class TcmConstitutionRules
|
||||
MattressHeatingLevel = 0, MattressLeftFirmness = 0, MattressRightFirmness = 0,
|
||||
MattressMode = "智能适配",
|
||||
EnableFragrance = fragrance && input.Answers["allergy"] != "often", FragranceLevel = 1,
|
||||
EnableSpeakerSleepMode = true, SpeakerVolumePercent = volume
|
||||
EnableSpeakerSleepMode = true, SpeakerVolumePercent = 60
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user