Getting data off selected contact to the inputs group

I created an app form following the documentation here. My interest was drawn to the contact selector for fetching data to the contact group under inputs whereby db:person seems to do the job as long as referenced attributes exist in the JSON document even though person is not the selected contact_type ID. Here’s how my inputs group looks like

followed by the corresponding JSON data below:

 "inputs": {
    "meta": {
      "location": {
        "lat": "",
        "long": "",
        "error": "",
        "message": ""
      },
      "deprecatedID": ""
    },
    "source": "contact",
    "source_id": "",
    "contact": {
      "_id": "21707844-cf59-4f82-9482-b38fcef4a243",
      "name": "Region A",
      "patient_id": "",
      "date_of_birth": "",
      "sex": "",
      "parent": {
        "_id": "92b2bc81-c0a3-4d80-905d-819e52b7193e",
        "name": "National Hospital",
        "parent": {
          "_id": "",
          "name": "",
          "contact": {
            "_id": "",
            "name": "",
            "phone": ""
          }
        }
      }
    }
  }

This is observed in version 3.13.0.

Should this be the expected behavior?

I double-checked this and observed similar behavior on 3.4.0 and also running master.

I believe this is “expected” behavior in that any pre-selected value (e.g. one coming from the inputs) will be set without checking its contact type. The filtering by contact type only happens when the user actually performs a search…

I will leave it to someone with more knowledge and experience than mine to say if this is actually the behavior that we want

Yes, that’s the expected behaviour, and I believe the desired one as well.

There is no real type validation on data passed to the form. As such, any data type can be passed to the form input fields. The db:person is a XLSForm type that comes into play only when completing the inputs section in the UI, which happens when opening the form from the Reports tab, as noted by the ./source = 'user' relevant condition. This pattern is followed in many forms of the default config since it avoid repetition of fields and calculations that would otherwise be needed to handle both automated and manual selection of the contact in the form.

1 Like