home *** CD-ROM | disk | FTP | other *** search
-
- ; ****Fever System****
-
- ;Declarations
-
- ;Data Base Elements
- (literalize question name text)
- (literalize selection name text)
-
- ;Answer Elements
- (literalize answer qname result)
-
- ;Print Text Elements
- (literalize print-text what which text)
- (literalize print-text-finished what which)
-
- ;Declare Text to be a vector element
- (vector-attribute text)
-
-
- ;*********Initialization production to build the data base**********
- (p INIT
- (start)
- -->
- (remove 1)
-
- ; Questions
- (make question ^name question1
- ^text "Is the child's temp 105 or higher? *" stop)
- (make question ^name question2
- ^text "Is the child no older than 4 months? *" stop)
- (make question ^name question3
- ^text "Has temp of 104 degrees or more persisted for"
- " 4 hours or longer? *" stop)
- (make question ^name question4
- ^text "Has an oral temp greater than 101 or rectal temp"
- "greater than 102 persisted more than 24hrs? *" stop)
- (make question ^name question5
- ^text "Has a temp greater than normal persisted for"
- "4 or more days? *" stop)
- (make question ^name question6
- ^text "Does the child have any of: stiff neck, sore throat,"
- "earache, bad cough, trouble breathing, extreme lethargy,"
- "vomiting, or diarrhea? *" stop)
-
- ; Selections
- (make selection ^name call
- ^text "Best call the doctor...." stop)
- (make selection ^name ok
- ^text "Probably not serious at this time. " stop)
-
- ; *****Pass Control to the Expert Rules*****
- (make answer start0 any) )
-
-
-
- ; The Expert Rules.
-
- (p RULE0
- (answer ^qname start0) ; Rule to ask the first question
- -->
- (remove 1)
- (make ask-question ^name question1))
-
- ; All of the following rules say:
- ; if then answer to the nth question is "no",
- ; then ask the n+1st question.
- (p RULE1
- (answer ^qname question1 ^result n)
- -->
- (make ask-question ^name question2))
-
- (p RULE2
- (answer ^qname question2 ^result n)
- -->
- (make ask-question ^name question3))
-
- (p RULE3
- (answer ^qname question3 ^result n)
- -->
- (make ask-question ^name question4))
-
- (p RULE4
- (answer ^qname question4 ^result n)
- -->
- (make ask-question ^name question5))
-
- (p RULE5
- (answer ^qname question5 ^result n)
- -->
- (make ask-question ^name question6))
-
- ; If the answer to the last question is "no",
- ; then tell them it is probably not serious.
- (p RULE6
- (answer ^qname question6 ^result n)
- -->
- (make give-selection ^name ok))
-
- ; If any answer is "yes", then tell them to call the doctor.
- (p RULE-YES
- (answer ^result y)
- -->
- (make give-selection ^name call))
-
-
-
- ; ***System Interpretation Rules***
-
- ; Rules for asking questions.
- (p QUERY1
- (ask-question <name>)
- (question ^name <name>)
- -->
- (remove 1)
- (bind <first> (litval text))
- (make print-text
- ^what question
- ^which <name>
- ^text (substr 2 <first> inf)))
-
- (p QUERY2
- (print-text-finished ^what question ^which <name>)
- -->
- (remove 1)
- (bind <ans> (accept))
- (make answer ^name <name> ^result <ans>))
-
-
- ; Rules for giving selections (diagnoses).
- (p SELECT1
- (give-selection ^name <name>)
- (selection ^name <name>)
- -->
- (remove 1)
- (bind <first> (litval text))
- (make print-text
- ^what selection
- ^which <name>
- ^text (substr 2 <first> inf)))
-
- (p SELECT2
- (print-text-finished ^what selection)
- -->
- (remove 1)
- (halt))
-
-
-
- ; Rules for printing text vectors.
- ; These rules (and the corresponding text elements in the
- ; data base) use a special symbolic atom `stop' to determine
- ; when to stop printing.
-
- (p PRINT-TEXT
- (print-text ^what <what> ^which <name> ^text {<val> <> stop})
- -->
- (remove 1)
- (write (crlf))
- (write <val>)
- (bind <current> (litval text))
- (bind <first> (compute <current> + 1))
- (make print-text
- ^what <what>
- ^which <name>
- ^text (substr 1 <first> inf)))
-
- (p PRINT-TEXT0
- (print-text ^what <what> ^which <name> ^text {<val> = stop})
- -->
- (remove 1)
- (make print-text-finished ^what <what> ^which <name>))
-