i am VERY new to CLIPS and trying to create an expert system for medical diagnosis. Of course it is just for practice. My code runs so far, however, there are a few things I couldn't get to work.
For the first 3 symptoms (fever, cough, fatigue) if any 2 are answered yes it outputs a diagnosis. If not, it continues on to ask the patient about the less common symptoms. Right now I have made it so that if even one of the uncommon symptomps are answered yes, there is a diagnosis. However, I want to make it so that if atleast 3 of them are answered yes it outputs a diagnosis. The problem is that i dont know how to make a rule that checks for this, without having to make a bunch of separate rules checking for each and every possibility of yes and no combinations which would be tedious.
Here is a link to my code as it is rather long to put on here. https://codeshare.io/arBpq6
Define some deftemplates so you can represent your questions and answers as facts.
Your system has three tiers of questions which can now be represented as facts:
A generic rule can now be created for asking questions. Questions are removed once answered and questions will not be asked until all questions from higher tiers have been answered.
You can now add rules for each tier that look for a specific number of answers: