Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Domains
- list = list
- % Predicates
- nondeterm medicine(symbol, integer, list, list, integer, symbol).
- nondeterm recommended_medicine(list, integer, symbol).
- nondeterm has_contraindications(symbol, list).
- nondeterm patient_has(symbol).
- % Clauses
- patient_has('Pregnancy').
- patient_has('Peptic ulcer disease').
- patient_has('Allergy').
- % Add more facts as needed
- % Contraindications for medicines
- has_contraindications('Aspirin', ['Pregnancy']).
- has_contraindications('Paracetamol', []).
- has_contraindications('Ibuprofen', ['Peptic ulcer disease']).
- has_contraindications('Cetirizine', ['Pregnancy']).
- has_contraindications('Amoxicillin', ['Allergy']).
- has_contraindications('Loratadine', []).
- % Medicine facts
- medicine('Aspirin', 18, ['Headache', 'Fever'], ['Pregnancy'], 50, 'Available').
- medicine('Paracetamol', 12, ['Headache', 'Fever'], [], 30, 'Available').
- medicine('Ibuprofen', 16, ['Headache', 'Toothache'], ['Peptic ulcer disease'], 40, 'Available').
- medicine('Cetirizine', 6, ['Allergy'], ['Pregnancy'], 25, 'Available').
- medicine('Amoxicillin', 20, ['Throat', 'Fever'], ['Allergy'], 60, 'Available').
- medicine('Loratadine', 10, ['Allergy'], [], 35, 'Not available').
- % Recommended medicines rules
- recommended_medicine(Symptoms, Age, Medicine) :-
- medicine(Medicine, AgeLimit, Symptoms, Contraindications, _, 'Available'),
- Age >= AgeLimit,
- not(has_contraindications(Medicine, Contraindications)).
- % Check for contraindications
- has_contraindications(_, []) :- !.
- has_contraindications(Medicine, [Contraindication | Rest]) :-
- patient_has(Contraindication),
- write('Contraindication for '), write(Medicine), write(': '), writeln(Contraindication),
- has_contraindications(Medicine, Rest).
- % Goal
- goal
- recommended_medicine(['Fever'], 22, Medicine).
- % ERRORS:
- % E;Test_Goal, pos: 11, 3 Illegal keyword
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement