@EventSubscriber(topic = "executeRuleHICData") public IHICData executeRuleHICData(IHICData dataObject) throws Exception { this.hicData = dataObject; System.out.println("-----Inside ExecuteRuleHICData----hicData=" + hicData); List<String> resultList = new ArrayList<String>(); try { String factInStrFormat = hicData.getData().getSqlQuery(); hicData.setUniqueID(factInStrFormat); System.out.println("-------Inside Execute RULES---factInStrFormat" + factInStrFormat); Object[] facts = {hicData}; System.out.println("------Facts Object-------- =" + facts); List<IRuleClass> ruleClassList = new ArrayList<IRuleClass>(); ruleClassList = executeRules(facts); // Should be called every time a fact arrives System.out.println( "-------Inside Execute RULES- number of rules mathcing=--ruleClassList.size()=" + ruleClassList.size()); if (ruleClassList.size() > 0) { for (int i = 0; i < ruleClassList.size(); i++) { IRuleClass rule = ruleClassList.get(i); Consequence con = (Consequence) rule.getConsequenceList().get(0); resultList.add(con.getConsequenceString()); hicData .getData() .getFormPattern() .getFormValues() .put("RulesComponent", con.getConsequenceString()); } } for (int i = 0; i < resultList.size(); i++) { System.out.println("Inside executeRuleHICData consequence list"); System.out.println(resultList.get(i)); // hicData.getData().setRawData(resultLis } } catch (ComponentException e) { e.printStackTrace(); throw new Exception(e.getMessage()); } System.out.println("-----Done with ExecuteRuleHICData----hicData=" + hicData); return hicData; }
@Override public IHICData getMatchingDataObjectForUser(IHICData incomingDataObject, String nodeExecStatus) { /*String tempUniqueId = incomingDataObject.getUniqueID(); // Update DO unique id to Patient ID which is unique for each patient updateDataObjectUniqueId(incomingDataObject);*/ // For UniqueId to be same across server restart, search should not be based on UniqueId List<Object[]> output = DataObjectQueueImpl.checkDataObjectForUser(incomingDataObject, nodeExecStatus, false); // Check for null if list of data object if (output != null) { boolean idSet = false; for (int i = 0; i < output.size(); i++) { Dataobject dObj = (Dataobject) output.get(i)[0]; if (dObj != null) { // This check is added in case more than one dataoject is recieved for same node exection // status. // So a unqiue id check is added if the stored dataobject and incoming dataobject has same // unqiue id and then unqiue id set if (output.size() > 1) { incomingDataObject = UniqueIDUtil.updateUniqueId(incomingDataObject); String uniqueId = incomingDataObject.getUniqueID(); if (uniqueId.equalsIgnoreCase(dObj.getUniqueid())) idSet = true; } // Update incoming data object incomingDataObject = NOLISRuntimeHandler.prepareHICData(incomingDataObject); incomingDataObject.getData().getFormPattern().setFormId(dObj.getFormpattern()); incomingDataObject.getData().getDataPattern().setDataPatternId(dObj.getDatapattern()); // TODO create User Pattern info also // incomingDataObject.getData().a incomingDataObject.getData().setStatus(dObj.getStatus()); incomingDataObject.setUniqueID(dObj.getUniqueid()); incomingDataObject .getData() .getWorkflowPattern() .setWorkflowPattern(dObj.getWorkflownodeinfo().getWorkflowinfo().getName()); incomingDataObject .getData() .getWorkflowPattern() .setWorkflowNode(dObj.getWorkflownodeinfo().getNodeinfo().getNodename()); // Fetch meta data for this data object /*List<Dataobjectmetadata> doMetadataList = DataObjectMetaDataImpl.getAllMetaDataForDataObject(dObj.getId()); if (doMetadataList != null) { // Create form values Hashtable<String, Object> formValues = incomingDataObject.getData().getFormPattern().getFormValues(); if (formValues == null) formValues = new Hashtable<String, Object>(); ArrayList toolOutValues= new ArrayList(); for (int j = 0; j < doMetadataList.size(); j++) { Dataobjectmetadata metaData = doMetadataList.get(j); if ((formValues.containsKey(WorkflowConstant.TOOL_OUTPUT_FILE)) && (metaData.getDatakey().equals(WorkflowConstant.TOOL_OUTPUT_FILE))) { Object obj = formValues.get(WorkflowConstant.TOOL_OUTPUT_FILE); if(obj instanceof ArrayList) { toolOutValues = (ArrayList)obj; if (!toolOutValues.contains(metaData.getDatavalue())) toolOutValues.add(metaData.getDatavalue()); formValues.put(WorkflowConstant.TOOL_OUTPUT_FILE,toolOutValues); } else { String toolValue = obj.toString(); if (!toolOutValues.contains(toolValue)) toolOutValues.add(toolValue); if (!toolOutValues.contains(metaData.getDatavalue())) toolOutValues.add(metaData.getDatavalue()); formValues.put(WorkflowConstant.TOOL_OUTPUT_FILE,toolOutValues); } } else { // Add entries to Form Values; but do not over-write if (!formValues.containsKey(metaData.getDatakey())) formValues.put(metaData.getDatakey(), metaData.getDatavalue()); } } // Set Form Values incomingDataObject.getData().getFormPattern().setFormValues(formValues); }*/ // Sent back the first matching data according to input received. if (output.size() > 1 && i < output.size() && !idSet) { continue; } else break; } } } /*incomingDataObject.setUniqueID(tempUniqueId);*/ return incomingDataObject; }