How we can write a medical system using prolog language?
Don't use this system to treat real life patients. This is only for education purpose.
Create a new prolog file and take the following code inside it.
go:- write('what is the patients name?'),
read(Patient),
hypothesis(Patient,Disease),
write(Patient),write(' '),
write('probably has'),write(' '),
write(Disease),nl.
go:- write('Sorry i dont seem to be able to'), nl,
write('diagnose the disease'),nl.
symptom(Patient,fever):-
write('does'),write(Patient) , write('have a fever (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,cough):-
write('does'),write(Patient) , write('have a cough (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,rash):-
write('does'),write(Patient) , write('have a rash (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,headache):-
write('does'),write(Patient) , write('have a headache (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,runny_nose):-
write('does'),write(Patient) , write('have a runny_nose (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,conjunctivitis):-
write('does'),write(Patient) , write('have a conjunctivitis (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,body_ache):-
write('does'),write(Patient) , write('have a body_ache (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,chills):-
write('does'),write(Patient) , write('have a chills (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,sore_throat):-
write('does'),write(Patient) , write('have a conjunctivitis (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,sneezing):-
write('does'),write(Patient) , write('have a sneezing (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,swollen_glands):-
write('does'),write(Patient) , write('have a swollen_glands (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
hypothesis(Patient,measles):-
symptom(Patient,fever),
symptom(Patient,cough),
symptom(Patient,conjunctivitis),
symptom(Patient,runny_nose),
symptom(Patient,rash).
hypothesis(Patient,german_measles):-
symptom(Patient,fever),
symptom(Patient,headache),
symptom(Patient,runny_nose),
symptom(Patient,rash).
hypothesis(Patient,flu):-
symptom(Patient,fever),
symptom(Patient,headache),
symptom(Patient,body_ache),
symptom(Patient,conjunctivitis),
symptom(Patient,chills),
symptom(Patient,sore_throat),
symptom(Patient,cough),
symptom(Patient,runny_nose).
hypothesis(Patient,common_cold):-
symptom(Patient,headache),
symptom(Patient,sneezing),
symptom(Patient,sore_throat),
symptom(Patient,chills),
symptom(Patient,runny_nose).
hypothesis(Patient,mumps):-
symptom(Patient,fever),
symptom(Patient,swollen_glands).
hypothesis(Patient,chicken_pox):-
symptom(Patient,fever),
symptom(Patient,rash),
symptom(Patient,body_ache),
symptom(Patient,chills).
hypothesis(Patient,whooping_cough):-
symptom(Patient,cough),
symptom(Patient,sneezing),
symptom(Patient,runny_nose).
hypothesis(Patient,flem):-
symptom(Patient,fever),
symptom(Patient,cough).
Now compile and run the program. At the console type go. ( With the period). There you go.
Thank you.
Don't use this system to treat real life patients. This is only for education purpose.
Create a new prolog file and take the following code inside it.
go:- write('what is the patients name?'),
read(Patient),
hypothesis(Patient,Disease),
write(Patient),write(' '),
write('probably has'),write(' '),
write(Disease),nl.
go:- write('Sorry i dont seem to be able to'), nl,
write('diagnose the disease'),nl.
symptom(Patient,fever):-
write('does'),write(Patient) , write('have a fever (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,cough):-
write('does'),write(Patient) , write('have a cough (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,rash):-
write('does'),write(Patient) , write('have a rash (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,headache):-
write('does'),write(Patient) , write('have a headache (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,runny_nose):-
write('does'),write(Patient) , write('have a runny_nose (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,conjunctivitis):-
write('does'),write(Patient) , write('have a conjunctivitis (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,body_ache):-
write('does'),write(Patient) , write('have a body_ache (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,chills):-
write('does'),write(Patient) , write('have a chills (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,sore_throat):-
write('does'),write(Patient) , write('have a conjunctivitis (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,sneezing):-
write('does'),write(Patient) , write('have a sneezing (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
symptom(Patient,swollen_glands):-
write('does'),write(Patient) , write('have a swollen_glands (Y/N)?'),
read(Reply),
write(Reply),
Reply = 'yes'.
hypothesis(Patient,measles):-
symptom(Patient,fever),
symptom(Patient,cough),
symptom(Patient,conjunctivitis),
symptom(Patient,runny_nose),
symptom(Patient,rash).
hypothesis(Patient,german_measles):-
symptom(Patient,fever),
symptom(Patient,headache),
symptom(Patient,runny_nose),
symptom(Patient,rash).
hypothesis(Patient,flu):-
symptom(Patient,fever),
symptom(Patient,headache),
symptom(Patient,body_ache),
symptom(Patient,conjunctivitis),
symptom(Patient,chills),
symptom(Patient,sore_throat),
symptom(Patient,cough),
symptom(Patient,runny_nose).
hypothesis(Patient,common_cold):-
symptom(Patient,headache),
symptom(Patient,sneezing),
symptom(Patient,sore_throat),
symptom(Patient,chills),
symptom(Patient,runny_nose).
hypothesis(Patient,mumps):-
symptom(Patient,fever),
symptom(Patient,swollen_glands).
hypothesis(Patient,chicken_pox):-
symptom(Patient,fever),
symptom(Patient,rash),
symptom(Patient,body_ache),
symptom(Patient,chills).
hypothesis(Patient,whooping_cough):-
symptom(Patient,cough),
symptom(Patient,sneezing),
symptom(Patient,runny_nose).
hypothesis(Patient,flem):-
symptom(Patient,fever),
symptom(Patient,cough).
Now compile and run the program. At the console type go. ( With the period). There you go.
Thank you.
No comments:
Post a Comment