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://opensrp.io
Apache License 2.0
56 stars 56 forks source link

[Quest] - Update ANC StructureMap to not only capture pregnancy as a Tag but also create a new Condition of Pregnancy #1379

Closed f-odhiambo closed 2 years ago

f-odhiambo commented 2 years ago

Description Update ANC StructureMap to not only capture pregnancy as a Tag as is currently the case but also create a new Condition of Pregnancy.This will make it more efficient to query Prengnacies and also track its status as using tags will make a patient perpetually pregnant unless updated. We can also track the pregnancy from the Condition + Encounter resource. This is inline to the WHO SMART Guidelines for ANC https://build.fhir.org/ig/WorldHealthOrganization/smart-anc/index.html

This should also be defined as a codable concept using SNOMED i.e.

    "code": {
        "coding": [
            {
                "system": "http://snomed.info/sct",
                "code": "77386006",
                "display": "Pregnancy"
            }
        ],
        "text": "Pregnancy"
    },

Sample Condition

{
    "resourceType": "Condition",
    "id": "charity-otala-1-pregnancy",
    "meta": {
        "versionId": "3",
        "lastUpdated": "2022-06-27T09:27:04.782+00:00",
        "profile": [
            "http://fhir.org/guides/who/anc-cds/StructureDefinition/anc-condition",
            "http://fhir.org/guides/who/core/StructureDefinition/who-condition"
        ]
    },
    "clinicalStatus": {
        "coding": [
            {
                "system": "http://terminology.hl7.org/CodeSystem/condition-clinical",
                "code": "active"
            }
        ]
    },
    "verificationStatus": {
        "coding": [
            {
                "system": "http://terminology.hl7.org/CodeSystem/condition-ver-status",
                "code": "confirmed"
            }
        ]
    },
    "category": [
        {
            "coding": [
                {
                    "system": "http://terminology.hl7.org/CodeSystem/condition-category",
                    "code": "problem-list-item",
                    "display": "Problem List Item"
                }
            ]
        }
    ],
    "code": {
        "coding": [
            {
                "system": "http://snomed.info/sct",
                "code": "77386006",
                "display": "Pregnancy"
            }
        ],
        "text": "Pregnancy"
    },
    "subject": {
        "reference": "Patient/charity-otala-1"
    },
    "onsetDateTime": "2019-05-22"
}
f-odhiambo commented 2 years ago

Here are the links to the ANC StructureMaps

  1. https://github.com/opensrp/fhir-resources/blob/main/ecbis/structure_map/text/anc_register.txt
  2. https://github.com/opensrp/fhir-resources/blob/main/ecbis/structure_map/json/anc_register.json

Kindly verify if this is what is in use @dubdabasoduba @maimoonak

f-odhiambo commented 2 years ago

Relatedly this will be crucial for the Pregnancy Indicator to work efficiently https://github.com/opensrp/fhir-resources/blob/main/ecbis/measure_cql/pregnancy_measure_reporting.cql

pld commented 2 years ago

In that CQL, couldn't we look for the pregnancy codable concept instead of looking for the condition?

FikriMilano commented 2 years ago

@maimoonak @f-odhiambo This is the first time I work on StructureMap. I will need sometime to understand how it works. Let me know if there are some other links to quickly understand this.

http://build.fhir.org/structuremap.html

f-odhiambo commented 2 years ago

https://github.com/opensrp/fhir-resources/blob/main/ecbis/measure_cql/pregnancy_measure_reporting.cql

@pld That's what's actually happening This is the query

define "All ANC": "All Patients" F where F.gender='female' 
    and  [Condition: "Pregnancy code"] O
    where O.clinicalStatus ~ "active"

This is the reference code code "Pregnancy code": '77386006' from "SNOMED" display 'Pregnant'

and looking for the code '77386006' but the human-readable result will be 'Pregnant'

pld commented 2 years ago

OK I see so the condition is the only way to attach the code to the patient, the code is embedded in the condition.

Then will we not add the Tag?

f-odhiambo commented 2 years ago

OK I see so the condition is the only way to attach the code to the patient, the code is embedded in the condition.

Then will we not add the Tag?

@pld I want to strongly say Yes but think that needs a discussion, I think we need to formalise what will/will not use Tags

pld commented 2 years ago

Cool, yea I guess the question is do we have cases where we are using the Tags to do business logic, because we'll have to migrate those, which may included content that is looking at Tags and will break, but that won't show up in tests.

But just for the sake of argument, could we change that indicator to look for the tag instead of the condition?

f-odhiambo commented 2 years ago

Cool, yea I guess the question is do we have cases where we are using the Tags to do business logic, because we'll have to migrate those, which may include content that is looking at Tags and will break, but that won't show up in tests.

But just for the sake of argument, could we change that indicator to look for the tag instead of the condition?

I would argue NO based on

  1. It's Harder to track the status (changes to the Mother etc) from a Patient resource with a Tag and not a condition in this case if something happens to the pregnancy/mother etc.
  2. Codable concepts make it easier to query resources than tags and resources such as conditions make it more efficient to store additional info if desired to be passed via a query
  3. We may need to keep a formal library of tags to avoid abuse as they may not be of standard usage
FikriMilano commented 2 years ago

I had a chat w @maimoonak yesterday.

Basically she suggested to separate the current StructureMap and the Pregnancy Condition generation. Because Condition is not part of PlanDefinition.

Hence the Pregnancy Condition generation will be part of a new extraction StructureMap.

FikriMilano commented 2 years ago

Also, I noticed the tag is currently not used in the provided StructureMap. I will add that as well in the new extraction StructureMap.

FikriMilano commented 2 years ago

@dubdabasoduba @f-odhiambo I need a sample of QuestionnaireResponse related to this StructureMap https://github.com/opensrp/fhir-resources/blob/main/ecbis/structure_map/text/new_pregnancy_registration_and_visit.txt

maimoonak commented 2 years ago

https://github.com/opensrp/fhircore/tree/main/android/engine/src/test/resources/plans/anc-visit .. plz find this in samples dir

FikriMilano commented 2 years ago

@maimoonak @f-odhiambo Let me know if this will work.

map "http://hl7.org/fhir/StructureMap/ANCPregnancy" = "ANCPregnancy"

uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireReponse" as source
uses "http://hl7.org/fhir/StructureDefinition/Bundle" as target

group ANCPregnancy(source src : QuestionnaireResponse, target bundle: Bundle) {
    src -> bundle.type = "collection" "r_bundle_type";
    src -> src.subject as subject, subject.reference as refPatient then
        ExtractPregnancyCondition(src, bundle, refPatient) "r_bundle_entries";
}

group ExtractPregnancyCondition(source src : QuestionnaireResponse, target bundle : Bundle, source refPatient : Reference) {
    src.item as item_preg where(linkId = "da999955-2174-4219-825e-8ae2b948b7e7" and answer.count() > 0 and answer.value.code = "yes") then {
        src -> bundle.entry as entry, entry.resource = create("Condition") as cnd then {
            src -> cnd.id = uuid() "r_cnd_id";

            src.item as item_lmp_date where(linkId = "245679f2-6172-456e-8ff3-425f5cea3243") then {
                src -> cnd.onsetDateTime = evaluate(item_lmp_date, $this.answer.value) "r_cnd_onset_date_val";
            } "r_cnd_onset_date";

            src -> cnd.clinicalStatus = cc("http://terminology.hl7.org/CodeSystem/condition-clinical", "active") "r_cnd_clinical_st";
            src -> cnd.verificationStatus = cc("http://terminology.hl7.org/CodeSystem/condition-ver-status", "confirmed") "r_cnd_verif_st";
            src -> cnd.category = cc("http://terminology.hl7.org/CodeSystem/condition-category", "problem-list-item", "Problem List Item") "r_cnd_category";
            src -> cnd.subject = refPatient "r_cnd_sub";

            src -> cnd.code = create("CodeableConcept") as ccPreg then {
                     src -> ccPreg.coding = c("http://snomed.info/sct", "77386006", "Pregnancy") "r_cnd_code_coding";
                     src -> ccPreg.text = "Pregnant" "r_cnd_code_text";
                 } "r_cnd_code";

        } "r_cnd";
    } "r_cnd_preg";
}
maimoonak commented 2 years ago

@FikriMilano the linkid in questionnaire is

"linkId": "da999955-2174-4219-825e-8ae2b948b7e7",
 "text": "Was the pregnancy confirmed in a health facility?"

I think we do not need any check for this. If questionnaire is submitted it means patient has to be enrolled into ANC care, irrespective of any other variables. @f-odhiambo

FikriMilano commented 2 years ago

Okay, makes sense.

Other than that, Let me know your feedback as well @f-odhiambo

FikriMilano commented 2 years ago

@f-odhiambo @maimoonak I added the final StructureMap to the server and fhir-resource repo as well https://fhir.labs.smartregister.org/fhir/StructureMap/133813 https://github.com/opensrp/fhir-resources/pull/97