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

Configure unique identifier assignment #3075

Closed ellykits closed 2 months ago

ellykits commented 6 months ago

IMPORTANT: Where possible all PRs must be linked to a Github issue

Fixes 3048

Engineer Checklist

Code Reviewer Checklist

codecov[bot] commented 6 months ago

Codecov Report

Attention: Patch coverage is 36.11111% with 46 lines in your changes missing coverage. Please review.

Project coverage is 28.3%. Comparing base (ac82739) to head (5a98047). Report is 91 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/opensrp/fhircore/pull/3075/graphs/tree.svg?width=650&height=150&src=pr&token=IJUTHZUGGH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensrp)](https://app.codecov.io/gh/opensrp/fhircore/pull/3075?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensrp) ```diff @@ Coverage Diff @@ ## main #3075 +/- ## ========================================= - Coverage 29.6% 28.3% -1.3% - Complexity 658 720 +62 ========================================= Files 239 266 +27 Lines 11204 12689 +1485 Branches 1948 2244 +296 ========================================= + Hits 3323 3600 +277 - Misses 7447 8614 +1167 - Partials 434 475 +41 ``` | [Flag](https://app.codecov.io/gh/opensrp/fhircore/pull/3075/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensrp) | Coverage Δ | | |---|---|---| | [engine](https://app.codecov.io/gh/opensrp/fhircore/pull/3075/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensrp) | `64.8% <68.4%> (-1.4%)` | :arrow_down: | | [geowidget](https://app.codecov.io/gh/opensrp/fhircore/pull/3075/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensrp) | `18.7% <ø> (-28.5%)` | :arrow_down: | | [quest](https://app.codecov.io/gh/opensrp/fhircore/pull/3075/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensrp) | `5.1% <0.0%> (-0.3%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensrp#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/opensrp/fhircore/pull/3075?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensrp) | Coverage Δ | | |---|---|---| | [...e/engine/data/local/register/RegisterRepository.kt](https://app.codecov.io/gh/opensrp/fhircore/pull/3075?src=pr&el=tree&filepath=android%2Fengine%2Fsrc%2Fmain%2Fjava%2Forg%2Fsmartregister%2Ffhircore%2Fengine%2Fdata%2Flocal%2Fregister%2FRegisterRepository.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensrp#diff-YW5kcm9pZC9lbmdpbmUvc3JjL21haW4vamF2YS9vcmcvc21hcnRyZWdpc3Rlci9maGlyY29yZS9lbmdpbmUvZGF0YS9sb2NhbC9yZWdpc3Rlci9SZWdpc3RlclJlcG9zaXRvcnkua3Q=) | `70.3% <ø> (+0.1%)` | :arrow_up: | | [...ircore/engine/configuration/QuestionnaireConfig.kt](https://app.codecov.io/gh/opensrp/fhircore/pull/3075?src=pr&el=tree&filepath=android%2Fengine%2Fsrc%2Fmain%2Fjava%2Forg%2Fsmartregister%2Ffhircore%2Fengine%2Fconfiguration%2FQuestionnaireConfig.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensrp#diff-YW5kcm9pZC9lbmdpbmUvc3JjL21haW4vamF2YS9vcmcvc21hcnRyZWdpc3Rlci9maGlyY29yZS9lbmdpbmUvY29uZmlndXJhdGlvbi9RdWVzdGlvbm5haXJlQ29uZmlnLmt0) | `79.7% <83.3%> (-1.5%)` | :arrow_down: | | [...er/fhircore/engine/data/local/DefaultRepository.kt](https://app.codecov.io/gh/opensrp/fhircore/pull/3075?src=pr&el=tree&filepath=android%2Fengine%2Fsrc%2Fmain%2Fjava%2Forg%2Fsmartregister%2Ffhircore%2Fengine%2Fdata%2Flocal%2FDefaultRepository.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensrp#diff-YW5kcm9pZC9lbmdpbmUvc3JjL21haW4vamF2YS9vcmcvc21hcnRyZWdpc3Rlci9maGlyY29yZS9lbmdpbmUvZGF0YS9sb2NhbC9EZWZhdWx0UmVwb3NpdG9yeS5rdA==) | `63.7% <61.5%> (-4.3%)` | :arrow_down: | | [...e/quest/ui/questionnaire/QuestionnaireViewModel.kt](https://app.codecov.io/gh/opensrp/fhircore/pull/3075?src=pr&el=tree&filepath=android%2Fquest%2Fsrc%2Fmain%2Fjava%2Forg%2Fsmartregister%2Ffhircore%2Fquest%2Fui%2Fquestionnaire%2FQuestionnaireViewModel.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensrp#diff-YW5kcm9pZC9xdWVzdC9zcmMvbWFpbi9qYXZhL29yZy9zbWFydHJlZ2lzdGVyL2ZoaXJjb3JlL3F1ZXN0L3VpL3F1ZXN0aW9ubmFpcmUvUXVlc3Rpb25uYWlyZVZpZXdNb2RlbC5rdA==) | `2.8% <0.0%> (-0.8%)` | :arrow_down: | ... and [19 files with indirect coverage changes](https://app.codecov.io/gh/opensrp/fhircore/pull/3075/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensrp)
ellykits commented 6 months ago

This PR introduces a new configuration for unique ID assignments. Refer to the QuestionnaireConfig docs session to find out more. Here is a sample config:

{
  "uniqueIdAssignment": {
    "linkId": "phn",
    "idFhirPathExpression": "Group.characteristic.where(exclude=false and code.text='phn').first().value.text",
    "readOnly": false,
    "resource": "Group",
    "sortConfigs": [
      {
        "paramName": "_lastUpdated",
        "dataType": "DATE",
        "order": "DESCENDING"
      }
    ],
    "resourceFilterExpression": {
      "conditionalFhirPathExpressions": [
        "Group.active = true and Group.type = 'device' and Group.name = 'Unique IDs'"
      ],
      "matchAll": true
    }
  }
}
pld commented 6 months ago

@allan-on please add a top level feature for unique ID assignment here, https://docs.opensrp.io/features/app-features, then tag @rowo and me to review it

ellykits commented 6 months ago

@allan-on I will add the remaining tests to improve the coverage during CHT this week.

pld commented 6 months ago

@allan-on I will add the remaining tests to improve the coverage during CHT this week.

can add an issue that refs this pr?

ellykits commented 6 months ago

Sure

pld commented 3 months ago

Looks like testRetrieveUniqueIdAssignmentResourceShouldReturnAResource is failing there's more coverage needed for retrieveUniqueIdAssignmentResource, along with a couple other functions