Changeset 3386
- Timestamp:
- 02/14/08 15:50:53 (9 months ago)
- Files:
-
- openmrs-modules/dss/.classpath (modified) (1 diff)
- openmrs-modules/dss/lib-common/openmrs-api-1.2.0.3204.jar (deleted)
- openmrs-modules/dss/lib-common/openmrs-api-1.2.0.3328.jar (added)
- openmrs-modules/dss/metadata/config.xml (modified) (1 diff)
- openmrs-modules/dss/src/org/openmrs/module/dss/DssElement.java (modified) (1 diff)
- openmrs-modules/dss/src/org/openmrs/module/dss/DssManager.java (modified) (4 diffs)
- openmrs-modules/dss/src/org/openmrs/module/dss/DssRule.java (modified) (1 diff)
- openmrs-modules/dss/src/org/openmrs/module/dss/impl/DssServiceImpl.java (modified) (6 diffs)
- openmrs-modules/dss/src/org/openmrs/module/dss/service/DssService.java (modified) (2 diffs)
- openmrs-modules/dss/web/src/org/openmrs/module/dss/web/RunRulesController.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs-modules/dss/.classpath
r3303 r3386 62 62 <classpathentry kind="lib" path="lib-common/tests-openmrs-api-1.2.0.3085.jar"/> 63 63 <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.3 204.jar"/>64 <classpathentry kind="lib" path="lib-common/openmrs-api-1.2.0.3328.jar"/> 65 65 <classpathentry kind="output" path="build"/> 66 66 </classpath> openmrs-modules/dss/metadata/config.xml
r3289 r3386 7 7 <id>dss</id> 8 8 <name>Dss</name> 9 <version>2.0 3</version>9 <version>2.04</version> 10 10 <package>org.openmrs.module.@MODULE_ID@</package> 11 11 <author>Vibha Anand and Tammy Dugan</author> openmrs-modules/dss/src/org/openmrs/module/dss/DssElement.java
r3119 r3386 11 11 { 12 12 private String text = null; 13 private int ruleId = -1;14 private int fieldId = -1;13 private Integer ruleId = null; 14 private Integer fieldId = null; 15 15 16 16 /** openmrs-modules/dss/src/org/openmrs/module/dss/DssManager.java
r3203 r3386 12 12 import org.openmrs.api.AdministrationService; 13 13 import org.openmrs.api.context.Context; 14 import org.openmrs.logic.result.Result; 14 15 import org.openmrs.module.dss.hibernateBeans.Rule; 15 16 import org.openmrs.module.dss.service.DssService; … … 30 31 } 31 32 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) Context45 .getService(DssService.class);46 ArrayList<Rule> ruleList = new ArrayList<Rule>();47 ruleList.add(rule);48 49 return dssService.runRules(this.patient, ruleList);50 }51 52 33 public void populateDssElements(int numDssElements,String type, boolean override) 53 34 { … … 78 59 ArrayList<Rule> ruleList = null; 79 60 DssElement currDssElement = null; 80 ArrayList< String> results = null;61 ArrayList<Result> results = null; 81 62 ArrayList<Rule> processedRules = null; 82 StringcurrResult = null;63 Result currResult = null; 83 64 int batchSize = numDssElements; 84 65 AdministrationService adminService = Context.getAdministrationService(); … … 113 94 if (currResult != null) 114 95 { 115 currDssElement = new DssElement(currResult ,96 currDssElement = new DssElement(currResult.toString(), 116 97 currRule.getRuleId()); 117 98 dssElements.add(currDssElement); openmrs-modules/dss/src/org/openmrs/module/dss/DssRule.java
r3261 r3386 27 27 public String getAction(); 28 28 public String getType(); 29 30 /**31 * Allows custom formatting to be applied to32 * a Result from a rule evaluation33 * @param ruleResult Result from a rule evaluation34 * @return35 */36 public String postprocessing(Result ruleResult);37 29 } openmrs-modules/dss/src/org/openmrs/module/dss/impl/DssServiceImpl.java
r3289 r3386 1 1 package org.openmrs.module.dss.impl; 2 2 3 import java.lang.reflect.InvocationTargetException;4 3 import java.lang.reflect.Method; 5 4 import java.util.ArrayList; … … 55 54 ArrayList<Rule> ruleList) 56 55 { 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); 58 63 String reply = ""; 59 64 … … 63 68 } 64 69 65 for( Stringresult:results)70 for(Result result:results) 66 71 { 67 72 if(result != null) … … 73 78 } 74 79 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>(); 81 110 Map<String,Object> parameters = null; 82 111 String ruleName = null; … … 85 114 { 86 115 Context.openSession(); 87 LogicService logicSvc = Context.getLogicService();88 116 89 117 for (Rule rule : ruleList) 90 118 { 91 resultString = null;92 119 ruleName = rule.getShortName(); 93 120 parameters = rule.getParameters(); … … 110 137 { 111 138 log.error("Error evaluating rule: "+ruleName,e); 112 results.add( "");139 results.add(null); 113 140 continue; 114 141 } 115 142 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); 127 144 } 128 145 openmrs-modules/dss/src/org/openmrs/module/dss/service/DssService.java
r3203 r3386 6 6 import org.openmrs.Patient; 7 7 import org.openmrs.api.APIException; 8 import org.openmrs.logic.LogicService; 9 import org.openmrs.logic.result.Result; 8 10 import org.openmrs.module.dss.DssRule; 9 11 import org.openmrs.module.dss.hibernateBeans.Rule; … … 11 13 public interface DssService 12 14 { 13 public ArrayList<String> runRules(Patient p,14 ArrayList<Rule> ruleList);15 15 public String runRulesAsString(Patient p, 16 16 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 17 30 public Rule getRule(int ruleId) throws APIException; 18 31 openmrs-modules/dss/web/src/org/openmrs/module/dss/web/RunRulesController.java
r3289 r3386 12 12 import org.openmrs.Patient; 13 13 import org.openmrs.api.context.Context; 14 import org.openmrs.logic.result.Result; 14 15 import org.openmrs.module.dss.hibernateBeans.Rule; 15 16 import org.openmrs.module.dss.service.DssService; … … 62 63 ruleList.add(currRule); 63 64 } 64 ArrayList< String> results = dssService.runRules(patient,65 ArrayList<Result> results = dssService.runRules(patient, 65 66 ruleList); 66 67 if (results != null) … … 69 70 { 70 71 Rule currRule = rules.get(i); 71 String currResult = results.get(i) ;72 String currResult = results.get(i).toString(); 72 73 if (currResult != null) 73 74 {