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
50 stars 41 forks source link

[New Feature] Add Related Entity Location Tag to newly created resources #3077

Closed f-odhiambo closed 4 months ago

f-odhiambo commented 5 months ago

Background & Context

As a health practitioner, I want to be able to distinguish patients based on the location they are located at.

As a data collector or service monitor, I want to be able to distinguish information related to a point of interest based on its connection to that point of interest.

Also see discussion item

Proposed Solution

High level:

Assigning a value to meta.tag: "Related Entity Location" can happen in 3 ways

  1. Using a location ID submitted in a Questionnaire and stored in a QR (QuestionnaireResponse).
    • This will happen during entity creation, e.g. creation of a Patient, Group (e.g. representing a family), or Location (e.g. represent a service point)
    • When creating the entity the users selects a location in the registration questionnaire, this is saved in the QR
    • In extraction a StructureMap creates a Location resource, or references an existing Location
    • This location is stored in the meta.tag: "Related Entity Location" of the related entity (in this case the related entity is the entity itself).
  2. When saving a resource connected to a related entity, set to the value in the related entity
    • This applies when the registration above has already happened and the data is generated through other operations, e.g the generation of CarePlans and Tasks via $apply or the extraction of Observations via StructureMaps.
    • We assume a subject or similar field links the newly saved resource to the related entity
    • Set [new resource].meta.tag: "Related Entity Location" = [related entity].meta.tag: "Related Entity Location"

Example meta tag:

{
  "system": "https://smartregister.org/related-entity-location-tag-id",
  "code": "1a8ae4f2-c94b-4366-ac31-f55ccf3168a2",
  "display": "Related Entity Location"
}

Patient resource with meta-tag:

{
  "resourceType": "Patient",
  "id": "21248",
  "meta": {
    "versionId": "1",
    "lastUpdated": "2023-06-20T12:43:56.633+00:00",
    "source": "#e58f8eb4117b05a8",
    "tag": [
      {
        "system" : "https://smartregister.org/care-team-tag-id",
        "code"   : "2309fc1e-9fbc-46f3-8a70-8dbd9d2448ed"      ,
        "display": "Practitioner CareTeam"
      },
      {
        "system" : "https://smartregister.org/app-version",
        "code"   : "0.2.2-bunda"                          ,
        "display": "Application Version"
      },
      {
        "system" : "https://smartregister.org/location-tag-id",
        "code"   : "Not defined"                              ,
        "display": "Practitioner Location"
      },
      {
        "system" : "https://smartregister.org/organisation-tag-id",
        "code"   : "1a8ae4f2-c94b-4366-ac31-f55ccf3168a2"         ,
        "display": "Practitioner Organization"
      },
      {
        "system" : "https://smartregister.org/practitioner-tag-id",
        "code"   : "6e744577-cf1c-4876-a122-2d0e9c5e0f23"         ,
        "display": "Practitioner"
      },
      {
        "system" : "https://smartregister.org/related-entity-location-tag-id",
        "code"   : "1a8ae4f2-c94b-4366-ac31-f55ccf3168a2"                    ,
        "display": "Related Entity Location"
      }
    ]
  },
  .....................
  .....................
  "generalPractitioner": [
    {"reference": "Practitioner/6e744577-cf1c-4876-a122-2d0e9c5e0f23"}
  ],
  "managingOrganization": {
    "reference": "Organization/1a8ae4f2-c94b-4366-ac31-f55ccf3168a2"
  }
}
f-odhiambo commented 5 months ago

TBD From where do we retrieve the Location ID - this needs to follow a configurable approach

  1. From the Location selection profile view in the case of EUSM
  2. Get Location selection from newly created Group/Patient in the case of SID

Some thoughts

For the case of SID maybe create a group and then save the location to the shared pref. For subsequent family member addition, the use the stored group location id in pref. To avoid issues we will not have location selection in the add member form.

Every time we switch to a new group update the location is in the shared preference. i.e. new Family selection

pld commented 5 months ago

I rewrote to abstract this a bit.

dubdabasoduba commented 5 months ago

TBD From where do we retrieve the Location ID - this needs to follow a configurable approach

  1. From the Location selection profile view in the case of EUSM
  2. Get Location selection from newly created Group/Patient in the case of SID

Some thoughts

For the case of SID maybe create a group and then save the location to the shared pref. For subsequent family member addition, the use the stored group location id in pref. To avoid issues we will not have location selection in the add member form.

Every time we switch to a new group update the location is in the shared preference. i.e. new Family selection

@pld @f-odhiambo I think this is defined here. The idea is to also find the subject of the data being created and then find the Location linked to it based on the linkage defined here

We can decide to use the Questionnaire subject to find the Entity the data belongs to. This will however break for use on workflows that do not need a questionnaire to be filled.

pld commented 5 months ago

I update the issue to add more details

ellykits commented 5 months ago

@dubdabasoduba @f-odhiambo

Can you confirm the system used for this new resource tag.

  {
                "system": "https://smartregister.org/patient-location-tag-id",
                "code": "1a8ae4f2-c94b-4366-ac31-f55ccf3168a2",
                "display": "Related Entity Location"
            }

The strings for the other tags are hardcoded in the string.xml file for the app. So we need to get it right.

dubdabasoduba commented 5 months ago

@ellykits here you go

{
  "system": "https://smartregister.org/related-entity-location-tag-id",
  "code": "1a8ae4f2-c94b-4366-ac31-f55ccf3168a2",
  "display": "Related Entity Location"
}
f-odhiambo commented 5 months ago

Update needed for Resources created from the patient's profile. At the moment the Related Entity Location Tag is not cascaded when you start a workflow from the profile

CC @ellykits