medic / cht-core

The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.
https://communityhealthtoolkit.org
GNU Affero General Public License v3.0
469 stars 217 forks source link

Searching report doesn't populate all reports #9631

Closed 1yuv closed 1 week ago

1yuv commented 2 weeks ago

Describe the bug Searching for reports by medic id doesn't populate app forms. Only sms forms are populated on search result.

To Reproduce Steps to reproduce the behavior:

  1. Have a configuration where both SMS forms and App forms can be submitted for patient.
  2. Register/Create a patient, note patient's medic id.
  3. Submit SMS form(s) and webapp form for that patient.
  4. Go to reports tab and search by providing Medic id from step 2.
  5. Only sms froms will be populated on the results and web app form won't be populated on the results.

Expected behavior If we are searching on reports tab by medic id, result should populate all reports (sms and app forms).

Logs

Screenshots

Environment

dianabarsan commented 2 weeks ago

@1yuv Which webapp form are you submitting? The connection between report and patient is done through patient_uuid and patient_id fields, but these are configured within the form itself and aren't added automatically. If your form doesn't store patient_id, then there will be no reference to the patient contact through that string.

Can you share the JSON body of the XML report that you expected to see as a search result, please?

1yuv commented 2 weeks ago

Hi @dianabarsan , the XML report had patient_id set to empty. Which may be the reason why that form didn't come on as a search result. How about searching from patient name? The patient name is in both SMS form and xml form. Is it because they may be stored in different json path?

dianabarsan commented 2 weeks ago

If the report didn't have a patient_id, this is expected behavior and not a bug. The report form itself is responsible with populating these fields.

Are you not getting the XML report when searching by name?

dianabarsan commented 1 week ago

Any updates here @1yuv ? Did you find another behavior which is not expected?

1yuv commented 1 week ago

Hi @dianabarsan , I am seeing strange search result on local instance. Sometimes Sms forms are not coming on search result and sometimes xml form are not coming on. Below is the example of sms form not coming on as a result.

Search result showing xml form only: Image

Patient's contact page with 1 xml form and 1 sms form: Image

Let's keep this issue open for a while and observe it on other instances.

1yuv commented 1 week ago

If the report didn't have a patient_id, this is expected behavior and not a bug. The report form itself is responsible with populating these fields.

Are you not getting the XML report when searching by name?

I think for the name field also same thing applies. If name is not on the field of the other reports, it won't be populated on search result.

dianabarsan commented 1 week ago

If name is not on the field of the other reports, it won't be populated on search result.

This applies on any field. Search uses fields in the reports alone, and doesn't do any smart connection to contacts.