Med-Expert

Developer(s): Pete Fischer
Date: 1983
Type: Program
Platform(s): TS 2068

This medical expert system can diagnose over 90 different maladies based on the information you provide in answering questions. But be advised, this program is S-L-O-W ! It takes, on average, about TWO HOURS to arrive at an opinion.

It takes your answer to a question and recalculates the probabilities of likelihood for all the 90+ possible outcomes, then it selects the next most important question and prints it. All this is done in BASIC. Since it is in BASIC, it takes about 2 minutes between each question. But when it finally does reach its opinion, it will also give you a precise estimate of it’s probability of accuracy!

This program written by Chris Naylor and is in his book BUILD YOUR OWN EXPERT SYSTEM, published by John Wiley & Sons.

Appears on

Gallery

Med-Expert

Source Code

    1 REM "MED-EXPER" by Chris  Naylor \* 1983
    2 REM This is a Rule Based Expert System
    3 REM For more information,   write, Pete Fischer/P.O.Box    2002 /Tempe,AZ 85281
   16 BORDER 0: PAPER 0: INK 7: GO TO 4000
   18 CLS : PRINT ''''''"Initializing, please wait...": PRINT : PRINT "Takes about 1.5 minutes": DIM a$(200): DIM b$(20): DIM i$(20)
   20 READ a$,a$
   30 LET il=0: LET rl=0
   40 READ p,j
   50 READ z: IF z<>999 THEN GO TO 50
   60 LET il=il+1
   70 READ a$: IF a$( TO 8)="symptoms" THEN GO TO 90
   80 GO TO 40
   90 READ p,a$: IF a$( TO 3)="end" THEN GO TO 120
  100 LET rl=rl+1
  110 GO TO 90
  120 DIM p(il): DIM v(rl): DIM o(il): DIM i(il): DIM a(il): DIM l(il): DIM r(rl)
  130 FOR j=1 TO rl
  140 LET r(j)=1
  150 NEXT j
  170 RESTORE : READ a$
  180 FOR i=1 TO il
  190 READ a$,p(i),j
  200 LET p=p(i)
  210 READ py,pn,s
  220 LET o(i)=o(i)+1
  230 LET v(j)=v(j)+ABS (p*py/(p*py+(1-p)*pn)-p*(1-py)/(p*(1-py)+(1-p)*(1-pn)))
  240 IF s<>999 THEN LET j=s: GO TO 210
  250 LET l(i)=o(i)
  260 NEXT i
  280 LET r=0: LET hr=0
  290 FOR j=1 TO rl
  300 IF v(j)>r THEN LET hr=j: LET r=v(j)
  310 LET v(j)=0
  320 NEXT j
  330 IF hr=0 THEN PRINT "No further symptoms": STOP 
  340 READ a$
  350 FOR j=1 TO hr
  360 READ p,a$
  370 NEXT j
  380 CLS : PRINT AT 1,0;,"MEDICAL"',"EXPERT"''"Question:"'(a$)
  390 LET r(hr)=0
  400 INPUT "Reply on-5 TO +5 Scale:";re
  415 CLS : PRINT ''''''"Takes about 2 min please be      patient..."
  420 RESTORE : READ a$
  430 FOR i=1 TO il
  440 READ a$,p
  450 FOR k=1 TO l(i)
  460 READ j,py,pn
  470 IF j<>hr OR o(i)=0 THEN GO TO 540
  480 LET o(i)=o(i)-1
  490 LET p=p(i)
  500 LET pe=p*py+(1-p)*pn
  510 IF re>0 THEN LET p(i)=p*(1+(py/pe-1)*re/5)
  520 IF re<=0 THEN LET p(i)=p*(1+(py-(1-py)*pe/(1-pe))*re/5)
  530 IF p(i)=INT (p(i)) THEN LET o(i)=0
  540 NEXT k
  550 READ st
  560 NEXT i
  570 REM find new rule values,minima and maxima
  580 RESTORE 
  590 READ a$
  600 LET mm=0: LET mh=0
  610 FOR i=1 TO il
  620 LET p=p(i)
  630 LET a1=1: LET a2=1: LET a3=1: LET a4=1
  640 READ a$,pz
  650 FOR k=1 TO l(i)
  660 READ j,py,pn
  670 IF r(j)*o(i)=0 THEN GO TO 740
  680 IF pn>py THEN LET py=1-py: LET pn=1-pn
  690 LET v(j)=v(j)+p*py/(p*py+(1-p)*pn)-p*(1-py)/(p*(1-py)+(1-p)*(1-pn))
  700 LET a1=a1*py
  710 LET a2=a2*pn
  720 LET a3=a3*(1-py)
  730 LET a4=a4*(1-pn)
  740 NEXT k
  750 LET a(i)=p*a1/(p*a1+(1-p)*a2)
  760 LET i(i)=p*a3/(p*a3+(1-p)*a4)
  770 IF a(i)<pz THEN LET o(i)=0
  780 IF i(i)>mm THEN LET mh=i: LET mm=i(i)
  790 READ s
  800 NEXT i
  820 FOR i=1 TO il
  830 IF i(mh)<=a(i) AND i<>mh THEN LET mm=0
  840 NEXT i
  850 IF mm=0 THEN GO TO 270
  860 RESTORE : READ a$
  870 FOR i=1 TO mh
  880 READ i$,p
  890 FOR k=1 TO l(i)
  900 READ j,py,pn
  910 NEXT k
  920 READ s
  930 NEXT i
  940 CLS : PRINT AT 12,0;,"EXPERT"',"______"''"The most likely outcome is "'(i$)''"with a probability ";(p(mh))
  960 STOP 
 1000 DATA "illnesses"
 1010 DATA "COMMON COLD",.02,1,.9,.05,2,.8,.02,3,.8,.02,5,.6,.01,6,1,.01,7,.2,.01,8,.5,.01,15,.8,.01,34,0,.01,999
 1020 DATA "ALLERGIC RHINITIS",.01,1,1,.01,2,1,.01,6,.9,.01,10,.7,.01,11,.7,.01,12,.6,.01,20,.9,.01,999
 1030 DATA "SINUSITIS",.01,14,.8,.01,13,.9,.01,15,.8,.01,7,.6,.01,22,.5,.01,2,.5,.001,6,.5,.01,63,.9,.01,999
 1040 DATA "PHARYNGITIS",.02,3,1,.01,16,.9,.01,8,.5,.01,11,.9,.01,37,.8,.3,64,.4,.01,999
 1050 DATA "TONSILLITIS",.001,3,1,.01,7,.9,.01,15,1,.01,16,.7,.01,19,0,.5,8,.8,.01,34,0,.01,64,.8,.01,999
 1060 DATA "INFLUENZA",.01,3,.9,.01,1,.9,.01,6,.5,.01,7,.7,.01,8,1,.01,15,1,.01,17,.8,.01,18,.6,.01,34,0,.01,999
 1070 DATA "LARYNGITIS",.01,4,1,.01,8,.6,.01,15,.05,.01,16,.7,.01,37,.8,.3,999
 1080 DATA "TUMOR OF THE LARYNX",.00004,4,1,.01,34,.99,.01,37,.8,.3,999
 1090 DATA "ACUTE BRONCHITIS",.005,5,.1,.01,8,1,.01,12,1,.01,15,1,.01,18,.5,.01,21,1,.01,31,.9,.01,34,0,.01,22,.9,.01,999
 1100 DATA "CHRONIC BRONCHITIS",.005,5,1,.01,12,.9,.01,14,.5,.01,21,1,.01,22,.8,.01,34,1,.01,36,.9,.01,37,.8,.3,999
 1110 DATA "ASTHMA",.02,12,.8,.01,22,1,.01,23,.5,.01,24,.5,.01,25,.5,.01,26,.5,.01,31,.8,.01,999
 1120 DATA "EMPHYSEMA",.01,22,1,.01,5,.001,.01,26,.8,.01,12,.001,.01,21,.001,.01,37,.8,.3,999
 1130 DATA "PNEUMONIA",.003,8,1,.01,15,1,.01,18,.8,.01,22,1,.01,23,.5,.01,26,.5,.01,28,.1,.01,29,.02,.01,27,.2,.01,31,.9,.01,36,.1,.9,7,.9,.01,17,.9,.01,32,.5,.001,999
 1140 DATA "PLEURISY",.001,31,.8,.01,32,.8,.01,22,.5,.01,5,.8,.01,8,.9,.01,15,1,.01,34,0,.01,999
 1150 DATA "PNEUMOTHORAX",.0002,18,.8,.01,22,.8,.01,32,.8,.01,999
 1160 DATA "BRONCHIECTASIS",.00001,21,1,.01,27,.5,.01,5,1,.01,14,.5,.01,999
 1170 DATA "LUNG ABSCESS",1E-5,33,.9,.01,18,.5,.01,21,.5,.01,27,.5,.01,999
 1180 DATA "PNEUMOCONIOSIS",.001,22,1,.01,36,1,.01,21,.8,.01,9,1,.001,999
 1190 DATA "LUNG CANCER",.001,5,1,.01,21,.8,.01,27,.5,.01,22,.5,.01,18,.8,.01,12,.5,.01,37,.99,.3,999
 1200 DATA "INTESTINAL FIBROSIS",1E-5,22,.8,.01,35,.8,.01,21,.6,.01,999
 1210 DATA "PULMONARY OEDEMA",.001,22,.9,.01,25,.9,.01,30,.5,.01,27,.5,.01,26,.5,.01,12,.8,.01,999
 1220 DATA "GASTRITIS",.01,41,.8,.01,43,.8,.01,42,.5,.01,8,.4,.01,37,.9,.5,999
 1230 DATA "HIATUS HERNIA",.001,18,.9,.01,32,.5,.001,42,.8,.001,57,.9,.01,16,.9,.01,41,.8,.01,999
 1240 DATA "DUODENAL ULCER",.01,37,.8,.2,42,.99,.001,41,.8,.01,999
 1250 DATA "PEPTIC ULCER",.01,42,.9,.001,18,.5,.01,20,.8,.01,41,.7,.01,56,.9,.01,62,.0001,.01,999
 1260 DATA "DIVERTICULAR DISEASE",.001,42,.6,.001,43,.5,.01,41,.5,.01,8,.5,.01,49,.5,.01,999
 1280 DATA "CROHN'S DISEASE",.0001,42,.9,.001,43,.9,.01,15,.9,.01,8,.7,.01,62,.00001,.01,999
 1290 DATA "INTESTINAL OBSTRUCTION",.00001,42,.9,.001,43,.8,.01,41,.5,.01,999
 1300 DATA "APPENDICITIS",.001,34,.1,.9,42,.9,.001,41,.8,.01,8,.8,.01,44,0,.5,999
 1310 DATA "FOOD POISONING",.001,42,.5,.001,41,.9,.01,43,.9,.01,7,.8,.01,999
 1320 DATA "GASTROENTERITIS",.01,41,.8,.01,42,.7,.001,43,.9,.01,8,.5,.01,999
 1330 DATA "KIDNEY STONES",.001,42,.7,.001,999
 1340 DATA "ACUTE PYELONEPHRITIS",.001,42,.9,.001,8,.8,.01,41,.7,.01,67,.9,.01,999
 1350 DATA "GALLSTONES",.01,42,.5,.001,41,.5,.01,57,.9,.01,999
 1360 DATA "CHOLECYSTITIS",.001,42,.8,.001,8,.9,.01,41,.8,.01,45,.8,.001,999
 1370 DATA "SHINGLES",.001,42,.5,.001,18,.5,.001,60,.9,.01,59,.9,.01,2,.6,.01,46,.5,.01,999
 1380 DATA "DEEP VEIN THROMBOSIS",.0005,40,.8,.01,999
 1390 DATA "RHEUMATOID ARTHRITIS",.001,15,.8,.01,17,.8,.01,40,.5,.001,999
 1400 DATA "HEART FAILURE",.001,22,.9,.01,36,.5,.01,25,.5,.001,12,.6,.01,18,.5,.001,32,.3,.001,40,.5,.01,42,.5,.01,28,.3,.001,47,.9,.01,999
 1410 DATA "ANXIETY",.01,46,.9,.01,28,.3,.01,47,.6,.01,39,.8,.01,23,.6,.01,48,.6,.01,16,.3,.01,43,.2,.01,22,.5,.01,50,.5,.01,57,.5,.01,58,.5,.01,15,.5,.01,7,.5,.01,7,.5,.01,4,.5,.01,999
 1420 DATA "DEPRESSION",.01,47,.5,.01,7,.5,.01,49,.5,.01,50,.5,.01,15,.5,.01,62,.8,.05,999
 1430 DATA "CORONARY THROMBOSIS",.01,18,.5,.01,32,.9,.001,20,.5,.01,36,0,.2,38,.5,.01,22,.5,.01,23,.5,.01,41,.5,.01,15,.9,.01,999
 1440 DATA "ANGINA",.01,37,.8,.3,18,.9,.01,36,.9,.01,22,.5,.01,23,.5,.01,38,.5,.01,41,.3,.01,999
 1450 DATA "PULMONARY EMBOLISM",.0001,22,1,.01,18,.7,.01,21,.6,.01,27,.5,.001,25,.5,.001,26,.4,.0001,999
 1460 DATA "STROKE",.001,28,.8,.01,38,.7,.01,51,.8,.001,58,.9,.01,999
 1470 DATA "TRANSIENT ISCHAEMIC ATTACK",.001,28,.8,.01,38,.7,.01,51,.8,.001,34,0,.01,20,.5,.01,58,.9,.01,61,.9,.01,999
 1480 DATA "TUBERCULOSIS",.0001,7,.5,.01,8,.5,.01,12,.5,.01,18,.5,.01,5,.5,.01,30,.5,.01,27,.5,.001,22,.5,.01,62,.0001,.01,23,.5,.01,999
 1490 DATA "HAEMORRHIDS",.01,52,.9,.001,49,.8,.01,56,.9,.01,59,.5,.01,999
 1500 DATA "HYPOTHYROIDISM",.001,49,.8,.01,17,.5,.01,24,0,.01,23,.001,.01,39,.001,.01,4,.5,.01,43,0,.01,46,.001,.01,48,.001,.01,62,.9,.05,999
 1510 DATA "IRRITABLE COLON",.0007,43,.5,.01,49,.5,.01,42,.8,.001,41,.3,.01,57,.9,.01,999
 1520 DATA "CANCER OF THE LARGE INTESTINE",.001,43,.9,.01,49,.9,.01,52,.5,.001,42,.5,.001,56,.9,.01,62,.0001,.01,999
 1530 DATA "ULCERATIVE COLITIS",.0004,42,.8,.001,43,.8,.01,52,.6,.001,23,.5,.01,41,.5,.01,8,.5,.01,34,.4,.01,56,.9,.01,999
 1540 DATA "MENIERE'S DISEASE",.0005,38,.9,.001,41,.8,.01,34,.5,.01,20,.9,.01,999
 1550 DATA "CERVICAL SPONDYLOSIS",.006,54,.9,.01,7,.5,.01,38,.5,.01,58,.9,.01,61,.5,.01,999
 1560 DATA "SUBDURAL HAEMORRHAGE",.000001,55,.99,.0001,28,.9,.001,7,.9,.01,41,.9,.01,38,.9,.01,20,.5,.01,34,.5,.01,999
 1570 DATA "BRAIN TUMOR",1E-6,7,.9,.01,41,.9,.01,38,.8,.01,50,.8,.01,34,.5,.01,999
 1580 DATA "MENINGITIS",1E-6,8,.9,.01,7,.9,.01,41,.9,.01,28,.7,.01,54,.9,.01,2,.9,.01,60,.5,.01,999
 1590 DATA "SUBARACHNOID HAEMORRAGE",.00001,7,.99,.01,54,.9,.01,38,.7,.01,28,.7,.01,41,.8,.01,2,.8,.01,999
 1600 DATA "ACUTE GLAUCOMA",.01,2,.9,.01,7,.9,.01,41,.7,.01,20,.8,.01,34,.8,.01,63,.8,.01,68,.9,.01,999
 1610 DATA "TEMPORAL ARTERITIS",.001,7,.9,.01,8,.7,.01,17,.7,.01,2,.8,.01,63,.99,.01,999
 1620 DATA "DYSPEPSIA",.1,18,.7,.01,57,.7,.01,42,.7,.01,41,.7,.01,46,.5,.01,20,.9,.01,999
 1630 DATA "HEART BLOCK",.0003,22,.5,.01,58,.8,.01,39,.6,.01,18,.6,.01,999
 1640 DATA "PERNICIOUS ANAEMIA",.0004,22,.9,.01,58,.9,.01,39,.9,.01,36,.9,.01,45,.5,.01,42,.5,.01,50,.5,.01,28,.4,.01,999
 1650 DATA "MIGRANE",.1,7,1,.01,15,.9,.01,41,.9,.01,43,.5,.01,2,.9,.01,20,.9,.01,34,.9,.01,63,.99,.01,999
 1660 DATA "HYPERTENSION",.15,7,.5,.01,39,.5,.01,15,.5,.01,34,.9,.01,999
 1670 DATA "ECZEMA",.03,59,.9,.01,60,1,.01,999
 1680 DATA "URTICARIA",.03,59,.9,.01,60,1,.01,46,.5,.01,999
 1690 DATA "SCABIES",.001,59,1,.01,60,1,.01,999
 1700 DATA "MEASLES",.02,15,1,.01,8,1,.01,6,.9,.01,2,.9,.01,11,.9,.01,5,.9,.01,43,.5,.01,60,.8,.01,7,.5,.01,34,0,.01,999
 1710 DATA "RUBELLA",.01,8,.5,.01,60,.9,.01,54,.2,.01,34,0,.01,64,.5,.01,999
 1720 DATA "CHICKENPOX",.001,60,1,.01,59,1,.01,8,.8,.01,7,.5,.01,15,.5,.01,8,.8,.01,7,.5,.01,15,.5,.01,34,0,.01,999
 1730 DATA "PSORIASIS",.02,46,.6,.01,3,.5,.01,60,.99,.01,59,.5,.01,999
 1740 DATA "PITYRIASIS ROSEA",.01,60,1,.01,59,.9,.01,34,.5,.01,999
 1750 DATA "ACNE ROSACEA",.01,60,.9,.01,2,.5,.01,34,.8,.01,999
 1760 DATA "THYROTOXICOSIS",.001,46,.9,.01,47,.8,.01,48,.9,.01,23,.9,.01,39,.9,.01,22,.8,.01,43,.8,.01,62,.00001,.01,2,.5,.01,24,.9,.01,64,.3,.01,68,.3,.01,999
 1770 DATA "DIABETES MELLITUS",.01,62,.0001,.01,61,.5,.01,2,.5,.01,66,.99,.01,68,.1,.01,999
 1780 DATA "STOMACH CANCER",.0003,41,.5,.01,42,.7,.001,62,.0001,.01,52,.6,.001,56,.5,.01,999
 1790 DATA "ARTERIAL FILIBRATION",.001,39,.8,.01,38,.5,.01,42,.4,.01,58,.5,.01,999
 1800 DATA "HODGKIN'S DISEASE",.0001,23,.5,.01,63,.6,.01,54,.8,.01,59,.7,.01,64,.99,.01,999
 1810 DATA "GLANDULAR FEVER",.001,8,.9,.01,7,.9,.01,3,.9,.01,15,.9,.01,64,.8,.001,54,.8,.01,45,.5,.001,60,.5,.01,999
 1820 DATA "LYMPHOMA",.0001,64,.9,.01,54,.8,.01,15,.8,.01,62,.001,.01,8,.8,.01,23,.5,.01,59,.8,.01,999
 1830 DATA "MUMPS",.01,64,.99,.01,8,.8,.01,15,.9,.01,16,.7,.01,54,.6,.01,3,.8,.01,999
 1840 DATA "BELL'S PALSY",.0003,51,.9,.01,63,.5,.01,999
 1850 DATA "PARKINSON'S DISEASE",.001,48,.9,.01,51,.8,.01,42,.3,.01,50,.2,.01,28,.1,.01,999
 1860 DATA "RHEUMATIC FEVER",.01,3,.8,.01,15,.8,.01,8,.8,.01,64,.8,.01,60,.5,.01,59,.001,.01,48,.1,.01,999
 1870 DATA "CYSTITIS",.01,66,.9,.01,65,.9,.01,67,.9,.01,8,.5,.01,999
 1880 DATA "KIDNEY TUMOR",.001,8,.6,.01,62,.0001,.01,41,.5,.01,42,.5,.01,65,.7,.01,999
 1890 DATA "BLADDER TUMOR",.0004,65,.9,.01,42,.5,.01,66,.5,.01,67,.5,.01,8,.3,.01,999
 1900 DATA "IRITIS",.0005,2,.9,.01,68,.9,.01,999
 1910 DATA "ACUTE HEPATITIS",.001,8,.8,.01,15,.8,.01,17,.5,.01,42,.5,.01,45,.5,.01,41,.5,.01,999
 1999 REM *********************
 2000 DATA "symptoms"
 2010 DATA 1,"ARE YOU SNEEZING A LOT?"
 2020 DATA 2,"ARE YOUR EYES PAINFUL OR        WATERING A LOT?"
 2030 DATA 3,"DO YOU HAVE A SORE THROAT?"
 2040 DATA 4,"IS YOUR VOICE HOARSE?"
 2050 DATA 5,"ARE YOU COUGHING A LOT?"
 2060 DATA 6,"DO YOU HAVE A RUNNY NOSE?"
 2070 DATA 7,"DO YOU HAVE A HEADACHE, OR- IN  GENERAL - DO YOU SUFFER FROM    HEADACHES AT ALL?"
 2080 DATA 8,"DO YOU HAVE A HIGH TEMPERATURE? (SAY, OVER 100F)"
 2090 DATA 9,"DO YOU SPEND A LOT OF YOUR TIME IN A VERY DUSTY ATMOSPHERE?"
 2100 DATA 10,"DOES YOUR SKIN ITCH?"
 2110 DATA 11,"DO YOU HAVE A DRY THROAT?"
 2120 DATA 12,"IS YOUR BREATHING,'WHEEZY'?"
 2130 DATA 13,"IS YOUR NOSE VERY 'BLOCKED UP'?"
 2140 DATA 14,"HAVE YOU HAD A COLD OR SIMILAR  INFECTION RECENTLY?"
 2150 DATA 15,"DO YOU FEEL GENERALLY ILL?"
 2160 DATA 16,"DO YOU HAVE TROUBLE SWALLOWING?"
 2170 DATA 17,"DO YOUR MUSCLES ACHE?"
 2180 DATA 18,"DO YOU HAVE ANY PAIN AT ALL IN  YOUR CHEST?"
 2190 DATA 19,"HAVE YOU HAD YOUR TONSILS       REMOVED?"
 2200 DATA 20,"DO YOU HAVE ANY SYNPTOMS WHICH  TEND TO OCCUR IN 'ATTACKS'      RATHER THAN BEING PRESENT ALL   THE TIME?"
 2210 DATA 21,"DO YOU HAVE A 'PRODUCTIVE' COUGH- A COUGH IN WHICH YOU BRING UP SOMETHING?"
 2220 DATA 22,"ARE YOU RATHER BREATHLESS?"
 2230 DATA 23,"DO YOU SWEAT A LOT- NOT JUST    WHEN YOU EXERT YOURSELF,BUT WHENYOU ARE APPARENTLY RELAXING AS  WELL?"
 2240 DATA 24,"IS YOUR PULSE RATE HIGH?        NORMALLY IT SHOULD BE ABOUT 60  TO 80 BEATS/MINUTE, SLIGHTLY    FASTER FOR PEOPLE OVER 70 AND   UNDER 20."
 2250 DATA 25,"DO YOU HAVE SEVERE ATTACKS OF   BREATHLESSNESS - ENOUGH TO      SERIOUSLY WORRY YOU?"
 2260 DATA 26,"DOES YOUR SKIN HAVE A BLUISH    TINGE?"
 2270 DATA 27,"WHEN YOU COUGH, IS YOUR PHLEGM  STAINED WITH BLOOD?"
 2280 DATA 28,"ARE YOU SOMETIMES CONFUSED ABOUTWHAT'S GOING ON AROUND YOU?"
 2290 DATA 29,"ARE YOU (OR THE PATIENT)        DELERIOUS- TALKING INCOHERENTLY WITH POOR MUSCULAR COORDINATION?"
 2300 DATA 30,"DO YOU HAVE A DRY               (NON-PRODUCTIVE) COUGH?"
 2310 DATA 31,"IS IT PAINFUL WHEN YOU BREATH OR COUGH?"
 2320 DATA 32,"DO YOU HAVE ANY REALLY SEVERE   PAIN IN  YOUR CHEST?"
 2330 DATA 33,"DO YOU SWING BETWEEN FEELING    CHILLED AND FEELING FEVERISH?"
 2340 DATA 34,"DO YOU HAVE ANY SYMPTOMS WHICH  HAVE BEEN PRESENT FOR SOME TIME-POSSIBLY SIX WEEKS OR MORE?"
 2350 DATA 35,"DO YOU HAVE 'CLUBBED FINGERS'?  -THESE ARE FINGERS IN WHICH THE CUTICLES HAVE ALMOST DISAPPEAREDAND THE NAILS CURVE OVER AT THE FINGER TIPS."
 2360 DATA 36,"DO YOU HAVE ANY SYMPTOMS WHICH  MAINLY OCCUR WHEN YOU EXERT     YOURSELF?"
 2370 DATA 37,"DO YOU SMOKE?-TO REPLY, DIVIDE  THE NUMBER OF CIGARETTES YOU    SMOKE BY 5- USE THIS NUMBER TO  REPLY (IF YOU SMOKE 20/DAY,     REPLY 4).5 IS THE MAXIMUM REPLY AND -5 MEANS YOU DO NOT SMOKE."
 2380 DATA 38,"DO YOU SUFFER FROM FEELINGS OF  DIZZYNESS?"
 2390 DATA 39,"DO YOU HAVE PALPITATIONS? - THE FEELING THAT YOUR HEART IS      BEATING MORE STRONGLY OR FASTER OR MORE UNEVENLY THAN IT SHOULD."
 2400 DATA 40,"IS EITHER OF YOUR ANKLES UNDULY SWOLLEN?"
 2410 DATA 41,"ARE YOU VOMITING OR HAVE STRONG FEELINGS OF NAUSEA?"
 2420 DATA 42,"DO YOU HAVE ANY ABDOMINAL PAIN? THIS IS A PAIN ANYWHERE BETWEEN THE BOTTOM OF THE RIBCAGE AND   THE GROIN."
 2430 DATA 43,"DO YOU SUFFER FROM DIARRHOEA?"
 2440 DATA 44,"HAVE YOU HAD YOUR APPENDIX      REMOVED?"
 2450 DATA 45,"DO YOU HAVE JAUNDICE? THIS IS   NOT A DISEASE, BUT A SYMPTOM OF DISEASE. OFTEN IT IS MOST       OBVIOUS IN THE EYES- THE WHITES BECOME YELLOW."
 2460 DATA 46,"ARE YOU RATHER TENSE AND        APPREHENSIVE?"
 2470 DATA 47,"DO YOU FIND IT HARD TO GET TO   SLEEP OR DO YOU OFTEN WAKE IN   THE MIDDLE OF THE NIGHT?"
 2480 DATA 48,"DO YOU HAVE ANY INVOLUNTARY     TWITCHING OR TREMBLING?"
 2490 DATA 49,"DO YOU SUFFER FROM CONSTIPATION?PASSING FAECES INFREQUENTLY OR  WITH DIFFICULTY."
 2500 DATA 50,"DO YOU HAVE A POOR MEMORY?- THATIS, DIFFICULTY IN REMEMBERING   INDIVIDUAL FACTS EITHER         OCCASIONALLY OR REGULARLY?"
 2510 DATA 51,"HAVE YOU TOTALLY OR NEARLY LOST YOUR POWER OF SPEECH?"
 2520 DATA 52,"HAVE YOU EXPERIENCED ANY        BLEEDING FROM YOUR BACK PASSAGE?"
 2530 DATA 53,"ARE YOU MALE OR FEMALE? ANSWER 5 FOR MALE AND -5 FOR FEMALE. IF YOU'D LIKE THE ANALYSIS TO BE   GENERAL (FOR EITHER SEX) REPLY 0"
 2540 DATA 54,"IS YOUR NECK STIFF AND/OR       PAINFUL?"
 2550 DATA 55,"HAVE YOU SUSTAINED ANY KIND OF  HEAD INJURY OVER THE LAST FEW   WEEKS? EVEN A VERY SLIGHT INJURYCAN BE IMPORTANT."
 2560 DATA 56,"HAVE YOU RECENTLY BEEN PASSING  ABNORMAL LOOKING FAECES?"
 2570 DATA 57,"ARE YOU PASSING LARGE QUANITIES OF WIND- EITHER BY BELCHING OR  BY FLATULENCE?"
 2580 DATA 58,"DO YOU HAVE SUDDEN FEELINGS OF  FAINTNESS- FEELING WEAK AND     UNSTEADY, MAYBE EVEN LOSING     CONSCIOUSNESS?"
 2590 DATA 59,"DOES ANY PART OF YOUR BODY ITCH?WITH OR WITHOUT THE PRESENCE OF ANY RASH?"
 2600 DATA 60,"DO YOU HAVE A SKIN RASH OF ANY  SORT?"
 2610 DATA 61,"IS ANY PART OF YOUR BODY NUMB?- OR DO YOU HAVE A TINGLING 'PINS AND NEEDLES' SENSATION ANYWHERE?"
 2620 DATA 62,"ARE YOU OVERWEIGHT OR           UNDERWEIGHT? REPLY 5 FOR        DEFINATE OVERWEIGHT AND -5 FOR  DEFINATE UNDERWEIGHT. REPLY 0 IFYOUR WEIGHT IS JUST RIGHT."
 2630 DATA 63,"DO YOU HAVE ANY PAIN IN YOUR    FACE OR FOREHEAD?"
 2640 DATA 64,"DO YOU HAVE ANY SWELLINGS UNDER THE SKIN?"
 2650 DATA 65,"IS YOUR URINE AN ABNORMAL COLOR?"
 2660 DATA 66,"ARE YOU URINATING UNUSUALLY     FREQUENTLY?"
 2670 DATA 67,"IS IT PAINFUL WHEN YOU URINATE?"
 2680 DATA 68,"IS YOUR VISION IMPAIRED IN ANY  WAY- BLURRING OR DOUBLE VISION  OR SEEING FLASHING LIGHTS? (THISDOES NOT INCLUDE DEFECTS WHICH  CAN BE CORRECTED BY EYEGLASSES)."
 3000 DATA 68,"end"
 4000 CLS : PRINT AT 2,10;"SPECTRUM"
 4010 PRINT AT 4,11;"MEDICAL"
 4020 PRINT AT 6,8;"EXPERT SYSTEM"
 4030 PAUSE 10
 4040 PRINT AT 10,9;"Written  by"
 4050 PRINT AT 12,9;"Chris Naylor"
 4060 PRINT AT 20,2;"(Press any key to continue)"
 4070 IF INKEY$="" THEN GO TO 4070:
 4080 CLS : PRINT AT 4,13;"MENU"
 4090 PRINT AT 7,1;"Beginner's Information......1"
 4100 PRINT AT 9,1;"Diagnose a Patient..........2"
 4110 PRINT AT 11,1;"Advanced Information........3"
 4120 PRINT AT 13,1;"STOP the program............4"
 4130 INPUT ;"YOUR CHOICE?";C
 4140 IF C=1 THEN GO TO 5000
 4150 IF C=2 THEN GO TO 18
 4160 IF C=3 THEN GO TO 6000
 4170 IF c=4 THEN CLS : PRINT AT 5,5;"If you would like more     information about this program  or about Artificial Intelligenceas it can be demonstrated on    Sinclair Computers, write me:                                              Pete Fischer                    P.O.Box 2002                    Tempe,AZ 85281                  MCI Mail #310-4437": STOP 
 5000 CLS : PRINT AT 2,5;"BEGINNER'S INFORMATION"
 5010 PRINT AT 4,2;"This is a REAL Medical Expert."
 5020 PRINT AT 5,0;"It is not a DEMO or a toy. It "
 5030 PRINT AT 6,0;"can diagnose over 90 different"
 5040 PRINT AT 7,0;"maladies based on the informa-"
 5050 PRINT AT 8,0;"tion you provide in answering"
 5060 PRINT AT 9,0;"questions."
 5070 PRINT AT 10,3;"But be advised, this program"
 5080 PRINT AT 11,0;"is S-L-O-W ! It takes, on aver-"
 5090 PRINT AT 12,0;"age, about TWO HOURS to arrive"
 5100 PRINT AT 13,0;"at an opinion. It takes your"
 5110 PRINT AT 14,0;"answer to a question and recal-"
 5120 PRINT AT 15,0;"culates the probabilities of"
 5130 PRINT AT 16,0;"likelihood for all the 90+"
 5140 PRINT AT 17,0;"possible outcomes, then it se-"
 5150 PRINT AT 18,0;"lects the next most important"
 5160 PRINT AT 19,0;"question and prints it. All "
 5170 PRINT AT 20,0;"this is done in BASIC."
 5175 PRINT AT 21,4;"(Press any key to continue)"
 5177 IF INKEY$="" THEN GO TO 5177
 5178 CLS 
 5180 PRINT AT 2,0;"Since it IS in BASIC, it takes"
 5190 PRINT AT 3,0;"about 2 minutes between each"
 5200 PRINT AT 4,0;"question."
 5210 PRINT AT 5,5;"But when it finally DOES"
 5220 PRINT AT 6,0;"reach it's opinion, it will"
 5230 PRINT AT 7,0;"also give you a precise esti-"
 5240 PRINT AT 8,0;"mate of it's probability of"
 5250 PRINT AT 9,0;"accuracy!"
 5260 PRINT AT 10,5;"How does it work? Well, to"
 5270 PRINT AT 11,0;"give you a real understanding"
 5280 PRINT AT 12,0;"requires a bit of explanation."
 5290 PRINT AT 13,0;"It employs Bayes Theorem. For"
 5300 PRINT AT 14,0;"a technical description of this"
 5310 PRINT AT 15,0;"select 'Advanced Information"
 5320 PRINT AT 16,0;"from the main menu."
 5325 PRINT AT 20,5;"(PRESS ANY KEY TO CONTINUE)"
 5327 IF INKEY$="" THEN GO TO 5317
 5330 CLS : PRINT AT 1,5;"This Program written by "
 5340 PRINT AT 2,0;"Chris Naylor and is in his book"
 5350 PRINT AT 3,0;"BUILD YOUR OWN EXPERT SYSTEM"
 5360 PRINT AT 4,0;"Published by John Wiley & Sons, New York,1983. It can be found  in most B.Dalton bookstores."
 5370 PRINT AT 7,5;"If you'd like more informa-tion on this program or on Arti-ficial Intelligence as it can be demonstrated on Sinclair Compu-ters, write me:"
 5380 PRINT AT 13,7;"Pete Fischer                    P.O.Box 2002                    Tempe,AZ 85281                  MCI Mail#310-4437"
 5460 PRINT AT 20,5;"(PRESS ANY KEY TO CONTINUE)"
 5470 IF INKEY$="" THEN GO TO 5470
 5480 GO TO 4080
 6000 CLS : PRINT AT 2,3;"ADVANCED USER INFORMATION"
 6010 PRINT AT 4,5;"This program operates on   Bayes Theorem. In order to set  up this program, or one like it on another subject; you need a  lot of detailed information."
 6015 PRINT AT 9,5;"In order to create an Ex-  pert system, we first need to   define the Domain of Enquiry.   Simply using 'medicine' is not  enough."
 6030 PRINT AT 14,5;"So if we are diagnosing    'ILL' patients, we will need to include some maladies and ex-   clude others. If only because weknow more about some things."
 6040 PRINT AT 20,3;"(PRESS ANY KEY)"
 6050 IF INKEY$="" THEN GO TO 6050
 6060 CLS : PRINT AT 1,5;"Presumably, Mr.Naylor was  able to find excellent informa- tion on some diseases, but lit- tle on others."
 6070 PRINT AT 5,5;"What kind of information dowe need? Well, here is the way  it is set up in the DATA state- ments:"
 6080 PRINT AT 10,0;"1010 DATA 'Illness A',p,j,py,pn,999"
 6090 PRINT AT 13,5;"Where 'Illness A' refers tothe name of the disorder (say,  MEASLES, for example).Then p is the overall probability of any  given patient having Measles."
 6095 PRINT AT 18,0;"The next 3 variables may be"
 6100 PRINT AT 20,3;"(PRESS ANY KEY)"
 6110 IF INKEY$="" THEN GO TO 6110
 6120 CLS : PRINT AT 1,0;"repeated a number of times de-  pending on the number of symp-  toms related to that particular illness. The j refers to the    number we have assigned to each symptom."
 6130 PRINT AT 7,5;"The first symptom our new  expert asks to identify Measles is #15,'Do you feel generally   ill?'"
 6140 PRINT AT 11,5;"So far, our DATA statementsays:                                DATA 'Measles',.02,15,py,pn,"
 6150 PRINT AT 15,5;"This means there's a .02%  chance of any given patient hav-ing Measles, and the first thingour expert needs to know is doesthe patient feel 'generally ill'"
 6160 PRINT AT 20,8;"(PRESS ANY KEY)"
 6170 IF INKEY$="" THEN GO TO 6170
 6180 CLS : PRINT AT 0,5;"Then we need to know what  the chances are that our patientwill give us good or bad infor- mation. 'py' equals the proba-  bility that the patient HAS the Measles and also answers 'Yes'  to this question. 'pn' is the   probability of a 'No' answer."
 6190 PRINT AT 8,5;"In the case of Measles, ourexpert goes on to ask a total of10 questions (to which it must  receive the correct answers to),before concluding that the pa-  tient DOES have Measles"
 6200 PRINT AT 20,5;"(PRESS ANY KEY TO CONTINUE)"
 6210 IF INKEY$="" THEN GO TO 6210
 6220 GO TO 4080
 7000 STOP 
 9998 SAVE "MED5" LINE 1
 9999 VERIFY "MED5"
Scroll to Top