title: Declaring object in drools excel descision table
body: <p>I'm trying to use a Drools decision table.
  The problem I'm facing is that drools does not assign a variable for me with the current object.</p>
  
  <p>I get this error from drools:</p>
  
  <blockquote>
    <p>Drools error: Rule Compilation error patient cannot be resolved</p>
  </blockquote>
  
  <p>My excel file looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/LQTWZ.png" alt="enter image description here"></p>
  
  <p>And part of my lab code looks like this:</p>
  
  <pre><code>DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration();
          dtconf.setInputType(DecisionTableInputType.XLS);
          dtconf.setWorksheetName("Sheet1"); 
  
          KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
          Resource r = ResourceFactory.newClassPathResource("rules.xls");
          kbuilder.add(r, ResourceType.DTABLE, dtconf);
  
          SpreadsheetCompiler compiler = new SpreadsheetCompiler();
          String drl = compiler.compile(r.getInputStream(), InputType.XLS);
  
          System.out.println(drl);
  
          if(kbuilder.hasErrors()) {
              for(KnowledgeBuilderError err : kbuilder.getErrors()) {
                  System.out.println("Drools error: " + err.getMessage());
              }
              model.addAttribute("droolErrors", kbuilder.getErrors());
              return "index";
          }
  
          KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
          knowledgeBase.addKnowledgePackages(kbuilder.getKnowledgePackages()); 
          StatefulKnowledgeSession dsess = knowledgeBase.newStatefulKnowledgeSession();
  
          for(Patient p : patients) {
              dsess.insert(p);
          }
  
          model.addAttribute("factCount", dsess.getFactCount());
  
          KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(dsess, "test"); 
  
          int res = dsess.fireAllRules();
          System.out.println(res);
          dsess.dispose();
  
  
          logger.close();
  </code></pre>
  
  <p>The generated drl looks like this:</p>
  
  <pre><code>package com.sorkmos.drools.domain;
  //generated from Decision Table
  import com.sorkmos.drools.domain.*;
  // rule values at C11, header at C6
  rule "Risks rules_11"
      when
          Patient(age == 75)
      then
          patient.setAge(22);
  end
  
  
  Drools error: Rule Compilation error patient cannot be resolved
  </code></pre>
  
  <p>It's quite obvious I need to set the "patient" variable. But I can't figure out how. 
  A correct drl version would be like this:</p>
  
  <pre><code>package com.sorkmos.drools.domain;
  //generated from Decision Table
  import com.sorkmos.drools.domain.*;
  // rule values at C11, header at C6
  rule "Risks rules_11"
      when
          Patient(age == 75);
          patient: Patient();
      then
          patient.setAge(22);
  end
  </code></pre>