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.
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.
If the antibody count is low,
or (anaemia is absent,
and the lifestyle is active),
then the recommended admission is outpatient.
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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…