Fun one with Accumulate:
(deftemplate encounter
(slot date)
(slot code))
(reset)
(assert (encounter (date "2005-10-31") (code 440)))
(assert (encounter (date "2005-10-31") (code 440)))
(assert (encounter (date "2005-10-31") (code 777.1)))
(assert (encounter (date "2005-10-31") (code 468.1)))
(assert (encounter (date "2005-10-31") (code 440)))
(assert (encounter (date "2005-10-31") (code 777.1)))
(assert (encounter (date "2005-10-31") (code 777.1)))
(assert (encounter (date "2005-10-31") (code 468.1)))
(assert (encounter (date "2005-10-31") (code 440)))
(assert (encounter (date "2005-10-31") (code 440)))
(defrule count-icd9-codes
?c <- (accumulate (bind ?count
0)
;; initializer
(bind ?count
(+ ?count
1))
;; action
?count
;; result
(encounter (code ?c &: (eq ?c 440)))
)
=>
(printout t "There are ")
(printout t ?c)
(printout t " encounter. for ICD9 code: ")
)
(facts)
(run)
This (and anything in the accumlates match area) *always* returns 0 as
the count variable. I took the example (modified) from the 7.0
'new features' area of the docs.
I tried just (encounter) to match on *any* encounter, and I always get 0.
Any hints?
Roger
- JESS: String to Symbol bobillo
- Re: JESS: String to Symbol ejfried
- Re: JESS: String to Symbol bobillo
- Re: JESS: String to Symbol Henrique Lopes Cardoso
- Re: JESS: String to Symbol Roger Studner
- Re: JESS: String to Symbol ejfried
- Re: JESS: String to Symbo... Roger Studner
- Re: JESS: String to S... ejfried
- JESS: Checking if a fact exists bobillo