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

📄 project.clp

📁 NASA 开发使用的一个专家系统
💻 CLP
📖 第 1 页 / 共 3 页
字号:
(defrule B2F2K "Rules to reach box K"
  ?f1 <- (patient2 (state ?state) (done ?done) (hdl ?hdl)
		   (chol ?chol))
  (test (= 0 (str-compare ?done no)))
  (test (= 0 (str-compare ?state b)))
  (test (< ?hdl 35))
  =>
  (modify ?f1 (state k)))

; rule going from box C->G->J
(defrule C2G2J "Rules to reach box J"
  ?f1 <- (patient2 (state ?state) (chd ?chd) (done ?done) (hdl ?hdl)
		   (name ?name))
  (test (= 0 (str-compare ?done no)))
  (test (= 0 (str-compare ?state c)))   
  (test (>= ?hdl 35))
  =>
  (printout t crlf "Patient " ?name " needs the following treatement:"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (printout t "| 1. Provide Information on Dietary Modification,     |"crlf)
  (printout t "|    Physical Activity, and Risk Factor Reduction.    |"crlf)
  (printout t "| 2. Reevaluate Patient in 1 to 2 years:              |"crlf)
  (printout t "|    a. Repeat Total and HDL Cholesterol Measurements.|"crlf)
  (printout t "|    b. Reinforce Nutrition and Physical Activity     |"crlf)
  (printout t "|       Education.                                    |"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (modify ?f1 (done yes) (state j)))

; rule going from box C->H->K
(defrule C2H2K "Rules to reach box K"
  ?f1 <- (patient2 (state ?state) (chd ?chd) (done ?done) (hdl ?hdl)
		   (name ?name))
  (test (= 0 (str-compare ?done no)))
  (test (= 0 (str-compare ?state c)))   
  (test (< ?hdl 35))
  =>
  (modify ?f1 (state k)))


; rule going from box D to box K
(defrule D2K "Rules to reach box K"
  ?f1 <- (patient2 (state ?state)
		   (done ?done))
  (test (= 0 (str-compare ?done no)))
  (test (= 0 (str-compare ?state d)))  
  =>
  (modify ?f1 (state k)))


; check for availability of ldl after reaching box K
(defrule check-ldl-at-K "Check for ldl"
  ?f1 <- (patient2 (ldl ?ldl)
		   (done ?done)
		   (state ?state)
		   (name ?name))
  (test (= ?ldl -1))  ; see other rules with ldl > 0
  (test (= 0 (str-compare ?done no)))
  (test (= 0 (str-compare ?state k)))
  =>
  (printout t crlf
	    "Please input patient " ?name "'s ldl value [-1 if no value]"crlf)
  (bind ?answer (read))
  (if (and (numberp ?answer) (> ?answer 0)) then
	  (modify ?f1 (ldl ?answer)) ; do not modify state here
   else
          (printout t crlf
		 "-------------------------------------------------------"crlf)
	  (printout t "Please obtain ldl test on " ?name crlf)
	  (printout t 
		 "-------------------------------------------------------"crlf)
	  (modify ?f1 (done yes))))

; rule to check the age of the ldl value
(defrule check-ldl-date "date must be within 5 years"
  ?f1 <- (patient2 (name ?name) (ldl-date ?ldl-date) 
		   (done ?done) (state ?state))
  (test (five-years ?ldl-date))
  (test (= 0 (str-compare ?done no)))
=>
  (printout t crlf
		 "-------------------------------------------------------"crlf)
  (printout t "| The last ldl value for " ?name 
	    " is over 5 years old." crlf)
  (printout t "| Please check ldl value on " ?name crlf)
  (printout t "-------------------------------------------------------"crlf)
  (modify ?f1 (done yes)))

; rule from box K->L->O->T
; do high risk rule first
(defrule K2L2O2S "Rule S"
  ?f1 <- (patient2 (name ?name) (state ?state) (done ?done) (risk ?risk)
		   (ldl ?ldl))
  (test (= 0 (str-compare ?done no)))
  (test (= 0 (str-compare ?state k)))
; remove  (test (<= ?ldl 159)) all pat with 2 risk get same rx.
  (test (>= ?ldl 130))
  (test (>= ?risk 2))
  =>
  (printout t crlf "Patient " ?name " needs the following treatement:"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (printout t "| 1. Do Clinical Evaluation (History, Physical        |"crlf)
  (printout t "|    Examination, and Laboratory Tests):              |"crlf)
  (printout t "|    a. Evaluate for Secondary Causes (When Indicated)|"crlf)
  (printout t "|    b. Evaluate for Familial Disorders (When         |"crlf)
  (printout t "|       Indicated)                                    |"crlf)
  (printout t "| 2. Consider Influences of Age, Sex, and Other CHD   |"crlf)
  (printout t "|    Risk Factors                                     |"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (printout t "| 3. Initiate Dietary Therapy with Goal of Lowering   |"crlf)
  (printout t "|    LDL Cholesterol below 130 mg/dl                  |"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (modify ?f1 (done yes) (state t)))


; rules from box K to box T (via box P)
(defrule K2L2P2T "Inititate dietary therapy"
  ?f1 <- (patient2 (name ?name) (state ?state) (done ?done) (ldl ?ldl))
  (test (= 0 (str-compare ?done no)))
  (test (= 0 (str-compare ?state k)))
  (test (>= ?ldl 160))
  =>
  (printout t crlf "Patient " ?name " needs the following treatement:"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (printout t "| 1. Do Clinical Evaluation (History, Physical        |"crlf)
  (printout t "|    Examination, and Laboratory Tests):              |"crlf)
  (printout t "|    a. Evaluate for Secondary Causes (When Indicated)|"crlf)
  (printout t "|    b. Evaluate for Familial Disorders (When         |"crlf)
  (printout t "|       Indicated)                                    |"crlf)
  (printout t "| 2. Consider Influences of Age, Sex, and Other CHD   |"crlf)
  (printout t "|    Risk Factors                                     |"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (printout t "| 3. Initiate Dietary Therapy with Goal of Lowering   |"crlf)
  (printout t "|    LDL Cholesterol below 160 mg/dl                  |"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (modify ?f1 (done yes) (state t)))

; rule from box K->L->M->R
(defrule K2L2M2R "Rule R"
  ?f1 <- (patient2 (name ?name)
		   (state ?state)
		   (done ?done)
		   (ldl ?ldl))
  (test (= 0 (str-compare ?done no)))
  (test (= 0 (str-compare ?state k)))
  (test (< ?ldl 130))
  =>
  (printout t crlf "Patient " ?name " needs the following treatement:"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (printout t "| 1. Repeat Total Cholesterol and HDL Cholesterol     |"crlf)
  (printout t "|    Measurement Within 5 Years                       |"crlf)
  (printout t "| 2. Provide Education on Genral Population Eating    |"crlf)
  (printout t "|    Pattern, Physical Activity, and Risk Factor      |"crlf)
  (printout t "|    Reduction.                                       |"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (modify ?f1 (done yes) (state r)))

; rule from box K->L->N->S
(defrule K2L2N2S "Rule S"
  ?f1 <- (patient2 (name ?name) (state ?state) (done ?done) (risk ?risk)
		   (ldl ?ldl))
  (test (= 0 (str-compare ?done no)))
  (test (= 0 (str-compare ?state k)))
  (test (<= ?ldl 159))
  (test (>= ?ldl 130))
  (test (< ?risk 2))
  =>
  (printout t crlf "Patient " ?name " needs the following treatement:"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (printout t "| 1. Provide Information on Step 1 Diet and Physical  |"crlf)
  (printout t "|    Activity.                                        |"crlf)
  (printout t "| 2. Reevaluate Patient Status Annually, Including    |"crlf)
  (printout t "|    Risk Factor Reduction                            |"crlf)
  (printout t "|    a. Repeat Lipoprotein Analysis                   |"crlf)
  (printout t "|    b. Reinforce Nutrition and Physical Activity     |"crlf)
  (printout t "|       Education.                                    |"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (modify ?f1 (done yes) (state s)))


;************************************************************************
;**************START OF RULES FOR PATIENTS WITH CHD *********************
;************************************************************************

; The following rules are for patients with CHD

; rule for box U. All patients with CHD  goes to box A
(defrule ruleU "getting to box U"
  ?f1 <- (patient2 (chd ?chd) (done ?done) 
		   (treatment ?treatment)(state ?state))
  (test (= 0 (str-compare ?chd yes)))
  (test (= 0 (str-compare ?done no)))
  (test (= 0 (str-compare ?treatment  none)))
  (test (= 0 (str-compare ?state aa))) ; state
  =>
  (modify ?f1 (state u)))

; rule to check for ldl at box U
(defrule check-ldl-at-U
  ?f1 <- (patient2 (name ?name) (done ?done) (state ?state) (ldl ?ldl))
  (test (= 0 (str-compare ?done no)))
  (test (= 0 (str-compare ?state u)))
  (test (= ?ldl -1))
  =>
  (printout t crlf 
	    "Please input patient " ?name "'s ldl value [-1 if no value]"crlf)
  (bind ?answer (read))
  (if (and (numberp ?answer) (> ?answer 0)) then
	  (modify ?f1 (ldl ?answer)) 
   else
          (printout t crlf
		 "-------------------------------------------------------"crlf)
	  (printout t "Please obtain ldl test on" ?name crlf)
          (printout t 
		 "-------------------------------------------------------"crlf)
	  (modify ?f1 (done yes))))

; rule from box U->V->X
(defrule U2V2X "Rule X"
  ?f1 <- (patient2 (name ?name)
		   (state ?state)
		   (done ?done)
		   (ldl ?ldl))
  (test (= 0 (str-compare ?done no)))
  (test (= 0 (str-compare ?state u)))
  (test (<= ?ldl 100))
  (test (> ?ldl 0))
  =>
  (printout t crlf "Patient " ?name " needs the following treatement:"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (printout t "| 1. Indivudualize Instruction on Diet and Physical   |"crlf)
  (printout t "|    Activity Level.                                  |"crlf)
  (printout t "| 2. Repeat Lipoprotein Analysis Annually.            |"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (modify ?f1 (done yes) (state x)))

; rule from box U->W->X
(defrule U2W2Z "Rule Z"
  ?f1 <- (patient2 (name ?name)
		   (state ?state)
		   (done ?done)
		   (ldl ?ldl))
  (test (= 0 (str-compare ?done no)))
  (test (= 0 (str-compare ?state u)))
  (test (> ?ldl 100))
  =>
  (printout t crlf "Patient " ?name " needs the following treatement:"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (printout t "| 1. Do Clinical Evaluation (History, Physical Exam,  |"crlf)
  (printout t "|    and Lab Tests).                                  |"crlf)
  (printout t "| 2. Evaluate for Secondary Causes (When Indicated).  |"crlf)
  (printout t "| 3. Evaluate for Familial Disorders (When Indicated).|"crlf)
  (printout t "| 4. Consider Influences of Age, Sex, and Other CHD   |"crlf)
  (printout t "|    Risk Factors.                                    |"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (printout t "| 5. Initiate Dietary Therapy: Goal is LDL < 100 mg/dl|"crlf)
  (printout t "-------------------------------------------------------"crlf)
  (modify ?f1 (done yes) (state z)))

;**************************************************************************
;************END OF RULES FOR UNTREATED PATIENTS WITH CHD******************
;**************************************************************************

;**************************************************************************
;**********     START OF RULES FOR TREATED PATIENTS  **********************
;**************************************************************************


; rule to identify all treated patients
(defrule ruleT1 "getting to box t1"
  ?f1 <- (patient2 (done ?done) 
		   (treatment ?treatment) (state ?state))
  (test (= 0 (str-compare ?done no)))
  (test (= 0 (str-compare ?state aa))) ; state
  (test (<> 0 (str-compare ?treatment none))) ;treatment other than none
  =>
  (modify ?f1 (state t1)))

⌨️ 快捷键说明

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