prestoncabe / dmn-benefit-toolbox

Scaffolding for modeling public benefits' eligibility logic with Decision Model and Notation (DMN)
2 stars 1 forks source link

Can we reasonably build a Philly benefit screener with Camunda Forms + DMN? #34

Closed prestoncabe closed 1 month ago

prestoncabe commented 2 months ago

I'll experiment and document my findings here.

This is for #28

prestoncabe commented 2 months ago

I looked more deeply into this last night and today:

What I learned/did

Things to explore further

@sierscse FYI

prestoncabe commented 2 months ago

This page has really interesting ideas for how to customize Camunda Forms:

prestoncabe commented 2 months ago

Some other food for thought for using Camunda Forms effectively: https://camunda.com/blog/2023/05/draft-to-perfection-effective-forms-human-workflows/

prestoncabe commented 2 months ago

Another idea: using custom properties of form components to customize those components. For example, you could reference an external API (like a DMN decision service) to populate some reference on a form (like the current income limit or something like that).

Is this also how we could use the response from DMN to hide/show form elements based on whether the household is still eligible for a particular benefit? For example, the changed/submitted callbacks could update properties that are used to hide/show questions for a benefit.

https://github.com/bpmn-io/form-js-examples/blob/master/custom-properties/README.md

prestoncabe commented 2 months ago

I was able to rig up a development environment for using Camunda forms interacting with our DMN API. Using Project IDX (or Cloud Shell) makes this a bit more convoluted as compared to using a local dev environment, but it can be worked around.

Here are the steps:

  1. Create the .form file using Camunda Modeler (local desktop application).
    • I hope eventually to rig up a way to do this in VS Code itself (by rigging up an extension for the web version of the Modeler app), but this is out of scope for now.
  2. Copy/paste the form into a special script tag (<script type="application/form-schema">) in an html file.
  3. Use Camunda Forms "viewer" API to write code that loads the form and defines listeners for changed/submitted events.
    • the listeners are what POST to the DMN API and do something with the results.
  4. Use Project IDX's "Generate Access Token" command to create an authorization token to put in the request headers where you POST to the DMN. (something similar is available in Cloud Shell... I think?)
  5. Serve the html file by naming it index.html, putting it in the root directory of the project, and running npx live-server. (can put it somewhere else if you run the server from the other directory).
  6. Steps 4 and 5 are only needed if not running locally. (if the DMN API is running locally, you should just be able to open the html file directly on the same machine with no issues).

With the above steps, I am able to develop and test forms, see results back from the DMN!! It's fairly clunky to setup, but I expect that we'll streamline this over time.

Example gist: https://gist.github.com/prestoncabe/f44800973357ce5f191c0a4a6152040f

For now, I think I'll take a break on this front and fix some issues in the DMN revealed by testing the form (it doesn't handle blank/null data like I think we'll want).

@sierscse FYI

prestoncabe commented 1 month ago

Things to do a proof of concept for (that we will need for the philly tax benefit screener):

prestoncabe commented 1 month ago

I'm still swimming around in uncertainty, but I've learned some more things in the past couple of days:

Use FEEL to hide/show "scripting" text based on the state of the form.

Use the "Previews" feature of Project IDX

You can configure IDX to automatically launch a web server and preview it within the IDX window. Makes it easy to sit down and automatically troubleshoot forms. Not sure how/if this will be useful long term for a hypothetical DMN Benefits Toolbox developer, but it seems like it will have a place in helping to simplify the experience.

prestoncabe commented 1 month ago

Well, I think I've proved the concept of a simple screener using Camunda Forms + DMN. There's a lot more to figure out to build a real screener (need a production deployment plan, figure out how to handle multiple benefits in one screening, deal with the look and feel - including what to do about the BPMN.io watermark, etc.)... but I think the enough pieces are there to start planning what a MVP solution for Philly real estate tax benefits would look like.

@sierscse - we can start talking about that tomorrow!

prestoncabe commented 1 month ago

Screencast from 2024-10-07 22-29-08.webm

demo! @sierscse