예제 #1
0
        /// <summary>
        /// 切割
        /// </summary>
        /// <param name="advice"></param>
        /// <param name="maxItemWordCount"></param>
        /// <param name="maxDosageWordCount"></param>
        /// <returns></returns>
        private static Tuple <bool, string, string, string, string> GetSplitOrder(AdviceInfo advice, int maxItemWordCount, int maxDosageWordCount)
        {
            Tuple <bool, string, string, string, string> tuple = null;
            double itemNameLengthRecorder = 0.0;
            int    itemNameIndex          = 0;

            foreach (char charOfName in advice.ItemName)
            {
                if ((int)charOfName > 127)
                {
                    itemNameLengthRecorder += 1;
                }
                else
                {
                    itemNameLengthRecorder += 0.5;
                }
                itemNameIndex++;
                if (itemNameLengthRecorder >= maxItemWordCount - 0.5)
                {
                    break;
                }
            }
            //这里存在两种情况:一种是全部英文字母占多,实际不用换行。  一种是需要换行的。
            if (advice.ItemName.Length <= itemNameIndex + 2)
            {
                //不需要换行
                tuple = new Tuple <bool, string, string, string, string>(false, advice.ItemName, "", advice.Dosage, "");
            }
            else
            {
                string dosage1 = string.Empty;
                string dosage2 = string.Empty;
                if (advice.Dosage.Length > maxDosageWordCount)
                {
                    double dosageLengthRecorder = 0.0;
                    int    dosageIndex          = 0;
                    foreach (char charOfName in advice.Dosage)
                    {
                        if ((int)charOfName > 127)
                        {
                            dosageLengthRecorder += 1;
                        }
                        else
                        {
                            dosageLengthRecorder += 0.5;
                        }
                        dosageIndex++;
                        if (dosageLengthRecorder >= maxDosageWordCount - 0.5)
                        {
                            break;
                        }
                    }
                    if (advice.Dosage.Length <= dosageIndex + 1)
                    {
                        dosage1 = advice.Dosage;
                    }
                    else
                    {
                        dosage1 = advice.Dosage.Substring(0, dosageIndex + 1);
                        dosage2 = advice.Dosage.Substring(dosageIndex + 1);
                    }
                }
                else
                {
                    dosage1 = advice.Dosage;
                }
                tuple = new Tuple <bool, string, string, string, string>(true, advice.ItemName.Substring(0, itemNameIndex + 1), advice.ItemName.Substring(itemNameIndex + 1), dosage1, dosage2);
            }
            return(tuple);
        }
예제 #2
0
 /// <summary>
 /// 医嘱内容超长换行处理
 /// </summary>
 /// <remarks>
 /// 处理思路:
 /// 1.首先判断医嘱项目名称,如果全部字数不超过itemMaxWordCount的话,则不做换行处理,返回当前内容
 /// 2.如果名字超长,但是超长不多于2个字,一样不做换行处理
 /// </remarks>
 /// <param name="advice"></param>
 /// <param name="maxItemWordCount"></param>
 /// <param name="maxDosageWordCount"></param>
 /// <returns></returns>
 private static Tuple <bool, string, string, string, string> HandleOrderContent(AdviceInfo advice, int maxItemWordCount = 15, int maxDosageWordCount = 3)
 {
     if (advice.ItemName.Length > maxItemWordCount + 2)
     {
         //需要计算是否需要换行(理论这里是需要换行的,但是不排除存在英文名称的药品名称)
         return(GetSplitOrder(advice, maxItemWordCount, maxDosageWordCount));
     }
     else
     {
         return(new Tuple <bool, string, string, string, string>(false, advice.ItemName, "", advice.Dosage, ""));
     }
 }