opensrp / fhircore

FHIR Core / OpenSRP 2 is a Kotlin application for delivering offline-capable, mobile-first healthcare project implementations from local community to national and international scale using FHIR and WHO Smart Guidelines on Android.
https://smartregister.org
Apache License 2.0
53 stars 41 forks source link

Add support for use of rules and computed values in Register configs and FAB #3048

Closed allan-on closed 3 months ago

allan-on commented 7 months ago

Describe the feature request. Implement support for the use of rules and computed values in Register configs and FAB actions.

Additional context There's no support for rules in the register config (Other than configRules) outside of registerCard configs. Rules with access to the resource data can only be defined within the registerCard.

Acceptance criteria Rules based on the resource data can be defined outside the registerCard. Rules and the computed values should be accessible within the FAB actions.

Implementation plan (For Engineers) The plan for implementing the solution e.g. via a description or a check list for the various ordered tasks that will need to be completed. i.e. Describe how you intend to solve the problem

allan-on commented 7 months ago

Sample rules and WDF DC use-case:

a. Query for unique ID Group resource b. Retrieve unique ID for pre-population into a Questionnaire

  "rules": [...   
    {
      "condition": "true",
      "actions": [
        "data.put('uniqueIdGroup',  service.filterResources(uniqueIds, \"Group.active = true and Group.type = 'device' and Group.name = 'Unique IDs'\"))"
      ]
    },
    {
      "name": "uniqueIdGroupId",
      "condition": "true",
      "priority": 2,
      "actions": [
        "data.put('uniqueIdGroupId',  fhirPath.extractValue(data.get('uniqueIdGroup').get(0), 'Group.id'))"
      ]
    },
    {
      "name": "uniqueId",
      "condition": "true",
      "priority": 2,
      "actions": [
        "data.put('uniqueId',  fhirPath.extractValue(data.get('uniqueIdGroup').get(0), \"Group.characteristic.where(exclude=false and code.text='phn').first().value.text\"))"
      ]
    }, ...

These can be tested from the diabetes-compass branch in fhircore cc @ellykits

allan-on commented 3 months ago

This is no longer required because the configs were refactored here https://github.com/opensrp/fhircore/pull/3075 The configs introduced in that PR allow the use of the unique ID configs from register configs