Contact-summary value exposure and report usage

Is there a way to hide a recently completed task?
When a task gets triggered for a patient, and is subsequently completed, it shows up in the “reports” card as expected.
However, when the “+” button is clicked, that same task is still shown as an option.
Is there a way to hide a recently completed task?

when the “+” button is clicked

Are you talking about the “Submit Report” button on the Reports tab? If so, I believe that the context.expression for the form is evaluated to determine which forms to display in that list. If you have a form that you only want to be triggered from a task (and users should never be able to submit ad-hoc) then perhaps you can just have a false expression so the form is never visible.

I was referring to the people tab’s plus button, the one present in the hierarchy:


I’m assuming they are the same thing?

Thank you for the explanation, we do plan on taking a deeper dive into the task scheduling at a later stage.

For now, is there a way to access previous report data within that context.expression?
I know we can expose values to the <form_name>.properties.json via the contact-summary, but I’ve been unable to ascertain if we’re able to tap into report data.

Our use case is we have a project specific (each project has forms for various levels) consent form.
If the patient does not consent, or that form has not been completed yet, we should hide that project’s other app forms in the selection list.
This requirement is tangential to the one originally mentioned.

:+1: Got it. Makes sense! I believe that the context.expression should affect both the available forms on the People tab and on the Reports tab.

For now, is there a way to access previous report data within that context.expression?

The recommended mechanism for doing something like this is really to just include the data you need in your contact-summary (which, as you noted, is accessible from the content.expression). This thread has a pretty good walk-though of what this config can look at, but I think the workflow would be something like:

  • Update the contact-summary configuration to set a consent field based on the contact’s consent status.
  • For the relevant forms, update the content.expression to check for that consent field in the summary.
1 Like

Thank you for the info regarding this functionality, it really is appreciated!

The suggested seemed to have worked for the following cases:

  • Based on the Household Consent forms relating to that project are shown/hidden correctly for that level.
  • This also seems to be the mechanism that one taps into when trying to access a previous follow up form’s data via the instance('contact-summary')/context/${variable} method in xlsx?

For the latter point:
It mentions “variable”, does it have to be a variable such as “hasFlu” or is it possible to reference a property inside an object such as “illnesses.flu”?
The hope is one can simply return the most recent relevant form’s fields unpacked into the context object. So if one of the fields have a nested value structure, it’s an easy reference rather than having to unpack everything into a flat structure.
This would keep “building previous form references” simple even if those form values change over time.

With the former:
the problem I’m facing now is that the Household Consent previously mentioned is on the household level, however, the values of that form also needs to be accessed on the household member level which is one level down.

I don’t seem to have access to that report on that level.
Do you perhaps know of a workaround?

@jkuester We opted to use the following approach in our initial release.
It would be awesome to hear your thoughts or concerns with the following.

It seems reports are specific to a hierarchy level. We’ve opted to create an “individual level consent” form to satisfy our other requirement.

In the contact-summary-extras.js:

// Since multiple forms can be unpacked into the context at a time
// To ensure conflicts between values do not occur, each key will be prefixed by the form name
function getFlattenedReportData(reports, formName) {
  const fields = getAppFormFields(reports, formName);
  return fields && flattenObject(fields, formName);
}

function getAppFormFields(reports, formName) {
  const item = reports && reports.find(obj => obj.form === formName);
  return item ? item.fields : undefined;
}

function flattenObject(obj, parentKey = '') {
  const result = {};

  for (const key in obj) {
    if (Object.prototype.hasOwnProperty.call(obj, key)) {
      // It seems very few special characters are supported by the "pojo2xml" lib
      // Both "." and "-" being among them.
      // Therefore "__" is used as a delimiter when constructing a flat key
      // While any key containing a "-" is replaced by a "_" instead.
      // It also only threw an error when trying to open an app form.
      let newKey = parentKey ? `${parentKey}__${key}` : key;
      newKey = newKey.replace(/-/g, '_');

      if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) {
        Object.assign(result, flattenObject(obj[key], newKey));
      } else {
        result[newKey] = obj[key];
      }
    }
  }

  return result;
}

In the contact-summary-templated.js:

const copcHouseholdScreening = isHouseholdLevel &&
  getFlattenedReportData(reports, 'copc-hhscreening');

...

const context = {
  ...
};

// Unfortunately spreading does not seem to be supported.
// # COPC app form fields
Object.assign(context, (copcHouseholdScreening || {}));

module.exports = {
  cards,
  fields,
  context,
};

Sorry for the late response here! Unfortunately, I do not know of any better way to address this issue than what you have suggested with the “individual level consent” form. When building the contact-summary for a contact, there is just not really any way to access the reports (or even contact-summary) of a different contact. The only sort of alternative that I have been able to come up with is that if you could record the consent by editing the Household contact (via the household’s edit form) and store the consent value as a field on the household contact, that does open some opportunities. When calculating the contact-summary of the household member, you would have access to the household contact at contact.partent and could read the consent field from there.

Also, for the record, the answer here is no, it does not have to be just a variable. You can set more complex objects in the contact-summary context!

1 Like