%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                        %%
%%     The Physician advisory system      %%
%%                                        %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Include the Advisor interface
#include('PAS_rules.pred.pl').

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% The doctor need to select certain treatments
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

chose(X) :- recommendation(X),  not exclude(X), not discarded(X).

discarded(X) :- not available(X).
available(X) :- not discarded(X).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% There are some rules to chose/recommentd treatments
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% 1. Aggressive Reasoning: The aggressive reasoning pattern can be
%% stated as "take an action (e.g., recommend treatment) inot f there
%% is a reason; no evidence of contraindication means there is no
%% danger in taking that action".

recommendation(T) :-
    reason(T),
    not contraindication(T).

%% 2. Conservative Reasoning: This reasoning pattern is stated as "A
%% reason for a recommendation is not enough; evidence that the
%% recommendation is not harmful must be available".

recommendation(T) :-
    reason(T),
    -contraindication(T).

%% 3. Anti-recommendation: The anti-recommendation pattern is stated
%% as "a choice can be prohibited if evidence of contraindication can
%% be found"

%% contraindication/1.

%% 4. Preference: The preference pattern is stated as "use the
%% second-line choice when the first-line choice is not available".

recommendation(T2) :-
    second_line(T1,T2),
    reason(T1),
    contraindication(T1),
    not contraindication(T2).

%% 5. Concomitant Choice: The concomitant choice pattern is stated as
%% "if a choice is made, some other choices are automatically in
%% effect unless they are prohibited."

exclude(T0) :-
    concomitant(T0,T),
    recommendation(T),
    not chose(T).

%% 6. Indispensable Choice: The indispensable choice pattern is stated
%% as "if a choice is made, some other choices must also be made; if
%% those choices can't be made, then the first choice is revoked".

exclude(T0) :-
    indispensable(T0,T),
    not chose(T).

%% 7. Incompatible Choice: The incompatibility pattern is stated as
%% "some choices cannot be in effect at the same time"

exclude(T2) :-
    incompatibility(T1,T2),
    not discarded(T1).
exclude(T1) :-
    incompatibility(T1,T2),
    not discarded(T2).