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:
- User presses a "COMPLETE SURVEY"
- API called via AJAX
- call stored procedure from API
- SQL SERVER looks for custom rules
- 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:
-
Config files that contain rules - making generic function to run the rules - keeping the rules confined to some logical boundaries?
-
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.
0 comments:
Post a Comment