Source:
public EvaluatedPatientData evaluate(PatientDataDefinition definition, EvaluationContext context) throws EvaluationException { ScriptedCompositionPatientDataDefinition pd = (ScriptedCompositionPatientDataDefinition) definition; Map<String, Mapped<PatientDataDefinition>> containedDataDefintions = pd.getContainedDataDefinitions(); EvaluatedPatientData evaluationResult = new EvaluatedPatientData(pd, context); List<EvaluatedPatientData> evaluatedContainedDataDefinitions = new ArrayList<EvaluatedPatientData>(); for (Mapped<PatientDataDefinition> def : containedDataDefintions.values()) { PatientDataDefinition data = def.getParameterizable(); def.setParameterizable(data); EvaluatedPatientData patientDataResult = Context.getService(PatientDataService.class).evaluate(def, context); evaluatedContainedDataDefinitions.add(patientDataResult); } if (pd.getScriptCode() != null) { ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine scriptEngine = manager.getEngineByName(pd.getScriptType().getLanguage()); scriptEngine.put("context", context); scriptEngine.put("parameters", context.getParameterValues()); scriptEngine.put("containedDataDefinitionResults", evaluatedContainedDataDefinitions); scriptEngine.put("evaluationResult", evaluationResult); try { Object result = scriptEngine.eval(pd.getScriptCode()); if (result instanceof EvaluatedPatientData) { return (EvaluatedPatientData) result; } } catch (ScriptException ex) { throw new EvaluationException("An error occured while evaluating script", ex); } catch (ClassCastException ex) { throw new EvaluationException("A Scripted Patient Data Definition must return an EvaluatedPatientData", ex); } return evaluationResult; } return evaluationResult; }

Target:
public EvaluatedPatientData evaluate(PatientDataDefinition definition, EvaluationContext context) throws EvaluationException { ScriptedCompositionPatientDataDefinition pd = (ScriptedCompositionPatientDataDefinition) definition; Map<String, Mapped<PatientDataDefinition>> containedDataDefintions = pd.getContainedDataDefinitions(); if (containedDataDefintions.size() < 1) { throw new EvaluationException( "No patient data definition(s) found on this ScriptedCompositionPatientDataDefinition"); } if (pd.getScriptCode() == null) { throw new EvaluationException("No script code found on this ScriptedCompositionPatientDataDefinition"); } if (pd.getScriptType() == null) { throw new EvaluationException("No script type found on this ScriptedCompositionPatientDataDefinition"); } EvaluatedPatientData evaluationResult = new EvaluatedPatientData(pd, context); Map<String, EvaluatedPatientData> evaluatedContainedDataDefinitions = new HashMap<String, EvaluatedPatientData>(); for (Entry<String, Mapped<PatientDataDefinition>> definitions : containedDataDefintions.entrySet()) { EvaluatedPatientData patientDataResult = Context.getService(PatientDataService.class).evaluate( definitions.getValue(), context); evaluatedContainedDataDefinitions.put(definitions.getKey(), patientDataResult); } ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine scriptEngine = manager.getEngineByName(pd.getScriptType().getLanguage()); scriptEngine.put("context", context); scriptEngine.put("parameters", context.getParameterValues()); scriptEngine.put("containedDataDefinitionResults", evaluatedContainedDataDefinitions); scriptEngine.put("evaluationResult", evaluationResult); try { scriptEngine.eval(pd.getScriptCode()); } catch (ScriptException ex) { throw new EvaluationException("An error occured while evaluating script", ex); } return evaluationResult; }