Help with Design Hurdle – Dynamic rules on the fly

I am working on improving a health care survey for various appointment types – so there are multiple survey types, with multiple sections and questions.

Custom rules might exist like this for instance: if user answers YES to question 50 do SomethingReallyCool

=>>>>but there is also the situation where just for customer A answering question 50 of survey 1 do SomethingDifferent

I need to some how generate dynamic, custom actions based on what clinic is conducting the survey, what survey and section it is. My question is about my idea – which is to create a sql table that has SQL CODE in a NVARCHAR(MAX) field, run a query to see if any custom rules exist for the customer completing the survey, the section and question. Then run the string of sql using sp_executesql command in SQL Server?

The process of calling this code is:

  1. User presses a “COMPLETE SURVEY”
  2. API called via AJAX
  3. call stored procedure from API
  4. SQL SERVER looks for custom rules
  5. Executes dynamic sql on server

Front-end only sends the SurveyID to API. So no custom parameters are sent. SQL Injection not a threat.

I’ve also thought about:

  1. Config files that contain rules – making generic function to run the rules – keeping the rules confined to some logical boundaries?

  2. I have thought about running some run time language like python scripts that process the rules…

I really don’t want to make an API change every time we on-board a new customer.

submitted by /u/BrocliRob
[link] [comments]

Leave a Reply