Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (deftemplate Fever
- (slot level))
- (defrule GetTemperature
- =>
- (printout t "Enter temperature: ")
- (bind ?response (read))
- (assert (temperature ?response)))
- (defrule GetSoreThroat
- =>
- (printout t "Does the patient have a sore throat (yes or no): ): ")
- (bind ?response (read))
- (assert (sore_throat ?response)))
- (defrule Tiredness
- =>
- (printout t "Does the patient feel tiredness (yes or no): ")
- (bind ?response (read))
- (assert (tiredness ?response)))
- (defrule LossOfTaste
- =>
- (printout t "Does the patient feel loss of taste (yes or no): ")
- (bind ?response (read))
- (assert (lossoftaste ?response)))
- (defrule Fever1
- (temperature ?t)
- (test (>= ?t 38))
- =>
- (assert (fever high))
- (printout t "High fever diagnosed" crlf))
- (defrule Fever2
- (temperature ?t)
- (test (and (< ?t 38) (> ?t 37)))
- =>
- (assert (fever mild))
- (printout t "Mild fever diagnosed" crlf))
- (defrule Flu
- (sore_throat yes)
- (fever mild|high)
- =>
- (assert (diagnosis flu))
- (printout t "Flu diagnosed" crlf))
- (defrule Covid
- (sore_throat yes)
- (diagnosis flu)
- (lossoftaste yes)
- (tiredness yes)
- =>
- (assert (diagnosis covid))
- (printout t "Covid diagnosed" crlf))
- (defrule Bed_rest
- (diagnosis flu)
- =>
- (assert (treatment bed_rest))
- (printout t "Bed rest prescribed" crlf))
- (defrule Hospital
- (diagnosis covid)
- =>
- (assert (treatment hospital))
- (printout t "Hospital treatment" crlf))
- (defrule None
- (declare (salience -100))
- (not (diagnosis ?))
- =>
- (printout t "No diagnosis possible consult human expert" crlf))
- (reset)
- (run)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement