コード例 #1
0
ファイル: Rhinitis.cs プロジェクト: ourworldcn/CnMedicine
        /// <summary>
        /// 获取诊断的详细信息。
        /// </summary>
        /// <returns></returns>
        public string GetDescription()
        {
            StringBuilder sb = new StringBuilder();
            string        result;

            sb.AppendLine($"诊断: ({string.Join(";", RhinitisConversions.Select(c => c.ToString()))}) ");
            sb.AppendLine($"脏腑评分:{string.Join(";", MaxVicerals.Select(c => c.ToString()))};症候评分:{string.Join(";", MaxPhenomenons.Select(c => c.ToString()))};病机评分:{string.Join(";", Pathogens.Select(c => c.ToString()))}");
            result = sb.ToString();
            return(result);
        }
コード例 #2
0
ファイル: Rhinitis.cs プロジェクト: ourworldcn/CnMedicine
        /// <summary>
        /// 刷新药物输出表的项。
        /// </summary>
        private void RefreshRhinitisCnDrugConversions()
        {
            if (null == _RhinitisCnDrugConversions)
            {
                _RhinitisCnDrugConversions = new List <RhinitisCnDrugConversion>();
            }
            else
            {
                _RhinitisCnDrugConversions.Clear();
            }
            HashSet <string> hsViscerals   = new HashSet <string>(RhinitisConversions.SelectMany(c => c.CnVisceralProperties).Select(c => c.Item1)); //如果 collection 包含重复的元素,该集将包含一个唯一的每个元素。
            HashSet <string> hsPhenomenons = new HashSet <string>(RhinitisConversions.SelectMany(c => c.CnPhenomenonProperties).Select(c => c.Item1));
            HashSet <string> hsPathogens   = new HashSet <string>(RhinitisConversion.DefaultCollection.SelectMany(c => c.CnPathogenProperties).Select(c => c.Item1));

            //脏腑评分
            var VisceralScroes = RhinitisConversions.SelectMany(c => c.CnVisceralProperties);
            var visceralAry    = VisceralScroes.GroupBy(c => c.Item1).Select(c => Tuple.Create(c.Key, c.Sum(c1 => c1.Item2))).OrderByDescending(c => c.Item2).ToArray();
            var maxVisceral    = visceralAry.FirstOrDefault()?.Item2 ?? 0;

            //一定要和第二分值比较,鼻炎取前两分值,并列第一时,取并列第一值,不再取第二值
            decimal sendVisceral = 0;

            if (visceralAry.Length > 1)
            {
                sendVisceral = visceralAry[1]?.Item2 ?? 0;//第二个脏腑分
            }
            ;
            if (sendVisceral == maxVisceral) //并列第一
            {
                MaxVicerals = visceralAry.Where(c => c.Item2 >= maxVisceral).ToList();
            }
            else
            {
                MaxVicerals = visceralAry.Where(c => c.Item2 >= sendVisceral).ToList();
            }



            //症候评分
            var PhenomenonScores = RhinitisConversions.SelectMany(c => c.CnPhenomenonProperties);
            var phenomennoAry    = PhenomenonScores.GroupBy(c => c.Item1).Select(c => Tuple.Create(c.Key, c.Sum(c1 => c1.Item2))).OrderByDescending(c => c.Item2).ToArray();
            var maxPhenomenon    = phenomennoAry.FirstOrDefault()?.Item2 ?? 0;

            decimal sendPhenomenon = 0;

            if (phenomennoAry.Length > 1)
            {
                sendPhenomenon = phenomennoAry[1]?.Item2 ?? 0;//第二个症候分
            }
            ;
            if (sendPhenomenon == maxPhenomenon)
            {
                MaxPhenomenons = phenomennoAry.Where(c => c.Item2 >= maxPhenomenon).ToList();
                //数字逻辑上可能出现例如:心,肝并列第一;且风热,痰热并列第一。此时药物输出算作4个么?心-风热,心-痰热,肝-风热,肝-痰热,结算笛卡尔积
            }
            else
            {
                MaxPhenomenons = phenomennoAry.Where(c => c.Item2 >= sendPhenomenon).ToList();
            }

            //病机评分
            var PathogenScores = RhinitisConversions.SelectMany(c => c.CnPathogenProperties);
            var pathogennoAry  = PathogenScores.GroupBy(c => c.Item1).Select(c => Tuple.Create(c.Key, c.Sum(c1 => c1.Item2))).OrderByDescending(c => c.Item2).ToArray();

            Pathogens = pathogennoAry.Where(c => c.Item2 >= 0).ToList();


            var coll = from tmp in MaxVicerals
                       from tmp1 in MaxPhenomenons
                       select Tuple.Create(tmp.Item1, tmp1.Item1);  //无论如何先获取笛卡尔积

            _RhinitisCnDrugConversions.AddRange(RhinitisCnDrugConversion.DefaultCollection.Join(coll, c => Tuple.Create(c.CnMedicineVisceral, c.CnMedicinePhenomenon), c => c, (drug, c) => drug));
        }