Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 3460

Show
Ignore:
Timestamp:
02/22/08 15:04:38 (11 months ago)
Author:
tmdugan
Message:

-- atd

* made changes to accommodate changes made in dss 2.07

Files:

Legend:

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

    r3447 r3460  
    6565        <classpathentry kind="lib" path="/dss/dist"/> 
    6666        <classpathentry kind="lib" path="lib-common/openmrs-api-1.2.0.3328.jar" sourcepath="/openmrs_logic/src"/> 
    67         <classpathentry kind="lib" path="lib-common/dss-2.06.jar"/> 
     67        <classpathentry kind="lib" path="lib-common/dss-2.07.jar"/> 
    6868        <classpathentry kind="output" path="build"/> 
    6969</classpath> 
  • openmrs-modules/atd/metadata/config.xml

    r3447 r3460  
    77        <id>atd</id> 
    88        <name>ATD</name> 
    9         <version>1.09</version> 
     9        <version>1.10</version> 
    1010        <package>org.openmrs.module.@MODULE_ID@</package> 
    1111        <author>Tammy Dugan</author> 
  • openmrs-modules/atd/src/org/openmrs/module/atd/TeleformTranslator.java

    r3447 r3460  
    1515import org.apache.commons.logging.Log; 
    1616import org.apache.commons.logging.LogFactory; 
     17import org.openmrs.Concept; 
    1718import org.openmrs.Field; 
    1819import org.openmrs.FieldType; 
     
    246247                 
    247248                int dssMergeCounter = 0; 
     249                String mode = "PRODUCE"; 
     250 
     251                HashMap<String,Object> parameters = new HashMap<String,Object>(); 
     252                 
     253                parameters.put("formInstanceId", formInstanceId); 
     254                 
     255                if(encounterId != null) 
     256                { 
     257                        parameters.put("encounterId", encounterId); 
     258                } 
     259                 
     260                parameters.put("mode", mode); 
    248261                 
    249262                while (iter.hasNext()) 
     
    269282                        if(currField.getFieldType().equals(atdMergeType)) 
    270283                        { 
     284                                Concept concept = currField.getConcept(); 
     285                                if (concept != null) 
     286                                { 
     287                                        try 
     288                                        { 
     289                                                parameters.put("concept", concept.getName().getName()); 
     290                                        } catch (Exception e) 
     291                                        { 
     292                                        } 
     293                                }else 
     294                                { 
     295                                        parameters.put("concept",null); 
     296                                } 
    271297                                if (dssService.getRules(defaultValue).size()>0) 
    272298                                {        
    273299                                        dssManager.populateDssElements( 
    274                                                         defaultValue, false); 
     300                                                        defaultValue, false,parameters); 
    275301                                        result = processDssElements(dssManager, dssMergeCounter, 
    276302                                                        currField.getFieldId(),  
     
    280306                                { 
    281307                                         
    282                                         result = atdService.evaluateRule(currField.getConcept(),defaultValue, 
    283                                                         formInstanceId,encounterId,patient,"PRODUCE",null); 
     308                                        result = atdService.evaluateRule(defaultValue, 
     309                                                        patient,parameters); 
    284310                                } 
    285311                                 
  • openmrs-modules/atd/src/org/openmrs/module/atd/impl/ATDServiceImpl.java

    r3447 r3460  
    189189                        } 
    190190                } 
    191                  
     191                String mode = "CONSUME"; 
     192                 
     193                HashMap<String, Object> parameters =  
     194                        new HashMap<String,Object>(); 
    192195                Set<FormField> fieldsWithValues = formFieldToValue.keySet(); 
    193196                Concept currConcept = null; 
     
    195198                Iterator<String> valuesIter = null; 
    196199                Obs obs = null; 
    197                 String weightUnit = this.evaluateRule(null, "birthdate>weightSF",  
    198                                 formInstanceId, encounterId, patient,"PRODUCE",null); 
     200                String weightUnit = this.evaluateRule( "birthdate>weightSF",  
     201                                  patient,parameters); 
     202                 
     203                parameters.put("formInstanceId", formInstanceId); 
     204                 
     205                parameters.put("mode", mode); 
    199206                 
    200207                // merge list of values into single value based on concept type 
     
    206213                        String defaultValue = currField.getField().getDefaultValue(); 
    207214                         
     215                        if (currConcept != null) 
     216                        { 
     217                                try 
     218                                { 
     219                                        parameters.put("concept", currConcept.getName()); 
     220                                } catch (Exception e) 
     221                                { 
     222                                } 
     223                        }else 
     224                        { 
     225                                parameters.put("concept", null); 
     226                        } 
     227                         
     228                        String fieldName = currField.getField().getName(); 
     229                        if(fieldName != null) 
     230                        { 
     231                                parameters.put("fieldName", fieldName); 
     232                        } 
    208233                        values = formFieldToValue.get(currField); 
    209234                         
     
    235260                        if (defaultValue != null) 
    236261                        { 
    237                                 this.evaluateRule(currConcept, defaultValue, 
    238                                                 formInstanceId, encounterId, patient,"CONSUME", 
    239                                                 currField.getField().getName()); 
     262                                this.evaluateRule(defaultValue, patient, parameters); 
    240263                                continue; 
    241264                        } 
     
    410433        } 
    411434 
    412         public String evaluateRule(Concept concept, 
    413                         String ruleEvalString,  
    414                         Integer formInstanceId,  
    415                         Integer encounterId,Patient patient, 
    416                         String mode,String fieldName) 
     435        public String evaluateRule(String ruleEvalString,Patient patient, 
     436                        HashMap<String, Object> baseParameters) 
    417437        { 
    418438                DssService dssService = (DssService) Context.getService(DssService.class); 
     
    421441                        new StringTokenizer(ruleEvalString,">"); 
    422442                ArrayList<String> ruleTokens = new ArrayList<String>(); 
     443                HashMap<String, Object> parameters = null; 
    423444                 
    424445                while(tokenizer.hasMoreTokens()) 
     
    426447                        ruleTokens.add(tokenizer.nextToken().trim()); 
    427448                } 
    428                  
    429                 Map<String, Object> parameters = new HashMap<String, Object>(); 
    430                  
     449                parameters = new HashMap<String, Object>(); 
     450                parameters.putAll(baseParameters); 
     451                        
    431452                for (String ruleToken : ruleTokens) 
    432453                { 
    433                          
    434454                        if(ruleToken.contains("\"")) 
    435455                        { 
    436                                 parameters = new HashMap<String, Object>(); 
    437456                                tokenizer  = new StringTokenizer(ruleToken.substring(1,ruleToken.length()-1),","); 
    438457                                int position = 0; 
     
    446465                         
    447466                        Rule rule = new Rule(); 
    448                          
    449                         if (concept != null) 
    450                         { 
    451                                 try 
    452                                 { 
    453                                         parameters.put("concept", concept.getName().getName()); 
    454                                 } catch (Exception e) 
    455                                 { 
    456                                 } 
    457                         } 
    458                          
    459                         if(formInstanceId != null) 
    460                         { 
    461                                 parameters.put("formInstanceId", formInstanceId); 
    462                         } 
    463                          
    464                         if(encounterId != null) 
    465                         { 
    466                                 parameters.put("encounterId", encounterId); 
    467                         } 
    468                          
    469                         if(mode != null) 
    470                         { 
    471                                 parameters.put("mode", mode); 
    472                         } 
    473                          
    474                         if(fieldName != null) 
    475                         { 
    476                                 parameters.put("fieldName", fieldName); 
    477                         } 
    478467                         
    479468                        rule.setShortName(ruleToken); 
     
    483472                                dssService.runRule(patient, rule, logicService); 
    484473                        parameters = new HashMap<String, Object>(); 
     474                        parameters.putAll(baseParameters); 
    485475                         
    486476                        if (result != null) 
  • openmrs-modules/atd/src/org/openmrs/module/atd/service/ATDService.java

    r3447 r3460  
    33import java.io.InputStream; 
    44import java.io.OutputStream; 
     5import java.util.HashMap; 
    56 
    67import org.openmrs.Concept; 
     
    4849        public FormInstance addFormInstance(Integer formId); 
    4950         
    50         public String evaluateRule(Concept concept, 
    51                         String ruleEvalString,  
    52                         Integer formInstanceId,  
    53                         Integer encounterId,Patient patient, 
    54                         String mode,String fieldName); 
     51        public String evaluateRule(String ruleEvalString,Patient patient, 
     52                        HashMap<String, Object> baseParameters); 
    5553         
    5654        public void addPatientATD(int patientId, Integer formId, DssElement dssElement,