I am new to Drools and am trying to design some rules for a dental insurance application. The system will basically let users known when a procedure they are about to perform may not be covered by insurance based on the history of previously performed services. It will have other rules as well, which may be age based, but I can handle those.
My facts are:
- Patient - Listing of patient information.
- Services - Previously performed services. (ie: serviceCode=D1234, datePerformed=Date)
- Alerts - (alertName = "Xrays 2/12 Month Period")
I need a rule which says WHEN a patient has had D1234 performed 2 or more times in the last 12 month period THEN add a warning saying that D1234 may not be covered by insurance until 12 months after date of last D1234 service.
Further complicating the situation is the fact that there could be groups of codes which are limited in the same way. So, the codes listed in the rule may be an array of codes and not just a single one, but the rule would still need to fire.
I could write a service to fetch all the services performed and just do it like that, but I would think it is nicer to just throw all the facts (previous services, etc) into Drools and let it work it all out. This way I could have a rule process run for each patient with their alerts and previous services as facts and the result with be a list of warnings.
Can someone help me understand how to write a rule like I need above?