コード例 #1
0
        public ReturnValueClass getNextUIState()
        {
            //run the clips first
            clipsEnvironment.Run();
            ReturnValueClass returnValue = new ReturnValueClass();
            // Get the state-list.
            String evalStr = "(find-all-facts ((?f state-list)) TRUE)";

            using (FactAddressValue allFacts = (FactAddressValue)((MultifieldValue)clipsEnvironment.Eval(evalStr))[0])
            {
                string currentID = allFacts.GetFactSlot("current").ToString();
                evalStr = "(find-all-facts ((?f UI-state)) " +
                          "(eq ?f:id " + currentID + "))";
            }
            using (FactAddressValue evalFact = (FactAddressValue)((MultifieldValue)clipsEnvironment.Eval(evalStr))[0])
            {
                //get the state from clipse
                string state = evalFact.GetFactSlot("state").ToString();
                returnValue.State = state;
                using (MultifieldValue validAnswers = (MultifieldValue)evalFact.GetFactSlot("valid-answers"))
                {
                    for (int i = 0; i < validAnswers.Count; i++)
                    {
                        returnValue.validAnswers.Add((SymbolValue)validAnswers[i]);
                    }
                }
                returnValue.displayQuestion = GetString((SymbolValue)evalFact.GetFactSlot("display"));
            }
            return(returnValue);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: BlueMadWolf/IS
        private void HandleResponse()
        {
            //  Вытаскиаваем факт из ЭС
            String           evalStr = "(find-fact ((?f ioproxy)) TRUE)";
            FactAddressValue fv      = (FactAddressValue)((MultifieldValue)clips.Eval(evalStr))[0];

            MultifieldValue damf = (MultifieldValue)fv["messages"];
            MultifieldValue vamf = (MultifieldValue)fv["answers"];

            textBox2.Text += "Новая итерация : " + System.Environment.NewLine;
            for (int i = 0; i < damf.Count; i++)
            {
                LexemeValue da    = (LexemeValue)damf[i];
                byte[]      bytes = Encoding.Default.GetBytes(da.Value);
                textBox2.Text += Encoding.UTF8.GetString(bytes) + System.Environment.NewLine;
            }

            if (vamf.Count > 0)
            {
                textBox2.Text += "----------------------------------------------------" + System.Environment.NewLine;
                for (int i = 0; i < damf.Count; i++)
                {
                    LexemeValue va = (LexemeValue)vamf[i];
                    textBox2.Text += va.Value + System.Environment.NewLine;
                }
            }

            clips.Eval("(assert (clearmessage))");
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: implikacja/CLIPS
        private void NextUIState()
        {
            String           evalStr = "(find-fact ((?f UI-state)) TRUE)";
            FactAddressValue fv      = (FactAddressValue)((MultifieldValue)clips.Eval(evalStr))[0];


            if (fv.GetFactSlot("state").ToString().Equals("final"))
            {
                nextButton.Tag          = "Restart";
                nextButton.Content      = "Restart";
                choicesPanel.Visibility = Visibility.Collapsed;
            }
            else if (fv.GetFactSlot("state").ToString().Equals("initial"))
            {
                nextButton.Tag          = "Next";
                nextButton.Content      = "Next >";
                choicesPanel.Visibility = Visibility.Collapsed;
            }
            else
            {
                nextButton.Tag          = "Next";
                nextButton.Content      = "Next >";
                choicesPanel.Visibility = Visibility.Visible;
            }

            choicesPanel.Children.Clear();

            relationAsserted = fv.GetFactSlot("relation-asserted").ToString();

            if (relationAsserted == lastRelationAsserted)
            {
                clips.Run(1);
                NextUIState();
                return;
            }

            lastRelationAsserted = relationAsserted;

            MultifieldValue va = (MultifieldValue)fv.GetFactSlot("valid-answers");


            String selected = fv.GetFactSlot("response").ToString();

            foreach (var item in va)
            {
                RadioButton rButton = new RadioButton();
                rButton.Content    = l[item.ToString()];
                rButton.IsChecked  = item.ToString() == selected;
                rButton.Tag        = item.ToString();
                rButton.Visibility = Visibility.Visible;
                rButton.Margin     = new Thickness(5);
                choicesPanel.Children.Add(rButton);
            }

            messageTextBox.Text = l[fv.GetFactSlot("display").ToString()];
        }
コード例 #4
0
        private void HandleResponse()
        {
            //  Вытаскиаваем факт из ЭС
            String           evalStr = "(find-fact ((?f ioproxy)) TRUE)";
            FactAddressValue fv      = (FactAddressValue)((MultifieldValue)clips.Eval(evalStr))[0];

            MultifieldValue damf = (MultifieldValue)fv["messages"];
            MultifieldValue vamf = (MultifieldValue)fv["answers"];

            outputBox.Text += "Новая итерация : " + System.Environment.NewLine;
            for (int i = 0; i < damf.Count; i++)
            {
                LexemeValue da    = (LexemeValue)damf[i];
                byte[]      bytes = Encoding.Default.GetBytes(da.Value);

                string message = Encoding.UTF8.GetString(bytes);
                outputBox.Text += message + System.Environment.NewLine;

                string[] messages = message.Split();
                string   fact     = messages.Last().ToString();

                if (checkedListBox1.Items.Contains(fact))
                {
                    outputBox.Text    += "для этой команды соперников контрпик найден" + System.Environment.NewLine;
                    nextButton.Enabled = false;
                    return;
                }
            }

            var phrases = new List <string>();

            if (vamf.Count > 0)
            {
                outputBox.Text += "----------------------------------------------------" + System.Environment.NewLine;
                for (int i = 0; i < vamf.Count; i++)
                {
                    //  Варианты !!!!!
                    LexemeValue va      = (LexemeValue)vamf[i];
                    byte[]      bytes   = Encoding.Default.GetBytes(va.Value);
                    string      message = Encoding.UTF8.GetString(bytes);
                    phrases.Add(message);
                    outputBox.Text += "Добавлен вариант для распознавания " + message + System.Environment.NewLine;
                }
            }

            if (vamf.Count == 0)
            {
                clips.Eval("(assert (clearmessage))");
            }
            else
            {
                NewRecognPhrases(phrases);
            }
        }
コード例 #5
0
 private void AddAnswers(MultifieldValue answers)
 {
     for (int i = 0; i < answers.Count; i++)
     {
         var rb = new RadioButton {
             Margin = new Thickness(3), Content = answers[i]
         };
         QuestionStackPnl.Children.Add(rb);
     }
     if (answers.Count > 0)
     {
         (QuestionStackPnl.Children[1] as RadioButton).IsChecked = true;
     }
 }
コード例 #6
0
        private void HandleResponse()
        {
            //  Вытаскиаваем факт из ЭС
            FactAddressValue fv = clips.FindFact("ioproxy");

            MultifieldValue damf = (MultifieldValue)fv["messages"];

            textBox1.Text = "";
            for (int i = 0; i < damf.Count; i++)
            {
                LexemeValue da    = (LexemeValue)damf[i];
                byte[]      bytes = Encoding.Default.GetBytes(da.Value);
                textBox1.Text += Encoding.UTF8.GetString(bytes) + System.Environment.NewLine;
            }

            clips.Eval("(assert (clearmessage))");
        }
コード例 #7
0
        private void HandleResponse()
        {
            //  Вытаскиаваем факт из ЭС
            string           evalStr = "(find-fact ((?f ioproxy)) TRUE)";
            FactAddressValue fv      = (FactAddressValue)((MultifieldValue)clips.Eval(evalStr))[0];

            MultifieldValue damf = (MultifieldValue)fv["messages"];
            MultifieldValue vamf = (MultifieldValue)fv["answers"];

            textBox1.Text += "Новая итерация: " + System.Environment.NewLine;
            for (int i = 0; i < damf.Count; i++)
            {
                LexemeValue da    = (LexemeValue)damf[i];
                byte[]      bytes = Encoding.Default.GetBytes(da.Value);
                textBox1.Text += "Вопрос: " + Encoding.UTF8.GetString(bytes) + System.Environment.NewLine;
            }

            if (vamf.Count > 0)
            {
                List <string> answers  = new List <string>();
                LexemeValue   da       = (LexemeValue)damf[damf.Count - 1];
                byte[]        bytes    = Encoding.Default.GetBytes(da.Value);
                string        question = Encoding.UTF8.GetString(bytes) + System.Environment.NewLine;

                for (int i = 0; i < vamf.Count; i++)
                {
                    LexemeValue va = (LexemeValue)vamf[i];
                    bytes = Encoding.Default.GetBytes(va.Value);
                    answers.Add(Encoding.UTF8.GetString(bytes));
                }
                Dialog df = new Dialog(question, answers);
                df.ShowDialog(this);

                textBox1.Text += "Ответ: " + answers[answer_index] + System.Environment.NewLine;
                textBox1.Text += "----------------------------------------------------" + System.Environment.NewLine;

                clips.Eval("(write-answer \"" + answers[answer_index] + "\" )");
            }



            clips.Eval("(assert (clearmessage))");
        }
コード例 #8
0
        private bool HandleResponse()
        {
            //  Вытаскиаваем факт из ЭС
            String           evalStr = "(find-fact ((?f ioproxy)) TRUE)";
            FactAddressValue fv      = (FactAddressValue)((MultifieldValue)clips.Eval(evalStr))[0];

            MultifieldValue damf = (MultifieldValue)fv["messages"];
            MultifieldValue vamf = (MultifieldValue)fv["answers"];

            for (int i = 0; i < damf.Count; i++)
            {
                LexemeValue da      = (LexemeValue)damf[i];
                byte[]      bytes   = Encoding.Default.GetBytes(da.Value);
                string      message = Encoding.UTF8.GetString(bytes);
                outputBox.Text += message + System.Environment.NewLine;

                //if(message == "")
                //{
                //    if (vamf.Count == 0)
                //        clips.Eval("(assert (clearmessage))");
                //    return false;
                //}
            }

            if (damf.Count == 0)
            {
                if (vamf.Count == 0)
                {
                    clips.Eval("(assert (clearmessage))");
                }

                return(false);
            }

            if (vamf.Count == 0)
            {
                clips.Eval("(assert (clearmessage))");
            }

            return(true);
        }
コード例 #9
0
ファイル: Form1.cs プロジェクト: Black0274/FinalProject
        private string HandleResponse()
        {
            string result = "";
            //  Вытаскиаваем факт из ЭС
            String           evalStr = "(find-fact ((?f ioproxy)) TRUE)";
            FactAddressValue fv      = (FactAddressValue)((MultifieldValue)clips.Eval(evalStr))[0];

            MultifieldValue damf = (MultifieldValue)fv["messages"];
            MultifieldValue vamf = (MultifieldValue)fv["answers"];

            for (int i = 0; i < damf.Count; i++)
            {
                LexemeValue da    = (LexemeValue)damf[i];
                byte[]      bytes = Encoding.Default.GetBytes(da.Value);
                result += Encoding.UTF8.GetString(bytes) + System.Environment.NewLine;
            }

            clips.Eval("(assert (clearmessage))");

            return(result);
        }
コード例 #10
0
        private void HandleResponse()
        {
            //  Вытаскиаваем факт из ЭС
            FactAddressValue fv = clips.FindFact("ioproxy");

            MultifieldValue damf  = (MultifieldValue)fv["messages"];
            List <string>   films = new List <string>();

            for (int i = 0; i < damf.Count; i++)
            {
                LexemeValue da    = (LexemeValue)damf[i];
                byte[]      bytes = Encoding.Default.GetBytes(da.Value);
                var         elem  = Encoding.UTF8.GetString(bytes);
                films.Add(elem);
            }
            label_films.Text = "";
            for (int i = 0; i < films.Count; i++)
            {
                label_films.Text += films[i].ToString() + "\n";
            }
            clips.Eval("(assert (clearmessage))");
        }
コード例 #11
0
        private void HandleResponse()
        {
            /*===========================*/
            /* Get the current UI state. */
            /*===========================*/

            String           evalStr = "(find-fact ((?f UI-state)) TRUE)";
            FactAddressValue fv      = (FactAddressValue)((MultifieldValue)clips.Eval(evalStr))[0];

            /*========================================*/
            /* Determine the Next/Prev button states. */
            /*========================================*/

            if (fv["state"].ToString().Equals("conclusion"))
            {
                interviewState = InterviewState.CONCLUSION;
                //nextButton.Tag = "Restart";
                //nextButton.Text = "Restart";
                nextButton.Visible   = false;
                prevButton.Visible   = true;
                choicesPanel.Visible = false;
            }
            else if (fv["state"].ToString().Equals("greeting"))
            {
                interviewState     = InterviewState.GREETING;
                nextButton.Visible = false;
                //nextButton.Tag = "Next";
                //nextButton.Text = "Next >";
                prevButton.Visible   = false;
                choicesPanel.Visible = false;
            }
            else
            {
                interviewState       = InterviewState.INTERVIEW;
                nextButton.Visible   = true;
                nextButton.Tag       = "Next";
                nextButton.Text      = "Next >";
                prevButton.Visible   = false;
                choicesPanel.Visible = true;
                if (priorAnswers.Count < 1)
                {
                    prevButton.Visible = false;
                }
            }

            /*=====================*/
            /* Set up the choices. */
            /*=====================*/

            choicesPanel.Controls.Clear();

            MultifieldValue damf = (MultifieldValue)fv["display-answers"];
            MultifieldValue vamf = (MultifieldValue)fv["valid-answers"];

            String      selected    = fv["response"].ToString();
            RadioButton firstButton = null;

            for (int i = 0; i < damf.Count; i++)
            {
                LexemeValue da = (LexemeValue)damf[i];
                LexemeValue va = (LexemeValue)vamf[i];
                RadioButton rButton;
                String      buttonName, buttonText, buttonAnswer;

                buttonName   = da.Value;
                buttonText   = buttonName.Substring(0, 1).ToUpperInvariant() + buttonName.Substring(1);
                buttonAnswer = va.Value;

                rButton      = new RadioButton();
                rButton.Text = buttonText;
                if (((lastAnswer != null) && buttonAnswer.Equals(lastAnswer)) ||
                    ((lastAnswer == null) && buttonAnswer.Equals(selected)))
                {
                    rButton.Checked = true;
                }
                else
                {
                    rButton.Checked = false;
                }

                rButton.Tag      = buttonAnswer;
                rButton.Visible  = true;
                rButton.AutoSize = true;
                choicesPanel.Controls.Add(rButton);

                if (firstButton == null)
                {
                    firstButton = rButton;
                }
            }

            if ((GetCheckedChoiceButton() == null) && (firstButton != null))
            {
                firstButton.Checked = true;
            }

            /*====================================*/
            /* Set the label to the display text. */
            /*====================================*/

            relationAsserted = ((LexemeValue)fv["relation-asserted"]).Value;

            /*====================================*/
            /* Set the label to the display text. */
            /*====================================*/

            String messageString = ((StringValue)fv["display"]).Value;

            messageLabel.Text = messageString;
        }
コード例 #12
0
        private void NextUIState()
        {
            nextButton.Visible = false;
            prevButton.Visible = false;
            choicesPanel.Controls.Clear();
            clipsEnvironment.Run();

            // Get the state-list.
            String evalStr = "(find-all-facts ((?f state-list)) TRUE)";

            using (FactAddressValue allFacts = (FactAddressValue)((MultifieldValue)clipsEnvironment.Eval(evalStr))[0])
            {
                string currentID = allFacts.GetFactSlot("current").ToString();
                evalStr = "(find-all-facts ((?f UI-state)) " +
                          "(eq ?f:id " + currentID + "))";
            }

            using (FactAddressValue evalFact = (FactAddressValue)((MultifieldValue)clipsEnvironment.Eval(evalStr))[0])
            {
                string state = evalFact.GetFactSlot("state").ToString();
                if (state.Equals("initial"))
                {
                    nextButton.Visible = true;
                    nextButton.Tag     = "Next";
                    nextButton.Text    = "Next";
                    prevButton.Visible = false;
                }
                else if (state.Equals("final"))
                {
                    nextButton.Visible = true;
                    nextButton.Tag     = "Restart";
                    nextButton.Text    = "Restart";
                    prevButton.Visible = false;
                }
                else
                {
                    nextButton.Visible = true;
                    nextButton.Tag     = "Next";
                    prevButton.Tag     = "Prev";
                    prevButton.Visible = true;
                }



                using (MultifieldValue validAnswers = (MultifieldValue)evalFact.GetFactSlot("valid-answers"))
                {
                    //clear of the old label
                    lblAnsClips.Text = string.Empty;
                    String selected = evalFact.GetFactSlot("response").ToString();
                    for (int i = 0; i < validAnswers.Count; i++)
                    {
                        RadioButton rb = new RadioButton();
                        rb.Text          = (SymbolValue)validAnswers[i];
                        rb.Tag           = rb.Text;
                        lblAnsClips.Text = lblAnsClips.Text + " " + rb.Text;
                        rb.Visible       = true;
                        rb.Location      = new Point(10, 20 * (i + 1));
                        choicesPanel.Controls.Add(rb);
                    }
                    lblAnsClips.Text = lblAnsClips.Text + " :Updated on " + DateTime.Now.ToLongTimeString();
                }
                messageLabel.Text = GetString((SymbolValue)evalFact.GetFactSlot("display"));
            }
        }
コード例 #13
0
        public override DecisionResult IdentifyTreatment()
        {
            List <Treatment> treatments = new List <Treatment>();
            List <Action>    actions    = new List <Action>();
            List <Reason>    reasons    = new List <Reason>();

            string currentGFR = "";
            string GFRTrend   = "unknown";
            bool   Dialysis   = false;

            double       latest    = testData.Offsets().Min();
            List <Value> GfrValues = testData.Values("gfr");
            double       slope     = 0;

            if (GfrValues.Count() == 0)
            {
                Action action = new Action();
                action.text = "Please provide at least one GFR value.";
                actions.Add(action);
            }
            else if (GfrValues.Count() > 1)
            {
                List <double> weights = new List <double>();
                List <double> offsets = new List <double>();
                List <double> values  = new List <double>();
                foreach (Value value in GfrValues)
                {
                    double days       = (value.offset - latest) / 86400;
                    double new_weight = Math.Pow((1 - test_trend_decay_per_day), (double)value.value);
                    offsets.Add(value.offset);
                    values.Add((double)value.value);
                    weights.Add(Math.Max(0.125, new_weight));
                }
                double[] lsrResults = LeastSquaresWeightedBestFitLine1(offsets.ToArray(), values.ToArray(), weights.ToArray());
                //intercept = results[0];
                slope      = -lsrResults[1];
                currentGFR = testData.Value("gfr", latest).value.ToString();
                if (currentGFR == "-1")
                {
                    currentGFR = "";
                    GFRTrend   = "";
                    Dialysis   = true;
                }
                else if (GfrValues.Count > 1 && currentGFR != "")
                {
                    // double diff = (y_values[0] - intercept) / intercept;
                    GFRTrend = "stable";
                    if (slope / (double)testData.Value("gfr", latest).value > 0.1)
                    {
                        GFRTrend = "increasing";
                    }
                    if (slope / (double)testData.Value("gfr", latest).value < -0.1)
                    {
                        GFRTrend = "decreasing";
                    }
                }
            }
            else // Single GFR value
            {
                if (GfrValues.Count() > 0)
                {
                    currentGFR = testData.Value("gfr", latest).value.ToString();
                }
                if (currentGFR == "-1")
                {
                    currentGFR = "";
                    GFRTrend   = "";
                    Dialysis   = true;
                }
                else
                {
                    GFRTrend = "stable";
                }
            }

            Value  urineProduction      = testData.Value("urine production", latest);
            double urineProductionValue = 0;

            if (urineProduction.value == null || !(urineProduction.value is double))
            {
                Action action = new Action();
                action.text = "Please provide urine production as a number.";
                actions.Add(action);
            }
            else
            {
                urineProductionValue = (double)urineProduction.value;
            }
            Value  potassium      = testData.Value("potassium", latest);
            double potassiumValue = 0;

            if (potassium.value == null || !(potassium.value is double))
            {
                Action action = new Action();
                action.text = "Please provide potassium as a number.";
                actions.Add(action);
            }
            else
            {
                potassiumValue = (double)potassium.value;
            }
            Value  magnesium      = testData.Value("magnesium", latest);
            double magnesiumValue = 0;

            if (magnesium.value == null || !(magnesium.value is double))
            {
                Action action = new Action();
                action.text = "Please provide magnesium as a number.";
                actions.Add(action);
            }
            else
            {
                magnesiumValue = (double)magnesium.value;
            }
            Value  phosphorus      = testData.Value("phosphorus", latest);
            double phosphorusValue = 0;

            if (phosphorus.value == null || !(phosphorus.value is double))
            {
                Action action = new Action();
                action.text = "Please provide phosphorus as a number.";
                actions.Add(action);
            }
            else
            {
                phosphorusValue = (double)phosphorus.value;
            }
            Value  calcium      = testData.Value("calcium, ionized", latest);
            double calciumValue = 0;

            if (calcium.value == null || !(calcium.value is double))
            {
                Action action = new Action();
                action.text = "Please provide calcium as a number.";
                actions.Add(action);
            }
            else
            {
                calciumValue = (double)calcium.value;
            }
            Value  diarrhea      = testData.Value("diarrhea", latest);
            string diarrheaValue = diarrhea.value as string;

            if (diarrheaValue == null || diarrheaValue == "")
            {
                diarrheaValue = "X";
            }
            else
            {
                diarrheaValue = diarrheaValue.ToUpper();
                if (diarrheaValue[0] != 'N' && diarrheaValue[0] != 'Y')
                {
                    Action action = new Action();
                    action.text = "Please provide diarrhea as Yes, Y, No or N.";
                    actions.Add(action);
                }
                else
                {
                    diarrheaValue = diarrheaValue.Substring(0, 1);
                }
            }

            double recentKCL            = 0;
            int    recentKCLtreatements = 0;

            List <Value> kclTreatments = treatmentData.Values("kcl");

            foreach (Value kclTreatment in kclTreatments)
            {
                if (kclTreatment.offset <= 2 * 86400) // 2 days
                {
                    recentKCL += (double)kclTreatment.value;
                    recentKCLtreatements++;
                }
            }

            if (actions.Count == 0) // no errors
            {
                // Clear old values
                //clips.Eval("(clear)");
                //clips.Load("Hypokalemia.clp");
                //clips.Eval("(reset)"); // load facts from deffacts constructs.
                clips.Clear();
                clips.Load("Hypokalemia.clp");
                clips.Reset(); // load facts from deffacts constructs.

                // Set values in CLIPS
                clips.AssertString("(diagnosis (patient " + patientID + ") (name HYPOKALEMIA))");
                if (Dialysis)
                {
                    clips.AssertString("(test-value (patient " + patientID + ") (name Dialysis) (value TRUE))");
                }
                if (currentGFR != "")
                {
                    clips.AssertString("(test-value (patient " + patientID + ") (name GFR) (value " + currentGFR + "))");
                }
                if (GFRTrend != "")
                {
                    clips.AssertString("(test-value (patient " + patientID + ") (name GFR-trend) (value " + GFRTrend.ToUpper() + "))");
                }
                if (urineProduction != null)
                {
                    clips.AssertString("(test-value (patient " + patientID + ") (name Urine-production) (value " + urineProductionValue + "))");
                }
                if (potassium != null)
                {
                    clips.AssertString("(test-value (patient " + patientID + ") (name Potassium) (value " + potassiumValue + "))");
                }

                if (magnesium != null)
                {
                    clips.AssertString("(test-value (patient " + patientID + ") (name Magnesium) (value " + magnesiumValue + "))");
                }
                if (phosphorus != null)
                {
                    clips.AssertString("(test-value (patient " + patientID + ") (name Phosphorus) (value " + phosphorusValue + "))");
                }
                if (calcium != null)
                {
                    clips.AssertString("(test-value (patient " + patientID + ") (name Calcium) (value " + calciumValue + "))");
                }
                if (diarrhea != null)
                {
                    clips.AssertString("(test-value (patient " + patientID + ") (name Diarrhea) (value " + diarrheaValue + "))");
                }

                Value EnteralRoute = testData.Value("enteralroute", latest);
                if (EnteralRoute != null && (bool)EnteralRoute.value)
                {
                    clips.AssertString("(available-routes (patient " + patientID + ") (type ENTERAL))");
                }
                Value CentralRoute = testData.Value("centralroute", latest);
                if (CentralRoute != null && (bool)CentralRoute.value)
                {
                    clips.AssertString("(available-routes (patient " + patientID + ") (type CENTRAL-IV))");
                }
                Value PeripheralRoute = testData.Value("peripheralroute", latest);
                if (PeripheralRoute != null && (bool)PeripheralRoute.value)
                {
                    clips.AssertString("(available-routes (patient " + patientID + ") (type PERIPHERAL-IV))");
                }

                clips.AssertString("(test-value (patient " + patientID + ") (name Recent-KCL) (value " + recentKCL + "))");
                clips.AssertString("(test-value (patient " + patientID + ") (name Recent-KCL-Treatements) (value " + recentKCLtreatements + "))");

                //clips.Reset();
                clips.Run();

                // Get values from CLIPS
                MultifieldValue treatmentFacts = clips.Eval("(find-all-facts ((?treatment treatment)) TRUE)") as MultifieldValue;
                foreach (FactAddressValue fv in treatmentFacts)
                {
                    Treatment treatment = new Treatment();
                    //treatment.index = (int)((NumberValue)fv.GetFactSlot("index")).GetIntegerValue();
                    //treatment.type = ((LexemeValue)fv.GetFactSlot("type")).GetLexemeValue();
                    //treatment.med = ((LexemeValue)fv.GetFactSlot("med")).GetLexemeValue();
                    //treatment.quantity = ((NumberValue)fv.GetFactSlot("quantity")).GetFloatValue();
                    //treatment.units = ((LexemeValue)fv.GetFactSlot("units")).GetLexemeValue();
                    //treatment.route = ((LexemeValue)fv.GetFactSlot("route")).GetLexemeValue();
                    object tempIndex = fv.GetFactSlot("index");
                    if (tempIndex is FloatValue)
                    {
                        FloatValue tempValue = (FloatValue)tempIndex;
                        treatment.index = (float)(tempValue);
                    }
                    else
                    {
                        IntegerValue tempValue = (IntegerValue)tempIndex;
                        treatment.index = (int)(tempValue);
                    }
                    treatment.type = (string)((SymbolValue)fv.GetFactSlot("type"));
                    treatment.med  = (string)((SymbolValue)fv.GetFactSlot("med"));
                    PrimitiveValue quantitySlot = fv.GetFactSlot("quantity");
                    if (quantitySlot is FloatValue)
                    {
                        treatment.quantity = (double)((FloatValue)quantitySlot);
                    }
                    else
                    {
                        treatment.quantity = (int)((IntegerValue)quantitySlot);
                    }
                    treatment.units = (string)((SymbolValue)fv.GetFactSlot("units"));
                    treatment.route = (string)((SymbolValue)fv.GetFactSlot("route"));
                    treatments.Add(treatment);
                }

                MultifieldValue actionFacts = clips.Eval("(find-all-facts ((?action action)) TRUE)") as MultifieldValue;
                foreach (FactAddressValue fv in actionFacts)
                {
                    Action action = new Action();
                    action.text = ((SymbolValue)fv.GetFactSlot("text")).ToString().Replace("GFR-trend", "Previous GFR");
                    actions.Add(action);
                }

                MultifieldValue reasonFacts = clips.Eval("(find-all-facts ((?reason reason)) TRUE)") as MultifieldValue;
                foreach (FactAddressValue fv in reasonFacts)
                {
                    Reason reason = new Reason(
                        (int)((IntegerValue)fv.GetFactSlot("level")),
                        ((SymbolValue)fv.GetFactSlot("rule")).ToString(),
                        ((SymbolValue)fv.GetFactSlot("text")).ToString().Replace("GFR-trend", "Previous GFR"));
                    reasons.Add(reason);
                }
            }

            return(new DecisionResult(treatments, actions, reasons));
        }
コード例 #14
0
        private void HandleResponse()
        {
            /*===========================*/
            /* Get the current UI state. */
            /*===========================*/

            String           evalStr = "(find-fact ((?f UI-state)) TRUE)";
            FactAddressValue fv      = (FactAddressValue)((MultifieldValue)clips.Eval(evalStr))[0];

            /*========================================*/
            /* Determine the Next/Prev button states. */
            /*========================================*/

            if (fv.GetFactSlot("state").ToString().Equals("conclusion"))
            {
                interviewState          = InterviewState.CONCLUSION;
                nextButton.Tag          = "Restart";
                nextButton.Content      = "Restart";
                prevButton.Visibility   = Visibility.Visible;
                choicesPanel.Visibility = Visibility.Collapsed;
            }
            else if (fv.GetFactSlot("state").ToString().Equals("greeting"))
            {
                interviewState          = InterviewState.GREETING;
                nextButton.Tag          = "Next";
                nextButton.Content      = "Next >";
                prevButton.Visibility   = Visibility.Collapsed;
                choicesPanel.Visibility = Visibility.Collapsed;
            }
            else
            {
                interviewState          = InterviewState.INTERVIEW;
                nextButton.Tag          = "Next";
                nextButton.Content      = "Next >";
                prevButton.Visibility   = Visibility.Visible;
                choicesPanel.Visibility = Visibility.Visible;
            }

            /*=====================*/
            /* Set up the choices. */
            /*=====================*/

            choicesPanel.Children.Clear();

            MultifieldValue damf = (MultifieldValue)fv.GetFactSlot("display-answers");
            MultifieldValue vamf = (MultifieldValue)fv.GetFactSlot("valid-answers");

            String      selected    = fv.GetFactSlot("response").ToString();
            RadioButton firstButton = null;

            for (int i = 0; i < damf.Count; i++)
            {
                LexemeValue da = (LexemeValue)damf[i];
                LexemeValue va = (LexemeValue)vamf[i];
                RadioButton rButton;
                String      buttonName, buttonText, buttonAnswer;

                buttonName   = da.GetLexemeValue();
                buttonText   = buttonName.Substring(0, 1).ToUpperInvariant() + buttonName.Substring(1);
                buttonAnswer = va.GetLexemeValue();

                rButton         = new RadioButton();
                rButton.Content = buttonText;
                if (((lastAnswer != null) && buttonAnswer.Equals(lastAnswer)) ||
                    ((lastAnswer == null) && buttonAnswer.Equals(selected)))
                {
                    rButton.IsChecked = true;
                }
                else
                {
                    rButton.IsChecked = false;
                }

                rButton.Tag        = buttonAnswer;
                rButton.Visibility = Visibility.Visible;
                rButton.Margin     = new Thickness(5);
                choicesPanel.Children.Add(rButton);

                if (firstButton == null)
                {
                    firstButton = rButton;
                }
            }

            if ((GetCheckedChoiceButton() == null) && (firstButton != null))
            {
                firstButton.IsChecked = true;
            }

            /*====================================*/
            /* Set the label to the display text. */
            /*====================================*/

            relationAsserted = ((LexemeValue)fv.GetFactSlot("relation-asserted")).GetLexemeValue();

            /*====================================*/
            /* Set the label to the display text. */
            /*====================================*/

            String messageString = ((StringValue)fv.GetFactSlot("display")).GetStringValue();
            double theWidth      = ComputeTextBoxWidth(messageString);

            messageTextBox.Width    = theWidth;
            messageTextBox.MinWidth = theWidth;
            messageTextBox.Text     = messageString;
        }
コード例 #15
0
 private void AddQAndA(string question, MultifieldValue answers)
 {
     ResetStackPanel();
     AddQuestion(question);
     AddAnswers(answers);
 }
コード例 #16
0
        private void HandleResponse()
        {
            /*===========================*/
            /* Get the current UI state. */
            /*===========================*/
            string           evalStr = "(find-fact ((?f UI-state)) TRUE)";
            FactAddressValue fv      = (FactAddressValue)((MultifieldValue)clips.Eval(evalStr))[0];

            /*========================================*/
            /* Determine the Next/Prev button states. */
            /*========================================*/
            if (fv["state"].ToString().Equals("conclusion"))
            {
                interviewState          = InterviewState.CONCLUSION;
                nextButton.Tag          = "Restart";
                nextButton.Content      = "Restart";
                prevButton.Visibility   = Visibility.Hidden;
                scrollViewer.Visibility = Visibility.Visible;
                choicesPanel.Visibility = Visibility.Hidden;
                leftPanel.Visibility    = Visibility.Hidden;
                rightPanel.Visibility   = Visibility.Hidden;
            }
            else if (fv["state"].ToString().Equals("greeting"))
            {
                interviewState          = InterviewState.GREETING;
                nextButton.Tag          = "Next";
                nextButton.Content      = "Next >";
                prevButton.Visibility   = Visibility.Hidden;
                scrollViewer.Visibility = Visibility.Hidden;
                choicesPanel.Visibility = Visibility.Hidden;
                leftPanel.Visibility    = Visibility.Hidden;
                rightPanel.Visibility   = Visibility.Hidden;
            }
            else
            {
                interviewState          = InterviewState.INTERVIEW;
                nextButton.Tag          = "Next";
                nextButton.Content      = "Next >";
                prevButton.Visibility   = Visibility.Visible;
                scrollViewer.Visibility = Visibility.Hidden;
                choicesPanel.Visibility = Visibility.Visible;
                leftPanel.Visibility    = Visibility.Visible;
                rightPanel.Visibility   = Visibility.Visible;
            }
            leftLabel.Visibility  = Visibility.Hidden;
            rightLabel.Visibility = Visibility.Hidden;

            // Show different image according to job group
            string currentPath = System.Environment.CurrentDirectory;

            string[] temp = currentPath.Split("\\".ToCharArray());
            currentPath = "";
            for (int i = 0; i < temp.Length - 2; i++)
            {
                currentPath += temp[i];
                currentPath += "\\";
            }

            /*=====================*/
            /* Set up the choices. */
            /*=====================*/
            resultsPanel.Children.Clear();
            choicesPanel.Children.Clear();
            leftPanel.Children.Clear();
            rightPanel.Children.Clear();

            /*===========================*/
            /* Set up the panel context. */
            /*===========================*/
            if (fv["state"].ToString().Equals("conclusion"))
            {
                MultifieldValue drmf      = (MultifieldValue)fv["display-results"];
                Label           linkLabel = null;
                Run             linkText  = null;
                Hyperlink       link      = null;

                // Read excel for link of Job & Course & Prodiver
                List <string> jobNameList      = new List <string>();
                List <string> jobLinkList      = new List <string>();
                List <string> courseNameList   = new List <string>();
                List <string> courseLinkList   = new List <string>();
                List <string> providerNameList = new List <string>();
                List <string> providerLinkList = new List <string>();
                DataTable     dt = new DataTable();
                dt = LoadExcel(currentPath + "\\doc\\LinkData.xlsx", "Job");
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    jobNameList.Add(dt.Rows[i][0].ToString());
                    jobLinkList.Add(dt.Rows[i][1].ToString());
                }

                dt = LoadExcel(currentPath + "\\doc\\LinkData.xlsx", "Course");
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    courseNameList.Add(dt.Rows[i][0].ToString());
                    courseLinkList.Add(dt.Rows[i][1].ToString());
                }

                dt = LoadExcel(currentPath + "\\doc\\LinkData.xlsx", "Provider");
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    providerNameList.Add(dt.Rows[i][0].ToString());
                    providerLinkList.Add(dt.Rows[i][1].ToString());
                }

                for (int i = 0; i < drmf.Count; i++)
                {
                    LexemeValue dr           = (LexemeValue)drmf[i];
                    string      resultValue  = dr.Value;
                    string[]    resultValues = resultValue.Split(';');

                    // Job
                    StackPanel jPanel = new StackPanel();
                    jPanel.HorizontalAlignment = HorizontalAlignment.Left;
                    jPanel.VerticalAlignment   = VerticalAlignment.Center;
                    jPanel.Orientation         = Orientation.Horizontal;
                    jPanel.Height = 40;

                    Ellipse jEllipse = new Ellipse();
                    jEllipse.Width  = 20;
                    jEllipse.Height = 20;
                    SolidColorBrush jSolidColorBrush = new SolidColorBrush();
                    jSolidColorBrush.Color = Color.FromArgb(255, 255, 255, 255);
                    jEllipse.Fill          = jSolidColorBrush;
                    jPanel.Children.Add(jEllipse);

                    linkLabel             = new Label();
                    linkText              = new Run(" " + resultValues[0].ToString());
                    link                  = new Hyperlink(linkText);
                    link.NavigateUri      = new Uri(jobLinkList[jobNameList.IndexOf(resultValues[0].ToString())]);
                    link.RequestNavigate += new RequestNavigateEventHandler(delegate(object sender, RequestNavigateEventArgs e) {
                        Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
                        e.Handled = true;
                    });
                    link.MouseEnter     += new MouseEventHandler(OnLinkMouseEnter);
                    link.MouseLeave     += new MouseEventHandler(OnLinkMouseLeave);
                    link.Foreground      = System.Windows.Media.Brushes.White;
                    link.TextDecorations = null;
                    linkLabel.Content    = link;
                    linkLabel.FontSize   = 22;
                    linkLabel.Foreground = System.Windows.Media.Brushes.White;
                    jPanel.Children.Add(linkLabel);
                    resultsPanel.Children.Add(jPanel);

                    // Course1
                    StackPanel c1Panel = new StackPanel();
                    c1Panel.HorizontalAlignment = HorizontalAlignment.Left;
                    c1Panel.VerticalAlignment   = VerticalAlignment.Center;
                    c1Panel.Orientation         = Orientation.Horizontal;
                    c1Panel.Height = 30;
                    c1Panel.SetValue(Canvas.LeftProperty, 20d);

                    Label c1Label = new Label();
                    c1Label.Content = "    ";
                    c1Panel.Children.Add(c1Label);

                    Ellipse c1Ellipse = new Ellipse();
                    c1Ellipse.Width  = 15;
                    c1Ellipse.Height = 15;
                    SolidColorBrush c1SolidColorBrush = new SolidColorBrush();
                    c1SolidColorBrush.Color = Color.FromArgb(255, 255, 255, 255);
                    c1Ellipse.Fill          = c1SolidColorBrush;
                    c1Panel.Children.Add(c1Ellipse);

                    linkLabel             = new Label();
                    linkText              = new Run(resultValues[1].ToString());
                    link                  = new Hyperlink(linkText);
                    link.NavigateUri      = new Uri(courseLinkList[courseNameList.IndexOf(resultValues[1].ToString())]);
                    link.RequestNavigate += new RequestNavigateEventHandler(delegate(object sender, RequestNavigateEventArgs e) {
                        Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
                        e.Handled = true;
                    });
                    link.MouseEnter     += new MouseEventHandler(OnLinkMouseEnter);
                    link.MouseLeave     += new MouseEventHandler(OnLinkMouseLeave);
                    link.Foreground      = System.Windows.Media.Brushes.White;
                    link.TextDecorations = null;
                    linkLabel.Content    = link;
                    linkLabel.FontSize   = 18;
                    linkLabel.Foreground = System.Windows.Media.Brushes.White;
                    c1Panel.Children.Add(linkLabel);
                    resultsPanel.Children.Add(c1Panel);

                    // Provider1
                    StackPanel p1Panel = new StackPanel();
                    p1Panel.HorizontalAlignment = HorizontalAlignment.Left;
                    p1Panel.VerticalAlignment   = VerticalAlignment.Center;
                    p1Panel.Orientation         = Orientation.Horizontal;
                    p1Panel.Height = 30;
                    p1Panel.SetValue(Canvas.LeftProperty, 40d);

                    Label p1Label = new Label();
                    p1Label.Content = "        ";
                    p1Panel.Children.Add(p1Label);

                    Ellipse p1Ellipse = new Ellipse();
                    p1Ellipse.Width  = 10;
                    p1Ellipse.Height = 10;
                    SolidColorBrush p1SolidColorBrush = new SolidColorBrush();
                    p1SolidColorBrush.Color = Color.FromArgb(255, 255, 255, 255);
                    p1Ellipse.Fill          = p1SolidColorBrush;
                    p1Panel.Children.Add(p1Ellipse);

                    linkLabel             = new Label();
                    linkText              = new Run(resultValues[3].ToString());
                    link                  = new Hyperlink(linkText);
                    link.NavigateUri      = new Uri(providerLinkList[providerNameList.IndexOf(resultValues[3].ToString())]);
                    link.RequestNavigate += new RequestNavigateEventHandler(delegate(object sender, RequestNavigateEventArgs e) {
                        Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
                        e.Handled = true;
                    });
                    link.MouseEnter     += new MouseEventHandler(OnLinkMouseEnter);
                    link.MouseLeave     += new MouseEventHandler(OnLinkMouseLeave);
                    link.Foreground      = System.Windows.Media.Brushes.White;
                    link.TextDecorations = null;
                    linkLabel.Content    = link;
                    linkLabel.FontSize   = 14;
                    linkLabel.Foreground = System.Windows.Media.Brushes.White;
                    p1Panel.Children.Add(linkLabel);
                    resultsPanel.Children.Add(p1Panel);

                    // Course2
                    StackPanel c2Panel = new StackPanel();
                    c2Panel.HorizontalAlignment = HorizontalAlignment.Left;
                    c2Panel.VerticalAlignment   = VerticalAlignment.Center;
                    c2Panel.Orientation         = Orientation.Horizontal;
                    c2Panel.Height = 30;
                    c2Panel.SetValue(Canvas.LeftProperty, 20d);

                    Label c2Label = new Label();
                    c2Label.Content = "    ";
                    c2Panel.Children.Add(c2Label);

                    Ellipse c2Ellipse = new Ellipse();
                    c2Ellipse.Width  = 15;
                    c2Ellipse.Height = 15;
                    SolidColorBrush c2SolidColorBrush = new SolidColorBrush();
                    c2SolidColorBrush.Color = Color.FromArgb(255, 255, 255, 255);
                    c2Ellipse.Fill          = c2SolidColorBrush;
                    c2Panel.Children.Add(c2Ellipse);

                    linkLabel             = new Label();
                    linkText              = new Run(resultValues[2].ToString());
                    link                  = new Hyperlink(linkText);
                    link.NavigateUri      = new Uri(courseLinkList[courseNameList.IndexOf(resultValues[2].ToString())]);
                    link.RequestNavigate += new RequestNavigateEventHandler(delegate(object sender, RequestNavigateEventArgs e) {
                        Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
                        e.Handled = true;
                    });
                    link.MouseEnter     += new MouseEventHandler(OnLinkMouseEnter);
                    link.MouseLeave     += new MouseEventHandler(OnLinkMouseLeave);
                    link.Foreground      = System.Windows.Media.Brushes.White;
                    link.TextDecorations = null;
                    linkLabel.Content    = link;
                    linkLabel.FontSize   = 18;
                    linkLabel.Foreground = System.Windows.Media.Brushes.White;
                    c2Panel.Children.Add(linkLabel);
                    resultsPanel.Children.Add(c2Panel);

                    // Provider2
                    StackPanel p2Panel = new StackPanel();
                    p2Panel.HorizontalAlignment = HorizontalAlignment.Left;
                    p2Panel.VerticalAlignment   = VerticalAlignment.Center;
                    p2Panel.Orientation         = Orientation.Horizontal;
                    p2Panel.Height = 30;
                    p2Panel.SetValue(Canvas.LeftProperty, 40d);

                    Label p2Label = new Label();
                    p2Label.Content = "        ";
                    p2Panel.Children.Add(p2Label);

                    Ellipse p2Ellipse = new Ellipse();
                    p2Ellipse.Width  = 10;
                    p2Ellipse.Height = 10;
                    SolidColorBrush p2SolidColorBrush = new SolidColorBrush();
                    p2SolidColorBrush.Color = Color.FromArgb(255, 255, 255, 255);
                    p2Ellipse.Fill          = p2SolidColorBrush;
                    p2Panel.Children.Add(p2Ellipse);

                    linkLabel             = new Label();
                    linkText              = new Run(resultValues[4].ToString());
                    link                  = new Hyperlink(linkText);
                    link.NavigateUri      = new Uri(providerLinkList[providerNameList.IndexOf(resultValues[4].ToString())]);
                    link.RequestNavigate += new RequestNavigateEventHandler(delegate(object sender, RequestNavigateEventArgs e) {
                        Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
                        e.Handled = true;
                    });
                    link.MouseEnter     += new MouseEventHandler(OnLinkMouseEnter);
                    link.MouseLeave     += new MouseEventHandler(OnLinkMouseLeave);
                    link.Foreground      = System.Windows.Media.Brushes.White;
                    link.TextDecorations = null;
                    linkLabel.Content    = link;
                    linkLabel.FontSize   = 14;
                    linkLabel.Foreground = System.Windows.Media.Brushes.White;
                    p2Panel.Children.Add(linkLabel);
                    resultsPanel.Children.Add(p2Panel);
                }
                scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
                scrollViewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
                scrollViewer.SetValue(Canvas.HeightProperty, 450d);
                resultsPanel.VerticalAlignment = VerticalAlignment.Top;

                Uri uri = null;
                if (jobGroup != null)
                {
                    uri = new Uri(currentPath + "\\image\\" + jobGroup + ".png", UriKind.RelativeOrAbsolute);
                }
                else
                {
                    uri = new Uri(currentPath + "\\image\\Path.png", UriKind.RelativeOrAbsolute);
                }

                BitmapImage bitmap = new BitmapImage(uri);
                pathImage.Source = bitmap;

                // Change window background
                if (jobGroup != null)
                {
                    string color = "";
                    switch (jobGroup)
                    {
                    case "JobGroupsBA":
                        color = "#FF20C2D7";
                        break;

                    case "JobGroupsCC":
                        color = "#FF0886B7";
                        break;

                    case "JobGroupsDDM":
                        color = "#FF27BBD5";
                        break;

                    case "JobGroupsINS":
                        color = "#FF007386";
                        break;

                    case "JobGroupsISM":
                        color = "#FF059DCC";
                        break;

                    case "JobGroupsITM":
                        color = "#FF008CAD";
                        break;

                    case "JobGroupsSSD":
                        color = "#FF00AB9B";
                        break;
                    }

                    prevButton.Background = nextButton.Background = this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(color));
                }
                else
                {
                    this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF75B2B3"));
                }

                // Hidden progressBar
                progressPanel.Visibility = Visibility.Hidden;
            }
            else
            {
                MultifieldValue damf = (MultifieldValue)fv["display-answers"];
                MultifieldValue vamf = (MultifieldValue)fv["valid-answers"];

                string      selected         = fv["response"].ToString();
                Button      firstButton      = null;
                RadioButton firstRadioButton = null;

                Uri         uri    = null;
                BitmapImage bitmap = null;

                for (int i = 0; i < damf.Count; i++)
                {
                    LexemeValue da = (LexemeValue)damf[i];
                    LexemeValue va = (LexemeValue)vamf[i];
                    RadioButton rButton;
                    Button      button;
                    string      buttonName, buttonText, buttonAnswer;

                    buttonName   = da.Value;
                    buttonText   = buttonName.Substring(0, 1).ToUpperInvariant() + buttonName.Substring(1);
                    buttonAnswer = va.Value;

                    // Character
                    if (fv["relation-asserted"].ToString().Equals("mind-types") ||
                        fv["relation-asserted"].ToString().Equals("see-things") ||
                        fv["relation-asserted"].ToString().Equals("judge-things") ||
                        fv["relation-asserted"].ToString().Equals("act-towards-changes"))
                    {
                        button = new Button();

                        // Button with image
                        uri    = new Uri(currentPath + "\\image\\" + buttonAnswer + ".png", UriKind.RelativeOrAbsolute);
                        bitmap = new BitmapImage(uri);
                        Image cellImage = new Image();
                        cellImage.Source = bitmap;
                        button           = new Button();
                        button.Content   = cellImage;
                        button.Tag       = buttonAnswer;
                        button.Width     = 150;
                        button.Height    = 150;
                        button.IsDefault = false;
                        button.Click    += OnClickButton;

                        button.Visibility = Visibility.Visible;
                        button.Margin     = new Thickness(5);
                        if (leftPanel.Children.Count == 0)
                        {
                            leftPanel.Children.Add(button);
                            leftLabel.Content    = buttonText;
                            leftLabel.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            rightPanel.Children.Add(button);
                            rightLabel.Content    = buttonText;
                            rightLabel.Visibility = Visibility.Visible;
                        }

                        button.SetValue(Canvas.LeftProperty, 10d);
                        button.SetValue(Canvas.TopProperty, 10d);
                        button.SetValue(Canvas.BackgroundProperty, null);

                        if (firstButton == null)
                        {
                            firstButton = button;
                        }
                    }
                    else
                    {
                        rButton         = new RadioButton();
                        rButton.Content = buttonText;
                        if (((lastAnswer != null) && buttonAnswer.Equals(lastAnswer)) ||
                            ((lastAnswer == null) && buttonAnswer.Equals(selected)))
                        {
                            rButton.IsChecked = true;
                        }
                        else
                        {
                            rButton.IsChecked = false;
                        }

                        rButton.Tag        = buttonAnswer;
                        rButton.Visibility = Visibility.Visible;
                        rButton.Margin     = new Thickness(5);
                        choicesPanel.Children.Add(rButton);

                        if (firstRadioButton == null)
                        {
                            firstRadioButton = rButton;
                        }
                    }
                }

                if ((GetCheckedChoiceButton() == null) && (firstButton != null))
                {
                    firstButton.IsDefault = true;
                }

                if ((GetCheckedChoiceButton() == null) && (firstRadioButton != null))
                {
                    firstRadioButton.IsChecked = true;
                }

                relationAsserted = ((LexemeValue)fv["relation-asserted"]).Value;
                competency       = fv["competency"].ToString();

                // Change background when click Prev
                if (fv["state"].ToString().Equals("greeting"))
                {
                    uri = new Uri(currentPath + "\\image\\Login.png", UriKind.RelativeOrAbsolute);
                }
                else
                {
                    uri = new Uri(currentPath + "\\image\\Path.png", UriKind.RelativeOrAbsolute);
                }
                bitmap                = new BitmapImage(uri);
                pathImage.Source      = bitmap;
                prevButton.Background = nextButton.Background = this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF75B2B3"));

                // Update progressBar
                progressBar.Value = variableAsserts.Count * 100 / 13;
            }

            /*====================================*/
            /* Set the label to the display text. */
            /*====================================*/
            string messageString = ((StringValue)fv["display"]).Value;
            double theWidth      = ComputeTextBoxWidth(messageString);

            messageTextBox.Width    = theWidth;
            messageTextBox.MinWidth = theWidth;
            messageTextBox.Text     = messageString;
        }
コード例 #17
0
ファイル: MainForm.cs プロジェクト: nkowalik/MediApp
        private void NextUIState()
        {
            messageLabel.Visible = false;
            nextButton.Visible   = false;
            prevButton.Visible   = false;
            label1.Visible       = false;
            pictureBox1.Visible  = false;
            pictureBox2.Visible  = false;
            choicesPanel.Controls.Clear();
            _theEnv.Run();

            // Get the state-list.
            String evalStr = "(find-all-facts ((?f state-list)) TRUE)";

            using (FactAddressValue allFacts = (FactAddressValue)((MultifieldValue)_theEnv.Eval(evalStr))[0]) {
                string currentID = allFacts.GetFactSlot("current").ToString();
                evalStr = "(find-all-facts ((?f UI-state)) " +
                          "(eq ?f:id " + currentID + "))";
            }

            using (FactAddressValue evalFact = (FactAddressValue)((MultifieldValue)_theEnv.Eval(evalStr))[0]) {
                string state = evalFact.GetFactSlot("state").ToString();
                if (state.Equals("initial"))
                {
                    nextButton.Visible = true;
                    nextButton.Tag     = "Next";
                    nextButton.Text    = "Next";
                    prevButton.Visible = false;
                }
                else if (state.Equals("final"))
                {
                    nextButton.Visible = true;
                    nextButton.Tag     = "Restart";
                    nextButton.Text    = "Restart";
                    prevButton.Visible = false;
                }
                else
                {
                    nextButton.Visible = true;
                    nextButton.Tag     = "Next";
                    prevButton.Tag     = "Prev";
                    prevButton.Visible = true;
                }

                messageLabel.Visible  = true;
                messageLabel.Location = new Point(12, 9);
                messageLabel.Text     = GetString((SymbolValue)evalFact.GetFactSlot("display"));
                Controls.Add(messageLabel);

                using (MultifieldValue validAnswers = (MultifieldValue)evalFact.GetFactSlot("valid-answers")) {
                    String selected = evalFact.GetFactSlot("response").ToString();
                    String question = evalFact.GetFactSlot("display").ToString();
                    switch (question)
                    {
                    case "WelcomeMessage":
                        SetQuestion("Program ma charakter wyłącznie \ninformacyjno-edukacyjny i wynik testu \nnie może być traktowany jak porada, \nkonsultacja lub diagnoza lekarza.");
                        break;

                    case "HighTemperatureQuestion":
                        label1.Visible  = true;
                        label1.Text     = "Korzystając z termometru wybierz aktualną temperaturę swojego ciała";
                        label1.Location = new Point(12, 47);
                        Controls.Add(label1);
                        pictureBox2.Image    = new Bitmap("pasek.jpg");
                        pictureBox2.Location = new Point(216, 86);
                        pictureBox2.Width    = 11;
                        pictureBox2.Height   = 105;
                        pictureBox2.Visible  = true;
                        Controls.Add(pictureBox2);
                        pictureBox1.Image    = new Bitmap("termometrmaly.jpg");
                        pictureBox1.Location = new Point(102, 36);
                        pictureBox1.Width    = 225;
                        pictureBox1.Height   = 235;
                        pictureBox1.Visible  = true;
                        Controls.Add(pictureBox1);
                        termometr = true;     // zdefiniuj inny sposob przekazania wartosci formularza
                        break;

                    case "KichanieQuestion":
                        SetQuestion("Zaznacz 'Tak', jeśli kichasz znacznie \nczęściej niż zdarzało Ci się to dotychczas \n(kilka-kilkanaście razy dziennie).");
                        break;

                    case "PoczucieRozbiciaQuestion":
                        SetQuestion("Zaznacz 'Tak', jeśli czujesz się bardziej \nzmęczony i osłabiony niż zazwyczaj.");
                        break;

                    case "BoleKostnoStawoweQuestion":
                        SetQuestion("Zaznacz 'Tak', jeśli ból występuje i \nw ostatnim czasie nie wykonywałeś \nczynności wymagających dużego wysiłku \nfizycznego lub czujesz sztywność \nstawów po dłuzszym bezruchu.");
                        break;

                    case "BolGlowyQuestion":
                        SetQuestion("Zaznacz 'Tak', jeśli ból nie występował \nprzedtem, nasilił się w ostatnim czasie.");
                        break;

                    case "DreszczeQuestion":
                        SetQuestion("Zaznacz 'Tak', jeśli odczuwasz nieprzyjemny \nchłód oraz drżenie ciała pomimo \ntemperatury pokojowej pomieszczenia, \nw którym się znajdujesz.");
                        break;

                    case "DlugotrwalyKatarQuestion":
                        SetQuestion("Zaznacz 'Tak', jeśli katar trwa \ndłuzej niż 2 tygodnie.");
                        break;

                    case "DryCoughQuestion":
                        SetQuestion("Zaznacz 'Tak, jeśli podczas kaszlenia masz \nuczucie drażnienia w tchawicy, masz duszące \nataki kaszlu lub ustawicznie pokasłujesz. \nKaszel suchy jest męczący, brzmi jak \nposzczekiwanie i nie powoduje \nodkrztuszania wydzieliny.");
                        break;

                    case "SwiszczacyOddechQuestion":
                        SetQuestion("Zaznacz 'Tak' jeśli wydechowi towarzyszy \nciągły, wysoki dzwięk przypominający świst.");
                        break;

                    case "SuchyKaszelQuestion":
                        SetQuestion("Zaznacz 'Tak', jeśli masz napady dusznosci, \nczujesz ucisk w klatce piersiowej, a \nobjawy nasilaja się po wysilku fizycznym.");
                        break;

                    case "RozpulchnienieQuestion":
                        SetQuestion("Zaznacz 'Tak', jeśli z trudem mówisz, nie \nmożesz przełknąć śliny, męczy Cię chrypka. \nOpuchnięte gardło często jest przyczyną \ndotkliwego bólu podczas przełykania.");
                        break;

                    case "ZaczerwienienieQuestion":
                        SetQuestion("Zaznacz 'Tak' jeśli zauważyłeś/aś, że \nmasz przekrwioną błonę śluzową gardła \noraz migdałki. \nNierzadko są one również opuchnięte.");
                        break;
                    }
                    if (!termometr) // jesli pytanie nie dotyczylo temperatury - dodaj przyciski yes/no
                    {
                        int[] coord = { 3, 26 };
                        for (int i = 0; i < validAnswers.Count; i++)
                        {
                            RadioButton rb = new RadioButton();
                            switch ((SymbolValue)validAnswers[i])
                            {
                            case "No":
                                rb.Text = "Nie";
                                break;

                            case "Yes":
                                rb.Text = "Tak";
                                break;
                            }
                            rb.Tag      = rb.Text;
                            rb.Visible  = true;
                            rb.Location = new Point(3, coord[i]);
                            if (i == 0)
                            {
                                rb.Checked = true;
                            }
                            choicesPanel.Controls.Add(rb);
                        }
                    }
                }
            }
        }
コード例 #18
0
        private void NextUIState()
        {
            nextButton.Visible = false;
            prevButton.Visible = false;
            choicesPanel.Controls.Clear();
            Env.Run();

            // Get the state-list.
            String evalStr = "(find-all-facts ((?f state-list)) TRUE)";

            using (FactAddressValue allFacts = (FactAddressValue)((MultifieldValue)Env.Eval(evalStr))[0])
            {
                string currentID = allFacts.GetFactSlot("current").ToString();
                evalStr = "(find-all-facts ((?f UI-state)) " +
                          "(eq ?f:id " + currentID + "))";
            }


            using (FactAddressValue evalFact = (FactAddressValue)((MultifieldValue)Env.Eval(evalStr))[0])
            {
                System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
                gp.AddEllipse(0, 0, pictureBox1.Width - 3, pictureBox1.Height - 3);
                Region rg = new Region(gp);
                pictureBox1.Region = rg;
                pictureBox2.Region = rg;
                pictureBox3.Region = rg;
                string state = evalFact.GetFactSlot("state").ToString();
                if (state.Equals("initial"))
                {
                    pictureBox1.Visible = false;
                    pictureBox2.Visible = false;
                    pictureBox3.Visible = false;
                    nextButton.Visible  = true;
                    nextButton.Tag      = "Next";
                    nextButton.Text     = "Next";
                    prevButton.Visible  = false;
                }
                else if (state.Equals("finalPurple"))
                {
                    choicesPanel.Visible = false;
                    pictureBox1.BringToFront();
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(173, 3, 252);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalYellow"))
                {
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(255, 255, 38);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalGreen"))
                {
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(17, 217, 34);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalBlue"))
                {
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(38, 107, 255);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalRed"))
                {
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(255, 38, 38);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalBeige"))
                {
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(247, 231, 139);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalNavy"))
                {
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(22, 8, 66);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalOrange"))
                {
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(255, 157, 0);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalPink"))
                {
                    pictureBox1.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(318, 150);
                    pictureBox1.BackColor = Color.FromArgb(255, 0, 132);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalOrangeGreen"))
                {
                    pictureBox1.Visible   = true;
                    pictureBox2.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(280, 150);
                    pictureBox2.Location  = new Point(360, 150);
                    pictureBox1.BackColor = Color.FromArgb(255, 157, 0);
                    pictureBox2.BackColor = Color.FromArgb(17, 217, 34);
                    prevButton.Visible    = false;
                }
                else if (state.Equals("finalGreenWhiteBeige"))
                {
                    pictureBox1.Visible   = true;
                    pictureBox2.Visible   = true;
                    pictureBox3.Visible   = true;
                    nextButton.Visible    = true;
                    nextButton.Tag        = "Restart";
                    nextButton.Text       = "Restart";
                    pictureBox1.Location  = new Point(250, 150);
                    pictureBox2.Location  = new Point(330, 150);
                    pictureBox3.Location  = new Point(390, 150);
                    pictureBox1.BackColor = Color.FromArgb(17, 217, 34);
                    pictureBox2.BackColor = Color.White;
                    pictureBox3.BackColor = Color.FromArgb(247, 231, 139);
                    prevButton.Visible    = false;
                }
                else
                {
                    pictureBox1.Visible = false;
                    pictureBox2.Visible = false;
                    pictureBox3.Visible = false;
                    nextButton.Visible  = true;
                    nextButton.Tag      = "Next";
                    prevButton.Tag      = "Prev";
                    prevButton.Visible  = true;
                }



                using (MultifieldValue validAnswers = (MultifieldValue)evalFact.GetFactSlot("valid-answers"))
                {
                    String selected = evalFact.GetFactSlot("response").ToString();
                    for (int i = 0; i < validAnswers.Count; i++)
                    {
                        RadioButton rb = new RadioButton();
                        rb.Text     = (SymbolValue)validAnswers[i];
                        rb.Tag      = rb.Text;
                        rb.Visible  = true;
                        rb.Location = new Point(200, 30 * (i + 1));
                        choicesPanel.Controls.Add(rb);
                    }
                }
                messageLabel.Text = GetString((SymbolValue)evalFact.GetFactSlot("display"));
            }
        }
コード例 #19
0
        public override DecisionResult IdentifyTreatment()
        {
            List <Treatment> treatments = new List <Treatment>();
            List <Action>    actions    = new List <Action>();
            List <Reason>    reasons    = new List <Reason>();

            //// Step 1
            //string potassiumValue = null;

            //List<Value> Values = testData.Values("potassium");
            //if (Values.Count > 0)
            //{
            //    potassiumValue = Values[0].ToString();
            //}

            //// Step 2
            //string Dialysis = "NO";

            //Values = testData.Values("dialysis");
            //if (Values.Count() > 0)
            //{
            //    Dialysis = Values[0].ToString().ToUpper();
            //}

            //// Step 3
            //string currentGFR = "";
            //string GFRTrend = "Unknown";

            //Values = testData.Values("gfr");
            //double slope = 0;
            //if (Values.Count() > 0)
            //{
            //    currentGFR = Values[0].ToString();
            //}
            //if (Values.Count() > 1)
            //{
            //    List<double> weights = new List<double>();
            //    List<double> offsets = new List<double>();
            //    List<double> values = new List<double>();
            //    foreach (Value value in Values)
            //    {
            //        double days = value.offset / 86400;
            //        offsets.Add(days);
            //        values.Add((double)value.value);
            //        double new_weight = Math.Pow((1 - test_trend_decay_per_day), days);
            //        weights.Add(Math.Max(0.125, new_weight));
            //    }
            //    double[] lsrResults = LeastSquaresWeightedBestFitLine1(offsets.ToArray(), values.ToArray(), weights.ToArray());
            //    //intercept = results[0];
            //    slope = -lsrResults[1];
            //    // double diff = (y_values[0] - intercept) / intercept;
            //    GFRTrend = "Stable";
            //    if (slope / (double)Values[0].value > 0.1)
            //    {
            //        GFRTrend = "Improving";
            //    }
            //    if (slope / (double)Values[0].value < -0.1)
            //    {
            //        GFRTrend = "Worsening";
            //    }
            //}

            //Values = testData.Values("urine production");
            //string urineProduction = null;
            //if (Values.Count() > 0)
            //{
            //    double urineProductionValue = (double)Values[0].value;
            //    if (urineProductionValue > 0.5) urineProduction = "Normal";
            //    else if (urineProductionValue >= 0.4) urineProduction = "Marginal";
            //    else if (urineProductionValue >= 0.1) urineProduction = "Oliguric";
            //    else urineProduction = "Anuric";
            //}
            //else
            //{
            //    urineProduction = "Unknown";
            //}

            //// Step 4.
            //string TTTstate = "NONE";
            //string timeToRewarming = "over-4-hours";

            //Values = testData.Values("TTT-state");
            //if (Values.Count() > 0)
            //{
            //    TTTstate = Values[0].ToString().ToUpper();
            //}

            //Values = testData.Values("time-to-rewarming");
            //if (Values.Count() > 0)
            //{
            //    timeToRewarming = Values[0].ToString();
            //}

            //// Step 5.
            //string pastLoopDiuretic = "NO";

            //Values = testData.Values("past-loop-diuretic");
            //if (Values.Count() > 0)
            //{
            //    pastLoopDiuretic = Values[0].ToString().ToUpper();
            //}

            //// Step 6.
            //string diarrheaValue = "NO";

            //Values = testData.Values("past-diarrhea");
            //if (Values.Count() > 0)
            //{
            //    diarrheaValue = Values[0].ToString().ToUpper();
            //}

            //// Step 7.
            //string PastSupplementation = "NONE";
            //string PotassiumTrend = "Stable";

            //Values = treatmentData.Values("supplement24hrs");
            //if (Values.Count() > 0 && Values[0].ToString() != "0")
            //{
            //    if(Values[0].value is double)
            //    {
            //        double value = (double)Values[0].value;
            //        if (value == 0) PastSupplementation = "NONE";
            //        else if(value <= 30) PastSupplementation = "20mEq";
            //        else if (value <= 50) PastSupplementation = "40mEq";
            //        else PastSupplementation = "60mEq";
            //    }
            //}

            //Values = testData.Values("potassium");
            //if (Values.Count() > 1)
            //{
            //    if((double)Values[0].value - (double)Values[1].value >= 0.3)
            //    {
            //        PotassiumTrend = "Increasing";
            //    }
            //    if ((double)Values[0].value - (double)Values[1].value <= -0.3)
            //    {
            //        PotassiumTrend = "Decreasing";
            //    }
            //}

            //// Step 8.
            //Values = testData.Values("potassium");
            //string potassiumRange = null;
            //if (Values.Count > 0)
            //{
            //    double potassium = (double)Values[0].value;
            //    if (3.8 <= potassium) potassiumRange = "HIGH";
            //    else if (3.4 <= potassium && potassium < 3.8) potassiumRange = "MED";
            //    else if (3.0 <= potassium && potassium < 3.4) potassiumRange = "LOW";
            //    else potassiumRange = "VLOW";
            //}

            //// Step 9.
            //// Removed by Tzvi

            //// Step 10.
            //string phosphorusRange = "UNKNOWN";

            //Values = testData.Values("phosphorus");
            //if (Values.Count > 0)
            //{
            //    double potassium = (double)Values[0].value;
            //    if (2.0 <= potassium) phosphorusRange = "HIGH";
            //    else if (1.5 < potassium && potassium < 2.0) phosphorusRange = "MED";
            //    else phosphorusRange = "LOW";
            //}

            //// Step 11.
            //string calciumValue = "1.0";

            //Values = testData.Values("calcium, ionized");
            //if (Values.Count() > 0)
            //{
            //    calciumValue = Values[0].ToString();
            //}

            //if (actions.Count == 0) // no errors
            //{
            // Clear old values
            //clips.Eval("(clear)");
            //clips.Load("Hypokalemia.clp");
            //clips.Eval("(reset)"); // load facts from deffacts constructs.
            clips.Clear();
            clips.Load("HypokalemiaV2.clp");
            clips.Reset();     // load facts from deffacts constructs.

            // Set values in CLIPS

            List <string> dataValues = DataValues();

            foreach (string dataValue in dataValues)
            {
                clips.AssertString(dataValue);
            }
////                clips.AssertString("(diagnosis (patient " + patientID + ") (name Hypokalemia))");
//                if (Dialysis != "")
//                {
//                    //(data-value (name dialysis) (patient 123456) (value NO))
//                    string dataValue = "(data-value (patient " + patientID + ") (name dialysis) (value " + Dialysis + "))";
//                    clips.AssertString(dataValue);
//                }
//                if (currentGFR != "")
//                {
//                    //(data-value (name GFR) (patient 123456) (value 45))
//                    string dataValue = "(data-value (patient " + patientID + ") (name GFR) (value " + currentGFR + "))";
//                    clips.AssertString(dataValue);
//                }
//                if (GFRTrend != "")
//                {
//                    //(data-value (name GFR-trend) (patient 123456) (value Stable))
//                    string dataValue = "(data-value (patient " + patientID + ") (name GFR-trend) (value " + GFRTrend + "))";
//                    clips.AssertString(dataValue);
//                }
//                if (urineProduction != null)
//                {
//                    //(data-value (name Urine-production) (patient 123456) (value Normal))
//                    string dataValue = "(data-value (patient " + patientID + ") (name Urine-production) (value " + urineProduction + "))";
//                    clips.AssertString(dataValue);
//                }
//                if (potassiumValue != null)
//                {
//                    //(data-value (name potassium) (patient 123456) (value 3.5))
//                    string dataValue = "(data-value (patient " + patientID + ") (name potassium) (value " + potassiumValue + "))";
//                    clips.AssertString(dataValue);
//                }
//                if (potassiumRange != null)
//                {
//                    //(data-value (name potassium) (patient 123456) (value 3.5))
//                    string dataValue = "(data-value (patient " + patientID + ") (name potassium-range) (value " + potassiumRange + "))";
//                    clips.AssertString(dataValue);
//                }
//                if (phosphorusRange != null)
//                {
//                    //(data-value (name phosphorus) (patient 123456) (value 2.5))
//                    string dataValue = "(data-value (patient " + patientID + ") (name phosphorus-range) (value " + phosphorusRange + "))";
//                    clips.AssertString(dataValue);
//                }
//                if (calciumValue != null)
//                {
//                    //(data-value (name calcium) (patient 123456) (value 2.0))
//                    string dataValue = "(data-value (patient " + patientID + ") (name calcium) (value " + calciumValue + "))";
//                    clips.AssertString(dataValue);
//                }
//                if (diarrheaValue != null)
//                {
//                    //(data-value (name past-diarrhea) (patient 123456) (value NO))
//                    string dataValue = "(data-value (patient " + patientID + ") (name past-diarrhea) (value " + diarrheaValue + "))";
//                    clips.AssertString(dataValue);
//                }
//                if (TTTstate != null)
//                {
//                    //(data-value (name TTT-state) (patient 123456) (value COOLING))
//                    string dataValue = "(data-value (patient " + patientID + ") (name TTT-state) (value " + TTTstate + "))";
//                    clips.AssertString(dataValue);
//                }
//                if (timeToRewarming != null)
//                {
//                    //(data-value (name time-to-rewarming) (patient 123456) (value over-4-hours))
//                    string dataValue = "(data-value (patient " + patientID + ") (name time-to-rewarming) (value " + timeToRewarming + "))";
//                    clips.AssertString(dataValue);
//                }
//                if (pastLoopDiuretic != null)
//                {
//                    //(data-value (name past-loop-diuretic) (patient 123456) (value NO))
//                    string dataValue = "(data-value (patient " + patientID + ") (name past-loop-diuretic) (value " + pastLoopDiuretic + "))";
//                    clips.AssertString(dataValue);
//                }
//                if (PastSupplementation != null)
//                {
//                    //(data-value (name Past-Supplementation) (patient 123456) (value NONE))
//                    string dataValue = "(data-value (patient " + patientID + ") (name Past-Supplementation) (value " + PastSupplementation + "))";
//                    clips.AssertString(dataValue);
//                }
//                if (PotassiumTrend != null)
//                {
//                    //(data-value (name Potassium-trend) (patient 123456) (value Stable))
//                    string dataValue = "(data-value (patient " + patientID + ") (name Potassium-trend) (value " + PotassiumTrend + "))";
//                    clips.AssertString(dataValue);
//                }

            clips.AssertString("(state (patient " + patientID + ") (name Step-1))");

            clips.Run();

            MultifieldValue stateFacts = clips.Eval("(find-all-facts ((?fact state)) TRUE)") as MultifieldValue;

            foreach (FactAddressValue fv in stateFacts)
            {
                string name = ((SymbolValue)fv.GetFactSlot("name"));
            }

            // Get values from CLIPS
            MultifieldValue treatmentFacts = clips.Eval("(find-all-facts ((?treatment treatment)) TRUE)") as MultifieldValue;

            foreach (FactAddressValue fv in treatmentFacts)
            {
                Treatment treatment = new Treatment();
                //treatment.index = (int)((NumberValue)fv.GetFactSlot("index")).GetIntegerValue();
                //treatment.type = ((LexemeValue)fv.GetFactSlot("type")).GetLexemeValue();
                //treatment.med = ((LexemeValue)fv.GetFactSlot("med")).GetLexemeValue();
                //treatment.quantity = ((NumberValue)fv.GetFactSlot("quantity")).GetFloatValue();
                //treatment.units = ((LexemeValue)fv.GetFactSlot("units")).GetLexemeValue();
                //treatment.route = ((LexemeValue)fv.GetFactSlot("route")).GetLexemeValue();
                object tempIndex = fv.GetFactSlot("index");
                if (tempIndex is FloatValue)
                {
                    FloatValue tempValue = (FloatValue)tempIndex;
                    treatment.index = (float)(tempValue);
                    treatment.type  = (string)((SymbolValue)fv.GetFactSlot("type"));
                }
                else if (tempIndex is IntegerValue)
                {
                    IntegerValue tempValue = (IntegerValue)tempIndex;
                    treatment.index = (int)(tempValue);
                    treatment.type  = (string)((SymbolValue)fv.GetFactSlot("type"));
                }
                else
                {
                    treatment.type = tempIndex.ToString();
                }
                //treatment.med = (string)((SymbolValue)fv.GetFactSlot("med"));
                //PrimitiveValue quantitySlot = fv.GetFactSlot("quantity");
                //if (quantitySlot is FloatValue)
                //{
                //    treatment.quantity = (double)((FloatValue)quantitySlot);
                //}
                //else
                //{
                //    treatment.quantity = (int)((IntegerValue)quantitySlot);
                //}
                //treatment.units = (string)((SymbolValue)fv.GetFactSlot("units"));
                treatment.route = ((SymbolValue)fv.GetFactSlot("routes"));
                treatments.Add(treatment);
            }

            MultifieldValue actionFacts = clips.Eval("(find-all-facts ((?action action)) TRUE)") as MultifieldValue;

            foreach (FactAddressValue fv in actionFacts)
            {
                Action action     = new Action();
                string actionText = ((SymbolValue)fv.GetFactSlot("text")).ToString();
                if (!actions.Any(a => a.text == actionText))
                {
                    action.text = actionText;
                    actions.Add(action);
                }
            }

            MultifieldValue reasonFacts = clips.Eval("(find-all-facts ((?reason reason)) TRUE)") as MultifieldValue;

            foreach (FactAddressValue fv in reasonFacts)
            {
                Reason reason = new Reason(
                    0,     // (int)((IntegerValue)fv.GetFactSlot("level")),
                    ((SymbolValue)fv.GetFactSlot("rule")).ToString(),
                    ReplaceReasonText(((SymbolValue)fv.GetFactSlot("text")).ToString()));
                reasons.Add(reason);
            }
            //}

            return(new DecisionResult(treatments, actions, reasons));
        }