Patient registration from App Form

Hi,
I’m trying to use transitions, the registrations transition, to add a new patient from an app form, in app_settings/base_settings.json I have

"registrations": [
    {
      "form": "tb_health_center_out_area_patient",
      "fields": [
        {
          "field_name": "",
          "title": ""
        }
      ],
      "help": "",
      "events": [
        {
          "name": "on_create",
          "trigger": "add_patient",
          "params": "",
          "bool_expr": ""
        }
      ],
      "validations": {
        "join_responses": false,
        "list": [
          {
            "property": "",
            "rule": "",
            "message": [
              {
                "content": "",
                "locale": ""
              }
            ]
          }
        ]
      },
      "messages": [
        {
          "message": [
            {
              "content": "",
              "locale": ""
            }
          ],
          "recipient": ""
        }
      ]
    }
  ]

And this is the report I send to trigger sentinel transition

{
  "_id": "51692df2-849d-45ee-8185-5161d0b08364",
  "_rev": "1-a6b7f246458365ab9df2d77dd50e6ad5",
  "form": "tb_health_center_out_area_patient",
  "type": "data_record",
  "content_type": "xml",
  "reported_date": 1653382105830,
  "contact": {
    "_id": "094bb5d0-8e45-4cf3-854e-ef20ba9ed6f6",
    "parent": {
      "_id": "d150570f-83ae-469f-9729-07afec448a30",
      "parent": {
        "_id": "71a5a547-dfaf-4e17-867f-badf885b5954"
      }
    }
  },
  "from": "",
  "hidden_fields": [
    "patient_sex_fr",
    "patient_sex_bm",
    "meta"
  ],
  "fields": {
    "inputs": {
      "meta": {
        "location": {
          "lat": "",
          "long": "",
          "error": "",
          "message": ""
        },
        "deprecatedID": ""
      },
      "source": "contact",
      "source_id": "",
      "t_cscom_area": "",
      "t_tb_diagnosis": "",
      "t_patient_name": "",
      "t_date_of_birth": "",
      "t_patient_sex": "",
      "t_patient_phone": "",
      "t_muso_id": "",
      "contact": {
        "_id": "d150570f-83ae-469f-9729-07afec448a30"
      }
    },
    "patient_age_in_years": "0",
    "patient_age_in_months": "",
    "patient_age_in_days": "NaN",
    "patient_age_display": "0 years and 0 months old",
    "patient_age_display_fr": "0 ans et 0 mois",
    "patient_age_display_bm": "San 0 ani  Kalo 0",
    "patient_sex": "",
    "patient_sex_fr": "",
    "patient_sex_bm": "",
    "parent_id": "d150570f-83ae-469f-9729-07afec448a30",
    "muso_id": "",
    "patient_name": "Oscar",
    "patient_phone": "",
    "tb_test_result": "",
    "s_tb_result_display": "",
    "needs_signoff": "true",
    "cscom_area": "",
    "s_patient_arrival": {
      "s_fill_info": "no",
      "s_why_no_fill": "other",
      "s_why_no_fill_reason": "Other",
      "fullname": "Oscar"
    },
    "group_summary": {
      "r_summary": "",
      "r_patient_info": "",
      "no_fill_reason": "Oscar",
      "n_si_3": "",
      "no_diagnosis_reason": ""
    },
    "meta": {
      "instanceID": "uuid:1760e508-aea6-4306-acdb-4848eadf425d"
    }
  },
  "geolocation": {
    "latitude": 12.5925044,
    "longitude": -7.9316331,
    "altitude": null,
    "accuracy": 2234.5887658184297,
    "altitudeAccuracy": null,
    "heading": null,
    "speed": null
  },
  "_attachments": {
    "content": {
      "content_type": "application/xml",
      "revpos": 1,
      "digest": "md5-VVSpIiS08eC9ef5Jq4gQgQ==",
      "length": 2382,
      "stub": true
    }
  }
}

I expected to find a new patient with name Oscar provided in patient_name field and with parent d150570f-83ae-469f-9729-07afec448a30 this is the parent of the report sender.
The new patient is not created and I really don’t know where could I look at to know what is failing
any help is appreciated

Hello @bamatic I like that you are clear on what you intend to achieve.

Reading through how you have approached it, you have taken the route of JSON forms that essentially would work hand-in-hand with the transition. However, you want to use an app form to create a patient.

The concept, for reference purposes, is creating additional docs from app forms. In this scenario, the new patient document would be a linked document off the tb_health_center_out_area_patient report.

The parent of the patient created would not necessarily be the parent of the report sender, but expected to be the parent of the contact under whose profile the report is submitted. For example, if the report was submitted for a household member, the the parent of the new patient would be the household of the existing contact. The child-parent relationship is not by default, but configured in the form as you define the fields for the additional document, as you will notice.

When done right, you should get your documents as expected, which would be similar to the following initial and resulting docs respectively.

{
  "_id": "51692df2-849d-45ee-8185-5161d0b08364",
  "_rev": "1-a6b7f246458365ab9df2d77dd50e6ad5",
  "form": "tb_health_center_out_area_patient",
  "type": "data_record",
  "content_type": "xml",
  "reported_date": 1653382105830,
  "fields": {
    ...
  }
  ...
}
{
  "_id": "...",
  "_rev": "...",
  "type": "contact",
  "contact_type": "{{contact-type-id}}",
  "name": "Oscar",
  "created_by_doc": "51692df2-849d-45ee-8185-5161d0b08364",
  ...
}

Let us know how it goes.

1 Like

Hi @kitsao thank you very much for this
I think that your suggestion cover our needs, instead of using transitions I will try to use this thank you.