Support for saving customized objects using EMRAPI EncounterTransaction

Bahmni uses EMRAPI for saving obs, orders & diagnosis information in a single call. We would like to save some custom entities like Regimen/Smear/DST to be supported as part of EncounterTransaction. These entities might have a custom logic to get saved into the database. But we would want EncounterTransaction to provide a placeholder for custom processing. We are exploring options using which it can be done in a generic way. We would like to take help of community in this regards. Any ideas in this regard would be appreciated.

It will be great to have a generic mechanism for this. It would be really nice if a module can provide a way to post as part of the encounter transaction

{
    "drug_sensitivity_test_result": {
        // client-friendly representation
    }
}

instead of having to do something client-unfriendly like this:

{
    "obs": [
        {
            concept, "some-long-uuid",
            groupMembers: [ /* ugly */ ]
        }
    ] 
}

My first thought is to simply allow for a module to define custom EncounterTransactionPropertyHandlers. And when the REST service handles a GET or a POST, it delegates to that handler with the in-progress Encounter as an argument. (If it’s a POST you’d trigger a handler based on the property name. If it’s a GET I guess you’d always run through all the handlers to determine whether they need to show anything.)

It would probably also be helpful if when one of these handlers is producing a GET representation of the encounter, it has a way to signal something like "I have handled these Obs, so do not include them in the ‘obs’ section.