Skip to content
LambogeniusDocs

HL7 v2 Codec for Azure Logic Apps

Quick start

Install the package, add the connection and a schema, and build a workflow that decodes and acknowledges.

Service provider/serviceProviders/lamboHl7CodecLicensed together with the HL7 MLLP Connector. One token covers both.

Decode a message and return its ACK

  1. 1
    Reference the package

    in a NuGet-based Logic Apps Standard project. Download Lambogenius.Hl7Codec.LogicApps.<version>.nupkg from Downloads (sign in first), save it in a folder such as packages/, and make that folder a package source in nuget.config.

    <ItemGroup>
      <PackageReference Include="Lambogenius.Hl7Codec.LogicApps" Version="<version>" />
    </ItemGroup>

    The host.json the runtime reads must not have an extensionBundle section, or the runtime ignores the project's packages. Remove it from the build and publish copies.

  2. 2
    Add the connection.

    The runtime needs a connection for every built-in action. Its parameters are optional, but it needs at least one value:

    {
      "serviceProviderConnections": {
        "lamboHl7Codec": {
          "displayName": "HL7 v2 (Lambogenius)",
          "serviceProvider": { "id": "/serviceProviders/lamboHl7Codec" },
          "parameterValues": { "schemaFolder": "" }
        }
      }
    }
  3. 3
    Add schemas

    for your message types to Artifacts/Schemas, for example ADT_A01 generated with the HL7 v2 Schema Generator.

  4. 4
    Create the workflow.

    It decodes the posted message, reads MSH-10 with XPath when decoding succeeded, and always returns the ACK (AA, AE or AR):

    {
      "definition": {
        "triggers": {
          "When_an_HL7_message_is_received": { "type": "Request", "kind": "Http", "inputs": {} }
        },
        "actions": {
          "Decode_HL7": {
            "type": "ServiceProvider",
            "inputs": {
              "parameters": { "message": "@{triggerBody()}" },
              "serviceProviderConfiguration": {
                "connectionName": "lamboHl7Codec",
                "operationId": "decode",
                "serviceProviderId": "/serviceProviders/lamboHl7Codec"
              }
            },
            "runAfter": {}
          },
          "If_decoded": {
            "type": "If",
            "expression": { "and": [ { "equals": [ "@body('Decode_HL7')?['success']", true ] } ] },
            "actions": {
              "Message_control_id": {
                "type": "Compose",
                "inputs": "@xpath(xml(body('Decode_HL7')?['xml']), 'string(/*/MSH/*[starts-with(local-name(), ''MSH_10'')])')"
              }
            },
            "else": { "actions": { "Decode_errors": { "type": "Compose", "inputs": "@body('Decode_HL7')?['errors']" } } },
            "runAfter": { "Decode_HL7": [ "Succeeded" ] }
          },
          "Return_ACK": {
            "type": "Response",
            "kind": "Http",
            "inputs": { "statusCode": 200, "body": "@body('Decode_HL7')?['ack']" },
            "runAfter": { "If_decoded": [ "Succeeded" ] }
          }
        }
      },
      "kind": "Stateful"
    }
  5. 5
    Run it.

    Run func start locally, then POST an HL7 message as text/plain to the trigger URL. The response is the ACK.