Chatbot-Covid finder
In 2020, I wrote a python programme to make a chatbot.
In 2020, at the beginniing of coronavirus outbreak in our country, I wrote a python programme to make a chatbot. This chatbot asked some questions to the user. Depending on the answers, it tried to asses if the user had covid-19 infection. It was a relatively new idea that time. Now, this type of chatbots can be seen in action on many healthcare-related websites.
Hardware and Software used:
Python 3 IDLE
Any regular PC or laptop. You can also use a SBC like the Raspberry Pi
Programme:
Hardware and Software used:
Python 3 IDLE
Any regular PC or laptop. You can also use a SBC like the Raspberry Pi
Programme:
print ("Hello,I am covid finder. What is your name?") name= input() print ("How old are you?") age= int(input()) print("Are you a male or female?") gender=input() gender=gender.lower() print ("OK "+ name + ", now answer the following questions in Yes or No.") print ("Do you have fever?") feveryn=input() feveryn=feveryn.lower() if (feveryn=='yes'): print ("How many degree fahrenheit?") feverdegree=int(input()) if(feverdegree>102): print("That is quite a high temperature.") print ("For how many days? Please write the number only.") feverdays=int(input()) print ("Have you taken any medicine? If so, please mention the name.") medicine=input() elif (feveryn=='no'): feverdegree=int(0) feverdays=int(0) else: while(1): print("Please answer in yes or no.") feveryn=input() feveryn=feveryn.lower() if(feveryn=='yes'or feveryn=='no'): break if (feveryn=='yes'): print ("How many degrees?") feverdegree=int(input()) if(feverdegree>102): print("That is quite a high temperature.") print ("For how many days? Please write the number only.") feverdays=int(input()) print ("Have you taken any medicine? If so, please mention the name.") medicine=input() elif (feveryn=='no'): feverdegree=int(0) feverdays=int(0) print ("Do you have cough and/or sore throat?") coughyn=input() coughyn=coughyn.lower() while(coughyn!='yes'and coughyn!='no'): print("Please answer in yes or no.") coughyn=input() coughyn=coughyn.lower() if(coughyn=='yes'or coughyn=='no'): break print ("Do you have runny nose?") runnyyn=input() runnyyn=runnyyn.lower() while(runnyyn!='yes'and runnyyn!='no'): print("Please answer in yes or no.") runnyyn=input() runnyyn=runnyyn.lower() if(runnyyn=='yes'or runnyyn=='no'): break print ("Do you have breathing difficulties?") breathingyn=input() breathingyn=breathingyn.lower() while(breathingyn!='yes'and breathingyn!='no'): print("Please answer in yes or no.") breathingyn=input() breathingyn=breathingyn.lower() if(breathingyn=='yes'or breathingyn=='no'): break print ("Can you smell everything well?") smellyn=input() smellyn=smellyn.lower() while(smellyn!='yes'and smellyn!='no'): print("Please answer in yes or no.") smellyn=input() smellyn=smellyn.lower() if(smellyn=='yes'or smellyn=='no'): break print ("Can you taste foods without any abnormality?") tasteyn=input() tasteyn=tasteyn.lower() while(tasteyn!='yes'and tasteyn!='no'): print("Please answer in yes or no.") tasteyn=input() tasteyn=tasteyn.lower() if(tasteyn=='yes'or tasteyn=='no'): break print("Have you travelled recently to/from any other country or city?") travelyn=input() travelyn=travelyn.lower() while(travelyn!='yes'and travelyn!='no'): print("Please answer in yes or no.") travelyn=input() travelyn=travelyn.lower() if(travelyn=='yes'or travelyn=='no'): break print ("Did any of your family members come back home after travelling anywhere?") travelyn2=input() travelyn2=travelyn2.lower() while(travelyn2!='yes'and travelyn2!='no'): print("Please answer in yes or no.") travelyn2=input() travelyn2=travelyn2.lower() if(travelyn2=='yes'or travelyn2=='no'): break if(gender=='male'): print("I am sorry to ask such a personal question but it is important.") print("Can you feel any pain or swelling in your scrotum?") swelling=input() swelling=swelling.lower() while(swelling!='yes'and swelling!='no'): print("Please answer in yes or no") swelling=input() swelling=swelling.lower() if(swelling=='yes'or swelling=='no'): break if(gender!='male'): swelling='no' if(swelling=='yes'): print ("Many Covid patients have complained about scrotal swelling and pain. I think you must pay attention to this issue") if(feveryn=='no' and coughyn=='yes' and runnyyn=='no' and breathingyn=='no' and smellyn=='yes' and tasteyn=='yes'): print ("May be it is a normal cough. Try home remedies like honey,lemon & hot water drink,licorice etc.") print("If anything serious occurs like continuous coughing for hours or breathing difficulty, contact a doctor soon.") if(breathingyn=='yes'): print ("Try to manage an oxymeter and measure your oxygen saturation. Below 95% is an emergency and needs medical attention.") if(feveryn=='yes'and feverdegree<102 and feverdays<4 and swelling=='no'): print("If the temperature goes higher and persists after 3 days, please consult a doctor for COVID-19 test recommendation.") if(feveryn=='yes'and feverdegree<102 and feverdays>=4 and swelling=='no'): print("please consult a doctor for COVID-19 test recommendation.") if(feveryn=='yes'and feverdegree>102 and feverdays<5): print("Considering your very high temperature, I suggest you to contact a doctor immidiately. Testing for both Coronavirus and dengue may be needed.") print("Unless prescribed by a doctor, do not take antibiotic. Use paracetamol supositary if your fever is 103 or above.") if(feveryn=='no' and coughyn=='no' and runnyyn=='yes' and breathingyn=='no' and smellyn=='yes' and tasteyn=='yes' ): print("It can happen due to seasonal cold or alergy. But no one is beyond suspition now. Isolate yourself as much as possible and wear mask when you really need to interact with others.") if(feveryn=='no' and coughyn=='yes' and runnyyn=='yes' and breathingyn=='no' and tasteyn=='yes' ): print("It can happen due to seasonal cold or alergy. But no one is beyond suspition now. Isolate yourself as much as possible and wear mask when you really need to interact with others.") if( feveryn=='yes'and feverdegree>=102 and feverdays>=5): print ("Well, I can see your fever is for quite a long time.You would better go for a COVID-19 test.") if(feveryn=='yes' and coughyn=='yes' and runnyyn=='yes' and breathingyn=='yes' and feverdays<=3 and smellyn=='yes' and tasteyn=='yes' and feverdegree<=102): print ("Hmm, all these symptoms are quite similar to coronavirus.But this can be normal flue also. If the fever persists after 3 days, please go for a covid-19 test.") if(feveryn=='yes' and coughyn=='yes' and runnyyn=='yes' and breathingyn=='yes' and feverdays>=4 and smellyn=='yes' and tasteyn=='yes' ): print ("Hmm, all these symptoms are quite similar to coronavirus.please go for a covid-19 test.") if(feveryn=='yes' and coughyn=='no' and runnyyn=='no' and breathingyn=='no' and feverdegree<=102 and feverdays<=3 and smellyn=='yes' and tasteyn=='yes' and swelling=='no' ): print ("Since there is no other symptoms than fever, if the fever persists after 3 days, please go for a covid-19 test.") if(feveryn=='yes' and coughyn=='no' and runnyyn=='no' and breathingyn=='no' and feverdegree<=102 and feverdays<=3 and smellyn=='yes' and tasteyn=='yes' and swelling=='yes' ): print ("Please consult a doctor and tell all the symptoms.") if(feveryn=='yes' and coughyn=='yes' and runnyyn=='yes' and breathingyn=='no' and feverdegree<=102 and feverdays<=3 and smellyn=='yes' and tasteyn=='yes'and swelling=='no'): print ("Since there is no other symptoms than fever and cold I think It is not an emergency, if the fever persists after 3 days, please go for a covid-19 test.") if(feveryn=='yes' and coughyn=='yes' and runnyyn=='yes' and breathingyn=='no' and feverdegree<=102 and feverdays<=3 and smellyn=='yes' and tasteyn=='yes'and swelling=='yes'): print ("Please consult a doctor.") if(feveryn=='yes' and coughyn=='yes' and runnyyn=='no' and breathingyn=='no' and feverdegree<=102 and feverdays<=3 and smellyn=='yes' and tasteyn=='yes'and swelling=='yes'): print ("Please consult a doctor and tell these symptoms.") if(travelyn=='yes' or travelyn2 =='yes'): print("I believe the travel history that you have provided has enough reasons to be afraid of. Even if you have no symptoms, you are at risk.") if(smellyn=='no' and tasteyn =='no'): print("Difficulty in smelling and tasting are prominents symptoms. I think you should go for a COVID -19 test.") if(smellyn =='no'and tasteyn =='yes' ): print ("Loss of smelling sense is a very prominent symptom. If you cannot smell anything even when you do not have runny nose, I think you should go for a COVID -19 test.") if(tasteyn=='no'and smellyn =='yes'): print ("Loss of taste is a very prominent symptom. I think you should go for a COVID -19 test.") if(feveryn=='no' and coughyn=='no' and runnyyn=='no' and breathingyn=='no' and smellyn=='yes' and tasteyn=='yes' and swelling=='no'): print ("You seem quite OK to me. Please stay indoor as much as possible. Use mask when you go out.") if(12=50): print("Considering your age you should always be very careful.") print("If you have any comorbidity like asthma,kidney problems or heart diseases,please keep in touch with your regular doctors.") print ("Press any key to end conversation.") end=input()
Discussie (0 opmerking(en))