[rules-users] Facts - One to Many

Wolfgang Laun wolfgang.laun at gmail.com
Thu Jan 2 02:01:49 EST 2014


Ideally, a relation is represented by separate objects. Then you might have
a rule

   $p: Patient()
   $p: Takes( patient == $p, $m: medication )
   Medication( this == $m )

and this rule will fire for each medication of the patient.

Answering such questions without details about the actual data model
is impossible.

-W

On 02/01/2014, Ray Hooker <ray.hooker at me.com> wrote:
> I am trying to figure out how to work with an existing model. The data is
> in
> MongoDB with embedded documents.  It is about patients would have
> sub-documents.  For example.  An individual patient may have multiple
> allergies. Also a patient has multiple medications.  So it is as follows:
>
> - Patient.medications ---> multiple Medication objects
>
> So I see where you have a simple one to one.  Typically perhaps you might
> have the medication record know that it is associated with the patient, but
> that is not how it is currently organized.  So the question is can I write
> rules when patients.medications returns a set/ collection of medications
> associated with the patient. I want to write a rule such as "if a patient
> is
> taking medication=xxx...."
>
> Thanks for your help.
>
> Ray Hooker


More information about the rules-users mailing list