Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
643 views
in Technique[技术] by (71.8m points)

prolog - I cannot get my Flex program to output a result into the console, it only returns "no"

I'm doing a little training project in flex, a hospital booking system. I can't seem to get it to output the admission type into the console; (inpatient, outpatient, day patient, waitlist), based upon the rules. It only returns "no", it should return 'inpatient','daypatient','outpatient' or 'waitlist' can anyone else see what I'm missing? It's driving me up the wall...

question subject
'what is subject name?' ;
input name.

question patient_risk
'what is the patient risk?' ;
choose one of high, medium, low.

question condition_time
'how long have they had the condition for?' ;
choose one of months, weeks, days.

question clinical_trial
'is the trial justifiable?' ;
choose one of yes, no.

question antibody_count
'what is their antibody count?' ;
choose one of high, medium, low.

question life_style 
'How do they live?' ;
choose one of sedentary, active.

question anaemia_state
'do they have anemia?' ;
choose one of yes, no.

question blood_pressure
'is their blood pressure raised?' ;
choose one of yes, no.
%ACTION---------------------------

action create ; %This action is to create 
do ask subject
and ask patient_risk
and ask condition_time
and ask clinical_trial
and ask antibody_count
and ask life_style
and ask anaemia_state
and ask blood_pressure
and check that Patient1 is subject
and subject is a new patient whose patient_risk is patient_risk
and whose condition is patient_condition
and whose lifestyle is life_style
and whose anaemia is anaemia_state
and invoke ruleset testing
and restart. %resets collected data

%ACTION---------------------------

%consider rulesets instead for admission types.

rule clinical_trial_not_ok
if patient_risk is high
then clinical_trial becomes no
and admission becomes daypatient
and write ( 'the recommended admission is ' )
and write ( admission ).

rule condition_months
if patient_risk is included in ( low, medium )
and condition_time is months
then antibody_count becomes high
and admission becomes daypatient
and write ( 'the recommended admission is ' )
and write ( admission ).

rule condition_days
if condition_time is days
then antibody_count becomes low
and admission becomes outpatient
and write ( 'the recommended admission is ' )
and write ( admission ).

rule active_not_anaemic
if patient_risk is included in ( low, medium )
and condition_time is weeks
and life_style is active
and anaemia_state is no
then admission becomes outpatient
and write ( 'the recommended admission is ' )
and write ( admission ).

rule sedentary_highblood_anaemic
if patient_risk is included in ( low, medium )
and life_style is sedentary
and anaemia_state is yes
and blood_pressure is yes
then admission becomes inpatient
and write ( 'the recommended admission is ' )
and write ( admission ).

rule active_and_anaemic
if patient_risk is included in ( low, medium )
and condition_time is weeks
and life_style is active
and anaemia_state is yes
then admission becomes waitlist
and write ( 'the recommended admission is ' )
and write ( admission ).

rule sedentary_fineblood_anaemic
if patient_risk is included in ( low, medium )
and life_style is sedentary
and anaemia_state is yes
and blood_pressure is no
then admission becomes waitlist
and write ( 'the recommended admission is ' )
and write ( admission ).

rule sedentary_not_anaemic
if patient_risk is included in ( low, medium )
and life_style is sedentary
and anaemia_state is no
then admission becomes waitlist
and write ( 'the recommended admission is ' )
and write ( admission ).

ruleset testing
contains all rules ;
select rule by first come first served.

frame patient ; %frame for base values of patients.
and default patient_risk is none %sets the risk to 'none'
and default condition_time is none
and default clinical_trial is none
and default antibody_count is none
and default life_style is none
and default anaemia_state is none

It's supposed to work by asking questions and collecting data from the questions to satisfy the rules, which; when they fit the conditions of an admission type, display that admission to the console.

  1. If the antibody count is medium, and the lifestyle is sedentary, and a clinical trial is justifiable, and anaemia is present, and the blood pressure is raised, then the recommended admission is inpatient.

  2. If the antibody count is low, or (anaemia is absent, and the lifestyle is active), then the recommended admission is outpatient.

  3. If the antibody count is high, or a clinical trial is unjustifiable, then the recommended admission is daypatient.

If the recommended admission is not inpatient, and the recommended admission is not outpatient, and the recommended admission is not daypatient, then the recommended admission is waiting list.

question from:https://stackoverflow.com/questions/65645979/i-cannot-get-my-flex-program-to-output-a-result-into-the-console-it-only-return

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...