PREFIX math: <http://www.w3.org/2000/10/swap/math#>
PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>
PREFIX fl: <http://eulersharp.sourceforge.net/2003/03swap/fl-rules#>
PREFIX : <http://eulersharp.sourceforge.net/2006/02swap/med#>

(:Ann :Fever) fl:mu 0.8.
(:Ann :AllergyForAspirin) fl:mu 0.001.
(:Joe :AcuteMyocardialInfarction) fl:mu 0.9.
(:Joe :ActivePepticUlcerDisease) fl:mu 0.006.
(:Joe :AllergyForAspirin) fl:mu 0.001.
(:Joe :SevereAsthma) fl:mu 0.001.
(:Joe :ChronicObstructivePumonaryDisease) fl:mu 0.001.

:aspirinHighDose :prescribedFor :Fever.
:aspirinLowDose :prescribedFor :AcuteMyocardialInfarction.
:betaBlocker :prescribedFor :AcuteMyocardialInfarction.

:aspirinHighDose :excludedFor :ActivePepticUlcerDisease.
:aspirinHighDose :excludedFor :AllergyForAspirin.
:aspirinLowDose :excludedFor :ActivePepticUlcerDisease.
:aspirinLowDose :excludedFor :AllergyForAspirin.
:betaBlocker :excludedFor :SevereAsthma.
:betaBlocker :excludedFor :ChronicObstructivePumonaryDisease.

{?MEDICATION :prescribedFor ?DIAGNOSIS.
 (?WHO ?DIAGNOSIS) fl:mu ?MEMBERSHIP.
 ?MEMBERSHIP math:greaterThan 0.7.
 ?SCOPE e:findall (?EXCLUSION {?MEDICATION :excludedFor ?EXCLUSION} ?LIST).
 ?SCOPE e:findall (?EXCLUSION {?MEDICATION :excludedFor ?EXCLUSION.
                               (?WHO ?EXCLUSION) fl:mu ?VALUE.
                               ?VALUE math:notGreaterThan 0.01} ?LIST)}
 =>
 {?WHO :isPrescribed ?MEDICATION}.
