⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 disease_diagnosis.clp

📁 基于专家系统的 智能医疗诊断系统 CLIPS源代码
💻 CLP
📖 第 1 页 / 共 2 页
字号:
   (headache-state patient has-headache)
   (throatache-state patient has-throatache)
   (not (hard-to-breath-state patient ?))   
   =>
     (if (yes-or-no-p "Do you feel breath hardly(yes/no)? ") then (assert (hard-to-breath-state patient has-hard-to-breath))
      else (assert (ans "unknown disease"))))

(defrule sars-cold-virus-in-blood-state ""
   (fever-state patient fever-high)
   (cough-state patient has-cough)
   (sputum-state patient has-sputum)
   (snuffle-state patient no-snuffle)
   (headache-state patient has-headache)
   (throatache-state patient has-throatache)
   (hard-to-breath-state patient has-hard-to-breath)
   (not (virus-in-blood-state patient ?))   
   =>
     (if (yes-or-no-p "Do you have virus in blood(yes/no)? ") then (assert (virus-in-blood-state patient has-virus-in-blood))
      else (assert (ans "unknown disease"))))

(defrule determine-sars ""
   (fever-state patient fever-high)
   (cough-state patient has-cough)
   (sputum-state patient has-sputum)
   (snuffle-state patient no-snuffle)
   (headache-state patient has-headache)
   (throatache-state patient has-throatache)
   (hard-to-breath-state patient has-hard-to-breath)
   (virus-in-blood-state patient has-virus-in-blood)
   (not (neck-harden-state patient ?))   
   =>
     (if (yes-or-no-p "Do you feel your neck harden(yes/no)? ") then (assert (ans "unknown disease"))
      else (assert (ans "SARS"))))

;;------------------Finish to determine:SARS---------------------------------------------------------------------------


;;------------------Start to determine:Flu-1,Heavy Cold,Meningistis----------------------------------------------------

(defrule chain-3-2-sputum-state ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (not (sputum-state patient ?))   
   =>
     (if (yes-or-no-p "Do you have sputum(yes/no)? ") then (assert (ans "unknown disease"))
      else (assert (sputum-state patient no-sputum))))

(defrule chain-3-2-snuffle-state ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (sputum-state patient no-sputum)
   (not (snuffle-state patient ?))   
   =>
     (if (yes-or-no-p "Do you have Snuffle and Drivel(yes/no)? ") then (assert (snuffle-state patient has-snuffle))
      else (assert (snuffle-state patient no-snuffle))))

(defrule flu1-heavy-cold-headache-state ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (sputum-state patient no-sputum)
   (snuffle-state patient has-snuffle)
   (not (headache-state patient ?))   
   =>
     (if (yes-or-no-p "Do you have headache(yes/no)? ") then (assert (headache-state patient has-headache))
      else (assert (ans "unknown disease"))))

(defrule flu1-heavy-cold-throatache-state ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (sputum-state patient no-sputum)
   (snuffle-state patient has-snuffle)
   (headache-state patient has-headache)
   (not (throatache-state patient ?))   
   =>
     (if (yes-or-no-p "Do you have throactache(yes/no)? ") then (assert (throatache-state patient has-throatache))
      else (assert (ans "unknown disease"))))

(defrule flu1-heavy-cold-hard-to-breath-state ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (sputum-state patient no-sputum)
   (snuffle-state patient has-snuffle)
   (headache-state patient has-headache)
   (throatache-state patient has-throatache)
   (not (hard-to-breath-state patient ?))   
   =>
     (if (yes-or-no-p "Do you feel breath hardly(yes/no)? ") then (assert (hard-to-breath-state patient has-hard-to-breath))
      else (assert (ans "unknown disease"))))

(defrule flu1-heavy-cold-virus-in-blood-state ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (sputum-state patient no-sputum)
   (snuffle-state patient has-snuffle)
   (headache-state patient has-headache)
   (throatache-state patient has-throatache)
   (hard-to-breath-state patient has-hard-to-breath)
   (not (virus-in-blood-state patient ?))   
   =>
     (if (yes-or-no-p "Do you have virus in blood(yes/no)? ") then (assert (virus-in-blood-state patient has-virus-in-blood))
      else (assert (virus-in-blood-state patient no-virus-in-blood))))

(defrule determine-flu-1 ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (sputum-state patient no-sputum)
   (snuffle-state patient has-snuffle)
   (headache-state patient has-headache)
   (throatache-state patient has-throatache)
   (hard-to-breath-state patient has-hard-to-breath)
   (virus-in-blood-state patient has-virus-in-blood)
   (not (neck-harden-state patient ?))   
   =>
     (if (yes-or-no-p "Do you feel your neck harden(yes/no)? ") then (assert (ans "unknown disease"))
      else (assert (ans "Flu-1"))))

(defrule determine-heavy-cold-2 ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (sputum-state patient no-sputum)
   (snuffle-state patient has-snuffle)
   (headache-state patient has-headache)
   (throatache-state patient has-throatache)
   (hard-to-breath-state patient has-hard-to-breath)
   (virus-in-blood-state patient no-virus-in-blood)
   (not (neck-harden-state patient ?))   
   =>
     (if (yes-or-no-p "Do you feel your neck harden(yes/no)? ") then (assert (ans "unknown disease"))
      else (assert (ans "Heavy Cold"))))

;;------------------Finish to determine:Flu-1,Heavy Cold---------------------------------------------------------------


;;------------------Start to determine:Meningistis---------------------------------------------------------------------

(defrule meningitis-headache-state ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (sputum-state patient no-sputum)
   (snuffle-state patient no-snuffle)
   (not (headache-state patient ?))   
   =>
     (if (yes-or-no-p "Do you have headache(yes/no)? ") then (assert (headache-state patient has-headache))
      else (assert (ans "unknown disease"))))

(defrule meningitis-throatache-state ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (sputum-state patient no-sputum)
   (snuffle-state patient no-snuffle)
   (headache-state patient has-headache)
   (not (throatache-state patient ?))   
   =>
     (if (yes-or-no-p "Do you have throactache(yes/no)? ") then (assert (throatache-state patient has-throatache))
      else (assert (ans "unknown disease"))))

(defrule meningitis-hard-to-breath-state ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (sputum-state patient no-sputum)
   (snuffle-state patient no-snuffle)
   (headache-state patient has-headache)
   (throatache-state patient has-throatache)
   (not (hard-to-breath-state patient ?))   
   =>
     (if (yes-or-no-p "Do you feel breath hardly(yes/no)? ") then (assert (hard-to-breath-state patient has-hard-to-breath))
      else (assert (ans "unknown disease"))))

(defrule meningitis-virus-in-blood-state ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (sputum-state patient no-sputum)
   (snuffle-state patient no-snuffle)
   (headache-state patient has-headache)
   (throatache-state patient has-throatache)
   (hard-to-breath-state patient has-hard-to-breath)
   (not (virus-in-blood-state patient ?))   
   =>
     (if (yes-or-no-p "Do you have virus in blood(yes/no)? ") then (assert (virus-in-blood-state patient has-virus-in-blood))
      else (assert (ans "unknown disease"))))

(defrule meningitis-neck-harden-state ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (sputum-state patient no-sputum)
   (snuffle-state patient no-snuffle)
   (headache-state patient has-headache)
   (throatache-state patient has-throatache)
   (hard-to-breath-state patient has-hard-to-breath)
   (virus-in-blood-state patient has-virus-in-blood)
   (not (neck-harden-state patient ?))   
   =>
     (if (yes-or-no-p "Do you feel your neck harden(yes/no)? ") then (assert (neck-harden-state patient has-neck-harden))
      else (assert (neck-harden-state patient no-neck-harden))))

(defrule determine-meningitis ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (sputum-state patient no-sputum)
   (snuffle-state patient no-snuffle)
   (headache-state patient has-headache)
   (throatache-state patient has-throatache)
   (hard-to-breath-state patient has-hard-to-breath)
   (virus-in-blood-state patient has-virus-in-blood)
   (neck-harden-state patient has-neck-harden)
   =>
     (assert (ans "Meningitis")))


;;------------------Finish to determine:Meningitis---------------------------------------------------------------


;;-------------------------modify----------------------------------------------------------------------------
(defrule determine-flu2-modify ""
   (fever-state patient fever-low)
   (cough-state patient has-cough)
   (sputum-state patient has-sputum)
   (snuffle-state patient no-snuffle)
   (headache-state patient no-headache)
   (throatache-state patient has-throatache)                                      
   (hard-to-breath-state patient no-hard-to-breath)
   (virus-in-blood-state patient has-virus-in-blood)
   (neck-harden-state patient no-neck-harden)
   (not (ans ?))     
   =>
      (assert (ans "unknown disease")))

(defrule determine-normal-cold-modify ""
   (fever-state patient fever-low)
   (cough-state patient has-cough)
   (sputum-state patient has-sputum)
   (snuffle-state patient no-snuffle)
   (headache-state patient no-headache)
   (throatache-state patient has-throatache)
   (hard-to-breath-state patient no-hard-to-breath)
   (virus-in-blood-state patient no-virus-in-blood)
   (neck-harden-state patient no-neck-harden)
   (not (ans ?))     
   =>
       (assert (ans "unknown disease")))

(defrule determine-pneumonia-modify ""
   (fever-state patient fever-low)
   (cough-state patient has-cough)
   (sputum-state patient has-sputum)
   (snuffle-state patient has-snuffle)
   (headache-state patient has-headache)
   (hard-to-breath-state patient has-hard-to-breath)
   (virus-in-blood-state patient no-virus-in-blood)
   (neck-harden-state patient no-neck-harden)
   (not (ans ?))     
   =>
      (assert (ans "unknown disease")))

(defrule determine-heavy-cold-modify ""
   (fever-state patient fever-high)
   (cough-state patient has-cough)
   (sputum-state patient has-sputum)
   (snuffle-state patient no-snuffle)
   (headache-state patient has-headache)
   (throatache-state patient has-throatache)
   (hard-to-breath-state patient no-hard-to-breath)
   (virus-in-blood-state patient no-virus-in-blood)
   (neck-harden-state patient no-neck-harden)   
   =>
     (assert (ans "unknown disease")))

(defrule determine-sars-modify ""
   (fever-state patient fever-high)
   (cough-state patient has-cough)
   (sputum-state patient has-sputum)
   (snuffle-state patient has-snuffle)
   (headache-state patient has-headache)
   (throatache-state patient has-throatache)
   (hard-to-breath-state patient has-hard-to-breath)
   (virus-in-blood-state patient has-virus-in-blood)
   (neck-harden-state patient no-neck-harden)   
   =>
      (assert (ans "unknown disease")))

(defrule determine-flu-1-modify ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (sputum-state patient no-sputum)
   (snuffle-state patient no-snuffle)
   (headache-state patient has-headache)
   (throatache-state patient has-throatache)
   (hard-to-breath-state patient has-hard-to-breath)
   (virus-in-blood-state patient has-virus-in-blood)
   (neck-harden-state patient no-neck-harden)   
   =>
     (assert (ans "unknown disease")))

(defrule determine-heavy-cold-modify ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (sputum-state patient no-sputum)
   (snuffle-state patient no-snuffle)
   (headache-state patient has-headache)
   (throatache-state patient has-throatache)
   (hard-to-breath-state patient has-hard-to-breath)
   (virus-in-blood-state patient no-virus-in-blood)
   (neck-harden-state patient no-neck-harden)   
   =>
     (assert (ans "unknown disease")))

(defrule determine-meningitis-modify ""
   (fever-state patient fever-high)
   (cough-state patient no-cough)
   (sputum-state patient no-sputum)
   (snuffle-state patient has-snuffle)
   (headache-state patient has-headache)
   (throatache-state patient has-throatache)
   (hard-to-breath-state patient has-hard-to-breath)
   (virus-in-blood-state patient has-virus-in-blood)
   (neck-harden-state patient no-neck-harden)   
   =>
     (assert (ans "unknown disease")))


;--------------------------------------------------------------------------------------------------------------------------




























(defrule print-ans ""
  (declare (salience 10))
  (ans ?item)
  =>
  (printout t crlf crlf)
  (printout t "I think you've got:")
  (printout t crlf crlf)
  (format t " %s%n%n%n" ?item))

















⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -