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
441 stars 212 forks source link

Missing information and hyperlink in reports created while offline before the contact gets synced #6334

Open binokaryg opened 4 years ago

binokaryg commented 4 years ago

Describe the bug As an offline user, if I create a new contact and add their report quickly without letting it sync first, the report does not get the information such as the link to the contact and Patient ID.

To Reproduce

  1. Steps to reproduce the behavior:
  2. Log in as an offline user
  3. Create a person
  4. Add a report for that person
  5. Click on the report just added. The report does not have any link to directly go to the person.
  6. Sync
  7. The report still does not have any usable link to go to the contact

If you pull the following fields to the report from contact:

  1. Patient UUID contact/_id
  2. Patient Name contact/name
  3. Patient ID contact/patient_id

Fields 1 and 2 show up as hyperlinks in the report, but they only take you to the contact tab. Field 3 does not populate if the contact has not been synced yet.

If a report is sent after syncing the contact, Patient ID and name are shown with a hyperlink, but it takes you to the Contacts tab as reported in #6149 and #3414.

Expected behavior

  1. We should be able to go to the contact from a report
  2. Patient/Medic ID should be added to the report after both contact and report get synced

Screenshots 1. Report submitted before contact is synced: image

2. Report submitted after contact is synced: image

In the report submitted after the Contact is synced submitted before the Contact not synced
Contact name appears at the top? yes, with proper link yes, but no link
Patient UUID appears in fields? yes, with proper link yes, but the link takes you to the contacts tab only
Patient ID appears in fields? yes, with link to the contacts tab no
Patient Name appears in fields? yes, with link to the contacts tab yes, with link to the contacts tab
     

Environment

Additional context When digitizing paper forms, people like to quickly create a person and then add reports before it gets synced. Later when we find an interesting report and we want to go to its contact, we have to search using the name which is not very convenient.

dianabarsan commented 4 years ago

hey @binokaryg Do you think this is a duplicate of: https://github.com/medic/cht-core/issues/6149 ?

binokaryg commented 4 years ago

I don't think it's a duplicate, but yes some overlap is there, as mentioned in my original post above. There are two expectations that are different from #6149:

dianabarsan commented 4 years ago

Update Medic/Patient ID in the report after its corresponding contact gets one (currently blank)

This is not a bug. We should consider this request a for new feature or an improvement of an old feature.

We have mechanics in place to link a patient to a report without the "patient_id", for example by using the "uuid" of the patient document.

binokaryg commented 4 years ago

Thanks @dianabarsan. We can change it to a feature request or improvement.

Another thing that I have noticed is that the link of Patient UUID is not working in a report that has Medic ID blank (submitted before a contact was synced). However, it is working in a report that has Medic ID (synced contact).

It can also be seen in the screenshots that I have shared in the original post. I have marked the Patient UUIDs as number 2.

For example:

  1. Not linked: https://covid-demo.dev.medicmobile.org/#/reports/376d2a53-2b00-4487-875d-1434a0f07a79
  2. Linked: https://covid-demo.dev.medicmobile.org/#/reports/78d76b6b-2fab-4373-8e70-d06a8ae392ff

This behavior is different from what you have shown in #6149, such as this report. Here, the UUID field does not take you to the contact. It only takes you to the contacts tab. I believe that the report was sent after its contact was synced, henced the hyperlinked name at the top. What do you think? Could it be because of the different versions of the web-app?

binokaryg commented 4 years ago

Because of the missing "Patient ID", Multi-Report SMS alert can not include it. For example, if we want to send this message: {{contact.name}} has reported a high risk case with ID {{new_reports.0.fields.patient_id}}. Please follow up. The "patient_id" is often sent as blank:

dianabarsan commented 4 years ago

@binokaryg The reports that are provided to the messages in multi-report-alerts are fully hydrated. You are able to access patient information with like {{new_reports.0.patient.patient_id}}

brad1905 commented 4 years ago

AT passed, ready to merge

dianabarsan commented 4 years ago

This was only partially a duplicate of https://github.com/medic/cht-core/issues/6149, so not resolved by its fix. The remaining part (the request to update older reports when patient_id is generated on the patient contact) is probably a duplicate of https://github.com/medic/cht-core/issues/6383 .