# What do the various \`source\` types represent on reports

**URL:** <https://forum.communityhealthtoolkit.org/t/what-do-the-various-source-types-represent-on-reports/492>\
**Category:** Technical Support\
**Tags:** documentation, forms, data\
**Created:** [October 30, 2019, 10:00pm UTC](https://forum.communityhealthtoolkit.org/t/what-do-the-various-source-types-represent-on-reports/492 "2019-10-30T22:00:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/michael/32/319_2.png) [@michael](https://forum.communityhealthtoolkit.org/u/michael)\
**Post date:** [October 30, 2019, 10:00pm UTC](https://forum.communityhealthtoolkit.org/t/what-do-the-various-source-types-represent-on-reports/492/1 "2019-10-30T22:00:48Z")

</div>

Reports normally have a `source` field. I’ve seen 3 different values in this field: `task`, `contact`, and `user`. Are these the only possible values and are the assumptions below correct?

**`task`** - report was submitted from the `#/tasks/` tab  
**`contact`** - report was submitted from the `#/contacts/`tab  
**`user`** - report was submitted from the `#/reports/` tab

---

<div class="post-metadata">

**Author:** ![marc](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/marc/32/602_2.png) [@marc](https://forum.communityhealthtoolkit.org/u/marc)\
**Post date:** [October 31, 2019, 12:24am UTC](https://forum.communityhealthtoolkit.org/t/what-do-the-various-source-types-represent-on-reports/492/2 "2019-10-31T00:24:17Z")

</div>

Yes, that is the way we’ve used them. That said, the field is created and set within forms, so it is more of a convention that we’ve used so far. A community health app using the Core Framework could have other values set, or not use this field at all.

---

<div class="post-metadata">

**Author:** ![michael](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/michael/32/319_2.png) [@michael](https://forum.communityhealthtoolkit.org/u/michael)\
**Post date:** [October 31, 2019, 2:15am UTC](https://forum.communityhealthtoolkit.org/t/what-do-the-various-source-types-represent-on-reports/492/3 "2019-10-31T02:15:15Z")

</div>

Thanks. Looking at the [pregnancy](https://github.com/medic/cht-core/blob/master/config/default/forms/app/pregnancy.xlsx) form in the [Antenatal Care Reference App](https://docs.communityhealthtoolkit.org/#antenatal-care-reference-app-by-medic-mobile) as an example…

 ![20%20PM](https://communityhealthtoolkit.b-cdn.net/uploads/default/original/1X/7abf89cadc658c696c8c09649f219537b6b0ce66.png)  
… I see a reference to `./source ='user'` in the `relevant` field for the `inputs` group. There is also a `default` value set to `user`.

This is a form that is most likely accessed from the `contacts` tab. How/where/when does `./source` get set… and if it gets set to `contact`, wouldn’t the entire `inputs` group be skipped?

---

<div class="post-metadata">

**Author:** ![diana](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/diana/32/2049_2.png) [@diana](https://forum.communityhealthtoolkit.org/u/diana)\
**Post date:** [October 31, 2019, 9:03am UTC](https://forum.communityhealthtoolkit.org/t/what-do-the-various-source-types-represent-on-reports/492/4 "2019-10-31T09:03:25Z")

</div>

As you’ve already noted, the `source` field default (conventional) value of `user` is set directly in the form.

When the report is submitted from the Contacts tab, the value is changed to `contact` by webapp code [here](https://github.com/medic/cht-core/blob/master/webapp/src/js/controllers/contacts-report.js#L71):

```auto
var instanceData = {
  source: 'contact',
  contact: contact.doc,
};
....
Enketo.render('#contact-report', form, instanceData)

```

When the report is submitted from the Task tab, the value is changed to `task` by the configuration code generated by `medic-conf` [here](https://github.com/medic/medic-conf/blob/master/src/nools/task-emitter.js#L137):

```auto
var content = {
  source: 'task',
  contact: c.contact,
};

```

This value is used by webapp when rendering the form in the Task tab [here](https://github.com/medic/cht-core/blob/master/webapp/src/js/controllers/tasks-content.js#L91)

```auto
Enketo.render('#task-report', form, content)

```

---

<div class="post-metadata">

**Author:** ![marc](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/marc/32/602_2.png) [@marc](https://forum.communityhealthtoolkit.org/u/marc)\
**Post date:** [October 31, 2019, 1:39pm UTC](https://forum.communityhealthtoolkit.org/t/what-do-the-various-source-types-represent-on-reports/492/5 "2019-10-31T13:39:06Z")

</div>

> if it gets set to `contact` , wouldn’t the entire `inputs` group be skipped?

Correct, that is intended. When accessing a form from the Reports tab the form doesn’t have the context to know who the form is about, so fields in the `inputs` section are used to ask the user to explicitly select the person (or place). When completing the form from the _Contact_ or the _Task_ tab the form knows who the report will be about so that whole `inputs` section is not displayed to the user.

Although this is mostly based on convention, there are a couple of things to note. As @diana mentioned, the Core Framework populates the `source` field when coming from a _Contact_ or _Task_. Also, the `inputs` section is always saved with a report, even if the `relevant` condition is false.

_Some additional background: Non-relevant fields used to always be saved with reports. This changed in 2.18. When this change occurred we updated the Core Framework to always save the `inputs` section, regardless of the `relevant` condition. More info can be seen in this GitHub issue: [Inputs group not saved when its relevance is set to false · Issue #4875 · medic/cht-core · GitHub](https://github.com/medic/cht-core/issues/4875)_

---

<div class="post-metadata">

**Author:** ![marc](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/marc/32/602_2.png) [@marc](https://forum.communityhealthtoolkit.org/u/marc)\
**Post date:** [October 31, 2019, 1:51pm UTC](https://forum.communityhealthtoolkit.org/t/what-do-the-various-source-types-represent-on-reports/492/6 "2019-10-31T13:51:04Z")

</div>

Writing up [the response](https://forum.communityhealthtoolkit.org/t/what-do-the-various-source-types-represent-on-reports/492/5) made me think that we should be more explicit than our current documentation [[link1](https://github.com/medic/medic-docs/blob/master/configuration/forms.md#general-structure), [link2](https://github.com/medic/medic-docs/blob/master/configuration/developing-community-health-applications.md#app-forms)] is about the `inputs` section as something important for forms used by the Core Framework.

Aside from updating documentation, perhaps `medic-conf` should verify for a decently formed `inputs` section in all forms, and post a warning otherwise.

---

<div class="post-metadata">

**Author:** ![michael](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/michael/32/319_2.png) [@michael](https://forum.communityhealthtoolkit.org/u/michael)\
**Post date:** [May 26, 2023, 5:03pm UTC](https://forum.communityhealthtoolkit.org/t/what-do-the-various-source-types-represent-on-reports/492/7 "2023-05-26T17:03:31Z")

</div>

> [@diana](#):
>
> When the report is submitted from the Task tab, the value is changed to `task` by the configuration code generated by `medic-conf` [here](https://github.com/medic/medic-conf/blob/master/src/nools/task-emitter.js#L137):
> 
> ```auto
> var content = {
> source: 'task',
> contact: c.contact,
> };
> 
> ```

Do you think it would be reasonable to have the `source` changed to `task-group` (or something like that) if the report was submitted from the [_Household_ Tasks](https://docs.communityhealthtoolkit.org/apps/features/tasks/#household-tasks) screen?

---

<div class="post-metadata">

**Author:** ![diana](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/diana/32/2049_2.png) [@diana](https://forum.communityhealthtoolkit.org/u/diana)\
**Post date:** [May 29, 2023, 12:06pm UTC](https://forum.communityhealthtoolkit.org/t/what-do-the-various-source-types-represent-on-reports/492/8 "2023-05-29T12:06:19Z")

</div>

> [@michael](#):
>
> Do you think it would be reasonable to have the `source` changed to `task-group` (or something like that) if the report was submitted from the [_Household_ Tasks](https://docs.communityhealthtoolkit.org/apps/features/tasks/#household-tasks) screen?

I think we would be creating a little bit of inconsistency.  
Right now, there are three ways for a user to get to open a task:

1. directly from the tasks tab
2. link from the task list from the contact page
3. link from household task popup

If the way the user got to a specific task is significant enough to replace the “source”, then we should probably have a second source for the link from contact page as well.

---

<div class="post-metadata">

**Author:** ![michael](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/michael/32/319_2.png) [@michael](https://forum.communityhealthtoolkit.org/u/michael)\
**Post date:** [May 30, 2023, 6:01pm UTC](https://forum.communityhealthtoolkit.org/t/what-do-the-various-source-types-represent-on-reports/492/9 "2023-05-30T18:01:24Z")

</div>

I actually thought that the source would have been set to `contact` if the user tapped on the Task from the Contacts tab. Based on your list and specification of “directly from” vs. “link from”, now I understand that even if the user tapped on the Task from the Contacts tab and completed the from, the report `source` would actually be `task` instead of `contact`. Is my understanding correct?

If so, it makes sense why you’d suggest a second `source` for the link from Contact page.

The reason I’m interested in all of this is that I want to know _where users are completing Tasks_ _ **from** _…

- directly from the Tasks page
- accessing from the Contact page
- are they completing _ **any** _ tasks from the household tasks page (haven’t [found](https://forum.communityhealthtoolkit.org/t/how-to-interpret-telemetry-for-household-tasks-task-groups/2777) this in telemetry yet)

I don’t think it’s possible to know any of this today, but setting the `source` would actually make it really easy.

---

<div class="post-metadata">

**Author:** ![diana](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/diana/32/2049_2.png) [@diana](https://forum.communityhealthtoolkit.org/u/diana)\
**Post date:** [May 31, 2023, 12:31pm UTC](https://forum.communityhealthtoolkit.org/t/what-do-the-various-source-types-represent-on-reports/492/10 "2023-05-31T12:31:23Z")

</div>

I believe that when completing a task, no matter where from where the user navigated to the task, the `source` will always be `task`, I think `source: 'contact'` is when a report is submitted directly from the contacts page.
