Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
07/03/08 12:57:59 (5 months ago)
Author:
tmdugan
Message:

-- openmrs logic-api-refactoring

* added age_max and age_min processing for rules
* added changes to grammar file to ignore reserved words in text

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/branches/logic-api-refactoring/src/api/org/openmrs/arden/ArdenRecognizer.g

    r4615 r4803  
    108108        LINKS="links"; 
    109109        TYPE="type"; 
    110         DATA="data"; 
    111         LOGIC="logic"; 
    112         ACTION="action"; 
    113110        DATE="date"; 
     111        AGE_MIN="age_min"; 
     112        AGE_MAX="age_max"; 
    114113         
    115114        OF = "of"; 
     
    120119        TO = "to"; 
    121120        ANY = "any"; 
     121        RESEARCH = "research"; 
     122        SECOND = "second"; 
     123        OCCUR = "occur"; 
     124        PRESENT = "present"; 
     125        NUMBER = "number"; 
    122126         
    123127} 
     
    285289        action_slot 
    286290        urgency_slot! 
     291        age_min_slot 
     292        age_max_slot 
    287293        ; 
    288294 
     
    383389        | READ | MINIMUM | MIN | MAXIMUM | MAX | LAST | FIRST | EARLIEST | LATEST | EVENT | WHERE | EXIST | EXISTS | PAST 
    384390        | AVERAGE | AVG | SUM | MEDIAN | CONCLUDE | ELSE | ELSEIF | ENDIF | TRUE | FALSE | DATA | LOGIC | ACTION | CALL | WITH 
    385         | TO | ANY 
     391        | TO | ANY | RESEARCH | DAY | SECOND | OCCUR | PURPOSE | PRESENT | NUMBER | KNOWLEDGE 
    386392        ; 
    387393 
    388394text 
    389     : ID | (any_reserved_word) | INTLIT | (LPAREN (ID| INTLIT| (any_reserved_word))* RPAREN)   
     395    : ID | (any_reserved_word) | INTLIT |  
     396    MINUS | COMMA| DOT | DIV | UNDERSCORE|AT|STRING_LITERAL| 
     397    (LPAREN (ID| INTLIT| (any_reserved_word))* RPAREN) 
    390398//    exception 
    391399//    catch [RecognitionException ex] 
     
    960968          | 
    961969         
     970        ; 
     971age_min_slot: 
     972        |  /* empty */ 
     973        | AGE_MIN^ COLON INTLIT age_code ENDBLOCK 
     974        ; 
     975age_max_slot: 
     976        |  /* empty */ 
     977        | AGE_MAX^ COLON INTLIT age_code ENDBLOCK 
     978        ; 
     979 
     980age_code 
     981        : "days" | "weeks" | "months" | "years" 
    962982        ; 
    963983 
     
    12691289           
    12701290          | ((EXIST | EXISTS) 
    1271           {s+=b;obj.setReadType("last"); obj.setHowMany("1");System.err.println("ReadType = Exist");} 
     1291          {s+=b;obj.setReadType("exist"); obj.setHowMany("1");System.err.println("ReadType = Exist");} 
    12721292           b=readAST[obj, instr])  
    12731293           
     
    14391459{String a,b;} 
    14401460: ( 
    1441     #(CALL b=exprStringAST[obj, key] {obj.SetConceptVar(b);} a = exprStringAST [obj, b] {obj.setReadType("call"); obj.AddConcept(a);
     1461    #(CALL b=exprStringAST[obj, key] {obj.SetConceptVar(b);} a = exprStringAST [obj, b] {obj.setReadType("call");
    14421462       
    14431463     )  
     
    14481468{String a,b;} 
    14491469: ( 
    1450     #(CALL b=exprStringAST[obj, key] a = exprStringAST [obj, b] {obj.addCall(b,a);} 
     1470    #(CALL b=callStringAST[obj, key] a = callStringAST [obj, b] {obj.addCall(b,a);} 
    14511471       
    14521472     )  
     
    15281548        ; 
    15291549 
     1550callStringAST [MLMObject obj, String instr] returns [String s=""] 
     1551{String a="",b="";} 
     1552: 
     1553( 
     1554        #(ift:ID  
     1555                              { a = ift.getText(); System.err.println("text = " + a);  
     1556                                s=a; 
     1557                              }   
     1558           )                   
     1559  ) 
     1560; 
    15301561 
    15311562exprStringAST [MLMObject obj, String instr] returns [String s=""] 
     
    17541785: //#(COLON {System.err.println("\n"); System.err.println("-------Starting Action--------");}  
    17551786         ( 
    1756            {System.err.println("-----------Starting Write -------");} s = writeAST[obj] {obj.addAction(s); System.err.println("\n");System.err.println("-----------End Write -------");} 
     1787           {System.err.println("-----------Starting Write -------");} s = writeAST[obj] { System.err.println("\n");System.err.println("-----------End Write -------");} 
    17571788            | {System.err.println("-----------Starting CALL -------"); a = "" ;} callActionAST[obj, a]  {System.err.println("\n");System.err.println("-----------End CALL -------");} 
    17581789         )*  
     
    17741805           | (i:STRING_LITERAL  {s += i.getText();} /* {a = i.getText(); s += a.substring(1, a.length()-1); } */  )  /* get rid of "" sorrounding each string literal */ 
    17751806       )* 
    1776                        
     1807       {obj.addAction(s);}             
    17771808       ( 
    17781809          AT idat: ID {obj.setAt(idat.getText());}               
     
    18341865           ) 
    18351866          */ 
     1867          |#(AGE_MIN  
     1868              COLON {s += " Age_Min: "; }  b = doubleAST[obj] {obj.setAgeMin(b); s += b; s += "\n";}  
     1869           ) 
     1870           |#(AGE_MAX  
     1871              COLON {s += " Age_Max: "; }  b = doubleAST[obj] {obj.setAgeMax(b); s += b; s += "\n";}  
     1872           ) 
    18361873                 | a = textAST[obj] {s += a;} ENDBLOCK {s += "\n";}              
    18371874        ) 
     
    18781915           ) 
    18791916          */ 
     1917          |#(AGE_MIN  
     1918              COLON   b = doubleAST[obj] {obj.setAgeMin(b); s += b; s += "\n";}  
     1919           ) 
     1920           |#(AGE_MAX  
     1921              COLON   b = doubleAST[obj] {obj.setAgeMax(b); s += b; s += "\n";}  
     1922           ) 
    18801923                 | a = textAST[obj] {s += a;} ENDBLOCK {s += "\n";}              
    18811924        )