tech-by-design / polyglot-prime

Primary monorepo for TechBD polyglot bespoke code
https://tech-by-design.github.io/polyglot-prime/
GNU Affero General Public License v3.0
2 stars 21 forks source link

Prepare New BizOps Feature Flags Infrastructure for accept/reject Bundle functionality #466

Open shah opened 6 days ago

shah commented 6 days ago

We need to turn on auto-rejection (not forward errors to SHIN-NY) and set up a new Business Operations (BizOps) Feature Flags infrastructure in our Help Desk. This infrastructure will allow application users to see and modify feature flags, starting with which messages to accept/reject, via a file in a GitHub repo.

App Strategy:

shah commented 6 days ago

The initial file has been created in Help Desk Repo /feature-flag/non-sensitive-common.yml.

bizOps:
  api:
    fhir:
      bundle:
        contentActions:
          # allow one or more jsonPath-based actions
          - jsonPaths:
              # see https://github.com/json-path/JsonPath for JSONPath expressions
              # the following finds ... "location": [ "Bundle.entry[0].resource/Patient/cc6ce0d9-297d-4166-b264-f7e33db53b67/.meta.lastUpdated"]
              # basically any "location" entry that starts with `Bundle.entry[n].resource/Patient` and ends with `/.meta.lastUpdated` will match
              - "$.location[?(@ =~ /^Bundle\\.entry\\[\\d+\\]\\.resource\\/.*\\.meta\\.lastUpdated$/)]"  
            action:
              nature: "reject"  # might have other natures in the future, for now it's just "reject"
              injectContent: {}  # whatever goes into `inject` is added to the operation outcome, allow Spring template expressions}
shah commented 6 days ago

@raphaelvp @ratheesh-kr I've introduced a new utility class JsonContentAction which you can learn about in hub-prime/src/test/java/lib/aide/JsonContentActionTest.java test case.

JsonContentAction provides a framework for defining rejection rules based on JSONPath expressions and applying transformations to JSON objects using Spring SpEL expressions.

The class supports two main types of transformations:

This is useful in scenarios where you need to reject or modify JSON content based on specific rules, like handling errors or modifying content dynamically.

The class uses a builder pattern to allow chaining multiple rejection rules, and each rule defines a JSONPath condition and a set of transformations to apply when the condition is met.

Please assign this as a high priority task to a senior Java engineer.

// Switch these to assertions 
System.out.println(appliedJson);
System.out.println(appendedJson);

final var actionable = fhirJCA.execute(myFhirBundle); // if actionable.rejections().size() is greater than zero, prepare to reject // add an empty list to myFhirBundle to store the rejection // final var updatedBundleWithRejectionMsg = actionable.rejections().get(0).transformed(new HashMap<>(myFhirBundle), Map.of());



- [ ] Then, re-implement #465 by removing all hard-coded Java and allow future expansion using GitHub YAML as the source