Exemplo n.º 1
0
        /// <summary>
        /// 使用CLIPS推理引擎进行推理
        /// </summary>
        /// <param name="strRuleLevel"></param>
        /// <param name="lstDataModelForIE"></param>
        /// <param name="oIEOutputInfo"></param>
        /// <returns></returns>
        public static bool ReasonWithCLIPSEngine(string strRuleLevel, List <vMRClsDef.DataModel> lstDataModelForIE,
                                                 ref vMRClsDef.OutputInfo oIEOutputInfo)
        {
            //ClipsEngine oClipsEngine = new ClipsEngine();
            oClipsEngine.Clear();
            List <vMRClsDef.DataModel> lstNewFact = new List <vMRClsDef.DataModel>();

            FactObtain.ObtainConcludeWithEvent(oIEOutputInfo.oTriggeringEvent.oEvent.strEventName, ref lstNewFact);
            if (oIEOutputInfo.oTriggeringEvent.m_emInferenceType
                == vMRClsDef.EnumInferenceType.PRIMARY)
            {
                oClipsEngine.DoInference(strRuleLevel, lstDataModelForIE, ref lstNewFact, oIEOutputInfo.oTriggeringEvent);
                InferenceResultConstruct.ConstructInferResult(oClipsEngine.InferResult, lstNewFact, ref oIEOutputInfo);
                return(true);
            }
            else if (oIEOutputInfo.oTriggeringEvent.m_emInferenceType
                     == vMRClsDef.EnumInferenceType.SECONDTIME)
            {
                //GoOnInference();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public static void FormatResult(vMRClsDef.InputDataModel oIEInputDataModel, vMRClsDef.OutputInfo oOutputInfo)
        {
            switch (oOutputInfo.oTriggeringEvent.m_emInferenceResultType)
            {
            case vMRClsDef.EnumInferenceResultType.DIAGNOSIS:
                FormatDiagnosiResult(oIEInputDataModel, oOutputInfo);
                //FormatExplanation(oIEInputDataModel, oOutputInfo);
                break;

            //case vMRClsDef.EnumInferenceResultType.MSEVALUATION:
            //    FormatMSEvaluationResult(oOutputInfo);
            //    break;
            //case vMRClsDef.EnumInferenceResultType.THERAPY:
            //    FormatTherpayResult(oIEInputDataModel, oOutputInfo);
            //    break;
            //case vMRClsDef.EnumInferenceResultType.SELFMONITOR:
            //    FormatSelfMonitorResult(oIEInputDataModel, oOutputInfo);
            //    break;
            //case vMRClsDef.EnumInferenceResultType.RISKEVALUATION:
            //    FormatMSRiskEvaluationResult(oOutputInfo);
            //    break;
            //case vMRClsDef.EnumInferenceResultType.DIETARY:
            //    FormatDietary(oIEInputDataModel, oOutputInfo);
            //    break;
            //case vMRClsDef.EnumInferenceResultType.PHYSICALACTIVITY:
            //    FormatPhysicalActivity(oIEInputDataModel, oOutputInfo);
            //    break;
            default:
                break;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 调用推理引擎进行推理
 /// </summary>
 /// <param name="oRoles"></param>
 /// <param name="lstDataModelForIE"></param>
 /// <param name="oIEOutputInfo"></param>
 /// <returns></returns>
 public static bool BeginInference(
     vMRClsDef.Role oRoles,
     List <vMRClsDef.DataModel> lstDataModelForIE,
     ref vMRClsDef.OutputInfo oIEOutputInfo)
 {
     ForwardsInference(oRoles, lstDataModelForIE, ref oIEOutputInfo);
     BackwardsInference();
     return(true);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 推理引擎端决策代理服务具体实现,UI端调用
 /// </summary>
 /// <param name="oIEvMRInputDataValue"></param>
 /// <param name="oIEvMROutput"></param>
 /// <returns></returns>
 public static bool vMRDataValueFromUItoIE(vMRClsDef.IEvMRInput oIEvMRInputDataValue, ref vMRClsDef.IEvMROutput oIEvMROutput)
 {
     oIEvMROutput.oRoles = oIEvMRInputDataValue.oRoles;
     foreach (vMRClsDef.InputDataModel oInputDataModel in oIEvMRInputDataValue.lstInputDataModel)
     {
         List <vMRClsDef.DataModel> lstDataModelForIE = new List <vMRClsDef.DataModel>();
         vMRClsDef.OutputInfo       oIEOutputInfo     = new vMRClsDef.OutputInfo();
         FactConstruct.FormFactInDataModel(oInputDataModel, ref lstDataModelForIE);
         oIEOutputInfo.oTriggeringEvent = oInputDataModel.oTriggeringEvent;
         InferenceService.BeginInference(oIEvMROutput.oRoles, lstDataModelForIE, ref oIEOutputInfo);
         ExplanationService.BeginExplanation();
         oIEvMROutput.lstOutputInfo.Add(oIEOutputInfo);
     }
     return(true);
 }
Exemplo n.º 5
0
        /// <summary>
        /// 正向推理
        /// </summary>
        /// <param name="oRoles"></param>
        /// <param name="lstDataModelForIE"></param>
        /// <param name="oIEOutputInfo"></param>
        /// <returns></returns>
        public static bool ForwardsInference(
            vMRClsDef.Role oRoles,
            List <vMRClsDef.DataModel> lstDataModelForIE,
            ref vMRClsDef.OutputInfo oIEOutputInfo)
        {
            string strRuleLevel = ChooseRuleLevelWithRole(oRoles);

            if (strRuleLevel != string.Empty)
            {
                return(ReasonWithCLIPSEngine(strRuleLevel, lstDataModelForIE, ref oIEOutputInfo));
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 6
0
        public static int DiseaseInfoExisted(vMRClsDef.OutputInfo oOutputInfo)
        {
            for (int i = 0; i < GlobalData.DiagnosedResult.DiseaseDiagnosedResultList.Count; i++)
            {
                if (GlobalData.DiagnosedResult.DiseaseDiagnosedResultList[i].Name == oOutputInfo.oTriggeringEvent.oDisease.strDiseaseCNName)
                {
                    return(i);
                }
            }

            CDSSOneDiseaseDiagnosedResult oOneDiseaseDiagnosedResult = new CDSSOneDiseaseDiagnosedResult();

            oOneDiseaseDiagnosedResult.Name = oOutputInfo.oTriggeringEvent.oDisease.strDiseaseCNName;
            GlobalData.DiagnosedResult.DiseaseDiagnosedResultList.Add(oOneDiseaseDiagnosedResult);

            return(GlobalData.DiagnosedResult.DiseaseDiagnosedResultList.Count - 1);
        }
Exemplo n.º 7
0
        public static string ObtainEventCNNamewithEventName(vMRClsDef.OutputInfo oOutputInfo)
        {
            if (lstTriggeringEvents.Count == 0)
            {
                ObtainTriggeringEventListFromCLIPSDataModel();
            }

            foreach (vMRClsDef.TriggeringEvent oTriggeringEvent in  lstTriggeringEvents)
            {
                if (oOutputInfo.oTriggeringEvent.oEvent.strEventName == oTriggeringEvent.oEvent.strEventName)
                {
                    return(oTriggeringEvent.oEvent.strEventCNName);
                }
            }

            return(string.Empty);
        }
Exemplo n.º 8
0
        public static void ConstructInferResult(ClipsEngine.Result oClipsInferResult,
                                                List <vMRClsDef.DataModel> lstNewFact, ref vMRClsDef.OutputInfo oOutputInfo)
        {
            //触发事件的中文名信息获取
            oOutputInfo.oTriggeringEvent.oEvent.strEventCNName = ClipsFactObtain.ObtainEventCNNamewithEventName(oOutputInfo);
            //诊断或治疗结构化推理结论
            oOutputInfo.oInference.lstStructedInferMessage.AddRange(lstNewFact);

            //诊断、治疗和自我监测非结构化推理结论
            for (int i = 0; i < oClipsInferResult.Recommendations.Count; i++)
            {
                vMRClsDef.UnStructMessage oRecommendation = new vMRClsDef.UnStructMessage();
                oRecommendation.strUnStructMessage = oClipsInferResult.Recommendations[i];
                oOutputInfo.oInference.lstUnstructedInferenceMessage.Add(oRecommendation);
            }

            //推理所缺数据
            for (int j = 0; j < oClipsInferResult.DataNotice.Data.Count; j++)
            {
                vMRClsDef.DataModel oShortDataModel = new vMRClsDef.DataModel();
                oShortDataModel.strDataName   = oClipsInferResult.DataNotice.Data[j];
                oShortDataModel.strDataCNName = ClipsFactObtain.ObtainDataCNNamewithDataName(oOutputInfo, oShortDataModel.strDataName);
                oOutputInfo.lstShortDataModel.Add(oShortDataModel);
            }

            //解释过程
            for (int k = 0; k < oClipsInferResult.lstInInterpretation.Count; k++)
            {
                ExplanationService.ConstructExplanation(oClipsInferResult.lstInInterpretation[k], ref oOutputInfo);
            }
        }
Exemplo n.º 9
0
 public static void FormatShortDataInfo(vMRClsDef.InputDataModel oIEInputDataModel, vMRClsDef.OutputInfo oOutputInfo, ref string strExistShortData)
 {
     //string strShortData = string.Empty;
     for (int i = 0; i < oOutputInfo.lstShortDataModel.Count; i++)
     {
         string strDataName = oOutputInfo.lstShortDataModel[i].strDataName;
         foreach (vMRClsDef.DataModel oDataModel in oIEInputDataModel.lstDataModel)
         {
             //BugDB00005686 revised by wbf 2009-03-26
             if (oDataModel.strDataName == strDataName)
             {
                 if (!strExistShortData.Contains(oDataModel.strDataCNName))
                 {
                     strExistShortData += oDataModel.strDataCNName + " ";
                 }
             }
         }
     }
 }
Exemplo n.º 10
0
        public static void FormatDiagnosiResult(vMRClsDef.InputDataModel oIEInputDataModel, vMRClsDef.OutputInfo oOutputInfo)
        {
            int iResultIndex = DiseaseInfoExisted(oOutputInfo);

            string result    = string.Empty;
            string tmpresult = string.Empty;

            for (int i = 0; i < oOutputInfo.oInference.lstStructedInferMessage.Count; i++)
            {
                tmpresult = oOutputInfo.oInference.lstStructedInferMessage[i].strDataValue;

                if (tmpresult != "")
                {
                    result = result + MapStructedInfoToCN(tmpresult) + " ";
                }
            }
            GlobalData.DiagnosedResult.DiseaseDiagnosedResultList[iResultIndex].Result = result;
            FormatShortDataInfo(oIEInputDataModel, oOutputInfo, ref GlobalData.DiagnosedResult.DiseaseDiagnosedResultList[iResultIndex].DataNeeded);
        }
Exemplo n.º 11
0
 public static string ObtainDataCNNamewithDataName(vMRClsDef.OutputInfo oOutputInfo, string strDataName)
 {
     return(string.Empty);
 }
Exemplo n.º 12
0
 public static void ConstructExplanation(ClipsEngine.Interpretation oClipsInterpration, ref vMRClsDef.OutputInfo oOutputInfo)
 {
     vMRClsDef.CLIPSInterpretation oIEInterpration = new vMRClsDef.CLIPSInterpretation();
     oIEInterpration.lstFactUsed.AddRange(oClipsInterpration.lstFactUsed);
     oIEInterpration.lstRecomm.AddRange(oClipsInterpration.lstRecomm);
     oIEInterpration.strInterpretationIndex = oClipsInterpration.strInterpretationIndex;
     oOutputInfo.oExplanation.lstClipsInterpretation.Add(oIEInterpration);
 }