Decode a message and return its ACK
- 1Reference the package
in a NuGet-based Logic Apps Standard project. Download
Lambogenius.Hl7Codec.LogicApps.<version>.nupkgfrom Downloads (sign in first), save it in a folder such aspackages/, and make that folder a package source innuget.config.<ItemGroup> <PackageReference Include="Lambogenius.Hl7Codec.LogicApps" Version="<version>" /> </ItemGroup>The
host.jsonthe runtime reads must not have anextensionBundlesection, or the runtime ignores the project's packages. Remove it from the build and publish copies. - 2Add 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": "" } } } } - 3Add schemas
for your message types to
Artifacts/Schemas, for exampleADT_A01generated with the HL7 v2 Schema Generator. - 4Create 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" } - 5Run it.
Run
func startlocally, then POST an HL7 message astext/plainto the trigger URL. The response is the ACK.