Nothing changed that would affect this function, no; it seems more likely that the modify isn't being called. Have you used "watch all" to see that that the fact is being changed when the rule fires?

On Dec 7, 2006, at 7:26 AM, Mike Dean wrote:

I have written (or adapted from someone else) a routine to append text
to a slot in a shadow fact, which is then displayed to the user as an
explanation for a decision. This routine worked until recent switch to
release version of Jess, and I cannot identify any changes in my own
code during same period.  Has there been a change that would explain
this?

Here is an example rule:

(defrule moderate-hypoglycemia-definition
                "Define whether hypoglycemia is moderate"
        (currentGlucoseBelowRange)
        ?decision <- (GlucoseDecision (serumGlucoseConcentration
?value))
                =>
        (if (and (< ?value ?*moderateHypoglycemiaLimit*) (>= ?value
?*extremeHypoglycemiaLimit*))
        then (assert(moderateHypoglycemia))
    (modify ?decision (rationaleText (append-text (fact-slot-value
?decision rationaleText)
            "The patient is moderately hypoglycemic (< 60 mg/dL).")))
        )       )

My function is append-text, which is loaded earlier in the clp file:

(load-function edu.utah.cdmcc.jess.extensions.TextAppendFunction)

Here is the Java code for the function:

public class TextAppendFunction implements Userfunction {
        private static String NEWLINE =
System.getProperty("line.separator");

        public String getName() {
                return "append-text";
        }

        public Value call(ValueVector vv, Context context) throws
JessException {
                String oldString= vv.get(1).stringValue(context);
                System.out.println(oldString);
                StringBuffer sb = new StringBuffer(100);
                if (oldString.length() > 0) {
                sb.append(oldString.toString());
                sb.append(NEWLINE);}
                for (int i = 2; i < vv.size(); i++) {
                        Value v = vv.get(i).resolveValue(context);
                        switch (v.type()) {
                        case RU.SYMBOL:
                                // noinspection
EqualsBetweenInconvertibleTypes
                                if (v.equals("crlf")) {
                                        sb.append(NEWLINE);
                                        break;
                                }
                                // FALL THROUGH
                        case RU.STRING:
                                sb.append(v.stringValue(context));
                                break;
                        case RU.INTEGER:
                                sb.append(v.intValue(context));
                                break;
                        case RU.FLOAT:
                                sb.append(v.numericValue(context));
                                break;
                        case RU.FACT:
                                sb.append(v);
                                break;
                        case RU.LIST:
                                
sb.append(v.listValue(context).toStringWithParens());
                                break;
                        case RU.JAVA_OBJECT:
                                sb.append(v.toString());
                                break;
                        default:
                                sb.append(v.toString());
                        }
                }
                Value result = new Value(sb.toString(),RU.STRING);
                return result;
        }
}

There is no complaint from the program, but instead of having something
like:

The glucose is low.
The patient is on insulin.
Insulin should be turned off when glucose is low.

I am now just getting

The glucose is low.

The rules are firing correctly, according to the trace.

Thanks for any assistance.

- Mike



J. Michael Dean, M.D., M.B.A.
H.A. and Edna Benning Presidential Professor of Pediatrics
Professor of Family and Preventive Medicine
Professor of Biomedical Informatics
Chief, Division of Pediatric Critical Care
Vice Chairman, Department of Pediatrics
University of Utah School of Medicine
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify owner-jess- [EMAIL PROTECTED]
--------------------------------------------------------------------

---------------------------------------------------------
Ernest Friedman-Hill
Advanced Software Research          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550                 http://www.jessrules.com
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to