Advertisement
Mitsanski

ES Covid Tester

Jan 15th, 2022
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. (deftemplate Fever
  2. (slot level))
  3.  
  4. (defrule GetTemperature
  5. =>
  6. (printout t "Enter temperature: ")
  7. (bind ?response (read))
  8. (assert (temperature ?response)))
  9.  
  10. (defrule GetSoreThroat
  11. =>
  12. (printout t "Does the patient have a sore throat (yes or no): ): ")
  13. (bind ?response (read))
  14. (assert (sore_throat ?response)))
  15.  
  16. (defrule Tiredness
  17. =>
  18. (printout t "Does the patient feel tiredness (yes or no): ")
  19. (bind ?response (read))
  20. (assert (tiredness ?response)))
  21.  
  22. (defrule LossOfTaste
  23. =>
  24. (printout t "Does the patient feel loss of taste (yes or no): ")
  25. (bind ?response (read))
  26. (assert (lossoftaste ?response)))
  27.  
  28. (defrule Fever1
  29. (temperature ?t)
  30. (test (>= ?t 38))
  31. =>
  32. (assert (fever high))
  33. (printout t "High fever diagnosed" crlf))
  34.  
  35. (defrule Fever2
  36. (temperature ?t)
  37. (test (and (< ?t 38) (> ?t 37)))
  38. =>
  39. (assert (fever mild))
  40. (printout t "Mild fever diagnosed" crlf))
  41.  
  42. (defrule Flu
  43. (sore_throat yes)
  44. (fever mild|high)
  45. =>
  46. (assert (diagnosis flu))
  47. (printout t "Flu diagnosed" crlf))
  48.  
  49. (defrule Covid
  50. (sore_throat yes)
  51. (diagnosis flu)
  52. (lossoftaste yes)
  53. (tiredness yes)
  54. =>
  55. (assert (diagnosis covid))
  56. (printout t "Covid diagnosed" crlf))
  57.  
  58. (defrule Bed_rest
  59. (diagnosis flu)
  60. =>
  61. (assert (treatment bed_rest))
  62. (printout t "Bed rest prescribed" crlf))
  63.  
  64. (defrule Hospital
  65. (diagnosis covid)
  66. =>
  67. (assert (treatment hospital))
  68. (printout t "Hospital treatment" crlf))
  69.  
  70. (defrule None
  71. (declare (salience -100))
  72. (not (diagnosis ?))
  73. =>
  74. (printout t "No diagnosis possible consult human expert" crlf))
  75.  
  76. (reset)
  77. (run)
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement