Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 3386

Show
Ignore:
Timestamp:
02/14/08 15:50:53 (9 months ago)
Author:
tmdugan
Message:

-- dss

* removed postprocessing method from DssRule interface
* changed runRule methods in DssService to return an ArrayList of Results instead of Strings

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/dss/.classpath

    r3303 r3386  
    6262        <classpathentry kind="lib" path="lib-common/tests-openmrs-api-1.2.0.3085.jar"/> 
    6363        <classpathentry kind="lib" path="lib-common/web-openmrs-api-1.2.0.3085.jar"/> 
    64         <classpathentry kind="lib" path="lib-common/openmrs-api-1.2.0.3204.jar"/> 
     64        <classpathentry kind="lib" path="lib-common/openmrs-api-1.2.0.3328.jar"/> 
    6565        <classpathentry kind="output" path="build"/> 
    6666</classpath> 
  • openmrs-modules/dss/metadata/config.xml

    r3289 r3386  
    77        <id>dss</id> 
    88        <name>Dss</name> 
    9         <version>2.03</version> 
     9        <version>2.04</version> 
    1010        <package>org.openmrs.module.@MODULE_ID@</package> 
    1111        <author>Vibha Anand and Tammy Dugan</author> 
  • openmrs-modules/dss/src/org/openmrs/module/dss/DssElement.java

    r3119 r3386  
    1111{ 
    1212        private String text = null; 
    13         private int ruleId = -1
    14         private int fieldId = -1
     13        private Integer ruleId = null
     14        private Integer fieldId = null
    1515         
    1616        /** 
  • openmrs-modules/dss/src/org/openmrs/module/dss/DssManager.java

    r3203 r3386  
    1212import org.openmrs.api.AdministrationService; 
    1313import org.openmrs.api.context.Context; 
     14import org.openmrs.logic.result.Result; 
    1415import org.openmrs.module.dss.hibernateBeans.Rule; 
    1516import org.openmrs.module.dss.service.DssService; 
     
    3031        } 
    3132         
    32         public String evalRuleAsString(Rule rule) 
    33         { 
    34                 ArrayList<String> results = this.evalRule(rule); 
    35                 if(results != null && results.size()>0) 
    36                 { 
    37                         return results.get(0); 
    38                 } 
    39                 return null; 
    40         } 
    41          
    42         public ArrayList<String> evalRule(Rule rule) 
    43         { 
    44                 DssService dssService = (DssService) Context 
    45                                 .getService(DssService.class); 
    46             ArrayList<Rule> ruleList = new ArrayList<Rule>(); 
    47                 ruleList.add(rule); 
    48                  
    49                 return dssService.runRules(this.patient, ruleList); 
    50         } 
    51  
    5233        public void populateDssElements(int numDssElements,String type, boolean override) 
    5334        { 
     
    7859                ArrayList<Rule> ruleList = null; 
    7960                DssElement currDssElement = null; 
    80                 ArrayList<String> results = null; 
     61                ArrayList<Result> results = null; 
    8162                ArrayList<Rule> processedRules = null; 
    82                 String currResult = null; 
     63                Result currResult = null; 
    8364                int batchSize = numDssElements; 
    8465                AdministrationService adminService = Context.getAdministrationService(); 
     
    11394                                if (currResult != null) 
    11495                                { 
    115                                         currDssElement = new DssElement(currResult
     96                                        currDssElement = new DssElement(currResult.toString()
    11697                                                        currRule.getRuleId()); 
    11798                                        dssElements.add(currDssElement); 
  • openmrs-modules/dss/src/org/openmrs/module/dss/DssRule.java

    r3261 r3386  
    2727        public String getAction(); 
    2828        public String getType(); 
    29          
    30         /** 
    31          * Allows custom formatting to be applied to  
    32          * a Result from a rule evaluation 
    33          * @param ruleResult Result from a rule evaluation 
    34          * @return 
    35          */ 
    36         public String postprocessing(Result ruleResult); 
    3729} 
  • openmrs-modules/dss/src/org/openmrs/module/dss/impl/DssServiceImpl.java

    r3289 r3386  
    11package org.openmrs.module.dss.impl; 
    22 
    3 import java.lang.reflect.InvocationTargetException; 
    43import java.lang.reflect.Method; 
    54import java.util.ArrayList; 
     
    5554                        ArrayList<Rule> ruleList) 
    5655        { 
    57                 ArrayList<String> results = this.runRules(p, ruleList); 
     56                return this.runRulesAsString(p, ruleList, Context.getLogicService()); 
     57        } 
     58         
     59        public String runRulesAsString(Patient p,  
     60                        ArrayList<Rule> ruleList, LogicService logicService) 
     61        { 
     62                ArrayList<Result> results = this.runRules(p, ruleList); 
    5863                String reply = ""; 
    5964                 
     
    6368                } 
    6469                                 
    65                 for(String result:results) 
     70                for(Result result:results) 
    6671                { 
    6772                        if(result != null) 
     
    7378        } 
    7479         
    75         public ArrayList<String> runRules(Patient p, 
    76                         ArrayList<Rule> ruleList) 
    77         { 
    78                 ArrayList<String> results = new ArrayList<String>(); 
    79                 String resultString = null; 
    80                 org.openmrs.logic.Rule currRule = null; 
     80        public Result runRule(Patient p, Rule rule) 
     81        { 
     82                return this.runRule(p, rule, Context.getLogicService()); 
     83        } 
     84         
     85        public Result runRule(Patient p, Rule rule, LogicService logicService) 
     86        { 
     87                ArrayList<Rule> ruleList = new ArrayList<Rule>(); 
     88                ruleList.add(rule); 
     89                 
     90                ArrayList<Result> results =  
     91                        this.runRules(p, ruleList, logicService); 
     92                 
     93                if(results != null && results.size()>0) 
     94                { 
     95                        return results.get(0); 
     96                } 
     97                 
     98                return Result.emptyResult(); 
     99        } 
     100         
     101        public ArrayList<Result> runRules(Patient p, ArrayList<Rule> ruleList) 
     102        { 
     103                return this.runRules(p, ruleList, Context.getLogicService()); 
     104        } 
     105         
     106        public ArrayList<Result> runRules(Patient p, 
     107                        ArrayList<Rule> ruleList,LogicService logicSvc) 
     108        { 
     109                ArrayList<Result> results = new ArrayList<Result>(); 
    81110                Map<String,Object> parameters = null; 
    82111                String ruleName = null; 
     
    85114                { 
    86115                        Context.openSession(); 
    87                         LogicService logicSvc = Context.getLogicService(); 
    88116                         
    89117                        for (Rule rule : ruleList) 
    90118                        {                
    91                                 resultString = null; 
    92119                                ruleName = rule.getShortName(); 
    93120                                parameters = rule.getParameters(); 
     
    110137                                { 
    111138                                        log.error("Error evaluating rule: "+ruleName,e); 
    112                                         results.add(""); 
     139                                        results.add(null); 
    113140                                        continue; 
    114141                                } 
    115142                                 
    116                                 currRule = logicSvc.getRule(ruleName); 
    117                                  
    118                                 if(currRule instanceof DssRule) 
    119                                 { 
    120                                         resultString = ((DssRule) currRule).postprocessing(result); 
    121                                 }else 
    122                                 { 
    123                                         resultString = result.toString(); 
    124                                 } 
    125                                  
    126                                 results.add(resultString); 
     143                                results.add(result); 
    127144                        } 
    128145 
  • openmrs-modules/dss/src/org/openmrs/module/dss/service/DssService.java

    r3203 r3386  
    66import org.openmrs.Patient; 
    77import org.openmrs.api.APIException; 
     8import org.openmrs.logic.LogicService; 
     9import org.openmrs.logic.result.Result; 
    810import org.openmrs.module.dss.DssRule; 
    911import org.openmrs.module.dss.hibernateBeans.Rule; 
     
    1113public interface DssService 
    1214{ 
    13         public ArrayList<String> runRules(Patient p,   
    14                         ArrayList<Rule> ruleList); 
    1515        public String runRulesAsString(Patient p,  
    1616                        ArrayList<Rule> ruleList); 
     17 
     18        public String runRulesAsString(Patient p, ArrayList<Rule> ruleList, 
     19                        LogicService logicService); 
     20 
     21        public Result runRule(Patient p, Rule rule); 
     22 
     23        public Result runRule(Patient p, Rule rule, LogicService logicService); 
     24 
     25        public ArrayList<Result> runRules(Patient p,ArrayList<Rule> ruleList); 
     26 
     27        public ArrayList<Result> runRules(Patient p,ArrayList<Rule> ruleList, 
     28                        LogicService logicSvc); 
     29 
    1730        public Rule getRule(int ruleId) throws APIException; 
    1831 
  • openmrs-modules/dss/web/src/org/openmrs/module/dss/web/RunRulesController.java

    r3289 r3386  
    1212import org.openmrs.Patient; 
    1313import org.openmrs.api.context.Context; 
     14import org.openmrs.logic.result.Result; 
    1415import org.openmrs.module.dss.hibernateBeans.Rule; 
    1516import org.openmrs.module.dss.service.DssService; 
     
    6263                                ruleList.add(currRule); 
    6364                        } 
    64                         ArrayList<String> results = dssService.runRules(patient,  
     65                        ArrayList<Result> results = dssService.runRules(patient,  
    6566                                        ruleList); 
    6667                        if (results != null) 
     
    6970                                { 
    7071                                        Rule currRule = rules.get(i); 
    71                                         String currResult = results.get(i)
     72                                        String currResult = results.get(i).toString()
    7273                                        if (currResult != null) 
    7374                                        {