Uploaded image for project: 'Logic Module'
  1. Logic Module
  2. LOGIC-77

Rules have access to a full Patient, but LogicDataSources don't

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Should
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Logic 0.5
    • Labels:
      None
    • Complexity:
      Medium

      Description

      When you evaluate a rule, the logic service fetches a Patient object to pass to Rule.eval(LogicContext, Patient, Map). This fetch is expensive for large cohorts--it's actually the most expensive step in evaluating simple rules. (It takes ~30 seconds for 20k patients on my laptop.)

      However doing a data source read (perhaps through a ReferenceRule) does not give you access to that Patient. The method signature is read(LogicContext, Cohort, LogicCriteria).

      A side-effect of this is that it is twice as slow to run the ReferenceRule "person.birthdate" (which goes to the data source, even though the framework has already loaded up patient objects) than it would be to write a birthdate rule in java which would just return the birthdate off the passed-in patient object.

      There are two possible fixes:

      1. Don't pass a real Patient object to Rule.eval – instead pass it a "new Patient(pid)" and force the rule to do a data source read if it wants a full Patient object.
        • Burke points out that this is bad and we should just change the method signature to take an Integer. I agree in theory, but I don't know how to change this in a backwards-compatible way. Maybe since few people are using logic, we can break backwards-compatibility this time.
      2. Change the method signature of LogicDataSource.read to take a Collection<Patient> instead of a Cohort.

      I prefer the first option, and I'm okay breaking backwards-compatibility this time.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              darius Darius Jazayeri
              Reporter:
              darius Darius Jazayeri
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: