Skip to content

Commit

Permalink
Add contentBackgroundColor config to profile (#2770)
Browse files Browse the repository at this point in the history
- Update documentation to include new profile config parameter
- Clean up profile config documentation
  • Loading branch information
qiarie authored Sep 19, 2023
1 parent 40faa3d commit 1a68ce2
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ data class ProfileConfiguration(
ActiveResourceFilterConfig(resourceType = ResourceType.Group, active = true),
),
val configRules: List<RuleConfig>? = null,
val contentBackgroundColor: String? = "#FFFFFF",
) : Configuration()
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ fun ProfileScreen(
)
},
) { innerPadding ->
Box(modifier = modifier.background(Color.White).fillMaxSize().padding(innerPadding)) {
Box(
modifier =
modifier
.background(profileUiState.profileConfiguration?.contentBackgroundColor.parseColor())
.fillMaxSize()
.padding(innerPadding),
) {
if (profileUiState.showDataLoadProgressIndicator) {
CircularProgressIndicator(
modifier = modifier.align(Alignment.Center).size(24.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ fun CardView(
elevation = viewProperties.elevation.dp,
modifier =
modifier
.padding(horizontal = viewProperties.padding.dp)
.padding(
start = viewProperties.padding.dp,
end = viewProperties.padding.dp,
bottom = viewProperties.padding.dp,
)
.fillMaxWidth()
.clip(RoundedCornerShape(viewProperties.cornerSize.dp)),
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ title: Profile

# Profile configuration

These configurations are used to control the content of the profile screen as well as how to render the profile UI. Typically for every register in application there is a corresponding profile. Technically the same implemention is used for all profiles, however the content configured.
These configurations are used to control the content of the profile screen as well as how to render the profile UI. Typically for every register in application there is a corresponding profile. Technically the same implementation is used for all profiles, however the content configured.

:::info
For every register in the application there should at least be one profile configuration. Similar registers can re-use the same profile configuration.
:::

### Working with dynamic data queries
Assume you would like to filter resource data based on a criteria that needs computation before application. e.g show patients who are under 5 years or over 18 below, then this is the config to use.

Before you use this rule on a dataQuery, you need to execute it first. The rules are executed within a `configRules` block which follows rules engine standard and default priority of 1 which can be change based on requirement.
Below is a JSON config that shows how to execute rules.Refer to working with rules section.

Below is a JSON config that shows how to execute rules. Refer to working with rules section.
``` json
{
"appId": "appId",
"appId": "appId",
"configType": "register",
"id": "childRegister",
"configRules": [
Expand All @@ -31,111 +33,114 @@ Below is a JSON config that shows how to execute rules.Refer to working with rul
}
```

Below is a sample dataQuery config to filter register data by configRules
Below is a sample dataQuery config to filter register data by configRules.

``` json
"fhirResource": {
"baseResource": {
"resource": "Patient",
"dataQueries": [
{
"paramName": "birthdate",
"filterCriteria": [
{
"dataType": "DATE",
"computedRule": "under5",
"prefix": "GREATERTHAN_OR_EQUALS"
}
]
}
]
}
}
"baseResource": {
"resource": "Patient",
"dataQueries": [
{
"paramName": "birthdate",
"filterCriteria": [
{
"dataType": "DATE",
"computedRule": "under5",
"prefix": "GREATERTHAN_OR_EQUALS"
}
]
}
]
}
}
```

## Config properties

|Property | Description | Required | Default |
|--|--|:--:|:--:|
appId | Unique identifier for the application | Yes | |
configType | Type of configuration | Yes | `profile` |
computedRules | A block that defines the rules to execute | no | null |
baseResource | base resource to load data from | Yes | |
paramName | dataQuery unique identifier | Yes | |
filterCriteria | a list of logic to be executed | Yes | |
filterCriteria: dataType | dataType of the filter param | Yes | |
filterCriteria: computedRule | key that will hold dynamic value after computation | No but recommended | app defaults to using value/valueDate/valueDateTime |
filterCriteria: prefix | criteria to use | No | null |


## Dynamic data pass between Profiles and registers

For you to pass data between profiles you can make use of **action config params** which are executed when **LAUNCH_PROFILE** is invoked
Data extraction happens during rules execution and is persisted in computedValuesMap which is later used to interpolated values annotated with @value
For example, assume the LAUNCH_PROFILE onClick function of practitioner_profile_config takes you to household_profile screen and you would like pass send practitionerId from practitioner_profile_config to household_profile, define it as described below

### Practitioner LAUNCH_PROFILE
#### Sample JSON
|--|--|:--:|--|
`appId` | `String` - unique identifier for the application | Yes | |
`configType` | Type of configuration | Yes | `profile` |
`id` | `String` | Yes | |
`fhirResource` | `FhirResourceConfig` | Yes | |
`secondaryResources` | List of `FhirResourceConfig`s | No |
`managingEntity` | `ManagingEntityConfig` | No | |
`profileParams` | A list Strings | Yes | |
`rules` | List of `RuleConfig`s | Yes | `emptyList()` |
`topAppBar` | `TopBarConfig` | No | |
`views` | List of `ViewProperties` | Yes | |
`fabActions` | List of `NavigationMenuConfig`s| Yes | `emptyList()` |
`overFlowMenuItems` | List of `OverflowMenuItemConfig`s | Yes | `emptyList()` |
`filterActiveResources` | List of `ActiveResourceFilterConfig`s | Yes | `listOf(ActiveResourceFilterConfig(resourceType = ResourceType.Patient, active = true), ActiveResourceFilterConfig(resourceType = ResourceType.Group, active = true))` |
`configRules` | List of `RuleConfig`s | No | `null` |
`contentBackgroundColor` | `String` | No | `#FFFFFF` |

## Dynamic data pass between profiles and registers

For you to pass data between profiles you can make use of **action config params** which are executed when **LAUNCH_PROFILE** is invoked.

Data extraction happens during rules execution and is persisted in `computedValuesMap` which is later used to interpolate values annotated with `@value`.

For example, assume the `LAUNCH_PROFILE` `onClick` function of `practitioner_profile_config` takes you to `household_profile` screen and you would like pass send `practitionerId` from `practitioner_profile_config` to `household_profile`, define it as described below.

### Practitioner **LAUNCH_PROFILE**
1. Write rules to extract the data you need.
``` json
"rules":[
{
``` json
"rules":[
{
"name": "practitionerId",
"condition": "true",
"actions": [
"data.put('practitionerId', fhirPath.extractValue(Practitioner, 'Practitioner.id.replace(\"Practitioner/\",\"\")').split(\"/\").get(0))"
]
}
]
```
```

2. add your params at **LAUNCH_REGISTER** section of practition_register_config.json
#### Sample JSON
``` json
"actions": [
{
"trigger": "ON_CLICK",
"workflow": "LAUNCH_PROFILE",
"id": "practitionerProfile",
"params": [
{
"paramType": "PARAMDATA",
"key": "practitionerId",
"value": "@{practitionerId}"
}
]
}
]
```

### Household_config.json
A dataquery config to filter by practitionerId. For more info refer to dataquery section
2. Add your params in **LAUNCH_REGISTER** section of `practition_register_config.json`
``` json
"actions": [
{
"trigger": "ON_CLICK",
"workflow": "LAUNCH_PROFILE",
"id": "practitionerProfile",
"params": [
{
"paramType": "PARAMDATA",
"key": "practitionerId",
"value": "@{practitionerId}"
}
]
}
]
```

#### Sample JSON
### household_config.json
A dataquery config to filter by `practitionerId`. For more info refer to dataquery section.

``` json
{
"id": "householdQueryPractitionerId",
"filterType": "TOKEN",
"key": "_tag",
"valueType": "CODING",
"valueCoding": {
"system": "https://smartregister.org/",
"code": "@{practitionerId}"
}
}
{
"id": "householdQueryPractitionerId",
"filterType": "TOKEN",
"key": "_tag",
"valueType": "CODING",
"valueCoding": {
"system": "https://smartregister.org/",
"code": "@{practitionerId}"
}
}
```

## Dynamic data pass between profiles config properties

|Property | Description | Required | Default |
|--|--|:--:|:--:|
|--|--|:--:|--|
rules name | Unique identifier for the rules | Yes | empty string |
condition | specification of execution | Yes | false |
actions | an array of the rule logic with a fhirPathExpression | Yes | null |
trigger | application workflow action | Yes | no default |
workflow | An application event that can trigger a workflow | Yes | null |
params | An array of actionParameters to pass to another profile | no | emptyArray |
paramType | Action ParameterType to use e.g PREPOPULATE OR PARAMDATA | no | null |
key | Action ParameterType unique key if defined but not tag is given | yes | application throws exception |
value | Action ParameterType corresponding key's value | yes | application throws exception |
`condition` | specification of execution | Yes | `false` |
`actions` | an array of the rule logic with a fhirPathExpression | Yes | `null` |
`trigger` | application workflow action | Yes | |
`workflow` | An application event that can trigger a workflow | Yes | `null` |
`params` | An array of actionParameters to pass to another profile | No | emptyArray |
`paramType` | Action ParameterType to use e.g PREPOPULATE OR PARAMDATA | No | `null` |
`key` | Action ParameterType unique key if defined but not tag is given | Yes | |
`value` | Action ParameterType corresponding key's value | Yes | |

0 comments on commit 1a68ce2

Please sign in to comment.