title: creating a simple rule engine in java
body: <p>I am exploring different ways to create a simple business rule engine in Java. I need to present the client with a simple webapp that lets him configure a bunch of rules. A sample of rule base might look like this :</p>
  
  <p>Here's example:</p>
  
  <pre><code> IF (PATIENT_TYPE = "A" AND ADMISSION_TYPE="O")
   SEND TO OUTPATIENT
   ELSE IF PATIENT_TYPE = "B" 
   SEND TO INPATIENT
  </code></pre>
  
  <p>The rule engine is pretty simple, the final action could be just one of two actions, sending to inpatient or outpatient. The operators involved in an expression could be <code>=,&gt;,&lt;,!=</code> and logical operators between expressions are <code>AND, OR and NOT</code>. </p>
  
  <p>I want to build a web application where user will write in a small script in a <code>textarea</code>, and I would evaluate the expression - this way, business rules are explained in simple English and business user has complete control on logic.</p>
  
  <p>From the research I did so far, I came across, <code>ANTLR</code> and writing my own scripting language as possible options to solve this problem. I haven't explore options like Drools rules engine, because I have a feeling that it might be an overkill here. Have you had any experience in solving these kind of problems? If yes, how did you go about it?  </p>