medic / cht-core

The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.
https://communityhealthtoolkit.org
GNU Affero General Public License v3.0
467 stars 217 forks source link

Add support to check if either of multiple forms is submitted for a patient. #8402

Closed 1yuv closed 1 week ago

1yuv commented 1 year ago

There's a validation method in pupil like exists, which allows us to check multiple conditions, for example if a particular form has been submitted before for the same patient or not.

However, this function only supports one form and there's no provision to check multiple forms. Our scenario is:

  1. We want to ensure that pregnancy registration form has been submitted for a patient before pregnancy visit or delivery form is submitted.
  2. We've 4 ways of registering pregnancy form i.e. Any form out of those 4 form submitted means a pregnancy form is submitted.
  3. exists() method currently accepts only one form.
  4. Also looks like rules like this is not supported:
    "rule": "exists('A', 'patient_id') || exists('L', 'patient_id')",

We need a mechanism to check if any of those forms has been submitted. More on this here

1yuv commented 10 months ago

Hi @dianabarsan , @garethbowen ,

The cht-core documentation for rules mentions that Pupil.js rules and rules specific to the CHT can not be combined. However, it should allow similar type of rules to be combined together. For example something like this is a cht specific rule and should be allowed.
exists('A', 'patient_id') || exists('L', 'patient_id'). CHT doesn't complain about the rule, but it's not actually working.

If we had that functionality, we could have tested multiple functions with this.