system_doradzwa_medycznego_.../asd.pl

147 lines
5.3 KiB
Perl
Raw Normal View History

% | ======================= |
% | == disease data base == |
% | ======================= |
disease('flu',[('pain',['throat']),('runny nose'),('fever',-1),('general weakness'),('cough')],[('pain',['muscles'])]).
2021-06-12 16:14:29 +02:00
disease('malaria',[('fever',2),('general weakness')],[('pain',['head']),('chills'),('erythrocyte',-1)]).
2021-06-12 16:21:07 +02:00
disease('angina',[('fever',2),('cough'),('general weakness'),('magnifying lymph nodes'),('pain',['throat'])],[('cannot swallow'),('pain',['head']),('chills')]).
2021-06-12 16:14:29 +02:00
disease('diphtheria',[('fever',1),('general weakness'),('dyspnea')],[('Unclear Speech'),('cannot swallow')]).
disease('typhoid',[('fever',-1),('pain',['stomach']),('spleen enlargement')],['tire symptoms']).
disease('plague',[('fever',2),('general weakness'),('magnifying lymph nodes'),('liver enlargement'),('spleen enlargement')],[('cloded rash')]).
disease('haemophilia',[('epistaxis'),('impaired blood clotting'),('spleen enlargement')],[]).
2021-06-12 16:21:07 +02:00
disease('whooping cough',[('fever',1),('pain',['throat']),('paroxysmal cough')],[('conjunctivitis'),('vomiting')]).
2021-06-12 16:14:29 +02:00
disease('myasthenia',[('excessive fatigue')],[('muscle weakness'),('double vision')]).
disease('atrial fibrillation',[('dizziness'),('fainting'),('excessive fatigue')],[('cough')]).
% | ===================== |
% | == main procedures == |
% | ===================== |
% temporarily returning true
diagnose(Sentence, Answer) :- true.
% | ==================================== |
% | == disease recognizing procedures == |
% | ==================================== |
% | = auxiliary procedures = |
includesAll(_, []) :- true, !.
includesAll(List, [Inhd|Intl]) :- member(Inhd, List), includesAll(List, Intl), !.
includesAny(_, []) :- false, !.
includesAny(List, [Inhd|Intl]) :- member(Inhd, List); includesAny(List, Intl), !.
checkForDiseaseStrong(Symptoms, Disease) :-
disease(Disease, ObligatorySymptoms, AdditionalSymptoms),
append(ObligatorySymptoms, AdditionalSymptoms, ExpectedSymptoms),
includesAll(Symptoms, ObligatorySymptoms),
includesAll(ExpectedSymptoms, Symptoms),
!.
checkForDiseaseWeak(Symptoms, Disease) :-
disease(Disease, ObligatorySymptoms, AdditionalSymptoms),
append(ObligatorySymptoms, AdditionalSymptoms, ExpectedSymptoms),
includesAny(Symptoms, ExpectedSymptoms),
includesAll(ExpectedSymptoms, Symptoms),
!.
% | = suggest procedure = |
% flu
suggest(Symptoms, Answer) :-
checkForDiseaseStrong(Symptoms, 'flu'),
Answer = "The patients disease is almost certainly flu.".
suggest(Symptoms, Answer) :-
checkForDiseaseWeak(Symptoms, 'flu'),
Answer = "The patients disease might be flu.".
% malaria
suggest(Symptoms, Answer) :-
checkForDiseaseStrong(Symptoms, 'malaria'),
Answer = "The patients disease is almost certainly malaria.".
suggest(Symptoms, Answer) :-
checkForDiseaseWeak(Symptoms, 'malaria'),
Answer = "The patients disease might be malaria.".
% angina
suggest(Symptoms, Answer) :-
checkForDiseaseStrong(Symptoms, 'angina'),
Answer = "The patients disease is almost certainly angina.".
suggest(Symptoms, Answer) :-
checkForDiseaseWeak(Symptoms, 'angina'),
Answer = "The patients disease might be angina.".
% diphtheria
suggest(Symptoms, Answer) :-
checkForDiseaseStrong(Symptoms, 'diphtheria'),
Answer = "The patients disease is almost certainly diphtheria.".
suggest(Symptoms, Answer) :-
checkForDiseaseWeak(Symptoms, 'diphtheria'),
Answer = "The patients disease might be diphtheria.".
% typhoid
suggest(Symptoms, Answer) :-
checkForDiseaseStrong(Symptoms, 'typhoid'),
Answer = "The patients disease is almost certainly typhoid.".
suggest(Symptoms, Answer) :-
checkForDiseaseWeak(Symptoms, 'typhoid'),
Answer = "The patients disease might be typhoid.".
% plague
suggest(Symptoms, Answer) :-
checkForDiseaseStrong(Symptoms, 'plague'),
Answer = "The patients disease is almost certainly plague.".
suggest(Symptoms, Answer) :-
checkForDiseaseWeak(Symptoms, 'plague'),
Answer = "The patients disease might be plague.".
% haemophilia
suggest(Symptoms, Answer) :-
checkForDiseaseStrong(Symptoms, 'haemophilia'),
Answer = "The patients disease is almost certainly haemophilia.".
suggest(Symptoms, Answer) :-
checkForDiseaseWeak(Symptoms, 'haemophilia'),
Answer = "The patients disease might be haemophilia.".
% whooping cough
suggest(Symptoms, Answer) :-
checkForDiseaseStrong(Symptoms, 'whooping cough'),
Answer = "The patients disease is almost certainly whooping cough.".
suggest(Symptoms, Answer) :-
checkForDiseaseWeak(Symptoms, 'whooping cough'),
Answer = "The patients disease might be whooping cough.".
% myasthenia
suggest(Symptoms, Answer) :-
checkForDiseaseStrong(Symptoms, 'myasthenia'),
Answer = "The patients disease is almost certainly myasthenia.".
suggest(Symptoms, Answer) :-
checkForDiseaseWeak(Symptoms, 'myasthenia'),
Answer = "The patients disease might be myasthenia.".
% atrial fibrillation
suggest(Symptoms, Answer) :-
checkForDiseaseStrong(Symptoms, 'atrial fibrillation'),
Answer = "The patients disease is almost certainly atrial fibrillation.".
suggest(Symptoms, Answer) :-
checkForDiseaseWeak(Symptoms, 'atrial fibrillation'),
Answer = "The patients disease might be atrial fibrillation.".