`accept_case_reports` form entry dependency on a corresponding entry in `registrations`?

I have this config (reducted) in app settings.

"registrations": [
    {
        "form": "chv_signal_reporting",
        "events": [{
            "name": "on_create",
            "trigger": "add_case"
        }],
        "messages": [
            {
                "event_type": "report_accepted",
                "bool_expr": "true",
                "message": "<message>",
                "recipient": "parent"
            }
        ]
    },
    {
        "form": "cha_signal_reporting_verification",
        "events": [{
            "name": "on_create",
            "trigger": "add_case"
        }],
        "messages": [
            {
                "event_type": "report_accepted",
                "bool_expr": "<condition>",
                "message": "<message>",
                "recipient": "parent"
            }
        ]
    },
    {
        "form": "cha_signal_verification",
        "events": [{
            "name": "on_create",
            "trigger": "clear_schedule",
            "params": "dummy"
        }]
    }
  ],
  "accept_case_reports": [
    {
        "form": "cha_signal_verification",
        "validations": {},
        "messages": [
            {
                "event_type": "report_accepted",
                "bool_expr": "<condition>",
                "message": "<msg>",
                "recipient": "parent"
            }
        ]
    }
  ],
  "schedules": [
    {
      "name": "dummy",
      "summary": "<txt>",
      "description": "",
      "start_from": "reported_date",
      "start_mid_group": true,
      "messages": [
        {
          "translation_key": "schedules.dummy.message",
          "group": 1,
          "offset": "52 weeks",
          "send_day": "monday",
          "send_time": "09:00",
          "recipient": "reporting_unit"
        }
      ]
    }
  ]

Note that there is a dummy schedule entry whose only purpose is to allow registering cha_signal_verification in registrations.

What I really wanted to do is to just accept cha_signal_verification report as a case report linked to the case generated in chv_signal_reporting’s registration and send an SMS notification.

If I omit the entry for cha_signal_verification form in registrations, it’s accept_case_reports config does not work and no SMS is sent.

Is this by design? It seems to me accepting a case report should be independent of a registration for a form.

Hi @bernard

I believe this is by design, as the registration transition first “assigns” a unique case_id to the original report, with subsequent reports referring to this generated case_id. This is how accept_patient_reports works as well - it relies on the patient_id being created beforehand by something else (but there are more mechanisms that generate patient_ids).

1 Like

Thank you @diana for confirming. In this case though, the report that generates the case_id is different from the one referring to it. For such cases, we should consider breaking the dependency. What do you think?

Hi @bernard

I’ve tested this locally and I’m getting an SMS message even though I have no schedule or registration entry for the second form:

    "transitions": {
      "accept_case_reports": true,
      "default_responses": true,
      "registration": true,
      "update_clinics": true,
      "generate_patient_id_on_people": true,
    },
    "forms": {
        "CW": {
        "meta": {
          "code": "CW",
          "icon": "child",
          "translation_key": "form.cw.title"
        },
        "fields": {
          "weeks_since_birth": {
            "labels": {
              "short": {
                "translation_key": "report.cw.weeks_since_birth"
              }
            },
            "position": 0,
            "type": "integer",
            "length": [
              1,
              3
            ],
            "range": [
              0,
              260
            ],
            "required": true,
            "validations": {},
            "flags": {}
          },
          "patient_name": {
            "labels": {
              "short": {
                "translation_key": "report.cw.patient_name"
              }
            },
            "position": 1,
            "type": "string",
            "length": [
              1,
              30
            ],
            "required": true
          }
        },
        "public_form": false,
        "use_sentinel": true
      },
    "GC": {
        "meta": {
          "code": "GC",
          "icon": "child",
          "translation_key": "form.g.title"
        },
        "fields": {
          "case_id": {
            "labels": {
              "short": {
                "translation_key": "case_id"
              },
              "tiny": {
                "en": "ID"
              }
            },
            "position": 0,
            "type": "string",
            "length": [
              5,
              13
            ],
            "required": true,
            "validations": {},
            "flags": {}
          },
          "severity": {
            "labels": {
              "short": {
                "translation_key": "report.g.severity"
              },
              "tiny": {
                "en": "severity"
              }
            },
            "position": 1,
            "type": "string",
            "length": [
              1,
              1
            ],
            "required": true
          }
        },
        "public_form": false,
        "use_sentinel": true
      },
    },
    "schedules": [],
    "registrations": [
      {
        "form": "CW",
        "events": [
          {
            "name": "on_create",
            "trigger": "add_case",
            "params": "",
            "bool_expr": ""
          }
        ]
      }
    ],
    "accept_case_reports": [
      {
        "form": "GC",
        "messages": [
          {
            "event_type": "report_accepted",
            "message": "Case accepted",
            "recipient": "parent",
            "params": "",
            "bool_expr": ""
          }
        ]
      }
    ]