Groovy web console

subscribe to the feed Subscribe
to this
site
rule engine (via #groovywebconsole)
tweet this snippet Tweet
this
script

rule engine

Published 4 weeks ago by Abhinandan with tags davaa
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
Map patientData = [age: 20, gender: "Female", acqired: "Hospital"]
List route = []
String prferredAntibiotic

if (patientData.age >= 25) {
    route << "L1"
} else if (patientData.age <= 20) {
    route << "L3"
} else {
    route << "L2"
}

if (patientData.gender == "Male") {
    route << "L4"
} else {
    route << "L5"
}

if (patientData.acquired == "Hospital") {
    route << "L6"
} else {
    route << "L7"
}

println("route:" + route)

if (route.equals(["L1", "L4", "L7"]) || route.equals(["L1", "L5", "L6"])) {
    prferredAntibiotic = "ceftriaxone"
} else if (route.equals(["L1", "L4", "L6"]) || route.equals(["L3", "L5", "L7"])) {
    prferredAntibiotic = "ciprofloxacin"
} else if (route.equals(["L1", "L5", "L7"]) || route.equals(["L3", "L5", "L6"])) {
    prferredAntibiotic = "ciprofloxacin"
} else {
    prferredAntibiotic = "Not available"
}

println("Prferred Antibiotic is:" + prferredAntibiotic)