Contact.reports

Hi team, happy new year, I need some help
I’m thinking in tasks appliedTo contacts, and the contact.reports array
wich reports appears there ? those that have report’s contact._id the same as the contact _id ?

Hi @bamatic, happy new year.

Regarding which reports are associated with a contact, I found this in the CHT Docs (app | Community Health Toolkit):

Reports that have at least one of place_id , patient_id , and patient_uuid at the top level will be associated with that contact.

However, the above document is about app forms and does not specify anything about tasks. So I looked further and found this in the cht-core source:

Here, the view medic-client/reports_by_subject is being used to fetch the reports that belong to the subject (contact). When looking inside the view, we can see:

From the above snippet, we can understand that any report that has at least one of these fields matching should be associated with the contact:

  • report.patient_id
  • report.place_id
  • report.case_id
  • report.fields.patient_id
  • report.fields.place_id
  • report.fields.case_id
  • report.fields.patient_uuid
  • report.fields.place_uuid
2 Likes

Thanks a lot binod
second question if possible
is the same logic used for the reports variables in the contact summary, I mean this reports var in docs, https://docs.communityhealthtoolkit.org/apps/reference/contact-page/

reports An array of reports for the contact or for any of the contact’s children.

hi binod
this data_record

{
_id: "e29b3f14-aa2a-4322-a2a6-020c5d246a98",
_rev: "1-35e7bc2c56bbd51bf147dc4e2163d2fc",
form: "epi_daily_report",
type: "data_record",
content_type: "xml",
reported_date: 1703422294044,
contact: {
_id: "16259fcc-d057-4874-8638-2f89d3ff2f20",
parent: {
_id: "dbc49be5-d79f-4a01-a97a-fbee9e2af68e",
parent: {
_id: "4db0d71e-1363-4f33-8411-505b381f90bf",
parent: {
_id: "686a4d50-383b-4abe-95a0-73e1bffb454e",
parent: {
_id: "9e0c4f1a-daed-4283-9d9f-f129ca501838"
}
}
}
}
},
from: "+22364318170",
form_version: {
time: 1703100633771,
sha256: "bd784ebfd8805d2dacf789220f01bc7ee5d6580aff405b20275ba62ee64f872c"
},
hidden_fields: [
"meta"
],
fields: {
inputs: {
meta: {
location: {
lat: "",
long: "",
error: "",
message: ""
},
deprecatedID: ""
},
source: "task",
source_id: "16259fcc-d057-4874-8638-2f89d3ff2f20",
contact: {
_id: "16259fcc-d057-4874-8638-2f89d3ff2f20",
name: "ASC-Assawèrè Tessougué",
date_of_birth: "",
sex: "",
parent: {
_id: "dbc49be5-d79f-4a01-a97a-fbee9e2af68e",
parent: {
_id: "4db0d71e-1363-4f33-8411-505b381f90bf",
parent: {
_id: "686a4d50-383b-4abe-95a0-73e1bffb454e",
parent: {
_id: "9e0c4f1a-daed-4283-9d9f-f129ca501838"
}
}
}
}
}
},
lineage: {
c50_patient_uuid: "",
c50_family_uuid: "",
c40_chw_area_uuid: "dbc49be5-d79f-4a01-a97a-fbee9e2af68e",
c30_supervisor_area_uuid: "4db0d71e-1363-4f33-8411-505b381f90bf",
c20_health_area_uuid: "686a4d50-383b-4abe-95a0-73e1bffb454e",
c10_site_uuid: "9e0c4f1a-daed-4283-9d9f-f129ca501838"
},
chw_id: "16259fcc-d057-4874-8638-2f89d3ff2f20",
chw_name: "ASC-Assawèrè Tessougué",
patient_id: "16259fcc-d057-4874-8638-2f89d3ff2f20",
patient_name: "ASC-Assawèrè Tessougué",
date_of_report: "01-12-2023",
completion_date: {
report_today: "no",
which_date: "2023-12-01"
},
material_usage: {
quantity_used: "",
qty_mask: "1",
qty_glasses: "0",
qty_gloves: "2",
qty_hydroalcoholic: "0",
qty_soap: "0",
qty_tissues: "0"
},
ppe_needs: {
need_tomorrow: "yes",
need_month: "yes"
},
c_usage_summary: {
c_qty_mask: "",
c_qty_glasses: "",
c_qty_gloves: "",
c_qty_hydroalcoholic: "",
c_qty_soap: "",
c_qty_tissues: "",
c_confirm_usage: "yes"
},
summary: {
usage_summary: "",
r_chw_info: "",
r_usage_summary: "",
r_qty_mask: "",
r_qty_glasses: "",
r_qty_gloves: "",
r_qty_hydroalcoholic: "",
r_qty_soap: "",
r_qty_tissues: ""
},
meta: {
instanceID: "uuid:30b75746-24f6-4f8f-8801-8d1176a7be2c"
}
},
geolocation_log: [
{
timestamp: 1703422294268,
recording: {
code: -1,
message: "Geolocation timeout exceeded"
}
}
],
geolocation: {
code: -1,
message: "Geolocation timeout exceeded"
},
_attachments: {
content: {
content_type: "application/xml",
revpos: 1,
digest: "md5-pfDfbiFnyj9te+CrlzrlNg==",
length: 3572,
stub: true
}
}

appears as a report of contact dbc49be5-d79f-4a01-a97a-fbee9e2af68e here https://muso-mali.app.medicmobile.org/#/contacts/dbc49be5-d79f-4a01-a97a-fbee9e2af68e
but he has not any of the fields mentioned set to dbc49be5-d79f-4a01-a97a-fbee9e2af68e

Why are they associated to this place dbc49be5-d79f-4a01-a97a-fbee9e2af68e ???

The reports variable in the contact summary will include the reports belonging to the contact being displayed, and additionally, reports belonging to the immediate children of the contact.

Here is the relevant code snippet that loads the reports in the cht-core:

That’s probably because of the same logic as above. The contact-view-model-generator.service loads reports that belong to the contact and its children.

In your case, the report has this field:
"patient_id": "16259fcc-d057-4874-8638-2f89d3ff2f20"

And the contact with this _id is a child of dbc49be5-d79f-4a01-a97a-fbee9e2af68e.

1 Like

thanks now I understand why the health area shows reports of the chw (child of the head area) but not the reports associated with households like home visits, even if househould are children of the health area, but as you have shown in the code group.type.person is getting only reports associated with children of type person, it will be great to have this in docs of contact_summary

1 Like