Outbound - Destination property

Hi,

When creating outbounds, is it possible to have multiple destinations? So that we have two or more URLs / external services per configuration object (with the same trigger / mapping) instead of creating one per external service?

@magp18 - You can have multiple destinations, but they each need their own declaration in app settings, so your triggers and mapping will have to be duplicated.

For an example of what this might look like, you can see this app settings file on line 362 to the end.

Best of luck!

1 Like

Hi, yes it is great and works! However, we are seeing one object outbound being executed twice for the same form. Never the first one and it works if it’s only one outbound object, but if we have two outbound objects, the second one is executed twice. If there are three the second and the third one are executed twice as well.
We thought it could be related to the mediator (because they have different destinations), but if we change the order of the outbound objects we observe the same behavior, where the first one succeeds without duplication, the second and third duplicate.
Has anyone encountered the same issue?

@magp18 - Sounds like a potential bug! However, maybe it’s related to this issue?

Could you also paste in a sanitized version of your outbound config so that we might try and reproduce the issue?

I think it’s unrelated, in this case it’s as soon as one form is filled, but multiple outbounds trigger. It’s independent of starting a new form or even editing one.

Sure

  "outbound": {
    "firstconf": {
      "relevant_to": "doc.type === 'data_record' && ((doc.form === 'algo1' && doc.fields.ask_something === 'No') || (doc.form === 'algo1_task' && doc.fields.inputs.ask_something === 'Yes'))",
      "destination": {
        "base_url": "https://url1.demo.org",
        "path": "/channel/ch1",
        "auth": {
          "type": "basic",
          "username": "test",
          "password_key": "test_key"
        }
      },
      "mapping":{
        "report._id":"doc._id",
        "report.p_age":"doc.fields.p_age",
        "report.d_fever":"doc.fields.d_fever",
        "report.d_fever_past_present": {
          "expr": "doc.fields.d_fever_past",
          "optional": false
        },
        "report.patient_uuid": {
          "expr" : "doc.fields.patient_uuid",
          "optional": false
        },
        "report.reported_date": {
          "expr" : "new Date(doc.reported_date).toISOString();",
          "optional" : false
        },
        "report.var1": {
          "expr": "doc.fields.var1",
          "optional": false
        },
        "report.var2": {
          "expr": "doc.fields.var2",
          "optional": false
        },
        "report.var3": {
          "expr": "doc.fields.var3",
          "optional": false
        },
        "report.var4": {
          "expr" : "doc.fields.var4",
          "optional": false
        },
        "report.var5": {
          "expr" : "doc.fields.var5",
          "optional" : false
        }
      }
    },
    "secondconf": {
       "relevant_to": "doc.type === 'data_record' && ((doc.form === 'algo1' && doc.fields.ask_something === 'No') || (doc.form === 'algo1_task' && doc.fields.inputs.ask_something === 'Yes'))",
      "destination": {
        "base_url": "https://url2.demo.org",
        "path": "/channel/ch2",
        "auth": {
          "type": "basic",
          "username": "test",
          "password_key": "test_key"
        }
      },
      "mapping":{
        "report._id":"doc._id",
        "report.p_age":"doc.fields.p_age",
        "report.d_fever":"doc.fields.d_fever",
        "report.d_fever_past_present": {
          "expr": "doc.fields.d_fever_past",
          "optional": false
        },
        "report.patient_uuid": {
          "expr" : "doc.fields.patient_uuid",
          "optional": false
        },
        "report.reported_date": {
          "expr" : "new Date(doc.reported_date).toISOString();",
          "optional" : false
        },
        "report.var1": {
          "expr": "doc.fields.var1",
          "optional": false
        },
        "report.var2": {
          "expr": "doc.fields.var2",
          "optional": false
        },
        "report.var3": {
          "expr": "doc.fields.var3",
          "optional": false
        },
        "report.var4": {
          "expr" : "doc.fields.var4",
          "optional": false
        },
        "report.var5": {
          "expr" : "doc.fields.var5",
          "optional" : false
        }
      }
    }
 }

It looks something like this, there are more variables but I presume they are not really important here since they don’t define when it’s triggered. This is when having two, adding another one with the same relevant_to after the second one will again be executed twice with the first one still being triggered only once

1 Like

Hey @magp18

This is so great! You found a bug! Thank you for the excellent reproduction steps, this helped a lot in finding the root cause.
I’ve created an issue to fix this: Duplicate outbound requests are sent when a document matches multiple config options · Issue #8160 · medic/cht-core · GitHub
Please feel free to add any additional details that I might have missed.

1 Like

Hello @AshleyWWW,
I would like to bring you in on this issue so that you can guide me on how we can navigate around this issue on OpenHIM. Please feel free to post your solution, I will be on standby.
Thanks,
Job