%Global PatientSupporter %-------------------- %PARTICIPATION CHECK %------------------- participation(?ProfileID,?Injury,?MinRSVP,?MaxRSVP) :- groupSize(?ProfileID,?Injury,?Min,?Max), greaterThanOrEqual(?MinRSVP,?Min), lessThanOrEqual(?MaxRSVP,?Max). %AGE CHECK ageCheck(?ProfileID,?MinAge,?MaxAge,?Age) :- age(?ProfileID,?Age), greaterThanOrEqual(?Age,?MinAge), lessThanOrEqual(?Age,?MaxAge). %GOOD DURATION CHECK %------------------- goodDuration(?ProfileID,?Injury, dateTime[?DurYear,?DurMonth,?DurDay,?DurHour,?DurMinute], dateTime[?StartYear,?StartMonth,?StartDay,?StartHour,?StartMinute], dateTime[?EndYear,?EndMonth,?EndDay,?EndHour,?EndMinute]) :- event(?ProfileID,?Injury,?Tense, dateTime[?StartYear,?StartMonth,?StartDay,?StartHour,?StartMinute], dateTime[?EndYear,?EndMonth,?EndDay,?EndHour,?EndMinute]), duration(?ProfileID,?Injury, dateTime[?DurYear,?DurMonth,?DurDay,?DurHour,?DurMinute]), %Convert all duration variables into seconds. multiply(?DurYearSeconds,?DurYear,31556926:integer), multiply(?DurMonthSeconds,?DurMonth,2629744:integer), multiply(?DurDaySeconds,?DurDay,86400:integer), multiply(?DurHourSeconds,?DurHour,3600:integer), multiply(?DurMinuteSeconds,?DurMinute,60:integer), %Add them together in a single variable DurTotal. add(?DurTotal,?DurMinuteSeconds,?DurHourSeconds,?DurDaySeconds,?DurMonthSeconds,?DurYearSeconds), %Get the difference between start and end time of each variable. subtract(?DurYearTemp,?EndYear,?StartYear), subtract(?DurMonthTemp,?EndMonth,?StartMonth), subtract(?DurDayTemp,?EndDay,?StartDay), subtract(?DurHourTemp,?EndHour,?StartHour), subtract(?DurMinuteTemp,?EndMinute,?StartMinute), %Get the absolute value of the results. This essentially gives you an event duration. abs(?DurYearAbs,?DurYearTemp), abs(?DurMonthAbs,?DurMonthTemp), abs(?DurDayAbs,?DurDayTemp), abs(?DurHourAbs,?DurHourTemp), abs(?DurMinuteAbs,?DurMinuteTemp), %Convert all duration variables into seconds. multiply(?EventDurYearSeconds,?DurYearAbs,31556926:integer), multiply(?EventDurMonthSeconds,?DurMonthAbs,2629744:integer), multiply(?EventDurDaySeconds,?DurDayAbs,86400:integer), multiply(?EventDurHourSeconds,?DurHourAbs,3600:integer), multiply(?EventDurMinuteSeconds,?DurMinuteAbs,60:integer), %Add them together in a single variable DurTotal. add(?EventDurTotal,?EventDurMinuteSeconds,?EventDurHourSeconds,?EventDurDaySeconds,?EventDurMonthSeconds,?EventDurYearSeconds), %Insure EventDurTotal is not greater than DurTotal %(the event has a good duration for the start and end time given) greaterThanOrEqual(?EventDurTotal,?DurTotal). %Checks to see if element is a member of a list. notMember(?X, []). notMember(?X, [?H|?T]) :- notEqual(?X, ?H), notMember(?X, ?T). notMemberList( ?X, []). notMemberList( ?X, [?H]) :- naf(equalList(?X, ?H)). notMemberList( ?X,[?H|?T]) :- naf(equalList(?X, ?H)), notMemberList(?X,?T). equalList(?L, ?L).