Get in touch: info@samuelfair.com

The If and Switch logic policy – Digital Transformation with IBM API Connect-2

7. Drag an invoke policy from the left pane and drop it on the line below Otherwise:

    Figure 6.28 – Dragging an invoke policy and dropping on the line

    8. Now, you will update the properties for the invoke policy to specify the URL and patient ID to act as our default test user. In the Properties pane, enter this in the URL field: http://hapi.fhir.org/baseR4/Patient?_id=1263576.

    Figure 6.29 – Adding values to the URL

    9. Lastly, we want to ensure that we don’t run the same invoke policy for both cases, so we will drag the first invoke policy to our case, checking for the header. Drag and drop the invoke policy to the left and drop on the switch case for our header check:

    Figure 6.30 – Drag the invoke policy to the first switch case

    10. Your final assembly is complete. Click on the Save button.

    Figure 6.31 – Final switch completed

    You have updated your API to apply some logic that will run debugging only if the debug header is set to true. You are ready to run a test. You will accomplish that by using the Test tab, as shown here:

    Figure 6.32 – Navigating to the Test tab

    Perform the following steps here:

    1. Click on the Test tab and use the dropdown to select Get patient operation. Change the Value of the APIm-Debug parameter to false:

    Figure 6.33 – Running a test using the Test tab

    2. Click on the Send button and review the response. You should see information about the single patient you set within the Otherwise case:

    Figure 6.34 – Response returned from the test

    Now you have successfully applied If logic to an API. While that was a simple example to introduce you to logic switches, you will probably be more interested in seeing how to apply a switch that routes to the proper operations you have created for your API. You will do that next.

    Leave a Reply

    Your email address will not be published. Required fields are marked *